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 9F757606A333 for ; Wed, 2 Dec 2026 22:36:38 +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=n1XIhfTI Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0AC3E1125A2; Wed, 2 Dec 2026 22:36:33 +0000 (UTC) Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4AE1F1125A2 for ; Wed, 2 Dec 2026 22:36:27 +0000 (UTC) Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-67be9601f31so11889917d50.3 for ; Wed, 02 Dec 2026 14:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796250986; x=1796855786; 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=QSQ2VKfs13gzlZgBHBkytBABZrnXmv87WW7GbjONTFg=; b=n1XIhfTI20t6knMcfrAHXe7k1Un/RcYItWfzXhkGJv8S2o7NeXBtrJ55h6JrTvH4TH rW83mAaE+Vw6gCe7eBGsavMuC4V1a9H1uhEeliGDXs34DNW9jDqsy7bcwoavyXXujP6P bsi+EjmjS9xrBdE7HtAHeXyqd7o4DnKKUyl9WhnjitomM4TU7q9nwYN12CIYLbu+7uus fkZOx20mUuz7xcRAOE9o48wRZolzXYJfIJ+zp1bLn7CzzpKkH7Fm1IBo1dTYAnpjfNWl sGsUehJxUUHR96SiJuM6MSiNH671zZawMwsMmhZ+TlvfWP7CsMWqGya4MH4CrKKD+Z8z cDfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796250986; x=1796855786; 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=QSQ2VKfs13gzlZgBHBkytBABZrnXmv87WW7GbjONTFg=; b=lIXyckdpbK+fH8yBv7yT6P5aiS6xv5ULqh5rdnt2pxx4UbX+tuG7N2rzguMPjQoOHn y+uhCiKElkZvGlyk3JSo6J2TOEsqH0aJvU5ttNxR9xRoZ8rOpHzb9HBUMwnJL9QjyRVm trOoj8esJnysr/DauzOk0OzhFw29s7dE3ph9Rpd1SN1LNeensT4kkuxFujH/2uX3c5/Y yB51rS1pnwvezmUBtgv9uhYLj6Z5GmtEIlf+qsFytF/4q3hupE8GY7rznyoEn9fCkpoK INZ8lVwBapn8rrUEz3gOmstjjIH7mdMTSqPJ1EfWj3WxqRtUBVAVBF6wa+hXeSiGoIo+ ToyQ== X-Gm-Message-State: APuU4Z+Sn4Nj2JjKSk1e2QYPaW/FMBBmilgm3NFRzoFF8UA+Xh01HY6c el/qmuI8QN++Ibri1CJVrwKkv9m/3XQlzyCP2+yjP37HbLkct2D4U/gb X-Gm-Gg: AZFdTZctFGxXT+u271VUwYht3a2QcrVymCRrfDiKsC47XsyPR3ezw+w26hfTGl96ovL 8oNtoSAxIk7gnOji2MYrjEtd7SGm2i+kLC/ljGOPxWjN5DSwEqCpxbYXHpIGerAuGa0Le2HdrAc 1+LzbClCBBvEuRevii7fsAzoS8JvtZOWe/S8RKKwQaD04mttSXj0YHedtv5aSlEPv8DfHQdxPBn RLM/PKe4CsU1uR23PBa2nGPbl0AFA2UD1NfogbP5UQwD2Z+v4OeBj+kRuZy3TAxwPBCc4bdCvK2 tQWfKNZheg5uGQlRbBo+N52vYIDwYTxbUFIgbuM6FUCGK+RpfgF4r73CLTuEo+UpymThTNEpKzD Zf4LXotNNdHqbbm++Sr8wASSJicpA4P/VaK1rmUyW6c0TTNws9nPrvKu3073+u9u6OLrFNN5EnO VWxgVYBBzRa0/hSwEKLTLcSjQnDkEHiLmfKzKpPAkBQzRoTilkozD1z455vzWVv34euGm7mxvoB JiEh4vJVpxQrZ0LAqUD3TTgPUN1kSuyoe+SOGpxuvmg1AhaHZIiW2nzLmg+HZwxs9UlreH1X3I4 U1ZrrXMkzLP+1Dp8DZneRqzRiOa/PDSUtlhGV2o8vunQOlGQC7Hr6yuQRipG9Uxtq7MGOLEDyVF epoH68SHFze4cA6o91ECHmZFrFD9nofbNd/xMlUQSSTHsCFC3Ic1Cu1Fk8k3YnUIjEkrzJl88Wz TbIW/KVSRQUwObZJBkyoQ= X-Received: by 2002:a05:690e:128c:b0:67d:c122:e5e6 with SMTP id 956f58d0204a3-67df440b767mr17896186d50.31.1796250986197; Wed, 02 Dec 2026 14:36:26 -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-67eb40514besm2092150d50.22.2026.12.02.14.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 14:36:24 -0800 (PST) From: Matt Turner Date: Wed, 02 Dec 2026 17:36:13 -0500 Subject: [PATCH 07/14] drm/amdgpu: copy the IB contents before formatting the devcoredump X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-amdgpu-devcoredump-v1-7-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 , Gregoire Pean X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=15235; i=mattst88@gmail.com; h=from:subject:message-id; bh=IlelfdI2VfkDyVKsK/WSjJu6d6BH+3rt44X9IDUvghg=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLIF5kbwTDc1/nl1Q9HkEyd/ptXdmhGSsu16SsXn/bbrJ MqXv591ouMjC4MYF8NMMUWWuPWKLLPadiz1OS39C2YOKxPIEGmRBgYgYGHgy03MKzXSMdIz1TbU MwQydIziIXJ6DBqZxcWlqUW6aQVFDnn5JYklmfl5xXr5Bal5BekFemmZaSUZGflFxalAI/TyUkt MXR3djAwNTCwdLcycLBxNTZydnQyd3BwdnV2djCzNTQycLR1NXC3NGbg4BWCuEXBj+Gck6ZZwdt 9XlTtTjgeLt9kcv6XotIL1Y/tR903z1c9/tmthZHhsU+NXH17KUbPl47nInurqhmN+v35dTtII6 Qqvk2fawQwA 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 IB contents are read from inside the formatting function, which runs twice: once to size the output and once to fill it. The sizing pass does not lock the VM, so it prints a placeholder for every dword, and only the second pass reads the BOs and finds out whether an IB is readable. Nothing records why one could not be read. Copy the IB contents once from the coredump worker before formatting, into a buffer per IB along with an error code explaining why the contents are missing. Both formatting passes then print the same data, and the dump says why an IB is absent. This replaces the ttm_bo_kmap() based read from "drm/amdgpu: fix IB content read in the devcoredump". The copy only needs a GPU address and a size within one mapping, so describe it with a struct amdgpu_coredump_blob, which later changes use to copy other ranges of the VM. Factor the BO read into a helper that does not allocate and does not map the whole BO. VRAM is read through amdgpu_device_vram_access() 4 KiB at a time, so that the MM_INDEX/MM_DATA fallback for CPU invisible VRAM never keeps interrupts disabled for long. System memory is read one page at a time with kmap_local_page() when the kernel's linear mapping of the pages can be used: TTM only gives it the caching of the BO on x86, and maps decrypted BOs with pgprot_decrypted(), so other BOs are read through ttm_bo_kmap() of just the range being copied. BOs whose pages are not resident are refused. The copies are freed once the dump is formatted, since reading the dump only uses the formatted text. Suggested-by: Gregoire Pean Signed-off-by: Matt Turner --- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 319 +++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 11 + 2 files changed, 224 insertions(+), 106 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c index 4d1b89527545..c3f01acc0e8c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "amdgpu_dev_coredump.h" #include "atom.h" @@ -222,38 +223,157 @@ amdgpu_devcoredump_mapping_bo(struct amdgpu_bo_va_mapping *mapping) return mapping->bo_va->base.bo; } -static void -amdgpu_devcoredump_print_ibs(struct drm_printer *p, - struct amdgpu_coredump_info *coredump, - bool sizing_pass) +/* + * Whether the pages of @ttm can be read through the kernel's linear mapping. + * TTM only gives that mapping the caching of the BO on x86, and maps the pages + * of a decrypted BO with pgprot_decrypted(), so read anything else through + * ttm_bo_kmap() as TTM does. + */ +static bool amdgpu_devcoredump_tt_linear_ok(struct ttm_tt *ttm) +{ + if (ttm->page_flags & TTM_TT_FLAG_DECRYPTED) + return false; + + return ttm->caching == ttm_cached || IS_ENABLED(CONFIG_X86); +} + +/* + * Copy @size bytes at @offset in @abo to @dst. The caller holds the BO's + * reservation. VRAM is read 4 KiB at a time, which bounds how long the + * MM_INDEX/MM_DATA fallback for CPU invisible VRAM keeps interrupts disabled + * whatever the page size. + */ +static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset, + void *dst, u64 size) +{ + struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev); + struct ttm_resource *res = abo->tbo.resource; + struct ttm_tt *ttm = abo->tbo.ttm; + struct ttm_bo_kmap_obj map; + bool is_iomem; + int r; + + if (!res) + return -ENODATA; + + if (!IS_ALIGNED(offset, 4) || !IS_ALIGNED(size, 4)) + return -EINVAL; + + switch (res->mem_type) { + case TTM_PL_VRAM: { + struct amdgpu_res_cursor cursor; + + amdgpu_res_first(res, offset, size, &cursor); + while (cursor.remaining) { + u64 len = min_t(u64, cursor.size, SZ_4K); + + amdgpu_device_vram_access(adev, cursor.start, dst, len, + false); + dst += len; + amdgpu_res_next(&cursor, len); + cond_resched(); + } + return 0; + } + case TTM_PL_SYSTEM: + case TTM_PL_TT: + case AMDGPU_PL_PREEMPT: + if (!ttm || !ttm->pages) + return -EOPNOTSUPP; + + if (!ttm_tt_is_populated(ttm) || + ttm->page_flags & (TTM_TT_FLAG_SWAPPED | TTM_TT_FLAG_BACKED_UP)) + return -ENODATA; + + if (!amdgpu_devcoredump_tt_linear_ok(ttm)) { + pgoff_t first = offset >> PAGE_SHIFT; + + r = ttm_bo_kmap(&abo->tbo, first, + PFN_UP(offset + size) - first, &map); + if (r) + return r; + memcpy(dst, ttm_kmap_obj_virtual(&map, &is_iomem) + + offset_in_page(offset), size); + ttm_bo_kunmap(&map); + return 0; + } + + while (size) { + pgoff_t idx = offset >> PAGE_SHIFT; + size_t pg_off = offset_in_page(offset); + size_t len = min_t(u64, size, PAGE_SIZE - pg_off); + void *src; + + if (idx >= ttm->num_pages || !ttm->pages[idx]) + return -ENODATA; + + src = kmap_local_page(ttm->pages[idx]); + memcpy(dst, src + pg_off, len); + kunmap_local(src); + + dst += len; + offset += len; + size -= len; + cond_resched(); + } + return 0; + default: + return -EOPNOTSUPP; + } +} + +/* + * Copy a range of GPU memory, which must lie within a single mapping, into a + * newly allocated buffer. The VM root PD and the BO behind the mapping must be + * reserved by the caller. + */ +static int amdgpu_devcoredump_copy_blob(struct amdgpu_vm *vm, + struct amdgpu_coredump_blob *blob) +{ + struct amdgpu_bo_va_mapping *mapping; + struct amdgpu_bo *abo; + u64 offset; + void *data; + int r; + + mapping = amdgpu_vm_bo_lookup_mapping(vm, blob->va); + abo = amdgpu_devcoredump_mapping_bo(mapping); + if (!abo) + return -ENOENT; + + if (blob->va + blob->size > (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE) + return -ERANGE; + + offset = blob->va - mapping->start * AMDGPU_GPU_PAGE_SIZE + + mapping->offset; + + /* amdgpu_device_vram_access() can fail without telling us. */ + data = kvzalloc(blob->size, GFP_KERNEL | __GFP_NOWARN); + if (!data) + return -ENOMEM; + + r = amdgpu_devcoredump_read_bo(abo, offset, data, blob->size); + if (r) { + kvfree(data); + return r; + } + + blob->data = data; + return 0; +} + +/* + * Copy the contents of the IBs of the hung job, blocking on the reservation + * locks as needed. This runs from the coredump worker, before formatting, so + * that both formatting passes see the same data. + */ +static void amdgpu_devcoredump_capture_vm(struct amdgpu_coredump_info *coredump) { - struct amdgpu_device *adev = coredump->adev; struct amdgpu_bo_va_mapping *mapping; struct amdgpu_bo *abo; struct drm_exec exec; struct amdgpu_vm *vm; - u32 *ib_content; - u64 va_start, offset; - u8 *kptr; - u32 off; - int r; - - /* - * On the sizing pass there is no VM to look up and no BO to lock; the - * size estimate doesn't depend on whether the IB BOs are reachable. - * Just emit the per-IB headers (the content is not written anywhere). - */ - if (sizing_pass) { - for (int i = 0; i < coredump->num_ibs; i++) { - drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i, - coredump->ibs[i].gpu_addr, - coredump->ibs[i].ib_size_dw); - - for (int j = 0; j < coredump->ibs[i].ib_size_dw; j++) - drm_printf(p, "0xffffffff\n"); - } - return; - } + int r = 0; /* * Lock the VM root PD and every IB BO together in a single drm_exec @@ -264,14 +384,18 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p, */ drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 1 + coredump->num_ibs); drm_exec_until_all_locked(&exec) { - vm = amdgpu_vm_lock_by_pasid(adev, coredump->pasid, &exec); - if (!vm) + /* Don't keep an -EDEADLK from a previous pass. */ + r = 0; + vm = amdgpu_vm_lock_by_pasid(coredump->adev, coredump->pasid, + &exec); + if (!vm) { + r = -ESRCH; goto unlock; + } for (int i = 0; i < coredump->num_ibs; i++) { - u64 addr = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK; - - mapping = amdgpu_vm_bo_lookup_mapping(vm, addr); + mapping = amdgpu_vm_bo_lookup_mapping(vm, + coredump->ibs[i].blob.va); abo = amdgpu_devcoredump_mapping_bo(mapping); if (!abo) continue; @@ -284,80 +408,47 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p, } for (int i = 0; i < coredump->num_ibs; i++) { - u64 size = (u64)coredump->ibs[i].ib_size_dw * 4; - bool emit_content = false; + struct amdgpu_coredump_blob *blob = &coredump->ibs[i].blob; - ib_content = kvmalloc_array(coredump->ibs[i].ib_size_dw, 4, - GFP_KERNEL); - if (!ib_content) - continue; - - va_start = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK; - mapping = amdgpu_vm_bo_lookup_mapping(vm, va_start); - abo = amdgpu_devcoredump_mapping_bo(mapping); - if (!abo || !abo->tbo.resource) - goto output_ib_content; - - if (va_start + size > - (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE) - goto output_ib_content; - - offset = va_start - mapping->start * AMDGPU_GPU_PAGE_SIZE + - mapping->offset; - - if (abo->tbo.resource->mem_type == TTM_PL_VRAM) { - struct amdgpu_res_cursor cursor; - - off = 0; - amdgpu_res_first(abo->tbo.resource, offset, size, - &cursor); - while (cursor.remaining) { - amdgpu_device_vram_access(adev, cursor.start, - &ib_content[off], - cursor.size, false); - off += cursor.size / 4; - amdgpu_res_next(&cursor, cursor.size); - } - emit_content = true; - } else { - struct ttm_bo_kmap_obj map; - unsigned long first = offset >> PAGE_SHIFT; - bool is_iomem; - - /* - * Map only the pages backing the IB, into a local map - * object so a kernel mapping held in abo->kmap is left - * untouched. - */ - r = ttm_bo_kmap(&abo->tbo, first, - PFN_UP(offset + size) - first, &map); - if (r) - goto output_ib_content; - - kptr = ttm_kmap_obj_virtual(&map, &is_iomem); - kptr += offset_in_page(offset); - if (is_iomem) - memcpy_fromio(ib_content, - (void __iomem *)kptr, size); - else - memcpy(ib_content, kptr, size); - - ttm_bo_kunmap(&map); - emit_content = true; - } - -output_ib_content: - drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i, - coredump->ibs[i].gpu_addr, coredump->ibs[i].ib_size_dw); - if (emit_content) { - for (int j = 0; j < coredump->ibs[i].ib_size_dw; j++) - drm_printf(p, "0x%08x\n", ib_content[j]); - } - kvfree(ib_content); + blob->status = amdgpu_devcoredump_copy_blob(vm, blob); } unlock: drm_exec_fini(&exec); + + if (r) { + for (int i = 0; i < coredump->num_ibs; i++) + coredump->ibs[i].blob.status = r; + } +} + +/* Print the contents of a blob, or why they are missing. */ +static void amdgpu_devcoredump_print_blob(struct drm_printer *p, + struct amdgpu_coredump_blob *blob) +{ + const u32 *dw = blob->data; + + if (!blob->data) { + drm_printf(p, "contents unavailable: %pe\n", + ERR_PTR(blob->status)); + return; + } + + for (u64 i = 0; i < blob->size / 4; i++) + drm_printf(p, "0x%08x\n", dw[i]); +} + +static void +amdgpu_devcoredump_print_ibs(struct drm_printer *p, + struct amdgpu_coredump_info *coredump) +{ + for (int i = 0; i < coredump->num_ibs; i++) { + struct amdgpu_coredump_ib_info *ib = &coredump->ibs[i]; + + drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i, ib->gpu_addr, + ib->ib_size_dw); + amdgpu_devcoredump_print_blob(p, &ib->blob); + } } static ssize_t @@ -370,9 +461,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf struct amdgpu_ring *ring; int ver, i, j; u32 ring_idx; - bool sizing_pass; - sizing_pass = buffer == NULL; iter.data = buffer; iter.start = 0; iter.offset = 0; @@ -503,7 +592,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf drm_printf(&p, "VRAM is lost due to GPU reset!\n"); if (coredump->num_ibs) - amdgpu_devcoredump_print_ibs(&p, coredump, sizing_pass); + amdgpu_devcoredump_print_ibs(&p, coredump); return count - iter.remain; } @@ -531,12 +620,22 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, return byte_copied; } +/* Free the copied memory, which is only needed to format the dump. */ +static void amdgpu_devcoredump_free_blobs(struct amdgpu_coredump_info *coredump) +{ + for (int i = 0; i < coredump->num_ibs; i++) { + kvfree(coredump->ibs[i].blob.data); + coredump->ibs[i].blob.data = NULL; + } +} + static void amdgpu_devcoredump_free(void *data) { struct amdgpu_coredump_info *coredump = data; u32 i; kvfree(coredump->formatted); + amdgpu_devcoredump_free_blobs(coredump); for (i = 0; i < coredump->num_rings; i++) kvfree(coredump->rings[i].ring_dw); kvfree(coredump->rings); @@ -551,6 +650,9 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work) if (!coredump) goto end; + if (coredump->num_ibs) + amdgpu_devcoredump_capture_vm(coredump); + /* Do a one-time preparation of the coredump output because * repeatingly calling drm_coredump_printer is very slow. */ @@ -563,6 +665,7 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work) } amdgpu_devcoredump_format(coredump->formatted, coredump->formatted_size, coredump); + amdgpu_devcoredump_free_blobs(coredump); /* If there's an existing coredump for this device, the free function will be * called immediately so coredump might be invalid after the call to dev_coredumpm. @@ -656,8 +759,12 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, coredump->vmid = job->vmid; coredump->num_ibs = job->num_ibs; for (i = 0; i < job->num_ibs; ++i) { - coredump->ibs[i].gpu_addr = job->ibs[i].gpu_addr; - coredump->ibs[i].ib_size_dw = job->ibs[i].length_dw; + struct amdgpu_coredump_ib_info *ib = &coredump->ibs[i]; + + ib->gpu_addr = job->ibs[i].gpu_addr; + ib->ib_size_dw = job->ibs[i].length_dw; + ib->blob.va = ib->gpu_addr & AMDGPU_GMC_HOLE_MASK; + ib->blob.size = (u64)ib->ib_size_dw * 4; } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h index 6836f312b3f8..ffcb08428631 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h @@ -38,9 +38,20 @@ struct amdgpu_coredump_ring { u32 ring_index; }; +/* A range of GPU memory copied into the coredump */ +struct amdgpu_coredump_blob { + /* GPU VA with the hole bits masked off, and size in bytes */ + u64 va; + u64 size; + /* contents, or NULL with the reason in status */ + void *data; + int status; +}; + struct amdgpu_coredump_ib_info { uint64_t gpu_addr; u32 ib_size_dw; + struct amdgpu_coredump_blob blob; }; struct amdgpu_coredump_info { -- 2.56.1