From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 2/6] drm/xe: Allow to assign GGTT region to the VF
Date: Mon, 15 Apr 2024 10:19:35 +0530 [thread overview]
Message-ID: <f3151915-3057-4fe8-981f-cf58ced43b04@intel.com> (raw)
In-Reply-To: <20240414190137.1243-3-michal.wajdeczko@intel.com>
[-- Attachment #1: Type: text/plain, Size: 3841 bytes --]
On 15-04-2024 00:31, Michal Wajdeczko wrote:
> VF's drivers can't modify GGTT PTEs except the range explicitly
> assigned by the PF driver. To allow hardware enforcement of this
> requirement, each GGTT PTE has a field with the VF number that
> identifies which VF can modify that particular GGTT PTE entry.
>
> Only PF driver can modify this field and PF driver shall do that
> before VF drivers will be loaded. Add function to prepare PTEs.
> Since it will be used only by the PF driver, make it available
> only for CONFIG_PCI_IOV=y.
>
> Bspec: 45015
> Signed-off-by: Michal Wajdeczko<michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/regs/xe_gtt_defs.h | 2 ++
> drivers/gpu/drm/xe/xe_ggtt.c | 44 +++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_ggtt.h | 4 +++
> 3 files changed, 50 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/regs/xe_gtt_defs.h b/drivers/gpu/drm/xe/regs/xe_gtt_defs.h
> index 558519ce48c7..4389e5a76f89 100644
> --- a/drivers/gpu/drm/xe/regs/xe_gtt_defs.h
> +++ b/drivers/gpu/drm/xe/regs/xe_gtt_defs.h
> @@ -9,6 +9,8 @@
> #define XELPG_GGTT_PTE_PAT0 BIT_ULL(52)
> #define XELPG_GGTT_PTE_PAT1 BIT_ULL(53)
>
> +#define GGTT_PTE_VFID GENMASK_ULL(11, 2)
Patch looks good to me.
Just to confrim, based on BSPEC, this MASK applies to GRAPHICS_VER >=
12.50. For versions before this, the applicable mask is (4, 2). I infer
that since SRIOV support on XE is expected beyond GRAPHICS_VER version
12.50, you are using mask (11, 2).
> +
> #define GUC_GGTT_TOP 0xFEE00000
>
> #define XELPG_PPGTT_PTE_PAT3 BIT_ULL(62)
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index ff2239c0eda5..f090cab065b8 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -460,6 +460,50 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> }
>
> +#ifdef CONFIG_PCI_IOV
> +static u64 xe_encode_vfid_pte(u16 vfid)
> +{
> + return FIELD_PREP(GGTT_PTE_VFID, vfid) | XE_PAGE_PRESENT;
> +}
> +
> +static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid)
> +{
> + u64 start = node->start;
> + u64 size = node->size;
> + u64 end = start + size - 1;
> + u64 pte = xe_encode_vfid_pte(vfid);
> +
> + lockdep_assert_held(&ggtt->lock);
> +
> + if (!drm_mm_node_allocated(node))
> + return;
> +
> + while (start < end) {
> + xe_ggtt_set_pte(ggtt, start, pte);
> + start += XE_PAGE_SIZE;
> + }
> +
> + xe_ggtt_invalidate(ggtt);
> +}
> +
> +/**
> + * xe_ggtt_assign - assign a GGTT region to the VF
> + * @ggtt: the &xe_ggtt where the node belongs
> + * @node: the &drm_mm_node to update
> + * @vfid: the VF identifier
> + *
> + * This function is used by the PF driver to assign a GGTT region to the VF.
> + * In addition to PTE's VFID bits 11:2 also PRESENT bit 0 is set as on some
> + * platforms VFs can't modify that either.
This info regarding bit 0 not being modifiable by VF's on some platforms
is missing in Bspec.
> + */
> +void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid)
> +{
> + mutex_lock(&ggtt->lock);
> + xe_ggtt_assign_locked(ggtt, node, vfid);
> + mutex_unlock(&ggtt->lock);
> +}
> +#endif
> +
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
> {
> int err;
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 8306ef74abc6..4a41a1762358 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -33,4 +33,8 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
>
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
>
> +#ifdef CONFIG_PCI_IOV
> +void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid);
> +#endif
> +
> #endif
[-- Attachment #2: Type: text/html, Size: 5573 bytes --]
next prev parent reply other threads:[~2024-04-15 4:49 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-14 19:01 [PATCH 0/6] PF: Add support to configure SR-IOV VFs Michal Wajdeczko
2024-04-14 19:01 ` [PATCH 1/6] drm/xe: Add helper to format SR-IOV function name Michal Wajdeczko
2024-04-15 3:47 ` Ghimiray, Himal Prasad
2024-04-15 7:56 ` Piotr Piórkowski
2024-04-15 8:30 ` Michal Wajdeczko
2024-04-14 19:01 ` [PATCH 2/6] drm/xe: Allow to assign GGTT region to the VF Michal Wajdeczko
2024-04-15 4:49 ` Ghimiray, Himal Prasad [this message]
2024-04-15 9:01 ` Michal Wajdeczko
2024-04-15 9:10 ` Piotr Piórkowski
2024-04-15 9:12 ` Ghimiray, Himal Prasad
2024-04-14 19:01 ` [PATCH 3/6] drm/xe: Add xe_ttm_vram_get_avail Michal Wajdeczko
2024-04-15 4:51 ` Ghimiray, Himal Prasad
2024-04-14 19:01 ` [PATCH 4/6] drm/xe/guc: Add PF2GUC_UPDATE_VF_CFG to ABI Michal Wajdeczko
2024-04-15 9:29 ` Piotr Piórkowski
2024-04-14 19:01 ` [PATCH 5/6] drm/xe/pf: Add SR-IOV PF specific early GT initialization Michal Wajdeczko
2024-04-15 5:19 ` Ghimiray, Himal Prasad
2024-04-15 8:14 ` Michal Wajdeczko
2024-04-14 19:01 ` [PATCH 6/6] drm/xe/pf: Add support to configure SR-IOV VFs Michal Wajdeczko
2024-04-15 14:29 ` Piotr Piórkowski
2024-04-15 17:06 ` Michal Wajdeczko
2024-04-15 17:15 ` ✓ CI.Patch_applied: success for PF: " Patchwork
2024-04-15 17:15 ` ✗ CI.checkpatch: warning " Patchwork
2024-04-15 17:16 ` ✓ CI.KUnit: success " Patchwork
2024-04-15 17:27 ` ✓ CI.Build: " Patchwork
2024-04-15 17:30 ` ✓ CI.Hooks: " Patchwork
2024-04-15 17:31 ` ✓ CI.checksparse: " Patchwork
2024-04-15 17:57 ` ✓ CI.BAT: " Patchwork
2024-04-16 3:44 ` ✓ 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=f3151915-3057-4fe8-981f-cf58ced43b04@intel.com \
--to=himal.prasad.ghimiray@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