diff mbox series

[v5,13/14] xen/arm: account IO handlers for emulated PCI MSI-X

Message ID 20211125110251.2877218-14-andr2000@gmail.com (mailing list archive)
State New, archived
Headers show
Series PCI devices passthrough on Arm, part 3 | expand

Commit Message

Oleksandr Andrushchenko Nov. 25, 2021, 11:02 a.m. UTC
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

At the moment, we always allocate an extra 16 slots for IO handlers
(see MAX_IO_HANDLER). So while adding IO trap handlers for the emulated
MSI-X registers we need to explicitly tell that we have additional IO
handlers, so those are accounted.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

---
Cc: Julien Grall <julien@xen.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>
---
This actually moved here from the part 2 of the prep work for PCI
passthrough on Arm as it seems to be the proper place for it.

New in v5
---
 xen/arch/arm/vpci.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Roger Pau Monné Jan. 13, 2022, 1:23 p.m. UTC | #1
On Thu, Nov 25, 2021 at 01:02:50PM +0200, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> 
> At the moment, we always allocate an extra 16 slots for IO handlers
> (see MAX_IO_HANDLER). So while adding IO trap handlers for the emulated
> MSI-X registers we need to explicitly tell that we have additional IO
> handlers, so those are accounted.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

LGTM, just one comment below. This will require an Ack from the Arm
guys.

> ---
> Cc: Julien Grall <julien@xen.org>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> ---
> This actually moved here from the part 2 of the prep work for PCI
> passthrough on Arm as it seems to be the proper place for it.
> 
> New in v5
> ---
>  xen/arch/arm/vpci.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
> index 3d134f42d07e..902f8491e030 100644
> --- a/xen/arch/arm/vpci.c
> +++ b/xen/arch/arm/vpci.c
> @@ -134,6 +134,8 @@ static int vpci_get_num_handlers_cb(struct domain *d,
>  
>  unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d)
>  {
> +    unsigned int count;
> +
>      if ( !has_vpci(d) )
>          return 0;
>  
> @@ -145,7 +147,18 @@ unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d)
>      }
>  
>      /* For a single emulated host bridge's configuration space. */
> -    return 1;
> +    count = 1;
> +
> +#ifdef CONFIG_HAS_PCI_MSI
> +    /*
> +     * There's a single MSI-X MMIO handler that deals with both PBA
> +     * and MSI-X tables per each PCI device being passed through.
> +     * Maximum number of emulated virtual devices is VPCI_MAX_VIRT_DEV.
> +     */
> +    count += VPCI_MAX_VIRT_DEV;

You could also use IS_ENABLED(CONFIG_HAS_PCI_MSI) since
VPCI_MAX_VIRT_DEV is defined unconditionally.

Thanks, Roger.
Oleksandr Andrushchenko Feb. 2, 2022, 2:08 p.m. UTC | #2
Hi, Roger!

On 13.01.22 15:23, Roger Pau Monné wrote:
> On Thu, Nov 25, 2021 at 01:02:50PM +0200, Oleksandr Andrushchenko wrote:
>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>>
>> At the moment, we always allocate an extra 16 slots for IO handlers
>> (see MAX_IO_HANDLER). So while adding IO trap handlers for the emulated
>> MSI-X registers we need to explicitly tell that we have additional IO
>> handlers, so those are accounted.
>>
>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> LGTM, just one comment below. This will require an Ack from the Arm
> guys.
>
>> ---
>> Cc: Julien Grall <julien@xen.org>
>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>> ---
>> This actually moved here from the part 2 of the prep work for PCI
>> passthrough on Arm as it seems to be the proper place for it.
>>
>> New in v5
>> ---
>>   xen/arch/arm/vpci.c | 15 ++++++++++++++-
>>   1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
>> index 3d134f42d07e..902f8491e030 100644
>> --- a/xen/arch/arm/vpci.c
>> +++ b/xen/arch/arm/vpci.c
>> @@ -134,6 +134,8 @@ static int vpci_get_num_handlers_cb(struct domain *d,
>>   
>>   unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d)
>>   {
>> +    unsigned int count;
>> +
>>       if ( !has_vpci(d) )
>>           return 0;
>>   
>> @@ -145,7 +147,18 @@ unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d)
>>       }
>>   
>>       /* For a single emulated host bridge's configuration space. */
>> -    return 1;
>> +    count = 1;
>> +
>> +#ifdef CONFIG_HAS_PCI_MSI
>> +    /*
>> +     * There's a single MSI-X MMIO handler that deals with both PBA
>> +     * and MSI-X tables per each PCI device being passed through.
>> +     * Maximum number of emulated virtual devices is VPCI_MAX_VIRT_DEV.
>> +     */
>> +    count += VPCI_MAX_VIRT_DEV;
> You could also use IS_ENABLED(CONFIG_HAS_PCI_MSI) since
> VPCI_MAX_VIRT_DEV is defined unconditionally.
Yes, will use, thank you
>
> Thanks, Roger.
Thank you,
Oleksandr
diff mbox series

Patch

diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
index 3d134f42d07e..902f8491e030 100644
--- a/xen/arch/arm/vpci.c
+++ b/xen/arch/arm/vpci.c
@@ -134,6 +134,8 @@  static int vpci_get_num_handlers_cb(struct domain *d,
 
 unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d)
 {
+    unsigned int count;
+
     if ( !has_vpci(d) )
         return 0;
 
@@ -145,7 +147,18 @@  unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d)
     }
 
     /* For a single emulated host bridge's configuration space. */
-    return 1;
+    count = 1;
+
+#ifdef CONFIG_HAS_PCI_MSI
+    /*
+     * There's a single MSI-X MMIO handler that deals with both PBA
+     * and MSI-X tables per each PCI device being passed through.
+     * Maximum number of emulated virtual devices is VPCI_MAX_VIRT_DEV.
+     */
+    count += VPCI_MAX_VIRT_DEV;
+#endif
+
+    return count;
 }
 
 /*