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 62EE9CD98FE for ; Wed, 11 Oct 2023 08:16:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A254B10E20F; Wed, 11 Oct 2023 08:16:47 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id DDD3910E20F for ; Wed, 11 Oct 2023 08:16: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=1697012204; x=1728548204; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=p0wXNWqLN0X64cRWO2mJRHBI1E4zdfmoZETM5D01cxQ=; b=fTfZDvVAeWl03hja8UUCoMIOV3WNu4c5g6ZopaLXiSaSaR0F6oCgAi6Q qZWa9TUV8t+LR90Pqbdpre5ftMUj81v/zds/RpHlbUwO8YKcBH30WDny5 IKG9d6DQJ3taMsuPrnqhSr490TrtcQwkss0oawlspb/WPoA1qOfgFoxF2 aErRgqGkEgiu7B4Tumvy7DdpDHl0ibNw/urplPFUmr1+KFM8u3+2GDQ1s oGYfmhWGg3f2W6XzIUZs+T5n/JLAqkCHfyBPwf1PIgdOZXvoTXuOE/77i 9970KjJkd/tnnw4mzp4HZHNsSEN+hT0KZvoH/vjj12YCBlam93j3d8ylA g==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="387449790" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="387449790" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:16:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="870053068" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="870053068" Received: from cjodwyer-mobl.ger.corp.intel.com (HELO [10.213.194.149]) ([10.213.194.149]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:16:42 -0700 Message-ID: Date: Wed, 11 Oct 2023 09:16:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Jonathan Cavitt , intel-gfx@lists.freedesktop.org References: <20231010184423.2118908-1-jonathan.cavitt@intel.com> <20231010184423.2118908-13-jonathan.cavitt@intel.com> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc In-Reply-To: <20231010184423.2118908-13-jonathan.cavitt@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Intel-gfx] [RFC PATCH 10/10] drm/i915: Use selective tlb invalidations where supported 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: saurabhg.gupta@intel.com, andi.shyti@intel.com, nirmoy.das@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 10/10/2023 19:44, Jonathan Cavitt wrote: > For platforms supporting selective tlb invalidations, we don't need to > do a full tlb invalidation. Rather do a range based tlb invalidation for > every unbind of purged vma belongs to an active vm. > > Signed-off-by: Prathap Kumar Valsan > Cc: Niranjana Vishwanathapura > Cc: Fei Yang > Signed-off-by: Mauro Carvalho Chehab > Signed-off-by: Jonathan Cavitt > --- > drivers/gpu/drm/i915/gt/intel_ppgtt.c | 2 +- > drivers/gpu/drm/i915/i915_vma.c | 14 +++++++++----- > drivers/gpu/drm/i915/i915_vma.h | 3 ++- > 3 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c b/drivers/gpu/drm/i915/gt/intel_ppgtt.c > index d07a4f97b9434..b43dae3cbd59f 100644 > --- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c > +++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c > @@ -211,7 +211,7 @@ void ppgtt_unbind_vma(struct i915_address_space *vm, > return; > > vm->clear_range(vm, vma_res->start, vma_res->vma_size); > - vma_invalidate_tlb(vm, vma_res->tlb); > + vma_invalidate_tlb(vm, vma_res->tlb, vma_res->start, vma_res->vma_size); > } > > static unsigned long pd_count(u64 size, int shift) > diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c > index d09aad34ba37f..cb05d794f0d0f 100644 > --- a/drivers/gpu/drm/i915/i915_vma.c > +++ b/drivers/gpu/drm/i915/i915_vma.c > @@ -1339,7 +1339,8 @@ I915_SELFTEST_EXPORT int i915_vma_get_pages(struct i915_vma *vma) > return err; > } > > -void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb) > +void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb > + u64 start, u64 size) > { > struct intel_gt *gt; > int id; > @@ -1355,9 +1356,11 @@ void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb) > * the most recent TLB invalidation seqno, and if we have not yet > * flushed the TLBs upon release, perform a full invalidation. > */ > - for_each_gt(gt, vm->i915, id) > - WRITE_ONCE(tlb[id], > - intel_gt_next_invalidate_tlb_full(gt)); > + for_each_gt(gt, vm->i915, id) { > + if (!intel_gt_invalidate_tlb_range(gt, start, size)) > + WRITE_ONCE(tlb[id], > + intel_gt_next_invalidate_tlb_full(gt)); > + } > } > > static void __vma_put_pages(struct i915_vma *vma, unsigned int count) > @@ -2041,7 +2044,8 @@ struct dma_fence *__i915_vma_evict(struct i915_vma *vma, bool async) > dma_fence_put(unbind_fence); > unbind_fence = NULL; > } > - vma_invalidate_tlb(vma->vm, vma->obj->mm.tlb); > + vma_invalidate_tlb(vma->vm, vma->obj->mm.tlb, > + vma->node.start, vma->size); The RFC looks like just what we needed so I'll drop an ack on the other patch series. Thanks for sending it out so quickly. Regards, Tvrtko > } > > /* > diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h > index e356dfb883d34..5a604aad55dfe 100644 > --- a/drivers/gpu/drm/i915/i915_vma.h > +++ b/drivers/gpu/drm/i915/i915_vma.h > @@ -260,7 +260,8 @@ bool i915_vma_misplaced(const struct i915_vma *vma, > u64 size, u64 alignment, u64 flags); > void __i915_vma_set_map_and_fenceable(struct i915_vma *vma); > void i915_vma_revoke_mmap(struct i915_vma *vma); > -void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb); > +void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb, > + u64 start, u64 size); > struct dma_fence *__i915_vma_evict(struct i915_vma *vma, bool async); > int __i915_vma_unbind(struct i915_vma *vma); > int __must_check i915_vma_unbind(struct i915_vma *vma);