Skip to content

Commit b3c4014

Browse files
committed
Merge tag 'asoc-fix-v5.0-rc2' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v5.0 Quite a big batch of fixes here. There's a couple of things going on, the main one is that we found some issues with not deferring probe when we should, causing us to skip some driver initialization. The fixes for this then in turn exposed some issues with how we were searching for components which had previously gone unnoticed due to the original issue. There's also been the normal driver specific stuff and there's been what looks like several batches of automated scanning for issues which have generated quite a large set of smaller fixes for potential crashes and missed error handling.
2 parents 687ae9e + 4cb79ef commit b3c4014

23 files changed

+208
-184
lines changed

include/sound/soc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,12 @@ struct snd_soc_dai_link {
985985
/* Do not create a PCM for this DAI link (Backend link) */
986986
unsigned int ignore:1;
987987

988+
/*
989+
* This driver uses legacy platform naming. Set by the core, machine
990+
* drivers should not modify this value.
991+
*/
992+
unsigned int legacy_platform:1;
993+
988994
struct list_head list; /* DAI link list of the soc card */
989995
struct snd_soc_dobj dobj; /* For topology */
990996
};

sound/core/compress_offload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ static int snd_compress_check_input(struct snd_compr_params *params)
541541
{
542542
/* first let's check the buffer parameter's */
543543
if (params->buffer.fragment_size == 0 ||
544-
params->buffer.fragments > INT_MAX / params->buffer.fragment_size)
544+
params->buffer.fragments > INT_MAX / params->buffer.fragment_size ||
545+
params->buffer.fragments == 0)
545546
return -EINVAL;
546547

547548
/* now codec parameters */

sound/soc/amd/raven/acp3x-pcm-dma.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,16 @@ static int acp3x_audio_probe(struct platform_device *pdev)
611611
}
612612
irqflags = *((unsigned int *)(pdev->dev.platform_data));
613613

614-
adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data),
615-
GFP_KERNEL);
616614
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
617615
if (!res) {
618616
dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n");
619617
return -ENODEV;
620618
}
621619

620+
adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL);
621+
if (!adata)
622+
return -ENOMEM;
623+
622624
adata->acp3x_base = devm_ioremap(&pdev->dev, res->start,
623625
resource_size(res));
624626

sound/soc/codecs/pcm512x.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,24 +1400,20 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
14001400
if (ret != 0) {
14011401
dev_err(component->dev,
14021402
"Failed to set digital mute: %d\n", ret);
1403-
mutex_unlock(&pcm512x->mutex);
1404-
return ret;
1403+
goto unlock;
14051404
}
14061405

14071406
regmap_read_poll_timeout(pcm512x->regmap,
14081407
PCM512x_ANALOG_MUTE_DET,
14091408
mute_det, (mute_det & 0x3) == 0,
14101409
200, 10000);
1411-
1412-
mutex_unlock(&pcm512x->mutex);
14131410
} else {
14141411
pcm512x->mute &= ~0x1;
14151412
ret = pcm512x_update_mute(pcm512x);
14161413
if (ret != 0) {
14171414
dev_err(component->dev,
14181415
"Failed to update digital mute: %d\n", ret);
1419-
mutex_unlock(&pcm512x->mutex);
1420-
return ret;
1416+
goto unlock;
14211417
}
14221418

14231419
regmap_read_poll_timeout(pcm512x->regmap,
@@ -1428,9 +1424,10 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
14281424
200, 10000);
14291425
}
14301426

1427+
unlock:
14311428
mutex_unlock(&pcm512x->mutex);
14321429

1433-
return 0;
1430+
return ret;
14341431
}
14351432

