linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family
@ 2020-07-29 23:18 Logan Gunthorpe
  2020-07-30  4:31 ` Alex Deucher
  2020-07-30 15:27 ` Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Logan Gunthorpe @ 2020-07-29 23:18 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: Logan Gunthorpe, Bjorn Helgaas, Alex Deucher,
	Christian König, Huang Rui

In order to avoid needing to add every new AMD CPU host bridge to the list
every cycle, allow P2PDMA if the CPUs vendor is AMD and family is
greater than 0x17 (Zen).

This should cut down a bunch of the churn adding to the list of allowed
host bridges.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Huang Rui <ray.huang@amd.com>

---

Here's a reworked patch to enable P2PDMA on Zen2 (and in fact all
subsequent Zen platforms).

This should remove all the churn on the list for the AMD side. Still
don't have a good solution for Intel.

 drivers/pci/p2pdma.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index e8e444eeb1cd..f1cab2c50595 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -273,6 +273,24 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev)
 	seq_buf_printf(buf, "%s;", pci_name(pdev));
 }

+#ifdef CONFIG_X86
+static bool cpu_supports_p2pdma(void)
+{
+	struct cpuinfo_x86 *c = &cpu_data(0);
+
+	/* Any AMD CPU who's family id is newer than Zen will support p2pdma */
+	if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17)
+		return true;
+
+	return false;
+}
+#else
+static bool cpu_supports_p2pdma(void)
+{
+	return false;
+}
+#endif
+
 static const struct pci_p2pdma_whitelist_entry {
 	unsigned short vendor;
 	unsigned short device;
@@ -280,11 +298,6 @@ static const struct pci_p2pdma_whitelist_entry {
 		REQ_SAME_HOST_BRIDGE	= 1 << 0,
 	} flags;
 } pci_p2pdma_whitelist[] = {
-	/* AMD ZEN */
-	{PCI_VENDOR_ID_AMD,	0x1450,	0},
-	{PCI_VENDOR_ID_AMD,	0x15d0,	0},
-	{PCI_VENDOR_ID_AMD,	0x1630,	0},
-
 	/* Intel Xeon E5/Core i7 */
 	{PCI_VENDOR_ID_INTEL,	0x3c00, REQ_SAME_HOST_BRIDGE},
 	{PCI_VENDOR_ID_INTEL,	0x3c01, REQ_SAME_HOST_BRIDGE},
@@ -473,7 +486,8 @@ upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client,
 					      acs_redirects, acs_list);

 	if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) {
-		if (!host_bridge_whitelist(provider, client))
+		if (!cpu_supports_p2pdma() &&
+		    !host_bridge_whitelist(provider, client))
 			map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED;
 	}


base-commit: 92ed301919932f777713b9172e525674157e983d
--
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family
  2020-07-29 23:18 [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family Logan Gunthorpe
@ 2020-07-30  4:31 ` Alex Deucher
  2020-07-30 15:27 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2020-07-30  4:31 UTC (permalink / raw)
  To: Logan Gunthorpe
  Cc: LKML, Linux PCI, Bjorn Helgaas, Christian König, Huang Rui

On Wed, Jul 29, 2020 at 7:18 PM Logan Gunthorpe <logang@deltatee.com> wrote:
>
> In order to avoid needing to add every new AMD CPU host bridge to the list
> every cycle, allow P2PDMA if the CPUs vendor is AMD and family is
> greater than 0x17 (Zen).

Might want to say "greater than or equal to" to clarify that all Zen
parts (Zen1, Zen2, etc.) support p2p.  With that clarified,
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

>
> This should cut down a bunch of the churn adding to the list of allowed
> host bridges.
>
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Alex Deucher <alexdeucher@gmail.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Huang Rui <ray.huang@amd.com>
>
> ---
>
> Here's a reworked patch to enable P2PDMA on Zen2 (and in fact all
> subsequent Zen platforms).
>
> This should remove all the churn on the list for the AMD side. Still
> don't have a good solution for Intel.
>
>  drivers/pci/p2pdma.c | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index e8e444eeb1cd..f1cab2c50595 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -273,6 +273,24 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev)
>         seq_buf_printf(buf, "%s;", pci_name(pdev));
>  }
>
> +#ifdef CONFIG_X86
> +static bool cpu_supports_p2pdma(void)
> +{
> +       struct cpuinfo_x86 *c = &cpu_data(0);
> +
> +       /* Any AMD CPU who's family id is newer than Zen will support p2pdma */
> +       if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17)
> +               return true;
> +
> +       return false;
> +}
> +#else
> +static bool cpu_supports_p2pdma(void)
> +{
> +       return false;
> +}
> +#endif
> +
>  static const struct pci_p2pdma_whitelist_entry {
>         unsigned short vendor;
>         unsigned short device;
> @@ -280,11 +298,6 @@ static const struct pci_p2pdma_whitelist_entry {
>                 REQ_SAME_HOST_BRIDGE    = 1 << 0,
>         } flags;
>  } pci_p2pdma_whitelist[] = {
> -       /* AMD ZEN */
> -       {PCI_VENDOR_ID_AMD,     0x1450, 0},
> -       {PCI_VENDOR_ID_AMD,     0x15d0, 0},
> -       {PCI_VENDOR_ID_AMD,     0x1630, 0},
> -
>         /* Intel Xeon E5/Core i7 */
>         {PCI_VENDOR_ID_INTEL,   0x3c00, REQ_SAME_HOST_BRIDGE},
>         {PCI_VENDOR_ID_INTEL,   0x3c01, REQ_SAME_HOST_BRIDGE},
> @@ -473,7 +486,8 @@ upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client,
>                                               acs_redirects, acs_list);
>
>         if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) {
> -               if (!host_bridge_whitelist(provider, client))
> +               if (!cpu_supports_p2pdma() &&
> +                   !host_bridge_whitelist(provider, client))
>                         map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED;
>         }
>
>
> base-commit: 92ed301919932f777713b9172e525674157e983d
> --
> 2.20.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family
  2020-07-29 23:18 [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family Logan Gunthorpe
  2020-07-30  4:31 ` Alex Deucher
@ 2020-07-30 15:27 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2020-07-30 15:27 UTC (permalink / raw)
  To: Logan Gunthorpe
  Cc: linux-kernel, linux-pci, Bjorn Helgaas, Alex Deucher,
	Christian König, Huang Rui

On Wed, Jul 29, 2020 at 05:18:44PM -0600, Logan Gunthorpe wrote:
> In order to avoid needing to add every new AMD CPU host bridge to the list
> every cycle, allow P2PDMA if the CPUs vendor is AMD and family is
> greater than 0x17 (Zen).
> 
> This should cut down a bunch of the churn adding to the list of allowed
> host bridges.
> 
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Alex Deucher <alexdeucher@gmail.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Huang Rui <ray.huang@amd.com>

Thanks, applied as below with Alex's reviewed-by to pci/peer-to-peer
for v5.9.

I had to enable CONFIG_MEMORY_HOTREMOVE and CONFIG_ZONE_DEVICE in
order to compile p2pdma.c.  I see some reasons why that is, but it's
not exactly intuitive, especially for MEMORY_HOTREMOVE.


commit dea286bb71ba ("PCI/P2PDMA: Allow P2PDMA on AMD Zen and newer CPUs")
Author: Logan Gunthorpe <logang@deltatee.com>
Date:   Wed Jul 29 17:18:44 2020 -0600

    PCI/P2PDMA: Allow P2PDMA on AMD Zen and newer CPUs
    
    Allow P2PDMA if the CPU vendor is AMD and family is 0x17 (Zen) or greater.
    
    [bhelgaas: commit log, simplify #if/#else/#endif]
    Link: https://lore.kernel.org/r/20200729231844.4653-1-logang@deltatee.com
    Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Huang Rui <ray.huang@amd.com>

diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index e8e444eeb1cd..1ec61fced4c3 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -273,6 +273,19 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev)
 	seq_buf_printf(buf, "%s;", pci_name(pdev));
 }
 
+static bool cpu_supports_p2pdma(void)
+{
+#ifdef CONFIG_X86
+	struct cpuinfo_x86 *c = &cpu_data(0);
+
+	/* Any AMD CPU whose family ID is Zen or newer supports p2pdma */
+	if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17)
+		return true;
+#endif
+
+	return false;
+}
+
 static const struct pci_p2pdma_whitelist_entry {
 	unsigned short vendor;
 	unsigned short device;
@@ -280,11 +293,6 @@ static const struct pci_p2pdma_whitelist_entry {
 		REQ_SAME_HOST_BRIDGE	= 1 << 0,
 	} flags;
 } pci_p2pdma_whitelist[] = {
-	/* AMD ZEN */
-	{PCI_VENDOR_ID_AMD,	0x1450,	0},
-	{PCI_VENDOR_ID_AMD,	0x15d0,	0},
-	{PCI_VENDOR_ID_AMD,	0x1630,	0},
-
 	/* Intel Xeon E5/Core i7 */
 	{PCI_VENDOR_ID_INTEL,	0x3c00, REQ_SAME_HOST_BRIDGE},
 	{PCI_VENDOR_ID_INTEL,	0x3c01, REQ_SAME_HOST_BRIDGE},
@@ -473,7 +481,8 @@ upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client,
 					      acs_redirects, acs_list);
 
 	if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) {
-		if (!host_bridge_whitelist(provider, client))
+		if (!cpu_supports_p2pdma() &&
+		    !host_bridge_whitelist(provider, client))
 			map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED;
 	}
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-30 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 23:18 [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family Logan Gunthorpe
2020-07-30  4:31 ` Alex Deucher
2020-07-30 15:27 ` 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).