From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
cascardo@linux.vnet.ibm.com,
Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [PATCH v3 2/2] PCI: Apply warm reset to specific devices
Date: Mon, 23 Mar 2015 14:02:51 +1100 [thread overview]
Message-ID: <1427079771-18472-2-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1427079771-18472-1-git-send-email-gwshan@linux.vnet.ibm.com>
Currently, VFIO infrastructure depends on pci_reset_function()
to ensure the PCI device in clean state when passing to guest,
or being returned back to host. However, the function doesn't
work (or well) on some PCI devices on PowerPC platforms, which
potentially brings pending traffic over the boundary between
host/guest and usually causes memory corruption.
The patch applies warm reset to those PCI devices, which is
implemented based on pci_set_pcie_reset_state() to get clean
state when passing device from host to guest, or returning it
back to host. The reset request is routed to platform specific
pcibios_set_pcie_reset_state() and processed there.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
drivers/pci/quirks.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 85f247e..9846d5e 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3504,6 +3504,22 @@ static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe)
return 0;
}
+static int pci_dev_warm_reset(struct pci_dev *pdev, int probe)
+{
+ int ret;
+
+ /* Check the device can take the reset or not */
+ if (probe)
+ return pci_set_pcie_reset_state(pdev, pcie_warm_reset, probe);
+
+ /* Issue warm reset */
+ ret = pci_set_pcie_reset_state(pdev, pcie_warm_reset, 0);
+ if (!ret)
+ ret = pci_set_pcie_reset_state(pdev, pcie_deassert_reset, 0);
+
+ return ret;
+}
+
#define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed
#define PCI_DEVICE_ID_INTEL_IVB_M_VGA 0x0156
#define PCI_DEVICE_ID_INTEL_IVB_M2_VGA 0x0166
@@ -3519,6 +3535,18 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
reset_intel_generic_dev },
{ PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
reset_chelsio_generic_dev },
+ { PCI_VENDOR_ID_IBM, PCI_ANY_ID,
+ pci_dev_warm_reset },
+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_57800,
+ pci_dev_warm_reset },
+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_57840,
+ pci_dev_warm_reset },
+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_57810,
+ pci_dev_warm_reset },
+ { PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
+ pci_dev_warm_reset },
+ { PCI_VENDOR_ID_TI, PCI_ANY_ID,
+ pci_dev_warm_reset },
{ 0 }
};
--
1.8.3.2
next prev parent reply other threads:[~2015-03-23 3:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 3:02 [PATCH v3 1/2] PCI: One more parameter to pci_set_pcie_reset_state() Gavin Shan
2015-03-23 3:02 ` Gavin Shan [this message]
2015-03-23 3:34 ` Alex Williamson
2015-03-23 3:56 ` Gavin Shan
2015-03-23 4:06 ` Alex Williamson
2015-03-23 4:40 ` Gavin Shan
2015-03-23 12:40 ` Alex Williamson
2015-03-23 20:07 ` cascardo
2015-03-23 21:08 ` Alex Williamson
2015-03-24 0:23 ` Benjamin Herrenschmidt
2015-03-24 0:19 ` Benjamin Herrenschmidt
2015-03-23 22:54 ` Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427079771-18472-2-git-send-email-gwshan@linux.vnet.ibm.com \
--to=gwshan@linux.vnet.ibm.com \
--cc=bhelgaas@google.com \
--cc=cascardo@linux.vnet.ibm.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).