From patchwork Mon Jul 31 10:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13334293 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 90F70C001E0 for ; Mon, 31 Jul 2023 10:49:38 +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=DWzF1knaPKTMENBlDWEX9kMqHRL0x9rJXrDxj0Qx1BQ=; b=k9fixqcAcpyHRsww7Ar9HrUUE7 1MtLjw5UZEpCRBRvXhCaquu79x83sENHOym87FmOhS5RdMZ3dFIxWBpYwrZbwir4Y8sjWl9nwh5vw Mhmppd0SntLyfiBkm69n32UUtlXwfvnKSXFo6SfqOKavG5D7n/bmsNxREEmRmE9hMQ46nCwUs5+83 MRRnAHnOYhlqApoNlnFVVb0/MsdbOkHcIk1v45haFPUnKJpSthLv+djVAEfPwsUqrSyeP06eYxXme N7ACESgRL7hW9AaS7yBh9F6yHOsUc2M5O+0m51U8d+xbBhlcX00WjGEtL3FNSyfmdIBcurRIEGvBJ a9cP863g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQQSh-00F9OE-2P; Mon, 31 Jul 2023 10:49:15 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQQSO-00F9Dx-3B for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2023 10:48:58 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5847479b559so50737747b3.1 for ; Mon, 31 Jul 2023 03:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690800535; x=1691405335; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6LEwoPypxNg/0wwK9DSpnnqLrV8S3AoRDp+1fjKUE9c=; b=EEMFNUSXVHTC6HAOa38cmSdOEiaoD2jrNpOHT4VveZGabJGsF8dATyht8Xu/hVKbF6 yF/iFDQeMQ7/gWSYJLsfl+7c5oWtTZh4CfBNMmT/WxVunxHXK3tDqFjxNbgpcGTWmW+6 cCaTaHWSlh3Tx2Qr1H7elgc4IPaOX0m36Jh/tnctw8a3UvBC18Lue9/rCCUw7agpoWnn jucQMcbNR9YDAU9QQomc+FfMt3++7DCVfUkBTYzM86OAzAZaPJea2J7EHFIApn8iEbL9 HLW1iV8Q8HojjNdueabZhuwjVbL6Bl/q/sGb/wFWCKz7nO2mFW0tD5gwBxK+TJ1ofVJO fIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690800535; x=1691405335; 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=6LEwoPypxNg/0wwK9DSpnnqLrV8S3AoRDp+1fjKUE9c=; b=V715pNrGBya7WfhL+dsdYN434wzHpy9cLQGeMSBiWgT5+G8QYLEHigx0NVPoFm3hLH 25Q1JUZqP5B7EWEOQwRHEp9lvb+nx8rmBP4RhAc/uySzq7wAf3Tk9bIXLJ1m+RQxNiMr 9uzGHs/wcHBkDTvwk4fmf8EQR3z2DdGC8pltzPUmQ2pCAXqHffhjG6Q/8IWS2YjSFGCR HOgGs9bv3SKqGlPEMdXFoPxOYXeCyai6nnHUckkF0h9FDsguhb817IhMLxSwuqquBqpQ 6RCKjbEtAcN/fQt5WsyJtJ/GnBrXHBQMad2OsXQ29fTXBZtK07LghsF9apDIc6r8IL0B zipQ== X-Gm-Message-State: ABy/qLbxoblex6e1+e8rqfkNgP6lUAkGHbgTu/AqH6OnoCVnF7w8eP2j 2OFyPx0MyUL1ueKodiiX552ZPDYP63Ee X-Google-Smtp-Source: APBJJlGFT8JRbNN2pllj+H+26z9eiMA1wqXAGjOqgKNZgKbHNZEnTJSje3k6Z2LOS2azPtan7cioZd2AbX0T X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:affc:ad1d:5cbb:3c6a]) (user=mshavit job=sendgmr) by 2002:a81:b703:0:b0:584:41a6:6cd8 with SMTP id v3-20020a81b703000000b0058441a66cd8mr66785ywh.8.1690800535642; Mon, 31 Jul 2023 03:48:55 -0700 (PDT) Date: Mon, 31 Jul 2023 18:48:13 +0800 In-Reply-To: <20230731104833.800114-1-mshavit@google.com> Mime-Version: 1.0 References: <20230731104833.800114-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230731184817.v2.3.I875254464d044a8ce8b3a2ad6beb655a4a006456@changeid> Subject: [PATCH v2 3/8] 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-20230731_034857_057765_E196E270 X-CRM114-Status: GOOD ( 12.40 ) 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. Signed-off-by: Michael Shavit Reviewed-by: Jason Gunthorpe --- (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 8cf4987dd9ec7..8a286e3838d70 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 *cdcfg = &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; - cdcfg->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;