From: David Gibson <david@gibson.dropbear.id.au>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org
Subject: Re: [PATCH kernel] vfio/spapr_tce: Set window when adding additional groups to container
Date: Thu, 9 Feb 2017 12:05:29 +1100 [thread overview]
Message-ID: <20170209010529.GL17644@umbus.fritz.box> (raw)
In-Reply-To: <20170207123559.2b878948@t450s.home>
[-- Attachment #1: Type: text/plain, Size: 5406 bytes --]
On Tue, Feb 07, 2017 at 12:35:59PM -0700, Alex Williamson wrote:
> On Tue, 7 Feb 2017 17:26:57 +1100
> Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
>
> > If a container already has a group attached, attaching a new group
> > should just program already created IOMMU tables to the hardware via
> > the iommu_table_group_ops::set_window() callback.
> >
> > However 6f01cc692 "vfio/spapr: Add a helper to create default DMA window"
> > did not just simplify the code but also removed the set_window() calls
> > in the case of attaching groups to a container which already has tables
> > so it broke VFIO PCI hotplug.
> >
> > This reverts set_window() bits in tce_iommu_take_ownership_ddw().
> >
> > Fixes: 6f01cc692
>
> See Documentation/process/submitting-patches.rst for the expected
> format here, 12 char SHA-1 + --oneline summary.
>
> > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> > ---
> > drivers/vfio/vfio_iommu_spapr_tce.c | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> > index 7690e5bf3cf1..14c62a8495a2 100644
> > --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> > +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> > @@ -1245,6 +1245,8 @@ static void tce_iommu_release_ownership_ddw(struct tce_container *container,
> > static long tce_iommu_take_ownership_ddw(struct tce_container *container,
> > struct iommu_table_group *table_group)
> > {
> > + long i, ret = 0;
> > +
> > if (!table_group->ops->create_table || !table_group->ops->set_window ||
> > !table_group->ops->release_ownership) {
> > WARN_ON_ONCE(1);
> > @@ -1253,7 +1255,26 @@ static long tce_iommu_take_ownership_ddw(struct tce_container *container,
> >
> > table_group->ops->take_ownership(table_group);
> >
> > + /* Set all windows to the new group */
> > + for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
> > + struct iommu_table *tbl = container->tables[i];
>
> checkpatch wants a blank line here.
>
> > + if (!tbl)
> > + continue;
> > +
> > + ret = table_group->ops->set_window(table_group, i, tbl);
> > + if (ret)
> > + goto release_exit;
> > + }
> > +
> > return 0;
> > +
> > +release_exit:
> > + for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i)
> > + table_group->ops->unset_window(table_group, i);
> > +
> > + table_group->ops->release_ownership(table_group);
> > +
> > + return ret;
> > }
> >
> > static int tce_iommu_attach_group(void *iommu_data,
>
>
> I've fixed these as shown below. David, please review/ack as well and
> I'll send a pull for v4.10. Thanks,
>
> Alex
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
>
> commit c019167838156a2efcc60a15fa4207710bac6e82
> Author: Alexey Kardashevskiy <aik@ozlabs.ru>
> Date: Tue Feb 7 17:26:57 2017 +1100
>
> vfio/spapr_tce: Set window when adding additional groups to container
>
> If a container already has a group attached, attaching a new group
> should just program already created IOMMU tables to the hardware via
> the iommu_table_group_ops::set_window() callback.
>
> However commit 6f01cc692a16 ("vfio/spapr: Add a helper to create
> default DMA window") did not just simplify the code but also removed
> the set_window() calls in the case of attaching groups to a container
> which already has tables so it broke VFIO PCI hotplug.
>
> This reverts set_window() bits in tce_iommu_take_ownership_ddw().
>
> Fixes: 6f01cc692a16 ("vfio/spapr: Add a helper to create default DMA window")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
>
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 7690e5bf3cf1..59b3f62a2d64 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -1245,6 +1245,8 @@ static void tce_iommu_release_ownership_ddw(struct tce_container *container,
> static long tce_iommu_take_ownership_ddw(struct tce_container *container,
> struct iommu_table_group *table_group)
> {
> + long i, ret = 0;
> +
> if (!table_group->ops->create_table || !table_group->ops->set_window ||
> !table_group->ops->release_ownership) {
> WARN_ON_ONCE(1);
> @@ -1253,7 +1255,27 @@ static long tce_iommu_take_ownership_ddw(struct tce_container *container,
>
> table_group->ops->take_ownership(table_group);
>
> + /* Set all windows to the new group */
> + for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
> + struct iommu_table *tbl = container->tables[i];
> +
> + if (!tbl)
> + continue;
> +
> + ret = table_group->ops->set_window(table_group, i, tbl);
> + if (ret)
> + goto release_exit;
> + }
> +
> return 0;
> +
> +release_exit:
> + for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i)
> + table_group->ops->unset_window(table_group, i);
> +
> + table_group->ops->release_ownership(table_group);
> +
> + return ret;
> }
>
> static int tce_iommu_attach_group(void *iommu_data,
>
--
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: 819 bytes --]
prev parent reply other threads:[~2017-02-09 2:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 6:26 [PATCH kernel] vfio/spapr_tce: Set window when adding additional groups to container Alexey Kardashevskiy
2017-02-07 19:35 ` Alex Williamson
2017-02-09 1:05 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170209010529.GL17644@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).