From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Arunpravin Paneer Selvam" <arunpravin.paneerselvam@amd.com>,
"Christian König" <christian.koenig@amd.com>,
intel-xe@lists.freedesktop.org
Cc: Sashiko-bot <sashiko-bot@kernel.org>,
"Friedrich Vock" <friedrich.vock@gmx.de>,
"Maarten Lankhorst" <dev@lankhorst.se>,
"Tejun Heo" <tj@kernel.org>, "Maxime Ripard" <mripard@kernel.org>,
"Alex Deucher" <alexander.deucher@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
stable@vger.kernel.org, "Natalie Vock" <natalie.vock@gmx.de>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
cgroups@vger.kernel.org, "Huang Rui" <ray.huang@amd.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Simona Vetter" <simona@ffwll.ch>,
"David Airlie" <airlied@gmail.com>,
"Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 1/6] drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init()
Date: Tue, 21 Jul 2026 14:26:34 +0200 [thread overview]
Message-ID: <06bcc2e8-a7fd-483d-8c73-2a253b433840@linux.intel.com> (raw)
In-Reply-To: <60de7db0d25e387de4c13d0acb52d2dc1cc22d39.camel@linux.intel.com>
Hey,
On 7/21/26 14:10, Thomas Hellström wrote:
> Hi, Maarten,
>
> On Tue, 2026-07-21 at 13:46 +0200, Maarten Lankhorst wrote:
>> Hey,
>>
>> Can I merge this through drm-misc-next together with the rest of the
>> series?
>>
>> Kind regards
>> ~Maarten
>
> For the xe patches, Ack from me.
>
> I do have a v8 that fixes a sashiko comment on the last patch, though,
> but I was holding that awaiting a review on the other patches.
Yeah seems about right. Patches themselves look good to me now, so would be nice if amd can ack here or in v8.
Series themselves look good, so feel free to add my r-b to entire series: (and Thadeu's t-b)
Reviewed-By: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>
> Thanks,
> Thomas
>
>
>
>>
>> On 7/7/26 20:05, Arunpravin Paneer Selvam wrote:
>>>
>>>
>>> On 7/3/2026 6:38 PM, Christian König wrote:
>>>> Arun please take a look at this.
>>> Sure Christian. This fix looks correct to me.
>>> Reviewed-by: Arunpravin Paneer Selvam
>>> <Arunpravin.PaneerSelvam@amd.com>
>>>
>>> Thanks,
>>> Arun.
>>>>
>>>> Thanks,
>>>> Christian.
>>>>
>>>> On 7/3/26 15:05, Thomas Hellström wrote:
>>>>> drmm_cgroup_register_region() is called before INIT_LIST_HEAD()
>>>>> and
>>>>> gpu_buddy_init() in amdgpu_vram_mgr_init(). If it fails, the
>>>>> function
>>>>> returns early and bypasses those initializations.
>>>>>
>>>>> Since adev->mman.initialized is set to true before
>>>>> amdgpu_vram_mgr_init()
>>>>> is called, a failure triggers amdgpu_ttm_fini(), which calls
>>>>> amdgpu_vram_mgr_fini(), which then:
>>>>>
>>>>> - Calls list_for_each_entry_safe() on reservations_pending
>>>>> and
>>>>> reserved_pages, whose list_head::next pointers are zero-
>>>>> initialized
>>>>> (NULL). The loop does not recognize them as empty and
>>>>> dereferences NULL.
>>>>>
>>>>> - Calls gpu_buddy_fini(), which iterates free_trees[]
>>>>> unconditionally
>>>>> via for_each_free_tree(). Since mm->free_trees is NULL
>>>>> (never allocated), this dereferences NULL.
>>>>>
>>>>> Both result in a kernel panic on the module load error path.
>>>>>
>>>>> Fix by moving drmm_cgroup_register_region() to after the list
>>>>> and buddy
>>>>> allocator are fully initialized, so the teardown path is safe
>>>>> to run.
>>>>>
>>>>> Reported-by: Sashiko-bot <sashiko-bot@kernel.org>
>>>>> Closes:
>>>>> https://sashiko.dev/#/patchset/20260428073116.15687-1-thomas.hellstrom@linux.intel.com?part=4
>>>>> Fixes: 2b624a2c1865 ("drm/ttm: Handle cgroup based eviction in
>>>>> TTM")
>>>>> Cc: Friedrich Vock <friedrich.vock@gmx.de>
>>>>> Cc: Maarten Lankhorst <dev@lankhorst.se>
>>>>> Cc: Tejun Heo <tj@kernel.org>
>>>>> Cc: Maxime Ripard <mripard@kernel.org>
>>>>> Cc: Christian König <christian.koenig@amd.com>
>>>>> Cc: Alex Deucher <alexander.deucher@amd.com>
>>>>> Cc: amd-gfx@lists.freedesktop.org
>>>>> Cc: dri-devel@lists.freedesktop.org
>>>>> Cc: <stable@vger.kernel.org> # v6.14+
>>>>> Assisted-by: GitHub_Copilot:claude-sonnet-4.6
>>>>> Signed-off-by: Thomas Hellström
>>>>> <thomas.hellstrom@linux.intel.com>
>>>>> ---
>>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 ++++---
>>>>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>>>> index 2a241a5b12c4..ac3f71d77140 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>>>> @@ -918,9 +918,6 @@ int amdgpu_vram_mgr_init(struct
>>>>> amdgpu_device *adev)
>>>>> struct ttm_resource_manager *man = &mgr->manager;
>>>>> int err;
>>>>> - man->cg = drmm_cgroup_register_region(adev_to_drm(adev),
>>>>> "vram", adev->gmc.real_vram_size);
>>>>> - if (IS_ERR(man->cg))
>>>>> - return PTR_ERR(man->cg);
>>>>> ttm_resource_manager_init(man, &adev->mman.bdev,
>>>>> adev->gmc.real_vram_size);
>>>>> @@ -935,6 +932,10 @@ int amdgpu_vram_mgr_init(struct
>>>>> amdgpu_device *adev)
>>>>> if (err)
>>>>> return err;
>>>>> + man->cg = drmm_cgroup_register_region(adev_to_drm(adev),
>>>>> "vram", adev->gmc.real_vram_size);
>>>>> + if (IS_ERR(man->cg))
>>>>> + return PTR_ERR(man->cg);
>>>>> +
>>>>> ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM,
>>>>> &mgr->manager);
>>>>> ttm_resource_manager_set_used(man, true);
>>>>> return 0;
>>>
next prev parent reply other threads:[~2026-07-21 12:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 13:05 [PATCH v7 0/6] Add reclaim to the dmem cgroup controller Thomas Hellström
2026-07-03 13:05 ` [PATCH v7 1/6] drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init() Thomas Hellström
2026-07-03 13:08 ` Christian König
2026-07-03 13:11 ` Thomas Hellström
2026-07-22 9:58 ` Arunpravin Paneer Selvam
2026-07-07 18:05 ` Arunpravin Paneer Selvam
2026-07-21 11:46 ` Maarten Lankhorst
2026-07-21 12:10 ` Thomas Hellström
2026-07-21 12:26 ` Maarten Lankhorst [this message]
2026-07-22 9:49 ` Arunpravin Paneer Selvam
2026-08-03 12:30 ` Christian König
2026-07-03 13:05 ` [PATCH v7 2/6] cgroup/dmem: Introduce struct dmem_cgroup_init for region initialization Thomas Hellström
2026-07-03 13:05 ` [PATCH v7 3/6] cgroup/dmem: Add reclaim callback for lowering max below current usage Thomas Hellström
2026-07-06 19:25 ` Tejun Heo
2026-07-07 7:20 ` Thomas Hellström
2026-07-07 10:01 ` Maarten Lankhorst
2026-07-03 13:05 ` [PATCH v7 4/6] drm/ttm: Hook up a cgroup-aware reclaim callback for the dmem controller Thomas Hellström
2026-07-03 13:05 ` [PATCH v7 5/6] drm/xe: Wire up dmem cgroup reclaim for VRAM manager Thomas Hellström
2026-07-03 13:05 ` [PATCH v7 6/6] drm/amdgpu: " Thomas Hellström
2026-07-03 13:27 ` ✗ CI.checkpatch: warning for Add reclaim to the dmem cgroup controller (rev7) Patchwork
2026-07-03 13:28 ` ✓ CI.KUnit: success " Patchwork
2026-07-03 14:11 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-03 14:37 ` [PATCH v7 0/6] Add reclaim to the dmem cgroup controller Thadeu Lima de Souza Cascardo
2026-07-04 0:07 ` ✗ Xe.CI.FULL: failure for Add reclaim to the dmem cgroup controller (rev7) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06bcc2e8-a7fd-483d-8c73-2a253b433840@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arunpravin.paneerselvam@amd.com \
--cc=cascardo@igalia.com \
--cc=cgroups@vger.kernel.org \
--cc=christian.koenig@amd.com \
--cc=dev@lankhorst.se \
--cc=dri-devel@lists.freedesktop.org \
--cc=friedrich.vock@gmx.de \
--cc=hannes@cmpxchg.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=mkoutny@suse.com \
--cc=mripard@kernel.org \
--cc=natalie.vock@gmx.de \
--cc=ray.huang@amd.com \
--cc=rodrigo.vivi@intel.com \
--cc=sashiko-bot@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tj@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox