Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Maslak <jan.maslak@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: zbigniew.kempczynski@intel.com, Jan Maslak <jan.maslak@intel.com>
Subject: [PATCH v6 06/11] lib/mocs: Add packed MOCS helpers
Date: Mon, 13 Jul 2026 15:37:41 +0200	[thread overview]
Message-ID: <20260713133746.453051-7-jan.maslak@intel.com> (raw)
In-Reply-To: <20260713133746.453051-1-jan.maslak@intel.com>

Some genxml-generated pack headers represent MOCS as a single 7-bit
field encoding both the 6-bit MOCS table index at bits 6:1 and the PXP
protected-content bit at bit 0. The existing _index() helpers return
only the table index, which is correct for layouts where the index and
protection bit are represented separately, but not for genxml fields
that expect the packed value.

Add helpers that return the full 7-bit value ready for direct
assignment:

  - intel_get_wb_mocs(fd): write-back policy, PXP clear
  - intel_get_uc_mocs(fd): uncached policy, PXP clear

Keep the existing _index() helpers for callers using layouts where the
MOCS index and protection or encryption bit are represented separately.

Signed-off-by: Jan Maslak <jan.maslak@intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 lib/intel_mocs.c | 28 ++++++++++++++++++++++++++++
 lib/intel_mocs.h |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/lib/intel_mocs.c b/lib/intel_mocs.c
index 778fd848ed..973bf9e7b9 100644
--- a/lib/intel_mocs.c
+++ b/lib/intel_mocs.c
@@ -81,6 +81,34 @@ uint8_t intel_get_wb_mocs_index(int fd)
 	return mocs.wb_index;
 }
 
+/**
+ * intel_get_wb_mocs:
+ * @fd: the DRM file descriptor
+ *
+ * Returns: The full 7-bit MOCS field value for write-back caching, with the
+ * 6-bit table index shifted to bits 6:1 and the PXP bit (bit 0) cleared.
+ * Use this when assigning to a genxml-generated MOCS field, which encodes
+ * both the index and PXP bit in a single 7-bit value.
+ */
+uint8_t intel_get_wb_mocs(int fd)
+{
+	return intel_get_wb_mocs_index(fd) << 1;
+}
+
+/**
+ * intel_get_uc_mocs:
+ * @fd: the DRM file descriptor
+ *
+ * Returns: The full 7-bit MOCS field value for uncached accesses, with the
+ * 6-bit table index shifted to bits 6:1 and the PXP bit (bit 0) cleared.
+ * Use this when assigning to a genxml-generated MOCS field, which encodes
+ * both the index and PXP bit in a single 7-bit value.
+ */
+uint8_t intel_get_uc_mocs(int fd)
+{
+	return intel_get_uc_mocs_index(fd) << 1;
+}
+
 /**
  * intel_get_uc_mocs_index:
  * @fd: the DRM file descriptor
diff --git a/lib/intel_mocs.h b/lib/intel_mocs.h
index 394bb41be0..6a1c0f99ce 100644
--- a/lib/intel_mocs.h
+++ b/lib/intel_mocs.h
@@ -12,6 +12,8 @@
 #define DISPLAYABLE_MOCS_INDEX ((uint8_t)-2)
 
 uint8_t intel_get_wb_mocs_index(int fd);
+uint8_t intel_get_wb_mocs(int fd);
+uint8_t intel_get_uc_mocs(int fd);
 uint8_t intel_get_uc_mocs_index(int fd);
 uint8_t intel_get_displayable_mocs_index(int fd);
 uint8_t intel_get_defer_to_pat_mocs_index(int fd);
-- 
2.43.0


  parent reply	other threads:[~2026-07-13 13:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:37 [PATCH v6 00/11] lib/genxml: Introduce Mesa genxml infrastructure to IGT Jan Maslak
2026-07-13 13:37 ` [PATCH v6 01/11] lib/intel/genxml: Add genxml generators, headers, and build integration Jan Maslak
2026-07-13 13:37 ` [PATCH v6 04/11] lib/intel/genxml: Import Xe2/Xe3/Xe3p XML hardware definitions from Mesa Jan Maslak
2026-07-13 13:37 ` [PATCH v6 05/11] lib/intel_bufops: Add intel_buf_mocs() helper Jan Maslak
2026-07-13 13:37 ` Jan Maslak [this message]
2026-07-13 13:37 ` [PATCH v6 07/11] lib/rendercopy: Convert surface state and sampler setup to genxml Jan Maslak
2026-07-13 13:37 ` [PATCH v6 08/11] lib/rendercopy: Convert vertex data and CC state " Jan Maslak
2026-07-13 13:37 ` [PATCH v6 09/11] lib/rendercopy: Convert pipeline emit commands " Jan Maslak
2026-07-16  9:50   ` Zbigniew Kempczyński
2026-07-13 13:37 ` [PATCH v6 10/11] lib/rendercopy: Convert render op and entry points " Jan Maslak
2026-07-13 13:37 ` [PATCH v6 11/11] lib: Add genxml annotated batch buffer decode Jan Maslak
2026-07-16 10:54   ` Kamil Konieczny
2026-07-13 19:14 ` ✓ Xe.CI.BAT: success for lib/genxml: Introduce Mesa genxml infrastructure to IGT (rev7) Patchwork
2026-07-13 19:31 ` ✓ i915.CI.BAT: " Patchwork
2026-07-13 22:59 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-07-14  4:08 ` ✓ i915.CI.Full: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260713133746.453051-7-jan.maslak@intel.com \
    --to=jan.maslak@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox