03 Sep, 2020

1 commit


25 Jun, 2020

1 commit

  • The module argument passed to snd_card_new() must be a valid non-NULL
    pointer when the module support is enabled. Since ASoC driver passes
    the argument from each snd_soc_card definition, one may forget to set
    the owner field and lead to a NULL module easily.

    For catching such an overlook, add a WARN_ON() in snd_card_new().
    Also, put the card->module assignment in the ifdef block for a very
    minor optimization.

    Link: https://lore.kernel.org/r/20200624160300.21703-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

21 Jan, 2020

1 commit

  • Currently, the available buffer allocation size for a PCM stream
    depends on the preallocated size; when a buffer has been preallocated,
    the max buffer size is set to that size, so that application won't
    re-allocate too much memory. OTOH, when no preallocation is done,
    each substream may allocate arbitrary size of buffers as long as
    snd_pcm_hardware.buffer_bytes_max allows -- which can be quite high,
    HD-audio sets 1GB there.

    It means that the system may consume a high amount of pages for PCM
    buffers, and they are pinned and never swapped out. This can lead to
    OOM easily.

    For avoiding such a situation, this patch adds the upper limit per
    card. Each snd_pcm_lib_malloc_pages() and _free_pages() calls are
    tracked and it will return an error if the total amount of buffers
    goes over the defined upper limit. The default value is set to 32MB,
    which should be really large enough for usual operations.

    If larger buffers are needed for any specific usage, it can be
    adjusted (also dynamically) via snd_pcm.max_alloc_per_card option.
    Setting zero there means no chceck is performed, and again, unlimited
    amount of buffers are allowed.

    Link: https://lore.kernel.org/r/20200120124423.11862-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

21 Nov, 2019

1 commit

  • Many PCI and other drivers performs snd_pcm_period_elapsed() simply in
    its interrupt handler, so the sync_stop operation is just to call
    synchronize_irq(). Instead of putting this call multiple times,
    introduce the common card->sync_irq field. When this field is set,
    PCM core performs synchronize_irq() for sync-stop operation. Each
    driver just needs to copy its local IRQ number to card->sync_irq, and
    that's all we need.

    Link: https://lore.kernel.org/r/20191117085308.23915-8-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

06 May, 2019

1 commit


17 Apr, 2019

1 commit

  • The snd_cards[] array holds the card pointers that have been currently
    registered, and it's exported for the external modules that may need
    to refer a card object. But accessing to this array can be racy
    against the driver probe or removal, as the card registration or free
    may happen concurrently.

    This patch gets rid of the direct access to snd_cards[] array and
    provides a helper function to give the card object from the index
    number with a refcount management. Then the caller can access to the
    given card object safely, and releases it via snd_card_unref().

    While we're at it, add a proper comment to snd_card_unref() and make
    it an inlined function for type-safety, too.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

16 Apr, 2019

1 commit

  • There is a small race window in the card disconnection code that
    allows the registration of another card with the very same card id.
    This leads to a warning in procfs creation as caught by syzkaller.

    The problem is that we delete snd_cards and snd_cards_lock entries at
    the very beginning of the disconnection procedure. This makes the
    slot available to be assigned for another card object while the
    disconnection procedure is being processed. Then it becomes possible
    to issue a procfs registration with the existing file name although we
    check the conflict beforehand.

    The fix is simply to move the snd_cards and snd_cards_lock clearances
    at the end of the disconnection procedure. The references to these
    entries are merely either from the global proc files like
    /proc/asound/cards or from the card registration / disconnection, so
    it should be fine to shift at the very end.

    Reported-by: syzbot+48df349490c36f9f54ab@syzkaller.appspotmail.com
    Cc:
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

07 Feb, 2019

2 commits

  • The creation of card's id proc file can be moved gracefully into
    info.c. Also, the assignment of card->proc_id is superfluous and can
    be dropped. So let's do it.

    Basically this is no functional change but code refactoring, but one
    potential behavior change is that now it returns properly the error
    code from snd_info_card_register(), which is a good thing (tm).

    Reviewed-by: Jaroslav Kysela
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • It's referred only in snd_card_id_read() which can receive the card
    object via private_data.

    Reviewed-by: Jaroslav Kysela
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

28 May, 2018

1 commit

  • Convert the S_ 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

    Miscellanea:

    o Wrapped one multi-line call to a single line

    Signed-off-by: Joe Perches
    Acked-by: Vinod Koul
    Signed-off-by: Takashi Iwai

    Joe Perches
     

27 Feb, 2018

1 commit


12 Feb, 2018

