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

Re: [PATCH v2 1/3] PCI: simplify (and thus correct) pci_get_pdev{,_by_domain}()


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 11 Aug 2022 15:21:31 +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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V2977ye/d6M8LEtJlSGpyx62Eq26xhcvUCxRD6aJums=; b=FYSzQFrWUVzRpzRKAuxtPUOXbMxCnDp2GHU6PcAJrGjYFQoVgN0XKT1r0rrTcZSfHEJi/PJud6WImqcrnvU1inVIuv1rI8bt71xJDiu3yxmWaWimB82wk0u9Wh+zJzBx5dsQ5aUwKUmgLndKV/L9D1SbB1ZozcmloKucwWP8W10n4SFtS6vFdGWHc+kAOsvRIGV3LUgvvwsoXY+coGQCH/Jh+dwudo6istyxYmoTie+PC5IcYf2kHsq22OSrRbDa4l9fP2avH0QABV3Q5MPQcVLbXoQX91pjxxW9CW+3BdMxQFtWfeSvjpU7ekS77Bi8DcSlMWNTcgidPEcXDR9g/g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nztw/jhRc4Yxl0QjqfY19ywJBfSAwBuQFsB1C4KAlXwDJ2Lf18DzJsePQhYjWOwUxlnlYpmBqTQTlpbdKr1CZHthLHZUiP3D6rlB9f5uJi0fdSwcZwdN0RtTRXv9CfH8CmbARVOxe0sRm+MkQpcaCKPbBCv1cp3U9fudWLeIZ0RbrvT+OyPfLC/OYonMRwNuJTLusItvnvoKRibfdxsrhLwRi30FZjcsIpNNTWxzI7LpS5xhBtsOQbZo06x+5R28PKLiDnod9EEmwHt7diV4qjj5WZbrDGQPWHW5mAPzSkXnEDkUfMNnCPqeFne0tMt3twHm349hquCxk5ypO1sVhw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Rahul Singh <Rahul.Singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 11 Aug 2022 13:21:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.08.2022 15:11, Andrew Cooper wrote:
> On 11/08/2022 11:51, Jan Beulich wrote:
>> The last "wildcard" use of either function went away with f591755823a7
>> ("IOMMU/PCI: don't let domain cleanup continue when device de-assignment
>> failed"). Don't allow them to be called this way anymore. Besides
>> simplifying the code this also fixes two bugs:
>>
>> 1) When seg != -1, the outer loops should have been terminated after the
>>    first iteration, or else a device with the same BDF but on another
>>    segment could be found / returned.
>>
>> Reported-by: Rahul Singh <rahul.singh@xxxxxxx>
>>
>> 2) When seg == -1 calling get_pseg() is bogus. The function (taking a
>>    u16) would look for segment 0xffff, which might exist. If it exists,
>>    we might then find / return a wrong device.
>>
>> In pci_get_pdev_by_domain() also switch from using the per-segment list
>> to using the per-domain one, with the exception of the hardware domain
>> (see the code comment there).
>>
>> While there also constify "pseg" and drop "pdev"'s already previously
>> unnecessary initializer.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Thanks.

> I'm not totally convinced that special casing hwdom is right, because
> quarantine devices are domio not hwdom.  But I also can't identify a
> case where it's definitely wrong either.
> 
>> --- a/xen/include/xen/pci.h
>> +++ b/xen/include/xen/pci.h
>> @@ -177,10 +177,10 @@ int pci_add_device(u16 seg, u8 bus, u8 d
>>  int pci_remove_device(u16 seg, u8 bus, u8 devfn);
>>  int pci_ro_device(int seg, int bus, int devfn);
>>  int pci_hide_device(unsigned int seg, unsigned int bus, unsigned int devfn);
>> -struct pci_dev *pci_get_pdev(int seg, int bus, int devfn);
>> +struct pci_dev *pci_get_pdev(uint16_t seg, uint8_t bus, uint8_t devfn);
> 
> I was going to make a request, but I can't quite get it to compile...
> 
> Passing sbdf as 3 parameters is a waste, and it would be great if we
> could take this opportunity to improve.
> 
> Sadly,
> 
> -struct pci_dev *pci_get_pdev(uint16_t seg, uint8_t bus, uint8_t devfn);
> +struct pci_dev *pci_get_pdev(pci_sbdf_t sbdf);
> +
> +#define pci_get_pdev(...)                               \
> +    ({                                                  \
> +        count_args(__VA_ARGS__) == 1                    \
> +            ? pci_get_pdev(__VA_ARGS__)                 \
> +            : pci_get_pdev(PCI_SBDF(__VA_ARGS__));      \
> +    })
> 
> this doesn't quite compile as a transition plan, and I'm stuck for
> further ideas.

Just look at patch 2.

Jan



 


Rackspace

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