Skip to contentSkip to conversation

ASoC: dt-bindings: sound: atmel_ac97c: Convert to DT schema

PATCH In review Manish Baing 3 participants 5 messages May 30 – May 31

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ASoC: dt-bindings: sound: atmel_ac97c: Convert to DT schema

Convert the Atmel AC97 controller binding from text format to YAML schema.

The binding constraints were updated during conversion to align with actual driver behavior:
- Added previously undocumented 'clocks' and 'clock-names' properties. These are made required, as the driver unconditionally requests them.
- Removed 'ac97-gpios' from the required list, as the driver treats the reset pin as optional, and requiring it breaks existing .dtsi validation.
- Fixed the ac97-gpios array in the example to use standard comma-separated formatting.

---
Changes in v3:
- Updated the commit message to include the reasoning behind the property changes, addressing Sashiko bot feedback.
Changes in v2:
- Added undocumented 'clocks' and 'clock-names' properties which are unconditionally required by the driver.
- Removed 'ac97-gpios' from the required list, as the driver treats it as optional, fixing validation for existing dtsi files.

 .../sound/atmel,at91sam9263-ac97c.yaml        | 70 +++++++++++++++++++
 .../devicetree/bindings/sound/atmel_ac97c.txt | 20 ------
 2 files changed, 70 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/atmel_ac97c.txt
Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml new file +70 -0
new file mode 100644
index 000000000000..5f4ebe81bf90
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/atmel,at91sam9263-ac97c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Atmel AC97 Controller
+
+maintainers:
+  - Nicolas Ferre <[email protected]>
+  - Alexandre Belloni <[email protected]>
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: atmel,at91sam9263-ac97c
+
+  reg:
+    maxItems: 1
+    description: Address and length of the register set for the device.
+
+  interrupts:
+    maxItems: 1
+    description: Should contain the AC97 interrupt.
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: ac97_clk
+
+  ac97-gpios:
+    minItems: 3
+    maxItems: 4
+    description: |
+      AC97 link GPIOs- sync, sdata_out, reset, and optional sdata_in.
+      The driver primarily uses the reset pin.
+
+  pinctrl-0: true
+
+  pinctrl-names:
+    const: default
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/clock/at91.h>
+
+    sound@fffa0000 {
+        compatible = "atmel,at91sam9263-ac97c";
+        reg = <0xfffa0000 0x4000>;
+        interrupts = <18 IRQ_TYPE_LEVEL_HIGH 5>;
+        clocks = <&pmc PMC_TYPE_PERIPHERAL 2>;
+        clock-names = "ac97_clk";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ac97>;
+        ac97-gpios = <&pioB 0 0>, <&pioB 2 0>, <&pioC 29 GPIO_ACTIVE_LOW>;
+    };
Documentation/devicetree/bindings/sound/atmel_ac97c.txt deleted +0 -20
deleted file mode 100644
index b151bd902ce3..000000000000
@@ -1,20 +0,0 @@
-* Atmel AC97 controller
-
-Required properties:
-  - compatible: "atmel,at91sam9263-ac97c"
-  - reg: Address and length of the register set for the device
-  - interrupts: Should contain AC97 interrupt
-  - ac97-gpios: Please refer to soc-ac97link.txt, only ac97-reset is used
-Optional properties:
-  - pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt
-
-Example:
-sound@fffa0000 {
-       compatible = "atmel,at91sam9263-ac97c";
-       pinctrl-names = "default";
-       pinctrl-0 = <&pinctrl_ac97>;
-       reg = <0xfffa0000 0x4000>;
-       interrupts = <18 IRQ_TYPE_LEVEL_HIGH 5>;
-
-       ac97-gpios = <&pioB 0 0 &pioB 2 0 &pioC 29 GPIO_ACTIVE_LOW>;
-};
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] The driver fails to properly handle -EPROBE_DEFER when requesting the reset GPIO, incorrectly bypassing hardware reset and permanently falling back to software reset.
- [High] Incorrect initialization and teardown ordering of hardware resources (IRQs, memory maps, clocks) leading to potential kernel panics due to NULL pointer dereferences or unmapped memory access. --

commit dce8eddfc311c261daebe971da37753c69680689
Author: Manish Baing <[email protected]>

ASoC: dt-bindings: sound: atmel_ac97c: Convert to DT schema

Convert the Atmel AC97 controller binding from text format to YAML schema. The binding constraints were updated during conversion to align with actual driver behavior.

Quoted 2 lines

- Added previously undocumented 'clocks' and 'clock-names' properties. These are made required, as the driver unconditionally requests them.

[Severity: High]
This isn't a bug introduced by this patch, but since we are aligning with driver behavior regarding clocks, is the initialization and teardown ordering in sound/atmel/ac97c.c safe?

In atmel_ac97c_probe(), request_irq() is called before ioremap():

	retval = request_irq(irq, atmel_ac97c_interrupt, 0, "AC97C", chip);
	...
	chip->regs = ioremap(regs->start, resource_size(regs));

If an interrupt fires immediately, will the handler atmel_ac97c_interrupt() dereference chip->regs via ac97c_readl() while it is still NULL?

Additionally, in the probe error path and atmel_ac97c_remove(), iounmap() and clk_disable_unprepare() are called before free_irq():

	clk_disable_unprepare(chip->pclk);
	clk_put(chip->pclk);
	iounmap(chip->regs);
	free_irq(chip->irq, chip);

	snd_card_free(card);

Could an interrupt occurring in this window cause the handler to attempt access to unmapped I/O memory or registers with a disabled clock?

Quoted 3 lines

- Removed 'ac97-gpios' from the required list, as the driver treats the reset pin as optional, and requiring it breaks existing .dtsi validation.

[Severity: High]
This is a pre-existing issue, but does the driver properly handle probe deferral when treating the reset pin as optional?

In sound/atmel/ac97c.c:atmel_ac97c_probe(), when requesting the GPIO:

	chip->reset_pin = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_OUT_HIGH);
	if (IS_ERR(chip->reset_pin))
		dev_dbg(dev, "reset pin not available\n");

	atmel_ac97c_reset(chip);

If devm_gpiod_get_index() returns -EPROBE_DEFER, does this check swallow the deferral request and permanently fall back to a software register reset in atmel_ac97c_reset() instead of waiting for the hardware reset pin?

	} else {
		ac97c_writel(chip, MR, AC97C_MR_WRST | AC97C_MR_ENA);
		udelay(2);
		ac97c_writel(chip, MR, AC97C_MR_ENA);
	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Manish Baing
Quoted 14 lines · Manish Baing

Convert the Atmel AC97 controller binding from text format to YAML schema.

The binding constraints were updated during conversion to align with actual driver behavior:
- Added previously undocumented 'clocks' and 'clock-names' properties. These are made required, as the driver unconditionally requests them.
- Removed 'ac97-gpios' from the required list, as the driver treats the reset pin as optional, and requiring it breaks existing .dtsi validation.
- Fixed the ac97-gpios array in the example to use standard comma-separated formatting.

Quoted 8 lines

---
Changes in v3:
- Updated the commit message to include the reasoning behind the property changes, addressing Sashiko bot feedback.
Changes in v2:
- Added undocumented 'clocks' and 'clock-names' properties which are unconditionally required by the driver.
- Removed 'ac97-gpios' from the required list, as the driver treats

Srsly, stop. I don't even know where to reply...

Best regards,
Krzysztof

#3 lore raw

Hi Krzysztof,

I sincerely apologize for the massive amount of noise I have created on the mailing lists today.
I am new to the kernel patch submission process and made several major workflow mistakes in rapid succession.
I am stopping all patch submissions immediately.
I will hold off on further submissions until I have properly verified all in-tree users. I will then send a single, consolidated patch series with corrected terminology and constraints.

Thank you for your patience and for taking the time to correct my workflow. I will do better.

Quoted 30 lines · Krzysztof Kozlowski
Quoted 14 lines · Manish Baing

Convert the Atmel AC97 controller binding from text format to YAML schema.

The binding constraints were updated during conversion to align with actual driver behavior:
- Added previously undocumented 'clocks' and 'clock-names' properties. These are made required, as the driver unconditionally requests them.
- Removed 'ac97-gpios' from the required list, as the driver treats the reset pin as optional, and requiring it breaks existing .dtsi validation.
- Fixed the ac97-gpios array in the example to use standard comma-separated formatting.

Quoted 8 lines

---
Changes in v3:
- Updated the commit message to include the reasoning behind the property changes, addressing Sashiko bot feedback.
Changes in v2:
- Added undocumented 'clocks' and 'clock-names' properties which are unconditionally required by the driver.
- Removed 'ac97-gpios' from the required list, as the driver treats

Srsly, stop. I don't even know where to reply...

Best regards,
Krzysztof

#4 lore raw
In reply to Manish Baing
Quoted 10 lines · Manish Baing
Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml new file +10 -0
+properties:
+  compatible:
+    const: atmel,at91sam9263-ac97c
+
+  reg:
+    maxItems: 1
+    description: Address and length of the register set for the device.
+
+  interrupts:
+    maxItems: 1

Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml line 35

Quoted 10 lines
Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml new file +10 -0
+    description: Should contain the AC97 interrupt.
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: ac97_clk
+
+  ac97-gpios:
+    minItems: 3

This stays...

Quoted 1 line

+ maxItems: 4

this drop

Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml

Quoted 3 lines
Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml new file +3 -0
+    description: |
+      AC97 link GPIOs- sync, sdata_out, reset, and optional sdata_in.
+      The driver primarily uses the reset pin.a

and instead list the items with description.

Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml line 44

Quoted 5 lines
Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml new file +5 -0
+
+  pinctrl-0: true
+
+  pinctrl-names:
+    const: default

Drop both pinctrl properties, not needed, already core schema provides them. No need to mention that in commit msg.

Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml line 53

Quoted 9 lines
Documentation/devicetree/bindings/sound/atmel,at91sam9263-ac97c.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false

Best regards,
Krzysztof