linux/drivers/gpu/host1x
Mainak Sen ca9388fba5 gpu: host1x: Fix race in syncpt alloc/free
[ Upstream commit c7d393267c ]

Fix race condition between host1x_syncpt_alloc()
and host1x_syncpt_put() by using kref_put_mutex()
instead of kref_put() + manual mutex locking.

This ensures no thread can acquire the
syncpt_mutex after the refcount drops to zero
but before syncpt_release acquires it.
This prevents races where syncpoints could
be allocated while still being cleaned up
from a previous release.

Remove explicit mutex locking in syncpt_release
as kref_put_mutex() handles this atomically.

Signed-off-by: Mainak Sen <msen@nvidia.com>
Fixes: f5ba33fb96 ("gpu: host1x: Reserve VBLANK syncpoints at initialization")
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20250707-host1x-syncpt-race-fix-v1-1-28b0776e70bc@nvidia.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-01-19 13:09:22 +01:00
..
hw gpu: host1x: Don't skip assigning syncpoints to channels 2023-03-10 09:39:25 +01:00
bus.c gpu: host1x: Do not setup DMA for virtual devices 2024-05-17 11:50:54 +02:00
bus.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201 2019-05-30 11:29:52 -07:00
cdma.c gpu: host1x: Add no-recovery mode 2021-08-10 14:40:23 +02:00
cdma.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201 2019-05-30 11:29:52 -07:00
channel.c gpu: host1x: Request channels for clients, not devices 2019-10-28 11:18:33 +01:00
channel.h gpu: host1x: Request channels for clients, not devices 2019-10-28 11:18:33 +01:00
debug.c gpu: host1x: Show number of pending waiters in debugfs 2021-03-30 19:53:24 +02:00
debug.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201 2019-05-30 11:29:52 -07:00
dev.c gpu: host1x: Avoid trying to use GART on Tegra20 2022-12-02 17:41:11 +01:00
dev.h gpu: host1x: Reserve VBLANK syncpoints at initialization 2021-03-31 17:42:13 +02:00
fence.c gpu: host1x: Plug potential memory leak 2021-09-16 18:06:52 +02:00
fence.h gpu: host1x: Add DMA fence implementation 2021-08-10 14:39:50 +02:00
intr.c gpu: host1x: Add DMA fence implementation 2021-08-10 14:39:50 +02:00
intr.h gpu: host1x: Add DMA fence implementation 2021-08-10 14:39:50 +02:00
job.c gpu: host1x: Add option to skip firewall for a job 2021-08-10 14:42:49 +02:00
job.h gpu: host1x: Add support for syncpoint waits in CDMA pushbuffer 2021-08-10 14:41:19 +02:00
Kconfig gpu: host1x: select CONFIG_DMA_SHARED_BUFFER 2022-01-27 11:03:39 +01:00
Makefile gpu: host1x: Add DMA fence implementation 2021-08-10 14:39:50 +02:00
mipi.c media: gpu: host1x: mipi: Keep MIPI clock enabled and mutex locked till calibration done 2020-08-28 15:12:38 +02:00
syncpt.c gpu: host1x: Fix race in syncpt alloc/free 2026-01-19 13:09:22 +01:00
syncpt.h gpu: host1x: Add no-recovery mode 2021-08-10 14:40:23 +02:00