From patchwork Fri Sep 15 13:17:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 140528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1163628vqi; Fri, 15 Sep 2023 09:17:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHW7MyOEnknlNcKWbjqzdhds3oyMvfljd1c9MRg5zLeuN1aMZyiAjqAgavh8h3v7scxQ7Y X-Received: by 2002:a17:90b:19d8:b0:268:d456:123 with SMTP id nm24-20020a17090b19d800b00268d4560123mr1870379pjb.41.1694794636657; Fri, 15 Sep 2023 09:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694794636; cv=none; d=google.com; s=arc-20160816; b=xeMiEKLRmo/bk/nuxkV5dZAV7BZy8Yj5v0L1ytwvNodRNM14PW/+usJj03gWQv42ur KgnwICZTJvjGqbzLO+zcyMC/3UjBA21T+c8ICzmoz1qZjdHEmWhqfENDzThBNoctMzIX w2iyvHNtdh5j672+zpp8WpyxI40bRVGs7SbMwNjrcBOT4hXwqjTC8E84TrKHQ5cjs9AK u6fJcashWkFTA5qD4O6Ghu/EvO00wtIOqGYFR1PoKzvxlQLGZM8QByH1uV6pUWs0syyd OAUTfdN0yeMQ5yba0ap2fwuDzlJjhiCV0XhYldZUeU+Q6h66ZXgec4KB/o2KfrzjSDkX nqag== 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=SUPSRV1Y2NOennFdL40BVpulBOE2JdAWnJXz+eg2+lg=; fh=yLUVUCpwXxa7JvtfFJiLr61NZJXkXSzdUYJStTN7VZ4=; b=HanyVR4aTRhe9H0jGfJxU+TM9XVdgIz6jyTHtq040Ce26rrsfLvm0X0AHRmHTNFVU3 QrZvzfH59hEujG7EtzmTPQP4eGSQZseEy2MnIIz4ev/JA67+xRZLLy7ZpWkKpH0fwh00 xZ97W+Fnfd7vlu9xzuloFHmg9pJD5V4rXm/2StcLDrgCiNsYq6tRtjh1sUfIQoZ2NFTQ Zbccu7jJRVqJ9N+IC7tbexVNd03SwdJHckFfdZ+AeVfYg+FWkzlJnqnyXX97QIzJl8xj neDOoYf16WACbIDVR6/qO7INvCW32dGzlWUTkHTxCGa2V5qCdmltUwfJKBc7PKkY/TfO LLuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="LaqL/D23"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x9-20020a17090a970900b0025bcbba10c6si3632722pjo.85.2023.09.15.09.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:17:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="LaqL/D23"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id E2D1C8310D3D; Fri, 15 Sep 2023 06:21:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232911AbjIONVW (ORCPT + 31 others); Fri, 15 Sep 2023 09:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235318AbjIONVR (ORCPT ); Fri, 15 Sep 2023 09:21:17 -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 E537E171C for ; Fri, 15 Sep 2023 06:21:11 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-594e1154756so27838287b3.2 for ; Fri, 15 Sep 2023 06:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694784071; x=1695388871; 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=SUPSRV1Y2NOennFdL40BVpulBOE2JdAWnJXz+eg2+lg=; b=LaqL/D23zPPJum+rergsyFuhrt7xuewTVYgoCSBc7ephoMGc384kG9hP2AJF32uaRF mzkNMsuKMM04XH/K7GRiTwUKoKktzzUnI2eKQBZOF6IeIMN9d1akjTQLrEA/Rl7PiBMm hup2OFjcAgPupzs61hX5zcpwsNISNZG425rwXK4ep1YAzqxDoXjw12nAV8wAGaRtCMgn FNnkecmicXeKfWAVgm+W5W0734jVXZRTERHbLj3Z8Iv1Y3BrVnErR3TQg8FWt5B3fBii EzVTLeNbQ9OxBHLPlbr2KBrG0PEtKCU0CQrxPJ/fdR4kJKbsUlBmbJaqiKYJ6uYq9Jg+ e2+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694784071; x=1695388871; 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=SUPSRV1Y2NOennFdL40BVpulBOE2JdAWnJXz+eg2+lg=; b=mvmRWxB4nFvYYU4Vh74Sz/J+ajg5SHpGmwGBN0cHg7bw9oAa4lAFdVAMNIcN61ziJW YgZka4XN+CTS9ySmfTNarB4Ex7pfeerzituwDMi4a+v9xCFxbDkVFkMpjiqAEfgtSNGu 23MPKu4SfkM21ZywFXys0JU8+1FH9vyY8mGwjWaSYuaxHZmBCgysGtsqXhdY2yUuIDfy DIjX7vKauHt0lg+QkRTKB7F2A8glew1fIE0TUTENFu8yQJY2ACm/XHyECe4wHVYQ7ouq ZwmlhYwedgZPEvMIUSnBWhQbfhrBPEohBwMA2vwvYaskLJVacbyoN5aHSwPtupjsk5Rl J3bw== X-Gm-Message-State: AOJu0Yz/fz0GNX2lHs/lO3mjvALVubY1/XkZRrC8RuPfhapXr84/AKgz QZ/yFt37IWgoOo1bquoYOh6XddHgHjqg X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:47bc:d53f:1c50:a3f2]) (user=mshavit job=sendgmr) by 2002:a81:ae49:0:b0:59b:ec33:ec70 with SMTP id g9-20020a81ae49000000b0059bec33ec70mr39843ywk.6.1694784071028; Fri, 15 Sep 2023 06:21:11 -0700 (PDT) Date: Fri, 15 Sep 2023 21:17:34 +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.3.I875254464d044a8ce8b3a2ad6beb655a4a006456@changeid> Subject: [PATCH v8 3/9] iommu/arm-smmu-v3: Encapsulate ctx_desc_cfg init in alloc_cd_tables 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 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:21:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777120980566875771 X-GMAIL-MSGID: 1777120980566875771 This is slighlty cleaner: arm_smmu_ctx_desc_cfg is initialized in a single function instead of having pieces set ahead-of time by its caller. Reviewed-by: Jason Gunthorpe Reviewed-by: Nicolin Chen Signed-off-by: Michael Shavit --- (no changes since v1) drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 ++++----- 1 file changed, 4 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 1ccff6d87edf7..a9649eaeed8dc 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1132,7 +1132,8 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid, return 0; } -static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain) +static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain, + struct arm_smmu_master *master) { int ret; size_t l1size; @@ -1140,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->s1cdmax = master->ssid_bits; max_contexts = 1 << cdcfg->s1cdmax; if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB) || @@ -2087,7 +2089,6 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, int ret; u32 asid; struct arm_smmu_device *smmu = smmu_domain->smmu; - struct arm_smmu_ctx_desc_cfg *cd_table = &smmu_domain->cd_table; struct arm_smmu_ctx_desc *cd = &smmu_domain->cd; typeof(&pgtbl_cfg->arm_lpae_s1_cfg.tcr) tcr = &pgtbl_cfg->arm_lpae_s1_cfg.tcr; @@ -2100,11 +2101,9 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, if (ret) goto out_unlock; - cd_table->s1cdmax = master->ssid_bits; - smmu_domain->stall_enabled = master->stall_enabled; - ret = arm_smmu_alloc_cd_tables(smmu_domain); + ret = arm_smmu_alloc_cd_tables(smmu_domain, master); if (ret) goto out_free_asid;