From patchwork Thu Jul 27 18:26:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 127171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp7590vqg; Thu, 27 Jul 2023 13:55:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlGB5XaIeVpZJUNdppbXet+K5O60l80KnntT3VDqGpccNKFGWpmt02+453l4+vrZCQUBjiLX X-Received: by 2002:a17:903:230b:b0:1bb:d8d1:37a7 with SMTP id d11-20020a170903230b00b001bbd8d137a7mr448028plh.37.1690491337885; Thu, 27 Jul 2023 13:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690491337; cv=none; d=google.com; s=arc-20160816; b=nKJ0OmK2rcC0iMwE/ktMN+wCI1BdOh4JrQskerSJi50DFsF7n6qorocu98pUSSSwus EXY45Lr7Vf/VUcRmc4takpKNXtK1r5fkclzoJA+AjT+EP9SL/hoDponm+o9hN9lyhe3y eiijRUtLRQZ09ebh2vNuTp4Fwor/K957M2Lmql0P/uOByJSXeDdW2OsnJAb6QtJubL3t dy5p8pRfZn111cmmTwARdTPP7ESqkPJlQ82F5hRCXO1uVDCPcSmseJxGjO2iQE7uGKNH 1Ktu7jHpeMgjqHnS6fJIjFqO5PAINOiZxdbQ2PqYjEOcdwZlHv7YSslUrHWWIkjTfZKH tQjg== 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=/RPG6EjTpCmrlpk3X3dE+3LLtmtBMtKD9Q5+XxQMCjE=; fh=HnAFHWFlJx6556zbVk+xHReF/Bq7K9G33irMhQzl/Ec=; b=Vb5kxOlTMhYWHgqwY66wtNQ46NeeIncdcXFv9IrLRMIWxUlL0qY+OINTW/8bkNirwp qOYPXmFx/Bxuz1PzepmuOzIFGFz0IdI11B8AWFQvG1lh1EFkqnNQ3GKkrLjl06Tlms2D nbbnGwPizj1+oWT+EOwkiSS3Ap3YpHMXlz84rUHRB6shSO2e+iLxcoovK9oXxyQFUN/G TtqkNrIbhjJmIhu2qjOd5v5gurqKHkQStPD0NXYtXCoLmKgQPnJkwYX9ozkZpfbzSKvD o7kI02MBj84fGvEecHFO0yCYKPxkZ1H+Q2DD97h739NLdXew7TjIdEkCJo345w7Lz6Iu 5S+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=AjK5zSMi; 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 p9-20020a170902e74900b001b87bd2f7b0si1886075plf.402.2023.07.27.13.55.24; Thu, 27 Jul 2023 13:55:37 -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=AjK5zSMi; 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 S229463AbjG0S2t (ORCPT + 99 others); Thu, 27 Jul 2023 14:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjG0S2p (ORCPT ); Thu, 27 Jul 2023 14:28:45 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 334433A94 for ; Thu, 27 Jul 2023 11:28:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c64ef5bde93so1223437276.0 for ; Thu, 27 Jul 2023 11:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690482510; x=1691087310; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/RPG6EjTpCmrlpk3X3dE+3LLtmtBMtKD9Q5+XxQMCjE=; b=AjK5zSMi0Im0w3fYQ15yRccpeOAI+14Zvl4PVzDHTHhNvwzjh917aJdYWewXqc2I7J wRBzfd9DM1syldv8VA5K0fQ7RLiLKSZeQPH3Ada/itXI3betjMpH20YG/uq9x6aHZz2B cyk5BEHGFiuEMyvVAX9Mwcp4O2GgsAyuh2RN7dESRFRpeOR1Q9WM1QQpfa5YWjbGHTXd r03k4z/GNWuHOb+G9Sj1j6Nwn4rS3MYRotmRxYEJb1uqN4We7R3WauHxoXhlRwPEZSfw f42lVGxivrRZ6JJUS3a06HvKZ/V+CFTe1MQlTl9ed9YJtDMiE2uqIq9CGRJtqBMSNfRh Cxnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690482510; x=1691087310; 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=/RPG6EjTpCmrlpk3X3dE+3LLtmtBMtKD9Q5+XxQMCjE=; b=fUU1GeFmprUNzNYjhOUfxYfc5DhJlyugGPknijWs/2oLP8V/T0sSXC7aF3Z8vEyMjt Y9omuewIiQk1nCoLwudb6XzhYvZJ3QcATeyBnaevBX6/GLa5PtEe/GBxV78yKFCDGv2R cC37qIPR+Hlk6n/Si/0qTpFhcsuxY+9gDs7Xg9eeNL6yt6QQO2fjS5mKhrRxkTQsPyIU R04NNcWVC0Ad+AnBmXiyOAlKDZBC5mraPHMhk39qflKORfPR6bxbjOjEoRQYy7nKupie aLUcfKM0YlFA8kSQOkz/JRBp/PjihWBauZpTbBeYvUzW98ownsV8ThPLKdBTBdlAEXgu +GVQ== X-Gm-Message-State: ABy/qLZknenA9qn6Pi14GlCTbf+WGcJMHcFIaq26vCqKvPltq8K3lSYO sDMJmKhp/e3MN0O4ScmsLAT1XIWhd/SF X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:780f:26da:d952:3463]) (user=mshavit job=sendgmr) by 2002:a25:d001:0:b0:d0a:5674:c4f6 with SMTP id h1-20020a25d001000000b00d0a5674c4f6mr1094ybg.3.1690482510319; Thu, 27 Jul 2023 11:28:30 -0700 (PDT) Date: Fri, 28 Jul 2023 02:26:20 +0800 In-Reply-To: <20230727182647.4106140-1-mshavit@google.com> Mime-Version: 1.0 References: <20230727182647.4106140-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230727182647.4106140-5-mshavit@google.com> Subject: [PATCH v1 4/7] iommu/arm-smmu-v3: move stall_enabled to the cd table From: Michael Shavit To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Michael Shavit , jean-philippe@linaro.org, nicolinc@nvidia.com, jgg@nvidia.com, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org 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_NONE, 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: 1772608644966755003 X-GMAIL-MSGID: 1772608644966755003 This controls whether CD entries will have the stall bit set when writing entries into the table. Signed-off-by: Michael Shavit --- 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 8a286e3838d70..654acf6002bf3 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->max_cds_bits = master->ssid_bits; max_contexts = 1 << cdcfg->max_cds_bits; @@ -2121,8 +2122,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; @@ -2461,7 +2460,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 006a724ee9230..0e55ca0d40e6b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -597,6 +597,8 @@ struct arm_smmu_ctx_desc_cfg { unsigned int num_l1_ents; /* log2 of the maximum number of CDs supported by this table */ u8 max_cds_bits; + /* Whether CD entries in this table have the stall bit set. */ + bool stall_enabled; }; struct arm_smmu_s2_cfg { @@ -714,7 +716,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;