Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp927309rdb; Thu, 15 Feb 2024 22:52:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUt8hsNvkgNuBq3Z3rkIW0Kd1yZh35nt8/RS7dt8GM6J1iV1hF7YMPvLzsbChMNRrK2ERON3ZI7srbWfootJ8sdgcrrLBo+qy8zlE/vKQ== X-Google-Smtp-Source: AGHT+IFfTX0zAdBYZsMmEjvY19nPMsMYFvTMl8kOMdBaD3uau+FTP56Ww4vGJNBJoaKgYxRtJXdI X-Received: by 2002:a05:6a21:1799:b0:1a0:56c9:608e with SMTP id nx25-20020a056a21179900b001a056c9608emr5051673pzb.61.1708066336307; Thu, 15 Feb 2024 22:52:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708066336; cv=pass; d=google.com; s=arc-20160816; b=iu9SZUgzcJkyHIzLfNUfjEGfbEMppmDUzkHssMJIZSemzod1F8+tFlihZ64NJJwDp8 yV45jKiIR33grm79UNm+viE2vPN2GnxKfZ1bj3r86cS7netNbijzm22rIzsxORMMGpvR M+3oxcrysOgZUGad/JEToDwkRx2UeWohBz1p2awNYDzyivow0tO/ce3tnb7MptKkB635 hZ27u60oa0Xs53RUP2/RZvDFgBJVfk60qEbPdaQ6cg6saWp7+gxn6BZ1IHWgCTqXBcIf si8AAGzLghIcUMdZ4ujILM7gti2wfU/yb6O1Ki+W8TR1yTYsaKzfD4sp/1MpGBl7xZAf iULw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tbM9tMSrKHLqL68rea9CRVR08AwLWiMpSyyNYXiuQlw=; fh=vxwmO19AUIBHZsRHTi3IYm4Dxwz5IuHwKkDDOPwwHnM=; b=mmSldWEcTNQciyE1OC5ua2kSc5bYogy7G53gLWEe1MplM1SJIBsXvIjrBLb14sW/oy MXWeGztBEqNSdc6RFODTSZu9m7WZ3ekZ9y3M8ZbyQkJPt64gk+pGfwOPQTYO/3HgipUV WN+bM2k7VMzteRMQSkIoATeu2Z9HwYsHJf4yg7zN3mWKfuH5iag+K0p1tq6h9efcMzOW 8v5lDdNVJP4lVJd17HX2c8WwQT9ABUqgZXENtzOJWXtv9YPtFF8gk1TPFHntSFV9dhsV fyBbhEV2Q1LhfREKgCEC3wYDmaLvZqI/rpPtcJoq0j3LTtSnEJ3H/YsHp2Dz9Y1Ww4FY dQsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r5SkEpmS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68113-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a17-20020aa78651000000b006e086ac9d5dsi2476038pfo.105.2024.02.15.22.52.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r5SkEpmS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68113-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68113-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B79F8B23DF5 for ; Fri, 16 Feb 2024 06:52:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F75714A90; Fri, 16 Feb 2024 06:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r5SkEpmS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42682134CE; Fri, 16 Feb 2024 06:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708066312; cv=none; b=TcSdWADhG7oEUIapLrrnxSPf+L/GiRMo/R6//X1DfkMIA87jJYes/VaK7w58iTdymDli8Ux7PIQWlhOA8M3TQ3Br85+Zs3o1y7B6DrRUHqtMKQEOO7OaDo2Rk6JloRqW/+Nq8YEX7iEM02DLFUwcD/OUpQw08D63/iMOq05yNr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708066312; c=relaxed/simple; bh=4OniHEQYYYMWlJOoq5xp/Wu7H+JX44MheQBlaOy9geY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JZT/6dobgSWtbJRfICLJNCiSJd0o+5LyjkFJe3A3NFRbI6t+7Rxpg3zErjDYO2t1PIdev1kksyI3seDi7W6Q/PLD5BisYFFxUJwvgywuhSFm9HeNKBolYmDKoSa+ukePm0tJNGnSzIsgtziUBkIve3CG3jTQPB2ONFuk9on+RnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r5SkEpmS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BF1CC433F1; Fri, 16 Feb 2024 06:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708066311; bh=4OniHEQYYYMWlJOoq5xp/Wu7H+JX44MheQBlaOy9geY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r5SkEpmSkvHJjtN0pXMbqeQbvvLOZWiU6SX10TYjnAR4E0d137coRNoroy0bgvjoo K7qXj04Hf7rVExj1f9qFr/2n7yop6TZcl5/hETHQV6bXWBpz+09ubCKwC4a8TKhh00 4+Kg5Qqbd7h7a8mRkO0AChYmogH80Sh604QF06SbvTXJUpPZb0iSLv7vClO2s7piM9 vMfcVvPZKEG1DL37nZarqDAlrZen0pRqY186KK2pt9xkQs8Vz6kIDLc5tDBceNv4ir YOjMg+/rLkvr5A3nc7XnQBQjHYTfNWAHw3CnYNp3kPvfk1syeqx1QCEFhJDwuhjQ7a WYIfakEiaWQpg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1ras50-000000004Cl-2tMr; Fri, 16 Feb 2024 07:52:15 +0100 Date: Fri, 16 Feb 2024 07:52:14 +0100 From: Johan Hovold To: Konrad Dybcio Cc: Bjorn Helgaas , Bjorn Andersson , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Philipp Zabel , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: Re: [PATCH v2 2/3] PCI: qcom: Read back PARF_LTSSM register Message-ID: References: <20240215161114.GA1292081@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Feb 15, 2024 at 07:44:27PM +0100, Konrad Dybcio wrote: > On 15.02.2024 17:11, Bjorn Helgaas wrote: > > On Thu, Feb 15, 2024 at 11:21:45AM +0100, Konrad Dybcio wrote: > >> On 14.02.2024 23:28, Bjorn Helgaas wrote: > >>> On Wed, Feb 14, 2024 at 10:35:16PM +0100, Konrad Dybcio wrote: > >>>> On 12.02.2024 22:17, Bjorn Helgaas wrote: > >>>>> Maybe include the reason in the subject? "Read back" is literally > >>>>> what the diff says. > >>>>> > >>>>> On Sat, Feb 10, 2024 at 06:10:06PM +0100, Konrad Dybcio wrote: > >>>>>> To ensure write completion, read the PARF_LTSSM register after setting > >>>>>> the LTSSM enable bit before polling for "link up". > >>>>> > >>>>> The write will obviously complete *some* time; I assume the point is > >>>>> that it's important for it to complete before some other event, and it > >>>>> would be nice to know why that's important. > >>>> > >>>> Right, that's very much meaningful on non-total-store-ordering > >>>> architectures, like arm64, where the CPU receives a store instruction, > >>>> but that does not necessarily impact the memory/MMIO state immediately. > >>> > >>> I was hinting that maybe we could say what the other event is, or what > >>> problem this solves? E.g., maybe it's as simple as "there's no point > >>> in polling for link up until after the PARF_LTSSM store completes." > >>> > >>> But while the read of PARF_LTSSM might reduce the number of "is the > >>> link up" polls, it probably wouldn't speed anything up otherwise, so I > >>> suspect there's an actual functional reason for this patch, and that's > >>> what I'm getting at. > >> > >> So, the register containing the "enable switch" (PARF_LTSSM) can (due > >> to the armv8 memory model) be "written" but not "change the value of > >> memory/mmio from the perspective of other (non-CPU) memory-readers > >> (such as the MMIO-mapped PCI controller itself)". > >> > >> In that case, the CPU will happily continue calling qcom_pcie_link_up() > >> in a loop, waiting for the PCIe controller to bring the link up, however > >> the PCIE controller may have never received the PARF_LTSSM "enable link" > >> write by the time we decide to time out on checking the link status. This makes no sense. As Bjorn already said, you're just polling for the link to come up (for a second). And unless you have something else that depends on the write to have reached the device, there is no need to read it back. It's not going to be cached indefinitely if that's what you fear. > Generally, it's a good idea to add such readbacks after all timing- > critical writes, especially when they concern asserting reset, > enabling/disabling power, etc., to make sure we're not assuming the > hardware state of a peripheral has changed before we ask it to do so. Again no, there is no general need to do that. It all depends on what the code does and how the device works. Johan