iommu/amd: Use device max PRI outstanding requests
Subsystems (2)
PATCH 1/1 iommu/amd: Use device max PRI outstanding requests
From: xiongweimin <[email protected]>
pci_enable_pri() already clamps the requested outstanding count to the device PCI_PRI_MAX_REQ value. Passing a hardcoded 32 under-utilizes capable devices and can oversubscribe weaker ones.
Pass ~0U so the allocated request count matches what the device advertises.
--- drivers/iommu/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/amd/iommu.c +3 -3
@@ -602,10 +602,10 @@ static inline int pdev_enable_cap_pri(struct pci_dev *pdev)if (dev_data->flags &AMD_IOMMU_DEVICE_FLAG_PRI_SUP ) {/* -* First reset the PRI state of the device. -* FIXME: Hardcode number of outstanding requests for now +* Reset PRI then enable with the device-advertised maximum. +* pci_enable_pri() clamps @reqs to PCI_PRI_MAX_REQ. */ -if (!pci_reset_pri (pdev) && !pci_enable_pri (pdev,32 )) { +if (!pci_reset_pri (pdev) && !pci_enable_pri (pdev, ~0U )) { dev_data->pri_enabled =1 ; dev_data->pri_tlp =pci_prg_resp_pasid_required (pdev);
Signature · 5 lines
2.43.0 No virus found Checked by Hillstone Network AntiVirus
Quoted 19 lines · weimin xiong
From: xiongweimin <[email protected]>
pci_enable_pri()already clamps the requested outstanding count to the devicePCI_PRI_MAX_REQvalue. Passing a hardcoded 32 under-utilizes capable devices and can oversubscribe weaker ones.Pass ~0U so the allocated request count matches what the device advertises.
Signed-off-by xiongweimin <[email protected]>--- drivers/iommu/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iommu/amd/iommu.c +0
-0
drivers/iommu/amd/iommu.c static inline int pdev_enable_cap_pri(struct pci_dev *pdev) · line 607
Quoted 8 lines
drivers/iommu/amd/iommu.c +2
-2@@ -602,10 +602,10 @@ static inline int pdev_enable_cap_pri(struct pci_dev *pdev)if (dev_data->flags &AMD_IOMMU_DEVICE_FLAG_PRI_SUP ) {/* -* First reset the PRI state of the device. -* FIXME: Hardcode number of outstanding requests for now +* Reset PRI then enable with the device-advertised maximum. +* pci_enable_pri() clamps @reqs to PCI_PRI_MAX_REQ. */
Hi,
I don't think this is a good idea.
The outstanding-request allocation is a per-device cap, but the PPR log is a single buffer shared by all devices behind the IOMMU (512 entries by default). ~0U grants every device its full advertised capacity (potentially hundreds or thousands), so a few PRI-capable devices can collectively far exceed the log depth and rely entirely on the optional overflow handling to stay correct.
-Ankit
Quoted 12 lines
drivers/iommu/amd/iommu.c +1
-1-if (!pci_reset_pri (pdev) && !pci_enable_pri (pdev,32 )) { +if (!pci_reset_pri (pdev) && !pci_enable_pri (pdev, ~0U )) { dev_data->pri_enabled =1 ; dev_data->pri_tlp =pci_prg_resp_pasid_required (pdev);Signature · 5 lines
2.43.0 No virus found Checked by Hillstone Network AntiVirus
Hi Ankit,
Thanks for the explanation.
I overlooked that the PPR log is a shared IOMMU-wide resource with limited depth, while ~0U would enable each device up to its full advertised PRI capacity. That can clearly oversubscribe the log.
I will drop this change as proposed and will not send a v2 that simply switches 32 to ~0U.
If there is a preferred policy later (e.g. a bounded derivation from PPR log depth / number of PRI devices), I am happy to follow that guidance.
Thanks,
Weimin
Quoted 53 lines · Ankit Soni
Quoted 19 lines · weimin xiong
From: xiongweimin <[email protected]>
pci_enable_pri()already clamps the requested outstanding count to the devicePCI_PRI_MAX_REQvalue. Passing a hardcoded 32 under-utilizes capable devices and can oversubscribe weaker ones.Pass ~0U so the allocated request count matches what the device advertises.
Signed-off-by xiongweimin <[email protected]>--- drivers/iommu/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iommu/amd/iommu.c +0
-0drivers/iommu/amd/iommu.c static inline int pdev_enable_cap_pri(struct pci_dev *pdev) · line 607
Quoted 8 lines
drivers/iommu/amd/iommu.c +2
-2@@ -602,10 +602,10 @@ static inline int pdev_enable_cap_pri(struct pci_dev *pdev)if (dev_data->flags &AMD_IOMMU_DEVICE_FLAG_PRI_SUP ) {/* -* First reset the PRI state of the device. -* FIXME: Hardcode number of outstanding requests for now +* Reset PRI then enable with the device-advertised maximum. +* pci_enable_pri() clamps @reqs to PCI_PRI_MAX_REQ. */ Hi,
I don't think this is a good idea.
The outstanding-request allocation is a per-device cap, but the PPR log is a single buffer shared by all devices behind the IOMMU (512 entries by default). ~0U grants every device its full advertised capacity (potentially hundreds or thousands), so a few PRI-capable devices can collectively far exceed the log depth and rely entirely on the optional overflow handling to stay correct.
-Ankit
Quoted 12 lines
drivers/iommu/amd/iommu.c +1
-1-if (!pci_reset_pri (pdev) && !pci_enable_pri (pdev,32 )) { +if (!pci_reset_pri (pdev) && !pci_enable_pri (pdev, ~0U )) { dev_data->pri_enabled =1 ; dev_data->pri_tlp =pci_prg_resp_pasid_required (pdev);Signature · 5 lines
2.43.0 No virus found Checked by Hillstone Network AntiVirus