1. 16 8月, 2019 2 次提交
    • T
      ALSA: hda - Workaround for crackled sound on AMD controller (1022:1457) · af9d64f8
      Takashi Iwai 提交于
      commit c02f77d32d2c45cfb1b2bb99eabd8a78f5ecc7db upstream.
      
      A long-time problem on the recent AMD chip (X370, X470, B450, etc with
      PCI ID 1022:1457) with Realtek codecs is the crackled or distorted
      sound for capture streams, as well as occasional playback hiccups.
      After lengthy debugging sessions, the workarounds we've found are like
      the following:
      
      - Set up the proper driver caps for this controller, similar as the
        other AMD controller.
      
      - Correct the DMA position reporting with the fixed FIFO size, which
        is similar like as workaround used for VIA chip set.
      
      - Even after the position correction, PulseAudio still shows
        mysterious stalls of playback streams when a capture is triggered in
        timer-scheduled mode.  Since we have no clear way to eliminate the
        stall, pass the BATCH PCM flag for PA to suppress the tsched mode as
        a temporary workaround.
      
      This patch implements the workarounds.  For the driver caps, it
      defines a new preset, AXZ_DCAPS_PRESET_AMD_SB.  It enables the FIFO-
      corrected position reporting (corresponding to the new position_fix=6)
      and enforces the SNDRV_PCM_INFO_BATCH flag.
      
      Note that the current implementation is merely a workaround.
      Hopefully we'll find a better alternative in future, especially about
      removing the BATCH flag hack again.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=195303
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af9d64f8
    • T
      ALSA: hda - Don't override global PCM hw info flag · 06f0bcac
      Takashi Iwai 提交于
      commit c1c6c877b0c79fd7e05c931435aa42211eaeebaf upstream.
      
      The commit bfcba288 ("ALSA - hda: Add support for link audio time
      reporting") introduced the conditional PCM hw info setup, but it
      overwrites the global azx_pcm_hw object.  This will cause a problem if
      any other HD-audio controller, as it'll inherit the same bit flag
      although another controller doesn't support that feature.
      
      Fix the bug by setting the PCM hw info flag locally.
      
      Fixes: bfcba288 ("ALSA - hda: Add support for link audio time reporting")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06f0bcac
  2. 01 6月, 2018 1 次提交
    • B
      ALSA: hda - Handle kzalloc() failure in snd_hda_attach_pcm_stream() · a3aa60d5
      Bo Chen 提交于
      When 'kzalloc()' fails in 'snd_hda_attach_pcm_stream()', a new pcm instance is
      created without setting its operators via 'snd_pcm_set_ops()'. Following
      operations on the new pcm instance can trigger kernel null pointer dereferences
      and cause kernel oops.
      
      This bug was found with my work on building a gray-box fault-injection tool for
      linux-kernel-module binaries. A kernel null pointer dereference was confirmed
      from line 'substream->ops->open()' in function 'snd_pcm_open_substream()' in
      file 'sound/core/pcm_native.c'.
      
      This patch fixes the bug by calling 'snd_device_free()' in the error handling
      path of 'kzalloc()', which removes the new pcm instance from the snd card before
      returns with an error code.
      Signed-off-by: NBo Chen <chenbo@pdx.edu>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      a3aa60d5
  3. 28 6月, 2017 2 次提交
    • T
      ALSA: hda - Skip card registration when no codec is found · 17890880
      Takashi Iwai 提交于
      It's nonsense to register a card object when no codec is bound on it,
      as we don't support the deferred codec binding.  Instead of
      registering an empty card object, just skip the registration by
      returning an error from azx_codec_configure().
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      17890880
    • T
      ALSA: hda - Fix endless loop of codec configure · d94815f9
      Takashi Iwai 提交于
      azx_codec_configure() loops over the codecs found on the given
      controller via a linked list.  The code used to work in the past, but
      in the current version, this may lead to an endless loop when a codec
      binding returns an error.
      
      The culprit is that the snd_hda_codec_configure() unregisters the
      device upon error, and this eventually deletes the given codec object
      from the bus.  Since the list is initialized via list_del_init(), the
      next object points to the same device itself.  This behavior change
      was introduced at splitting the HD-audio code code, and forgotten to
      adapt it here.
      
      For fixing this bug, just use a *_safe() version of list iteration.
      
      Fixes: d068ebc2 ("ALSA: hda - Move some codes up to hdac_bus struct")
      Reported-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      d94815f9
  4. 15 1月, 2017 1 次提交
    • T
      ALSA: hda - Make single_cmd option to stop the fallback mechanism · 41438f13
      Takashi Iwai 提交于
      HD-audio driver has a mechanism to fall back to the single cmd mode as
      a last resort if the CORB/RIRB communication goes wrong even after
      switching to the polling mode.  The switching has worked in the past
      well, but Enrico Mioso reported that his system crashes when this
      happens.
      
      Although the actual cause of the crash isn't still fully analyzed yet,
      it'd be in anyway good to provide an option to turn off the fallback
      mode.  Now this patch extends the behavior of the existing single_cmd
      option for that.  Namely,
      
      - The option is changed from bool to bint.
      - As default, it is the mode allowing the fallback to single cmd.
      - Once when either true/false value is given to the option, the driver
        explicitly turns on/off the single cmd mode, but without the
        fallback.
      
      That is, if you want to disable the fallback, just pass single_cmd=0
      option.  Passing single_cmd=1 will keep working like before.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      41438f13
  5. 02 9月, 2016 1 次提交
    • J
      ALSA: constify snd_pcm_ops structures · 6769e988
      Julia Lawall 提交于
      Check for snd_pcm_ops structures that are only stored in the ops field of a
      snd_soc_platform_driver structure or passed as the third argument to
      snd_pcm_set_ops.  The corresponding field or parameter is declared const,
      so snd_pcm_ops structures that have this property can be declared as const
      also.
      
      The semantic patch that makes this change is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @r disable optional_qualifier@
      identifier i;
      position p;
      @@
      static struct snd_pcm_ops i@p = { ... };
      
      @ok1@
      identifier r.i;
      struct snd_soc_platform_driver e;
      position p;
      @@
      e.ops = &i@p;
      
      @ok2@
      identifier r.i;
      expression e1, e2;
      position p;
      @@
      snd_pcm_set_ops(e1, e2, &i@p)
      
      @bad@
      position p != {r.p,ok1.p,ok2.p};
      identifier r.i;
      struct snd_pcm_ops e;
      @@
      e@i@p
      
      @depends on !bad disable optional_qualifier@
      identifier r.i;
      @@
      static
      +const
       struct snd_pcm_ops i = { ... };
      // </smpl>
      Signed-off-by: NJulia Lawall <Julia.Lawall@lip6.fr>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      6769e988
  6. 09 8月, 2016 2 次提交
  7. 26 2月, 2016 1 次提交
    • T
      ALSA: hda - Loop interrupt handling until really cleared · 473f4145
      Takashi Iwai 提交于
      Currently the interrupt handler of HD-audio driver assumes that no irq
      update is needed while processing the irq.  But in reality, it has
      been confirmed that the HW irq is issued even during the irq
      handling.  Since we clear the irq status at the beginning, process the
      interrupt, then exits from the handler, the lately issued interrupt is
      left untouched without being properly processed.
      
      This patch changes the interrupt handler code to loop over the
      check-and-process.  The handler tries repeatedly as long as the IRQ
      status are turned on, and either stream or CORB/RIRB is handled.
      
      For checking the stream handling, snd_hdac_bus_handle_stream_irq()
      returns a value indicating the stream indices bits.  Other than that,
      the change is only in the irq handler itself.
      Reported-by: NLibin Yang <libin.yang@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      473f4145
  8. 17 12月, 2015 2 次提交
  9. 15 12月, 2015 1 次提交
  10. 03 11月, 2015 1 次提交
    • T
      ALSA: hda - Fix lost 4k BDL boundary workaround · de1ab6af
      Takashi Iwai 提交于
      During the migration to HDA core code, we lost the workaround for 4k
      BDL boundary.  The flag exists in the new hdac_bus, but it's never
      set.  This resulted in the sudden sound stall on some controllers that
      require this workaround like Creative Recon3D.
      
      This patch fixes the issue by setting the flag for such controllers
      properly.
      
      Fixes: ccc98865 ('ALSA: hda - Migrate more hdac_stream codes')
      Cc: <stable@vger.kernel.org> # v4.2+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      de1ab6af
  11. 18 10月, 2015 1 次提交
    • T
      ALSA: hda - Fix bogus codec address check for mixer name assignment · 2f0eaad9
      Takashi Iwai 提交于
      The recent commit [7fbe824a: ALSA: hda - Update mixer name for the
      lower codec address] tried to improve the mixer chip name assignment
      in the order of codec address.  However, this fix was utterly bogus;
      it checks the field set in each codec, thus this value is reset at
      each codec creation, of course.  For really handling this priority,
      the assignment has to be remembered in the common place, namely in
      hda_bus, instead of hda_codec.
      
      Fixes: 7fbe824a ('ALSA: hda - Update mixer name for the lower codec address')
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      2f0eaad9
  12. 18 5月, 2015 1 次提交
  13. 29 4月, 2015 1 次提交
  14. 18 4月, 2015 1 次提交
  15. 17 4月, 2015 2 次提交
  16. 16 4月, 2015 9 次提交
  17. 14 4月, 2015 1 次提交
  18. 23 3月, 2015 1 次提交
    • T
      ALSA: hda - Move some codes up to hdac_bus struct · d068ebc2
      Takashi Iwai 提交于
      A few basic codes for communicating over HD-audio bus are moved to
      struct hdac_bus now.  It has only command and get_response ops in
      addition to the unsolicited event handling.
      
      Note that the codec-side tracing support is disabled temporarily
      during this transition due to the code shuffling.  It will be
      re-enabled later once when all pieces are settled down.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      d068ebc2
  19. 13 3月, 2015 1 次提交
  20. 09 3月, 2015 1 次提交
    • T
      ALSA: hda - Fix regression of HD-audio controller fallback modes · a1f3f1ca
      Takashi Iwai 提交于
      The commit [63e51fd7: ALSA: hda - Don't take unresponsive D3
      transition too serious] introduced a conditional fallback behavior to
      the HD-audio controller depending on the flag set.  However, it
      introduced a silly bug, too, that the flag was evaluated in a reverse
      way.  This resulted in a regression of HD-audio controller driver
      where it can't go to the fallback mode at communication errors.
      
      Unfortunately (or fortunately?) this didn't come up until recently
      because the affected code path is an error handling that happens only
      on an unstable hardware chip.  Most of recent chips work stably, thus
      they didn't hit this problem.  Now, we've got a regression report with
      a VIA chip, and this seems indeed requiring the fallback to the
      polling mode, and finally the bug was revealed.
      
      The fix is a oneliner to remove the wrong logical NOT in the check.
      (Lesson learned - be careful about double negation.)
      
      The bug should be backported to stable, but the patch won't be
      applicable to 3.13 or earlier because of the code splits.  The stable
      fix patches for earlier kernels will be posted later manually.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=94021
      Fixes: 63e51fd7 ('ALSA: hda - Don't take unresponsive D3 transition too serious')
      Cc: <stable@vger.kernel.org> # v3.14+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      a1f3f1ca
  21. 03 3月, 2015 4 次提交
  22. 26 2月, 2015 3 次提交
    • T
      ALSA: hda - Clear pcm pointer assigned to hda_pcm at device removal · 820cc6cf
      Takashi Iwai 提交于
      We leave the pcm field of struct hda_pcm at removal of each device, so
      far.  This hasn't been a problem since unbinding the codec driver
      isn't supposed to happen and another route via snd_hda_codec_reset()
      clears all the once.  However, for a proper unbind implementation, we
      need to care about it.
      
      This patch does the thing above properly:
      
      - Include struct hda_pcm pointer instead of struct hda_pcm_stream
        pointers in struct azx_dev.  This allows us to point the hda_pcm
        object at dev_free callback.
      
      - Introduce to_hda_pcm_stream() macro for better readability.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      820cc6cf
    • T
      ALSA: hda - Replace bus pm_notify with the standard runtime PM framework · 55ed9cd1
      Takashi Iwai 提交于
      Now the final bit of runtime PM cleanup: instead of manual
      notification of the power up/down of the codec via hda_bus pm_notify
      ops, use the standard runtime PM feature.
      
      The child codec device will kick off the runtime PM of the parent
      (PCI) device upon suspend/resume automatically.  For managing whether
      the link can be really turned off, we use the bit flags
      bus->codec_powered instead of the earlier bus->power_keep_link_on.
      flag.  Each codec driver is responsible to set/clear the bit flag, and
      the controller device can be turned off only when all these bits are
      cleared.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      55ed9cd1
    • T
      ALSA: hda - Drop power_save value indirection in hda_bus · bb573928
      Takashi Iwai 提交于
      We used to pass the power_save option value to hda_bus via a given
      pointer.  This was needed to refer to the value from the HD-audio core
      side.  However, after the transition to the runtime PM, this is no
      longer needed.
      
      This patch drops the power_save value indirection in hda_bus above,
      and let the controller driver reprograms the autosuspend value
      explicitly by a new helper, snd_hda_set_power_save().  Without this
      call, the HD-audio core doesn't set up the autosuspend and flip the
      runtime PM.  (User may still be able to set up via sysfs, though.)
      
      Along with this change, the pointer argument of azx_bus_create() is
      dropped as well.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      bb573928