Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
d04ad24
regmap-irq: Update interrupt clear register for proper reset
Feb 17, 2022
9cb7275
ALSA: hda/realtek: Add quirk for Clevo NP50PNJ
crawfxrd Mar 7, 2022
09354eb
Merge tag 'asoc-fix-v5.17-rc7' of https://git.kernel.org/pub/scm/linu…
tiwai Mar 10, 2022
882bd07
ALSA: hda/realtek - Fix headset mic problem for a HP machine with alc671
hwithaheart Mar 11, 2022
0f306cc
ALSA: usb-audio: Add mute TLV for playback volumes on RODE NT-USB
larsclausen Mar 11, 2022
b755726
ALSA: hda/realtek: Add quirk for ASUS GA402
Zinput Mar 13, 2022
c14231c
ALSA: cmipci: Restore aux vol on suspend/resume
jonathan-teh Mar 13, 2022
e6194c8
ALSA: hda/realtek: fix right sounds and mute/micmute LEDs for HP mach…
Mar 14, 2022
a8ae15e
ASoC: atmel: mchp-pdmc: Fix `-Wpointer-bool-conversion` warning
alviroiskandar Mar 15, 2022
0af0f46
ASoC: SOF: Introduce struct snd_sof_dai_link
ranj063 Mar 14, 2022
226abb7
ASoC: SOF: IPC: Introduce IPC ops
ranj063 Mar 14, 2022
d87524b
ASoC: SOF: topology: Add helper function for processing tuple arrays
ranj063 Mar 14, 2022
7006d20
ASoC: SOF: Introduce IPC3 ops
ranj063 Mar 14, 2022
2141b55
ASoC: SOF: topology: Make scheduler widget parsing IPC agnostic
ranj063 Mar 14, 2022
6bd0be1
ASoC: SOF: topology: Make buffer widget parsing IPC agnostic
ranj063 Mar 14, 2022
8a2e4a7
ASoC: SOF: topology: Make pga widget parsing IPC agnostic
ranj063 Mar 14, 2022
30f4168
ASoC: SOF: topology: Make mixer widget parsing IPC agnostic
ranj063 Mar 14, 2022
683b54e
ASoC: SOF: topology: Make mux/demux widget parsing IPC agnostic
ranj063 Mar 14, 2022
8d8b129
ASoC: SOF: topology: Make src widget parsing IPC agnostic
ranj063 Mar 14, 2022
cb7ed49
ASoC: SOF: topology: Make asrc widget parsing IPC agnostic
ranj063 Mar 14, 2022
111d66f
ASoC: SOF: topology: Make siggen widget parsing IPC agnostic
ranj063 Mar 14, 2022
f2cf24a
ASoC: SOF: topology: Make effect widget parsing IPC agnostic
ranj063 Mar 14, 2022
85ec856
ASoC: SOF: topology: Make route setup IPC agnostic
ranj063 Mar 14, 2022
909dadf
ASoC: SOF: topology: Make DAI widget parsing IPC agnostic
ranj063 Mar 14, 2022
b5cee8f
ASoC: SOF: topology: Make control parsing IPC agnostic
ranj063 Mar 14, 2022
8ef1439
ASoC: SOF: topology: Make widget binding IPC agnostic
ranj063 Mar 14, 2022
61ad28f
ASoC: SOF: topology: remove snd_sof_complete_pipeline()
ranj063 Mar 14, 2022
d39664c
ASoC: samsung: i2s: check the return value of kstrdup()
x2018 Mar 14, 2022
cc5d8ac
ASoC: rockchip: Fix PM usage reference of rockchip_i2s_tdm_resume
Mar 15, 2022
740dc3e
ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe
Yuuoniy Mar 16, 2022
28a265a
ASoC: mediatek: Fix error handling in mt8183_da7219_max98357_dev_probe
Yuuoniy Mar 16, 2022
e8ca4ce
ASoC: ti: Fix spelling mistake "cant" -> "can't"
ColinIanKing Mar 15, 2022
9ebd62d
ASoC: msm8916-wcd-analog: Fix error handling in pm8916_wcd_analog_spm…
Yuuoniy Mar 16, 2022
abed17f
ASoC: rt1308-sdw: get calibration params after power on
shumingfan Mar 15, 2022
c4b7174
ASoC: mediatek: mt8195: Fix error handling in mt8195_mt6359_rt1019_rt…
Yuuoniy Mar 16, 2022
9531a63
ASoC: codecs: wcd934x: Add missing of_node_put() in wcd934x_codec_par…
Yuuoniy Mar 16, 2022
54e1bf9
ASoC: amd: Fix reference to PCM buffer address
imtangmeng Mar 16, 2022
455c565
ASoC: sti: Fix deadlock via snd_pcm_stop_xrun() call
tiwai Mar 15, 2022
1c19601
ASoC: codecs: Fix misplaced lpass_macro_pds_exit call
Mar 15, 2022
835ca59
ASoC: ak4642: Use of_device_get_match_data()
Mar 15, 2022
753132f
Introduce IPC abstraction for SOF topology parsing
broonie Mar 16, 2022
b26f965
ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy
Mar 17, 2022
638cec3
ASoC: fsl_spdif: Add new registers included on i.MX8ULP
TE-N-ShengjiuWang Mar 16, 2022
864cb14
ALSA: hda/realtek: Fix LED on Zbook Studio G9
Mar 17, 2022
a893b7f
ALSA: core: Fix typo in 'PCM Timer Interface' help
Mar 18, 2022
efb6402
ALSA: oss: Fix PCM OSS buffer allocation overflow
tiwai Mar 18, 2022
8a580a2
ALSA: oss: Release temporary buffers upon errors
tiwai Mar 18, 2022
40c2c63
ASoC: SOF: set up scheduler widget before all other widgets in the pi…
ranj063 Mar 17, 2022
051744b
ASoC: SOF: Make sof_widget_setup/free IPC agnostic
ranj063 Mar 17, 2022
657774a
ASoC: SOF: Make sof_suspend/resume IPC agnostic
ranj063 Mar 17, 2022
a0149a6
ASoC: SOF: Introduce IPC ops for kcontrol IO
ranj063 Mar 17, 2022
10f461d
ASoC: SOF: Add IPC3 topology control ops
ranj063 Mar 17, 2022
838d04f
ASoC: SOF: Add volume_get/put IPC3 ops
ranj063 Mar 17, 2022
a666874
ASoC: SOF: Add switch get/put IPC3 ops
ranj063 Mar 17, 2022
049307a
ASoC: SOF: Add enum_get/put control ops for IPC3
ranj063 Mar 17, 2022
544ac88
ASoC: SOF: Add bytes_get/put control IPC ops for IPC3
ranj063 Mar 17, 2022
67ec2a0
ASoC: SOF: Add bytes_ext control IPC ops for IPC3
ranj063 Mar 17, 2022
967885e
ASoC: SOF: Introduce IPC-specific PCM ops
ranj063 Mar 17, 2022
442c712
ASoC: SOF: pcm: expose the sof_pcm_setup_connected_widgets() function
ranj063 Mar 17, 2022
4123c24
ASoC: SOF: Introduce IPC3 PCM hw_free op
ranj063 Mar 17, 2022
621fd48
ASoC: SOF: Define hw_params PCM op for IPC3
ranj063 Mar 17, 2022
beac3f4
ASoC: SOF: Add trigger PCM op for IPC3
ranj063 Mar 17, 2022
b243b43
ASoC: SOF: Add dai_link_fixup PCM op for IPC3
ranj063 Mar 17, 2022
3816bbe
ASoC: SOF: expose sof_route_setup()
ranj063 Mar 17, 2022
31cd6e4
ASoC: SOF: topology: Add ops for setting up and tearing down pipelines
ranj063 Mar 17, 2022
85f7a8b
ASoC: SOF: Add a new dai_get_clk topology IPC op
ranj063 Mar 17, 2022
d1129bb
MAINTAINERS: Add Shengjiu to maintainer list of sound/soc/fsl
Mar 17, 2022
c639e85
ASoC: atmel: mchp-pdmc: print the correct property name
Mar 18, 2022
86fc59e
regmap: add configurable downshift for addresses
colin-foster-in-advantage Mar 13, 2022
0074f3f
regmap: allow a defined reg_base to be added to every address
colin-foster-in-advantage Mar 13, 2022
49a24e9
Make the SOF control, PCM and PM code IPC agnostic
broonie Mar 18, 2022
7dd5ab0
Merge branch 'regmap-linus' into regmap-next
broonie Mar 18, 2022
c53d92b
Merge remote-tracking branch 'regmap/for-5.18' into regmap-next
broonie Mar 18, 2022
a7663c8
ASoC: mediatek: mt6358: add missing EXPORT_SYMBOLs
yujiaxinff Mar 19, 2022
5cb90dc
ASoC: fsl-asoc-card: Fix jack_event() always return 0
imtangmeng Mar 21, 2022
a6d4b68
Merge branch 'for-next' into for-linus
tiwai Mar 21, 2022
646b907
Merge tag 'asoc-v5.18' of https://git.kernel.org/pub/scm/linux/kernel…
tiwai Mar 21, 2022
92ee3c6
ALSA: pcm: Fix races among concurrent hw_params and hw_free calls
tiwai Mar 22, 2022
dca947d
ALSA: pcm: Fix races among concurrent read/write and buffer changes
tiwai Mar 22, 2022
3c3201f
ALSA: pcm: Fix races among concurrent prepare and hw_params/hw_free c…
tiwai Mar 22, 2022
69534c4
ALSA: pcm: Fix races among concurrent prealloc proc writes
tiwai Mar 22, 2022
1f68915
ALSA: pcm: Add stream lock during PCM reset ioctl operations
tiwai Mar 22, 2022
17aaf01
ALSA: pci: fix reading of swapped values from pcmreg in AC97 codec
giacomoguiduzzi Mar 22, 2022
ef248d9
ALSA: hda/realtek: Add alc256-samsung-headphone fixup
Sonarman Mar 22, 2022
2f45a4e
ASoC: rockchip: i2s_tdm: Fixup config for SND_SOC_DAIFMT_DSP_A/B
imtangmeng Mar 18, 2022
ce18f90
ALSA: hda/realtek: Add mute and micmut LED support for Zbook Fury 17 G9
Mar 24, 2022
664d66d
ASoC: SOF: Intel: Fix build error without SND_SOC_SOF_PCI_DEV
zhengbin13 Mar 23, 2022
b0793cb
Merge remote-tracking branch 'asoc/for-5.17' into asoc-linus
broonie Mar 25, 2022
5a87385
ALSA: hda/realtek: Enable headset mic on Lenovo P360
Mar 25, 2022
0112f82
ALSA: cs4236: fix an incorrect NULL check on list iterator
Mar 27, 2022
8a77245
ALSA: hda/cs8409: Fix Warlock to use mono mic configuration
Mar 28, 2022
bdc159d
ALSA: hda/cs8409: Re-order quirk table into ascending order
Mar 28, 2022
342b6b6
ALSA: hda/cs8409: Fix Full Scale Volume setting for all variants
Mar 28, 2022
6581a04
ALSA: hda/cs8409: Support new Warlock MLK Variants
Mar 28, 2022
5e74a14
ALSA: hda/cs8409: Disable HSBIAS_SENSE_EN for Cyborg
Mar 28, 2022
5e2baa0
ALSA: hda/cs8409: Add new Dolphin HW variants
Mar 28, 2022
f30741c
ALSA: hda/realtek: Fix audio regression on Mi Notebook Pro 2020
Mar 30, 2022
6ddc2f7
ALSA: hda: Avoid unsol event during RPM suspending
mkumard Mar 29, 2022
21b5954
Merge tag 'asoc-fix-v5.18' of https://git.kernel.org/pub/scm/linux/ke…
tiwai Mar 30, 2022
bc55cfd
ALSA: pcm: Fix potential AB/BA lock with buffer_mutex and mmap_lock
tiwai Mar 30, 2022
012ad52
Merge remote-tracking branch 'takashi/for-next' into sound/upstream-2…
ranj063 Mar 30, 2022
2210a17
Merge remote-tracking branch 'soundwire/next' into sound/upstream-202…
ranj063 Mar 30, 2022
74d6694
Merge remote-tracking branch 'regmap/for-next' into sound/upstream-20…
ranj063 Mar 30, 2022
5c5b381
Merge branch 'sound/upstream-20220330' into merge/sound-upstream-2022…
ranj063 Mar 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Documentation/sound/hd-audio/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ alc-sense-combo
huawei-mbx-stereo
Enable initialization verbs for Huawei MBX stereo speakers;
might be risky, try this at your own risk
alc298-samsung-headphone
Samsung laptops with ALC298
alc256-samsung-headphone
Samsung laptops with ALC256

ALC66x/67x/892
==============
Expand Down
4 changes: 2 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -7779,10 +7779,10 @@ F: drivers/net/ethernet/freescale/fs_enet/
F: include/linux/fs_enet_pd.h

FREESCALE SOC SOUND DRIVERS
M: Nicolin Chen <nicoleotsuka@gmail.com>
M: Shengjiu Wang <shengjiu.wang@gmail.com>
M: Xiubo Li <Xiubo.Lee@gmail.com>
R: Fabio Estevam <festevam@gmail.com>
R: Shengjiu Wang <shengjiu.wang@gmail.com>
R: Nicolin Chen <nicoleotsuka@gmail.com>
L: alsa-devel@alsa-project.org (moderated for non-subscribers)
L: linuxppc-dev@lists.ozlabs.org
S: Maintained
Expand Down
2 changes: 2 additions & 0 deletions drivers/base/regmap/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct regmap_format {
size_t buf_size;
size_t reg_bytes;
size_t pad_bytes;
size_t reg_downshift;
size_t val_bytes;
void (*format_write)(struct regmap *map,
unsigned int reg, unsigned int val);
Expand Down Expand Up @@ -62,6 +63,7 @@ struct regmap {
regmap_unlock unlock;
void *lock_arg; /* This is passed to lock/unlock functions */
gfp_t alloc_flags;
unsigned int reg_base;

struct device *dev; /* Device we do I/O on */
void *work_buf; /* Scratch buffer used to format I/O */
Expand Down
20 changes: 6 additions & 14 deletions drivers/base/regmap/regmap-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,9 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
ret = regmap_write(map, reg, d->mask_buf[i]);
if (d->chip->clear_ack) {
if (d->chip->ack_invert && !ret)
ret = regmap_write(map, reg,
d->mask_buf[i]);
ret = regmap_write(map, reg, UINT_MAX);
else if (!ret)
ret = regmap_write(map, reg,
~d->mask_buf[i]);
ret = regmap_write(map, reg, 0);
}
if (ret != 0)
dev_err(d->map->dev, "Failed to ack 0x%x: %d\n",
Expand Down Expand Up @@ -556,11 +554,9 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
data->status_buf[i]);
if (chip->clear_ack) {
if (chip->ack_invert && !ret)
ret = regmap_write(map, reg,
data->status_buf[i]);
ret = regmap_write(map, reg, UINT_MAX);
else if (!ret)
ret = regmap_write(map, reg,
~data->status_buf[i]);
ret = regmap_write(map, reg, 0);
}
if (ret != 0)
dev_err(map->dev, "Failed to ack 0x%x: %d\n",
Expand Down Expand Up @@ -817,13 +813,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
d->status_buf[i] & d->mask_buf[i]);
if (chip->clear_ack) {
if (chip->ack_invert && !ret)
ret = regmap_write(map, reg,
(d->status_buf[i] &
d->mask_buf[i]));
ret = regmap_write(map, reg, UINT_MAX);
else if (!ret)
ret = regmap_write(map, reg,
~(d->status_buf[i] &
d->mask_buf[i]));
ret = regmap_write(map, reg, 0);
}
if (ret != 0) {
dev_err(map->dev, "Failed to ack 0x%x: %d\n",
Expand Down
11 changes: 11 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,11 @@ struct regmap *__regmap_init(struct device *dev,
else
map->alloc_flags = GFP_KERNEL;

map->reg_base = config->reg_base;

map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
map->format.pad_bytes = config->pad_bits / 8;
map->format.reg_downshift = config->reg_downshift;
map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
map->format.buf_size = DIV_ROUND_UP(config->reg_bits +
config->val_bits + config->pad_bits, 8);
Expand Down Expand Up @@ -1735,6 +1738,8 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
return ret;
}

reg += map->reg_base;
reg >>= map->format.reg_downshift;
map->format.format_reg(map->work_buf, reg, map->reg_shift);
regmap_set_work_buf_flag_mask(map, map->format.reg_bytes,
map->write_flag_mask);
Expand Down Expand Up @@ -1905,6 +1910,8 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg,
return ret;
}

reg += map->reg_base;
reg >>= map->format.reg_downshift;
map->format.format_write(map, reg, val);

trace_regmap_hw_write_start(map, reg, 1);
Expand Down Expand Up @@ -2346,6 +2353,8 @@ static int _regmap_raw_multi_reg_write(struct regmap *map,
unsigned int reg = regs[i].reg;
unsigned int val = regs[i].def;
trace_regmap_hw_write_start(map, reg, 1);
reg += map->reg_base;
reg >>= map->format.reg_downshift;
map->format.format_reg(u8, reg, map->reg_shift);
u8 += reg_bytes + pad_bytes;
map->format.format_val(u8, val, 0);
Expand Down Expand Up @@ -2673,6 +2682,8 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
return ret;
}

reg += map->reg_base;
reg >>= map->format.reg_downshift;
map->format.format_reg(map->work_buf, reg, map->reg_shift);
regmap_set_work_buf_flag_mask(map, map->format.reg_bytes,
map->read_flag_mask);
Expand Down
6 changes: 6 additions & 0 deletions include/linux/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ typedef void (*regmap_unlock)(void *);
* @reg_stride: The register address stride. Valid register addresses are a
* multiple of this value. If set to 0, a value of 1 will be
* used.
* @reg_downshift: The number of bits to downshift the register before
* performing any operations.
* @reg_base: Value to be added to every register address before performing any
* operation.
* @pad_bits: Number of bits of padding between register and value.
* @val_bits: Number of bits in a register value, mandatory.
*
Expand Down Expand Up @@ -360,6 +364,8 @@ struct regmap_config {

int reg_bits;
int reg_stride;
int reg_downshift;
unsigned int reg_base;
int pad_bits;
int val_bits;

Expand Down
2 changes: 2 additions & 0 deletions include/sound/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ struct snd_pcm_runtime {
wait_queue_head_t tsleep; /* transfer sleep */
struct fasync_struct *fasync;
bool stop_operating; /* sync_stop will be called */
struct mutex buffer_mutex; /* protect for buffer changes */
atomic_t buffer_accessing; /* >0: in r/w operation, <0: blocked */

/* -- private section -- */
void *private_data;
Expand Down
2 changes: 1 addition & 1 deletion sound/core/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ config SND_PCM_TIMER
help
If you disable this option, pcm timer will be unavailable, so
those stubs that use pcm timer (e.g. dmix, dsnoop & co) may work
incorrectlly.
incorrectly.

For some embedded devices, we may disable it to reduce memory
footprint, about 20KB on x86_64 platform.
Expand Down
40 changes: 23 additions & 17 deletions sound/core/oss/pcm_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,11 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,

if (oss_period_size < 16)
return -EINVAL;

/* don't allocate too large period; 1MB period must be enough */
if (oss_period_size > 1024 * 1024)
return -ENOMEM;

runtime->oss.period_bytes = oss_period_size;
runtime->oss.period_frames = 1;
runtime->oss.periods = oss_periods;
Expand Down Expand Up @@ -837,6 +842,17 @@ static void unlock_params(struct snd_pcm_runtime *runtime)
mutex_unlock(&runtime->oss.params_lock);
}

static void snd_pcm_oss_release_buffers(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;

kvfree(runtime->oss.buffer);
runtime->oss.buffer = NULL;
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
snd_pcm_oss_plugin_clear(substream);
#endif
}

/* call with params_lock held */
static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
{
Expand Down Expand Up @@ -967,12 +983,10 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
snd_pcm_oss_plugin_clear(substream);
if (!direct) {
/* add necessary plugins */
snd_pcm_oss_plugin_clear(substream);
err = snd_pcm_plug_format_plugins(substream, params, sparams);
if (err < 0) {
pcm_dbg(substream->pcm,
"snd_pcm_plug_format_plugins failed: %i\n", err);
snd_pcm_oss_plugin_clear(substream);
goto failure;
}
if (runtime->oss.plugin_first) {
Expand All @@ -981,18 +995,15 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
if (err < 0) {
pcm_dbg(substream->pcm,
"snd_pcm_plugin_build_io failed: %i\n", err);
snd_pcm_oss_plugin_clear(substream);
goto failure;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
err = snd_pcm_plugin_append(plugin);
} else {
err = snd_pcm_plugin_insert(plugin);
}
if (err < 0) {
snd_pcm_oss_plugin_clear(substream);
if (err < 0)
goto failure;
}
}
}
#endif
Expand Down Expand Up @@ -1043,10 +1054,9 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
goto failure;
}
#endif
oss_period_size *= oss_frame_size;

oss_buffer_size = oss_period_size * runtime->oss.periods;
if (oss_buffer_size < 0) {
oss_period_size = array_size(oss_period_size, oss_frame_size);
oss_buffer_size = array_size(oss_period_size, runtime->oss.periods);
if (oss_buffer_size <= 0) {
err = -EINVAL;
goto failure;
}
Expand Down Expand Up @@ -1082,6 +1092,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)

err = 0;
failure:
if (err)
snd_pcm_oss_release_buffers(substream);
kfree(sw_params);
kfree(params);
kfree(sparams);
Expand Down Expand Up @@ -2351,13 +2363,7 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,

static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime;
runtime = substream->runtime;
kvfree(runtime->oss.buffer);
runtime->oss.buffer = NULL;
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
snd_pcm_oss_plugin_clear(substream);
#endif
snd_pcm_oss_release_buffers(substream);
substream->oss.oss = 0;
}

Expand Down
5 changes: 4 additions & 1 deletion sound/core/oss/pcm_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
width = snd_pcm_format_physical_width(format->format);
if (width < 0)
return width;
size = frames * format->channels * width;
size = array3_size(frames, format->channels, width);
/* check for too large period size once again */
if (size > 1024 * 1024)
return -ENOMEM;
if (snd_BUG_ON(size % 8))
return -ENXIO;
size /= 8;
Expand Down
3 changes: 3 additions & 0 deletions sound/core/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,8 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
init_waitqueue_head(&runtime->tsleep);

runtime->status->state = SNDRV_PCM_STATE_OPEN;
mutex_init(&runtime->buffer_mutex);
atomic_set(&runtime->buffer_accessing, 0);

substream->runtime = runtime;
substream->private_data = pcm->private_data;
Expand Down Expand Up @@ -1002,6 +1004,7 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
} else {
substream->runtime = NULL;
}
mutex_destroy(&runtime->buffer_mutex);
kfree(runtime);
put_pid(substream->pid);
substream->pid = NULL;
Expand Down
5 changes: 5 additions & 0 deletions sound/core/pcm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,10 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
err = -EINVAL;
goto _end_unlock;
}
if (!atomic_inc_unless_negative(&runtime->buffer_accessing)) {
err = -EBUSY;
goto _end_unlock;
}
snd_pcm_stream_unlock_irq(substream);
if (!is_playback)
snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_CPU);
Expand All @@ -2281,6 +2285,7 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
if (is_playback)
snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE);
snd_pcm_stream_lock_irq(substream);
atomic_dec(&runtime->buffer_accessing);
if (err < 0)
goto _end_unlock;
err = pcm_accessible_state(runtime);
Expand Down
11 changes: 7 additions & 4 deletions sound/core/pcm_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,20 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry,
size_t size;
struct snd_dma_buffer new_dmab;

mutex_lock(&substream->pcm->open_mutex);
if (substream->runtime) {
buffer->error = -EBUSY;
return;
goto unlock;
}
if (!snd_info_get_line(buffer, line, sizeof(line))) {
snd_info_get_str(str, line, sizeof(str));
size = simple_strtoul(str, NULL, 10) * 1024;
if ((size != 0 && size < 8192) || size > substream->dma_max) {
buffer->error = -EINVAL;
return;
goto unlock;
}
if (substream->dma_buffer.bytes == size)
return;
goto unlock;
memset(&new_dmab, 0, sizeof(new_dmab));
new_dmab.dev = substream->dma_buffer.dev;
if (size > 0) {
Expand All @@ -189,7 +190,7 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry,
substream->pcm->card->number, substream->pcm->device,
substream->stream ? 'c' : 'p', substream->number,
substream->pcm->name, size);
return;
goto unlock;
}
substream->buffer_bytes_max = size;
} else {
Expand All @@ -201,6 +202,8 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry,
} else {
buffer->error = -EINVAL;
}
unlock:
mutex_unlock(&substream->pcm->open_mutex);
}

static inline void preallocate_info_init(struct snd_pcm_substream *substream)
Expand Down
Loading