On 13.09.2023 01:41, Volodymyr Babchuk wrote:
> Jan Beulich <[email protected]> writes:
>> On 30.08.2023 01:19, Volodymyr Babchuk wrote:
>>> @@ -1481,6 +1488,13 @@ static int assign_device(struct domain *d, u16 seg,
>>> u8 bus, u8 devfn, u32 flag)
>>> if ( pdev->broken && d != hardware_domain && d != dom_io )
>>> goto done;
>>>
>>> + if ( IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) )
>>> + {
>>> + write_lock(&pdev->domain->pci_lock);
>>> + vpci_deassign_device(pdev);
>>> + write_unlock(&pdev->domain->pci_lock);
>>> + }
>>
>> Why is the DomIO special case ...
>
> vpci_deassign_device() does nothing if vPCI was initialized for a
> domain. So it not wrong to call this function even if pdev belongs to dom_io.
Well, okay, but then you acquire a lock just to do nothing (apart
from the apparent asymmetry).
>>> @@ -1506,6 +1520,15 @@ static int assign_device(struct domain *d, u16 seg,
>>> u8 bus, u8 devfn, u32 flag)
>>> rc = iommu_call(hd->platform_ops, assign_device, d, devfn,
>>> pci_to_dev(pdev), flag);
>>> }
>>> + if ( rc )
>>> + goto done;
>>> +
>>> + if ( IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) && d != dom_io)
>>> + {
>>> + write_lock(&d->pci_lock);
>>> + rc = vpci_assign_device(pdev);
>>> + write_unlock(&d->pci_lock);
>>> + }
>>
>> ... relevant only here?
>>
>
> There is no sense to initialize vPCI for dom_io.
Of course.
Jan