On 2/13/2020 3:27 PM, Thomas Monjalon wrote:
> 13/02/2020 16:16, Ferruh Yigit:
>> On 2/13/2020 2:33 PM, Thomas Monjalon wrote:
>>> The function rte_eth_dev_release_port() is called by drivers
>>> when closing or removing a device.
>>> Its main usage should be via rte_eth_dev_close() by up-to-date
>>> drivers which are compliant with RTE_ETH_DEV_CLOSE_REMOVE flag.
>>>
>>> When a port is released, the data (rte_eth_dev_data) are cleared,
>>> but the pointers in rte_eth_dev were not cleared.
>>> It may cause issues with code paths trying to use dangling pointers
>>> (e.g. the .device pointer which may reference a removed rte_device).
>>> Everything is now cleared to 0 when releasing.
>>> The state is explicitly set to RTE_ETH_DEV_UNUSED which is 0 anyway.
>>>
>>> Using this patch may reveal bugs in some code paths:
>>>     - device pointer must be saved before closing a port if needed
>>
>> Is this saving should be done in application code or will be done by ethdev?
> 
> by the application
> From ethdev point of view, when a port is closed, there is nothing more to do 
> next.
> 

That sound reasonable from ethdev perspective, but it will push dealing with
rte_device level details to the application.

Like this change will be forcing each application to store the rte_device
pointer before close(), in case device can be detached later.

Reply via email to