Skip to contentSkip to conversation

Add Cix Sky1 AUDSS clock and reset support

PATCH In review [email protected] 4 participants 10 messages Jul 23 – Jul 24

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

v11 cover Add Cix Sky1 AUDSS clock and reset support

From: Joakim Zhang <[email protected]>

The Cix Sky1 Audio Subsystem (AUDSS) groups audio-related blocks such as HDA, I2S, DSP, DMA, mailboxes, watchdog and timer behind one Clock and Reset Unit (CRU). The CRU is a single MMIO register block that provides clock muxing, gating and block-level software reset lines for those peripherals.

Clock and reset support are submitted in one series because they belong to the same hardware block and share one devicetree node (cix,sky1-audss-cru). The binding, clock indices and reset indices are defined together; the clock driver maps the CRU and instantiates the reset controller as an auxiliary driver on that node. Splitting clk and reset across separate series would leave neither side self-contained: the DTS node needs both providers, and the reset driver has no standalone probe path without the clock driver.

---
ChangeLogs:
v10->v11:
* clk driver:
* Kconfig: spell out menu title as "Cixtech Audio Subsystem Clock Driver"
* rpm cleanup: only call pm_runtime_force_suspend() (it already disables runtime PM)
* reset driver:
* drop unused linux/of.h
* use fsleep() with a single SKY1_RESET_SLEEP_US define
* use regmap_assign_bits() for active-low SW reset bits
* move the post-write delay into sky1_audss_reset_set()

v9->v10:
* clk driver:
* drop unused linux/of_device.h
* enable parent clocks before NOC deassert; assert NOC before disabling clocks on suspend (and reverse on resume)
* enable runtime PM only after parent clocks are on; collapse probe error paths into a single fail_pm label
* move runtime PM teardown to devm_add_action_or_reset() and drop remove(), so the OF provider is unbound before force_suspend

v8->v9:
* Reverse Christmas tree order
* use devm_clk_hw_register_composite_pdata()
* assert reset if clks enabled failed
* add pm_ptr

v7->v8:
* reset Kconfig: drop select REGMAP_MMIO

v6->v7:
* reset driver:
* propagate regmap errors in assert/deassert ops
* drop .reset and .status ops (no consumer uses them)
* remove regmap fallback path; use parent regmap only
* use dev->of_node for rcdev.of_node
* drop of_reset_n_cells and dev_set_drvdata()
* dt-binding:
* Reviewed-by: Krzysztof Kozlowski <[email protected]>

v5->v6:
* rename dt-bindings headers to cix,sky1-audss-cru.h to match compatible
* drop status = "okay" from audss_cru node in sky1.dtsi

v4->v5:
* refactor the driver, using platform_driver for clk and auxiliary_driver for reset.

v3->v4:
* move both power domain and resets into parset node (audss_cru)
* remove "simple-mfd", and change to populate the child node
* cix,sky1-audss.h -> cix,sky1-audss-clock.h

v2->v3:
* clk part:
* devm_reset_control_get()->devm_reset_control_get_exclusive()
* assert noc reset from suspend
* clock parents changes from 6 to 4, and rename the clock names, explain more about this: confirm with our designer, In fact, there are 6 clock sources going into the audio subsystem. audio_clk1 and audio_clk3 are redundant in design and are not actually needed in practice, so they are not shown here.
* refine clocks and clock-names property
* add detailed description of clocks
* drop parent node from clk binding
* drop define AUDSS_MAX_CLKS
* reset part:
* rename reset signal macro, remove _N
* drop SKY1_AUDSS_SW_RESET_NUM
* switching to compatible-style of defining subnodes in parent schema

v1->v2:
* remove audss_rst device node since it doesn't has resource, and move to reset-sky1.c driver.
* remove hda related which would be sent after this patch set accepted
* soc componnet is okay by default from dtsi
* fix for audss clk driver:
* remove "comment "Clock options for Cixtech audss:""
* add select MFD_SYSCON
* move lock and clk_data into struct sky1_audss_clks_priv
* const char *name -> const char * const * name
* remove CLK_GET_RATE_NOCACHE
* divicer -> divider
* Reverse Christmas tree order
* return reg ? 1 : 0; -> return !!reg;
* return ERR_CAST(hw); -> return hw;
* of_device_get_match_data(dev) -> device_get_match_data()
* add lock from runtime_suspend/resume
* loop to more mailing lists

