[PATCH v1] raw/ifpga: remove virtual device unplug operation

Huang, Wei wei.huang at intel.com
Thu Mar 23 04:26:06 CET 2023



> -----Original Message-----
> From: Thomas Monjalon <thomas at monjalon.net>
> Sent: Wednesday, March 22, 2023 19:54
> To: Huang, Wei <wei.huang at intel.com>
> Cc: dev at dpdk.org; david.marchand at redhat.com; stable at dpdk.org; Xu,
> Rosen <rosen.xu at intel.com>; Zhang, Tianfei <tianfei.zhang at intel.com>;
> Zhang, Qi Z <qi.z.zhang at intel.com>
> Subject: Re: [PATCH v1] raw/ifpga: remove virtual device unplug operation
> 
> 22/03/2023 02:26, Huang, Wei:
> > From: Thomas Monjalon <thomas at monjalon.net>
> > > 21/03/2023 09:41, Huang, Wei:
> > > > From: Thomas Monjalon <thomas at monjalon.net>
> > > > > 21/03/2023 01:11, Huang, Wei:
> > > > > > From: Thomas Monjalon <thomas at monjalon.net>
> > > > > > > 16/03/2023 21:44, Wei Huang:
> > > > > > > > VDEV bus has implemented cleanup() function to perform
> > > > > > > > cleanup for devices on the bus during eal_cleanup(), so
> > > > > > > > there is no need for ifpga driver to record virtual devices and
> unplug them.
> > > > > > >
> > > > > > > Why no need?
> > > > > > > If the application wants to explicitly remove a device, what
> happens?
> > > > > > >
> > > > > > >
> > > > > > EAL will output an error information "Cannot find plugged device
> (%s)".
> > > > >
> > > > > It does not look what we expect.
> > > > >
> > > > Let me clear it.
> > > > With this patch, no error information will be outputted.
> > > > Without this patch, error information will be outputted.
> > > > Because bus cleanup action will unplug virtual device, then ifpga
> > > > PMD unplug the virtual device which is already be cleanup,
> > >
> > > Why ipfga unplug the device after the bus cleanup?
> > > I'm not following.
> > >
> > The virtual device is created upon ifpga, if VDEV bus doesn't perform
> > cleanup, ifpga has the responsibility to unplug these virtual devices.
> 
> Really I don't understand the flow.
> Are you talking about EAL cleanup case?
Yes, it's about EAL cleanup.
> What happens first? Do you need ifpga to be called first?
The cleanup flow is rte_eal_cleanup() -> eal_bus_cleanup()
eal_bus_cleanup() will call each bus's cleanup method to complete cleanup work.  
There are three types of device related to ifpga PMD: PCI device, VDEV device and AFU device.
VDEV device is created on PCI device, it's a mediate device which purpose is to plug a AFU device on IFPGA bus.
Before eal_bus_cleanup() is implemented, application will call rte_pmd_ifpga_cleanup() to remove PCI device, VDEV device will be removed when PCI device is removed, AFU device will be removed when VDEV device is removed, it works fine.
Now eal_bus_cleanup() takes the job, application has no need to call rte_pmd_ifpga_cleanup(), ifpga PCI device has no need to remove ifpga VDEV device and ifpga VDEV device has no need to remove ifpga AFU device.
> I think you need the correct checks to allow any order of cleanup.
When this patch is committed, no order dependent on cleanup.

> > > > bus->find_device() returns NULL,
> > > > EAL output "Cannot find plugged device (%s)\n" at line 302 in
> > > > eal_common_dev.c
> > >
> > > Anyway, the good answer is not to completely remove the "remove"
> > > operation.
> > >
> > If not to completely remove the "remove", the same virtual device will be
> unplug twice, is it reasonable?
> 
> You need to add a check to not unplug something already unplugged.
> But you must allow the user calling "remove" directly.
> 
rte_pmd_ifpga_cleanup() is the only one interface for user to calling "remove" directly, when this patch is committed, VDEV and AFU device will not be unplugged twice.
For PCI device, the implementation of rte_pmd_ifpga_cleanup() is like below
	for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
		dev = &ifpga_rawdevices[i];
		if (dev->rawdev) {
			rte_rawdev_pmd_release(dev->rawdev);
			dev->rawdev = NULL;
		}
	}
If ifpga PCI device is already removed, dev->rawdev is NULL, it will not be unplugged again.



More information about the stable mailing list