diff mbox series

[1/2] s390x/pci: bypass vfio DMA counting when using cdev

Message ID 20231109225302.401344-2-mjrosato@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x/pci: small set of fixes | expand

Commit Message

Matthew Rosato Nov. 9, 2023, 10:53 p.m. UTC
The current code assumes that there is always a vfio group, but
that's no longer guaranteed with the iommufd backend when using
cdev.  In this case, we don't need to track the vfio dma limit
anyway.

Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
 hw/s390x/s390-pci-vfio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Nov. 10, 2023, 5:21 a.m. UTC | #1
On 9/11/23 23:53, Matthew Rosato wrote:
> The current code assumes that there is always a vfio group, but
> that's no longer guaranteed with the iommufd backend when using
> cdev.  In this case, we don't need to track the vfio dma limit
> anyway.
> 
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
>   hw/s390x/s390-pci-vfio.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
> index 59a2e03873..7218583883 100644
> --- a/hw/s390x/s390-pci-vfio.c
> +++ b/hw/s390x/s390-pci-vfio.c
> @@ -66,7 +66,11 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
>   
>       assert(vpdev);
>   

Matter of taste, simpler as:

        if (!vpdev->vbasedev.group) {
            return NULL;
        }

> -    id = vpdev->vbasedev.group->container->fd;

and this line isn't changed.

> +    if (vpdev->vbasedev.group) {
> +        id = vpdev->vbasedev.group->container->fd;
> +    } else {
> +        return NULL;
> +    }
>   
>       if (!s390_pci_update_dma_avail(id, &avail)) {
>           return NULL;
Philippe Mathieu-Daudé Nov. 10, 2023, 5:22 a.m. UTC | #2
[Sent too fast by inadvertence...]

Hi Matthew,

On 10/11/23 06:21, Philippe Mathieu-Daudé wrote:
> On 9/11/23 23:53, Matthew Rosato wrote:
>> The current code assumes that there is always a vfio group, but
>> that's no longer guaranteed with the iommufd backend when using
>> cdev.  In this case, we don't need to track the vfio dma limit
>> anyway.
>>
>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
>> ---
>>   hw/s390x/s390-pci-vfio.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
>> index 59a2e03873..7218583883 100644
>> --- a/hw/s390x/s390-pci-vfio.c
>> +++ b/hw/s390x/s390-pci-vfio.c
>> @@ -66,7 +66,11 @@ S390PCIDMACount 
>> *s390_pci_start_dma_count(S390pciState *s,
>>       assert(vpdev);
> 
> Matter of taste, simpler as:
> 
>         if (!vpdev->vbasedev.group) {
>             return NULL;
>         }
> 
>> -    id = vpdev->vbasedev.group->container->fd;
> 
> and this line isn't changed.
> 
>> +    if (vpdev->vbasedev.group) {
>> +        id = vpdev->vbasedev.group->container->fd;
>> +    } else {
>> +        return NULL;
>> +    }
>>       if (!s390_pci_update_dma_avail(id, &avail)) {
>>           return NULL;
> 

Regards,

Phil :)
diff mbox series

Patch

diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
index 59a2e03873..7218583883 100644
--- a/hw/s390x/s390-pci-vfio.c
+++ b/hw/s390x/s390-pci-vfio.c
@@ -66,7 +66,11 @@  S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
 
     assert(vpdev);
 
-    id = vpdev->vbasedev.group->container->fd;
+    if (vpdev->vbasedev.group) {
+        id = vpdev->vbasedev.group->container->fd;
+    } else {
+        return NULL;
+    }
 
     if (!s390_pci_update_dma_avail(id, &avail)) {
         return NULL;