Joakim Zhang (4):
dt-bindings: soc: cix: add sky1 audss cru controller
clk: cix: add sky1 audss clock controller
reset: cix: add sky1 audss auxiliary reset driver
arm64: dts: cix: sky1: add audss cru

 .../bindings/soc/cix/cix,sky1-audss-cru.yaml  |   92 ++
 arch/arm64/boot/dts/cix/sky1.dtsi             |   18 +
 drivers/clk/Kconfig                           |    1 +
 drivers/clk/Makefile                          |    1 +
 drivers/clk/cix/Kconfig                       |   16 +
 drivers/clk/cix/Makefile                      |    3 +
 drivers/clk/cix/clk-sky1-audss.c              | 1206 +++++++++++++++++
 drivers/reset/Kconfig                         |   13 +
 drivers/reset/Makefile                        |    1 +
 drivers/reset/reset-sky1-audss.c              |  127 ++
 .../dt-bindings/clock/cix,sky1-audss-cru.h    |   60 +
 .../dt-bindings/reset/cix,sky1-audss-cru.h    |   25 +
 12 files changed, 1563 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/cix/cix,sky1-audss-cru.yaml
 create mode 100644 drivers/clk/cix/Kconfig
 create mode 100644 drivers/clk/cix/Makefile
 create mode 100644 drivers/clk/cix/clk-sky1-audss.c
 create mode 100644 drivers/reset/reset-sky1-audss.c
 create mode 100644 include/dt-bindings/clock/cix,sky1-audss-cru.h
 create mode 100644 include/dt-bindings/reset/cix,sky1-audss-cru.h
Signature · 1 line
2.50.1
#1 lore raw

PATCH v11 1/4 dt-bindings: soc: cix: add sky1 audss cru controller

From: Joakim Zhang <[email protected]>

The Cix Sky1 Audio Subsystem (AUDSS) Clock and Reset Unit (CRU) groups clock muxing, gating and block-level software reset control in a single register block.

---
 .../bindings/soc/cix/cix,sky1-audss-cru.yaml  | 92 +++++++++++++++++++
 .../dt-bindings/clock/cix,sky1-audss-cru.h    | 60 ++++++++++++
 .../dt-bindings/reset/cix,sky1-audss-cru.h    | 25 +++++
 3 files changed, 177 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/cix/cix,sky1-audss-cru.yaml
 create mode 100644 include/dt-bindings/clock/cix,sky1-audss-cru.h
 create mode 100644 include/dt-bindings/reset/cix,sky1-audss-cru.h
Documentation/devicetree/bindings/soc/cix/cix,sky1-audss-cru.yaml new file +92 -0
new file mode 100644
index 000000000000..50dd0593e1d9
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/cix/cix,sky1-audss-cru.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cix Sky1 audio subsystem clock and reset unit
+
+maintainers:
+  - Joakim Zhang <[email protected]>
+
+description: |
+  The Cix Sky1 Audio Subsystem (AUDSS) Clock and Reset Unit (CRU) groups
+  audio-related clock muxing, gating and block-level software reset control
+  in a single register block.
+
+  A single device node exposes both the clock controller and software reset
+  lines. The clock driver registers as a platform driver; the reset controller
+  is registered by an auxiliary driver bound from the clock driver.
+
+  Four SoC-level reference clocks listed in clocks/clock-names feed the AUDSS
+  clock tree. Internal AUDSS clocks are exposed via #clock-cells; indices are
+  defined in include/dt-bindings/clock/cix,sky1-audss-cru.h.
+
+  Block-level software reset indices are exposed via #reset-cells; indices
+  are defined in include/dt-bindings/reset/cix,sky1-audss-cru.h.
+
+  The SoC syscon NoC (or bus) reset is described via resets. The audio
+  subsystem power domain is described via power-domains.
+
+properties:
+  compatible:
+    const: cix,sky1-audss-cru
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+    description:
+      Clock indices are defined in include/dt-bindings/clock/cix,sky1-audss-cru.h.
+
+  '#reset-cells':
+    const: 1
+    description:
+      Reset indices are defined in include/dt-bindings/reset/cix,sky1-audss-cru.h.
+
+  clocks:
+    items:
+      - description: I2S parent clock for sampling rates multiple of 8kHz.
+      - description: I2S parent clock for sampling rates multiple of 11.025kHz.
+      - description: Clock feeding most devices in AUDSS (NOC, DSP, SRAM, HDA, DMAC, I2S, and mailbox).
+      - description: Clock feeding HDA, timer and watchdog, which is a dedicated 48 MHz clock.
+
+  clock-names:
+    items:
+      - const: x8k
+      - const: x11k
+      - const: sys
+      - const: 48m
+
+  power-domains:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - '#clock-cells'
+  - '#reset-cells'
+  - clocks
+  - clock-names
+  - power-domains
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    audss_cru: clock-controller@7110000 {
+        compatible = "cix,sky1-audss-cru";
+        reg = <0x7110000 0x10000>;
+        #clock-cells = <1>;
+        #reset-cells = <1>;
+        clocks = <&scmi_clk 76>, <&scmi_clk 78>,
+                 <&scmi_clk 70>, <&scmi_clk 71>;
+        clock-names = "x8k", "x11k", "sys", "48m";
+        power-domains = <&smc_devpd 0>;
+        resets = <&s5_syscon 31>;
+    };
include/dt-bindings/clock/cix,sky1-audss-cru.h new file +60 -0

60 lines not on this page · raw message

include/dt-bindings/reset/cix,sky1-audss-cru.h new file +25 -0
new file mode 100644
index 000000000000..55e9f3797b30
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright 2026 Cix Technology Group Co., Ltd.
+ */
+#ifndef DT_BINDINGS_RESET_CIX_SKY1_AUDSS_CRU_H
+#define DT_BINDINGS_RESET_CIX_SKY1_AUDSS_CRU_H
+
+#define AUDSS_I2S0_SW_RST	0
+#define AUDSS_I2S1_SW_RST	1
+#define AUDSS_I2S2_SW_RST	2
+#define AUDSS_I2S3_SW_RST	3
+#define AUDSS_I2S4_SW_RST	4
+#define AUDSS_I2S5_SW_RST	5
+#define AUDSS_I2S6_SW_RST	6
+#define AUDSS_I2S7_SW_RST	7
+#define AUDSS_I2S8_SW_RST	8
+#define AUDSS_I2S9_SW_RST	9
+#define AUDSS_WDT_SW_RST	10
+#define AUDSS_TIMER_SW_RST	11
+#define AUDSS_MB0_SW_RST	12
+#define AUDSS_MB1_SW_RST	13
+#define AUDSS_HDA_SW_RST	14
+#define AUDSS_DMAC_SW_RST	15
+
+#endif
Signature · 1 line
2.50.1
#2 lore raw

PATCH v11 2/4 clk: cix: add sky1 audss clock controller

In reply to [email protected]

From: Joakim Zhang <[email protected]>

Add a platform driver for the Cix Sky1 AUDSS CRU. The driver maps the CRU registers and registers mux, divider and gate clocks for DSP, SRAM, HDA, DMAC, I2S, mailbox, watchdog and timer blocks.

Four SoC-level audio reference clocks are enabled as inputs to the internal clock tree. The driver releases the AUDSS NOC reset, enables runtime PM and instantiates the auxiliary reset device.

---
 drivers/clk/Kconfig              |    1 +
 drivers/clk/Makefile             |    1 +
 drivers/clk/cix/Kconfig          |   16 +
 drivers/clk/cix/Makefile         |    3 +
 drivers/clk/cix/clk-sky1-audss.c | 1206 ++++++++++++++++++++++++++++++
 5 files changed, 1227 insertions(+)
 create mode 100644 drivers/clk/cix/Kconfig
 create mode 100644 drivers/clk/cix/Makefile
 create mode 100644 drivers/clk/cix/clk-sky1-audss.c
drivers/clk/Kconfig +1 -0
index 1717ce75a907..cfcaab39068a 100644
@@ -509,6 +509,7 @@ source "drivers/clk/actions/Kconfig"
 source "drivers/clk/analogbits/Kconfig"
 source "drivers/clk/aspeed/Kconfig"
 source "drivers/clk/bcm/Kconfig"
+source "drivers/clk/cix/Kconfig"
 source "drivers/clk/eswin/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"
 source "drivers/clk/imgtec/Kconfig"
drivers/clk/Makefile +1 -0
index cc108a75a900..87c992f0df54 100644
@@ -119,6 +119,7 @@ obj-$(CONFIG_ARCH_ARTPEC)		+= axis/
 obj-$(CONFIG_ARC_PLAT_AXS10X)		+= axs10x/
 obj-y					+= bcm/
 obj-$(CONFIG_ARCH_BERLIN)		+= berlin/
+obj-y					+= cix/
 obj-$(CONFIG_ARCH_DAVINCI)		+= davinci/
 obj-$(CONFIG_COMMON_CLK_ESWIN)		+= eswin/
 obj-$(CONFIG_ARCH_HISI)			+= hisilicon/
drivers/clk/cix/Kconfig new file +16 -0
new file mode 100644
index 000000000000..b057ef85fab6
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0
+# Audio subsystem clock support for Cixtech SoC family
+menu "Cixtech Audio Subsystem Clock Driver"
+
+config CLK_SKY1_AUDSS
+	tristate "Cixtech Sky1 Audio Subsystem Clock Driver"
+	depends on ARCH_CIX || COMPILE_TEST
+	select AUXILIARY_BUS
+	select REGMAP_MMIO
+	select RESET_CONTROLLER
+	help
+	  Support for the Audio Subsystem clock controller present on
+	  Cixtech Sky1 SoC. This driver provides mux, divider and gate
+	  clocks for DSP, I2S, HDA and related blocks in the audio
+	  subsystem. Say M or Y here if you want to build this driver.
+endmenu
drivers/clk/cix/Makefile new file +3 -0
new file mode 100644
index 000000000000..bc612f1d08b2
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_CLK_SKY1_AUDSS) += clk-sky1-audss.o
drivers/clk/cix/clk-sky1-audss.c new file +1206 -0

1,206 lines not on this page · raw message

Signature · 1 line
2.50.1
#3 lore raw

Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider: - [High] Ignored return values from `regmap_read` cause uninitialized stack variables to be written back to…

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:
- [High] Ignored return values from regmap_read cause uninitialized stack variables to be written back to CRU hardware.
- [High] Multiple distinct CCF composite clocks share the exact same hardware gate bits, leading to accidental clock shutdown.
- [High] Self-deadlock via recursive CCF prepare_lock acquisition in PM runtime resume.
- [Medium] Missing pm_runtime_disable() leaves PM runtime unbalanced on driver unbind or probe failure.
- [Medium] The driver mutates a static global array to store instance-specific register context during suspend.
- [Medium] The PM runtime usage counter is leaked if devm_add_action_or_reset fails, preventing device suspend.
- [Medium] devm_auxiliary_device_create returns an ERR_PTR on failure, but the code only checks for NULL.
- [Medium] Parent clocks and reset lines permanently leak on unbind if CONFIG_PM is disabled.
--

--- Patch [2]: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller --- commit 19bc5160a5549b717fff68a9a09d43f5b6738fca
Author: Joakim Zhang <[email protected]>
Subject: clk: cix: add sky1 audss clock controller

This commit adds a platform driver for the Cix Sky1 AUDSS CRU. It maps the CRU registers, provides mux, divider, and gate clocks, manages reference clocks, enables runtime PM, and creates an auxiliary reset device.

drivers/clk/cix/clk-sky1-audss.c new file +0 -0
@@ -0,0 +1,1206 @@

[ ... ]

Review

Quoted 7 lines
(quoted diff) +7 -0
+static u32 sky1_reg_save[][2] = {
+	{ INFO_HIFI0,  0 },
+	{ INFO_CLK_GATE,  0 },
+	{ INFO_CLK_DIV, 0 },
+	{ INFO_CLK_MUX, 0 },
+	{ INFO_MCLK, 0 },
+};

[Severity: Medium]
Does this global array get overwritten if multiple instances of this driver suspend? Since sky1_audss_clk_runtime_suspend writes instance-specific register context directly into this shared array, it seems like device states could clobber each other.

[ ... ]

Quoted 8 lines
(quoted diff) +8 -0
+	CFG(CLK_I2S0_APB,
+	    "audss_i2s0_apb",
+	    i2s_apb_parent,
+	    NULL,
+	    -1, 0, 0, 0,
+	    INFO_CLK_DIV, 0, 2, 0,
+	    INFO_CLK_GATE, 0, 0,
+	    0),

[ ... ]

Review

Quoted 8 lines
(quoted diff) +8 -0
+	CFG(CLK_I2S0,
+	    "audss_i2s0",
+	    i2s0_parents,
+	    NULL,
+	    INFO_CLK_MUX, 0, 2, 0,
+	    INFO_CLK_DIV, 2, 2, 0,
+	    INFO_CLK_GATE, 0, 0,
+	    0),

[Severity: High]
Do CLK_I2S0_APB and CLK_I2S0 share the exact same hardware gate bits? Both use INFO_CLK_GATE at shift 0. If they point to the same physical bit, could disabling one clock cause the CCF to write a 0 and unintentionally shut down the other active clock?

[ ... ]

Review

