[RFC 3/7] drm/i915: Introduce GEN8 {set, get} private PAT index ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce operations of {set, get} private PAT index to decode and encode
the private PAT index in a guest/shadow PPGTT page table entry.

Signed-off-by: Zhi Wang <zhi.a.wang@xxxxxxxxx>
---
 drivers/gpu/drm/i915/gvt/gtt.c | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/gtt.h |  3 +++
 2 files changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 16bfca9..c630015 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -378,6 +378,42 @@ static void gtt_entry_clear_present(struct intel_gvt_gtt_entry *e)
 }
 
 /*
+ * For GEN8 platform.
+ * PAT: bit 7, PCD: bit 4, PWT: bit 3.
+ * Index: index = 4 * PAT + 2 * PCD + PWT
+ */
+static unsigned int gen8_get_pat_index(struct intel_gvt_gtt_entry *e)
+{
+	u8 index = 0;
+
+	if (_PAGE_PWT & e->val64)
+		index |= (1 << 0);
+
+	if (_PAGE_PCD & e->val64)
+		index |= (1 << 1);
+
+	if (_PAGE_PAT & e->val64)
+		index |= (1 << 2);
+
+	return index;
+}
+
+static void gen8_set_pat_index(struct intel_gvt_gtt_entry *e,
+			       unsigned int index)
+{
+	e->val64 &= ~(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT);
+
+	if (index & (1 << 0))
+		e->val64 |= _PAGE_PWT;
+
+	if (index & (1 << 1))
+		e->val64 |= _PAGE_PCD;
+
+	if (index & (1 << 2))
+		e->val64 |= _PAGE_PAT;
+}
+
+/*
  * Per-platform GMA routines.
  */
 static unsigned long gma_to_ggtt_pte_index(unsigned long gma)
@@ -484,6 +520,8 @@ static struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = {
 	.test_pse = gen8_gtt_test_pse,
 	.get_pfn = gen8_gtt_get_pfn,
 	.set_pfn = gen8_gtt_set_pfn,
+	.get_pat_index = gen8_get_pat_index,
+	.set_pat_index = gen8_set_pat_index,
 };
 
 static struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = {
diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h
index 7a9eb05..02f6bd9 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.h
+++ b/drivers/gpu/drm/i915/gvt/gtt.h
@@ -66,6 +66,9 @@ struct intel_gvt_gtt_pte_ops {
 	bool (*test_pse)(struct intel_gvt_gtt_entry *e);
 	void (*set_pfn)(struct intel_gvt_gtt_entry *e, unsigned long pfn);
 	unsigned long (*get_pfn)(struct intel_gvt_gtt_entry *e);
+	unsigned int (*get_pat_index)(struct intel_gvt_gtt_entry *e);
+	void (*set_pat_index)(struct intel_gvt_gtt_entry *e,
+			      unsigned int index);
 };
 
 struct intel_gvt_gtt_gma_ops {
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux