Skip to contentSkip to conversation

drm/i915: Factor out setup_private_pat()

PATCH In review Zhi Wang 4 participants 12 messages Sep 5, 2017 – Sep 8, 2017

Subsystems (2)
lore
Share & tools
lore

Zhi Wang

author
#0 lore raw

PATCH 1/4 drm/i915: Factor out setup_private_pat()

Factor out setup_private_pat() for introducing the following patches.

Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +12 -8
index c33c2f9..2fc0656 100644
@@ -2915,6 +2915,16 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
 	cleanup_scratch_page(vm);
 }
 
+static void setup_private_pat(struct drm_i915_private *dev_priv)
+{
+	if (INTEL_GEN(dev_priv) >= 10)
+		cnl_setup_private_ppat(dev_priv);
+	else if (IS_CHERRYVIEW(dev_priv) || IS_GEN9_LP(dev_priv))
+		chv_setup_private_ppat(dev_priv);
+	else
+		bdw_setup_private_ppat(dev_priv);
+}
+
 static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 {
 	struct drm_i915_private *dev_priv = ggtt->base.i915;
@@ -2947,14 +2957,6 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 	}
 
 	ggtt->base.total = (size / sizeof(gen8_pte_t)) << PAGE_SHIFT;
-
-	if (INTEL_GEN(dev_priv) >= 10)
-		cnl_setup_private_ppat(dev_priv);
-	else if (IS_CHERRYVIEW(dev_priv) || IS_GEN9_LP(dev_priv))
-		chv_setup_private_ppat(dev_priv);
-	else
-		bdw_setup_private_ppat(dev_priv);
-
 	ggtt->base.cleanup = gen6_gmch_remove;
 	ggtt->base.bind_vma = ggtt_bind_vma;
 	ggtt->base.unbind_vma = ggtt_unbind_vma;
@@ -2975,6 +2977,8 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 
 	ggtt->invalidate = gen6_ggtt_invalidate;
 
+	setup_private_pat(dev_priv);
+
 	return ggtt_probe_common(ggtt, size);
 }
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH 2/4 drm/i915: Introduce private PAT management

The private PAT management is to support PPAT entry manipulation. Two APIs are introduced for dynamically managing PPAT entries: intel_ppat_get and intel_ppat_put.

intel_ppat_get will search for an existing PPAT entry which perfectly matches the required PPAT value. If not, it will try to allocate or return a partially matched PPAT entry if there is any available PPAT indexes or not.

intel_ppat_put will put back the PPAT entry which comes from intel_ppat_get. If it's dynamically allocated, the reference count will be decreased. If the reference count turns into zero, the PPAT index is freed again.

Besides, another two callbacks are introduced to support the private PAT management framework. One is ppat->update_hw(), which writes the PPAT configurations in ppat->entries into HW. Another one is ppat->match, which will return a score to show how two PPAT values match with each other.

v7:

- Keep all the register writes unchanged in this patch. (Joonas)

v6:

- Address all comments from Chris:
http://www.spinics.net/lists/intel-gfx/msg136850.html

- Address all comments from Joonas:
http://www.spinics.net/lists/intel-gfx/msg136845.html

v5:

- Add check and warnnings for those platforms which don't have PPAT.

v3:

- Introduce dirty bitmap for PPAT registers. (Chris)
- Change the name of the pointer "dev_priv" to "i915". (Chris)
- intel_ppat_{get, put} returns/takes a const intel_ppat_entry *. (Chris)

v2:

- API re-design. (Chris)

Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +
 drivers/gpu/drm/i915/i915_gem_gtt.c | 279 +++++++++++++++++++++++++++++-------
 drivers/gpu/drm/i915/i915_gem_gtt.h |  36 +++++
 3 files changed, 268 insertions(+), 49 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 789f750..a3f5b96 100644
