Skip to content

Commit 0f07e10

Browse files
committed
Merge tag 'sound-4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "Unfortunately we still have received a significant amount of changes at the late stage, but at least all are small and clear fixes. There are two fixes for ALSA core stuff, yet another timer race fix and sequencer lockdep annotation fix. Both are spotted by syzkaller, and not too serious but better to paper over quickly. All other commits are about ASoC drivers, most notably, a revert of RT5514 hotword control that was included in 4.14-rc (due to a kind of abuse of kctl TLV ABI), together with topology API fixes and other device-specific small fixes that should go for stable, too" * tag 'sound-4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: seq: Fix nested rwsem annotation for lockdep splat ALSA: timer: Add missing mutex lock for compat ioctls ASoC: rt5616: fix 0x91 default value ASoC: rt5659: connect LOUT Amp with Charge Pump ASoC: rt5659: register power bit of LOUT Amp ASoC: rt5663: Change the dev getting function in rt5663_irq ASoC: rt5514: Revert Hotword Model control ASoC: topology: Fix a potential memory leak in 'soc_tplg_dapm_widget_denum_create()' ASoC: topology: Fix a potential NULL pointer dereference in 'soc_tplg_dapm_widget_denum_create()' ASoC: rt5514-spi: check irq status to schedule data copy ASoC: adau17x1: Workaround for noise bug in ADC
2 parents 6965f1a + a53a0ab commit 0f07e10

File tree

12 files changed

+69
-76
lines changed

12 files changed

+69
-76
lines changed

sound/core/seq/seq_clientmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
663663
if (atomic)
664664
read_lock(&grp->list_lock);
665665
else
666-
down_read(&grp->list_mutex);
666+
down_read_nested(&grp->list_mutex, hop);
667667
list_for_each_entry(subs, &grp->list_head, src_list) {
668668
/* both ports ready? */
669669
if (atomic_read(&subs->ref_count) != 2)

sound/core/timer_compat.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ enum {
133133
#endif /* CONFIG_X86_X32 */
134134
};
135135

136-
static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
136+
static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
137+
unsigned long arg)
137138
{
138139
void __user *argp = compat_ptr(arg);
139140

@@ -153,7 +154,7 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
153154
case SNDRV_TIMER_IOCTL_PAUSE:
154155
case SNDRV_TIMER_IOCTL_PAUSE_OLD:
155156
case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
156-
return snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
157+
return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
157158
case SNDRV_TIMER_IOCTL_GPARAMS32:
158159
return snd_timer_user_gparams_compat(file, argp);
159160
case SNDRV_TIMER_IOCTL_INFO32:
@@ -167,3 +168,15 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
167168
}
168169
return -ENOIOCTLCMD;
169170
}
171+
172+
static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
173+
unsigned long arg)
174+
{
175+
struct snd_timer_user *tu = file->private_data;
176+
long ret;
177+
178+
mutex_lock(&tu->ioctl_lock);
179+
ret = __snd_timer_user_ioctl_compat(file, cmd, arg);
180+
mutex_unlock(&tu->ioctl_lock);
181+
return ret;
182+
}

sound/soc/codecs/adau17x1.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@ static int adau17x1_pll_event(struct snd_soc_dapm_widget *w,
9090
return 0;
9191
}
9292

