Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp668221imw; Thu, 14 Jul 2022 08:37:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uL4ifHM993ak8wE0thGylluStYSXMgClj32KDErWeThqG5K9S/tweInLof4mycg0AXxoCO X-Received: by 2002:a17:902:e5c6:b0:16c:413c:fbff with SMTP id u6-20020a170902e5c600b0016c413cfbffmr9018744plf.62.1657813061101; Thu, 14 Jul 2022 08:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657813061; cv=none; d=google.com; s=arc-20160816; b=BOV7BAn1EXcvV16/5m+pUdXz62eB4x++BY9zdZ77rJmd1kRPf1ZZi39+re3r1GtrEp vdmKgDjBUF78crzjcn0TCbXLbhlX7ZsCLu1+mr6g2gF1A9yXgY5SZMozQgZAai74qzBX DKfEiZWTLbMp8ItvMEhbArpY0MhoSOPAVh1c7bxk1ZqqQPe4SSKrAX+sCF2OfEJZo9f5 mNGoSnkO7CtSMLqZgHWmYUFQbF6X3g1M2TEQ8h0VKUaZ4RlRzpPu4SRDzLudVmXSGCC2 ctZUawc2pEdWY/Z6KCvHk9sL/AjPRvcGj1yvHaZTZznAOevv4HOmiPw/OaJGt2oDAEIi hLCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=QO4jTiAukpbRShpSofA/YhalXEJyphmqJuM9qwUymjY=; b=z+Rx8lPj3CYQ0M8Zv+y8SHW5f6HLptuZ+5bxqxz4tzOY8nRH6jFvqvZijloOoRf1W0 zPzMqbkmOhZG2nUH/5I6w2LME+6bsK3Pr7s+tlnh2vfGG86jJM55r6wXKQEsd259+XtA u9YIV9upaX2G2XFGQZZKBbLGhiQx8ErG8R8vOpCItTekFzRuk85WnO53DGrHhKv9dw2J 8xVTFB0JYI0rM1v6vpNKpnepSQ1KhOCxsNtS4Onm1xCtUnpGDgAq4m5TuTz3a7x4VenM ieMIj9EFGj9gyVU2Y7mD234Vo9tcanY9nJMAZndDKGEO4zVL2p95Um+RL8xYfEv697dL hfgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LyPChm5B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a630607000000b0040d1da68c7bsi1062216pgg.7.2022.07.14.08.37.26; Thu, 14 Jul 2022 08:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LyPChm5B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239995AbiGNPUY (ORCPT + 99 others); Thu, 14 Jul 2022 11:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231937AbiGNPUX (ORCPT ); Thu, 14 Jul 2022 11:20:23 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A7E481C2 for ; Thu, 14 Jul 2022 08:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657812022; x=1689348022; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=sbZhaT5tdicd4HOKbtLgjSP8ggs3tLu6dffAfZ7Zzk0=; b=LyPChm5BH+ib5lg/4gVRjJX4ZThdLQOtnIatkYXN76peOuQhCEyl5CKL AxSMy+a6/AK5uZzxYhxWA8a3Bkm90sw3XPzqIjTaY3dICBHpdG5wmbS1+ S0OKZdr5qYa9o1hZHhA37kqquEXBjqo2ojiYW894uol7V6KlId9wG8tOH Y7gmwJO8hQ7I9pxY5vaFhoPTTPvtXvclp5CC2IdIkgQovWzFrFYNV8AM+ DiWnttUoRgpVJk+TuBFPULM4/BCTAQCX2WXyXMcJtiByT1Lb6SFjWWHjs afTK7poU5CzMi0Qooo2PiavDSIFPFVIfeOmPtHqGmRZxx7K/axBuLw6Nx w==; X-IronPort-AV: E=McAfee;i="6400,9594,10408"; a="285564040" X-IronPort-AV: E=Sophos;i="5.92,271,1650956400"; d="scan'208";a="285564040" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 08:20:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,271,1650956400"; d="scan'208";a="923107992" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga005.fm.intel.com with ESMTP; 14 Jul 2022 08:20:18 -0700 Received: from [10.249.147.144] (mwajdecz-MOBL.ger.corp.intel.com [10.249.147.144]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 26EFKGKA026921; Thu, 14 Jul 2022 16:20:16 +0100 Message-ID: Date: Thu, 14 Jul 2022 17:20:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.11.0 Subject: Re: [PATCH v2 16/21] drm/i915: Define GuC Based TLB invalidation routines Content-Language: en-US To: Mauro Carvalho Chehab Cc: Prathap Kumar Valsan , Alan Previn , Borislav Petkov , Daniel Vetter , Daniele Ceraolo Spurio , David Airlie , Jani Nikula , John Harrison , Joonas Lahtinen , Lucas De Marchi , Matt Roper , Matthew Brost , Rodrigo Vivi , Tvrtko Ursulin , Umesh Nerlige Ramappa , Vinay Belgaumkar , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <335645ebfde73421a506d6df72e78d370805aa9c.1657800199.git.mchehab@kernel.org> From: Michal Wajdeczko In-Reply-To: <335645ebfde73421a506d6df72e78d370805aa9c.1657800199.git.mchehab@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.07.2022 14:06, Mauro Carvalho Chehab wrote: > From: Prathap Kumar Valsan > > Add routines to interface with GuC firmware for selective TLB invalidation > supported on XeHP. > > Signed-off-by: Prathap Kumar Valsan > Cc: Matthew Brost > Signed-off-by: Mauro Carvalho Chehab > --- > > To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. > See [PATCH v2 00/21] at: https://lore.kernel.org/all/cover.1657800199.git.mchehab@kernel.org/ > > .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h | 3 + > drivers/gpu/drm/i915/gt/uc/intel_guc.c | 90 +++++++++++++++++++ > drivers/gpu/drm/i915/gt/uc/intel_guc.h | 10 +++ > drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h | 3 + > 4 files changed, 106 insertions(+) > > diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h > index fb0af33e43cc..5c019856a269 100644 > --- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h > +++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h > @@ -188,6 +188,9 @@ enum intel_guc_state_capture_event_status { > #define INTEL_GUC_TLB_INVAL_FLUSH_CACHE (1 << 31) > > enum intel_guc_tlb_invalidation_type { > + INTEL_GUC_TLB_INVAL_FULL = 0x0, > + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE = 0x1, > + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX = 0x2, > INTEL_GUC_TLB_INVAL_GUC = 0x3, > }; > > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c b/drivers/gpu/drm/i915/gt/uc/intel_guc.c > index 8a104a292598..98260a7bc90b 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c > @@ -923,6 +923,96 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 *action, u32 size) > return err; > } > > + /* Full TLB invalidation */ > +int intel_guc_invalidate_tlb_full(struct intel_guc *guc, > + enum intel_guc_tlb_inval_mode mode) > +{ > + u32 action[] = { > + INTEL_GUC_ACTION_TLB_INVALIDATION, > + 0, > + INTEL_GUC_TLB_INVAL_FULL << INTEL_GUC_TLB_INVAL_TYPE_SHIFT | > + mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT | > + INTEL_GUC_TLB_INVAL_FLUSH_CACHE, > + }; > + > + if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION(guc)) { > + DRM_ERROR("Tlb invalidation: Operation not supported in this platform!\n"); s/Tlb/TLB and use drm_err() or even consider GEM_BUG_ON() as this looks more like a coding mistake if we will be here, no ? > + return 0; > + } > + > + return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action)); > +} > + > +/* > + * Selective TLB Invalidation for Address Range: > + * TLB's in the Address Range is Invalidated across all engines. > + */ > +int intel_guc_invalidate_tlb_page_selective(struct intel_guc *guc, > + enum intel_guc_tlb_inval_mode mode, > + u64 start, u64 length) > +{ > + u64 vm_total = BIT_ULL(INTEL_INFO(guc_to_gt(guc)->i915)->ppgtt_size); > + u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K)); drop extra ( ) > + u32 full_range = vm_total == length; bool ? > + u32 action[] = { > + INTEL_GUC_ACTION_TLB_INVALIDATION, > + 0, > + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE << INTEL_GUC_TLB_INVAL_TYPE_SHIFT | > + mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT | > + INTEL_GUC_TLB_INVAL_FLUSH_CACHE, > + 0, > + full_range ? full_range : lower_32_bits(start), > + full_range ? 0 : upper_32_bits(start), > + full_range ? 0 : address_mask, > + }; > + > + if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION_SELECTIVE(guc)) { > + DRM_ERROR("Tlb invalidation: Operation not supported in this platform!\n"); as above > + return 0; > + } > + > + GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE_4K)); > + GEM_BUG_ON(!IS_ALIGNED(length, I915_GTT_PAGE_SIZE_4K)); > + GEM_BUG_ON(range_overflows(start, length, vm_total)); > + > + return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action)); > +} > + > +/* > + * Selective TLB Invalidation for Context: > + * Invalidates all TLB's for a specific context across all engines. > + */ > +int intel_guc_invalidate_tlb_page_selective_ctx(struct intel_guc *guc, > + enum intel_guc_tlb_inval_mode mode, > + u64 start, u64 length, u32 ctxid) > +{ > + u64 vm_total = BIT_ULL(INTEL_INFO(guc_to_gt(guc)->i915)->ppgtt_size); > + u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K)); drop ( ) > + u32 full_range = vm_total == length; bool > + u32 action[] = { > + INTEL_GUC_ACTION_TLB_INVALIDATION, > + 0, > + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX << INTEL_GUC_TLB_INVAL_TYPE_SHIFT | > + mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT | > + INTEL_GUC_TLB_INVAL_FLUSH_CACHE, > + ctxid, > + full_range ? full_range : lower_32_bits(start), > + full_range ? 0 : upper_32_bits(start), > + full_range ? 0 : address_mask, > + }; > + > + if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION_SELECTIVE(guc)) { > + DRM_ERROR("Tlb invalidation: Operation not supported in this platform!\n"); as above > + return 0; > + } > + > + GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE_4K)); > + GEM_BUG_ON(!IS_ALIGNED(length, I915_GTT_PAGE_SIZE_4K)); > + GEM_BUG_ON(range_overflows(start, length, vm_total)); > + > + return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action)); > +} > + > /* > * Guc TLB Invalidation: Invalidate the TLB's of GuC itself. > */ > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h b/drivers/gpu/drm/i915/gt/uc/intel_guc.h > index 01c6478451cc..df6ba1c32808 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h > @@ -384,6 +384,16 @@ int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size, > int intel_guc_self_cfg32(struct intel_guc *guc, u16 key, u32 value); > int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, u64 value); > > +int intel_guc_g2g_register(struct intel_guc *guc); drop this, not part of this series > + > +int intel_guc_invalidate_tlb_full(struct intel_guc *guc, > + enum intel_guc_tlb_inval_mode mode); > +int intel_guc_invalidate_tlb_page_selective(struct intel_guc *guc, > + enum intel_guc_tlb_inval_mode mode, > + u64 start, u64 length); > +int intel_guc_invalidate_tlb_page_selective_ctx(struct intel_guc *guc, > + enum intel_guc_tlb_inval_mode mode, > + u64 start, u64 length, u32 ctxid); > int intel_guc_invalidate_tlb_guc(struct intel_guc *guc, > enum intel_guc_tlb_inval_mode mode); > int intel_guc_invalidate_tlb_all(struct intel_guc *guc); > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h b/drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h > index 3edf567b3f65..29e402f70a94 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h > @@ -436,5 +436,8 @@ enum intel_guc_recv_message { > ((intel_guc_ct_enabled(&(guc)->ct)) && \ > (intel_guc_submission_is_used(guc)) && \ > (GRAPHICS_VER(guc_to_gt((guc))->i915) >= 12)) > +#define INTEL_GUC_SUPPORTS_TLB_INVALIDATION_SELECTIVE(guc) \ > + (INTEL_GUC_SUPPORTS_TLB_INVALIDATION(guc) && \ > + HAS_SELECTIVE_TLB_INVALIDATION(guc_to_gt(guc)->i915)) > > #endif ,Michal