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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2F7AC433EF for ; Tue, 7 Dec 2021 16:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=py+0UucylzB/ZMTvTbTWDPIPaxY6R/4X2lBmUweo/C8=; b=dF9sy66ZvhGi+B rlF02/wNE66PkvUZTfBjTqTGNOSQETuBAPF3kLR+un9W9ZHtbHpfE6oWpujEz+7i9q8H+sXrYdHPg bVFGPg6zY+/SCmV1O1bpGStk95slcmpGTy7gZcnQ11aEAEEJrkgPOS7WNGmwyLqqO2sy+F6GL0rHO 8NDKveBRu/zYn265E7xsSnHRaPtdz3Gi8ch6e68KPpHysnfkRxwSzHTf3uQSqAvHe+v6JVkqaDar4 UXcxEu/KcazCwhiRe6GT1q9aHhFAt/NStZl0FNpes00FslUV8UuW+kCHBq+L1JG8ptlXSH6ofYfH9 nZvJVWVoyxF8CDj61nEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mudFE-009QuC-AC; Tue, 07 Dec 2021 16:23:08 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mudFA-009Qsr-Fs for linux-arm-kernel@lists.infradead.org; Tue, 07 Dec 2021 16:23:06 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B11DACE1C1C; Tue, 7 Dec 2021 16:23:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B26BC341C1; Tue, 7 Dec 2021 16:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638894179; bh=J8QNuptCRMd5FPz3sYAxGk59NtvnPv/BN3NdiOYbym8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=rm1+9y3P//iqR/ITy9maM963Sskw8m0oJfvWK2EEs1y+/CTy6C9o/y1lEn0dUP+AZ AajiJaIlEVhQrRTdoL/ir417yGdqSMr1jxcKPsB6COnYaE0IsvxN2/5DYjWNS3eht/ 4OgIt85RvmWm37ulTCpw2Ugf9Hxmoxd9FJdEbAWlsfKFrNzObAGUHsyRBeTrJV5VTK f2/eCAdCfsjcIa+0DqqRsTnSCH3kqyIDu35kmiOVE/wPJ86JV2gA5QCFGsGgsQMUNV XblxC6rzvJeGo/BHRGOwoPRfsoxv0vFxNY/zN1x/0cd9zQ3LN3/esS8cWG/GA5Jmcu O4RtyJLyldrhQ== Date: Tue, 7 Dec 2021 10:22:57 -0600 From: Bjorn Helgaas To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, Pali =?iso-8859-1?Q?Roh=E1r?= , Alyssa Rosenzweig , Lorenzo Pieralisi , Bjorn Helgaas , Mark Kettenis , Luca Ceresoli , kernel-team@android.com Subject: Re: [PATCH v3 1/3] PCI: apple: Follow the PCIe specifications when resetting the port Message-ID: <20211207162257.GA44468@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211123180636.80558-2-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211207_082304_938855_4CFD8E17 X-CRM114-Status: GOOD ( 26.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 23, 2021 at 06:06:34PM +0000, Marc Zyngier wrote: > While the Apple PCIe driver works correctly when directly booted > from the firmware, it fails to initialise when the kernel is booted > from a bootloader using PCIe such as u-boot. > = > That's beacuse we're missing a proper reset of the port (we only > clear the reset, but never assert it). > = > The PCIe spec requirements are two-fold: > = > - #PERST must be asserted before setting up the clocks, and > stay asserted for at least 100us (Tperst-clk). > = > - Once #PERST is deasserted, the OS must wait for at least 100ms > "from the end of a Conventional Reset" before we can start talking > to the devices Unless somebody objects, I'll s/#PERST/PERST#/ to match the spec usage, both here and in the comments below. I also notice gpiod_get_from_of_node(..., "#PERST") earlier in apple_pcie_setup_port(). If it wouldn't break anything, I'd like to change that, too. > Implementing this results in a booting system. > = > Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up") > Acked-by: Pali Roh=E1r > Signed-off-by: Marc Zyngier > Cc: Alyssa Rosenzweig > Cc: Lorenzo Pieralisi > Cc: Bjorn Helgaas > --- > drivers/pci/controller/pcie-apple.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > = > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller= /pcie-apple.c > index 1bf4d75b61be..957960a733c4 100644 > --- a/drivers/pci/controller/pcie-apple.c > +++ b/drivers/pci/controller/pcie-apple.c > @@ -539,13 +539,23 @@ static int apple_pcie_setup_port(struct apple_pcie = *pcie, > = > rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK); > = > + /* Engage #PERST before setting up the clock */ > + gpiod_set_value(reset, 0); > + > ret =3D apple_pcie_setup_refclk(pcie, port); > if (ret < 0) > return ret; > = > + /* The minimal Tperst-clk value is 100us (PCIe CMS r2.0, 2.6.2) */ > + usleep_range(100, 200); Spec says "min 100us from REFCLK stable before PERST# inactive". So I guess when apple_pcie_setup_refclk() returns, we know REFCLK is already stable? > + /* Deassert #PERST */ > rmw_set(PORT_PERST_OFF, port->base + PORT_PERST); > gpiod_set_value(reset, 1); > = > + /* Wait for 100ms after #PERST deassertion (PCIe r2.0, 6.6.1) */ > + msleep(100); Does this port support speeds greater than 5 GT/s? If so, 6.6.1 says we need "100ms after Link training completes," not just after deasserting PERST#. I'll update this citation to "PCIe r5.0, 6.6.1" to reference the current spec. > ret =3D readl_relaxed_poll_timeout(port->base + PORT_STATUS, stat, > stat & PORT_STATUS_READY, 100, 250000); > if (ret < 0) { > -- = > 2.30.2 > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel