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