1. 12 6月, 2017 2 次提交
  2. 09 6月, 2017 14 次提交
  3. 07 6月, 2017 7 次提交
    • T
      ALSA: pcm: obsolete RULES_DEBUG local macro · c6706de0
      Takashi Sakamoto 提交于
      Added tracepoints obsoleted RULES_DEBUG local macro and relevant codes.
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      c6706de0
    • T
      ALSA: pcm: enable parameter tracepoints only when CONFIG_SND_DEBUG is enabled · 37567c55
      Takashi Sakamoto 提交于
      In a previous commit, tracepoints are added for PCM parameter processing.
      As long as I know, this implementation increases size of relocatable
      object by 35%. For vendors who are conscious of memory footprint, it
      brings apparent disadvantage.
      
      This commit utilizes CONFIG_SND_DEBUG configuration to enable/disable the
      tracepoints.
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      37567c55
    • T
      ALSA: pcm: tracepoints for refining PCM parameters · be4e31da
      Takashi Sakamoto 提交于
      When working for devices which support configurable modes for its data
      transmission or which consists of several components, developers are
      likely to use rules of parameters of PCM substream. However, there's no
      infrastructure to assist their work.
      
      In old days, ALSA PCM core got a local 'RULES_DEBUG' macro to debug
      refinement of parameters for PCM substream. Although this is merely a
      makeshift. With some modifications, we get the infrastructure.
      
      This commit is for the purpose. Refinement of mask/interval type of
      PCM parameters is probed as tracepoint events as 'hw_mask_param' and
      'hw_interval_param' on existent 'snd_pcm' subsystem.
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      be4e31da
    • T
      ALSA: timer: Wrap with spinlock for queue access · d7f910bf
      Takashi Iwai 提交于
      For accessing the snd_timer_user queue indices, we take tu->qlock.
      But it's forgotten in a couple of places.
      
      The one in snd_timer_user_params() should be safe without the
      spinlock as the timer is already stopped.  But it's better for
      consistency.
      
      The one in poll is just a read-out, so it's not inevitably needed, but
      it'd be good to make the result consistent, too.
      Tested-by: NAlexander Potapenko <glider@google.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      d7f910bf
    • T
      ALSA: timer: Improve user queue reallocation · 890e2cb5
      Takashi Iwai 提交于
      ALSA timer may reallocate the user queue upon request, and it happens
      at three places for now: at opening, at SNDRV_TIMER_IOCTL_PARAMS, and
      at SNDRV_TIMER_IOCTL_SELECT.  However, the last one,
      snd_timer_user_tselect(), doesn't need to reallocate the buffer since
      it doesn't change the queue size.  It does just because tu->tread
      might have been changed before starting the timer.
      
      Instead of *_SELECT ioctl, we should reallocate the queue at
      SNDRV_TIMER_IOCTL_TREAD; then the timer is guaranteed to be stopped,
      thus we can reassign the buffer more safely.
      
      This patch implements that with a slight code refactoring.
      Essentially, the patch achieves:
      - Introduce realloc_user_queue() for (re-)allocating the ring buffer,
        and call it from all places.  Also, realloc_user_queue() uses
        kcalloc() for avoiding possible leaks.
      - Add the buffer reallocation at SNDRV_TIMER_IOCTL_TREAD.  When it
        fails, tu->tread is restored to the old value, too.
      - Drop the buffer reallocation at snd_timer_user_tselect().
      Tested-by: NAlexander Potapenko <glider@google.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      890e2cb5
    • T
      ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT · ba3021b2
      Takashi Iwai 提交于
      snd_timer_user_tselect() reallocates the queue buffer dynamically, but
      it forgot to reset its indices.  Since the read may happen
      concurrently with ioctl and snd_timer_user_tselect() allocates the
      buffer via kmalloc(), this may lead to the leak of uninitialized
      kernel-space data, as spotted via KMSAN:
      
        BUG: KMSAN: use of unitialized memory in snd_timer_user_read+0x6c4/0xa10
        CPU: 0 PID: 1037 Comm: probe Not tainted 4.11.0-rc5+ #2739
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:16
         dump_stack+0x143/0x1b0 lib/dump_stack.c:52
         kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:1007
         kmsan_check_memory+0xc2/0x140 mm/kmsan/kmsan.c:1086
         copy_to_user ./arch/x86/include/asm/uaccess.h:725
         snd_timer_user_read+0x6c4/0xa10 sound/core/timer.c:2004
         do_loop_readv_writev fs/read_write.c:716
         __do_readv_writev+0x94c/0x1380 fs/read_write.c:864
         do_readv_writev fs/read_write.c:894
         vfs_readv fs/read_write.c:908
         do_readv+0x52a/0x5d0 fs/read_write.c:934
         SYSC_readv+0xb6/0xd0 fs/read_write.c:1021
         SyS_readv+0x87/0xb0 fs/read_write.c:1018
      
      This patch adds the missing reset of queue indices.  Together with the
      previous fix for the ioctl/read race, we cover the whole problem.
      Reported-by: NAlexander Potapenko <glider@google.com>
      Tested-by: NAlexander Potapenko <glider@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      ba3021b2
    • T
      ALSA: timer: Fix race between read and ioctl · d11662f4
      Takashi Iwai 提交于
      The read from ALSA timer device, the function snd_timer_user_tread(),
      may access to an uninitialized struct snd_timer_user fields when the
      read is concurrently performed while the ioctl like
      snd_timer_user_tselect() is invoked.  We have already fixed the races
      among ioctls via a mutex, but we seem to have forgotten the race
      between read vs ioctl.
      
      This patch simply applies (more exactly extends the already applied
      range of) tu->ioctl_lock in snd_timer_user_tread() for closing the
      race window.
      Reported-by: NAlexander Potapenko <glider@google.com>
      Tested-by: NAlexander Potapenko <glider@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      d11662f4
  4. 03 6月, 2017 11 次提交
  5. 31 5月, 2017 1 次提交
  6. 30 5月, 2017 1 次提交
    • B
      ALSA: declare snd_kcontrol_new structures as const · 905e46ac
      Bhumika Goyal 提交于
      Declare snd_kcontrol_new structures as const as they are only passed an
      argument to the function snd_ctl_new1. This argument is of type const,
      so snd_kcontrol_new structures having this property can be made const.
      Done using Coccinelle:
      
      @r disable optional_qualifier@
      identifier x;
      position p;
      @@
      static struct snd_kcontrol_new x@p={...};
      
      @ok@
      identifier r.x;
      position p;
      @@
      snd_ctl_new1(&x@p,...)
      
      @bad@
      position p != {r.p,ok.p};
      identifier r.x;
      @@
      x@p
      
      @depends on !bad disable optional_qualifier@
      identifier r.x;
      @@
      +const
      struct snd_kcontrol_new x;
      
      Cross compiled these files:
      sound/aoa/codecs/tas.c - powerpc
      sound/mips/{hal2.c/sgio2audio.c} - mips
      sound/ppc/{awacs.c/beep.c/tumbler.c} - powerpc
      sound/soc/sh/siu_dai.c - sh
      Could not find an architecture to compile sound/sh/aica.c.
      Signed-off-by: NBhumika Goyal <bhumirks@gmail.com>
      Acked-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      905e46ac
  7. 26 5月, 2017 2 次提交
    • T
      ALSA: pcm: add local header file for snd-pcm module · 2c4842d3
      Takashi Sakamoto 提交于
      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: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      2c4842d3
    • T
      ALSA: pcm: Call ack() whenever appl_ptr is updated · 9027c463
      Takashi Iwai 提交于
      Although the ack callback is supposed to be called at each appl_ptr or
      hw_ptr update, we missed a few opportunities: namely, forward, rewind
      and sync_ptr.
      
      Formerly calling ack at rewind may have leaded to unexpected results
      due to the forgotten negative appl_ptr update in indirect-PCM helper,
      which is the major user of the PCM ack callback.  But now we fixed
      this oversights, thus we can call ack callback safely even at rewind
      callback -- of course with the proper handling of the error from the
      callback.
      
      This patch adds the calls of ack callback in the places mentioned in
      the above.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      9027c463
  8. 24 5月, 2017 1 次提交
  9. 23 5月, 2017 1 次提交
    • T
      ALSA: info: Use kvzalloc() for a temporary write buffer · ffb73b08
      Takashi Iwai 提交于
      We used to use kmalloc (more exactly, krealloc()) for creating and
      growing the temporary buffer for text proc write.  It can grow up to
      16kB, and it's already a bit doubtful whether it's always safe to use
      kmalloc().  With the recent addition of kvmalloc(), we can have a
      better chance for succeed of memory allocation, so let's switch to
      that new API.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      ffb73b08