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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8AE6C43461 for ; Sun, 13 Sep 2020 03:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CE3E207EA for ; Sun, 13 Sep 2020 03:26:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yyrNCTgA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbgIMD0G (ORCPT ); Sat, 12 Sep 2020 23:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbgIMD0E (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 3D804C061573 for ; Sat, 12 Sep 2020 20:26:03 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id c13so13882737oiy.6 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=klHvGkuhaXKtzzW5VZp851gPRSV+QrqSW0LdHs0ghhim6cqJs+/8NnC+TvCi6puFBg enw1fiIY2Ew9EOi2nwK+T6/FxwtyUNxeSs4vCbScMZ+gtKcuW8+DDTD71+o0QboXDjd1 LNaS5E0rUvDuRb8TinvugygZTchCEBWgSWIRywHJbwFf9aGlApZDXkJkMKpTQr3wyfE+ yoRocYTuCXz4BTiJc3/ImGcAyByrglmC2g1tJIeg7rI2dg++u8XwHgANWUfJqwu5r7s1 +THlULWhaw7wlyRDNgCeiwOFv2I5A9S9xKt6YO/uXeIFT2sg3RUKSjF/Sqqw2lB9ExQU QNkA== X-Gm-Message-State: AOAM531iLTpoWe6cYkaKZt/g7eA5czOnL5LDuw3vSo9x7SEkK5jkGmlR AHWJMH3ApA0n6bHTcl04kMqJ/A== X-Google-Smtp-Source: ABdhPJxuAIm2+/oMuWoP3Xg/emHDDPJVX7MIdtBknMrXrH/r4UieHbwSGIT61sNebSjEFvwanaMmUg== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 > > 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 X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06C66C433E2 for ; Sun, 13 Sep 2020 03:26:10 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8EE7C207EA for ; Sun, 13 Sep 2020 03:26:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yyrNCTgA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EE7C207EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 266F587098; Sun, 13 Sep 2020 03:26:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oz14dRJCVe0M; Sun, 13 Sep 2020 03:26:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 5F9F28707F; Sun, 13 Sep 2020 03:26:08 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4329DC0859; Sun, 13 Sep 2020 03:26:08 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 29141C0051 for ; Sun, 13 Sep 2020 03:26:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0DFE786C80 for ; Sun, 13 Sep 2020 03:26:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tOeXYkSzXYRI for ; Sun, 13 Sep 2020 03:26:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id EB8D986CB4 for ; Sun, 13 Sep 2020 03:26:03 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id y6so13897849oie.5 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=LO84mvDIHX6OD8IIzkmM/E/Nsy0AVFaJoXwhAHJ8HGT3ES1ejWIDp0y+kAVyx0VEdU P1+kwRU9zAcRy55oP2D5vcc8BOI/JfvhZ2aEyTbnwNrhEXbZLfiHWswx9JWOKgYw468L rdeEGJrREyMXHCl1zexJcKMz8Y6/QcuGj0HIcGUV1tnP9arvopRqb6F1cMPnhtWgqKPN jtm5hM7XxmnRodHO+6/N05ttlzW+jNuVFRZZZEB1L/PYJqnxOM+ZG/jyNDNYKC38ePww s2NqWV/lnsYwqgcD8pdtRYd525P+j+4wXPBJMpjkL5neffTcCQnsBbDJpb1IfF0seJEm DOpA== X-Gm-Message-State: AOAM531XaRiwohXAwJdug8SdR8inF7tHez7FtC2z92xqMP5JINTSyooo fr9GbYJDlneC76TyDu0DB4OXBg== X-Google-Smtp-Source: ABdhPJxuAIm2+/oMuWoP3Xg/emHDDPJVX7MIdtBknMrXrH/r4UieHbwSGIT61sNebSjEFvwanaMmUg== 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 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-Disposition: inline In-Reply-To: <0bfcc8f7-d054-616b-834b-319461b1ecb9@arm.com> Cc: Rob Clark , linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Sibi Sankar , Will Deacon , linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 > > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D31BC43461 for ; Sun, 13 Sep 2020 03:27:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ACD7A20732 for ; Sun, 13 Sep 2020 03:27:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="z0F9AKxY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yyrNCTgA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACD7A20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sLZSAGqke8NsubippN1rZOby8EMn9WsjAAx9/UY92tg=; b=z0F9AKxYbSyW/PoKWKAcr5xay oZ/lD+3oYRnhUx/zCQS8wWYrvQRAYl9VcgQ0bYwVbZdXrApBdinIZZIKk2l2+Ivv1GjeutZfssPfy 32mr3OWxATf/WYATYxlXrtr4/ZIb7r+Bg7nkiBbkUJ3vCmbDTlAiBIt1ZYleMs9QeGrCUGRJiYBWR C+/9EpObITurQaZm1Az2CWIdorRDxnvnVHH1KAYVdM0yC+qTrGwX6dRMaFAk+2dZRlRk7BR3bAcsg 8B+FAx7B3DWOAcUUecoGEh8OrCyLvtfotr9PYaC19OPxJccK1nEZudc7CvvLhaL9UWpyXRY4Mlgd2 mhB/yB5Fw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHIeX-0007bN-Pt; Sun, 13 Sep 2020 03:26:09 +0000 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHIeT-0007ar-83 for linux-arm-kernel@lists.infradead.org; Sun, 13 Sep 2020 03:26:08 +0000 Received: by mail-oi1-x242.google.com with SMTP id t76so13881471oif.7 for ; Sat, 12 Sep 2020 20:26:04 -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=Z8GFoHG3eH8+829dhv0ZKq4Odg4kCjq5RDf4AA0eBnO1NWogakQMbx8oNRdnAVnF4Q 8hhaLyKT5nJnZIbVqK7pjAz1xa+dXJqYQ0axhZtaqZprxkBSXQpBH4/s75O6MF4fLQtc 8qGHQs2IZvF1ylowmNsNBUoy2RXwg+EncjHwzCv8yYqCUFSZ2oaCVPSmtUHT/oROtjoj X1uaFYhsmx7hFG04Fi6xOa/xdoP+q3ugwKFW2iCfZHDvc7/FmglC+8IvnBxx5yLhcp34 AvO4MosZRyOh5wLoaCL3+Msz7/mAYvzB3EvKbcRCxY4P3rVCJ5MnGKjii/gaGEgFDSGK S3Aw== X-Gm-Message-State: AOAM533gzQrnC5gc5N+Se2udFfG96VwX5f1ZubbMmF0wNQxApKxqwmdc smczTlEudEIPDaCzsGLtv7eSi/sLMUuJ6bvr X-Google-Smtp-Source: ABdhPJxuAIm2+/oMuWoP3Xg/emHDDPJVX7MIdtBknMrXrH/r4UieHbwSGIT61sNebSjEFvwanaMmUg== 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 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-Disposition: inline In-Reply-To: <0bfcc8f7-d054-616b-834b-319461b1ecb9@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200912_232605_615941_2A2876DB X-CRM114-Status: GOOD ( 30.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Sai Prakash Ranjan , linux-arm-msm@vger.kernel.org, Joerg Roedel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Jordan Crouse , Sibi Sankar , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel