* [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
@ 2020-05-27 15:55 Philippe Mathieu-Daudé
2020-05-27 16:04 ` Cornelia Huck
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-27 15:55 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Cornelia Huck, Peter Xu, Eric Auger,
Alex Williamson, Philippe Mathieu-Daudé
One might want to check which IOMMU version the host kernel
provide. Add a trace event to see in which mode we opened
our container.
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v2: Only display string description (Eric)
Supersedes: <20200526173542.28710-1-philmd@redhat.com>
---
hw/vfio/common.c | 19 ++++++++++++++-----
hw/vfio/trace-events | 1 +
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 0b3593b3c0..f24450472e 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1157,15 +1157,24 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
static int vfio_get_iommu_type(VFIOContainer *container,
Error **errp)
{
- int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
- VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
+ static const struct {
+ int type;
+ const char *name;
+ } iommu[] = {
+ {VFIO_TYPE1v2_IOMMU, "Type1 (v2)"},
+ {VFIO_TYPE1_IOMMU, "Type1 (v1)"},
+ {VFIO_SPAPR_TCE_v2_IOMMU, "sPAPR TCE (v2)"},
+ {VFIO_SPAPR_TCE_IOMMU, "sPAPR TCE (v1)"}
+ };
int i;
- for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
- if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
- return iommu_types[i];
+ for (i = 0; i < ARRAY_SIZE(iommu); i++) {
+ if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu[i].type)) {
+ trace_vfio_get_iommu_type(iommu[i].name);
+ return iommu[i].type;
}
}
+ trace_vfio_get_iommu_type("Not available or not supported");
error_setg(errp, "No available IOMMU models");
return -EINVAL;
}
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
index b1ef55a33f..d3f1e48618 100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -115,6 +115,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
vfio_dma_unmap_overflow_workaround(void) ""
+vfio_get_iommu_type(const char *type) "IOMMU type: %s"
# platform.c
vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
--
2.21.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
2020-05-27 15:55 [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened Philippe Mathieu-Daudé
@ 2020-05-27 16:04 ` Cornelia Huck
2020-05-29 7:33 ` Auger Eric
2020-06-09 17:23 ` Laurent Vivier
2 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2020-05-27 16:04 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-trivial, Eric Auger, Alex Williamson, qemu-devel, Peter Xu
On Wed, 27 May 2020 17:55:55 +0200
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> One might want to check which IOMMU version the host kernel
> provide. Add a trace event to see in which mode we opened
> our container.
>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v2: Only display string description (Eric)
Also fine with me.
>
> Supersedes: <20200526173542.28710-1-philmd@redhat.com>
> ---
> hw/vfio/common.c | 19 ++++++++++++++-----
> hw/vfio/trace-events | 1 +
> 2 files changed, 15 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
2020-05-27 15:55 [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened Philippe Mathieu-Daudé
2020-05-27 16:04 ` Cornelia Huck
@ 2020-05-29 7:33 ` Auger Eric
2020-06-09 17:23 ` Laurent Vivier
2 siblings, 0 replies; 7+ messages in thread
From: Auger Eric @ 2020-05-29 7:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-trivial, Alex Williamson, Cornelia Huck, Peter Xu
Hi Philippe,
On 5/27/20 5:55 PM, Philippe Mathieu-Daudé wrote:
> One might want to check which IOMMU version the host kernel
> provide. Add a trace event to see in which mode we opened
> our container.
>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> v2: Only display string description (Eric)
>
> Supersedes: <20200526173542.28710-1-philmd@redhat.com>
> ---
> hw/vfio/common.c | 19 ++++++++++++++-----
> hw/vfio/trace-events | 1 +
> 2 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 0b3593b3c0..f24450472e 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1157,15 +1157,24 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
> static int vfio_get_iommu_type(VFIOContainer *container,
> Error **errp)
> {
> - int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
> - VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
> + static const struct {
> + int type;
> + const char *name;
> + } iommu[] = {
> + {VFIO_TYPE1v2_IOMMU, "Type1 (v2)"},
> + {VFIO_TYPE1_IOMMU, "Type1 (v1)"},
> + {VFIO_SPAPR_TCE_v2_IOMMU, "sPAPR TCE (v2)"},
> + {VFIO_SPAPR_TCE_IOMMU, "sPAPR TCE (v1)"}
> + };
> int i;
>
> - for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
> - if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
> - return iommu_types[i];
> + for (i = 0; i < ARRAY_SIZE(iommu); i++) {
> + if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu[i].type)) {
> + trace_vfio_get_iommu_type(iommu[i].name);
> + return iommu[i].type;
> }
> }
> + trace_vfio_get_iommu_type("Not available or not supported");
> error_setg(errp, "No available IOMMU models");
> return -EINVAL;
> }
> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
> index b1ef55a33f..d3f1e48618 100644
> --- a/hw/vfio/trace-events
> +++ b/hw/vfio/trace-events
> @@ -115,6 +115,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
> vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
> vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
> vfio_dma_unmap_overflow_workaround(void) ""
> +vfio_get_iommu_type(const char *type) "IOMMU type: %s"
>
> # platform.c
> vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
2020-05-27 15:55 [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened Philippe Mathieu-Daudé
2020-05-27 16:04 ` Cornelia Huck
2020-05-29 7:33 ` Auger Eric
@ 2020-06-09 17:23 ` Laurent Vivier
2020-06-09 17:33 ` Alex Williamson
2 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2020-06-09 17:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-trivial, Eric Auger, Alex Williamson, Cornelia Huck, Peter Xu
Le 27/05/2020 à 17:55, Philippe Mathieu-Daudé a écrit :
> One might want to check which IOMMU version the host kernel
> provide. Add a trace event to see in which mode we opened
> our container.
>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v2: Only display string description (Eric)
>
> Supersedes: <20200526173542.28710-1-philmd@redhat.com>
> ---
> hw/vfio/common.c | 19 ++++++++++++++-----
> hw/vfio/trace-events | 1 +
> 2 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 0b3593b3c0..f24450472e 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1157,15 +1157,24 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
> static int vfio_get_iommu_type(VFIOContainer *container,
> Error **errp)
> {
> - int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
> - VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
> + static const struct {
> + int type;
> + const char *name;
> + } iommu[] = {
> + {VFIO_TYPE1v2_IOMMU, "Type1 (v2)"},
> + {VFIO_TYPE1_IOMMU, "Type1 (v1)"},
> + {VFIO_SPAPR_TCE_v2_IOMMU, "sPAPR TCE (v2)"},
> + {VFIO_SPAPR_TCE_IOMMU, "sPAPR TCE (v1)"}
> + };
> int i;
>
> - for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
> - if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
> - return iommu_types[i];
> + for (i = 0; i < ARRAY_SIZE(iommu); i++) {
> + if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu[i].type)) {
> + trace_vfio_get_iommu_type(iommu[i].name);
> + return iommu[i].type;
> }
> }
> + trace_vfio_get_iommu_type("Not available or not supported");
> error_setg(errp, "No available IOMMU models");
> return -EINVAL;
> }
> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
> index b1ef55a33f..d3f1e48618 100644
> --- a/hw/vfio/trace-events
> +++ b/hw/vfio/trace-events
> @@ -115,6 +115,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
> vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
> vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
> vfio_dma_unmap_overflow_workaround(void) ""
> +vfio_get_iommu_type(const char *type) "IOMMU type: %s"
>
> # platform.c
> vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
>
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
2020-06-09 17:23 ` Laurent Vivier
@ 2020-06-09 17:33 ` Alex Williamson
2020-06-09 17:34 ` Philippe Mathieu-Daudé
2020-06-09 18:00 ` Laurent Vivier
0 siblings, 2 replies; 7+ messages in thread
From: Alex Williamson @ 2020-06-09 17:33 UTC (permalink / raw)
To: Laurent Vivier
Cc: qemu-trivial, Cornelia Huck, qemu-devel, Peter Xu, Eric Auger,
Philippe Mathieu-Daudé
On Tue, 9 Jun 2020 19:23:32 +0200
Laurent Vivier <laurent@vivier.eu> wrote:
> Le 27/05/2020 à 17:55, Philippe Mathieu-Daudé a écrit :
> > One might want to check which IOMMU version the host kernel
> > provide. Add a trace event to see in which mode we opened
> > our container.
> >
> > Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > ---
> > v2: Only display string description (Eric)
> >
> > Supersedes: <20200526173542.28710-1-philmd@redhat.com>
> > ---
> > hw/vfio/common.c | 19 ++++++++++++++-----
> > hw/vfio/trace-events | 1 +
> > 2 files changed, 15 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index 0b3593b3c0..f24450472e 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -1157,15 +1157,24 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
> > static int vfio_get_iommu_type(VFIOContainer *container,
> > Error **errp)
> > {
> > - int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
> > - VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
> > + static const struct {
> > + int type;
> > + const char *name;
> > + } iommu[] = {
> > + {VFIO_TYPE1v2_IOMMU, "Type1 (v2)"},
> > + {VFIO_TYPE1_IOMMU, "Type1 (v1)"},
> > + {VFIO_SPAPR_TCE_v2_IOMMU, "sPAPR TCE (v2)"},
> > + {VFIO_SPAPR_TCE_IOMMU, "sPAPR TCE (v1)"}
> > + };
> > int i;
> >
> > - for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
> > - if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
> > - return iommu_types[i];
> > + for (i = 0; i < ARRAY_SIZE(iommu); i++) {
> > + if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu[i].type)) {
> > + trace_vfio_get_iommu_type(iommu[i].name);
> > + return iommu[i].type;
> > }
> > }
> > + trace_vfio_get_iommu_type("Not available or not supported");
> > error_setg(errp, "No available IOMMU models");
> > return -EINVAL;
> > }
> > diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
> > index b1ef55a33f..d3f1e48618 100644
> > --- a/hw/vfio/trace-events
> > +++ b/hw/vfio/trace-events
> > @@ -115,6 +115,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
> > vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
> > vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
> > vfio_dma_unmap_overflow_workaround(void) ""
> > +vfio_get_iommu_type(const char *type) "IOMMU type: %s"
> >
> > # platform.c
> > vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
> >
>
> Applied to my trivial-patches branch.
I was not actually a fan of this patch:
https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08144.html
I don't think the convenience to the trace user to avoid looking up the
type string in the header is worth the bloat to the non-trace user to
declare these strings in the code. Thanks,
Alex
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
2020-06-09 17:33 ` Alex Williamson
@ 2020-06-09 17:34 ` Philippe Mathieu-Daudé
2020-06-09 18:00 ` Laurent Vivier
1 sibling, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-06-09 17:34 UTC (permalink / raw)
To: Alex Williamson, Laurent Vivier
Cc: qemu-trivial, Eric Auger, Cornelia Huck, qemu-devel, Peter Xu
On 6/9/20 7:33 PM, Alex Williamson wrote:
> On Tue, 9 Jun 2020 19:23:32 +0200
> Laurent Vivier <laurent@vivier.eu> wrote:
>
>> Le 27/05/2020 à 17:55, Philippe Mathieu-Daudé a écrit :
>>> One might want to check which IOMMU version the host kernel
>>> provide. Add a trace event to see in which mode we opened
>>> our container.
>>>
>>> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>> v2: Only display string description (Eric)
>>>
>>> Supersedes: <20200526173542.28710-1-philmd@redhat.com>
>>> ---
>>> hw/vfio/common.c | 19 ++++++++++++++-----
>>> hw/vfio/trace-events | 1 +
>>> 2 files changed, 15 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>>> index 0b3593b3c0..f24450472e 100644
>>> --- a/hw/vfio/common.c
>>> +++ b/hw/vfio/common.c
>>> @@ -1157,15 +1157,24 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
>>> static int vfio_get_iommu_type(VFIOContainer *container,
>>> Error **errp)
>>> {
>>> - int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
>>> - VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
>>> + static const struct {
>>> + int type;
>>> + const char *name;
>>> + } iommu[] = {
>>> + {VFIO_TYPE1v2_IOMMU, "Type1 (v2)"},
>>> + {VFIO_TYPE1_IOMMU, "Type1 (v1)"},
>>> + {VFIO_SPAPR_TCE_v2_IOMMU, "sPAPR TCE (v2)"},
>>> + {VFIO_SPAPR_TCE_IOMMU, "sPAPR TCE (v1)"}
>>> + };
>>> int i;
>>>
>>> - for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
>>> - if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
>>> - return iommu_types[i];
>>> + for (i = 0; i < ARRAY_SIZE(iommu); i++) {
>>> + if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu[i].type)) {
>>> + trace_vfio_get_iommu_type(iommu[i].name);
>>> + return iommu[i].type;
>>> }
>>> }
>>> + trace_vfio_get_iommu_type("Not available or not supported");
>>> error_setg(errp, "No available IOMMU models");
>>> return -EINVAL;
>>> }
>>> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
>>> index b1ef55a33f..d3f1e48618 100644
>>> --- a/hw/vfio/trace-events
>>> +++ b/hw/vfio/trace-events
>>> @@ -115,6 +115,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
>>> vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
>>> vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
>>> vfio_dma_unmap_overflow_workaround(void) ""
>>> +vfio_get_iommu_type(const char *type) "IOMMU type: %s"
>>>
>>> # platform.c
>>> vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
>>>
>>
>> Applied to my trivial-patches branch.
>
> I was not actually a fan of this patch:
>
> https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08144.html
>
> I don't think the convenience to the trace user to avoid looking up the
> type string in the header is worth the bloat to the non-trace user to
> declare these strings in the code. Thanks,
Yep, planned to send simpler v3 but re-prioritize stuffs...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened
2020-06-09 17:33 ` Alex Williamson
2020-06-09 17:34 ` Philippe Mathieu-Daudé
@ 2020-06-09 18:00 ` Laurent Vivier
1 sibling, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2020-06-09 18:00 UTC (permalink / raw)
To: Alex Williamson
Cc: qemu-trivial, Cornelia Huck, qemu-devel, Peter Xu, Eric Auger,
Philippe Mathieu-Daudé
Le 09/06/2020 à 19:33, Alex Williamson a écrit :
> On Tue, 9 Jun 2020 19:23:32 +0200
> Laurent Vivier <laurent@vivier.eu> wrote:
>
>> Le 27/05/2020 à 17:55, Philippe Mathieu-Daudé a écrit :
>>> One might want to check which IOMMU version the host kernel
>>> provide. Add a trace event to see in which mode we opened
>>> our container.
>>>
>>> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>> v2: Only display string description (Eric)
>>>
>>> Supersedes: <20200526173542.28710-1-philmd@redhat.com>
>>> ---
>>> hw/vfio/common.c | 19 ++++++++++++++-----
>>> hw/vfio/trace-events | 1 +
>>> 2 files changed, 15 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>>> index 0b3593b3c0..f24450472e 100644
>>> --- a/hw/vfio/common.c
>>> +++ b/hw/vfio/common.c
>>> @@ -1157,15 +1157,24 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
>>> static int vfio_get_iommu_type(VFIOContainer *container,
>>> Error **errp)
>>> {
>>> - int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
>>> - VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
>>> + static const struct {
>>> + int type;
>>> + const char *name;
>>> + } iommu[] = {
>>> + {VFIO_TYPE1v2_IOMMU, "Type1 (v2)"},
>>> + {VFIO_TYPE1_IOMMU, "Type1 (v1)"},
>>> + {VFIO_SPAPR_TCE_v2_IOMMU, "sPAPR TCE (v2)"},
>>> + {VFIO_SPAPR_TCE_IOMMU, "sPAPR TCE (v1)"}
>>> + };
>>> int i;
>>>
>>> - for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
>>> - if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
>>> - return iommu_types[i];
>>> + for (i = 0; i < ARRAY_SIZE(iommu); i++) {
>>> + if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu[i].type)) {
>>> + trace_vfio_get_iommu_type(iommu[i].name);
>>> + return iommu[i].type;
>>> }
>>> }
>>> + trace_vfio_get_iommu_type("Not available or not supported");
>>> error_setg(errp, "No available IOMMU models");
>>> return -EINVAL;
>>> }
>>> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
>>> index b1ef55a33f..d3f1e48618 100644
>>> --- a/hw/vfio/trace-events
>>> +++ b/hw/vfio/trace-events
>>> @@ -115,6 +115,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
>>> vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
>>> vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8"
>>> vfio_dma_unmap_overflow_workaround(void) ""
>>> +vfio_get_iommu_type(const char *type) "IOMMU type: %s"
>>>
>>> # platform.c
>>> vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
>>>
>>
>> Applied to my trivial-patches branch.
>
> I was not actually a fan of this patch:
>
> https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg08144.html
I missed it as v1 was not sent to qemu-trivial.
> I don't think the convenience to the trace user to avoid looking up the
> type string in the header is worth the bloat to the non-trace user to
> declare these strings in the code. Thanks,
>
Understood. Removed.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-06-09 18:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 15:55 [PATCH v2] hw/vfio/common: Trace in which mode an IOMMU is opened Philippe Mathieu-Daudé
2020-05-27 16:04 ` Cornelia Huck
2020-05-29 7:33 ` Auger Eric
2020-06-09 17:23 ` Laurent Vivier
2020-06-09 17:33 ` Alex Williamson
2020-06-09 17:34 ` Philippe Mathieu-Daudé
2020-06-09 18:00 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).