1. 04 Mar, 2024 1 commit
    • Kenny Levinsen's avatar
      ALSA: usb-audio: Name feature ctl using output if input is PCM · 1601cd53
      Kenny Levinsen authored
      When building feature controls from a unit without a name, we try to
      derive a name first from the feature unit's input, then fall back to the
      output terminal.
      
      If a feature unit connects directly to a "USB Streaming" input terminal
      rather than a mixer or other virtual type, the control receives the
      somewhat meaningless name "PCM", even if the output had a descriptive
      type such as "Headset" or "Speaker".
      
      Here is an example of such AudioControl descriptor from a USB headset
      which ends up named "PCM Playback" and is therefore not recognized as
      headphones by userspace:
      
            AudioControl Interface Descriptor:
              bLength                12
              bDescriptorType        36
              bDescriptorSubtype      2 (INPUT_TERMINAL)
              bTerminalID             4
              wTerminalType      0x0101 USB Streaming
              bAssocTerminal          5
              bNrChannels             2
              wChannelConfig     0x0003
                Left Front (L)
                Right Front (R)
              iChannelNames           0
              iTerminal               0
            AudioControl Interface Descriptor:
              bLength                 9
              bDescriptorType        36
              bDescriptorSubtype      3 (OUTPUT_TERMINAL)
              bTerminalID             5
              wTerminalType      0x0402 Headset
              bAssocTerminal          4
              bSourceID               6
              iTerminal               0
            AudioControl Interface Descriptor:
              bLength                13
              bDescriptorType        36
              bDescriptorSubtype      6 (FEATURE_UNIT)
              bUnitID                 6
              bSourceID               4
              bControlSize            2
              bmaControls(0)     0x0002
                Volume Control
              bmaControls(1)     0x0000
              bmaControls(2)     0x0000
              iFeature                0
      
      Other headsets and DACs I tried that used their output terminal for
      naming only did so due to their input being an unnamed sidetone mixer.
      
      Instead of always starting with the input terminal, check the type of it
      first. If it seems uninteresting, invert the order and use the output
      terminal first for naming.
      
      This makes userspace recognize headsets with simple controls as
      headphones, and leads to more consistent naming of playback devices
      based on their outputs irrespective of sidetone mixers.
      Signed-off-by: default avatarKenny Levinsen <kl@kl.wtf>
      Link: https://lore.kernel.org/r/20240301231107.42679-1-kl@kl.wtfSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      1601cd53
  2. 01 Mar, 2024 1 commit
    • Nathan Chancellor's avatar
      ALSA: hwdep: Move put_user() call out of scoped_guard() in snd_hwdep_control_ioctl() · 72165c86
      Nathan Chancellor authored
      Clang prior to 17.0.0 has a bug in its asm goto jump scope analysis to
      determine that no variables with the cleanup attribute are skipped by an
      indirect jump. Instead of only checking the scope of each label that is
      a possible target of each asm goto statement, it checks the scope of
      every label, which can cause an error when a variable with the cleanup
      attribute is used between two asm goto statements with different scopes,
      even if they have completely different label targets:
      
        sound/core/hwdep.c:273:8: error: cannot jump from this asm goto statement to one of its possible targets
                                if (get_user(device, (int __user *)arg))
                                    ^
        arch/powerpc/include/asm/uaccess.h:295:5: note: expanded from macro 'get_user'
                          __get_user(x, _gu_addr) :                             \
                          ^
        arch/powerpc/include/asm/uaccess.h:283:2: note: expanded from macro '__get_user'
                __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err);      \
                ^
        arch/powerpc/include/asm/uaccess.h:199:3: note: expanded from macro '__get_user_size_allowed'
                        __get_user_size_goto(x, ptr, size, __gus_failed);       \
                        ^
        arch/powerpc/include/asm/uaccess.h:187:10: note: expanded from macro '__get_user_size_goto'
                case 1: __get_user_asm_goto(x, (u8 __user *)ptr, label, "lbz"); break;  \
                        ^
        arch/powerpc/include/asm/uaccess.h:158:2: note: expanded from macro '__get_user_asm_goto'
                asm_volatile_goto(                                      \
                ^
        include/linux/compiler_types.h:366:33: note: expanded from macro 'asm_volatile_goto'
        #define asm_volatile_goto(x...) asm goto(x)
                                        ^
        sound/core/hwdep.c:291:9: note: possible target of asm goto statement
                                        if (put_user(device, (int __user *)arg))
                                            ^
        arch/powerpc/include/asm/uaccess.h:66:5: note: expanded from macro 'put_user'
                          __put_user(x, _pu_addr) : -EFAULT;                    \
                          ^
        arch/powerpc/include/asm/uaccess.h:52:9: note: expanded from macro '__put_user'
                                                                        \
                                                                        ^
        sound/core/hwdep.c:276:4: note: jump bypasses initialization of variable with __attribute__((cleanup))
                                scoped_guard(mutex, &register_mutex) {
                                ^
        include/linux/cleanup.h:169:20: note: expanded from macro 'scoped_guard'
                for (CLASS(_name, scope)(args),                                 \
      
      To avoid this issue, move the put_user() call out of the scoped_guard()
      scope, which allows the asm goto scope analysis to see that the variable
      with the cleanup attribute will never be skipped by the asm goto
      statements.
      
      There should be no functional change because prior to the refactoring,
      put_user() was not called under register_mutex, so this call does not
      even need to be in the scoped_guard() in the first place.
      
      Fixes: e6684d08 ("ALSA: hwdep: Use guard() for locking")
      Closes: https://github.com/ClangBuiltLinux/linux/issues/2003Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Link: https://lore.kernel.org/r/20240301-fix-snd-hwdep-guard-v1-1-6aab033f3f83@kernel.orgSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      72165c86
  3. 28 Feb, 2024 25 commits
  4. 23 Feb, 2024 12 commits
  5. 22 Feb, 2024 1 commit