Hi Bjorn,
This patch series consists of the P2PDMA cleanup and prep patches based
on feedback from my P2PDMA mapping operations series (most recently
posted at [1]). I've reduced the recipient list of this series to those
that I thought would be interested or have provided the feedback that
inspired these patches.
Please consider taking these patches in the near term ahead of my mapping
ops series. These patches are largely cleanup and other minor fixes. The only
functional change is Patch 4 which adds a new warning that was suggested by
Don.
Patch 6 arguably isn't necessary yet as we don't care about sleeping
yet -- but it'd be a nice to have to reduce the number of prep patches for my
other series. However, if you don't want to take this patch now, I can
carry it in my other series.
I'm happy to make further fixes and update this series if anyone finds any
additional issues on review.
Thanks,
Logan
[1] https://lore.kernel.org/linux-block/[email protected]/
--
Logan Gunthorpe (6):
PCI/P2PDMA: Rename upstream_bridge_distance() and rework documentation
PCI/P2PDMA: Use a buffer on the stack for collecting the acs list
PCI/P2PDMA: Cleanup type for return value of calc_map_type_and_dist()
PCI/P2PDMA: Print a warning if the host bridge is not in the whitelist
PCI/P2PDMA: Refactor pci_p2pdma_map_type() to take pagemap and device
PCI/P2PDMA: Avoid pci_get_slot() which sleeps
drivers/pci/p2pdma.c | 157 +++++++++++++++++++++++++------------------
1 file changed, 92 insertions(+), 65 deletions(-)
base-commit: 614124bea77e452aa6df7a8714e8bc820b489922
--
2.20.1
If the host bridge is not in the whitelist print a warning in the
calc_map_type_and_dist_warn() path detailing the vendor and device IDs
that would need to be added to the whitelist.
Suggested-by: Don Dutile <[email protected]>
Signed-off-by: Logan Gunthorpe <[email protected]>
---
drivers/pci/p2pdma.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index 09c864f193d2..2de4a9e2da58 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -309,7 +309,7 @@ static const struct pci_p2pdma_whitelist_entry {
};
static bool __host_bridge_whitelist(struct pci_host_bridge *host,
- bool same_host_bridge)
+ bool same_host_bridge, bool warn)
{
struct pci_dev *root = pci_get_slot(host->bus, PCI_DEVFN(0, 0));
const struct pci_p2pdma_whitelist_entry *entry;
@@ -331,6 +331,10 @@ static bool __host_bridge_whitelist(struct pci_host_bridge *host,
return true;
}
+ if (warn)
+ pci_warn(root, "Host bridge not in P2PDMA whitelist: %04x:%04x\n",
+ vendor, device);
+
return false;
}
@@ -338,16 +342,17 @@ static bool __host_bridge_whitelist(struct pci_host_bridge *host,
* If we can't find a common upstream bridge take a look at the root
* complex and compare it to a whitelist of known good hardware.
*/
-static bool host_bridge_whitelist(struct pci_dev *a, struct pci_dev *b)
+static bool host_bridge_whitelist(struct pci_dev *a, struct pci_dev *b,
+ bool warn)
{
struct pci_host_bridge *host_a = pci_find_host_bridge(a->bus);
struct pci_host_bridge *host_b = pci_find_host_bridge(b->bus);
if (host_a == host_b)
- return __host_bridge_whitelist(host_a, true);
+ return __host_bridge_whitelist(host_a, true, warn);
- if (__host_bridge_whitelist(host_a, false) &&
- __host_bridge_whitelist(host_b, false))
+ if (__host_bridge_whitelist(host_a, false, warn) &&
+ __host_bridge_whitelist(host_b, false, warn))
return true;
return false;
@@ -483,7 +488,7 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client,
if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) {
if (!cpu_supports_p2pdma() &&
- !host_bridge_whitelist(provider, client))
+ !host_bridge_whitelist(provider, client, acs_redirects))
map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED;
}
--
2.20.1
On Thu, Jun 10, 2021 at 10:06:03AM -0600, Logan Gunthorpe wrote:
> Hi Bjorn,
>
> This patch series consists of the P2PDMA cleanup and prep patches based
> on feedback from my P2PDMA mapping operations series (most recently
> posted at [1]). I've reduced the recipient list of this series to those
> that I thought would be interested or have provided the feedback that
> inspired these patches.
>
> Please consider taking these patches in the near term ahead of my mapping
> ops series. These patches are largely cleanup and other minor fixes. The only
> functional change is Patch 4 which adds a new warning that was suggested by
> Don.
>
> Patch 6 arguably isn't necessary yet as we don't care about sleeping
> yet -- but it'd be a nice to have to reduce the number of prep patches for my
> other series. However, if you don't want to take this patch now, I can
> carry it in my other series.
>
> I'm happy to make further fixes and update this series if anyone finds any
> additional issues on review.
>
> Thanks,
>
> Logan
>
> [1] https://lore.kernel.org/linux-block/[email protected]/
>
> --
>
> Logan Gunthorpe (6):
> PCI/P2PDMA: Rename upstream_bridge_distance() and rework documentation
> PCI/P2PDMA: Use a buffer on the stack for collecting the acs list
> PCI/P2PDMA: Cleanup type for return value of calc_map_type_and_dist()
> PCI/P2PDMA: Print a warning if the host bridge is not in the whitelist
> PCI/P2PDMA: Refactor pci_p2pdma_map_type() to take pagemap and device
> PCI/P2PDMA: Avoid pci_get_slot() which sleeps
>
> drivers/pci/p2pdma.c | 157 +++++++++++++++++++++++++------------------
> 1 file changed, 92 insertions(+), 65 deletions(-)
Applied all 6 to pci/p2pdma for v5.14, thanks!
6389d4374522 ("PCI/P2PDMA: Rename upstream_bridge_distance() and rework doc")
e4ece59abd70 ("PCI/P2PDMA: Collect acs list in stack buffer to avoid sleeping")
f9c125b9eb30 ("PCI/P2PDMA: Use correct calc_map_type_and_dist() return type")
cf201bfe8cdc ("PCI/P2PDMA: Warn if host bridge not in whitelist")
7e2faa1710c4 ("PCI/P2PDMA: Refactor pci_p2pdma_map_type()")
3ec0c3ec2d92 ("PCI/P2PDMA: Avoid pci_get_slot(), which may sleep")