[1/2] bus/pci: fix driver detach clear

Message ID 1573548459-6931-1-git-send-email-matan@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [1/2] bus/pci: fix driver detach clear |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Matan Azrad Nov. 12, 2019, 8:47 a.m. UTC
  When a rte_device is unplugged, the driver should be detached from the
device.

The PCI detach driver operation wrongly didn't clear the driver from the
device structure what remain the device in probe state from the EAL
point of view.

Clear the driver in driver detach successful operation.

Fixes: dbe6b4b61b0e ("pci: probe or close device")
Cc: mukawa@igel.co.jp
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/bus/pci/pci_common.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Thomas Monjalon Nov. 19, 2019, 10:40 p.m. UTC | #1
12/11/2019 09:47, Matan Azrad:
> When a rte_device is unplugged, the driver should be detached from the
> device.

Yes

> The PCI detach driver operation wrongly didn't clear the driver from the
> device structure what remain the device in probe state from the EAL
> point of view.

Are you aware of an use case which is broken because of that?


> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -247,6 +247,7 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)

The git context above is wrong, it should show the function rte_pci_detach_dev.

>  	/* clear driver structure */
>  	dev->driver = NULL;
> +	dev->device.driver = NULL;

It looks a good fix.
Acked-by: Thomas Monjalon <thomas@monjalon.net>

I am wondering if there could be a risk for any test application
if applied in 19.11-rc3.
I think we should try to get it and revert if a side effect is discovered.
  
Matan Azrad Nov. 20, 2019, 9:02 a.m. UTC | #2
Hi

From: Thomas Monjalon
> 12/11/2019 09:47, Matan Azrad:
> > When a rte_device is unplugged, the driver should be detached from the
> > device.
> 
> Yes
> 
> > The PCI detach driver operation wrongly didn't clear the driver from
> > the device structure what remain the device in probe state from the
> > EAL point of view.
> 
> Are you aware of an use case which is broken because of that?

Yes, will add  a small example.

> 
> > --- a/drivers/bus/pci/pci_common.c
> > +++ b/drivers/bus/pci/pci_common.c
> > @@ -247,6 +247,7 @@ static struct rte_devargs
> > *pci_devargs_lookup(struct rte_pci_device *dev)
> 
> The git context above is wrong, it should show the function
> rte_pci_detach_dev.
> 
> >  	/* clear driver structure */
> >  	dev->driver = NULL;
> > +	dev->device.driver = NULL;
> 
> It looks a good fix.
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
> 
> I am wondering if there could be a risk for any test application if applied in
> 19.11-rc3.
> I think we should try to get it and revert if a side effect is discovered.
>
  

Patch

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 6b46b4f..3f55420 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -247,6 +247,7 @@  static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 
 	/* clear driver structure */
 	dev->driver = NULL;
+	dev->device.driver = NULL;
 
 	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
 		/* unmap resources for devices that use igb_uio */