Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1307832pxk; Sat, 12 Sep 2020 20:31:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwRfadvVT31K7KfpetQBhI8B/4epJucIUHEzuH7jzDoKqHjAUMHUt2Hjw0VE9j7+xPdKny X-Received: by 2002:a17:906:e24f:: with SMTP id gq15mr8614432ejb.395.1599967867891; Sat, 12 Sep 2020 20:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599967867; cv=none; d=google.com; s=arc-20160816; b=DIERSLPLD49nz2O2dmjKAYyUw+P/Jz8I6XgSW2GP+3oTPeOm5ZPPfZOpT80yseWNVL HYJR1ay9Nc5sSUTHHWA8hvyWrzu3GmBJNgWWBf7LIVgUOdVum19CMZq5cbn/unxVa/lB +Oj94fJFaHI6yauyBsJ1VGGA04cDhh8Kv1SvuvXiGLyFogkIFUCA+uWEP61hUTylKJx6 P7eYcVew1w0UMAUHAbAE1HJk2KYF9cY6oX9FYDIfCwX73UfuLaME43WeTAS1oTUj+OoR DrZPl/8iSc/3UrnS0udJk2jYPG7UWlZZlXPtWapys5ogrpnufgy4YNsI8QxlczJ4l5b0 J7TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Ke7lMIRXust3VuSv0nKgJkbwsX5Y5U3wXBvizA4PXrY=; b=TF/4tkaWUQYao7hqVdriJBBUKiCG6+cSgbnVzJiUe2QnpQTLsOxeUWv417KdkXnM3+ NneU+Mzm8UWKHGZc12KrkPBzgGMidBSryyu8sNjB+Muv2yYST+XVHob3qU6KB1N5Poyq vKCLOGl1AiMnYtA0NnCikW+4pEJlcV91+MPipVQxmUqUL/guxHFF7S2tLZVVq/ancZyB rv3Y/4GUzDE2X/ZJc0RM+jxPNf61sDAMFzkEYwrvMJW+HAuP4QGyBrgqcMrrzLRhuJcq 2lmbVErz6GMqueAGzfrWZdUbIh5lFFHXCgqQaHtbu3lxFJlrkMFZf1tptUQutTRci/ro Ld5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yyrNCTgA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si4762298edi.48.2020.09.12.20.30.32; Sat, 12 Sep 2020 20:31:07 -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; dkim=pass header.i=@linaro.org header.s=google header.b=yyrNCTgA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725918AbgIMD0H (ORCPT + 99 others); Sat, 12 Sep 2020 23:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgIMD0E (ORCPT ); Sat, 12 Sep 2020 23:26:04 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A8DC061574 for ; Sat, 12 Sep 2020 20:26:03 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id i17so13885659oig.10 for ; Sat, 12 Sep 2020 20:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ke7lMIRXust3VuSv0nKgJkbwsX5Y5U3wXBvizA4PXrY=; b=yyrNCTgAFp3sCepk225S6NTSjOCGVhzw4iRmePIaTzvjnZwKHF3PuOcLpxPadQ3vvq OkgdzrIYnZ4nWcncJEqM+FHOgG094D0K/+BioANbWip4mn832eoNK+dWcSxVvlYu2JYQ ZBoR0LJ5Lc+YxYqe8zvagnENnOCCUX+VMuZ3EJ/Wv0nOellILxqC31ZzAxjdYWLYyuxY FJY1jRg0jdevnILWK2NMHL1mgpgBv5HhDm1IJVSqYdh8oZlnDefvYn1k9H/ZY4rmCLvR 7kvI70mV4GYFUNiKigTpeSQCuhslkDyJfMhaJt0gQS/lx8H2tZDbm5I6KJbn9wj11oxS 8CWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ke7lMIRXust3VuSv0nKgJkbwsX5Y5U3wXBvizA4PXrY=; b=cnW/Z2KNahqRQNaf/BhNa+Diw6FyKDsjyVsOmlFd4vLDopI4RMAOWZbBo3C++9GvnB H8W01gJbqPM34OI0+CMpSHjbIqu+zZRyyQWVhNA2lmBxNTdrAPSiXDkYuqm90TLC9mMI wVJhmPPGC3qKgBqJuvuOo7EibCpHraKmuH+nNDNumEBnu4/qSuRrVwJDpxmHXonBQ5SU WflnbIs8blkM8JIT8idUYH/1nSz/G8n5qlFjMJ8DFr0nk3CYx/TR7/3vBJ/ueOOxmzTW vvjIlSKPIfC/kUB73CZsgf553hzO2XcUrL/sU1KPvkh3qhiqN14jpVrDAHOSY5BIcOMw RaIQ== X-Gm-Message-State: AOAM532ZsM+I3TVPy4Qgq7iSD8NgNEzQBytrEGWuj1CxB62A7AoYJxkE XbTrCiLK3z7HUK41Cc2l3KHIzw== X-Received: by 2002:aca:1006:: with SMTP id 6mr5092573oiq.2.1599967562993; Sat, 12 Sep 2020 20:26:02 -0700 (PDT) Received: from yoga ([2605:6000:e5cb:c100:8898:14ff:fe6d:34e]) by smtp.gmail.com with ESMTPSA id 9sm1207669ois.10.2020.09.12.20.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 20:26:02 -0700 (PDT) Date: Sat, 12 Sep 2020 22:25:59 -0500 From: Bjorn Andersson To: Robin Murphy Cc: Will Deacon , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Rob Clark , Sibi Sankar , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v3 6/8] iommu/arm-smmu: Add impl hook for inherit boot mappings Message-ID: <20200913032559.GT3715@yoga> References: <20200904155513.282067-1-bjorn.andersson@linaro.org> <20200904155513.282067-7-bjorn.andersson@linaro.org> <0bfcc8f7-d054-616b-834b-319461b1ecb9@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0bfcc8f7-d054-616b-834b-319461b1ecb9@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 11 Sep 12:13 CDT 2020, Robin Murphy wrote: > 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. I did this because as of 6a79a5a3842b ("iommu/arm-smmu: Call configuration impl hook before consuming features") we no longer have setup pgsize_bitmap as we hit cfg_probe, which means that I need to replicate this logic to set up the iommu_domain. If I avoid setting up an iommu_domain for the identity context, as you request in patch 8, this shouldn't be needed anymore. > If that can't work, I'm very curious as to what I've overlooked. > I believe that will work, I will rework the patches and try it out. Thanks, Bjorn > 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 > >