On Tue, 14 Aug 2018 05:52:20 +0000
Matan Azrad <ma...@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;

The failsafe driver never checks the return value, and therefore doesn't see 
that it never clears ownership.

Reply via email to