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 27393C433DF for ; Mon, 19 Oct 2020 15:37:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B79C522269 for ; Mon, 19 Oct 2020 15:37:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="C6WGncCy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730090AbgJSPhG (ORCPT ); Mon, 19 Oct 2020 11:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730059AbgJSPhF (ORCPT ); Mon, 19 Oct 2020 11:37:05 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BB1C0613CE for ; Mon, 19 Oct 2020 08:37:05 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id t15so33919otk.0 for ; Mon, 19 Oct 2020 08:37:05 -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=ZuObq9whWGDMmuO49RORrwrhqdb/dKbIiBCbbe3MZ+8=; b=C6WGncCyg42oqfIwbZX16QroJD8lscb0ArhpyKgf4GkpPaB4D7iGfaU9Bzj0g6qSis 0372FjoZBSTHj262jqlLl96tMRrEQlDhd2XZt52kuE8stnuNjDOnmewwjwBBcOHHu+Gy 0Q8lHEIs6Te5T37TFUENmQIe6g9VQHWikMFvW0WU2M/i5mk5JwTme3rLDmv9kr611/Ry lPruuQAiILKYVUYEs06XzhPcbaQCdS70pbv4o2s4uqjv+zjseP3FhCkf3c4r0mxiv063 wam1WtZWQLuxojz+ymhE1L3ftMqDYk7NBmwRXcQMfEA/J0Cwtjc7XlzQYw2dUupN2J4t H0Yg== 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=ZuObq9whWGDMmuO49RORrwrhqdb/dKbIiBCbbe3MZ+8=; b=YfRvxeocMrNv8SjSSjMGf2AjuOWB6+FEUWbwBcg2Sml9mxrF5FhrQL9F+MGdR/Up22 w9l4lXW5O9ofn3eDF0vqomVN1+WB0AaN5uybRE+EqILo0fZr1NywVclPKP24rG0PtC5i eQKewFedS7IKreGN7Qcd9bawtKCJEmdRnRGG4R7p045U3A1n8IWFm16qS1mfshy2uT4A 7dSOTt7GE+qwmrkUXxXVgaQpEGrf8Jy1aJedq2y3WbpWVOOVdZGcMu4AcmZGNZ5EqDY4 3JWHFguuzC0x7PW05e9kL72MA/K3TKksboAw+mICsQtiXo7FPpuTVnfWMwVcx+hoL/AN IPmQ== X-Gm-Message-State: AOAM531Csa51O+MQ2PW4dgRFQhRDxDKItDd7NhsN98mzIIixA3gzEX0L qMoqxI4QRUm1rxZit+xH0ZrDGg== X-Google-Smtp-Source: ABdhPJxyQj0BxuHZkdFy97PqND3qA9PIazxUOwIJ6MKfl9YWhfxFCeAHoSjERQkg821O8disXAds2w== X-Received: by 2002:a9d:6c8a:: with SMTP id c10mr384950otr.293.1603121825018; Mon, 19 Oct 2020 08:37:05 -0700 (PDT) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id p21sm3497994oto.21.2020.10.19.08.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:37:04 -0700 (PDT) Date: Mon, 19 Oct 2020 10:31:59 -0500 From: Bjorn Andersson To: Robin Murphy Cc: Will Deacon , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Thierry Reding , Rob Clark , 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 v4 2/3] iommu/arm-smmu-qcom: Read back stream mappings Message-ID: <20201019153159.GC6705@builder.lan> References: <20201017043907.2656013-1-bjorn.andersson@linaro.org> <20201017043907.2656013-3-bjorn.andersson@linaro.org> <5eeecd0e-e3f3-f805-12d5-633284a29074@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5eeecd0e-e3f3-f805-12d5-633284a29074@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Mon 19 Oct 09:03 CDT 2020, Robin Murphy wrote: > On 2020-10-17 05:39, Bjorn Andersson wrote: > > The Qualcomm boot loader configures stream mapping for the peripherals > > that it accesses and in particular it sets up the stream mapping for the > > display controller to be allowed to scan out a splash screen or EFI > > framebuffer. > > > > Read back the stream mappings during initialization and make the > > arm-smmu driver maintain the streams in bypass mode. > > > > Signed-off-by: Bjorn Andersson > > --- > > > > Changes since v3: > > - Extracted from different patch in v3. > > - Now configures the stream as BYPASS, rather than translate, which should work > > for platforms with working S2CR handling as well. > > > > drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 24 ++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > index be4318044f96..0089048342dd 100644 > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > @@ -23,6 +23,29 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = { > > { } > > }; > > +static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) > > +{ > > + u32 smr; > > + int i; > > + > > + for (i = 0; i < smmu->num_mapping_groups; i++) { > > + smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); > > + > > + if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) { > > + smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); > > + smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); > > + smmu->smrs[i].valid = true; > > + > > + smmu->s2crs[i].type = S2CR_TYPE_BYPASS; > > + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; > > + smmu->s2crs[i].cbndx = 0xff; > > + smmu->s2crs[i].count++; > > FWIW I don't think you actually need to adjust the count here - the SMR > being valid should already prevent the whole SME from being reassigned until > the display probes, at which point it should "take over" the SMR based on > matching values and claim the "initial" refcount. After that you're back > into the standard flow. It might be a little unintuitive to have something > in a valid but "unused" state, but arguably it's entirely accurate in terms > of the software abstraction here. > > Otherwise, you end up making boot-time SMRs - so potentially all SMRs after > a kexec - effectively immutable, since even after Linux has taken control of > the whole system such that they *could* be reassigned safely, there's still > this undroppable refcount hanging around preventing it. > I did increment the count here to make sure the stream mapping do survive a probe deferral of the display controller (which is rather common when you have some bridge chip hanging off it). But after digging through the code further I've convinced myself that the sme won't be freed while the device is pending probe deferral. So I will drop this. > That said, for a mobile SoC use-case if you have enough SMRs for all your > stream IDs and don't have any kind of device hotplug, that restriction > shouldn't make much difference in practice, so I'm not too concerned either > way. Otherwise this is as nice and tidy as I'd hoped :) I agree, I'm quite happy with where we are now! Thanks, Bjorn > > Robin. > > > + } > > + } > > + > > + return 0; > > +} > > + > > static int qcom_smmu_def_domain_type(struct device *dev) > > { > > const struct of_device_id *match = > > @@ -61,6 +84,7 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) > > } > > static const struct arm_smmu_impl qcom_smmu_impl = { > > + .cfg_probe = qcom_smmu_cfg_probe, > > .def_domain_type = qcom_smmu_def_domain_type, > > .reset = qcom_smmu500_reset, > > }; > > 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 BA35AC433E7 for ; Mon, 19 Oct 2020 15:37:10 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 2486422260 for ; Mon, 19 Oct 2020 15:37:10 +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="C6WGncCy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2486422260 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 silver.osuosl.org (Postfix) with ESMTP id AFF392D946; Mon, 19 Oct 2020 15:37:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7dCJhByoGR1I; Mon, 19 Oct 2020 15:37:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id D2C01203AA; Mon, 19 Oct 2020 15:37:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BAE61C0052; Mon, 19 Oct 2020 15:37:07 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0A001C0051 for ; Mon, 19 Oct 2020 15:37:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E483E86E34 for ; Mon, 19 Oct 2020 15:37: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 u-rP8tB+tNHn for ; Mon, 19 Oct 2020 15:37:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 0519786CE1 for ; Mon, 19 Oct 2020 15:37:05 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id e20so10817053otj.11 for ; Mon, 19 Oct 2020 08:37:05 -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=ZuObq9whWGDMmuO49RORrwrhqdb/dKbIiBCbbe3MZ+8=; b=C6WGncCyg42oqfIwbZX16QroJD8lscb0ArhpyKgf4GkpPaB4D7iGfaU9Bzj0g6qSis 0372FjoZBSTHj262jqlLl96tMRrEQlDhd2XZt52kuE8stnuNjDOnmewwjwBBcOHHu+Gy 0Q8lHEIs6Te5T37TFUENmQIe6g9VQHWikMFvW0WU2M/i5mk5JwTme3rLDmv9kr611/Ry lPruuQAiILKYVUYEs06XzhPcbaQCdS70pbv4o2s4uqjv+zjseP3FhCkf3c4r0mxiv063 wam1WtZWQLuxojz+ymhE1L3ftMqDYk7NBmwRXcQMfEA/J0Cwtjc7XlzQYw2dUupN2J4t H0Yg== 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=ZuObq9whWGDMmuO49RORrwrhqdb/dKbIiBCbbe3MZ+8=; b=OnI04ITzcX0vBRiELqyK1TyMI5UmkA2jFW9NJ/uBR4pUP6kAwcjzRk7iCmYmc3Rz5J 8orVVRbgNMkymlLc5iPZoknuH0A3c/KMOaEUQk5NQvHq77YC9BB+2lQarEtl0ZyXnqEK 90SWweXWRhmuutjLkzrp4/64MyjOFYlVsXl+gS4/zx8rOb3bd+w2p1QIMgWDCvtzp+MQ nPmthsPfzzHtuxzJQvriCldPv7jMLW4w3JM7xdKGYr2QxQxk6Kc32ybYtxW+mOxtN0aw k9SLvpIFtwziB5PnKRf3TDFF4f7YAkLpw5z4R8hZ5JEHWwBXb7DNvC7H7OchXh4TkciR lKgA== X-Gm-Message-State: AOAM531/PImUj+ZDRC8QS7ghBtdZgYT4Q1TJ/8WRm985qHIaSmhSxU7u OxMuR1hLLopszacwIJDv91NJ7Q== X-Google-Smtp-Source: ABdhPJxyQj0BxuHZkdFy97PqND3qA9PIazxUOwIJ6MKfl9YWhfxFCeAHoSjERQkg821O8disXAds2w== X-Received: by 2002:a9d:6c8a:: with SMTP id c10mr384950otr.293.1603121825018; Mon, 19 Oct 2020 08:37:05 -0700 (PDT) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id p21sm3497994oto.21.2020.10.19.08.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:37:04 -0700 (PDT) Date: Mon, 19 Oct 2020 10:31:59 -0500 From: Bjorn Andersson To: Robin Murphy Subject: Re: [PATCH v4 2/3] iommu/arm-smmu-qcom: Read back stream mappings Message-ID: <20201019153159.GC6705@builder.lan> References: <20201017043907.2656013-1-bjorn.andersson@linaro.org> <20201017043907.2656013-3-bjorn.andersson@linaro.org> <5eeecd0e-e3f3-f805-12d5-633284a29074@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5eeecd0e-e3f3-f805-12d5-633284a29074@arm.com> Cc: Rob Clark , linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Thierry Reding , 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 Mon 19 Oct 09:03 CDT 2020, Robin Murphy wrote: > On 2020-10-17 05:39, Bjorn Andersson wrote: > > The Qualcomm boot loader configures stream mapping for the peripherals > > that it accesses and in particular it sets up the stream mapping for the > > display controller to be allowed to scan out a splash screen or EFI > > framebuffer. > > > > Read back the stream mappings during initialization and make the > > arm-smmu driver maintain the streams in bypass mode. > > > > Signed-off-by: Bjorn Andersson > > --- > > > > Changes since v3: > > - Extracted from different patch in v3. > > - Now configures the stream as BYPASS, rather than translate, which should work > > for platforms with working S2CR handling as well. > > > > drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 24 ++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > index be4318044f96..0089048342dd 100644 > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > @@ -23,6 +23,29 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = { > > { } > > }; > > +static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) > > +{ > > + u32 smr; > > + int i; > > + > > + for (i = 0; i < smmu->num_mapping_groups; i++) { > > + smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); > > + > > + if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) { > > + smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); > > + smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); > > + smmu->smrs[i].valid = true; > > + > > + smmu->s2crs[i].type = S2CR_TYPE_BYPASS; > > + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; > > + smmu->s2crs[i].cbndx = 0xff; > > + smmu->s2crs[i].count++; > > FWIW I don't think you actually need to adjust the count here - the SMR > being valid should already prevent the whole SME from being reassigned until > the display probes, at which point it should "take over" the SMR based on > matching values and claim the "initial" refcount. After that you're back > into the standard flow. It might be a little unintuitive to have something > in a valid but "unused" state, but arguably it's entirely accurate in terms > of the software abstraction here. > > Otherwise, you end up making boot-time SMRs - so potentially all SMRs after > a kexec - effectively immutable, since even after Linux has taken control of > the whole system such that they *could* be reassigned safely, there's still > this undroppable refcount hanging around preventing it. > I did increment the count here to make sure the stream mapping do survive a probe deferral of the display controller (which is rather common when you have some bridge chip hanging off it). But after digging through the code further I've convinced myself that the sme won't be freed while the device is pending probe deferral. So I will drop this. > That said, for a mobile SoC use-case if you have enough SMRs for all your > stream IDs and don't have any kind of device hotplug, that restriction > shouldn't make much difference in practice, so I'm not too concerned either > way. Otherwise this is as nice and tidy as I'd hoped :) I agree, I'm quite happy with where we are now! Thanks, Bjorn > > Robin. > > > + } > > + } > > + > > + return 0; > > +} > > + > > static int qcom_smmu_def_domain_type(struct device *dev) > > { > > const struct of_device_id *match = > > @@ -61,6 +84,7 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) > > } > > static const struct arm_smmu_impl qcom_smmu_impl = { > > + .cfg_probe = qcom_smmu_cfg_probe, > > .def_domain_type = qcom_smmu_def_domain_type, > > .reset = qcom_smmu500_reset, > > }; > > _______________________________________________ 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 537ADC433E7 for ; Mon, 19 Oct 2020 15:38:42 +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 B60D422269 for ; Mon, 19 Oct 2020 15:38:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xy/WXNlN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="C6WGncCy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B60D422269 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=jQBdMfZ8kDA/Ghr8xsuMGF4eZNlYy/SZNILwp6fsYSs=; b=xy/WXNlNnZFabJxVqvHxM/seA CDGkV0bDxM8bxQh+kiKoh3fXLTrCVKijhBWshU1BMdWfI6lKkgWtbLLRZO/vC8rPGJUrbIY8tsFa0 Ud8BBArdY6RK+OJ/0yQFCIQ4AY+SsJlXGwQfqXMIvkDVtrWOzdloO3iz9nh+kQXGnxmnhQebaoXv7 512krtwA6bAZmUJb/iP/boA3ruIRaoy2frLLrvJDkCSSxBY2B8CHhDFTvYVTrQeVxtslsgaNxfg+6 RVy0gQMVybTEzaQvy6Ws3evCnzk68zT2oXdcMe6Vx6hL6Whga6PZHzkQr3NdeH0I5UME0UJOrrA5E jk/BFuQJQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUXDk-0004Xf-8x; Mon, 19 Oct 2020 15:37:12 +0000 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUXDg-0004W8-Cc for linux-arm-kernel@lists.infradead.org; Mon, 19 Oct 2020 15:37:09 +0000 Received: by mail-ot1-x342.google.com with SMTP id d28so27875ote.1 for ; Mon, 19 Oct 2020 08:37:06 -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=ZuObq9whWGDMmuO49RORrwrhqdb/dKbIiBCbbe3MZ+8=; b=C6WGncCyg42oqfIwbZX16QroJD8lscb0ArhpyKgf4GkpPaB4D7iGfaU9Bzj0g6qSis 0372FjoZBSTHj262jqlLl96tMRrEQlDhd2XZt52kuE8stnuNjDOnmewwjwBBcOHHu+Gy 0Q8lHEIs6Te5T37TFUENmQIe6g9VQHWikMFvW0WU2M/i5mk5JwTme3rLDmv9kr611/Ry lPruuQAiILKYVUYEs06XzhPcbaQCdS70pbv4o2s4uqjv+zjseP3FhCkf3c4r0mxiv063 wam1WtZWQLuxojz+ymhE1L3ftMqDYk7NBmwRXcQMfEA/J0Cwtjc7XlzQYw2dUupN2J4t H0Yg== 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=ZuObq9whWGDMmuO49RORrwrhqdb/dKbIiBCbbe3MZ+8=; b=sdWeYBcaVf+MsxD0KKuzUy4x75cj9VyqcrBq2vLBpa8LPL5zvYlvrZshrR1WjEL4eb kDBPTc0SaCtPQFymyLtCXHnq3HHhV5MIdkeySwIXM9+Awl1Z+Ou3HqzhrPsW+7BXNLkC W+H1FYqnhMLVBKCDbIHMwIc67XMy7KSxx0KjtRspv1RBa8aZyc/AOO70hWch5ysiwQSB Fa6SdTuK0ROsO6X6WiT8DymvraUN3mQMljPQ4pa4llsnMLPW7voWfAGfhG9bYEKe5sR4 NU/eWzLSYCd9xiHcWBq4uaV8pmTSoYVTcg4SCsuMrsP/3FNzyE+laPrUHLN+1gveSvY2 +wWw== X-Gm-Message-State: AOAM533Jzh2UngqDiw+6xwAeToza/CT1TsWp9piOTSy5PiVx+R1pkH2l XLMK0bWCG1R5Gzsba6Hs/sDK4g== X-Google-Smtp-Source: ABdhPJxyQj0BxuHZkdFy97PqND3qA9PIazxUOwIJ6MKfl9YWhfxFCeAHoSjERQkg821O8disXAds2w== X-Received: by 2002:a9d:6c8a:: with SMTP id c10mr384950otr.293.1603121825018; Mon, 19 Oct 2020 08:37:05 -0700 (PDT) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id p21sm3497994oto.21.2020.10.19.08.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:37:04 -0700 (PDT) Date: Mon, 19 Oct 2020 10:31:59 -0500 From: Bjorn Andersson To: Robin Murphy Subject: Re: [PATCH v4 2/3] iommu/arm-smmu-qcom: Read back stream mappings Message-ID: <20201019153159.GC6705@builder.lan> References: <20201017043907.2656013-1-bjorn.andersson@linaro.org> <20201017043907.2656013-3-bjorn.andersson@linaro.org> <5eeecd0e-e3f3-f805-12d5-633284a29074@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5eeecd0e-e3f3-f805-12d5-633284a29074@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_113708_445281_62AE58BF X-CRM114-Status: GOOD ( 34.00 ) 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 , Thierry Reding , 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 Mon 19 Oct 09:03 CDT 2020, Robin Murphy wrote: > On 2020-10-17 05:39, Bjorn Andersson wrote: > > The Qualcomm boot loader configures stream mapping for the peripherals > > that it accesses and in particular it sets up the stream mapping for the > > display controller to be allowed to scan out a splash screen or EFI > > framebuffer. > > > > Read back the stream mappings during initialization and make the > > arm-smmu driver maintain the streams in bypass mode. > > > > Signed-off-by: Bjorn Andersson > > --- > > > > Changes since v3: > > - Extracted from different patch in v3. > > - Now configures the stream as BYPASS, rather than translate, which should work > > for platforms with working S2CR handling as well. > > > > drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 24 ++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > index be4318044f96..0089048342dd 100644 > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > > @@ -23,6 +23,29 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = { > > { } > > }; > > +static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) > > +{ > > + u32 smr; > > + int i; > > + > > + for (i = 0; i < smmu->num_mapping_groups; i++) { > > + smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); > > + > > + if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) { > > + smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); > > + smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); > > + smmu->smrs[i].valid = true; > > + > > + smmu->s2crs[i].type = S2CR_TYPE_BYPASS; > > + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; > > + smmu->s2crs[i].cbndx = 0xff; > > + smmu->s2crs[i].count++; > > FWIW I don't think you actually need to adjust the count here - the SMR > being valid should already prevent the whole SME from being reassigned until > the display probes, at which point it should "take over" the SMR based on > matching values and claim the "initial" refcount. After that you're back > into the standard flow. It might be a little unintuitive to have something > in a valid but "unused" state, but arguably it's entirely accurate in terms > of the software abstraction here. > > Otherwise, you end up making boot-time SMRs - so potentially all SMRs after > a kexec - effectively immutable, since even after Linux has taken control of > the whole system such that they *could* be reassigned safely, there's still > this undroppable refcount hanging around preventing it. > I did increment the count here to make sure the stream mapping do survive a probe deferral of the display controller (which is rather common when you have some bridge chip hanging off it). But after digging through the code further I've convinced myself that the sme won't be freed while the device is pending probe deferral. So I will drop this. > That said, for a mobile SoC use-case if you have enough SMRs for all your > stream IDs and don't have any kind of device hotplug, that restriction > shouldn't make much difference in practice, so I'm not too concerned either > way. Otherwise this is as nice and tidy as I'd hoped :) I agree, I'm quite happy with where we are now! Thanks, Bjorn > > Robin. > > > + } > > + } > > + > > + return 0; > > +} > > + > > static int qcom_smmu_def_domain_type(struct device *dev) > > { > > const struct of_device_id *match = > > @@ -61,6 +84,7 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) > > } > > static const struct arm_smmu_impl qcom_smmu_impl = { > > + .cfg_probe = qcom_smmu_cfg_probe, > > .def_domain_type = qcom_smmu_def_domain_type, > > .reset = qcom_smmu500_reset, > > }; > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel