drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
Extension
.c
Size
20255 bytes
Lines
607
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

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");
		}
	}

	/* Add ring buffer information */
	drm_printf(&p, "Ring buffer information\n");
	if (coredump->num_rings) {
		for (i = 0; i < coredump->num_rings; i++) {
			ring_idx = coredump->rings[i].ring_index;
			ring = coredump->adev->rings[ring_idx];
			off = coredump->rings[i].offset;

			drm_printf(&p, "ring name: %s\n", ring->name);
			drm_printf(&p, "Rptr: 0x%llx Wptr: 0x%llx RB mask: %x\n",
				   coredump->rings[i].rptr,
				   coredump->rings[i].wptr,
				   ring->buf_mask);
			drm_printf(&p, "Ring size in dwords: %d\n",
				ring->ring_size / 4);
			drm_printf(&p, "Ring contents\n");
			drm_printf(&p, "Offset \t Value\n");

			for (j = 0; j < ring->ring_size; j += 4)
				drm_printf(&p, "0x%x \t 0x%x\n", j,
					   coredump->rings_dw[off + j / 4]);
		}
	}

	if (coredump->skip_vram_check)
		drm_printf(&p, "VRAM lost check is skipped!\n");
	else if (coredump->reset_vram_lost)
		drm_printf(&p, "VRAM is lost due to GPU reset!\n");

	if (coredump->num_ibs) {
		/* Don't try to lookup the VM or map the BOs when calculating the
		 * size required to store the devcoredump.
		 */
		if (sizing_pass)
			vm = NULL;
		else
			vm = amdgpu_vm_lock_by_pasid(adev, &root, coredump->pasid);

		for (int i = 0; i < coredump->num_ibs && (sizing_pass || vm); i++) {
			ib_content = kvmalloc_array(coredump->ibs[i].ib_size_dw, 4,
						    GFP_KERNEL);
			if (!ib_content)
				continue;

			/* vm=NULL can only happen when 'sizing_pass' is true. Skip to the
			 * drm_printf() calls (ib_content doesn't need to be initialized
			 * as its content won't be written anywhere).
			 */
			if (!vm)
				goto output_ib_content;

			va_start = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK;
			mapping = amdgpu_vm_bo_lookup_mapping(vm, va_start / AMDGPU_GPU_PAGE_SIZE);
			if (!mapping)
				goto free_ib_content;

			offset = va_start - (mapping->start * AMDGPU_GPU_PAGE_SIZE);
			abo = amdgpu_bo_ref(mapping->bo_va->base.bo);
			r = amdgpu_bo_reserve(abo, false);
			if (r)
				goto free_ib_content;

			if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
				off = 0;

				if (abo->tbo.resource->mem_type != TTM_PL_VRAM)
					goto unreserve_abo;

				amdgpu_res_first(abo->tbo.resource, offset,
						 coredump->ibs[i].ib_size_dw * 4,
						 &cursor);
				while (cursor.remaining) {
					amdgpu_device_mm_access(adev, cursor.start / 4,
								&ib_content[off], cursor.size / 4,
								false);
					off += cursor.size;
					amdgpu_res_next(&cursor, cursor.size);
				}
			} else {
				r = ttm_bo_kmap(&abo->tbo, 0,
						PFN_UP(abo->tbo.base.size),
						&abo->kmap);
				if (r)

Annotation

Implementation Notes