1. 23 May, 2023 2 commits
    • Maxim Kochetkov's avatar
      ASoC: dwc: move DMA init to snd_soc_dai_driver probe() · 011a8719
      Maxim Kochetkov authored
      When using DMA mode we are facing with Oops:
      [  396.458157] Unable to handle kernel access to user memory without uaccess routines at virtual address 000000000000000c
      [  396.469374] Oops [#1]
      [  396.471839] Modules linked in:
      [  396.475144] CPU: 0 PID: 114 Comm: arecord Not tainted 6.0.0-00164-g9a8eccdaf2be-dirty #68
      [  396.483619] Hardware name: YMP ELCT FPGA (DT)
      [  396.488156] epc : dmaengine_pcm_open+0x1d2/0x342
      [  396.493227]  ra : dmaengine_pcm_open+0x1d2/0x342
      [  396.498140] epc : ffffffff807fe346 ra : ffffffff807fe346 sp : ffffffc804e138f0
      [  396.505602]  gp : ffffffff817bf730 tp : ffffffd8042c8ac0 t0 : 6500000000000000
      [  396.513045]  t1 : 0000000000000064 t2 : 656e69676e65616d s0 : ffffffc804e13990
      [  396.520477]  s1 : ffffffd801b86a18 a0 : 0000000000000026 a1 : ffffffff816920f8
      [  396.527897]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 0000000000000000
      [  396.535319]  a5 : 0000000000000000 a6 : ffffffd801b87040 a7 : 0000000000000038
      [  396.542740]  s2 : ffffffd801b94a00 s3 : 0000000000000000 s4 : ffffffd80427f5e8
      [  396.550153]  s5 : ffffffd80427f5e8 s6 : ffffffd801b44410 s7 : fffffffffffffff5
      [  396.557569]  s8 : 0000000000000800 s9 : 0000000000000001 s10: ffffffff8066d254
      [  396.564978]  s11: ffffffd8059cf768 t3 : ffffffff817d5577 t4 : ffffffff817d5577
      [  396.572391]  t5 : ffffffff817d5578 t6 : ffffffc804e136e8
      [  396.577876] status: 0000000200000120 badaddr: 000000000000000c cause: 000000000000000d
      [  396.586007] [<ffffffff806839f4>] snd_soc_component_open+0x1a/0x68
      [  396.592439] [<ffffffff807fdd62>] __soc_pcm_open+0xf0/0x502
      [  396.598217] [<ffffffff80685d86>] soc_pcm_open+0x2e/0x4e
      [  396.603741] [<ffffffff8066cea4>] snd_pcm_open_substream+0x442/0x68e
      [  396.610313] [<ffffffff8066d1ea>] snd_pcm_open+0xfa/0x212
      [  396.615868] [<ffffffff8066d39c>] snd_pcm_capture_open+0x3a/0x60
      [  396.622048] [<ffffffff8065b35a>] snd_open+0xa8/0x17a
      [  396.627421] [<ffffffff801ae036>] chrdev_open+0xa0/0x218
      [  396.632893] [<ffffffff801a5a28>] do_dentry_open+0x17c/0x2a6
      [  396.638713] [<ffffffff801a6d9a>] vfs_open+0x1e/0x26
      [  396.643850] [<ffffffff801b8544>] path_openat+0x96e/0xc96
      [  396.649518] [<ffffffff801b9390>] do_filp_open+0x7c/0xf6
      [  396.655034] [<ffffffff801a6ff2>] do_sys_openat2+0x8a/0x11e
      [  396.660765] [<ffffffff801a735a>] sys_openat+0x50/0x7c
      [  396.666068] [<ffffffff80003aca>] ret_from_syscall+0x0/0x2
      [  396.674964] ---[ end trace 0000000000000000 ]---
      
      It happens because of play_dma_data/capture_dma_data pointers are NULL.
      Current implementation assigns these pointers at snd_soc_dai_driver
      startup() callback and reset them back to NULL at shutdown(). But
      soc_pcm_open() sequence uses DMA pointers in dmaengine_pcm_open()
      before snd_soc_dai_driver startup().
      Most generic DMA capable I2S drivers use snd_soc_dai_driver probe()
      callback to init DMA pointers only once at probe. So move DMA init
      to dw_i2s_dai_probe and drop shutdown() and startup() callbacks.
      Signed-off-by: default avatarMaxim Kochetkov <fido_max@inbox.ru>
      Link: https://lore.kernel.org/r/20230512110343.66664-1-fido_max@inbox.ruSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      011a8719
    • Stefan Binding's avatar
  2. 22 May, 2023 9 commits
  3. 18 May, 2023 1 commit
    • Ranjani Sridharan's avatar
      ASoC: soc-pcm: test if a BE can be prepared · e123036b
      Ranjani Sridharan authored
      In the BE hw_params configuration, the existing code checks if any of the
      existing FEs are prepared, running, paused or suspended - and skips the
      configuration in those cases. This allows multiple calls of hw_params
      which the ALSA state machine supports.
      
      This check is not handled for the prepare stage, which can lead to the
      same BE being prepared multiple times. This patch adds a check similar to
      that of the hw_params, with the main difference being that the suspended
      state is allowed: the ALSA state machine allows a transition from
      suspended to prepared with hw_params skipped.
      
      This problem was detected on Intel IPC4/SoundWire devices, where the BE
      dailink .prepare stage is used to configure the SoundWire stream with a
      bank switch. Multiple .prepare calls lead to conflicts with the .trigger
      operation with IPC4 configurations. This problem was not detected earlier
      on Intel devices, HDaudio BE dailinks detect that the link is already
      prepared and skip the configuration, and for IPC3 devices there is no BE
      trigger.
      
      Link: https://github.com/thesofproject/sof/issues/7596
      Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Link: https://lore.kernel.org/r/20230517185731.487124-1-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      e123036b
  4. 17 May, 2023 2 commits
    • Matthias Kaehlcke's avatar
      ASoC: rt5682: Disable jack detection interrupt during suspend · 8b271370
      Matthias Kaehlcke authored
      The rt5682 driver switches its regmap to cache-only when the
      device suspends and back to regular mode on resume. When the
      jack detect interrupt fires rt5682_irq() schedules the jack
      detect work. This can result in invalid reads from the regmap
      in cache-only mode if the work runs before the device has
      resumed:
      
      [   56.245502] rt5682 9-001a: ASoC: error at soc_component_read_no_lock on rt5682.9-001a for register: [0x000000f0] -16
      
      Disable the jack detection interrupt during suspend and
      re-enable it on resume. The driver already schedules the
      jack detection work on resume, so any state change during
      suspend is still handled.
      
      This is essentially the same as commit f7d00a9b ("SoC:
      rt5682s: Disable jack detection interrupt during suspend")
      for the rt5682s.
      
      Cc: stable@kernel.org
      Signed-off-by: Matthias Kaehlcke <mka@chromium.org
      Reviewed-by: Douglas Anderson <dianders@chromium.org
      Reviewed-by: Stephen Boyd <swboyd@chromium.org
      Link: https://lore.kernel.org/r/20230516164629.1.Ibf79e94b3442eecc0054d2b478779cc512d967fc@changeid
      Signed-off-by: Mark Brown <broonie@kernel.org
      8b271370
    • Ravulapati Vishnu Vardhan Rao's avatar
      ASoC: lpass: Fix for KASAN use_after_free out of bounds · 75e5fab7
      Ravulapati Vishnu Vardhan Rao authored
      When we run syzkaller we get below Out of Bounds error.
      
      "KASAN: slab-out-of-bounds Read in regcache_flat_read"
      
      Below is the backtrace of the issue:
      
      BUG: KASAN: slab-out-of-bounds in regcache_flat_read+0x10c/0x110
      Read of size 4 at addr ffffff8088fbf714 by task syz-executor.4/14144
      CPU: 6 PID: 14144 Comm: syz-executor.4 Tainted: G        W
      Hardware name: Qualcomm Technologies, Inc. sc7280 CRD platform (rev5+) (DT)
      Call trace:
      dump_backtrace+0x0/0x4ec
      show_stack+0x34/0x50
      dump_stack_lvl+0xdc/0x11c
      print_address_description+0x30/0x2d8
      kasan_report+0x178/0x1e4
      __asan_report_load4_noabort+0x44/0x50
      regcache_flat_read+0x10c/0x110
      regcache_read+0xf8/0x5a0
      _regmap_read+0x45c/0x86c
      _regmap_update_bits+0x128/0x290
      regmap_update_bits_base+0xc0/0x15c
      snd_soc_component_update_bits+0xa8/0x22c
      snd_soc_component_write_field+0x68/0xd4
      tx_macro_put_dec_enum+0x1d0/0x268
      snd_ctl_elem_write+0x288/0x474
      
      By Error checking and checking valid values issue gets rectifies.
      
      Signed-off-by: Ravulapati Vishnu Vardhan Rao <quic_visr@quicinc.com
      Link: https://lore.kernel.org/r/20230511112532.16106-1-quic_visr@quicinc.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      75e5fab7
  5. 15 May, 2023 20 commits
    • Mark Brown's avatar
      ASoC: SOF: Intel: hda-mlink: fixes and extensions · 9be0b3a0
      Mark Brown authored
      Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:
      
      With additional testing with multiple links and multiple DAI types, we
      found a couple of mistakes with refcounts, base address, missing
      initialization.
      
      A new helper was also added due to a change in the SoundWire
      programming sequences, with the host driver in charge of setting up
      the DMA channel mapping instead of the firmware.
      9be0b3a0
    • Ranjani Sridharan's avatar
      ASoC: SOF: topology: Fix tuples array allocation · 1c0d023c
      Ranjani Sridharan authored
      The memory allocated for the tuples array assumes that there's 1
      instance of all tokens already. So for those tokens that have multiple
      instances in topology, we need to exclude the initial instance that has
      already been accounted for.
      
      Fixes: 4fdef47a ("ASoC: SOF: ipc4-topology: Add new tokens for input/output pin format count")
      Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230515085200.17094-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      1c0d023c
    • Ranjani Sridharan's avatar
      ASoC: SOF: Separate the tokens for input and output pin index · be3c2153
      Ranjani Sridharan authored
      Using the same token ID for both input and output format pin index
      results in collisions and incorrect pin index getting parsed from
      topology.
      
      Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com
      Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230515104403.32207-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      be3c2153
    • Mark Brown's avatar
      ASoC: SOF: Various runtime pm fixes, improvements · aa70f36f
      Mark Brown authored
      Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:
      
      Three patch to correct error path PM runtime handling in few places.
      
      Regards,
      Peter
      ---
      Pierre-Louis Bossart (3):
        ASoC: SOF: debug: conditionally bump runtime_pm counter on exceptions
        ASoC: SOF: pcm: fix pm_runtime imbalance in error handling
        ASoC: SOF: sof-client-probes: fix pm_runtime imbalance in error
          handling
      
       sound/soc/sof/debug.c             |  4 ++--
       sound/soc/sof/pcm.c               | 11 ++++++-----
       sound/soc/sof/sof-client-probes.c | 14 ++++++++------
       3 files changed, 16 insertions(+), 13 deletions(-)
      
      --
      2.40.1
      aa70f36f
    • Lucas Tanure's avatar
      MAINTAINERS: Remove self from Cirrus Codec drivers · dc60b67d
      Lucas Tanure authored
      I'm leaving Cirrus Logic, and will no longer have access to
      hardware and documentation necessary to be effective in a
      maintainership role.
      
      Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com
      Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com
      Link: https://lore.kernel.org/r/20230512154503.741718-1-rf@opensource.cirrus.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      dc60b67d
    • Simon Trimmer's avatar
      ASoC: cs35l56: Prevent unbalanced pm_runtime in dsp_work() on SoundWire · 17082e09
      Simon Trimmer authored
      Flush the SoundWire interrupt handler work instead of cancelling it.
      
      When a SoundWire interrupt is triggered the pm_runtime is held
      until the work has completed. It's therefore unsafe to cancel
      the work, it must be flushed.
      
      Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com
      Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com
      Link: https://lore.kernel.org/r/20230512144237.739000-1-rf@opensource.cirrus.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      17082e09
    • Ranjani Sridharan's avatar
      ASoC: SOF: topology: Fix logic for copying tuples · 41c5305c
      Ranjani Sridharan authored
      Topology could have more instances of the tokens being searched for than
      the number of sets that need to be copied. Stop copying token after the
      limit of number of token instances has been reached. This worked before
      only by chance as we had allocated more size for the tuples array than
      the number of actual tokens being parsed.
      
      Fixes: 7006d20e ("ASoC: SOF: Introduce IPC3 ops")
      Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230512114630.24439-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      41c5305c
    • Kai Vehmanen's avatar
      ASoC: SOF: pm: save io region state in case of errors in resume · 171b53be
      Kai Vehmanen authored
      If there are failures in DSP runtime resume, the device state will not
      reach active and this makes it impossible e.g. to retrieve a possible
      DSP panic dump via "exception" debugfs node. If
      CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE=y is set, the data in
      cache is stale. If debugfs cache is not used, the region simply cannot
      be read.
      
      To allow debugging these scenarios, update the debugfs cache contents in
      resume error handler. User-space can then later retrieve DSP panic and
      other state via debugfs (requires SOF debugfs cache to be enabled in
      build).
      
      Reported-by: Curtis Malainey <cujomalainey@chromium.org
      Link: https://github.com/thesofproject/linux/issues/4274
      Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com
      Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Curtis Malainey <cujomalainey@chromium.org
      Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230512104638.21376-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      171b53be
    • Krzysztof Kozlowski's avatar
      ASoC: MAINTAINERS: drop Krzysztof Kozlowski from Samsung audio · 647b5f5f
      Krzysztof Kozlowski authored
      Remove Krzysztof Kozlowski from maintainer of Samsung SoC Audio drivers
      and change the status to maintenance (no one is reality being paid for
      looking at this).
      
      Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org
      Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com
      Link: https://lore.kernel.org/r/20230513090228.4340-1-krzysztof.kozlowski@linaro.org
      Signed-off-by: Mark Brown <broonie@kernel.org
      647b5f5f
    • Douglas Anderson's avatar
      ASoC: mediatek: mt8186: Fix use-after-free in driver remove path · a93d2afd
      Douglas Anderson authored
      When devm runs function in the "remove" path for a device it runs them
      in the reverse order. That means that if you have parts of your driver
      that aren't using devm or are using "roll your own" devm w/
      devm_add_action_or_reset() you need to keep that in mind.
      
      The mt8186 audio driver didn't quite get this right. Specifically, in
      mt8186_init_clock() it called mt8186_audsys_clk_register() and then
      went on to call a bunch of other devm function. The caller of
      mt8186_init_clock() used devm_add_action_or_reset() to call
      mt8186_deinit_clock() but, because of the intervening devm functions,
      the order was wrong.
      
      Specifically at probe time, the order was:
      1. mt8186_audsys_clk_register()
      2. afe_priv->clk = devm_kcalloc(...)
      3. afe_priv->clk[i] = devm_clk_get(...)
      
      At remove time, the order (which should have been 3, 2, 1) was:
      1. mt8186_audsys_clk_unregister()
      3. Free all of afe_priv->clk[i]
      2. Free afe_priv->clk
      
      The above seemed to be causing a use-after-free. Luckily, it's easy to
      fix this by simply using devm more correctly. Let's move the
      devm_add_action_or_reset() to the right place. In addition to fixing
      the use-after-free, code inspection shows that this fixes a leak
      (missing call to mt8186_audsys_clk_unregister()) that would have
      happened if any of the syscon_regmap_lookup_by_phandle() calls in
      mt8186_init_clock() had failed.
      
      Fixes: 55b423d5 ("ASoC: mediatek: mt8186: support audio clock control in platform driver")
      Signed-off-by: Douglas Anderson <dianders@chromium.org
      Link: https://lore.kernel.org/r/20230511092437.1.I31cceffc8c45bb1af16eb613e197b3df92cdc19e@changeid
      Signed-off-by: Mark Brown <broonie@kernel.org
      a93d2afd
    • Peter Ujfalusi's avatar
      ASoC: SOF: ipc3-topology: Make sure that only one cmd is sent in dai_config · 4708449e
      Peter Ujfalusi authored
      The commands in sof_ipc_dai_config.flags are encoded as bits:
      1 (bit0) - hw_params
      2 (bit1) - hw_free
      4 (bit2) - pause
      
      These are commands, they cannot be combined as one would assume, for
      example
      3 (bit0 | bit1) is invalid.
      
      This can happen right at the second start of a stream as at the end of the
      first stream we set the hw_free command (bit1) and on the second start we
      would OR on top of it the hw_params (bit0).
      
      Fixes: b66bfc3a ("ASoC: SOF: sof-audio: Fix broken early bclk feature for SSP")
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Link: https://lore.kernel.org/r/20230512110317.5180-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      4708449e
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: sof-client-probes: fix pm_runtime imbalance in error handling · bc424273
      Pierre-Louis Bossart authored
      When an error occurs, we need to make sure the device can pm_runtime
      suspend instead of keeping it active.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230512103315.8921-4-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      bc424273
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: pcm: fix pm_runtime imbalance in error handling · da0fe8fd
      Pierre-Louis Bossart authored
      When an error occurs, we need to make sure the device can pm_runtime
      suspend instead of keeping it active.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230512103315.8921-3-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      da0fe8fd
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: debug: conditionally bump runtime_pm counter on exceptions · 3de97586
      Pierre-Louis Bossart authored
      When a firmware IPC error happens during a pm_runtime suspend, we
      ignore the error and suspend anyways. However, the code
      unconditionally increases the runtime_pm counter. This results in a
      confusing configuration where the code will suspend, resume but never
      suspend again due to the use of pm_runtime_get_noresume().
      
      The intent of the counter increase was to prevent entry in D3, but if
      that transition to D3 is already started it cannot be stopped. In
      addition, there's no point in that case in trying to prevent anything,
      the firmware error is handled and the next resume will re-initialize
      the firmware completely.
      
      This patch changes the logic to prevent suspend when the device is
      pm_runtime active and has a use_count > 0.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
      Link: https://lore.kernel.org/r/20230512103315.8921-2-peter.ujfalusi@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      3de97586
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: Intel: hda-mlink: add helper to program SoundWire PCMSyCM registers · ccc2f0c1
      Pierre-Louis Bossart authored
      These registers enable the HDaudio DMA hardware to split/merge data
      from different PDIs, possibly on different links.
      
      This capability exists for all types of HDaudio extended links, but
      for now is only required for SoundWire. In the SSP/DMIC case, the IP
      is programmed by the DSP firmware.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Rander Wang <rander.wang@intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Link: https://lore.kernel.org/r/20230512174611.84372-7-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      ccc2f0c1
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: Intel: hda-mlink: initialize instance_offset member · 9643456e
      Pierre-Louis Bossart authored
      We defined the values but never initialized it for SoundWire/SSP, fix
      this miss.
      
      A Fixes: tag is not provided as instance_offset was not used so far,
      so nothing was really broken. This patch is only required for the
      SoundWire support in the following patch.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Rander Wang <rander.wang@intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Link: https://lore.kernel.org/r/20230512174611.84372-6-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      9643456e
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: Intel: hda-mlink: use 'ml_addr' parameter consistently · 7dfd1ccd
      Pierre-Louis Bossart authored
      We mix the use of hlink->ml_addr and the 'ml_addr' parameter. It's the
      same thing, let's align on using the parameter.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Rander Wang <rander.wang@intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Link: https://lore.kernel.org/r/20230512174611.84372-5-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      7dfd1ccd
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: Intel: hda-mlink: fix base_ptr computation · af8c32b1
      Pierre-Louis Bossart authored
      The base_ptr value needs to be derived from the remap_addr pointer,
      not the ml_addr. This base_ptr was used only in debug logs that were
      so far not contributed upstream so the issue was not detected. It
      needs to be fixed for SoundWire support on LunarLake.
      
      Fixes: 17c9b6ec ("ASoC: SOF: Intel: hda-mlink: add structures to parse ALT links")
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Reviewed-by: Rander Wang <rander.wang@intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Link: https://lore.kernel.org/r/20230512174611.84372-4-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      af8c32b1
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: Intel: hda-mlink: add helper to get SoundWire hlink · dcb88fc4
      Pierre-Louis Bossart authored
      Same functionality as for DMIC/SSP with different ID.
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Rander Wang <rander.wang@intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Link: https://lore.kernel.org/r/20230512174611.84372-3-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      dcb88fc4
    • Pierre-Louis Bossart's avatar
      ASoC: SOF: Intel: hda-mlink: fix sublink refcounting · 7430dea4
      Pierre-Louis Bossart authored
      In hindsight it was a very bad idea to use the same refcount for
      Extended and 'legacy' HDaudio multi-links. The existing solution only
      powers-up the first sublink, which causes SoundWire and SSP tests to
      fail when more than one DAI is used concurrently. Solving this problem
      requires per-sublink refcounting, as suggested in this patch.
      
      The existing refcounting remains for 'legacy' HdAudio links, mainly to
      avoid changing the obscure programming sequence in
      snd_hdac_ext_bus_link_put().
      
      Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
      Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
      Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
      Link: https://lore.kernel.org/r/20230512174611.84372-2-pierre-louis.bossart@linux.intel.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      7430dea4
  6. 12 May, 2023 1 commit
    • Paweł Anikiel's avatar
      ASoC: ssm2602: Add workaround for playback distortions · f63550e2
      Paweł Anikiel authored
      Apply a workaround for what appears to be a hardware quirk.
      
      The problem seems to happen when enabling "whole chip power" (bit D7
      register R6) for the very first time after the chip receives power. If
      either "output" (D4) or "DAC" (D3) aren't powered on at that time,
      playback becomes very distorted later on.
      
      This happens on the Google Chameleon v3, as well as on a ZYBO Z7-10:
      https://ez.analog.com/audio/f/q-a/543726/solved-ssm2603-right-output-offset-issue/480229
      I suspect this happens only when using an external MCLK signal (which
      is the case for both of these boards).
      
      Here are some experiments run on a Google Chameleon v3. These were run
      in userspace using a wrapper around the i2cset utility:
      ssmset() {
              i2cset -y 0 0x1a $(($1*2)) $2
      }
      
      For each of the following sequences, we apply power to the ssm2603
      chip, set the configuration registers R0-R5 and R7-R8, run the selected
      sequence, and check for distortions on playback.
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x07 # chip, out, dac
        OK
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x87 # out, dac
        ssmset 0x06 0x07 # chip
        OK
      
        (disable MCLK)
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x1f # chip
        ssmset 0x06 0x07 # out, dac
        (enable MCLK)
        OK
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x1f # chip
        ssmset 0x06 0x07 # out, dac
        NOT OK
      
        ssmset 0x06 0x1f # chip
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x07 # out, dac
        NOT OK
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x0f # chip, out
        ssmset 0x06 0x07 # dac
        NOT OK
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x17 # chip, dac
        ssmset 0x06 0x07 # out
        NOT OK
      
      For each of the following sequences, we apply power to the ssm2603
      chip, run the selected sequence, issue a reset with R15, configure
      R0-R5 and R7-R8, run one of the NOT OK sequences from above, and check
      for distortions.
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x07 # chip, out, dac
        OK
      
        (disable MCLK)
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x07 # chip, out, dac
        (enable MCLK after reset)
        NOT OK
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x17 # chip, dac
        NOT OK
      
        ssmset 0x09 0x01 # core
        ssmset 0x06 0x0f # chip, out
        NOT OK
      
        ssmset 0x06 0x07 # chip, out, dac
        NOT OK
      
      Signed-off-by: Paweł Anikiel <pan@semihalf.com
      Link: https://lore.kernel.org/r/20230508113037.137627-8-pan@semihalf.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      f63550e2
  7. 11 May, 2023 2 commits
    • Martin Povišer's avatar
      ASoC: dt-bindings: Adjust #sound-dai-cells on TI's single-DAI codecs · efb2bfd7
      Martin Povišer authored
      A bunch of TI's codecs have binding schemas which force #sound-dai-cells
      to one despite those codecs only having a single DAI. Allow for bindings
      with zero DAI cells and deprecate the former non-zero value.
      
      Signed-off-by: Martin Povišer <povik+lin@cutebit.org
      Link: https://lore.kernel.org/r/20230509153412.62847-1-povik+lin@cutebit.org
      Signed-off-by: Mark Brown <broonie@kernel.org
      efb2bfd7
    • Aidan MacDonald's avatar
      ASoC: jz4740-i2s: Make I2S divider calculations more robust · ad721bc9
      Aidan MacDonald authored
      When the CPU supplies bit/frame clocks, the system clock (clk_i2s)
      is divided to produce the bit clock. This is a simple 1/N divider
      with a fairly limited range, so for a given system clock frequency
      only a few sample rates can be produced. Usually a wider range of
      sample rates is supported by varying the system clock frequency.
      
      The old calculation method was not very robust and could easily
      produce the wrong clock rate, especially with non-standard rates.
      For example, if the system clock is 1.99x the target bit clock
      rate, the divider would be calculated as 1 instead of the more
      accurate 2.
      
      Instead, use a more accurate method that considers two adjacent
      divider settings and selects the one that produces the least error
      versus the requested rate. If the error is 5% or higher then the
      rate setting is rejected to prevent garbled audio.
      
      Skip divider calculation when the codec is supplying both the bit
      and frame clock; in that case, the divider outputs are unused and
      we don't want to constrain the sample rate.
      
      Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com
      Link: https://lore.kernel.org/r/20230509125134.208129-1-aidanmacdonald.0x0@gmail.com
      Signed-off-by: Mark Brown <broonie@kernel.org
      ad721bc9
  8. 09 May, 2023 1 commit
  9. 08 May, 2023 2 commits