Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1265516
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC V2] iommu: correct group reference count |
| Date | 2015-11-09 11:20 +0100 |
| Message-ID | <qsRIl-55g-5@gated-at.bofh.it> (permalink) |
| References | <qsNY6-2He-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Nov 09, 2015 at 02:13:28PM +0800, Peng Fan wrote:
> The basic flow for iommu_group_for_dev is:
> iommu_group_get_for_dev
> |-> iommu_group_get : increase reference count by 1.
> return group;
> |-> ops->device_group : Init/increase reference count to/by 1.
> iommu_group_add_device : Increase reference count by 1.
> return group;
>
> We can see that ops->device_group and iommu_group_add_device will together
> increase the iommu group reference count by 2. Actually we only need 1,
> but not 2. So we need add iommu_group_put after iommu_group_add_device
> to make sure iommu_group_get_for_dev only increase reference count by 1.
>
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>
> V1 thread: https://lkml.org/lkml/2015/11/3/304
> Changes V2:
> I did not see the update about device_group when I worked out V1. So
> redo the patch and refine commit msg and rebased to latest linus'
> linux master tree.
>
> drivers/iommu/iommu.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index abae363..9c1971b 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -852,10 +852,10 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
> }
>
> ret = iommu_group_add_device(group, dev);
> - if (ret) {
> - iommu_group_put(group);
> + iommu_group_put(group);
> +
> + if (ret)
> return ERR_PTR(ret);
> - }
Hmm, I don't think this is correct either:
(1) It doesn't help the arm-smmu driver (which deals with platform
devices too)
(2) It breaks IOMMU drivers that currently have the explicit put already
(e.g. amd-iommu.c:init_iommu_group)
The easiest way for you to proceed is to extend your original patch so
that it also adds an iommu_group_put to the arm-smmu-v3 driver after
a successful iommu_group_get_for_dev.
Will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC V2] iommu: correct group reference count Peng Fan <van.freenix@gmail.com> - 2015-11-09 07:20 +0100
Re: [RFC V2] iommu: correct group reference count Will Deacon <will.deacon@arm.com> - 2015-11-09 11:20 +0100
Re: [RFC V2] iommu: correct group reference count Peng Fan <van.freenix@gmail.com> - 2015-11-09 14:40 +0100
Re: [RFC V2] iommu: correct group reference count Alex Williamson <alex.williamson@redhat.com> - 2015-11-09 16:30 +0100
Re: [RFC V2] iommu: correct group reference count Peng Fan <van.freenix@gmail.com> - 2015-11-10 02:40 +0100
csiph-web