From patchwork Fri Sep 15 13:17:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 140574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1211512vqi; Fri, 15 Sep 2023 10:33:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWS6OE8ozzf5MBONDXe7BfpHXWO/YMnIuLT+6YHmAR7CgpudyXn/g8afwo9Dp2lLh84aT/ X-Received: by 2002:a05:6a20:3255:b0:133:bbe0:2ff1 with SMTP id hm21-20020a056a20325500b00133bbe02ff1mr2331781pzc.44.1694799230078; Fri, 15 Sep 2023 10:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694799230; cv=none; d=google.com; s=arc-20160816; b=QhK1kt7E6YOEvWNBMIBJTrg+ZK2HEGN+eE88bXpcYZHidfEiAWJeG3mt7sBObtI8Xq dy/93mMw2vUgZgkcwbYi8+ylpT+M3yZln66gDbVZTCFmWdWiQE0pquCZXh1lS7PHEWvW 0SSgfsooR4nYQ/x4ubY3JBGbTr723XDgdNHizyuWSDGcVfg1g/W1I3YyqPMHqCtV0WEX vBrbxHaH6Y8WWUQ9NPqltkoBDL9yvwLPz7e4ug0ZcOXw0Xq7YK8fCHtsia8Chb4/FIAi dYPZYPkw8AJQaOWGG+uBvEiwbip5Mp8xYVNsvN5GNdVWhyiWR8Xh9N4vZGRRVPGMWM3Y vLug== 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=rk7ktlAtF0nCHbLqPotJ0gZV9JuU0iwAIccoyoIY0ho=; fh=yLUVUCpwXxa7JvtfFJiLr61NZJXkXSzdUYJStTN7VZ4=; b=O9tEJdq/LylYL8NhphvPbJtdRZdGNUkA1+fe4GRIBQXBgbqnkQIhY634r4frxGTOzI BLqGzhtZOBFk5ckvI4e5ZRubOe0aiAXnIO0Q7iVOmPDrcczMztOuAtmHGrd1VMKN0E2E UssolI8KCAIkPKwd7/1CyO87UiMvaAcBlW6n3pZ9WeeAsMWh/OiLbw3sRkTT5rtRt04q 5alHu1xiCaSPce4nKTlrb8pLftIOdoQhKt+rjVuYtnu2OYt9Ks6GxeBGHv0TTDKzXgLZ XnQPLHt5MevXY1QpT4MDZ+NvHmLO6PrZwJd1iqqLIRI8dytBX3AjANpulhBr25tuiGky NiRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZqfIEoXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cm16-20020a056a020a1000b00563fe2c1163si3595162pgb.168.2023.09.15.10.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZqfIEoXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 36D4B836FDDD; Fri, 15 Sep 2023 06:21:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235324AbjIONVZ (ORCPT + 31 others); Fri, 15 Sep 2023 09:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235281AbjIONVV (ORCPT ); Fri, 15 Sep 2023 09:21:21 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BE961BEB for ; Fri, 15 Sep 2023 06:21:16 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b5a586da6so40496247b3.1 for ; Fri, 15 Sep 2023 06:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694784075; x=1695388875; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rk7ktlAtF0nCHbLqPotJ0gZV9JuU0iwAIccoyoIY0ho=; b=ZqfIEoXYt3g2DlwYU/c8JMlhqkzOKqN0GKE2Z6NDkjwHgJwtLMpwqPRiUfx0LjJ0Ba 4Rf5z9PBefcGD9v5FgMSAYhg8klz2/YNdKX7KblTrz/pnHnasQmhx6/Ie+NFFmPhyTKR UIusysQY/S+x0ThFqEdQQ5LvIjKtoTrQ59i4usC6xz/vpcUVqpxuZSPBi23l5D1ri1KB RrRkqDCIKBBJsIS09YPUOkI+cH5jumBU/smYx2/U/N5+BQDZi29qLvSij6LeOwG9pdcw KyuBVkYF3wgZiW/vJ7nSORpg7V76elF0T6foPIhS1pVW11XWEvwTKR7DNdfHnKD22mNp 0uvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694784075; x=1695388875; 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=rk7ktlAtF0nCHbLqPotJ0gZV9JuU0iwAIccoyoIY0ho=; b=TRkezblnBFvWqi0aSx0W3m/QsakpgpzUpUnUtdUgqTjxW5+raEpOY9u3r/KMS5g8Vl fUTu29AxOHFNlvPLGMyhLfsluNvUF0Qn/wkQIdIu+Ct49oDYttK3+6xv/CTUj4YYSowc WLD3A6fgutbfbs6JC8aeqvTA75x1mNEDUSj99kw58Wfwhsd0GR8ZLIL7PC3m2njVdLxq 2++KLRqqEDzQWlMkcFdcpTt6ghg/FcBADpEDqesrCmCF0yl6EOJZ3K6KZS0E0lE0WA7L IaHnOWlFc8ToCpOf8emChBqeKXJSCz8Nhjv6mDcyIC1fKZNfmNPtxJFc/II7g1eL5gLu vLRQ== X-Gm-Message-State: AOJu0YyOPr9UMGRtPPpJ+dkCWIYV4B8xFFanGPKFdMOn7nTjUruK8Xyt i+uv+VSuJxityCa2xBL4+h7S4d5zn9ti X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:47bc:d53f:1c50:a3f2]) (user=mshavit job=sendgmr) by 2002:a05:690c:2c07:b0:595:7304:68e5 with SMTP id eo7-20020a05690c2c0700b00595730468e5mr131795ywb.0.1694784075473; Fri, 15 Sep 2023 06:21:15 -0700 (PDT) Date: Fri, 15 Sep 2023 21:17:35 +0800 In-Reply-To: <20230915132051.2646055-1-mshavit@google.com> Mime-Version: 1.0 References: <20230915132051.2646055-1-mshavit@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230915211705.v8.4.I5aa89c849228794a64146cfe86df21fb71629384@changeid> Subject: [PATCH v8 4/9] iommu/arm-smmu-v3: move stall_enabled to the cd table From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nicolinc@nvidia.com, jgg@nvidia.com, jean-philippe@linaro.org, robin.murphy@arm.com, will@kernel.org, Michael Shavit , Alistair Popple , Dawei Li , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Kevin Tian , "Kirill A. Shutemov" , Lu Baolu , Tomas Krcka 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,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:21:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777125797525926471 X-GMAIL-MSGID: 1777125797525926471 A domain can be attached to multiple masters with different master->stall_enabled values. The stall bit of a CD entry should follow master->stall_enabled and has an inverse relationship with the STE.S1STALLD bit. The stall_enabled bit does not depend on any property of the domain, so move it out of the arm_smmu_domain struct. Move it to the CD table struct so that it can fully describe how CD entries should be written to it. Reviewed-by: Jason Gunthorpe Reviewed-by: Nicolin Chen Signed-off-by: Michael Shavit --- (no changes since v5) Changes in v5: - Reword commit Changes in v2: - Use a bitfield instead of a bool for stall_enabled drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++++---- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) 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 a9649eaeed8dc..0b06b58dce6ba 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1114,7 +1114,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid, FIELD_PREP(CTXDESC_CD_0_ASID, cd->asid) | CTXDESC_CD_0_V; - if (smmu_domain->stall_enabled) + if (smmu_domain->cd_table.stall_enabled) val |= CTXDESC_CD_0_S; } @@ -1141,6 +1141,7 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain, struct arm_smmu_device *smmu = smmu_domain->smmu; struct arm_smmu_ctx_desc_cfg *cdcfg = &smmu_domain->cd_table; + cdcfg->stall_enabled = master->stall_enabled; cdcfg->s1cdmax = master->ssid_bits; max_contexts = 1 << cdcfg->s1cdmax; @@ -2101,8 +2102,6 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, if (ret) goto out_unlock; - smmu_domain->stall_enabled = master->stall_enabled; - ret = arm_smmu_alloc_cd_tables(smmu_domain, master); if (ret) goto out_free_asid; @@ -2443,7 +2442,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) ret = -EINVAL; goto out_unlock; } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && - smmu_domain->stall_enabled != master->stall_enabled) { + smmu_domain->cd_table.stall_enabled != + master->stall_enabled) { ret = -EINVAL; goto out_unlock; } 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 def1de62a59c6..287bef2d16aae 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -598,6 +598,8 @@ struct arm_smmu_ctx_desc_cfg { u8 s1fmt; /* log2 of the maximum number of CDs supported by this table */ u8 s1cdmax; + /* Whether CD entries in this table have the stall bit set. */ + u8 stall_enabled:1; }; struct arm_smmu_s2_cfg { @@ -715,7 +717,6 @@ struct arm_smmu_domain { struct mutex init_mutex; /* Protects smmu pointer */ struct io_pgtable_ops *pgtbl_ops; - bool stall_enabled; atomic_t nr_ats_masters; enum arm_smmu_domain_stage stage;