14361433
static const struct snd_soc_dai_ops pcm512x_dai_ops = {

sound/soc/codecs/rt274.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,11 @@ static int rt274_i2c_probe(struct i2c_client *i2c,
11281128
return ret;
11291129
}
11301130

1131-
regmap_read(rt274->regmap,
1131+
ret = regmap_read(rt274->regmap,
11321132
RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
1133+
if (ret)
1134+
return ret;
1135+
11331136
if (val != RT274_VENDOR_ID) {
11341137
dev_err(&i2c->dev,
11351138
"Device with ID register %#x is not rt274\n", val);

sound/soc/codecs/rt5514-spi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
280280

281281
rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
282282
GFP_KERNEL);
283+
if (!rt5514_dsp)
284+
return -ENOMEM;
283285

284286
rt5514_dsp->dev = &rt5514_spi->dev;
285287
mutex_init(&rt5514_dsp->dma_lock);

sound/soc/codecs/rt5682.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,7 @@ static void rt5682_calibrate(struct rt5682_priv *rt5682)
25122512
regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000);
25132513
regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000);
25142514
regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
2515+
regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0xc0c4);
25152516

25162517
mutex_unlock(&rt5682->calibrate_mutex);
25172518

sound/soc/codecs/rt5682.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -849,18 +849,18 @@
849849
#define RT5682_SCLK_SRC_PLL2 (0x2 << 13)
850850
#define RT5682_SCLK_SRC_SDW (0x3 << 13)
851851
#define RT5682_SCLK_SRC_RCCLK (0x4 << 13)
852-
#define RT5682_PLL1_SRC_MASK (0x3 << 10)
853-
#define RT5682_PLL1_SRC_SFT 10
854-
#define RT5682_PLL1_SRC_MCLK (0x0 << 10)
855-
#define RT5682_PLL1_SRC_BCLK1 (0x1 << 10)
856-
#define RT5682_PLL1_SRC_SDW (0x2 << 10)
857-
#define RT5682_PLL1_SRC_RC (0x3 << 10)
858-
#define RT5682_PLL2_SRC_MASK (0x3 << 8)
859-
#define RT5682_PLL2_SRC_SFT 8
860-
#define RT5682_PLL2_SRC_MCLK (0x0 << 8)
861-
#define RT5682_PLL2_SRC_BCLK1 (0x1 << 8)
862-
#define RT5682_PLL2_SRC_SDW (0x2 << 8)
863-
#define RT5682_PLL2_SRC_RC (0x3 << 8)
852+
#define RT5682_PLL2_SRC_MASK (0x3 << 10)
853+
#define RT5682_PLL2_SRC_SFT 10
854+
#define RT5682_PLL2_SRC_MCLK (0x0 << 10)
855+
#define RT5682_PLL2_SRC_BCLK1 (0x1 << 10)
856+
#define RT5682_PLL2_SRC_SDW (0x2 << 10)
857+
#define RT5682_PLL2_SRC_RC (0x3 << 10)
858+
#define RT5682_PLL1_SRC_MASK (0x3 << 8)
859+
#define RT5682_PLL1_SRC_SFT 8
860+
#define RT5682_PLL1_SRC_MCLK (0x0 << 8)
861+
#define RT5682_PLL1_SRC_BCLK1 (0x1 << 8)
862+
#define RT5682_PLL1_SRC_SDW (0x2 << 8)
863+
#define RT5682_PLL1_SRC_RC (0x3 << 8)
864864

865865

866866

sound/soc/codecs/tlv320aic32x4.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,10 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,
822822
case SND_SOC_BIAS_PREPARE:
823823
break;
824824
case SND_SOC_BIAS_STANDBY:
825+
/* Initial cold start */
826+
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
827+
break;
828+
825829
/* Switch off BCLK_N Divider */
826830
snd_soc_component_update_bits(component, AIC32X4_BCLKN,
827831
AIC32X4_BCLKEN, 0);

sound/soc/fsl/imx-audmux.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,49 +86,49 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
8686
if (!buf)
8787
return -ENOMEM;
8888

89-
ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
89+
ret = scnprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
9090
pdcr, ptcr);
9191

9292
if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR)
93-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
93+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
9494
"TxFS output from %s, ",
9595
audmux_port_string((ptcr >> 27) & 0x7));
9696
else
97-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
97+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
9898
"TxFS input, ");
9999

100100
if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR)
101-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
101+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
102102
"TxClk output from %s",
103103
audmux_port_string((ptcr >> 22) & 0x7));
104104
else
105-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
105+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
106106
"TxClk input");
107107

108-
ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
108+
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
109109

110110
if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) {
111-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
111+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
112112
"Port is symmetric");
113113
} else {
114114
if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR)
115-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
115+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
116116
"RxFS output from %s, ",
117117
audmux_port_string((ptcr >> 17) & 0x7));
118118
else
119-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
119+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
120120
"RxFS input, ");
121121

122122
if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR)
123-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
123+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
124124
"RxClk output from %s",
125125
audmux_port_string((ptcr >> 12) & 0x7));
126126
else
127-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
127+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
128128
"RxClk input");
129129
}
130130

131-
ret += snprintf(buf + ret, PAGE_SIZE - ret,
131+
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
132132
"\nData received from %s\n",
133133
audmux_port_string((pdcr >> 13) & 0x7));
134134

sound/soc/intel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ config SND_SST_ATOM_HIFI2_PLATFORM_PCI
9191
config SND_SST_ATOM_HIFI2_PLATFORM_ACPI
9292
tristate "ACPI HiFi2 (Baytrail, Cherrytrail) Platforms"
9393
default ACPI
94-
depends on X86 && ACPI
94+
depends on X86 && ACPI && PCI
9595
select SND_SST_IPC_ACPI
9696
select SND_SST_ATOM_HIFI2_PLATFORM
9797
select SND_SOC_ACPI_INTEL_MATCH

sound/soc/intel/atom/sst-mfld-platform-pcm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,13 @@ static int sst_media_hw_params(struct snd_pcm_substream *substream,
399399
struct snd_pcm_hw_params *params,
400400
struct snd_soc_dai *dai)
401401
{
402-
snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
402+
int ret;
403+
404+
ret =
405+
snd_pcm_lib_malloc_pages(substream,
406+
params_buffer_bytes(params));
407+
if (ret)
408+
return ret;
403409
memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
404410
return 0;
405411
}

sound/soc/intel/boards/broadwell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
192192
.stream_name = "Loopback",
193193
.cpu_dai_name = "Loopback Pin",
194194
.platform_name = "haswell-pcm-audio",
195-
.dynamic = 0,
195+
.dynamic = 1,
196196
.codec_name = "snd-soc-dummy",
197197
.codec_dai_name = "snd-soc-dummy-dai",
198198
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},

sound/soc/intel/boards/glk_rt5682_max98357a.c

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,6 @@ enum {
5555
GLK_DPCM_AUDIO_HDMI3_PB,
5656
};
5757

58-
static int platform_clock_control(struct snd_soc_dapm_widget *w,
59-
struct snd_kcontrol *k, int event)
60-
{
61-
struct snd_soc_dapm_context *dapm = w->dapm;
62-
struct snd_soc_card *card = dapm->card;
63-
struct snd_soc_dai *codec_dai;
64-
int ret = 0;
65-
66-
codec_dai = snd_soc_card_get_codec_dai(card, GLK_REALTEK_CODEC_DAI);
67-
if (!codec_dai) {
68-
dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
69-
return -EIO;
70-
}
71-
72-
if (SND_SOC_DAPM_EVENT_OFF(event)) {
73-
ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
74-
if (ret)
75-
dev_err(card->dev, "failed to stop sysclk: %d\n", ret);
76-
} else if (SND_SOC_DAPM_EVENT_ON(event)) {
77-
ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK,
78-
GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
79-
if (ret < 0) {
80-
dev_err(card->dev, "can't set codec pll: %d\n", ret);
81-
return ret;
82-
}
83-
}
84-
85-
if (ret)
86-
dev_err(card->dev, "failed to start internal clk: %d\n", ret);
87-
88-
return ret;
89-
}
90-
9158
static const struct snd_kcontrol_new geminilake_controls[] = {
9259
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
9360
SOC_DAPM_PIN_SWITCH("Headset Mic"),
@@ -102,22 +69,17 @@ static const struct snd_soc_dapm_widget geminilake_widgets[] = {
10269
SND_SOC_DAPM_SPK("HDMI1", NULL),
10370
SND_SOC_DAPM_SPK("HDMI2", NULL),
10471
SND_SOC_DAPM_SPK("HDMI3", NULL),
105-
SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
106-
platform_clock_control, SND_SOC_DAPM_PRE_PMU |
107-
SND_SOC_DAPM_POST_PMD),
10872
};
10973

11074
static const struct snd_soc_dapm_route geminilake_map[] = {
11175
/* HP jack connectors - unknown if we have jack detection */
112-
{ "Headphone Jack", NULL, "Platform Clock" },
11376
{ "Headphone Jack", NULL, "HPOL" },
11477
{ "Headphone Jack", NULL, "HPOR" },
11578

11679
/* speaker */
11780
{ "Spk", NULL, "Speaker" },
11881

11982
/* other jacks */
120-
{ "Headset Mic", NULL, "Platform Clock" },
12183
{ "IN1P", NULL, "Headset Mic" },
12284

12385
/* digital mics */
@@ -177,6 +139,13 @@ static int geminilake_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
177139
struct snd_soc_jack *jack;
178140
int ret;
179141

142+
ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK,
143+
GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
144+
if (ret < 0) {
145+
dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
146+
return ret;
147+
}
148+
180149
/* Configure sysclk for codec */
181150
ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL1,
182151
RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);

sound/soc/intel/boards/haswell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static struct snd_soc_dai_link haswell_rt5640_dais[] = {
146146
.stream_name = "Loopback",
147147
.cpu_dai_name = "Loopback Pin",
148148
.platform_name = "haswell-pcm-audio",
149-
.dynamic = 0,
149+
.dynamic = 1,
150150
.codec_name = "snd-soc-dummy",
151151
.codec_dai_name = "snd-soc-dummy-dai",
152152
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},

sound/soc/qcom/qdsp6/q6asm-dai.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,10 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
570570
prtd->audio_client = q6asm_audio_client_alloc(dev,
571571
(q6asm_cb)compress_event_handler,
572572
prtd, stream_id, LEGACY_PCM_MODE);
573-
if (!prtd->audio_client) {
573+
if (IS_ERR(prtd->audio_client)) {
574574
dev_err(dev, "Could not allocate memory\n");
575-
kfree(prtd);
576-
return -ENOMEM;
575+
ret = PTR_ERR(prtd->audio_client);
576+
goto free_prtd;
577577
}
578578

579579
size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE *
@@ -582,7 +582,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
582582
&prtd->dma_buffer);
583583
if (ret) {
584584
dev_err(dev, "Cannot allocate buffer(s)\n");
585-
return ret;
585+
goto free_client;
586586
}
587587

588588
if (pdata->sid < 0)
@@ -595,6 +595,13 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
595595
runtime->private_data = prtd;
596596

597597
return 0;
598+
599+
free_client:
600+
q6asm_audio_client_free(prtd->audio_client);
601+
free_prtd:
602+
kfree(prtd);
603+
604+
return ret;
598605
}
599606

600607
static int q6asm_dai_compr_free(struct snd_compr_stream *stream)
@@ -874,7 +881,7 @@ static int of_q6asm_parse_dai_data(struct device *dev,
874881

875882
for_each_child_of_node(dev->of_node, node) {
876883
ret = of_property_read_u32(node, "reg", &id);
877-
if (ret || id > MAX_SESSIONS || id < 0) {
884+
if (ret || id >= MAX_SESSIONS || id < 0) {
878885
dev_err(dev, "valid dai id not found:%d\n", ret);
879886
continue;
880887
}

0 commit comments

Comments
 (0)