01 Oct, 2020

2 commits

  • [ Upstream commit dff70572e9a3a1a01d9dbc2279faa784d95f41b6 ]

    Before removing the slave device, disable pm_runtime to prevent any
    race condition with the resume being executed after the bus and slave
    devices are removed.

    Since this pm_runtime_disable() is handled in common routines,
    implementations of Slave drivers do not need to call it in their
    .remove() routine.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20200115000844.14695-8-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Pierre-Louis Bossart
     
  • [ Upstream commit 49ea07d33d9a32c17e18b322e789507280ceb2a3 ]

    Multiple changes squashed in single patch to avoid tick-tock effect
    and avoid breaking compilation/bisect

    1. Per the hardware documentation, all changes to MCP_CONFIG,
    MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL need to be validated with a
    self-clearing write to MCP_CONFIG_UPDATE. Add a helper and do the
    update when the CONFIG is changed.

    2. Move interrupt enable after interrupt handler registration

    3. Add a new helper to start the hardware bus reset with maximum duration
    to make sure the Slave(s) correctly detect the reset pattern and to
    ensure electrical conflicts can be resolved.

    4. flush command FIFOs

    Better error handling will be provided after interrupt disable is
    provided in follow-up patches.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20191022235448.17586-2-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Pierre-Louis Bossart
     

17 Sep, 2020

1 commit

  • [ Upstream commit 3fbbf2148a406b3e350fe91e6fdd78eb42ecad24 ]

    clang static analysis flags this problem

    stream.c:844:9: warning: Use of memory after
    it is freed
    kfree(bus->defer_msg.msg->buf);
    ^~~~~~~~~~~~~~~~~~~~~~~

    This happens in an error handler cleaning up memory
    allocated for elements in a list.

    list_for_each_entry(m_rt, &stream->master_list, stream_node) {
    bus = m_rt->bus;

    kfree(bus->defer_msg.msg->buf);
    kfree(bus->defer_msg.msg);
    }

    And is triggered when the call to sdw_bank_switch() fails.
    There are a two problems.

    First, when sdw_bank_switch() fails, though it frees memory it
    does not clear bus's reference 'defer_msg.msg' to that memory.

    The second problem is the freeing msg->buf. In some cases
    msg will be NULL so this will dereference a null pointer.
    Need to check before freeing.

    Fixes: 99b8a5d608a6 ("soundwire: Add bank switch routine")
    Signed-off-by: Tom Rix
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20200902202650.14189-1-trix@redhat.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Tom Rix
     

22 Jul, 2020

1 commit

  • [ Upstream commit bf6d6e68d2028a2d82f4c106f50ec75cc1e6ef89 ]

    The dais are allocated with devm_kcalloc() but their name isn't
    resourced managed and never freed. Fix by also using devm_ for the dai
    names as well.

    Fixes: c46302ec554c5 ('soundwire: intel: Add audio DAI ops')
    Signed-off-by: Pierre-Louis Bossart
    Reviewed-by: Daniel Baluta
    Reviewed-by: Kai Vehmanen
    Reviewed-by: Rander Wang
    Reviewed-by: Guennadi Liakhovetski
    Reviewed-by: Bard Liao
    Link: https://lore.kernel.org/r/20200617163536.17401-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Pierre-Louis Bossart
     

24 Jun, 2020

1 commit

  • [ Upstream commit 8893ab5e8ee5d7c12e0fc1dca4a309475064473d ]

    The error handling flow seems incorrect, there is no reason to try and
    add debugfs support if the device registration did not
    succeed. Return on error.

    Signed-off-by: Pierre-Louis Bossart
    Signed-off-by: Bard Liao
    Reviewed-by: Ranjani Sridharan
    Reviewed-by: Guennadi Liakhovetski
    Link: https://lore.kernel.org/r/20200419185117.4233-2-yung-chuan.liao@linux.intel.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Pierre-Louis Bossart
     

31 Dec, 2019

1 commit

  • [ Upstream commit c134f914e9f55b7817e2bae625ec0e5f1379f7cd ]

    The previous formula is incorrect for PDI0/1, the mapping is not
    linear but has a discontinuity between PDI1 and PDI2.

    This change has no effect on PCM PDIs (same mapping).

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20191022232948.17156-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Pierre-Louis Bossart
     

24 Oct, 2019

1 commit

  • fix cppcheck warning:

    [drivers/soundwire/slave.c:145]: (warning) %x in format string (no. 1)
    requires 'unsigned int *' but the argument type is 'signed int *'.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20191022233147.17268-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     

21 Oct, 2019

1 commit

  • There are two issues, likely copy/paste:

    1. Use cdns->pcm.num_in instead of stream_num_in for consistency with
    the rest of the code. This was not detected earlier since platforms did
    not have input-only PDIs.

    2. use the correct offset for bi-dir PDM, based on IN and OUT
    PDIs. Again this was not detected since PDM was not supported earlier.

    Reported-by: Ranjani Sridharan
    Signed-off-by: Bard Liao
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190916192348.467-2-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Bard Liao
     

15 Oct, 2019

2 commits

  • Now devicetree is supported for probing soundwire as well.

    On platforms built with !ACPI !OF (ie s390x) the device still cannot be
    probed and gives a build warning.

    Cc: stable@vger.kernel.org
    Fixes: a2e484585ad3 ("soundwire: core: add device tree support for slave devices")
    Signed-off-by: Michal Suchanek
    Link: https://lore.kernel.org/r/0b89b4ea16a93f523105c81a2f718b0cd7ec66f2.1570097621.git.msuchanek@suse.de
    Signed-off-by: Vinod Koul

    Michal Suchanek
     
  • The device cannot be probed on !ACPI and gives this warning:

    drivers/soundwire/slave.c:16:12: warning: ‘sdw_slave_add’ defined but
    not used [-Wunused-function]
    static int sdw_slave_add(struct sdw_bus *bus,
    ^~~~~~~~~~~~~

    Cc: stable@vger.kernel.org
    Fixes: 7c3cd189b86d ("soundwire: Add Master registration")
    Signed-off-by: Michal Suchanek
    Link: https://lore.kernel.org/r/bd685232ea511251eeb9554172f1524eabf9a46e.1570097621.git.msuchanek@suse.de
    Signed-off-by: Vinod Koul

    Michal Suchanek
     

23 Sep, 2019

1 commit

  • Pull soundwire updates from Vinod Koul:
    "This includes DT support thanks to Srini and more work done by Intel
    (Pierre) on improving cadence and intel support.

    Summary:

    - Add DT bindings and DT support in core

    - Add debugfs support for soundwire properties

    - Improvements on streaming handling to core

    - Improved handling of Cadence module

    - More updates and improvements to Intel driver"

    * tag 'soundwire-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: (30 commits)
    soundwire: stream: make stream name a const pointer
    soundwire: Add compute_params callback
    soundwire: core: add device tree support for slave devices
    dt-bindings: soundwire: add slave bindings
    soundwire: bus: set initial value to port_status
    soundwire: intel: handle disabled links
    soundwire: intel: add debugfs register dump
    soundwire: cadence_master: add debugfs register dump
    soundwire: add debugfs support
    soundwire: intel: remove unused variables
    soundwire: intel: move shutdown() callback and don't export symbol
    soundwire: cadence_master: add kernel parameter to override interrupt mask
    soundwire: intel_init: add kernel module parameter to filter out links
    soundwire: cadence_master: fix divider setting in clock register
    soundwire: cadence_master: make use of mclk_freq property
    soundwire: intel: read mclk_freq property from firmware
    soundwire: add new mclk_freq field for properties
    soundwire: stream: remove unnecessary variable initializations
    soundwire: stream: fix disable sequence
    soundwire: include mod_devicetable.h to avoid compiling warnings
    ...

    Linus Torvalds
     

04 Sep, 2019

4 commits


23 Aug, 2019

4 commits

  • On most hardware platforms, SoundWire interfaces are pin-muxed with
    other interfaces (typically DMIC or I2S) and the status of each link
    needs to be checked at boot time.

    For Intel platforms, the BIOS provides a menu to enable/disable the
    links separately, and the information is provided to the OS with an
    Intel-specific _DSD property. The same capability will be added to
    revisions of the MIPI DisCo specification.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190821185821.12690-5-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • Add debugfs file to dump the Intel SoundWire registers

    Credits: this patch is based on an earlier internal contribution by
    Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah.

    Reviewed-by: Greg Kroah-Hartman
    Acked-by: Sanyog Kale
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190821185821.12690-4-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • Add debugfs file to dump the Cadence master registers.

    Credits: this patch is based on an earlier internal contribution by
    Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah.

    Reviewed-by: Greg Kroah-Hartman
    Acked-by: Sanyog Kale
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190821185821.12690-3-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • Add base debugfs mechanism for SoundWire bus by creating soundwire
    root and master-N and slave-x hierarchy.

    Also add SDW Slave SCP, DP0 and DP-N register debug file.

    Registers not implemented will print as "XX"

    Credits: this patch is based on an earlier internal contribution by
    Vinod Koul, Sanyog Kale, Shreyas Nc and Hardik Shah.

    Reviewed-by: Greg Kroah-Hartman
    Acked-by: Sanyog Kale
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190821185821.12690-2-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     

22 Aug, 2019

1 commit

  • Variables 'nval' and 'i' are no longer used sdw_master_read_intel_prop()
    so remove them.

    drivers/soundwire/intel.c: In function 'sdw_master_read_intel_prop':
    drivers/soundwire/intel.c:829:12: warning: unused variable 'i' [-Wunused-variable]
    int nval, i;
    ^
    drivers/soundwire/intel.c:829:6: warning: unused variable 'nval' [-Wunused-variable]
    int nval, i;
    ^~~~

    Reported-by: Stephen Rothwell
    Fixes: 085f4ace103d ("soundwire: intel: read mclk_freq property from firmware")
    Signed-off-by: Vinod Koul

    Vinod Koul
     

21 Aug, 2019

14 commits

  • All DAI callbacks are in intel.c except for shutdown. Move and remove
    export symbol

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-18-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • The code has a set of defaults which may not be relevant in all cases,
    add kernel parameter as a helper - mostly for early board bring-up.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-17-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • The hardware and ACPI info may report the presence of links that are
    not physically enabled (e.g. due to pin-muxing or hardware reworks),
    which in turn can result in errors being thrown. This shouldn't be the
    case for production devices but will happen a lot on development
    devices - even more so when they expose a connector.

    Even when the ACPI information is correct, it's useful to be able to
    only enable the links that need attention - mostly to filter out
    dynamic debug messages.

    Add a module parameter to filter out such links, e.g. adding the
    following config to a file in /etc/modprobe.d will select the second
    and third links only.

    options soundwire_intel_init sdw_link_mask=0x6

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-16-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • The existing code uses an OR operation which would mix the original
    divider setting with the new one, resulting in an invalid
    configuration that can make codecs hang.

    Add the mask definition and use cdns_updatel to update divider

    Signed-off-by: Rander Wang
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-14-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Rander Wang
     
  • Now that the prototype and Intel implementation are enabled, use this
    property to avoid hard-coded values.

    For example for ICL the mclk_freq value is 38.4 MHz while on CNL/CML
    it's 24 MHz. The mclk_freq should not be confused with the
    max_clk_freq, which si the maximum bus clock. The mclk_freq is
    typically tied to the oscillator frequency and does not change between
    platforms. The max_clk_freq value is linked to the maximum bandwidth
    needed and topology/trace length.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-13-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • The BIOS provides an Intel-specific property, let's use it to avoid
    hard-coded clock dividers.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-12-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • A number of variables don't need to be initialized.

    In a couple of cases where we loop on a list of runtimes, the code
    handling of the 'bus' variable leads to warnings that it may not be
    initialized. Add a specific error case to trap such cases.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-10-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • When we disable the stream and then call hw_free, two bank switches
    will be handled and as a result we re-enable the stream on hw_free.

    Make sure the stream is disabled on both banks.

    TODO: we need to completely revisit all this and make sure we have a
    mirroring mechanism between current and alternate banks.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-9-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • Remove hard-coding and use firmware (BIOS/DT) values. If they are
    wrong use default 48x2 frame shape.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-7-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • Add a prefix for common tables and export 2 helpers to set the frame
    shapes based on row/col values.

    These changes simplify bandwidth allocation algorithms as well as the
    Cadence parts which all need to convert from frame shape to indices
    used by the standard. These helpers are used in the following patch.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-6-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • update comments to provide better understanding of enumeration flows.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-5-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • Adding missing interrupt masks (parity, etc) and missing checks.
    Clarify which masks are for which usage.

    Signed-off-by: Bard Liao
    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-4-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • On all released Intel controllers (CNL/CML/ICL), PDI2 reports an
    invalid count, force the correct hardware-supported value

    This may have to be revisited with platform-specific values if the
    hardware changes, but for now this is good enough.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-3-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     
  • This should not happen in production systems but we should test for
    all callback arguments before invoking the config_stream callback.

    Update the prototype to clarify that the first argument is mandatory.

    Also use local variable instead of multiple dereferences to improve
    readability.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190806005522.22642-2-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     

09 Aug, 2019

1 commit

  • The existing code has a mixed select/depend usage which makes no sense.

    config SOUNDWIRE_BUS
    tristate
    select REGMAP_SOUNDWIRE

    config REGMAP_SOUNDWIRE
    tristate
    depends on SOUNDWIRE_BUS

    Let's remove one layer of Kconfig definitions and align with the
    solutions used by all other serial links.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190718230215.18675-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     

03 Aug, 2019

1 commit

  • Assigning a device number to a Slave will result in additional events
    when it reports its status in a PING frame. There is no point in
    dealing with all the other devices in a loop, this can be done when a
    non-device0 event happens.

    Signed-off-by: Pierre-Louis Bossart
    Link: https://lore.kernel.org/r/20190725234032.21152-19-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Vinod Koul

    Pierre-Louis Bossart
     

02 Aug, 2019

4 commits