From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Marcin Bernatowicz" <marcin.bernatowicz@linux.intel.com>,
"Adam Miszczak" <adam.miszczak@linux.intel.com>,
"Jakub Kolakowski" <jakub1.kolakowski@intel.com>,
"Lukasz Laguna" <lukasz.laguna@intel.com>,
"Michał Wajdeczko" <michal.wajdeczko@intel.com>,
"Michał Winiarski" <michal.winiarski@intel.com>,
"Narasimha C V" <narasimha.c.v@intel.com>,
"Piotr Piórkowski" <piotr.piorkowski@intel.com>,
"Satyanarayana K V P" <satyanarayana.k.v.p@intel.com>,
"Tomasz Lis" <tomasz.lis@intel.com>
Subject: [PATCH i-g-t 3/5] lib/xe/xe_sriov_provisioning: Add shared resource provisionability check
Date: Wed, 18 Dec 2024 13:00:54 +0100 [thread overview]
Message-ID: <20241218120056.779962-4-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20241218120056.779962-1-marcin.bernatowicz@linux.intel.com>
Introduce a helper `xe_sriov_is_shared_res_provisionable` to determine
if a shared resource can be provisioned.
Add macros `xe_sriov_for_each_shared_res` and
`xe_sriov_for_each_provisionable_shared_res` to iterate over shared
resources and provisionable shared resources, respectively.
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Narasimha C V <narasimha.c.v@intel.com>
Cc: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Cc: Tomasz Lis <tomasz.lis@intel.com>
---
lib/xe/xe_sriov_provisioning.c | 22 ++++++++++++++++++++++
lib/xe/xe_sriov_provisioning.h | 29 +++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
index 536121931..22035ffd8 100644
--- a/lib/xe/xe_sriov_provisioning.c
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -9,6 +9,7 @@
#include "intel_chipset.h"
#include "linux_scaffold.h"
#include "xe/xe_mmio.h"
+#include "xe/xe_query.h"
#include "xe/xe_sriov_debugfs.h"
#include "xe/xe_sriov_provisioning.h"
@@ -274,3 +275,24 @@ void xe_sriov_pf_set_shared_res_attr(int pf, enum xe_sriov_shared_res res,
{
igt_fail_on(__xe_sriov_pf_set_shared_res_attr(pf, res, vf_num, gt_num, value));
}
+
+/**
+ * xe_sriov_is_shared_res_provisionable - Check if a shared resource is provisionable
+ * @pf: PF device file descriptor
+ * @res: Shared resource type (see enum xe_sriov_shared_res)
+ * @gt_num: GT number
+ *
+ * Determines whether a specified shared resource can be provisioned.
+ *
+ * Return: true if the shared resource is provisionable, false otherwise.
+ */
+bool xe_sriov_is_shared_res_provisionable(int pf, enum xe_sriov_shared_res res,
+ unsigned int gt_num)
+{
+ if (res == XE_SRIOV_SHARED_RES_LMEM)
+ return xe_has_vram(pf) && !xe_is_media_gt(pf, gt_num);
+ else if (res == XE_SRIOV_SHARED_RES_GGTT)
+ return !xe_is_media_gt(pf, gt_num);
+
+ return true;
+}
diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
index 168b50394..b4300ec2e 100644
--- a/lib/xe/xe_sriov_provisioning.h
+++ b/lib/xe/xe_sriov_provisioning.h
@@ -27,6 +27,34 @@ enum xe_sriov_shared_res {
XE_SRIOV_SHARED_RES_LMEM,
};
+/**
+ * XE_SRIOV_SHARED_RES_NUM - Number of shared resource types
+ */
+#define XE_SRIOV_SHARED_RES_NUM (XE_SRIOV_SHARED_RES_LMEM + 1)
+
+/**
+ * xe_sriov_for_each_shared_res - Iterate over all shared resource types
+ * @res: Loop counter variable of type `enum xe_sriov_shared_res`
+ *
+ * Iterates over each shared resource type defined in the `enum xe_sriov_shared_res`.
+ */
+#define xe_sriov_for_each_shared_res(res) \
+ for ((res) = 0; (res) < XE_SRIOV_SHARED_RES_NUM; (res)++)
+
+/**
+ * xe_sriov_for_each_provisionable_shared_res - Iterate over provisionable shared
+ * resource types
+ * @res: Loop counter variable of type `enum xe_sriov_shared_res`
+ * @pf: PF device file descriptor of type int
+ * @gt: GT number of type unsigned int
+ *
+ * Iterates over each provisionable shared resource type for the given PF device
+ * and GT number.
+ */
+#define xe_sriov_for_each_provisionable_shared_res(res, pf, gt) \
+ for ((res) = 0; (res) < XE_SRIOV_SHARED_RES_NUM; (res)++) \
+ for_if(xe_sriov_is_shared_res_provisionable((pf), (res), (gt)))
+
/**
* struct xe_sriov_provisioned_range - Provisioned range for a Virtual Function (VF)
* @vf_id: The ID of the VF
@@ -43,6 +71,7 @@ struct xe_sriov_provisioned_range {
};
const char *xe_sriov_shared_res_to_string(enum xe_sriov_shared_res res);
+bool xe_sriov_is_shared_res_provisionable(int pf, enum xe_sriov_shared_res res, unsigned int gt);
int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, int gt, struct xe_mmio *mmio,
struct xe_sriov_provisioned_range **ranges,
unsigned int *nr_ranges);
--
2.31.1
next prev parent reply other threads:[~2024-12-18 12:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 12:00 [PATCH i-g-t 0/5] Add xe_sriov_auto_provisioning tests Marcin Bernatowicz
2024-12-18 12:00 ` [PATCH i-g-t 1/5] lib/xe/xe_sriov_debugfs: Add debugfs get/set functions for u32, u64, bool Marcin Bernatowicz
2024-12-18 14:18 ` Laguna, Lukasz
2024-12-18 12:00 ` [PATCH i-g-t 2/5] lib/xe/xe_sriov_provisioning: Add accessors for quota/spare attributes Marcin Bernatowicz
2024-12-18 14:28 ` Laguna, Lukasz
2024-12-18 12:00 ` Marcin Bernatowicz [this message]
2024-12-18 14:47 ` [PATCH i-g-t 3/5] lib/xe/xe_sriov_provisioning: Add shared resource provisionability check Laguna, Lukasz
2024-12-18 12:00 ` [PATCH i-g-t 4/5] lib/igt_sriov_device: Add helper functions for VF range validation Marcin Bernatowicz
2024-12-19 14:39 ` Laguna, Lukasz
2024-12-18 12:00 ` [PATCH i-g-t 5/5] tests/xe_sriov_auto_provisioning: Add tests for SR-IOV auto-provisioning Marcin Bernatowicz
2024-12-19 14:48 ` Laguna, Lukasz
2024-12-19 15:54 ` Bernatowicz, Marcin
2025-01-07 11:52 ` Laguna, Lukasz
2024-12-18 22:25 ` ✓ i915.CI.BAT: success for Add xe_sriov_auto_provisioning tests Patchwork
2024-12-19 1:00 ` ✓ Xe.CI.BAT: " Patchwork
2024-12-19 12:22 ` ✗ i915.CI.Full: failure " Patchwork
2024-12-19 17:51 ` ✗ 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=20241218120056.779962-4-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=adam.miszczak@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@intel.com \
--cc=narasimha.c.v@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=satyanarayana.k.v.p@intel.com \
--cc=tomasz.lis@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