diff mbox series

[2/2] tools/libxl: Skip missing PCI GSIs

Message ID 20250226201022.42447-3-jason.andryuk@amd.com (mailing list archive)
State New
Headers show
Series tools: Fix PVH dom0 passthrough with legacy irq | expand

Commit Message

Jason Andryuk Feb. 26, 2025, 8:10 p.m. UTC
A PCI device may not have a legacy IRQ.  In that case, we don't need to
do anything, so don't fail in libxl__arch_hvm_map_gsi() and
libxl__arch_hvm_unmap_gsi().

Requires an updated pciback to return -ENOENT.

Fixes: f97f885c7198 ("tools: Add new function to do PIRQ (un)map on PVH dom0")
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 tools/libs/light/libxl_x86.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Jan Beulich Feb. 27, 2025, 8:25 a.m. UTC | #1
On 26.02.2025 21:10, Jason Andryuk wrote:
> --- a/tools/libs/light/libxl_x86.c
> +++ b/tools/libs/light/libxl_x86.c
> @@ -901,7 +901,10 @@ int libxl__arch_hvm_map_gsi(libxl__gc *gc, uint32_t sbdf, uint32_t domid)
>      int pirq = -1, gsi, r;
>  
>      gsi = xc_pcidev_get_gsi(CTX->xch, sbdf);
> -    if (gsi < 0) {
> +    if (gsi == -1 && errno == ENOENT) {
> +        LOGD(DEBUG, domid, "xc_pcidev_get_gsi no gsi");
> +        return 0;
> +    } else if (gsi < 0) {
>          return ERROR_FAIL;
>      }
>  
> @@ -925,7 +928,10 @@ int libxl__arch_hvm_unmap_gsi(libxl__gc *gc, uint32_t sbdf, uint32_t domid)
>      int pirq = -1, gsi, r;
>  
>      gsi = xc_pcidev_get_gsi(CTX->xch, sbdf);
> -    if (gsi < 0) {
> +    if (gsi == -1 && errno == ENOENT) {
> +        LOGD(DEBUG, domid, "xc_pcidev_get_gsi no gsi");
> +        return 0;
> +    } else if (gsi < 0) {
>          return ERROR_FAIL;
>      }
>  

Why the special-casing of the value -1?

Jan
Jason Andryuk Feb. 27, 2025, 3:24 p.m. UTC | #2
On 2025-02-27 03:25, Jan Beulich wrote:
> On 26.02.2025 21:10, Jason Andryuk wrote:
>> --- a/tools/libs/light/libxl_x86.c
>> +++ b/tools/libs/light/libxl_x86.c

>> @@ -925,7 +928,10 @@ int libxl__arch_hvm_unmap_gsi(libxl__gc *gc, uint32_t sbdf, uint32_t domid)
>>       int pirq = -1, gsi, r;
>>   
>>       gsi = xc_pcidev_get_gsi(CTX->xch, sbdf);
>> -    if (gsi < 0) {
>> +    if (gsi == -1 && errno == ENOENT) {
>> +        LOGD(DEBUG, domid, "xc_pcidev_get_gsi no gsi");
>> +        return 0;
>> +    } else if (gsi < 0) {
>>           return ERROR_FAIL;
>>       }
>>   
> 
> Why the special-casing of the value -1?

No good reason.  I'll restore it to < 0.  I originally thought 
xc_pcidev_get_gsi() was returning -errno in gsi.  That was not the case.

Regards,
Jason
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c
index a3164a3077..63208362af 100644
--- a/tools/libs/light/libxl_x86.c
+++ b/tools/libs/light/libxl_x86.c
@@ -901,7 +901,10 @@  int libxl__arch_hvm_map_gsi(libxl__gc *gc, uint32_t sbdf, uint32_t domid)
     int pirq = -1, gsi, r;
 
     gsi = xc_pcidev_get_gsi(CTX->xch, sbdf);
-    if (gsi < 0) {
+    if (gsi == -1 && errno == ENOENT) {
+        LOGD(DEBUG, domid, "xc_pcidev_get_gsi no gsi");
+        return 0;
+    } else if (gsi < 0) {
         return ERROR_FAIL;
     }
 
@@ -925,7 +928,10 @@  int libxl__arch_hvm_unmap_gsi(libxl__gc *gc, uint32_t sbdf, uint32_t domid)
     int pirq = -1, gsi, r;
 
     gsi = xc_pcidev_get_gsi(CTX->xch, sbdf);
-    if (gsi < 0) {
+    if (gsi == -1 && errno == ENOENT) {
+        LOGD(DEBUG, domid, "xc_pcidev_get_gsi no gsi");
+        return 0;
+    } else if (gsi < 0) {
         return ERROR_FAIL;
     }