From patchwork Thu Oct 26 18:36:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 13437797 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 87D35C25B6E for ; Thu, 26 Oct 2023 18:36:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C0FF10E85C; Thu, 26 Oct 2023 18:36:46 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13E9110E85C for ; Thu, 26 Oct 2023 18:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698345401; x=1729881401; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=AjPc+GKHiOJFfCanvoppvXlqwfxfw95D27ahg/URuyk=; b=hVhw3hbW3uzebCjxilgLgn6z4DRh2Q18nLI8L5UtJ4BNBeh+4OLpfX0X FIE6BmxOFmUkd5GNTcZu9P7R/Th4369GIDhe1Cb7buP2751ZlxdgxUN6d JmL/Mtnbd/5J4YsClvBifkRigtDyxlXqWiKMRe63tfKe3iJagYUo3J3kM 4z6hVbxUrdSI2t1/6NsUyqQxlxVOz6kbY74LTxWwHCrrhGJBHmfBP6VRr BG4G8sl5bfZ3Tp8DPsfNn9mfsRQaGZ5311s/ns+NJOQaM27xCRxHAvbss KSAkhI/XfnRm8cpeKwmRQt+6zQsEPZKSZrsp4v/ST0Lkspk5QI/ft1XZL w==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="391497773" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="391497773" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="762941888" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="762941888" Received: from lab-ah.igk.intel.com ([10.102.138.202]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:39 -0700 From: Andrzej Hajda Date: Thu, 26 Oct 2023 20:36:26 +0200 MIME-Version: 1.0 Message-Id: <20231026-wabb-v6-1-4aa7d55d0a8a@intel.com> References: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> In-Reply-To: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> To: intel-gfx@lists.freedesktop.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3277; i=andrzej.hajda@intel.com; h=from:subject:message-id; bh=AjPc+GKHiOJFfCanvoppvXlqwfxfw95D27ahg/URuyk=; b=owEB7QES/pANAwAKASNispPeEP3XAcsmYgBlOrGzfWX/HQsWhlmgQN5Prc3cu3kja/1o+6zt7FFL aMB+HsCJAbMEAAEKAB0WIQT8qEQxNN2/XeF/A00jYrKT3hD91wUCZTqxswAKCRAjYrKT3hD914ssC/ 48xuHGZuu6kNzv3UFq35zSQZ8QDUKso1PTxjqp+EC08ZVr1r09xP9qooldf9ANMw/DTZtm1QbcpRuX TwT6T7ZYbooE6Ldm6wvtcNIneTikclBpYBv8zqpfX6oglBbqawjXzoOvqja32RzVN7qoSOrDWYjDVF S/qrKjD49b62UGuFuWYyCnLv5HthqFgtaEU3C1ISRtRiMZfVoVMqqVq9RaoWKvv/TVrHSV32P5Gf9O /K7YpzE65G9s5QL/vRd9PayIit0kSnwiDWow+cDqRkEAyXFAYwA3G6JobP6W7p8vNK1ugi9h1VXu2o 6f+g0qlP5fuURFngpbj32KGmNNUuw2n8XFDgXEHtjoku6ZA2nGd+OyeJvUzqgSuMmCzmUtS6ePldMx d4vwoCTHn+R6pSFwhmOkxCmK26FqEANam9VLgkLHGPacScA9Gz1L6JmVJ7qZAX/ys5iChr5fjGPZR+ yLOHmqHa1y8CClgMEtwO9bQ6sNV+jYfCultHTWMeCaIzY= X-Developer-Key: i=andrzej.hajda@intel.com; a=openpgp; fpr=FCA8443134DDBF5DE17F034D2362B293DE10FDD7 Subject: [Intel-gfx] [PATCH v6 1/4] drm/i915: Reserve some kernel space per vm X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan Cavitt , Andrzej Hajda , 20231026-gtt_size_fix-v1-2-882d0e0022ec@intel.com, Chris Wilson , Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Reserve one page in each vm for kernel space to use for things such as workarounds. v2: use real memory, do not decrease vm.total v4: reserve only one page and explain flag v5: remove allocated object on ppgtt cleanup v6: decrease vm->total by reservation size Suggested-by: Chris Wilson Signed-off-by: Andrzej Hajda Reviewed-by: Jonathan Cavitt Reviewed-by: Nirmoy Das Reviewed-by: Andi Shyti --- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 43 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_gtt.h | 4 ++++ 2 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c index 9895e18df0435a..fa46d2308b0ed3 100644 --- a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c +++ b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c @@ -5,6 +5,7 @@ #include +#include "gem/i915_gem_internal.h" #include "gem/i915_gem_lmem.h" #include "gen8_ppgtt.h" @@ -222,6 +223,9 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm) { struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm); + if (vm->rsvd.obj) + i915_gem_object_put(vm->rsvd.obj); + if (intel_vgpu_active(vm->i915)) gen8_ppgtt_notify_vgt(ppgtt, false); @@ -950,6 +954,41 @@ gen8_alloc_top_pd(struct i915_address_space *vm) return ERR_PTR(err); } +static int gen8_init_rsvd(struct i915_address_space *vm) +{ + struct drm_i915_private *i915 = vm->i915; + struct drm_i915_gem_object *obj; + struct i915_vma *vma; + int ret; + + /* The memory will be used only by GPU. */ + obj = i915_gem_object_create_lmem(i915, PAGE_SIZE, + I915_BO_ALLOC_VOLATILE | + I915_BO_ALLOC_GPU_ONLY); + if (IS_ERR(obj)) + obj = i915_gem_object_create_internal(i915, PAGE_SIZE); + if (IS_ERR(obj)) + return PTR_ERR(obj); + + vma = i915_vma_instance(obj, vm, NULL); + if (IS_ERR(vma)) { + ret = PTR_ERR(vma); + goto unref; + } + + ret = i915_vma_pin(vma, 0, 0, PIN_USER | PIN_HIGH); + if (ret) + goto unref; + + vm->rsvd.vma = i915_vma_make_unshrinkable(vma); + vm->rsvd.obj = obj; + vm->total -= vma->node.size; + return 0; +unref: + i915_gem_object_put(obj); + return ret; +} + /* * GEN8 legacy ppgtt programming is accomplished through a max 4 PDP registers * with a net effect resembling a 2-level page table in normal x86 terms. Each @@ -1031,6 +1070,10 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt, if (intel_vgpu_active(gt->i915)) gen8_ppgtt_notify_vgt(ppgtt, true); + err = gen8_init_rsvd(&ppgtt->vm); + if (err) + goto err_put; + return ppgtt; err_put: diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h index b471edac269920..028a5a988eea02 100644 --- a/drivers/gpu/drm/i915/gt/intel_gtt.h +++ b/drivers/gpu/drm/i915/gt/intel_gtt.h @@ -249,6 +249,10 @@ struct i915_address_space { struct work_struct release_work; struct drm_mm mm; + struct { + struct drm_i915_gem_object *obj; + struct i915_vma *vma; + } rsvd; struct intel_gt *gt; struct drm_i915_private *i915; struct device *dma; From patchwork Thu Oct 26 18:36:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 13437799 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 289D0C25B6B for ; Thu, 26 Oct 2023 18:36:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7129610E856; Thu, 26 Oct 2023 18:36:50 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0090A10E85F for ; Thu, 26 Oct 2023 18:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698345403; x=1729881403; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=SRG34D7TfrcAIb+0ha84zpf1GFglof/9rPuKpx2QwZ8=; b=nCIP/mD3+P9Bc41xqODYWoOu6asd+wAnZxeS8i2OmHSH8KR9Pmu3DanF sbVF8z0Kyjlx1CYbv4h1qYk1nwJfSDKkzabvGy5FaNxtTDV1/43G0uwSd 2nZ0BiezSh2g8OUp3MTXzG9LR9VXFdEKj/EogWT1HqMDz+s2Nl33Q5+jV hSAa7FbUY/mPEjZBFX9lL+QZ1uSymfhisNmKxUFp/6HJ7bWGufqmBQ2AV o1Nj96aDLj7P8Pnwklt/2KZshvD3mJukEfnOQIVmhI+UYYKA6jj1ugZE2 BZ1ds3aDZZZz9J2UlYcPe27xFwUPb11xax1K/5JkK7OAZtZ8vAr9p8uJo A==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="391497774" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="391497774" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="762941912" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="762941912" Received: from lab-ah.igk.intel.com ([10.102.138.202]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:40 -0700 From: Andrzej Hajda Date: Thu, 26 Oct 2023 20:36:27 +0200 MIME-Version: 1.0 Message-Id: <20231026-wabb-v6-2-4aa7d55d0a8a@intel.com> References: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> In-Reply-To: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> To: intel-gfx@lists.freedesktop.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7349; i=andrzej.hajda@intel.com; h=from:subject:message-id; bh=SRG34D7TfrcAIb+0ha84zpf1GFglof/9rPuKpx2QwZ8=; b=owEB7QES/pANAwAKASNispPeEP3XAcsmYgBlOrGzdf7nn84EQlJguCKQLd5Nu38sPuvzNUD5/ihU OEFc1ziJAbMEAAEKAB0WIQT8qEQxNN2/XeF/A00jYrKT3hD91wUCZTqxswAKCRAjYrKT3hD91w77C/ 9rgpQ0ZAj0djPWW2AHr1iIP/VQ57lJifblTo26FOqGoLzRhClArCuc4guqh4wTwf6tGifsnQ8dYKJX hvRtDlH4k0rLTULjOtQ/Pw/FtgVh9r6Axme2hpAMz+pPwTrrTVY6lrmFKWMWQIuNaFrojygyZ6FRlf k/o30tPE8+qBnpv1X2NMfOgw4jcOESHasaiD2XbkHWflaMSH2EgjTITm0cpGHSrwAyjGG/t1rbyZLa Tykd5OwSAXtkTZj3s+O8kYCjEpx8WSyiyUUGif2++1w3a/uKSMQVynCJ4fnEdutuz61/FnUwywY4DK X0rRiWPVJIEDaQz8RUHtPjFVO/QeCTVHcVhmyraGc3IzvOAnXAblDKZsGmlQBo4LD7miYiE5qv4XtW ZybhePzZl9hV4dh4RDqotwnRPkrAEVd5wl67TOuzobM9ngEVy/O7ePITXOHTqSgefL6NNlAde3DTtx mxEluwu/UKq7xPROSLx1iuQX07bc3OzHeFQccY4dTgggo= X-Developer-Key: i=andrzej.hajda@intel.com; a=openpgp; fpr=FCA8443134DDBF5DE17F034D2362B293DE10FDD7 Subject: [Intel-gfx] [PATCH v6 2/4] drm/i915: Add WABB blit for Wa_16018031267 / Wa_16018063123 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan Cavitt , Andrzej Hajda , 20231026-gtt_size_fix-v1-2-882d0e0022ec@intel.com, Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Apply WABB blit for Wa_16018031267 / Wa_16018063123. v3: drop unused enum definition v4: move selftest to separate patch, use wa only on BCS0. v5: fixed selftest caller to context_wabb Signed-off-by: Nirmoy Das Signed-off-by: Jonathan Cavitt Signed-off-by: Andrzej Hajda Reviewed-by: Andi Shyti --- drivers/gpu/drm/i915/gt/intel_engine_regs.h | 3 + drivers/gpu/drm/i915/gt/intel_gt.h | 4 ++ drivers/gpu/drm/i915/gt/intel_lrc.c | 100 +++++++++++++++++++++++++++- drivers/gpu/drm/i915/gt/selftest_lrc.c | 2 +- 4 files changed, 105 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_engine_regs.h b/drivers/gpu/drm/i915/gt/intel_engine_regs.h index fdd4ddd3a978a2..b8618ee3e3041a 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_regs.h +++ b/drivers/gpu/drm/i915/gt/intel_engine_regs.h @@ -118,6 +118,9 @@ #define CCID_EXTENDED_STATE_RESTORE BIT(2) #define CCID_EXTENDED_STATE_SAVE BIT(3) #define RING_BB_PER_CTX_PTR(base) _MMIO((base) + 0x1c0) /* gen8+ */ +#define PER_CTX_BB_FORCE BIT(2) +#define PER_CTX_BB_VALID BIT(0) + #define RING_INDIRECT_CTX(base) _MMIO((base) + 0x1c4) /* gen8+ */ #define RING_INDIRECT_CTX_OFFSET(base) _MMIO((base) + 0x1c8) /* gen8+ */ #define ECOSKPD(base) _MMIO((base) + 0x1d0) diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h index 970bedf6b78a7b..9ffdb05e231e21 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt.h +++ b/drivers/gpu/drm/i915/gt/intel_gt.h @@ -82,6 +82,10 @@ struct drm_printer; ##__VA_ARGS__); \ } while (0) +#define NEEDS_FASTCOLOR_BLT_WABB(engine) ( \ + IS_GFX_GT_IP_RANGE(engine->gt, IP_VER(12, 55), IP_VER(12, 71)) && \ + engine->class == COPY_ENGINE_CLASS && engine->instance == 0) + static inline bool gt_is_root(struct intel_gt *gt) { return !gt->info.id; diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c index eaf66d90316655..7c367ba8d9dcf1 100644 --- a/drivers/gpu/drm/i915/gt/intel_lrc.c +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c @@ -828,6 +828,18 @@ lrc_ring_indirect_offset_default(const struct intel_engine_cs *engine) return 0; } +static void +lrc_setup_bb_per_ctx(u32 *regs, + const struct intel_engine_cs *engine, + u32 ctx_bb_ggtt_addr) +{ + GEM_BUG_ON(lrc_ring_wa_bb_per_ctx(engine) == -1); + regs[lrc_ring_wa_bb_per_ctx(engine) + 1] = + ctx_bb_ggtt_addr | + PER_CTX_BB_FORCE | + PER_CTX_BB_VALID; +} + static void lrc_setup_indirect_ctx(u32 *regs, const struct intel_engine_cs *engine, @@ -1020,7 +1032,13 @@ static u32 context_wa_bb_offset(const struct intel_context *ce) return PAGE_SIZE * ce->wa_bb_page; } -static u32 *context_indirect_bb(const struct intel_context *ce) +/* + * per_ctx below determines which WABB section is used. + * When true, the function returns the location of the + * PER_CTX_BB. When false, the function returns the + * location of the INDIRECT_CTX. + */ +static u32 *context_wabb(const struct intel_context *ce, bool per_ctx) { void *ptr; @@ -1029,6 +1047,7 @@ static u32 *context_indirect_bb(const struct intel_context *ce) ptr = ce->lrc_reg_state; ptr -= LRC_STATE_OFFSET; /* back to start of context image */ ptr += context_wa_bb_offset(ce); + ptr += per_ctx ? PAGE_SIZE : 0; return ptr; } @@ -1105,7 +1124,8 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine) if (GRAPHICS_VER(engine->i915) >= 12) { ce->wa_bb_page = context_size / PAGE_SIZE; - context_size += PAGE_SIZE; + /* INDIRECT_CTX and PER_CTX_BB need separate pages. */ + context_size += PAGE_SIZE * 2; } if (intel_context_is_parent(ce) && intel_engine_uses_guc(engine)) { @@ -1407,12 +1427,85 @@ gen12_emit_indirect_ctx_xcs(const struct intel_context *ce, u32 *cs) return gen12_emit_aux_table_inv(ce->engine, cs); } +static u32 *xehp_emit_fastcolor_blt_wabb(const struct intel_context *ce, u32 *cs) +{ + struct intel_gt *gt = ce->engine->gt; + int mocs = gt->mocs.uc_index << 1; + + /** + * Wa_16018031267 / Wa_16018063123 requires that SW forces the + * main copy engine arbitration into round robin mode. We + * additionally need to submit the following WABB blt command + * to produce 4 subblits with each subblit generating 0 byte + * write requests as WABB: + * + * XY_FASTCOLOR_BLT + * BG0 -> 5100000E + * BG1 -> 0000003F (Dest pitch) + * BG2 -> 00000000 (X1, Y1) = (0, 0) + * BG3 -> 00040001 (X2, Y2) = (1, 4) + * BG4 -> scratch + * BG5 -> scratch + * BG6-12 -> 00000000 + * BG13 -> 20004004 (Surf. Width= 2,Surf. Height = 5 ) + * BG14 -> 00000010 (Qpitch = 4) + * BG15 -> 00000000 + */ + *cs++ = XY_FAST_COLOR_BLT_CMD | (16 - 2); + *cs++ = FIELD_PREP(XY_FAST_COLOR_BLT_MOCS_MASK, mocs) | 0x3f; + *cs++ = 0; + *cs++ = 4 << 16 | 1; + *cs++ = lower_32_bits(i915_vma_offset(ce->vm->rsvd.vma)); + *cs++ = upper_32_bits(i915_vma_offset(ce->vm->rsvd.vma)); + *cs++ = 0; + *cs++ = 0; + *cs++ = 0; + *cs++ = 0; + *cs++ = 0; + *cs++ = 0; + *cs++ = 0; + *cs++ = 0x20004004; + *cs++ = 0x10; + *cs++ = 0; + + return cs; +} + +static u32 * +xehp_emit_per_ctx_bb(const struct intel_context *ce, u32 *cs) +{ + /* Wa_16018031267, Wa_16018063123 */ + if (NEEDS_FASTCOLOR_BLT_WABB(ce->engine)) + cs = xehp_emit_fastcolor_blt_wabb(ce, cs); + + return cs; +} + +static void +setup_per_ctx_bb(const struct intel_context *ce, + const struct intel_engine_cs *engine, + u32 *(*emit)(const struct intel_context *, u32 *)) +{ + /* Place PER_CTX_BB on next page after INDIRECT_CTX */ + u32 * const start = context_wabb(ce, true); + u32 *cs; + + cs = emit(ce, start); + + /* PER_CTX_BB must manually terminate */ + *cs++ = MI_BATCH_BUFFER_END; + + GEM_BUG_ON(cs - start > I915_GTT_PAGE_SIZE / sizeof(*cs)); + lrc_setup_bb_per_ctx(ce->lrc_reg_state, engine, + lrc_indirect_bb(ce) + PAGE_SIZE); +} + static void setup_indirect_ctx_bb(const struct intel_context *ce, const struct intel_engine_cs *engine, u32 *(*emit)(const struct intel_context *, u32 *)) { - u32 * const start = context_indirect_bb(ce); + u32 * const start = context_wabb(ce, false); u32 *cs; cs = emit(ce, start); @@ -1511,6 +1604,7 @@ u32 lrc_update_regs(const struct intel_context *ce, /* Mutually exclusive wrt to global indirect bb */ GEM_BUG_ON(engine->wa_ctx.indirect_ctx.size); setup_indirect_ctx_bb(ce, engine, fn); + setup_per_ctx_bb(ce, engine, xehp_emit_per_ctx_bb); } return lrc_descriptor(ce) | CTX_DESC_FORCE_RESTORE; diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c index 5f826b6dcf5d6f..823d38aa393467 100644 --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c @@ -1596,7 +1596,7 @@ emit_indirect_ctx_bb_canary(const struct intel_context *ce, u32 *cs) static void indirect_ctx_bb_setup(struct intel_context *ce) { - u32 *cs = context_indirect_bb(ce); + u32 *cs = context_wabb(ce, false); cs[CTX_BB_CANARY_INDEX] = 0xdeadf00d; From patchwork Thu Oct 26 18:36:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 13437798 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 BD2A6C25B48 for ; Thu, 26 Oct 2023 18:36:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A9EF10E854; Thu, 26 Oct 2023 18:36:50 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 909F410E851 for ; Thu, 26 Oct 2023 18:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698345404; x=1729881404; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Dyd8vcYo8Tt5xV/PmQ4i/KezAADpjs3tCIKM12CJ+Ls=; b=cUm8SyryjOau5lnx+cxpE1j27X7k4c/6yRwC1toON+2Iw+eelyIVKbZj IxoQJkNsHMqdTdaWhHMjAuk3sIqH0EXYnBWyxeX0eYNRGEGLnApnNlHf0 a1NdUWwhHwWMisv3PXq0+vNmUiQQR+TLmOnhKu/6S++I2lVkXt/KuiW4t 9uFi+LhO/liqhCBcvZevm/KkTr7huEuvZM+bB+evNdyZgGN3Qoz83Rvsd a7X5J7aF7dmRNuHLufIG6dwzK9q8kcDCD99/hBWLZ7br4Ne4y7/b14QJd b0XVUZzLgp8kbF/e0BBs8YIDmX5fbE7aQQJYwx4suR5OiQEeD2+FyVzeS w==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="391497778" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="391497778" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="762941922" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="762941922" Received: from lab-ah.igk.intel.com ([10.102.138.202]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:42 -0700 From: Andrzej Hajda Date: Thu, 26 Oct 2023 20:36:28 +0200 MIME-Version: 1.0 Message-Id: <20231026-wabb-v6-3-4aa7d55d0a8a@intel.com> References: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> In-Reply-To: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> To: intel-gfx@lists.freedesktop.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5319; i=andrzej.hajda@intel.com; h=from:subject:message-id; bh=Dyd8vcYo8Tt5xV/PmQ4i/KezAADpjs3tCIKM12CJ+Ls=; b=owEB7QES/pANAwAKASNispPeEP3XAcsmYgBlOrG0wAKR7hBCrAmXbv9I0W8cUWDZ4PzqvdA2JTdH /NnsjwKJAbMEAAEKAB0WIQT8qEQxNN2/XeF/A00jYrKT3hD91wUCZTqxtAAKCRAjYrKT3hD919DaC/ sH9LW75fLioaJAREVDdhWaLgIoKtqwJDhydiXO850f42ekTzJtfzEmmIeWyQHdXVWwBRyaCIOscklp U24SeEz8WJRXfbWqwDeaHdd1sIChE7B0nLM5y4Bdhz7zMFJJFP/KPVYJCB00uXmRuu1p3Uqgzd5s32 1xZP7NoRfoqjXtO09Hfsv32RCJXZI8Q2zMxcQcxi5ChAaDJZAIjeIQyaFVVl7vbIE8UFSft1FQ/YCI Yv02qzOw2BY95ap1zZ/bbskmYHeHf67ZoUrdvj3C0BGMp+eYT6jjOxj/du05ol2/3IdnU38EKolzZb Gym8v002hfdVfnCY8DnW4T6nyO4ABFjtQ2pfuuQkmIj6Z+QnOe2VhyweuxmBFa6A+tf3+reIvwPmtO lCRycdIQ8uLJDryc6RtHeumZmUvmP8q90lHR3u1nXrdQFEYO5UP0uzyFfPOIIGuUrh/CQLTy3/9jIU XolCyB3sl9n40g8e2VeF1S3qFR58ILjDFdJ27fC8+Oza0= X-Developer-Key: i=andrzej.hajda@intel.com; a=openpgp; fpr=FCA8443134DDBF5DE17F034D2362B293DE10FDD7 Subject: [Intel-gfx] [PATCH v6 3/4] drm/i915/gt: add selftest to exercise WABB X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan Cavitt , Andrzej Hajda , 20231026-gtt_size_fix-v1-2-882d0e0022ec@intel.com, Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Test re-uses logic form indirect ctx BB selftest. Signed-off-by: Nirmoy Das Signed-off-by: Jonathan Cavitt Signed-off-by: Andrzej Hajda Reviewed-by: Andi Shyti --- drivers/gpu/drm/i915/gt/selftest_lrc.c | 65 ++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c index 823d38aa393467..e17b8777d21dc9 100644 --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c @@ -1555,7 +1555,7 @@ static int live_lrc_isolation(void *arg) return err; } -static int indirect_ctx_submit_req(struct intel_context *ce) +static int wabb_ctx_submit_req(struct intel_context *ce) { struct i915_request *rq; int err = 0; @@ -1579,7 +1579,8 @@ static int indirect_ctx_submit_req(struct intel_context *ce) #define CTX_BB_CANARY_INDEX (CTX_BB_CANARY_OFFSET / sizeof(u32)) static u32 * -emit_indirect_ctx_bb_canary(const struct intel_context *ce, u32 *cs) +emit_wabb_ctx_canary(const struct intel_context *ce, + u32 *cs, bool per_ctx) { *cs++ = MI_STORE_REGISTER_MEM_GEN8 | MI_SRM_LRM_GLOBAL_GTT | @@ -1587,26 +1588,43 @@ emit_indirect_ctx_bb_canary(const struct intel_context *ce, u32 *cs) *cs++ = i915_mmio_reg_offset(RING_START(0)); *cs++ = i915_ggtt_offset(ce->state) + context_wa_bb_offset(ce) + - CTX_BB_CANARY_OFFSET; + CTX_BB_CANARY_OFFSET + + (per_ctx ? PAGE_SIZE : 0); *cs++ = 0; return cs; } +static u32 * +emit_indirect_ctx_bb_canary(const struct intel_context *ce, u32 *cs) +{ + return emit_wabb_ctx_canary(ce, cs, false); +} + +static u32 * +emit_per_ctx_bb_canary(const struct intel_context *ce, u32 *cs) +{ + return emit_wabb_ctx_canary(ce, cs, true); +} + static void -indirect_ctx_bb_setup(struct intel_context *ce) +wabb_ctx_setup(struct intel_context *ce, bool per_ctx) { - u32 *cs = context_wabb(ce, false); + u32 *cs = context_wabb(ce, per_ctx); cs[CTX_BB_CANARY_INDEX] = 0xdeadf00d; - setup_indirect_ctx_bb(ce, ce->engine, emit_indirect_ctx_bb_canary); + if (per_ctx) + setup_per_ctx_bb(ce, ce->engine, emit_per_ctx_bb_canary); + else + setup_indirect_ctx_bb(ce, ce->engine, emit_indirect_ctx_bb_canary); } -static bool check_ring_start(struct intel_context *ce) +static bool check_ring_start(struct intel_context *ce, bool per_ctx) { const u32 * const ctx_bb = (void *)(ce->lrc_reg_state) - - LRC_STATE_OFFSET + context_wa_bb_offset(ce); + LRC_STATE_OFFSET + context_wa_bb_offset(ce) + + (per_ctx ? PAGE_SIZE : 0); if (ctx_bb[CTX_BB_CANARY_INDEX] == ce->lrc_reg_state[CTX_RING_START]) return true; @@ -1618,21 +1636,21 @@ static bool check_ring_start(struct intel_context *ce) return false; } -static int indirect_ctx_bb_check(struct intel_context *ce) +static int wabb_ctx_check(struct intel_context *ce, bool per_ctx) { int err; - err = indirect_ctx_submit_req(ce); + err = wabb_ctx_submit_req(ce); if (err) return err; - if (!check_ring_start(ce)) + if (!check_ring_start(ce, per_ctx)) return -EINVAL; return 0; } -static int __live_lrc_indirect_ctx_bb(struct intel_engine_cs *engine) +static int __lrc_wabb_ctx(struct intel_engine_cs *engine, bool per_ctx) { struct intel_context *a, *b; int err; @@ -1667,14 +1685,14 @@ static int __live_lrc_indirect_ctx_bb(struct intel_engine_cs *engine) * As ring start is restored apriori of starting the indirect ctx bb and * as it will be different for each context, it fits to this purpose. */ - indirect_ctx_bb_setup(a); - indirect_ctx_bb_setup(b); + wabb_ctx_setup(a, per_ctx); + wabb_ctx_setup(b, per_ctx); - err = indirect_ctx_bb_check(a); + err = wabb_ctx_check(a, per_ctx); if (err) goto unpin_b; - err = indirect_ctx_bb_check(b); + err = wabb_ctx_check(b, per_ctx); unpin_b: intel_context_unpin(b); @@ -1688,7 +1706,7 @@ static int __live_lrc_indirect_ctx_bb(struct intel_engine_cs *engine) return err; } -static int live_lrc_indirect_ctx_bb(void *arg) +static int lrc_wabb_ctx(void *arg, bool per_ctx) { struct intel_gt *gt = arg; struct intel_engine_cs *engine; @@ -1697,7 +1715,7 @@ static int live_lrc_indirect_ctx_bb(void *arg) for_each_engine(engine, gt, id) { intel_engine_pm_get(engine); - err = __live_lrc_indirect_ctx_bb(engine); + err = __lrc_wabb_ctx(engine, per_ctx); intel_engine_pm_put(engine); if (igt_flush_test(gt->i915)) @@ -1710,6 +1728,16 @@ static int live_lrc_indirect_ctx_bb(void *arg) return err; } +static int live_lrc_indirect_ctx_bb(void *arg) +{ + return lrc_wabb_ctx(arg, false); +} + +static int live_lrc_per_ctx_bb(void *arg) +{ + return lrc_wabb_ctx(arg, true); +} + static void garbage_reset(struct intel_engine_cs *engine, struct i915_request *rq) { @@ -1947,6 +1975,7 @@ int intel_lrc_live_selftests(struct drm_i915_private *i915) SUBTEST(live_lrc_garbage), SUBTEST(live_pphwsp_runtime), SUBTEST(live_lrc_indirect_ctx_bb), + SUBTEST(live_lrc_per_ctx_bb), }; if (!HAS_LOGICAL_RING_CONTEXTS(i915)) From patchwork Thu Oct 26 18:36:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 13437800 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 54923C25B6B for ; Thu, 26 Oct 2023 18:36:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C545910E857; Thu, 26 Oct 2023 18:36:57 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57E2010E854 for ; Thu, 26 Oct 2023 18:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698345406; x=1729881406; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=MaIIC5+jLotuZfswE6jbxOhim++eaDpNW2KNVSpJeug=; b=cmgP64NiNyXI40Iwk0drC8xkxgHAbMoN0Waietss+G/6Q2Dg86rOgzV1 1fN32Ykh4K23vFCBsehOey88FsdEXQeEOzjQxFvfZ1Q4TZK9GkvEoo/IN Jqw38lOUweu1uG5f17kVOZK3R1kLO4PuzizpUK3MTnK9LpqqzgZBaYQhi FyJn+QT7AClUDcifmVNX5hs9sJ9I+P6nELnUZuRJ/UoQoiYgFBEDArkpE ysGsGNdCqQErqu21xYcM3yAagZpgazfYKqCPytn5YAvF5dutaate/zoE6 vkLgfNti+HaYp4AzEPG75AbS2rvxXjvKDhFQw3L6tt2oxgNIFuh3DuFUP A==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="391497780" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="391497780" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="762941937" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="762941937" Received: from lab-ah.igk.intel.com ([10.102.138.202]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 11:36:44 -0700 From: Andrzej Hajda Date: Thu, 26 Oct 2023 20:36:29 +0200 MIME-Version: 1.0 Message-Id: <20231026-wabb-v6-4-4aa7d55d0a8a@intel.com> References: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> In-Reply-To: <20231026-wabb-v6-0-4aa7d55d0a8a@intel.com> To: intel-gfx@lists.freedesktop.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1937; i=andrzej.hajda@intel.com; h=from:subject:message-id; bh=9gE7Hw27KBcB9MG25aFN/4oXxak8vUVcOmAtGhnJbio=; b=owEB7QES/pANAwAKASNispPeEP3XAcsmYgBlOrG0j4eM+ZP9dk58b9OdlZtixanDFO30HDqARQE9 zMFPPsyJAbMEAAEKAB0WIQT8qEQxNN2/XeF/A00jYrKT3hD91wUCZTqxtAAKCRAjYrKT3hD91zOeC/ 99WFrhLkmZKuOEvSzRyuiWplOOyrzhaGilSsvU03Qy8tHQzmObo+MGp6JblsqvdlZjgaXB7z1TZSCy /2YL16NFLH+uMWA9WMJvOuKHlYY2v25dNgjqOUbkvoMPAHH4HfVzQ6xXNqtkosRXHK2NjpA0xNxMmH rYPhlr+rmBir1JtUyxUeUtFK8oxTlcKp7ZIpQwioxT0swI53C5SAYCn6qWB5jk7D8PzaaxTdMKnqf1 TOo2ZvnsqFY+ik3yNQr1WVVEvy/fkX89PFu2PCiGnBaJCwmaTq34XMSgE8ox8qStXsCvbXdVvL/jr1 /oazwUHqRC/v+7SkCGfaNbLXqvEEbqn4kT6lQKb/FUx5+1GyiRIlfyReQJ2qiK7k9EgyUCWrgD+qI9 nRzvQUMh19SZ1xYEc/VvVWcTwwKeahXE79y0oBkiHRDgvE0DUhjBtXI/78w3vYIEDQ6PifG8OKlFlD 0Ak0jDE9DJu9Gy5z1/WOg7VLxdV//5NIofuj7qc/wX9xY= X-Developer-Key: i=andrzej.hajda@intel.com; a=openpgp; fpr=FCA8443134DDBF5DE17F034D2362B293DE10FDD7 Subject: [Intel-gfx] [PATCH v6 4/4] drm/i915: Set copy engine arbitration for Wa_16018031267 / Wa_16018063123 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan Cavitt , Andrzej Hajda , 20231026-gtt_size_fix-v1-2-882d0e0022ec@intel.com, Nirmoy Das Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Jonathan Cavitt Set copy engine arbitration into round robin mode for part of Wa_16018031267 / Wa_16018063123 mitigation. Signed-off-by: Nirmoy Das Signed-off-by: Jonathan Cavitt Signed-off-by: Andrzej Hajda Reviewed-by: Andi Shyti --- drivers/gpu/drm/i915/gt/intel_engine_regs.h | 3 +++ drivers/gpu/drm/i915/gt/intel_workarounds.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/gt/intel_engine_regs.h b/drivers/gpu/drm/i915/gt/intel_engine_regs.h index b8618ee3e3041a..c0c8c12edea104 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_regs.h +++ b/drivers/gpu/drm/i915/gt/intel_engine_regs.h @@ -124,6 +124,9 @@ #define RING_INDIRECT_CTX(base) _MMIO((base) + 0x1c4) /* gen8+ */ #define RING_INDIRECT_CTX_OFFSET(base) _MMIO((base) + 0x1c8) /* gen8+ */ #define ECOSKPD(base) _MMIO((base) + 0x1d0) +#define XEHP_BLITTER_SCHEDULING_MODE_MASK REG_GENMASK(12, 11) +#define XEHP_BLITTER_ROUND_ROBIN_MODE \ + REG_FIELD_PREP(XEHP_BLITTER_SCHEDULING_MODE_MASK, 1) #define ECO_CONSTANT_BUFFER_SR_DISABLE REG_BIT(4) #define ECO_GATING_CX_ONLY REG_BIT(3) #define GEN6_BLITTER_FBC_NOTIFY REG_BIT(3) diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c index 192ac0e59afa13..108d9326735910 100644 --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c @@ -2782,6 +2782,11 @@ xcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal) RING_SEMA_WAIT_POLL(engine->mmio_base), 1); } + /* Wa_16018031267, Wa_16018063123 */ + if (NEEDS_FASTCOLOR_BLT_WABB(engine)) + wa_masked_field_set(wal, ECOSKPD(engine->mmio_base), + XEHP_BLITTER_SCHEDULING_MODE_MASK, + XEHP_BLITTER_ROUND_ROBIN_MODE); } static void