From patchwork Tue Aug 22 10:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13360482 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 23CAAEE49A8 for ; Tue, 22 Aug 2023 10:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=X4MhnGNZBo5YBNIXZ/0qB/OJEezrz7izihIMuty4B8g=; b=O6NA9k1fVACRIX9MaNqKoPjODg ygW49dAEUJulD0PUYBjy7VGDplAaOTF8q6537eYxcJA483Uj/osWWU6PWAfQ+2jvq8nV1odAqjPVH 5dcgMQ+DZq75QHZlaL1GLQX5UjLgFVpmP+e/vya95GiZnnbMIoI1cVvIL9m/w1mkRuL8WANNudHxn f/PhO/gPljE95eKR4C9ksKDn8kkwODKZ+q1fENZE7QFW374HoZSNzJkuXU01J1WmSCyx2/0OP3ETJ QG+5bbT5Ihm0Uz8Nj2up5qOJY9m86I0C+sf0vjrRBGYhnFR8gxrf1vZOlEDlg8km1B25Wl8nHq1Nu iYA0J2XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYP5M-00FmLw-0X; Tue, 22 Aug 2023 10:58:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYP5K-00FmKo-37 for linux-arm-kernel@bombadil.infradead.org; Tue, 22 Aug 2023 10:58:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/fIEK+scFoPaQOWipSrbqlwk87RaTCX5IMBMHhwH0rc=; b=X55SLKfXsBhq8Rw//XHDuve7ph 87Pj8aNAdSCUeNrZfoJBp42++cKWzMhupJW/qSWofQpwQ9pCxUg1+vcEaxlcRBokXByD0hMmcDKpq bEEskVXnpVhhQfANYIh3q5NPDmbQzvPUJySsf+i4PPAud3qimG2ItNsZm0Ww83oasddAXZDaEs3qP SFqk3X8dPJ3g7SwEgjB5wlQfwThys9E0jdkFKB0EVOf993Rrame3KNhH5bAN/VNfNTkQNWiSzeth5 tStLHkyV2zz0+1hQXmmXL7BLwLtJ0MApCIAjvdGQXY/Zc24QPBdqu8mO6SP0OdlOlUKz3xVPnmRV5 AHf7nGTQ==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYP5G-002h7B-0F for linux-arm-kernel@lists.infradead.org; Tue, 22 Aug 2023 10:58:05 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d74a6dfb0deso2642016276.0 for ; Tue, 22 Aug 2023 03:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692701875; x=1693306675; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/fIEK+scFoPaQOWipSrbqlwk87RaTCX5IMBMHhwH0rc=; b=VzPvLxPEkUWtvGRxaI4vgChrPgBtjf6/0dO4DMIS0sPgv7fDNtvVXPrbRKl0S6dUJG 5Jif4cnLgI2SCQegLHuKV6Ak4FpQ5uV5ha/XyE96/30mOKtY80ezUODmcLJR7lN/E4kj oFARbyu2wcSqnVV4Vx7NMcXOH5qGa3vTVWgioQ5cHoX27qkYhbvOYyEP4aYyicsnmHgI H6eDa0S8GVMMekyTEt3vZkmhl8Zj0XCgFGBH/v64XbaWn+dP6J04Ryf7QlXsFMV/HynZ BTlRcj7wq/qZJYEPC//+OeNhBH7vb9knU6I0fmh0RYk7s8pNxp6+lXRt0tRHaizJP9fA SWQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692701875; x=1693306675; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/fIEK+scFoPaQOWipSrbqlwk87RaTCX5IMBMHhwH0rc=; b=Qd8nRNT5tVGbu78hfqbSTlAGNgWTyNXHfakfzwsu5nLKVLHSy9SLmz7rnkQVv5DDBb 43iaoMDucGqL4eap68bzbN+beX6HPKmgfwR6N24FjE0K91cldmYktKvU0/DiUMw/qK54 5qsyYI28OrShXTr/YppkLc2qx5wMZlwVQ6cxRfvgSQ9BO3ih/HN4K9FpuWJrZNKGz4YU iWUwT/VqGgjTBtVeZI5A0ZpBxMLgajCH0WVaSDTj4nZC7g/yLf1SeFAUSto0rFOXOT/l 3KeFVGrgTa2FI6VXu6yA6ALtfnMUzZ7qjqHAujVm0Q5MLmgg5flY3h4aGD9vZCSsgJnm Xjlg== X-Gm-Message-State: AOJu0Yw8PFnld9lwhHeJ2704d4hbtTnOlsnHsM3x6I4I+tSn+X8I+iJk d5RFRUsiHFcY3bJXRXnP8iP62mGYd5XP X-Google-Smtp-Source: AGHT+IEeWLCXictoCF2DKIdsuoaCa730sOxBT91INqbmQdApKPT2Vvx2k50fuMZ0N/jHCgwdsRZutgwQV7Yp X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:44ad:3968:8aaa:c4fe]) (user=mshavit job=sendgmr) by 2002:a25:874c:0:b0:d35:bf85:5aa0 with SMTP id e12-20020a25874c000000b00d35bf855aa0mr82026ybn.4.1692701875089; Tue, 22 Aug 2023 03:57:55 -0700 (PDT) Date: Tue, 22 Aug 2023 18:56:58 +0800 In-Reply-To: <20230822105738.1607365-1-mshavit@google.com> Mime-Version: 1.0 References: <20230822105738.1607365-1-mshavit@google.com> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Message-ID: <20230822185632.RFC.v2.2.I9e9adbe1cb8164398d7a8f56907e6823fddb45bf@changeid> Subject: [RFC PATCH v2 2/9] iommu/arm-smmu-v3-sva: Move SVA optimization into arm_smmu_tlb_inv_range_asid From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nicolinc@nvidia.com, tina.zhang@intel.com, jean-philippe@linaro.org, will@kernel.org, robin.murphy@arm.com, jgg@nvidia.com, Michael Shavit , Dawei Li , Jason Gunthorpe , Joerg Roedel , "Kirill A. Shutemov" , Lu Baolu , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230822_115802_216324_C9A1A9C0 X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This will allow the optimization to be decided on a per SMMU basis when arm_smmu_tlb_inv_range_asid operates on multiple SMMUs. Signed-off-by: Michael Shavit --- Changes in v2: - New commit drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 5 ++--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 238ede8368d10..53f65a89a55f9 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -230,9 +230,8 @@ static void arm_smmu_mm_invalidate_range(struct mmu_notifier *mn, */ size = end - start; - if (!(smmu_domain->smmu->features & ARM_SMMU_FEAT_BTM)) - arm_smmu_tlb_inv_range_asid(start, size, smmu_mn->cd->asid, - PAGE_SIZE, false, smmu_domain); + arm_smmu_tlb_inv_range_asid(start, size, smmu_mn->cd->asid, + PAGE_SIZE, false, true, smmu_domain); arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, start, size); } diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 37b9223c145ba..db4df9d6aef10 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1974,6 +1974,7 @@ static void arm_smmu_tlb_inv_range_domain(unsigned long iova, size_t size, void arm_smmu_tlb_inv_range_asid(unsigned long iova, size_t size, int asid, size_t granule, bool leaf, + bool skip_btm_capable_devices, struct arm_smmu_domain *smmu_domain) { struct arm_smmu_cmdq_ent cmd = { @@ -1985,6 +1986,9 @@ void arm_smmu_tlb_inv_range_asid(unsigned long iova, size_t size, int asid, }, }; + if (skip_btm_capable_devices && + smmu_domain->smmu->features & ARM_SMMU_FEAT_BTM) + return; __arm_smmu_tlb_inv_range(&cmd, iova, size, granule, smmu_domain); } diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 83d2790b701e7..05599914eb0a0 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -751,6 +751,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_master *smmu_master, int ssid, void arm_smmu_tlb_inv_asid(struct arm_smmu_device *smmu, u16 asid); void arm_smmu_tlb_inv_range_asid(unsigned long iova, size_t size, int asid, size_t granule, bool leaf, + bool skip_btm_capable_devices, struct arm_smmu_domain *smmu_domain); bool arm_smmu_free_asid(struct arm_smmu_ctx_desc *cd); int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid,