Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3667481imw; Mon, 18 Jul 2022 12:16:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uG++FLozOOGVOlFUcWtSYN2cxApPREY0Sw3QqKU5PDZaFOCpjQqiE1mhfIX45tc7Da+tpo X-Received: by 2002:a17:902:8602:b0:16c:dfae:9afb with SMTP id f2-20020a170902860200b0016cdfae9afbmr12811013plo.35.1658171817086; Mon, 18 Jul 2022 12:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658171817; cv=none; d=google.com; s=arc-20160816; b=bLDyTcvhidg5OiK7NWN4aDm2G2se6C98DU9KS7NfscMR2sSLec6KZngZaS71tagOX2 Ze5hS+GnbnDI5wrHwp/1r/b+24Ka+etu6N0ibqmtGTFgkV61nPQj/dum6hUHsSoy4mOy uYueZyNVC221aTiBA7UygAvft6lOnutPZ7qS2l7aLZrvpODSrXosJ/MyRY7+n1tWeNX9 xqPDgGqI1qvbv8d1XSdBfAfwF4WdtaNJmv7cqKbcWF8TLx3qtD/2On3m82UloLx4XsEy FlhG342H2hprNBhelomYBh6xe/4KNLKWvRaEiS8BHRCcR+eCpLiBts04NKggiA9sT99/ WEkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=RwJFmGBGAj77WtRtkfpVCH5KHevPIQx4n6DOqV2+xgU=; b=oDW9ayhTtGqLwo5qkKvCvhSKLUCy/CgivXtMcH2xzbLBtW8+clEDuUD07OWlmImTFt zvhDrvRdSbQ3wZ8v+pd+sIXKGBmc0DSXwd67UQPpSw3W4huNSyU1r9im4ed4B43TqiVS Xax0ng37t7FmFtBCfJzvaIsVBDD4tyO1EOedqR0WEaODYGwTpCZq7fk0DQqbrlrkO99T vw8OAhmJpINDWYKSjB86gbrP+VxiMGSe9wlu1Tmrucl1LimfHpt1egyzqHdSpyJD6YsQ lMsQBwHJlzD0FJm8o2UVGSt+7t0frUFya2Z22rU/+7FdAqyxY69QrPd1k0ssrd2UftxF wXzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N5PAtTh5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn15-20020a056a00340f00b00528d882b07csi11367247pfb.303.2022.07.18.12.16.42; Mon, 18 Jul 2022 12:16:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N5PAtTh5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233932AbiGRSOc (ORCPT + 99 others); Mon, 18 Jul 2022 14:14:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbiGRSOb (ORCPT ); Mon, 18 Jul 2022 14:14:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F1B2CCB9; Mon, 18 Jul 2022 11:14:30 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id C2418B816CF; Mon, 18 Jul 2022 18:14:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3937BC341C0; Mon, 18 Jul 2022 18:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658168067; bh=7mJAJ79anHwJ/WB2hxfx2DwpigreSJuf5+TDz+HsVrM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=N5PAtTh5h0s19MfOscwKfm7aa21gxE3sa57C64jOyouZ7OUJsYE39vA18FpeMNv7k zE3yKETrh12Y4gF3Efxu1HH+gAp6eG0A/GYlaa/J54vlSs//o/9sz4GRRvXwBy1bSV QrYDPfQdSfBgrcJggs40rKoYy72Npcsmsdt5THMcfAsYSV3F5SHRhqKzCZb3XDGyXl gVakm5QwwQFohcWLM8Rpz47lnWCcvteDO8CO/ZFSXUGYIVpV+Yw5rxCV2w5418Cdpl Kxvq3HaCSs5767/Jab8bT7Ztu91UUHkEDnAxTkOMb1KB0Gz3d0dgCCgtgLzNnp1scZ sYGzjyNkz/gDg== Date: Mon, 18 Jul 2022 13:14:25 -0500 From: Bjorn Helgaas To: Jim Quinlan Cc: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, james.quinlan@broadcom.com, Florian Fainelli , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , open list Subject: Re: [PATCH v2 2/6] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Message-ID: <20220718181425.GA1431580@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220716222454.29914-3-jim2101024@gmail.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 16, 2022 at 06:24:49PM -0400, Jim Quinlan wrote: > Currently, the function does the setup for establishing PCIe link-up > with the downstream device, and it does the actual link-up as well. > The calling sequence is (roughly) the following in the probe: > > -> brcm_pcie_probe() > -> brcm_pcie_setup(); /* Set-up and link-up */ > -> pci_host_probe(bridge); > > This commit splits the setup function in two: brcm_pcie_setup(), which only > does the set-up, and brcm_pcie_start_link(), which only does the link-up. > The reason why we are doing this is to lay a foundation for subsequent > commits so that we can turn on any power regulators, as described in the > root port's DT node, prior to doing link-up. All drivers that care about power regulators turn them on before link-up, but typically those regulators are described directly under the host bridge itself. IIUC the difference here is that you have regulators described under Root Ports (not the host bridge/Root Complex itself), so you don't know about them until you've enumerated the Root Ports. brcm_pcie_probe() can't turn them on directly because it doesn't know what Root Ports are present and doesn't know about regulators below them. So I think brcm_pcie_setup() does initialization that doesn't depend on the link or any downstream devices, and brcm_pcie_start_link() does things that depend on the link being up. Right? If so, "start_link" might be a slight misnomer since AFAICT brcm_pcie_start_link() doesn't do anything to initiate link-up except maybe deasserting fundamental reset. Some drivers start the LTSSM or explicitly enable link training, but brcm_pcie_start_link() doesn't seem to do anything like that. brcm_pcie_start_link() still does brcm_pcie_set_outbound_win(). Does that really depend on the link being up? If that only affects the Root Port, maybe it could be done before link-up? > We do this by defining an > add_bus() callback which is invoked during enumeraion. At the end of this > patchset the probe function trace will look something like this: > > -> brcm_pcie_probe() > -> brcm_pcie_setup(); /* Set-up only */ > -> pci_host_probe(bridge); > -> [enumeration] > -> pci_alloc_child_bus() > -> bus->ops->add_bus(bus); /* We've set this op */ > -> brcm_pcie_add_bus() /* Our callback */ > -> [turn on regulators] /* Main objective! */ > -> brcm_pcie_start_link() /* Link-up */