1 commit

  • This is the mindless scripted replacement of kernel use of POLL*
    variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
    L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
    for f in $L; do sed -i "-es/^\([^\"]*\)\(\\)/\\1E\\2/" $f; done
    done

    with de-mangling cleanups yet to come.

    NOTE! On almost all architectures, the EPOLL* constants have the same
    values as the POLL* constants do. But they keyword here is "almost".
    For various bad reasons they aren't the same, and epoll() doesn't
    actually work quite correctly in some cases due to this on Sparc et al.

    The next patch from Al will sort out the final differences, and we
    should be all done.

    Scripted-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

28 Nov, 2017

1 commit


11 Oct, 2017

1 commit

  • In case of user unbind ALSA driver during playing back / capturing,
    each driver needs to stop and remove it correctly. One note here is
    that we can't cancel from remove function in such case, because
    unbind operation doesn't check return value from remove function.
    So, we *must* stop and remove in this case.

    For this purpose, we need to sync (= wait) until the all top-level
    operations are canceled at remove function.
    For example, snd_card_free() processes the disconnection procedure at
    first, then waits for the completion. That's how the hot-unplug works
    safely. It's implemented, at least, in the top-level driver removal.

    Now for the lower level driver, we need a similar strategy. Notify to
    the toplevel for hot-unplug (disconnect in ALSA), and sync with the
    stop operation, then continue the rest of its own remove procedure.

    This patch adds snd_card_disconnect_sync(), and driver can use it from
    remove function.

    Note: the "lower level" driver here refers to a middle layer driver
    (e.g. ASoC components) that can be unbound freely during operation.
    Most of legacy ALSA helper drivers don't have such a problem because
    they can't be unbound.

    Note#2: snd_card_disconnect_sync() merely calls snd_card_disconnect()
    and syncs with closing all pending files. It takes only the files
    opened by user-space into account, and doesn't care about object
    refcounts. (The latter is handled by snd_card_free() completion call,
    BTW.) Also, the function doesn't free resources by itself.

    Tested-by: Kuninori Morimoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

31 Aug, 2017

1 commit

  • Currently we're taking power_lock at each card component for assuring
    the power-up sequence, but it doesn't help anything in the
    implementation at the moment: it just serializes unnecessarily the
    callers, but it doesn't protect about the power state change itself.
    It used to have some usefulness in the early days where we managed the
    PM manually. But now the suspend/resume core procedure is beyond our
    hands, and power_lock lost its meaning.

    This patch drops the power_lock from allover the places.
    There shouldn't be any issues by this change, as it's no helper
    regarding the power state change. Rather we'll get better performance
    by removing the serialization; which is the only slight concern of any
    behavior change, but it can't be a showstopper, after all.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

04 Aug, 2017

1 commit

  • At a previous commit, concurrent requests for TLV data are maintained
    exclusively between read requests and write/command requests. TLV
    callback handlers in each driver has no risk from concurrent access for
    reference/change.

    In current implementation, 'struct snd_card' has a mutex to control
    concurrent accesses to user-defined element sets. This commit obsoletes it.

    Signed-off-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Sakamoto
     

07 Jul, 2017

1 commit

  • Pull sound updates from Takashi Iwai:
    "This development cycle resulted in a fair amount of changes in both
    core and driver sides. The most significant change in ALSA core is
    about PCM. Also the support of of-graph card and the new DAPM widget
    for DSP are noteworthy changes in ASoC core. And there're lots of
    small changes splat over the tree, as you can see in diffstat.

    Below are a few highlights:

    ALSA core:
    - Removal of set_fs() hackery from PCM core stuff, and the code
    reorganization / optimization thereafter
    - Improved support of PCM ack ops, and a new ABI for improved
    control/status mmap handling
    - Lots of constifications in various codes

    ASoC core:
    - The support of of-graph card, which may work as a better generic
    device for a replacement of simple-card
    - New widget types intended mainly for use with DSPs

    ASoC drivers:
    - New drivers for Allwinner V3s SoCs
    - Ensonic ES8316 codec support
    - More Intel SKL and KBL works
    - More device support for Intel SST Atom (mostly for cheap tablets
    and 2-in-1 devices)
    - Support for Rockchip PDM controllers
    - Support for STM32 I2S and S/PDIF controllers
    - Support for ZTE AUD96P22 codecs

    HD-audio:
    - Support of new Realtek codecs (ALC215/ALC285/ALC289), more quirks
    for HP and Dell machines
    - A few more fixes for i915 component binding"

    * tag 'sound-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (418 commits)
    ALSA: hda - Fix unbalance of i915 module refcount
    ASoC: Intel: Skylake: Remove driver debugfs exit
    ASoC: Intel: Skylake: explicitly add the headers sst-dsp.h
    ALSA: hda/realtek - Remove GPIO_MASK
    ALSA: hda/realtek - Fix typo of pincfg for Dell quirk
    ALSA: pcm: add a documentation for tracepoints
    ALSA: atmel: ac97c: fix error return code in atmel_ac97c_probe()
    ALSA: x86: fix error return code in hdmi_lpe_audio_probe()
    ASoC: Intel: Skylake: Add support to read firmware registers
    ASoC: Intel: Skylake: Add sram address to sst_addr structure
    ASoC: Intel: Skylake: Debugfs facility to dump module config
    ASoC: Intel: Skylake: Add debugfs support
    ASoC: fix semicolon.cocci warnings
    ASoC: rt5645: Add quirk override by module option
    ASoC: rsnd: make arrays path and cmd_case static const
    ASoC: audio-graph-card: add widgets and routing for external amplifier support
    ASoC: audio-graph-card: update bindings for amplifier support
    ASoC: rt5665: calibration should be done before jack detection
    ASoC: rsnd: constify dev_pm_ops structures.
    ASoC: nau8825: change crosstalk-bypass property to bool type
    ...

    Linus Torvalds
     

