intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: Matt Roper <matthew.d.roper@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations
Date: Fri, 31 Mar 2023 13:14:15 -0700	[thread overview]
Message-ID: <20230331201415.gdlb7xmjpae5ybbb@ldmartin-desk2.lan> (raw)
In-Reply-To: <20230329173334.4015124-2-matthew.d.roper@intel.com>

On Wed, Mar 29, 2023 at 10:33:32AM -0700, Matt Roper wrote:
>The hardware prefetches several cachelines of data from batchbuffers
>before they are parsed.  This prefetching only stops when the parser
>encounters an MI_BATCH_BUFFER_END instruction (or a nested
>MI_BATCH_BUFFER_START), so we must ensure that there is enough padding
>at the end of the batchbuffer to prevent the prefetcher from running
>past the end of the allocation and potentially faulting.
>
>Bspec: 45717
>Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
>---
> drivers/gpu/drm/xe/xe_bb.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
>index 5b24018e2a80..f326f117ba3b 100644
>--- a/drivers/gpu/drm/xe/xe_bb.c
>+++ b/drivers/gpu/drm/xe/xe_bb.c
>@@ -8,11 +8,26 @@
> #include "regs/xe_gpu_commands.h"
> #include "xe_device.h"
> #include "xe_engine_types.h"
>+#include "xe_gt.h"
> #include "xe_hw_fence.h"
> #include "xe_sa.h"
> #include "xe_sched_job.h"
> #include "xe_vm_types.h"
>
>+static int bb_prefetch(struct xe_gt *gt)
>+{
>+	struct xe_device *xe = gt->xe;
>+
>+	if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
>+		/*
>+		 * RCS and CCS require 1K, although other engines would be
>+		 * okay with 512.
>+		 */
>+		return SZ_1K;
>+	else
>+		return SZ_512;
>+}
>+
> struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
> {
> 	struct xe_bb *bb = kmalloc(sizeof(*bb), GFP_KERNEL);
>@@ -21,8 +36,14 @@ struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
> 	if (!bb)
> 		return ERR_PTR(-ENOMEM);
>
>-	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool :
>-			      &gt->usm.bb_pool, 4 * dwords + 4);
>+	/*
>+	 * We need to allocate space for the requested number of dwords,
>+	 * one additional MI_BATCH_BUFFER_END dword, and additional buffer
>+	 * space to accomodate the platform-specific hardware prefetch
>+	 * requirements.
>+	 */
>+	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool : &gt->usm.bb_pool,
>+			      4 * (dwords + 1) + bb_prefetch(gt));

if the command buffer for the CS is 512 or 1024, wouldn't it be
sufficient to just align the end rather than increase it by that?

Lucas De Marchi

  reply	other threads:[~2023-03-31 20:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
2023-03-29 17:33 ` [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations Matt Roper
2023-03-31 20:14   ` Lucas De Marchi [this message]
2023-03-31 20:34     ` Matt Roper
2023-03-29 17:33 ` [Intel-xe] [PATCH 2/3] drm/xe: Adjust batchbuffer space warning when creating a job Matt Roper
2023-03-29 17:33 ` [Intel-xe] [PATCH 3/3] drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer Matt Roper
2023-03-29 17:36 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes Patchwork
2023-03-29 17:36 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
2023-03-29 18:20   ` Michal Wajdeczko
2023-03-29 17:59 ` [Intel-xe] [PATCH 0/3] " Souza, Jose
2023-03-29 18:08 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes (rev2) Patchwork
2023-03-29 18:09 ` [Intel-xe] ✗ CI.KUnit: failure " 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=20230331201415.gdlb7xmjpae5ybbb@ldmartin-desk2.lan \
    --to=lucas.demarchi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@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;
as well as URLs for NNTP newsgroup(s).