Hi Benjmain, Jason,
Le lundi 25 août 2025 à 14:05 -0300, Jason Gunthorpe a écrit :
On Mon, Aug 25, 2025 at 05:34:43PM +0200, Benjamin Gaignard wrote:
quoted
diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 81328c63b796..a28a181013b9 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
#ifndef HANTRO_H_
#define HANTRO_H_
+#include <linux/dma-map-ops.h>
+#include <linux/iommu.h>
+#include <linux/iommu-dma.h>
This is an internal header it should not be included in drivers.
quoted
+static void rockchip_vpu981_av1_restore_iommu(struct hantro_ctx *ctx)
+{
+ if (ctx->iommu_domain) {
+ iommu_attach_device(ctx->iommu_domain, ctx->dev->v4l2_dev.dev);
+ iommu_detach_device(ctx->iommu_domain, ctx->dev->v4l2_dev.dev);
+ }
+}
What is this supposed to do? Put it back to the default domain? Who
changed it away from the default domain?
If you rename the iommu_domain into empty_domain it adds a bit of sense. When
you attach another domain (this one is empty, but it does not matter) and detach
it, the default domain get restored. That effectively forces the reprogramming
(in the VSI case flushing) of the iommu configuration.
Did some other driver change the attached domain (if so that's wild
and wrong)? The commit message hints at that but it should be
explained alot more.
This just seems wrong and goofy. Driver shouldn't be changing their
iommu domains if they are using the default domain at all. We now have
APIs to allow you to allocate wide chunks of IOVA space and manage
them directly. Maybe these 'multiple stream's should be doing that
instead of mucking with iommu domains?
This is seeking inspiration of what we do in rkvdec [0], the iommu-dma.h should
not be needed.
Jason, the point is that the iommu and the VPU are not separate devices, which
comes with side effects. On RKVDec side, the iommu configuration get resets
whenever a decoding error leads to a VPU "self reset". I can't remember who from
the iommu subsystem suggested that, but the empty domain method was agreed to be
the least invasive way to workaround that issue. I believe Detlev tried multiple
time to add APIs for that before the discussion lead to this path.
Benjamin, please improve the naming, comment and description, I agree with Jason
its not completely clear. I'm also surprised that you do that every frame, seems
excessive.
regards,
Nicolas
[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ff8c5622f9f7c644e995d013af320b59e4d61b93