Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3340855lqp; Tue, 26 Mar 2024 06:48:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvKUxpSk9TLRKmdOHnQ7gYXN9yqdj4LzTV0W9Qc6g2o+zVeMDgZY0QBT3j+6m9enE3IamkQT9a5yn0FaE+hu2T8ut73LIYo0gfZfOSHw== X-Google-Smtp-Source: AGHT+IGvD7e3uGzvrOe7eVMziICF4OXgnHHoxDPnw3i5ulaBxaXMh7I4nM0JynxtTKZnLPyec/fo X-Received: by 2002:a50:bb6b:0:b0:56b:d92f:32c6 with SMTP id y98-20020a50bb6b000000b0056bd92f32c6mr8663411ede.5.1711460928205; Tue, 26 Mar 2024 06:48:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711460928; cv=pass; d=google.com; s=arc-20160816; b=bzYv4xOL26Q0TH9JjLDo3P369+UtzmU/wdOOo2xkykWWJK6gZX0dZJv+UWqpQpCwj6 oR1EoAndSZVF6udF+xAs49Phf91e4Vj4hVouSWkvDGuHQfrCupT8y/RY3eiwU698dg6O b2eBDWjEUOsWHNrwvgtX10kA5qgU1yZAOFDCnsUaL31v2sjSSljmW7zKafMcd9eKD6oY DqvPGU4zjh6FNPC/FVZUSCXe6o1Mt2HquTZ40KS9tazelsjFGVPOOMeTPHAW5yTDUK96 BvL6c+yV+HZvOrfQuFkpFQtrmr53js0c18gU381OmL7NFY/bxjDMIxkxbl9D6zrIFm1h dTbw== 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=Db6mVE2k98hmAgK4XOmb6JAAwlNPwisOJR8flMT+PI8=; fh=0tIhEViLo7PUpyJI/8YvAfn7aU9qwVOIrJ6jkc06K5o=; b=MB7uhE+jr+cXe5ZobnRc5zI1idV9FsC9mMj5WS1/ElPfL2Sh8SjRVmgfBbv/XplJz1 nW12oVFV3GiIdJE59lLs7zsPLJhRwIvneWtY3zH2BIpqz3EvChUtv0eJQOWQoe6CfrhN ShIlDOY9YhlBCPd/lkvbR0EB4vQZCIUrgUr8x5p2uJYzf4MRlwsIgHDFe1+4j4c9VhKj C+1RFiLfaSRJeG/DfwRr7FwCK2I1hfbl5Och6ybq43oLKYB6HfWF8eOdQhZWsc60s4km H2f1S146NcuKAWtxDrvnXn6w/ujdO9JToPQgWTiMBbGak750K07h0CiQmjUV62xRB1BH A0Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pYeJpAUH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-119093-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q10-20020aa7da8a000000b0056884c2f202si3671445eds.515.2024.03.26.06.48.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:48:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119093-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pYeJpAUH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-119093-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119093-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CE1DC1F6472F for ; Tue, 26 Mar 2024 13:48:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E371574BE8; Tue, 26 Mar 2024 13:47:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pYeJpAUH" 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 F3F4974C17; Tue, 26 Mar 2024 13:47:36 +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=1711460857; cv=none; b=gyCnljRFV/0Jdo6aKKVlfMld2HUxB48ROTX+ENJcU2kPLZo9jexOmbou5G7KEL9K6TbC7hcGhyJTBo1HL6jDe9LZBDJkg9PD98v77cazCbi7SA5SvZVQpIXg53TLlAAYh0Algkjk3ENWgLTsjwUFq0afREL60NK6uPjimBcZxRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711460857; c=relaxed/simple; bh=P2qK25AOinNz1eP+vHSK/lBmvdrjVtBZ8Su3RQbwtRQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bHoba7KgkBBzapWlV7ExMnPz2tfbkYjx2WO6jTOu3cBWOw+qab1TdW6nsEC1a+CMcaEeB/gX3XuhEzfEnekZTFeqQZKY4C9xabPCYCGF+O8A2Rb8co4nVl6hjAcelwROkwFSazIVIP5RJx+RS/6ezl6VMtH4HJJiP1yyRADV+5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pYeJpAUH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A807CC433C7; Tue, 26 Mar 2024 13:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711460856; bh=P2qK25AOinNz1eP+vHSK/lBmvdrjVtBZ8Su3RQbwtRQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pYeJpAUHeFOtG+bIdXG4Ruq0TGZaT46Di9QiU5jbnT4y5EU9XK1+HYVCYRYP+QIGd H85d8RqAmdnILOZQGO1qo1KdsKLrUibL0+sH46/JIdwl99uiItbPikVDfNWmvWAVZb ucKWnIWAwts3UaDdSfSyN3bmzu/9xOt24yVX9WAaL/GuyLS6YcW2JvnEh+USq8VDmn WEp9bB5M1INWnORCaztLLJ9m1LP9cTLSMOIdhui4ACXSvAimJ+CCWr8f/cyN4RkTsb If9D5XeKXZDIun/nWRAOJcv7IcL2go3FXh61EAbq3DJeQf1kUd+HKY8wAt6hK1e4CC DcGcFdR15J+0w== Date: Tue, 26 Mar 2024 14:47:30 +0100 From: Niklas Cassel To: Manivannan Sadhasivam Cc: Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Kishon Vijay Abraham I , Thierry Reding , Jonathan Hunter , Jingoo Han , Gustavo Pimentel , linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mhi@lists.linux.dev, linux-tegra@vger.kernel.org Subject: Re: [PATCH 01/11] PCI: qcom-ep: Disable resources unconditionally during PERST# assert Message-ID: References: <20240314-pci-epf-rework-v1-0-6134e6c1d491@linaro.org> <20240314-pci-epf-rework-v1-1-6134e6c1d491@linaro.org> <20240326074429.GC9565@thinkpad> <20240326111021.GA13849@thinkpad> 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: <20240326111021.GA13849@thinkpad> On Tue, Mar 26, 2024 at 04:40:21PM +0530, Manivannan Sadhasivam wrote: > > I was planning to drop enable_resources() from Qcom driver once the DBI rework > series gets merged. Because, the resource enablement during probe is currently > done to avoid the crash that is bound to happen if registers are accessed during > probe. > > But what your observation reveals is that it is possible to get PERST# assert > during the EP boot up itself which I was not accounting for. I always assumed > that the EP will receive PERST# deassert first. If that is not the case, then > this patch needs to be dropped. From what I saw when having debug prints from my old email to you: https://lore.kernel.org/linux-pci/Zalu%2F%2FdNi5BhZlBU@x1-carbon/ ## RC side: # reboot ## EP side [ 845.606810] pci: PERST asserted by host! [ 852.483985] pci: PERST de-asserted by host! [ 852.503041] pci: PERST asserted by host! [ 852.522375] pci: link up! (LTSSM_STATUS: 0x230011) [ 852.610318] pci: PERST de-asserted by host! So in my case, I assume that the RC asserts PERST during a SoC reset. This is obviously from the RC driver asserting PERST + sleep 100 ms + PERST deassert: [ 852.503041] pci: PERST asserted by host! [ 852.610318] pci: PERST de-asserted by host! The two before that: [ 852.483985] pci: PERST de-asserted by host! [ 852.503041] pci: PERST asserted by host! appears to be because the RC I am using, incorrectly sets the PERST gpio as ACTIVE HIGH: https://github.com/torvalds/linux/blob/v6.9-rc1/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts#L300 Well, at least they are bug compatible and sets the output to: https://github.com/torvalds/linux/blob/v6.9-rc1/drivers/pci/controller/dwc/pcie-dw-rockchip.c#L170-L184 0 and the 1, which, since the DT binding is incorrect, will actually do the right thing and assert and the deassert PERST. The problem seems to be that the initial flags: https://github.com/torvalds/linux/blob/v6.9-rc1/drivers/pci/controller/dwc/pcie-dw-rockchip.c#L242-L243 is: GPIOD_OUT_HIGH which explains why I get the extra: [ 852.483985] pci: PERST de-asserted by host! before [ 852.503041] pci: PERST asserted by host! with basically no time between them.. I guess I should send a patch to set the initial value to GPIOD_OUT_LOW, so that the RC driver does not trigger a "spurious" PERST deassertion when requesting the IRQ. So I think this patch should be fine if the RC is not buggy, but as we can see, in reality there are at least one platform in mainline that does manage to get this wrong. Kind regards, Niklas