drm/xe/hwmon: Refactor xe hwmon
authorKarthik Poosa <karthik.poosa@intel.com>
Thu, 1 Feb 2024 18:06:00 +0000 (23:36 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 6 Feb 2024 13:42:03 +0000 (08:42 -0500)
Check latest platform first in xe_hwmon_get_reg.
Move PVC HWMON registers to regs/xe_pcode.h.

Suggested-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240201180600.434822-1-karthik.poosa@intel.com
drivers/gpu/drm/xe/regs/xe_gt_regs.h
drivers/gpu/drm/xe/regs/xe_pcode_regs.h [new file with mode: 0644]
drivers/gpu/drm/xe/xe_hwmon.c

index cd27480f6486268a7dd07d38afedae9668bbfc24..15ac2d284d48f6cdf59ded2fff9ee459ae4242a5 100644 (file)
 #define   GT_CS_MASTER_ERROR_INTERRUPT         REG_BIT(3)
 #define   GT_RENDER_USER_INTERRUPT             REG_BIT(0)
 
-#define PVC_GT0_PACKAGE_ENERGY_STATUS          XE_REG(0x281004)
-#define PVC_GT0_PACKAGE_RAPL_LIMIT             XE_REG(0x281008)
-#define PVC_GT0_PACKAGE_POWER_SKU_UNIT         XE_REG(0x281068)
-#define PVC_GT0_PLATFORM_ENERGY_STATUS         XE_REG(0x28106c)
-#define PVC_GT0_PACKAGE_POWER_SKU              XE_REG(0x281080)
-
 #endif
diff --git a/drivers/gpu/drm/xe/regs/xe_pcode_regs.h b/drivers/gpu/drm/xe/regs/xe_pcode_regs.h
new file mode 100644 (file)
index 0000000..3dae858
--- /dev/null
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2024 Intel Corporation
+ */
+
+#ifndef _XE_PCODE_REGS_H_
+#define _XE_PCODE_REGS_H_
+
+#include "regs/xe_reg_defs.h"
+
+/*
+ * This file contains addresses of PCODE registers visible through GT MMIO space.
+ */
+
+#define PVC_GT0_PACKAGE_ENERGY_STATUS           XE_REG(0x281004)
+#define PVC_GT0_PACKAGE_RAPL_LIMIT              XE_REG(0x281008)
+#define PVC_GT0_PACKAGE_POWER_SKU_UNIT          XE_REG(0x281068)
+#define PVC_GT0_PLATFORM_ENERGY_STATUS          XE_REG(0x28106c)
+#define PVC_GT0_PACKAGE_POWER_SKU               XE_REG(0x281080)
+
+#endif /* _XE_PCODE_REGS_H_ */
index 89c6f7f84b5a52863d9108021c0e50d19464ad2c..f0194d5121a5dd10547e34370ee2fead2eb95fd2 100644 (file)
@@ -10,6 +10,7 @@
 #include <drm/drm_managed.h>
 #include "regs/xe_gt_regs.h"
 #include "regs/xe_mchbar_regs.h"
+#include "regs/xe_pcode_regs.h"
 #include "xe_device.h"
 #include "xe_gt.h"
 #include "xe_hwmon.h"
@@ -77,32 +78,32 @@ static u32 xe_hwmon_get_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg hwmon_reg)
 
        switch (hwmon_reg) {
        case REG_PKG_RAPL_LIMIT:
-               if (xe->info.platform == XE_DG2)
-                       reg = PCU_CR_PACKAGE_RAPL_LIMIT;
-               else if (xe->info.platform == XE_PVC)
+               if (xe->info.platform == XE_PVC)
                        reg = PVC_GT0_PACKAGE_RAPL_LIMIT;
+               else if (xe->info.platform == XE_DG2)
+                       reg = PCU_CR_PACKAGE_RAPL_LIMIT;
                break;
        case REG_PKG_POWER_SKU:
-               if (xe->info.platform == XE_DG2)
-                       reg = PCU_CR_PACKAGE_POWER_SKU;
-               else if (xe->info.platform == XE_PVC)
+               if (xe->info.platform == XE_PVC)
                        reg = PVC_GT0_PACKAGE_POWER_SKU;
+               else if (xe->info.platform == XE_DG2)
+                       reg = PCU_CR_PACKAGE_POWER_SKU;
                break;
        case REG_PKG_POWER_SKU_UNIT:
-               if (xe->info.platform == XE_DG2)
-                       reg = PCU_CR_PACKAGE_POWER_SKU_UNIT;
-               else if (xe->info.platform == XE_PVC)
+               if (xe->info.platform == XE_PVC)
                        reg = PVC_GT0_PACKAGE_POWER_SKU_UNIT;
+               else if (xe->info.platform == XE_DG2)
+                       reg = PCU_CR_PACKAGE_POWER_SKU_UNIT;
                break;
        case REG_GT_PERF_STATUS:
                if (xe->info.platform == XE_DG2)
                        reg = GT_PERF_STATUS;
                break;
        case REG_PKG_ENERGY_STATUS:
-               if (xe->info.platform == XE_DG2)
-                       reg = PCU_CR_PACKAGE_ENERGY_STATUS;
-               else if (xe->info.platform == XE_PVC)
+               if (xe->info.platform == XE_PVC)
                        reg = PVC_GT0_PLATFORM_ENERGY_STATUS;
+               else if (xe->info.platform == XE_DG2)
+                       reg = PCU_CR_PACKAGE_ENERGY_STATUS;
                break;
        default:
                drm_warn(&xe->drm, "Unknown xe hwmon reg id: %d\n", hwmon_reg);