From patchwork Tue Aug 1 18:35:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 129451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2892707vqg; Tue, 1 Aug 2023 12:41:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlEJTSxq/UPP7r1OcCg52E7fqmTd8i//spjRYmsYqZApEtlR5rPA5uTFT8wgtiNjG/wd3n/R X-Received: by 2002:aca:6707:0:b0:3a7:3a47:b137 with SMTP id z7-20020aca6707000000b003a73a47b137mr6200081oix.54.1690918871950; Tue, 01 Aug 2023 12:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690918871; cv=none; d=google.com; s=arc-20160816; b=S7VxUVVXgOaG3AUWAe7Cvo4B6K9mvdnZ1TkYfAk1kagK0O4pA2tDBlF1NEfpUiAWEg WHzPs3HB198ZkCJ3eIyUmyXTml15h4q3r9ivyVH9uqThKis4EQq1UyqdKw8QYk/QFpGC AEqmHAwTmQFRDRn3MrNrREVnJpm153GOr7AwlBtEh35pQGWeoh0x4dRq3f/lY0ETXCuq u4uGr/Jc08VHK2ZhTncXXqLK8fj3pRKNDMEuxtqdUA3YNPEAbMWcmph6TuuwIOIARNPy RkG1G5xxT6krq+LD/eDiEAwTwz0BHgOu20FbXjWeFMvdWTD3xr6M6q9lwVDYOiTTgq+f OCJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=zsOLF65GCnXc9xKNLgceJ3I7vQXpvGjuscvCrSUFmw0=; fh=HkZvzqpG3su5HjbZWNf3b9WXpSpTqqQbUzDG8abrZ4M=; b=xYEN3eDduYl2bvSiQ59UgQu7uOtkMpp5FrIScHx+KfSk+A4rkbE8OVma8fp6Qu4CC3 +mv0ZS7TwH46qrGkPy2cS7PESb+/W06iH0R2NwTbT4LVeZSfhtDUXQbhAKkejIxFTBzu HjsysPqH6iM/dxDF8l6ycEKo6KBWxAazzMSEVXlyX4ZsfnlqwaVXTv2A9n4DtM0p9Bsr 9glL9P4IvbdnW9CyG6VEQfgZq75h/EGHhwYz331jlu7U6uhSjEgwua6aOPPY7BhSbQI0 NGDTOxTOKhyo2OwktIWXEG9xZt9PYs+ca5X9VYJweo12CvdMKio169oU7Gi4VTIL0XMX /MJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2lYCxVWe; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y23-20020a63de57000000b00553c4551a08si9175832pgi.887.2023.08.01.12.40.50; Tue, 01 Aug 2023 12:41: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=pass header.i=@google.com header.s=20221208 header.b=2lYCxVWe; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbjHASjw (ORCPT + 99 others); Tue, 1 Aug 2023 14:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbjHASjj (ORCPT ); Tue, 1 Aug 2023 14:39:39 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED4F92707 for ; Tue, 1 Aug 2023 11:39:25 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-58456435437so70156717b3.0 for ; Tue, 01 Aug 2023 11:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690915164; x=1691519964; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zsOLF65GCnXc9xKNLgceJ3I7vQXpvGjuscvCrSUFmw0=; b=2lYCxVWeQ0XEbkaQCNlXmhkYY1Kddd521lbbTuATXI6HVCwfX4ZbVxfWE6VfMRva/L 3Ct0jredgG+9aQzrxInlmujaq12uQZjp6ylQi9BXuqmb2qytUTybE7o0QTJw7nzoLnkM 8s4H+06T5uZKGYi8wEcf1n/Tci3igvOBSxV4S+yZl79EGASbRc0CZ/togSNvBOcrnXvU Kg/VCSL1rl4AWel2PaVZZtLplRbQaYvRJQWmYLmfMfjqYZ3cAAna4hFrRFVB0ZK7tuUd Xy2SIOee1UdOvQU5vB3mTlPPU+4g8q8J/RMNVp+J+W4u5DJPKBzvgASjh1DefH2DaLKn X8Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690915164; x=1691519964; 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=zsOLF65GCnXc9xKNLgceJ3I7vQXpvGjuscvCrSUFmw0=; b=K+g65lW1hvOMzfUMkMVSYMWGTGysVQbR8YgwEW1Xv+Ldp6MzQNTv33EhXa+fGsUKvN x2yVux9A9NTes0TGtPoyKYmijzp+tCnKU6L4+IkezvGJlcDCniL/3X3jzZ2TZITMX4V8 u2ccRFuoeW3tmHk6F+wQC91cxFG3DQajonXiqQR87mTMOrdbloFZZODw5WI9nPggMhqj eiGs2OkMtMkzbz0lokeWr4aS1fjJEWekbcIqkjOV3XkixbdWPrng7L2hT2Pv8K4dd85z PMop05aacmkL7VkicNgtqFbt3Tor+bvWuu5CBusRCBa2fwKFsWqv1gxBL07NU7apXarT Mjyg== X-Gm-Message-State: ABy/qLYlvWkaY9g1x1lBK7jtrjjujX9IwSi3nPGcpf/hGQ13qo/pFlxt JcT3O/sZ8BpueC8PL1H1wVqIYpTABHJ1 X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:a54:d53d:50e4:b5b8]) (user=mshavit job=sendgmr) by 2002:a25:c712:0:b0:d0c:1f08:5fef with SMTP id w18-20020a25c712000000b00d0c1f085fefmr82652ybe.12.1690915164624; Tue, 01 Aug 2023 11:39:24 -0700 (PDT) Date: Wed, 2 Aug 2023 02:35:24 +0800 In-Reply-To: <20230801183845.4026101-1-mshavit@google.com> Mime-Version: 1.0 References: <20230801183845.4026101-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230802023524.v3.7.Idedc0f496231e2faab3df057219c5e2d937bbfe4@changeid> Subject: [PATCH v3 7/8] iommu/arm-smmu-v3: Skip cd sync if CD table isn't active From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: robin.murphy@arm.com, will@kernel.org, jean-philippe@linaro.org, jgg@nvidia.com, nicolinc@nvidia.com, Michael Shavit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773056946737973931 X-GMAIL-MSGID: 1773056946737973931 This commit explicitly keeps track of whether a CD table is installed in an STE so that arm_smmu_sync_cd can skip the sync when unnecessary. This was previously achieved through the domain->devices list, but we are moving to a model where arm_smmu_sync_cd directly operates on a master and the master's CD table instead of a domain. Signed-off-by: Michael Shavit Reviewed-by: Jason Gunthorpe --- Changes in v3: - Flip the cd_table.installed bit back off when table is detached - re-order the commit later in the series since flipping the installed bit to off isn't obvious when the cd_table is still shared by multiple masters. Changes in v2: - Store field as a bit instead of a bool. Fix comment about STE being live before the sync in write_ctx_desc(). drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 +++++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 b05963cd4e5b5..94922d4ff7be0 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -985,6 +985,9 @@ static void arm_smmu_sync_cd(struct arm_smmu_master *master, }, }; + if (!master->cd_table.installed) + return; + cmds.num = 0; for (i = 0; i < master->num_streams; i++) { cmd.cfgi.sid = master->streams[i].id; @@ -1091,7 +1094,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_master *master, int ssid, cdptr[3] = cpu_to_le64(cd->mair); /* - * STE is live, and the SMMU might read dwords of this CD in any + * STE may be live, and the SMMU might read dwords of this CD in any * order. Ensure that it observes valid values before reading * V=1. */ @@ -1360,6 +1363,9 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, cd_table->l1_desc ? STRTAB_STE_0_S1FMT_64K_L2 : STRTAB_STE_0_S1FMT_LINEAR); + cd_table->installed = true; + } else { + master->cd_table.installed = false; } if (s2_cfg) { 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 f2acfcc1af925..0ee3dc7291a15 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -599,6 +599,8 @@ struct arm_smmu_ctx_desc_cfg { u8 max_cds_bits; /* Whether CD entries in this table have the stall bit set. */ u8 stall_enabled:1; + /* Whether this CD table is installed in any STE */ + u8 installed:1; }; struct arm_smmu_s2_cfg {