* [PATCH 1/4] accel/rocket: Fix the IOMMU domain leak in rocket_ioctl_create_bo
2026-08-14 2:24 [PATCH 0/4] accel/rocket: resource leak and stability improvements Chaoyi Chen
@ 2026-08-14 2:24 ` Chaoyi Chen
2026-11-17 21:45 ` Daniel Drake
2026-08-14 2:24 ` [PATCH 2/4] accel/rocket: Fix the panic in rocket_iommu_domain_put when the domain is NULL Chaoyi Chen
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Chaoyi Chen @ 2026-08-14 2:24 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
When rocket_ioctl_create_bo fails, rocket_iommu_domain_put should be
called to avoid an IOMMU domain leak.
Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
---
drivers/accel/rocket/rocket_gem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index a5fffa51ff35..438694ba567b 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -127,6 +127,8 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
mutex_unlock(&rocket_priv->mm_lock);
err:
+ rocket_iommu_domain_put(rkt_obj->domain);
+ rkt_obj->domain = NULL;
drm_gem_shmem_object_free(gem_obj);
return ret;
--
2.53.0
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 1/4] accel/rocket: Fix the IOMMU domain leak in rocket_ioctl_create_bo
2026-08-14 2:24 ` [PATCH 1/4] accel/rocket: Fix the IOMMU domain leak in rocket_ioctl_create_bo Chaoyi Chen
@ 2026-11-17 21:45 ` Daniel Drake
0 siblings, 0 replies; 11+ messages in thread
From: Daniel Drake @ 2026-11-17 21:45 UTC (permalink / raw)
To: Chaoyi Chen, Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
On 14/08/2026 03:24, Chaoyi Chen wrote:
> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>
> When rocket_ioctl_create_bo fails, rocket_iommu_domain_put should be
> called to avoid an IOMMU domain leak.
>
> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
> Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
Reviewed-by: Daniel Drake <ddrake@baylibre.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/4] accel/rocket: Fix the panic in rocket_iommu_domain_put when the domain is NULL
2026-08-14 2:24 [PATCH 0/4] accel/rocket: resource leak and stability improvements Chaoyi Chen
2026-08-14 2:24 ` [PATCH 1/4] accel/rocket: Fix the IOMMU domain leak in rocket_ioctl_create_bo Chaoyi Chen
@ 2026-08-14 2:24 ` Chaoyi Chen
2026-11-17 21:47 ` Daniel Drake
2026-08-14 2:24 ` [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq Chaoyi Chen
2026-08-14 2:24 ` [PATCH 4/4] MAINTAINERS: accel/rocket: Add rockchip mail list for rocket Chaoyi Chen
3 siblings, 1 reply; 11+ messages in thread
From: Chaoyi Chen @ 2026-08-14 2:24 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
In rocket_ioctl_submit_job(), since the domain is assigned last, an
error before that triggers rocket_job_put() -> rocket_job_cleanup()
-> rocket_iommu_domain_put() with the domain still NULL,
causing a panic in that function.
Therefore, the input parameters should be validated.
Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
---
drivers/accel/rocket/rocket_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
index 8bbbce594883..77cd2ecce001 100644
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -65,7 +65,8 @@ rocket_iommu_domain_get(struct rocket_file_priv *rocket_priv)
void
rocket_iommu_domain_put(struct rocket_iommu_domain *domain)
{
- kref_put(&domain->kref, rocket_iommu_domain_destroy);
+ if (domain)
+ kref_put(&domain->kref, rocket_iommu_domain_destroy);
}
static int
--
2.53.0
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 2/4] accel/rocket: Fix the panic in rocket_iommu_domain_put when the domain is NULL
2026-08-14 2:24 ` [PATCH 2/4] accel/rocket: Fix the panic in rocket_iommu_domain_put when the domain is NULL Chaoyi Chen
@ 2026-11-17 21:47 ` Daniel Drake
0 siblings, 0 replies; 11+ messages in thread
From: Daniel Drake @ 2026-11-17 21:47 UTC (permalink / raw)
To: Chaoyi Chen, Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
On 14/08/2026 03:24, Chaoyi Chen wrote:
> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>
> In rocket_ioctl_submit_job(), since the domain is assigned last, an
> error before that triggers rocket_job_put() -> rocket_job_cleanup()
> -> rocket_iommu_domain_put() with the domain still NULL,
> causing a panic in that function.
>
> Therefore, the input parameters should be validated.
>
> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
> Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
This issue was already fixed in commit
70e6a33d68a9b03335c5426332666e52d07f45d6.
This patch is not needed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq
2026-08-14 2:24 [PATCH 0/4] accel/rocket: resource leak and stability improvements Chaoyi Chen
2026-08-14 2:24 ` [PATCH 1/4] accel/rocket: Fix the IOMMU domain leak in rocket_ioctl_create_bo Chaoyi Chen
2026-08-14 2:24 ` [PATCH 2/4] accel/rocket: Fix the panic in rocket_iommu_domain_put when the domain is NULL Chaoyi Chen
@ 2026-08-14 2:24 ` Chaoyi Chen
2026-11-17 21:53 ` Daniel Drake
2026-08-14 2:24 ` [PATCH 4/4] MAINTAINERS: accel/rocket: Add rockchip mail list for rocket Chaoyi Chen
3 siblings, 1 reply; 11+ messages in thread
From: Chaoyi Chen @ 2026-08-14 2:24 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
The rocket attaches the IOMMU group in rocket_job_run() and detaches it
in rocket_job_handle_irq(). Calling iommu_group_get() in
rocket_job_handle_irq() causes the reference count to increase
unexpectedly. And this causes rocket_core_fini() to fail to release the
IOMMU group, leading to a resource leak.
Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
---
drivers/accel/rocket/rocket_job.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 2f1861f960cc..db10848926d8 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -340,7 +340,7 @@ static void rocket_job_handle_irq(struct rocket_core *core)
return;
}
- iommu_detach_group(NULL, iommu_group_get(core->dev));
+ iommu_detach_group(NULL, core->iommu_group);
dma_fence_signal(core->in_flight_job->done_fence);
pm_runtime_put_autosuspend(core->dev);
core->in_flight_job = NULL;
--
2.53.0
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq
2026-08-14 2:24 ` [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq Chaoyi Chen
@ 2026-11-17 21:53 ` Daniel Drake
2026-11-18 2:29 ` Chaoyi Chen
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Drake @ 2026-11-17 21:53 UTC (permalink / raw)
To: Chaoyi Chen, Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
On 14/08/2026 03:24, Chaoyi Chen wrote:
> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>
> The rocket attaches the IOMMU group in rocket_job_run() and detaches it
> in rocket_job_handle_irq(). Calling iommu_group_get() in
> rocket_job_handle_irq() causes the reference count to increase
> unexpectedly. And this causes rocket_core_fini() to fail to release the
> IOMMU group, leading to a resource leak.
While there is a leak here, I think sashiko correct in saying this
change would introduce a crash because core->iommu_group can be set to
NULL before this codepath is reached. That might be a simple fix.
> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Wrong commit mentioned here.
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq
2026-11-17 21:53 ` Daniel Drake
@ 2026-11-18 2:29 ` Chaoyi Chen
2026-11-18 8:58 ` Tomeu Vizoso
0 siblings, 1 reply; 11+ messages in thread
From: Chaoyi Chen @ 2026-11-18 2:29 UTC (permalink / raw)
To: Daniel Drake
Cc: Chaoyi Chen, Tomeu Vizoso, Oded Gabbay, Heiko Stuebner,
Jeff Hugo, linux-kernel, dri-devel, linux-rockchip,
linux-arm-kernel
Hi Daniel,
On 11/18/2026 5:53 AM, Daniel Drake wrote:
> On 14/08/2026 03:24, Chaoyi Chen wrote:
>> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>>
>> The rocket attaches the IOMMU group in rocket_job_run() and detaches it
>> in rocket_job_handle_irq(). Calling iommu_group_get() in
>> rocket_job_handle_irq() causes the reference count to increase
>> unexpectedly. And this causes rocket_core_fini() to fail to release the
>> IOMMU group, leading to a resource leak.
>
>
> While there is a leak here, I think sashiko correct in saying this change would introduce a crash because core->iommu_group can be set to NULL before this codepath is reached. That might be a simple fix.
>
>> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
>
>
> Wrong commit mentioned here.
Thanks for you review. This is indeed a problem.
And it has been a long time since I sent this series. :)
During this time, I have seen a lot of similar work. For example, work
similar to patch1 is here[0]. And some of the issues mentioned by
Sashikoare also being fixed by in-flight patches like[1].
I'm not sure whether I should slow down the submission, since it seems
Tomeu is quite busy and hasn't gotten to some of the backlogged patches.
[0]: https://lore.kernel.org/all/20260915041152.1725014-1-vulab@iscas.ac.cn/
[1]: https://lore.kernel.org/all/18667b2afdcaae217fa1038f5348ab23ed756bdc.1794615323.git.gahing@gahingwoo.com/
--
Best,
Chaoyi
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq
2026-11-18 2:29 ` Chaoyi Chen
@ 2026-11-18 8:58 ` Tomeu Vizoso
2026-11-18 9:16 ` Chaoyi Chen
0 siblings, 1 reply; 11+ messages in thread
From: Tomeu Vizoso @ 2026-11-18 8:58 UTC (permalink / raw)
To: Chaoyi Chen
Cc: Daniel Drake, Chaoyi Chen, Oded Gabbay, Heiko Stuebner,
Jeff Hugo, LKML, dri-devel, open list:ARM/Rockchip SoC...,
LAKML
Hi Chaoyi and Daniel,
On Wed, Nov 18, 2026 at 3:29 AM Chaoyi Chen <chaoyi.chen@rock-chips.com> wrote:
>
> Hi Daniel,
>
> On 11/18/2026 5:53 AM, Daniel Drake wrote:
> > On 14/08/2026 03:24, Chaoyi Chen wrote:
> >> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> >>
> >> The rocket attaches the IOMMU group in rocket_job_run() and detaches it
> >> in rocket_job_handle_irq(). Calling iommu_group_get() in
> >> rocket_job_handle_irq() causes the reference count to increase
> >> unexpectedly. And this causes rocket_core_fini() to fail to release the
> >> IOMMU group, leading to a resource leak.
> >
> >
> > While there is a leak here, I think sashiko correct in saying this change would introduce a crash because core->iommu_group can be set to NULL before this codepath is reached. That might be a simple fix.
> >
> >> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
> >
> >
> > Wrong commit mentioned here.
I fixed this one when applying.
> Thanks for you review. This is indeed a problem.
I'm sorry but I had already applied this patch to drm-misc-fixes and
pushed when I read this. I have looked at fixing just this crash, but
have decided against it because we anyway crash in drm_sched on core
unbind whenever a client is active (no need to have a job in flight),
due to the sched entities keeping a reference to the stale scheduler.
> And it has been a long time since I sent this series. :)
>
> During this time, I have seen a lot of similar work. For example, work
> similar to patch1 is here[0]. And some of the issues mentioned by
> Sashikoare also being fixed by in-flight patches like[1].
Core removal needs to be fixed as a whole: detach the open files'
entities from the scheduler that goes away, complete or cancel the job
in flight, and quiesce the job interrupt before the resources it uses
are released.
> I'm not sure whether I should slow down the submission, since it seems
> Tomeu is quite busy and hasn't gotten to some of the backlogged patches.
I'm sorry about the big backlog of patches. With Heiko and Daniel's
help I expect to get it cleared soon and be more responsive.
Regards,
Tomeu
> [0]: https://lore.kernel.org/all/20260915041152.1725014-1-vulab@iscas.ac.cn/
> [1]: https://lore.kernel.org/all/18667b2afdcaae217fa1038f5348ab23ed756bdc.1794615323.git.gahing@gahingwoo.com/
>
> --
> Best,
> Chaoyi
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq
2026-11-18 8:58 ` Tomeu Vizoso
@ 2026-11-18 9:16 ` Chaoyi Chen
0 siblings, 0 replies; 11+ messages in thread
From: Chaoyi Chen @ 2026-11-18 9:16 UTC (permalink / raw)
To: Tomeu Vizoso
Cc: Daniel Drake, Chaoyi Chen, Oded Gabbay, Heiko Stuebner,
Jeff Hugo, LKML, dri-devel, open list:ARM/Rockchip SoC...,
LAKML
Hi Tomeu,
On 11/18/2026 4:58 PM, Tomeu Vizoso wrote:
> Hi Chaoyi and Daniel,
>
> On Wed, Nov 18, 2026 at 3:29 AM Chaoyi Chen <chaoyi.chen@rock-chips.com> wrote:
>>
>> Hi Daniel,
>>
>> On 11/18/2026 5:53 AM, Daniel Drake wrote:
>>> On 14/08/2026 03:24, Chaoyi Chen wrote:
>>>> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>>>>
>>>> The rocket attaches the IOMMU group in rocket_job_run() and detaches it
>>>> in rocket_job_handle_irq(). Calling iommu_group_get() in
>>>> rocket_job_handle_irq() causes the reference count to increase
>>>> unexpectedly. And this causes rocket_core_fini() to fail to release the
>>>> IOMMU group, leading to a resource leak.
>>>
>>>
>>> While there is a leak here, I think sashiko correct in saying this change would introduce a crash because core->iommu_group can be set to NULL before this codepath is reached. That might be a simple fix.
>>>
>>>> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
>>>
>>>
>>> Wrong commit mentioned here.
>
> I fixed this one when applying.
>
>> Thanks for you review. This is indeed a problem.
>
> I'm sorry but I had already applied this patch to drm-misc-fixes and
> pushed when I read this. I have looked at fixing just this crash, but
> have decided against it because we anyway crash in drm_sched on core
> unbind whenever a client is active (no need to have a job in flight),
> due to the sched entities keeping a reference to the stale scheduler.
>
Oh, that's true, but it seems no merge notification email was sent out?
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/5c4aeafcac8c46be7b08b86795baa64453eb68aa
>> And it has been a long time since I sent this series. :)
>>
>> During this time, I have seen a lot of similar work. For example, work
>> similar to patch1 is here[0]. And some of the issues mentioned by
>> Sashikoare also being fixed by in-flight patches like[1].
>
> Core removal needs to be fixed as a whole: detach the open files'
> entities from the scheduler that goes away, complete or cancel the job
> in flight, and quiesce the job interrupt before the resources it uses
> are released.
>
>> I'm not sure whether I should slow down the submission, since it seems
>> Tomeu is quite busy and hasn't gotten to some of the backlogged patches.
>
> I'm sorry about the big backlog of patches. With Heiko and Daniel's
> help I expect to get it cleared soon and be more responsive.
>
Thanks for your excellent work! I think patch4 could also be merged?
That way, people on the rockchip mailing list can also conveniently help
us review these patches. :-)
--
Best,
Chaoyi
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/4] MAINTAINERS: accel/rocket: Add rockchip mail list for rocket
2026-08-14 2:24 [PATCH 0/4] accel/rocket: resource leak and stability improvements Chaoyi Chen
` (2 preceding siblings ...)
2026-08-14 2:24 ` [PATCH 3/4] accel/rocket: Fix the extra iommu_group_get call in rocket_job_handle_irq Chaoyi Chen
@ 2026-08-14 2:24 ` Chaoyi Chen
3 siblings, 0 replies; 11+ messages in thread
From: Chaoyi Chen @ 2026-08-14 2:24 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Heiko Stuebner, Jeff Hugo
Cc: linux-kernel, dri-devel, linux-rockchip, linux-arm-kernel, Chaoyi Chen
From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
The rocket is a DRM accel driver for the Rockchip NPU. Add the Rockchip
mailing listso that changes can be tracked.
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 4a8b0fd665ce..388ec1758ce7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7942,6 +7942,7 @@ F: include/uapi/drm/ivpu_accel.h
DRM ACCEL DRIVER FOR ROCKCHIP NPU
M: Tomeu Vizoso <tomeu@tomeuvizoso.net>
L: dri-devel@lists.freedesktop.org
+L: linux-rockchip@lists.infradead.org
S: Supported
T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
F: Documentation/accel/rocket/
--
2.53.0
^ permalink raw reply [flat|nested] 11+ messages in thread