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

Re: [PATCH v2 1/8] driver/pci: Get next capability without passing caps


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Fri, 11 Apr 2025 08:08:12 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JMNZK5Ll+mK1erBU7KB7MfUdYtKmClDeJ4wjXHmzxDE=; b=Hq9CURPFdbEOrNTo/J2GvYpPWpEE1MeUK7eUrjalZCq3h9RzC6RkEcGY/vujpHoP1kR7AdWQLUCZTHqX4ZU35ZdROC27KsBaV355RBCjV72OJfTYB5XaZRC/KrULdzQd45uxVi7AfiKxc+asnNF/HjPSG1wDvWoA7fUay6kI82Bh761/j3PIMy6Ho24FHXDXJDBc1BlJVdFjV5yhn9I45gNQBdHGpyVggYnPWiYYlAu2FLo7inSubL3IpCUdicVEt8m6qF0YozS3j9+azdZHq5sGfIwytLcEaID+b6GKeK1TWoDHEqy1/dDN5ikloRC7yhjhASdmkdDYzFNqtaX0/Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ivK8t0cJOkKkiX3MSjEOB/OfqJTNaCyjf9h77ETJEEH2+In8kTP9nDpXeNXCyWeHPtjQAUBiR4MIpNahy8C4pvdoA9wY28zbTVEAA2JibscUSotv2fPTCv1mTRER/PA0NSoVyt4bkxa6rQXJCj+5rS5k2dVGEPKzkHXFfQS3fjlwSqvW3iMvP1hNpmJKdBVe/A74tTQWL8a7PT8Tflxr7Bt4RdXekM89Jw/3kWx63REIfgkTzcr51F6i7Rr3vLCUEp/KJN/G0t14LNe3alXTNGqO7rvcl+fga0AX40Uit+6OmL55BwGe2wVksr7FXwi21CD8I94Ur05YOm7chY9+dQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Orzel, Michal" <Michal.Orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Fri, 11 Apr 2025 08:08:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbqRsYW9r+TjshqU+vmdXYCVrO/7Oc16GAgAFv6YD//9W+AIAAh8GA
  • Thread-topic: [PATCH v2 1/8] driver/pci: Get next capability without passing caps

On 2025/4/11 16:00, Jan Beulich wrote:
> On 11.04.2025 04:51, Chen, Jiqian wrote:
>> On 2025/4/10 20:34, Jan Beulich wrote:
>>> On 09.04.2025 08:45, Jiqian Chen wrote:
>>>> --- a/xen/drivers/pci/pci.c
>>>> +++ b/xen/drivers/pci/pci.c
>>>> @@ -40,7 +40,7 @@ unsigned int pci_find_cap_offset(pci_sbdf_t sbdf, 
>>>> unsigned int cap)
>>>>  }
>>>>  
>>>>  unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, unsigned int pos,
>>>> -                                   const unsigned int caps[], unsigned 
>>>> int n,
>>>> +                                   const unsigned int *caps, unsigned int 
>>>> n,
>>>
>>> I don't follow the need for this change.
>> This changed is for my next patch "vpci/header: Emulate legacy capability 
>> list for host".
>> Currently, vpci only emulates capability list for domU, not for dom0.
>> For domU, vpci exposes a fixed capability array which calls "supported_caps".
>> My changes want to emulate capability list for dom0.
>> I think vpci should expose all devices capabilities to dom0.
>> When I emulate it, I need to iterate over all capabilities without another 
>> fixed array,
>> so I need this function to return the position of next capability directly 
>> when passing a zero length array to this function.
> 
> This doesn't answer my question. The change you need for the next patch is
> the hunk below, not the one above. Aiui at least.
Ah, yes.
I will abandon changing this function definition in next version since it just 
needs to check "n == 0".

> 
>>>> @@ -55,6 +55,10 @@ unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, 
>>>> unsigned int pos,
>>>>  
>>>>          if ( id == 0xff )
>>>>              break;
>>>> +
>>>> +        if ( !caps || n == 0 )
>>>> +            return pos;
>>>
>>> Checking n to be zero ought to suffice here? In that case it doesn't matter
>>> what caps is. Plus if n is non-zero, it clearly is an error if caps was 
>>> NULL.
>> Two checking is to prevent null pointer errors.
>> But as you said, if checking n to be zero is enough, then I don't need to 
>> change the definition of this function.
>> I will change in next version.
> 
> If you really wanted to, you could add e.g. ASSERT(caps) after this if().
OK, will add in next version, too.

> 
> Jan

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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