[v3] pci/linux: copy new id for inserted device

Message ID 20201012220136.6618-1-james.r.harris@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v3] pci/linux: copy new id for inserted device |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Performance-Testing fail build patch failure
ci/travis-robot warning Travis build: failed
ci/Intel-compilation fail apply issues

Commit Message

Harris, James R Oct. 12, 2020, 10:01 p.m. UTC
  When a device is inserted into an existing BDF slot
that has not been probed, we must overwrite the old
PCI ID with the ID of the new function. Otherwise
we may not probe the function with the correct driver,
if at all.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
---
 drivers/bus/pci/linux/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 13, 2020, 8:40 a.m. UTC | #1
13/10/2020 00:01, Jim Harris:
> When a device is inserted into an existing BDF slot
> that has not been probed, we must overwrite the old
> PCI ID with the ID of the new function. Otherwise
> we may not probe the function with the correct driver,
> if at all.
> 
> Signed-off-by: Jim Harris <james.r.harris@intel.com>
> ---
> --- a/drivers/bus/pci/linux/pci.c
> +++ b/drivers/bus/pci/linux/pci.c
> @@ -352,6 +352,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
>  				if (!rte_dev_is_probed(&dev2->device)) {
>  					dev2->kdrv = dev->kdrv;
>  					dev2->max_vfs = dev->max_vfs;
> +					dev2->id = dev->id;

This simple assignment looks nicer than memcpy.
Thanks for this change.

[...]
>  					if (dev2->kdrv != dev->kdrv ||
> -						dev2->max_vfs != dev->max_vfs)
> +						dev2->max_vfs != dev->max_vfs ||
> +						dev2->id != dev->id)

Unfortunately comparison of structs is not supported.
It seems your original memcmp is right.
  

Patch

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index a2198abf4..2e37735c2 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -352,6 +352,7 @@  pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 				if (!rte_dev_is_probed(&dev2->device)) {
 					dev2->kdrv = dev->kdrv;
 					dev2->max_vfs = dev->max_vfs;
+					dev2->id = dev->id;
 					pci_name_set(dev2);
 					memmove(dev2->mem_resource,
 						dev->mem_resource,
@@ -365,7 +366,8 @@  pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 					 * need to do anything here unless...
 					 **/
 					if (dev2->kdrv != dev->kdrv ||
-						dev2->max_vfs != dev->max_vfs)
+						dev2->max_vfs != dev->max_vfs ||
+						dev2->id != dev->id)
 						/*
 						 * This should not happens.
 						 * But it is still possible if