[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 02:51:59 +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=Ux3IHsZSUN/lKueQAl7xlfT7DAX3r4VFyjFzr+ipY+U=; b=v40Q7o34SDO4WlA4s3ap80Wu7sRFYsqaTN3x08RqZpuV8gVLZ4OzaLFiII5yIxsP6vlIpRUdzYtq+YppopD6LTaUl01y6TMR9T0SNlVjiQIPshVYle3LWTo9QcJ2WtI/DC/baBxTJkeougVKWPVLuqwu0lfRvpaYU89LyHxBEJ5ZEHYEsNTq5hAXqlcOXMFKGYBQyOv/L94QGhZgUmzfB6mEDBtcQ6iO+N1ieFSeXTneM19CwxCV2nWY7GXvFJ/0CP2Kr2v3Q5GHkPertzJduE+9D8/ScU7aWgKwE6UIbf3zEKWW0PwI+/QpxlAnqKiNs8RDRXgFJlOBWdQURHT+Xg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Au6DZeQkVyNqQkNu5YZvZCVTGnVveurzLVNL851sR0PxA52R9tPDmO99cDj2N9G8ngZcwiLUC2wZMhejH8KWSLaH1ixJbsLq02J6hyAgRYGdzTLeE88XD7OK8C/5f0dmJ8bvPk9QUS4RNCkSrB6fKueZWlq0wqUh+VnVX3IpKC9g4ln/Gt91kS0WcD6OJpJ5j6uLMnj0lCqlb6mSA2wSS9fhKXPnDVjss3kI6CYyPDhTJ1xurxlpG0asPtKMqIkzKiBkp4zO8zt9jyBD9Xy0MIyrAmpmabCKP6FWVH8RGz3KJzXebaWPLRCUaKDw2i39Rd0osd9MF+Y/MyEpU1bBxQ==
- 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 02:52:15 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHbqRsYW9r+TjshqU+vmdXYCVrO/7Oc16GAgAFv6YA=
- Thread-topic: [PATCH v2 1/8] driver/pci: Get next capability without passing caps
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.
>
>> @@ -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.
>
> Jan
--
Best regards,
Jiqian Chen.
|