* [PATCH 66/78] ASoC: codecs: wcd938x: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/wcd938x.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index c69e18667a85..9eef1ecec352 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -1976,7 +1976,7 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
int req_volt, int micb_num)
{
struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
- int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en, ret = 0;
+ int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en;
switch (micb_num) {
case MIC_BIAS_1:
@@ -1994,7 +1994,7 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
default:
return -EINVAL;
}
- mutex_lock(&wcd938x->micb_lock);
+ guard(mutex)(&wcd938x->micb_lock);
/*
* If requested micbias voltage is same as current micbias
* voltage, then just return. Otherwise, adjust voltage as
@@ -2009,15 +2009,11 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
WCD938X_MICB_VOUT_MASK);
req_vout_ctl = wcd_get_micb_vout_ctl_val(component->dev, req_volt);
- if (req_vout_ctl < 0) {
- ret = -EINVAL;
- goto exit;
- }
+ if (req_vout_ctl < 0)
+ return -EINVAL;
- if (cur_vout_ctl == req_vout_ctl) {
- ret = 0;
- goto exit;
- }
+ if (cur_vout_ctl == req_vout_ctl)
+ return 0;
if (micb_en == WCD938X_MICB_ENABLE)
snd_soc_component_write_field(component, micb_reg,
@@ -2038,9 +2034,8 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
*/
usleep_range(2000, 2100);
}
-exit:
- mutex_unlock(&wcd938x->micb_lock);
- return ret;
+
+ return 0;
}
static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component,
--
2.43.0
^ permalink raw reply related
* [PATCH 65/78] ASoC: codecs: wcd937x: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/wcd937x.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/sound/soc/codecs/wcd937x.c b/sound/soc/codecs/wcd937x.c
index e0169e783ee9..8336316866ea 100644
--- a/sound/soc/codecs/wcd937x.c
+++ b/sound/soc/codecs/wcd937x.c
@@ -1056,7 +1056,7 @@ static int wcd937x_micbias_control(struct snd_soc_component *component,
return -EINVAL;
}
- mutex_lock(&wcd937x->micb_lock);
+ guard(mutex)(&wcd937x->micb_lock);
switch (req) {
case MICB_PULLUP_ENABLE:
wcd937x->pullup_ref[micb_index]++;
@@ -1136,7 +1136,6 @@ static int wcd937x_micbias_control(struct snd_soc_component *component,
}
break;
}
- mutex_unlock(&wcd937x->micb_lock);
return 0;
}
@@ -1460,7 +1459,7 @@ static int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
int req_volt, int micb_num)
{
struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
- int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en, ret = 0;
+ int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en;
switch (micb_num) {
case MIC_BIAS_1:
@@ -1475,7 +1474,7 @@ static int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
default:
return -EINVAL;
}
- mutex_lock(&wcd937x->micb_lock);
+ guard(mutex)(&wcd937x->micb_lock);
/*
* If requested micbias voltage is same as current micbias
* voltage, then just return. Otherwise, adjust voltage as
@@ -1490,15 +1489,11 @@ static int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
WCD937X_MICB_VOUT_MASK);
req_vout_ctl = wcd_get_micb_vout_ctl_val(component->dev, req_volt);
- if (req_vout_ctl < 0) {
- ret = -EINVAL;
- goto exit;
- }
+ if (req_vout_ctl < 0)
+ return -EINVAL;
- if (cur_vout_ctl == req_vout_ctl) {
- ret = 0;
- goto exit;
- }
+ if (cur_vout_ctl == req_vout_ctl)
+ return 0;
if (micb_en == WCD937X_MICB_ENABLE)
snd_soc_component_write_field(component, micb_reg,
@@ -1519,9 +1514,8 @@ static int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
*/
usleep_range(2000, 2100);
}
-exit:
- mutex_unlock(&wcd937x->micb_lock);
- return ret;
+
+ return 0;
}
static int wcd937x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component,
--
2.43.0
^ permalink raw reply related
* [PATCH 64/78] ASoC: codecs: wcd934x: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/wcd934x.c | 46 ++++++++++++++++----------------------
1 file changed, 19 insertions(+), 27 deletions(-)
diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index bc41a1466c70..817ad53595fc 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -1265,13 +1265,12 @@ static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, int sido_src)
static int wcd934x_enable_ana_bias_and_sysclk(struct wcd934x_codec *wcd)
{
- mutex_lock(&wcd->sysclk_mutex);
-
- if (++wcd->sysclk_users != 1) {
- mutex_unlock(&wcd->sysclk_mutex);
- return 0;
+ scoped_guard(mutex, &wcd->sysclk_mutex) {
+ if (++wcd->sysclk_users != 1) {
+ mutex_unlock(&wcd->sysclk_mutex);
+ return 0;
+ }
}
- mutex_unlock(&wcd->sysclk_mutex);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS,
WCD934X_ANA_BIAS_EN_MASK,
@@ -1328,12 +1327,12 @@ static int wcd934x_enable_ana_bias_and_sysclk(struct wcd934x_codec *wcd)
static int wcd934x_disable_ana_bias_and_syclk(struct wcd934x_codec *wcd)
{
- mutex_lock(&wcd->sysclk_mutex);
- if (--wcd->sysclk_users != 0) {
- mutex_unlock(&wcd->sysclk_mutex);
- return 0;
+ scoped_guard(mutex, &wcd->sysclk_mutex) {
+ if (--wcd->sysclk_users != 0) {
+ mutex_unlock(&wcd->sysclk_mutex);
+ return 0;
+ }
}
- mutex_unlock(&wcd->sysclk_mutex);
regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG,
WCD934X_EXT_CLK_BUF_EN_MASK |
@@ -2384,7 +2383,7 @@ static int wcd934x_micbias_control(struct snd_soc_component *component,
__func__, micb_num);
return -EINVAL;
}
- mutex_lock(&wcd934x->micb_lock);
+ guard(mutex)(&wcd934x->micb_lock);
switch (req) {
case MICB_PULLUP_ENABLE:
@@ -2446,8 +2445,6 @@ static int wcd934x_micbias_control(struct snd_soc_component *component,
break;
}
- mutex_unlock(&wcd934x->micb_lock);
-
return 0;
}
@@ -2488,7 +2485,7 @@ static int wcd934x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
int req_volt, int micb_num)
{
struct wcd934x_codec *wcd934x = snd_soc_component_get_drvdata(component);
- int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en, ret = 0;
+ int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en;
switch (micb_num) {
case MIC_BIAS_1:
@@ -2506,7 +2503,7 @@ static int wcd934x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
default:
return -EINVAL;
}
- mutex_lock(&wcd934x->micb_lock);
+ guard(mutex)(&wcd934x->micb_lock);
/*
* If requested micbias voltage is same as current micbias
* voltage, then just return. Otherwise, adjust voltage as
@@ -2521,15 +2518,11 @@ static int wcd934x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
WCD934X_MICB_VAL_MASK);
req_vout_ctl = wcd_get_micb_vout_ctl_val(component->dev, req_volt);
- if (req_vout_ctl < 0) {
- ret = -EINVAL;
- goto exit;
- }
+ if (req_vout_ctl < 0)
+ return -EINVAL;
- if (cur_vout_ctl == req_vout_ctl) {
- ret = 0;
- goto exit;
- }
+ if (cur_vout_ctl == req_vout_ctl)
+ return 0;
if (micb_en == WCD934X_MICB_ENABLE)
snd_soc_component_write_field(component, micb_reg,
@@ -2550,9 +2543,8 @@ static int wcd934x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
*/
usleep_range(2000, 2100);
}
-exit:
- mutex_unlock(&wcd934x->micb_lock);
- return ret;
+
+ return 0;
}
static int wcd934x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component,
--
2.43.0
^ permalink raw reply related
* [PATCH 63/78] ASoC: codecs: wcd-mbhc: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/wcd-mbhc-v2.c | 142 +++++++++++++++------------------
1 file changed, 66 insertions(+), 76 deletions(-)
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index bb0c8478a8eb..b8e87d0b79b1 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -419,9 +419,8 @@ static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc,
struct work_struct *work)
{
mbhc->hs_detect_work_stop = true;
- mutex_unlock(&mbhc->lock);
+ guard(mutex)(&mbhc->lock);
cancel_work_sync(work);
- mutex_lock(&mbhc->lock);
}
static void wcd_mbhc_cancel_pending_work(struct wcd_mbhc *mbhc)
@@ -458,7 +457,7 @@ static void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
if (mbhc->current_plug == plug_type)
return;
- mutex_lock(&mbhc->lock);
+ guard(mutex)(&mbhc->lock);
switch (plug_type) {
case MBHC_PLUG_TYPE_HEADPHONE:
@@ -481,7 +480,6 @@ static void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,
mbhc->current_plug, plug_type);
break;
}
- mutex_unlock(&mbhc->lock);
}
static void wcd_schedule_hs_detect_plug(struct wcd_mbhc *mbhc,
@@ -517,7 +515,7 @@ static void mbhc_plug_detect_fn(struct work_struct *work)
enum snd_jack_types jack_type;
bool detection_type;
- mutex_lock(&mbhc->lock);
+ guard(mutex)(&mbhc->lock);
mbhc->in_swch_irq_handler = true;
@@ -578,7 +576,6 @@ static void mbhc_plug_detect_fn(struct work_struct *work)
exit:
mbhc->in_swch_irq_handler = false;
- mutex_unlock(&mbhc->lock);
}
static irqreturn_t wcd_mbhc_mech_plug_detect_irq(int irq, void *data)
@@ -673,29 +670,28 @@ static irqreturn_t wcd_mbhc_btn_press_handler(int irq, void *data)
int mask;
unsigned long msec_val;
- mutex_lock(&mbhc->lock);
+ guard(mutex)(&mbhc->lock);
wcd_cancel_btn_work(mbhc);
mbhc->is_btn_press = true;
msec_val = jiffies_to_msecs(jiffies - mbhc->jiffies_atreport);
/* Too short, ignore button press */
if (msec_val < MBHC_BUTTON_PRESS_THRESHOLD_MIN)
- goto done;
+ return IRQ_HANDLED;
/* If switch interrupt already kicked in, ignore button press */
if (mbhc->in_swch_irq_handler)
- goto done;
+ return IRQ_HANDLED;
/* Plug isn't headset, ignore button press */
if (mbhc->current_plug != MBHC_PLUG_TYPE_HEADSET)
- goto done;
+ return IRQ_HANDLED;
mask = wcd_mbhc_get_button_mask(mbhc);
mbhc->buttons_pressed |= mask;
if (schedule_delayed_work(&mbhc->mbhc_btn_dwork, msecs_to_jiffies(400)) == 0)
WARN(1, "Button pressed twice without release event\n");
-done:
- mutex_unlock(&mbhc->lock);
+
return IRQ_HANDLED;
}
@@ -704,14 +700,14 @@ static irqreturn_t wcd_mbhc_btn_release_handler(int irq, void *data)
struct wcd_mbhc *mbhc = data;
int ret;
- mutex_lock(&mbhc->lock);
+ guard(mutex)(&mbhc->lock);
if (mbhc->is_btn_press)
mbhc->is_btn_press = false;
else /* fake btn press */
- goto exit;
+ return IRQ_HANDLED;
if (!(mbhc->buttons_pressed & WCD_MBHC_JACK_BUTTON_MASK))
- goto exit;
+ return IRQ_HANDLED;
ret = wcd_cancel_btn_work(mbhc);
if (ret == 0) { /* Reporting long button release event */
@@ -725,8 +721,6 @@ static irqreturn_t wcd_mbhc_btn_release_handler(int irq, void *data)
}
}
mbhc->buttons_pressed &= ~WCD_MBHC_JACK_BUTTON_MASK;
-exit:
- mutex_unlock(&mbhc->lock);
return IRQ_HANDLED;
}
@@ -768,62 +762,60 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
return ret;
}
- mutex_lock(&mbhc->lock);
-
- if (mbhc->cfg->typec_analog_mux)
- mbhc->swap_thr = GND_MIC_USBC_SWAP_THRESHOLD;
- else
- mbhc->swap_thr = GND_MIC_SWAP_THRESHOLD;
-
- /* setup HS detection */
- if (mbhc->mbhc_cb->hph_pull_up_control_v2)
- mbhc->mbhc_cb->hph_pull_up_control_v2(component,
- mbhc->cfg->typec_analog_mux ?
- HS_PULLUP_I_OFF : HS_PULLUP_I_DEFAULT);
- else if (mbhc->mbhc_cb->hph_pull_up_control)
- mbhc->mbhc_cb->hph_pull_up_control(component,
- mbhc->cfg->typec_analog_mux ?
- I_OFF : I_DEFAULT);
- else
- wcd_mbhc_write_field(mbhc, WCD_MBHC_HS_L_DET_PULL_UP_CTRL,
- mbhc->cfg->typec_analog_mux ? 0 : 3);
-
- wcd_mbhc_write_field(mbhc, WCD_MBHC_HPHL_PLUG_TYPE, mbhc->cfg->hphl_swh);
- wcd_mbhc_write_field(mbhc, WCD_MBHC_GND_PLUG_TYPE, mbhc->cfg->gnd_swh);
- wcd_mbhc_write_field(mbhc, WCD_MBHC_SW_HPH_LP_100K_TO_GND, 1);
- if (mbhc->cfg->gnd_det_en && mbhc->mbhc_cb->mbhc_gnd_det_ctrl)
- mbhc->mbhc_cb->mbhc_gnd_det_ctrl(component, true);
- wcd_mbhc_write_field(mbhc, WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, 1);
-
- /* Plug detect is triggered manually if analog goes through USBCC */
- if (mbhc->cfg->typec_analog_mux)
- wcd_mbhc_write_field(mbhc, WCD_MBHC_L_DET_EN, 0);
- else
- wcd_mbhc_write_field(mbhc, WCD_MBHC_L_DET_EN, 1);
-
- if (mbhc->cfg->typec_analog_mux)
- /* Insertion debounce set to 48ms */
- wcd_mbhc_write_field(mbhc, WCD_MBHC_INSREM_DBNC, 4);
- else
- /* Insertion debounce set to 96ms */
- wcd_mbhc_write_field(mbhc, WCD_MBHC_INSREM_DBNC, 6);
+ scoped_guard(mutex, &mbhc->lock) {
+ if (mbhc->cfg->typec_analog_mux)
+ mbhc->swap_thr = GND_MIC_USBC_SWAP_THRESHOLD;
+ else
+ mbhc->swap_thr = GND_MIC_SWAP_THRESHOLD;
+
+ /* setup HS detection */
+ if (mbhc->mbhc_cb->hph_pull_up_control_v2)
+ mbhc->mbhc_cb->hph_pull_up_control_v2(component,
+ mbhc->cfg->typec_analog_mux ?
+ HS_PULLUP_I_OFF : HS_PULLUP_I_DEFAULT);
+ else if (mbhc->mbhc_cb->hph_pull_up_control)
+ mbhc->mbhc_cb->hph_pull_up_control(component,
+ mbhc->cfg->typec_analog_mux ?
+ I_OFF : I_DEFAULT);
+ else
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_HS_L_DET_PULL_UP_CTRL,
+ mbhc->cfg->typec_analog_mux ? 0 : 3);
+
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_HPHL_PLUG_TYPE, mbhc->cfg->hphl_swh);
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_GND_PLUG_TYPE, mbhc->cfg->gnd_swh);
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_SW_HPH_LP_100K_TO_GND, 1);
+ if (mbhc->cfg->gnd_det_en && mbhc->mbhc_cb->mbhc_gnd_det_ctrl)
+ mbhc->mbhc_cb->mbhc_gnd_det_ctrl(component, true);
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, 1);
+
+ /* Plug detect is triggered manually if analog goes through USBCC */
+ if (mbhc->cfg->typec_analog_mux)
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_L_DET_EN, 0);
+ else
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_L_DET_EN, 1);
- /* Button Debounce set to 16ms */
- wcd_mbhc_write_field(mbhc, WCD_MBHC_BTN_DBNC, 2);
+ if (mbhc->cfg->typec_analog_mux)
+ /* Insertion debounce set to 48ms */
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_INSREM_DBNC, 4);
+ else
+ /* Insertion debounce set to 96ms */
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_INSREM_DBNC, 6);
- /* enable bias */
- mbhc->mbhc_cb->mbhc_bias(component, true);
- /* enable MBHC clock */
- if (mbhc->mbhc_cb->clk_setup)
- mbhc->mbhc_cb->clk_setup(component,
- mbhc->cfg->typec_analog_mux ? false : true);
+ /* Button Debounce set to 16ms */
+ wcd_mbhc_write_field(mbhc, WCD_MBHC_BTN_DBNC, 2);
- /* program HS_VREF value */
- wcd_program_hs_vref(mbhc);
+ /* enable bias */
+ mbhc->mbhc_cb->mbhc_bias(component, true);
+ /* enable MBHC clock */
+ if (mbhc->mbhc_cb->clk_setup)
+ mbhc->mbhc_cb->clk_setup(component,
+ mbhc->cfg->typec_analog_mux ? false : true);
- wcd_program_btn_threshold(mbhc, false);
+ /* program HS_VREF value */
+ wcd_program_hs_vref(mbhc);
- mutex_unlock(&mbhc->lock);
+ wcd_program_btn_threshold(mbhc, false);
+ }
pm_runtime_put_autosuspend(component->dev);
@@ -1327,7 +1319,7 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
unsigned long timeout;
int adc_threshold, output_mv, retry = 0;
- mutex_lock(&mbhc->lock);
+ guard(mutex)(&mbhc->lock);
timeout = jiffies + msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS);
adc_threshold = wcd_mbhc_adc_get_hs_thres(mbhc);
@@ -1342,7 +1334,7 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
/* Check for fake removal */
if ((output_mv <= adc_threshold) && retry > FAKE_REM_RETRY_ATTEMPTS)
- goto exit;
+ return IRQ_HANDLED;
} while (!time_after(jiffies, timeout));
/*
@@ -1359,8 +1351,6 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
wcd_mbhc_elec_hs_report_unplug(mbhc);
wcd_mbhc_write_field(mbhc, WCD_MBHC_BTN_ISRC_CTL, 0);
-exit:
- mutex_unlock(&mbhc->lock);
return IRQ_HANDLED;
}
@@ -1622,10 +1612,10 @@ void wcd_mbhc_deinit(struct wcd_mbhc *mbhc)
free_irq(mbhc->intr_ids->mbhc_btn_press_intr, mbhc);
free_irq(mbhc->intr_ids->mbhc_sw_intr, mbhc);
- mutex_lock(&mbhc->lock);
- wcd_cancel_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);
- cancel_work_sync(&mbhc->mbhc_plug_detect_work);
- mutex_unlock(&mbhc->lock);
+ scoped_guard(mutex, &mbhc->lock) {
+ wcd_cancel_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);
+ cancel_work_sync(&mbhc->mbhc_plug_detect_work);
+ }
kfree(mbhc);
}
--
2.43.0
^ permalink raw reply related
* [PATCH 62/78] ASoC: codecs: twl6040: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/twl6040.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index e10c51092a35..6b18252fa8c6 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -273,7 +273,7 @@ static void twl6040_hs_jack_report(struct snd_soc_component *component,
struct twl6040_data *priv = snd_soc_component_get_drvdata(component);
int status;
- mutex_lock(&priv->mutex);
+ guard(mutex)(&priv->mutex);
/* Sync status */
status = twl6040_read(component, TWL6040_REG_STATUS);
@@ -281,8 +281,6 @@ static void twl6040_hs_jack_report(struct snd_soc_component *component,
snd_soc_jack_report(jack, report, report);
else
snd_soc_jack_report(jack, 0, report);
-
- mutex_unlock(&priv->mutex);
}
void twl6040_hs_jack_detect(struct snd_soc_component *component,
--
2.43.0
^ permalink raw reply related
* [PATCH 61/78] ASoC: codecs: tscs454: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/tscs454.c | 106 ++++++++++++++-----------------------
1 file changed, 41 insertions(+), 65 deletions(-)
diff --git a/sound/soc/codecs/tscs454.c b/sound/soc/codecs/tscs454.c
index aad394937ce6..af0c21ca3a16 100644
--- a/sound/soc/codecs/tscs454.c
+++ b/sound/soc/codecs/tscs454.c
@@ -329,12 +329,10 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
return -EINVAL;
}
- mutex_lock(coeff_ram_lock);
-
- memcpy(ucontrol->value.bytes.data,
- &coeff_ram[ctl->addr * COEFF_SIZE], params->max);
-
- mutex_unlock(coeff_ram_lock);
+ scoped_guard(mutex, coeff_ram_lock) {
+ memcpy(ucontrol->value.bytes.data,
+ &coeff_ram[ctl->addr * COEFF_SIZE], params->max);
+ }
return 0;
}
@@ -428,15 +426,15 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
return -EINVAL;
}
- mutex_lock(coeff_ram_lock);
+ guard(mutex)(coeff_ram_lock);
*coeff_ram_synced = false;
memcpy(&coeff_ram[ctl->addr * COEFF_SIZE],
ucontrol->value.bytes.data, params->max);
- mutex_lock(&tscs454->pll1.lock);
- mutex_lock(&tscs454->pll2.lock);
+ guard(mutex)(&tscs454->pll1.lock);
+ guard(mutex)(&tscs454->pll2.lock);
val = snd_soc_component_read(component, R_PLLSTAT);
if (val) { /* PLLs locked */
@@ -446,18 +444,12 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
if (ret < 0) {
dev_err(component->dev,
"Failed to flush coeff ram cache (%d)\n", ret);
- goto exit;
+ return ret;
}
*coeff_ram_synced = true;
}
- ret = 0;
-exit:
- mutex_unlock(&tscs454->pll2.lock);
- mutex_unlock(&tscs454->pll1.lock);
- mutex_unlock(coeff_ram_lock);
-
- return ret;
+ return 0;
}
static inline int coeff_ram_sync(struct snd_soc_component *component,
@@ -465,41 +457,35 @@ static inline int coeff_ram_sync(struct snd_soc_component *component,
{
int ret;
- mutex_lock(&tscs454->dac_ram.lock);
- if (!tscs454->dac_ram.synced) {
- ret = write_coeff_ram(component, tscs454->dac_ram.cache,
- R_DACCRS, R_DACCRADD, R_DACCRWDL,
- 0x00, COEFF_RAM_COEFF_COUNT);
- if (ret < 0) {
- mutex_unlock(&tscs454->dac_ram.lock);
- return ret;
+ scoped_guard(mutex, &tscs454->dac_ram.lock) {
+ if (!tscs454->dac_ram.synced) {
+ ret = write_coeff_ram(component, tscs454->dac_ram.cache,
+ R_DACCRS, R_DACCRADD, R_DACCRWDL,
+ 0x00, COEFF_RAM_COEFF_COUNT);
+ if (ret < 0)
+ return ret;
}
}
- mutex_unlock(&tscs454->dac_ram.lock);
- mutex_lock(&tscs454->spk_ram.lock);
- if (!tscs454->spk_ram.synced) {
- ret = write_coeff_ram(component, tscs454->spk_ram.cache,
- R_SPKCRS, R_SPKCRADD, R_SPKCRWDL,
- 0x00, COEFF_RAM_COEFF_COUNT);
- if (ret < 0) {
- mutex_unlock(&tscs454->spk_ram.lock);
- return ret;
+ scoped_guard(mutex, &tscs454->spk_ram.lock) {
+ if (!tscs454->spk_ram.synced) {
+ ret = write_coeff_ram(component, tscs454->spk_ram.cache,
+ R_SPKCRS, R_SPKCRADD, R_SPKCRWDL,
+ 0x00, COEFF_RAM_COEFF_COUNT);
+ if (ret < 0)
+ return ret;
}
}
- mutex_unlock(&tscs454->spk_ram.lock);
- mutex_lock(&tscs454->sub_ram.lock);
- if (!tscs454->sub_ram.synced) {
- ret = write_coeff_ram(component, tscs454->sub_ram.cache,
- R_SUBCRS, R_SUBCRADD, R_SUBCRWDL,
- 0x00, COEFF_RAM_COEFF_COUNT);
- if (ret < 0) {
- mutex_unlock(&tscs454->sub_ram.lock);
- return ret;
+ scoped_guard(mutex, &tscs454->sub_ram.lock) {
+ if (!tscs454->sub_ram.synced) {
+ ret = write_coeff_ram(component, tscs454->sub_ram.cache,
+ R_SUBCRS, R_SUBCRADD, R_SUBCRWDL,
+ 0x00, COEFF_RAM_COEFF_COUNT);
+ if (ret < 0)
+ return ret;
}
}
- mutex_unlock(&tscs454->sub_ram.lock);
return 0;
}
@@ -658,16 +644,14 @@ static int set_sysclk(struct snd_soc_component *component)
static inline void reserve_pll(struct pll *pll)
{
- mutex_lock(&pll->lock);
+ guard(mutex)(&pll->lock);
pll->users++;
- mutex_unlock(&pll->lock);
}
static inline void free_pll(struct pll *pll)
{
- mutex_lock(&pll->lock);
+ guard(mutex)(&pll->lock);
pll->users--;
- mutex_unlock(&pll->lock);
}
static int pll_connected(struct snd_soc_dapm_widget *source,
@@ -679,15 +663,13 @@ static int pll_connected(struct snd_soc_dapm_widget *source,
int users;
if (strstr(source->name, "PLL 1")) {
- mutex_lock(&tscs454->pll1.lock);
- users = tscs454->pll1.users;
- mutex_unlock(&tscs454->pll1.lock);
+ scoped_guard(mutex, &tscs454->pll1.lock)
+ users = tscs454->pll1.users;
dev_dbg(component->dev, "%s(): PLL 1 users = %d\n", __func__,
users);
} else {
- mutex_lock(&tscs454->pll2.lock);
- users = tscs454->pll2.users;
- mutex_unlock(&tscs454->pll2.lock);
+ scoped_guard(mutex, &tscs454->pll2.lock)
+ users = tscs454->pll2.users;
dev_dbg(component->dev, "%s(): PLL 2 users = %d\n", __func__,
users);
}
@@ -806,7 +788,7 @@ static inline int aif_free(struct snd_soc_component *component,
{
struct tscs454 *tscs454 = snd_soc_component_get_drvdata(component);
- mutex_lock(&tscs454->aifs_status_lock);
+ guard(mutex)(&tscs454->aifs_status_lock);
dev_dbg(component->dev, "%s(): aif %d\n", __func__, aif->id);
@@ -829,8 +811,6 @@ static inline int aif_free(struct snd_soc_component *component,
free_pll(tscs454->internal_rate.pll);
}
- mutex_unlock(&tscs454->aifs_status_lock);
-
return 0;
}
@@ -3174,7 +3154,7 @@ static int tscs454_hw_params(struct snd_pcm_substream *substream,
unsigned int val;
int ret;
- mutex_lock(&tscs454->aifs_status_lock);
+ guard(mutex)(&tscs454->aifs_status_lock);
dev_dbg(component->dev, "%s(): aif %d fs = %u\n", __func__,
aif->id, fs);
@@ -3207,14 +3187,14 @@ static int tscs454_hw_params(struct snd_pcm_substream *substream,
ret = set_aif_fs(component, aif->id, fs);
if (ret < 0) {
dev_err(component->dev, "Failed to set aif fs (%d)\n", ret);
- goto exit;
+ return ret;
}
ret = set_aif_sample_format(component, params_format(params), aif->id);
if (ret < 0) {
dev_err(component->dev,
"Failed to set aif sample format (%d)\n", ret);
- goto exit;
+ return ret;
}
set_aif_status_active(&tscs454->aifs_status, aif->id,
@@ -3223,11 +3203,7 @@ static int tscs454_hw_params(struct snd_pcm_substream *substream,
dev_dbg(component->dev, "Set aif %d active. Streams status is 0x%x\n",
aif->id, tscs454->aifs_status.streams);
- ret = 0;
-exit:
- mutex_unlock(&tscs454->aifs_status_lock);
-
- return ret;
+ return 0;
}
static int tscs454_hw_free(struct snd_pcm_substream *substream,
--
2.43.0
^ permalink raw reply related
* [PATCH 60/78] ASoC: codecs: tscs42xx: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/tscs42xx.c | 44 ++++++++++++-------------------------
1 file changed, 14 insertions(+), 30 deletions(-)
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index dba581857920..66810b992935 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -210,23 +210,21 @@ static int power_up_audio_plls(struct snd_soc_component *component)
return ret;
}
- mutex_lock(&tscs42xx->pll_lock);
+ guard(mutex)(&tscs42xx->pll_lock);
ret = snd_soc_component_update_bits(component, R_PLLCTL1C, mask, val);
if (ret < 0) {
dev_err(component->dev, "Failed to turn PLL on (%d)\n", ret);
- goto exit;
+ return ret;
}
if (!plls_locked(component)) {
dev_err(component->dev, "Failed to lock plls\n");
ret = -ENOMSG;
- goto exit;
+ return ret;
}
ret = 0;
-exit:
- mutex_unlock(&tscs42xx->pll_lock);
return ret;
}
@@ -236,26 +234,24 @@ static int power_down_audio_plls(struct snd_soc_component *component)
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
- mutex_lock(&tscs42xx->pll_lock);
+ guard(mutex)(&tscs42xx->pll_lock);
ret = snd_soc_component_update_bits(component, R_PLLCTL1C,
RM_PLLCTL1C_PDB_PLL1,
RV_PLLCTL1C_PDB_PLL1_DISABLE);
if (ret < 0) {
dev_err(component->dev, "Failed to turn PLL off (%d)\n", ret);
- goto exit;
+ return ret;
}
ret = snd_soc_component_update_bits(component, R_PLLCTL1C,
RM_PLLCTL1C_PDB_PLL2,
RV_PLLCTL1C_PDB_PLL2_DISABLE);
if (ret < 0) {
dev_err(component->dev, "Failed to turn PLL off (%d)\n", ret);
- goto exit;
+ return ret;
}
ret = 0;
-exit:
- mutex_unlock(&tscs42xx->pll_lock);
return ret;
}
@@ -269,13 +265,11 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
(struct coeff_ram_ctl *)kcontrol->private_value;
struct soc_bytes_ext *params = &ctl->bytes_ext;
- mutex_lock(&tscs42xx->coeff_ram_lock);
+ guard(mutex)(&tscs42xx->coeff_ram_lock);
memcpy(ucontrol->value.bytes.data,
&tscs42xx->coeff_ram[ctl->addr * COEFF_SIZE], params->max);
- mutex_unlock(&tscs42xx->coeff_ram_lock);
-
return 0;
}
@@ -290,14 +284,14 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
unsigned int coeff_cnt = params->max / COEFF_SIZE;
int ret;
- mutex_lock(&tscs42xx->coeff_ram_lock);
+ guard(mutex)(&tscs42xx->coeff_ram_lock);
tscs42xx->coeff_ram_synced = false;
memcpy(&tscs42xx->coeff_ram[ctl->addr * COEFF_SIZE],
ucontrol->value.bytes.data, params->max);
- mutex_lock(&tscs42xx->pll_lock);
+ guard(mutex)(&tscs42xx->pll_lock);
if (plls_locked(component)) {
ret = write_coeff_ram(component, tscs42xx->coeff_ram,
@@ -305,16 +299,12 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
if (ret < 0) {
dev_err(component->dev,
"Failed to flush coeff ram cache (%d)\n", ret);
- goto exit;
+ return ret;
}
tscs42xx->coeff_ram_synced = true;
}
ret = 0;
-exit:
- mutex_unlock(&tscs42xx->pll_lock);
-
- mutex_unlock(&tscs42xx->coeff_ram_lock);
return ret;
}
@@ -385,19 +375,17 @@ static int dac_event(struct snd_soc_dapm_widget *w,
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
- mutex_lock(&tscs42xx->coeff_ram_lock);
+ guard(mutex)(&tscs42xx->coeff_ram_lock);
if (!tscs42xx->coeff_ram_synced) {
ret = write_coeff_ram(component, tscs42xx->coeff_ram, 0x00,
COEFF_RAM_COEFF_COUNT);
if (ret < 0)
- goto exit;
+ return ret;
tscs42xx->coeff_ram_synced = true;
}
ret = 0;
-exit:
- mutex_unlock(&tscs42xx->coeff_ram_lock);
return ret;
}
@@ -926,12 +914,10 @@ static int setup_sample_rate(struct snd_soc_component *component,
return ret;
}
- mutex_lock(&tscs42xx->audio_params_lock);
+ guard(mutex)(&tscs42xx->audio_params_lock);
tscs42xx->samplerate = rate;
- mutex_unlock(&tscs42xx->audio_params_lock);
-
return 0;
}
@@ -1253,12 +1239,10 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai,
return ret;
}
- mutex_lock(&tscs42xx->audio_params_lock);
+ guard(mutex)(&tscs42xx->audio_params_lock);
tscs42xx->bclk_ratio = ratio;
- mutex_unlock(&tscs42xx->audio_params_lock);
-
return 0;
}
--
2.43.0
^ permalink raw reply related
* [PATCH 59/78] ASoC: codecs: tlv320dac33: Use guard() for mutex & spin locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex & spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/tlv320dac33.c | 77 ++++++++++++++--------------------
1 file changed, 31 insertions(+), 46 deletions(-)
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 223c49dfc450..85c42a4efbf7 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -236,13 +236,10 @@ static int dac33_write_locked(struct snd_soc_component *component, unsigned int
unsigned int value)
{
struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component);
- int ret;
- mutex_lock(&dac33->mutex);
- ret = dac33_write(component, reg, value);
- mutex_unlock(&dac33->mutex);
+ guard(mutex)(&dac33->mutex);
- return ret;
+ return dac33_write(component, reg, value);
}
#define DAC33_I2C_ADDR_AUTOINC 0x80
@@ -365,13 +362,13 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component);
int ret = 0;
- mutex_lock(&dac33->mutex);
+ guard(mutex)(&dac33->mutex);
/* Safety check */
if (unlikely(power == dac33->chip_power)) {
dev_dbg(component->dev, "Trying to set the same power state: %s\n",
power ? "ON" : "OFF");
- goto exit;
+ return ret;
}
if (power) {
@@ -380,7 +377,7 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
if (ret != 0) {
dev_err(component->dev,
"Failed to enable supplies: %d\n", ret);
- goto exit;
+ return ret;
}
if (dac33->reset_gpiod) {
@@ -388,7 +385,7 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
if (ret < 0) {
dev_err(&dac33->i2c->dev,
"Failed to set reset GPIO: %d\n", ret);
- goto exit;
+ return ret;
}
}
@@ -400,7 +397,7 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
if (ret < 0) {
dev_err(&dac33->i2c->dev,
"Failed to set reset GPIO: %d\n", ret);
- goto exit;
+ return ret;
}
}
@@ -409,14 +406,12 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
if (ret != 0) {
dev_err(component->dev,
"Failed to disable supplies: %d\n", ret);
- goto exit;
+ return ret;
}
dac33->chip_power = 0;
}
-exit:
- mutex_unlock(&dac33->mutex);
return ret;
}
@@ -659,7 +654,6 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
{
struct snd_soc_component *component = dac33->component;
unsigned int delay;
- unsigned long flags;
switch (dac33->fifo_mode) {
case DAC33_FIFO_MODE1:
@@ -667,10 +661,10 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
DAC33_THRREG(dac33->nsample));
/* Take the timestamps */
- spin_lock_irqsave(&dac33->lock, flags);
- dac33->t_stamp2 = ktime_to_us(ktime_get());
- dac33->t_stamp1 = dac33->t_stamp2;
- spin_unlock_irqrestore(&dac33->lock, flags);
+ scoped_guard(spinlock_irqsave, &dac33->lock) {
+ dac33->t_stamp2 = ktime_to_us(ktime_get());
+ dac33->t_stamp1 = dac33->t_stamp2;
+ }
dac33_write16(component, DAC33_PREFILL_MSB,
DAC33_THRREG(dac33->alarm_threshold));
@@ -682,11 +676,11 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
break;
case DAC33_FIFO_MODE7:
/* Take the timestamp */
- spin_lock_irqsave(&dac33->lock, flags);
- dac33->t_stamp1 = ktime_to_us(ktime_get());
- /* Move back the timestamp with drain time */
- dac33->t_stamp1 -= dac33->mode7_us_to_lthr;
- spin_unlock_irqrestore(&dac33->lock, flags);
+ scoped_guard(spinlock_irqsave, &dac33->lock) {
+ dac33->t_stamp1 = ktime_to_us(ktime_get());
+ /* Move back the timestamp with drain time */
+ dac33->t_stamp1 -= dac33->mode7_us_to_lthr;
+ }
dac33_write16(component, DAC33_PREFILL_MSB,
DAC33_THRREG(DAC33_MODE7_MARGIN));
@@ -704,14 +698,12 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
static inline void dac33_playback_handler(struct tlv320dac33_priv *dac33)
{
struct snd_soc_component *component = dac33->component;
- unsigned long flags;
switch (dac33->fifo_mode) {
case DAC33_FIFO_MODE1:
/* Take the timestamp */
- spin_lock_irqsave(&dac33->lock, flags);
- dac33->t_stamp2 = ktime_to_us(ktime_get());
- spin_unlock_irqrestore(&dac33->lock, flags);
+ scoped_guard(spinlock_irqsave, &dac33->lock)
+ dac33->t_stamp2 = ktime_to_us(ktime_get());
dac33_write16(component, DAC33_NSAMPLE_MSB,
DAC33_THRREG(dac33->nsample));
@@ -735,7 +727,7 @@ static void dac33_work(struct work_struct *work)
dac33 = container_of(work, struct tlv320dac33_priv, work);
component = dac33->component;
- mutex_lock(&dac33->mutex);
+ guard(mutex)(&dac33->mutex);
switch (dac33->state) {
case DAC33_PREFILL:
dac33->state = DAC33_PLAYBACK;
@@ -757,18 +749,15 @@ static void dac33_work(struct work_struct *work)
dac33_write(component, DAC33_FIFO_CTRL_A, reg);
break;
}
- mutex_unlock(&dac33->mutex);
}
static irqreturn_t dac33_interrupt_handler(int irq, void *dev)
{
struct snd_soc_component *component = dev;
struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component);
- unsigned long flags;
- spin_lock_irqsave(&dac33->lock, flags);
- dac33->t_stamp1 = ktime_to_us(ktime_get());
- spin_unlock_irqrestore(&dac33->lock, flags);
+ scoped_guard(spinlock_irqsave, &dac33->lock)
+ dac33->t_stamp1 = ktime_to_us(ktime_get());
/* Do not schedule the workqueue in Mode7 */
if (dac33->fifo_mode != DAC33_FIFO_MODE7)
@@ -902,14 +891,13 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream,
return -EINVAL;
}
- mutex_lock(&dac33->mutex);
+ guard(mutex)(&dac33->mutex);
if (!dac33->chip_power) {
/*
* Chip is not powered yet.
* Do the init in the dac33_set_bias_level later.
*/
- mutex_unlock(&dac33->mutex);
return 0;
}
@@ -1053,8 +1041,6 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream,
break;
}
- mutex_unlock(&dac33->mutex);
-
return 0;
}
@@ -1156,16 +1142,15 @@ static snd_pcm_sframes_t dac33_dai_delay(
unsigned int time_delta, uthr;
int samples_out, samples_in, samples;
snd_pcm_sframes_t delay = 0;
- unsigned long flags;
switch (dac33->fifo_mode) {
case DAC33_FIFO_BYPASS:
break;
case DAC33_FIFO_MODE1:
- spin_lock_irqsave(&dac33->lock, flags);
- t0 = dac33->t_stamp1;
- t1 = dac33->t_stamp2;
- spin_unlock_irqrestore(&dac33->lock, flags);
+ scoped_guard(spinlock_irqsave, &dac33->lock) {
+ t0 = dac33->t_stamp1;
+ t1 = dac33->t_stamp2;
+ }
t_now = ktime_to_us(ktime_get());
/* We have not started to fill the FIFO yet, delay is 0 */
@@ -1230,10 +1215,10 @@ static snd_pcm_sframes_t dac33_dai_delay(
}
break;
case DAC33_FIFO_MODE7:
- spin_lock_irqsave(&dac33->lock, flags);
- t0 = dac33->t_stamp1;
- uthr = dac33->uthr;
- spin_unlock_irqrestore(&dac33->lock, flags);
+ scoped_guard(spinlock_irqsave, &dac33->lock) {
+ t0 = dac33->t_stamp1;
+ uthr = dac33->uthr;
+ }
t_now = ktime_to_us(ktime_get());
/* We have not started to fill the FIFO yet, delay is 0 */
--
2.43.0
^ permalink raw reply related
* [PATCH 58/78] ASoC: codecs: tas675x: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260618110827.232983-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/tas675x.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tas675x.c b/sound/soc/codecs/tas675x.c
index 6f89a422f3c6..c44bf9144e44 100644
--- a/sound/soc/codecs/tas675x.c
+++ b/sound/soc/codecs/tas675x.c
@@ -162,7 +162,7 @@ static int tas675x_dsp_mem_write(struct tas675x_priv *tas, u8 page, u8 reg, u32
* DSP regs in a different book, therefore block
* regmap access before completion.
*/
- mutex_lock(&tas->io_lock);
+ guard(mutex)(&tas->io_lock);
ret = __tas675x_select_book(tas, TAS675X_BOOK_DSP);
if (ret)
@@ -176,7 +176,6 @@ static int tas675x_dsp_mem_write(struct tas675x_priv *tas, u8 page, u8 reg, u32
out:
__tas675x_select_book(tas, TAS675X_BOOK_DEFAULT);
- mutex_unlock(&tas->io_lock);
return ret;
}
@@ -191,7 +190,7 @@ static int tas675x_dsp_mem_read(struct tas675x_priv *tas, u8 page, u8 reg, u32 *
* DSP regs in a different book, therefore block
* regmap access before completion.
*/
- mutex_lock(&tas->io_lock);
+ guard(mutex)(&tas->io_lock);
ret = __tas675x_select_book(tas, TAS675X_BOOK_DSP);
if (ret)
@@ -211,7 +210,6 @@ static int tas675x_dsp_mem_read(struct tas675x_priv *tas, u8 page, u8 reg, u32 *
out:
__tas675x_select_book(tas, TAS675X_BOOK_DEFAULT);
- mutex_unlock(&tas->io_lock);
return ret;
}
--
2.43.0
^ permalink raw reply related
* [PATCH 57/78] ASoC: codecs: tas5805m: Use guard() for mutex locks
From: phucduc.bui @ 2026-06-18 11:08 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cheng-Yi Chiang,
Tzung-Bi Shih, Guenter Roeck, Benson Leung, David Rhodes,
Richard Fitzgerald, povik+lin, Charles Keepax, Support Opensource,
Nick Li, Herve Codina, Srinivas Kandagatla, Matthias Brugger,
AngeloGioacchino Del Regno, Shenghao Ding, Kevin Lu, Baojun Xu,
Sen Wang, Oder Chiou, Lars-Peter Clausen, nuno.sa, Steven Eckhoff,
patches, chrome-platform, asahi, linux-arm-msm, linux-sound,
linux-kernel, linux-arm-kernel, linux-mediatek, bui duc phuc
In-Reply-To: <20260617103235.449609-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/tas5805m.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c
index bcc8cab8d667..f21670dab0f4 100644
--- a/sound/soc/codecs/tas5805m.c
+++ b/sound/soc/codecs/tas5805m.c
@@ -230,10 +230,9 @@ static int tas5805m_vol_get(struct snd_kcontrol *kcontrol,
struct tas5805m_priv *tas5805m =
snd_soc_component_get_drvdata(component);
- mutex_lock(&tas5805m->lock);
+ guard(mutex)(&tas5805m->lock);
ucontrol->value.integer.value[0] = tas5805m->vol[0];
ucontrol->value.integer.value[1] = tas5805m->vol[1];
- mutex_unlock(&tas5805m->lock);
return 0;
}
@@ -255,7 +254,7 @@ static int tas5805m_vol_put(struct snd_kcontrol *kcontrol,
volume_is_valid(ucontrol->value.integer.value[1])))
return -EINVAL;
- mutex_lock(&tas5805m->lock);
+ guard(mutex)(&tas5805m->lock);
if (tas5805m->vol[0] != ucontrol->value.integer.value[0] ||
tas5805m->vol[1] != ucontrol->value.integer.value[1]) {
tas5805m->vol[0] = ucontrol->value.integer.value[0];
@@ -267,7 +266,6 @@ static int tas5805m_vol_put(struct snd_kcontrol *kcontrol,
tas5805m_refresh(tas5805m);
ret = 1;
}
- mutex_unlock(&tas5805m->lock);
return ret;
}
@@ -332,7 +330,7 @@ static void do_work(struct work_struct *work)
dev_dbg(&tas5805m->i2c->dev, "DSP startup\n");
- mutex_lock(&tas5805m->lock);
+ guard(mutex)(&tas5805m->lock);
/* We mustn't issue any I2C transactions until the I2S
* clock is stable. Furthermore, we must allow a 5ms
* delay after the first set of register writes to
@@ -345,7 +343,6 @@ static void do_work(struct work_struct *work)
tas5805m->is_powered = true;
tas5805m_refresh(tas5805m);
- mutex_unlock(&tas5805m->lock);
}
static int tas5805m_dac_event(struct snd_soc_dapm_widget *w,
@@ -362,7 +359,7 @@ static int tas5805m_dac_event(struct snd_soc_dapm_widget *w,
dev_dbg(component->dev, "DSP shutdown\n");
cancel_work_sync(&tas5805m->work);
- mutex_lock(&tas5805m->lock);
+ guard(mutex)(&tas5805m->lock);
if (tas5805m->is_powered) {
tas5805m->is_powered = false;
@@ -379,7 +376,6 @@ static int tas5805m_dac_event(struct snd_soc_dapm_widget *w,
regmap_write(rm, REG_DEVICE_CTRL_2, DCTRL2_MODE_HIZ);
}
- mutex_unlock(&tas5805m->lock);
}
return 0;
@@ -414,14 +410,13 @@ static int tas5805m_mute(struct snd_soc_dai *dai, int mute, int direction)
struct tas5805m_priv *tas5805m =
snd_soc_component_get_drvdata(component);
- mutex_lock(&tas5805m->lock);
+ guard(mutex)(&tas5805m->lock);
dev_dbg(component->dev, "set mute=%d (is_powered=%d)\n",
mute, tas5805m->is_powered);
tas5805m->is_muted = mute;
if (tas5805m->is_powered)
tas5805m_refresh(tas5805m);
- mutex_unlock(&tas5805m->lock);
return 0;
}
--
2.43.0
^ permalink raw reply related
* Re: [PATCH net v3] net: airoha: Fix skb->priority underflow in airoha_dev_select_queue()
From: Wayen Yan @ 2026-06-18 14:10 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Lorenzo Bianconi, netdev, horms, pabeni, edumazet, andrew+netdev,
angelogioacchino.delregno, matthias.bgg, linux-arm-kernel,
linux-mediatek
In-Reply-To: <20260617161951.52abe413@kernel.org>
On Wed, Jun 18, 2026 at 08:19:51AM +0200, Jakub Kicinski wrote:
> Hi Lorenzo, is there a reason we're subtracting 1 here in the first
> place? Could be just me, but may be worth adding a comment here.
>
> Please respin with some sort of an explanation..
Hi Jakub,
The (priority - 1) mapping predates my involvement — I only addressed
the underflow bug when skb->priority is 0, where the unsigned
subtraction wraps and routes best-effort packets to the highest-priority
queue.
Lorenzo, could you clarify the intended priority-to-queue mapping so
I can add a proper comment in the respin?
Regards,
Wayen
^ permalink raw reply
* [RESEND PATCH v3] coresight: etm-perf: Fix reference count
From: Ma Ke @ 2026-06-18 10:50 UTC (permalink / raw)
To: suzuki.poulose, mike.leach, james.clark, leo.yan,
alexander.shishkin, mathieu.poirier
Cc: coresight, linux-arm-kernel, linux-kernel, akpm, Ma Ke, stable
bus_find_device() returns a device with its reference count
incremented. When a user-selected sink is obtained through
coresight_get_sink_by_id(), etm_setup_aux() keeps using the returned
sink while building the path and allocating the sink buffer.
Therefore the lookup reference must remain valid while etm_setup_aux()
is still using the sink, otherwise the sink could be removed under the
caller. Drop the lookup reference on the common exit path, after
etm_setup_aux() no longer directly uses the user-selected sink.
The CoreSight path code takes the references it needs for built paths,
so the initial lookup reference from coresight_get_sink_by_id() is no
longer needed after setup_aux finishes.
Found by code review.
Signed-off-by: Ma Ke <make_ruc2021@163.com>
Cc: stable@vger.kernel.org
Fixes: 0e6c20517596 ("coresight: etm-perf: Allow an event to use different sinks")
---
Changes in v3:
- do not drop the lookup reference in coresight_get_sink_by_id(), as
that would return a sink pointer without keeping the device reference
while etm_setup_aux() is still using it.
- dropped the lookup reference in etm_setup_aux on the common exit path,
as suggested by Suzuki.
- updated the commit message to describe why the reference is kept
until etm_setup_aux() finishes using the sink.
Changes in v2:
- modified the patch as suggestions.
---
drivers/hwtracing/coresight/coresight-etm-perf.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index f85dedf89a3f..d5116177c1b9 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -456,6 +456,11 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
goto err;
out:
+ if (user_sink) {
+ put_device(&user_sink->dev);
+ user_sink = NULL;
+ }
+
return event_data;
err:
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v4 3/4] drivers/firmware: add SDEI cross-CPU NMI service for arm64
From: Julian Braha @ 2026-06-18 10:46 UTC (permalink / raw)
To: Kiryl Shutsemau, Catalin Marinas, Will Deacon, James Morse
Cc: Mark Rutland, Marc Zyngier, Doug Anderson, Petr Mladek,
Thomas Gleixner, Andrew Morton, Baoquan He, Puranjay Mohan,
Usama Arif, Breno Leitao, Julien Thierry, Lecopzer Chen,
Sumit Garg, kernel-team, kexec, linux-arm-kernel, linux-kernel,
Kiryl Shutsemau (Meta)
In-Reply-To: <ab745689c0bfd01438d98ed1c79328bf2121be3b.1781709543.git.kas@kernel.org>
Hi Kiryl,
On 6/17/26 20:20, Kiryl Shutsemau wrote:
> +config ARM_SDEI_NMI
> + bool "SDEI-based cross-CPU NMI service (arm64)"
> + depends on ARM64 && ARM_SDE_INTERFACE
The dependency on ARM64 is redundant here since you already have the
dependency on ARM_SDE_INTERFACE. Maybe a comment instead, though I think
it's pretty clear from the prompt...
- Julian Braha
^ permalink raw reply
* Re: [PATCH v4 4/6] drm/verisilicon: add DC8000 (DCUltraLite) display controller support
From: Icenowy Zheng @ 2026-06-18 10:33 UTC (permalink / raw)
To: Joey Lu, maarten.lankhorst, mripard, tzimmermann, airlied, simona,
robh, krzk+dt, conor+dt, Michael Turquette, Stephen Boyd,
Brian Masney
Cc: ychuang3, schung, yclu4, dri-devel, devicetree, linux-arm-kernel,
linux-kernel, linux-clk
In-Reply-To: <df7363be-0e3f-4459-be4a-43ffb0a5366c@gmail.com>
(CC'ed clk maintainers for weird clock gate bit)
在 2026-06-17三的 18:35 +0800,Joey Lu写道:
>
> On 6/15/2026 4:51 PM, Icenowy Zheng wrote:
> > 在 2026-06-15一的 14:50 +0800,Joey Lu写道:
> > > The Nuvoton MA35D1 SoC integrates a Verisilicon DCUltraLite
> > > display
> > > controller whose register layout differs from the DC8200 in
> > > several
> > > important ways:
> > >
> > > 1. No CONFIG_EX commit path: framebuffer updates use the enable
> > > (bit
> > > 0)
> > > and reset (bit 4) bits in FB_CONFIG instead of the DC8200
> > > staging
> > > registers (FB_CONFIG_EX, FB_TOP_LEFT, FB_BOTTOM_RIGHT,
> > > FB_BLEND_CONFIG, PANEL_CONFIG_EX).
> > >
> > > 2. No PANEL_START register: panel output starts when
> > > PANEL_CONFIG.RUNNING is set; there is no multi-display sync
> > > start
> > > register.
> > >
> > > 3. Different IRQ registers: DCUltraLite uses DISP_IRQ_STA
> > > (0x147C) /
> > > DISP_IRQ_EN (0x1480) versus DC8200's TOP_IRQ_ACK (0x0010) /
> > > TOP_IRQ_EN (0x0014).
> > >
> > > 4. Per-frame commit cycle: DCUltraLite requires the VALID bit in
> > > FB_CONFIG to be set at the start of each atomic commit
> > > (crtc_begin)
> > > and cleared after (crtc_flush).
> > >
> > > 5. Simpler clock topology: only 'core' (bus gate) and 'pix0'
> > > (pixel
> > > divider) clocks; no axi or ahb clocks required. Make axi_clk
> > > and
> > > ahb_clk optional (devm_clk_get_optional_enabled) so DC8000
> > > nodes
> > > without those clocks are handled gracefully.
> > >
> > > Add vs_dc8000.c implementing the vs_dc_funcs vtable for the above
> > > differences. The probe now selects vs_dc8000_funcs when the
> > > identified
> > > generation is VSDC_GEN_DC8000 (DCUltraLite reads model 0x0,
> > > revision 0x5560, customer_id 0x305).
> > >
> > > Signed-off-by: Joey Lu <a0987203069@gmail.com>
> > > ---
> > > drivers/gpu/drm/verisilicon/Makefile | 2 +-
> > > drivers/gpu/drm/verisilicon/vs_dc.c | 9 ++-
> > > drivers/gpu/drm/verisilicon/vs_dc.h | 1 +
> > > drivers/gpu/drm/verisilicon/vs_dc8000.c | 78
> > > +++++++++++++++++++++++++
> > > 4 files changed, 86 insertions(+), 4 deletions(-)
> > > create mode 100644 drivers/gpu/drm/verisilicon/vs_dc8000.c
> > >
> > > diff --git a/drivers/gpu/drm/verisilicon/Makefile
> > > b/drivers/gpu/drm/verisilicon/Makefile
> > > index 9d4cd16452fa..d2fd8e4dff24 100644
> > > --- a/drivers/gpu/drm/verisilicon/Makefile
> > > +++ b/drivers/gpu/drm/verisilicon/Makefile
> > > @@ -1,6 +1,6 @@
> > > # SPDX-License-Identifier: GPL-2.0-only
> > >
> > > -verisilicon-dc-objs := vs_bridge.o vs_crtc.o vs_dc.o vs_dc8200.o
> > > vs_drm.o vs_hwdb.o \
> > > +verisilicon-dc-objs := vs_bridge.o vs_crtc.o vs_dc.o vs_dc8200.o
> > > vs_dc8000.o vs_drm.o vs_hwdb.o \
> > > vs_plane.o vs_primary_plane.o vs_cursor_plane.o
> > >
> > > obj-$(CONFIG_DRM_VERISILICON_DC) += verisilicon-dc.o
> > > diff --git a/drivers/gpu/drm/verisilicon/vs_dc.c
> > > b/drivers/gpu/drm/verisilicon/vs_dc.c
> > > index 9729b693d360..9499fffbca58 100644
> > > --- a/drivers/gpu/drm/verisilicon/vs_dc.c
> > > +++ b/drivers/gpu/drm/verisilicon/vs_dc.c
> > > @@ -90,13 +90,13 @@ static int vs_dc_probe(struct platform_device
> > > *pdev)
> > > return PTR_ERR(dc->core_clk);
> > > }
> > >
> > > - dc->axi_clk = devm_clk_get_enabled(dev, "axi");
> > > + dc->axi_clk = devm_clk_get_optional_enabled(dev, "axi");
> > > if (IS_ERR(dc->axi_clk)) {
> > > dev_err(dev, "can't get axi clock\n");
> > > return PTR_ERR(dc->axi_clk);
> > > }
> > >
> > > - dc->ahb_clk = devm_clk_get_enabled(dev, "ahb");
> > > + dc->ahb_clk = devm_clk_get_optional_enabled(dev, "ahb");
> > Please make the clock change a separated patch for atomicity.
> >
> > BTW the MA35D1 manual's clock tree shows that DCUltra appears on
> > AXI2
> > ACLK, AHB_HCLK2, behind a mux of SYS-PLL/EPLL-DIV2 (which seems to
> > be
> > the core clock), and behind a divider (which seems to be the pixel
> > clock).
> >
> > However it's weird that only one DCUltra Clock Enable Bit exists
> > despite both bus clocks have "ICG" (I think it means "Integrated
> > Clock
> > Gating"). In addition the linux clk-ma35d1 driver assigns
> > "dcu_gate" as
> > a downstream of "dcu_mux", although the Figure 6.5-2 in the TRM
> > shows
> > no ICG after the "Display core CLK" mux.
> >
> > Is the two bus clocks controlled by a single gate bit, and is the
> > bit
> > also gating DC core clock?
> >
> > Thanks,
> > Icenowy
> I will split the axi/ahb optional-clock change into its own patch in
> v5
> for atomicity.
> Regarding the MA35D1 clock tree: from the TRM, the single "dcu_gate"
> bit
> gates both bus clocks (AXI ACLK and AHB HCLK) together with the
> display
> core clock through the same ICG cell. The clk-ma35d1 driver exposes
> only
> "dcu_gate" (downstream of "dcu_mux") and does not provide separate
Then it's one of the case that the clock tree doesn't properly
represent the hardware, which is bad. However, as three gates share the
same bit, I am not sure how to represent such kind of thing in the
common clk framework.
> axi/ahb clock entries. Therefore the MA35D1 DT binding will use only
> two
> clocks ("core" and "pix0"); making axi and ahb optional in the driver
> is the correct approach, and this will be stated clearly in the
> split-out patch.
I agree to make them optional, although these two clocks do exist in
the hardware of MA35D1.
Thanks,
Icenowy
> > > if (IS_ERR(dc->ahb_clk)) {
> > > dev_err(dev, "can't get ahb clock\n");
> > > return PTR_ERR(dc->ahb_clk);
^ permalink raw reply
* Re: [PATCH v2 1/1] reset: imx7: Correct polarity of MIPI CSI resets on i.MX8MQ
From: Philipp Zabel @ 2026-06-18 10:24 UTC (permalink / raw)
To: Robby Cai
Cc: Frank.Li, s.hauer, festevam, krzk+dt, andrew.smirnov, kernel, imx,
linux-arm-kernel, linux-kernel, aisheng.dong, guoniu.zhou
In-Reply-To: <20260417092809.GA582835@shlinux88>
On Fr, 2026-04-17 at 17:28 +0800, Robby Cai wrote:
> On Fri, Apr 17, 2026 at 10:47:48AM +0200, Philipp Zabel wrote:
> > On Fr, 2026-04-17 at 16:08 +0800, Robby Cai wrote:
> > > On i.MX8MQ, the MIPI CSI reset lines are active-low and not self-clearing.
> > > Writing '0' asserts reset and it remains asserted until explicitly
> > > deasserted by software.
> > >
> > > This driver previously treated the MIPI CSI reset signals as active-high,
> > > which led to incorrect reset assert/deassert sequencing. This issue was
> > > exposed by commit 6d79bb8fd2aa ("media: imx8mq-mipi-csi2: Explicitly
> > > release reset").
> >
> > If this patch is backported without 6d79bb8fd2aa, or the other way
> > around, will that break MIPI CSI-2 on older kernels? That would warrant
> > a Cc: stable tag.
> >
>
> Yes, will break.
> These two patches should be backported as a pair to ensure correct behavior.
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Can you please resend with
Cc: <stable@vger.kernel.org> # 6d79bb8fd2aa: media: imx8mq-mipi-csi2: Explicitly release reset
regards
Philipp
^ permalink raw reply
* Re: [PATCH v4 1/6] dt-bindings: display: verisilicon, dc: generalize for single-output variants
From: Icenowy Zheng @ 2026-06-18 10:24 UTC (permalink / raw)
To: Joey Lu, maarten.lankhorst, mripard, tzimmermann, airlied, simona,
robh, krzk+dt, conor+dt
Cc: ychuang3, schung, yclu4, dri-devel, devicetree, linux-arm-kernel,
linux-kernel
In-Reply-To: <6d3e3121-22f2-4c59-9678-df2f57ff4d31@gmail.com>
在 2026-06-17三的 18:25 +0800,Joey Lu写道:
>
> On 6/15/2026 4:19 PM, Icenowy Zheng wrote:
> > 在 2026-06-15一的 14:49 +0800,Joey Lu写道:
> > > The existing schema hard-codes the five-clock/three-reset/dual-
> > > port
> > > topology of the DC8200 IP block, preventing reuse for single-
> > > output
> > > variants such as the Verisilicon DCUltraLite used in the Nuvoton
> > > MA35D1
> > > SoC.
> > >
> > > Rework the schema so that variant-specific constraints are
> > > expressed
> > > via
> > > allOf/if blocks:
> > >
> > > - Add nuvoton,ma35d1-dcu to the SoC-specific compatible enum.
> > > The
> > > generic verisilicon,dc fallback remains the driver-binding
> > > string.
> > > - Move clock and reset items descriptions into the per-variant
> > > allOf/if
> > > blocks; keep only minItems/maxItems at the top level so the
> > > base
> > > schema
> > > accepts all variants.
> > > - Restore full items lists for clock-names and reset-names at the
> > > top
> > > level with minItems so the names are validated against the
> > > descriptions.
> > > - Keep ports in the global required list and keep
> > > additionalProperties: false.
> > > - Add an allOf/if block for thead,th1520-dc8200: five-clock
> > > (core,
> > > axi,
> > > ahb, pix0, pix1), three-reset (core, axi, ahb), required
> > > resets.
> > > - Add an allOf/if block for nuvoton,ma35d1-dcu: two-clock (core,
> > > pix0),
> > > one-reset (core), required resets.
> > >
> > > Signed-off-by: Joey Lu <a0987203069@gmail.com>
> > > ---
> > > .../bindings/display/verisilicon,dc.yaml | 80
> > > +++++++++++++++++--
> > > 1 file changed, 73 insertions(+), 7 deletions(-)
> > >
> > > diff --git
> > > a/Documentation/devicetree/bindings/display/verisilicon,dc.yaml
> > > b/Documentation/devicetree/bindings/display/verisilicon,dc.yaml
> > > index 9dc35ab973f2..0c41286b8223 100644
> > > ---
> > > a/Documentation/devicetree/bindings/display/verisilicon,dc.yaml
> > > +++
> > > b/Documentation/devicetree/bindings/display/verisilicon,dc.yaml
> > > @@ -17,6 +17,7 @@ properties:
> > > items:
> > > - enum:
> > > - thead,th1520-dc8200
> > > + - nuvoton,ma35d1-dcu
> > > - const: verisilicon,dc # DC IPs have discoverable
> > > ID/revision
> > > registers
> > >
> > > reg:
> > > @@ -26,14 +27,12 @@ properties:
> > > maxItems: 1
> > >
> > > clocks:
> > > - items:
> > > - - description: DC Core clock
> > > - - description: DMA AXI bus clock
> > > - - description: Configuration AHB bus clock
> > > - - description: Pixel clock of output 0
> > > - - description: Pixel clock of output 1
> > Clock descriptions should still be in the global part instead of
> > the
> > per-compatible part.
> >
> > In the per-compatible part, clock-names should be constraint for
> > SoCs.
> I will move the `items:` clock descriptions back into the global
> `clocks:` property, covering all five possible clocks. In the
> per-compatible sections I will remove the description items and only
> constrain `clocks: minItems/maxItems` and `clock-names:
> minItems/maxItems`; for nuvoton,ma35d1-dcu I will additionally
> override
> `clock-names: items:` to the two names actually used (core, pix0).
Yes, this should be the correct practice, although I wonder whether the
minItems and maxItems properties are needed globally (because these two
seem to have default implicit value).
BTW the MA35D1 manual in fact shows 4 clocks for "DCUltra" in the clock
tree, maybe the DT binding needs to be reconsidered?
Thanks,
Icenowy
> > > + minItems: 2
> > > + maxItems: 5
> > >
> > > clock-names:
> > > + minItems: 2
> > > + maxItems: 5
> > > items:
> > > - const: core
> > > - const: axi
^ permalink raw reply
* Re: [PATCH] pinctrl: Match DT helper types
From: Florian Fainelli @ 2026-06-18 10:24 UTC (permalink / raw)
To: Rob Herring (Arm), Linus Walleij, Ray Jui, Scott Branden,
Broadcom internal kernel review list
Cc: linux-gpio, linux-arm-kernel, linux-kernel
In-Reply-To: <20260612214939.1883911-1-robh@kernel.org>
On 6/12/2026 2:49 PM, 'Rob Herring (Arm)' via
BCM-KERNEL-FEEDBACK-LIST,PDL wrote:
> The affected pinctrl drivers either check for the presence of a standard
> property or read a property documented with an 8-bit cell encoding.
> Using boolean or u32 helpers for those cases disagrees with the binding.
>
> Use a presence helper for "gpio-ranges" and read
> "microchip,spi-present-mask" with the u8 helper documented by the
> binding.
>
> Assisted-by: Codex:gpt-5-5
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply
* [PATCH v4 1/2] dt-bindings: clock: Add Amlogic A9 AO clock controller
From: Jian Hu via B4 Relay @ 2026-06-18 9:49 UTC (permalink / raw)
To: Neil Armstrong, Jerome Brunet, Michael Turquette, Stephen Boyd,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Xianwei Zhao,
Kevin Hilman, Martin Blumenstingl
Cc: linux-amlogic, linux-clk, devicetree, linux-kernel,
linux-arm-kernel, Jian Hu, Conor Dooley
In-Reply-To: <20260618-a9_aoclk-v4-0-569d0425e50c@amlogic.com>
From: Jian Hu <jian.hu@amlogic.com>
Add the Always-On clock controller dt-bindings for the Amlogic A9
SoC family.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Jian Hu <jian.hu@amlogic.com>
---
.../bindings/clock/amlogic,a9-aoclkc.yaml | 76 ++++++++++++++++++++++
include/dt-bindings/clock/amlogic,a9-aoclkc.h | 76 ++++++++++++++++++++++
2 files changed, 152 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/amlogic,a9-aoclkc.yaml b/Documentation/devicetree/bindings/clock/amlogic,a9-aoclkc.yaml
new file mode 100644
index 000000000000..1fa9b3a32fbb
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/amlogic,a9-aoclkc.yaml
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/amlogic,a9-aoclkc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 Series Always-On Clock Controller
+
+maintainers:
+ - Neil Armstrong <neil.armstrong@linaro.org>
+ - Jerome Brunet <jbrunet@baylibre.com>
+ - Jian Hu <jian.hu@amlogic.com>
+ - Xianwei Zhao <xianwei.zhao@amlogic.com>
+
+properties:
+ compatible:
+ const: amlogic,a9-aoclkc
+
+ reg:
+ maxItems: 1
+
+ '#clock-cells':
+ const: 1
+
+ clocks:
+ minItems: 5
+ items:
+ - description: input oscillator
+ - description: input fclk div 3
+ - description: input fclk div 4
+ - description: input fclk div 5
+ - description: input sys clk
+ - description: external fixed 32k (optional)
+
+ clock-names:
+ minItems: 5
+ items:
+ - const: xtal
+ - const: fdiv3
+ - const: fdiv4
+ - const: fdiv5
+ - const: sys
+ - const: ext_32k
+
+required:
+ - compatible
+ - reg
+ - '#clock-cells'
+ - clocks
+ - clock-names
+
+additionalProperties: false
+
+examples:
+ - |
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ clock-controller@0 {
+ compatible = "amlogic,a9-aoclkc";
+ reg = <0x0 0x0 0x0 0x58>;
+ #clock-cells = <1>;
+ clocks = <&xtal>,
+ <&scmi_clk 14>,
+ <&scmi_clk 16>,
+ <&scmi_clk 18>,
+ <&scmi_clk 21>;
+ clock-names = "xtal",
+ "fdiv3",
+ "fdiv4",
+ "fdiv5",
+ "sys";
+ };
+ };
diff --git a/include/dt-bindings/clock/amlogic,a9-aoclkc.h b/include/dt-bindings/clock/amlogic,a9-aoclkc.h
new file mode 100644
index 000000000000..a7d704d4b58e
--- /dev/null
+++ b/include/dt-bindings/clock/amlogic,a9-aoclkc.h
@@ -0,0 +1,76 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2026 Amlogic, Inc. All rights reserved.
+ */
+
+#ifndef __AMLOGIC_A9_AO_CLKC_H
+#define __AMLOGIC_A9_AO_CLKC_H
+
+#define CLKID_AO_XTAL_IN 0
+#define CLKID_AO_XTAL 1
+#define CLKID_AO_SYS 2
+#define CLKID_AO_SYS_I3C 3
+#define CLKID_AO_SYS_RTC_REG 4
+#define CLKID_AO_SYS_CLKTREE 5
+#define CLKID_AO_SYS_RST_CTRL 6
+#define CLKID_AO_SYS_PAD 7
+#define CLKID_AO_SYS_RTC_DIG 8
+#define CLKID_AO_SYS_IRQ 9
+#define CLKID_AO_SYS_PWRCTRL 10
+#define CLKID_AO_SYS_PWM_A 11
+#define CLKID_AO_SYS_PWM_B 12
+#define CLKID_AO_SYS_PWM_C 13
+#define CLKID_AO_SYS_PWM_D 14
+#define CLKID_AO_SYS_PWM_E 15
+#define CLKID_AO_SYS_PWM_F 16
+#define CLKID_AO_SYS_PWM_G 17
+#define CLKID_AO_SYS_I2C_A 18
+#define CLKID_AO_SYS_I2C_B 19
+#define CLKID_AO_SYS_I2C_C 20
+#define CLKID_AO_SYS_I2C_D 21
+#define CLKID_AO_SYS_SED 22
+#define CLKID_AO_SYS_IR_CTRL 23
+#define CLKID_AO_SYS_UART_B 24
+#define CLKID_AO_SYS_UART_C 25
+#define CLKID_AO_SYS_UART_D 26
+#define CLKID_AO_SYS_UART_E 27
+#define CLKID_AO_SYS_SPISG_0 28
+#define CLKID_AO_SYS_RTC_SECURE 29
+#define CLKID_AO_SYS_CEC 30
+#define CLKID_AO_SYS_AOCPU 31
+#define CLKID_AO_SYS_SRAM 32
+#define CLKID_AO_SYS_SPISG_1 33
+#define CLKID_AO_SYS_SPISG_2 34
+#define CLKID_AO_PWM_A_SEL 35
+#define CLKID_AO_PWM_A_DIV 36
+#define CLKID_AO_PWM_A 37
+#define CLKID_AO_PWM_B_SEL 38
+#define CLKID_AO_PWM_B_DIV 39
+#define CLKID_AO_PWM_B 40
+#define CLKID_AO_PWM_C_SEL 41
+#define CLKID_AO_PWM_C_DIV 42
+#define CLKID_AO_PWM_C 43
+#define CLKID_AO_PWM_D_SEL 44
+#define CLKID_AO_PWM_D_DIV 45
+#define CLKID_AO_PWM_D 46
+#define CLKID_AO_PWM_E_SEL 47
+#define CLKID_AO_PWM_E_DIV 48
+#define CLKID_AO_PWM_E 49
+#define CLKID_AO_PWM_F_SEL 50
+#define CLKID_AO_PWM_F_DIV 51
+#define CLKID_AO_PWM_F 52
+#define CLKID_AO_PWM_G_SEL 53
+#define CLKID_AO_PWM_G_DIV 54
+#define CLKID_AO_PWM_G 55
+#define CLKID_AO_RTC_DUALDIV_IN 56
+#define CLKID_AO_RTC_DUALDIV_DIV 57
+#define CLKID_AO_RTC_DUALDIV_SEL 58
+#define CLKID_AO_RTC_DUALDIV 59
+#define CLKID_AO_RTC 60
+#define CLKID_AO_CEC_DUALDIV_IN 61
+#define CLKID_AO_CEC_DUALDIV_DIV 62
+#define CLKID_AO_CEC_DUALDIV_SEL 63
+#define CLKID_AO_CEC_DUALDIV 64
+#define CLKID_AO_CEC 65
+
+#endif /* __AMLOGIC_A9_AO_CLKC_H */
--
2.47.1
^ permalink raw reply related
* Re: [PATCH v1 11/11] KVM: arm64: Implement lazy vCPU state sync for non-protected guests
From: Fuad Tabba @ 2026-06-18 10:18 UTC (permalink / raw)
To: Marc Zyngier
Cc: Oliver Upton, Will Deacon, Catalin Marinas, Quentin Perret,
Vincent Donnefort, Sebastian Ene, Per Larsen, Suzuki K Poulose,
Zenghui Yu, Joey Gouly, Steffen Eiden, Mark Rutland,
Jonathan Cameron, Hyunwoo Kim, linux-arm-kernel, kvmarm,
linux-kernel
In-Reply-To: <86fr2krw56.wl-maz@kernel.org>
On Thu, 18 Jun 2026 at 11:16, Marc Zyngier <maz@kernel.org> wrote:
>
> On Fri, 12 Jun 2026 07:59:25 +0100,
> tabba@google.com wrote:
> >
> > pKVM copies a non-protected guest's register context between the host
> > and the hypervisor on every world switch, even when the host never
> > inspects it. Defer the copy: on entry, flush the host context into the
> > hyp vCPU only when the host marked it dirty (PKVM_HOST_STATE_DIRTY); on
> > exit, leave it in the hyp vCPU and copy it back only when the host needs
> > it, via a __pkvm_vcpu_sync_state hypercall on trap handling or at vcpu
> > put. A protected guest's context is copied as before, since lazy sync
> > only helps where the host is trusted to see the guest's registers.
> >
> > The PC is the exception: it is copied back on every exit so the
> > kvm_exit tracepoint reports the guest's real exit PC rather than the
> > value left by the previous sync.
> >
> > Signed-off-by: Fuad Tabba <tabba@google.com>
> > ---
> > arch/arm64/include/asm/kvm_asm.h | 1 +
> > arch/arm64/include/asm/kvm_host.h | 2 +
> > arch/arm64/kvm/arm.c | 7 +++
> > arch/arm64/kvm/handle_exit.c | 22 ++++++++
> > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 88 ++++++++++++++++++++++++++++--
> > 5 files changed, 115 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> > index 043495f7fc78..6e1135b3ded4 100644
> > --- a/arch/arm64/include/asm/kvm_asm.h
> > +++ b/arch/arm64/include/asm/kvm_asm.h
> > @@ -113,6 +113,7 @@ enum __kvm_host_smccc_func {
> > __KVM_HOST_SMCCC_FUNC___pkvm_finalize_teardown_vm,
> > __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_load,
> > __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_put,
> > + __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_sync_state,
> > __KVM_HOST_SMCCC_FUNC___pkvm_tlb_flush_vmid,
> >
> > MARKER(__KVM_HOST_SMCCC_FUNC_MAX)
> > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> > index a49042bfa801..1ef660774adc 100644
> > --- a/arch/arm64/include/asm/kvm_host.h
> > +++ b/arch/arm64/include/asm/kvm_host.h
> > @@ -1113,6 +1113,8 @@ struct kvm_vcpu_arch {
> > /* SError pending for nested guest */
> > #define NESTED_SERROR_PENDING __vcpu_single_flag(sflags, BIT(8))
> >
> > +/* pKVM host vcpu state is dirty, needs resync (nVHE-only) */
> > +#define PKVM_HOST_STATE_DIRTY __vcpu_single_flag(iflags, BIT(4))
>
> Please don't add flags in random positions. Keep them grouped by
> type.
>
> Also, it is unclear to me whether this is really an input to the
> hypervisor (which is what iflags indicates), but rather a new type of
> flag that indicate some hypervisor-private state. May not be that
> important right now, but worth keeping in mind.
Will move it and come up with a better name/comment.
Cheers,
/fuad
>
> M.
>
> --
> Without deviation from the norm, progress is not possible.
^ permalink raw reply
* Re: [PATCH v1 10/11] KVM: arm64: Add primitives to flush/sync the VGIC state at EL2
From: Fuad Tabba @ 2026-06-18 10:17 UTC (permalink / raw)
To: Marc Zyngier
Cc: Oliver Upton, Will Deacon, Catalin Marinas, Quentin Perret,
Vincent Donnefort, Sebastian Ene, Per Larsen, Suzuki K Poulose,
Zenghui Yu, Joey Gouly, Steffen Eiden, Mark Rutland,
Jonathan Cameron, Hyunwoo Kim, linux-arm-kernel, kvmarm,
linux-kernel
In-Reply-To: <86h5n0rwfw.wl-maz@kernel.org>
On Thu, 18 Jun 2026 at 11:10, Marc Zyngier <maz@kernel.org> wrote:
>
> On Fri, 12 Jun 2026 07:59:24 +0100,
> tabba@google.com wrote:
> >
> > From: Marc Zyngier <maz@kernel.org>
> >
> > pKVM performs its own world switch for protected VMs but has no
> > primitives to move the per-vCPU VGIC state between the host and
> > hypervisor vCPU contexts.
> >
> > Add flush_hyp_vgic_state() and sync_hyp_vgic_state(). Flush copies
> > vgic_hcr, the in-use list registers and used_lrs from the host into the
> > hyp vCPU and pins vgic_sre to a fixed value; sync copies vgic_hcr,
> > vgic_vmcr and the in-use list registers back. The active priority
> > registers are handled separately by the save/restore-aprs path.
> >
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > Co-developed-by: Fuad Tabba <tabba@google.com>
> > Signed-off-by: Fuad Tabba <tabba@google.com>
> > ---
> > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 50 +++++++++++++++++++++++++-----
> > 1 file changed, 42 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > index 2f165b6c7b07..23e644c24a03 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > @@ -99,6 +99,46 @@ static void fpsimd_sve_sync(struct kvm_vcpu *vcpu)
> > *host_data_ptr(fp_owner) = FP_STATE_HOST_OWNED;
> > }
> >
> > +static void flush_hyp_vgic_state(struct pkvm_hyp_vcpu *hyp_vcpu)
> > +{
> > + struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;
> > + struct vgic_v3_cpu_if *host_cpu_if, *hyp_cpu_if;
> > + unsigned int used_lrs, max_lrs, i;
> > +
> > + host_cpu_if = &host_vcpu->arch.vgic_cpu.vgic_v3;
> > + hyp_cpu_if = &hyp_vcpu->vcpu.arch.vgic_cpu.vgic_v3;
> > +
> > + max_lrs = (read_gicreg(ICH_VTR_EL2) & ICH_VTR_EL2_ListRegs) + 1;
>
> This really needs to be rebased on the current state of kvmarm/next,
> particularly 8cc8bbbfab14c ("KVM: arm64: Bound used_lrs when flushing
> the pKVM hyp vCPU").
>
> I really want to avoid using ICH_VTR_EL2 on each and every entry to
> the guest, as this has really bad performance impacts when running
> this under NV (which is the only way I run pKVM).
Will do.
Thanks,
/fuad
>
> Thanks,
>
> M.
>
> --
> Without deviation from the norm, progress is not possible.
^ permalink raw reply
* Re: [PATCH v1 11/11] KVM: arm64: Implement lazy vCPU state sync for non-protected guests
From: Marc Zyngier @ 2026-06-18 10:16 UTC (permalink / raw)
To: tabba
Cc: Oliver Upton, Will Deacon, Catalin Marinas, Quentin Perret,
Vincent Donnefort, Sebastian Ene, Per Larsen, Suzuki K Poulose,
Zenghui Yu, Joey Gouly, Steffen Eiden, Mark Rutland,
Jonathan Cameron, Hyunwoo Kim, linux-arm-kernel, kvmarm,
linux-kernel
In-Reply-To: <20260612065925.755562-12-tabba@google.com>
On Fri, 12 Jun 2026 07:59:25 +0100,
tabba@google.com wrote:
>
> pKVM copies a non-protected guest's register context between the host
> and the hypervisor on every world switch, even when the host never
> inspects it. Defer the copy: on entry, flush the host context into the
> hyp vCPU only when the host marked it dirty (PKVM_HOST_STATE_DIRTY); on
> exit, leave it in the hyp vCPU and copy it back only when the host needs
> it, via a __pkvm_vcpu_sync_state hypercall on trap handling or at vcpu
> put. A protected guest's context is copied as before, since lazy sync
> only helps where the host is trusted to see the guest's registers.
>
> The PC is the exception: it is copied back on every exit so the
> kvm_exit tracepoint reports the guest's real exit PC rather than the
> value left by the previous sync.
>
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
> arch/arm64/include/asm/kvm_asm.h | 1 +
> arch/arm64/include/asm/kvm_host.h | 2 +
> arch/arm64/kvm/arm.c | 7 +++
> arch/arm64/kvm/handle_exit.c | 22 ++++++++
> arch/arm64/kvm/hyp/nvhe/hyp-main.c | 88 ++++++++++++++++++++++++++++--
> 5 files changed, 115 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> index 043495f7fc78..6e1135b3ded4 100644
> --- a/arch/arm64/include/asm/kvm_asm.h
> +++ b/arch/arm64/include/asm/kvm_asm.h
> @@ -113,6 +113,7 @@ enum __kvm_host_smccc_func {
> __KVM_HOST_SMCCC_FUNC___pkvm_finalize_teardown_vm,
> __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_load,
> __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_put,
> + __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_sync_state,
> __KVM_HOST_SMCCC_FUNC___pkvm_tlb_flush_vmid,
>
> MARKER(__KVM_HOST_SMCCC_FUNC_MAX)
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index a49042bfa801..1ef660774adc 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -1113,6 +1113,8 @@ struct kvm_vcpu_arch {
> /* SError pending for nested guest */
> #define NESTED_SERROR_PENDING __vcpu_single_flag(sflags, BIT(8))
>
> +/* pKVM host vcpu state is dirty, needs resync (nVHE-only) */
> +#define PKVM_HOST_STATE_DIRTY __vcpu_single_flag(iflags, BIT(4))
Please don't add flags in random positions. Keep them grouped by
type.
Also, it is unclear to me whether this is really an input to the
hypervisor (which is what iflags indicates), but rather a new type of
flag that indicate some hypervisor-private state. May not be that
important right now, but worth keeping in mind.
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply
* Re: [PATCH v8 02/10] reset: Add Realtek basic reset support
From: Philipp Zabel @ 2026-06-18 10:11 UTC (permalink / raw)
To: Yu-Chun Lin, mturquette, sboyd, robh, krzk+dt, conor+dt, cylee12,
afaerber, jyanchou
Cc: bmasney, devicetree, linux-clk, linux-kernel, linux-arm-kernel,
linux-realtek-soc, james.tai, cy.huang, stanley_chang
In-Reply-To: <20260610080824.255063-3-eleanor.lin@realtek.com>
On Mi, 2026-06-10 at 16:08 +0800, Yu-Chun Lin wrote:
> From: Cheng-Yu Lee <cylee12@realtek.com>
>
> Define the reset operations backed by a regmap-based register interface
> and prepare the reset controller to be registered through the reset
> framework.
>
> Since the reset controllers on Realtek SoCs often share the same register
> space with the clock controllers, this common framework is designed to
> extract the regmap and device tree node from the parent device
> (e.g., an auxiliary device parent).
>
> Signed-off-by: Cheng-Yu Lee <cylee12@realtek.com>
> Co-developed-by: Yu-Chun Lin <eleanor.lin@realtek.com>
> Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>
> ---
> Changes in v8:
> - None
> ---
> MAINTAINERS | 1 +
> drivers/reset/Kconfig | 1 +
> drivers/reset/Makefile | 1 +
> drivers/reset/realtek/Kconfig | 8 +++
> drivers/reset/realtek/Makefile | 2 +
> drivers/reset/realtek/common.c | 90 ++++++++++++++++++++++++++++++++++
> drivers/reset/realtek/common.h | 29 +++++++++++
> 7 files changed, 132 insertions(+)
> create mode 100644 drivers/reset/realtek/Kconfig
> create mode 100644 drivers/reset/realtek/Makefile
> create mode 100644 drivers/reset/realtek/common.c
> create mode 100644 drivers/reset/realtek/common.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 613ca7e95e47..80e840a6691d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -22484,6 +22484,7 @@ L: devicetree@vger.kernel.org
> L: linux-clk@vger.kernel.org
> S: Supported
> F: Documentation/devicetree/bindings/clock/realtek*
> +F: drivers/reset/realtek/*
> F: include/dt-bindings/clock/realtek*
> F: include/dt-bindings/reset/realtek*
>
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index d009eb0849a3..45a4227b5f44 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -418,6 +418,7 @@ config RESET_ZYNQMP
>
> source "drivers/reset/amlogic/Kconfig"
> source "drivers/reset/hisilicon/Kconfig"
> +source "drivers/reset/realtek/Kconfig"
> source "drivers/reset/spacemit/Kconfig"
> source "drivers/reset/starfive/Kconfig"
> source "drivers/reset/sti/Kconfig"
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 3e52569bd276..7330fee91365 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -2,6 +2,7 @@
> obj-y += core.o
> obj-y += amlogic/
> obj-y += hisilicon/
> +obj-y += realtek/
> obj-y += spacemit/
> obj-y += starfive/
> obj-y += sti/
> diff --git a/drivers/reset/realtek/Kconfig b/drivers/reset/realtek/Kconfig
> new file mode 100644
> index 000000000000..bb6dd856a64a
> --- /dev/null
> +++ b/drivers/reset/realtek/Kconfig
> @@ -0,0 +1,8 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +config RESET_RTK_COMMON
> + tristate "Realtek common reset driver" if COMPILE_TEST
> + help
> + This option enables the common reset controller library for
> + Realtek SoCs. It provides shared reset control operations
> + (assert, deassert, status) and a registration helper function
> + that other Realtek-specific reset drivers can use.
> diff --git a/drivers/reset/realtek/Makefile b/drivers/reset/realtek/Makefile
> new file mode 100644
> index 000000000000..b59a3f7f2453
> --- /dev/null
> +++ b/drivers/reset/realtek/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +obj-$(CONFIG_RESET_RTK_COMMON) += common.o
That's an awfully generic module name. Id doesn't match the config option well. Please rename this to reset-rtk-common.o, reset-realtek.o, or something similar.
regards
Philipp
^ permalink raw reply
* Re: [PATCH v1 10/11] KVM: arm64: Add primitives to flush/sync the VGIC state at EL2
From: Marc Zyngier @ 2026-06-18 10:10 UTC (permalink / raw)
To: tabba
Cc: Oliver Upton, Will Deacon, Catalin Marinas, Quentin Perret,
Vincent Donnefort, Sebastian Ene, Per Larsen, Suzuki K Poulose,
Zenghui Yu, Joey Gouly, Steffen Eiden, Mark Rutland,
Jonathan Cameron, Hyunwoo Kim, linux-arm-kernel, kvmarm,
linux-kernel
In-Reply-To: <20260612065925.755562-11-tabba@google.com>
On Fri, 12 Jun 2026 07:59:24 +0100,
tabba@google.com wrote:
>
> From: Marc Zyngier <maz@kernel.org>
>
> pKVM performs its own world switch for protected VMs but has no
> primitives to move the per-vCPU VGIC state between the host and
> hypervisor vCPU contexts.
>
> Add flush_hyp_vgic_state() and sync_hyp_vgic_state(). Flush copies
> vgic_hcr, the in-use list registers and used_lrs from the host into the
> hyp vCPU and pins vgic_sre to a fixed value; sync copies vgic_hcr,
> vgic_vmcr and the in-use list registers back. The active priority
> registers are handled separately by the save/restore-aprs path.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Co-developed-by: Fuad Tabba <tabba@google.com>
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
> arch/arm64/kvm/hyp/nvhe/hyp-main.c | 50 +++++++++++++++++++++++++-----
> 1 file changed, 42 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 2f165b6c7b07..23e644c24a03 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> @@ -99,6 +99,46 @@ static void fpsimd_sve_sync(struct kvm_vcpu *vcpu)
> *host_data_ptr(fp_owner) = FP_STATE_HOST_OWNED;
> }
>
> +static void flush_hyp_vgic_state(struct pkvm_hyp_vcpu *hyp_vcpu)
> +{
> + struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;
> + struct vgic_v3_cpu_if *host_cpu_if, *hyp_cpu_if;
> + unsigned int used_lrs, max_lrs, i;
> +
> + host_cpu_if = &host_vcpu->arch.vgic_cpu.vgic_v3;
> + hyp_cpu_if = &hyp_vcpu->vcpu.arch.vgic_cpu.vgic_v3;
> +
> + max_lrs = (read_gicreg(ICH_VTR_EL2) & ICH_VTR_EL2_ListRegs) + 1;
This really needs to be rebased on the current state of kvmarm/next,
particularly 8cc8bbbfab14c ("KVM: arm64: Bound used_lrs when flushing
the pKVM hyp vCPU").
I really want to avoid using ICH_VTR_EL2 on each and every entry to
the guest, as this has really bad performance impacts when running
this under NV (which is the only way I run pKVM).
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply
* [PATCH 8/8] arm64: dts: imx8qxp-mek: Describe the PCIe M.2 Key E connector
From: Sherry Sun (OSS) @ 2026-06-18 10:10 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, Frank.Li, s.hauer, kernel, festevam,
amitkumar.karwar, neeraj.sanjaykale, marcel, luiz.dentz,
hongxing.zhu, l.stach, lpieralisi, kwilczynski, mani, bhelgaas,
brgl
Cc: imx, linux-pci, linux-arm-kernel, devicetree, linux-kernel,
linux-bluetooth, linux-pm, sherry.sun
In-Reply-To: <20260618101047.4185497-1-sherry.sun@oss.nxp.com>
From: Sherry Sun <sherry.sun@nxp.com>
The i.MX8QXP-MEK has the PCIe M.2 Mechanical Key E connector to connect
wireless connectivity cards over PCIe and UART interfaces. Hence,
describe the connector node and link it with the PCIe b Root Port and
LPUART1 nodes through graph port/endpoint.
The M.2 Key E connector is powered by a 3.3V fixed regulator
(reg_3v3) on board.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
arch/arm64/boot/dts/freescale/imx8qxp-mek.dts | 54 ++++++++++++++-----
1 file changed, 41 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/imx8qxp-mek.dts b/arch/arm64/boot/dts/freescale/imx8qxp-mek.dts
index a9b967d0a9be..c9fe4034cc2d 100644
--- a/arch/arm64/boot/dts/freescale/imx8qxp-mek.dts
+++ b/arch/arm64/boot/dts/freescale/imx8qxp-mek.dts
@@ -40,6 +40,37 @@ memory@80000000 {
reg = <0x00000000 0x80000000 0 0x40000000>;
};
+ m2-connector {
+ compatible = "pcie-m2-e-connector";
+ vpcie3v3-supply = <®_3v3>;
+ w-disable1-gpios = <&pca9557_a 2 GPIO_ACTIVE_LOW>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+ m2_e_pcie_ep: endpoint@0 {
+ reg = <0>;
+ remote-endpoint = <&pcieb_port0_ep>;
+ };
+ };
+
+ port@3 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <3>;
+ m2_e_uart_ep: endpoint@0 {
+ reg = <0>;
+ remote-endpoint = <&lpuart1_ep>;
+ };
+ };
+ };
+ };
+
reg_usdhc2_vmmc: usdhc2-vmmc {
compatible = "regulator-fixed";
regulator-name = "SD1_SPWR";
@@ -157,15 +188,6 @@ reg_3v3: regulator-3v3 {
regulator-max-microvolt = <3300000>;
};
- reg_pcieb: regulator-pcie {
- compatible = "regulator-fixed";
- regulator-max-microvolt = <3300000>;
- regulator-min-microvolt = <3300000>;
- regulator-name = "mpcie_3v3";
- gpio = <&pca9557_a 2 GPIO_ACTIVE_HIGH>;
- enable-active-high;
- };
-
reg_audio: regulator-audio {
compatible = "regulator-fixed";
regulator-max-microvolt = <3300000>;
@@ -696,8 +718,10 @@ &lpuart1 {
pinctrl-0 = <&pinctrl_lpuart1>;
status = "okay";
- bluetooth {
- compatible = "nxp,88w8987-bt";
+ port {
+ lpuart1_ep: endpoint {
+ remote-endpoint = <&m2_e_uart_ep>;
+ };
};
};
@@ -746,8 +770,12 @@ &pcie0_ep {
&pcieb_port0 {
reset-gpios = <&lsio_gpio4 0 GPIO_ACTIVE_LOW>;
- vpcie-supply = <®_pcieb>;
- vpcie3v3aux-supply = <®_pcieb>;
+
+ port {
+ pcieb_port0_ep: endpoint {
+ remote-endpoint = <&m2_e_pcie_ep>;
+ };
+ };
};
&scu_key {
--
2.50.1
^ permalink raw reply related
* [PATCH 7/8] arm64: dts: imx8qm-mek: Describe the PCIe M.2 Key E connector
From: Sherry Sun (OSS) @ 2026-06-18 10:10 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, Frank.Li, s.hauer, kernel, festevam,
amitkumar.karwar, neeraj.sanjaykale, marcel, luiz.dentz,
hongxing.zhu, l.stach, lpieralisi, kwilczynski, mani, bhelgaas,
brgl
Cc: imx, linux-pci, linux-arm-kernel, devicetree, linux-kernel,
linux-bluetooth, linux-pm, sherry.sun
In-Reply-To: <20260618101047.4185497-1-sherry.sun@oss.nxp.com>
From: Sherry Sun <sherry.sun@nxp.com>
The i.MX8QM-MEK has the PCIe M.2 Mechanical Key E connector to connect
wireless connectivity cards over PCIe and UART interfaces. Hence,
describe the connector node and link it with the PCIe a Root Port and
LPUART1 nodes through graph port/endpoint.
The M.2 Key E connector is powered by a 3.3V fixed regulator
(reg_3v3) on board.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
arch/arm64/boot/dts/freescale/imx8qm-mek.dts | 58 +++++++++++++++-----
1 file changed, 43 insertions(+), 15 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/imx8qm-mek.dts b/arch/arm64/boot/dts/freescale/imx8qm-mek.dts
index 5e725ad8aef9..4c02592cfe14 100644
--- a/arch/arm64/boot/dts/freescale/imx8qm-mek.dts
+++ b/arch/arm64/boot/dts/freescale/imx8qm-mek.dts
@@ -32,6 +32,39 @@ memory@80000000 {
reg = <0x00000000 0x80000000 0 0x40000000>;
};
+ m2-connector {
+ compatible = "pcie-m2-e-connector";
+ pinctrl-0 = <&pinctrl_pciea_reg>;
+ pinctrl-names = "default";
+ vpcie3v3-supply = <®_3v3>;
+ w-disable1-gpios = <&lsio_gpio1 13 GPIO_ACTIVE_LOW>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+ m2_e_pcie_ep: endpoint@0 {
+ reg = <0>;
+ remote-endpoint = <&pciea_port0_ep>;
+ };
+ };
+
+ port@3 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <3>;
+ m2_e_uart_ep: endpoint@0 {
+ reg = <0>;
+ remote-endpoint = <&lpuart1_ep>;
+ };
+ };
+ };
+ };
+
xtal24m: clock-xtal24m {
compatible = "fixed-clock";
#clock-cells = <0>;
@@ -320,17 +353,6 @@ reg_can2_stby: regulator-can2-stby {
vin-supply = <®_can2_en>;
};
- reg_pciea: regulator-pcie {
- compatible = "regulator-fixed";
- pinctrl-0 = <&pinctrl_pciea_reg>;
- pinctrl-names = "default";
- regulator-max-microvolt = <3300000>;
- regulator-min-microvolt = <3300000>;
- regulator-name = "mpcie_3v3";
- gpio = <&lsio_gpio1 13 GPIO_ACTIVE_HIGH>;
- enable-active-high;
- };
-
reg_usb_otg1_vbus: regulator-usbotg1-vbus {
compatible = "regulator-fixed";
regulator-name = "usb_otg1_vbus";
@@ -718,8 +740,10 @@ &lpuart1 {
pinctrl-0 = <&pinctrl_lpuart1>;
status = "okay";
- bluetooth {
- compatible = "nxp,88w8987-bt";
+ port {
+ lpuart1_ep: endpoint {
+ remote-endpoint = <&m2_e_uart_ep>;
+ };
};
};
@@ -818,8 +842,12 @@ &pciea {
&pciea_port0 {
reset-gpios = <&lsio_gpio4 29 GPIO_ACTIVE_LOW>;
- vpcie-supply = <®_pciea>;
- vpcie3v3aux-supply = <®_pciea>;
+
+ port {
+ pciea_port0_ep: endpoint {
+ remote-endpoint = <&m2_e_pcie_ep>;
+ };
+ };
};
&pcieb {
--
2.50.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox