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 03B22C4829E for ; Thu, 15 Feb 2024 19:02:20 +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=IhbTfPehsdTY7oHSXwmB0R03zK2UJf7v2As1SWCCMQU=; b=O3qGBC7Slh/lZr RbaFu56hjib9hyv0MEQePh17QRb9d1NchVda25aqwR1VCmqkgwaaeR4K6aZvBmFx8Onb5JRdqk5JM 6KsTcIqx3U5Q+U87krIKGSZtZJtwVjoWTf61Ngg5NeKs7d0hl1ZB9QVCKSZmX1K4cfi8S1+Sai8vR swRZVckKrEjSBXTLrLDY1ciAqqUlOdkEXh1G6B8r+IvhT1qkvv1RH+e0OTfdYoee8AMJFY/jatDk5 W40AHuod2nH0XsSMm4S5pCR/o8YRCWXjTz7r/pRacvaqGD7e5/6gHt1Hnqi+ulc3oKBXGBlvXd47z aBKFdhVQ2JDJWCB4wfVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ragzp-0000000HRMc-2z1U; Thu, 15 Feb 2024 19:02:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ragzm-0000000HRLy-3gV6 for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2024 19:02:08 +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 81AE61FB; Thu, 15 Feb 2024 11:02:43 -0800 (PST) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A46043F762; Thu, 15 Feb 2024 11:02:00 -0800 (PST) Message-ID: Date: Thu, 15 Feb 2024 19:01:59 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 03/17] iommu/arm-smmu-v3: Move arm_smmu_rmr_install_bypass_ste() Content-Language: en-GB To: Mostafa Saleh , Jason Gunthorpe Cc: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Will Deacon , Lu Baolu , Jean-Philippe Brucker , Joerg Roedel , Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum , Zhangfei Gao References: <0-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> <3-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> From: Robin Murphy In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_110207_046346_7005873A X-CRM114-Status: GOOD ( 20.03 ) 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 13/02/2024 3:37 pm, Mostafa Saleh wrote: > Hi Jason, > > On Tue, Feb 06, 2024 at 11:12:40AM -0400, Jason Gunthorpe wrote: >> Logically arm_smmu_init_strtab() is the function that allocates and >> populates the stream table with the initial value of the STEs. After this >> function returns the stream table should be fully ready. >> >> arm_smmu_rmr_install_bypass_ste() adjusts the initial stream table to force >> any SIDs that the FW says have IOMMU_RESV_DIRECT to use bypass. This >> ensures there is no disruption to the identity mapping during boot. >> >> Put arm_smmu_rmr_install_bypass_ste() into arm_smmu_init_strtab(), it >> already executes immediately after arm_smmu_init_strtab(). >> >> No functional change intended. > > I think arm_smmu_init_strtab is quite low level to abstract FW configuration in it. > For example in KVM[1] we'd re-use a big part of this driver and rely on similar > low-level functions. But no strong opinion. Right, the fact that RMR handling is currently based on bypass STEs is an implementation detail; if we ever get round to doing the strict version with full-on temporary pagetables, that would obviously not belong in init_strtab, thus I would prefer to leave the "handle RMRs" step in its appropriate place in the higher-level flow regardless of how it happens to be named and implemented today. Thanks, Robin. > > [1] https://lore.kernel.org/kvmarm/20230201125328.2186498-1-jean-philippe@linaro.org/ > > > Thanks, > Mostafa > >> Tested-by: Shameer Kolothum >> Tested-by: Nicolin Chen >> Tested-by: Moritz Fischer >> Signed-off-by: Jason Gunthorpe >> --- >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 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 6123e5ad95822c..2ab36dcf7c61f5 100644 >> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >> @@ -101,6 +101,8 @@ static struct arm_smmu_option_prop arm_smmu_options[] = { >> { 0, NULL}, >> }; >> >> +static void arm_smmu_rmr_install_bypass_ste(struct arm_smmu_device *smmu); >> + >> static void parse_driver_options(struct arm_smmu_device *smmu) >> { >> int i = 0; >> @@ -3256,6 +3258,7 @@ static int arm_smmu_init_strtab_linear(struct arm_smmu_device *smmu) >> cfg->strtab_base_cfg = reg; >> >> arm_smmu_init_bypass_stes(strtab, cfg->num_l1_ents); >> + >> return 0; >> } >> >> @@ -3279,6 +3282,8 @@ static int arm_smmu_init_strtab(struct arm_smmu_device *smmu) >> >> ida_init(&smmu->vmid_map); >> >> + /* Check for RMRs and install bypass STEs if any */ >> + arm_smmu_rmr_install_bypass_ste(smmu); >> return 0; >> } >> >> @@ -4073,9 +4078,6 @@ static int arm_smmu_device_probe(struct platform_device *pdev) >> /* Record our private device structure */ >> platform_set_drvdata(pdev, smmu); >> >> - /* Check for RMRs and install bypass STEs if any */ >> - arm_smmu_rmr_install_bypass_ste(smmu); >> - >> /* Reset the device */ >> ret = arm_smmu_device_reset(smmu, bypass); >> if (ret) >> -- >> 2.43.0 >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel