Skip to content

Commit 52517d9

Browse files
committed
Merge tag 'asoc-fix-v5.17-rc2' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v5.17 Quite a few fixes here, including an unusually large set in the core spurred on by various testing efforts as well as the usual small driver fixes. There are quite a few fixes for out of bounds writes in both the core and the various Qualcomm drivers, plus a couple of fixes for locking in the DPCM code.
2 parents 1c7f0e3 + a4f399a commit 52517d9

File tree

20 files changed

+175
-80
lines changed

20 files changed

+175
-80
lines changed

drivers/input/touchscreen/wm97xx-core.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,9 @@ static int wm97xx_register_touch(struct wm97xx *wm)
615615
* extensions)
616616
*/
617617
wm->touch_dev = platform_device_alloc("wm97xx-touch", -1);
618-
if (!wm->touch_dev) {
619-
ret = -ENOMEM;
620-
goto touch_err;
621-
}
618+
if (!wm->touch_dev)
619+
return -ENOMEM;
620+
622621
platform_set_drvdata(wm->touch_dev, wm);
623622
wm->touch_dev->dev.parent = wm->dev;
624623
wm->touch_dev->dev.platform_data = pdata;
@@ -629,18 +628,13 @@ static int wm97xx_register_touch(struct wm97xx *wm)
629628
return 0;
630629
touch_reg_err:
631630
platform_device_put(wm->touch_dev);
632-
touch_err:
633-
input_unregister_device(wm->input_dev);
634-
wm->input_dev = NULL;
635631

636632
return ret;
637633
}
638634

639635
static void wm97xx_unregister_touch(struct wm97xx *wm)
640636
{
641637
platform_device_unregister(wm->touch_dev);
642-
input_unregister_device(wm->input_dev);
643-
wm->input_dev = NULL;
644638
}
645639

646640
static int _wm97xx_probe(struct wm97xx *wm)

include/sound/pcm.h

+15
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ void snd_pcm_stream_unlock(struct snd_pcm_substream *substream);
617617
void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);
618618
void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);
619619
unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
620+
unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream);
620621

621622
/**
622623
* snd_pcm_stream_lock_irqsave - Lock the PCM stream
@@ -635,6 +636,20 @@ unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
635636
void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
636637
unsigned long flags);
637638

639+
/**
640+
* snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking
641+
* @substream: PCM substream
642+
* @flags: irq flags
643+
*
644+
* This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with
645+
* the single-depth lockdep subclass.
646+
*/
647+
#define snd_pcm_stream_lock_irqsave_nested(substream, flags) \
648+
do { \
649+
typecheck(unsigned long, flags); \
650+
flags = _snd_pcm_stream_lock_irqsave_nested(substream); \
651+
} while (0)
652+
638653
/**
639654
* snd_pcm_group_for_each_entry - iterate over the linked substreams
640655
* @s: the iterator

include/uapi/sound/asound.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@
5656
* *
5757
****************************************************************************/
5858

59+
#define AES_IEC958_STATUS_SIZE 24
60+
5961
struct snd_aes_iec958 {
60-
unsigned char status[24]; /* AES/IEC958 channel status bits */
62+
unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel status bits */
6163
unsigned char subcode[147]; /* AES/IEC958 subcode bits */
6264
unsigned char pad; /* nothing */
6365
unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */

sound/core/pcm_native.c

+13
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream)
172172
}
173173
EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave);
174174

175+
unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream)
176+
{
177+
unsigned long flags = 0;
178+
if (substream->pcm->nonatomic)
179+
mutex_lock_nested(&substream->self_group.mutex,
180+
SINGLE_DEPTH_NESTING);
181+
else
182+
spin_lock_irqsave_nested(&substream->self_group.lock, flags,
183+
SINGLE_DEPTH_NESTING);
184+
return flags;
185+
}
186+
EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave_nested);
187+
175188
/**
176189
* snd_pcm_stream_unlock_irqrestore - Unlock the PCM stream
177190
* @substream: PCM substream

sound/soc/amd/acp/acp-mach-common.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ static const struct snd_soc_dapm_route rt1019_map_lr[] = {
303303

304304
static struct snd_soc_codec_conf rt1019_conf[] = {
305305
{
306-
.dlc = COMP_CODEC_CONF("i2c-10EC1019:00"),
306+
.dlc = COMP_CODEC_CONF("i2c-10EC1019:01"),
307307
.name_prefix = "Left",
308308
},
309309
{
310-
.dlc = COMP_CODEC_CONF("i2c-10EC1019:01"),
310+
.dlc = COMP_CODEC_CONF("i2c-10EC1019:00"),
311311
.name_prefix = "Right",
312312
},
313313
};

sound/soc/codecs/cpcap.c

+2
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,8 @@ static int cpcap_codec_probe(struct platform_device *pdev)
16671667
{
16681668
struct device_node *codec_node =
16691669
of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec");
1670+
if (!codec_node)
1671+
return -ENODEV;
16701672

16711673
pdev->dev.of_node = codec_node;
16721674

sound/soc/codecs/hdmi-codec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ struct hdmi_codec_priv {
277277
bool busy;
278278
struct snd_soc_jack *jack;
279279
unsigned int jack_status;
280-
u8 iec_status[5];
280+
u8 iec_status[AES_IEC958_STATUS_SIZE];
281281
};
282282

283283
static const struct snd_soc_dapm_widget hdmi_widgets[] = {

sound/soc/codecs/lpass-rx-macro.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2688,8 +2688,8 @@ static uint32_t get_iir_band_coeff(struct snd_soc_component *component,
26882688
int reg, b2_reg;
26892689

26902690
/* Address does not automatically update if reading */
2691-
reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx;
2692-
b2_reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx;
2691+
reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx;
2692+
b2_reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx;
26932693

26942694
snd_soc_component_write(component, reg,
26952695
((band_idx * BAND_MAX + coeff_idx) *
@@ -2718,7 +2718,7 @@ static uint32_t get_iir_band_coeff(struct snd_soc_component *component,
27182718
static void set_iir_band_coeff(struct snd_soc_component *component,
27192719
int iir_idx, int band_idx, uint32_t value)
27202720
{
2721-
int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx;
2721+
int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx;
27222722

27232723
snd_soc_component_write(component, reg, (value & 0xFF));
27242724
snd_soc_component_write(component, reg, (value >> 8) & 0xFF);
@@ -2739,7 +2739,7 @@ static int rx_macro_put_iir_band_audio_mixer(
27392739
int iir_idx = ctl->iir_idx;
27402740
int band_idx = ctl->band_idx;
27412741
u32 coeff[BAND_MAX];
2742-
int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx;
2742+
int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx;
27432743

27442744
memcpy(&coeff[0], ucontrol->value.bytes.data, params->max);
27452745

sound/soc/codecs/max9759.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static int speaker_gain_control_put(struct snd_kcontrol *kcontrol,
6464
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
6565
struct max9759 *priv = snd_soc_component_get_drvdata(c);
6666

67-
if (ucontrol->value.integer.value[0] > 3)
67+
if (ucontrol->value.integer.value[0] < 0 ||
68+
ucontrol->value.integer.value[0] > 3)
6869
return -EINVAL;
6970

7071
priv->gain = ucontrol->value.integer.value[0];

sound/soc/codecs/rt5682-i2c.c

+4-11
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,12 @@ static void rt5682_jd_check_handler(struct work_struct *work)
5959
struct rt5682_priv *rt5682 = container_of(work, struct rt5682_priv,
6060
jd_check_work.work);
6161

62-
if (snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL)
63-
& RT5682_JDH_RS_MASK) {
62+
if (snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL) & RT5682_JDH_RS_MASK)
6463
/* jack out */
65-
rt5682->jack_type = rt5682_headset_detect(rt5682->component, 0);
66-
67-
snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type,
68-
SND_JACK_HEADSET |
69-
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
70-
SND_JACK_BTN_2 | SND_JACK_BTN_3);
71-
} else {
64+
mod_delayed_work(system_power_efficient_wq,
65+
&rt5682->jack_detect_work, 0);
66+
else
7267
schedule_delayed_work(&rt5682->jd_check_work, 500);
73-
}
7468
}
7569

7670
static irqreturn_t rt5682_irq(int irq, void *data)
@@ -198,7 +192,6 @@ static int rt5682_i2c_probe(struct i2c_client *i2c,
198192
}
199193

200194
mutex_init(&rt5682->calibrate_mutex);
201-
mutex_init(&rt5682->jdet_mutex);
202195
rt5682_calibrate(rt5682);
203196

204197
rt5682_apply_patch_list(rt5682, &i2c->dev);

sound/soc/codecs/rt5682.c

+8-16
Original file line numberDiff line numberDiff line change
@@ -922,15 +922,13 @@ static void rt5682_enable_push_button_irq(struct snd_soc_component *component,
922922
*
923923
* Returns detect status.
924924
*/
925-
int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
925+
static int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
926926
{
927927
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
928928
struct snd_soc_dapm_context *dapm = &component->dapm;
929929
unsigned int val, count;
930930

931931
if (jack_insert) {
932-
snd_soc_dapm_mutex_lock(dapm);
933-
934932
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
935933
RT5682_PWR_VREF2 | RT5682_PWR_MB,
936934
RT5682_PWR_VREF2 | RT5682_PWR_MB);
@@ -981,8 +979,6 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
981979
snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
982980
RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
983981
RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);
984-
985-
snd_soc_dapm_mutex_unlock(dapm);
986982
} else {
987983
rt5682_enable_push_button_irq(component, false);
988984
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
@@ -1011,7 +1007,6 @@ int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert)
10111007
dev_dbg(component->dev, "jack_type = %d\n", rt5682->jack_type);
10121008
return rt5682->jack_type;
10131009
}
1014-
EXPORT_SYMBOL_GPL(rt5682_headset_detect);
10151010

10161011
static int rt5682_set_jack_detect(struct snd_soc_component *component,
10171012
struct snd_soc_jack *hs_jack, void *data)
@@ -1094,6 +1089,7 @@ void rt5682_jack_detect_handler(struct work_struct *work)
10941089
{
10951090
struct rt5682_priv *rt5682 =
10961091
container_of(work, struct rt5682_priv, jack_detect_work.work);
1092+
struct snd_soc_dapm_context *dapm;
10971093
int val, btn_type;
10981094

10991095
while (!rt5682->component)
@@ -1102,7 +1098,9 @@ void rt5682_jack_detect_handler(struct work_struct *work)
11021098
while (!rt5682->component->card->instantiated)
11031099
usleep_range(10000, 15000);
11041100

1105-
mutex_lock(&rt5682->jdet_mutex);
1101+
dapm = snd_soc_component_get_dapm(rt5682->component);
1102+
1103+
snd_soc_dapm_mutex_lock(dapm);
11061104
mutex_lock(&rt5682->calibrate_mutex);
11071105

11081106
val = snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL)
@@ -1162,6 +1160,9 @@ void rt5682_jack_detect_handler(struct work_struct *work)
11621160
rt5682->irq_work_delay_time = 50;
11631161
}
11641162

