ASoC: qcom and pinctrl: add LPASS LPR voting and Hawi LPASS LPI TLMM
Subsystems (9)
v3 cover ASoC: qcom and pinctrl: add LPASS LPR voting and Hawi LPASS LPI TLMM
This series adds support for LPASS low-power resource (LPR) voting through PRM and introduces LPASS LPI TLMM pinctrl support for newer platforms such as Hawi.
On such platforms, LPASS requires LPR resource voting via PRM to keep the subsystem active. This is handled by adding a new clock ID and support for PARAM_ID_RSC_CPU_LPR in q6prm.
Additionally, a new LPASS LPI TLMM block is introduced, requiring a dedicated DT binding and pinctrl driver.
Changes in v3:
- Drop the mutex cleanup patch from this series. Since this change
is not required for Hawi enablement, keep the current series
focused on LPASS LPR voting and LPASS LPI TLMM support, and
address the cleanup in a dedicated follow-up series.
- As Srini suggested changed LPR_CPU_SS_SLEEP_DISABLED to LPR_CPU_SS_SLEEP_DISABLE in patch#2.
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Add mutex cleanup devm-managed in LPASS LPI Pinctrl.
- Addressed Bart Comments related to newline and readability.
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
Prasad Kumpatla (4):
ASoC: dt-bindings: qcom: add LPASS LPR vote clock ID
ASoC: qcom: q6prm: add support for LPASS LPR resource voting
dt-bindings: pinctrl: qcom,hawi-lpass-lpi-pinctrl: Add Hawi LPI
pinctrl
pinctrl: qcom: hawi-lpass-lpi: add Hawi LPASS LPI TLMM
.../pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml | 109 ++++++++ drivers/pinctrl/qcom/Kconfig | 10 + drivers/pinctrl/qcom/Makefile | 1 + drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c | 244 ++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-lpass-lpi.h | 17 ++ .../sound/qcom,q6dsp-lpass-ports.h | 3 +- sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 2 +- sound/soc/qcom/qdsp6/q6prm-clocks.c | 2 + sound/soc/qcom/qdsp6/q6prm.c | 16 +- sound/soc/qcom/qdsp6/q6prm.h | 1 + 10 files changed, 400 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml create mode 100644 drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c
Signature · 1 line
2.34.1
PATCH v3 1/4 ASoC: dt-bindings: qcom: add LPASS LPR vote clock ID
Add a new clock ID, LPASS_HW_LPR_VOTE, to represent the LPASS low-power resource (LPR) vote through the PRM interface.
The LPASS PRM supports a resource voting mechanism to control low-power states via PARAM_ID_RSC_CPU_LPR. Exposing this as a q6prm clock ID allows clients to request the LPR vote using the existing qcom,q6prm clock provider interface.
This functionality is required on newer platforms (e.g. Hawi) where LPASS clients need to explicitly manage LPR resource voting via PRM.
Also update Q6AFE_MAX_CLK_ID to account for the newly added clock ID.
--- include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +2 -1
@@ -236,8 +236,9 @@#define LPASS_HW_AVTIMER_VOTE 101#define LPASS_HW_MACRO_VOTE 102#define LPASS_HW_DCODEC_VOTE 103 +#define LPASS_HW_LPR_VOTE 104 -#define Q6AFE_MAX_CLK_ID 104 +#define Q6AFE_MAX_CLK_ID 105#define LPASS_CLK_ATTRIBUTE_INVALID 0x0#define LPASS_CLK_ATTRIBUTE_COUPLE_NO 0x1
Signature · 1 line
2.34.1
Re: [PATCH v3 1/4] ASoC: dt-bindings: qcom: add LPASS LPR vote clock ID
Quoted 24 lines · Prasad Kumpatla
Add a new clock ID,
LPASS_HW_LPR_VOTE, to represent the LPASS low-power resource (LPR) vote through the PRM interface.The LPASS PRM supports a resource voting mechanism to control low-power states via
PARAM_ID_RSC_CPU_LPR. Exposing this as a q6prm clock ID allows clients to request the LPR vote using the existing qcom,q6prm clock provider interface.This functionality is required on newer platforms (e.g. Hawi) where LPASS clients need to explicitly manage LPR resource voting via PRM.
Also update
Q6AFE_MAX_CLK_IDto account for the newly added clock ID.Reviewed-by Bartosz Golaszewski <[email protected]>Signed-off-by Prasad Kumpatla <[email protected]>--- include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +0
-0
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h line 241
Quoted 7 lines
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +2
-1@@ -236,8 +236,9 @@#define LPASS_HW_AVTIMER_VOTE 101#define LPASS_HW_MACRO_VOTE 102#define LPASS_HW_DCODEC_VOTE 103 +#define LPASS_HW_LPR_VOTE 104 -#define Q6AFE_MAX_CLK_ID 104 +#define Q6AFE_MAX_CLK_ID 105
Nope, ABI break. You cannot change that and as stated many times already
- if you need it, then it is not a binding.
Best regards,
Krzysztof
Re: [PATCH v3 1/4] ASoC: dt-bindings: qcom: add LPASS LPR vote clock ID
Quoted 30 lines · Krzysztof Kozlowski
Quoted 29 lines · Prasad Kumpatla
Add a new clock ID,
LPASS_HW_LPR_VOTE, to represent the LPASS low-power resource (LPR) vote through the PRM interface.The LPASS PRM supports a resource voting mechanism to control low-power states via
PARAM_ID_RSC_CPU_LPR. Exposing this as a q6prm clock ID allows clients to request the LPR vote using the existing qcom,q6prm clock provider interface.This functionality is required on newer platforms (e.g. Hawi) where LPASS clients need to explicitly manage LPR resource voting via PRM.
Also update
Q6AFE_MAX_CLK_IDto account for the newly added clock ID.Reviewed-by Bartosz Golaszewski <[email protected]>Signed-off-by Prasad Kumpatla <[email protected]>--- include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +1
-0@@ -236,8 +236,9 @@#define LPASS_HW_AVTIMER_VOTE 101#define LPASS_HW_MACRO_VOTE 102#define LPASS_HW_DCODEC_VOTE 103 +#define LPASS_HW_LPR_VOTE 104
Quoted 4 lines
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h line 241
Quoted 2 lines
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +1
-1-#define Q6AFE_MAX_CLK_ID 104 +#define Q6AFE_MAX_CLK_ID 105Nope, ABI break. You cannot change that and as stated many times already
- if you need it, then it is not a binding.
Hi Krzysztof,
Thanks for the review.
LPASS_HW_LPR_VOTE is intended to be consumed via the DT clock specifier, similar to LPASS_HW_MACRO_VOTE and LPASS_HW_DCODEC_VOTE. My intention was therefore to add a new DT-visible clock ID.
Regarding the ABI concern, would assigning LPASS_HW_LPR_VOTE from the currently unused range (for example 100) and keeping Q6AFE_MAX_CLK_ID unchanged address the issue, or is the concern that LPASS_HW_LPR_VOTE should not be exposed as a DT binding at all? If not, could you please advise the appropriate place/example for defining this CLK ID?
Thanks,
Prasad
Quoted 5 lines
Best regards,
Krzysztof
Re: [PATCH v3 1/4] ASoC: dt-bindings: qcom: add LPASS LPR vote clock ID
Quoted 15 lines · Prasad Kumpatla
Quoted 6 lines
include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h line 241
Quoted 4 lines
#define LPASS_HW_DCODEC_VOTE 103include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h +2
-1+#define LPASS_HW_LPR_VOTE 104 -#define Q6AFE_MAX_CLK_ID 104 +#define Q6AFE_MAX_CLK_ID 105Nope, ABI break. You cannot change that and as stated many times already
- if you need it, then it is not a binding.Hi Krzysztof,
Thanks for the review.
LPASS_HW_LPR_VOTEis intended to be consumed via the DT clock specifier, similar toLPASS_HW_MACRO_VOTEandLPASS_HW_DCODEC_VOTE. My intention was therefore to add a new DT-visible clock ID.
Quoted 6 lines
Regarding the ABI concern, would assigning
LPASS_HW_LPR_VOTEfrom the currently unused range (for example 100) and keepingQ6AFE_MAX_CLK_IDunchanged address the issue, or is the concern thatLPASS_HW_LPR_VOTEshould not be exposed as a DT binding at all? If not, could you please advise the appropriate place/example for defining this CLK ID?
Just drop the Q6AFE_MAX_CLK_ID from the bindings. I do not see it even being used in the drivers, so no need to move it (unless you are aware of some out-of-tree user).
Best regards,
Krzysztof
PATCH v3 2/4 ASoC: qcom: q6prm: add support for LPASS LPR resource voting
In reply to Prasad KumpatlaAdd support for issuing LPASS low-power resource (LPR) votes through the PRM interface.
Some platforms (e.g. Hawi) require the LPASS to be kept active via LPR resource voting instead of the existing hardware core vote mechanism. Handle this by introducing support for PARAM_ID_RSC_CPU_LPR when the LPR vote clock ID is requested.
For LPR requests, use the appropriate parameter ID and payload format to disable CPU subsystem sleep, ensuring that the LPASS register space remains accessible.
Also add the corresponding clock mapping for LPASS_HW_LPR_VOTE and make the q6dsp clock ID range consistent with the dt-bindings by deriving it from Q6AFE_MAX_CLK_ID.
--- sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 2 +- sound/soc/qcom/qdsp6/q6prm-clocks.c | 2 ++ sound/soc/qcom/qdsp6/q6prm.c | 16 +++++++++++++--- sound/soc/qcom/qdsp6/q6prm.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c +1 -1
@@ -12,7 +12,7 @@#include <dt-bindings/sound/qcom,q6dsp-lpass-ports.h> #include "q6dsp-lpass-clocks.h" -#define Q6DSP_MAX_CLK_ID 104 +#define Q6DSP_MAX_CLK_ID Q6AFE_MAX_CLK_ID#define Q6DSP_LPASS_CLK_ROOT_DEFAULT 0
sound/soc/qcom/qdsp6/q6prm-clocks.c +2 -0
@@ -63,6 +63,8 @@ static const struct q6dsp_clk_init q6prm_clks[] = { "LPASS_HW_MACRO"),Q6DSP_VOTE_CLK (LPASS_HW_DCODEC_VOTE ,Q6PRM_HW_CORE_ID_DCODEC ,"LPASS_HW_DCODEC" ), +Q6DSP_VOTE_CLK (LPASS_HW_LPR_VOTE ,Q6PRM_HW_LPR_VOTE , + "LPASS_HW_LPR_VOTE"), }; static const struct q6dsp_clk_desc q6dsp_clk_q6prm __maybe_unused = {
sound/soc/qcom/qdsp6/q6prm.c +13 -3
@@ -31,10 +31,16 @@ struct q6prm {#define PARAM_ID_RSC_HW_CORE 0x08001032#define PARAM_ID_RSC_LPASS_CORE 0x0800102B#define PARAM_ID_RSC_AUDIO_HW_CLK 0x0800102C +#define PARAM_ID_RSC_CPU_LPR 0x08001A6E + +#define LPR_CPU_SS_SLEEP_DISABLE 0x1struct prm_cmd_request_hw_core {struct apm_module_param_data param_data; -uint32_t hw_clk_id; +union { +u32 hw_clk_id; +u32 lpr_state; + }; } __packed;struct prm_cmd_request_rsc {
@@ -62,6 +68,7 @@ static int q6prm_set_hw_core_req(struct device *dev, uint32_t hw_block_id, boolstruct prm_cmd_request_hw_core *req;gpr_device_t *gdev = prm->gdev;uint32_t opcode, rsp_opcode; +bool lpr_req = (hw_block_id ==Q6PRM_HW_LPR_VOTE );if (enable) { opcode =PRM_CMD_REQUEST_HW_RSC ;
@@ -82,10 +89,13 @@ static int q6prm_set_hw_core_req(struct device *dev, uint32_t hw_block_id, bool param_data->module_instance_id =GPR_PRM_MODULE_IID ; param_data->error_code =0 ; - param_data->param_id =PARAM_ID_RSC_HW_CORE ; + param_data->param_id = lpr_req ?PARAM_ID_RSC_CPU_LPR :PARAM_ID_RSC_HW_CORE ; param_data->param_size =sizeof (*req) -APM_MODULE_PARAM_DATA_SIZE ; - req->hw_clk_id = hw_block_id; +if (lpr_req) + req->lpr_state =LPR_CPU_SS_SLEEP_DISABLE ; +else + req->hw_clk_id = hw_block_id;return q6prm_send_cmd_sync (prm, pkt, rsp_opcode); }
sound/soc/qcom/qdsp6/q6prm.h +1 -0
@@ -87,6 +87,7 @@#define Q6PRM_LPASS_CLK_ROOT_DEFAULT 0#define Q6PRM_HW_CORE_ID_LPASS 1#define Q6PRM_HW_CORE_ID_DCODEC 2 +#define Q6PRM_HW_LPR_VOTE 3int q6prm_set_lpass_clock (struct device *dev,int clk_id,int clk_attr,int clk_root,unsigned int freq);
Signature · 1 line
2.34.1
PATCH v3 3/4 dt-bindings: pinctrl: qcom,hawi-lpass-lpi-pinctrl: Add Hawi LPI pinctrl
In reply to Prasad KumpatlaAdd bindings for the pin controller in Low Power Audio SubSystem (LPASS) of Qualcomm Hawi SoC.
The controller has 23 GPIOs (gpio0-gpio22) with functions including SoundWire, I2S, DMIC, VA I2S, ext_mclk1, slimbus and lpass_lpi_dbg_clk.
--- .../pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml new file +109 -0
@@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Hawi SoC LPASS LPI TLMM + +maintainers: + - Krzysztof Kozlowski <[email protected]> + - Srinivas Kandagatla <[email protected]> + - Prasad Kumpatla <[email protected]> + +description: + Top Level Mode Multiplexer pin controller in the Low Power Audio SubSystem + (LPASS) Low Power Island (LPI) of Qualcomm Hawi SoC. + +properties: + compatible: + const: qcom,hawi-lpass-lpi-pinctrl + + reg: + items: + - description: LPASS LPI TLMM Control and Status registers + + clocks: + items: + - description: LPASS LPR(Low Power Resource) voting clock + - description: LPASS Audio voting clock + + clock-names: + items: + - const: lpr + - const: audio + +patternProperties: + "-state$": + oneOf: + - $ref: "#/$defs/qcom-hawi-lpass-state" + - patternProperties: + "-pins$": + $ref: "#/$defs/qcom-hawi-lpass-state" + additionalProperties: false + +$defs: + qcom-hawi-lpass-state: + type: object + description: + Pinctrl node's client devices use subnodes for desired pin configuration. + Client device subnodes use below standard properties. + $ref: qcom,lpass-lpi-common.yaml#/$defs/qcom-tlmm-state + unevaluatedProperties: false + + properties: + pins: + description: + List of gpio pins affected by the properties specified in this + subnode. + items: + pattern: "^gpio([0-9]|1[0-9]|2[0-2])$" + + function: + enum: [dmic1_clk, dmic1_data, dmic2_clk, dmic2_data, dmic3_clk, + dmic3_data, dmic4_clk, dmic4_data, ext_mclk1_a, ext_mclk1_b, + ext_mclk1_c, ext_mclk1_d, ext_mclk1_e, gpio, i2s0_clk, + i2s0_data, i2s0_ws, i2s1_clk, i2s1_data, i2s1_ws, i2s2_clk, + i2s2_data, i2s2_ws, i2s3_clk, i2s3_data, i2s3_ws, + lpass_lpi_dbg_clk, qca_swr_clk, qca_swr_data, slimbus_clk, + slimbus_data, swr_rx_clk, swr_rx_data, swr_tx_clk, swr_tx_clk1, + swr_tx_data, va_i2s0_clk, va_i2s0_data, va_i2s0_ws, + wsa2_swr_clk, wsa2_swr_data, wsa_swr_clk, wsa_swr_data] + description: + Specify the alternative function to be configured for the specified + pins. + +allOf: + - $ref: qcom,lpass-lpi-common.yaml# + +required: + - compatible + - reg + - clocks + - clock-names + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/sound/qcom,q6dsp-lpass-ports.h> + + lpass_tlmm: pinctrl@7f60000 { + compatible = "qcom,hawi-lpass-lpi-pinctrl"; + reg = <0x07f60000 0x20000>; + + clocks = <&q6prmcc LPASS_HW_LPR_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6prmcc LPASS_HW_DCODEC_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + clock-names = "lpr", "audio"; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&lpass_tlmm 0 0 23>; + + tx-swr-sleep-clk-state { + pins = "gpio0"; + function = "swr_tx_clk"; + drive-strength = <2>; + bias-pull-down; + }; + };
Signature · 1 line
2.34.1
Re: [PATCH v3 3/4] dt-bindings: pinctrl: qcom,hawi-lpass-lpi-pinctrl: Add Hawi LPI pinctrl
Quoted 11 lines · Prasad Kumpatla
Add bindings for the pin controller in Low Power Audio SubSystem (LPASS) of Qualcomm Hawi SoC.
The controller has 23 GPIOs (gpio0-gpio22) with functions including SoundWire, I2S, DMIC, VA I2S,
ext_mclk1, slimbus andlpass_lpi_dbg_clk.Signed-off-by Prasad Kumpatla <[email protected]>--- .../pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,hawi-lpass-lpi-pinctrl.yaml
Best regards,
Krzysztof
PATCH v3 4/4 pinctrl: qcom: hawi-lpass-lpi: add Hawi LPASS LPI TLMM
In reply to Prasad KumpatlaAdd pin controller driver for the Low Power Audio SubSystem (LPASS) Low Power Island (LPI) of Qualcomm Hawi SoC.
The controller has 23 GPIOs with SoundWire, I2S, DMIC, VA I2S, ext_mclk1 and slimbus mux functions.
Two pins (gpio13, gpio22) require 6 mux slots due to a test_bus entry occupying a middle hardware slot. Add LPI_PINGROUP6 macro to pinctrl-lpass-lpi.h to support pins with 5 alternate functions.
--- drivers/pinctrl/qcom/Kconfig | 10 + drivers/pinctrl/qcom/Makefile | 1 + drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c | 244 ++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-lpass-lpi.h | 17 ++ 4 files changed, 272 insertions(+) create mode 100644 drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c
drivers/pinctrl/qcom/Kconfig +10 -0
@@ -62,6 +62,16 @@ config PINCTRL_LPASS_LPI Qualcomm Technologies Inc LPASS (Low Power Audio SubSystem) LPI (Low Power Island) found on the Qualcomm Technologies Inc SoCs. +config PINCTRL_HAWI_LPASS_LPI + tristate "Qualcomm Technologies Inc Hawi LPASS LPI pin controller driver" + depends on ARM64 || COMPILE_TEST + depends on PINCTRL_LPASS_LPI + help + This is the pinctrl, pinmux, pinconf and gpiolib driver for the + Qualcomm Technologies Inc LPASS (Low Power Audio SubSystem) LPI + (Low Power Island) found on the Qualcomm Technologies Inc Hawi + platform. + config PINCTRL_MILOS_LPASS_LPI tristate "Qualcomm Milos LPASS LPI pin controller driver" depends on ARM64 || COMPILE_TEST
drivers/pinctrl/qcom/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_PINCTRL_APQ8084) += pinctrl-apq8084.o obj-$(CONFIG_PINCTRL_ELIZA) += pinctrl-eliza.o obj-$(CONFIG_PINCTRL_GLYMUR) += pinctrl-glymur.o obj-$(CONFIG_PINCTRL_HAWI) += pinctrl-hawi.o +obj-$(CONFIG_PINCTRL_HAWI_LPASS_LPI) += pinctrl-hawi-lpass-lpi.o obj-$(CONFIG_PINCTRL_IPQ4019) += pinctrl-ipq4019.o obj-$(CONFIG_PINCTRL_IPQ5018) += pinctrl-ipq5018.o obj-$(CONFIG_PINCTRL_IPQ8064) += pinctrl-ipq8064.o
drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c new file +244 -0
244 lines not on this page · raw message
drivers/pinctrl/qcom/pinctrl-lpass-lpi.h +17 -0
@@ -92,6 +92,23 @@ struct pinctrl_pin_desc; .pin_offset = 0, \ } +#define LPI_PINGROUP6 (id, soff, f1, f2, f3, f4, f5) \ + { \ + .pin = id, \ + .slew_offset = soff, \ + .slew_base_spare_1 = false, \ + .funcs = (int[]){ \ + LPI_MUX_gpio, \ + LPI_MUX_##f1, \ + LPI_MUX_##f2, \ + LPI_MUX_##f3, \ + LPI_MUX_##f4, \ + LPI_MUX_##f5, \ + }, \ + .nfuncs = 6, \ + .pin_offset = 0, \ + } +/* * Slew rate control is done in the same register as rest of the * pin configuration.
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v3 4/4] pinctrl: qcom: hawi-lpass-lpi: add Hawi LPASS LPI TLMM
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] Functions like lpi_gpio_read() and lpi_gpio_set_mux() incorrectly return the result of pm_runtime_put_autosuspend(), leading to spurious -EAGAIN failures during concurrent access.
- [High] The driver destroys its mutex in lpi_pinctrl_remove() and the error path of lpi_pinctrl_probe(), but relies on delayed devm teardown to unregister the pinctrl and gpiochip devices, creating a window where callbacks can access the destroyed mutex. --
--- Patch [4]: [PATCH v3 4/4] pinctrl: qcom: hawi-lpass-lpi: add Hawi LPASS LPI TLMM --- commit b206b5a7cb05f8fc2d4dea4f8c7ff6d338891d30
Author: Prasad Kumpatla <[email protected]>
pinctrl: qcom: hawi-lpass-lpi: add Hawi LPASS LPI TLMM
Add pin controller driver for the Low Power Audio SubSystem (LPASS) Low Power Island (LPI) of Qualcomm Hawi SoC.
The controller has 23 GPIOs with SoundWire, I2S, DMIC, VA I2S, ext_mclk1 and slimbus mux functions.
Two pins (gpio13, gpio22) require 6 mux slots due to a test_bus entry occupying a middle hardware slot. Add LPI_PINGROUP6 macro to pinctrl-lpass-lpi.h to support pins with 5 alternate functions.
drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c
Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-hawi-lpass-lpi.c new file +0
-0
[ ... ]
While reviewing this new driver, I noticed a couple of pre-existing issues in the core driver code that this driver uses:
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c:lpi_gpio_read() {
...
lpi_gpio_read_reg(state, pin, addr, val);
return pm_runtime_put_autosuspend(state->dev);
}[Severity: High]
This is a pre-existing issue, but does this cause spurious failures?
If multiple threads access the pinctrl device concurrently, for example if a consumer holds a PM reference via pm_runtime_resume_and_get(), calling pm_runtime_put_autosuspend() drops the usage counter but it remains greater than zero. The PM core intentionally returns -EAGAIN in this scenario.
Returning this value causes lpi_gpio_read() to falsely report a failure back to the consumer despite a successful hardware read. The same pattern is also present in lpi_gpio_set_mux() and lpi_config_set().
I also noticed this in the probe and remove paths:
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c:lpi_pinctrl_probe() {
...
ret = devm_gpiochip_add_data(dev, &pctrl->chip, pctrl);
if (ret) {
dev_err(pctrl->dev, "can't add gpio chip\n");
goto err_pinctrl;
}
return 0;err_pinctrl:
mutex_destroy(&pctrl->lock);
return ret;
}And similarly during removal:
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c:lpi_pinctrl_remove() {
struct lpi_pinctrl *pctrl = platform_get_drvdata(pdev);
int i;
mutex_destroy(&pctrl->lock);
for (i = 0; i < pctrl->data->npins; i++)
pinctrl_generic_remove_group(pctrl->ctrl, i);
}[Severity: High]
This is a pre-existing issue, but does destroying this mutex before devres cleanup create a race condition?
The pinctrl and gpiochip devices are registered using devm_ calls, meaning they remain active until lpi_pinctrl_probe() or lpi_pinctrl_remove() returns and the driver core executes devres cleanup. If a concurrent operation invokes a callback like lpi_gpio_set_mux() during this window, it could attempt to lock the destroyed mutex.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4