* [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1
@ 2017-12-12 5:16 Alexey Kardashevskiy
2017-12-15 6:01 ` David Gibson
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kardashevskiy @ 2017-12-12 5:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, David Gibson, Alex Williamson
The vfio_iommu_spapr_tce driver advertises kernel's support for
v1 and v2 IOMMU support, however it is not always possible to use
the requested IOMMU type. For example, a pseries host platform does not
support dynamic DMA windows so v2 cannot initialize and QEMU fails to
start.
This adds a fallback to the v1 IOMMU if v2 cannot be used.
Fixes: 318f67ce1371 "vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)"
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* updated commit log
---
hw/vfio/common.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7b2924c..cd81cc9 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1040,6 +1040,11 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
if (ret) {
+ container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
+ v2 = false;
+ ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
+ }
+ if (ret) {
error_setg_errno(errp, errno, "failed to set iommu for container");
ret = -errno;
goto free_container_exit;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1
2017-12-12 5:16 [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1 Alexey Kardashevskiy
@ 2017-12-15 6:01 ` David Gibson
2017-12-15 6:06 ` Alexey Kardashevskiy
0 siblings, 1 reply; 3+ messages in thread
From: David Gibson @ 2017-12-15 6:01 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: qemu-devel, qemu-ppc, Alex Williamson
[-- Attachment #1: Type: text/plain, Size: 1794 bytes --]
On Tue, Dec 12, 2017 at 04:16:19PM +1100, Alexey Kardashevskiy wrote:
> The vfio_iommu_spapr_tce driver advertises kernel's support for
> v1 and v2 IOMMU support, however it is not always possible to use
> the requested IOMMU type. For example, a pseries host platform does not
> support dynamic DMA windows so v2 cannot initialize and QEMU fails to
> start.
>
> This adds a fallback to the v1 IOMMU if v2 cannot be used.
>
> Fixes: 318f67ce1371 "vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Alex, will you take this through your tree, or should I take it
through mine?
> ---
> Changes:
> v2:
> * updated commit log
>
> ---
> hw/vfio/common.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 7b2924c..cd81cc9 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1040,6 +1040,11 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
> ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
> if (ret) {
> + container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
> + v2 = false;
> + ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
> + }
> + if (ret) {
> error_setg_errno(errp, errno, "failed to set iommu for container");
> ret = -errno;
> goto free_container_exit;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1
2017-12-15 6:01 ` David Gibson
@ 2017-12-15 6:06 ` Alexey Kardashevskiy
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2017-12-15 6:06 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-devel, qemu-ppc, Alex Williamson
[-- Attachment #1: Type: text/plain, Size: 1740 bytes --]
On 15/12/17 17:01, David Gibson wrote:
> On Tue, Dec 12, 2017 at 04:16:19PM +1100, Alexey Kardashevskiy wrote:
>> The vfio_iommu_spapr_tce driver advertises kernel's support for
>> v1 and v2 IOMMU support, however it is not always possible to use
>> the requested IOMMU type. For example, a pseries host platform does not
>> support dynamic DMA windows so v2 cannot initialize and QEMU fails to
>> start.
>>
>> This adds a fallback to the v1 IOMMU if v2 cannot be used.
>>
>> Fixes: 318f67ce1371 "vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)"
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> Alex, will you take this through your tree, or should I take it
> through mine?
It is already in upstream.
>
>> ---
>> Changes:
>> v2:
>> * updated commit log
>>
>> ---
>> hw/vfio/common.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>> index 7b2924c..cd81cc9 100644
>> --- a/hw/vfio/common.c
>> +++ b/hw/vfio/common.c
>> @@ -1040,6 +1040,11 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
>> v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
>> ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
>> if (ret) {
>> + container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
>> + v2 = false;
>> + ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
>> + }
>> + if (ret) {
>> error_setg_errno(errp, errno, "failed to set iommu for container");
>> ret = -errno;
>> goto free_container_exit;
>
--
Alexey
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-15 6:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-12 5:16 [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1 Alexey Kardashevskiy
2017-12-15 6:01 ` David Gibson
2017-12-15 6:06 ` Alexey Kardashevskiy
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).