From: Greg KH <gregkh@linuxfoundation.org>
To: Sachin Parekh <sachinparekh@google.com>
Cc: rafael@kernel.org, will@kernel.org, robin.murphy@arm.com,
lokeshvutla@google.com, linux-kernel@vger.kernel.org,
iommu@lists.linux.dev
Subject: Re: [RFC PATCH] driver core: platform: Call iommu_release_device in dma_cleanup
Date: Thu, 29 Aug 2024 15:52:24 +0200 [thread overview]
Message-ID: <2024082941-lagging-escapade-d9d8@gregkh> (raw)
In-Reply-To: <20240829120504.2976612-1-sachinparekh@google.com>
On Thu, Aug 29, 2024 at 12:05:04PM +0000, Sachin Parekh wrote:
> Installing a kernel module that has an iommu node in its
> device tree increments corresponding iommu kernel module
> reference count during driver_register.
> Removing the same kernel module doesn't decrement the
> iommu reference count resulting in error while
> removing the iommu kernel module
Please wrap kernel changelog text at 72 columns like your editor asked
you to :)
> $ modprobe arm-smmu-v3
> $ modprobe test_module
> $ modprobe -r test_module
> $ modprobe -r arm-smmu-v3
> modprobe: can't unload module arm_smmu_v3: Resource temporarily unavailable
Does this happen for any in-kernel driver?
Why has this not been noticed before?
>
> Cause:
> platform_driver_register
> ...
> -> platform_dma_configure
> ...
> -> iommu_probe_device (Increments reference count)
>
> platform_driver_unregister
> ...
> -> platform_dma_cleanup
> ...
> -> No corresponding iommu_release_device call
>
> Fix:
> Call iommu_release_device in platform_dma_cleanup to remove the
> iommu from the corresponding kernel module
>
> Signed-off-by: Sachin Parekh <sachinparekh@google.com>
What commit id does this fix?
> ---
> drivers/base/platform.c | 3 +++
> drivers/iommu/iommu.c | 3 +--
> include/linux/iommu.h | 1 +
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 4c3ee6521ba5..c8125325a5e9 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -1467,6 +1467,9 @@ static void platform_dma_cleanup(struct device *dev)
>
> if (!drv->driver_managed_dma)
> iommu_device_unuse_default_domain(dev);
> +
> + if (dev_of_node(dev))
> + iommu_release_device(dev);
Are you sure that all devices that pass this should have this call made?
How well was this tested on different systems?
thanks,
greg k-h
next prev parent reply other threads:[~2024-08-29 13:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 12:05 [RFC PATCH] driver core: platform: Call iommu_release_device in dma_cleanup Sachin Parekh
2024-08-29 13:52 ` Greg KH [this message]
2024-09-02 6:44 ` Sachin Parekh
2024-08-29 13:58 ` Robin Murphy
2024-09-02 6:17 ` Sachin Parekh
2024-09-01 13:28 ` kernel test robot
2024-09-01 13:49 ` kernel test robot
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=2024082941-lagging-escapade-d9d8@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lokeshvutla@google.com \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sachinparekh@google.com \
--cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.