From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [PATCH 1/6] drm/xe/vf: Use register values obtained from the PF
Date: Thu, 23 May 2024 21:22:35 +0200 [thread overview]
Message-ID: <20240523192240.844-2-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20240523192240.844-1-michal.wajdeczko@intel.com>
As part of the its initialization, the VF driver has already
obtained a list of the runtime (fuse) register values from the
PF driver. When VF driver is attempting to read register that is
inaccessible to the VF, use the values from this list instead.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 53 +++++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_gt_sriov_vf.h | 2 ++
drivers/gpu/drm/xe/xe_mmio.c | 4 +++
3 files changed, 59 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
index bab3858b423e..237486a80fb5 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
@@ -4,6 +4,7 @@
*/
#include <linux/bitfield.h>
+#include <linux/bsearch.h>
#include <drm/drm_managed.h>
#include <drm/drm_print.h>
@@ -21,6 +22,7 @@
#include "xe_guc.h"
#include "xe_guc_hxg_helpers.h"
#include "xe_guc_relay.h"
+#include "xe_mmio.h"
#include "xe_sriov.h"
#define make_u64_from_u32(hi, lo) ((u64)((u64)(u32)(hi) << 32 | (u32)(lo)))
@@ -677,6 +679,57 @@ int xe_gt_sriov_vf_query_runtime(struct xe_gt *gt)
return err;
}
+static int vf_runtime_reg_cmp(const void *a, const void *b)
+{
+ const struct vf_runtime_reg *ra = a;
+ const struct vf_runtime_reg *rb = b;
+
+ return (int)ra->offset - (int)rb->offset;
+}
+
+static struct vf_runtime_reg *vf_lookup_reg(struct xe_gt *gt, u32 addr)
+{
+ struct xe_gt_sriov_vf_runtime *runtime = >->sriov.vf.runtime;
+ struct vf_runtime_reg key = { .offset = addr };
+
+ xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
+
+ return bsearch(&key, runtime->regs, runtime->regs_size, sizeof(key),
+ vf_runtime_reg_cmp);
+}
+
+/**
+ * xe_gt_sriov_vf_read32 - Get a register value from the runtime data.
+ * @gt: the &xe_gt
+ * @reg: the register to read
+ *
+ * This function is for VF use only.
+ * This function shall be called after VF has connected to PF.
+ * This function is dedicated for registers that VFs can't read directly.
+ *
+ * Return: register value obtained from the PF or 0 if not found.
+ */
+u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg)
+{
+ u32 addr = xe_mmio_adjusted_addr(gt, reg.addr);
+ struct vf_runtime_reg *rr;
+
+ xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
+ xe_gt_assert(gt, gt->sriov.vf.pf_version.major);
+ xe_gt_assert(gt, !reg.vf);
+
+ rr = vf_lookup_reg(gt, addr);
+ if (!rr) {
+ xe_gt_WARN(gt, IS_ENABLED(CONFIG_DRM_XE_DEBUG),
+ "VF is trying to read an inaccessible register %#x+%#x\n",
+ reg.addr, addr - reg.addr);
+ return 0;
+ }
+
+ xe_gt_sriov_dbg_verbose(gt, "runtime[%#x] = %#x\n", addr, rr->value);
+ return rr->value;
+}
+
/**
* xe_gt_sriov_vf_print_config - Print VF self config.
* @gt: the &xe_gt
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.h b/drivers/gpu/drm/xe/xe_gt_sriov_vf.h
index d6d37b193d17..be69c1025320 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.h
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.h
@@ -10,6 +10,7 @@
struct drm_printer;
struct xe_gt;
+struct xe_reg;
int xe_gt_sriov_vf_bootstrap(struct xe_gt *gt);
int xe_gt_sriov_vf_query_config(struct xe_gt *gt);
@@ -17,6 +18,7 @@ int xe_gt_sriov_vf_connect(struct xe_gt *gt);
int xe_gt_sriov_vf_query_runtime(struct xe_gt *gt);
u16 xe_gt_sriov_vf_guc_ids(struct xe_gt *gt);
+u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg);
void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p);
void xe_gt_sriov_vf_print_runtime(struct xe_gt *gt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
index 8a39d4c18554..16c94f118119 100644
--- a/drivers/gpu/drm/xe/xe_mmio.c
+++ b/drivers/gpu/drm/xe/xe_mmio.c
@@ -22,6 +22,7 @@
#include "xe_gt.h"
#include "xe_gt_mcr.h"
#include "xe_gt_printk.h"
+#include "xe_gt_sriov_vf.h"
#include "xe_macros.h"
#include "xe_module.h"
#include "xe_sriov.h"
@@ -479,6 +480,9 @@ u32 xe_mmio_read32(struct xe_gt *gt, struct xe_reg reg)
struct xe_tile *tile = gt_to_tile(gt);
u32 addr = xe_mmio_adjusted_addr(gt, reg.addr);
+ if (!reg.vf && IS_SRIOV_VF(gt_to_xe(gt)))
+ return xe_gt_sriov_vf_read32(gt, reg);
+
return readl((reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + addr);
}
--
2.43.0
next prev parent reply other threads:[~2024-05-23 19:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 19:22 [PATCH 0/6] VF: Use the runtime registers Michal Wajdeczko
2024-05-23 19:22 ` Michal Wajdeczko [this message]
2024-05-23 21:28 ` [PATCH 1/6] drm/xe/vf: Use register values obtained from the PF Matt Roper
2024-05-23 19:22 ` [PATCH 2/6] drm/xe/guc: Add GLOBAL_CFG_GMD_ID KLV definition Michal Wajdeczko
2024-05-23 20:50 ` Matt Roper
2024-05-23 19:22 ` [PATCH 3/6] drm/xe/vf: Obtain value of GMDID register from GuC Michal Wajdeczko
2024-05-23 20:52 ` Matt Roper
2024-05-23 19:22 ` [PATCH 4/6] drm/xe/vf: Provide early access to GMDID register Michal Wajdeczko
2024-05-23 21:08 ` Matt Roper
2024-05-23 21:17 ` Matt Roper
2024-05-23 21:43 ` Michal Wajdeczko
2024-05-23 22:30 ` [PATCH v2 " Michal Wajdeczko
2024-05-23 19:22 ` [PATCH 5/6] drm/xe/vf: Cache value of the " Michal Wajdeczko
2024-05-23 21:20 ` Matt Roper
2024-05-23 19:22 ` [PATCH 6/6] drm/xe/vf: Treat GMDID as another runtime register Michal Wajdeczko
2024-05-23 21:21 ` Matt Roper
2024-05-23 19:29 ` ✓ CI.Patch_applied: success for VF: Use the runtime registers Patchwork
2024-05-23 19:29 ` ✓ CI.checkpatch: " Patchwork
2024-05-23 19:30 ` ✓ CI.KUnit: " Patchwork
2024-05-23 19:41 ` ✓ CI.Build: " Patchwork
2024-05-23 19:44 ` ✓ CI.Hooks: " Patchwork
2024-05-23 19:45 ` ✓ CI.checksparse: " Patchwork
2024-05-23 23:05 ` ✓ CI.Patch_applied: success for VF: Use the runtime registers (rev2) Patchwork
2024-05-23 23:06 ` ✓ CI.checkpatch: " Patchwork
2024-05-23 23:07 ` ✓ CI.KUnit: " Patchwork
2024-05-23 23:18 ` ✓ CI.Build: " Patchwork
2024-05-23 23:19 ` ✗ CI.FULL: failure for VF: Use the runtime registers Patchwork
2024-05-23 23:21 ` ✓ CI.Hooks: success for VF: Use the runtime registers (rev2) Patchwork
2024-05-23 23:22 ` ✓ CI.checksparse: " Patchwork
2024-05-23 23:49 ` ✓ CI.BAT: " Patchwork
2024-05-24 2:10 ` ✗ CI.FULL: failure " Patchwork
2024-05-24 7:50 ` Michal Wajdeczko
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=20240523192240.844-2-michal.wajdeczko@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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