wireless: p54 devicetree conversion
Subsystems (10)
v5 cover wireless: p54 devicetree conversion
From: Arnd Bergmann <[email protected]>
This is an older patch of mine that I lost track of. We already decided a while ago that the OMAP2 platform should probably be removed entirely, and this is the only known user, but it's probably a good idea to still get the driver changes in, in case there are other out-of-tree users.
We probably don't have to worry about bisectability any more though, so the devicetree and driver changes can just get merged independently through the OMAP and wireless trees, respectively.
Arnd
---
v4 Link: https://lore.kernel.org/all/[email protected]/
v3 Link: https://lore.kernel.org/all/[email protected]/
v2 Link: https://lore.kernel.org/all/[email protected]/
Arnd Bergmann (3):
[v5 net-next] dt-bindings: net: add st,stlc4560/p54spi binding [v5 net-next] p54spi: convert to devicetree
[v5 omap] ARM: dts: omap2: add stlc4560 spi-wireless node
.../bindings/net/wireless/st,stlc4560.yaml | 61 +++++++++++++++++ MAINTAINERS | 1 + arch/arm/boot/dts/ti/omap/omap2.dtsi | 4 ++ .../dts/ti/omap/omap2420-n8x0-common.dtsi | 12 ++++ arch/arm/mach-omap2/board-n8x0.c | 18 ----- drivers/net/wireless/intersil/p54/p54spi.c | 67 +++++++------------ drivers/net/wireless/intersil/p54/p54spi.h | 3 + 7 files changed, 104 insertions(+), 62 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml
Signature · 1 line
2.39.5
PATCH v5 1/3 dt-bindings: net: add st,stlc4560/p54spi binding
From: Arnd Bergmann <[email protected]>
The SPI version of Prism54 was sold under a couple of different names and supported by the Linux p54spi driver, but there was never a DT binding for it.
Document the four known names of this device and the properties that are sufficient for its use on the Nokia N8x0 tablet.
As I don't have this hardware or documentation for it, this is purely based on existing usage in the driver.
---
v5: fix name in MAINTAINERS file
v4: renamed file to st,stlc4560, matching the primary compatible string
require st,stlc4560 string
--- .../bindings/net/wireless/st,stlc4560.yaml | 61 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +61 -0
@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wireless/st,stlc4560.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ST/Intersil/Conexant stlc45xx/p54spi/cx3110x SPI wireless device + +maintainers: + - Christian Lamparter <[email protected]> + +description: + The SPI variant of the Intersil Prism54 wireless device was sold + under a variety of names, including Conexant CX3110x and + ST Microelectronics STLC5460. + +allOf: + - $ref: ieee80211.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + oneOf: + - const: st,stlc4560 + - items: + - enum: + - cnxt,3110x + - isil,p54spi + - st,stlc4550 + - const: st,stlc4560 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + powerdown-gpios: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + wifi@0 { + compatible = "st,stlc4560"; + reg = <0>; + spi-max-frequency = <48000000>; + interrupts-extended = <&gpio 23>; + powerdown-gpios = <&gpio 1>; + }; + };
MAINTAINERS +1 -0
@@ -20142,6 +20142,7 @@ M: Christian Lamparter <[email protected]> L: [email protected] S: Maintained W: https://wireless.wiki.kernel.org/en/users/Drivers/p54 +F: Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml F: drivers/net/wireless/intersil/ PACKET SOCKETS
Signature · 1 line
2.39.5
Re: [PATCH 1/3] [v5 net-next] dt-bindings: net: add st,stlc4560/p54spi binding
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The SPI version of Prism54 was sold under a couple of different names and supported by the Linux p54spi driver, but there was never a DT binding for it.
Document the four known names of this device and the properties that are sufficient for its use on the Nokia N8x0 tablet.
Quoted 6 lines
As I don't have this hardware or documentation for it, this is purely based on existing usage in the driver.
[email protected]
AI reviewRe: [PATCH 1/3] [v5 net-next] dt-bindings: net: add st,stlc4560/p54spi binding
In reply to Arnd BergmannThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Typo in the binding description: 'STLC5460' is used instead of 'STLC4560'. - [Low] The…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Typo in the binding description: 'STLC5460' is used instead of 'STLC4560'.
- [Low] The interrupts-extended and powerdown-gpios specifiers in the example lack standard secondary cells (flags/triggers). --
commit b803e7cb976e6f9f5ea1b9d2c76cdffbb8fe0d67
Author: Arnd Bergmann <[email protected]>
dt-bindings: net: add st,stlc4560/p54spi binding
This commit adds a device tree binding for the SPI version of the Prism54 wireless device. It documents the known names of this device and the properties sufficient for its use.
Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +5
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wireless/st,stlc4560.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +10
-0+ +title: ST/Intersil/Conexant stlc45xx/p54spi/cx3110x SPI wireless device + +maintainers: + - Christian Lamparter <[email protected]> + +description: + The SPI variant of the Intersil Prism54 wireless device was sold + under a variety of names, including Conexant CX3110x and + ST Microelectronics STLC5460.
This isn't a bug, but there's a typo in the description (STLC5460 instead of STLC4560).
[ ... ]
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 59
Quoted 12 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +12
-0+examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + wifi@0 { + compatible = "st,stlc4560"; + reg = <0>; + spi-max-frequency = <48000000>; + interrupts-extended = <&gpio 23>; + powerdown-gpios = <&gpio 1>;
Do these specifiers need standard secondary cells for flags and triggers?
Real-world GPIO controllers typically require #gpio-cells = <2> or #interrupt-cells = <2> to specify trigger types and active levels. While dt_binding_check accepts this since the phandle cell sizes are unknown, copying this example into a real device tree will result in a compilation error.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/3] [v5 net-next] dt-bindings: net: add st,stlc4560/p54spi binding
Quoted 58 lines · On Fri, May 08, 2026 at 09:32:54PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Typo in the binding description: 'STLC5460' is used instead of 'STLC4560'.
- [Low] Theinterrupts-extendedandpowerdown-gpiosspecifiers in the example lack standard secondary cells (flags/triggers). --commit
b803e7cb976e6f9f5ea1b9d2c76cdffbb8fe0d67
Author: Arnd Bergmann <[email protected]>dt-bindings: net: add st,stlc4560/p54spi binding
This commit adds a device tree binding for the SPI version of the Prism54 wireless device. It documents the known names of this device and the properties sufficient for its use.
Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +5
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wireless/st,stlc4560.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +10
-0+ +title: ST/Intersil/Conexant stlc45xx/p54spi/cx3110x SPI wireless device + +maintainers: + - Christian Lamparter <[email protected]> + +description: + The SPI variant of the Intersil Prism54 wireless device was sold + under a variety of names, including Conexant CX3110x and + ST Microelectronics STLC5460.This isn't a bug, but there's a typo in the description (STLC5460 instead of STLC4560).
[ ... ]
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 59
Quoted 12 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +12
-0+examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + wifi@0 { + compatible = "st,stlc4560"; + reg = <0>; + spi-max-frequency = <48000000>; + interrupts-extended = <&gpio 23>; + powerdown-gpios = <&gpio 1>;Do these specifiers need standard secondary cells for flags and triggers?
Quoted 5 lines
Real-world GPIO controllers typically require #gpio-cells = <2> or #interrupt-cells = <2> to specify trigger types and active levels. While
dt_binding_checkaccepts this since the phandle cell sizes are unknown, copying this example into a real device tree will result in a compilation error.
Can we make this thing not whinge about stuff like this? It's an /example/ and these fields cannot be copy-pasted anyway.
Quoted 3 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/3] [v5 net-next] dt-bindings: net: add st,stlc4560/p54spi binding
Quoted 59 lines · Conor Dooley
Quoted 58 lines · On Fri, May 08, 2026 at 09:32:54PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Typo in the binding description: 'STLC5460' is used instead of 'STLC4560'.
- [Low] Theinterrupts-extendedandpowerdown-gpiosspecifiers in the example lack standard secondary cells (flags/triggers). --commit
b803e7cb976e6f9f5ea1b9d2c76cdffbb8fe0d67
Author: Arnd Bergmann <[email protected]>dt-bindings: net: add st,stlc4560/p54spi binding
This commit adds a device tree binding for the SPI version of the Prism54 wireless device. It documents the known names of this device and the properties sufficient for its use.
Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +5
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wireless/st,stlc4560.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +10
-0+ +title: ST/Intersil/Conexant stlc45xx/p54spi/cx3110x SPI wireless device + +maintainers: + - Christian Lamparter <[email protected]> + +description: + The SPI variant of the Intersil Prism54 wireless device was sold + under a variety of names, including Conexant CX3110x and + ST Microelectronics STLC5460.This isn't a bug, but there's a typo in the description (STLC5460 instead of STLC4560).
[ ... ]
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 59
Quoted 12 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +12
-0+examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + wifi@0 { + compatible = "st,stlc4560"; + reg = <0>; + spi-max-frequency = <48000000>; + interrupts-extended = <&gpio 23>; + powerdown-gpios = <&gpio 1>;Do these specifiers need standard secondary cells for flags and triggers?
Quoted 8 lines
Quoted 5 lines
Real-world GPIO controllers typically require #gpio-cells = <2> or #interrupt-cells = <2> to specify trigger types and active levels. While
dt_binding_checkaccepts this since the phandle cell sizes are unknown, copying this example into a real device tree will result in a compilation error.Can we make this thing not whinge about stuff like this? It's an /example/ and these fields cannot be copy-pasted anyway.
If you have an idea how to convert it into a rule, I'm happy to merge it into prompts. Something like "fields X and Y are not required for example dt records". Sorry, it's really far from my area of expertise, so I don't know what's right here and what's not.
Thanks!
Re: [PATCH 1/3] [v5 net-next] dt-bindings: net: add st,stlc4560/p54spi binding
Quoted 67 lines · Roman Gushchin
Quoted 65 lines · Conor Dooley
Quoted 63 lines · On Fri, May 08, 2026 at 09:32:54PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Typo in the binding description: 'STLC5460' is used instead of 'STLC4560'.
- [Low] Theinterrupts-extendedandpowerdown-gpiosspecifiers in the example lack standard secondary cells (flags/triggers). --commit
b803e7cb976e6f9f5ea1b9d2c76cdffbb8fe0d67
Author: Arnd Bergmann <[email protected]>dt-bindings: net: add st,stlc4560/p54spi binding
This commit adds a device tree binding for the SPI version of the Prism54 wireless device. It documents the known names of this device and the properties sufficient for its use.
Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +5
-0@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wireless/st,stlc4560.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +10
-0+ +title: ST/Intersil/Conexant stlc45xx/p54spi/cx3110x SPI wireless device + +maintainers: + - Christian Lamparter <[email protected]> + +description: + The SPI variant of the Intersil Prism54 wireless device was sold + under a variety of names, including Conexant CX3110x and + ST Microelectronics STLC5460.This isn't a bug, but there's a typo in the description (STLC5460 instead of STLC4560).
[ ... ]
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml line 59
Quoted 12 lines
Documentation/devicetree/bindings/net/wireless/st,stlc4560.yaml new file +12
-0+examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + wifi@0 { + compatible = "st,stlc4560"; + reg = <0>; + spi-max-frequency = <48000000>; + interrupts-extended = <&gpio 23>; + powerdown-gpios = <&gpio 1>;Do these specifiers need standard secondary cells for flags and triggers?
Real-world GPIO controllers typically require #gpio-cells = <2> or #interrupt-cells = <2> to specify trigger types and active levels. While
dt_binding_checkaccepts this since the phandle cell sizes are unknown, copying this example into a real device tree will result in a compilation error.
Quoted 7 lines
Quoted 2 lines
Can we make this thing not whinge about stuff like this? It's an /example/ and these fields cannot be copy-pasted anyway.
If you have an idea how to convert it into a rule, I'm happy to merge it into prompts. Something like "fields X and Y are not required for example dt records". Sorry, it's really far from my area of expertise, so I don't know what's right here and what's not.
"Ignore phandle arguments in examples, when the phandle doesn't reference a node in the example"? Although, probably can go as far as "ignore phandle arguments in examples", since Rob's bot does validation on examples, and should catch a mismatch where the target of phandle exists.
I dunno if "argument" is the correct word for the RHS of the property.
PATCH v5 2/3 p54spi: convert to devicetree
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The Prism54 SPI driver hardcodes GPIO numbers and expects users to pass them as module parameters, apparently a relic from its life as a staging driver. This works because there is only one user, the Nokia N8x0 tablet.
Convert this to the gpio descriptor interface and DT based probing to improve this and simplify the code at the same time.
---
v5:
- fix irq assignment # https://sashiko.dev/#/patchset/20260430081242.3686993-1-arnd%40kernel.org
v4:
- make gpio line optional again
- fix EPROBE_DEFER handling
- match only st,stlc4560 compatible value, with binding change
v3:
- rebase an older patch
--- arch/arm/mach-omap2/board-n8x0.c | 18 ------ drivers/net/wireless/intersil/p54/p54spi.c | 67 ++++++++-------------- drivers/net/wireless/intersil/p54/p54spi.h | 3 + 3 files changed, 26 insertions(+), 62 deletions(-)
arch/arm/mach-omap2/board-n8x0.c +0 -18
@@ -20,7 +20,6 @@#include <linux/spi/spi.h> #include <linux/usb/musb.h> #include <linux/mmc/host.h> -#include <linux/platform_data/spi-omap2-mcspi.h> #include <linux/platform_data/mmc-omap.h> #include <linux/mfd/menelaus.h>
@@ -106,21 +105,6 @@ static void __init n8x0_usb_init(void) {}#endif /*CONFIG_USB_MUSB_TUSB6010 */ - -static struct omap2_mcspi_device_config p54spi_mcspi_config = { - .turbo_mode =0 , -}; - -static struct spi_board_info n800_spi_board_info[]__initdata = { - { - .modalias ="p54spi" , - .bus_num =2 , - .chip_select =0 , - .max_speed_hz =48000000 , - .controller_data = &p54spi_mcspi_config, - }, -}; -#if defined(CONFIG_MENELAUS ) &&IS_ENABLED (CONFIG_MMC_OMAP )/*
@@ -524,7 +508,5 @@ omap_late_initcall(n8x0_late_initcall);void *__init n8x0_legacy_init (void ) {board_check_revision (); -spi_register_board_info (n800_spi_board_info, -ARRAY_SIZE (n800_spi_board_info));return &mmc1_data; }
drivers/net/wireless/intersil/p54/p54spi.c +23 -44
131 lines not on this page · raw message
drivers/net/wireless/intersil/p54/p54spi.h +3 -0
@@ -107,6 +107,9 @@ struct p54s_priv {enum fw_state fw_state;const struct firmware *firmware; + +struct gpio_desc *gpio_powerdown; + int irq; };#endif /* P54SPI_H */
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH 2/3] [v5 net-next] p54spi: convert to devicetree
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The `p54spi_spi_read` function performs an SPI transfer using a stack-allocated buffer, which…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The p54spi_spi_read function performs an SPI transfer using a stack-allocated buffer, which violates DMA mapping rules.
- [High] Missing validation for spi->irq before calling request_irq().
--
commit fa2ad50656ff32f99005056eb774d07bdf3f221c
Author: Arnd Bergmann <[email protected]>
p54spi: convert to devicetree
This commit converts the Prism54 SPI driver from using hardcoded GPIO module parameters to using the GPIO descriptor interface and device tree probing.
Quoted 4 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-0
[ ... ]
Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-6@@ -30,19 +31,6 @@MODULE_FIRMWARE ("3826.arm" );MODULE_FIRMWARE ("3826.eeprom" ); -/* gpios should be handled in board files and provided via platform data, -* but because it's currently impossible for p54spi to have a header file -* in include/linux, let's use module parameters for now -*/ - -static int p54spi_gpio_power =97 ;
drivers/net/wireless/intersil/p54/p54spi.c line 36
Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-7-module_param (p54spi_gpio_power, int,0444 ); -MODULE_PARM_DESC (p54spi_gpio_power,"gpio number for power line" ); - -static int p54spi_gpio_irq =87 ; -module_param (p54spi_gpio_irq, int,0444 ); -MODULE_PARM_DESC (p54spi_gpio_irq,"gpio number for irq line" ); -static void p54spi_spi_read (struct p54s_priv *priv,u8 address,void *buf,size_t len) {
This problem wasn't introduced by this patch, but I noticed a pre-existing issue in the context here. Does the p54spi_spi_read() function perform an SPI transfer using a stack-allocated buffer?
Looking at p54spi_spi_read(), the addr variable is allocated on the stack and passed as a transfer buffer to spi_sync(). The SPI framework maps transfer buffers for DMA. Passing a stack-allocated buffer is illegal, particularly with CONFIG_VMAP_STACK enabled, because stack memory resides in vmalloc space and cannot be safely DMA-mapped.
Could this cause memory corruption or a kernel panic during the transfer?
[ ... ]
Quoted 17 lines
drivers/net/wireless/intersil/p54/p54spi.c +4
-6@@ -608,31 +596,20 @@ static int p54spi_probe(struct spi_device *spi) goto err_free; } - ret =gpio_request (p54spi_gpio_power,"p54spi power" ); -if (ret <0 ) { -dev_err (&priv->spi->dev,"power GPIO request failed: %d" , ret); + priv->gpio_powerdown =gpiod_get_optional (&spi->dev,"powerdown" ,GPIOD_OUT_HIGH ); +if (IS_ERR (priv->gpio_powerdown)) { + ret =dev_err_probe (&priv->spi->dev,PTR_ERR (priv->gpio_powerdown), +"powerdown GPIO request failed\n" ); goto err_free; } - ret =gpio_request (p54spi_gpio_irq,"p54spi irq" ); -if (ret <0 ) { -dev_err (&priv->spi->dev,"irq GPIO request failed: %d" , ret);
drivers/net/wireless/intersil/p54/p54spi.c static int p54spi_probe(struct spi_device *spi) · line 606
Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-9- goto err_free_gpio_power; - } - -gpio_direction_output (p54spi_gpio_power,0 ); -gpio_direction_input (p54spi_gpio_irq); - - ret =request_irq (gpio_to_irq (p54spi_gpio_irq), - p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , - priv->spi); + ret =request_irq (spi->irq, p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , priv->spi);
Is there missing validation for spi->irq before calling request_irq()?
If the device tree node lacks an interrupts property, the SPI core may set spi->irq to 0 or a negative error code.
Passing this directly to request_irq() without validation can successfully hijack a core system interrupt like the system timer on some architectures, leading to system instability or deadlocks.
Should there be a check like if (spi->irq <= 0) to fail the probe gracefully?
Quoted 5 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-1if (ret <0 ) {dev_err (&priv->spi->dev,"request_irq() failed" ); - goto err_free_gpio_irq; + goto err_free_gpio_power; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 2/3] [v5 net-next] p54spi: convert to devicetree
Quoted 12 lines · On Fri, May 8, 2026, at 23:32, [email protected] wrote:
drivers/net/wireless/intersil/p54/p54spi.c line 36
Quoted 7 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-4-static int p54spi_gpio_irq =87 ; -module_param (p54spi_gpio_irq, int,0444 ); -MODULE_PARM_DESC (p54spi_gpio_irq,"gpio number for irq line" ); -static void p54spi_spi_read (struct p54s_priv *priv,u8 address,void *buf,size_t len) {This problem wasn't introduced by this patch, but I noticed a pre-existing issue in the context here. Does the
p54spi_spi_read()function perform an SPI transfer using a stack-allocated buffer?
Quoted 7 lines
Looking at
p54spi_spi_read(), the addr variable is allocated on the stack and passed as a transfer buffer tospi_sync(). The SPI framework maps transfer buffers for DMA. Passing a stack-allocated buffer is illegal, particularly withCONFIG_VMAP_STACKenabled, because stack memory resides in vmalloc space and cannot be safely DMA-mapped.Could this cause memory corruption or a kernel panic during the transfer?
In theory it could, as passing long buffers on stack is not allowed for SPI drivers. In practice this seems to work because all SPI drivers that perform DMA check for short transfers and fall back to MMIO if possible. In this case, the spi-omap2-mcspi driver uses DMA_MIN_BYTES=160, while the on-stack transfers are only two or four bytes and will always be done through MMIO.
The driver has other flaws that I'm not trying to address either.
Quoted 8 lines
drivers/net/wireless/intersil/p54/p54spi.c static int p54spi_probe(struct spi_device *spi) · line 606
Quoted 5 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-4- - ret =request_irq (gpio_to_irq (p54spi_gpio_irq), - p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , - priv->spi); + ret =request_irq (spi->irq, p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , priv->spi);Is there missing validation for
spi->irqbefore callingrequest_irq()?
Quoted 8 lines
If the device tree node lacks an interrupts property, the SPI core may set
spi->irqto 0 or a negative error code.Passing this directly to
request_irq()without validation can successfully hijack a core system interrupt like the system timer on some architectures, leading to system instability or deadlocks.Should there be a check like if (
spi->irq<= 0) to fail the probe gracefully?
request_irq() fails with -EINVAL in this case, which is an appropriate return code. This is again the same behavior as before, if an invalid GPIO, or a GPIO that is not connected to an irqchip gets passed.
Arnd
Re: [PATCH 2/3] [v5 net-next] p54spi: convert to devicetree
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The Prism54 SPI driver hardcodes GPIO numbers and expects users to pass them as module parameters, apparently a relic from its life as a staging driver. This works because there is only one user, the Nokia N8x0 tablet.
Quoted 7 lines
Convert this to the gpio descriptor interface and DT based probing to improve this and simplify the code at the same time.
Reviewed-by Linus Walleij <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>---
Simon Horman
reviewerRe: [PATCH 2/3] [v5 net-next] p54spi: convert to devicetree
In reply to Arnd BergmannFrom: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
p54spi: convert to devicetree
This commit converts the Prism54 SPI driver from using hardcoded GPIO module parameters to using the GPIO descriptor interface and device tree probing.
Quoted 4 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-0
[ ... ]
Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-6@@ -30,19 +31,6 @@MODULE_FIRMWARE ("3826.arm" );MODULE_FIRMWARE ("3826.eeprom" ); -/* gpios should be handled in board files and provided via platform data, -* but because it's currently impossible for p54spi to have a header file -* in include/linux, let's use module parameters for now -*/ - -static int p54spi_gpio_power =97 ;
drivers/net/wireless/intersil/p54/p54spi.c line 36
Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +0
-7-module_param (p54spi_gpio_power, int,0444 ); -MODULE_PARM_DESC (p54spi_gpio_power,"gpio number for power line" ); - -static int p54spi_gpio_irq =87 ; -module_param (p54spi_gpio_irq, int,0444 ); -MODULE_PARM_DESC (p54spi_gpio_irq,"gpio number for irq line" ); -static void p54spi_spi_read (struct p54s_priv *priv,u8 address,void *buf,size_t len) {
Simon says: As a pre-existing issue I don't think we need to be concerned
about this in the scope of this patch-set. But it may be a potential for follow-up.
This problem wasn't introduced by this patch, but I noticed a pre-existing issue in the context here. Does the p54spi_spi_read() function perform an SPI transfer using a stack-allocated buffer?
Looking at p54spi_spi_read(), the addr variable is allocated on the stack and passed as a transfer buffer to spi_sync(). The SPI framework maps transfer buffers for DMA. Passing a stack-allocated buffer is illegal, particularly with CONFIG_VMAP_STACK enabled, because stack memory resides in vmalloc space and cannot be safely DMA-mapped.
Could this cause memory corruption or a kernel panic during the transfer?
[ ... ]
Quoted 17 lines
drivers/net/wireless/intersil/p54/p54spi.c +4
-6@@ -608,31 +596,20 @@ static int p54spi_probe(struct spi_device *spi) goto err_free; } - ret =gpio_request (p54spi_gpio_power,"p54spi power" ); -if (ret <0 ) { -dev_err (&priv->spi->dev,"power GPIO request failed: %d" , ret); + priv->gpio_powerdown =gpiod_get_optional (&spi->dev,"powerdown" ,GPIOD_OUT_HIGH ); +if (IS_ERR (priv->gpio_powerdown)) { + ret =dev_err_probe (&priv->spi->dev,PTR_ERR (priv->gpio_powerdown), +"powerdown GPIO request failed\n" ); goto err_free; } - ret =gpio_request (p54spi_gpio_irq,"p54spi irq" ); -if (ret <0 ) { -dev_err (&priv->spi->dev,"irq GPIO request failed: %d" , ret);
drivers/net/wireless/intersil/p54/p54spi.c static int p54spi_probe(struct spi_device *spi) · line 606
Quoted 10 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-9- goto err_free_gpio_power; - } - -gpio_direction_output (p54spi_gpio_power,0 ); -gpio_direction_input (p54spi_gpio_irq); - - ret =request_irq (gpio_to_irq (p54spi_gpio_irq), - p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , - priv->spi); + ret =request_irq (spi->irq, p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , priv->spi);
Simon says: This one seems more concerning in the context of this patch-set.
Is there missing validation for spi->irq before calling request_irq()?
If the device tree node lacks an interrupts property, the SPI core may set spi->irq to 0 or a negative error code.
Passing this directly to request_irq() without validation can successfully hijack a core system interrupt like the system timer on some architectures, leading to system instability or deadlocks.
Should there be a check like if (spi->irq <= 0) to fail the probe gracefully?
Quoted 5 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-1if (ret <0 ) {dev_err (&priv->spi->dev,"request_irq() failed" ); - goto err_free_gpio_irq; + goto err_free_gpio_power; }
Re: [PATCH 2/3] [v5 net-next] p54spi: convert to devicetree
Quoted 9 lines · Simon Horman
Simon says: As a pre-existing issue I don't think we need to be concerned
about this in the scope of this patch-set. But it may be a potential for follow-up.This problem wasn't introduced by this patch, but I noticed a pre-existing issue in the context here. Does the
p54spi_spi_read()function perform an SPI transfer using a stack-allocated buffer?
Quoted 7 lines
Looking at
p54spi_spi_read(), the addr variable is allocated on the stack and passed as a transfer buffer tospi_sync(). The SPI framework maps transfer buffers for DMA. Passing a stack-allocated buffer is illegal, particularly withCONFIG_VMAP_STACKenabled, because stack memory resides in vmalloc space and cannot be safely DMA-mapped.Could this cause memory corruption or a kernel panic during the transfer?
I already commented on this earlier: This is indeed a theoretical bug, but it works in practice because DMA-capable SPI controllers tend to all use MMIO for short transfers instead of DMA.
SPI is very fragile this way, and I do have some patches to improve that overall, but it seems out of scope for this one driver.
Quoted 13 lines
drivers/net/wireless/intersil/p54/p54spi.c static int p54spi_probe(struct spi_device *spi) · line 606
Quoted 8 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-7- -gpio_direction_output (p54spi_gpio_power,0 ); -gpio_direction_input (p54spi_gpio_irq); - - ret =request_irq (gpio_to_irq (p54spi_gpio_irq), - p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , - priv->spi); + ret =request_irq (spi->irq, p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , priv->spi);Simon says: This one seems more concerning in the context of this patch-set.
Is there missing validation for
spi->irqbefore callingrequest_irq()?
Quoted 8 lines
If the device tree node lacks an interrupts property, the SPI core may set
spi->irqto 0 or a negative error code.Passing this directly to
request_irq()without validation can successfully hijack a core system interrupt like the system timer on some architectures, leading to system instability or deadlocks.Should there be a check like if (
spi->irq<= 0) to fail the probe gracefully?
I also commented on this: request_irq() already fails gracefully with -EINVAL when presented with an invalid IRQ. IRQ 0 is guaranteed to be invalid on any target that uses devicetree.
Arnd
Simon Horman
reviewerRe: [PATCH 2/3] [v5 net-next] p54spi: convert to devicetree
Quoted 16 lines · Arnd Bergmann
Quoted 15 lines · Simon Horman
Simon says: As a pre-existing issue I don't think we need to be concerned
about this in the scope of this patch-set. But it may be a potential for follow-up.This problem wasn't introduced by this patch, but I noticed a pre-existing issue in the context here. Does the
p54spi_spi_read()function perform an SPI transfer using a stack-allocated buffer?Looking at
p54spi_spi_read(), the addr variable is allocated on the stack and passed as a transfer buffer tospi_sync(). The SPI framework maps transfer buffers for DMA. Passing a stack-allocated buffer is illegal, particularly withCONFIG_VMAP_STACKenabled, because stack memory resides in vmalloc space and cannot be safely DMA-mapped.
Quoted 8 lines
Quoted 1 line
Could this cause memory corruption or a kernel panic during the transfer?
I already commented on this earlier: This is indeed a theoretical bug, but it works in practice because DMA-capable SPI controllers tend to all use MMIO for short transfers instead of DMA.
SPI is very fragile this way, and I do have some patches to improve that overall, but it seems out of scope for this one driver.
Thanks, I agree this is out of scope.
Quoted 20 lines
Quoted 20 lines
drivers/net/wireless/intersil/p54/p54spi.c static int p54spi_probe(struct spi_device *spi) · line 606
Quoted 8 lines
drivers/net/wireless/intersil/p54/p54spi.c +1
-7- -gpio_direction_output (p54spi_gpio_power,0 ); -gpio_direction_input (p54spi_gpio_irq); - - ret =request_irq (gpio_to_irq (p54spi_gpio_irq), - p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , - priv->spi); + ret =request_irq (spi->irq, p54spi_interrupt,IRQF_NO_AUTOEN ,"p54spi" , priv->spi);Simon says: This one seems more concerning in the context of this patch-set.
Is there missing validation for
spi->irqbefore callingrequest_irq()?If the device tree node lacks an interrupts property, the SPI core may set
spi->irqto 0 or a negative error code.Passing this directly to
request_irq()without validation can successfully hijack a core system interrupt like the system timer on some architectures, leading to system instability or deadlocks.
Quoted 5 lines
Quoted 1 line
Should there be a check like if (
spi->irq<= 0) to fail the probe gracefully?I also commented on this:
request_irq()already fails gracefully with-EINVALwhen presented with an invalid IRQ. IRQ 0 is guaranteed to be invalid on any target that uses devicetree.
Thanks, and sorry for not seeing your earlier comment. Or realising it is a false positive.
PATCH v5 3/3 ARM: dts: omap2: add stlc4560 spi-wireless node
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
Converted from the platform_device creation in board-n8x0.c.
--- arch/arm/boot/dts/ti/omap/omap2.dtsi | 4 ++++ arch/arm/boot/dts/ti/omap/omap2420-n8x0-common.dtsi | 12 ++++++++++++ 2 files changed, 16 insertions(+)
arch/arm/boot/dts/ti/omap/omap2.dtsi +4 -0
@@ -129,6 +129,8 @@ i2c2: i2c@48072000 { }; mcspi1: spi@48098000 { + #address-cells = <1>; + #size-cells = <0>; compatible = "ti,omap2-mcspi"; ti,hwmods = "mcspi1"; reg = <0x48098000 0x100>;
@@ -140,6 +142,8 @@ mcspi1: spi@48098000 { }; mcspi2: spi@4809a000 { + #address-cells = <1>; + #size-cells = <0>; compatible = "ti,omap2-mcspi"; ti,hwmods = "mcspi2"; reg = <0x4809a000 0x100>;
arch/arm/boot/dts/ti/omap/omap2420-n8x0-common.dtsi +12 -0
@@ -109,3 +109,15 @@ partition@5 { }; }; }; + +&mcspi2 { + status = "okay"; + + wifi@0 { + reg = <0>; + compatible = "st,stlc4560"; + spi-max-frequency = <48000000>; + interrupts-extended = <&gpio3 23 IRQ_TYPE_EDGE_RISING>; + powerdown-gpios = <&gpio4 1 GPIO_ACTIVE_LOW>; /* gpio 97 */ + }; +};
Signature · 1 line
2.39.5