All of lore.kernel.org
 help / color / mirror / Atom feed
From: apoorva1.singh@intel.com
To: apoorva1.singh@intel.com, igt-dev@lists.freedesktop.org,
	ramalingam.c@intel.com, zbigniew.kempczynski@intel.com,
	arjun.melkaveri@intel.com
Subject: [igt-dev] [PATCH i-g-t, v4 1/5] lib/i915: Introduce library intel_mocs
Date: Fri, 10 Dec 2021 18:35:29 +0530	[thread overview]
Message-ID: <20211210130533.3688728-2-apoorva1.singh@intel.com> (raw)
In-Reply-To: <20211210130533.3688728-1-apoorva1.singh@intel.com>

From: Apoorva Singh <apoorva1.singh@intel.com>

Add new library intel_mocs for mocs settings.

Signed-off-by: Apoorva Singh <apoorva1.singh@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Melkaveri, Arjun <arjun.melkaveri@intel.com>
---
 lib/i915/intel_mocs.c | 51 +++++++++++++++++++++++++++++++++++++++++++
 lib/i915/intel_mocs.h | 19 ++++++++++++++++
 lib/meson.build       |  1 +
 3 files changed, 71 insertions(+)
 create mode 100644 lib/i915/intel_mocs.c
 create mode 100644 lib/i915/intel_mocs.h

diff --git a/lib/i915/intel_mocs.c b/lib/i915/intel_mocs.c
new file mode 100644
index 00000000..e8c19309
--- /dev/null
+++ b/lib/i915/intel_mocs.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2021 Intel Corporation
+ */
+
+#include "igt.h"
+#include "i915/gem.h"
+#include "intel_mocs.h"
+
+static void get_mocs_index(int fd, struct drm_i915_mocs_index *mocs)
+{
+	uint16_t devid = intel_get_drm_devid(fd);
+
+	/*
+	 * Gen >= 12 onwards don't have a setting for PTE,
+	 * so using I915_MOCS_PTE as mocs index may leads to
+	 * some undefined MOCS behavior.
+	 * This helper function is providing current UC as well
+	 * as WB MOCS index based on platform.
+
+	 */
+	if (IS_DG1(devid)) {
+		mocs->uc_index = 1;
+		mocs->wb_index = 5;
+	} else if (IS_GEN12(devid)) {
+		mocs->uc_index = 3;
+		mocs->wb_index = 2;
+	} else {
+		mocs->uc_index = I915_MOCS_PTE;
+		mocs->wb_index = I915_MOCS_CACHED;
+	}
+}
+
+/* BitField [6:1] represents index to MOCS Tables
+ * BitField [0] represents Encryption/Decryption */
+
+uint8_t intel_get_wb_mocs(int fd)
+{
+	struct drm_i915_mocs_index mocs;
+
+	get_mocs_index(fd, &mocs);
+	return mocs.wb_index << 1;
+}
+
+uint8_t intel_get_uc_mocs(int fd)
+{
+	struct drm_i915_mocs_index mocs;
+
+	get_mocs_index(fd, &mocs);
+	return mocs.uc_index << 1;
+}
diff --git a/lib/i915/intel_mocs.h b/lib/i915/intel_mocs.h
new file mode 100644
index 00000000..efd8607f
--- /dev/null
+++ b/lib/i915/intel_mocs.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef _INTEL_MOCS_H
+#define _INTEL_MOCS_H
+
+#define XY_BLOCK_COPY_BLT_MOCS_SHIFT		21
+#define XY_CTRL_SURF_COPY_BLT_MOCS_SHIFT	25
+
+struct drm_i915_mocs_index {
+	uint8_t uc_index;
+	uint8_t wb_index;
+};
+
+uint8_t intel_get_wb_mocs(int fd);
+uint8_t intel_get_uc_mocs(int fd);
+#endif /* _INTEL_MOCS_H */
diff --git a/lib/meson.build b/lib/meson.build
index b9568a71..f500f0f1 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -11,6 +11,7 @@ lib_sources = [
 	'i915/gem_mman.c',
 	'i915/gem_vm.c',
 	'i915/intel_memory_region.c',
+	'i915/intel_mocs.c',
 	'igt_collection.c',
 	'igt_color_encoding.c',
 	'igt_debugfs.c',
-- 
2.25.1

  reply	other threads:[~2021-12-10 13:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 13:05 [igt-dev] [PATCH i-g-t,v4 0/5] Add testing for CCS apoorva1.singh
2021-12-10 13:05 ` apoorva1.singh [this message]
2021-12-13 15:58   ` [igt-dev] [PATCH i-g-t, v4 1/5] lib/i915: Introduce library intel_mocs Zbigniew Kempczyński
2021-12-10 13:05 ` [igt-dev] [PATCH i-g-t, v4 2/5] lib/i915: Introduce library i915_blt apoorva1.singh
2021-12-15  9:40   ` Zbigniew Kempczyński
2021-12-16 13:11   ` Zbigniew Kempczyński
2021-12-16 13:15   ` Zbigniew Kempczyński
2021-12-16 13:19   ` Zbigniew Kempczyński
2021-12-16 14:18     ` Singh, Apoorva1
2021-12-10 13:05 ` [igt-dev] [PATCH i-g-t, v4 3/5] lib/intel_chipset.h: Add has_flat_ccs flag apoorva1.singh
2021-12-10 13:05 ` [igt-dev] [PATCH i-g-t, v4 4/5] i915/gem_engine_topology: Only use the main copy engines for XY_BLOCK_COPY apoorva1.singh
2021-12-10 13:05 ` [igt-dev] [PATCH i-g-t,v4 5/5] i915/gem_ccs: Add testing for CCS apoorva1.singh
2021-12-10 13:45 ` [igt-dev] ✓ Fi.CI.BAT: success for Add testing for CCS (rev4) Patchwork
2021-12-11  8:42 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20211210130533.3688728-2-apoorva1.singh@intel.com \
    --to=apoorva1.singh@intel.com \
    --cc=arjun.melkaveri@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=ramalingam.c@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.