[dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset

Ferruh Yigit ferruh.yigit at intel.com
Fri Aug 24 15:55:56 CEST 2018


On 8/14/2018 8:46 PM, Matan Azrad wrote:
> Hi Stephen
> 
> From: Stephen Hemminger
>> On Tue, 14 Aug 2018 05:52:20 +0000
>> Matan Azrad <matan at mellanox.com> wrote:
>>
>>> Hi Stephen
>>>
>>> From: Stephen Hemminger
>>>> The rte_eth_dev_owner_unset function is unusable because it always
>>>> returns -EINVAL. This is because the magic (unowned) value is
>>>> flagged as not valid.
>>>>
>>>
>>> It's OK to raise an error when you do unset for unowned device.
>>> It means that unset owner should be called for owned device.
>>>
>>
>> Original code was broken. The following would always fail.
>>
>> 	rte_eth_dev_owner_new(&owner.id);
>> 	sprintf(owner.name, "example");
>> 	rte_eth_dev_owner_set(port_id, &owner);
>> 	rte_eth_dev_owner_unset(port_id, owner.id);
>>
>> That is because of:
>> 	rte_eth_dev_owner_unset(port_id, owner_id)
>> 		_rte_eth_dev_owner_set(port_id, owner_id, &new_owner)
>> << new_owner.id == RTE_ETH_DEV_NO_OWNER (0)
>>
>>
>> 	if (!rte_eth_is_valid_owner_id(new_owner->id) &&  <<
>> new_owner->id == RTE_ETH_DEV_NO_OWNER (which is flagged as invalid)
>> 	    !rte_eth_is_valid_owner_id(old_owner_id))
>> 		return -EINVAL;
>>
> 
> But both should be invalid the new owner and the old owner(&&) to raise an EINVAL error.
> 
> In the aforementioned check above the old owner should be valid.

It looks rte_eth_dev_owner_unset() works, updating patch as rejected.



More information about the dev mailing list