18 Feb, 2020

2 commits


10 Feb, 2020

1 commit

  • snd_hdac_ext_bus_link_get() does not work correctly in case
    there are multiple codecs on the bus. It unconditionally
    resets the bus->codec_mask value. As per documentation in
    hdaudio.h and existing use in client code, this field should
    be used to store bit flag of detected codecs on the bus.

    By overwriting value of the codec_mask, information on all
    detected codecs is lost. No current user of hdac is impacted,
    but use of bus->codec_mask is planned in future patches
    for SOF.

    Signed-off-by: Kai Vehmanen
    Reviewed-by: Ranjani Sridharan
    Reviewed-by: Pierre-Louis Bossart
    Reviewed-by: Takashi Iwai
    Link: https://lore.kernel.org/r/20200206200223.7715-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Mark Brown

    Kai Vehmanen
     

28 Jan, 2020

1 commit

  • Tegra HDA has FIFO size which can hold upto 10 audio frames to support
    DVFS. When HDA DMA RUN bit is set to 0 to stop the stream, the DMA RUN
    bit will be cleared to 0 only after transferring all the remaining audio
    frames queued up in the fifo. This is not in sync with spec which states
    the controller will stop transmitting(output) in the beginning of the
    next frame for the relevant stream.

    The above behavior with Tegra HDA was resulting in machine check error
    during the system suspend flow with active audio playback with below kernel
    error logs.
    [ 33.524583] mc-err: [mcerr] (hda) csr_hdar: EMEM address decode error
    [ 33.531088] mc-err: [mcerr] status = 0x20000015; addr = 0x00000000
    [ 33.537431] mc-err: [mcerr] secure: no, access-type: read, SMMU fault: none

    This was due to the fifo has more than one audio frame when the DMA
    RUN bit is set to 0 during system suspend flow and the timeout handling in
    snd_hdac_stream_sync() was not designed to handle this scenario. So the
    DMA will continue running even after timeout hit until all remaining
    audio frames in the fifo are transferred, but the suspend flow will try
    to reset the controller and turn off the hda clocks without the knowledge
    of the DMA is still running and could result in mc-err.

    The above issue can be resolved by doing stream reset with the help of
    snd_hdac_stream_reset() which would ensure the DMA RUN bit is cleared
    if the timeout was hit in snd_hdac_stream_sync().

    Signed-off-by: Mohan Kumar
    Link: https://lore.kernel.org/r/20200128051508.26064-1-mkumard@nvidia.com
    Signed-off-by: Takashi Iwai

    Mohan Kumar
     

21 Jan, 2020

1 commit

  • Like many other drivers, HD-audio drivers also do PCM buffer
    preallocation to assure the buffer pages allocated at the early boot
    stage. This step is useful for platforms that may fail to allocate
    the PCM hardware buffers -- which is mostly for either large
    continuous pages or with the specific DMA mask (like emu10k1).

    OTOH, when a buffer is allocated as SG-buffer and the DMA mask is
    either 32 or 64 bits, the allocation almost never fails unless it hits
    the real OOM situation. In such a case, we don't need the
    preallocation inevitably unlike the cases above.

    That said, we may drop the preallocation for HD-audio that does
    allocate via SG-buffers, and the patch achieves it.

    However, there is one caveat: the buffer allocation behavior depends
    on CONFIG_SND_DMA_SGBUF, and it falls back to the continuous pages
    when it's not set. And, currently this SG buffer allocation is
    enabled only on x86 platforms. So, covering those fall-outs, the
    patch adjusts CONFIG_SND_HDA_PREALLOC_SIZE depending on the condition,
    and keeps the old behavior as-is for non-x86 platforms.

    On x86, the kconfig item is no longer adjustable but always set to
    zero for disabling the preallocation. You can still enable the
    preallocation via procfs interface at any time later, too.

    Link: https://lore.kernel.org/r/20200120124423.11862-2-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

14 Jan, 2020

1 commit


13 Jan, 2020

1 commit

  • In the commit 8e85def5723e ("ALSA: hda: enable regmap internal
    locking"), we re-enabled the regmap lock due to the reported
    regression that showed the possible concurrent accesses. It was a
    temporary workaround, and there are still a few opened races even
    after the revert. In this patch, we cover those still opened windows
    with a proper mutex lock and disable the regmap internal lock again.

    First off, the patch introduces a new snd_hdac_device.regmap_lock
    mutex that is applied for each snd_hdac_regmap_*() call, including
    read, write and update helpers. The mutex is applied carefully so
    that it won't block the self-power-up procedure in the helper
    function. Also, this assures the protection for the accesses without
    regmap, too.

    The snd_hdac_regmap_update_raw() is refactored to use the standard
    regmap_update_bits_check() function instead of the open-code. The
    non-regmap case is still open-coded but it's an easy part. The all
    read and write operations are in the single mutex protection, so it's
    now race-free.

    In addition, a couple of new helper functions are added:
    snd_hdac_regmap_update_raw_once() and snd_hdac_regmap_sync(). Both
    are called from HD-audio legacy driver. The former is to initialize
    the given verb bits but only once when it's not initialized yet. Due
    to this condition, the function invokes regcache_cache_only(), and
    it's now performed inside the regmap_lock (formerly it was racy) too.
    The latter function is for simply invoking regcache_sync() inside the
    regmap_lock, which is called from the codec resume call path.
    Along with that, the HD-audio codec driver code is slightly modified /
    simplified to adapt those new functions.

    And finally, snd_hdac_regmap_read_raw(), *_write_raw(), etc are
    rewritten with the helper macro. It's just for simplification because
    the code logic is identical among all those functions.

    Tested-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200109090104.26073-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

11 Jan, 2020

1 commit


09 Jan, 2020

1 commit

  • This reverts commit 42ec336f1f9d ("ALSA: hda: Disable regmap
    internal locking").

    Without regmap locking, there is a race between snd_hda_codec_amp_init()
    and PM callbacks issuing regcache_sync(). This was caught by
    following kernel warning trace:

    [358.080081] WARNING: CPU: 2 PID: 4157 at drivers/base/regmap/regcache.c:498 regcache_cache_only+0xf5/0x130
    [...]
    [358.080148] Call Trace:
    [358.080158] snd_hda_codec_amp_init+0x4e/0x100 [snd_hda_codec]
    [358.080169] snd_hda_codec_amp_init_stereo+0x40/0x80 [snd_hda_codec]

    Suggested-by: Takashi Iwai
    BugLink: https://gitlab.freedesktop.org/drm/intel/issues/592
    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200108180856.5194-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Kai Vehmanen
     

08 Jan, 2020

1 commit


05 Jan, 2020

1 commit

  • Apply const prefix to the remaining possible places: the string
    tables, the rate tables, the verb tables, the index tables, etc.

    Just for minor optimization and no functional changes.

    Link: https://lore.kernel.org/r/20200105144823.29547-10-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

19 Dec, 2019

1 commit


15 Dec, 2019

2 commits

  • The call of snd_hdac_bus_update_rirb() needs the bus->reg_lock
    spinlock protection for concurrency. Comment about it more
    explicitly.

    Link: https://lore.kernel.org/r/20191213163005.19116-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • The commit e38e486d66e2 ("ALSA: hda: Modify stream stripe mask only
    when needed") tried to address the regression by the unconditional
    application of the stripe mask, but this caused yet another
    regression for the previously working devices. Namely, the patch
    clears the azx_dev->stripe flag at snd_hdac_stream_clear(), but this
    may be called multiple times before restarting the stream, so this
    ended up with clearance of the flag for the whole time.

    This patch fixes the regression by moving the azx_dev->stripe flag
    clearance at the counter-part, the close callback of HDMI codec
    driver instead.

    Fixes: e38e486d66e2 ("ALSA: hda: Modify stream stripe mask only when needed")
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205855
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204477
    Cc:
    Link: https://lore.kernel.org/r/20191214175217.31852-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

13 Dec, 2019

2 commits

  • Now most of the get_response handling became quite similar between
    HDA-core and legacy drivers, and the only differences are:

    - the handling of extra-long polling delay for some codecs
    - the debug message for the stalled communication

    and both are worth to share in the common code.

    This patch unifies the code into snd_hdac_bus_get_response(), and use
    this from the legacy get_response callback. It results in a good
    amount of code reduction in the end.

    Reviewed-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20191212191101.19517-3-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • This patch implements the same logic that was done for the legacy
    HD-audio controller driver by the commit 88452da92ba2 ("ALSA: hda: Use
    standard waitqueue for RIRB wakeup") to the HDA-core helper code,
    too. This makes snd_hdac_bus_get_response() waiting for the response
    with bus->rirb_wq instead of polling when bus->polling is false.
    It'll save both CPU time and response latency.

    Reviewed-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20191212191101.19517-2-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

11 Dec, 2019

1 commit

  • The HD-audio CORB/RIRB communication was programmed in a way that was
    documented in the reference in decades ago, which is essentially a
    polling in the waiter side. It's working fine but costs CPU cycles on
    some platforms that support only slow communications. Also, for some
    platforms that had unreliable communications, we put longer wait time
    (2 ms), which accumulate quite long time if you execute many verbs in
    a shot (e.g. at the initialization or resume phase).

    This patch attempts to improve the situation by introducing the
    standard waitqueue in the RIRB waiter side instead of polling. The
    test results on my machine show significant improvements. The time
    spent for "cat /proc/asound/card*/codec#*" were changed like:

    * Intel SKL + Realtek codec
    before the patch:
    0.00user 0.04system 0:00.10elapsed 40.0%CPU
    after the patch:
    0.00user 0.01system 0:00.10elapsed 10.0%CPU

    * Nvidia GP107GL + Nvidia HDMI codec
    before the patch:
    0.00user 0.00system 0:02.76elapsed 0.0%CPU
    after the patch:
    0.00user 0.00system 0:00.01elapsed 17.0%CPU

    So, for Intel chips, the total time is same, while the total time is
    greatly reduced (from 2.76 to 0.01s) for Nvidia chips.
    The only negative data here is the increase of CPU time for Nvidia,
    but this is the unavoidable cost for faster wakeups, supposedly.

    Link: https://lore.kernel.org/r/20191210145727.22054-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

03 Dec, 2019

1 commit

  • The recent commit in HD-audio stream management for changing the
    stripe control seems causing a regression on some platforms. The
    stripe control is currently used only by HDMI codec, and applying the
    stripe mask unconditionally may lead to scratchy and static noises as
    seen on some MacBooks.

    For addressing the regression, this patch changes the stream
    management code to apply the stripe mask conditionally only when the
    codec driver requested.

    Fixes: 9b6f7e7a296e ("ALSA: hda: program stripe bits for controller")
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204477
    Tested-by: Michael Pobega
    Cc:
    Link: https://lore.kernel.org/r/20191202074947.1617-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

05 Nov, 2019

1 commit

  • Since we apply the own mutex (bus->cmd_mutex) in HDA core side, the
    internal locking in regmap is superfluous. This patch adds the flag
    to indicate that.

    Also, an infamous side-effect by this change is that it disables the
    regmap debugfs, too, and this is seen rather good; the regmap debugfs
    isn't quite useful for HD-audio as it provides the very sparse
    registers and its debugfs access tends to lead to the way too high
    resource usages or sometimes hang up. So it'd be rather safe to
    disable it altogether.

    Link: https://lore.kernel.org/r/2029139028.10333037.1572874551626.JavaMail.zimbra@redhat.com
    Link: https://lore.kernel.org/r/20191105081806.4896-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

28 Oct, 2019

3 commits

  • The recent addition of snd_intel_dsp_driver_probe() check caused a
    spurious kernel warning when the driver is loaded for a non-Intel
    hardware due to snd_BUG_ON(). Moreover, for such a hardware, we
    should always return SND_INTEL_DSP_DRIVER_ANY, not check the
    dsp_driver option at all.

    This patch fixes these issues for non-Intel devices.

    Fixes: 82d9d54a6c0e ("ALSA: hda: add Intel DSP configuration / probe code")
    Signed-off-by: Takashi Iwai
    Link: https://lore.kernel.org/r/20191028130634.3501-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Back-merge the development process for catching up the HD-audio fix
    (and apply a new one on top of that).

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • This reverts commit caa8422d01e983782548648e125fd617cadcec3f.

    It turned out that this commit caused a regression at shutdown /
    reboot, as the synchronize_irq() calls seems blocking the whole
    shutdown. Also another part of the change about shuffling the call
    order looks suspicious; the azx_stop_chip() call disables the CORB /
    RIRB while the others may still need the CORB/RIRB update.

    Since the original commit itself was a cargo-fix, let's revert the
    whole patch.

    Fixes: caa8422d01e9 ("ALSA: hda: Flush interrupts on disabling")
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205333
    BugLinK: https://bugs.freedesktop.org/show_bug.cgi?id=111174
    Signed-off-by: Takashi Iwai
    Cc: Chris Wilson
    Link: https://lore.kernel.org/r/20191028081056.22010-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

23 Oct, 2019

2 commits

  • Reshuffle list of devices by historical order and add correct
    information as needed.

    Signed-off-by: Pierre-Louis Bossart
    Signed-off-by: Jaroslav Kysela
    Link: https://lore.kernel.org/r/20191022174313.29087-2-perex@perex.cz
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     
  • For distributions, we need one place where we can decide
    which driver will be activated for the auto-configation of the
    Intel's HDA hardware with DSP. Actually, we cover three drivers:

    * Legacy HDA
    * Intel SST
    * Intel Sound Open Firmware (SOF)

    All those drivers registers similar PCI IDs, so the first
    driver probed from the PCI stack can win. But... it is not
    guaranteed that the correct driver wins.

    This commit changes Intel's NHLT ACPI module to a common
    DSP probe module for the Intel's hardware. All above sound
    drivers calls this code. The user can force another behaviour
    using the module parameter 'dsp_driver' located in
    the 'snd-intel-dspcfg' module.

    This change allows to add specific dmi checks for the specific
    systems. The examples are taken from the pull request:

    https://github.com/thesofproject/linux/pull/927

    Tested on Lenovo Carbon X1 7th gen.

    Signed-off-by: Jaroslav Kysela
    Tested-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20191022174313.29087-1-perex@perex.cz
    Signed-off-by: Takashi Iwai

    Jaroslav Kysela
     

07 Oct, 2019

1 commit

  • Fix potential DMA hang upon starting playback on devices in HDA mode
    on Intel platforms (Gemini Lake/Whiskey Lake/Comet Lake/Ice Lake). It
    doesn't affect platforms before Gemini Lake or any Intel device in
    non-HDA mode.

    The reset value for the LOSDIV register is all output streams valid.
    Clear this register to invalidate non-existent streams when the bus
    is powered up.

    Signed-off-by: Rander Wang
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190930142945.7805-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Takashi Iwai

    Rander Wang
     

16 Aug, 2019

1 commit

  • This reverts commit ee5f85d9290f ("ALSA: hda: Add codec on bus address
    table lately"). The commit caused several regression since I've
    overlooked that the function doesn't manage only the caddr_tbl but
    also the codec linked list that is referred indirectly in the other
    drivers.

    Revert for now to make everything back to work.

    Fixes: ee5f85d9290f ("ALSA: hda: Add codec on bus address table lately")
    Reported-by: Chris Wilson
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

15 Aug, 2019

3 commits

  • Drop EXPORT_SYMBOL*() from a few more stuff in HD-audio core that
    aren't used outside. Particular the unsol event handler can be
    staticized now because the recent change removed all external
    callers.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • snd_hdac_bus_add_device() and snd_hdac_remove_device() are called only
    internally in hda-core. Let's drop the exports of them and move the
    declarations into local.h.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • The call of snd_hdac_bus_add_device() is needed only for registering
    the codec onto the bus caddr_tbl[] that is referred essentially only
    in the unsol event handler. That is, the reason of this call and the
    release by the counter-part function snd_hdac_bus_remove_device() is
    just to assure that the unsol event gets notified to the codec.

    But the current implementation of the unsol notification wouldn't work
    properly when the codec is still in a premature init state. So this
    patch tries to work around it by delaying the caddr_tbl[] registration
    at the point of snd_hdac_device_register().

    Also, the order of snd_hdac_bus_remove_device() and device_del() calls
    are shuffled to make sure that the unsol event is masked before
    deleting the device.

    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204565
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

13 Aug, 2019

1 commit

  • Currently we set hdac_stream.fifo_size field only for the playback
    stream by some odd reason I forgot, while this field isn't referred in
    any places. Actually this fifo_size field would have been required in
    the position report correction for VIA chipset, but due to the lack of
    the fifo_size set for capture streams, snd-hda-intel driver fetches
    the register by itself.

    This patch straightens and simplifies the code by setting the
    fifo_size field for both playback and capture streams, and use it in
    the HD-audio controller driver.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

09 Aug, 2019

3 commits


08 Aug, 2019

2 commits

  • HD-audio drivers access to the mmio registers indirectly via the
    corresponding bus->io_ops callbacks. This is because some platform
    (notably Tegra SoC) requires the word-aligned access. But it's rather
    a rare case, and other platforms suffer from the penalties by indirect
    calls unnecessarily.

    This patch is an attempt to optimize and cleanup for this situation.
    Now the special aligned access is used only when a new kconfig
    CONFIG_SND_HDA_ALIGNED_MMIO is set. And the HD-audio core itself
    provides the aligned MMIO access helpers instead of the driver side.
    If Kconfig isn't set (as default), the standard helpers like readl()
    or writel() are used directly.

    A couple of places in ASoC Intel drivers have the access via io_ops
    reg_writel(), and they are replaced with the direct writel() calls.

    And now with this patch, the whole bus->io_ops becomes empty, so it's
    dropped completely. The bus initialization functions are changed
    accordingly as well to drop the whole bus->io_ops.

    Reviewed-by: Pierre-Louis Bossart
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • The HD-audio core allocates and releases pages via driver's specific
    dma_alloc_pages and dma_free_pages ops defined in bus->io_ops. This
    was because some platforms require the uncached pages and the handling
    of page flags had to be done locally in the driver code.

    Since the recent change in ALSA core memory allocator, we can simply
    pass SNDRV_DMA_TYPE_DEV_UC for the uncached pages, and the only
    difference became about this type to be passed to the core allocator.
    That is, it's good time for cleaning up the mess.

    This patch changes the allocation code in HD-audio core to call the
    core allocator directly so that we get rid of dma_alloc_pages and
    dma_free_pages io_ops. If a driver needs the uncached pages, it has
    to set bus->dma_type right after the bus initialization.

    This is merely a code refactoring and shouldn't bring any behavior
    changes.

    Reviewed-by: Pierre-Louis Bossart
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

06 Aug, 2019

1 commit


31 Jul, 2019

3 commits


27 Jul, 2019

1 commit

  • Distribution installation images such as Debian include different sets
    of modules which can be downloaded dynamically. Such images may notably
    include the hda sound modules but not the i915 DRM module, even if the
    latter was enabled at build time, as reported on
    https://bugs.debian.org/931507

    In such a case hdac_i915 would be linked in and try to load the i915
    module, fail since it is not there, but still wait for a whole minute
    before giving up binding with it.

    This fixes such as case by only waiting for the binding if the module
    was properly loaded (or module support is disabled, in which case i915
    is already compiled-in anyway).

    Fixes: f9b54e1961c7 ("ALSA: hda/i915: Allow delayed i915 audio component binding")
    Signed-off-by: Samuel Thibault
    Cc:
    Signed-off-by: Takashi Iwai

    Samuel Thibault