Skip to contentSkip to conversation

Catching up - round 2

PATCH In review Rodrigo Vivi 4 participants 27 messages Jan 20, 2023 – Jan 31, 2023

Subsystems (4)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

cover Catching up - round 2

Continuation of last week's:
https://lists.freedesktop.org/archives/intel-xe/2023-January/000024.html

More patches that we need to get proper reviews recorded or fixed subject before we can merge in cgit/drm-xe-next and continue the development in open.

I will also start to reply the patches individually asking questions and help.

Thanks,
Rodrigo.

Balasubramani Vivekanandan (1):
drm/xe/gt: Enable interrupt while initializing root gt

Lucas De Marchi (7):
drm/xe/ggtt: Use BIT_ULL() for 64bit
drm/xe: Fix some log messages on 32b
drm/xe/mmio: Use non-atomic writeq/readq variant for 32b drm/xe: Fix tracepoints on 32b
drm/xe/gt: Fix min() with u32 and u64
drm/xe: Add documentation for mem_type ]65;7002;1cdrm/xe: Add min config for kunit integration ARCH=um

Maarten Lankhorst (1):
drm/xe/ext: Dont call intel_display_power_is_enabled from irq
install/remove

Matthew Auld (2):
drm/xe/fbc: set compressed_fb to NULL on error
drm/xe/pcode: fix pcode error check

Matthew Brost (1):
drm/xe/migrate: Update emit_pte to cope with a size level than 4k

Mauro Carvalho Chehab (5):
drm/xe/Kconfig.debug: select DEBUG_FS for KUnit runs drm/xe: KUnit tests depend on CONFIG_DRM_FBDEV_EMULATION drm/xe: fix XE_DISPLAY dependency on ACPI drm/xe: allow building XE_DISPLAY without ACPI drm/xe: fix DRM_FBDEV_EMULATION dependencies

Philippe Lecluse (2):
drm/xe: fix xe_mmio_total_vram_size drm/xe: Fix Meteor Lake rsa issue on guc loading

Rodrigo Vivi (1):
drm/xe/guc_pc: Fix Meteor Lake registers.

 drivers/gpu/drm/i915/display/intel_fbc.c   |  2 +-
 drivers/gpu/drm/xe/.kunitconfig            | 11 ++++
 drivers/gpu/drm/xe/Kconfig.debug           |  3 +-
 drivers/gpu/drm/xe/Makefile                | 13 +++-
 drivers/gpu/drm/xe/display/ext/i915_irq.c  | 50 ++++------------
 drivers/gpu/drm/xe/tests/xe_migrate.c      |  6 +-
 drivers/gpu/drm/xe/xe_ggtt.c               |  4 +-
 drivers/gpu/drm/xe/xe_gt.c                 |  6 +-
 drivers/gpu/drm/xe/xe_guc_pc.c             | 70 ++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_guc_submit.c         |  2 +-
 drivers/gpu/drm/xe/xe_irq.c                |  2 +-
 drivers/gpu/drm/xe/xe_migrate.c            | 17 ++----
 drivers/gpu/drm/xe/xe_mmio.c               | 17 +-----
 drivers/gpu/drm/xe/xe_mmio.h               |  1 +
 drivers/gpu/drm/xe/xe_pcode.c              |  2 +-
 drivers/gpu/drm/xe/xe_trace.h              | 12 ++--
 drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h |  2 +-
 17 files changed, 129 insertions(+), 91 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/.kunitconfig
Signature · 1 line
2.39.0
author maintainer
#1 lore raw

PATCH 1/20 drm/xe/migrate: Update emit_pte to cope with a size level than 4k

From: Matthew Brost <[email protected]>

emit_pte assumes the size argument is 4k aligned, this may not be true for the PTEs emitted for CSS as seen by below call stack:

[   56.734228] xe_migrate_copy:585: size=327680, ccs_start=327680, css_size=1280,4096
[   56.734250] xe_migrate_copy:643: size=262144
[   56.734252] emit_pte:404: ptes=64
[   56.734255] emit_pte:418: chunk=64
[   56.734257] xe_migrate_copy:650: size=1024	@ CCS emit PTE
[   56.734259] emit_pte:404: ptes=1
[   56.734261] emit_pte:418: chunk=1
[   56.734339] xe_migrate_copy:643: size=65536
[   56.734342] emit_pte:404: ptes=16
[   56.734344] emit_pte:418: chunk=16
[   56.734346] xe_migrate_copy:650: size=256	# CCS emit PTE
[   56.734348] emit_pte:404: ptes=1
[   56.734350] emit_pte:418: chunk=1
[   56.734352] xe_res_next:174: size=4096, remaining=0

Update emit_pte to handle sizes less than 4k.

---
 drivers/gpu/drm/xe/xe_migrate.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/gpu/drm/xe/xe_migrate.c +6 -11