20 Jun, 2017

1 commit

  • Rename:

    wait_queue_t => wait_queue_entry_t

    'wait_queue_t' was always a slight misnomer: its name implies that it's a "queue",
    but in reality it's a queue *entry*. The 'real' queue is the wait queue head,
    which had to carry the name.

    Start sorting this out by renaming it to 'wait_queue_entry_t'.

    This also allows the real structure name 'struct __wait_queue' to
    lose its double underscore and become 'struct wait_queue_entry',
    which is the more canonical nomenclature for such data types.

    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

16 Jun, 2017

1 commit


13 Jan, 2016

1 commit

  • Currently the info in /proc/interrupts doesn't allow to figure out which
    interrupt belongs to which card (HDMI, PCH, ..).
    Therefore add card details to the interrupt description.
    With the patch the info in /proc/interrupts looks like this:

    PCI-MSI 442368-edge snd_hda_intel:card1
    PCI-MSI 49152-edge snd_hda_intel:card0

    NOTE: this patch adds the new irq_descr field snd_card struct that is
    filled automatically at a card object creation. This can be used
    generically for other drivers as well. The changes for others will
    follow later -- tiwai

    Signed-off-by: Heiner Kallweit
    Signed-off-by: Takashi Iwai

    Heiner Kallweit
     

30 Jun, 2015

1 commit

  • Static analysis with cppcheck found the following error:
    [sound/core/init.c:118]: (error) Uninitialized variable: err

    ..this was introduced by commit 2471b6c80a70e80de69f5ff4c37187c3912e5874
    ("ALSA: info: Register proc entries recursively, too") where the call
    to snd_info_card_register was removed and no longer setting the error
    return in err. When snd_info_create_card_entry fails to allocate a
    an entry, the error path exits with garbage in err. Fix is to return
    -ENOMEM if entry fails to be allocated.

    Fixes: 2471b6c80a ("ALSA: info: Register proc entries recursively, too")
    Signed-off-by: Colin Ian King
    Signed-off-by: Takashi Iwai

    Colin Ian King
     

28 May, 2015

1 commit

  • 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
    Reviewed-by: Mark Brown
    Signed-off-by: Takashi Iwai

    Jie Yang
     

18 May, 2015

1 commit

  • The commit [c560a6797e3b: ALSA: core: Remove child proc file elements
    recursively] converted snd_card_proc_new() with the normal
    snd_info_*() call and removed snd_device chain for such info
    entries. However, it misses one point: the creation of the proc entry
    was managed by snd_device chain in the former code, and now it's also
    gone, which results in no proc files creation at all. Mea culpa.

    This patch makes snd_info_card_register() creating the all pending
    child proc entries in a shot. Also, since snd_card_register() might
    be called multiple times, this function is also changed to be callable
    multiple times.

    Along with the changes above, now the linked list of snd_info_entry is
    added at creation time instead of snd_info_register() for keeping eyes
    of pending info entries.

    Fixes: c560a6797e3b ('ALSA: core: Remove child proc file elements recursively')
    Reported-by: "Lu, Han"
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

24 Apr, 2015

2 commits

  • So far we've ignored the errors at creating proc files in many places.
    But they should be rather treated seriously.

    Also, by assuring the error handling, we can get rid of superfluous
    snd_info_free_entry() calls as they will be removed by the parent in
    the caller side.

    This patch fixes the missing error checks and reduces the superfluous
    free calls.

    Acked-by: Jaroslav Kysela
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Since each proc entry is freed automatically by the parent, we don't
    have to take care of its life cycle any longer. This allows us to
    reduce a few more lines of codes.

    Acked-by: Jaroslav Kysela
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

03 Mar, 2015

1 commit


06 Feb, 2015

1 commit

  • For assigning sysfs entries for a card device from the driver,
    introduce a new helper function, snd_card_add_dev_attr(). In this
    way, we can avoid the possible race between the device registration
    and the sysfs addition / removal.

    The driver can pass a new attribute group to add freely. This has to
    be called before snd_card_register().

    Currently, up to two extra groups can be added. More than that, it'll
    return an error.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

02 Feb, 2015

1 commit


30 Oct, 2014

1 commit


18 Jun, 2014

1 commit

  • The user-control put and get handlers as well as the tlv do not protect against
    concurrent access from multiple threads. Since the state of the control is not
    updated atomically it is possible that either two write operations or a write
    and a read operation race against each other. Both can lead to arbitrary memory
    disclosure. This patch introduces a new lock that protects user-controls from
    concurrent access. Since applications typically access controls sequentially
    than in parallel a single lock per card should be fine.

    Signed-off-by: Lars-Peter Clausen
    Acked-by: Jaroslav Kysela
    Cc:
    Signed-off-by: Takashi Iwai

    Lars-Peter Clausen
     

25 Feb, 2014

2 commits

  • A few code cleanups and optimizations. In addition, drop
    snd_device_disconnect() that isn't used at all, and drop the return
    values from snd_device_free*().

    Another slight difference by this change is that now the device state
    will become always SNDRV_DEV_REGISTERED no matter whether dev_register
    ops is present or not. It's for better consistency. There should be
    no impact for the current tree, as the state isn't checked.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Basically, the device type specifies the priority of the device to be
    registered / freed, too. However, the priority value isn't well
    utilized but only it's checked as a group. This results in
    inconsistent register and free order (where each of them should be in
    reversed direction).

    This patch simplifies the device list management code by simply
    inserting a list entry at creation time in an incremental order for
    the priority value. Since we can just follow the link for register,
    disconnect and free calls, we don't have to specify the group; so the
    whole enum definitions are also simplified as well.

    The visible change to outside is that the priorities of some object
    types are revisited. For example, now the SNDRV_DEV_LOWLEVEL object
    is registered before others (control, PCM, etc) and, in return,
    released after others. Similarly, SNDRV_DEV_CODEC is in a lower
    priority than SNDRV_DEV_BUS for ensuring the dependency.

    Also, the unused SNDRV_DEV_TOPLEVEL, SNDRV_DEV_LOWLEVEL_PRE and
    SNDRV_DEV_LOWLEVEL_NORMAL are removed as a cleanup.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

19 Feb, 2014

1 commit

  • While moving the card device into struct snd_card, the reference to
    the assigned card in sysfs show/store callbacks were forgotten to be
    refreshed, still accessing to the no longer used drvdata. Fix these
    places to refer correctly via container_of().

    Also, remove the superfluous NULL checks since it's guaranteed to be
    non-NULL now.

    Fixes: 8bfb181c17d2 ('ALSA: Embed card device into struct snd_card')
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

14 Feb, 2014

4 commits


12 Feb, 2014

1 commit

  • This is a part of preliminary works for modernizing the ALSA device
    structure. So far, we set card->dev at later point after the object
    creation. Because of this, the core layer doesn't always know which
    device is being handled before it's actually registered, and it makes
    impossible to show the device in error messages, for example. The
    first goal is to achieve a proper struct device initialization at the
    very beginning of probing.

    As a first step, this patch introduces snd_card_new() function (yes
    there was the same named function in the very past), in order to
    receive the parent device pointer from the very beginning.
    snd_card_create() is marked as deprecated.

    At this point, there is no functional change other than that. The
    actual change of the device creation scheme will follow later.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

10 Feb, 2014

1 commit

  • Replace the lengthy #if defined(XXX) || defined(XXX_MODULE) with the
    new IS_ENABLED() macro.

    The patch still doesn't cover all ifdefs. For example, the dependency
    on CONFIG_GAMEPORT is still open-coded because this also has an extra
    dependency on MODULE. Similarly, an open-coded ifdef in pcm_oss.c and
    some sequencer-related stuff are left untouched.

    Signed-off-by: Takashi Iwai

    Takashi Iwai