From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796250980; b=TWdmBkpfZXU5Q6TloUgYli+lNGOWQz8fLuV32rmFNJtBsCaRPG8faFXVU3daNC03CGZ7 KAQMIORQgzHEo+CWmEzlfQKr1VHbX8Mleq1fNRZqxWgQYqqCxHq4+aqfj4K1oH4USxH7f RVFtUGWkXiYQYOPIJbTkNEXz30qfUMMSCpDOYtTnHJUXUG7Kp5RSobWYXihnz/bIbwW0K gijixhyh7+tAmnPj8rjub7P2/ENBp12KtUlMFFieWzYeABRwS7cVtOHZLiNKZrNCaSGwf snzfHbEQuwOm6+of1OKoQBb+oS50fu7AvgoM0pIui1dBXl5eZFF7cGLwGUgwCib/IGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796250980; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=NkCHri76SoLJDwXgJkKddTPs+IDzWYeVlPdUpiqz0ho=; b=0fWQ1BAMe9k9fkQjswBClTu2AVxw2tjtYcqMgmDBFd1h8XnVusz/bBXg1t+JqfT4HbO3 AFMitB6bXzGGGdm+IMmzGPuKUG3OL3zv4qjcHcumGvy8QjATxIdjUgKXnSWEmnVUdbInQ PwfPWjaKflKhdYCN46JEurMq2pf3yoYyxC8uYGhqeDso3wuMgryhvkKBevVjPShpzCjrJ FHFZgrxvPv+Kq3yKzZp9ckrEuxWJ7EutnG8+X6Jjom9uqbmj0xY7FcjGI5I8vW3kkjqIA A78RGCFt1VdRtZE6CS4dhYpfylIvPKZNK4JtUS5JMe9kA32nfVJ3GhTTCXywRASzFYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=sjdfOXka; arc=none smtp.remote-ip=209.85.128.174 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 157EA606A33C for ; Wed, 2 Dec 2026 22:36:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 157EA606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=sjdfOXka Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-8b32daac9d7so2799387b3.0 for ; Wed, 02 Dec 2026 14:36:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796250979; x=1796855779; darn=vger.kernel.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=NkCHri76SoLJDwXgJkKddTPs+IDzWYeVlPdUpiqz0ho=; b=sjdfOXkaHiqqDyevbTW8uVFDVbRf2uV7BWY+pN4CKlf9lpEdFC2Z8Rc+GU4SJWwOfy wVlqvL9/LOm0pR4Vhb0IV7ubuhx7gf/apAm2RDvEg19TFnhnaFkBX7XiQBT2CAcAD6/Q nVKVLduguBEE+kNuNpvc6eNZSu2bDAVM74MwwzCSeIfqPRn3evUpYx1QqXTDUG7AJidR /HOFsIa7gDD/XGmEq8TMY+kecEgp9hQ0uZj8JwMWMSenfCYFDEyF+dTydyWM90Ajhh8c TAjD6H7XRU3SYzOpWBJYFiFpKZVSlNxFs4iJ4f4f3A3ds7f8q4ICOKLuvw9A5W1ipJlG eQTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796250979; x=1796855779; 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=NkCHri76SoLJDwXgJkKddTPs+IDzWYeVlPdUpiqz0ho=; b=U3UJIg3IbSCDn6U4/Yk4I1E71rNgSGLk9d01uUBK8k9r6rRzyOZdyQPjczJU5KgDf8 wWmBMboIp8dA8eO4x+gtlcyRjZ2Blr9bR+jFof/O/mGyYK6YgI/2NLHtGzuxtsDy94pp pKUdpTDq35xps7HrYpl+oTv7nY6/nFfRHT3qHzdywi47wuRBAb+5DW0hLQnjVKTetgKE oMyJWIEBwTo/YxZAn5fpVZqLHhHhGsZ5zOj1IcCgbKRdtdnTPAq9vaAHu0flc67Jfvzo qaxHloLZmvFhnj39Bri4ZlsZvO6Iu9PGNjpbAQVwS1N39xXW9LvKbqYGFCYM5crEVi0X 4n6g== X-Forwarded-Encrypted: i=1; AL+hErH+cRk/HEBokJzJA6b7lF3/95Mep7EWrViIgVt8OI0pFCDQOXYgdWc9yCmt17cvHCs+UoQ1Yd/mam8O0mI=@vger.kernel.org X-Gm-Message-State: APuU4Z+EPLpCiwLfIkJyICXmsFFSx6FZ3OSca51UWwru+IT8DGXwfALW GO1GDuFHACzQ3eCQZhYWAv5mbZvk4pWvr07394Y0tMc9xSYuurnZ4USf X-Gm-Gg: AZFdTZd33xoaFfgS76xSturMYj+bfAm5hkAMopJOZkQr2hEhH0o21JyUvAy4h32Phx3 T35a9ZX6Hpjse7c2D/7wiQ28CYyTuQ9PbZPbOYukR4ftcS+l/9by0jWjrh/DjighhrT3B+oC3BL f5SrcuHFRGeDDZ1nArakKI3JoUmf7eilbvY6NKq5R6Q9FMZeLrzpdj4HryGRH34Y4w9rUXyU411 VhBkfGiCpthTcbidt+GzJxGTbM2zIuURjtonP/RBbjqh0lTMy8j9J/rKfJ9/uGT+YznAwpDU22e X5wzbB9F1HbM/9qVsleN7jtaSfoleuJfZAD6ueBN49g+k9c9nyVjPdpJyxc3MmJzgP5V3oZG5TU X0PrGZSYky8nQf64XOsT5fUklF/n62YFwuTX2LUXkI24GDCgV5EpkeYVzjXH6sleyFkt+yhK6Xa EwtKlRmiM2WH3ga497ltCb5BJXShlhWc10yuRdkON7XbAZpXe7gb9G8srUW1mmyflIcr7gJkJ/6 LHxrZTCozatdVl5RaSONpC87UjcEpaRebV5VbAUVPPpbxe5eyr/lDxo+0J+K3McdoyFwWxYk818 H1Hd6u1kki0sNSqGMdLyBjx169jsCTqvsuYrzKHxm6BG5J3HKUvL7sbb6AX+gRR6rqDmsXeTDnr l5e/4mujCLMaECCgTsTR5HP4xekDLQZja3F7U8RQXjPK/i76CfZs/YSH5ABdEjJ+GL5x1g2n6o6 6S2QiKz1Px+95VBM0uoeXakLukvX2KpIGKw/HfAcOn X-Received: by 2002:a05:690c:4689:b0:8b4:cbe3:292 with SMTP id 00721157ae682-8b5f5966571mr1526867b3.4.1796250978905; Wed, 02 Dec 2026 14:36:18 -0800 (PST) Received: from localhost (107-220-129-194.lightspeed.chrlnc.sbcglobal.net. [107.220.129.194]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b520ca0cf8sm161009437b3.29.2026.12.02.14.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 14:36:17 -0800 (PST) From: Matt Turner Date: Wed, 02 Dec 2026 17:36:10 -0500 Subject: [PATCH 04/14] drm/amdgpu: take a coredump before resets done by a reset handler X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-amdgpu-devcoredump-v1-4-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=5478; i=mattst88@gmail.com; h=from:subject:message-id; bh=mtZNGJUhat+24txQOtLxn+dGkvDbfGHwqimiVYCkDag=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLIF5kb8e7Pl3f3Eh5PEGOtLHmVscF5wxSOipazTu9Q6v yRaZ7NmxwcWBjEuhpliiixx6xVZZrXtWOpzWvoXzBxWJpAh0iINDEDAwsCXm5hXaqRjpGeqbahn CGToGMVD5PQYNDKLi0tTi3TTCooc8vJLEksy8/OK9fILUvMK0gv00jLTSjIy8ouKU4FG6OWllpi 6OroZGRqYWDpamDlZOJqaODs7GTq5OTo6uzoZWZqbGDhbOpq4WpozcHEKwFxzN56R4cC6LUkza0 Wnu7KtuVhRtD/vk6fzqX9hjx4Gl+3gF61ykWH48fyaHrcKf5uJwZWLlvb11VuDPaeXBnUs2Dt3l 4TerTRGAA== X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A With a reset handler, such as the mode2 handlers of aldebaran, sienna_cichlid, SMU 13.0.10 and soc_v1_0, amdgpu_device_pre_asic_reset() returns after the handler's prepare_hwcontext(), before dumping the IP state. amdgpu_do_asic_reset() then returns after restore_hwcontext() without calling amdgpu_device_reinit_after_reset(), where the default reset method takes its coredump. So a recovery that is not started by a job timeout, which takes its own coredump, produces no coredump when one of these handlers does the reset. Check whether a reset handler will be used, and if so dump the IP state and take the coredump at the start of amdgpu_device_pre_asic_reset(), before prepare_hwcontext() suspends the IP blocks and before the fences are force completed, so that the dump still has the rings with unsignaled fences. The VRAM lost check is not known yet, so it is reported as skipped, as for the coredump taken on a job timeout. Factor the handler lookup out of amdgpu_reset_prepare_hwcontext() for the check, and use it in amdgpu_reset_perform_reset() as well, which did not check for a get_reset_handler callback. Signed-off-by: Matt Turner --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 40 ++++++++++++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 +++ 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 9b61589b891e..970669af110a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -5140,6 +5140,20 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, if (reset_context->reset_req_dev == adev) job = reset_context->job; + /* + * A reset handler suspends the IP blocks itself in prepare_hwcontext() + * and restores them without amdgpu_device_reinit_after_reset(), which + * is where the coredump is taken for the default reset method. Take + * the coredump now, while the IP blocks still hold the state of the + * hang and before the fences are force completed. + */ + if (!amdgpu_sriov_vf(adev) && + !test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags) && + amdgpu_reset_has_handler(adev, reset_context)) { + amdgpu_coredump_dump_ip_state(adev); + amdgpu_coredump(adev, true, false, job); + } + if (amdgpu_sriov_vf(adev)) amdgpu_virt_pre_reset(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c index c8016fa55a92..43ca25081213 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c @@ -232,14 +232,40 @@ int amdgpu_reset_fini(struct amdgpu_device *adev) return ret; } +static struct amdgpu_reset_handler * +amdgpu_reset_get_handler(struct amdgpu_device *adev, + struct amdgpu_reset_context *reset_context) +{ + if (!adev->reset_cntl || !adev->reset_cntl->get_reset_handler) + return NULL; + + return adev->reset_cntl->get_reset_handler(adev->reset_cntl, + reset_context); +} + +/** + * amdgpu_reset_has_handler - check whether a reset handler will be used + * @adev: amdgpu device pointer + * @reset_context: the reset context + * + * Like amdgpu_reset_prepare_hwcontext(), this may choose the reset method and + * store it in @reset_context if none was requested. + * + * Return: true if the reset described by @reset_context is done by one of the + * device's reset handlers rather than by the default method. + */ +bool amdgpu_reset_has_handler(struct amdgpu_device *adev, + struct amdgpu_reset_context *reset_context) +{ + return amdgpu_reset_get_handler(adev, reset_context); +} + int amdgpu_reset_prepare_hwcontext(struct amdgpu_device *adev, struct amdgpu_reset_context *reset_context) { - struct amdgpu_reset_handler *reset_handler = NULL; + struct amdgpu_reset_handler *reset_handler; - if (adev->reset_cntl && adev->reset_cntl->get_reset_handler) - reset_handler = adev->reset_cntl->get_reset_handler( - adev->reset_cntl, reset_context); + reset_handler = amdgpu_reset_get_handler(adev, reset_context); if (!reset_handler) return -EOPNOTSUPP; @@ -251,11 +277,9 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev, struct amdgpu_reset_context *reset_context) { int ret; - struct amdgpu_reset_handler *reset_handler = NULL; + struct amdgpu_reset_handler *reset_handler; - if (adev->reset_cntl) - reset_handler = adev->reset_cntl->get_reset_handler( - adev->reset_cntl, reset_context); + reset_handler = amdgpu_reset_get_handler(adev, reset_context); if (!reset_handler) return -EOPNOTSUPP; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h index c9f23a8e8db8..6dac886de9a9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h @@ -145,6 +145,9 @@ struct amdgpu_reset_domain { int amdgpu_reset_init(struct amdgpu_device *adev); int amdgpu_reset_fini(struct amdgpu_device *adev); +bool amdgpu_reset_has_handler(struct amdgpu_device *adev, + struct amdgpu_reset_context *reset_context); + int amdgpu_reset_prepare_hwcontext(struct amdgpu_device *adev, struct amdgpu_reset_context *reset_context); -- 2.56.1