03 Nov, 2020

1 commit


12 Oct, 2020

1 commit

  • …e/sound into for-linus

    ASoC: Updates for v5.10

    Not a huge amount going on in the core for ASoC this time but quite a
    lot of driver activity, especially for the Intel platforms:

    - Replacement of the DSP driver for some older x86 systems with a new
    one which was written with closer reference to the DSP firmware so
    should hopefully be more robust and maintainable.
    - A big batch of static checker and other fixes for the rest of the x86
    DSP drivers.
    - Cleanup of the error unwinding code from Morimoto-san, hopefully
    making it more robust.
    - Helpers for parsing auxiluary devices from the device tree from
    Stephan Gerhold.
    - New support for AllWinner A64, Cirrus Logic CS4234, Mediatek MT6359
    Microchip S/PDIF TX and RX controllers, Realtek RT1015P, and Texas
    Instruments J721E, TAS2110, TAS2564 and TAS2764

    Takashi Iwai
     

09 Oct, 2020

1 commit

  • Current hdac_i915 uses a static completion instance to wait
    for i915 driver to complete the component bind.

    This design is not safe if multiple HDA controllers are active and
    communicating with different i915 instances, and can lead to list
    corruption and failed audio driver probe.

    Fix the design by moving completion mechanism to common acomp
    code and remove the related code from hdac_i915.

    Fixes: 7b882fe3e3e8 ("ALSA: hda - handle multiple i915 device instances")
    Co-developed-by: Kai Vehmanen
    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20201006161722.500256-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

06 Oct, 2020

1 commit


25 Sep, 2020

1 commit

  • Drop the kerneldoc markup for connectivity_check() as it's an
    static helper function. Fixes the following make W=1 warning:

    sound/hda/hdac_i915.c:80: warning: Function parameter or member 'i915' not described in 'connectivity_check'
    sound/hda/hdac_i915.c:80: warning: Function parameter or member 'hdac' not described in 'connectivity_check'

    Fixes: 7b882fe3e3e8 ('ALSA: hda - handle multiple i915 device instances')
    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200924161027.3402260-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Kai Vehmanen
     

22 Sep, 2020

1 commit

  • To provide backward compatibility to older systems, the SOF HDA driver
    allows user to specify which HDMI codec driver to use at runtime via
    kernel parameter. This mechanism has a subtle flaw in that it assumes
    the codec drivers not to be loaded when the SOF PCI driver is loaded.

    The problem is rooted in use of the hdev->type field.
    snd_hdac_ext_bus_device_init() initializes this field to HDA_DEV_ASOC.
    This signals the HDA core that ASoC drivers should be considered in
    driver matching (hda_bus_match()). The SOF and SST drivers continue by
    overriding this field to HDA_DEV_LEGACY and proceeding to load driver
    modules with request_module(). Correct drivers will get loaded and
    attached.

    If however the codec drivers are already loaded when
    snd_hdac_ext_bus_device_init() is called, the matching will not work as
    expected as device type is still set to HDA_DEV_ASOC. Specifically if
    hdac-hdmi is attached when machine driver is configured to use hdac-hda,
    this leads to out-of-bounds memory access in
    hda_dsp_hdmi_build_controls().

    Fix the issue by adding codec type as a parameter to
    snd_hdac_ext_bus_device_init() and ensuring type is set correctly from
    the start.

    Fixes: 139c7febad1a ("ASoC: SOF: Intel: add support for snd-hda-codec-hdmi")
    Signed-off-by: Kai Vehmanen
    Reviewed-by: Guennadi Liakhovetski
    Reviewed-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20200921100841.2882662-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Mark Brown

    Kai Vehmanen
     

21 Sep, 2020

2 commits

  • The CONTROLLER_IN_GPU() macro has different semantics than
    the similarly named macro in hda_intel.c. The name is also
    misleading as the macro is used to apply a Intel HSW/BDW
    programming logic for HDA controller clock configuration.
    Rename macro to reflect the actual implementation.

    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200921141741.2983072-5-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Kai Vehmanen
     
  • Currently i915_component_master_match() will return the first matching
    i915 instance. This does not work in case system has multiple i915
    and HDA audio controller instances.

    Add a new connectivity check that handles following cases:
    - i915 and HDA controller on same PCI bus
    - discrete GPU with embedded HDA audio controller connected
    via PCI bridge

    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200921141741.2983072-4-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Kai Vehmanen
     

03 Sep, 2020

2 commits

  • We use HDaudio and HDAudio, pick one to make searches easier.
    No functionality change

    Also fix timestamping typo in documentation.

    Reported-by: Guennadi Liakhovetski
    Signed-off-by: Pierre-Louis Bossart
    Reviewed-by: Bard Liao
    Reviewed-by: Guennadi Liakhovetski
    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200902154250.1440585-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     
  • In snd_hdac_device_init pm_runtime_set_active is called to
    increase child_count in parent device. But when it is failed
    to build connection with GPU for one case that integrated
    graphic gpu is disabled, snd_hdac_ext_bus_device_exit will be
    invoked to clean up a HD-audio extended codec base device. At
    this time the child_count of parent is not decreased, which
    makes parent device can't get suspended.

    This patch calls pm_runtime_set_suspended to decrease child_count
    in parent device in snd_hdac_device_exit to match with
    snd_hdac_device_init. pm_runtime_set_suspended can make sure that
    it will not decrease child_count if the device is already suspended.

    Signed-off-by: Rander Wang
    Reviewed-by: Ranjani Sridharan
    Reviewed-by: Pierre-Louis Bossart
    Reviewed-by: Bard Liao
    Reviewed-by: Guennadi Liakhovetski
    Signed-off-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200902154218.1440441-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai

    Rander Wang
     

19 Aug, 2020

1 commit

  • By default 'sdo_limit' is initialized with a default value of '8'
    as per spec. This is overridden in cases where a different value is
    required. However this is getting reset when snd_hdac_bus_init_chip()
    is called again, which happens during runtime PM cycle.

    Avoid this reset by moving 'sdo_limit' setup to 'snd_hdac_bus_init()'
    function which would be called only once.

    Fixes: 67ae482a59e9 ("ALSA: hda: add member to store ratio for stripe control")
    Cc:
    Signed-off-by: Sameer Pujar
    Link: https://lore.kernel.org/r/1597851130-6765-1-git-send-email-spujar@nvidia.com
    Signed-off-by: Takashi Iwai

    Sameer Pujar
     

05 Aug, 2020

1 commit

  • A variable dma_stop_delay is added as a new member in hdac_bus
    structure to avoid memory decode error incase DMA RUN bit is not
    disabled in the given timeout from snd_hdac_stream_sync function and
    followed by stream reset which results in memory decode error between
    reset set and clear operation.

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

    Mohan Kumar
     

22 Jun, 2020

1 commit


18 Jun, 2020

1 commit

  • We already have two configurations for CometLake, and a third one
    coming. On other platforms, we used a single Kconfig option, so we
    should follow the same trend by merging the two cases in a backwards
    compatible way.

    The backwards compatibility is handled by overloading the COMETLAKE_LP
    kconfig as COMETLAKE. In practice we've never seen a case where
    COMETLAKE_H is not selected along with COMETLAKE_LP, so keeping one
    of the two is enough.

    Signed-off-by: Pierre-Louis Bossart
    Reviewed-by: Guennadi Liakhovetski
    Reviewed-by: Kai Vehmanen
    Link: https://lore.kernel.org/r/20200617164755.18104-2-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Mark Brown

    Pierre-Louis Bossart
     

02 Jun, 2020

1 commit

  • …/sound into for-linus

    ASoC: Updates for v5.8

    This has been another very active release with a bunch of new drivers,
    lots of fixes everywhere and continued core improvements from
    Morimoto-san:

    - Lots of core cleanups and refactorings from Morimoto-san, factoring
    out common operations and making the card abstraction more solid.
    - Continued work on cleaning up and improving the Intel drivers, along
    with some new platform support for them.
    - Fixes to make the Marvell SSPA driver work upstream.
    - Support for AMD Renoir ACP, Dialog DA7212, Freescale EASRC and
    i.MX8M, Intel Elkhard Lake, Maxim MAX98390, Nuvoton NAU8812 and
    NAU8814 and Realtek RT1016.

    Takashi Iwai
     

01 Jun, 2020

1 commit


16 May, 2020