Quoted 10 lines
(quoted diff) +10 -0
+static int sky1_audss_reset_controller_register(struct device *dev)
+{
+	struct auxiliary_device *adev;
+
+	if (!of_property_present(dev->of_node, "#reset-cells"))
+		return 0;
+
+	adev = devm_auxiliary_device_create(dev, "reset", NULL);
+	if (!adev)
+		return -ENODEV;

[Severity: Medium]
Does devm_auxiliary_device_create return an ERR_PTR on failure instead of NULL? If it returns an ERR_PTR, the !adev check will fail to catch the error, and the function will silently return success, potentially hanging downstream drivers that need the reset controller.

[ ... ]

Quoted 2 lines
(quoted diff) +2 -0
+static int sky1_audss_clk_mux_set_parent(struct clk_hw *hw, u8 index)
+{

[ ... ]

Review

Quoted 9 lines
(quoted diff) +9 -0
+	if (mux->flags & CLK_MUX_HIWORD_MASK) {
+		reg = mux->mask << (mux->shift + 16);
+	} else {
+		regmap_read(sky1_mux->regmap, sky1_mux->offset, &reg);
+		reg &= ~(mux->mask << mux->shift);
+	}
+	val = val << mux->shift;
+	reg |= val;
+	regmap_write(sky1_mux->regmap, sky1_mux->offset, reg);

[Severity: High]
Can regmap_read fail here? If it returns an error, reg remains uninitialized. We would then modify this uninitialized stack variable and write it back to the hardware, which might corrupt the hardware state.

[ ... ]

Quoted 4 lines
(quoted diff) +4 -0
+static int sky1_audss_clk_divider_set_rate(struct clk_hw *hw,
+					   unsigned long rate,
+					   unsigned long parent_rate)
+{

[ ... ]

Review

Quoted 8 lines
(quoted diff) +8 -0
+	if (divider->flags & CLK_DIVIDER_HIWORD_MASK) {
+		val = clk_div_mask(divider->width) << (divider->shift + 16);
+	} else {
+		regmap_read(sky1_div->regmap, sky1_div->offset, &val);
+		val &= ~(clk_div_mask(divider->width) << divider->shift);
+	}
+	val |= (u32)value << divider->shift;
+	regmap_write(sky1_div->regmap, sky1_div->offset, val);

[Severity: High]
Similar to the mux function above, does this code handle regmap_read failures? If it fails, val is left uninitialized and could result in writing garbage back to the clock controller register.

[ ... ]

Quoted 7 lines
(quoted diff) +7 -0
+static int sky1_audss_clks_enable(struct sky1_audss_clks_priv *priv)
+{
+	const struct sky1_audss_clks_devtype_data *devtype_data = priv->devtype_data;
+	int i, err;
+
+	for (i = 0; i < devtype_data->clk_num; i++) {
+		err = clk_prepare_enable(priv->clks[i]);

[ ... ]

Review

Quoted 4 lines
(quoted diff) +4 -0
+static void sky1_audss_clk_rpm_cleanup(void *data)
+{
+	pm_runtime_force_suspend(data);
+}

[Severity: Medium]
If the kernel is built without CONFIG_PM, pm_runtime_force_suspend is a no-op. Could this mean that the parent clocks and reset lines enabled during probe will permanently leak on unbind, since this is the only teardown path?

Also, since pm_runtime_enable is called during probe, should we call pm_runtime_disable here to keep the PM runtime state balanced on driver unbind or probe failure?

[ ... ]

Quoted 2 lines
(quoted diff) +2 -0
+static int sky1_audss_clk_probe(struct platform_device *pdev)
+{

[ ... ]

Review

Quoted 10 lines
(quoted diff) +10 -0
+	pm_runtime_get_noresume(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
+	/*
+	 * Register cleanup action before clocks/provider (released last under LIFO).
+	 */
+	ret = devm_add_action_or_reset(dev, sky1_audss_clk_rpm_cleanup, dev);
+	if (ret)
+		return ret;

[Severity: Medium]
If devm_add_action_or_reset fails, we return directly. Does this leak the PM usage count incremented by pm_runtime_get_noresume just above, preventing the device from ever suspending?

[ ... ]

Review

Quoted 8 lines
(quoted diff) +8 -0
+static int __maybe_unused sky1_audss_clk_runtime_resume(struct device *dev)
+{
+	struct sky1_audss_clks_priv *priv = dev_get_drvdata(dev);
+	const struct sky1_audss_clks_devtype_data *devtype_data = priv->devtype_data;
+	unsigned long flags;
+	int i, ret;
+
+	ret = sky1_audss_clks_enable(priv);

[Severity: High]
Could this result in a deadlock? When a consumer calls clk_prepare on an audss clock, CCF acquires the global prepare_lock mutex and may call pm_runtime_resume_and_get. This triggers sky1_audss_clk_runtime_resume, which calls sky1_audss_clks_enable. Since sky1_audss_clks_enable executes clk_prepare_enable, it will attempt to acquire the non-recursive prepare_lock again.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller

In reply to [email protected]

Hi Joakim,

There's one question from Sashiko that I don't see where you answered that seems to be legit.

Quoted 11 lines · On Thu, Jul 23, 2026 at 05:08:06PM +0800, [email protected] wrote:

From: Joakim Zhang <[email protected]>

Add a platform driver for the Cix Sky1 AUDSS CRU. The driver maps the CRU registers and registers mux, divider and gate clocks for DSP, SRAM, HDA, DMAC, I2S, mailbox, watchdog and timer blocks.

Four SoC-level audio reference clocks are enabled as inputs to the internal clock tree. The driver releases the AUDSS NOC reset, enables runtime PM and instantiates the auxiliary reset device.

[snip]

drivers/clk/cix/clk-sky1-audss.c line 1149

Quoted 8 lines
drivers/clk/cix/clk-sky1-audss.c new file +8 -0
+static int __maybe_unused sky1_audss_clk_runtime_resume(struct device *dev)
+{
+	struct sky1_audss_clks_priv *priv = dev_get_drvdata(dev);
+	const struct sky1_audss_clks_devtype_data *devtype_data = priv->devtype_data;
+	unsigned long flags;
+	int i, ret;
+
+	ret = sky1_audss_clks_enable(priv);

From Sashiko:

[Severity: High]
Could this result in a deadlock? When a consumer calls clk_prepare on an audss clock, CCF acquires the global prepare_lock mutex and may call pm_runtime_resume_and_get. This triggers sky1_audss_clk_runtime_resume, which calls sky1_audss_clks_enable. Since sky1_audss_clks_enable executes clk_prepare_enable, it will attempt to acquire the non-recursive prepare_lock again.

I found drivers/clk/samsung/clk-exynos-audss.c that is similar to your driver and it calls clk_prepare_enable() in probe.

I'm not concerned about the other feedback from Sashiko.

Brian

#5 lore raw

RE: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller

Hi Brian,

Quoted 45 lines

-----Original Message-----
From: Brian Masney <[email protected]>
Sent: Friday, July 24, 2026 12:43 AM
To: Joakim Zhang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; cix-kernel- upstream <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]
Subject: Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller

EXTERNAL EMAIL

Hi Joakim,

There's one question from Sashiko that I don't see where you answered that seems to be legit.

Quoted 11 lines · On Thu, Jul 23, 2026 at 05:08:06PM +0800, [email protected] wrote:

From: Joakim Zhang <[email protected]>

Add a platform driver for the Cix Sky1 AUDSS CRU. The driver maps the CRU registers and registers mux, divider and gate clocks for DSP, SRAM, HDA, DMAC, I2S, mailbox, watchdog and timer blocks.

Four SoC-level audio reference clocks are enabled as inputs to the internal clock tree. The driver releases the AUDSS NOC reset, enables runtime PM and instantiates the auxiliary reset device.

[snip]

drivers/clk/cix/clk-sky1-audss.c line 1149

Quoted 9 lines
(quoted diff) +4 -0
+static int __maybe_unused sky1_audss_clk_runtime_resume(struct device
+*dev) {
+     struct sky1_audss_clks_priv *priv = dev_get_drvdata(dev);
+     const struct sky1_audss_clks_devtype_data *devtype_data = priv-

devtype_data;

drivers/clk/cix/clk-sky1-audss.c new file +4 -0
+     unsigned long flags;
+     int i, ret;
+
+     ret = sky1_audss_clks_enable(priv);

From Sashiko:

Quoted 7 lines

[Severity: High]
Could this result in a deadlock? When a consumer calls clk_prepare on an audss clock, CCF acquires the global prepare_lock mutex and may call pm_runtime_resume_and_get. This triggers sky1_audss_clk_runtime_resume, which calls sky1_audss_clks_enable. Since sky1_audss_clks_enable executes clk_prepare_enable, it will attempt to acquire the non-recursive prepare_lock again.

prepare_lock is re-entrant for the same task (see clk_prepare_lock(): if prepare_owner == current it just bumps prepare_refcnt). So calling clk_prepare_enable() on the parent SCMI clocks from runtime_resume(), while already in clk_prepare() for an AUDSS clock, does not deadlock. This matches how CCF recursively prepares parents under the same lock.

That safety assumes resume of the AUDSS CRU is driven from CCF while the same task already owns prepare_lock. If another device device-links to the AUDSS CRU (or otherwise runtime resumes it outside clk_prepare), a concurrent clk_prepare() can deadlock:
Thread A: holds prepare_lock, waits in pm_runtime for our resume
Thread B: in our runtime_resume, clk_prepare_enable() waits for prepare_lock

We do not have such a device-link usage today. Would you prefer we add a short comment near sky1_audss_clk_runtime_resume() / sky1_audss_clks_enable() documenting that consumers should use these clocks via CCF and should not PM-resume this device through a device link (or other non-CCF path) that can race with clk_prepare? Happy to add that in the next version if useful.

Quoted 2 lines

I found drivers/clk/samsung/clk-exynos-audss.c that is similar to your driver and it calls clk_prepare_enable() in probe.

Exynos AUDSS is only partially similar. It clk_prepare_enable()s EPLL in probe and keeps it enabled for the lifetime of the driver; its runtime PM callbacks only save/restore AUDSS registers and never disable that parent.

We cannot follow that pattern. Our parent clocks come from SCMI and also gate the audio subsystem power domain. If we clk_prepare_enable() them in probe and leave them enabled, their enable counts stay non-zero, so after system suspend (and on runtime idle) those SCMI clocks cannot be disabled and the audio SS power domain stays on.

That is why we enable the parent SCMI clocks in runtime_resume() and disable them in runtime_suspend(), instead of keeping a permanent prepare/enable from probe like Exynos.

Thanks,
Joakim

Reviewed-by
#6 lore raw

Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller

Hi Joakim,

Quoted 61 lines · Joakim Zhang
Quoted 45 lines

-----Original Message-----
From: Brian Masney <[email protected]>
Sent: Friday, July 24, 2026 12:43 AM
To: Joakim Zhang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; cix-kernel- upstream <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]
Subject: Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller

EXTERNAL EMAIL

Hi Joakim,

There's one question from Sashiko that I don't see where you answered that seems to be legit.

Quoted 11 lines · On Thu, Jul 23, 2026 at 05:08:06PM +0800, [email protected] wrote:

From: Joakim Zhang <[email protected]>

Add a platform driver for the Cix Sky1 AUDSS CRU. The driver maps the CRU registers and registers mux, divider and gate clocks for DSP, SRAM, HDA, DMAC, I2S, mailbox, watchdog and timer blocks.

Four SoC-level audio reference clocks are enabled as inputs to the internal clock tree. The driver releases the AUDSS NOC reset, enables runtime PM and instantiates the auxiliary reset device.

[snip]

drivers/clk/cix/clk-sky1-audss.c line 1149

Quoted 9 lines
(quoted diff) +4 -0
+static int __maybe_unused sky1_audss_clk_runtime_resume(struct device
+*dev) {
+     struct sky1_audss_clks_priv *priv = dev_get_drvdata(dev);
+     const struct sky1_audss_clks_devtype_data *devtype_data = priv-

devtype_data;

drivers/clk/cix/clk-sky1-audss.c new file +4 -0
+     unsigned long flags;
+     int i, ret;
+
+     ret = sky1_audss_clks_enable(priv);

From Sashiko:

Quoted 7 lines

[Severity: High]
Could this result in a deadlock? When a consumer calls clk_prepare on an audss clock, CCF acquires the global prepare_lock mutex and may call pm_runtime_resume_and_get. This triggers sky1_audss_clk_runtime_resume, which calls sky1_audss_clks_enable. Since sky1_audss_clks_enable executes clk_prepare_enable, it will attempt to acquire the non-recursive prepare_lock again.

prepare_lock is re-entrant for the same task (see clk_prepare_lock(): if prepare_owner == current it just bumps prepare_refcnt). So calling clk_prepare_enable() on the parent SCMI clocks from runtime_resume(), while already in clk_prepare() for an AUDSS clock, does not deadlock. This matches how CCF recursively prepares parents under the same lock.

That safety assumes resume of the AUDSS CRU is driven from CCF while the same task already owns prepare_lock. If another device device-links to the AUDSS CRU (or otherwise runtime resumes it outside clk_prepare), a concurrent clk_prepare() can deadlock:
Thread A: holds prepare_lock, waits in pm_runtime for our resume
Thread B: in our runtime_resume, clk_prepare_enable() waits for prepare_lock

We do not have such a device-link usage today. Would you prefer we add a short comment near sky1_audss_clk_runtime_resume() / sky1_audss_clks_enable() documenting that consumers should use these clocks via CCF and should not PM-resume this device through a device link (or other non-CCF path) that can race with clk_prepare? Happy to add that in the next version if useful.

Quoted 8 lines
Quoted 2 lines

I found drivers/clk/samsung/clk-exynos-audss.c that is similar to your driver and it calls clk_prepare_enable() in probe.

Exynos AUDSS is only partially similar. It clk_prepare_enable()s EPLL in probe and keeps it enabled for the lifetime of the driver; its runtime PM callbacks only save/restore AUDSS registers and never disable that parent.

We cannot follow that pattern. Our parent clocks come from SCMI and also gate the audio subsystem power domain. If we clk_prepare_enable() them in probe and leave them enabled, their enable counts stay non-zero, so after system suspend (and on runtime idle) those SCMI clocks cannot be disabled and the audio SS power domain stays on.

That is why we enable the parent SCMI clocks in runtime_resume() and disable them in runtime_suspend(), instead of keeping a permanent prepare/enable from probe like Exynos.

That makes sense and thanks for the clarification.

#7 lore raw

PATCH v11 3/4 reset: cix: add sky1 audss auxiliary reset driver

In reply to [email protected]

From: Joakim Zhang <[email protected]>

Add an auxiliary reset controller driver for the AUDSS CRU. Sixteen software reset lines for audio subsystem peripherals are controlled through one register in the CRU register map.

The driver is created by the AUDSS clock platform driver and registers the reset controller on the CRU device node.

---
 drivers/reset/Kconfig            |  13 ++++
 drivers/reset/Makefile           |   1 +
 drivers/reset/reset-sky1-audss.c | 127 +++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
 create mode 100644 drivers/reset/reset-sky1-audss.c
drivers/reset/Kconfig +13 -0
index d009eb0849a3..b19e719f2abe 100644
@@ -300,6 +300,19 @@ config RESET_SKY1
 	help
 	  This enables the reset controller for Cix Sky1.
 
+config RESET_SKY1_AUDSS
+	tristate "Cix Sky1 Audio Subsystem reset controller"
+	depends on ARCH_CIX || COMPILE_TEST
+	select AUXILIARY_BUS
+	default CLK_SKY1_AUDSS
+	help
+	  Support for block-level software reset lines in the Cix Sky1
+	  Audio Subsystem (AUDSS) Clock and Reset Unit. Sixteen reset
+	  outputs for audio peripherals are controlled through the CRU
+	  register map. The driver binds as an auxiliary device from
+	  the AUDSS clock driver. Say M or Y here if you want to build
+	  this driver.
+
 config RESET_SOCFPGA
 	bool "SoCFPGA Reset Driver" if COMPILE_TEST && (!ARM || !ARCH_INTEL_SOCFPGA)
 	default ARM && ARCH_INTEL_SOCFPGA
drivers/reset/Makefile +1 -0
index 3e52569bd276..e81407ea3e29 100644
@@ -39,6 +39,7 @@ obj-$(CONFIG_RESET_RZV2H_USB2PHY) += reset-rzv2h-usb2phy.o
 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
 obj-$(CONFIG_RESET_SKY1) += reset-sky1.o
+obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o
 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
drivers/reset/reset-sky1-audss.c new file +127 -0

127 lines not on this page · raw message

Signature · 1 line
2.50.1
maintainer Reviewed-by Acked-by on v11 3/4
#8 lore raw

Re: [PATCH v11 3/4] reset: cix: add sky1 audss auxiliary reset driver

Quoted 10 lines · On Do, 2026-07-23 at 17:08 +0800, [email protected] wrote:

From: Joakim Zhang <[email protected]>

Add an auxiliary reset controller driver for the AUDSS CRU. Sixteen software reset lines for audio subsystem peripherals are controlled through one register in the CRU register map.

The driver is created by the AUDSS clock platform driver and registers the reset controller on the CRU device node.

And

to be merged via the clock tree due to the dependency on patch 1.

regards
Philipp

#9 lore raw

PATCH v11 4/4 arm64: dts: cix: sky1: add audss cru

In reply to [email protected]

From: Joakim Zhang <[email protected]>

Add the AUDSS CRU device node providing clocks and software resets for audio subsystem peripherals.

---
 arch/arm64/boot/dts/cix/sky1.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm64/boot/dts/cix/sky1.dtsi +18 -0
index a77c52296ebd..9b2d969f6bfe 100644
@@ -6,6 +6,10 @@
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/clock/cix,sky1.h>
+#include <dt-bindings/clock/cix,sky1-audss-cru.h>
+#include <dt-bindings/reset/cix,sky1-system-control.h>
+#include <dt-bindings/reset/cix,sky1-s5-system-control.h>
+#include <dt-bindings/reset/cix,sky1-audss-cru.h>
 #include "sky1-power.h"
 
 / {
@@ -558,6 +562,20 @@ mbox_pm2ap: mailbox@65a0080 {
 			cix,mbox-dir = "rx";
 		};
 
+		audss_cru: clock-controller@7110000 {
+			compatible = "cix,sky1-audss-cru";
+			reg = <0x0 0x07110000 0x0 0x10000>;
+			#clock-cells = <1>;
+			#reset-cells = <1>;
+			clocks = <&scmi_clk CLK_TREE_AUDIO_CLK0>,
+				 <&scmi_clk CLK_TREE_AUDIO_CLK2>,
+				 <&scmi_clk CLK_TREE_AUDIO_CLK4>,
+				 <&scmi_clk CLK_TREE_AUDIO_CLK5>;
+			clock-names = "x8k", "x11k", "sys", "48m";
+			power-domains = <&smc_devpd SKY1_PD_AUDIO>;
+			resets = <&s5_syscon SKY1_AUDIO_HIFI5_NOC_RESET_N>;
+		};
+
 		mbox_sfh2ap: mailbox@8090000 {
 			compatible = "cix,sky1-mbox";
 			reg = <0x0 0x08090000 0x0 0x10000>;
Signature · 1 line
2.50.1