Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp473942imw; Thu, 14 Jul 2022 05:10:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tAKYeKfiU4DwOVS1KIlSJS6mT0onUub6tzvA0KX8NSLoGPIdQqYn1N96az9h0meedcQ9x3 X-Received: by 2002:a05:6402:2812:b0:43a:9041:d5db with SMTP id h18-20020a056402281200b0043a9041d5dbmr11693506ede.208.1657800611706; Thu, 14 Jul 2022 05:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657800611; cv=none; d=google.com; s=arc-20160816; b=n6qm0gFduOwdeXeHuIppl4eVX1xemgXbmxci1BM6NM2WON4iVRhvoPkbAyTfl27rUO WHf0HEOZRosOvlCy48d49Ib55+C51LpeCCqaFgwK09AcpYLcl20bxliZH1jgfbQGpDbV RWWs9Q9tlar9aZNpQf+KAtDjTV0ZuAT4aSH3xgBYZNZR4EnA4b8/XxnUC/YtJXLx4WsR wpeiuwlOhCKbW04KB5hpMncy6hrYD74eqSjfuSTtWoStXukZMcHxcIQluxsb/IXXyuOk TBkl+3QXEwPwUEtc0N5OQWPNsybLIA579QfToPbaiGNRyNSMQI+bgw90M7T7ZWAu263G DICA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=YLOMZgi/uqKpkdzy4GNiK4+773bOUQGLcFyY/Me8A0k=; b=d3CaVpGgFg/uXNGN6Kqge9ULfq2P+7bV/pfar2L3GEn83umcbkhKMALRfFzQQdz/XN aMv3z47c2wrC+yLy0O4XHs5975JqOK4X0mpWOcwGyNGh6dnBsL7Z6B930sn3zeSeIjW9 JvDnu9WVBM1KmnfV/X3nwFFfdtnQthF3D2QlewpLITDkZ4C8CDktFK1zHVWt0PcBsNMu gMGHSCMmS0QklMNYz2GaR5tJydriOSZe3/kc/8/Js78fdS2IhGs3U8EMg9Rd18hrJNJR 4FQVXKTXT4YxPyvFIh3PW2iQ7Xi9ZYWXlAnP7K1LSs5t98GYbUUUbymTAsYGsJmrgIdi 5inA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=itgE7dWj; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ju16-20020a17090798b000b007269af5c7f8si732470ejc.853.2022.07.14.05.09.44; Thu, 14 Jul 2022 05:10:11 -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=fail header.i=@kernel.org header.s=k20201202 header.b=itgE7dWj; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239173AbiGNMGz (ORCPT + 99 others); Thu, 14 Jul 2022 08:06:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238784AbiGNMGe (ORCPT ); Thu, 14 Jul 2022 08:06:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFEA25C9C1 for ; Thu, 14 Jul 2022 05:06:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 154EC61E4C for ; Thu, 14 Jul 2022 12:06:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9326C341E1; Thu, 14 Jul 2022 12:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657800390; bh=2nPh2QI3ZigEOFy12Hg7q1FTsviWqDN6vtCQov7Vlss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=itgE7dWjn8jQG3Utg4APjFEtp1xYe0bugHAToCAFYH66ABXD9fjwlN0Ed75og3U/R g8W5eW0Jm2CjnsCSz1E9uX4D9tMisnyzqj8Dt6iA3/1llebC1S2Ihi8BRgg5Zp9Ug0 dT8Hu+i/HMlqXo25wDvtTw2q9iCmwTLG83dkUNFhAldQaw9BLcRnBhloTFznJtmyxj HGkIwg/jJpc4DTb/3kQfPVUFlPorQiC+IXytp4wExZxbs6fQzneXL3Q/SSsPEsQqku /LNOTd8Vm+kPFFpLx90dsYRR7LvGWgaIEwVk3C25LCRbPtIs12flEMyqnGmSlocUpc XryyEzwSotzuw== Received: from mchehab by mail.kernel.org with local (Exim 4.95) (envelope-from ) id 1oBxbw-0059tO-6B; Thu, 14 Jul 2022 13:06:28 +0100 From: Mauro Carvalho Chehab Cc: Prathap Kumar Valsan , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Chris Wilson , Daniel Vetter , David Airlie , Jani Nikula , Joonas Lahtinen , Lucas De Marchi , Maarten Lankhorst , Matt Roper , Matthew Auld , Mauro Carvalho Chehab , Michael Cheng , Rodrigo Vivi , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Niranjana Vishwanathapura , Fei Yang Subject: [PATCH v2 18/21] drm/i915: Use selective tlb invalidations where supported Date: Thu, 14 Jul 2022 13:06:23 +0100 Message-Id: <7d55e7971e3f4544d8edeabb9e9c645c3042e01d.1657800199.git.mchehab@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Prathap Kumar Valsan 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. [mchehab: change moved from intel_ppgtt.c to i915_vma.c] Signed-off-by: Prathap Kumar Valsan Cc: Niranjana Vishwanathapura Cc: Fei Yang 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/ 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 f764d250e929..74782fb2ccbd 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 5edc745dcc51..6d881a6b403a 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -1309,7 +1309,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; @@ -1325,9 +1326,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(vm->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(vm->gt)); + } } static void __vma_put_pages(struct i915_vma *vma, unsigned int count) @@ -1980,7 +1983,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); } /* diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h index 33a58f605d75..3f0af9595e59 100644 --- a/drivers/gpu/drm/i915/i915_vma.h +++ b/drivers/gpu/drm/i915/i915_vma.h @@ -213,7 +213,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); -- 2.36.1