[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 02/11] vpci: Add hooks for PCI device assign/de-assign


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Thu, 30 Sep 2021 09:21:08 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=3mdNhlz9ee2At3vWD9/9dOjLTnENwnSEQLVZCu6rKRE=; b=isuotNQ9Xmwxra4CImz1M4KtGOUEHTw1B8hC4xPk0TXzvn4BUkPeQY/3kJAA6o38GuIfb1ETGVsNfem8XUy0YgaoAzxZJwPyOek1SpoM4kksdpPblYSfPsJFKm8iHw9HYovji/6lybii8w+92HlIjPuAOp8fousMfF4bpg2CucpS1LMVldebvuFdBLzh5xl3gygIQoDnVB0zgX+ix16J8AjZXKpU5+82k3LS1DQocX7HRbo61U5PAehK1kkCya4mQnLLVlTlh7+PoganlDHQvR200rMSA/rkPxHrERtfAKXofbO7ylB4pCtlV+ejqfNERRGCGP22a35WMoQWHWKSTg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JWk5Gu1nOmUhzXAZy0M1eXhlHsyZ2RaRm7nlgtGhJgkqdd94fX9bc/1nTaV0LS4amUq3G6H2aSpX0PEhagmAjwoF2cBOkYSEpwS9O7MT3FnqaMz4ZYuWkRvf3+nMaj0o6dxpzH8j3ATn6IuPFDGwubCbOlyqDTDclh1rSjBaejrieVbP2Vi4YukOsZ3UmS9jRqSDn8X1/oifcgjcYPtlA9rnTZoE5qNU62OVxSiWRe0NmgptQLH0QxiJn8/2WKsoVjvQUit2cXnr6Su6+Ca7zSDGyyX1Hu21pij1q8QOaHbrnZI077QJ/MMQRA4b/YHBwFqM1vApfEdQI1xnqFGIhw==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=epam.com;
  • Cc: "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "roger.pau@xxxxxxxxxx" <roger.pau@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Thu, 30 Sep 2021 09:21:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXtdAg2qzxZ1hIP02wGTFUbQtoPau8PLsAgAAGuICAAAXDAIAABCmA
  • Thread-topic: [PATCH v3 02/11] vpci: Add hooks for PCI device assign/de-assign


On 30.09.21 12:06, Jan Beulich wrote:
> On 30.09.2021 10:45, Oleksandr Andrushchenko wrote:
>> On 30.09.21 11:21, Jan Beulich wrote:
>>> On 30.09.2021 09:52, Oleksandr Andrushchenko wrote:
>>>> @@ -1429,6 +1433,11 @@ static int assign_device(struct domain *d, u16 seg, 
>>>> u8 bus, u8 devfn, u32 flag)
>>>>            rc = hd->platform_ops->assign_device(d, devfn, 
>>>> pci_to_dev(pdev), flag);
>>>>        }
>>>>    
>>>> +    if ( rc )
>>>> +        goto done;
>>>   From all I can tell this is dead code.
>> Before the change rc was set in the loop. And then we fall through
>> to the "done" label. I do agree that the way this code is done the
>> value of that rc will only reflect the last assignment done in the loop,
>> but with my change I didn't want to change the existing behavior,
>> thus "if ( rc"
> rc is always 0 upon loop exit, afaict:
>
>      for ( ; pdev->phantom_stride; rc = 0 )
>
> Granted this is unusual and hence possibly unexpected.
I will remove that check then. Do we want a comment about rc == 0,
so it is seen why there is no check for rc?
>
>>>> --- a/xen/drivers/vpci/vpci.c
>>>> +++ b/xen/drivers/vpci/vpci.c
>>>> @@ -86,6 +86,29 @@ int __hwdom_init vpci_add_handlers(struct pci_dev *pdev)
>>>>    
>>>>        return rc;
>>>>    }
>>>> +
>>>> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
>>>> +/* Notify vPCI that device is assigned to guest. */
>>>> +int vpci_assign_device(struct domain *d, const struct pci_dev *dev)
>>>> +{
>>>> +    /* It only makes sense to assign for hwdom or guest domain. */
>>> Could you clarify for me in how far this code path is indeed intended
>>> to be taken by hwdom? Because if it is, I'd like to further understand
>>> the interaction with setup_hwdom_pci_devices().
>> setup_hwdom_pci_devices is not used on Arm as we do rely on
>> Dom0 to perform PCI host initialization and PCI device enumeration.
>>
>> This is because of the fact that on Arm it is not a trivial task to
>> initialize a PCI host bridge in Xen, e.g. you need to properly initialize
>> power domains, clocks, quirks etc. for different SoCs.
>> All these make the task too complex and it was decided that at the
>> moment we do not want to bring PCI device drivers in Xen for that.
>> It was also decided that we expect Dom0 to take care of initialization
>> and enumeration.
>> Some day, when firmware can do PCI initialization for us and then we
>> can easily access ECAM, this will change. Then setup_hwdom_pci_devices
>> will be used on Arm as well.
>>
>> Thus, we need to take care that Xen knows about the discovered
>> PCI devices via assign_device etc.
> Fair enough, but since I've not spotted a patch expressing this
Well, it is all in the RFC for PCI passthrough on Arm which is mentioned
in series from Arm and EPAM (part 2). I didn't mention the RFC in the
cover letter for this series though.
>   (by
> adding suitable conditionals), may I ask that you do so in yet another
> patch (unless I've overlooked where this gets done)?
Could you please elaborate more on which conditionals you are
talking about here? I'm afraid I didn't understand this part.
>
>>>> +    if ( is_system_domain(d) || !has_vpci(d) )
>>>> +        return 0;
>>>> +
>>>> +    return 0;
>>>> +}
>>>> +
>>>> +/* Notify vPCI that device is de-assigned from guest. */
>>>> +int vpci_deassign_device(struct domain *d, const struct pci_dev *dev)
>>>> +{
>>>> +    /* It only makes sense to de-assign from hwdom or guest domain. */
>>>> +    if ( is_system_domain(d) || !has_vpci(d) )
>>>> +        return 0;
>>>> +
>>>> +    return 0;
>>>> +}
>>>> +#endif /* CONFIG_HAS_VPCI_GUEST_SUPPORT */
>>> At this point of the series #ifdef is the less preferable variant of
>>> arranging for dead code to get compiled out.
>> What is that other preferable way then?
> "if ( !IS_ENABLED() )" as I did already point out to you yesterday in
> reply to v2 of patch 10 of this very series.
Please see below
>
>>>    I expect later patches
>>> will change that?
>> No, it is going to be this way all the time
> The question wasn't whether you switch away from the #ifdef-s, but
> whether later patches leave that as the only choice (avoiding build
> breakage).
Yes, the code is going to always remain ifdef'ed, so we don't have
dead code for x86 (at least).
So, does the above mean that you are ok with "#ifdef 
CONFIG_HAS_VPCI_GUEST_SUPPORT"
and there is no need for "if ( !IS_ENABLED() )"?
>
> Jan
>
>
Thank you,
Oleksandr

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.