[Intel-xe] [RFC PATCH v3 3/3] drm/xe: Add platform specific functions for a new platform
Francois Dugast
francois.dugast at intel.com
Thu Mar 16 13:01:25 UTC 2023
This shows how platform specific code for a new platform can be
separated and maintained in its own file. With the use of function
pointers the modifications to the common code are minimal.
Signed-off-by: Francois Dugast <francois.dugast at intel.com>
---
drivers/gpu/drm/xe/Makefile | 1 +
drivers/gpu/drm/xe/xe_gt.c | 8 +++---
drivers/gpu/drm/xe/xe_gt.h | 4 +++
drivers/gpu/drm/xe/xe_guc_pc.c | 9 +++----
drivers/gpu/drm/xe/xe_guc_pc.h | 5 ++++
drivers/gpu/drm/xe/xe_newplatform.c | 34 ++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_newplatform.h | 15 ++++++++++++
drivers/gpu/drm/xe/xe_platform_types.h | 1 +
8 files changed, 68 insertions(+), 9 deletions(-)
create mode 100644 drivers/gpu/drm/xe/xe_newplatform.c
create mode 100644 drivers/gpu/drm/xe/xe_newplatform.h
diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index 4ae440d85918..8745f8095c36 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -67,6 +67,7 @@ xe-y += xe_bb.o \
xe_mmio.o \
xe_mocs.o \
xe_module.o \
+ xe_newplatform.o \
xe_pci.o \
xe_pcode.o \
xe_pm.o \
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 718cd18b6421..103547750ada 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -30,6 +30,7 @@
#include "xe_migrate.h"
#include "xe_mmio.h"
#include "xe_mocs.h"
+#include "xe_newplatform.h"
#include "xe_reg_sr.h"
#include "xe_ring_ops.h"
#include "xe_sa.h"
@@ -42,10 +43,6 @@
#include "xe_wa.h"
#include "xe_wopcm.h"
-struct xe_gt_platform_funcs {
- void (*setup_private_ppat)(struct xe_gt *gt);
-};
-
static void mtl_setup_private_ppat(struct xe_gt *gt);
static void pvc_setup_private_ppat(struct xe_gt *gt);
static void tgl_setup_private_ppat(struct xe_gt *gt);
@@ -413,6 +410,9 @@ int xe_gt_init_early(struct xe_gt *gt)
case XE_TIGERLAKE:
xe->gt_funcs = &tgl_funcs;
break;
+ case XE_NEWPLATFORM:
+ xe->gt_funcs = &newplatform_gt_funcs;
+ break;
default:
DRM_ERROR("Unsupported platform\n");
break;
diff --git a/drivers/gpu/drm/xe/xe_gt.h b/drivers/gpu/drm/xe/xe_gt.h
index 086369f7ee6d..18d732b49789 100644
--- a/drivers/gpu/drm/xe/xe_gt.h
+++ b/drivers/gpu/drm/xe/xe_gt.h
@@ -62,4 +62,8 @@ static inline bool xe_gt_is_usm_hwe(struct xe_gt *gt, struct xe_hw_engine *hwe)
hwe->instance == gt->usm.reserved_bcs_instance;
}
+struct xe_gt_platform_funcs {
+ void (*setup_private_ppat)(struct xe_gt *gt);
+};
+
#endif
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
index ef3ccf83ea3a..cffe7443c2ea 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.c
+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
@@ -19,6 +19,7 @@
#include "xe_guc_ct.h"
#include "xe_map.h"
#include "xe_mmio.h"
+#include "xe_newplatform.h"
#include "xe_pcode.h"
#define MCHBAR_MIRROR_BASE_SNB 0x140000
@@ -117,11 +118,6 @@ pc_to_maps(struct xe_guc_pc *pc)
return &pc->bo->vmap;
}
-struct xe_guc_pc_platform_funcs {
- void (*init_fused_rp_values)(struct xe_guc_pc *pc);
- void (*update_rpe_value)(struct xe_guc_pc *pc);
-};
-
static void mtl_init_fused_rp_values(struct xe_guc_pc *pc);
static void tgl_init_fused_rp_values(struct xe_guc_pc *pc);
static void mtl_update_rpe_value(struct xe_guc_pc *pc);
@@ -923,6 +919,9 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
case XE_TIGERLAKE:
xe->guc_pc_funcs = &tgl_funcs;
break;
+ case XE_NEWPLATFORM:
+ xe->guc_pc_funcs = &newplatform_guc_pc_funcs;
+ break;
default:
DRM_ERROR("Unsupported platform\n");
break;
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.h b/drivers/gpu/drm/xe/xe_guc_pc.h
index da29e4934868..c2c968da1dd2 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.h
+++ b/drivers/gpu/drm/xe/xe_guc_pc.h
@@ -12,4 +12,9 @@ int xe_guc_pc_init(struct xe_guc_pc *pc);
int xe_guc_pc_start(struct xe_guc_pc *pc);
int xe_guc_pc_stop(struct xe_guc_pc *pc);
+struct xe_guc_pc_platform_funcs {
+ void (*init_fused_rp_values)(struct xe_guc_pc *pc);
+ void (*update_rpe_value)(struct xe_guc_pc *pc);
+};
+
#endif /* _XE_GUC_PC_H_ */
diff --git a/drivers/gpu/drm/xe/xe_newplatform.c b/drivers/gpu/drm/xe/xe_newplatform.c
new file mode 100644
index 000000000000..9e791b633047
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_newplatform.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include "xe_newplatform.h"
+
+static void newplatform_setup_private_ppat(struct xe_gt *gt);
+static void newplatform_init_fused_rp_values(struct xe_guc_pc *pc);
+static void newplatform_update_rpe_value(struct xe_guc_pc *pc);
+
+const struct xe_gt_platform_funcs newplatform_gt_funcs = {
+ .setup_private_ppat = newplatform_setup_private_ppat,
+};
+
+const struct xe_guc_pc_platform_funcs newplatform_guc_pc_funcs = {
+ .init_fused_rp_values = newplatform_init_fused_rp_values,
+ .update_rpe_value = newplatform_update_rpe_value,
+};
+
+static void newplatform_setup_private_ppat(struct xe_gt *gt)
+{
+ /* platform specific implementation */
+}
+
+static void newplatform_init_fused_rp_values(struct xe_guc_pc *pc)
+{
+ /* platform specific implementation */
+}
+
+static void newplatform_update_rpe_value(struct xe_guc_pc *pc)
+{
+ /* platform specific implementation */
+}
diff --git a/drivers/gpu/drm/xe/xe_newplatform.h b/drivers/gpu/drm/xe/xe_newplatform.h
new file mode 100644
index 000000000000..e4e0448b86dd
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_newplatform.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef _XE_NEW_PLATFORM_H_
+#define _XE_NEW_PLATFORM_H_
+
+#include "xe_gt.h"
+#include "xe_guc_pc.h"
+
+extern const struct xe_gt_platform_funcs newplatform_gt_funcs;
+extern const struct xe_guc_pc_platform_funcs newplatform_guc_pc_funcs;
+
+#endif
diff --git a/drivers/gpu/drm/xe/xe_platform_types.h b/drivers/gpu/drm/xe/xe_platform_types.h
index 72612c832e88..aee2b1a4ba38 100644
--- a/drivers/gpu/drm/xe/xe_platform_types.h
+++ b/drivers/gpu/drm/xe/xe_platform_types.h
@@ -18,6 +18,7 @@ enum xe_platform {
XE_ALDERLAKE_S,
XE_ALDERLAKE_P,
XE_METEORLAKE,
+ XE_NEWPLATFORM,
};
enum xe_subplatform {
--
2.25.1
More information about the Intel-xe
mailing list