* [PATCH 0/3] Add ACS quirk for Zhaoxin
@ 2020-03-27 9:11 Raymond Pang
2020-03-27 9:11 ` [PATCH 1/3] PCI: Add Zhaoxin Vendor ID Raymond Pang
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Raymond Pang @ 2020-03-27 9:11 UTC (permalink / raw)
To: bhelgaas, linux-pci; +Cc: TonyWWang-oc, linux-kernel
Lots of Zhaoxin PCIe components have no ACS Capability Structure,
but do have ACS-like capability which ensures DMA isolation.
This patch makes isolated devices could be directly assigned to
different VMs through IOMMU.
Raymond Pang (3):
PCI: Add Zhaoxin Vendor ID
PCI: Add ACS quirk for Zhaoxin's multi-function devices
PCI: Add ACS quirk for Root/Downstream Ports
drivers/pci/quirks.c | 30 ++++++++++++++++++++++++++++++
include/linux/pci_ids.h | 2 ++
2 files changed, 32 insertions(+)
--
2.26.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] PCI: Add Zhaoxin Vendor ID
2020-03-27 9:11 [PATCH 0/3] Add ACS quirk for Zhaoxin Raymond Pang
@ 2020-03-27 9:11 ` Raymond Pang
2020-03-27 9:11 ` [PATCH 2/3] PCI: Add ACS quirk for Zhaoxin's multi-function devices Raymond Pang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Raymond Pang @ 2020-03-27 9:11 UTC (permalink / raw)
To: bhelgaas, linux-pci; +Cc: TonyWWang-oc, linux-kernel
Add Zhaoxin Vendor ID to pci_ids.h
Signed-off-by: Raymond Pang <RaymondPang-oc@zhaoxin.com>
---
include/linux/pci_ids.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 352c0d708720..6693cf561cd1 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2583,6 +2583,8 @@
#define PCI_VENDOR_ID_AMAZON 0x1d0f
+#define PCI_VENDOR_ID_ZHAOXIN 0x1d17
+
#define PCI_VENDOR_ID_HYGON 0x1d94
#define PCI_VENDOR_ID_HXT 0x1dbf
--
2.26.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] PCI: Add ACS quirk for Zhaoxin's multi-function devices
2020-03-27 9:11 [PATCH 0/3] Add ACS quirk for Zhaoxin Raymond Pang
2020-03-27 9:11 ` [PATCH 1/3] PCI: Add Zhaoxin Vendor ID Raymond Pang
@ 2020-03-27 9:11 ` Raymond Pang
2020-03-27 9:11 ` [PATCH 3/3] PCI: Add ACS quirk for Root/Downstream Ports Raymond Pang
2020-03-28 21:59 ` [PATCH 0/3] Add ACS quirk for Zhaoxin Bjorn Helgaas
3 siblings, 0 replies; 5+ messages in thread
From: Raymond Pang @ 2020-03-27 9:11 UTC (permalink / raw)
To: bhelgaas, linux-pci; +Cc: TonyWWang-oc, linux-kernel
Some Zhaoxin's endpoints are implemented as multi-function devices
without ACS capability. They actually don't support peer-to-peer
transactions. So add ACS quirk to declare DMA isolation.
Signed-off-by: Raymond Pang <RaymondPang-oc@zhaoxin.com>
---
drivers/pci/quirks.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3e0ca273f903..3f06496a3d4c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4767,6 +4767,10 @@ static const struct pci_dev_acs_enabled {
{ PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs },
/* Amazon Annapurna Labs */
{ PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs },
+ /* Zhaoxin multi-function devices */
+ { PCI_VENDOR_ID_ZHAOXIN, 0x3038, pci_quirk_mf_endpoint_acs },
+ { PCI_VENDOR_ID_ZHAOXIN, 0x3104, pci_quirk_mf_endpoint_acs },
+ { PCI_VENDOR_ID_ZHAOXIN, 0x9083, pci_quirk_mf_endpoint_acs },
{ 0 }
};
--
2.26.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] PCI: Add ACS quirk for Root/Downstream Ports
2020-03-27 9:11 [PATCH 0/3] Add ACS quirk for Zhaoxin Raymond Pang
2020-03-27 9:11 ` [PATCH 1/3] PCI: Add Zhaoxin Vendor ID Raymond Pang
2020-03-27 9:11 ` [PATCH 2/3] PCI: Add ACS quirk for Zhaoxin's multi-function devices Raymond Pang
@ 2020-03-27 9:11 ` Raymond Pang
2020-03-28 21:59 ` [PATCH 0/3] Add ACS quirk for Zhaoxin Bjorn Helgaas
3 siblings, 0 replies; 5+ messages in thread
From: Raymond Pang @ 2020-03-27 9:11 UTC (permalink / raw)
To: bhelgaas, linux-pci; +Cc: TonyWWang-oc, linux-kernel
Many Zhaoxin Root Ports and Switch Downstream Ports do provide ACS-like
capability but have no ACS Capability Structure. Peer-to-Peer
transactions could be blocked between these ports, so add quirk
to make devices behind them could be assigned to different IOMMU group.
Signed-off-by: Raymond Pang <RaymondPang-oc@zhaoxin.com>
---
drivers/pci/quirks.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3f06496a3d4c..49cf6e943f16 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4464,6 +4464,30 @@ static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags)
return pci_acs_ctrl_enabled(acs_flags,
PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
}
+
+/*
+ * Many Zhaoxin Root Ports and Switch Downstream Ports have no ACS capability.
+ * But the implementation could block peer-to-peer transactions between them
+ * and provide ACS-like functionality.
+ */
+static int pci_quirk_zhaoxin_pcie_ports_acs(struct pci_dev *dev, u16 acs_flags)
+{
+
+ if (!pci_is_pcie(dev) ||
+ ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
+ (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))
+ return -ENOTTY;
+
+ switch (dev->device) {
+ case 0x0710 ... 0x071e:
+ case 0x0721:
+ case 0x0723 ... 0x0732:
+ return pci_acs_ctrl_enabled(acs_flags,
+ PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
+ }
+
+ return false;
+}
/*
* Many Intel PCH Root Ports do provide ACS-like features to disable peer
@@ -4771,6 +4795,8 @@ static const struct pci_dev_acs_enabled {
{ PCI_VENDOR_ID_ZHAOXIN, 0x3038, pci_quirk_mf_endpoint_acs },
{ PCI_VENDOR_ID_ZHAOXIN, 0x3104, pci_quirk_mf_endpoint_acs },
{ PCI_VENDOR_ID_ZHAOXIN, 0x9083, pci_quirk_mf_endpoint_acs },
+ /* Zhaoxin Root/Downstream Ports */
+ { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs },
{ 0 }
};
--
2.26.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] Add ACS quirk for Zhaoxin
2020-03-27 9:11 [PATCH 0/3] Add ACS quirk for Zhaoxin Raymond Pang
` (2 preceding siblings ...)
2020-03-27 9:11 ` [PATCH 3/3] PCI: Add ACS quirk for Root/Downstream Ports Raymond Pang
@ 2020-03-28 21:59 ` Bjorn Helgaas
3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2020-03-28 21:59 UTC (permalink / raw)
To: Raymond Pang; +Cc: linux-pci, TonyWWang-oc, linux-kernel, Alex Williamson
[+cc Alex]
On Fri, Mar 27, 2020 at 05:11:45PM +0800, Raymond Pang wrote:
> Lots of Zhaoxin PCIe components have no ACS Capability Structure,
> but do have ACS-like capability which ensures DMA isolation.
> This patch makes isolated devices could be directly assigned to
> different VMs through IOMMU.
>
> Raymond Pang (3):
> PCI: Add Zhaoxin Vendor ID
> PCI: Add ACS quirk for Zhaoxin's multi-function devices
> PCI: Add ACS quirk for Root/Downstream Ports
>
> drivers/pci/quirks.c | 30 ++++++++++++++++++++++++++++++
> include/linux/pci_ids.h | 2 ++
> 2 files changed, 32 insertions(+)
Applied to pci/virtualization for v5.7, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-28 21:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 9:11 [PATCH 0/3] Add ACS quirk for Zhaoxin Raymond Pang
2020-03-27 9:11 ` [PATCH 1/3] PCI: Add Zhaoxin Vendor ID Raymond Pang
2020-03-27 9:11 ` [PATCH 2/3] PCI: Add ACS quirk for Zhaoxin's multi-function devices Raymond Pang
2020-03-27 9:11 ` [PATCH 3/3] PCI: Add ACS quirk for Root/Downstream Ports Raymond Pang
2020-03-28 21:59 ` [PATCH 0/3] Add ACS quirk for Zhaoxin Bjorn Helgaas
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).