#
734b5a0b |
| 23-Nov-2018 |
Takashi Iwai <tiwai@suse.de> |
ALSA: Replace snd_malloc_pages() and snd_free_pages() with standard helpers, take#2
snd_malloc_pages() and snd_free_pages() are merely thin wrappers of the standard page allocator / free functions.
ALSA: Replace snd_malloc_pages() and snd_free_pages() with standard helpers, take#2
snd_malloc_pages() and snd_free_pages() are merely thin wrappers of the standard page allocator / free functions. Even the arguments are compatible with some standard helpers, so there is little merit of keeping these wrappers.
This patch replaces the all existing callers of snd_malloc_pages() and snd_free_pages() with the direct calls of the standard helper functions. In this version, we use a recently introduced one, alloc_pages_exact(), which suits better than the old snd_malloc_pages() implementation for our purposes. Then we can avoid the waste of pages by alignment to power-of-two.
Since alloc_pages_exact() does split pages, we need no longer __GFP_COMP flag; or better to say, we must not pass __GFP_COMP to alloc_pages_exact(). So the former unconditional addition of __GFP_COMP flag in snd_malloc_pages() is dropped, as well as in most other places.
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
a8d14981 |
| 04-Feb-2019 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Remove superfluous snd_info_register() calls
The calls of snd_info_register() are superfluous and should be avoided at the procfs creation time. They are called at the end of the whole i
ALSA: pcm: Remove superfluous snd_info_register() calls
The calls of snd_info_register() are superfluous and should be avoided at the procfs creation time. They are called at the end of the whole initialization via snd_card_register(). This patch drops such superfluous calls, as well as cleaning up the calls of substream proc entries with a common helper.
Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
480e32eb |
| 23-Jan-2019 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Simplify proc file destruction
The proc files are recursively freed by calling with the root snd_info_entry object, so we don't have to keep each object for releasing one by one. Move th
ALSA: pcm: Simplify proc file destruction
The proc files are recursively freed by calling with the root snd_info_entry object, so we don't have to keep each object for releasing one by one. Move the release of the PCM stream proc root at the beginning, so that we can remove the redundant code and resource.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
73365cb1 |
| 13-Jan-2019 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Unify snd_pcm_group initialization
There are multiple open codes that initialize the same object. Create a common helper function instead.
Also, use kzalloc() to be safer at creating a g
ALSA: pcm: Unify snd_pcm_group initialization
There are multiple open codes that initialize the same object. Create a common helper function instead.
Also, use kzalloc() to be safer at creating a group object, and move the initialization out of the critical section.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
3d21ef0b |
| 11-Jan-2019 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Suspend streams globally via device type PM ops
Until now we rely on each driver calling snd_pcm_suspend*() explicitly at its own PM handling. However, this can be done far more easily b
ALSA: pcm: Suspend streams globally via device type PM ops
Until now we rely on each driver calling snd_pcm_suspend*() explicitly at its own PM handling. However, this can be done far more easily by setting the PM ops to each actual snd_pcm device object.
This patch adds the device_type object for PCM stream and assigns to each PCM stream object. The type contains only the PM ops for system suspend; we don't need to deal with the resume in general.
The suspend hook simply calls snd_pcm_suspend_all() for the given PCM streams. This implies that the PM order is correctly put, i.e. PCM is suspended before the main (or codec) driver, which should be true in general. If a special ordering is needed, you'd need to adjust the device PM order manually later.
This patch introduces a new flag, snd_pcm.no_device_suspend, too. With this flag set, the PCM device object won't invoke snd_pcm_suspend_all() by itself. This is needed for ASoC who wants to manage the PM call orders in its serialized way, and the flag is set in soc_new_pcm() as default.
For the non-ASoC world, we can get rid of the manual snd_pcm_suspend calls. This will be done in the later patches.
Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
94ffb030 |
| 12-Dec-2018 |
Gustavo A. R. Silva <gustavo@embeddedor.com> |
ALSA: pcm: Fix potential Spectre v1 vulnerability
stream is indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This issue was det
ALSA: pcm: Fix potential Spectre v1 vulnerability
stream is indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This issue was detected with the help of Smatch:
sound/core/pcm.c:140 snd_pcm_control_ioctl() warn: potential spectre issue 'pcm->streams' [r] (local cap)
Fix this by sanitizing stream before using it to index pcm->streams
Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1].
[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Cc: stable@vger.kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
e647f5a5 |
| 04-Jul-2018 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Use snd_pcm_stop_xrun() for xrun injection
Basically the xrun injection routine can simply call the standard helper snd_pcm_stop_xrun(), but with one exception: it may be called even when
ALSA: pcm: Use snd_pcm_stop_xrun() for xrun injection
Basically the xrun injection routine can simply call the standard helper snd_pcm_stop_xrun(), but with one exception: it may be called even when the stream is closed.
Make snd_pcm_stop_xrun() more robust and check the NULL runtime state, and simplify xrun injection code by calling it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
9cd641ed |
| 04-Jul-2018 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: trace XRUN event at injection, too
The PCM xrun injection triggers directly snd_pcm_stop() without the standard xrun handler, hence it's not recorded on the event buffer. Ditto for snd_pc
ALSA: pcm: trace XRUN event at injection, too
The PCM xrun injection triggers directly snd_pcm_stop() without the standard xrun handler, hence it's not recorded on the event buffer. Ditto for snd_pcm_stop_xrun() call and SNDRV_PCM_IOCTL_XRUN ioctl. They are inconvenient from the debugging POV.
Let's make them to trigger XRUN via the standard helper more consistently.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
6a73cf46 |
| 23-May-2018 |
Joe Perches <joe@perches.com> |
sound: Use octal not symbolic permissions
Convert the S_<FOO> symbolic permissions to their octal equivalents as using octal and not symbolic permissions is preferred by many as more readable.
see:
sound: Use octal not symbolic permissions
Convert the S_<FOO> symbolic permissions to their octal equivalents as using octal and not symbolic permissions is preferred by many as more readable.
see: https://lkml.org/lkml/2016/8/2/1945
Done with automated conversion via: $ ./scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace <files...>
Miscellanea:
o Wrapped one multi-line call to a single line
Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
a820ccbe |
| 02-Apr-2018 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Fix UAF at PCM release via PCM timer access
The PCM runtime object is created and freed dynamically at PCM stream open / close time. This is tracked via substream->runtime, and it's clea
ALSA: pcm: Fix UAF at PCM release via PCM timer access
The PCM runtime object is created and freed dynamically at PCM stream open / close time. This is tracked via substream->runtime, and it's cleared at snd_pcm_detach_substream().
The runtime object assignment is protected by PCM open_mutex, so for all PCM operations, it's safely handled. However, each PCM substream provides also an ALSA timer interface, and user-space can access to this while closing a PCM substream. This may eventually lead to a UAF, as snd_pcm_timer_resolution() tries to access the runtime while clearing it in other side.
Fortunately, it's the only concurrent access from the PCM timer, and it merely reads runtime->timer_resolution field. So, we can avoid the race by reordering kfree() and wrapping the substream->runtime clearance with the corresponding timer lock.
Reported-by: syzbot+8e62ff4e07aa2ce87826@syzkaller.appspotmail.com Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
362bca57 |
| 05-Dec-2017 |
Robb Glasser <rglasser@google.com> |
ALSA: pcm: prevent UAF in snd_pcm_info
When the device descriptor is closed, the `substream->runtime` pointer is freed. But another thread may be in the ioctl handler, case SNDRV_CTL_IOCTL_PCM_INFO.
ALSA: pcm: prevent UAF in snd_pcm_info
When the device descriptor is closed, the `substream->runtime` pointer is freed. But another thread may be in the ioctl handler, case SNDRV_CTL_IOCTL_PCM_INFO. This case calls snd_pcm_info_user() which calls snd_pcm_info() which accesses the now freed `substream->runtime`.
Note: this fixes CVE-2017-0861
Signed-off-by: Robb Glasser <rglasser@google.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
6ca73de7 |
| 11-Oct-2017 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Forcibly stop at disconnect callback
So far we assumed that each driver implements the hotplug PCM handling properly, e.g. dealing with the pending PCM stream at disconnect callback. But
ALSA: pcm: Forcibly stop at disconnect callback
So far we assumed that each driver implements the hotplug PCM handling properly, e.g. dealing with the pending PCM stream at disconnect callback. But most codes don't care, and it eventually leaves the PCM stream inconsistent state when an abrupt disconnection like sysfs unbind happens.
This patch is simple but a big-hammer solution: invoke snd_pcm_stop() at the common PCM disconnect callback always when the stream is running.
Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
8b645e4a |
| 17-Oct-2017 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Don't call register and disconnect callbacks for internal PCM
The internal PCM (aka DPCM backend PCM) doesn't need any registration procedure, thus currently we bail out immediately at de
ALSA: pcm: Don't call register and disconnect callbacks for internal PCM
The internal PCM (aka DPCM backend PCM) doesn't need any registration procedure, thus currently we bail out immediately at dev_register callback. Similarly, its counterpart, dev_disconnect callback, is superfluous for the internal PCM. For simplifying and avoiding the conflicting disconnect call for internal PCM objects, this patch drops dev_register and dev_disconnect callbacks for the internal ops.
The only uncertain thing by this action is whether skipping the PCM state change to SNDRV_PCM_STATE_DISCONNECT for the internal PCM is mandatory. Looking through the current implementations, this doesn't look so, hence dropping the whole dev_disconnect would make more sense.
Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
e6b4c525 |
| 24-Aug-2017 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Correct broken procfs set up
The commit c8da9be4a75f ("ALSA: pcm: Adjust nine function calls together with a variable assignment") contained a badly incorrect conversion, a "status" PCM p
ALSA: pcm: Correct broken procfs set up
The commit c8da9be4a75f ("ALSA: pcm: Adjust nine function calls together with a variable assignment") contained a badly incorrect conversion, a "status" PCM procfs creation was replaced with the next one. Luckily, this could be spotted easily by the kernel runtime warning.
Fixes: c8da9be4a75f ("ALSA: pcm: Adjust nine function calls together...") Reported-by: Fabio Estevam <fabio.estevam@nxp.com> Tested-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
c8da9be4 |
| 23-Aug-2017 |
Markus Elfring <elfring@users.sourceforge.net> |
ALSA: pcm: Adjust nine function calls together with a variable assignment
The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus f
ALSA: pcm: Adjust nine function calls together with a variable assignment
The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
97d15a14 |
| 23-Aug-2017 |
Markus Elfring <elfring@users.sourceforge.net> |
ALSA: pcm: Use common error handling code in _snd_pcm_new()
Add a jump target so that a bit of exception handling can be better reused at the end of this function.
This issue was detected by using
ALSA: pcm: Use common error handling code in _snd_pcm_new()
Add a jump target so that a bit of exception handling can be better reused at the end of this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
343fe850 |
| 29-Jun-2017 |
Arvind Yadav <arvind.yadav.cs@gmail.com> |
ALSA: pcm: constify attribute_group structures.
attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/device.h> work with const attri
ALSA: pcm: constify attribute_group structures.
attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/device.h> work with const attribute_group. So mark the non-const structs as const.
File size before: text data bss dec hex filename 9781 240 8 10029 272d sound/core/pcm.o
File size After adding 'const': text data bss dec hex filename 9813 176 8 9997 270d sound/core/pcm.o
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
2c4842d3 |
| 26-May-2017 |
Takashi Sakamoto <o-takashi@sakamocchi.jp> |
ALSA: pcm: add local header file for snd-pcm module
Several files are used to construct PCM core module, a.k.a snd-pcm. Although available APIs are described in 'include/sound/pcm.h', some of them a
ALSA: pcm: add local header file for snd-pcm module
Several files are used to construct PCM core module, a.k.a snd-pcm. Although available APIs are described in 'include/sound/pcm.h', some of them are not exported as symbols in kernel space. Such APIs are just for module local usage.
This commit adds module local header file and move some function prototypes into it so that scopes of them are controlled properly and developers get no confusion from unavailable symbols.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
9aee03f3 |
| 18-May-2017 |
Arnd Bergmann <arnd@arndb.de> |
ALSA: pcm: use "do {} while (0)" for empty macro
Recent compilers produce a harmless warning for the new pcm_call_notify() macro when CONFIG_SND_PCM_OSS is disabled:
sound/core/pcm.c: In function '
ALSA: pcm: use "do {} while (0)" for empty macro
Recent compilers produce a harmless warning for the new pcm_call_notify() macro when CONFIG_SND_PCM_OSS is disabled:
sound/core/pcm.c: In function 'snd_pcm_free': sound/core/pcm.c:905:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
This turns the empty macro into a 'do {} while (0)' statement to avoid the warning.
Fixes: 58f30d650c7f ("ALSA: pcm: Build pcm notifier code conditionally") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
58f30d65 |
| 12-May-2017 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Build pcm notifier code conditionally
The PCM notifier code is used only by OSS emulation layer, so we can build it conditionally for reducing the size.
Signed-off-by: Takashi Iwai <tiwa
ALSA: pcm: Build pcm notifier code conditionally
The PCM notifier code is used only by OSS emulation layer, so we can build it conditionally for reducing the size.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
a8ff48cb |
| 08-Jul-2016 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Free chmap at PCM free callback, too
The chmap ctls assigned to PCM streams are freed in the PCM disconnect callback. However, since the disconnect callback isn't called when the card ge
ALSA: pcm: Free chmap at PCM free callback, too
The chmap ctls assigned to PCM streams are freed in the PCM disconnect callback. However, since the disconnect callback isn't called when the card gets freed before registering, the chmap ctls may still be left assigned. They are eventually freed together with other ctls, but it may cause an Oops at pcm_chmap_ctl_private_free(), as the function refers to the assigned PCM stream, while the PCM objects have been already freed beforehand.
The fix is to free the chmap ctls also at PCM free callback, not only at PCM disconnect.
Reported-by: Laxminath Kasam <b_lkasam@codeaurora.org> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
0052b7dc |
| 13-Sep-2015 |
Takashi Sakamoto <o-takashi@sakamocchi.jp> |
ALSA: pcm: remove structure member of 'struct snd_pcm_hwptr_log *' type because this structure had been removed
This structure was added by 4d96eb255c53 ('ALSA: pcm_lib - add possibility to log last
ALSA: pcm: remove structure member of 'struct snd_pcm_hwptr_log *' type because this structure had been removed
This structure was added by 4d96eb255c53 ('ALSA: pcm_lib - add possibility to log last 10 DMA ring buffer positions') to store PCM pointers information of latest 10 pointer movements (=XRUN_LOG_CNT). When CONFIG_SND_PCM_XRUN_DEBUG is configured, 'struct snd_pcm_runtime' has 'hwptr_log' member with a pointer to the structure. When calling xrun_log() in pcm_lib.c, the structure was allocated to the pointer. When calling snd_pcm_detach_substream() in pcm.c, the allocated pointer is released.
In f5914908a5b7 ('ALSA: pcm: Replace PCM hwptr tracking with tracepoints'), the pointer logging is replaced with using Linux Kernel Tracepoints. The structure was also removed, while it's just declared. The member and kfree still remains.
This commit removes the member and related codes. I think this was overlooked because it brings no errors/warnings to C compilers.
Fixes: f5914908a5b7 ('ALSA: pcm: Replace PCM hwptr tracking with tracepoints') Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
60b93030 |
| 23-Jun-2015 |
Takashi Iwai <tiwai@suse.de> |
ALSA: pcm: Fix pcm_class sysfs output
The pcm_class sysfs of each PCM substream gives only "none" since the recent code change to embed the struct device. Fix the code to point directly to the embe
ALSA: pcm: Fix pcm_class sysfs output
The pcm_class sysfs of each PCM substream gives only "none" since the recent code change to embed the struct device. Fix the code to point directly to the embedded device object properly.
Fixes: ef46c7af93f9 ('ALSA: pcm: Embed struct device') Cc: <stable@vger.kernel.org> # v4.0+ Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
cd6a6503 |
| 27-May-2015 |
Jie Yang <yang.jie@intel.com> |
ALSA: replace CONFIG_PROC_FS with CONFIG_SND_PROC_FS
We may disable proc fs only for sound part, to reduce ALSA memory footprint. So add CONFIG_SND_PROC_FS and replace the old CONFIG_PROC_FSs in als
ALSA: replace CONFIG_PROC_FS with CONFIG_SND_PROC_FS
We may disable proc fs only for sound part, to reduce ALSA memory footprint. So add CONFIG_SND_PROC_FS and replace the old CONFIG_PROC_FSs in alsa code.
With sound proc fs disabled, we can save about 9KB memory size on X86_64 platform.
Signed-off-by: Jie Yang <yang.jie@intel.com> Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|
#
ec0e9937 |
| 10-Mar-2015 |
Takashi Iwai <tiwai@suse.de> |
ALSA: core: Drop superfluous error/debug messages after malloc failures
The kernel memory allocators already report the errors when the requested allocation fails, thus we don't need to warn it agai
ALSA: core: Drop superfluous error/debug messages after malloc failures
The kernel memory allocators already report the errors when the requested allocation fails, thus we don't need to warn it again in each caller side.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
show more ...
|