1. 04 7月, 2016 1 次提交
    • T
      ALSA: timer: Fix negative queue usage by racy accesses · 3fa6993f
      Takashi Iwai 提交于
      The user timer tu->qused counter may go to a negative value when
      multiple concurrent reads are performed since both the check and the
      decrement of tu->qused are done in two individual locked contexts.
      This results in bogus read outs, and the endless loop in the
      user-space side.
      
      The fix is to move the decrement of the tu->qused counter into the
      same spinlock context as the zero-check of the counter.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      3fa6993f
  2. 10 5月, 2016 1 次提交
    • T
      ALSA: pcm: Bail out when chmap is already present · 8d879be8
      Takashi Iwai 提交于
      When snd_pcm_add_chmap_ctls() is called to the PCM stream to which a
      chmap has been already assigned, it returns as an error due to the
      conflicting snd_ctl_add() result.  However, this also clears the
      already assigned chmap_kctl field via pcm_chmap_ctl_private_free(),
      and becomes inconsistent in the later operation.
      
      This patch adds the check of the conflicting chmap kctl before
      actually trying to allocate / assign.  The check failure is treated as
      a kernel warning, as the double call of snd_pcm_add_chmap_ctls() is
      basically a driver bug and having the stack trace would help
      developers to figure out the bad code path.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      8d879be8
  3. 09 5月, 2016 5 次提交
  4. 08 5月, 2016 3 次提交
  5. 28 4月, 2016 1 次提交
    • M
      ASoC: dmaengine_pcm: Add support for packed transfers · 73fe01cf
      Matthias Reichl 提交于
      dmaengine_pcm currently only supports setups where FIFO reads/writes
      correspond to exactly one sample, eg 16-bit sample data is transferred
      via 16-bit FIFO accesses, 32-bit data via 32-bit accesses.
      
      This patch adds support for setups with fixed width FIFOs where
      multiple samples are packed into a larger word.
      
      For example setups with a 32-bit wide FIFO register that expect
      16-bit sample transfers to be done with the left+right sample data
      packed into a 32-bit word.
      
      Support for packed transfers is controlled via the
      SND_DMAENGINE_PCM_DAI_FLAG_PACK flag in snd_dmaengine_dai_dma_data.flags
      
      If this flag is set dmaengine_pcm doesn't put any restriction on the
      supported formats and sets the DMA transfer width to undefined.
      
      This means control over the constraints is now transferred to the DAI
      driver and it's responsible to provide proper configuration and
      check for possible corner cases that aren't handled by the ALSA core.
      Signed-off-by: NMatthias Reichl <hias@horus.com>
      Acked-by: NLars-Peter Clausen <lars@metafoo.de>
      Tested-by: NMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      73fe01cf
  6. 26 4月, 2016 1 次提交
    • T
      ALSA: hrtimer: Handle start/stop more properly · d2c5cf88
      Takashi Iwai 提交于
      This patch tries to address the still remaining issues in ALSA hrtimer
      driver:
      - Spurious use-after-free was detected in hrtimer callback
      - Incorrect rescheduling due to delayed start
      - WARN_ON() is triggered in hrtimer_forward() invoked in hrtimer
        callback
      
      The first issue happens only when the new timer is scheduled even
      while hrtimer is being closed.  It's related with the second and third
      items; since ALSA timer core invokes hw.start callback during hrtimer
      interrupt, this may result in the explicit call of hrtimer_start().
      
      Also, the similar problem is seen for the stop; ALSA timer core
      invokes hw.stop callback even in the hrtimer handler, too.  Since we
      must not call the synced hrtimer_cancel() in such a context, it's just
      a hrtimer_try_to_cancel() call that doesn't properly work.
      
      Another culprit of the second and third items is the call of
      hrtimer_forward_now() before snd_timer_interrupt().  The timer->stick
      value may change during snd_timer_interrupt() call, but this
      possibility is ignored completely.
      
      For covering these subtle and messy issues, the following changes have
      been done in this patch:
      - A new flag, in_callback, is introduced in the private data to
        indicate that the hrtimer handler is being processed.
      - Both start and stop callbacks skip when called from (during)
        in_callback flag.
      - The hrtimer handler returns properly HRTIMER_RESTART and NORESTART
        depending on the running state now.
      - The hrtimer handler reprograms the expiry properly after
        snd_timer_interrupt() call, instead of before.
      - The close callback clears running flag and sets in_callback flag
        to block any further start/stop calls.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      d2c5cf88
  7. 25 4月, 2016 1 次提交
  8. 15 4月, 2016 1 次提交
    • T
      ALSA: pcm : Call kill_fasync() in stream lock · 3aa02cb6
      Takashi Iwai 提交于
      Currently kill_fasync() is called outside the stream lock in
      snd_pcm_period_elapsed().  This is potentially racy, since the stream
      may get released even during the irq handler is running.  Although
      snd_pcm_release_substream() calls snd_pcm_drop(), this doesn't
      guarantee that the irq handler finishes, thus the kill_fasync() call
      outside the stream spin lock may be invoked after the substream is
      detached, as recently reported by KASAN.
      
      As a quick workaround, move kill_fasync() call inside the stream
      lock.  The fasync is rarely used interface, so this shouldn't have a
      big impact from the performance POV.
      
      Ideally, we should implement some sync mechanism for the proper finish
      of stream and irq handler.  But this oneliner should suffice for most
      cases, so far.
      Reported-by: NBaozeng Ding <sploving1@gmail.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      3aa02cb6
  9. 07 4月, 2016 2 次提交
  10. 01 4月, 2016 1 次提交
    • T
      ALSA: timer: Use mod_timer() for rearming the system timer · 4a07083e
      Takashi Iwai 提交于
      ALSA system timer backend stops the timer via del_timer() without sync
      and leaves del_timer_sync() at the close instead.  This is because of
      the restriction by the design of ALSA timer: namely, the stop callback
      may be called from the timer handler, and calling the sync shall lead
      to a hangup.  However, this also triggers a kernel BUG() when the
      timer is rearmed immediately after stopping without sync:
       kernel BUG at kernel/time/timer.c:966!
       Call Trace:
        <IRQ>
        [<ffffffff8239c94e>] snd_timer_s_start+0x13e/0x1a0
        [<ffffffff8239e1f4>] snd_timer_interrupt+0x504/0xec0
        [<ffffffff8122fca0>] ? debug_check_no_locks_freed+0x290/0x290
        [<ffffffff8239ec64>] snd_timer_s_function+0xb4/0x120
        [<ffffffff81296b72>] call_timer_fn+0x162/0x520
        [<ffffffff81296add>] ? call_timer_fn+0xcd/0x520
        [<ffffffff8239ebb0>] ? snd_timer_interrupt+0xec0/0xec0
        ....
      
      It's the place where add_timer() checks the pending timer.  It's clear
      that this may happen after the immediate restart without sync in our
      cases.
      
      So, the workaround here is just to use mod_timer() instead of
      add_timer().  This looks like a band-aid fix, but it's a right move,
      as snd_timer_interrupt() takes care of the continuous rearm of timer.
      Reported-by: NJiri Slaby <jslaby@suse.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      4a07083e
  11. 23 3月, 2016 1 次提交
  12. 17 3月, 2016 1 次提交
  13. 11 3月, 2016 1 次提交
    • T
      ALSA: pcm: Avoid "BUG:" string for warnings again · 0ab1ace8
      Takashi Iwai 提交于
      The commit [d507941b: ALSA: pcm: Correct PCM BUG error message]
      made the warning prefix back to "BUG:" due to its previous wrong
      prefix.  But a kernel message containing "BUG:" seems taken as an Oops
      message wrongly by some brain-dead daemons, and it annoys users in the
      end.  Instead of teaching daemons, change the string again to a more
      reasonable one.
      
      Fixes: 507941beb1e ('ALSA: pcm: Correct PCM BUG error message')
      Cc: <stable@vger.kernel.org> # v3.19+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      0ab1ace8
  14. 08 3月, 2016 1 次提交
  15. 05 3月, 2016 3 次提交
  16. 04 3月, 2016 1 次提交
  17. 02 3月, 2016 1 次提交
  18. 29 2月, 2016 6 次提交
    • T
      ALSA: timer: Fix ioctls for X32 ABI · b24e7ad1
      Takashi Iwai 提交于
      X32 ABI takes the 64bit timespec, thus the timer user status ioctl becomes
      incompatible with IA32.  This results in NOTTY error when the ioctl is
      issued.
      
      Meanwhile, this struct in X32 is essentially identical with the one in
      X86-64, so we can just bypassing to the existing code for this
      specific compat ioctl.
      
      Cc: <stable@vger.kernel.org> # v3.4+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      b24e7ad1
    • T
      ALSA: timer: Fix broken compat timer user status ioctl · 3a72494a
      Takashi Iwai 提交于
      The timer user status compat ioctl returned the bogus struct used for
      64bit architectures instead of the 32bit one.  This patch addresses
      it to return the proper struct.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      3a72494a
    • T
      ALSA: rawmidi: Fix ioctls X32 ABI · 2251fbbc
      Takashi Iwai 提交于
      Like the previous fixes for ctl and PCM, we need a fix for
      incompatible X32 ABI regarding the rawmidi: namely, struct
      snd_rawmidi_status has the timespec, and the size and the alignment on
      X32 differ from IA32.
      
      This patch fixes the incompatible ioctl for X32.
      
      Cc: <stable@vger.kernel.org> # v3.4+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      2251fbbc
    • T
      ALSA: rawmidi: Use comapt_put_timespec() · dd7e3f80
      Takashi Iwai 提交于
      Instead of open-coding, use the existing helper to copy a 32bit
      timespec from/to 64bit.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      dd7e3f80
    • T
      ALSA: pcm: Fix ioctls for X32 ABI · 513ace79
      Takashi Iwai 提交于
      X32 ABI uses the 64bit timespec in addition to 64bit alignment of
      64bit values.  This leads to incompatibilities in some PCM ioctls
      involved with snd_pcm_channel_info, snd_pcm_status and
      snd_pcm_sync_ptr structs.  Fix the PCM compat ABI for these ioctls
      like the previous commit for ctl API.
      Reported-by: NSteven Newbury <steve@snewbury.org.uk>
      Cc: <stable@vger.kernel.org> # v3.4+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      513ace79
    • T
      ALSA: ctl: Fix ioctls for X32 ABI · 6236d8bb
      Takashi Iwai 提交于
      The X32 ABI takes the same alignment like x86-64, and this may result
      in the incompatible struct size from ia32.  Unfortunately, we hit this
      in some control ABI: struct snd_ctl_elem_value differs between them
      due to the position of 64bit variable array.  This ends up with the
      unknown ioctl (ENOTTY) error.
      
      The fix is to add the compat entries for the new aligned struct.
      Reported-and-tested-by: NSteven Newbury <steve@snewbury.org.uk>
      Cc: <stable@vger.kernel.org> # v3.4+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      6236d8bb
  19. 23 2月, 2016 1 次提交
    • T
      ALSA: jack: Allow building the jack layer without input device · fe0d128c
      Takashi Iwai 提交于
      Since the recent integration of kctl jack and input jack layers, we
      can basically build the jack layer even without input devices.  That
      is, the jack layer itself can be built with conditional to enable the
      input device support or not, while the users may enable always
      CONFIG_SND_JACK unconditionally.
      
      For achieving it, this patch changes the following:
      - A new Kconfig, CONFIG_SND_JACK_INPUT_DEV, was introduced to indicate
        whether the jack layer supports the input device,
      - A few items in snd_jack struct and relevant codes are conditionally
        built upon CONFIG_SND_JACK_INPUT_DEV,
      - The users of CONFIG_SND_JACK drop the messy dependency on
        CONFIG_INPUT.
      
      This change also automagically fixes a potential bug in HD-audio
      driver Arnd reported, where the NULL or uninitialized jack instance is
      dereferenced.
      Reported-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      fe0d128c
  20. 18 2月, 2016 1 次提交
    • T
      ALSA: pcm: Fix rwsem deadlock for non-atomic PCM stream · 67ec1072
      Takashi Iwai 提交于
      A non-atomic PCM stream may take snd_pcm_link_rwsem rw semaphore twice
      in the same code path, e.g. one in snd_pcm_action_nonatomic() and
      another in snd_pcm_stream_lock().  Usually this is OK, but when a
      write lock is issued between these two read locks, the problem
      happens: the write lock is blocked due to the first reade lock, and
      the second read lock is also blocked by the write lock.  This
      eventually deadlocks.
      
      The reason is the way rwsem manages waiters; it's queued like FIFO, so
      even if the writer itself doesn't take the lock yet, it blocks all the
      waiters (including reads) queued after it.
      
      As a workaround, in this patch, we replace the standard down_write()
      with an spinning loop.  This is far from optimal, but it's good
      enough, as the spinning time is supposed to be relatively short for
      normal PCM operations, and the code paths requiring the write lock
      aren't called so often.
      Reported-by: NVinod Koul <vinod.koul@intel.com>
      Tested-by: NRamesh Babu <ramesh.babu@intel.com>
      Cc: <stable@vger.kernel.org> # v3.18+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      67ec1072
  21. 16 2月, 2016 1 次提交
  22. 15 2月, 2016 1 次提交
  23. 12 2月, 2016 1 次提交
    • T
      ALSA: timer: Call notifier in the same spinlock · f65e0d29
      Takashi Iwai 提交于
      snd_timer_notify1() is called outside the spinlock and it retakes the
      lock after the unlock.  This is rather racy, and it's safer to move
      snd_timer_notify() call inside the main spinlock.
      
      The patch also contains a slight refactoring / cleanup of the code.
      Now all start/stop/continue/pause look more symmetric and a bit better
      readable.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      f65e0d29
  24. 10 2月, 2016 1 次提交
  25. 09 2月, 2016 2 次提交