Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp418317pxk; Fri, 11 Sep 2020 10:19:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnuWEJ5plWdYbqQN37RQlmn3YC0wxs4zwO4mfAS46MiUzktMOnfVyOhuT+qRrpFp+WH341 X-Received: by 2002:a17:906:d8cd:: with SMTP id re13mr2950159ejb.140.1599844769212; Fri, 11 Sep 2020 10:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599844769; cv=none; d=google.com; s=arc-20160816; b=yXQaNoznRXs8brcPMQPfe0I+oYrXJdtoxbM8Kx2Mln43AyIOAurXhAZDiPRLOVN/os C4PDRB+C3IzkMhKvltRvPTH19hwcGVFkg64lQYDSuhwWXI8blw9SlQAiWRBN2/KKt1sx BnfQiRDWtt7XlkSNQyDqtdTc1ElpPiioBqLBwOzC7IaFpH+SGBcxBQFaywrZsawV0ZKq Z6ODa61NThBlGhTDxvQ9B/R3FS7S4aByQ5L9lqpHUZP3EjDlbsywbixRWu+4UT+5I1Nr Xm3y6W93hw7twH6Wrf2oJVkiOrq26qCkdDMipSLXFnv5E5p+0waxAXUytU45/5d6AaAI qlag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=GLODs+Oc9jZ9UJdRN50zH+I7DVzbdkq76GlJYRxybeo=; b=hKOZsUndKUxTSmOFOrS+wILCxvtvN1atubeNj9hFLLNTpFcI8k5XF6ae0zn5h1PexT h54G0ucqAhtYrZgWCgjUB2O3xiQUc+0YmhQxDj8qt25nEZ+RsA+2c4rRFcwELasiFtY0 5kd30twgvzAgRn9xEhghtQ5bROyAZDPk6FjPHZhT6yjKdM388xWXIfAAzuI4wZHYGVTH VffNeyP9IMRhsilZYDApUzGIZlxT2/C2BTK1juwN01vanaNQ3Ev7mIochhzyx4/8IHFF 82HWVwmWWxKtqVe1RtblOBFIgMFLea+3y2bKvmVvjG7hwGu3NzvgB9eaZpnHnqhNBkZ7 AscQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si1795034edl.504.2020.09.11.10.19.05; Fri, 11 Sep 2020 10:19:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbgIKRQ3 (ORCPT + 99 others); Fri, 11 Sep 2020 13:16:29 -0400 Received: from foss.arm.com ([217.140.110.172]:39914 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbgIKRNN (ORCPT ); Fri, 11 Sep 2020 13:13:13 -0400 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 80D80106F; Fri, 11 Sep 2020 10:13:10 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C6733F68F; Fri, 11 Sep 2020 10:13:06 -0700 (PDT) Subject: Re: [PATCH v3 6/8] iommu/arm-smmu: Add impl hook for inherit boot mappings To: Bjorn Andersson , Will Deacon , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Rob Clark Cc: Sibi Sankar , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20200904155513.282067-1-bjorn.andersson@linaro.org> <20200904155513.282067-7-bjorn.andersson@linaro.org> From: Robin Murphy Message-ID: <0bfcc8f7-d054-616b-834b-319461b1ecb9@arm.com> Date: Fri, 11 Sep 2020 18:13:01 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904155513.282067-7-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-09-04 16:55, Bjorn Andersson wrote: > Add a new operation to allow platform implementations to inherit any > stream mappings from the boot loader. Is there a reason we need an explicit step for this? The aim of the cfg_probe hook is that the SMMU software state should all be set up by then, and you can mess about with it however you like before arm_smmu_reset() actually commits anything to hardware. I would have thought you could permanently steal a context bank, configure it as your bypass hole, read out the previous SME configuration and tweak smmu->smrs and smmu->s2crs appropriately all together "invisibly" at that point. If that can't work, I'm very curious as to what I've overlooked. Robin. > Signed-off-by: Bjorn Andersson > --- > > Changes since v2: > - New patch/interface > > drivers/iommu/arm/arm-smmu/arm-smmu.c | 11 ++++++----- > drivers/iommu/arm/arm-smmu/arm-smmu.h | 6 ++++++ > 2 files changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index eb5c6ca5c138..4c4d302cd747 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -85,11 +85,6 @@ static inline void arm_smmu_rpm_put(struct arm_smmu_device *smmu) > pm_runtime_put_autosuspend(smmu->dev); > } > > -static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) > -{ > - return container_of(dom, struct arm_smmu_domain, domain); > -} > - > static struct platform_driver arm_smmu_driver; > static struct iommu_ops arm_smmu_ops; > > @@ -2188,6 +2183,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev) > if (err) > return err; > > + if (smmu->impl->inherit_mappings) { > + err = smmu->impl->inherit_mappings(smmu); > + if (err) > + return err; > + } > + > if (smmu->version == ARM_SMMU_V2) { > if (smmu->num_context_banks > smmu->num_context_irqs) { > dev_err(dev, > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h > index 235d9a3a6ab6..f58164976e74 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h > @@ -378,6 +378,11 @@ struct arm_smmu_domain { > struct iommu_domain domain; > }; > > +static inline struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) > +{ > + return container_of(dom, struct arm_smmu_domain, domain); > +} > + > struct arm_smmu_master_cfg { > struct arm_smmu_device *smmu; > s16 smendx[]; > @@ -442,6 +447,7 @@ struct arm_smmu_impl { > int (*alloc_context_bank)(struct arm_smmu_domain *smmu_domain, > struct arm_smmu_device *smmu, > struct device *dev, int start); > + int (*inherit_mappings)(struct arm_smmu_device *smmu); > }; > > #define INVALID_SMENDX -1 >