index 7b9f3de11b47..e9a08d68d17a 100644
@@ -453,11 +453,8 @@ static void emit_pte(struct xe_migrate *m,
 		while (chunk--) {
 			u64 addr;
 
-			XE_BUG_ON(cur->start & (PAGE_SIZE - 1));
-
+			addr = xe_res_dma(cur) & PAGE_MASK;
 			if (is_vram) {
-				addr = cur->start;
-
 				/* Is this a 64K PTE entry? */
 				if ((m->eng->vm->flags & XE_VM_FLAGS_64K) &&
 				    !(cur_ofs & (16 * 8 - 1))) {
@@ -466,14 +463,12 @@ static void emit_pte(struct xe_migrate *m,
 				}
 
 				addr |= GEN12_PPGTT_PTE_LM;
-			} else {
-				addr = xe_res_dma(cur);
 			}
 			addr |= PPAT_CACHED | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
 			bb->cs[bb->len++] = lower_32_bits(addr);
 			bb->cs[bb->len++] = upper_32_bits(addr);
 
-			xe_res_next(cur, PAGE_SIZE);
+			xe_res_next(cur, min(size, (u32)PAGE_SIZE));
 			cur_ofs += 8;
 		}
 	}
@@ -615,13 +610,13 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
 	bool copy_system_ccs = copy_ccs && (!src_is_vram || !dst_is_vram);
 
 	if (!src_is_vram)
-		xe_res_first_sg(xe_bo_get_sg(bo), 0, bo->size, &src_it);
+		xe_res_first_sg(xe_bo_get_sg(bo), 0, size, &src_it);
 	else
-		xe_res_first(src, 0, bo->size, &src_it);
+		xe_res_first(src, 0, size, &src_it);
 	if (!dst_is_vram)
-		xe_res_first_sg(xe_bo_get_sg(bo), 0, bo->size, &dst_it);
+		xe_res_first_sg(xe_bo_get_sg(bo), 0, size, &dst_it);
 	else
-		xe_res_first(dst, 0, bo->size, &dst_it);
+		xe_res_first(dst, 0, size, &dst_it);
 
 	if (copy_system_ccs)
 		xe_res_first_sg(xe_bo_get_sg(bo), xe_bo_ccs_pages_start(bo),
Signature · 1 line
2.39.0
author maintainer
#2 lore raw

PATCH 2/20 drm/xe/fbc: set compressed_fb to NULL on error

In reply to Rodrigo Vivi

From: Matthew Auld <[email protected]>

On DG2 we get a massive flood of the following:

[ 1068.790446] xe 0000:03:00.0: drm_WARN_ON((!!(fbc->compressed_fb)))
[ 1068.790465] WARNING: CPU: 9 PID: 637 at drivers/gpu/drm/xe/display/intel_fbc.c:843 intel_fbc_update+0x605/0x670 [xe]
---
 drivers/gpu/drm/i915/display/intel_fbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_fbc.c +1 -1
index 82bc21b09332..13f03c6ea818 100644
@@ -75,7 +75,7 @@ static int i915_gem_stolen_insert_node_in_range(struct xe_device *xe, struct xe_
 					ttm_bo_type_kernel, flags);
 	if (IS_ERR(*bo)) {
 		err = PTR_ERR(*bo);
-		bo = NULL;
+		*bo = NULL;
 		return err;
 	}
 	err = xe_bo_pin(*bo);
Signature · 1 line
2.39.0
author maintainer
#3 lore raw

Re: [Intel-xe] [PATCH 02/20] drm/xe/fbc: set compressed_fb to NULL on error

Quoted 9 lines · Rodrigo Vivi

From: Matthew Auld <[email protected]>

On DG2 we get a massive flood of the following:

[ 1068.790446] xe 0000:03:00.0: drm_WARN_ON((!!(fbc->compressed_fb)))
[ 1068.790465] WARNING: CPU: 9 PID: 637 at drivers/gpu/drm/xe/display/intel_fbc.c:843 intel_fbc_update+0x605/0x670 [xe]
Cc Maarten Lankhort <[email protected]>

Maarten, may I convert your gitlab approvals per reviewed-bys here? or do you intend to go patch by patch here in the mailing list?

Quoted 21 lines
---
 drivers/gpu/drm/i915/display/intel_fbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_fbc.c +1 -2
index 82bc21b09332..13f03c6ea818 100644
@@ -75,7 +75,7 @@ static int i915_gem_stolen_insert_node_in_range(struct xe_device *xe, struct xe_
 					ttm_bo_type_kernel, flags);
 	if (IS_ERR(*bo)) {
 		err = PTR_ERR(*bo);
-		bo = NULL;
+		*bo = NULL;
 		return err;
 	}
 	err = xe_bo_pin(*bo);
--

2.39.0

author maintainer
#4 lore raw

PATCH 3/20 drm/xe/pcode: fix pcode error check

In reply to Rodrigo Vivi

From: Matthew Auld <[email protected]>

On DG2 we are now getting:

[  104.456607] xe 0000:03:00.0: [drm] *ERROR* PCODE timeout, retrying with preemption disabled

Looks like we just need to invert the error check for xe_pcode_try_request(), which returns zero on success.

---
 drivers/gpu/drm/xe/xe_pcode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_pcode.c +1 -1
index 39712e843728..1a76fe478853 100644
@@ -155,7 +155,7 @@ int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
 
 	ret = xe_pcode_try_request(gt, mbox, request, reply_mask, reply, &status,
 				   false, timeout_base_ms * 1000);
-	if (ret)
+	if (!ret)
 		goto out;
 
 	/*
Signature · 1 line
2.39.0
author maintainer
#5 lore raw

PATCH 4/20 drm/xe: fix xe_mmio_total_vram_size

In reply to Rodrigo Vivi

From: Philippe Lecluse <[email protected]>

As also cause issue on PVC, moving back
to what we did before stolen was
introduced

---
 drivers/gpu/drm/xe/xe_mmio.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_mmio.c +2 -6
index b3c1a39ef79d..7600ce348005 100644
@@ -162,12 +162,8 @@ int xe_mmio_total_vram_size(struct xe_device *xe, u64 *vram_size, u64 *usable_si
 
 	if (!xe->info.has_flat_ccs)  {
 		*vram_size = pci_resource_len(pdev, GEN12_LMEM_BAR);
-		if (usable_size) {
-			if (xe->info.platform == XE_DG1)
-				*usable_size = xe_mmio_read64(gt, GEN12_GSMBASE.reg);
-			else
-				*usable_size = *vram_size;
-		}
+		if (usable_size)
+			*usable_size = min(*vram_size, xe_mmio_read64(gt, GEN12_GSMBASE.reg));
 		return 0;
 	}
 
Signature · 1 line
2.39.0
author maintainer
#6 lore raw

PATCH 5/20 drm/xe/ggtt: Use BIT_ULL() for 64bit

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Make sure it's 64bit value in both 32b and 64b arch.

---
 drivers/gpu/drm/xe/xe_ggtt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_ggtt.c +2 -2
index d67f66b33aed..78557654e96e 100644
@@ -20,8 +20,8 @@
 #include "../i915/gt/intel_gt_regs.h"
 
 /* FIXME: Common file, preferably auto-gen */
-#define MTL_GGTT_PTE_PAT0	BIT(52)
-#define MTL_GGTT_PTE_PAT1	BIT(53)
+#define MTL_GGTT_PTE_PAT0	BIT_ULL(52)
+#define MTL_GGTT_PTE_PAT1	BIT_ULL(53)
 
 u64 xe_ggtt_pte_encode(struct xe_bo *bo, u64 bo_offset)
 {
Signature · 1 line
2.39.0
author maintainer
#7 lore raw

PATCH 6/20 drm/xe: Fix some log messages on 32b

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Either use the proper format or cast up to 64b depending on the case.

---
 drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++---
 drivers/gpu/drm/xe/xe_guc_submit.c    | 2 +-
 drivers/gpu/drm/xe/xe_mmio.c          | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/tests/xe_migrate.c +3 -3
index 0f3b819f0a34..03a60d5b42f1 100644
@@ -263,9 +263,9 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)
 		goto free_tiny;
 	}
 
-	kunit_info(test, "Starting tests, top level PT addr: %llx, special pagetable base addr: %llx\n",
-		   xe_bo_main_addr(m->eng->vm->pt_root[id]->bo, GEN8_PAGE_SIZE),
-		   xe_bo_main_addr(m->pt_bo, GEN8_PAGE_SIZE));
+	kunit_info(test, "Starting tests, top level PT addr: %lx, special pagetable base addr: %lx\n",
+		   (unsigned long)xe_bo_main_addr(m->eng->vm->pt_root[id]->bo, GEN8_PAGE_SIZE),
+		   (unsigned long)xe_bo_main_addr(m->pt_bo, GEN8_PAGE_SIZE));
 
 	/* First part of the test, are we updating our pagetable bo with a new entry? */
 	xe_map_wr(xe, &bo->vmap, GEN8_PAGE_SIZE * (NUM_KERNEL_PDE - 1), u64, 0xdeaddeadbeefbeef);
drivers/gpu/drm/xe/xe_guc_submit.c +1 -1
index 8ce3751f4705..e72329598848 100644
@@ -1632,7 +1632,7 @@ static void guc_engine_wq_print(struct xe_engine *e, struct drm_printer *p)
 		for (i = parallel_read(xe, map, wq_desc.head);
 		     i != parallel_read(xe, map, wq_desc.tail);
 		     i = (i + sizeof(u32)) % WQ_SIZE)
-			drm_printf(p, "\tWQ[%ld]: 0x%08x\n", i / sizeof(u32),
+			drm_printf(p, "\tWQ[%zu]: 0x%08x\n", i / sizeof(u32),
 				   parallel_read(xe, map, wq[i / sizeof(u32)]));
 	}
 }
drivers/gpu/drm/xe/xe_mmio.c +1 -1
index 7600ce348005..372ee632898f 100644
@@ -237,7 +237,7 @@ int xe_mmio_probe_vram(struct xe_device *xe)
 			 (u64)xe->mem.vram.size >> 20);
 	if (xe->mem.vram.size < lmem_size)
 		drm_warn(&xe->drm, "Restricting VRAM size to PCI resource size (0x%llx->0x%llx)\n",
-			 lmem_size, xe->mem.vram.size);
+			 lmem_size, (u64)xe->mem.vram.size);
 
 #ifdef CONFIG_64BIT
 	xe->mem.vram.mapping = ioremap_wc(xe->mem.vram.io_start, xe->mem.vram.size);
Signature · 1 line
2.39.0
author maintainer
#8 lore raw

PATCH 7/20 drm/xe/mmio: Use non-atomic writeq/readq variant for 32b

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

writeq() and readq() and other functions working on 64 bit variables are not provided by 32b arch. For that it's needed to choose between linux/io-64-nonatomic-hi-lo.h and linux/io-64-nonatomic-lo-hi.h, spliting the read/write in 2 accesses. For xe driver, it doesn't matter much, so just choose one and include in xe_mmio.h.

This also removes some ifdef CONFIG_64BIT we had around because of the missing 64bit functions.

