From patchwork Tue Dec 31 09:43:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13923731 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 59905191489; Tue, 31 Dec 2024 09:44:14 +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=1735638254; cv=none; b=Y1c6SnKwfgfTghLRHINKULwnMahvKFgI0ykaXh8PNL2yAJPqYZi+Gi0HuUHbMfJcMBplm8FMv8QosdcDfzyTp54D7Ye70+vFC7SlT6CpKamSljW3cN2ttmxLe5a98MUCNu08tsAIp/VfaJXw8Ji85baegeJO+KJM1Stsm0iNl5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735638254; c=relaxed/simple; bh=EtKM6ndxdOTEv3Lg6SK1avX9h/VksamOyCmNxI9AcNU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gBae8/C4WpjTwqQxU2ih6V4Dda4C53d0jD6k9yVhySEt2qpGrBUzMEImCQDJVygQ6x4f/XO+0Gm95jqI19q1OJzV42FXqXIhSi3TV4laWWkyHq8OadAYnn0lnflMxGTA070NrrEjwAGagG76resh7e7J1A+56L02NdM7FNMynBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=quNSMcgx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="quNSMcgx" Received: by smtp.kernel.org (Postfix) with ESMTPS id E1D64C4CEDD; Tue, 31 Dec 2024 09:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735638254; bh=EtKM6ndxdOTEv3Lg6SK1avX9h/VksamOyCmNxI9AcNU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=quNSMcgxiOtOJ188x/I+EJkt0rXpKxGIP+z/8Cxx5dX0iPn4zab6RsRU797akhLW6 k3kWfoa3hPqSeiIp0bo/af1TeacxZJmeWjn9q6zj7Z4QAnXxbN8Q14xe75+JY0RnQC mR7ztg+moetsN9F4beFtR/HGpEUVSc2WRRTr2Mv3cj662y+GaIMoQqo3/J+d5/VXJE eN6+EEYgXzyF8WQeoCuTjl4wMXKDkG8WW05u9fTMs49E9JI/FnBRGbHLMo88mlPj1n lSJsYY8iipgEFtSTBr6Mi9OHHWGDziZ4PKOACKkiUkXs5eFiUelztUe6QOeElBIw5M MVMV5pEqZYXqg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC530E77194; Tue, 31 Dec 2024 09:44:13 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 31 Dec 2024 15:13:42 +0530 Subject: [PATCH v2 1/6] regulator: Guard of_regulator_bulk_get_all() with CONFIG_OF Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241231-pci-pwrctrl-slot-v2-1-6a15088ba541@linaro.org> References: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> In-Reply-To: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> To: Bjorn Helgaas , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Qiang Yu , Manivannan Sadhasivam , Liam Girdwood , Mark Brown , kernel test robot X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2865; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=K+DYdieboNDk57dwVIEL7f2cQO+VTMxu2E7c8/n7Jlo=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnc7zqTMNVJc/B8DvCcn2G3OvvaTAA8fnoqVLv0 2ZwUIbqNt2JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ3O86gAKCRBVnxHm/pHO 9ZQhB/41JoxXANcG/9Tbc6G33jRxLNfoE/73Y3y9qigHsQ5X7/5RafygZfY4p79ClS3RIE5w4eB UahE3ASO8oYFZkN+sLicBX7NuVSe3qamxrcH0hWra+xz/D2BxAvJjXRDT5Mj1+I5HnWfI2kBETJ qmL/B6y7QOpDEfXftuWufkOA7NGj1ue4nKO6hn7ghLwoIqF4Or5XukrsFDR3zm8NSW74VuJ+vkq xbPXdIEvGXSW4+8MrCnEP+5uT7m7vQ86kknvDGcN654sYs1glDWOFOBnUKEJmnf2q/DwSAZtxHC nc+OapDZchATmfw/WgsZoztkd7yCskuTgSLQg0WEbuIXGwFV X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam Since the definition is in drivers/regulator/of_regulator.c and compiled only if CONFIG_OF is enabled, building the consumer driver without CONFIG_OF and with CONFIG_REGULATOR will result in below build error: ERROR: modpost: "of_regulator_bulk_get_all" [drivers/pci/pwrctrl/pci-pwrctl-slot.ko] undefined! Cc: Liam Girdwood Cc: Mark Brown Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202412181640.12Iufkvd-lkp@intel.com/ Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski --- include/linux/regulator/consumer.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 8c3c372ad735..85be83c8fa17 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -175,6 +175,8 @@ struct regulator *__must_check of_regulator_get_optional(struct device *dev, struct regulator *__must_check devm_of_regulator_get_optional(struct device *dev, struct device_node *node, const char *id); +int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np, + struct regulator_bulk_data **consumers); #else static inline struct regulator *__must_check of_regulator_get_optional(struct device *dev, struct device_node *node, @@ -189,6 +191,13 @@ static inline struct regulator *__must_check devm_of_regulator_get_optional(stru { return ERR_PTR(-ENODEV); } + +static inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, + struct regulator_bulk_data **consumers) +{ + return 0; +} + #endif int regulator_register_supply_alias(struct device *dev, const char *id, @@ -223,8 +232,6 @@ int regulator_disable_deferred(struct regulator *regulator, int ms); int __must_check regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers); -int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np, - struct regulator_bulk_data **consumers); int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers); void devm_regulator_bulk_put(struct regulator_bulk_data *consumers); @@ -483,12 +490,6 @@ static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, return 0; } -static inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, - struct regulator_bulk_data **consumers) -{ - return 0; -} - static inline int devm_regulator_bulk_get_const( struct device *dev, int num_consumers, const struct regulator_bulk_data *in_consumers, From patchwork Tue Dec 31 09:43:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13923729 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 5980913B7AE; Tue, 31 Dec 2024 09:44:14 +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=1735638254; cv=none; b=LAGsFR1QaRKXRVp/1KFlxR3IcxcGFL40IXlecH85FGWTIi4xwHuJv1C2Tt3mn6D/QtSeLe9VbUSPe25a8nu5LMiqzKtJn2/u4zF7ezDJpiEQlQeltfft7sKMgHXm2BlSTtqpGspqf0f+e6PMuey8VvhO0g7F9OCdZFfFK5I4JGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735638254; c=relaxed/simple; bh=WIQv3KD1TnKJ1FeAsp5Ms4Qm3siNonfJRB+TKoH/FEE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SVMcANEOGzC/WyDmESGKkzPDxxHw1iGlQjwNqWL0Ov5XpPBvxunKGxAHgfwqkeR3uywz/lSwSL7XYdtWweTr1ecHh5pDmitpNZp9xSgEQZvFZ6YomXDawIOcTyrVmZKm26451/upgP0ADd+bao3VZLjXyoYu1xA8MJB+tkTaHPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dUbfyxUA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dUbfyxUA" Received: by smtp.kernel.org (Postfix) with ESMTPS id EE1E2C4CEDC; Tue, 31 Dec 2024 09:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735638254; bh=WIQv3KD1TnKJ1FeAsp5Ms4Qm3siNonfJRB+TKoH/FEE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dUbfyxUA+NglW7iGzI8XkC+z8l6lULCZnKa8ertvZwmeN9oT80i9MfvxgXF4xgFK5 pHO97di83BhHWpLSo67xIW7L7I/WAG3ITI2bHNa0NBQ5fGa4aobUocLNeSJR0Mtqiq m4kLfyzSQRoBkqtUMk35omqk/2iJ+RRU/fnOFSh/eBASnKIOmftdsqyfHnqDuITJ50 7JPd4yoouD7VYOzMoMlsavdIcfmVjnhB4resKU/tpEZvlmtRvadgrkzsv9yaNOSC7r a5bdx8YjdS5V4OhFptO8kgvoX0K5qVb5D72Dy6i62ZKVBzHMecbN1Nrlo/yX2xk8wm YW6ZQ/1RLgvkA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD2D7E77197; Tue, 31 Dec 2024 09:44:13 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 31 Dec 2024 15:13:43 +0530 Subject: [PATCH v2 2/6] PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device() Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241231-pci-pwrctrl-slot-v2-2-6a15088ba541@linaro.org> References: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> In-Reply-To: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> To: Bjorn Helgaas , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Qiang Yu , Manivannan Sadhasivam , Lukas Wunner , Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5697; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=xIyJbEnDR6J92iNeHDHLDUlZlBfz305fAs7wXMTBhwA=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnc7zqGVqYCh9zKJ8rTHRjIBT+/jHKlwSn7ef3r Kv6bAH2d8CJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ3O86gAKCRBVnxHm/pHO 9UT0CACfn6kB5rPiWJ/jqdgHu1VMtAl/CKZg5GnkOq89WvfjVpOKJXZmM7AbUsGAvG3BXH9tCQP Em5ugKdexFWq/pogVtDpTeFaJkAx86m/cZm1srlA2StMancVgsi+xD5iomWwxhFbY5LsGs8YrBA RhptUPi3ZA6QglfCRj/xiz3mFbyHvW9ePk+5oabdhWEyjVbkgGwPlfgx156sENXtzPT7gI+NqwW nYE8fmCn8UO1iuaOXIlKbiItWZhI2poz/X+pfKH1po1/Boh/eHdWX5/dHzWu7g5W6QVjWUCh/Rr QnlLGBJSXtoSeukh4iUPSQ17JuVDuSf68OS83ow8Z6AVjecF X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam Current way of creating pwrctrl devices requires iterating through the child devicetree nodes of the PCI bridge in pci_pwrctrl_create_devices(). Even though it works, it creates confusion as there is no symmetry between this and pci_pwrctrl_unregister() function that removes the pwrctrl devices. So to make these two functions symmetric, move the creation of pwrctrl devices to pci_scan_device(). During the scan of each device in a slot, the devicetree node (if exists) for the PCI device will be checked. If it has the supplies populated, then the pwrctrl device will be created. Since the PCI device scan happens so early, there would be no 'struct pci_dev' available for the device. So the host bridge is used as the parent of all pwrctrl devices. One nice side effect of this move is that, it is now possible to have pwrctrl devices for PCI bridges as well (to control the supplies of PCI slots). Suggested-by: Lukas Wunner Tested-by: Bartosz Golaszewski Signed-off-by: Manivannan Sadhasivam --- drivers/pci/bus.c | 43 ------------------------------------------- drivers/pci/probe.c | 34 ++++++++++++++++++++++++++++++++++ drivers/pci/pwrctrl/core.c | 2 +- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 98910bc0fcc4..b6851101ac36 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -331,47 +331,6 @@ void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { } void __weak pcibios_bus_add_device(struct pci_dev *pdev) { } -/* - * Create pwrctrl devices (if required) for the PCI devices to handle the power - * state. - */ -static void pci_pwrctrl_create_devices(struct pci_dev *dev) -{ - struct device_node *np = dev_of_node(&dev->dev); - struct device *parent = &dev->dev; - struct platform_device *pdev; - - /* - * First ensure that we are starting from a PCI bridge and it has a - * corresponding devicetree node. - */ - if (np && pci_is_bridge(dev)) { - /* - * Now look for the child PCI device nodes and create pwrctrl - * devices for them. The pwrctrl device drivers will manage the - * power state of the devices. - */ - for_each_available_child_of_node_scoped(np, child) { - /* - * First check whether the pwrctrl device really - * needs to be created or not. This is decided - * based on at least one of the power supplies - * being defined in the devicetree node of the - * device. - */ - if (!of_pci_supply_present(child)) { - pci_dbg(dev, "skipping OF node: %s\n", child->name); - return; - } - - /* Now create the pwrctrl device */ - pdev = of_platform_device_create(child, NULL, parent); - if (!pdev) - pci_err(dev, "failed to create OF node: %s\n", child->name); - } - } -} - /** * pci_bus_add_device - start driver for a single device * @dev: device to add @@ -396,8 +355,6 @@ void pci_bus_add_device(struct pci_dev *dev) pci_proc_attach_device(dev); pci_bridge_d3_update(dev); - pci_pwrctrl_create_devices(dev); - /* * If the PCI device is associated with a pwrctrl device with a * power supply, create a device link between the PCI device and diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2e81ab0f5a25..91bdb2727c8e 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -2446,6 +2448,36 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); +/* + * Create pwrctrl device (if required) for the PCI device to handle the power + * state. + */ +static void pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) +{ + struct pci_host_bridge *host = pci_find_host_bridge(bus); + struct platform_device *pdev; + struct device_node *np; + + np = of_pci_find_child_device(dev_of_node(&bus->dev), devfn); + if (!np || of_find_device_by_node(np)) + return; + + /* + * First check whether the pwrctrl device really needs to be created or + * not. This is decided based on at least one of the power supplies + * being defined in the devicetree node of the device. + */ + if (!of_pci_supply_present(np)) { + pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name); + return; + } + + /* Now create the pwrctrl device */ + pdev = of_platform_device_create(np, NULL, &host->dev); + if (!pdev) + pr_err("PCI/pwrctrl: Failed to create pwrctrl device for OF node: %s\n", np->name); +} + /* * Read the config data for a PCI device, sanity-check it, * and fill in the dev structure. @@ -2455,6 +2487,8 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) struct pci_dev *dev; u32 l; + pci_pwrctrl_create_device(bus, devfn); + if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) return NULL; diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c index 2fb174db91e5..9cc7e2b7f2b5 100644 --- a/drivers/pci/pwrctrl/core.c +++ b/drivers/pci/pwrctrl/core.c @@ -44,7 +44,7 @@ static void rescan_work_func(struct work_struct *work) struct pci_pwrctrl, work); pci_lock_rescan_remove(); - pci_rescan_bus(to_pci_dev(pwrctrl->dev->parent)->bus); + pci_rescan_bus(to_pci_host_bridge(pwrctrl->dev->parent)->bus); pci_unlock_rescan_remove(); } From patchwork Tue Dec 31 09:43:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13923730 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 5986618755C; Tue, 31 Dec 2024 09:44:14 +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=1735638254; cv=none; b=d6O8phGX9AdJLs7IkgrkrpiykvYbEEir5HUEJr8JcS4EVQn15oHqFy3a1mg9CC0wbtVUvt9caXml8TIyMeXmDxada6nDhePzHD6H+NQVDjip8f9qOeLPw+QMdtfWSa8lCyaj6KGf8HmEUeyk4x+6imizSWf9RAvxUWe1QGGdGm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735638254; c=relaxed/simple; bh=pJh5AXQbg+1t0rZcEXAK+EutSUZovxAeK8iPRrFkzhw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tYy4F65TFBeYCCM4LECT/afmNEwJPSdXATOOj8gKFLAGxq9CcMDco/lu5l+Bh0QL2oK9LoQR26DCphgEiLlJSW8kJ4vgSrYlBtro+7VyyyCFytgw/4GhR4Z3JvfcNanGsagvlVE2DeeToIwZvXFkn6H+jHXoeNQDRj2pywvveiw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BMiUKz7l; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BMiUKz7l" Received: by smtp.kernel.org (Postfix) with ESMTPS id 07F0AC4AF0B; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735638254; bh=pJh5AXQbg+1t0rZcEXAK+EutSUZovxAeK8iPRrFkzhw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BMiUKz7lisA2K0V+mD5cocp88f5HWquX6gKMKiG++4iBBGSNWzxFhuxSintp5mNnD Hu4nleDkPJ0U4JiOdZO6v0C1bN7Hk52xleoLyTN/yK0NxM707pXddXI51/rPWtO/Wo eVtLZmk3bGTfEPom6shJwhWAF3J6rHKgklViFCUJR9PcS7v9a63VBbGBGQUqhX1KhQ 13lIKq+cZ8ZO2e3mc4g8SW1Z/MPwkaiY7tsYx0lzcLXeN4ytM4WEVXY0ijx7w3OnEx 0l3XV68zfYrVX7vmOjF/HTISU4mg1FRIOkxaxmlRIZ2hA8Ex7w2ID82NhgaMgaKK/6 CRTWTryBKSKjA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAA88E7718B; Tue, 31 Dec 2024 09:44:13 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 31 Dec 2024 15:13:44 +0530 Subject: [PATCH v2 3/6] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev() Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241231-pci-pwrctrl-slot-v2-3-6a15088ba541@linaro.org> References: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> In-Reply-To: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> To: Bjorn Helgaas , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Qiang Yu , Manivannan Sadhasivam , Lukas Wunner , Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1293; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=R/h8mRffg4ftb0mSxAjhuMkQ2AXNpRy+KTjYeuy7GyY=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnc7zqe/gxeg/v0jwc0tTdNPblhXylvQuh5P3pm uD8mA3Lzy2JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ3O86gAKCRBVnxHm/pHO 9Ym1B/4rWPv8lWQeEs4wVzLMvuKJ2+Bw9inpcseTx8Fp78JHx7SvU58LyUKncjTs5Zgql2CmBij TAjENRBZe4G/xUcAwFBxmbKUFB8beiO4YCV+Uar8NfEeQW4hb2zD83VRHJTHvglGxk48LI6kflQ +0Y1wGsOk42NLIAkimf/bhPZehhvTgiE1NRgFUH2LjjMJGqtzPtJ2N+QpqPVuQVUjJFqU5NMWok fpyP+ev3iDbwhZjjzJpspXbaYegoERYMcav0GZa31tq8WhYdm7en7AW492hNaS+JigrG5XDv1l1 G2/RZRAuMZp/YLJkPFX2+5RMFima3rmybEt/boxIU0AbDNbB X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam PCI core will try to access the devices even after pci_stop_dev() for things like Data Object Exchange (DOE), ASPM etc... So move pci_pwrctrl_unregister() to the near end of pci_destroy_dev() to make sure that the devices are powered down only after the PCI core is done with them. Suggested-by: Lukas Wunner Reviewed-by: Lukas Wunner Tested-by: Bartosz Golaszewski Signed-off-by: Manivannan Sadhasivam --- drivers/pci/remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index efc37fcb73e2..58859f9d92f7 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -41,7 +41,6 @@ static void pci_stop_dev(struct pci_dev *dev) if (!pci_dev_test_and_clear_added(dev)) return; - pci_pwrctrl_unregister(&dev->dev); device_release_driver(&dev->dev); pci_proc_detach_device(dev); pci_remove_sysfs_dev_files(dev); @@ -64,6 +63,7 @@ static void pci_destroy_dev(struct pci_dev *dev) pci_doe_destroy(dev); pcie_aspm_exit_link_state(dev); pci_bridge_d3_update(dev); + pci_pwrctrl_unregister(&dev->dev); pci_free_resources(dev); put_device(&dev->dev); } From patchwork Tue Dec 31 09:43:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13923733 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 599521925A6; Tue, 31 Dec 2024 09:44:14 +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=1735638254; cv=none; b=fQlD8M0dA9QJPBOv8m5TRTgZjOUPOrW5rZG2jPOjjhNUwgYePpoNOpMd7TOyT9KUXd5iv116tl9MtQ5mcaeB9znKAoKqrxRGTdMpBRFpN0a0D9QBg4ieUVXrltMDZM22JHZaiBYj9V6ZAikht6WrIOIYCWSFzXMuXW9XcyNWci4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735638254; c=relaxed/simple; bh=I85exvHlAdHCyIBwyyJVeayckDAvYb7ppB240+u+sv0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TvlN5cLpuwxOQJMPaNReKW6C+g1UlvMS1y4aSk1ssWq0CWwEaYBj8vPvUsD1bjf2iVVm4dKnr6DbWtQaVTeZ30KOPeVzcRfX9eVFqEJl6TOn7K2XnPPY5WWepV2xB+GpaF6bGFhd8sqrW/2/0rYnHCeHMqZlLL2dRpj9FmQ+0IY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TIhtr13R; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TIhtr13R" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0FB83C4CEE1; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735638254; bh=I85exvHlAdHCyIBwyyJVeayckDAvYb7ppB240+u+sv0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TIhtr13RstXyb56XfTTTu+LxMCmB14Y4yX9/IxxWddXSl3kPmQmhDau/E5rRO17ca XXar4lI7l3ey9YoOrb8ttJNbZ48cFASvD28pkJNjxMAguwhoRxPOvXYhBr29IPKf6M EBGWrM6fSD3s+C1DcFTZAne98DZbS6v4bC5BYLVrf1J3kCHlNKeG8EnmLz8Mi21jFr UQd0Lrvh5gDqjWjpaJbA3lXUUklJdzDvjkW4KIeZfXFHgOj35jzWhvPKcpdk069neV G8mq5sIFemW39aulyIM2egOKZK44X4bDjOogefSS8E60I7vRw99I4TCfKoWoMIz8p3 o5r5MTpV/2Ipw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08986E77188; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 31 Dec 2024 15:13:45 +0530 Subject: [PATCH v2 4/6] PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241231-pci-pwrctrl-slot-v2-4-6a15088ba541@linaro.org> References: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> In-Reply-To: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> To: Bjorn Helgaas , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Qiang Yu , Manivannan Sadhasivam X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2479; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=ZL4/V6JFUdmO0YAXp+rd+0EQhZLXt3iJU/vJV6wd1WE=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnc7zreRTAGViodhIerB4qBU+JGtkIrfAxenxfp 1BjYCey/LCJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ3O86wAKCRBVnxHm/pHO 9Xo5B/4k+7/RJtlU1DjUuo7dbArcYUOgE4GUwF22dv/aaIMygYddilkPq2OMFf+y/EGPrpqoXun LGMhs0Sj5Cqw2CY8wbsNpwU9RXLwfL9L66StOq7Koq3sbq2++3DwTKuSMD6wkZES6MeFT3YMVf3 OM72sPqwIPIiW7MLDhvyCYWaylUX2Dc1pjTLndJ3Jiuphzk7PaVuGofY5EmKQ7MdWGhwKzdyP+v BvdSLJH7W6A+5eZ1vrUC8py6a2qsH+m7LJVpPkk0Y6yZ14UT2O0Eue1wJjPkABHxEDq18Sv3BtQ WW3CO76Fqxh1qREaveLfBycZMwv41a6FWwoGEWojQFOwnrvy X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam The pwrctrl core will rescan the bus once the device is powered on. So there is no need to continue scanning for the device further. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski --- drivers/pci/probe.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 91bdb2727c8e..6121f81f7c98 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2448,11 +2448,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); -/* - * Create pwrctrl device (if required) for the PCI device to handle the power - * state. - */ -static void pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) +static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) { struct pci_host_bridge *host = pci_find_host_bridge(bus); struct platform_device *pdev; @@ -2460,7 +2456,7 @@ static void pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) np = of_pci_find_child_device(dev_of_node(&bus->dev), devfn); if (!np || of_find_device_by_node(np)) - return; + return NULL; /* * First check whether the pwrctrl device really needs to be created or @@ -2469,13 +2465,17 @@ static void pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) */ if (!of_pci_supply_present(np)) { pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name); - return; + return NULL; } /* Now create the pwrctrl device */ pdev = of_platform_device_create(np, NULL, &host->dev); - if (!pdev) - pr_err("PCI/pwrctrl: Failed to create pwrctrl device for OF node: %s\n", np->name); + if (!pdev) { + pr_err("PCI/pwrctrl: Failed to create pwrctrl device for node: %s\n", np->name); + return NULL; + } + + return pdev; } /* @@ -2487,7 +2487,14 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) struct pci_dev *dev; u32 l; - pci_pwrctrl_create_device(bus, devfn); + /* + * Create pwrctrl device (if required) for the PCI device to handle the + * power state. If the pwrctrl device is created, then skip scanning + * further as the pwrctrl core will rescan the bus after powering on + * the device. + */ + if (pci_pwrctrl_create_device(bus, devfn)) + return NULL; if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) return NULL; From patchwork Tue Dec 31 09:43:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13923734 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 A84C5196D90; Tue, 31 Dec 2024 09:44:14 +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=1735638254; cv=none; b=X1STClOovc0LEiXMuIf/gm5YjQJq9w9U9GrYRZbAd5gKdw5S3DzW/32WWu8BJnSjcUxjcIe8zlonA/hxDMszJ58+YYcZEr7XNF0SAamhu5JOf0JR/qNb7IG75/lbovmkl/7Q3DSGKF8nr4DJvpA5S6uK4oPO1q/yZEgsv01McPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735638254; c=relaxed/simple; bh=EmN4Jn2rIvX97LgY0ou3YPQGNYpXchenEI59Nhj03LU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JVhk0eNyPF3sHDWkfeO7uLa47FESR8zigNEEdhGlKgDK2PLOgWZ6RTee+T5Vy2TKA8009R+/lEeIm8e8EkqL35kc8EOsth7fRJZGlCylTjrnwYKEKmXeyIx/m0NYO0+gbl8p6B2FbbeWndQf/WobEBQpITUBhOR7mgy5xZUPBYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tg3uclUb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tg3uclUb" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2182BC4CEE6; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735638254; bh=EmN4Jn2rIvX97LgY0ou3YPQGNYpXchenEI59Nhj03LU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=tg3uclUbsdQ2rvF1gDq962DdXJWsUR5eWkQoKINsvc45XAtFyj6m33jNXCO5zOrU8 f2KuRYEuZ2uQQG5Gf++0KKXHXkfT8lmE8XxTqMvKrjA8LbO74tY8/3UC9+xIzCFSYb gSZIaSnjGZ3XMxptZmKAKcFVQ8cd2PYUf7V+durV+q/eOb3c7V9sbJ0ZNfw72duMAI puuDKzRTEjrrLjbbdOLp95HOec8Qp8apRFkLeW1S+zyMFq9wvub4/66iPMP59e62hV mVb5h/NnjCSM3aRAhKbwjVXGjZvQ7Vl71+MvQIbQFw1QZfU4XuFuPX3nBfTVlwYSCg yVow+gSbrL98w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1570DE77194; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 31 Dec 2024 15:13:46 +0530 Subject: [PATCH v2 5/6] dt-bindings: vendor-prefixes: Document the 'pciclass' prefix Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241231-pci-pwrctrl-slot-v2-5-6a15088ba541@linaro.org> References: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> In-Reply-To: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> To: Bjorn Helgaas , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Qiang Yu , Manivannan Sadhasivam , Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1265; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=2V7zx2KeHk/VkOVQ7/eUdxe/lfsvltP4xYw5h/bK3Jg=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnc7zrdciV1jQWsadhJ4t7js4Cn7Ak714NgV2do SpaQY946HaJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ3O86wAKCRBVnxHm/pHO 9Ww/B/wNerD31lCjE4OJmIqxQWZOqcYw66Ta2d/3+wwFEIL6JD4t1JgG2jL4MpUM78L0AcQO1VD ga8zNq0guDXRBO9DiyWZnziUcnARZccKeQ0uJD/Jtd937noG2D9fAld8rE9pePmYTCJLG821BO0 4N0V/jwr2uE6kxDFFU5flAp/65B8TMAstqX8ztjzDclxDWsrd9kTcnaPeJmvHuxYBFT6ChUtswZ H+1RImAANVNEIJfCP1UICzTDIoZDRE4qOAb2aUVTYAoDFdSh2oEtNv/FrGgWmMtuz0UYhux0e3C CneMG3xbsj2tInJeElO3YgsFrFHMxHdaMAkQTa/4EWQDc3bM X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam 'pciclass' is an existing prefix used to identify the PCI bridge devices, but it is not a vendor prefix. So document it in the non-vendor prefix list. Tested-by: Bartosz Golaszewski Acked-by: Rob Herring (Arm) Signed-off-by: Manivannan Sadhasivam --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index da01616802c7..0539aea6af5a 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -18,7 +18,7 @@ patternProperties: # DO NOT ADD NEW PROPERTIES TO THIS LIST "^(at25|bm|devbus|dmacap|dsa|exynos|fsi[ab]|gpio-fan|gpio-key|gpio|gpmc|hdmi|i2c-gpio),.*": true "^(keypad|m25p|max8952|max8997|max8998|mpmc),.*": true - "^(pinctrl-single|#pinctrl-single|PowerPC),.*": true + "^(pciclass|pinctrl-single|#pinctrl-single|PowerPC),.*": true "^(pl022|pxa-mmc|rcar_sound|rotary-encoder|s5m8767|sdhci),.*": true "^(simple-audio-card|st-plgpio|st-spics|ts),.*": true From patchwork Tue Dec 31 09:43:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13923735 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 A9F1F197552; Tue, 31 Dec 2024 09:44:14 +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=1735638254; cv=none; b=DPthiYI3zzfULig04BxeV5qAHuCDwlzxW7PufYfnrVkEO909RIqrMQYl0nDJadwxD9WMxH8l5RyPGDkn/SYzV4qwMROeV3hJn1Qvsfd88Penv3FY53lGHYM2OuEx6DCy3zjYhp5qpZ1uqlnxaN3Q/SYBjwwf2cvrLh7u0oHPD74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735638254; c=relaxed/simple; bh=AC4CmZODc6zttOyIPBfDblh9cJnGUWWU4vNPYxPmyso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sianb0/0KEDCa2lTkEplgcSvDY47rxtl6odYhtBrE0qx1mTJcsLmtv2mn8KlD/skQNQhRCcVLx2GyfiJ1Tp95xBg03SxISdLQutUv+8V7CUJs3amkhSApPVxONYFhRrJpQAjcIYABTjIopHAprLdvJsycdW/GxV45uZGJQz9lXw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o2DsjmP/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o2DsjmP/" Received: by smtp.kernel.org (Postfix) with ESMTPS id 32677C4AF16; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735638254; bh=AC4CmZODc6zttOyIPBfDblh9cJnGUWWU4vNPYxPmyso=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=o2DsjmP/5yWrrBljpQzy1Id7cdaQXN+Qt01qw9sfb+V1lW+0IX6F8/yZe7rPl7YWg TnMEdLVWjv0bzCzIVXL/4GuNy6Y6mRAmWWyEuYqFqZZ4GNbSlAraR7YpqIOFfUiyq3 lZXruJFihWhB/kK/JbSPAQ0gcgm4umkQht6+4XS0pHPLMC2idpr72O9ZLnctBXZVI5 n4y8bC09ym4V1DjH1dlVlh0FOio/7EQc+VtcjpbaMaYoHHwy2/kE3nllMEWF1UMyvc Dj3+cSBkOYhrZXT2FKD0Hf2/tQR+5+UZZNBe6L9AGYkBSWjQVn3joLMJxXxZVSHCQ9 Uwivw5Zg+t3DQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2555FE77198; Tue, 31 Dec 2024 09:44:14 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 31 Dec 2024 15:13:47 +0530 Subject: [PATCH v2 6/6] PCI/pwrctrl: Add pwrctrl driver for PCI Slots Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241231-pci-pwrctrl-slot-v2-6-6a15088ba541@linaro.org> References: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> In-Reply-To: <20241231-pci-pwrctrl-slot-v2-0-6a15088ba541@linaro.org> To: Bjorn Helgaas , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Andersson , Konrad Dybcio , Qiang Yu , Manivannan Sadhasivam , Bartosz Golaszewski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5046; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=5dX65BdkoJK96uXxbW3egypDqFuEy1NtN49QNZGGNsE=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnc7zr7I0vWAahaKk1DBFdKMQZ91pYlEUDFnSrL RAnljRPpcCJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ3O86wAKCRBVnxHm/pHO 9cZWB/91OJ2SOc0tiIbMRhbFZqRG+z01zOJH0m32xtqf6742piljnQrylYQ0cLvKDgZm445jn1V 9lM71Iz+aCLBEZeF2hbBdtEEIh6CmRUBDB+YcpwOsb7P0HVnbmt8ECjXQsu7cEQabuuRyyVzFtf aORILbefzyiIoeOsyKrPYsslnxx4gQp8c9r3+97crDAgA5yK3odKXzPuNkJk63tGJAWgRSJ1+zx LOlHQktW5LyVKJOTT4BAMyuT7SnHlpFa7KJo1+po33EXCoJSl0lceV6j7SEWq5PVlPB1eJvMoab wZ9qu9kz1JIVcWWwSz4OKGmpmlrqOftdCZVwfks/eeqg3mN8 X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam This driver is used to control the power state of the devices attached to the PCI slots. Currently, it controls the voltage rails of the PCI slots defined in the devicetree node of the root port. The voltage rails for PCI slots are documented in the dt-schema: https://github.com/devicetree-org/dt-schema/blob/v2024.11/dtschema/schemas/pci/pci-bus-common.yaml#L153 Since this driver has to work with different kind of slots (x{1/4/8/16} PCIe, Mini PCIe, PCI etc...), the driver is using the of_regulator_bulk_get_all() API to obtain the voltage regulators defined in the DT node, instead of hardcoding them. The DT node of the root port should define the relevant supply properties corresponding to the voltage rails of the PCI slot. Tested-by: Bartosz Golaszewski Signed-off-by: Manivannan Sadhasivam --- drivers/pci/pwrctrl/Kconfig | 11 ++++++ drivers/pci/pwrctrl/Makefile | 3 ++ drivers/pci/pwrctrl/slot.c | 93 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) diff --git a/drivers/pci/pwrctrl/Kconfig b/drivers/pci/pwrctrl/Kconfig index 54589bb2403b..990cab67d413 100644 --- a/drivers/pci/pwrctrl/Kconfig +++ b/drivers/pci/pwrctrl/Kconfig @@ -10,3 +10,14 @@ config PCI_PWRCTL_PWRSEQ tristate select POWER_SEQUENCING select PCI_PWRCTL + +config PCI_PWRCTL_SLOT + tristate "PCI Power Control driver for PCI slots" + select PCI_PWRCTL + help + Say Y here to enable the PCI Power Control driver to control the power + state of PCI slots. + + This is a generic driver that controls the power state of different + PCI slots. The voltage regulators powering the rails of the PCI slots + are expected to be defined in the devicetree node of the PCI bridge. diff --git a/drivers/pci/pwrctrl/Makefile b/drivers/pci/pwrctrl/Makefile index 75c7ce531c7e..ddfb12c5aadf 100644 --- a/drivers/pci/pwrctrl/Makefile +++ b/drivers/pci/pwrctrl/Makefile @@ -4,3 +4,6 @@ obj-$(CONFIG_PCI_PWRCTL) += pci-pwrctrl-core.o pci-pwrctrl-core-y := core.o obj-$(CONFIG_PCI_PWRCTL_PWRSEQ) += pci-pwrctrl-pwrseq.o + +obj-$(CONFIG_PCI_PWRCTL_SLOT) += pci-pwrctl-slot.o +pci-pwrctl-slot-y := slot.o diff --git a/drivers/pci/pwrctrl/slot.c b/drivers/pci/pwrctrl/slot.c new file mode 100644 index 000000000000..18becc144913 --- /dev/null +++ b/drivers/pci/pwrctrl/slot.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd. + * Author: Manivannan Sadhasivam + */ + +#include +#include +#include +#include +#include +#include +#include + +struct pci_pwrctrl_slot_data { + struct pci_pwrctrl ctx; + struct regulator_bulk_data *supplies; + int num_supplies; +}; + +static void devm_pci_pwrctrl_slot_power_off(void *data) +{ + struct pci_pwrctrl_slot_data *slot = data; + + regulator_bulk_disable(slot->num_supplies, slot->supplies); + regulator_bulk_free(slot->num_supplies, slot->supplies); +} + +static int pci_pwrctrl_slot_probe(struct platform_device *pdev) +{ + struct pci_pwrctrl_slot_data *slot; + struct device *dev = &pdev->dev; + int ret; + + slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL); + if (!slot) + return -ENOMEM; + + ret = of_regulator_bulk_get_all(dev, dev_of_node(dev), + &slot->supplies); + if (ret < 0) { + dev_err_probe(dev, ret, "Failed to get slot regulators\n"); + return ret; + } + + slot->num_supplies = ret; + ret = regulator_bulk_enable(slot->num_supplies, slot->supplies); + if (ret < 0) { + dev_err_probe(dev, ret, "Failed to enable slot regulators\n"); + goto err_regulator_free; + } + + ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off, + slot); + if (ret) + goto err_regulator_disable; + + pci_pwrctrl_init(&slot->ctx, dev); + + ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->ctx); + if (ret) + return dev_err_probe(dev, ret, "Failed to register pwrctrl driver\n"); + + return 0; + +err_regulator_disable: + regulator_bulk_disable(slot->num_supplies, slot->supplies); +err_regulator_free: + regulator_bulk_free(slot->num_supplies, slot->supplies); + + return ret; +} + +static const struct of_device_id pci_pwrctrl_slot_of_match[] = { + { + .compatible = "pciclass,0604", + }, + { } +}; +MODULE_DEVICE_TABLE(of, pci_pwrctrl_slot_of_match); + +static struct platform_driver pci_pwrctrl_slot_driver = { + .driver = { + .name = "pci-pwrctrl-slot", + .of_match_table = pci_pwrctrl_slot_of_match, + }, + .probe = pci_pwrctrl_slot_probe, +}; +module_platform_driver(pci_pwrctrl_slot_driver); + +MODULE_AUTHOR("Manivannan Sadhasivam "); +MODULE_DESCRIPTION("Generic PCI Power Control driver for PCI Slots"); +MODULE_LICENSE("GPL");