]> git.ipfire.org Git - thirdparty/linux.git/commit
drm/nouveau: Fixup gk20a instobj hierarchy
authorThierry Reding <treding@nvidia.com>
Fri, 8 Dec 2023 10:46:53 +0000 (11:46 +0100)
committerDave Airlie <airlied@redhat.com>
Fri, 15 Dec 2023 04:10:40 +0000 (14:10 +1000)
commit46dec61643d7047c9b5929f98a2b7fa4fa93a7dc
treee3deab4c8a1146e7f3af0a30ad4c9313711a0f78
parentf8678a336808f728ea2e0806cfc10362958ca4e5
drm/nouveau: Fixup gk20a instobj hierarchy

Commit 12c9b05da918 ("drm/nouveau/imem: support allocations not
preserved across suspend") uses container_of() to cast from struct
nvkm_memory to struct nvkm_instobj, assuming that all instance objects
are derived from struct nvkm_instobj. For the gk20a family that's not
the case and they are derived from struct nvkm_memory instead. This
causes some subtle data corruption (nvkm_instobj.preserve ends up
mapping to gk20a_instobj.vaddr) that causes a NULL pointer dereference
in gk20a_instobj_acquire_iommu() (and possibly elsewhere) and also
prevents suspend/resume from working.

Fix this by making struct gk20a_instobj derive from struct nvkm_instobj
instead.

Fixes: 12c9b05da918 ("drm/nouveau/imem: support allocations not preserved across suspend")
Reported-by: Jonathan Hunter <jonathanh@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231208104653.1917055-1-thierry.reding@gmail.com
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c