From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
Date: Fri, 9 Aug 2024 17:33:38 -0400 [thread overview]
Message-ID: <ZraLMv2UGwTltRuw@intel.com> (raw)
In-Reply-To: <3ef3dece-525e-4832-9952-0a425a9c1017@intel.com>
On Thu, Jul 11, 2024 at 10:00:51PM +0200, Michal Wajdeczko wrote:
>
>
> On 11.07.2024 19:11, Rodrigo Vivi wrote:
> > Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
> > demand and continue with the goal of limiting drm_mm access to xe_ggtt.
> >
> > Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
> > drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
> > 3 files changed, 38 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> > index 67337bfeb81e..dbaf1ce87fb4 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.c
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> > @@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> > bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> > }
> >
> > +/**
> > + * xe_ggtt_largest_hole - Largest GGTT hole
> > + * @ggtt: the &xe_ggtt that will be inspected
> > + * @alignment: mininum alignment
>
> typo: minimum
thanks, addressed this...
>
> > + * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
> > + *
> > + * Return: size of the largest continuous GGTT region
> > + */
> > +u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
> > +{
> > + const struct drm_mm *mm = &ggtt->mm;
> > + const struct drm_mm_node *entry;
> > + u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
>
> this is likely not needed any more as xe_ggtt is always above WOPCM
> (unlikely to previous driver ;)
hmmm... probably... but can we leave this to a follow up after we
get this series merged?
I'm trying to not modify the current behavior more then it is already
doing...
>
> > + u64 hole_start, hole_end, hole_size;
> > + u64 max_hole = 0;
> > +
> > + mutex_lock(&ggtt->lock);
> > +
> > + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> > + hole_start = max(hole_start, hole_min_start);
> > + hole_start = ALIGN(hole_start, alignment);
> > + hole_end = ALIGN_DOWN(hole_end, alignment);
> > + if (hole_start >= hole_end)
> > + continue;
> > + hole_size = hole_end - hole_start;
> > + if (spare)
> > + *spare -= min3(*spare, hole_size, max_hole);
> > + max_hole = max(max_hole, hole_size);
> > + }
> > +
> > + mutex_unlock(&ggtt->lock);
> > +
> > + return max_hole;
> > +}
> > +
> > #ifdef CONFIG_PCI_IOV
> > static u64 xe_encode_vfid_pte(u16 vfid)
> > {
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> > index f816b3c0732b..31060fe7644b 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.h
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> > @@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> > int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> > u64 start, u64 end);
> > void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> > +u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
> >
> > int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
> >
> > 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 efaf188290ea..1d17c34fe5a4 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > @@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
> > static u64 pf_get_max_ggtt(struct xe_gt *gt)
> > {
> > struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
> > - const struct drm_mm *mm = &ggtt->mm;
> > - const struct drm_mm_node *entry;
> > u64 alignment = pf_get_ggtt_alignment(gt);
> > u64 spare = pf_get_spare_ggtt(gt);
> > - u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
> > - u64 hole_start, hole_end, hole_size;
> > - u64 max_hole = 0;
> > -
> > - mutex_lock(&ggtt->lock);
> > -
> > - drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> > - hole_start = max(hole_start, hole_min_start);
> > - hole_start = ALIGN(hole_start, alignment);
> > - hole_end = ALIGN_DOWN(hole_end, alignment);
> > - if (hole_start >= hole_end)
> > - continue;
> > - hole_size = hole_end - hole_start;
> > - xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
> > - hole_start, hole_size / SZ_1K);
> > - spare -= min3(spare, hole_size, max_hole);
> > - max_hole = max(max_hole, hole_size);
> > - }
> > + u64 max_hole;
> >
> > - mutex_unlock(&ggtt->lock);
> > + max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
> >
> > xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
> > max_hole / SZ_1K, spare / SZ_1K);
next prev parent reply other threads:[~2024-08-09 21:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 02/12] drm/xe: Introduce GGTT documentation Rodrigo Vivi
2024-07-11 19:41 ` Michal Wajdeczko
2024-07-11 17:11 ` [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes Rodrigo Vivi
2024-07-11 18:35 ` Cavitt, Jonathan
2024-07-11 17:11 ` [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt Rodrigo Vivi
2024-07-11 18:38 ` Cavitt, Jonathan
2024-07-11 17:11 ` [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node Rodrigo Vivi
2024-07-11 19:51 ` Michal Wajdeczko
2024-07-16 17:16 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions Rodrigo Vivi
2024-07-16 17:24 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node Rodrigo Vivi
2024-07-17 23:27 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-07-11 20:00 ` Michal Wajdeczko
2024-08-09 21:33 ` Rodrigo Vivi [this message]
2024-07-11 17:11 ` [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes Rodrigo Vivi
2024-07-11 18:43 ` Cavitt, Jonathan
2024-07-11 20:09 ` Michal Wajdeczko
2024-08-09 21:38 ` Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear Rodrigo Vivi
2024-07-11 20:17 ` Michal Wajdeczko
2024-08-09 21:42 ` Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent Rodrigo Vivi
2024-07-17 23:50 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node Rodrigo Vivi
2024-07-16 17:32 ` Matthew Brost
2024-07-11 17:25 ` ✓ CI.Patch_applied: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk Patchwork
2024-07-11 17:26 ` ✓ CI.checkpatch: " Patchwork
2024-07-11 17:28 ` ✓ CI.KUnit: " Patchwork
2024-07-11 17:34 ` ✗ CI.Build: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-08-15 22:07 [PATCH 01/12] " Rodrigo Vivi
2024-08-15 22:07 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-16 15:02 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-16 15:02 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-16 15:35 ` Lucas De Marchi
2024-08-17 10:35 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-17 10:35 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-20 20:25 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-20 20:25 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-21 19:38 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-21 19:38 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
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=ZraLMv2UGwTltRuw@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@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.