93+
static int adau17x1_adc_fixup(struct snd_soc_dapm_widget *w,
94+
struct snd_kcontrol *kcontrol, int event)
95+
{
96+
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
97+
struct adau *adau = snd_soc_codec_get_drvdata(codec);
98+
99+
/*
100+
* If we are capturing, toggle the ADOSR bit in Converter Control 0 to
101+
* avoid losing SNR (workaround from ADI). This must be done after
102+
* the ADC(s) have been enabled. According to the data sheet, it is
103+
* normally illegal to set this bit when the sampling rate is 96 kHz,
104+
* but according to ADI it is acceptable for this workaround.
105+
*/
106+
regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
107+
ADAU17X1_CONVERTER0_ADOSR, ADAU17X1_CONVERTER0_ADOSR);
108+
regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
109+
ADAU17X1_CONVERTER0_ADOSR, 0);
110+
111+
return 0;
112+
}
113+
93114
static const char * const adau17x1_mono_stereo_text[] = {
94115
"Stereo",
95116
"Mono Left Channel (L+R)",
@@ -121,7 +142,8 @@ static const struct snd_soc_dapm_widget adau17x1_dapm_widgets[] = {
121142
SND_SOC_DAPM_MUX("Right DAC Mode Mux", SND_SOC_NOPM, 0, 0,
122143
&adau17x1_dac_mode_mux),
123144

124-
SND_SOC_DAPM_ADC("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0),
145+
SND_SOC_DAPM_ADC_E("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0,
146+
adau17x1_adc_fixup, SND_SOC_DAPM_POST_PMU),
125147
SND_SOC_DAPM_ADC("Right Decimator", NULL, ADAU17X1_ADC_CONTROL, 1, 0),
126148
SND_SOC_DAPM_DAC("Left DAC", NULL, ADAU17X1_DAC_CONTROL0, 0, 0),
127149
SND_SOC_DAPM_DAC("Right DAC", NULL, ADAU17X1_DAC_CONTROL0, 1, 0),

sound/soc/codecs/adau17x1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,7 @@ bool adau17x1_has_dsp(struct adau *adau);
129129

130130
#define ADAU17X1_CONVERTER0_CONVSR_MASK 0x7
131131

132+
#define ADAU17X1_CONVERTER0_ADOSR BIT(3)
133+
132134

133135
#endif

sound/soc/codecs/rt5514-spi.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ static void rt5514_spi_copy_work(struct work_struct *work)
145145
mutex_unlock(&rt5514_dsp->dma_lock);
146146
}
147147

148-
static irqreturn_t rt5514_spi_irq(int irq, void *data)
148+
static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp)
149149
{
150-
struct rt5514_dsp *rt5514_dsp = data;
151150
u8 buf[8];
152151

153152
rt5514_dsp->get_size = 0;
@@ -180,6 +179,13 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data)
180179
if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit &&
181180
rt5514_dsp->buf_rp && rt5514_dsp->buf_size)
182181
schedule_delayed_work(&rt5514_dsp->copy_work, 0);
182+
}
183+
184+
static irqreturn_t rt5514_spi_irq(int irq, void *data)
185+
{
186+
struct rt5514_dsp *rt5514_dsp = data;
187+
188+
rt5514_schedule_copy(rt5514_dsp);
183189

184190
return IRQ_HANDLED;
185191
}
@@ -199,12 +205,19 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream,
199205
struct rt5514_dsp *rt5514_dsp =
200206
snd_soc_platform_get_drvdata(rtd->platform);
201207
int ret;
208+
u8 buf[8];
202209

203210
mutex_lock(&rt5514_dsp->dma_lock);
204211
ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
205212
params_buffer_bytes(hw_params));
206213
rt5514_dsp->substream = substream;
207214
rt5514_dsp->dma_offset = 0;
215+
216+
/* Read IRQ status and schedule copy accordingly. */
217+
rt5514_spi_burst_read(RT5514_IRQ_CTRL, (u8 *)&buf, sizeof(buf));
218+
if (buf[0] & RT5514_IRQ_STATUS_BIT)
219+
rt5514_schedule_copy(rt5514_dsp);
220+
208221
mutex_unlock(&rt5514_dsp->dma_lock);
209222

210223
return ret;

sound/soc/codecs/rt5514-spi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#define RT5514_BUFFER_VOICE_BASE 0x18000200
2121
#define RT5514_BUFFER_VOICE_LIMIT 0x18000204
2222
#define RT5514_BUFFER_VOICE_WP 0x1800020c
23+
#define RT5514_IRQ_CTRL 0x18002094
24+
25+
#define RT5514_IRQ_STATUS_BIT (0x1 << 5)
2326

2427
/* SPI Command */
2528
enum {

sound/soc/codecs/rt5514.c

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -338,39 +338,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
338338
fw = NULL;
339339
}
340340

341-
if (rt5514->model_buf && rt5514->model_len) {
342-
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
343-
int ret;
344-
345-
ret = rt5514_spi_burst_write(0x4ff80000,
346-
rt5514->model_buf,
347-
((rt5514->model_len / 8) + 1) * 8);
348-
if (ret) {
349-
dev_err(codec->dev,
350-
"Model load failed %d\n", ret);
351-
return ret;
352-
}
353-
#else
354-
dev_err(codec->dev,
355-
"No SPI driver for loading firmware\n");
356-
#endif
357-
} else {
358-
request_firmware(&fw, RT5514_FIRMWARE3,
359-
codec->dev);
360-
if (fw) {
361-
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
362-
rt5514_spi_burst_write(0x4ff80000,
363-
fw->data,
364-
((fw->size/8)+1)*8);
365-
#else
366-
dev_err(codec->dev,
367-
"No SPI driver to load fw\n");
368-
#endif
369-
release_firmware(fw);
370-
fw = NULL;
371-
}
372-
}
373-
374341
/* DSP run */
375342
regmap_write(rt5514->i2c_regmap, 0x18002f00,
376343
0x00055148);
@@ -385,34 +352,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
385352
return 0;
386353
}
387354

388-
static int rt5514_hotword_model_put(struct snd_kcontrol *kcontrol,
389-
const unsigned int __user *bytes, unsigned int size)
390-
{
391-
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
392-
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
393-
struct snd_soc_codec *codec = rt5514->codec;
394-
int ret = 0;
395-
396-
if (rt5514->model_buf || rt5514->model_len < size) {
397-
if (rt5514->model_buf)
398-
devm_kfree(codec->dev, rt5514->model_buf);
399-
rt5514->model_buf = devm_kmalloc(codec->dev, size, GFP_KERNEL);
400-
if (!rt5514->model_buf) {
401-
ret = -ENOMEM;
402-
goto done;
403-
}
404-
}
405-
406-
/* Skips the TLV header. */
407-
bytes += 2;
408-
409-
if (copy_from_user(rt5514->model_buf, bytes, size))
410-
ret = -EFAULT;
411-
done:
412-
rt5514->model_len = (ret ? 0 : size);
413-
return ret;
414-
}
415-
416355
static const struct snd_kcontrol_new rt5514_snd_controls[] = {
417356
SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST,
418357
RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv),
@@ -424,8 +363,6 @@ static const struct snd_kcontrol_new rt5514_snd_controls[] = {
424363
adc_vol_tlv),
425364
SOC_SINGLE_EXT("DSP Voice Wake Up", SND_SOC_NOPM, 0, 1, 0,
426365
rt5514_dsp_voice_wake_up_get, rt5514_dsp_voice_wake_up_put),
427-
SND_SOC_BYTES_TLV("Hotword Model", 0x8504,
428-
NULL, rt5514_hotword_model_put),
429366
};
430367

431368
/* ADC Mixer*/

sound/soc/codecs/rt5514.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@
255255

256256
#define RT5514_FIRMWARE1 "rt5514_dsp_fw1.bin"
257257
#define RT5514_FIRMWARE2 "rt5514_dsp_fw2.bin"
258-
#define RT5514_FIRMWARE3 "rt5514_dsp_fw3.bin"
259258

260259
/* System Clock Source */
261260
enum {
@@ -282,8 +281,6 @@ struct rt5514_priv {
282281
int pll_in;
283282
int pll_out;
284283
int dsp_enabled;
285-
u8 *model_buf;
286-
unsigned int model_len;
287284
};
288285

289286
#endif /* __RT5514_H__ */

sound/soc/codecs/rt5616.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static const struct reg_default rt5616_reg[] = {
9898
{ 0x8e, 0x0004 },
9999
{ 0x8f, 0x1100 },
100100
{ 0x90, 0x0000 },
101-
{ 0x91, 0x0000 },
101+
{ 0x91, 0x0c00 },
102102
{ 0x92, 0x0000 },
103103
{ 0x93, 0x2000 },
104104
{ 0x94, 0x0200 },

sound/soc/codecs/rt5659.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,8 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = {
27442744
SND_SOC_DAPM_PRE_PMU),
27452745
SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, rt5659_hp_event,
27462746
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
2747-
SND_SOC_DAPM_PGA("LOUT Amp", SND_SOC_NOPM, 0, 0, NULL, 0),
2747+
SND_SOC_DAPM_PGA_S("LOUT Amp", 1, RT5659_PWR_ANLG_1, RT5659_PWR_LM_BIT,
2748+
0, NULL, 0),
27482749

27492750
SND_SOC_DAPM_SUPPLY("Charge Pump", SND_SOC_NOPM, 0, 0,
27502751
rt5659_charge_pump_event, SND_SOC_DAPM_PRE_PMU |
@@ -3208,6 +3209,7 @@ static const struct snd_soc_dapm_route rt5659_dapm_routes[] = {
32083209
{ "LOUT R MIX", "OUTVOL R Switch", "OUTVOL R" },
32093210
{ "LOUT Amp", NULL, "LOUT L MIX" },
32103211
{ "LOUT Amp", NULL, "LOUT R MIX" },
3212+
{ "LOUT Amp", NULL, "Charge Pump" },
32113213
{ "LOUT Amp", NULL, "SYS CLK DET" },
32123214
{ "LOUT L Playback", "Switch", "LOUT Amp" },
32133215
{ "LOUT R Playback", "Switch", "LOUT Amp" },

sound/soc/codecs/rt5663.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,8 @@ static irqreturn_t rt5663_irq(int irq, void *data)
16391639
{
16401640
struct rt5663_priv *rt5663 = data;
16411641

1642-
dev_dbg(rt5663->codec->dev, "%s IRQ queue work\n", __func__);
1642+
dev_dbg(regmap_get_device(rt5663->regmap), "%s IRQ queue work\n",
1643+
__func__);
16431644

16441645
queue_delayed_work(system_wq, &rt5663->jack_detect_work,
16451646
msecs_to_jiffies(250));

sound/soc/soc-topology.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
13011301
/* validate kcontrol */
13021302
if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) ==
13031303
SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
1304-
return NULL;
1304+
goto err;
13051305

13061306
se = kzalloc(sizeof(*se), GFP_KERNEL);
13071307
if (se == NULL)
@@ -1378,6 +1378,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
13781378
for (; i >= 0; i--) {
13791379
/* free values and texts */
13801380
se = (struct soc_enum *)kc[i].private_value;
1381+
if (!se)
1382+
continue;
1383+
13811384
kfree(se->dobj.control.dvalues);
13821385
for (j = 0; j < ec->items; j++)
13831386
kfree(se->dobj.control.dtexts[j]);

0 commit comments

Comments
 (0)