Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoundWire: fixes before changes to bind/unbind #3645

Commits on May 23, 2022

  1. ASoC: Intel: sof_sdw: allow HDaudio/HDMI disable

    For tests, it's rather common to disable the HDaudio links and codecs
    in the build. Since we already get a codec_mask parameter indicating
    that there are no codecs detected, it's straightforward to skip the
    HDMI dailink creation and create a card.
    
    Note that when disabling HDMI, a modified topology without HDMI
    pipelines needs to be provided as well.
    
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 23, 2022
    Configuration menu
    Copy the full SHA
    a8bc59b View commit details
    Browse the repository at this point in the history
  2. soundwire: bus_type: fix remove and shutdown support

    The bus sdw_drv_remove() and sdw_drv_shutdown() helpers are used
    conditionally, if the driver provides these routines.
    
    These helpers already test if the driver provides a .remove or
    .shutdown callback, so there's no harm in invoking the
    sdw_drv_remove() and sdw_drv_shutdown() unconditionally.
    
    In addition, the current code is imbalanced with
    dev_pm_domain_attach() called from sdw_drv_probe(), but
    dev_pm_domain_detach() called from sdw_drv_remove() only if the driver
    provides a .remove callback.
    
    Fixes: 9251345 ("soundwire: Add SoundWire bus type")
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 23, 2022
    Configuration menu
    Copy the full SHA
    20bb5df View commit details
    Browse the repository at this point in the history

Commits on May 26, 2022

  1. ASoC: Realtek/Maxim SoundWire codecs: disable pm_runtime on remove

    When binding/unbinding codec drivers, the following warnings are
    thrown:
    
    [ 107.266879] rt715-sdca sdw:3:025d:0714:01: Unbalanced pm_runtime_enable!
    [  306.879700] rt711-sdca sdw:0:025d:0711:01: Unbalanced pm_runtime_enable!
    
    Add a remove callback for all Realtek/Maxim SoundWire codecs and remove this
    warning.
    
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    54aa187 View commit details
    Browse the repository at this point in the history
  2. ASoC: rt711-sdca-sdw: fix calibrate mutex initialization

    In codec driver bind/unbind test, the following warning is thrown:
    
    DEBUG_LOCKS_WARN_ON(lock->magic != lock)
    ...
    [  699.182495]  rt711_sdca_jack_init+0x1b/0x1d0 [snd_soc_rt711_sdca]
    [  699.182498]  rt711_sdca_set_jack_detect+0x3b/0x90 [snd_soc_rt711_sdca]
    [  699.182500]  snd_soc_component_set_jack+0x24/0x50 [snd_soc_core]
    
    A quick check in the code shows that the 'calibrate_mutex' used by
    this driver are not initialized at probe time. Moving the
    initialization to the probe removes the issue.
    
    BugLink: thesofproject#3644
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    5e2ec0b View commit details
    Browse the repository at this point in the history
  3. ASoC: Intel: sof_sdw: handle errors on card registration

    If the card registration fails, typically because of deferred probes,
    the device properties added for headset codecs are not removed, which
    leads to kernel oopses in driver bind/unbind tests.
    
    We already clean-up the device properties when the card is removed,
    this code can be moved as a helper and called upon card registration
    errors.
    
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    aee4053 View commit details
    Browse the repository at this point in the history
  4. ASoC: rt711: fix calibrate mutex initialization

    Follow the same flow as rt711-sdca and initialize all mutexes at probe
    time.
    
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    8d01abf View commit details
    Browse the repository at this point in the history
  5. ASoC: rt7*-sdw: harden jack_detect_handler

    Realtek headset codec drivers typically check if the card is
    instantiated before proceeding with the jack detection.
    
    The rt700, rt711 and rt711-sdca are however missing a check on the
    card pointer, which can lead to NULL dereferences encountered in
    driver bind/unbind tests.
    
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    dfd7e2e View commit details
    Browse the repository at this point in the history
  6. ASoC: codecs: rt700/rt711/rt711-sdca: initialize workqueues in probe

    The workqueues are initialized in the io_init functions, which isn't
    quite right. In some tests, this leads to warnings throw from
    __queue_delayed_work()
    
    WARN_ON_FUNCTION_MISMATCH(timer->function, delayed_work_timer_fn);
    
    Move all the initializations to the probe functions.
    
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    8e02c4d View commit details
    Browse the repository at this point in the history
  7. ASoC: codecs: rt700/rt711/rt711-sdca: resume bus/codec in .set_jack_d…

    …etect
    
    The .set_jack_detect() codec component callback is invoked during card
    registration, which happens when the machine driver is probed.
    
    The issue is that this callback can race with the bus suspend/resume,
    and IO timeouts can happen. This can be reproduced very easily if the
    machine driver is 'blacklisted' and manually probed after the bus
    suspends. The bus and codec need to be re-initialized using pm_runtime
    helpers.
    
    Previous contributions tried to make sure accesses to the bus during
    the .set_jack_detect() component callback only happen when the bus is
    active. This was done by changing the regcache status on a component
    remove. This is however a layering violation, the regcache status
    should only be modified on device probe, suspend and resume. The
    component probe/remove should not modify how the device regcache is
    handled. This solution also didn't handle all the possible race
    conditions, and the RT700 headset codec was not handled.
    
    This patch tries to resume the codec device before handling the jack
    initializations. In case the codec has not yet been initialized,
    pm_runtime may not be enabled yet, so we don't squelch the -EACCES
    error code and only stop the jack information. When the codec reports
    as attached, the jack initialization will proceed as usual.
    
    BugLink: thesofproject#3643
    Fixes: 7ad4d23 ('ASoC: rt711-sdca: Add RT711 SDCA vendor-specific driver')
    Fixes: 899b125 ('ASoC: rt711: add snd_soc_component remove callback')
    Signed-off-by: Pierre-Louis Bossart <[email protected]>
    plbossart committed May 26, 2022
    Configuration menu
    Copy the full SHA
    2c68ce3 View commit details
    Browse the repository at this point in the history