1163+
mutex_unlock(&rt5682->calibrate_mutex);
1164+
snd_soc_dapm_mutex_unlock(dapm);
1165+
11651166
snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type,
11661167
SND_JACK_HEADSET |
11671168
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
@@ -1174,9 +1175,6 @@ void rt5682_jack_detect_handler(struct work_struct *work)
11741175
else
11751176
cancel_delayed_work_sync(&rt5682->jd_check_work);
11761177
}
1177-
1178-
mutex_unlock(&rt5682->calibrate_mutex);
1179-
mutex_unlock(&rt5682->jdet_mutex);
11801178
}
11811179
EXPORT_SYMBOL_GPL(rt5682_jack_detect_handler);
11821180

@@ -1526,7 +1524,6 @@ static int rt5682_hp_event(struct snd_soc_dapm_widget *w,
15261524
{
15271525
struct snd_soc_component *component =
15281526
snd_soc_dapm_to_component(w->dapm);
1529-
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
15301527

15311528
switch (event) {
15321529
case SND_SOC_DAPM_PRE_PMU:
@@ -1538,17 +1535,12 @@ static int rt5682_hp_event(struct snd_soc_dapm_widget *w,
15381535
RT5682_DEPOP_1, 0x60, 0x60);
15391536
snd_soc_component_update_bits(component,
15401537
RT5682_DAC_ADC_DIG_VOL1, 0x00c0, 0x0080);
1541-
1542-
mutex_lock(&rt5682->jdet_mutex);
1543-
15441538
snd_soc_component_update_bits(component, RT5682_HP_CTRL_2,
15451539
RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN,
15461540
RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN);
15471541
usleep_range(5000, 10000);
15481542
snd_soc_component_update_bits(component, RT5682_CHARGE_PUMP_1,
15491543
RT5682_CP_SW_SIZE_MASK, RT5682_CP_SW_SIZE_L);
1550-
1551-
mutex_unlock(&rt5682->jdet_mutex);
15521544
break;
15531545

15541546
case SND_SOC_DAPM_POST_PMD:

sound/soc/codecs/rt5682.h

-2
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,6 @@ struct rt5682_priv {
14631463

14641464
int jack_type;
14651465
int irq_work_delay_time;
1466-
struct mutex jdet_mutex;
14671466
};
14681467

14691468
extern const char *rt5682_supply_names[RT5682_NUM_SUPPLIES];
@@ -1473,7 +1472,6 @@ int rt5682_sel_asrc_clk_src(struct snd_soc_component *component,
14731472

14741473
void rt5682_apply_patch_list(struct rt5682_priv *rt5682, struct device *dev);
14751474

1476-
int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert);
14771475
void rt5682_jack_detect_handler(struct work_struct *work);
14781476

14791477
bool rt5682_volatile_register(struct device *dev, unsigned int reg);

0 commit comments

Comments
 (0)