[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>, Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 28 Sep 2021 09:59:19 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=++SQqnMhac3su4SgIB0DoC0eO8NuHYjHSgc9CfMdRLU=; b=d0X+AFxa8wVuCeyqc+kPIEBESpydDJabgkDtJrOAq1nCgyk9cIZMHNXOd7WlYovqEHlzpgm8ej9xDV9VfthDAQPaTzxO0fJARjWYr4zLRl8m4J+r8Um6sNlNvWEIEFId1Zdc7sKxj22uCQh++zEpvPMJdaTGe5eCaeUjVbMMoiRLlOtZwQ5k3CSh/2K5AixhhjyarrMfjDrXJSEyQahdeu06OF7Lv9PrgY8dxSwftt7Yl/gGYaJwvTXljUk3ETp8O42BpudE7zfXhDUAVkpwL+7MsN9SkHw7XzEPHlztqcQJwpdPgVKj0zG/BTjMtqs1SHwsxCUSZcc/a9kEBFpilA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HIQv51a+MyU1V/GcAIrGCRmPO8hixr+Qxnzyq8qv3uSmtghSddfxcIJM7Sb8wxxW2A/K8zuFEf6V0GnMQy+JxE11I/2ORRt5sENMfZ4t2otkSKmFFkYXQtekK8AqVT2dP6+/EWXwXcgw2fzAfsDIuWvc3TYG1aJNHD7Ohj19QIdzpR6DwHqfeSzQK7qKBx9hHf1vP8hpqIiHZRjP/FLvosRUUaCBoTFKb29qO/Cj0Vhy4MBZ8FEHAdLAece0rrNOTyLgCbHyD7OrlXflXWde2OiEcR1jKrO3+ECM1hTZ/6zAemXXeZUVIlpmTH3SSX55MtCu8DHm78BzY6pMZY7XlA==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: julien@xxxxxxx, sstabellini@xxxxxxxxxx, oleksandr_tyshchenko@xxxxxxxx, volodymyr_babchuk@xxxxxxxx, Artem_Mygaiev@xxxxxxxx, roger.pau@xxxxxxxxxx, bertrand.marquis@xxxxxxx, rahul.singh@xxxxxxx, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 28 Sep 2021 07:59:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.
> 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.

Jan




 


Rackspace

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