* [PATCH] iommu: Clear iommu-dma ops on cleanup
@ 2025-04-10 11:23 Robin Murphy
2025-04-11 2:04 ` Baolu Lu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Robin Murphy @ 2025-04-10 11:23 UTC (permalink / raw)
To: joro, will; +Cc: iommu, linux-kernel, Chen-Yu Tsai
If iommu_device_register() encounters an error, it can end up tearing
down already-configured groups and default domains, however this
currently still leaves devices hooked up to iommu-dma (and even
historically the behaviour in this area was at best inconsistent across
architectures/drivers...) Although in the case that an IOMMU is present
whose driver has failed to probe, users cannot necessarily expect DMA to
work anyway, it's still arguable that we should do our best to put
things back as if the IOMMU driver was never there at all, and certainly
the potential for crashing in iommu-dma itself is undesirable. Make sure
we clean up the dev->dma_iommu flag along with everything else.
Reported-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
drivers/iommu/iommu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index c8033ca66377..095f9e9afe8c 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -538,6 +538,9 @@ static void iommu_deinit_device(struct device *dev)
dev->iommu_group = NULL;
module_put(ops->owner);
dev_iommu_free(dev);
+#ifdef CONFIG_IOMMU_DMA
+ dev->dma_iommu = false;
+#endif
}
static struct iommu_domain *pasid_array_entry_to_domain(void *entry)
--
2.39.2.101.g768bb238c484.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: Clear iommu-dma ops on cleanup
2025-04-10 11:23 [PATCH] iommu: Clear iommu-dma ops on cleanup Robin Murphy
@ 2025-04-11 2:04 ` Baolu Lu
2025-04-11 3:55 ` Chen-Yu Tsai
2025-04-11 7:16 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Baolu Lu @ 2025-04-11 2:04 UTC (permalink / raw)
To: Robin Murphy, joro, will; +Cc: iommu, linux-kernel, Chen-Yu Tsai
On 4/10/25 19:23, Robin Murphy wrote:
> If iommu_device_register() encounters an error, it can end up tearing
> down already-configured groups and default domains, however this
> currently still leaves devices hooked up to iommu-dma (and even
> historically the behaviour in this area was at best inconsistent across
> architectures/drivers...) Although in the case that an IOMMU is present
> whose driver has failed to probe, users cannot necessarily expect DMA to
> work anyway, it's still arguable that we should do our best to put
> things back as if the IOMMU driver was never there at all, and certainly
> the potential for crashing in iommu-dma itself is undesirable. Make sure
> we clean up the dev->dma_iommu flag along with everything else.
>
> Reported-by: Chen-Yu Tsai<wenst@chromium.org>
> Signed-off-by: Robin Murphy<robin.murphy@arm.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: Clear iommu-dma ops on cleanup
2025-04-10 11:23 [PATCH] iommu: Clear iommu-dma ops on cleanup Robin Murphy
2025-04-11 2:04 ` Baolu Lu
@ 2025-04-11 3:55 ` Chen-Yu Tsai
2025-04-11 7:16 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2025-04-11 3:55 UTC (permalink / raw)
To: Robin Murphy; +Cc: joro, will, iommu, linux-kernel
On Thu, Apr 10, 2025 at 7:24 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> If iommu_device_register() encounters an error, it can end up tearing
> down already-configured groups and default domains, however this
> currently still leaves devices hooked up to iommu-dma (and even
> historically the behaviour in this area was at best inconsistent across
> architectures/drivers...) Although in the case that an IOMMU is present
> whose driver has failed to probe, users cannot necessarily expect DMA to
> work anyway, it's still arguable that we should do our best to put
> things back as if the IOMMU driver was never there at all, and certainly
> the potential for crashing in iommu-dma itself is undesirable. Make sure
> we clean up the dev->dma_iommu flag along with everything else.
>
> Reported-by: Chen-Yu Tsai <wenst@chromium.org>
Closes: https://lore.kernel.org/all/CAGXv+5HJpTYmQ2h-GD7GjyeYT7bL9EBCvu0mz5LgpzJZtzfW0w@mail.gmail.com/
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/iommu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index c8033ca66377..095f9e9afe8c 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -538,6 +538,9 @@ static void iommu_deinit_device(struct device *dev)
> dev->iommu_group = NULL;
> module_put(ops->owner);
> dev_iommu_free(dev);
> +#ifdef CONFIG_IOMMU_DMA
> + dev->dma_iommu = false;
> +#endif
> }
>
> static struct iommu_domain *pasid_array_entry_to_domain(void *entry)
> --
> 2.39.2.101.g768bb238c484.dirty
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: Clear iommu-dma ops on cleanup
2025-04-10 11:23 [PATCH] iommu: Clear iommu-dma ops on cleanup Robin Murphy
2025-04-11 2:04 ` Baolu Lu
2025-04-11 3:55 ` Chen-Yu Tsai
@ 2025-04-11 7:16 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2025-04-11 7:16 UTC (permalink / raw)
To: Robin Murphy; +Cc: will, iommu, linux-kernel, Chen-Yu Tsai
On Thu, Apr 10, 2025 at 12:23:48PM +0100, Robin Murphy wrote:
> Reported-by: Chen-Yu Tsai <wenst@chromium.org>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/iommu.c | 3 +++
> 1 file changed, 3 insertions(+)
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-11 7:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 11:23 [PATCH] iommu: Clear iommu-dma ops on cleanup Robin Murphy
2025-04-11 2:04 ` Baolu Lu
2025-04-11 3:55 ` Chen-Yu Tsai
2025-04-11 7:16 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox