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

Re: [PATCH v2 10/11] vpci: Add initial support for virtual PCI bus topology


  • To: Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 28 Sep 2021 12:58:06 +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=9jH0gqOOD1UJNMg5HtmMPrxSxjV+7hrmY6Y6Km41ztQ=; b=QsLr/yHXokHHYNm/nEqLp9QtrrwFf9lkbBozy4jXc4pmLoT+P1j4KlgBHc6D661Gf/QBAFlMtQpPAERQE1eefk/vNoluj2Hu+ML1oTSh65INYE69sG3mREIs+lOvzHmiw0EOEiTAyqSbxbc4d7hTdNMNL9M0/NRLGn3CfhD9neaQ/bWJIKoUNCDKBtcDkUqgU+Y9fVlJq86Cmuwp1n+05yMEExGa5QmVp91yAid8mg3YO4hxatcOxyxDXpy94PGUuqotkrppmhPmqp/tLe+Cr5Ygh1/wIw4ofjfQM0aDE1ltN8CwJPgdkxx7YRfguQmE28MpdxwWOq5ERF7ItVgG4g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y3rJ0gcak0RMP+kRZxxofZ4TFcVU/L8lhy19a/H39EuLlBqUoDPWtfduELRxqXFqXFOlQfSGUYTIVlKN19VYgx/980w9mKuuQe9lDzDwMqedPA/lgm5EMN983rkaZeSMDtl3rN1R2SkKsLBR0zIALJbn0aLGF9BAqa6tgmeuBiW5kyi4BHliVQfC5plZ/yGG3ThURMETjR5mKMkV0LJtMDJq3G/rVkWNn+itFYY6s/d5lj8+UB6JN/VeHbLSdSmwAZJ6KxhyYAJSUkZzKIDzXFc+JhV4unKzk3KDY/r36USgZ5FVGvGA7qmQsuvmccIcO7i1ZT2kWho/dkKWTLbLew==
  • Authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.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>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 28 Sep 2021 12:58:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXsHpEaYKJY1uGNUmlwbBKeBrI6Ku5GYwAgAAC+oCAAAUNAIAATmyA
  • Thread-topic: [PATCH v2 10/11] vpci: Add initial support for virtual PCI bus topology

On 28.09.21 11:17, Michal Orzel wrote:
>
> On 28.09.2021 09:59, Jan Beulich wrote:
>> On 28.09.2021 09:48, Michal Orzel wrote:
>>> On 23.09.2021 14:55, Oleksandr Andrushchenko wrote:
>>>> --- a/xen/drivers/passthrough/pci.c
>>>> +++ b/xen/drivers/passthrough/pci.c
>>>> @@ -833,6 +833,63 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
>>>>       return ret;
>>>>   }
>>>>   
>>>> +static struct vpci_dev *pci_find_virtual_device(const struct domain *d,
>>>> +                                                const struct pci_dev 
>>>> *pdev)
>>>> +{
>>>> +    struct vpci_dev *vdev;
>>>> +
>>>> +    list_for_each_entry ( vdev, &d->vdev_list, list )
>>>> +        if ( vdev->pdev == pdev )
>>>> +            return vdev;
>>>> +    return NULL;
>>>> +}
>>>> +
>>>> +int pci_add_virtual_device(struct domain *d, const struct pci_dev *pdev)
>>>> +{
>>>> +    struct vpci_dev *vdev;
>>>> +
>>>> +    ASSERT(!pci_find_virtual_device(d, pdev));
>>>> +
>>>> +    /* Each PCI bus supports 32 devices/slots at max. */
>>>> +    if ( d->vpci_dev_next > 31 )
>>>> +        return -ENOSPC;
>>>> +
>>>> +    vdev = xzalloc(struct vpci_dev);
>>>> +    if ( !vdev )
>>>> +        return -ENOMEM;
>>>> +
>>>> +    /* We emulate a single host bridge for the guest, so segment is 
>>>> always 0. */
>>>> +    *(u16*) &vdev->seg = 0;
>>> Empty line hear would improve readability due to the asterisks being so 
>>> close to each other.
Will add
>>> Apart from that:
>>> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
>>>> +    /*
>>>> +     * The bus number is set to 0, so virtual devices are seen
>>>> +     * as embedded endpoints behind the root complex.
>>>> +     */
>>>> +    *((u8*) &vdev->bus) = 0;
>>>> +    *((u8*) &vdev->devfn) = PCI_DEVFN(d->vpci_dev_next++, 0);
>> All of these casts are (a) malformed and (b) unnecessary in the first
>> place, afaics at least.
>>
> Agree.
> *((u8*) &vdev->bus) = 0;
> is the same as:
> vdev->bus = 0;

Overengineering at its best ;)

Will fix that

>> Jan
>>
Thank you,

Oleksandr

 


Rackspace

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