Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5638067imw; Wed, 20 Jul 2022 09:25:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1scjX4fkF7L9Pi4MF5T3r2w99GbZj3QLbwGlsdrgvlAW/0zK9PFuL4A6DrzaPWysHZfwHBR X-Received: by 2002:a05:6808:309b:b0:33a:6af5:f9c7 with SMTP id bl27-20020a056808309b00b0033a6af5f9c7mr2668621oib.59.1658334318722; Wed, 20 Jul 2022 09:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658334318; cv=none; d=google.com; s=arc-20160816; b=auxQGn7M/8bbjWls3xkA8f0xdyeKPN8EyyUOYHlbXz2CZJwC0Oyq1Hu2gkN0iqmLni OQzqaAX2YhDnhbwoflXR/qnV1TCThIzG/cii+wjxYhVSsA2tESudEh2rRcU6+DYw6+Qd YMhEVX/hCCGL+HSwJHRLzgqkmm4nyNZJ27QXcSlBwQIqXVWZuWtwQ1wVpohHoDsPCY35 KPo0iK+CdQvnFNG7bmOO7OPb4ehcgEr9Ef4DonaIsNIbbsiNMZf+fCq7GH6u+N4sTHGd 5zOokQ5zEASFBvDz7BhLNTwvNuexDTnzXdB6JwXEYDfAdcrchkT3BthNkdFQFzKynZo5 YehQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vnQbeZrRFY+pvsMGPhJ3qNV+CqsclpyzAJlR2pnoj4A=; b=KEZHhkIPzSmO/vV6jOV1Oa17bQi4+NPsQOMw2BxNSVEB88yBUPmPzTdnuqeYDwKzD+ tdmI9z+kizPR/R8VWJCQa6VebQ8p9Vsy8kKYc982P54j0SYwnUpQ4ugZe6h4kVh26iWE DZin8ljCRime14yu9vq0/Txv6RU2xjdrgBuGVL6bpOuwZ0cDEkwh9UBqYkbibldJEcPd cyJWZyH1p01rsu0mRZnTj2r2wB1t7OV0G67vgRvkjM/IbL0n6AE20FZpipo3VctagiNT 0rnzE4zcv8GIwvcJYi1xDOKWBimOcEeOubiz1xvcwMrtaFQnKnT9FUKi7RIh1cT/0I/F eInw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T9YI5+Fh; 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 ek27-20020a056870f61b00b000f2e7b8dbebsi15965193oab.14.2022.07.20.09.25.04; Wed, 20 Jul 2022 09:25:18 -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=T9YI5+Fh; 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 S238380AbiGTQSu (ORCPT + 99 others); Wed, 20 Jul 2022 12:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238337AbiGTQSo (ORCPT ); Wed, 20 Jul 2022 12:18:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DD5C54050; Wed, 20 Jul 2022 09:18:42 -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 CF0B3B8210A; Wed, 20 Jul 2022 16:18:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D508C341D0; Wed, 20 Jul 2022 16:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658333919; bh=dBAYRKIzFm0RTKOcH+0KPke3E8MEw8rlIWS4O1tZUf8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=T9YI5+FhKac8fuIV3QPR3CTu79OZY1DHEEAfFE4Iim6EREIDLDo+mQtP1mxW1sggg yt7JoQkZfykvX12pala/eTUXAaJ3AkijMLabBuMpLpzF+Up0VP8nP6WqWD5oYllZ7V T/NcMA6ky6NLqgMz9bHnkh7JhSPYcB9qMKxguCKk6PZQTgW/+j7Np/I9ItGdl8R3Sf IirxP8/4VzC0NN6Oqc19EFy/Tzj7n1fs3rlwpeMpIg74IFPBFuGlJoUI+Xdqks+UgY yzjYj2x+/rSwjxcUbDFOjRGhWwOh6e1hQLkAqsSbS8DfftnnfN4IZaFoBIxbhqHYd8 hlxESxWG0hfLQ== Received: by mail-vs1-f48.google.com with SMTP id l190so16812109vsc.0; Wed, 20 Jul 2022 09:18:39 -0700 (PDT) X-Gm-Message-State: AJIora8M3AUpI++Smmzjy6ERlkbaWrW8kWPO9r5Yuoh9RrB662lYXVfn 6hVr4oFzSOWHwGDOdfdrdJNMcycKntDVJastKQ== X-Received: by 2002:a67:c18e:0:b0:357:5fc3:45d7 with SMTP id h14-20020a67c18e000000b003575fc345d7mr13075314vsj.53.1658333918336; Wed, 20 Jul 2022 09:18:38 -0700 (PDT) MIME-Version: 1.0 References: <20220719200332.GA1552587@bhelgaas> In-Reply-To: From: Rob Herring Date: Wed, 20 Jul 2022 10:18:27 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/6] PCI: brcmstb: Split brcm_pcie_setup() into two funcs To: Jim Quinlan Cc: Bjorn Helgaas , Jim Quinlan , "open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS" , Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Florian Fainelli , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , open list Content-Type: text/plain; charset="UTF-8" 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 Wed, Jul 20, 2022 at 8:53 AM Jim Quinlan wrote: > > On Tue, Jul 19, 2022 at 4:03 PM Bjorn Helgaas wrote: > > > > On Tue, Jul 19, 2022 at 09:08:48AM -0400, Jim Quinlan wrote: > > > On Mon, Jul 18, 2022 at 6:40 PM Bjorn Helgaas wrote: > > > > On Mon, Jul 18, 2022 at 02:56:03PM -0400, Jim Quinlan wrote: > > > > > On Mon, Jul 18, 2022 at 2:14 PM Bjorn Helgaas wrote: > > > > > > 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. > > > > > > > > > > Actually, what you describe is what I proposed with my v1 back in Nov 2020. > > > > > The binding commit message said, > > > > > > > > > > "Quite similar to the regulator bindings found in > > > > > "rockchip-pcie-host.txt", this allows optional regulators to be > > > > > attached and controlled by the PCIe RC driver." > > > > > > > > > > > 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. > > > > > > > > > > The reviewer's requested me to move the regulator node(s) > > > > > elsewhere, and at some point later it was requested to be placed > > > > > under the Root Port driver. I would love to return them under the > > > > > host bridge, just say the word! > > > > > > > > Actually, I think my understanding is wrong. Even though the PCI core > > > > hasn't enumerated the Root Port as a pci_dev, brcm_pcie_setup() knows > > > > about it and should be able to look up the regulators and turn them > > > > on. > > > > > > One can do this with > > > regulator_bulk_get(NULL, ...); > > > > > > However, MarkB did not like the idea of a driver getting the > > > regulator from the global DT namespace [1]. > > > > > > For the RC driver, one cannot invoke regulator_bulk_get(dev, ...) > > > if there is not a direct child regulator node. One needs to use the > > > Port driver device. The Port driver device does not exist at this > > > point unless one tries to prematurely create it; I tried this and it > > > was a mess to say the least. > > > > > > > Can you dig up the previous discussion about why the regulators need > > > > to be under the Root Port and why they can't be turned on before > > > > calling pci_host_probe()? > > > > > > RobH did not want the regulators to be under the RC as he said their > > > DT location should resemble the HW [2]. The consensus evolved to > > > place it under the port driver, which can provide a general > > > mechanism for turning on regulators anywhere in the PCIe tree. > > > > I don't want to redesign this whole thing. I just want a crisp > > rationale for the commit log. > > > > All other drivers (exynos, imx6, rw-rockchip, histb, qcom, tegra194, > > tegra, rockchip-host) have regulators for downstream PCIe power > > directly under the RC. If putting the regulators under an RP instead > > is the direction of the future, I guess that might be OK, and I guess > > the reasons are: > > > > 1) Slot or device power regulators that are logically below the RP > > should be described that way in the DT. > > > > 2) Associating regulators with a RP allows the possibility of > > selectively controlling power to slots/devices below the RP, > > e.g., to power down devices below RP A when suspending while > > leaving wakeup devices below RP B powered up. > > > > I think in your case the motivating reason is 2). > > > > Your commit log for "Add mechanism to turn on subdev regulators" > > suggests that you want some user control of endpoint power, e.g., via > > sysfs, but I don't see that implemented yet except possibly via a > > "remove" file that would unbind the driver and remove the entire > > device. > Hi Bjorn, > > Initially we wanted to (a) turn on any regulator found under the RC > node and (b) allow the possibility of the regulator to control the > EP's power. From the feedback, we realized early on that neither of > these were going to fly, so we conceded both requests and just wanted > to turn on standard PCIe regulators. Upon reading the aforementioned > commit message I realize that there are a couple of leftover sentences > from these early days that must be removed. > > I think when I submitted v1 of the original series that only the > rockchip driver had regulators under the RC. And my recollection was > that this was accepted but there was apprehension of this turning into > the "standard" way of turning on such regulators, as the location of > the regulator nodes was in question. > > In short, I would be quite content to follow the existing examples. The existing examples are, in general, incomplete and only work for the simplest cases. There's 2 cases to consider here. The first is standard slots with standard PCIe signals (e.g. PERST#) and voltage rails. The 2nd is either non-standard slots or just soldered down devices which could have any number of device specific resources. In the latter case, those resources need to go into the node for the device. For the former case (which we are discussing here), putting the resources in the upstream (side of the link) node is fine. That's the root port node(s) or switch port nodes. However, since most host bridges are a single RP and don't put the RP node in DT, we've ended up with these properties in host bridge nodes. That's fine as long as it's a single RP and device. When it is not, we need to do something different. The only way this scales is putting resources in the port nodes as those are what have a 1:1 relationship to slots. If that's supported, then the simple cases are also easily supported with if the resources are not found in the port node/device, then look for them in the parent node. That's also the path for how we get the handling of PERST out of every host bridge driver. Rob