[PATCH] drm/panfrost: Give name to anonymous coredump object union

Adrián Larumbe adrian.larumbe at collabora.com
Mon Sep 12 16:44:13 UTC 2022


Building Mesa's Perfetto requires including the panfrost drm uAPI header in
C++ code, but the C++ compiler requires anonymous unions to have only
public non-static data members.

Commit 730c2bf4ad39 ("drm/panfrost: Add support for devcoredump")
introduces one such union, breaking the Mesa build.

Give it a name, and also rename pan_reg_hdr structure because it will
always be prefixed by the union name.

Bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7195

Signed-off-by: Adrián Larumbe <adrian.larumbe at collabora.com>
---
 drivers/gpu/drm/panfrost/panfrost_dump.c | 20 ++++++++++----------
 include/uapi/drm/panfrost_drm.h          |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_dump.c b/drivers/gpu/drm/panfrost/panfrost_dump.c
index 89056a1aac7d..e40b6eace187 100644
--- a/drivers/gpu/drm/panfrost/panfrost_dump.c
+++ b/drivers/gpu/drm/panfrost/panfrost_dump.c
@@ -177,11 +177,11 @@ void panfrost_core_dump(struct panfrost_job *job)
 	 * For now, we write the job identifier in the register dump header,
 	 * so that we can decode the entire dump later with pandecode
 	 */
-	iter.hdr->reghdr.jc = cpu_to_le64(job->jc);
-	iter.hdr->reghdr.major = cpu_to_le32(PANFROSTDUMP_MAJOR);
-	iter.hdr->reghdr.minor = cpu_to_le32(PANFROSTDUMP_MINOR);
-	iter.hdr->reghdr.gpu_id = cpu_to_le32(pfdev->features.id);
-	iter.hdr->reghdr.nbos = cpu_to_le64(job->bo_count);
+	iter.hdr->pan_hdr.regs.jc = cpu_to_le64(job->jc);
+	iter.hdr->pan_hdr.regs.major = cpu_to_le32(PANFROSTDUMP_MAJOR);
+	iter.hdr->pan_hdr.regs.minor = cpu_to_le32(PANFROSTDUMP_MINOR);
+	iter.hdr->pan_hdr.regs.gpu_id = cpu_to_le32(pfdev->features.id);
+	iter.hdr->pan_hdr.regs.nbos = cpu_to_le64(job->bo_count);
 
 	panfrost_core_dump_registers(&iter, pfdev, as_nr, slot);
 
@@ -205,20 +205,20 @@ void panfrost_core_dump(struct panfrost_job *job)
 
 		if (!bo->base.sgt) {
 			dev_err(pfdev->dev, "Panfrost Dump: BO has no sgt, cannot dump\n");
-			iter.hdr->bomap.valid = 0;
+			iter.hdr->pan_hdr.bomap.valid = 0;
 			goto dump_header;
 		}
 
 		ret = drm_gem_shmem_vmap(&bo->base, &map);
 		if (ret) {
 			dev_err(pfdev->dev, "Panfrost Dump: couldn't map Buffer Object\n");
-			iter.hdr->bomap.valid = 0;
+			iter.hdr->pan_hdr.bomap.valid = 0;
 			goto dump_header;
 		}
 
 		WARN_ON(!mapping->active);
 
-		iter.hdr->bomap.data[0] = cpu_to_le32((bomap - bomap_start));
+		iter.hdr->pan_hdr.bomap.data[0] = cpu_to_le32((bomap - bomap_start));
 
 		for_each_sgtable_page(bo->base.sgt, &page_iter, 0) {
 			struct page *page = sg_page_iter_page(&page_iter);
@@ -231,14 +231,14 @@ void panfrost_core_dump(struct panfrost_job *job)
 			}
 		}
 
-		iter.hdr->bomap.iova = cpu_to_le64(mapping->mmnode.start << PAGE_SHIFT);
+		iter.hdr->pan_hdr.bomap.iova = cpu_to_le64(mapping->mmnode.start << PAGE_SHIFT);
 
 		vaddr = map.vaddr;
 		memcpy(iter.data, vaddr, bo->base.base.size);
 
 		drm_gem_shmem_vunmap(&bo->base, &map);
 
-		iter.hdr->bomap.valid = cpu_to_le32(1);
+		iter.hdr->pan_hdr.bomap.valid = cpu_to_le32(1);
 
 dump_header:	panfrost_core_dump_header(&iter, PANFROSTDUMP_BUF_BO, iter.data +
 					  bo->base.base.size);
diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h
index eac87310b348..4da33e4d7e2c 100644
--- a/include/uapi/drm/panfrost_drm.h
+++ b/include/uapi/drm/panfrost_drm.h
@@ -248,7 +248,7 @@ struct panfrost_dump_object_header {
 			__le32 major;
 			__le32 minor;
 			__le64 nbos;
-		} reghdr;
+		} regs;
 
 		struct pan_bomap_hdr {
 			__le32 valid;
@@ -262,7 +262,7 @@ struct panfrost_dump_object_header {
 		 */
 
 		__le32 sizer[496];
-	};
+	} pan_hdr;
 };
 
 /* Registers object, an array of these */
-- 
2.37.0



More information about the dri-devel mailing list