@@ -2332,6 +2332,8 @@ struct drm_i915_private {
 	DECLARE_HASHTABLE(mm_structs, 7);
 	struct mutex mm_lock;
 
+	struct intel_ppat ppat;
+
 	/* Kernel Modesetting */
 
 	struct intel_crtc *plane_to_crtc_mapping[I915_MAX_PIPES];
drivers/gpu/drm/i915/i915_gem_gtt.c +230 -49

330 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_gtt.h +36 -0
index b4e3aa7..e10ca89 100644
@@ -143,6 +143,11 @@ typedef u64 gen8_ppgtt_pml4e_t;
 #define GEN8_PPAT_ELLC_OVERRIDE		(0<<2)
 #define GEN8_PPAT(i, x)			((u64)(x) << ((i) * 8))
 
+#define GEN8_PPAT_GET_CA(x) ((x) & 3)
+#define GEN8_PPAT_GET_TC(x) ((x) & (3 << 2))
+#define GEN8_PPAT_GET_AGE(x) ((x) & (3 << 4))
+#define CHV_PPAT_GET_SNOOP(x) ((x) & (1 << 6))
+
 struct sg_table;
 
 struct intel_rotation_info {
@@ -536,6 +541,37 @@ i915_vm_to_ggtt(struct i915_address_space *vm)
 	return container_of(vm, struct i915_ggtt, base);
 }
 
+#define INTEL_MAX_PPAT_ENTRIES 8
+#define INTEL_PPAT_PERFECT_MATCH (~0U)
+
+struct intel_ppat;
+
+struct intel_ppat_entry {
+	struct intel_ppat *ppat;
+	struct kref ref;
+	u8 value;
+};
+
+struct intel_ppat {
+	struct intel_ppat_entry entries[INTEL_MAX_PPAT_ENTRIES];
+	DECLARE_BITMAP(used, INTEL_MAX_PPAT_ENTRIES);
+	DECLARE_BITMAP(dirty, INTEL_MAX_PPAT_ENTRIES);
+	unsigned int max_entries;
+	u8 clear_value;
+	/*
+	 * Return a score to show how two PPAT values match,
+	 * a INTEL_PPAT_PERFECT_MATCH indicates a perfect match
+	 */
+	unsigned int (*match)(u8 src, u8 dst);
+	void (*update_hw)(struct drm_i915_private *i915);
+
+	struct drm_i915_private *i915;
+};
+
+const struct intel_ppat_entry *
+intel_ppat_get(struct drm_i915_private *i915, u8 value);
+void intel_ppat_put(const struct intel_ppat_entry *entry);
+
 int i915_gem_init_aliasing_ppgtt(struct drm_i915_private *i915);
 void i915_gem_fini_aliasing_ppgtt(struct drm_i915_private *i915);
 
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 2/4
#2 lore raw

Re: [PATCH 2/4] drm/i915: Introduce private PAT management

Quoting Zhi Wang (2017-09-05 20:58:25)

Quoted 56 lines

The private PAT management is to support PPAT entry manipulation. Two APIs are introduced for dynamically managing PPAT entries: intel_ppat_get and intel_ppat_put.

intel_ppat_get will search for an existing PPAT entry which perfectly matches the required PPAT value. If not, it will try to allocate or return a partially matched PPAT entry if there is any available PPAT indexes or not.

intel_ppat_put will put back the PPAT entry which comes from intel_ppat_get. If it's dynamically allocated, the reference count will be decreased. If the reference count turns into zero, the PPAT index is freed again.

Besides, another two callbacks are introduced to support the private PAT management framework. One is ppat->update_hw(), which writes the PPAT configurations in ppat->entries into HW. Another one is ppat->match, which will return a score to show how two PPAT values match with each other.

v7:

- Keep all the register writes unchanged in this patch. (Joonas)

v6:

- Address all comments from Chris:
http://www.spinics.net/lists/intel-gfx/msg136850.html

- Address all comments from Joonas:
http://www.spinics.net/lists/intel-gfx/msg136845.html

v5:

- Add check and warnnings for those platforms which don't have PPAT.

v3:

- Introduce dirty bitmap for PPAT registers. (Chris)
- Change the name of the pointer "dev_priv" to "i915". (Chris)
- intel_ppat_{get, put} returns/takes a const intel_ppat_entry *. (Chris)

v2:

- API re-design. (Chris)

Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index b4e3aa7..e10ca89 100644

drivers/gpu/drm/i915/i915_gem_gtt.h typedef u64 gen8_ppgtt_pml4e_t; · line 149

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +4 -0
@@ -143,6 +143,11 @@ typedef u64 gen8_ppgtt_pml4e_t;
 #define GEN8_PPAT_ELLC_OVERRIDE                (0<<2)
 #define GEN8_PPAT(i, x)                        ((u64)(x) << ((i) * 8))
 
+#define GEN8_PPAT_GET_CA(x) ((x) & 3)
+#define GEN8_PPAT_GET_TC(x) ((x) & (3 << 2))
+#define GEN8_PPAT_GET_AGE(x) ((x) & (3 << 4))
+#define CHV_PPAT_GET_SNOOP(x) ((x) & (1 << 6))

One day we will use bitfield.h to our advantage.

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#3 lore raw

PATCH 3/4 drm/i915: Do not allocate unused PPAT entries

In reply to Zhi Wang

Only PPAT entries 0/2/3/4 are using. Remove extra PPAT entry allocation during initialization.

Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 46 ++++++++++++++++---------------------
 drivers/gpu/drm/i915/i915_gem_gtt.h |  7 ++++++
 2 files changed, 27 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +20 -26
index 47899c7..53a2588 100644
@@ -2988,18 +2988,15 @@ static void cnl_setup_private_ppat(struct intel_ppat *ppat)
 
 	/* XXX: spec is unclear if this is still needed for CNL+ */
 	if (!USES_PPGTT(ppat->i915)) {
-		__alloc_ppat_entry(ppat, 0, GEN8_PPAT_UC);
+		__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_PDE_INDEX), GEN8_PPAT_UC);
 		return;
 	}
 
-	__alloc_ppat_entry(ppat, 0, GEN8_PPAT_WB | GEN8_PPAT_LLC);
-	__alloc_ppat_entry(ppat, 1, GEN8_PPAT_WC | GEN8_PPAT_LLCELLC);
-	__alloc_ppat_entry(ppat, 2, GEN8_PPAT_WT | GEN8_PPAT_LLCELLC);
-	__alloc_ppat_entry(ppat, 3, GEN8_PPAT_UC);
-	__alloc_ppat_entry(ppat, 4, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(0));
-	__alloc_ppat_entry(ppat, 5, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(1));
-	__alloc_ppat_entry(ppat, 6, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(2));
-	__alloc_ppat_entry(ppat, 7, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(3));
+	/* See gen8_pte_encode() for the mapping from cache-level to PPAT */
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_PDE_INDEX), GEN8_PPAT_WB | GEN8_PPAT_LLC);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_DISPLAY_ELLC_INDEX), GEN8_PPAT_WT | GEN8_PPAT_LLCELLC);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_UNCACHED_INDEX), GEN8_PPAT_UC);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_INDEX), GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(0));
 }
 
 /* The GGTT and PPGTT need a private PPAT setup in order to handle cacheability
@@ -3026,18 +3023,18 @@ static void bdw_setup_private_ppat(struct intel_ppat *ppat)
 		 * So we can still hold onto all our assumptions wrt cpu
 		 * clflushing on LLC machines.
 		 */
-		__alloc_ppat_entry(ppat, 0, GEN8_PPAT_UC);
+		__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_PDE_INDEX), GEN8_PPAT_UC);
 		return;
 	}
 
-	__alloc_ppat_entry(ppat, 0, GEN8_PPAT_WB | GEN8_PPAT_LLC);      /* for normal objects, no eLLC */
-	__alloc_ppat_entry(ppat, 1, GEN8_PPAT_WC | GEN8_PPAT_LLCELLC);  /* for something pointing to ptes? */
-	__alloc_ppat_entry(ppat, 2, GEN8_PPAT_WT | GEN8_PPAT_LLCELLC);  /* for scanout with eLLC */
-	__alloc_ppat_entry(ppat, 3, GEN8_PPAT_UC);                      /* Uncached objects, mostly for scanout */
-	__alloc_ppat_entry(ppat, 4, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(0));
-	__alloc_ppat_entry(ppat, 5, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(1));
-	__alloc_ppat_entry(ppat, 6, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(2));
-	__alloc_ppat_entry(ppat, 7, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(3));
+	/* See gen8_pte_encode() for the mapping from cache-level to PPAT */
+	/* for normal objects, no eLLC */
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_PDE_INDEX), GEN8_PPAT_WB | GEN8_PPAT_LLC);
+	/* for scanout with eLLC */
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_DISPLAY_ELLC_INDEX), GEN8_PPAT_WT | GEN8_PPAT_LLCELLC);
+	/* Uncached objects, mostly for scanout */
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_UNCACHED_INDEX), GEN8_PPAT_UC);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_INDEX), GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(0));
 }
 
 static void chv_setup_private_ppat(struct intel_ppat *ppat)
@@ -3066,14 +3063,11 @@ static void chv_setup_private_ppat(struct intel_ppat *ppat)
 	 * in order to keep the global status page working.
 	 */
 
-	__alloc_ppat_entry(ppat, 0, CHV_PPAT_SNOOP);
-	__alloc_ppat_entry(ppat, 1, 0);
-	__alloc_ppat_entry(ppat, 2, 0);
-	__alloc_ppat_entry(ppat, 3, 0);
-	__alloc_ppat_entry(ppat, 4, CHV_PPAT_SNOOP);
-	__alloc_ppat_entry(ppat, 5, CHV_PPAT_SNOOP);
-	__alloc_ppat_entry(ppat, 6, CHV_PPAT_SNOOP);
-	__alloc_ppat_entry(ppat, 7, CHV_PPAT_SNOOP);
+	/* See gen8_pte_encode() for the mapping from cache-level to PPAT */
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_PDE_INDEX), CHV_PPAT_SNOOP);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_DISPLAY_ELLC_INDEX), 0);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_UNCACHED_INDEX), 0);
+	__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_INDEX), CHV_PPAT_SNOOP);
 }
 
 static void gen6_gmch_remove(struct i915_address_space *vm)
drivers/gpu/drm/i915/i915_gem_gtt.h +7 -0
index e10ca89..575da15 100644
@@ -131,6 +131,13 @@ typedef u64 gen8_ppgtt_pml4e_t;
 #define PPAT_CACHED_INDEX		_PAGE_PAT /* WB LLCeLLC */
 #define PPAT_DISPLAY_ELLC_INDEX		_PAGE_PCD /* WT eLLC */
 
+/* PPAT index = 4 * PAT + 2 * PCD + PWT */
+static inline unsigned int ppat_bits_to_index(unsigned int bits)
+{
+	return (4 * !!(bits & _PAGE_PAT) + 2 * !!(bits & _PAGE_PCD)
+		+ !!(bits & _PAGE_PWT));
+}
+
 #define CHV_PPAT_SNOOP			(1<<6)
 #define GEN8_PPAT_AGE(x)		(x<<4)
 #define GEN8_PPAT_LLCeLLC		(3<<2)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH 3/4] drm/i915: Do not allocate unused PPAT entries

Quoting Zhi Wang (2017-09-05 20:58:26)

Quoted 6 lines

static void gen6_gmch_remove(struct i915_address_space *vm)

drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index e10ca89..575da15 100644

drivers/gpu/drm/i915/i915_gem_gtt.h typedef u64 gen8_ppgtt_pml4e_t; · line 139

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +6 -0
@@ -131,6 +131,13 @@ typedef u64 gen8_ppgtt_pml4e_t;
 #define PPAT_CACHED_INDEX              _PAGE_PAT /* WB LLCeLLC */
 #define PPAT_DISPLAY_ELLC_INDEX                _PAGE_PCD /* WT eLLC */
 
+/* PPAT index = 4 * PAT + 2 * PCD + PWT */
+static inline unsigned int ppat_bits_to_index(unsigned int bits)
+{
+       return (4 * !!(bits & _PAGE_PAT) + 2 * !!(bits & _PAGE_PCD)
+               + !!(bits & _PAGE_PWT));
+}

Let's not let this leak out of the gtt.c.

__alloc_ppat_entry(ppat, ppat_bits_to_index(PPAT_CACHED_PDE_INDEX), CHV_PPAT_SNOOP);

is horrible. bits_to_index() on an index is nonsense. We have a severe naming issue here...
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#5 lore raw

PATCH 4/4 drm/i915/selftests: Introduce live tests of private PAT management

In reply to Zhi Wang

Introduce two live tests of private PAT managment:

igt_ppat_init - This test is to check if all the PPAT configuration is written into HW.

igt_ppat_get - This test performs several sub-tests on intel_ppat_get() and intel_ppat_put().

The "perfect match" test case will try to get a PPAT entry with an existing value, then check if the returned PPAT entry is the same one.

The "alloc entries" test case will run out of PPAT table, and check if all the requested values are put into the newly allocated PPAT entries.

The "partial match" test case will generate a parital matched value from the existing PPAT table and try to match it.

The "put entries" test case will free all the PPAT entries that allocated in "alloc entries" test case. It will check if the values of freed PPAT entries turn into ppat->clear_value.

An example output of these test cases on my SKL box is:

[   38.934158] ppat: check private PAT on HW
[   38.942498] ppat: OK
[   38.946752] ppat: ppat table before the test
[   38.955580] ppat 0: 0x7
[   38.960509] ppat 2: 0xa
[   38.965484] ppat 3: 0x0
[   38.970267] ppat 4: 0xb
[   38.975387] ppat: make sure it's same with HW ppat table
[   38.985996] ppat: check private PAT on HW
[   38.994492] ppat: OK
[   38.998921] ppat: case 1: perfect match
[   39.006706] ppat: OK
[   39.011135] ppat: case 2: alloc new entries
[   39.019825] ppat: alloc new entry value 0x37 index 1
[   39.029771] ppat: alloc new entry value 0x27 index 5
[   39.039829] ppat: alloc new entry value 0x17 index 6
[   39.050076] ppat: alloc new entry value 0x3b index 7
[   39.059980] ppat: OK
[   39.064570] ppat: case 3: partial match
[   39.072354] ppat: generate value 0x2b
[   39.079432] ppat: partial match entry value 0x3b index 7
[   39.090219] ppat: put entries
[   39.096061] ppat: put entry value 0x37 index 1
[   39.105262] ppat: put entry value 0x27 index 5
[   39.114150] ppat: put entry value 0x17 index 6
[   39.123154] ppat: put entry value 0x3b index 7
[   39.132335] ppat: OK
[   39.136588] ppat: ppat table after the test
[   39.145239] ppat 0: 0x7
[   39.150198] ppat 2: 0xa
[   39.154981] ppat 3: 0x0
[   39.160100] ppat 4: 0xb
[   39.165058] ppat: make sure it's same with HW ppat table
[   39.175844] ppat: check private PAT on HW
[   39.184007] ppat: OK
[   39.188261] ppat: OK
Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 280 ++++++++++++++++++++++++++
 1 file changed, 280 insertions(+)
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +280 -0
index 6b132ca..cda0a41 100644
@@ -1094,6 +1094,284 @@ static int igt_ggtt_page(void *arg)
 	return err;
 }
 
+static int check_cnl_ppat_init(struct drm_i915_private *dev_priv)
+{
+	struct intel_ppat *ppat = &dev_priv->ppat;
+	int i;
+
+	for (i = 0; i < ppat->max_entries; i++) {
+		u32 value = I915_READ(GEN10_PAT_INDEX(i));
+		if (value != ppat->entries[i].value) {
+			pr_err("expected PPAT value isn't written into HW\n");
+			return -EINVAL;
+		}
+	}
+	return 0;
+}
+
+static int check_bdw_ppat_init(struct drm_i915_private *dev_priv)
+{
+	struct intel_ppat *ppat = &dev_priv->ppat;
+	u64 pat, hw_pat;
+	int i;
+
+	pat = hw_pat = 0;
+
+	for (i = 0; i < ppat->max_entries; i++)
+		pat |= GEN8_PPAT(i, ppat->entries[i].value);
+
+	hw_pat = I915_READ(GEN8_PRIVATE_PAT_HI);
+	hw_pat <<= 32;
+	hw_pat |= I915_READ(GEN8_PRIVATE_PAT_LO);
+
+	if (pat != hw_pat) {
+		pr_err("expected PPAT value isn't written into HW\n");
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int igt_ppat_init(void *arg)
+{
+	struct drm_i915_private *i915 = arg;
+	int ret;
+
+	if (!i915->ppat.max_entries)
+		return 0;
+
+	pr_debug("ppat: check private PAT on HW\n");
+
+	if (INTEL_GEN(i915) >= 10)
+		ret = check_cnl_ppat_init(i915);
+	else
+		ret = check_bdw_ppat_init(i915);
+
+	if (!ret)
+		pr_debug("ppat: OK\n");
+
+	return ret;
+}
+
+static u8 generate_new_value(struct intel_ppat *ppat, bool partial)
+{
+	u8 ca[] = { GEN8_PPAT_WB, GEN8_PPAT_WC, GEN8_PPAT_WT, GEN8_PPAT_UC };
+	u8 tc[] = { GEN8_PPAT_LLC, GEN8_PPAT_LLCELLC, GEN8_PPAT_LLCeLLC };
+	u8 age[] = { GEN8_PPAT_AGE(3), GEN8_PPAT_AGE(2), GEN8_PPAT_AGE(1), GEN8_PPAT_AGE(0) };
+	u8 value = 0;
+	bool same;
+	int ca_index, tc_index, age_index, i;
+
+#define for_each_ppat_attr(ca_index, tc_index, age_index) \
+	for ((ca_index) = 0 ; (ca_index) < ARRAY_SIZE(ca); (ca_index)++) \
+	for ((tc_index) = 0; (tc_index) < ARRAY_SIZE(tc); (tc_index)++) \
+	for ((age_index) = 0; (age_index) < ARRAY_SIZE(age); (age_index)++)
+
+	for_each_ppat_attr(ca_index, tc_index, age_index) {
+		value = age[age_index] | ca[ca_index] | tc[tc_index];
+		same = false;
+
+		for_each_set_bit(i, ppat->used, ppat->max_entries) {
+			if (value != ppat->entries[i].value)
+				continue;
+
+			same = true;
+			break;
+		}
+
+		if (same)
+			continue;
+
+		if (!partial)
+			return value;
+
+		/* partial match, cache attribute has to be the same. */
+		for_each_set_bit(i, ppat->used, ppat->max_entries) {
+			if (GEN8_PPAT_GET_CA(value) !=
+			    GEN8_PPAT_GET_CA(ppat->entries[i].value))
+				continue;
+
+			return value;
+		}
+	}
+#undef for_each_ppat_attr
+	return 0;
+}
+
+static inline bool ppat_table_is_full(struct intel_ppat *ppat)
+{
+	return bitmap_weight(ppat->used, ppat->max_entries) ==
+		ppat->max_entries;
+}
+
+static int igt_ppat_get(void *arg)
+{
+	struct drm_i915_private *i915 = arg;
+	struct intel_ppat *ppat = &i915->ppat;
+	const struct intel_ppat_entry **entries;
+	const struct intel_ppat_entry *entry;
+	unsigned int size = 0;
+	u8 value;
+	int i, ret;
+
+	if (!ppat->max_entries)
+		return 0;
+
+	pr_debug("ppat: ppat table before the test\n");
+
+	for_each_set_bit(i, ppat->used, ppat->max_entries)
+		pr_debug("ppat %d: 0x%x\n", i, ppat->entries[i].value);
+
+	pr_debug("ppat: make sure it's same with HW ppat table\n");
+
+	ret = igt_ppat_init(i915);
+	if (ret)
+		return ret;
+
+	pr_debug("ppat: case 1: perfect match\n");
+
+	entry = intel_ppat_get(i915, ppat->entries[0].value);
+	if (IS_ERR(entry))
+		return PTR_ERR(entry);
+
+	if (entry != &ppat->entries[0]) {
+		pr_err("not expected entry\n");
+		intel_ppat_put(entry);
+		return -EINVAL;
+	}
+
+	intel_ppat_put(entry);
+
+	pr_debug("ppat: OK\n");
+	pr_debug("ppat: case 2: alloc new entries\n");
+
+	entries = NULL;
+	ret = 0;
+
+	while (!ppat_table_is_full(ppat)) {
+		const struct intel_ppat_entry **p_entry;
+		DECLARE_BITMAP(used, INTEL_MAX_PPAT_ENTRIES);
+
+		bitmap_copy(used, ppat->used, ppat->max_entries);
+
+		entries = krealloc(entries, (size + 1) *
+				   sizeof(struct intel_ppat_entry *),
+				   GFP_KERNEL);
+		if (!entries) {
+			ret = -ENOSPC;
+			break;
+		}
+
+		p_entry = &entries[size++];
+		*p_entry = NULL;
+
+		value = generate_new_value(ppat, false);
+		if (!value) {
+			pr_err("cannot fill the unused PPAT entries?\n");
+			ret = -EINVAL;
+			break;
+		}
+
+		*p_entry = entry = intel_ppat_get(i915, value);
+		if (IS_ERR(entry)) {
+			pr_err("fail to get new entry\n");
+			ret = PTR_ERR(entry);
+			break;
+		}
+
+		if (entry->value != value) {
+			pr_err("fail to get expected new value\n");
+			ret = -EINVAL;
+			break;
+		}
+
+		if (bitmap_equal(used, ppat->used, ppat->max_entries)) {
+			pr_err("fail to alloc a new entry\n");
+			ret = -EINVAL;
+			break;
+		}
+
+		pr_debug("ppat: alloc new entry value 0x%x index %lu\n",
+			entry->value, entry - ppat->entries);
+	}
+
+	if (!ret)
+		pr_debug("ppat: OK\n");
+
+	if (!entries)
+		pr_debug("ppat: ppat table is full, skip\n");
+
+	if (ret)
+		goto ppat_put;
+
+	pr_debug("ppat: case 3: partial match\n");
+
+	value = generate_new_value(ppat, true);
+	if (!value) {
+		pr_err("fail to get new value\n");
+		ret = -EINVAL;
+		goto ppat_put;
+	}
+
+	pr_debug("ppat: generate value 0x%x\n", value);
+
+	entry = intel_ppat_get(i915, value);
+	if (IS_ERR(entry)) {
+		pr_err("fail to get new entry\n");
+		ret = PTR_ERR(entry);
+		goto ppat_put;
+	}
+
+	if (!(entry->value != value &&
+	    GEN8_PPAT_GET_CA(entry->value) == GEN8_PPAT_GET_CA(value))) {
+		pr_err("fail to get expected value\n");
+		ret = -EINVAL;
+	}
+
+	pr_debug("ppat: partial match entry value 0x%x index %lu\n",
+		entry->value, entry - ppat->entries);
+
+	intel_ppat_put(entry);
+
+ppat_put:
+	if (entries) {
+		pr_debug("ppat: put entries\n");
+
+		for (i = 0; i < size; i++) {
+			if (IS_ERR(entries[i]) || !entries[i])
+				continue;
+
+			pr_debug("ppat: put entry value 0x%x index %lu\n",
+				entries[i]->value, entries[i] - ppat->entries);
+
+			intel_ppat_put(entries[i]);
+
+			if (entries[i]->value != ppat->clear_value) {
+				pr_err("fail to put ppat value\n");
+				ret = -EINVAL;
+				break;
+			}
+		}
+		pr_debug("ppat: OK\n");
+		kfree(entries);
+		entries = NULL;
+	}
+
+	pr_debug("ppat: ppat table after the test\n");
+
+	for_each_set_bit(i, ppat->used, ppat->max_entries)
+		pr_debug("ppat %d: 0x%x\n", i, ppat->entries[i].value);
+
+	pr_debug("ppat: make sure it's same with HW ppat table\n");
+
+	ret = igt_ppat_init(i915);
+	if (ret)
+		return ret;
+
+	pr_debug("ppat: OK\n");
+
+	return ret;
+}
+
 static void track_vma_bind(struct i915_vma *vma)
 {
 	struct drm_i915_gem_object *obj = vma->obj;
@@ -1560,6 +1838,8 @@ int i915_gem_gtt_live_selftests(struct drm_i915_private *i915)
 		SUBTEST(igt_ggtt_pot),
 		SUBTEST(igt_ggtt_fill),
 		SUBTEST(igt_ggtt_page),
+		SUBTEST(igt_ppat_init),
+		SUBTEST(igt_ppat_get),
 	};
 
 	GEM_BUG_ON(offset_in_page(i915->ggtt.base.total));
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH 4/4] drm/i915/selftests: Introduce live tests of private PAT management

Quoting Zhi Wang (2017-09-05 20:58:27)

Quoted 51 lines

Introduce two live tests of private PAT managment:

igt_ppat_init - This test is to check if all the PPAT configuration is written into HW.

igt_ppat_get - This test performs several sub-tests on intel_ppat_get() and intel_ppat_put().

The "perfect match" test case will try to get a PPAT entry with an existing value, then check if the returned PPAT entry is the same one.

The "alloc entries" test case will run out of PPAT table, and check if all the requested values are put into the newly allocated PPAT entries.

The "partial match" test case will generate a parital matched value from the existing PPAT table and try to match it.

The "put entries" test case will free all the PPAT entries that allocated in "alloc entries" test case. It will check if the values of freed PPAT entries turn into ppat->clear_value.

An example output of these test cases on my SKL box is:

[   38.934158] ppat: check private PAT on HW
[   38.942498] ppat: OK
[   38.946752] ppat: ppat table before the test
[   38.955580] ppat 0: 0x7
[   38.960509] ppat 2: 0xa
[   38.965484] ppat 3: 0x0
[   38.970267] ppat 4: 0xb
[   38.975387] ppat: make sure it's same with HW ppat table
[   38.985996] ppat: check private PAT on HW
[   38.994492] ppat: OK
[   38.998921] ppat: case 1: perfect match
[   39.006706] ppat: OK
[   39.011135] ppat: case 2: alloc new entries
[   39.019825] ppat: alloc new entry value 0x37 index 1
[   39.029771] ppat: alloc new entry value 0x27 index 5
[   39.039829] ppat: alloc new entry value 0x17 index 6
[   39.050076] ppat: alloc new entry value 0x3b index 7
[   39.059980] ppat: OK
[   39.064570] ppat: case 3: partial match
[   39.072354] ppat: generate value 0x2b
[   39.079432] ppat: partial match entry value 0x3b index 7
[   39.090219] ppat: put entries
[   39.096061] ppat: put entry value 0x37 index 1
[   39.105262] ppat: put entry value 0x27 index 5
[   39.114150] ppat: put entry value 0x17 index 6
[   39.123154] ppat: put entry value 0x3b index 7
[   39.132335] ppat: OK
[   39.136588] ppat: ppat table after the test
Quoted 8 lines
[   39.145239] ppat 0: 0x7
[   39.150198] ppat 2: 0xa
[   39.154981] ppat 3: 0x0
[   39.160100] ppat 4: 0xb
[   39.165058] ppat: make sure it's same with HW ppat table
[   39.175844] ppat: check private PAT on HW
[   39.184007] ppat: OK
[   39.188261] ppat: OK

You don't feel this is too verbose? It's just noise (even at pr_debug and so usually hidden) for the signal is in the failure condition, which appears well documented.

I couldn't see any failure conditions tested, checking the handling of ENOSPC and then reallocation will be important.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

Re: [PATCH 4/4] drm/i915/selftests: Introduce live tests of private PAT management

In reply to Zhi Wang
reproduce:

Hi Zhi,

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on next-20170908]
[cannot apply to v4.13]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Zhi-Wang/drm-i915-Factor-out-setup_private_pat/20170908-154240
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-x001-201736 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

