Skip to contentSkip to conversation

Xe OA Consolidated Diffs

PATCH New Ashutosh Dixit 2 participants 3 messages Feb 8, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Xe OA Consolidated Diffs

Because Xe OA changes between successive revisions are distributed across multiple patches, I am providing a combined diff of all changes in a single patch to help with the code review.

These changes pertain to: https://patchwork.freedesktop.org/series/121084/

Ashutosh Dixit (1):
drm/xe/oa: Combined diff of changes between v8 and v9

 drivers/gpu/drm/xe/xe_oa.c    | 87 +++++++++++++++++++----------------
 drivers/gpu/drm/xe/xe_query.c |  8 ++--
 include/uapi/drm/xe_drm.h     | 73 ++++++++++++++++++++++-------
 3 files changed, 106 insertions(+), 62 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/1 drm/xe/oa: Combined diff of changes between v8 and v9

Because Xe OA changes between successive revisions are distributed across multiple patches, provide a combined diff of all changes in a single patch to help with the code review.

These changes pertain to: https://patchwork.freedesktop.org/series/121084/

This patch will not compile, it's purpose is to just provide the diff.

Changes between v8 and v9 include:

* Disable overrun mode only when time based sampling is enabled
* Use graphics versions rather than absolute platform names
* Skip reporting reserved engines attached to OA units
* Remove gt_id, open_stream and oa_buf_size from 'struct drm_xe_oa_unit' used in drm_xe_query_oa_units
* Expose oa_buf_size via DRM_XE_PERF_IOCTL_INFO perf fd ioctl
* Introduce 'struct drm_xe_oa_stream_status' for returning OA stream status (rather than returning just via DRM_XE_PERF_IOCTL_STATUS return code
* Clarify some uapi comments

---
 drivers/gpu/drm/xe/xe_oa.c    | 87 +++++++++++++++++++----------------
 drivers/gpu/drm/xe/xe_query.c |  8 ++--
 include/uapi/drm/xe_drm.h     | 73 ++++++++++++++++++++++-------
 3 files changed, 106 insertions(+), 62 deletions(-)
drivers/gpu/drm/xe/xe_oa.c +47 -40
index 560b6a3189e42..c26bbed1940ec 100644
@@ -381,7 +381,7 @@ static void xe_oa_init_oa_buffer(struct xe_oa_stream *stream)
 	 * mode to avoid this issue.
 	 */
 	if (GRAPHICS_VER(stream->oa->xe) >= 20 &&
-	    stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG)
+	    stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG && stream->sample)
 		oa_buf |= OAG_OABUFFER_DISABLE_OVERRUN_MODE;
 	/*
 	 * PRM says: "This MMIO must be set before the OATAILPTR register and after the
@@ -1029,12 +1029,29 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream,
 	return ret;
 }
 
-static long xe_oa_status_locked(struct xe_oa_stream *stream)
+static long xe_oa_status_locked(struct xe_oa_stream *stream, unsigned long arg)
 {
-	u32 ret = xe_mmio_read32(stream->gt, __oa_regs(stream)->oa_status);
+	struct drm_xe_oa_stream_status status = {};
+	void __user *uaddr = (void __user *)arg;
+
+	status.oa_status = xe_mmio_read32(stream->gt, __oa_regs(stream)->oa_status);
+
+	if (copy_to_user(uaddr, &status, sizeof(status)))
+		return -EFAULT;
 
 	xe_mmio_write32(stream->gt, __oa_regs(stream)->oa_status, 0);
-	return ret;
+	return 0;
+}
+
+static long xe_oa_info_locked(struct xe_oa_stream *stream, unsigned long arg)
+{
+	struct drm_xe_oa_stream_info info = { .oa_buf_size = XE_OA_BUFFER_SIZE, };
+	void __user *uaddr = (void __user *)arg;
+
+	if (copy_to_user(uaddr, &info, sizeof(info)))
+		return -EFAULT;
+
+	return 0;
 }
 
 static long xe_oa_ioctl_locked(struct xe_oa_stream *stream,
@@ -1051,7 +1068,9 @@ static long xe_oa_ioctl_locked(struct xe_oa_stream *stream,
 	case DRM_XE_PERF_IOCTL_CONFIG:
 		return xe_oa_config_locked(stream, arg);
 	case DRM_XE_PERF_IOCTL_STATUS:
-		return xe_oa_status_locked(stream);
+		return xe_oa_status_locked(stream, arg);
+	case DRM_XE_PERF_IOCTL_INFO:
+		return xe_oa_info_locked(stream, arg);
 	}
 
 	return -EINVAL;
@@ -2206,37 +2225,8 @@ static void oa_format_add(struct xe_oa *oa, enum xe_oa_format_name format)
 
 static void xe_oa_init_supported_formats(struct xe_oa *oa)
 {
-	switch (oa->xe->info.platform) {
-	case XE_TIGERLAKE:
-	case XE_ROCKETLAKE:
-	case XE_ALDERLAKE_S:
-	case XE_ALDERLAKE_P:
-	case XE_ALDERLAKE_N:
-	case XE_DG1:
-		oa_format_add(oa, XE_OA_FORMAT_A12);
-		oa_format_add(oa, XE_OA_FORMAT_A12_B8_C8);
-		oa_format_add(oa, XE_OA_FORMAT_A32u40_A4u32_B8_C8);
-		oa_format_add(oa, XE_OA_FORMAT_C4_B8);
-		break;
-
-	case XE_DG2:
-	case XE_PVC:
-		oa_format_add(oa, XE_OAR_FORMAT_A32u40_A4u32_B8_C8);
-		oa_format_add(oa, XE_OA_FORMAT_A24u40_A14u32_B8_C8);
-		oa_format_add(oa, XE_OAC_FORMAT_A24u64_B8_C8);
-		oa_format_add(oa, XE_OAC_FORMAT_A22u32_R2u32_B8_C8);
-		break;
-
-	case XE_METEORLAKE:
-		oa_format_add(oa, XE_OAR_FORMAT_A32u40_A4u32_B8_C8);
-		oa_format_add(oa, XE_OA_FORMAT_A24u40_A14u32_B8_C8);
-		oa_format_add(oa, XE_OAC_FORMAT_A24u64_B8_C8);
-		oa_format_add(oa, XE_OAC_FORMAT_A22u32_R2u32_B8_C8);
-		oa_format_add(oa, XE_OAM_FORMAT_MPEC8u64_B8_C8);
-		oa_format_add(oa, XE_OAM_FORMAT_MPEC8u32_B8_C8);
-		break;
-
-	case XE_LUNARLAKE:
+	if (GRAPHICS_VER(oa->xe) >= 20) {
+		/* Xe2+ */
 		oa_format_add(oa, XE_OAM_FORMAT_MPEC8u64_B8_C8);
 		oa_format_add(oa, XE_OAM_FORMAT_MPEC8u32_B8_C8);
 		oa_format_add(oa, XE_OA_FORMAT_PEC64u64);
@@ -2248,10 +2238,27 @@ static void xe_oa_init_supported_formats(struct xe_oa *oa)
 		oa_format_add(oa, XE_OA_FORMAT_PEC32u32_G2);
 		oa_format_add(oa, XE_OA_FORMAT_PEC36u64_G1_32_G2_4);
 		oa_format_add(oa, XE_OA_FORMAT_PEC36u64_G1_4_G2_32);
-		break;
-
-	default:
-		drm_err(&oa->xe->drm, "Unknown platform\n");
+	} else if (GRAPHICS_VERx100(oa->xe) >= 1270) {
+		/* XE_METEORLAKE */
+		oa_format_add(oa, XE_OAR_FORMAT_A32u40_A4u32_B8_C8);
+		oa_format_add(oa, XE_OA_FORMAT_A24u40_A14u32_B8_C8);
+		oa_format_add(oa, XE_OAC_FORMAT_A24u64_B8_C8);
+		oa_format_add(oa, XE_OAC_FORMAT_A22u32_R2u32_B8_C8);
+		oa_format_add(oa, XE_OAM_FORMAT_MPEC8u64_B8_C8);
+		oa_format_add(oa, XE_OAM_FORMAT_MPEC8u32_B8_C8);
+	} else if (GRAPHICS_VERx100(oa->xe) >= 1255) {
+		/* XE_DG2, XE_PVC */
+		oa_format_add(oa, XE_OAR_FORMAT_A32u40_A4u32_B8_C8);
+		oa_format_add(oa, XE_OA_FORMAT_A24u40_A14u32_B8_C8);
+		oa_format_add(oa, XE_OAC_FORMAT_A24u64_B8_C8);
+		oa_format_add(oa, XE_OAC_FORMAT_A22u32_R2u32_B8_C8);
+	} else {
+		/* Gen12+ */
+		xe_assert(oa->xe, GRAPHICS_VER(oa->xe) >= 12);
+		oa_format_add(oa, XE_OA_FORMAT_A12);
+		oa_format_add(oa, XE_OA_FORMAT_A12_B8_C8);
+		oa_format_add(oa, XE_OA_FORMAT_A32u40_A4u32_B8_C8);
+		oa_format_add(oa, XE_OA_FORMAT_C4_B8);
 	}
 }
 
drivers/gpu/drm/xe/xe_query.c +3 -5
index 6f8fc9d2127ed..828be65a076d6 100644
@@ -566,18 +566,15 @@ static int query_oa_units(struct xe_device *xe,
 
 			du->oa_unit_id = u->oa_unit_id;
 			du->oa_unit_type = u->type;
-			du->gt_id = gt->info.id;
-			du->open_stream = !!u->exclusive_stream;
 			du->oa_timestamp_freq = xe_oa_timestamp_frequency(gt);
-			du->oa_buf_size = XE_OA_BUFFER_SIZE;
-			du->num_engines = u->num_engines;
 
 			for (j = 1; j < DRM_XE_OA_PROPERTY_MAX; j++)
 				du->capabilities |= BIT(j);
 
 			j = 0;
 			for_each_hw_engine(hwe, gt, hwe_id) {
-				if (xe_oa_unit_id(hwe) == u->oa_unit_id) {
+				if (!xe_hw_engine_is_reserved(hwe) &&
+				    xe_oa_unit_id(hwe) == u->oa_unit_id) {
 					du->eci[j].engine_class =
 						xe_to_user_engine_class[hwe->class];
 					du->eci[j].engine_instance = hwe->logical_instance;
@@ -585,6 +582,7 @@ static int query_oa_units(struct xe_device *xe,
 					j++;
 				}
 			}
+			du->num_engines = j;
 			pdu += sizeof(*du) + j * sizeof(du->eci[0]);
 			qoa->num_oa_units++;
 		}
include/uapi/drm/xe_drm.h +56 -17

118 lines not on this page · raw message

Signature · 1 line
2.41.0
#2 lore raw

✗ CI.Patch_applied: failure for Xe OA Consolidated Diffs (rev2)

In reply to Ashutosh Dixit
== Series Details ==

== Series Details ==

Series: Xe OA Consolidated Diffs (rev2)
URL : https://patchwork.freedesktop.org/series/128993/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: a942be9b4 drm-tip: 2024y-02m-08d-00h-15m-57s UTC integration manifest === git am output follows ===
error: drivers/gpu/drm/xe/xe_oa.c: does not exist in index
error: patch failed: drivers/gpu/drm/xe/xe_query.c:566
error: drivers/gpu/drm/xe/xe_query.c: patch does not apply
error: patch failed: include/uapi/drm/xe_drm.h:1385
error: include/uapi/drm/xe_drm.h: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: drm/xe/oa: Combined diff of changes between v8 and v9
Patch failed at 0001 drm/xe/oa: Combined diff of changes between v8 and v9 When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".