1. 19 Feb, 2024 1 commit
  2. 13 Feb, 2024 7 commits
  3. 12 Feb, 2024 4 commits
  4. 11 Feb, 2024 4 commits
    • Cristian Ciocaltea's avatar
      ASoC: SOF: amd: Fix locking in ACP IRQ handler · c4b603c6
      Cristian Ciocaltea authored
      A recent change in acp_irq_thread() was meant to address a potential race
      condition while trying to acquire the hardware semaphore responsible for
      the synchronization between firmware and host IPC interrupts.
      
      This resulted in an improper use of the IPC spinlock, causing normal
      kernel memory allocations (which may sleep) inside atomic contexts:
      
      1707255557.133976 kernel: BUG: sleeping function called from invalid context at include/linux/sched/mm.h:315
      
      ...
      
      1707255557.134757 kernel:  sof_ipc3_rx_msg+0x70/0x130 [snd_sof]
      1707255557.134793 kernel:  acp_sof_ipc_irq_thread+0x1e0/0x550 [snd_sof_amd_acp]
      1707255557.134855 kernel:  acp_irq_thread+0xa3/0x130 [snd_sof_amd_acp]
      1707255557.134904 kernel:  ? irq_thread+0xb5/0x1e0
      1707255557.134947 kernel:  ? __pfx_irq_thread_fn+0x10/0x10
      1707255557.134985 kernel:  irq_thread_fn+0x23/0x60
      
      Moreover, there are attempts to lock a mutex from the same atomic
      context:
      
      1707255557.136357 kernel: =============================
      1707255557.136393 kernel: [ BUG: Invalid wait context ]
      1707255557.136413 kernel: 6.8.0-rc3-next-20240206-audio-next #9 Tainted: G        W
      1707255557.136432 kernel: -----------------------------
      1707255557.136451 kernel: irq/66-AudioDSP/502 is trying to lock:
      1707255557.136470 kernel: ffff965152f26af8 (&sb->s_type->i_mutex_key#2){+.+.}-{3:3}, at: start_creating.part.0+0x5f/0x180
      
      ...
      
      1707255557.137429 kernel:  start_creating.part.0+0x5f/0x180
      1707255557.137457 kernel:  __debugfs_create_file+0x61/0x210
      1707255557.137475 kernel:  snd_sof_debugfs_io_item+0x75/0xc0 [snd_sof]
      1707255557.137494 kernel:  sof_ipc3_do_rx_work+0x7cf/0x9f0 [snd_sof]
      1707255557.137513 kernel:  sof_ipc3_rx_msg+0xb3/0x130 [snd_sof]
      1707255557.137532 kernel:  acp_sof_ipc_irq_thread+0x1e0/0x550 [snd_sof_amd_acp]
      1707255557.137551 kernel:  acp_irq_thread+0xa3/0x130 [snd_sof_amd_acp]
      
      Fix the issues by reducing the lock scope in acp_irq_thread(), so that
      it guards only the hardware semaphore acquiring attempt.  Additionally,
      restore the initial locking in acp_sof_ipc_irq_thread() to synchronize
      the handling of immediate replies from DSP core.
      
      Fixes: 802134c8 ("ASoC: SOF: amd: Refactor spinlock_irq(&sdev->ipc_lock) sequence in irq_handler")
      Signed-off-by: default avatarCristian Ciocaltea <cristian.ciocaltea@collabora.com>
      Link: https://lore.kernel.org/r/20240208234315.2182048-1-cristian.ciocaltea@collabora.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      c4b603c6
    • Alexey Khoroshilov's avatar
      ASoC: rt5645: Fix deadlock in rt5645_jack_detect_work() · 6ef5d5b9
      Alexey Khoroshilov authored
      There is a path in rt5645_jack_detect_work(), where rt5645->jd_mutex
      is left locked forever. That may lead to deadlock
      when rt5645_jack_detect_work() is called for the second time.
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.
      
      Fixes: cdba4301 ("ASoC: rt5650: add mutex to avoid the jack detection failure")
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Link: https://lore.kernel.org/r/1707645514-21196-1-git-send-email-khoroshilov@ispras.ruSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      6ef5d5b9
    • Hans de Goede's avatar
      ASoC: Intel: cht_bsw_rt5645: Cleanup codec_name handling · 930375d3
      Hans de Goede authored
      4 fixes / cleanups to the rt5645 mc driver's codec_name handling:
      
      1. In the for loop looking for the dai_index for the codec, replace
      card->dai_link[i] with cht_dailink[i]. The for loop already uses
      ARRAY_SIZE(cht_dailink) as bound and card->dai_link is just a pointer to
      cht_dailink using card->dai_link only obfuscates that cht_dailink is being
      modified directly rather then say a copy of cht_dailink. Using
      cht_dailink[i] also makes the code consistent with other machine drivers.
      
      2. Don't set cht_dailink[dai_index].codecs->name in the for loop,
      this immediately gets overridden using acpi_dev_name(adev) directly
      below the loop.
      
      3. Add a missing break to the loop.
      
      4. Remove the now no longer used (only set, never read) codec_name field
      from struct cht_mc_private.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20240210134400.24913-3-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      930375d3
    • Hans de Goede's avatar
      ASoC: Intel: Boards: Fix NULL pointer deref in BYT/CHT boards · 7d99a70b
      Hans de Goede authored
      Since commit 13f58267 ("ASoC: soc.h: don't create dummy Component
      via COMP_DUMMY()") dummy snd_soc_dai_link.codecs entries no longer
      have a name set.
      
      This means that when looking for the codec dai_link the machine
      driver can no longer unconditionally run strcmp() on
      snd_soc_dai_link.codecs[0].name since this may now be NULL.
      
      Add a check for snd_soc_dai_link.codecs[0].name being NULL to all
      BYT/CHT machine drivers to avoid NULL pointer dereferences in
      their probe() methods.
      
      Fixes: 13f58267 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()")
      Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20240210134400.24913-2-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      7d99a70b
  5. 09 Feb, 2024 1 commit
  6. 08 Feb, 2024 2 commits
  7. 07 Feb, 2024 3 commits
  8. 06 Feb, 2024 1 commit
  9. 05 Feb, 2024 4 commits
  10. 01 Feb, 2024 13 commits
    • Mark Brown's avatar
      ALSA: Various fixes for Cirrus Logic CS35L56 support · e81fdba0
      Mark Brown authored
      Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>:
      
      These patches fixe various things that were undocumented, unknown or
      uncertain when the original driver code was written. And also a few
      things that were just bugs.
      e81fdba0
    • Richard Fitzgerald's avatar
      ALSA: hda: cs35l56: Remove unused test stub function · 28876c1a
      Richard Fitzgerald authored
      Remove an unused stub function that calls a non-existant function.
      
      This function was accidentally added as part of commit
      2144833e ("ALSA: hda: cirrus_scodec: Add KUnit test"). It was
      a relic of an earlier version of the test that should have been
      removed.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 2144833e ("ALSA: hda: cirrus_scodec: Add KUnit test")
      Link: https://msgid.link/r/20240129162737.497-19-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      28876c1a
    • Richard Fitzgerald's avatar
      ALSA: hda: cs35l56: Firmware file must match the version of preloaded firmware · 6f8ad048
      Richard Fitzgerald authored
      Check whether the firmware is already patched. If so, include the
      firmware version in the firmware file name.
      
      If the firmware has already been patched by the BIOS the driver
      can only replace it if it has control of hard RESET.
      
      If the driver cannot replace the firmware, it can still load a wmfw
      (for ALSA control definitions) and/or a bin (for additional tunings).
      But these must match the version of firmware that is running on the
      CS35L56.
      
      The firmware is pre-patched if either:
       - FIRMWARE_MISSING == 0, or
       - it is a secured CS35L56 (which implies that is was already patched),
      
      cs35l56_hw_init() will set preloaded_fw_ver to the (non-zero)
      firmware version if either of these conditions is true.
      
      Normal (unpatched or replaceable firmware):
         cs35l56-rev-dsp1-misc[-system_name].[wmfw|bin]
      
      Preloaded firmware:
         cs35l56-rev[-s]-VVVVVV-dsp1-misc[-system_name].[wmfw|bin]
      
      Where:
         [-s] is an optional -s added into the name for a secured CS35L56
         VVVVVV is the 24-bit firmware version in hexadecimal.
      
      Backport note:
      This won't apply to kernel versions older than v6.6.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 73cfbfa9 ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
      Link: https://msgid.link/r/20240129162737.497-18-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      6f8ad048
    • Richard Fitzgerald's avatar
      ALSA: hda: cs35l56: Fix filename string field layout · e82bc517
      Richard Fitzgerald authored
      Change the filename field layout to:
        cs35l56-rev[-s]-dsp1-misc[-sub].[wmfw|bin]
      
      This is to keep the same firmware file naming scheme as the
      CS35L56 ASoC driver.
      
      This is not a compatibility break because no firmware files have
      been published.
      
      The original field layout matched the ASoC driver, but the way the
      ASoC driver used the wm_adsp driver config to form this filename
      was bugged. Fixing the ASoC driver to use the correct wm_adsp config
      strings means that the 's' flag (to indicate a secured part) has to
      move to somewhere after the first '-'.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 73cfbfa9 ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
      Link: https://msgid.link/r/20240129162737.497-17-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      e82bc517
    • Richard Fitzgerald's avatar
      ALSA: hda: cs35l56: Fix order of searching for firmware files · 77c60722
      Richard Fitzgerald authored
      Check for the cases of system-specific bin file without a
      wmfw before falling back to looking for a generic wmfw.
      
      All system-specific options should be tried before falling
      back to loading a generic wmfw/bin. With the original code,
      the presence of a fallback generic wmfw on the filesystem
      would prevent using a system-specific tuning with a ROM
      firmware.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 73cfbfa9 ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
      Link: https://msgid.link/r/20240129162737.497-16-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      77c60722
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Allow more time for firmware to boot · 9e92b77c
      Richard Fitzgerald authored
      The original 50ms timeout for firmware boot is not long enough for
      worst-case time to reboot after a firmware download. Increase the
      timeout to 250ms.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: e4961125 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
      Link: https://msgid.link/r/20240129162737.497-15-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      9e92b77c
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Load tunings for the correct speaker models · 245eeff1
      Richard Fitzgerald authored
      If the "spk-id-gpios" property is present it points to GPIOs whose
      value must be used to select the correct bin file to match the
      speakers.
      
      Some manufacturers use multiple sources of speakers, which need
      different tunings for best performance. On these models the type of
      speaker fitted is indicated by the values of one or more GPIOs. The
      number formed by the GPIOs identifies the tuning required.
      
      The speaker ID must be used in combination with the subsystem ID
      (either from PCI SSID or cirrus,firmware-uid property), because the
      GPIOs can only indicate variants of a specific model.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 1a1c3d79 ("ASoC: cs35l56: Use PCI SSID as the firmware UID")
      Link: https://msgid.link/r/20240129162737.497-14-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      245eeff1
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Firmware file must match the version of preloaded firmware · f4ef5149
      Richard Fitzgerald authored
      Check during initialization whether the firmware is already patched.
      If so, include the firmware version in the wm_adsp fwf_name string.
      
      If the firmware has already been patched by the BIOS the driver
      can only replace it if it has control of hard RESET.
      
      If the driver cannot replace the firmware, it can still load a wmfw
      (for ALSA control definitions) and/or a bin (for additional tunings).
      But these must match the version of firmware that is running on the
      CS35L56.
      
      The firmware is pre-patched if FIRMWARE_MISSING == 0.
      
      Including the firmware version in the fwf_name string will
      qualify the firmware file name:
      
      Normal (unpatched or replaceable firmware):
        cs35l56-rev-dsp1-misc[-system_name].[wmfw|bin]
      
      Preloaded firmware:
        cs35l56-rev[-s]-VVVVVV-dsp1-misc[-system_name].[wmfw|bin]
      
      Where:
         [-s] is an optional -s added into the name for a secured CS35L56
         VVVVVV is the 24-bit firmware version in hexadecimal.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 608f1b0d ("ASoC: cs35l56: Move DSP part string generation so that it is done only once")
      Link: https://msgid.link/r/20240129162737.497-13-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      f4ef5149
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Fix misuse of wm_adsp 'part' string for silicon revision · f6c96794
      Richard Fitzgerald authored
      Put the silicon revision and secured flag in the wm_adsp fwf_name
      string instead of including them in the part string.
      
      This changes the format of the firmware name string from
      
       cs35l56[s]-rev-misc[-system_name]
      
      to
       cs35l56-rev[-s]-misc[-system_name]
      
      No firmware files have been published, so this doesn't cause a
      compatibility break.
      
      Silicon revision and secured flag are included in the firmware
      filename to pick a firmware compatible with the part. These strings
      were being added to the part string, but that is a misuse of the
      string. The correct place for these is the fwf_name string, which
      is specifically intended to select between multiple firmware files
      for the same part.
      
      Backport note:
      This won't apply to kernels older than v6.6.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 608f1b0d ("ASoC: cs35l56: Move DSP part string generation so that it is done only once")
      Link: https://msgid.link/r/20240129162737.497-12-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      f6c96794
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Fix for initializing ASP1 mixer registers · 07f7d6e7
      Richard Fitzgerald authored
      Defer initializing the state of the ASP1 mixer registers until
      the firmware has been downloaded and rebooted.
      
      On a SoundWire system the ASP is free for use as a chip-to-chip
      interconnect. This can be either for the firmware on multiple
      CS35L56 to share reference audio; or as a bridge to another
      device. If it is a firmware interconnect it is owned by the
      firmware and the Linux driver should avoid writing the registers.
      However, if it is a bridge then Linux may take over and handle
      it as a normal codec-to-codec link. Even if the ASP is used
      as a firmware-firmware interconnect it is useful to have
      ALSA controls for the ASP mixer. They are at least useful for
      debugging.
      
      CS35L56 is designed for SDCA and a generic SDCA driver would
      know nothing about these chip-specific registers. So if the
      ASP is being used on a SoundWire system the firmware sets up the
      ASP mixer registers. This means that we can't assume the default
      state of these registers. But we don't know the initial state
      that the firmware set them to until after the firmware has been
      downloaded and booted, which can take several seconds when
      downloading multiple amps.
      
      DAPM normally reads the initial state of mux registers during
      probe() but this would mean blocking probe() for several seconds
      until the firmware has initialized them. To avoid this, the
      mixer muxes are set SND_SOC_NOPM to prevent DAPM trying to read
      the register state. Custom get/set callbacks are implemented for
      ALSA control access, and these can safely block waiting for the
      firmware download.
      
      After the firmware download has completed, the state of the
      mux registers is known so a work job is queued to call
      snd_soc_dapm_mux_update_power() on each of the mux widgets.
      
      Backport note:
      This won't apply cleanly to kernels older than v6.6.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: e4961125 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
      Link: https://msgid.link/r/20240129162737.497-11-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      07f7d6e7
    • Richard Fitzgerald's avatar
      ALSA: hda: cs35l56: Initialize all ASP1 registers · 856ce898
      Richard Fitzgerald authored
      Add ASP1_FRAME_CONTROL1, ASP1_FRAME_CONTROL5 and the ASP1_TX?_INPUT
      registers to the sequence used to initialize the ASP configuration.
      Write this sequence to the cache and directly to the registers to
      ensure that they match.
      
      A system-specific firmware can patch these registers to values that are
      not the silicon default, so that the CS35L56 boots already in the
      configuration used by Windows or by "driverless" Windows setups such
      as factory tuning.
      
      These may not match how Linux is configuring the HDA codec. And anyway
      on Linux the ALSA controls are used to configure routing options.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 73cfbfa9 ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
      Link: https://msgid.link/r/20240129162737.497-10-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      856ce898
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Fix default SDW TX mixer registers · 782e6c53
      Richard Fitzgerald authored
      Patch the SDW TX mixer registers to silicon defaults.
      
      CS35L56 is designed for SDCA and a generic SDCA driver would
      know nothing about these chip-specific registers. So the
      firmware sets up the SDW TX mixer registers to whatever audio
      is relevant on a specific system.
      
      This means that the driver cannot assume the initial values
      of these registers. But Linux has ALSA controls to configure
      routing, so the registers can be patched to silicon default and
      the ALSA controls used to select what audio to feed back to the
      host capture path.
      
      Backport note:
      This won't apply to kernels older than v6.6.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: e4961125 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
      Link: https://msgid.link/r/20240129162737.497-9-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      782e6c53
    • Richard Fitzgerald's avatar
      ASoC: cs35l56: Fix to ensure ASP1 registers match cache · 72a77d76
      Richard Fitzgerald authored
      Add a dummy SUPPLY widget connected to the ASP that forces the
      chip registers to match the regmap cache when the ASP is
      powered-up.
      
      On a SoundWire system the ASP is free for use as a chip-to-chip
      interconnect. This can be either for the firmware on multiple
      CS35L56 to share reference audio; or as a bridge to another
      device. If it is a firmware interconnect it is owned by the
      firmware and the Linux driver should avoid writing the registers.
      However. If it is a bridge then Linux may take over and handle
      it as a normal codec-to-codec link.
      
      CS35L56 is designed for SDCA and a generic SDCA driver would
      know nothing about these chip-specific registers. So if the
      ASP is being used on a SoundWire system the firmware sets up the
      ASP registers. This means that we can't assume the default
      state of the ASP registers. But we don't know the initial state
      that the firmware set them to until after the firmware has been
      downloaded and booted, which can take several seconds when
      downloading multiple amps.
      
      To avoid blocking probe() for several seconds waiting for the
      firmware, the silicon defaults are assumed. This allows the machine
      driver to setup the ASP configuration during probe() without being
      blocked. If the ASP is hooked up and used, the SUPPLY widget
      ensures that the chip registers match what was configured in the
      regmap cache.
      
      If the machine driver does not hook up the ASP, it is assumed that
      it won't call any functions to configure the ASP DAI. Therefore
      the regmap cache will be clean for these registers so a
      regcache_sync() will not overwrite the chip registers. If the
      DAI is not hooked up, the dummy SUPPLY widget will not be
      invoked so it will never force-overwrite the chip registers.
      
      Backport note:
      This won't apply cleanly to kernels older than v6.6.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: e4961125 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
      Link: https://msgid.link/r/20240129162737.497-8-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      72a77d76