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 2D45CC54E67 for ; Wed, 27 Mar 2024 16:16:36 +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:References: 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: List-Owner; bh=AFEEMqiN1AIVq2914S1QT4BzIBbWsdqjuQruBmHtTHA=; b=3UUgTznqznO8RY Ss0gkQlfEHMtrGhTp5y9HzN2s9YA7VHhLvWMQ2vAeSW+KKazO5WjulJ0ftOtbP6mVd//RwdGTm8wr oB0onNRZKrJylpYotilyPCmOqH6g13VvmhV14ewOeOxG4jp52L+OrV4zT96OpApHwjGdMMBwMTQ45 E0mQL6RrxDimx5Whkbz/03pWHyBO85x7wAe89b1eDhNz3y0RCUb5kKJdW28dg6I8HMP9Hq7z1epvc Q9KEzyESqtxZdIXWvzDURXIkCejAItOen7MuFNkWbVuhpgLrMbYTKAismT9Qll4ZYSZ0TIMa+t6o4 WeT6KZaNkWotwz7ao6PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVwt-0000000A2O0-0YVg; Wed, 27 Mar 2024 16:16:23 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVwq-0000000A2NX-1FDz for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 16:16:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id BA2D1CE24F3; Wed, 27 Mar 2024 16:16:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5CADC433C7; Wed, 27 Mar 2024 16:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711556177; bh=On495Vosho8yghuPe/ZcVehrvgix78EySfxCo6i6kY8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=afq6nzfsTajwNl8LvbUonLyvoZy88ahtEF+Fkmr8Gp55VWkjLs02RvASLRTcGlPw9 A3k0+c1v5Oru+8yj3BFHimVUIVe4OlixbdFKebF2ujjugw6eNhDo/O9u9W8H8tIN3l YydxW0Vv+8AEQLXDLSm04PLqYwyGSDe6yaspn7eTWUW80gV+PCVCEWC7il7Ul4mNrY SwqO6F0OkjmS2ihwcJsLxTCZShaQsiShwljjoSa214PxaVDT/DjdHpGCmWS9dlAORe v7dPwEHLncbOl4VOkta++OzMHyOOBBuAXEiCm2WRsWW2f74aR42cEmKBCqEIFLKCDP Q2VEXR1vc5xmg== Date: Wed, 27 Mar 2024 16:16:07 +0000 From: Simon Horman To: Bartosz Golaszewski Cc: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v6 12/16] PCI/pwrctl: add PCI power control core code Message-ID: <20240327161607.GQ403975@kernel.org> References: <20240325131624.26023-1-brgl@bgdev.pl> <20240325131624.26023-13-brgl@bgdev.pl> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240325131624.26023-13-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_091620_715104_42DE343C X-CRM114-Status: GOOD ( 34.08 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 25, 2024 at 02:16:20PM +0100, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > Some PCI devices must be powered-on before they can be detected on the > bus. Introduce a simple framework reusing the existing PCI OF > infrastructure. > > The way this works is: a DT node representing a PCI device connected to > the port can be matched against its power control platform driver. If > the match succeeds, the driver is responsible for powering-up the device > and calling pcie_pwrctl_device_set_ready() which will trigger a PCI bus > rescan as well as subscribe to PCI bus notifications. > > When the device is detected and created, we'll make it consume the same > DT node that the platform device did. When the device is bound, we'll > create a device link between it and the parent power control device. > > Signed-off-by: Bartosz Golaszewski Hi Bartosz, some minor Kernel doc nits from my side. ... > diff --git a/drivers/pci/pwrctl/core.c b/drivers/pci/pwrctl/core.c ... > +/** > + * devm_pci_pwrctl_device_set_ready - Managed variant of > + * pci_pwrctl_device_set_ready(). > + * nit: @dev should be documented here > + * @pwrctl: PCI power control data > + * > + * Returns: > + * 0 on success, negative error number on error. > + */ > +int devm_pci_pwrctl_device_set_ready(struct device *dev, > + struct pci_pwrctl *pwrctl) > +{ > + int ret; > + > + ret = pci_pwrctl_device_set_ready(pwrctl); > + if (ret) > + return ret; > + > + return devm_add_action_or_reset(dev, > + devm_pci_pwrctl_device_unset_ready, > + pwrctl); > +} > +EXPORT_SYMBOL_GPL(devm_pci_pwrctl_device_set_ready); > + > +MODULE_AUTHOR("Bartosz Golaszewski "); > +MODULE_DESCRIPTION("PCI Device Power Control core driver"); > +MODULE_LICENSE("GPL"); > diff --git a/include/linux/pci-pwrctl.h b/include/linux/pci-pwrctl.h > new file mode 100644 > index 000000000000..ae8324ea7eeb > --- /dev/null > +++ b/include/linux/pci-pwrctl.h > @@ -0,0 +1,51 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (C) 2024 Linaro Ltd. > + */ > + > +#ifndef __PCI_PWRCTL_H__ > +#define __PCI_PWRCTL_H__ > + > +#include > + > +struct device; > +struct device_link; > + > +/* > + * This is a simple framework for solving the issue of PCI devices that require > + * certain resources (regulators, GPIOs, clocks) to be enabled before the > + * device can actually be detected on the PCI bus. > + * > + * The idea is to reuse the platform bus to populate OF nodes describing the > + * PCI device and its resources, let these platform devices probe and enable > + * relevant resources and then trigger a rescan of the PCI bus allowing for the > + * same device (with a second associated struct device) to be registered with > + * the PCI subsystem. > + * > + * To preserve a correct hierarchy for PCI power management and device reset, > + * we create a device link between the power control platform device (parent) > + * and the supplied PCI device (child). > + */ > + > +/** > + * struct pci_pwrctl - PCI device power control context. > + * @dev - Address of the power controlling device. nit: I think this should be "@dev: " rather than "@dev - " As is, "./scripts/kernel-doc -none" complains. > + * > + * An object of this type must be allocated by the PCI power control device and > + * passed to the pwrctl subsystem to trigger a bus rescan and setup a device > + * link with the device once it's up. > + */ > +struct pci_pwrctl { > + struct device *dev; > + > + /* Private, don't use. */ I think Private needs to be followed by a ':' rather than a ',' to keep kernel-doc happy. > + struct notifier_block nb; > + struct device_link *link; > +}; > + > +int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl); > +void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl); > +int devm_pci_pwrctl_device_set_ready(struct device *dev, > + struct pci_pwrctl *pwrctl); > + > +#endif /* __PCI_PWRCTL_H__ */ > -- > 2.40.1 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel