From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BD5CEED617 for ; Thu, 12 Sep 2024 16:23:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34A8410EBDE; Thu, 12 Sep 2024 16:23:42 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="LanR7PWB"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1A8110EBDE for ; Thu, 12 Sep 2024 16:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726158221; x=1757694221; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version:content-transfer-encoding; bh=sYKCvL6KDDBjRuG5hY8h/Zy/UgrVRLisVz2holajHUM=; b=LanR7PWBivyKwLqq0eLWG6TzAbusuyWNWkLyfFiMQiTgBOMPrs01cZ/D QzjpC9kf4JV0j0POD97Rx4JoEegwm/bq2oIZKgFnZW3fnUeMCK6lWGBFC CXOnCRNmA6FhJB5jVu5sT0tcE07wYsDY0KSXxPFsKOmK926MT69Rkggjp 8MasKqt+HNjidgWYkdiAJ7IMA1j4EIY8c2w/HNOtqRrEYigQHUlGcNIPM UyhPaiDzyJ+hRe502SIyJuLbCiInC8uL6F7GHYu01k2RQjKyZPg9vbkx+ o4+LryVJXx4vasDLBm6JRT/nxfzsLRXV6mlv8bscl+COEuEn5DP8enSbx w==; X-CSE-ConnectionGUID: 4Xf6hLOITga8rx3jFNVMsQ== X-CSE-MsgGUID: tLU+GgHeQyKrN9A77oL1RA== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="35695264" X-IronPort-AV: E=Sophos;i="6.10,223,1719903600"; d="scan'208";a="35695264" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 09:23:41 -0700 X-CSE-ConnectionGUID: DdDaRI0iSKKKWci6aIy7Pg== X-CSE-MsgGUID: FGc5UWcmTFyRNkZ6eHDYNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,223,1719903600"; d="scan'208";a="67738893" Received: from jhliu1-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.125.81.59]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 09:23:40 -0700 Date: Thu, 12 Sep 2024 09:07:42 -0700 Message-ID: <87h6ak3lf5.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: =?ISO-8859-1?Q?Jos=E9?= Roberto de Souza Cc: Subject: Re: [PATCH v2] drm/xe/oa: Fix overflow in oa batch buffer In-Reply-To: <20240912153842.35813-1-jose.souza@intel.com> References: <20240912153842.35813-1-jose.souza@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Thu, 12 Sep 2024 08:38:42 -0700, Jos=E9 Roberto de Souza wrote: > > By default xe_bb_create_job() appends a MI_BATCH_BUFFER_END to batch > buffer, this is not a problem if batch buffer is only used once but > oa reuses the batch buffer for the same metric and at each call > it appends a MI_BATCH_BUFFER_END, printing the warning below and then > overflowing. > > [ 381.072016] ------------[ cut here ]------------ > [ 381.072019] xe 0000:00:02.0: [drm] Assertion `bb->len * 4 + bb_prefetc= h(q->gt) <=3D size` failed! I'd think just this one line from this log is sufficient for the commit mes= sage. > platform: LUNARLAKE subplatform: 1 > graphics: Xe2_LPG / Xe2_HPG 20.04 step B0 > media: Xe2_LPM / Xe2_HPM 20.00 step B0 > tile: 0 VRAM 0 B > GT: 0 type 1 > > So here checking if batch buffer already have MI_BATCH_BUFFER_END if > not append it. > > v2: > - simply fix, suggestion from Ashutosh > > Cc: Ashutosh Dixit > Signed-off-by: Jos=E9 Roberto de Souza > --- > drivers/gpu/drm/xe/xe_bb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c > index a13e0b3a169ed..ef777dbdf4ecc 100644 > --- a/drivers/gpu/drm/xe/xe_bb.c > +++ b/drivers/gpu/drm/xe/xe_bb.c > @@ -65,7 +65,8 @@ __xe_bb_create_job(struct xe_exec_queue *q, struct xe_b= b *bb, u64 *addr) > { > u32 size =3D drm_suballoc_size(bb->bo); > > - bb->cs[bb->len++] =3D MI_BATCH_BUFFER_END; > + if (bb->len =3D=3D 0 || bb->cs[bb->len - 1] !=3D MI_BATCH_BUFFER_END) > + bb->cs[bb->len++] =3D MI_BATCH_BUFFER_END; In any case, thanks for the fix: Reviewed-by: Ashutosh Dixit > xe_gt_assert(q->gt, bb->len * 4 + bb_prefetch(q->gt) <=3D size); > > -- > 2.46.0 >