In file included from include/linux/kernel.h:13:0,

                    from include/asm-generic/bug.h:15,
                    from arch/x86/include/asm/bug.h:81,
                    from include/linux/bug.h:4,
                    from include/linux/mmdebug.h:4,
                    from include/linux/gfp.h:4,
                    from include/linux/slab.h:14,
                    from drivers/gpu/drm/i915/i915_gem_gtt.c:26:
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c: In function 'igt_ppat_get':
   include/linux/kern_levels.h:4:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:11: note: in definition of macro 'no_printk'
       printk(fmt, ##__VA_ARGS__); \
              ^~~
   include/linux/kern_levels.h:14:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:339:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
>> drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1293:3: note: in expansion of macro 'pr_debug'
      pr_debug("ppat: alloc new entry value 0x%x index %lu\n",
      ^~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:11: note: in definition of macro 'no_printk'
       printk(fmt, ##__VA_ARGS__); \
              ^~~
   include/linux/kern_levels.h:14:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:339:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1330:2: note: in expansion of macro 'pr_debug'
     pr_debug("ppat: partial match entry value 0x%x index %lu\n",
     ^~~~~~~~
   include/linux/kern_levels.h:4:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:11: note: in definition of macro 'no_printk'
       printk(fmt, ##__VA_ARGS__); \
              ^~~
   include/linux/kern_levels.h:14:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:339:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1343:4: note: in expansion of macro 'pr_debug'
       pr_debug("ppat: put entry value 0x%x index %lu\n",
       ^~~~~~~~

vim +/pr_debug +1293 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c

1205
1206 static int igt_ppat_get(void *arg)
1207 {
1208 struct drm_i915_private *i915 = arg;
1209 struct intel_ppat *ppat = &i915->ppat;
1210 const struct intel_ppat_entry **entries;
1211 const struct intel_ppat_entry *entry;
1212 unsigned int size = 0;
1213 u8 value;
1214 int i, ret;
1215
1216 if (!ppat->max_entries)
1217 return 0;
1218
1219 pr_debug("ppat: ppat table before the test\n");
1220
1221 for_each_set_bit(i, ppat->used, ppat->max_entries)
1222 pr_debug("ppat %d: 0x%x\n", i, ppat->entries[i].value);
1223
1224 pr_debug("ppat: make sure it's same with HW ppat table\n");
1225
1226 ret = igt_ppat_init(i915);
1227 if (ret)
1228 return ret;
1229
1230 pr_debug("ppat: case 1: perfect match\n");
1231
1232 entry = intel_ppat_get(i915, ppat->entries[0].value);
1233 if (IS_ERR(entry))
1234 return PTR_ERR(entry);
1235
1236 if (entry != &ppat->entries[0]) {
1237 pr_err("not expected entry\n");
1238 intel_ppat_put(entry);
1239 return -EINVAL;
1240 }
1241
1242 intel_ppat_put(entry);
1243
1244 pr_debug("ppat: OK\n");
1245 pr_debug("ppat: case 2: alloc new entries\n");
1246
1247 entries = NULL;
1248 ret = 0;
1249
1250 while (!ppat_table_is_full(ppat)) {
1251 const struct intel_ppat_entry **p_entry;
1252 DECLARE_BITMAP(used, INTEL_MAX_PPAT_ENTRIES);
1253
1254 bitmap_copy(used, ppat->used, ppat->max_entries);
1255
1256 entries = krealloc(entries, (size + 1) *
1257 sizeof(struct intel_ppat_entry *),
1258 GFP_KERNEL);
1259 if (!entries) {
1260 ret = -ENOSPC;
1261 break;
1262 }
1263
1264 p_entry = &entries[size++];
1265 *p_entry = NULL;
1266
1267 value = generate_new_value(ppat, false);
1268 if (!value) {
1269 pr_err("cannot fill the unused PPAT entries?\n");
1270 ret = -EINVAL;
1271 break;
1272 }
1273
1274 *p_entry = entry = intel_ppat_get(i915, value);
1275 if (IS_ERR(entry)) {
1276 pr_err("fail to get new entry\n");
1277 ret = PTR_ERR(entry);
1278 break;
1279 }
1280
1281 if (entry->value != value) {
1282 pr_err("fail to get expected new value\n");
1283 ret = -EINVAL;
1284 break;
1285 }
1286
1287 if (bitmap_equal(used, ppat->used, ppat->max_entries)) {
1288 pr_err("fail to alloc a new entry\n");
1289 ret = -EINVAL;
1290 break;
1291 }
1292

> 1293			pr_debug("ppat: alloc new entry value 0x%x index %lu\n",

1294 entry->value, entry - ppat->entries);
1295 }
1296
1297 if (!ret)
1298 pr_debug("ppat: OK\n");
1299
1300 if (!entries)
1301 pr_debug("ppat: ppat table is full, skip\n");
1302
1303 if (ret)
1304 goto ppat_put;
1305
1306 pr_debug("ppat: case 3: partial match\n");
1307
1308 value = generate_new_value(ppat, true);
1309 if (!value) {
1310 pr_err("fail to get new value\n");
1311 ret = -EINVAL;
1312 goto ppat_put;
1313 }
1314
1315 pr_debug("ppat: generate value 0x%x\n", value);
1316
1317 entry = intel_ppat_get(i915, value);
1318 if (IS_ERR(entry)) {
1319 pr_err("fail to get new entry\n");
1320 ret = PTR_ERR(entry);
1321 goto ppat_put;
1322 }
1323
1324 if (!(entry->value != value &&
1325 GEN8_PPAT_GET_CA(entry->value) == GEN8_PPAT_GET_CA(value))) {
1326 pr_err("fail to get expected value\n");
1327 ret = -EINVAL;
1328 }
1329
1330 pr_debug("ppat: partial match entry value 0x%x index %lu\n",
1331 entry->value, entry - ppat->entries);
1332
1333 intel_ppat_put(entry);
1334
1335 ppat_put:
1336 if (entries) {
1337 pr_debug("ppat: put entries\n");
1338
1339 for (i = 0; i < size; i++) {
1340 if (IS_ERR(entries[i]) || !entries[i])
1341 continue;
1342
1343 pr_debug("ppat: put entry value 0x%x index %lu\n",
1344 entries[i]->value, entries[i] - ppat->entries);
1345
1346 intel_ppat_put(entries[i]);
1347
1348 if (entries[i]->value != ppat->clear_value) {
1349 pr_err("fail to put ppat value\n");
1350 ret = -EINVAL;
1351 break;
1352 }
1353 }
1354 pr_debug("ppat: OK\n");
1355 kfree(entries);
1356 entries = NULL;
1357 }
1358
1359 pr_debug("ppat: ppat table after the test\n");
1360
1361 for_each_set_bit(i, ppat->used, ppat->max_entries)
1362 pr_debug("ppat %d: 0x%x\n", i, ppat->entries[i].value);
1363
1364 pr_debug("ppat: make sure it's same with HW ppat table\n");
1365
1366 ret = igt_ppat_init(i915);
1367 if (ret)
1368 return ret;
1369
1370 pr_debug("ppat: OK\n");
1371
1372 return ret;
1373 }
1374

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH 4/4] drm/i915/selftests: Introduce live tests of private PAT management

In reply to Zhi Wang
reproduce:

Hi Zhi,

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on next-20170908]
[cannot apply to v4.13]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Zhi-Wang/drm-i915-Factor-out-setup_private_pat/20170908-154240
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

In file included from include/linux/kernel.h:13:0,

                    from include/asm-generic/bug.h:15,
                    from arch/x86/include/asm/bug.h:81,
                    from include/linux/bug.h:4,
                    from include/linux/mmdebug.h:4,
                    from include/linux/gfp.h:4,
                    from include/linux/slab.h:14,
                    from drivers/gpu/drm/i915/i915_gem_gtt.c:26:
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c: In function 'igt_ppat_get':
>> drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1293:12: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'int' [-Wformat=]
      pr_debug("ppat: alloc new entry value 0x%x index %lu\n",
               ^
   include/linux/printk.h:285:21: note: in definition of macro 'pr_fmt'
    #define pr_fmt(fmt) fmt
                        ^~~
   include/linux/printk.h:333:2: note: in expansion of macro 'dynamic_pr_debug'
     dynamic_pr_debug(fmt, ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1293:3: note: in expansion of macro 'pr_debug'
      pr_debug("ppat: alloc new entry value 0x%x index %lu\n",
      ^~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1330:11: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'int' [-Wformat=]
     pr_debug("ppat: partial match entry value 0x%x index %lu\n",
              ^
   include/linux/printk.h:285:21: note: in definition of macro 'pr_fmt'
    #define pr_fmt(fmt) fmt
                        ^~~
   include/linux/printk.h:333:2: note: in expansion of macro 'dynamic_pr_debug'
     dynamic_pr_debug(fmt, ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1330:2: note: in expansion of macro 'pr_debug'
     pr_debug("ppat: partial match entry value 0x%x index %lu\n",
     ^~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1343:13: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'int' [-Wformat=]
       pr_debug("ppat: put entry value 0x%x index %lu\n",
                ^
   include/linux/printk.h:285:21: note: in definition of macro 'pr_fmt'
    #define pr_fmt(fmt) fmt
                        ^~~
   include/linux/printk.h:333:2: note: in expansion of macro 'dynamic_pr_debug'
     dynamic_pr_debug(fmt, ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c:1343:4: note: in expansion of macro 'pr_debug'
       pr_debug("ppat: put entry value 0x%x index %lu\n",
       ^~~~~~~~

vim +1293 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c

1205
1206 static int igt_ppat_get(void *arg)
1207 {
1208 struct drm_i915_private *i915 = arg;
1209 struct intel_ppat *ppat = &i915->ppat;
1210 const struct intel_ppat_entry **entries;
1211 const struct intel_ppat_entry *entry;
1212 unsigned int size = 0;
1213 u8 value;
1214 int i, ret;
1215
1216 if (!ppat->max_entries)
1217 return 0;
1218
1219 pr_debug("ppat: ppat table before the test\n");
1220
1221 for_each_set_bit(i, ppat->used, ppat->max_entries)
1222 pr_debug("ppat %d: 0x%x\n", i, ppat->entries[i].value);
1223
1224 pr_debug("ppat: make sure it's same with HW ppat table\n");
1225
1226 ret = igt_ppat_init(i915);
1227 if (ret)
1228 return ret;
1229
1230 pr_debug("ppat: case 1: perfect match\n");
1231
1232 entry = intel_ppat_get(i915, ppat->entries[0].value);
1233 if (IS_ERR(entry))
1234 return PTR_ERR(entry);
1235
1236 if (entry != &ppat->entries[0]) {
1237 pr_err("not expected entry\n");
1238 intel_ppat_put(entry);
1239 return -EINVAL;
1240 }
1241
1242 intel_ppat_put(entry);
1243
1244 pr_debug("ppat: OK\n");
1245 pr_debug("ppat: case 2: alloc new entries\n");
1246
1247 entries = NULL;
1248 ret = 0;
1249
1250 while (!ppat_table_is_full(ppat)) {
1251 const struct intel_ppat_entry **p_entry;
1252 DECLARE_BITMAP(used, INTEL_MAX_PPAT_ENTRIES);
1253
1254 bitmap_copy(used, ppat->used, ppat->max_entries);
1255
1256 entries = krealloc(entries, (size + 1) *
1257 sizeof(struct intel_ppat_entry *),
1258 GFP_KERNEL);
1259 if (!entries) {
1260 ret = -ENOSPC;
1261 break;
1262 }
1263
1264 p_entry = &entries[size++];
1265 *p_entry = NULL;
1266
1267 value = generate_new_value(ppat, false);
1268 if (!value) {
1269 pr_err("cannot fill the unused PPAT entries?\n");
1270 ret = -EINVAL;
1271 break;
1272 }
1273
1274 *p_entry = entry = intel_ppat_get(i915, value);
1275 if (IS_ERR(entry)) {
1276 pr_err("fail to get new entry\n");
1277 ret = PTR_ERR(entry);
1278 break;
1279 }
1280
1281 if (entry->value != value) {
1282 pr_err("fail to get expected new value\n");
1283 ret = -EINVAL;
1284 break;
1285 }
1286
1287 if (bitmap_equal(used, ppat->used, ppat->max_entries)) {
1288 pr_err("fail to alloc a new entry\n");
1289 ret = -EINVAL;
1290 break;
1291 }
1292

> 1293			pr_debug("ppat: alloc new entry value 0x%x index %lu\n",

1294 entry->value, entry - ppat->entries);
1295 }
1296
1297 if (!ret)
1298 pr_debug("ppat: OK\n");
1299
1300 if (!entries)
1301 pr_debug("ppat: ppat table is full, skip\n");
1302
1303 if (ret)
1304 goto ppat_put;
1305
1306 pr_debug("ppat: case 3: partial match\n");
1307
1308 value = generate_new_value(ppat, true);
1309 if (!value) {
1310 pr_err("fail to get new value\n");
1311 ret = -EINVAL;
1312 goto ppat_put;
1313 }
1314
1315 pr_debug("ppat: generate value 0x%x\n", value);
1316
1317 entry = intel_ppat_get(i915, value);
1318 if (IS_ERR(entry)) {
1319 pr_err("fail to get new entry\n");
1320 ret = PTR_ERR(entry);
1321 goto ppat_put;
1322 }
1323
1324 if (!(entry->value != value &&
1325 GEN8_PPAT_GET_CA(entry->value) == GEN8_PPAT_GET_CA(value))) {
1326 pr_err("fail to get expected value\n");
1327 ret = -EINVAL;
1328 }
1329
1330 pr_debug("ppat: partial match entry value 0x%x index %lu\n",
1331 entry->value, entry - ppat->entries);
1332
1333 intel_ppat_put(entry);
1334
1335 ppat_put:
1336 if (entries) {
1337 pr_debug("ppat: put entries\n");
1338
1339 for (i = 0; i < size; i++) {
1340 if (IS_ERR(entries[i]) || !entries[i])
1341 continue;
1342
1343 pr_debug("ppat: put entry value 0x%x index %lu\n",
1344 entries[i]->value, entries[i] - ppat->entries);
1345
1346 intel_ppat_put(entries[i]);
1347
1348 if (entries[i]->value != ppat->clear_value) {
1349 pr_err("fail to put ppat value\n");
1350 ret = -EINVAL;
1351 break;
1352 }
1353 }
1354 pr_debug("ppat: OK\n");
1355 kfree(entries);
1356 entries = NULL;
1357 }
1358
1359 pr_debug("ppat: ppat table after the test\n");
1360
1361 for_each_set_bit(i, ppat->used, ppat->max_entries)
1362 pr_debug("ppat %d: 0x%x\n", i, ppat->entries[i].value);
1363
1364 pr_debug("ppat: make sure it's same with HW ppat table\n");
1365
1366 ret = igt_ppat_init(i915);
1367 if (ret)
1368 return ret;
1369
1370 pr_debug("ppat: OK\n");
1371
1372 return ret;
1373 }
1374

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

✗ Fi.CI.BAT: warning for series starting with [1/4] drm/i915: Factor out setup_private_pat()

In reply to Zhi Wang
== Series Details ==

== Series Details ==

Series: series starting with [1/4] drm/i915: Factor out setup_private_pat()
URL : https://patchwork.freedesktop.org/series/29843/
State : warning

== Summary ==

Series 29843v1 series starting with [1/4] drm/i915: Factor out setup_private_pat()
https://patchwork.freedesktop.org/api/1.0/series/29843/revisions/1/mbox/

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                pass       -> SKIP       (fi-skl-x1585l) fdo#101781
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-n2820) fdo#101705
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> SKIP       (fi-cfl-s)
Test drv_module_reload:
        Subgroup basic-reload-inject:
                dmesg-fail -> DMESG-WARN (fi-cfl-s) k.org#196765

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705
k.org#196765 https://bugzilla.kernel.org/show_bug.cgi?id=196765

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:457s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:439s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:361s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:561s
fi-bwr-2160      total:289  pass:184  dwarn:0   dfail:0   fail:0   skip:105 time:255s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:523s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:522s
fi-byt-n2820     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:515s
fi-cfl-s         total:289  pass:249  dwarn:4   dfail:0   fail:0   skip:36  time:458s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:444s
fi-glk-2a        total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:613s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:443s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:427s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:430s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:513s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:479s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:509s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:602s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:607s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:527s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:467s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:540s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:514s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:445s
fi-skl-x1585l    total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:487s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:551s
fi-snb-2600      total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:404s

22fe7d7fe4c7a6e04c7f7f99d6b8985008616546 drm-tip: 2017y-09m-05d-19h-15m-06s UTC integration manifest c5aba3f37055 drm/i915/selftests: Introduce live tests of private PAT management 0c12116055eb drm/i915: Do not allocate unused PPAT entries
9322128c777a drm/i915: Introduce private PAT management
dde7f5c616c5 drm/i915: Factor out setup_private_pat()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5587/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw
In reply to Zhi Wang

Ping.

-----Original Message-----
From: Wang, Zhi A
Sent: Tuesday, September 5, 2017 10:58 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Widawsky, Benjamin <[email protected]>; Vivi, Rodrigo <[email protected]>
Subject: [PATCH 1/4] drm/i915: Factor out setup_private_pat()

Factor out setup_private_pat() for introducing the following patches.

Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +9 -0
index c33c2f9..2fc0656 100644
@@ -2915,6 +2915,16 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
 	cleanup_scratch_page(vm);
 }
 
+static void setup_private_pat(struct drm_i915_private *dev_priv) {
+	if (INTEL_GEN(dev_priv) >= 10)
+		cnl_setup_private_ppat(dev_priv);
+	else if (IS_CHERRYVIEW(dev_priv) || IS_GEN9_LP(dev_priv))
+		chv_setup_private_ppat(dev_priv);
+	else
+		bdw_setup_private_ppat(dev_priv);
+}
+
 static int gen8_gmch_probe(struct i915_ggtt *ggtt)  {
 	struct drm_i915_private *dev_priv = ggtt->base.i915; @@ -2947,14 +2957,6 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 	}

ggtt->base.total = (size / sizeof(gen8_pte_t)) << PAGE_SHIFT;
-
- if (INTEL_GEN(dev_priv) >= 10)
- cnl_setup_private_ppat(dev_priv);
- else if (IS_CHERRYVIEW(dev_priv) || IS_GEN9_LP(dev_priv))
- chv_setup_private_ppat(dev_priv);
- else
- bdw_setup_private_ppat(dev_priv);
-
ggtt->base.cleanup = gen6_gmch_remove;
ggtt->base.bind_vma = ggtt_bind_vma;
ggtt->base.unbind_vma = ggtt_unbind_vma; @@ -2975,6 +2977,8 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)

ggtt->invalidate = gen6_ggtt_invalidate;

+ setup_private_pat(dev_priv);
+
return ggtt_probe_common(ggtt, size);
}

--
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/4
#11 lore raw
In reply to Zhi Wang

Quoting Zhi Wang (2017-09-05 20:58:24)

Quoted 7 lines

Factor out setup_private_pat() for introducing the following patches.

Cc Ben Widawsky <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx