Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: [PATCH 11/13] drm/xe/pf: Use GuC Buffer Cache during VFs provisioning
Date: Thu, 12 Dec 2024 02:01:39 +0100	[thread overview]
Message-ID: <20241212010141.389-12-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20241212010141.389-1-michal.wajdeczko@intel.com>

Start using GuC buffer cache for the VF's configuration actions.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
v2: rebased (Michal)
---
 drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 69 +++++++++++-----------
 1 file changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 65082f12f1a8..8f756f81bc20 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -20,6 +20,7 @@
 #include "xe_gt_sriov_pf_policy.h"
 #include "xe_gt_sriov_printk.h"
 #include "xe_guc.h"
+#include "xe_guc_buf.h"
 #include "xe_guc_ct.h"
 #include "xe_guc_db_mgr.h"
 #include "xe_guc_fwif.h"
@@ -71,48 +72,27 @@ static int pf_send_vf_cfg_reset(struct xe_gt *gt, u32 vfid)
  * Return: number of KLVs that were successfully parsed and saved,
  *         negative error code on failure.
  */
-static int pf_send_vf_cfg_klvs(struct xe_gt *gt, u32 vfid, const u32 *klvs, u32 num_dwords)
+static int pf_send_vf_buf_klvs(struct xe_gt *gt, u32 vfid, struct xe_guc_buf buf, u32 num_dwords)
 {
-	const u32 bytes = num_dwords * sizeof(u32);
-	struct xe_tile *tile = gt_to_tile(gt);
-	struct xe_device *xe = tile_to_xe(tile);
 	struct xe_guc *guc = &gt->uc.guc;
-	struct xe_bo *bo;
-	int ret;
 
-	bo = xe_bo_create_pin_map(xe, tile, NULL,
-				  ALIGN(bytes, PAGE_SIZE),
-				  ttm_bo_type_kernel,
-				  XE_BO_FLAG_VRAM_IF_DGFX(tile) |
-				  XE_BO_FLAG_GGTT |
-				  XE_BO_FLAG_GGTT_INVALIDATE);
-	if (IS_ERR(bo))
-		return PTR_ERR(bo);
-
-	xe_map_memcpy_to(xe, &bo->vmap, 0, klvs, bytes);
-
-	ret = guc_action_update_vf_cfg(guc, vfid, xe_bo_ggtt_addr(bo), num_dwords);
-
-	xe_bo_unpin_map_no_vm(bo);
-
-	return ret;
+	return guc_action_update_vf_cfg(guc, vfid, xe_guc_buf_gpu_addr(buf), num_dwords);
 }
 
 /*
  * Return: 0 on success, -ENOKEY if some KLVs were not updated, -EPROTO if reply was malformed,
  *         negative error code on failure.
  */
-static int pf_push_vf_cfg_klvs(struct xe_gt *gt, unsigned int vfid, u32 num_klvs,
-			       const u32 *klvs, u32 num_dwords)
+static int pf_push_vf_buf_klvs(struct xe_gt *gt, unsigned int vfid, u32 num_klvs,
+			       struct xe_guc_buf buf, u32 num_dwords)
 {
 	int ret;
 
-	xe_gt_assert(gt, num_klvs == xe_guc_klv_count(klvs, num_dwords));
-
-	ret = pf_send_vf_cfg_klvs(gt, vfid, klvs, num_dwords);
+	ret = pf_send_vf_buf_klvs(gt, vfid, buf, num_dwords);
 
 	if (ret != num_klvs) {
 		int err = ret < 0 ? ret : ret < num_klvs ? -ENOKEY : -EPROTO;
+		void *klvs = xe_guc_buf_cpu_ptr(buf);
 		struct drm_printer p = xe_gt_info_printer(gt);
 		char name[8];
 
@@ -125,13 +105,35 @@ static int pf_push_vf_cfg_klvs(struct xe_gt *gt, unsigned int vfid, u32 num_klvs
 
 	if (IS_ENABLED(CONFIG_DRM_XE_DEBUG_SRIOV)) {
 		struct drm_printer p = xe_gt_info_printer(gt);
+		void *klvs = xe_guc_buf_cpu_ptr(buf);
+		char name[8];
 
+		xe_gt_sriov_info(gt, "pushed %s config with %u KLV%s:\n",
+				 xe_sriov_function_name(vfid, name, sizeof(name)),
+				 num_klvs, str_plural(num_klvs));
 		xe_guc_klv_print(klvs, num_dwords, &p);
 	}
 
 	return 0;
 }
 
+/*
+ * Return: 0 on success, -ENOBUFS if no free buffer for the indirect data,
+ *         negative error code on failure.
+ */
+static int pf_push_vf_cfg_klvs(struct xe_gt *gt, unsigned int vfid, u32 num_klvs,
+			       const u32 *klvs, u32 num_dwords)
+{
+	CLASS(xe_guc_buf_from_data, buf)(&gt->uc.guc.buf, klvs, num_dwords * sizeof(u32));
+
+	xe_gt_assert(gt, num_klvs == xe_guc_klv_count(klvs, num_dwords));
+
+	if (!xe_guc_buf_is_valid(buf))
+		return -ENOBUFS;
+
+	return pf_push_vf_buf_klvs(gt, vfid, num_klvs, buf, num_dwords);
+}
+
 static int pf_push_vf_cfg_u32(struct xe_gt *gt, unsigned int vfid, u16 key, u32 value)
 {
 	u32 klv[] = {
@@ -304,16 +306,17 @@ static u32 encode_config(u32 *cfg, const struct xe_gt_sriov_config *config, bool
 static int pf_push_full_vf_config(struct xe_gt *gt, unsigned int vfid)
 {
 	struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
-	u32 max_cfg_dwords = SZ_4K / sizeof(u32);
+	u32 max_cfg_dwords = xe_guc_buf_cache_dwords(&gt->uc.guc.buf);
+	CLASS(xe_guc_buf, buf)(&gt->uc.guc.buf, max_cfg_dwords);
 	u32 num_dwords;
 	int num_klvs;
 	u32 *cfg;
 	int err;
 
-	cfg = kcalloc(max_cfg_dwords, sizeof(u32), GFP_KERNEL);
-	if (!cfg)
-		return -ENOMEM;
+	if (!xe_guc_buf_is_valid(buf))
+		return -ENOBUFS;
 
+	cfg = xe_guc_buf_cpu_ptr(buf);
 	num_dwords = encode_config(cfg, config, true);
 	xe_gt_assert(gt, num_dwords <= max_cfg_dwords);
 
@@ -328,11 +331,11 @@ static int pf_push_full_vf_config(struct xe_gt *gt, unsigned int vfid)
 		num_dwords += encode_config_ggtt(cfg + num_dwords, other, true);
 	}
 	xe_gt_assert(gt, num_dwords <= max_cfg_dwords);
+	xe_guc_buf_flush(buf);
 
 	num_klvs = xe_guc_klv_count(cfg, num_dwords);
-	err = pf_push_vf_cfg_klvs(gt, vfid, num_klvs, cfg, num_dwords);
+	err = pf_push_vf_buf_klvs(gt, vfid, num_klvs, buf, num_dwords);
 
-	kfree(cfg);
 	return err;
 }
 
-- 
2.47.1


  parent reply	other threads:[~2024-12-12  1:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12  1:01 [PATCH 00/13] The xe_sa_manager based GuC Buffer Cache Michal Wajdeczko
2024-12-12  1:01 ` [PATCH 01/13] drm/xe/sa: Always call drm_suballoc_manager_fini() Michal Wajdeczko
2024-12-12  3:03   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 02/13] drm/xe/sa: Drop redundant NULL assignments Michal Wajdeczko
2024-12-12  3:03   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 03/13] drm/xe/sa: Cleanup internal BO data at device removal Michal Wajdeczko
2024-12-12  3:07   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 04/13] drm/xe/sa: Drop useless is_iomem member Michal Wajdeczko
2024-12-12  3:09   ` Matthew Brost
2024-12-18 20:53     ` Michal Wajdeczko
2024-12-12  1:01 ` [PATCH 05/13] drm/xe/sa: Improve error message on init failure Michal Wajdeczko
2024-12-12  3:10   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 06/13] drm/xe/sa: Tidy up coding style in init() Michal Wajdeczko
2024-12-12  3:11   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 07/13] drm/xe/sa: Allow making suballocations using custom gfp flags Michal Wajdeczko
2024-12-12  3:12   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 08/13] drm/xe/sa: Allow creating suballocator with custom guard size Michal Wajdeczko
2024-12-12  3:23   ` Matthew Brost
2024-12-12 21:57     ` Michal Wajdeczko
2024-12-12 22:48       ` Matthew Brost
2024-12-12  1:01 ` [PATCH 09/13] drm/xe/sa: Minor header cleanups Michal Wajdeczko
2024-12-12  3:14   ` Matthew Brost
2024-12-12  1:01 ` [PATCH 10/13] drm/xe/guc: Introduce the GuC Buffer Cache Michal Wajdeczko
2024-12-12  3:30   ` Matthew Brost
2024-12-12 21:48     ` Michal Wajdeczko
2024-12-13 18:38       ` Matthew Brost
2024-12-13 20:13         ` Rodrigo Vivi
2024-12-18 21:03           ` Michal Wajdeczko
2024-12-19 20:28             ` Rodrigo Vivi
2024-12-12  1:01 ` Michal Wajdeczko [this message]
2024-12-12  3:34   ` [PATCH 11/13] drm/xe/pf: Use GuC Buffer Cache during VFs provisioning Matthew Brost
2024-12-12 22:02     ` Michal Wajdeczko
2024-12-12  1:01 ` [PATCH 12/13] drm/xe/kunit: Allow to replace xe_managed_bo_create_pin_map() Michal Wajdeczko
2024-12-12  1:01 ` [PATCH 13/13] drm/xe/kunit: Add KUnit tests for GuC Buffer Cache Michal Wajdeczko
2024-12-12  3:36   ` Matthew Brost
2024-12-18 21:06     ` Michal Wajdeczko
2024-12-12  2:20 ` ✓ CI.Patch_applied: success for The xe_sa_manager based " Patchwork
2024-12-12  2:20 ` ✗ CI.checkpatch: warning " Patchwork
2024-12-12  2:21 ` ✓ CI.KUnit: success " Patchwork
2024-12-12  2:41 ` ✓ CI.Build: " Patchwork
2024-12-12  2:45 ` ✓ CI.Hooks: " Patchwork
2024-12-12  2:48 ` ✓ CI.checksparse: " Patchwork
2024-12-12  3:14 ` ✗ Xe.CI.BAT: failure " Patchwork
2024-12-12  8:50 ` ✗ Xe.CI.Full: " 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=20241212010141.389-12-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