From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B4CC606A6A3 for ; Wed, 2 Dec 2026 22:36:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TzMCrAnG Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E815D11259C; Wed, 2 Dec 2026 22:36:28 +0000 (UTC) Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB6D6112595 for ; Wed, 2 Dec 2026 22:36:17 +0000 (UTC) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-8b4fb5d96b3so5862327b3.1 for ; Wed, 02 Dec 2026 14:36:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796250977; x=1796855777; darn=lists.freedesktop.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NrTe/aVxF7ZATkQeyYf6Em6SvrMDF4pWrP3fijIlkYY=; b=TzMCrAnGaP7iHC0T4OEX9wndKYe3CRBuOKoygHpCc3QOs0EntxK3ay7sjAu6GB2WwK IwFxhwCAsDaPaLXNSnJi5q9n9ovJnPK5M8Tw6JfnFcrWM7ManfJHkv80LQ2RGpRvR2es 9ZxHYco8SoV6dId3f0uUJWjDDm6S2SOgM6nsP5GQyjjQLvNYA1A+cpCE5zeUhFBqPTYF aU3JcJ8nSKgtKM5SmtFiTgQu1BVPCaQN7Uxm+pwq1601tOpHFkRkj3EQ/askL86GsHJg AiwA5KDl7BiMWHH1PExvGlYbrq4tsOTCnyyYykE/BT6r7yE6yUMg2HJcbTqwZgjW5Dce 3bPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796250977; x=1796855777; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NrTe/aVxF7ZATkQeyYf6Em6SvrMDF4pWrP3fijIlkYY=; b=EsqOxHgnDZNaobeu5IVjZM0lUxK6vzKKWymdIvQTvB68BAscFD0BhVBZvgwkkwHvDT B0C3usDDhuIwtgdm3z1JP6q1LnsfyTJhqCodmh49WjUZBNSEPqllxlwOTGL6Ewbpo5hf CaAOITNkIRu/ERFb94nGkg51DZ/0mCQ9BXwLYE+jt/Z2crtbHL8s/2WMvk3WOlPVeKuo qVr6mfp02PtI+sKSWnF7uYSfDmCkUQ4dmOpMsYKEWAAXgUnIUrSDq0sR9QLURMJ/4bzv mTXDLtfP/tpAKm6QHziOVLwxyOiKK5CWrp6TV+WZWfwFVTKINwJDXmnpNCe5gbVKS1k5 zBvg== X-Gm-Message-State: APuU4Z8OrDRTVauMHkGNVAKy3KrNlDRTipmvNFKGGOJT1LVc5P/9qSPR mIhnaTDZOhDBo8sYaJHp5pt+BlNAvJoS1N7bKi2wzlH4O4Yt337ylVkY X-Gm-Gg: AZFdTZf/P0A3X9h29AlkBgOkBmgoNIKn/QuxXNTRod2O+En/KzTfCRJBTQ858MfBSGl uvKS+P3HRpciDO+otLsXikfs4SA6luYDKDXssSt6su8eQ9I7wJCIOU00N2aWYkmeYlbC5mlMnkW QeNprIebxJq83qJ0ZdCLq2E7kS74sST5CIYV2nislMrT+jGeLZSwegs9fl5E464puzZAFvO4f/J bTHfw9z6Dn8TnF8qut5zKiyaViuXbChnZXZ9JLtQZDgFoi42bBKK1X2SkyJJu2yWSpmloMwBaxJ 9deiwdLXFs+qo60/j6DXQTZGX9pbZRL8eiJ+uaj1vC1jPGsM0UQRIcWTzObp5geG/GL8inqqTbu tigCvCZl9rl02nCvMxRUlcUpvpg7i3lgAaOvVvlrzw3TTXtOFYU/gK06CmLO3CW4B12hknOGhx2 +hVJEiXszhpmfqi92sMEUvjIsJwZmu+7KabDM213eowu6pr5xfI7myM8rQqAAC5oW+PSRxGjk/y kYTr7xOwzzNV3oaT/Jl30LnOdoM/mOwKR7OaIffxHtnqAHZFyx55tgoJvZ3tkFTOgC8b/hVoNqX o6zHyytjCUXGySzu2QtzPq3eHpwEI3UMSU3ynO7Pd+h6kZqEaC5iWhhTuMQ3kxWge/vqaOaWKkW YTLtxdrtDIt2ckshlZFGPoZx0Y6dB/5rwlx9RcwvJ+jLeFUEQaoDRHMuyzvbWeXS6kTZhRHSRp9 DMLWlnMNoPgjuG1CdPDg== X-Received: by 2002:a05:690c:288:b0:8b4:c891:69b with SMTP id 00721157ae682-8b5f5f33616mr1212087b3.22.1796250976515; Wed, 02 Dec 2026 14:36:16 -0800 (PST) Received: from localhost (107-220-129-194.lightspeed.chrlnc.sbcglobal.net. [107.220.129.194]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df33554b5sm18708066d50.13.2026.12.02.14.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 14:36:15 -0800 (PST) From: Matt Turner Date: Wed, 02 Dec 2026 17:36:09 -0500 Subject: [PATCH 03/14] drm/amdgpu: don't overwrite the IP state while a coredump is formatted X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-amdgpu-devcoredump-v1-3-3dfa0e033b97@gmail.com> References: <20261202-amdgpu-devcoredump-v1-0-3dfa0e033b97@gmail.com> In-Reply-To: <20261202-amdgpu-devcoredump-v1-0-3dfa0e033b97@gmail.com> To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sunil Khatri , Trigger Huang Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Matt Turner X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8218; i=mattst88@gmail.com; h=from:subject:message-id; bh=tjK2hH0qFH8VcWFgQQJhwpMQ5YfUwUB2rjbwpmCpoRw=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLIF5kbcDl57iTf8clDBLdYFt7ub4iYyXJAz9VArKdbRL pBXTLjV8ZGFQYyLYaaYIkvcekWWWW07lvqclv4FM4eVCWSItEgDAxCwMPDlJuaVGukY6ZlqG+oZ Ahk6RvEQOT0Gjczi4tLUIt20giKHvPySxJLM/LxivfyC1LyC9AK9tMy0koyM/KLiVKARenmpJaa ujm5GhgYmlo4WZk4WjqYmzs5Ohk5ujo7Ork5GluYmBs6WjiauluYMXJwCMNf4MjMyTFRymh/Vuk dpxu2NL9wqTet5ju1Vu8FcncDLz+cgwJ8jwshw9Ern/LdP7O9rvo+f5Coi6Vr35sgTnd1hF3cy1 LrNvryBGQA= X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The IP blocks' dump_ip_state() saves their registers into per device arrays, and the coredump worker prints them from there with print_ip_state() while it formats the dump, concurrently with recovery. A hang detected while the worker is still busy runs dump_ip_state() again and overwrites the arrays under the worker, so the first dump can mix the registers of two hangs. The second hang's coredump is then dropped because the worker is busy, so the overwrite gains nothing. Move the dump into amdgpu_coredump_dump_ip_state(), which skips it while the worker is busy and records whether it ran. amdgpu_coredump() takes that into the coredump and clears it, so if the worker finishes between the two, the new dump says the IP state is unavailable instead of showing the previous hang's registers. The callers all run on the reset domain's workqueue, so no other dump can come in between. Fixes: af8644121e3e ("drm/amdgpu: add ip dump for each ip in devcoredump") Signed-off-by: Matt Turner --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 56 +++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 10 +---- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 5dfb57e7c0b3..7eff62f4cdda 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -930,6 +930,8 @@ struct amdgpu_device { #ifdef CONFIG_DEV_COREDUMP struct amdgpu_coredump_info *coredump; struct work_struct coredump_work; + /* the IP state was dumped for the next coredump */ + bool coredump_ip_state_valid; #endif struct mutex benchmark_mutex; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c index 0c6533b950f6..0e235096977b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c @@ -29,6 +29,9 @@ #include "atom.h" #ifndef CONFIG_DEV_COREDUMP +void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev) +{ +} void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, bool vram_lost, struct amdgpu_job *job) { @@ -451,12 +454,17 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf /* dump the ip state for each ip */ drm_printf(&p, "IP Dump\n"); - for (int i = 0; i < coredump->adev->num_ip_blocks; i++) { - ip_block = &coredump->adev->ip_blocks[i]; - if (ip_block->version->funcs->print_ip_state) { - drm_printf(&p, "IP: %s\n", ip_block->version->funcs->name); - ip_block->version->funcs->print_ip_state(ip_block, &p); - drm_printf(&p, "\n"); + if (!coredump->ip_state_valid) { + drm_printf(&p, "unavailable\n\n"); + } else { + for (int i = 0; i < coredump->adev->num_ip_blocks; i++) { + ip_block = &coredump->adev->ip_blocks[i]; + if (ip_block->version->funcs->print_ip_state) { + drm_printf(&p, "IP: %s\n", + ip_block->version->funcs->name); + ip_block->version->funcs->print_ip_state(ip_block, &p); + drm_printf(&p, "\n"); + } } } @@ -566,6 +574,36 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work) adev->coredump = NULL; } +/** + * amdgpu_coredump_dump_ip_state - save the IP state for the next coredump + * @adev: amdgpu device pointer + * + * Run each IP block's dump_ip_state() so that the following amdgpu_coredump() + * can include the register state at the time of the hang. + * + * The coredump worker reads the saved registers while it formats a dump, so + * skip this while the worker is busy. Callers run on the reset domain's + * single threaded workqueue, so no other hang can be dumped in between. + */ +void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev) +{ + int i; + + adev->coredump_ip_state_valid = false; + + if (work_busy(&adev->coredump_work)) + return; + + dev_info(adev->dev, "Dumping IP State\n"); + for (i = 0; i < adev->num_ip_blocks; i++) + if (adev->ip_blocks[i].version->funcs->dump_ip_state) + adev->ip_blocks[i].version->funcs + ->dump_ip_state((void *)&adev->ip_blocks[i]); + dev_info(adev->dev, "Dumping IP State Completed\n"); + + adev->coredump_ip_state_valid = true; +} + void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, bool vram_lost, struct amdgpu_job *job) { @@ -575,8 +613,13 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, struct drm_sched_job *s_job; u64 ring_count; struct amdgpu_ring *ring; + bool ip_state_valid; int i, idx; + /* Don't let a later coredump print this hang's IP state. */ + ip_state_valid = adev->coredump_ip_state_valid; + adev->coredump_ip_state_valid = false; + /* No need to generate a new coredump if there's one in progress already. */ if (work_busy(&adev->coredump_work)) return; @@ -590,6 +633,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, coredump->skip_vram_check = skip_vram_check; coredump->reset_vram_lost = vram_lost; + coredump->ip_state_valid = ip_state_valid; if (job && job->pasid) { struct amdgpu_task_info *ti; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h index cb874d8c3394..54b323b007db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h @@ -51,6 +51,8 @@ struct amdgpu_coredump_info { bool skip_vram_check; bool reset_vram_lost; struct amdgpu_ring *ring; + /* the IP blocks' dump_ip_state() was run for this hang */ + bool ip_state_valid; struct amdgpu_coredump_ring *rings; u32 num_rings; @@ -68,6 +70,7 @@ struct amdgpu_coredump_info { }; #endif +void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev); void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, bool vram_lost, struct amdgpu_job *job); void amdgpu_coredump_init(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 4a98a667526d..9b61589b891e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -5197,15 +5197,9 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, if (!amdgpu_sriov_vf(adev)) { need_full_reset = true; - if (!test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags)) { - dev_info(adev->dev, "Dumping IP State\n"); - /* Trigger ip dump before we reset the asic */ - for (i = 0; i < adev->num_ip_blocks; i++) - if (adev->ip_blocks[i].version->funcs->dump_ip_state) - adev->ip_blocks[i].version->funcs - ->dump_ip_state((void *)&adev->ip_blocks[i]); - dev_info(adev->dev, "Dumping IP State Completed\n"); - } + /* Trigger ip dump before we reset the asic */ + if (!test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags)) + amdgpu_coredump_dump_ip_state(adev); if (need_full_reset) r = amdgpu_device_ip_suspend(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index fa13d7beba80..e6d7514b0a02 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -36,15 +36,7 @@ static void amdgpu_job_do_core_dump(struct amdgpu_device *adev, struct amdgpu_job *job) { - int i; - - dev_info(adev->dev, "Dumping IP State\n"); - for (i = 0; i < adev->num_ip_blocks; i++) - if (adev->ip_blocks[i].version->funcs->dump_ip_state) - adev->ip_blocks[i].version->funcs - ->dump_ip_state((void *)&adev->ip_blocks[i]); - dev_info(adev->dev, "Dumping IP State Completed\n"); - + amdgpu_coredump_dump_ip_state(adev); amdgpu_coredump(adev, true, false, job); } -- 2.56.1