From patchwork Tue Aug 8 17:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13346508 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 93F52C001B0 for ; Tue, 8 Aug 2023 17:15:42 +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=x3NEgXn5FCSf6Cqkpt3j98JjqG6Tkajw6KObPoWlSPg=; b=ecBXOeHuuv2cu93rLDKvca1ubJ ctSQgnR71C5bV375q0JOuC8svicD5LBDeK6S51OQZ4Mw1c1str6X4ApSDkLuOlp/gJoMjYSI/agfy FcGoa6GoFHnACjNwU0ehxw8B14bMI31V+/2IkeRHxRV9iYzbPcjFJ4bAc8kxmvxAOR73S1a7P5/bf qQncIIenhnflViK5utXIXmxHbqAgJuqKW+ltjYyUYIv+bMfmfnIL444+Qo/pJ5pW/GsstLXBRXP2P Uj7allTcHFhwRE0Kz3TnOqLLD3rIrrDhHB+2uzUrV+028pWWRiCNLp72UP7IgfZfW4QDTI4eRojkw Aau5sLGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTQId-00365k-1r; Tue, 08 Aug 2023 17:15:15 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTQIb-003632-2M for linux-arm-kernel@lists.infradead.org; Tue, 08 Aug 2023 17:15:15 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d11f35a0d5cso6866007276.1 for ; Tue, 08 Aug 2023 10:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691514910; x=1692119710; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8kAnQzEdZvwUszc/Yra8uu5YltC92ywc9EvJ8VT09LQ=; b=oI/dqHd30VJau7uUvo843Y9Abtz75Eci2/yr/d2MWGmRYaIF60x7Uo8BVsyA5UL+iv GvrSQZ+d3MFahwdi8bnSc7+Cqzxr8iZVBy9h3GD7ChJD4fZ9psjBnVnh8ZaD2d4JxO86 x2QdqEYrZlm7bmKtB3dYzVaFtxnwPYQqpiREwDBE0j4CZ5Icp3P4hEdeYq+ZNurZstpC 4LjRrQtNw09UPeWPtfpPMjMyKmATqeiI0IDLi61Iu8/xVs1eqr7TtVKOIICwnVElUlp1 E7cCzyG/1JPWqrB1Rsnf61nL0pVh8Oajux04XTUcsEVJKFLrOxAD3BBXDRzWBxicH0AI kApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691514910; x=1692119710; 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=8kAnQzEdZvwUszc/Yra8uu5YltC92ywc9EvJ8VT09LQ=; b=SMCzTEiJXcwssEqeetKDHtsjS0Cn68C+KWk9YagXPLCebFApN5lbgGiWUbvF3VEvRD ZTEdPoas52O0TJ6bki7TSoLmUJvc35PslDsernJgHMxJnHxlvNdDs0FVwkTcn70bFwmG ymqXgO4Qw8sA9FM0GQ3AK/9c+rnRxYU+/cOgDUqoyQi6ksHIhdja5N3zbQx61SRCQKqt t8DzLs47A1l03Q8Y4anC0GgnEJQ1ybNB72ItDFmG2uZWnSngSrchae/pUV/uiYXxnDZI WLF6nHS9YU93S61YZmlUliy0lADJMQ7eUVygLBme0UUv/KxVq/Bvdr79HNT7ZGlJttot AKIA== X-Gm-Message-State: AOJu0YxDuTva6CfaBvMc01X4qyTJ6S9ngIWDku20JSSZTEt1lr1JoL+b Yh1kK8B9jVz0XQv4F5B9gGSB+aPeSUM7 X-Google-Smtp-Source: AGHT+IEMJeatprXvebM/DOZlLv0j3Dy4OuBMcAUr1GM1vtFLgnUQJaRUOVv2HdwNOFyJeYZpSyEmJg4bow4Z X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:986a:71d7:3b1e:ac1d]) (user=mshavit job=sendgmr) by 2002:a05:6902:1345:b0:d5d:6bfe:76d6 with SMTP id g5-20020a056902134500b00d5d6bfe76d6mr3195ybu.8.1691514909886; Tue, 08 Aug 2023 10:15:09 -0700 (PDT) Date: Wed, 9 Aug 2023 01:11:59 +0800 In-Reply-To: <20230808171446.2187795-1-mshavit@google.com> Mime-Version: 1.0 References: <20230808171446.2187795-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230809011204.v5.3.I875254464d044a8ce8b3a2ad6beb655a4a006456@changeid> Subject: [PATCH v5 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: will@kernel.org, robin.murphy@arm.com, nicolinc@nvidia.com, jgg@nvidia.com, jean-philippe@linaro.org, Michael Shavit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230808_101513_769453_88787839 X-CRM114-Status: GOOD ( 12.12 ) 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 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 ded613aedbb04..fe4b19c3b8dee 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->max_cds_bits = master->ssid_bits; max_contexts = 1 << cdcfg->max_cds_bits; if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB) || @@ -2107,7 +2109,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; @@ -2120,11 +2121,9 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, if (ret) goto out_unlock; - cd_table->max_cds_bits = 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;