---
 drivers/gpu/drm/xe/xe_mmio.c | 7 -------
 drivers/gpu/drm/xe/xe_mmio.h | 1 +
 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/xe/xe_mmio.c +0 -7
index 372ee632898f..30efe3569b5c 100644
@@ -51,7 +51,6 @@ static int xe_set_dma_info(struct xe_device *xe)
 	return err;
 }
 
-#ifdef CONFIG_64BIT
 static int
 _resize_bar(struct xe_device *xe, int resno, resource_size_t size)
 {
@@ -135,9 +134,6 @@ static int xe_resize_lmem_bar(struct xe_device *xe, resource_size_t lmem_size)
 	pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd);
 	return ret;
 }
-#else
-static int xe_resize_lmem_bar(struct xe_device *xe, resource_size_t lmem_size) { return 0; }
-#endif
 
 static bool xe_pci_resource_valid(struct pci_dev *pdev, int bar)
 {
@@ -239,10 +235,7 @@ int xe_mmio_probe_vram(struct xe_device *xe)
 		drm_warn(&xe->drm, "Restricting VRAM size to PCI resource size (0x%llx->0x%llx)\n",
 			 lmem_size, (u64)xe->mem.vram.size);
 
-#ifdef CONFIG_64BIT
 	xe->mem.vram.mapping = ioremap_wc(xe->mem.vram.io_start, xe->mem.vram.size);
-#endif
-
 	xe->mem.vram.size = min_t(u64, xe->mem.vram.size, usable_size);
 
 	drm_info(&xe->drm, "TOTAL VRAM: %pa, %pa\n", &xe->mem.vram.io_start, &xe->mem.vram.size);
drivers/gpu/drm/xe/xe_mmio.h +1 -0
index 7e7149c8d5ec..1bb7badf5898 100644
@@ -7,6 +7,7 @@
 #define _XE_MMIO_H_
 
 #include <linux/delay.h>
+#include <linux/io-64-nonatomic-lo-hi.h>
 
 #include "xe_gt_types.h"
 
Signature · 1 line
2.39.0
author maintainer
#9 lore raw

PATCH 8/20 drm/xe: Fix tracepoints on 32b

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Leave the types as u64, but cast the pointers to unsigned long before assigning so the compiler doesn't throw warning about casting a pointer to integer of different size.

Also, size_t should use %zu, not %ld.

---
 drivers/gpu/drm/xe/xe_trace.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_trace.h +6 -6
index 436593980c08..a00d4b210c3b 100644
@@ -32,10 +32,10 @@ DECLARE_EVENT_CLASS(xe_bo,
 		    TP_fast_assign(
 			   __entry->size = bo->size;
 			   __entry->flags = bo->flags;
-			   __entry->vm = (u64)bo->vm;
+			   __entry->vm = (unsigned long)bo->vm;
 			   ),
 
-		    TP_printk("size=%ld, flags=0x%02x, vm=0x%016llx",
+		    TP_printk("size=%zu, flags=0x%02x, vm=0x%016llx",
 			      __entry->size, __entry->flags, __entry->vm)
 );
 
@@ -185,7 +185,7 @@ DECLARE_EVENT_CLASS(xe_sched_job,
 			   atomic_read(&job->engine->guc->state);
 			   __entry->flags = job->engine->flags;
 			   __entry->error = job->fence->error;
-			   __entry->fence = (u64)job->fence;
+			   __entry->fence = (unsigned long)job->fence;
 			   __entry->batch_addr = (u64)job->batch_addr[0];
 			   ),
 
@@ -272,7 +272,7 @@ DECLARE_EVENT_CLASS(xe_hw_fence,
 		    TP_fast_assign(
 			   __entry->ctx = fence->dma.context;
 			   __entry->seqno = fence->dma.seqno;
-			   __entry->fence = (u64)fence;
+			   __entry->fence = (unsigned long)fence;
 			   ),
 
 		    TP_printk("ctx=0x%016llx, fence=0x%016llx, seqno=%u",
@@ -312,7 +312,7 @@ DECLARE_EVENT_CLASS(xe_vma,
 			     ),
 
 		    TP_fast_assign(
-			   __entry->vma = (u64)vma;
+			   __entry->vma = (unsigned long)vma;
 			   __entry->asid = vma->vm->usm.asid;
 			   __entry->start = vma->start;
 			   __entry->end = vma->end;
@@ -409,7 +409,7 @@ DECLARE_EVENT_CLASS(xe_vm,
 			     ),
 
 		    TP_fast_assign(
-			   __entry->vm = (u64)vm;
+			   __entry->vm = (unsigned long)vm;
 			   __entry->asid = vm->usm.asid;
 			   ),
 
Signature · 1 line
2.39.0
author maintainer
#10 lore raw

PATCH 9/20 drm/xe/gt: Fix min() with u32 and u64

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Fix the following error while building for 32b:

In file included from ../drivers/gpu/drm/xe/xe_gt.c:6:
../drivers/gpu/drm/xe/xe_gt.c: In function ‘gt_ttm_mgr_init’:
../include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast [-Werror]
20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^~

Cast it to u64 so size of the second operand matches the first one when building it for 32 bits.

---
 drivers/gpu/drm/xe/xe_gt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_gt.c +1 -1
index cb837745d893..bf5364046bab 100644
@@ -183,7 +183,7 @@ static int gt_ttm_mgr_init(struct xe_gt *gt)
 		if (err)
 			return err;
 		gtt_size = min(max((XE_DEFAULT_GTT_SIZE_MB << 20),
-				   gt->mem.vram.size),
+				   (u64)gt->mem.vram.size),
 			       gtt_size);
 		xe->info.mem_region_mask |= BIT(gt->info.vram_id) << 1;
 	}
Signature · 1 line
2.39.0
author maintainer
#11 lore raw

PATCH 10/20 drm/xe: Add documentation for mem_type

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

mem_type field was added in commit 3acae0eae518 ("drm/xe: Implement stolen memory.") to designate the TTM memory type for that mgr. Add kernel-doc with its description.

---
 drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h +1 -1
index cf02c62ff427..39aa2ec1b968 100644
@@ -27,7 +27,7 @@ struct xe_ttm_vram_mgr {
 	u64 default_page_size;
 	/** @lock: protects allocations of VRAM */
 	struct mutex lock;
-
+	/** @mem_type: The TTM memory type */
 	u32 mem_type;
 };
 
Signature · 1 line
2.39.0
author maintainer
#12 lore raw

PATCH 11/20 drm/xe/ext: Dont call intel_display_power_is_enabled from irq install/remove

In reply to Rodrigo Vivi

From: Maarten Lankhorst <[email protected]>

Just assume all power domains are enabled, since we use the INIT domain when suspending/resuming.

Not taking a mutex inside a spinlock makes suspend/resume work again.

---
 drivers/gpu/drm/xe/display/ext/i915_irq.c | 50 +++++------------------
 1 file changed, 11 insertions(+), 39 deletions(-)
drivers/gpu/drm/xe/display/ext/i915_irq.c +11 -39
index 36b684230663..183071eb50f5 100644
@@ -1407,34 +1407,20 @@ void gen11_display_irq_reset(struct drm_i915_private *dev_priv)
 	enum pipe pipe;
 	u32 trans_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) |
 		BIT(TRANSCODER_C) | BIT(TRANSCODER_D);
+	enum transcoder trans;
 
 	if (!HAS_DISPLAY(dev_priv))
 		return;
 
 	intel_uncore_write(dev_priv, GEN11_DISPLAY_INT_CTL, 0);
 
-	if (DISPLAY_VER(dev_priv) >= 12) {
-		enum transcoder trans;
-
-		for_each_cpu_transcoder_masked(dev_priv, trans, trans_mask) {
-			enum intel_display_power_domain domain;
-
-			domain = POWER_DOMAIN_TRANSCODER(trans);
-			if (!intel_display_power_is_enabled(dev_priv, domain))
-				continue;
-
-			intel_uncore_write(dev_priv, TRANS_PSR_IMR(trans), 0xffffffff);
-			intel_uncore_write(dev_priv, TRANS_PSR_IIR(trans), 0xffffffff);
-		}
-	} else {
-		intel_uncore_write(dev_priv, EDP_PSR_IMR, 0xffffffff);
-		intel_uncore_write(dev_priv, EDP_PSR_IIR, 0xffffffff);
+	for_each_cpu_transcoder_masked(dev_priv, trans, trans_mask) {
+		intel_uncore_write(dev_priv, TRANS_PSR_IMR(trans), 0xffffffff);
+		intel_uncore_write(dev_priv, TRANS_PSR_IIR(trans), 0xffffffff);
 	}
 
 	for_each_pipe(dev_priv, pipe)
-		if (intel_display_power_is_enabled(dev_priv,
-						   POWER_DOMAIN_PIPE(pipe)))
-			GEN8_IRQ_RESET_NDX(dev_priv, DE_PIPE, pipe);
+		GEN8_IRQ_RESET_NDX(dev_priv, DE_PIPE, pipe);
 
 	GEN3_IRQ_RESET(dev_priv, GEN8_DE_PORT_);
 	GEN3_IRQ_RESET(dev_priv, GEN8_DE_MISC_);
@@ -1653,6 +1639,7 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
 	u32 de_misc_masked = GEN8_DE_EDP_PSR;
 	u32 trans_mask = BIT(TRANSCODER_A) | BIT(TRANSCODER_B) |
 		BIT(TRANSCODER_C) | BIT(TRANSCODER_D);
+	enum transcoder trans;
 	enum pipe pipe;
 
 	if (!HAS_DISPLAY(dev_priv))
@@ -1682,30 +1669,15 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
 	else if (IS_BROADWELL(dev_priv))
 		de_port_enables |= BDW_DE_PORT_HOTPLUG_MASK;
 
-	if (DISPLAY_VER(dev_priv) >= 12) {
-		enum transcoder trans;
-
-		for_each_cpu_transcoder_masked(dev_priv, trans, trans_mask) {
-			enum intel_display_power_domain domain;
-
-			domain = POWER_DOMAIN_TRANSCODER(trans);
-			if (!intel_display_power_is_enabled(dev_priv, domain))
-				continue;
-
-			gen3_assert_iir_is_zero(dev_priv, TRANS_PSR_IIR(trans));
-		}
-	} else {
-		gen3_assert_iir_is_zero(dev_priv, EDP_PSR_IIR);
-	}
+	for_each_cpu_transcoder_masked(dev_priv, trans, trans_mask)
+		gen3_assert_iir_is_zero(dev_priv, TRANS_PSR_IIR(trans));
 
 	for_each_pipe(dev_priv, pipe) {
 		dev_priv->de_irq_mask[pipe] = ~de_pipe_masked;
 
-		if (intel_display_power_is_enabled(dev_priv,
-				POWER_DOMAIN_PIPE(pipe)))
-			GEN8_IRQ_INIT_NDX(dev_priv, DE_PIPE, pipe,
-					  dev_priv->de_irq_mask[pipe],
-					  de_pipe_enables);
+		GEN8_IRQ_INIT_NDX(dev_priv, DE_PIPE, pipe,
+				  dev_priv->de_irq_mask[pipe],
+				  de_pipe_enables);
 	}
 
 	GEN3_IRQ_INIT(dev_priv, GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
Signature · 1 line
2.39.0
author maintainer
#13 lore raw

PATCH 12/20 ]65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

In reply to Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Some of the tests may benefit from running with ARCH=um, forgoing any additional setup on the CI build side. Add min config for that.

Tested with:

	./tools/testing/kunit/kunit.py build \
		--kunitconfig drivers/gpu/drm/xe/.kunitconfig \
		--jobs $(nproc) \
		--build_dir build_kunit
---
 drivers/gpu/drm/xe/.kunitconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/.kunitconfig
drivers/gpu/drm/xe/.kunitconfig new file +7 -0
new file mode 100644
index 000000000000..ce8a4348669d
@@ -0,0 +1,7 @@
+# xe dependencies
+CONFIG_KUNIT=y
+CONFIG_PCI=y
+CONFIG_DRM=y
+CONFIG_DRM_XE=y
+CONFIG_EXPERT=y
+CONFIG_DRM_XE_KUNIT_TEST=y
Signature · 1 line
2.39.0
Reviewed-by on v1 12/20
#14 lore raw

Re: [Intel-xe] [PATCH 12/20] ]65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

Em Fri, 20 Jan 2023 15:44:18 -0500
Rodrigo Vivi <[email protected]> escreveu:

Quoted 7 lines

From: Lucas De Marchi <[email protected]>

Some of the tests may benefit from running with ARCH=um, forgoing any additional setup on the CI build side. Add min config for that.

Tested with:

Quoted 8 lines
	./tools/testing/kunit/kunit.py build \
		--kunitconfig drivers/gpu/drm/xe/.kunitconfig \
		--jobs $(nproc) \
		--build_dir build_kunit

There are some issues on this patch that were addressed later on in this series, on other patches, but, as after having this series applied, kunit.py runs, feel free to add:

Regards,
Mauro

PS.: I think "--jobs $(nproc)" is optional, as kunit.py already does that.

Quoted 11 lines
---
 drivers/gpu/drm/xe/.kunitconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/.kunitconfig
drivers/gpu/drm/xe/.kunitconfig new file +0 -0
new file mode 100644
index 000000000000..ce8a4348669d

drivers/gpu/drm/xe/.kunitconfig line 7

Quoted 7 lines
drivers/gpu/drm/xe/.kunitconfig new file +7 -0
@@ -0,0 +1,7 @@
+# xe dependencies
+CONFIG_KUNIT=y
+CONFIG_PCI=y
+CONFIG_DRM=y
+CONFIG_DRM_XE=y
+CONFIG_EXPERT=y
+CONFIG_DRM_XE_KUNIT_TEST=y

Thanks,
Mauro

#15 lore raw

Re: [Intel-xe] [PATCH 12/20] ]65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

In reply to Rodrigo Vivi
Quoted 1 line · Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Just noted some garbage chars in the subject of the this patch:

drm/xe: Add min config for kunit integration ARCH=um

65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

If you can remove that while applying, I'd appreciate. Should had been:

drm/xe: Add min config for kunit integration ARCH=um

thanks
Lucas De Marchi

author maintainer
#16 lore raw

Re: [Intel-xe] [PATCH 12/20] ]65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

