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: 13387063 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 836EAEE645C for ; Fri, 15 Sep 2023 13:21:44 +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=LTlCUy9Ae5sJzJx/jmPfnfX/CtKRiccEYTtsMQ9Rj9E=; b=iYtIIHkpUpX2OJ/tOQcUk6W8/B apq65dbJFtvf7hp+0WWnTAPi+wz0yZb8GtCnfc1YoX+fbQxhBVD6UTaic0GMvrzUO9rILaxQqfVVi rTiXQ7dML/7wtvYnq6kexd41mJ/4f+4f2xe7Cw7gBu7LB+dCod+I2KSOZWPP3KfC8CCRzpNm6Sras juS6MflQApW5y5E0YMSC1VNe5IFjnb9zOa9DrSkheOIW3YGdfdT6P2a33Si0NeLtNgnZE0j3YE+26 WBdWHFeMC+rZC9cX5HJaVrr6YyYtZEidbyhXf9O12ArWTshImXm0goZs+jaI/TF4L3MU7ZDE0DSx1 vzfJ6OnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qh8l3-00AnZe-2K; Fri, 15 Sep 2023 13:21:17 +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 1qh8ky-00AnWd-1k for linux-arm-kernel@lists.infradead.org; Fri, 15 Sep 2023 13:21:13 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-597f461adc5so27929887b3.1 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=lists.infradead.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=Au7MqKNF+sfUMg88sntgUijuezZTxPYrSTT8PZLVpKYgrERbIkLScjPuGNO7NidraT wb7QiQtyRCJU1CDLAFbPklgDPFPXTY657hHKJtZXP+IZ59AST1GIx5vkYYt3luV627Sr fmFeX2w7XMn6JrSnebzw5AfhCm0/rOhvDzcs2kxFw/tmAXja5t0rP4LMGN+5lvpNDpO4 aQfE8qW1Jfq0i57/a37W22kZ0jjGc7TXR2NVDv5ctwamaJQqbKOZ9nyZohO35Evjwf0s Bjr8u/AC73kJFsMu2iPngNL68c7vHC40D1ntgqZ9yv18/etlWi7ih0F52bCS+hKheiUo R+7Q== 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=jruj2mMQ89vHqK2O5L+Ua3R5sZPcClDnUqMaAzroHE6cZSLgQ6H7PwGe7JoShcrxO+ 8WWPv84gKYeicqa0Zt1wqpHm+nkGDWd4BX65XPPadmFh5sSeDo0p1xKkeO+m9z3L6guQ CUSu8ohyZCyMh/DWnqMl8Rh1L+ZQmVIQsyfL/19ZUCRUcNhMrWTWo1EdByYdcF1SSx4w Z8hbDPRSK/7yBWYWiscUP5I/DA0QM8JQOg+IqZyhW1s34bc8FaApbrXlaugmLi35TlT0 +mJz5rv2tRhwDt3KcLLY0cAw4XK4LmMEXMw6mI4XJx+mDoUTNyiilgsV6T1ur2GpnMR3 Ab4w== X-Gm-Message-State: AOJu0YxTmVBkgN92bNP4Gm7KoTZcP0Fi3TIZsD8BLfzpbr1bxdP0m7qZ ZHezaV8bosNmnmfd7JeQwENjEl90wCd5 X-Google-Smtp-Source: AGHT+IE80sO205KDJEKcNpKH17hvdhH3ildl+E6LHEuDB+h1xgVjg474K5hdxY3HF3T1uQfxYdpv6g4XFWRm 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_062112_578767_5799B211 X-CRM114-Status: GOOD ( 12.26 ) 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 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;