From patchwork Thu Aug 17 18:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 136187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2148769vqi; Sat, 19 Aug 2023 11:32:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZlWgQnCeY9GOK6BRfhQnOZU35Aqq0me1qft4lXwJOKOAbOgU0bmdywvC0vwGynWoSqSeM X-Received: by 2002:aca:1c17:0:b0:3a4:17cd:dd31 with SMTP id c23-20020aca1c17000000b003a417cddd31mr3290300oic.14.1692469936273; Sat, 19 Aug 2023 11:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692469936; cv=none; d=google.com; s=arc-20160816; b=ptc50M0H7r041QPubX97WVKZoSkeGcR7NZKWE4v7Eicl9dAhSr54mQwGXMDc6V5cHR 36hZVPo/WoxLeijbF4q6GVRCw9JVQuHopo85v12b1ee5wbxOItxXukgR2F+ZJfQU2GQO CTtbDhhuh9tlxgS/tFGc0vvknVJo0o00MahTNg9kZjgYQMubKw/PqIMPQgCxgOaki4aa FNblTS+9TX8RmC0dhAh6ptPhdv36/I+5C2KtACbku6Z2ekILbdPoaFp/IV3i+xOIEbUZ pCnxMgmQJ2RqipIHObTr/K13gulajiBWZ+nmT1Gzp6rs5NvUrRHAtMpQRb5dFZ0u+1/i k6ug== 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=4ZP10bOrqJHL85lu3Z2lUx2alTLUFh+2Q6vzg89i9Wk=; fh=tYpv6qsltcODcibInAuLkJrpWg7wzPyO6zvJCzf1BPg=; b=fcjQoaz3NsPWQj2k3y7+gD5vgCoioG3SDyK04+IypZrSDJeT+oKU/KfkS6bzP1C1W/ XM7luPZCxl5dQT7zrtvRYYg4prpM47b5bzaHejcp7Ti1zShzjHOcMVcbfXWi4ezXXn2i kdUR/hRqAGqknunW29gXAfmxsMsAiM9A71TxiUPBTzuli3QubzKFyV/zxTsEE3eC4ZBz 6wqQpvykj57bpf3v4t4lzUOv30czer9nMXvqzcGD66XbjTQmGNSWCdrJqvdHyJ3MhJBL CiiCTWIIrCpqk/X2htiws6nZTnmRSgqy6ocef1645HD4bcNNIRAleMQBADw6oy0zpwrV 2xyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3SMQXfpS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n7-20020a6543c7000000b00566022bbcacsi3656810pgp.440.2023.08.19.11.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 11:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3SMQXfpS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF949CA45; Sat, 19 Aug 2023 01:34:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354351AbjHQSXi (ORCPT + 99 others); Thu, 17 Aug 2023 14:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354396AbjHQSXQ (ORCPT ); Thu, 17 Aug 2023 14:23:16 -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 872623AB2 for ; Thu, 17 Aug 2023 11:22:40 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d1c693a29a0so183989276.1 for ; Thu, 17 Aug 2023 11:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692296492; x=1692901292; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4ZP10bOrqJHL85lu3Z2lUx2alTLUFh+2Q6vzg89i9Wk=; b=3SMQXfpShml6d9+BtmaqOK2GzQznRL6kyxmNNpDAk0CT1TqSZj14kVaCyjAuoY8Ax4 pUoE56xlNXNLOnXa9v2+/+DYWOtsfnIr1hiKC74FNdVVnrb/NQyojV5sLfI+Ffxg4ETV vRSA3YuSgWM7b0p3cR9XpwMtJEcS8nvF/1VpsdGANQjIZqUBDhgQWlHzpa5J75wKpO6Y qdqiK+/eWkHNqYp5fC/ATsxKWHE1j8rC+FNhpi4zsemW9RbIgorSVC8P/o7+Ur7AF02N zRfO9DP/B96rozUkWWcJhzFNNMBQW9IcwC+Rw1SZXEmJsB/7TtigLri8zQzxJjqpHC+L PQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692296492; x=1692901292; 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=4ZP10bOrqJHL85lu3Z2lUx2alTLUFh+2Q6vzg89i9Wk=; b=W5d2GQkFadTTH4mH0fksDssqw6DpRRPkVH1OQcrPpiJ2r9P0LjbPdNCpY4P44amzB/ vIs1dlmTeAQUulhHezjlrgTMSRxOiFPbBXg6DEwtX3QwRxKSqjoD2vI9LgH6ERysOzJp DfH4qwVUZ8HniM1p/XqqxkkgesT3GE42cLuMU0oGDPLbLycoFz84Ts7OnHECwzXW+Flq dNQGuFL2mjXwSkw4KOqHeyROJlIRgoO3BgNpZUUoKk7g/SK24CvwAGKcVPVtk/QVHIdt LyNoQXGHRaoBrW0f0hTjUG09T60YWbK8YUNngCov2bEjpjCKq3pifJq9bJLGSofs1Erw /WaA== X-Gm-Message-State: AOJu0Yy0rpIRcO4NKb6dS/xNn0ilEINkWjXTvhGF01y/xO3RlTHMwkZe iEJb8CVTJ6rbPNHMlWM6hxLE0iyKWann X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:4a77:fd20:7069:bdf9]) (user=mshavit job=sendgmr) by 2002:a05:6902:144e:b0:d44:585f:dfa8 with SMTP id a14-20020a056902144e00b00d44585fdfa8mr5677ybv.0.1692296492062; Thu, 17 Aug 2023 11:21:32 -0700 (PDT) Date: Fri, 18 Aug 2023 02:16:27 +0800 In-Reply-To: <20230817182055.1770180-1-mshavit@google.com> Mime-Version: 1.0 References: <20230817182055.1770180-1-mshavit@google.com> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Message-ID: <20230818021629.RFC.v1.5.Ia591869e7a4b88af16a57e09c92df21599d3312c@changeid> Subject: [RFC PATCH v1 5/8] iommu/arm-smmu-v3: Add arm_smmu_device as a parameter to domain_finalise From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: will@kernel.org, jgg@nvidia.com, nicolinc@nvidia.com, tina.zhang@intel.com, jean-philippe@linaro.org, robin.murphy@arm.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,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: 1774683356114569392 X-GMAIL-MSGID: 1774683356114569392 Remove the usage of arm_smmu_domain->smmu in arm_smmu_domain_finalise to prepare for the commit where a domain can be attached to multiple masters. Signed-off-by: Michael Shavit --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 c0943cf3c09ca..208fec5fba462 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2132,11 +2132,11 @@ static void arm_smmu_domain_free(struct iommu_domain *domain) } static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, + struct arm_smmu_device *smmu, struct io_pgtable_cfg *pgtbl_cfg) { int ret; u32 asid; - struct arm_smmu_device *smmu = smmu_domain->smmu; 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; @@ -2169,10 +2169,10 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, } static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain, + struct arm_smmu_device *smmu, struct io_pgtable_cfg *pgtbl_cfg) { int vmid; - struct arm_smmu_device *smmu = smmu_domain->smmu; struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg; typeof(&pgtbl_cfg->arm_lpae_s2_cfg.vtcr) vtcr; @@ -2227,15 +2227,16 @@ static int arm_smmu_prepare_pgtbl_cfg(struct arm_smmu_device *smmu, return 0; } -static int arm_smmu_domain_finalise(struct iommu_domain *domain) +static int arm_smmu_domain_finalise(struct iommu_domain *domain, + struct arm_smmu_device *smmu) { int ret; enum io_pgtable_fmt fmt; struct io_pgtable_ops *pgtbl_ops; int (*finalise_stage_fn)(struct arm_smmu_domain *, + struct arm_smmu_device *, struct io_pgtable_cfg *); struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); - struct arm_smmu_device *smmu = smmu_domain->smmu; struct io_pgtable_cfg *pgtbl_cfg = &smmu_domain->pgtbl_cfg; if (domain->type == IOMMU_DOMAIN_IDENTITY) { @@ -2275,7 +2276,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain) domain->geometry.aperture_end = (1UL << pgtbl_cfg->ias) - 1; domain->geometry.force_aperture = true; - ret = finalise_stage_fn(smmu_domain, pgtbl_cfg); + ret = finalise_stage_fn(smmu_domain, smmu, pgtbl_cfg); if (ret < 0) { free_io_pgtable_ops(pgtbl_ops); return ret; @@ -2585,7 +2586,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) if (!smmu_domain->smmu) { smmu_domain->smmu = smmu; - ret = arm_smmu_domain_finalise(domain); + ret = arm_smmu_domain_finalise(domain, smmu); if (ret) smmu_domain->smmu = NULL; } else if (smmu_domain->smmu != smmu)