From mboxrd@z Thu Jan 1 00:00:00 1970 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 2842EEE49A8 for ; Tue, 22 Aug 2023 09:41:21 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OZw3aSD+pgcAD2s3b9Xp4Sx8Gug14O+xxhmUqid56OM=; b=PKV3CYsDsZDWGk v6n9Sd3rYjTXs/m8k6Rc4RAxBDo6TiA+dPf3sIsNNrUQ5ZvqY0geqhWXivJYbYtB52huWwZt/K3vt 1jgukIMXVXcsHWRHSagI0/aRyzD23kGJPrfgg3okE8o3wDt8H4Hw1WwVnxur9QMh5csN8O/4xI2Az VmiMjY3zCl9bWRqTh6bXJ5iRk6vE7xPSL0nX4dQlURyWQ2kRa5lWA4YCmfeL2zRNFwXjk7e89dUXO qLaVYfuXqxqa0Lxq1cT+3niz0+oguBVHulDO2UWZ9jxORAb010ScDW9pF5LrdLtdKz44FALnOzoQY 0I9mqDIHXBeV+HKwsVBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYNsQ-00FYyy-0U; Tue, 22 Aug 2023 09:40:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYNsN-00FYy7-0X for linux-arm-kernel@lists.infradead.org; Tue, 22 Aug 2023 09:40:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AECE211FB; Tue, 22 Aug 2023 02:41:15 -0700 (PDT) Received: from [10.57.5.95] (unknown [10.57.5.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 84D073F64C; Tue, 22 Aug 2023 02:40:33 -0700 (PDT) Message-ID: <7e97b5a5-6be0-87a8-aaf7-89980b0a35d1@arm.com> Date: Tue, 22 Aug 2023 10:40:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH 2/3] iommu/arm-smmu-v3: Add an arm_smmu_tlb_inv_domain helper Content-Language: en-GB To: Nicolin Chen , will@kernel.org, jgg@nvidia.com Cc: joro@8bytes.org, jean-philippe@linaro.org, apopple@nvidia.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev References: <854e2b3f2d4f1b76f916fcfc288b34526d4d4162.1692693557.git.nicolinc@nvidia.com> From: Robin Murphy In-Reply-To: <854e2b3f2d4f1b76f916fcfc288b34526d4d4162.1692693557.git.nicolinc@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230822_024039_245047_28348B86 X-CRM114-Status: GOOD ( 19.45 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2023-08-22 09:45, Nicolin Chen wrote: > Move the part of per-asid or per-vmid invalidation command issuing into a > new helper function, which will be used in the following change. Why? This achieves nothing except make the code harder to follow and disconnect the rather important comment even further from the code it is significant to. It's not like we need a specific prototype to take a function pointer from, it's just another internal call - see arm_smmu_flush_iotlb_all() for instance. We know the cookie is an arm_smmu_domain pointer because we put it there, and converting it back from a void pointer is exactly the same *at* the function call boundary as immediately afterwards. Thanks, Robin. > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 +++++++++++++-------- > 1 file changed, 15 insertions(+), 9 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 9b0dc3505601..d6c647e1eb01 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -1854,12 +1854,24 @@ int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid, > return arm_smmu_cmdq_batch_submit(smmu_domain->smmu, &cmds); > } > > +static void arm_smmu_tlb_inv_domain(struct arm_smmu_domain *smmu_domain) > +{ > + struct arm_smmu_device *smmu = smmu_domain->smmu; > + struct arm_smmu_cmdq_ent cmd; > + > + if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { > + arm_smmu_tlb_inv_asid(smmu, smmu_domain->s1_cfg.cd.asid); > + } else { > + cmd.opcode = CMDQ_OP_TLBI_S12_VMALL; > + cmd.tlbi.vmid = smmu_domain->s2_cfg.vmid; > + arm_smmu_cmdq_issue_cmd_with_sync(smmu, &cmd); > + } > +} > + > /* IO_PGTABLE API */ > static void arm_smmu_tlb_inv_context(void *cookie) > { > struct arm_smmu_domain *smmu_domain = cookie; > - struct arm_smmu_device *smmu = smmu_domain->smmu; > - struct arm_smmu_cmdq_ent cmd; > > /* > * NOTE: when io-pgtable is in non-strict mode, we may get here with > @@ -1868,13 +1880,7 @@ static void arm_smmu_tlb_inv_context(void *cookie) > * insertion to guarantee those are observed before the TLBI. Do be > * careful, 007. > */ > - if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { > - arm_smmu_tlb_inv_asid(smmu, smmu_domain->s1_cfg.cd.asid); > - } else { > - cmd.opcode = CMDQ_OP_TLBI_S12_VMALL; > - cmd.tlbi.vmid = smmu_domain->s2_cfg.vmid; > - arm_smmu_cmdq_issue_cmd_with_sync(smmu, &cmd); > - } > + arm_smmu_tlb_inv_domain(smmu_domain); > arm_smmu_atc_inv_domain(smmu_domain, 0, 0, 0); > } > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel