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: 13356869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E3CAC3DA58 for ; Thu, 17 Aug 2023 18:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=t0bNUSCLEdfsdgOvhdy2cmDO6ZEq+/wZMKkHO8GAGY4=; b=rrEg+HeTmVSTWMZQ6o6CsSiw9K JBAaUI2I33xOodGuFXSW4cxuNVW1+GQEApAM8KiFGT/ywvOttTwZXrTRGT6I2WBzFDtdRK6DId3uF 5BG6Av9GEv3t8mndoujdY74Jemh8tdwUYBPoH6xIV6891kpxFDZtbAylP2bDewJHnWKjh+vrXqeLD HRWi5SH7iQYJ76f/4HtCOD72SJCFQhtOCJeZx6ZuyCtIQsE0NK3MkAow71MR6rzh5N+I7rtz/QJr+ vueQ/lordkL+H36JP/X8rhy1fY1JQ9GG8TR9ocq9gHOnydeA/1VplbyJ9PWbvencATZwnjHnxh7iQ xmJiio/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWhcx-006xXf-2g; Thu, 17 Aug 2023 18:21:47 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWhcj-006xR2-0v for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2023 18:21:35 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d630af4038fso193064276.0 for ; Thu, 17 Aug 2023 11:21:32 -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=T7m/l1TRWuWZr7SMlQuP/L1/LGM4X+eQhuYk/mO9DrG1PUPHyBJM1oaFzj8zRu+xWk WjqAEdEpoNTmEU8nE0LHK+3J3Qof3tU6yJOpCz3Uihl96FymXx+JuLaXsXU9cTg9IuMw 3wrLDMoHlhs6qEM7eEVqVq2Yru0QLi68qaNtcF5bHh84f7TMebZpMRC51kIYtjV57kRz idY0torTuJhn8LvBqoruEnmD0EREF0s0CnCSDsuWclGjaLimelBkHGvS9Ay3vAzrMHgH uCT2uorSbHU/qw5z8Be3ye4x31FJnxN+RMn46Z8aKW1elB1k/Z+TTKqCRkPzwc7eP7DP fO8w== X-Gm-Message-State: AOJu0YxDyA4TOwa5REO/Z+/3zeFahhFHsLB95ORfNcib9kE2u0xem9+5 PddWJhi9IKUZjLwg0LE5+V61ijT2Gdno X-Google-Smtp-Source: AGHT+IGbdbNVPcRg1sbArh45fkt6h+fxSGJJucKE8ciso+2BfxjvcUKG1RiUX+bGIUHNJJUh65fH4VC/apu1 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230817_112133_339017_12BF7948 X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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)