gpio:asm28xx-18xx: new driver
PATCH 1/1 gpio:asm28xx-18xx: new driver
Hi Bjorn Helgaas,
1. What are the other functions and where is the other driver?
Quoted 1 line
PCI bus and GPIO can be considered as two functions independently.
And the driver is located at drivers/gpio/gpio-amd8111.c
2.We end up with multiple drivers controlling the device without
any coordination between them?
Quoted 1 line
Yes,because two functions are independently in the device,and
the main driver for PCI bus function is more important.We wish they can't be affected and coordinated between two drivers as much as possible.If main driver is affected,it is more serious.
In our case,we have gpio registers on pci configuration space
of asm28xx pci-e bridge(with main pci bus driver).If we want to use it by another driver that use gpio subsystem /sys/class/ gpio/(sysfs interface).I find the driver(gpio-amd8111.c) that meet our request.Sorry! i am not best friend with git,and reply mail in the same way.
Hi Bartosz Golaszewski,
Thank you.And i have studied PCI MFD device in drivers/mfd.
Maybe,it is not what i am looking for.This type of device include core and miscellaneous function drivers.And function drivers export resources(io/mem/dma) to sysfs.Fist,we can't implement another pci bus driver as core driver,and secondly, it don't use gpio subsystem with /sys/class/gpio/(sysfs interface).
So,you will review this driver and upstream to mainline
kernel?
BR,
Richard
--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-asm28xx-18xx.c | 278 +++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+) create mode 100644 drivers/gpio/gpio-asm28xx-18xx.c
drivers/gpio/Kconfig +7 -0
@@ -113,6 +113,13 @@ config GPIO_AMDPT driver for GPIO functionality on Promontory IOHub Require ACPI ASL code to enumerate as a platform device. +config GPIO_ASM28XX + tristate "Asmedia 28XX/18XX GPIO support" + depends on PCI + select GPIO_GENERIC + help + Driver for GPIO functionality on Asmedia 28XX and 18XX PCI-E Bridge. + config GPIO_ASPEED tristate "Aspeed GPIO support" depends on (ARCH_ASPEED || COMPILE_TEST) && OF_GPIO
drivers/gpio/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o obj-$(CONFIG_GPIO_AMD_FCH) += gpio-amd-fch.o obj-$(CONFIG_GPIO_AMDPT) += gpio-amdpt.o obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o +obj-$(CONFIG_GPIO_ASM28XX) += gpio-asm28xx-18xx.o obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o obj-$(CONFIG_GPIO_ASPEED_SGPIO) += gpio-aspeed-sgpio.o obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o
drivers/gpio/gpio-asm28xx-18xx.c new file +278 -0
278 lines not on this page · raw message
Signature · 1 line
2.17.1
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Richard,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on gpio/for-next]
[also build test WARNING on v5.7 next-20200529]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Richard-Hsu/gpio-asm28xx-18xx-new-driver/20200601-160444 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next config: i386-allyesconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 reproduce (this is a W=1 build): # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/gpio/gpio-asm28xx-18xx.c:69:6: warning: no previous prototype for 'pci_config_pm_runtime_get' [-Wmissing-prototypes] 69 | void pci_config_pm_runtime_get(struct pci_dev *pdev) | ^~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpio/gpio-asm28xx-18xx.c:91:6: warning: no previous prototype for 'pci_config_pm_runtime_put' [-Wmissing-prototypes]
91 | void pci_config_pm_runtime_put(struct pci_dev *pdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
vim +/pci_config_pm_runtime_get +69 drivers/gpio/gpio-asm28xx-18xx.c
68
> 69 void pci_config_pm_runtime_get(struct pci_dev *pdev)
70 {
71 struct device *dev = &pdev->dev;
72 struct device *parent = dev->parent;
73
74 if (parent)
75 pm_runtime_get_sync(parent);
76 pm_runtime_get_noresume(dev);
77 /*
78 * pdev->current_state is set to PCI_D3cold during suspending,
79 * so wait until suspending completes
80 */
81 pm_runtime_barrier(dev);
82 /*
83 * Only need to resume devices in D3cold, because config
84 * registers are still accessible for devices suspended but
85 * not in D3cold.
86 */
87 if (pdev->current_state == PCI_D3cold)
88 pm_runtime_resume(dev);
89 }
90
> 91 void pci_config_pm_runtime_put(struct pci_dev *pdev)
92 {
93 struct device *dev = &pdev->dev;
94 struct device *parent = dev->parent;
95
96 pm_runtime_put(dev);
97 if (parent)
98 pm_runtime_put_sync(parent);
99 }100
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[+cc Lee in case he can shed light on the MFD question below]
Quoted 4 lines · Richard Hsu
Hi Bjorn Helgaas,
1. What are the other functions and where is the other driver?Quoted 1 line
PCI bus and GPIO can be considered as two functions independently.
And the driver is located at
drivers/gpio/gpio-amd8111.c
I'm obviously missing the point here; sorry for being slow.
drivers/gpio/gpio-amd8111.c uses for_each_pci_dev() to look for PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS [1022:746b] devices. drivers/i2c/busses/i2c-amd756.c claims that same device using the normal PCI probe mechanism.
In this case both i2c-amd756 and gpio-amd8111 want to use the same device, so there's at least a reason why gpio-amd8111 uses the non-standard mechanism.
Your driver looks for PCI_VENDOR_ID_ASMEDIA devices: [1b21:2824], [1b21:2812], [1b21:2806], [1b21:1824], etc). But I haven't found a second driver that needs to claim these devices.
I can't tell what any of these devices are (other than that they seem to have some GPIO). You might want to add them to the Linux PCI database at https://pci-ids.ucw.cz/read/PC/1b21 . If you do, then "lspci" will show the correct names for them.
You mention below that these devices are PCIe bridges. If that's the case, they would be claimed by the "pcieport" driver in the PCI core (drivers/pci/pcie/portdrv_pci.c). If you collect the output of "sudo lspci -vvxxxx", it would tell us whether the pcieport driver will claim it.
If it does, then we have a problem because the PCIe port services (AER, PME, DPC, etc) currently require pcieport. If you want the AER, PME, etc functionality in addition to GPIO, then we have to figure out how to coordinate things.
Quoted 15 lines
2.We end up with multiple drivers controlling the device without
any coordination between them?Quoted 1 line
Yes,because two functions are independently in the device,and
the main driver for PCI bus function is more important.We wish they can't be affected and coordinated between two drivers as much as possible.If main driver is affected,it is more serious.
In our case,we have gpio registers on pci configuration space
of asm28xx pci-e bridge(with main pci bus driver).If we want to use it by another driver that use gpio subsystem/sys/class/gpio/(sysfs interface).I find the driver(gpio-amd8111.c) that meet our request.Sorry! i am not best friend with git,and reply mail in the same way.
Quoted 2 lines
Hi Bartosz Golaszewski,
Thank you.And i have studied PCI MFD device indrivers/mfd.
I'm not familiar with drivers/mfd. It looks like it might be useful for cases where a single PCI function implements multiple sorts of functionality.
But if the problem is that you have a single function that is a PCIe switch port and also implements some GPIOs, I doubt drivers/mfd will help. In that case, both the existing pcieport driver and your new gpio-asm28xx-18xx driver would need to operate the same function, and we'd have to make some significant changes to both of them to fit into the MFD framework.
Long-term, I think it would be good to move the pcieport things directly into the PCI core instead of being a separate driver. We've tripped over this problem before with things like performance counters in PCIe ports.
Quoted 8 lines
Maybe,it is not what i am looking for.This type of device include core and miscellaneous function drivers.And function drivers export resources(io/mem/dma) to sysfs.Fist,we can't implement another pci bus driver as core driver,and secondly, it don't use gpio subsystem with /sys/class/gpio/(sysfs interface).
So,you will review this driver and upstream to mainline
kernel?
Hi Bjorn Helgaas,
Thank for your detailed explanation and benefited me a lot.
I am sorry for your confusion. As you mentioned, i have a single PCIe switch port
and also implements some GPIOs.
Quoted 2 lines
Your driver looks for
PCI_VENDOR_ID_ASMEDIAdevices: [1b21:2824], [1b21:2812], [1b21:2806], [1b21:1824], etc). But I haven't found a second driver that needs to claim these devices.
these devices are PCIe switch port and use "pcieport" as main driver.
Hi Bartosz Golaszewski and linus Walleij,
Thanks for your help. I almost know the problem of this driver. Sorry! This is my mistake to use driver's framework incorrectly.
BR,
Richard
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Saturday, June 6, 2020 1:13 AM
To: Richard Hsu <[email protected]>
Cc: Richard Hsu(許育彰) <[email protected]>; Yd Tseng(曾裕達) <[email protected]>; Jesse1 Chang(張國器) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lee Jones <[email protected]>
Subject: Re: [PATCH] gpio:asm28xx-18xx: new driver
[+cc Lee in case he can shed light on the MFD question below]
Quoted 4 lines · Richard Hsu
Hi Bjorn Helgaas,
1. What are the other functions and where is the other driver?Quoted 1 line
PCI bus and GPIO can be considered as two functions independently.
And the driver is located at
drivers/gpio/gpio-amd8111.c
I'm obviously missing the point here; sorry for being slow.
drivers/gpio/gpio-amd8111.c uses for_each_pci_dev() to look for PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS [1022:746b] devices. drivers/i2c/busses/i2c-amd756.c claims that same device using the normal PCI probe mechanism.
In this case both i2c-amd756 and gpio-amd8111 want to use the same device, so there's at least a reason why gpio-amd8111 uses the non-standard mechanism.
Your driver looks for PCI_VENDOR_ID_ASMEDIA devices: [1b21:2824], [1b21:2812], [1b21:2806], [1b21:1824], etc). But I haven't found a second driver that needs to claim these devices.
I can't tell what any of these devices are (other than that they seem to have some GPIO). You might want to add them to the Linux PCI database at https://pci-ids.ucw.cz/read/PC/1b21 . If you do, then "lspci" will show the correct names for them.
You mention below that these devices are PCIe bridges. If that's the case, they would be claimed by the "pcieport" driver in the PCI core (drivers/pci/pcie/portdrv_pci.c). If you collect the output of "sudo lspci -vvxxxx", it would tell us whether the pcieport driver will claim it.
If it does, then we have a problem because the PCIe port services (AER, PME, DPC, etc) currently require pcieport. If you want the AER, PME, etc functionality in addition to GPIO, then we have to figure out how to coordinate things.
Quoted 14 lines
2.We end up with multiple drivers controlling the device without any
coordination between them?Quoted 1 line
Yes,because two functions are independently in the device,and the
main driver for PCI bus function is more important.We wish they can't be affected and coordinated between two drivers as much as possible.If main driver is affected,it is more serious.
In our case,we have gpio registers on pci configuration space of
asm28xx pci-e bridge(with main pci bus driver).If we want to use it by another driver that use gpio subsystem/sys/class/gpio/(sysfs interface).I find the driver(gpio-amd8111.c) that meet our request.Sorry! i am not best friend with git,and reply mail in the same way.
Quoted 2 lines
Hi Bartosz Golaszewski,
Thank you.And i have studied PCI MFD device indrivers/mfd.
I'm not familiar with drivers/mfd. It looks like it might be useful for cases where a single PCI function implements multiple sorts of functionality.
But if the problem is that you have a single function that is a PCIe switch port and also implements some GPIOs, I doubt drivers/mfd will help. In that case, both the existing pcieport driver and your new gpio-asm28xx-18xx driver would need to operate the same function, and we'd have to make some significant changes to both of them to fit into the MFD framework.
Long-term, I think it would be good to move the pcieport things directly into the PCI core instead of being a separate driver. We've tripped over this problem before with things like performance counters in PCIe ports.
Quoted 6 lines
Maybe,it is not what i am looking for.This type of device include core and miscellaneous function drivers.And function drivers export resources(io/mem/dma) to sysfs.Fist,we can't implement another pci bus driver as core driver,and secondly, it don't use gpio subsystem with /sys/class/gpio/(sysfs interface).
So,you will review this driver and upstream to mainline kernel?
==================================================================================================================
This email and any attachments to it contain confidential information and are intended solely for the use of the individual to whom it is addressed.If you are not the intended recipient or receive it accidentally, please immediately notify the sender by e-mail and delete the message and any attachments from your computer system, and destroy all hard copies. If any, please be advised that any unauthorized disclosure, copying, distribution or any action taken or omitted in reliance on this, is illegal and prohibited. Furthermore, any views or opinions expressed are solely those of the author and do not represent those of ASMedia Technology Inc. Thank you for your cooperation.
==================================================================================================================