26 Aug, 2015

1 commit

  • After the recent fix of runtime PM for USB-audio driver, we got a
    lockdep warning like:

    =============================================
    [ INFO: possible recursive locking detected ]
    4.2.0-rc8+ #61 Not tainted
    ---------------------------------------------
    pulseaudio/980 is trying to acquire lock:
    (&chip->shutdown_rwsem){.+.+.+}, at: [] snd_usb_autoresume+0x1d/0x52 [snd_usb_audio]
    but task is already holding lock:
    (&chip->shutdown_rwsem){.+.+.+}, at: [] snd_usb_autoresume+0x1d/0x52 [snd_usb_audio]

    This comes from snd_usb_autoresume() invoking down_read() and it's
    used in a nested way. Although it's basically safe, per se (as these
    are read locks), it's better to reduce such spurious warnings.

    The read lock is needed to guarantee the execution of "shutdown"
    (cleanup at disconnection) task after all concurrent tasks are
    finished. This can be implemented in another better way.

    Also, the current check of chip->in_pm isn't good enough for
    protecting the racy execution of multiple auto-resumes.

    This patch rewrites the logic of snd_usb_autoresume() & co; namely,
    - The recursive call of autopm is avoided by the new refcount,
    chip->active. The chip->in_pm flag is removed accordingly.
    - Instead of rwsem, another refcount, chip->usage_count, is introduced
    for tracking the period to delay the shutdown procedure. At
    the last clear of this refcount, wake_up() to the shutdown waiter is
    called.
    - The shutdown flag is replaced with shutdown atomic count; this is
    for reducing the lock.
    - Two new helpers are introduced to simplify the management of these
    refcounts; snd_usb_lock_shutdown() increases the usage_count, checks
    the shutdown state, and does autoresume. snd_usb_unlock_shutdown()
    does the opposite. Most of mixer and other codes just need this,
    and simply returns an error if it receives an error from lock.

    Fixes: 9003ebb13f61 ('ALSA: usb-audio: Fix runtime PM unbalance')
    Reported-and-tested-by: Alexnader Kuleshov
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

17 May, 2013

1 commit

  • freqshift is only set for the data endpoint and syncmaxsize is only set
    for the sync endpoint. This results in a syncmaxsize of zero used in the
    proc output feedback format calculation, which gives a feedback format
    incorrectly shown as 8.16 for UAC2 devices.

    As neither the data nor the sync endpoint gives all the relevant
    content, output the two combined.

    Also remove the sync_endpoint "packet size" which is always zero
    and the sync_endpoint "momentary freq" which is constant.

    Tested with UAC2 async and UAC1 adaptive, not tested with UAC1 async.

    Reported-by: B. Zhang
    Signed-off-by: Torstein Hegge
    Signed-off-by: Takashi Iwai

    Torstein Hegge
     

29 Apr, 2013

1 commit


04 Apr, 2013

1 commit


30 Oct, 2012

1 commit

  • Close some races at disconnection of a USB audio device by adding the
    chip->shutdown_mutex and chip->shutdown check at appropriate places.

    The spots to put bandaids are:
    - PCM prepare, hw_params and hw_free
    - where the usb device is accessed for communication or get speed, in
    mixer.c and others; the device speed is now cached in subs->speed
    instead of accessing to chip->dev

    The accesses in PCM open and close don't need the mutex protection
    because these are already handled in the core PCM disconnection code.

    The autosuspend/autoresume codes are still uncovered by this patch
    because of possible mutex deadlocks. They'll be covered by the
    upcoming change to rwsem.

    Also the mixer codes are untouched, too. These will be fixed in
    another patch, too.

    Reported-by: Matthieu CASTET
    Cc:
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

21 Apr, 2012

1 commit


13 Apr, 2012

1 commit


27 Oct, 2010

1 commit

  • There are two USB Audio Class specifications (v1 and v2), but neither of
    them clearly defines the feedback format for high-speed UAC v1 devices.
    Add to this whatever the Creative and M-Audio firmware writers have been
    smoking, and it becomes impossible to predict the exact feedback format
    used by a particular device.

    Therefore, automatically detect the feedback format by looking at the
    magnitude of the first received feedback value.

    Also, this allows us to get rid of some special cases for E-Mu devices.

    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     

14 Aug, 2010

1 commit

  • This is V2 of the patch, after feedback from Clemens and Daniel.

    This patch adds SuperSpeed support to the USB drivers under sound/. It adds
    tests for USB_SPEED_SUPER to the appropriate places that check for the USB
    speed.

    This patch has been tested with our SS USB3 device emulating a set of Yamaha
    speakers and a Logitech microphone, but with the descriptors modified to add
    USB3 support. It has also been tested with the real speakers and microphone,
    to make sure that USB2 devices still work.

    Signed-off-by: Paul Zimmerman
    Cc: Clemens Ladisch
    Cc: Daniel Mack
    Cc: Greg Kroah-Hartman
    Signed-off-by: Takashi Iwai

    Paul Zimmerman
     

05 Mar, 2010

3 commits

  • In preparation for USB audio 2.0 support, change the audioformat
    structure so that it uses a bitmask to specify possible formats.

    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     
  • The snd_usb_substream::format field actually contains the index of the
    current alternate setting, so rename it to altset_idx to avoid
    confusion.

    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     
  • Clean up the usb audio driver by factoring out a lot of functions to
    separate files. Code for procfs, quirks, urbs, format parsers etc all
    got a new home now.

    Moved almost all special quirk handling to quirks.c and introduced new
    generic functions to handle them, so the exceptions do not pollute the
    whole driver.

    Renamed usbaudio.c to card.c because this is what it actually does now.
    Renamed usbmidi.c to midi.c for namespace clarity.
    Removed more things from usbaudio.h.

    The non-standard drivers were adopted accordingly.

    Signed-off-by: Daniel Mack
    Cc: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Daniel Mack