Skip to content

Commit 83dfc0e

Browse files
committed
Merge tag 'sound-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "Lots of small fixes for various drivers at this time, hopefully it will be the last big bump before 6.0 release. The significant changes are regression fixes for (yet again) HD-audio memory allocations and USB-audio PCM parameter handling, while there are many small ASoC device-specific fixes as well as a few out-of-bounds and race issues spotted by fuzzers" * tag 'sound-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (29 commits) ALSA: usb-audio: Clear fixed clock rate at closing EP ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() ALSA: hda: Once again fix regression of page allocations with IOMMU ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() ALSA: hda/tegra: Align BDL entry to 4KB boundary ALSA: hda/sigmatel: Fix unused variable warning for beep power change ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC ALSA: hda/sigmatel: Keep power up while beep is enabled ALSA: aloop: Fix random zeros in capture data when using jiffies timer ALSA: usb-audio: Split endpoint setups for hw_params and prepare ALSA: usb-audio: Register card again for iface over delayed_register option ALSA: usb-audio: Inform the delayed registration more properly ASoC: fsl_aud2htx: Add error handler for pm_runtime_enable ASoC: fsl_aud2htx: register platform component before registering cpu dai ASoC: SOF: ipc4-topology: fix alh_group_ida max value ASoC: mchp-spdiftx: Fix clang -Wbitfield-constant-conversion ASoC: SOF: Kconfig: Make IPC_MESSAGE_INJECTOR depend on SND_SOC_SOF ASoC: SOF: Kconfig: Make IPC_FLOOD_TEST depend on SND_SOC_SOF ASoC: fsl_mqs: Fix supported clock DAI format ASoC: nau8540: Implement hw constraint for rates ...
2 parents d8a450a + 09e3e31 commit 83dfc0e

26 files changed

+257
-168
lines changed

sound/core/memalloc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,13 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
543543
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev,
544544
sg_dma_address(sgt->sgl));
545545
p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt);
546-
if (p)
546+
if (p) {
547547
dmab->private_data = sgt;
548-
else
548+
/* store the first page address for convenience */
549+
dmab->addr = snd_sgbuf_get_addr(dmab, 0);
550+
} else {
549551
dma_free_noncontiguous(dmab->dev.dev, size, sgt, dmab->dev.dir);
552+
}
550553
return p;
551554
}
552555

@@ -780,6 +783,8 @@ static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size)
780783
if (!p)
781784
goto error;
782785
dmab->private_data = sgbuf;
786+
/* store the first page address for convenience */
787+
dmab->addr = snd_sgbuf_get_addr(dmab, 0);
783788
return p;
784789

785790
error:

sound/core/oss/pcm_oss.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,14 +1672,14 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
16721672
runtime = substream->runtime;
16731673
if (atomic_read(&substream->mmap_count))
16741674
goto __direct;
1675-
err = snd_pcm_oss_make_ready(substream);
1676-
if (err < 0)
1677-
return err;
16781675
atomic_inc(&runtime->oss.rw_ref);
16791676
if (mutex_lock_interruptible(&runtime->oss.params_lock)) {
16801677
atomic_dec(&runtime->oss.rw_ref);
16811678
return -ERESTARTSYS;
16821679
}
1680+
err = snd_pcm_oss_make_ready_locked(substream);
1681+
if (err < 0)
1682+
goto unlock;
16831683
format = snd_pcm_oss_format_from(runtime->oss.format);
16841684
width = snd_pcm_format_physical_width(format);
16851685
if (runtime->oss.buffer_used > 0) {

sound/drivers/aloop.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,17 +605,18 @@ static unsigned int loopback_jiffies_timer_pos_update
605605
cable->streams[SNDRV_PCM_STREAM_PLAYBACK];
606606
struct loopback_pcm *dpcm_capt =
607607
cable->streams[SNDRV_PCM_STREAM_CAPTURE];
608-
unsigned long delta_play = 0, delta_capt = 0;
608+
unsigned long delta_play = 0, delta_capt = 0, cur_jiffies;
609609
unsigned int running, count1, count2;
610610

611+
cur_jiffies = jiffies;
611612
running = cable->running ^ cable->pause;
612613
if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
613-
delta_play = jiffies - dpcm_play->last_jiffies;
614+
delta_play = cur_jiffies - dpcm_play->last_jiffies;
614615
dpcm_play->last_jiffies += delta_play;
615616
}
616617

617618
if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) {
618-
delta_capt = jiffies - dpcm_capt->last_jiffies;
619+
delta_capt = cur_jiffies - dpcm_capt->last_jiffies;
619620
dpcm_capt->last_jiffies += delta_capt;
620621
}
621622

sound/pci/emu10k1/emupcm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voic
124124
epcm->voices[0]->epcm = epcm;
125125
if (voices > 1) {
126126
for (i = 1; i < voices; i++) {
127-
epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i];
127+
epcm->voices[i] = &epcm->emu->voices[(epcm->voices[0]->number + i) % NUM_G];
128128
epcm->voices[i]->epcm = epcm;
129129
}
130130
}

sound/pci/hda/hda_intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
18171817

18181818
/* use the non-cached pages in non-snoop mode */
18191819
if (!azx_snoop(chip))
1820-
azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC;
1820+
azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC_SG;
18211821

18221822
if (chip->driver_type == AZX_DRIVER_NVIDIA) {
18231823
dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");

sound/pci/hda/hda_tegra.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ MODULE_DEVICE_TABLE(of, hda_tegra_match);
474474
static int hda_tegra_probe(struct platform_device *pdev)
475475
{
476476
const unsigned int driver_flags = AZX_DCAPS_CORBRP_SELF_CLEAR |
477-
AZX_DCAPS_PM_RUNTIME;
477+
AZX_DCAPS_PM_RUNTIME |
478+
AZX_DCAPS_4K_BDLE_BOUNDARY;
478479
struct snd_card *card;
479480
struct azx *chip;
480481
struct hda_tegra *hda;

sound/pci/hda/patch_sigmatel.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ struct sigmatel_spec {
209209

210210
/* beep widgets */
211211
hda_nid_t anabeep_nid;
212+
bool beep_power_on;
212213

213214
/* SPDIF-out mux */
214215
const char * const *spdif_labels;
@@ -4443,6 +4444,28 @@ static int stac_suspend(struct hda_codec *codec)
44434444

44444445
return 0;
44454446
}
4447+
4448+
static int stac_check_power_status(struct hda_codec *codec, hda_nid_t nid)
4449+
{
4450+
#ifdef CONFIG_SND_HDA_INPUT_BEEP
4451+
struct sigmatel_spec *spec = codec->spec;
4452+
#endif
4453+
int ret = snd_hda_gen_check_power_status(codec, nid);
4454+
4455+
#ifdef CONFIG_SND_HDA_INPUT_BEEP
4456+
if (nid == spec->gen.beep_nid && codec->beep) {
4457+
if (codec->beep->enabled != spec->beep_power_on) {
4458+
spec->beep_power_on = codec->beep->enabled;
4459+
if (spec->beep_power_on)
4460+
snd_hda_power_up_pm(codec);
4461+
else
4462+
snd_hda_power_down_pm(codec);
4463+
}
4464+
ret |= spec->beep_power_on;
4465+
}
4466+
#endif
4467+
return ret;
4468+
}
44464469
#else
44474470
#define stac_suspend NULL
44484471
#endif /* CONFIG_PM */
@@ -4455,6 +4478,7 @@ static const struct hda_codec_ops stac_patch_ops = {
44554478
.unsol_event = snd_hda_jack_unsol_event,
44564479
#ifdef CONFIG_PM
44574480
.suspend = stac_suspend,
4481+
.check_power_status = stac_check_power_status,
44584482
#endif
44594483
};
44604484

sound/soc/atmel/mchp-spdiftx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ struct mchp_spdiftx_dev {
196196
struct clk *pclk;
197197
struct clk *gclk;
198198
unsigned int fmt;
199-
int gclk_enabled:1;
199+
unsigned int gclk_enabled:1;
200200
};
201201

202202
static inline int mchp_spdiftx_is_running(struct mchp_spdiftx_dev *dev)

sound/soc/codecs/cs42l42.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,6 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
16171617
unsigned int current_plug_status;
16181618
unsigned int current_button_status;
16191619
unsigned int i;
1620-
int report = 0;
16211620

16221621
mutex_lock(&cs42l42->irq_lock);
16231622
if (cs42l42->suspended) {
@@ -1711,13 +1710,15 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
17111710

17121711
if (current_button_status & CS42L42_M_DETECT_TF_MASK) {
17131712
dev_dbg(cs42l42->dev, "Button released\n");
1714-
report = 0;
1713+
snd_soc_jack_report(cs42l42->jack, 0,
1714+
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1715+
SND_JACK_BTN_2 | SND_JACK_BTN_3);
17151716
} else if (current_button_status & CS42L42_M_DETECT_FT_MASK) {
1716-
report = cs42l42_handle_button_press(cs42l42);
1717-
1717+
snd_soc_jack_report(cs42l42->jack,
1718+
cs42l42_handle_button_press(cs42l42),
1719+
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1720+
SND_JACK_BTN_2 | SND_JACK_BTN_3);
17181721
}
1719-
snd_soc_jack_report(cs42l42->jack, report, SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1720-
SND_JACK_BTN_2 | SND_JACK_BTN_3);
17211722
}
17221723
}
17231724

sound/soc/codecs/nau8540.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,39 +357,56 @@ static const struct snd_soc_dapm_route nau8540_dapm_routes[] = {
357357
{"AIFTX", NULL, "Digital CH4 Mux"},
358358
};
359359

360-
static int nau8540_clock_check(struct nau8540 *nau8540, int rate, int osr)
360+
static const struct nau8540_osr_attr *
361+
nau8540_get_osr(struct nau8540 *nau8540)
361362
{
363+
unsigned int osr;
364+
365+
regmap_read(nau8540->regmap, NAU8540_REG_ADC_SAMPLE_RATE, &osr);
366+
osr &= NAU8540_ADC_OSR_MASK;
362367
if (osr >= ARRAY_SIZE(osr_adc_sel))
363-
return -EINVAL;
368+
return NULL;
369+
return &osr_adc_sel[osr];
370+
}
371+
372+
static int nau8540_dai_startup(struct snd_pcm_substream *substream,
373+
struct snd_soc_dai *dai)
374+
{
375+
struct snd_soc_component *component = dai->component;
376+
struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
377+
const struct nau8540_osr_attr *osr;
364378

365-
if (rate * osr > CLK_ADC_MAX) {
366-
dev_err(nau8540->dev, "exceed the maximum frequency of CLK_ADC\n");
379+
osr = nau8540_get_osr(nau8540);
380+
if (!osr || !osr->osr)
367381
return -EINVAL;
368-
}
369382

370-
return 0;
383+
return snd_pcm_hw_constraint_minmax(substream->runtime,
384+
SNDRV_PCM_HW_PARAM_RATE,
385+
0, CLK_ADC_MAX / osr->osr);
371386
}
372387

373388
static int nau8540_hw_params(struct snd_pcm_substream *substream,
374389
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
375390
{
376391
struct snd_soc_component *component = dai->component;
377392
struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
378-
unsigned int val_len = 0, osr;
393+
unsigned int val_len = 0;
394+
const struct nau8540_osr_attr *osr;
379395

380396
/* CLK_ADC = OSR * FS
381397
* ADC clock frequency is defined as Over Sampling Rate (OSR)
382398
* multiplied by the audio sample rate (Fs). Note that the OSR and Fs
383399
* values must be selected such that the maximum frequency is less
384400
* than 6.144 MHz.
385401
*/
386-
regmap_read(nau8540->regmap, NAU8540_REG_ADC_SAMPLE_RATE, &osr);
387-
osr &= NAU8540_ADC_OSR_MASK;
388-
if (nau8540_clock_check(nau8540, params_rate(params), osr))
402+
osr = nau8540_get_osr(nau8540);
403+
if (!osr || !osr->osr)
404+
return -EINVAL;
405+
if (params_rate(params) * osr->osr > CLK_ADC_MAX)
389406
return -EINVAL;
390407
regmap_update_bits(nau8540->regmap, NAU8540_REG_CLOCK_SRC,
391408
NAU8540_CLK_ADC_SRC_MASK,
392-
osr_adc_sel[osr].clk_src << NAU8540_CLK_ADC_SRC_SFT);
409+
osr->clk_src << NAU8540_CLK_ADC_SRC_SFT);
393410

394411
switch (params_width(params)) {
395412
case 16:
@@ -515,6 +532,7 @@ static int nau8540_set_tdm_slot(struct snd_soc_dai *dai,
515532

516533

517534
static const struct snd_soc_dai_ops nau8540_dai_ops = {
535+
.startup = nau8540_dai_startup,
518536
.hw_params = nau8540_hw_params,
519537
.set_fmt = nau8540_set_fmt,
520538
.set_tdm_slot = nau8540_set_tdm_slot,

0 commit comments

Comments
 (0)