Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f85876ba authored by Yu Zhao's avatar Yu Zhao Committed by Jesse Barnes
Browse files

PCI: support PM D0hot->D3 transition reset



PCI PM 1.2 specifies that the device will perform an internal reset upon
transitioning from D3hot to D0 when the NO_SOFT_RESET bit is clear. This
method can be used to reset a function if neither PCIe FLR nor PCI AF FLR
are supported.

Reviewed-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarYu Zhao <yu.zhao@intel.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 8c1c699f
Loading
Loading
Loading
Loading
+34 −0
Original line number Original line Diff line number Diff line
@@ -2132,6 +2132,36 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
	return 0;
	return 0;
}
}


static int pci_pm_reset(struct pci_dev *dev, int probe)
{
	u16 csr;

	if (!dev->pm_cap)
		return -ENOTTY;

	pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &csr);
	if (csr & PCI_PM_CTRL_NO_SOFT_RESET)
		return -ENOTTY;

	if (probe)
		return 0;

	if (dev->current_state != PCI_D0)
		return -EINVAL;

	csr &= ~PCI_PM_CTRL_STATE_MASK;
	csr |= PCI_D3hot;
	pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr);
	msleep(pci_pm_d3_delay);

	csr &= ~PCI_PM_CTRL_STATE_MASK;
	csr |= PCI_D0;
	pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr);
	msleep(pci_pm_d3_delay);

	return 0;
}

static int pci_dev_reset(struct pci_dev *dev, int probe)
static int pci_dev_reset(struct pci_dev *dev, int probe)
{
{
	int rc;
	int rc;
@@ -2149,6 +2179,10 @@ static int pci_dev_reset(struct pci_dev *dev, int probe)
		goto done;
		goto done;


	rc = pci_af_flr(dev, probe);
	rc = pci_af_flr(dev, probe);
	if (rc != -ENOTTY)
		goto done;

	rc = pci_pm_reset(dev, probe);
done:
done:
	if (!probe) {
	if (!probe) {
		up(&dev->dev.sem);
		up(&dev->dev.sem);