Quoted 4 lines · Lucas De Marchi
Quoted 1 line · Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Just noted some garbage chars in the subject of the this patch:

yeap, I just noticed this while replying to Mauro and have already removed in my tree.

Thanks a lot,
Rodrigo.

Quoted 11 lines

drm/xe: Add min config for kunit integration ARCH=um

65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

If you can remove that while applying, I'd appreciate. Should had been:

drm/xe: Add min config for kunit integration ARCH=um

thanks
Lucas De Marchi

author maintainer
#17 lore raw

Re: [Intel-xe] [PATCH 12/20] ]65; 7002; 1cdrm/xe: Add min config for kunit integration ARCH=um

In reply to Rodrigo Vivi
Quoted 7 lines · Rodrigo Vivi

From: Lucas De Marchi <[email protected]>

Some of the tests may benefit from running with ARCH=um, forgoing any additional setup on the CI build side. Add min config for that.

Tested with:

Quoted 7 lines
	./tools/testing/kunit/kunit.py build \
		--kunitconfig drivers/gpu/drm/xe/.kunitconfig \
		--jobs $(nproc) \
		--build_dir build_kunit
Cc Mauro Carvalho Chehab <[email protected]>

Mauro, may I convert your gitlab approvals in rv-bs or do you intend to go one by one here in the ml?

Quoted 22 lines
---
 drivers/gpu/drm/xe/.kunitconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/.kunitconfig
drivers/gpu/drm/xe/.kunitconfig new file +7 -0
new file mode 100644
index 000000000000..ce8a4348669d
@@ -0,0 +1,7 @@
+# xe dependencies
+CONFIG_KUNIT=y
+CONFIG_PCI=y
+CONFIG_DRM=y
+CONFIG_DRM_XE=y
+CONFIG_EXPERT=y
+CONFIG_DRM_XE_KUNIT_TEST=y
Signature · 1 line
2.39.0
author maintainer
#18 lore raw

PATCH 13/20 drm/xe/Kconfig.debug: select DEBUG_FS for KUnit runs

In reply to Rodrigo Vivi

From: Mauro Carvalho Chehab <[email protected]>

KUnit reuquires debugfs, as otherwise, it won't build:

$ make ARCH=x86_64 O=.kunit --jobs=8
ERROR:root:../drivers/gpu/drm/xe/display/intel_display_debugfs.c:1612:6: error: redefinition of ‘intel_display_debugfs_register’
 1612 | void intel_display_debugfs_register(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/display/intel_display_debugfs.c:18:
../drivers/gpu/drm/xe/display/intel_display_debugfs.h:18:20: note: previous definition of ‘intel_display_debugfs_register’ with type ‘void(struct xe_device *)’
   18 | static inline void intel_display_debugfs_register(struct drm_i915_private *i915) {}
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_display_debugfs.c:1935:6: error: redefinition of ‘intel_connector_debugfs_add’
 1935 | void intel_connector_debugfs_add(struct intel_connector *intel_connector)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_display_debugfs.h:19:20: note: previous definition of ‘intel_connector_debugfs_add’ with type ‘void(struct intel_connector *)’
   19 | static inline void intel_connector_debugfs_add(struct intel_connector *connector) {}
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_display_debugfs.c:1993:6: error: redefinition of ‘intel_crtc_debugfs_add’
 1993 | void intel_crtc_debugfs_add(struct drm_crtc *crtc)
      |      ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_display_debugfs.h:20:20: note: previous definition of ‘intel_crtc_debugfs_add’ with type ‘void(struct drm_crtc *)’
   20 | static inline void intel_crtc_debugfs_add(struct drm_crtc *crtc) {}
      |                    ^~~~~~~~~~~~~~~~~~~~~~
---
 drivers/gpu/drm/xe/.kunitconfig  | 1 +
 drivers/gpu/drm/xe/Kconfig.debug | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/.kunitconfig +1 -0
index ce8a4348669d..aaf30db71cea 100644
@@ -1,6 +1,7 @@
 # xe dependencies
 CONFIG_KUNIT=y
 CONFIG_PCI=y
+CONFIG_DEBUG_FS=y
 CONFIG_DRM=y
 CONFIG_DRM_XE=y
 CONFIG_EXPERT=y
drivers/gpu/drm/xe/Kconfig.debug +1 -1
index 0d42f30fbe81..b7fd6fa17bff 100644
@@ -63,7 +63,7 @@ config DRM_XE_SIMPLE_ERROR_CAPTURE
 
 config DRM_XE_KUNIT_TEST
         tristate "KUnit tests for the drm xe driver" if !KUNIT_ALL_TESTS
-	depends on DRM_XE && KUNIT
+	depends on DRM_XE && KUNIT && DEBUG_FS
 	default KUNIT_ALL_TESTS
 	select DRM_EXPORT_FOR_TESTS if m
 	help
Signature · 1 line
2.39.0
author maintainer
#19 lore raw

PATCH 14/20 drm/xe: KUnit tests depend on CONFIG_DRM_FBDEV_EMULATION

In reply to Rodrigo Vivi

From: Mauro Carvalho Chehab <[email protected]>

ERROR:root:../drivers/gpu/drm/xe/display/intel_fbdev.c:585:5: error: redefinition of ‘intel_fbdev_init’
585 | int intel_fbdev_init(struct drm_device *dev)

      |     ^~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/display/intel_fbdev.c:55:
../drivers/gpu/drm/xe/display/intel_fbdev.h:26:19: note: previous definition of ‘intel_fbdev_init’ with type ‘int(struct drm_device *)’
   26 | static inline int intel_fbdev_init(struct drm_device *dev)
      |                   ^~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:626:6: error: redefinition of ‘intel_fbdev_initial_config_async’
  626 | void intel_fbdev_initial_config_async(struct drm_device *dev)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:31:20: note: previous definition of ‘intel_fbdev_initial_config_async’ with type ‘void(struct drm_device *)’
   31 | static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:646:6: error: redefinition of ‘intel_fbdev_unregister’
  646 | void intel_fbdev_unregister(struct drm_i915_private *dev_priv)
      |      ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:35:20: note: previous definition of ‘intel_fbdev_unregister’ with type ‘void(struct xe_device *)’
   35 | static inline void intel_fbdev_unregister(struct drm_i915_private *dev_priv)
      |                    ^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:661:6: error: redefinition of ‘intel_fbdev_fini’
  661 | void intel_fbdev_fini(struct drm_i915_private *dev_priv)
      |      ^~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:39:20: note: previous definition of ‘intel_fbdev_fini’ with type ‘void(struct xe_device *)’
   39 | static inline void intel_fbdev_fini(struct drm_i915_private *dev_priv)
      |                    ^~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:692:6: error: redefinition of ‘intel_fbdev_set_suspend’
  692 | void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
      |      ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:43:20: note: previous definition of ‘intel_fbdev_set_suspend’ with type ‘void(struct drm_device *, int,  bool)’ {aka ‘void(struct drm_device *, int,  _Bool)’}
   43 | static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:751:6: error: redefinition of ‘intel_fbdev_output_poll_changed’
  751 | void intel_fbdev_output_poll_changed(struct drm_device *dev)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:47:20: note: previous definition of ‘intel_fbdev_output_poll_changed’ with type ‘void(struct drm_device *)’
   47 | static inline void intel_fbdev_output_poll_changed(struct drm_device *dev)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:770:6: error: redefinition of ‘intel_fbdev_restore_mode’
  770 | void intel_fbdev_restore_mode(struct drm_device *dev)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:51:20: note: previous definition of ‘intel_fbdev_restore_mode’ with type ‘void(struct drm_device *)’
   51 | static inline void intel_fbdev_restore_mode(struct drm_device *dev)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.c:785:27: error: redefinition of ‘intel_fbdev_framebuffer’
  785 | struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev)
      |                           ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_fbdev.h:54:41: note: previous definition of ‘intel_fbdev_framebuffer’ with type ‘struct intel_framebuffer *(struct intel_fbdev *)’
   54 | static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev)
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~
---
 drivers/gpu/drm/xe/.kunitconfig  | 3 +++
 drivers/gpu/drm/xe/Kconfig.debug | 1 +
 2 files changed, 4 insertions(+)
drivers/gpu/drm/xe/.kunitconfig +3 -0
index aaf30db71cea..06ed30420a8d 100644
@@ -3,6 +3,9 @@ CONFIG_KUNIT=y
 CONFIG_PCI=y
 CONFIG_DEBUG_FS=y
 CONFIG_DRM=y
+CONFIG_DRM_FBDEV_EMULATION=y
+CONFIG_DRM_KMS_HELPER=y
 CONFIG_DRM_XE=y
 CONFIG_EXPERT=y
+CONFIG_FB=y
 CONFIG_DRM_XE_KUNIT_TEST=y
drivers/gpu/drm/xe/Kconfig.debug +1 -0
index b7fd6fa17bff..6726caa63acc 100644
@@ -64,6 +64,7 @@ config DRM_XE_SIMPLE_ERROR_CAPTURE
 config DRM_XE_KUNIT_TEST
         tristate "KUnit tests for the drm xe driver" if !KUNIT_ALL_TESTS
 	depends on DRM_XE && KUNIT && DEBUG_FS
+	depends on FB && FB = DRM_KMS_HELPER && DRM_FBDEV_EMULATION
 	default KUNIT_ALL_TESTS
 	select DRM_EXPORT_FOR_TESTS if m
 	help
Signature · 1 line
2.39.0
author maintainer
#20 lore raw

PATCH 15/20 drm/xe: fix XE_DISPLAY dependency on ACPI

In reply to Rodrigo Vivi

From: Mauro Carvalho Chehab <[email protected]>

Trying to run KUnit without passing arch currently fails with:

$ ./tools/testing/kunit/kunit.py run  --kunitconfig drivers/gpu/drm/xe/.kunitconfig
[10:42:07] Configuring KUnit Kernel ...
[10:42:07] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=8
ERROR:root:../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_dsm_platform_mux_info’:
../drivers/gpu/drm/xe/display/intel_acpi.c:86:15: error: implicit declaration of function ‘acpi_evaluate_dsm_typed’; did you mean ‘acpi_evaluate_dsm’? [-Werror=implicit-function-declaration]
   86 |         pkg = acpi_evaluate_dsm_typed(dhandle, &intel_dsm_guid,
      |               ^~~~~~~~~~~~~~~~~~~~~~~
      |               acpi_evaluate_dsm
../drivers/gpu/drm/xe/display/intel_acpi.c:86:13: warning: assignment to ‘union acpi_object *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   86 |         pkg = acpi_evaluate_dsm_typed(dhandle, &intel_dsm_guid,
      |             ^
../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_dsm_pci_probe’:
../drivers/gpu/drm/xe/display/intel_acpi.c:142:14: error: implicit declaration of function ‘acpi_check_dsm’; did you mean ‘acpi_check_region’? [-Werror=implicit-function-declaration]
  142 |         if (!acpi_check_dsm(dhandle, &intel_dsm_guid, INTEL_DSM_REVISION_ID,
      |              ^~~~~~~~~~~~~~
      |              acpi_check_region
../drivers/gpu/drm/xe/display/intel_acpi.c: At top level:
../drivers/gpu/drm/xe/display/intel_acpi.c:176:6: error: redefinition of ‘intel_register_dsm_handler’
  176 | void intel_register_dsm_handler(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/display/intel_acpi.c:13:
../drivers/gpu/drm/xe/display/intel_acpi.h:19:20: note: previous definition of ‘intel_register_dsm_handler’ with type ‘void(void)’
   19 | static inline void intel_register_dsm_handler(void) { return; }
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c:182:6: error: redefinition of ‘intel_unregister_dsm_handler’
  182 | void intel_unregister_dsm_handler(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:20:20: note: previous definition of ‘intel_unregister_dsm_handler’ with type ‘void(void)’
   20 | static inline void intel_unregister_dsm_handler(void) { return; }
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c:186:6: error: redefinition of ‘intel_dsm_get_bios_data_funcs_supported’
  186 | void intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:22:6: note: previous definition of ‘intel_dsm_get_bios_data_funcs_supported’ with type ‘void(struct xe_device *)’
   22 | void intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_dsm_get_bios_data_funcs_supported’:
../drivers/gpu/drm/xe/display/intel_acpi.c:199:31: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
  199 |                 ACPI_FREE(obj);
      |                               ^
../drivers/gpu/drm/xe/display/intel_acpi.c:188:25: warning: unused variable ‘pdev’ [-Wunused-variable]
  188 |         struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
      |                         ^~~~
../drivers/gpu/drm/xe/display/intel_acpi.c: At top level:
../drivers/gpu/drm/xe/display/intel_acpi.c:266:6: error: redefinition of ‘intel_acpi_device_id_update’
  266 | void intel_acpi_device_id_update(struct drm_i915_private *dev_priv)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:24:6: note: previous definition of ‘intel_acpi_device_id_update’ with type ‘void(struct xe_device *)’
   24 | void intel_acpi_device_id_update(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c:291:6: error: redefinition of ‘intel_acpi_assign_connector_fwnodes’
  291 | void intel_acpi_assign_connector_fwnodes(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:26:6: note: previous definition of ‘intel_acpi_assign_connector_fwnodes’ with type ‘void(struct xe_device *)’
   26 | void intel_acpi_assign_connector_fwnodes(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_acpi_assign_connector_fwnodes’:
../drivers/gpu/drm/xe/display/intel_acpi.c:314:32: error: implicit declaration of function ‘acpi_find_child_device’; did you mean ‘acpi_match_device’? [-Werror=implicit-function-declaration]
  314 |                         adev = acpi_find_child_device(ACPI_COMPANION(drm_dev->dev),
      |                                ^~~~~~~~~~~~~~~~~~~~~~
      |                                acpi_match_device
../drivers/gpu/drm/xe/display/intel_acpi.c:314:30: warning: assignment to ‘struct acpi_device *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  314 |                         adev = acpi_find_child_device(ACPI_COMPANION(drm_dev->dev),
      |                              ^
../drivers/gpu/drm/xe/display/intel_acpi.c: At top level:
../drivers/gpu/drm/xe/display/intel_acpi.c:336:6: error: redefinition of ‘intel_acpi_video_register’
  336 | void intel_acpi_video_register(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:28:6: note: previous definition of ‘intel_acpi_video_register’ with type ‘void(struct xe_device *)’
   28 | void intel_acpi_video_register(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~

The reason is that XE_DISPLAY depends on ACPI. This issue may also manifest on other randconfig, so fix the dependencies.

---
 drivers/gpu/drm/xe/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/xe/Kconfig.debug +1 -0
index 6726caa63acc..6f7123e90563 100644
@@ -99,6 +99,7 @@ config DRM_XE_USERPTR_INVAL_INJECT
 config DRM_XE_DISPLAY
 	bool "Enable display support"
 	depends on DRM_XE && EXPERT
+	depends on ACPI
 	default y
 	help
 	  Disable this option only if you want to compile out display support.
Signature · 1 line
2.39.0
Reviewed-by Philippe Lecluse on v1 15/20
#21 lore raw

Re: [Intel-xe] [PATCH 15/20] drm/xe: fix XE_DISPLAY dependency on ACPI

-----Original Message-----
From: Vivi, Rodrigo <[email protected]>
Sent: Friday, January 20, 2023 9:44 PM
To: [email protected]; [email protected]; Lecluse, Philippe <[email protected]>; [email protected]
Cc: De Marchi, Lucas <[email protected]>; Vivi, Rodrigo <[email protected]>
Subject: [PATCH 15/20] drm/xe: fix XE_DISPLAY dependency on ACPI

From: Mauro Carvalho Chehab <[email protected]>

Trying to run KUnit without passing arch currently fails with:

$ ./tools/testing/kunit/kunit.py run  --kunitconfig drivers/gpu/drm/xe/.kunitconfig [10:42:07] Configuring KUnit Kernel ...
[10:42:07] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=8
ERROR:root:../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_dsm_platform_mux_info’:
../drivers/gpu/drm/xe/display/intel_acpi.c:86:15: error: implicit declaration of function ‘acpi_evaluate_dsm_typed’; did you mean ‘acpi_evaluate_dsm’? [-Werror=implicit-function-declaration]
   86 |         pkg = acpi_evaluate_dsm_typed(dhandle, &intel_dsm_guid,
      |               ^~~~~~~~~~~~~~~~~~~~~~~
      |               acpi_evaluate_dsm
../drivers/gpu/drm/xe/display/intel_acpi.c:86:13: warning: assignment to ‘union acpi_object *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   86 |         pkg = acpi_evaluate_dsm_typed(dhandle, &intel_dsm_guid,
      |             ^
../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_dsm_pci_probe’:
../drivers/gpu/drm/xe/display/intel_acpi.c:142:14: error: implicit declaration of function ‘acpi_check_dsm’; did you mean ‘acpi_check_region’? [-Werror=implicit-function-declaration]
  142 |         if (!acpi_check_dsm(dhandle, &intel_dsm_guid, INTEL_DSM_REVISION_ID,
      |              ^~~~~~~~~~~~~~
      |              acpi_check_region
../drivers/gpu/drm/xe/display/intel_acpi.c: At top level:
../drivers/gpu/drm/xe/display/intel_acpi.c:176:6: error: redefinition of ‘intel_register_dsm_handler’
  176 | void intel_register_dsm_handler(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/gpu/drm/xe/display/intel_acpi.c:13:
../drivers/gpu/drm/xe/display/intel_acpi.h:19:20: note: previous definition of ‘intel_register_dsm_handler’ with type ‘void(void)’
   19 | static inline void intel_register_dsm_handler(void) { return; }
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c:182:6: error: redefinition of ‘intel_unregister_dsm_handler’
  182 | void intel_unregister_dsm_handler(void)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:20:20: note: previous definition of ‘intel_unregister_dsm_handler’ with type ‘void(void)’
   20 | static inline void intel_unregister_dsm_handler(void) { return; }
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c:186:6: error: redefinition of ‘intel_dsm_get_bios_data_funcs_supported’
  186 | void intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:22:6: note: previous definition of ‘intel_dsm_get_bios_data_funcs_supported’ with type ‘void(struct xe_device *)’
   22 | void intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_dsm_get_bios_data_funcs_supported’:
../drivers/gpu/drm/xe/display/intel_acpi.c:199:31: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
  199 |                 ACPI_FREE(obj);
      |                               ^
../drivers/gpu/drm/xe/display/intel_acpi.c:188:25: warning: unused variable ‘pdev’ [-Wunused-variable]
  188 |         struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
      |                         ^~~~
../drivers/gpu/drm/xe/display/intel_acpi.c: At top level:
../drivers/gpu/drm/xe/display/intel_acpi.c:266:6: error: redefinition of ‘intel_acpi_device_id_update’
  266 | void intel_acpi_device_id_update(struct drm_i915_private *dev_priv)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:24:6: note: previous definition of ‘intel_acpi_device_id_update’ with type ‘void(struct xe_device *)’
   24 | void intel_acpi_device_id_update(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c:291:6: error: redefinition of ‘intel_acpi_assign_connector_fwnodes’
  291 | void intel_acpi_assign_connector_fwnodes(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:26:6: note: previous definition of ‘intel_acpi_assign_connector_fwnodes’ with type ‘void(struct xe_device *)’
   26 | void intel_acpi_assign_connector_fwnodes(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.c: In function ‘intel_acpi_assign_connector_fwnodes’:
../drivers/gpu/drm/xe/display/intel_acpi.c:314:32: error: implicit declaration of function ‘acpi_find_child_device’; did you mean ‘acpi_match_device’? [-Werror=implicit-function-declaration]
  314 |                         adev = acpi_find_child_device(ACPI_COMPANION(drm_dev->dev),
      |                                ^~~~~~~~~~~~~~~~~~~~~~
      |                                acpi_match_device
../drivers/gpu/drm/xe/display/intel_acpi.c:314:30: warning: assignment to ‘struct acpi_device *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  314 |                         adev = acpi_find_child_device(ACPI_COMPANION(drm_dev->dev),
      |                              ^
../drivers/gpu/drm/xe/display/intel_acpi.c: At top level:
../drivers/gpu/drm/xe/display/intel_acpi.c:336:6: error: redefinition of ‘intel_acpi_video_register’
  336 | void intel_acpi_video_register(struct drm_i915_private *i915)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/display/intel_acpi.h:28:6: note: previous definition of ‘intel_acpi_video_register’ with type ‘void(struct xe_device *)’
   28 | void intel_acpi_video_register(struct drm_i915_private *i915) { return; }
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~

The reason is that XE_DISPLAY depends on ACPI. This issue may also manifest on other randconfig, so fix the dependencies.

---
 drivers/gpu/drm/xe/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/xe/Kconfig.debug +1 -1
index 6726caa63acc..6f7123e90563 100644
@@ -99,6 +99,7 @@ config DRM_XE_USERPTR_INVAL_INJECT  config DRM_XE_DISPLAY
 	bool "Enable display support"
 	depends on DRM_XE && EXPERT
+	depends on ACPI
 	default y
 	help
 	  Disable this option only if you want to compile out display support.
--

2.39.0

---------------------------------------------------------------------
Intel Benelux B.V.
Registered in The Netherlands under number 24134020 Statutory seat: Rotterdam
Registered address: Capronilaan 37, 1119NG Schiphol-Rijk

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

author maintainer
#22 lore raw

PATCH 16/20 drm/xe: allow building XE_DISPLAY without ACPI

In reply to Rodrigo Vivi

From: Mauro Carvalho Chehab <[email protected]>

It is not needed to make XE_DISPLAY dependent on ACPI. All it is needed is to not include intel_acpi and intel_opregion.

---
 drivers/gpu/drm/xe/Kconfig.debug | 1 -
 drivers/gpu/drm/xe/Makefile      | 8 ++++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/Kconfig.debug +0 -1
index 6f7123e90563..6726caa63acc 100644
@@ -99,7 +99,6 @@ config DRM_XE_USERPTR_INVAL_INJECT
 config DRM_XE_DISPLAY
 	bool "Enable display support"
 	depends on DRM_XE && EXPERT
-	depends on ACPI
 	default y
 	help
 	  Disable this option only if you want to compile out display support.
drivers/gpu/drm/xe/Makefile +6 -2
index 06bed3f12b54..d9a66ad0543d 100644
@@ -112,7 +112,6 @@ CFLAGS_display/intel_fbdev.o = $(call cc-disable-warning, override-init)
 # Display..
 xe-$(CONFIG_DRM_XE_DISPLAY) += \
 	display/icl_dsi.o \
-	display/intel_acpi.o \
 	display/intel_atomic.o \
 	display/intel_atomic_plane.o \
 	display/intel_audio.o \
@@ -165,7 +164,6 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
 	display/intel_lvds.o \
 	display/intel_modeset_setup.o \
 	display/intel_modeset_verify.o \
-	display/intel_opregion.o \
 	display/intel_panel.o \
 	display/intel_pipe_crc.o \
 	display/intel_pps.o \
@@ -189,6 +187,12 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
 	display/ext/intel_pch.o \
 	display/ext/intel_pm.o
 
+ifeq ($(CONFIG_ACPI),y)
+	xe-$(CONFIG_DRM_XE_DISPLAY) += \
+		display/intel_acpi.o \
+		display/intel_opregion.o
+endif
+
 obj-$(CONFIG_DRM_XE) += xe.o
 obj-$(CONFIG_DRM_XE_KUNIT_TEST) += tests/
 
Signature · 1 line
2.39.0
author maintainer
#23 lore raw

PATCH 17/20 drm/xe: fix DRM_FBDEV_EMULATION dependencies

In reply to Rodrigo Vivi

From: Mauro Carvalho Chehab <[email protected]>

The intel_fbdev should only be added when framebuffer emulation is enabled.

---
 drivers/gpu/drm/xe/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/Makefile +4 -1
index d9a66ad0543d..08fff058e9d0 100644
@@ -150,7 +150,6 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
 	display/intel_dsi_vbt.o \
 	display/intel_fb.o \
 	display/intel_fbc.o \
-	display/intel_fbdev.o \
 	display/intel_fdi.o \
 	display/intel_fifo_underrun.o \
 	display/intel_frontbuffer.o \
@@ -193,6 +192,10 @@ ifeq ($(CONFIG_ACPI),y)
 		display/intel_opregion.o
 endif
 
+ifeq ($(CONFIG_DRM_FBDEV_EMULATION),y)
+	xe-$(CONFIG_DRM_XE_DISPLAY) += display/intel_fbdev.o
+endif
+
 obj-$(CONFIG_DRM_XE) += xe.o
 obj-$(CONFIG_DRM_XE_KUNIT_TEST) += tests/
 
Signature · 1 line
2.39.0
author maintainer
#24 lore raw

PATCH 18/20 drm/xe/gt: Enable interrupt while initializing root gt

In reply to Rodrigo Vivi

From: Balasubramani Vivekanandan <[email protected]>

At present the interrupts are enabled while initializing the last GT. But this is incorrect for a Multi-GT platform, as root GT initialization will fail with interrupt disabled. Interrupts are required for the GuC submission triggered during initialization.
Enable the interrupt during the root GT initialization.

---
 drivers/gpu/drm/xe/xe_irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_irq.c +1 -1
index 92fe6b38d735..18ce129bd6be 100644
@@ -349,7 +349,7 @@ static void dg1_irq_postinstall(struct xe_device *xe, struct xe_gt *gt)
 	GEN3_IRQ_INIT(gt, GEN11_GU_MISC_, ~GEN11_GU_MISC_GSE,
 		      GEN11_GU_MISC_GSE);
 
-	if (gt->info.id + 1 == xe->info.tile_count)
+	if (gt->info.id == XE_GT0)
 		dg1_intr_enable(xe, true);
 }
 
Signature · 1 line
2.39.0
author maintainer
#25 lore raw

PATCH 19/20 drm/xe: Fix Meteor Lake rsa issue on guc loading

In reply to Rodrigo Vivi

From: Philippe Lecluse <[email protected]>

[  117.901473] xe 0000:00:02.0: [drm] GuC load failed: status = 0x400000A0
[  117.901506] xe 0000:00:02.0: [drm] GuC load failed: status: Reset = 0, BootROM = 0x50, UKernel = 0x00, MIA = 0x00, Auth = 0x01

was introduced by this commit:
drm/xe: Move load of minimal GuC and hwconfig read much earlier

---
 drivers/gpu/drm/xe/xe_gt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +2 -2
index bf5364046bab..d3c93c046c48 100644
@@ -436,6 +436,8 @@ static int gt_fw_domain_init(struct xe_gt *gt)
 	if (err)
 		goto err_hw_fence_irq;
 
+	setup_private_ppat(gt);
+
 	if (!xe_gt_is_media_type(gt)) {
 		err = xe_ggtt_init(gt, gt->mem.ggtt);
 		if (err)
@@ -488,8 +490,6 @@ static int all_fw_domain_init(struct xe_gt *gt)
 	if (err)
 		goto err_hw_fence_irq;
 
-	setup_private_ppat(gt);
-
 	xe_reg_sr_apply_mmio(&gt->reg_sr, gt);
 
 	err = xe_gt_clock_init(gt);
Signature · 1 line
2.39.0
author maintainer
#26 lore raw

PATCH 20/20 drm/xe/guc_pc: Fix Meteor Lake registers.

In reply to Rodrigo Vivi

When adding the frequency management, Meteor Lake platform was left behind. Handling it properly now.

Cc Matthew Brost <[email protected]>
Cc Francois Dugast <[email protected]>
---
 drivers/gpu/drm/xe/xe_guc_pc.c | 70 ++++++++++++++++++++++++++++++++--
 1 file changed, 66 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_guc_pc.c +66 -4
index 506b9cb3f14c..bf3dff9e0c2b 100644
@@ -37,6 +37,9 @@
 #define GEN12_RPSTAT1		_MMIO(0x1381b4)
 #define   GEN12_CAGF_MASK	REG_GENMASK(19, 11)
 
+#define MTL_MIRROR_TARGET_WP1	_MMIO(0xc60)
+#define   MTL_CAGF_MASK		REG_GENMASK(8, 0)
+
 #define GT_FREQUENCY_MULTIPLIER	50
 #define GEN9_FREQ_SCALER	3
 
@@ -311,7 +314,20 @@ static int pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
 				   freq);
 }
 
-static void pc_update_rp_values(struct xe_guc_pc *pc)
+static void mtl_update_rpe_value(struct xe_guc_pc *pc)
+{
+	struct xe_gt *gt = pc_to_gt(pc);
+	u32 reg;
+
+	if (xe_gt_is_media_type(gt))
+		reg = xe_mmio_read32(gt, MTL_MPE_FREQUENCY.reg);
+	else
+		reg = xe_mmio_read32(gt, MTL_GT_RPE_FREQUENCY.reg);
+
+	pc->rpe_freq = REG_FIELD_GET(MTL_RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
+}
+
+static void tgl_update_rpe_value(struct xe_guc_pc *pc)
 {
 	struct xe_gt *gt = pc_to_gt(pc);
 	struct xe_device *xe = gt_to_xe(gt);
@@ -328,6 +344,17 @@ static void pc_update_rp_values(struct xe_guc_pc *pc)
 		reg = xe_mmio_read32(gt, GEN10_FREQ_INFO_REC.reg);
 
 	pc->rpe_freq = REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
+}
+
+static void pc_update_rp_values(struct xe_guc_pc *pc)
+{
+	struct xe_gt *gt = pc_to_gt(pc);
+	struct xe_device *xe = gt_to_xe(gt);
+
+	if (xe->info.platform == XE_METEORLAKE)
+		mtl_update_rpe_value(pc);
+	else
+		tgl_update_rpe_value(pc);
 
 	/*
 	 * RPe is decided at runtime by PCODE. In the rare case where that's
@@ -342,6 +369,7 @@ static ssize_t freq_act_show(struct device *dev,
 {
 	struct kobject *kobj = &dev->kobj;
 	struct xe_gt *gt = kobj_to_gt(kobj);
+	struct xe_device *xe = gt_to_xe(gt);
 	u32 freq;
 	ssize_t ret;
 
@@ -354,10 +382,17 @@ static ssize_t freq_act_show(struct device *dev,
 		return ret;
 
 	xe_device_mem_access_get(gt_to_xe(gt));
-	freq = xe_mmio_read32(gt, GEN12_RPSTAT1.reg);
+
+	if (xe->info.platform == XE_METEORLAKE) {
+		freq = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1.reg);
+		freq = REG_FIELD_GET(MTL_CAGF_MASK, freq);
+	} else {
+		freq = xe_mmio_read32(gt, GEN12_RPSTAT1.reg);
+		freq = REG_FIELD_GET(GEN12_CAGF_MASK, freq);
+	}
+
 	xe_device_mem_access_put(gt_to_xe(gt));
 
-	freq = REG_FIELD_GET(GEN12_CAGF_MASK, freq);
 	ret = sysfs_emit(buf, "%d\n", decode_freq(freq));
 
 	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
@@ -606,7 +641,24 @@ static const struct attribute *pc_attrs[] = {
 	NULL
 };
 
-static void pc_init_fused_rp_values(struct xe_guc_pc *pc)
+static void mtl_init_fused_rp_values(struct xe_guc_pc *pc)
+{
+	struct xe_gt *gt = pc_to_gt(pc);
+	u32 reg;
+
+	xe_device_assert_mem_access(pc_to_xe(pc));
+
+	if (xe_gt_is_media_type(gt))
+		reg = xe_mmio_read32(gt, MTL_MEDIAP_STATE_CAP.reg);
+	else
+		reg = xe_mmio_read32(gt, MTL_RP_STATE_CAP.reg);
+	pc->rp0_freq = REG_FIELD_GET(MTL_RP0_CAP_MASK, reg) *
+		GT_FREQUENCY_MULTIPLIER;
+	pc->rpn_freq = REG_FIELD_GET(MTL_RPN_CAP_MASK, reg) *
+		GT_FREQUENCY_MULTIPLIER;
+}
+
+static void tgl_init_fused_rp_values(struct xe_guc_pc *pc)
 {
 	struct xe_gt *gt = pc_to_gt(pc);
 	struct xe_device *xe = gt_to_xe(gt);
@@ -622,6 +674,16 @@ static void pc_init_fused_rp_values(struct xe_guc_pc *pc)
 	pc->rpn_freq = REG_FIELD_GET(RPN_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
 }
 
+static void pc_init_fused_rp_values(struct xe_guc_pc *pc)
+{
+	struct xe_gt *gt = pc_to_gt(pc);
+	struct xe_device *xe = gt_to_xe(gt);
+
+	if (xe->info.platform == XE_METEORLAKE)
+		mtl_init_fused_rp_values(pc);
+	else
+		tgl_init_fused_rp_values(pc);
+}
 static int pc_adjust_freq_bounds(struct xe_guc_pc *pc)
 {
 	int ret;
Signature · 1 line
2.39.0