2 commits

  • snd_hdac_bus_queue_event() and snd_hdac_bus_exec_verb() are used only
    internally in HD-audio core. Let's drop the exports and move the
    declarations into local.h.

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

    Takashi Iwai
     
  • The unsol event handling code has a loop retrieving the read/write
    indices and the arrays without locking while the append to the array
    may happen concurrently. This may lead to some inconsistency.
    Although there hasn't been any proof of this bad results, it's still
    safer to protect the racy accesses.

    This patch adds the spinlock protection around the unsol handling loop
    for addressing it. Here we take bus->reg_lock as the writer side
    snd_hdac_bus_queue_event() is also protected by that lock.

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

    Takashi Iwai
     

07 May, 2020

1 commit


05 May, 2020

1 commit


04 May, 2020

1 commit

  • Stripe control programming is governed by following formula, which is
    referenced from the HD Audio specification(Revision 1.0a).
    { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }

    Currently above is implemented in snd_hdac_get_stream_stripe_ctl().
    This patch introduces a structure member to store the default factor
    of '8'. If any HW wants to use a different value, this member can be
    easily updated.

    Signed-off-by: Sameer Pujar
    Link: https://lore.kernel.org/r/1588580176-2801-3-git-send-email-spujar@nvidia.com
    Signed-off-by: Takashi Iwai

    Sameer Pujar
     

02 May, 2020

1 commit


24 Apr, 2020

2 commits

  • Merge NHLT init cleanup.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • NHLT fetch based on _DSM prevents ACPI table override mechanism from
    being utilized. Make use of acpi_get_table to enable it and get rid of
    redundant code. In consequence, NHLT can be overridden just like any
    other ACPI table, e.g.: DSDT or SSDT.

    Change has been verified on all Intel AVS architecture platforms, RVP
    and production laptops both.

    Change possible due to addition of NHLT signature to the list of
    standard ACPI tables:
    https://patchwork.kernel.org/patch/11463235/

    Override helps not only with debug purposes but also allows user for
    table adjustment when one found on their production hardware is invalid.
    Shared official NHLT spec is now available to community at:
    https://01.org/blogs/intel-smart-sound-technology-audio-dsp

    NHLT support for iASL is still ongoing subject but should be available
    in nearest future.

    Signed-off-by: Cezary Rojewski
    Link: https://lore.kernel.org/r/20200423160310.28019-1-cezary.rojewski@intel.com
    Signed-off-by: Takashi Iwai

    Cezary Rojewski
     

14 Apr, 2020

1 commit

  • The commit c31427d0d21e ("ALSA: hda: No preallocation on x86
    platforms") changed CONFIG_SND_HDA_PREALLOC_SIZE setup and its default
    to zero for x86, as the preallocation should work almost all cases.
    However, this expectation was too naive; some applications try to
    allocate as the max buffer size as possible, and it leads to the
    memory exhaustion. More badly, the commit changed the kconfig no
    longer adjustable for x86, so you can't fix it statically (although it
    can be still adjusted via procfs).

    So, practically seen, it's more recommended to set a reasonable limit
    for x86, too. This patch follows to that experience, and changes the
    default to 2048 and allow the kconfig adjustable again.

    Fixes: c31427d0d21e ("ALSA: hda: No preallocation on x86 platforms")
    Cc:
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207223
    Link: https://lore.kernel.org/r/20200413201919.24241-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

11 Apr, 2020

1 commit

  • When an ACPI companion device is present and the SoundWire link mask
    information is available, use SoundWire instead of legacy HDA or
    Skylake drivers.

    The SOF driver is selected when SoundWire or DMIC are detected. There
    is no precedence at this level. In the SOF driver proper, SoundWire
    will be handled first since it is mutually exclusive with HDaudio.

    Known devices with an existing DMI quirk bypass this detection to
    avoid any dependency on ACPI/DSDT tables.

    Reviewed-by: Ranjani Sridharan
    Reviewed-by: Guennadi Liakhovetski
    Reviewed-by: Bard Liao
    Reviewed-by: Kai Vehmanen
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20200409190251.16569-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     

13 Mar, 2020

1 commit

  • snd_hdac_codec_modalias() truncates the string to the given size and
    returns its size, but it returned a wrong size from snprintf().
    snprintf() returns the would-be-output size, not the actual size.
    Use scnprintf() instead to return the correct size.

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

    Takashi Iwai
     

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

1 commit