1. 24 7月, 2019 2 次提交
  2. 04 7月, 2019 1 次提交
  3. 28 6月, 2019 2 次提交
  4. 26 6月, 2019 1 次提交
  5. 25 6月, 2019 6 次提交
  6. 19 6月, 2019 1 次提交
    • K
      ASoC: soc-core: allow no Platform on dai_link · 1d768989
      Kuninori Morimoto 提交于
      dai_link is used to selecting Component (= CPU/Codec/Platform) and
      DAI (= CPU/Codec). And selected CPU/Codec/Platform components are
      *listed* on Card.
      
      Many drivers don't need special Platform component, but was
      mandatory at legacy style ALSA SoC.
      Thus, there is this kind of settings on many drivers.
      
      	dai_link->platform_of_node = dai_link->cpu_of_node;
      
      In this case, soc_bind_dai_link() will pick-up "CPU component" as
      "Platform component", and try to add it to snd_soc_pcm_runtime.
      But it will be ignored, because it is already added when CPU bindings.
      
      Historically, this kind of "CPU component" is used/selected as
      "Platform" on many ALSA SoC drivers.
      OTOH, Dummy Platform will be selected automatically by ALSA SoC if
      driver doesn't have Platform settings.
      
      These indicates that there are 2 type of Platforms exist at current
      ALSA SoC if driver doesn't need special Platform.
      
      	1) use Dummy Platform as Platform component
      	2) use CPU component  as Platform component
      
      ALSA SoC will call Dummy Platform callback function if it is using
      Dummy Platform, but it is completely pointless. Because it is the
      sound card which doesn't need special Platform.
      
      Thus, the behavior we request to ALSA SoC is selecting 2) automatically
      instead of 1) if sound card doesn't need special Platform.
      And, 2) means "do nothing" as above explain.
      
      These were needed at legacy style dai_link, but is no longer needed
      at modern style dai_link anymore.
      
      This patch allows "no Platform" settings on dai_link, and will do
      nothing for it if there was no platform settings. This is same as 2).
      
      By this patch, all drivers which is selecting "CPU component" as
      "Platform" can remove such settings.
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      1d768989
  7. 10 6月, 2019 1 次提交
  8. 08 6月, 2019 1 次提交
    • S
      ASoC: Remove erroneous soc_cleanup_card_resources() call · 07799359
      Sylwester Nawrocki 提交于
      When soc_init_dai_link() call at the beginning of snd_soc_instantiate_card
      function fails soc_cleanup_card_resources() and then snd_soc_dapm_free()
      gets called with an incompletely initialized card->dapm. In particular
      card->dapm.card is NULL and it gets dereferenced in dapm_free_widgets().
      Also dapm->list is invalid and there is an invalid pointer dereference
      from list_del().
      
      The function call stack (deferred probing) on Chromebook Snow where this
      issue has shown up in today's -next is:
      
       snd_soc_dapm_free
       soc_cleanup_card_resources
       snd_soc_instantiate_card
       snd_soc_register_card
       devm_snd_soc_register_card
       snow_probe
      
      In patch 70fc5373 "ASoC: core: move DAI pre-links initiation to
      snd_soc_instantiate_card" there is an soc_cleanup_platform() call instead
      of soc_cleanup_card_resources() as in current -next.
      
      soc_cleanup_platform got renamed to soc_cleanup_legacy, then removed
      in commit adb76b5b "ASoC: soc-core: remove legacy style dai_link".
      
      It seems in merge conflict resolution the soc_cleanup_platform() call got
      renamed to soc_cleanup_card_resources(), instead of being removed.
      
      Correct this by removing an unnecessary soc_cleanup_card_resources() call.
      
      Fixes: a8e99234 ("Merge branch 'asoc-5.2' into asoc-5.3")
      Reported-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Suggested-by: NTzung-Bi Shih <tzungbi@google.com>
      Signed-off-by: NSylwester Nawrocki <s.nawrocki@samsung.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      07799359
  9. 07 6月, 2019 5 次提交
  10. 04 6月, 2019 1 次提交
  11. 29 5月, 2019 1 次提交
  12. 28 5月, 2019 1 次提交
    • K
      ASoC: soc-core: fixup references at soc_cleanup_card_resources() · 29040d1a
      Kuninori Morimoto 提交于
      commit 53e947a0 ("ASoC: soc-core: merge card resources cleanup
      method") merged cleanup method of snd_soc_instantiate_card() and
      soc_cleanup_card_resources().
      
      But, after this commit, if user uses unbind/bind to Component factor
      drivers, Kernel might indicates refcount error at
      soc_cleanup_card_resources().
      
      The 1st reason is card->snd_card is still exist even though
      snd_card_free() was called, but it is already cleaned.
      We need to set NULL to it.
      
      2nd is card->dapm and card create debugfs, but its dentry is still
      exist even though it was removed. We need to set NULL to it.
      
      Fixes: 53e947a0 ("ASoC: soc-core: merge card resources cleanup method")
      Cc: stable@vger.kernel.org # for v5.1
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      29040d1a
  13. 24 5月, 2019 1 次提交
  14. 20 5月, 2019 1 次提交
  15. 13 5月, 2019 5 次提交
  16. 08 4月, 2019 1 次提交
    • R
      ASoC: core: conditionally increase module refcount on component open · b4ed6b51
      Ranjani Sridharan 提交于
      Recently, for Intel platforms the "ignore_module_refcount" field
      was introduced for the component driver. In order to avoid a
      deadlock preventing the PCI modules from being removed
      even when the card was idle, the refcounts were not incremented
      for the device driver module during component probe.
      
      However, this change introduced a nasty side effect:
      the device driver module can be unloaded while a pcm stream is open.
      
      This patch proposes to change the field to be renamed as
      "module_get_upon_open". When this field is set, the module
      refcount should be incremented on pcm open amd decremented
      upon pcm close. This will enable modules to be removed
      when no PCM playback/capture happens and prevent removal
      when the component is actually in use.
      
      Also, align with the skylake component driver with the new name.
      
      Fixes: b450b878('ASoC: core: don't increase component module refcount
                       unconditionally'
      Signed-off-by: NRanjani Sridharan <ranjani.sridharan@linux.intel.com>
      Acked-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      b4ed6b51
  17. 05 4月, 2019 1 次提交
    • R
      ASoC: core: remove link components before cleaning up card resources · f96fb7d1
      Ranjani Sridharan 提交于
      When the card is registered by the machine driver,
      dai link components are probed after the snd_card is
      created. This is done in snd_soc_bind_card() which calls
      snd_soc_instantiate_card() to first create the snd_card
      and then probes the link components by calling
      soc_probe_link_components(). The snd_card is used by the
      component driver to add the kcontrols associated
      with dapm widgets to the card.
      
      When the machine driver is unregistered, the snd_card
      is freed when the card resources are cleaned up.
      But the snd_card needs to be valid while unloading the
      topology dapm widgets in order to remove the kcontrols
      from the card.
      
      Since, unloading topology is done when the component
      driver is removed, the link components should be removed
      in snd_soc_unbind_card(). This will ensure that the kcontrols
      are removed before the card resources are cleaned up and
      the snd_card itself is freed.
      Signed-off-by: NRanjani Sridharan <ranjani.sridharan@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      f96fb7d1
  18. 02 4月, 2019 1 次提交
  19. 18 3月, 2019 1 次提交
    • K
      ASoC: dpcm: prevent snd_soc_dpcm use after free · bbfaa7d3
      KaiChieh Chuang 提交于
      The dpcm get from fe_clients/be_clients
      may be free before use
      
      Add a spin lock at snd_soc_card level,
      to protect the dpcm instance.
      The lock may be used in atomic context, so use spin lock.
      
      possible race condition between
      void dpcm_be_disconnect(
      	...
      	list_del(&dpcm->list_be);
      	list_del(&dpcm->list_fe);
      	kfree(dpcm);
      	...
      
      and
      	for_each_dpcm_fe()
      	for_each_dpcm_be*()
      
      race condition example
      Thread 1:
          snd_soc_dapm_mixer_update_power()
              -> soc_dpcm_runtime_update()
                  -> dpcm_be_disconnect()
                      -> kfree(dpcm);
      Thread 2:
          dpcm_fe_dai_trigger()
              -> dpcm_be_dai_trigger()
                  -> snd_soc_dpcm_can_be_free_stop()
                      -> if (dpcm->fe == fe)
      
      Excpetion Scenario:
      	two FE link to same BE
      	FE1 -> BE
      	FE2 ->
      
      	Thread 1: switch of mixer between FE2 -> BE
      	Thread 2: pcm_stop FE1
      
      Exception:
      
      Unable to handle kernel paging request at virtual address dead0000000000e0
      
      pc=<> [<ffffff8960e2cd10>] dpcm_be_dai_trigger+0x29c/0x47c
      	sound/soc/soc-pcm.c:3226
      		if (dpcm->fe == fe)
      lr=<> [<ffffff8960e2f694>] dpcm_fe_dai_do_trigger+0x94/0x26c
      
      Backtrace:
      [<ffffff89602dba80>] notify_die+0x68/0xb8
      [<ffffff896028c7dc>] die+0x118/0x2a8
      [<ffffff89602a2f84>] __do_kernel_fault+0x13c/0x14c
      [<ffffff89602a27f4>] do_translation_fault+0x64/0xa0
      [<ffffff8960280cf8>] do_mem_abort+0x4c/0xd0
      [<ffffff8960282ad0>] el1_da+0x24/0x40
      [<ffffff8960e2cd10>] dpcm_be_dai_trigger+0x29c/0x47c
      [<ffffff8960e2f694>] dpcm_fe_dai_do_trigger+0x94/0x26c
      [<ffffff8960e2edec>] dpcm_fe_dai_trigger+0x3c/0x44
      [<ffffff8960de5588>] snd_pcm_do_stop+0x50/0x5c
      [<ffffff8960dded24>] snd_pcm_action+0xb4/0x13c
      [<ffffff8960ddfdb4>] snd_pcm_drop+0xa0/0x128
      [<ffffff8960de69bc>] snd_pcm_common_ioctl+0x9d8/0x30f0
      [<ffffff8960de1cac>] snd_pcm_ioctl_compat+0x29c/0x2f14
      [<ffffff89604c9d60>] compat_SyS_ioctl+0x128/0x244
      [<ffffff8960283740>] el0_svc_naked+0x34/0x38
      [<ffffffffffffffff>] 0xffffffffffffffff
      Signed-off-by: NKaiChieh Chuang <kaichieh.chuang@mediatek.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      bbfaa7d3
  20. 12 3月, 2019 1 次提交
    • K
      ASoC: dpcm: prevent snd_soc_dpcm use after free · a9764869
      KaiChieh Chuang 提交于
      The dpcm get from fe_clients/be_clients
      may be free before use
      
      Add a spin lock at snd_soc_card level,
      to protect the dpcm instance.
      The lock may be used in atomic context, so use spin lock.
      
      Use irq spin lock version,
      since the lock may be used in interrupts.
      
      possible race condition between
      void dpcm_be_disconnect(
      	...
      	list_del(&dpcm->list_be);
      	list_del(&dpcm->list_fe);
      	kfree(dpcm);
      	...
      
      and
      	for_each_dpcm_fe()
      	for_each_dpcm_be*()
      
      race condition example
      Thread 1:
          snd_soc_dapm_mixer_update_power()
              -> soc_dpcm_runtime_update()
                  -> dpcm_be_disconnect()
                      -> kfree(dpcm);
      Thread 2:
          dpcm_fe_dai_trigger()
              -> dpcm_be_dai_trigger()
                  -> snd_soc_dpcm_can_be_free_stop()
                      -> if (dpcm->fe == fe)
      
      Excpetion Scenario:
      	two FE link to same BE
      	FE1 -> BE
      	FE2 ->
      
      	Thread 1: switch of mixer between FE2 -> BE
      	Thread 2: pcm_stop FE1
      
      Exception:
      
      Unable to handle kernel paging request at virtual address dead0000000000e0
      
      pc=<> [<ffffff8960e2cd10>] dpcm_be_dai_trigger+0x29c/0x47c
      	sound/soc/soc-pcm.c:3226
      		if (dpcm->fe == fe)
      lr=<> [<ffffff8960e2f694>] dpcm_fe_dai_do_trigger+0x94/0x26c
      
      Backtrace:
      [<ffffff89602dba80>] notify_die+0x68/0xb8
      [<ffffff896028c7dc>] die+0x118/0x2a8
      [<ffffff89602a2f84>] __do_kernel_fault+0x13c/0x14c
      [<ffffff89602a27f4>] do_translation_fault+0x64/0xa0
      [<ffffff8960280cf8>] do_mem_abort+0x4c/0xd0
      [<ffffff8960282ad0>] el1_da+0x24/0x40
      [<ffffff8960e2cd10>] dpcm_be_dai_trigger+0x29c/0x47c
      [<ffffff8960e2f694>] dpcm_fe_dai_do_trigger+0x94/0x26c
      [<ffffff8960e2edec>] dpcm_fe_dai_trigger+0x3c/0x44
      [<ffffff8960de5588>] snd_pcm_do_stop+0x50/0x5c
      [<ffffff8960dded24>] snd_pcm_action+0xb4/0x13c
      [<ffffff8960ddfdb4>] snd_pcm_drop+0xa0/0x128
      [<ffffff8960de69bc>] snd_pcm_common_ioctl+0x9d8/0x30f0
      [<ffffff8960de1cac>] snd_pcm_ioctl_compat+0x29c/0x2f14
      [<ffffff89604c9d60>] compat_SyS_ioctl+0x128/0x244
      [<ffffff8960283740>] el0_svc_naked+0x34/0x38
      [<ffffffffffffffff>] 0xffffffffffffffff
      Signed-off-by: NKaiChieh Chuang <kaichieh.chuang@mediatek.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      a9764869
  21. 04 3月, 2019 1 次提交
    • J
      ASoC: soc-core: Fix probe deferral following prelink failure · c342febc
      Jonathan Hunter 提交于
      Commit 78a24e10 ("ASoC: soc-core: clear platform pointers on error")
      re-worked the clean-up of any platform pointers that may have been
      initialised by the function snd_soc_init_platform(). This commit missed
      one error path where if any of the prelinks for a soundcard failed to
      initialise, then these platform pointers would not be cleaned-up. This
      then prevents the soundcard from being initialised following a probe
      deferral when any of the soundcard prelinks cannot be found.
      
      Fix this by ensuring that soc_cleanup_platform() is called when
      initialising the soundcard prelinks fails.
      
      Fixes: 78a24e10 ("ASoC: soc-core: clear platform pointers on error")
      Signed-off-by: NJonathan Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c342febc
  22. 09 2月, 2019 1 次提交
    • P
      ASoC: core: don't increase component module refcount unconditionally · b450b878
      Pierre-Louis Bossart 提交于
      The ASoC core has for the longest time increased the module reference
      counts, even before the transition to the component model. This is
      probably fine on most platforms, but it introduces a deadlock case on
      Intel devices with the Skylake and SOF drivers which cannot be removed
      due to their reference counts being modified by the core.
      
      In these 2 cases, the PCI or ACPI driver .probe creates a platform
      device to let the machine driver .probe register the audio
      card. Conversely the PCI or ACPI driver .remove will unregister the
      platform device which results in the card being removed by the machine
      driver .remove.
      
      With ascii art, this can be represented as
      
      modprobe
      snd_soc_skl/
      soc-pci-dev/sof-acpci-dev  ----------> pci/acpi probe
             ^                                    |
             |                     ---------------|
             |                    |               |
             |                    V               V
          increase            register        register machine
          refcount            component       platform_device
             ^                                    |
             |                                    |
             |                                    V
          component <----   register card  <---- probe
          probe
      
      The issue is that by playing with the component's module reference
      counts during the card registration, it's no longer possible to remove
      the module which controls the component. This can be shown, e.g. with
      the following error:
      
      root@plb-XPS-13-9350:~# lsmod | grep snd_soc_skl
      snd_soc_skl           110592  1
      
      root@plb-XPS-13-9350:~# rmmod snd_soc_skl
      rmmod: ERROR: Module snd_soc_skl is in use
      
      Increasing the reference count during the component probe is not
      useful. If the PCI/ACPI module is removed, the card will be removed
      anyway.
      
      To avoid breaking existing platforms and allowing Intel platforms to
      safely deal with module load/unload cases, this patch introduces a
      flag which needs to be set during the component initialization. This
      is a strictly opt-in capability that should only be used when the
      handling of the component module does not require a reference count
      increase to prevent removal during use.
      
      Note that this solution is not directly applicable to the legacy
      Atom/SST driver, which uses a different device hierarchy. There are
      however additional refcount issues which prevent the ACPI driver from
      being removed. This is a different issue which would need a different
      patch.
      Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      b450b878
  23. 04 2月, 2019 1 次提交
    • C
      ASoC: soc-core: clear platform pointers on error · 78a24e10
      Curtis Malainey 提交于
      Originally snd_soc_init_platform was not cleaning up its pointers, this
      was fixed to always reallocate dynamic memory but created a memory leak
      when snd_soc_init_platform was called multiple times during the same
      probe attempt and also threw away any changes made to the struct between
      calls. In order to avoid reallocating memory that is still valid, the
      behaviour will be changed to clear the dynamically set pointers on a
      probe error and a unregister event and snd_soc_init_platform will go
      back to its original behaviour of only allocating null pointers so it will
      stop throwing away valid changes.
      Signed-off-by: NCurtis Malainey <cujomalainey@chromium.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      78a24e10
  24. 03 2月, 2019 1 次提交
  25. 28 1月, 2019 1 次提交