[v6,1/4] bus/pci: fix registration of PCI device

Message ID 20250206105428.237346-1-shperetz@nvidia.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series [v6,1/4] bus/pci: fix registration of PCI device |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Shani Peretz Feb. 6, 2025, 10:54 a.m. UTC
When registering a new PCI device, the device->name field stored
the user-provided string from devargs (e.g., "08:00.0" or "0000:08:00.0").
This approach led to inconsistencies when registering new devices.

This patch fix this issue by saving the parsed PCI in device->name,
so when a new PCI device is registering the name displayed in the device
list will be the parsed version.

Fixes: 23eaa9059ec2 ("bus/pci: use given name as generic name")

Cc: stable@dpdk.org
Signed-off-by: Shani Peretz <shperetz@nvidia.com>
---
 drivers/bus/pci/pci_common.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
  

Comments

Bruce Richardson Feb. 11, 2025, 5:04 p.m. UTC | #1
On Thu, Feb 06, 2025 at 12:54:24PM +0200, Shani Peretz wrote:
> When registering a new PCI device, the device->name field stored
> the user-provided string from devargs (e.g., "08:00.0" or "0000:08:00.0").
> This approach led to inconsistencies when registering new devices.
> 
> This patch fix this issue by saving the parsed PCI in device->name,
> so when a new PCI device is registering the name displayed in the device
> list will be the parsed version.
> 
> Fixes: 23eaa9059ec2 ("bus/pci: use given name as generic name")
> 
> Cc: stable@dpdk.org
> Signed-off-by: Shani Peretz <shperetz@nvidia.com>
> ---
>  drivers/bus/pci/pci_common.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
Tested-by: Bruce Richardson <bruce.richardson@intel.com>

Tested with running testpmd using -a 27:00.0 -a 27:00.1 and then using
dpdk-proc-info with the same ports prefixed with 0000:. Without this patch,
that gave an error. With this patch, output was the same with and without
the extra prefix.
Also tested the reverse case, running testpmd with the domain prefix, and
proc-info without, that too worked in testing.

/Bruce
  
Stephen Hemminger Feb. 12, 2025, 12:39 a.m. UTC | #2
On Thu, 6 Feb 2025 12:54:24 +0200
Shani Peretz <shperetz@nvidia.com> wrote:

> When registering a new PCI device, the device->name field stored
> the user-provided string from devargs (e.g., "08:00.0" or "0000:08:00.0").
> This approach led to inconsistencies when registering new devices.
> 
> This patch fix this issue by saving the parsed PCI in device->name,
> so when a new PCI device is registering the name displayed in the device
> list will be the parsed version.
> 
> Fixes: 23eaa9059ec2 ("bus/pci: use given name as generic name")
> 
> Cc: stable@dpdk.org
> Signed-off-by: Shani Peretz <shperetz@nvidia.com>

This part looks good, second part needs work.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 1173f0887c..70faae4e44 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -99,21 +99,11 @@  pci_common_set(struct rte_pci_device *dev)
 	/* Each device has its internal, canonical name set. */
 	rte_pci_device_name(&dev->addr,
 			dev->name, sizeof(dev->name));
+	dev->device.name = dev->name;
+
 	devargs = pci_devargs_lookup(&dev->addr);
 	dev->device.devargs = devargs;
 
-	/* When using a blocklist, only blocked devices will have
-	 * an rte_devargs. Allowed devices won't have one.
-	 */
-	if (devargs != NULL)
-		/* If an rte_devargs exists, the generic rte_device uses the
-		 * given name as its name.
-		 */
-		dev->device.name = dev->device.devargs->name;
-	else
-		/* Otherwise, it uses the internal, canonical form. */
-		dev->device.name = dev->name;
-
 	if (dev->bus_info != NULL ||
 			asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
 				dev->id.vendor_id, dev->id.device_id) != -1)