Message ID | 20241231-pci-pwrctrl-slot-v2-6-6a15088ba541@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | PCI/pwrctrl: Rework pwrctrl driver integration and add driver for PCI slot | expand |
Hi Manivannan, kernel test robot noticed the following build errors: [auto build test ERROR on 40384c840ea1944d7c5a392e8975ed088ecf0b37] url: https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam-via-B4-Relay/regulator-Guard-of_regulator_bulk_get_all-with-CONFIG_OF/20241231-174751 base: 40384c840ea1944d7c5a392e8975ed088ecf0b37 patch link: https://lore.kernel.org/r/20241231-pci-pwrctrl-slot-v2-6-6a15088ba541%40linaro.org patch subject: [PATCH v2 6/6] PCI/pwrctrl: Add pwrctrl driver for PCI Slots config: x86_64-randconfig-074-20250102 (https://download.01.org/0day-ci/archive/20250102/202501020407.HmQQQKa0-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250102/202501020407.HmQQQKa0-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202501020407.HmQQQKa0-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/pci/pwrctrl/slot.c: In function 'pci_pwrctrl_slot_probe': >> drivers/pci/pwrctrl/slot.c:39:15: error: implicit declaration of function 'of_regulator_bulk_get_all'; did you mean 'regulator_bulk_get'? [-Werror=implicit-function-declaration] 39 | ret = of_regulator_bulk_get_all(dev, dev_of_node(dev), | ^~~~~~~~~~~~~~~~~~~~~~~~~ | regulator_bulk_get cc1: some warnings being treated as errors vim +39 drivers/pci/pwrctrl/slot.c 28 29 static int pci_pwrctrl_slot_probe(struct platform_device *pdev) 30 { 31 struct pci_pwrctrl_slot_data *slot; 32 struct device *dev = &pdev->dev; 33 int ret; 34 35 slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL); 36 if (!slot) 37 return -ENOMEM; 38 > 39 ret = of_regulator_bulk_get_all(dev, dev_of_node(dev), 40 &slot->supplies); 41 if (ret < 0) { 42 dev_err_probe(dev, ret, "Failed to get slot regulators\n"); 43 return ret; 44 } 45 46 slot->num_supplies = ret; 47 ret = regulator_bulk_enable(slot->num_supplies, slot->supplies); 48 if (ret < 0) { 49 dev_err_probe(dev, ret, "Failed to enable slot regulators\n"); 50 goto err_regulator_free; 51 } 52 53 ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off, 54 slot); 55 if (ret) 56 goto err_regulator_disable; 57 58 pci_pwrctrl_init(&slot->ctx, dev); 59 60 ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->ctx); 61 if (ret) 62 return dev_err_probe(dev, ret, "Failed to register pwrctrl driver\n"); 63 64 return 0; 65 66 err_regulator_disable: 67 regulator_bulk_disable(slot->num_supplies, slot->supplies); 68 err_regulator_free: 69 regulator_bulk_free(slot->num_supplies, slot->supplies); 70 71 return ret; 72 } 73
On Thu, Jan 02, 2025 at 04:56:44AM +0800, kernel test robot wrote: > Hi Manivannan, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on 40384c840ea1944d7c5a392e8975ed088ecf0b37] > > url: https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam-via-B4-Relay/regulator-Guard-of_regulator_bulk_get_all-with-CONFIG_OF/20241231-174751 > base: 40384c840ea1944d7c5a392e8975ed088ecf0b37 > patch link: https://lore.kernel.org/r/20241231-pci-pwrctrl-slot-v2-6-6a15088ba541%40linaro.org > patch subject: [PATCH v2 6/6] PCI/pwrctrl: Add pwrctrl driver for PCI Slots > config: x86_64-randconfig-074-20250102 (https://download.01.org/0day-ci/archive/20250102/202501020407.HmQQQKa0-lkp@intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250102/202501020407.HmQQQKa0-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202501020407.HmQQQKa0-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > drivers/pci/pwrctrl/slot.c: In function 'pci_pwrctrl_slot_probe': > >> drivers/pci/pwrctrl/slot.c:39:15: error: implicit declaration of function 'of_regulator_bulk_get_all'; did you mean 'regulator_bulk_get'? [-Werror=implicit-function-declaration] > 39 | ret = of_regulator_bulk_get_all(dev, dev_of_node(dev), > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > | regulator_bulk_get Sigh! The driver was built with !CONFIG_REGULATOR. This requires fixing 'include/linux/regulator/consumer.h'. Will add it in next iteration. - Mani > cc1: some warnings being treated as errors > > > vim +39 drivers/pci/pwrctrl/slot.c > > 28 > 29 static int pci_pwrctrl_slot_probe(struct platform_device *pdev) > 30 { > 31 struct pci_pwrctrl_slot_data *slot; > 32 struct device *dev = &pdev->dev; > 33 int ret; > 34 > 35 slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL); > 36 if (!slot) > 37 return -ENOMEM; > 38 > > 39 ret = of_regulator_bulk_get_all(dev, dev_of_node(dev), > 40 &slot->supplies); > 41 if (ret < 0) { > 42 dev_err_probe(dev, ret, "Failed to get slot regulators\n"); > 43 return ret; > 44 } > 45 > 46 slot->num_supplies = ret; > 47 ret = regulator_bulk_enable(slot->num_supplies, slot->supplies); > 48 if (ret < 0) { > 49 dev_err_probe(dev, ret, "Failed to enable slot regulators\n"); > 50 goto err_regulator_free; > 51 } > 52 > 53 ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off, > 54 slot); > 55 if (ret) > 56 goto err_regulator_disable; > 57 > 58 pci_pwrctrl_init(&slot->ctx, dev); > 59 > 60 ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->ctx); > 61 if (ret) > 62 return dev_err_probe(dev, ret, "Failed to register pwrctrl driver\n"); > 63 > 64 return 0; > 65 > 66 err_regulator_disable: > 67 regulator_bulk_disable(slot->num_supplies, slot->supplies); > 68 err_regulator_free: > 69 regulator_bulk_free(slot->num_supplies, slot->supplies); > 70 > 71 return ret; > 72 } > 73 > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki
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 <manivannan.sadhasivam@linaro.org> + */ + +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/pci-pwrctrl.h> +#include <linux/platform_device.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> + +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 <manivannan.sadhasivam@linaro.org>"); +MODULE_DESCRIPTION("Generic PCI Power Control driver for PCI Slots"); +MODULE_LICENSE("GPL");