1. 26 11月, 2020 1 次提交
    • K
      ASoC: soc-component: add mark for snd_soc_link_compr_startup/shutdown() · cd7c7d10
      Kuninori Morimoto 提交于
      soc_compr_open() does rollback when failed (A),
      but, it is almost same as soc_compr_free().
      
      	static int soc_compr_open(xxx)
      	{
      		...
      		if (ret < 0)
      			goto xxx_err;
      		...
      		return 0;
      
       ^	machine_err:
       |		...
       |	out:
      (A)		...
       |	pm_err:
       |		...
       v		return ret;
      	}
      
      The difference is
      soc_compr_free()  is for all dai/component/substream,
      rollback          is for succeeded part only.
      
      This kind of duplicated code can be a hotbed of bugs,
      thus, we want to share soc_compr_free() and rollback.
      	1) snd_soc_dai_compr_startup/shutdown()
      	2) snd_soc_component_compr_open/free()
      =>	3) snd_soc_link_compr_startup/shutdown()
      
      This patch is for 3) snd_soc_link_compr_startup/shutdown()
      and adds new cstream mark.
      It will mark cstream when startup() was suceeded.
      If rollback happen *after* that, it will check rollback flag
      and marked cstream.
      
      It cares *previous* startup() only now,
      but we might want to check *whole* marked cstream in the future.
      This patch is using macro so that it can be easily adjust to it.
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87k0ui5iwf.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      cd7c7d10
  2. 11 11月, 2020 1 次提交
  3. 27 10月, 2020 3 次提交
    • K
      ASoC: soc-pcm: add soc_pcm_hw_clean() and call it from soc_pcm_hw_params/free() · 4662c596
      Kuninori Morimoto 提交于
      soc_pcm_hw_params() does rollback when failed (A),
      but, it is almost same as soc_pcm_hw_free().
      
      	static int soc_pcm_hw_params(xxx)
      	{
      		...
      		if (ret < 0)
      			goto xxx_err;
      		...
      		return ret;
      
       ^	component_err:
       |		...
       |	interface_err:
      (A)		...
       |	codec_err:
       |		...
       v		return ret;
      	}
      
      The difference is
      soc_pcm_hw_free() is for all dai/component/substream,
      rollback          is for succeeded part only.
      
      This kind of duplicated code can be a hotbed of bugs,
      thus, we want to share soc_pcm_hw_free() and rollback.
      
      Now, soc_pcm_hw_params/free() are handling
      	1) snd_soc_link_hw_params/free()
      	2) snd_soc_pcm_component_hw_params/free()
      	3) snd_soc_dai_hw_params/free()
      
      Now, 1) to 3) are handled.
      This patch adds new soc_pcm_hw_clean() and call it from
      soc_pcm_hw_params() as rollback, and from soc_pcm_hw_free() as
      normal close handler.
      
      Other difference is that soc_pcm_hw_free() handles digital mute
      if it was last user. Rollback also handles it by this patch.
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87h7rhgqab.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      4662c596
    • K
      ASoC: soc-link: add mark for snd_soc_link_hw_params/free() · 918ad772
      Kuninori Morimoto 提交于
      soc_pcm_hw_params() does rollback when failed (A),
      but, it is almost same as soc_pcm_hw_free().
      
      	static int soc_pcm_hw_params(xxx)
      	{
      		...
      		if (ret < 0)
      			goto xxx_err;
      		...
      		return ret;
      
       ^	component_err:
       |		...
       |	interface_err:
      (A)		...
       |	codec_err:
       |		...
       v		return ret;
      	}
      
      The difference is
      soc_pcm_hw_free() is for all dai/component/substream,
      rollback          is for succeeded part only.
      
      This kind of duplicated code can be a hotbed of bugs,
      thus, we want to share soc_pcm_hw_free() and rollback.
      
      Now, soc_pcm_hw_params/free() are handling
      =>	1) snd_soc_link_hw_params/free()
      	2) snd_soc_pcm_component_hw_params/free()
      	3) snd_soc_dai_hw_params/free()
      
      This patch is for 1) snd_soc_link_hw_params/free().
      
      The idea of having bit-flag or counter is not enough for this purpose.
      For example if one DAI is used for 2xPlaybacks for some reasons,
      and if 1st Playback was succeeded but 2nd Playback was failed,
      2nd Playback rollback doesn't need to call shutdown.
      But it has succeeded bit-flag or counter via 1st Playback,
      thus, 2nd Playback rollback will call unneeded shutdown.
      And 1st Playback's necessary shutdown will not be called,
      because bit-flag or counter was cleared by wrong 2nd Playback rollback.
      
      To avoid such case, this patch marks substream pointer when hw_params() was
      succeeded. If rollback needed, it will check rollback flag and marked
      substream pointer.
      
      One note here ist that it cares *previous* hw_params() only now,
      but we might want to check *whole* marked substream in the future.
      This patch is using macro named "push/pop", so that it can be easily
      update.
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87lfgtgqba.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      918ad772
    • K
      ASoC: soc.h: remove for_each_rtd_dais_rollback() · 5560d8c6
      Kuninori Morimoto 提交于
      commit 140a4532 ("ASoC: soc-pcm: add soc_pcm_clean() and call it
      from soc_pcm_open/close()") uses soc_pcm_clean() and then
      for_each_rtd_dais_rollback() is no longer used.
      This patch removes it.
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87o8lpgqbp.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      5560d8c6
  4. 29 9月, 2020 1 次提交
    • K
      ASoC: soc-link: add mark for snd_soc_link_startup/shutdown() · 6064ed73
      Kuninori Morimoto 提交于
      soc_pcm_open() does rollback when failed (A),
      but, it is almost same as soc_pcm_close().
      
      	static int soc_pcm_open(xxx)
      	{
      		...
      		if (ret < 0)
      			goto xxx_err;
      		...
      		return 0;
      
       ^	config_err:
       |		...
       |	rtd_startup_err:
      (A)		...
       |	component_err:
       |		...
       v		return ret;
      	}
      
      The difference is
      soc_pcm_close() is for all dai/component/substream,
      rollback        is for succeeded part only.
      
      This kind of duplicated code can be a hotbed of bugs,
      thus, we want to share soc_pcm_close() and rollback.
      
      Now, soc_pcm_open/close() are handling
      	1) snd_soc_dai_startup/shutdown()
      =>	2) snd_soc_link_startup/shutdown()
      	3) snd_soc_component_module_get/put()
      	4) snd_soc_component_open/close()
      	5) pm_runtime_put/get()
      
      This patch is for 2) snd_soc_link_startup/shutdown().
      
      The idea of having bit-flag or counter is not enough for this purpose.
      For example if one DAI is used for 2xPlaybacks for some reasons,
      and if 1st Playback was succeeded but 2nd Playback was failed,
      2nd Playback rollback doesn't need to call shutdown.
      But it has succeeded bit-flag or counter via 1st Playback,
      thus, 2nd Playback rollback will call unneeded shutdown.
      And 1st Playback's necessary shutdown will not be called,
      because bit-flag or counter was cleared by wrong 2nd Playback rollback.
      
      To avoid such case, this patch marks substream pointer when startup() was
      succeeded. If rollback needed, it will check rollback flag and marked
      substream pointer.
      
      One note here is that it cares *current* startup() only now.
      but we might want to check *whole* marked substream in the future.
      This patch is using macro named "push/pop", so that it can be easily
      update.
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87k0webwnv.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      6064ed73
  5. 07 9月, 2020 1 次提交
  6. 28 8月, 2020 1 次提交
    • K
      ASoC: soc-core: add snd_soc_find_dai_with_mutex() · 20d9fdee
      Kuninori Morimoto 提交于
      commit 25612477 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
      added snd_soc_dai_link_set_capabilities().
      But it is using snd_soc_find_dai() (A) which is required client_mutex (B).
      And client_mutex is soc-core.c local.
      
      	struct snd_soc_dai *snd_soc_find_dai(xxx)
      	{
      		...
      (B)		lockdep_assert_held(&client_mutex);
      		...
      	}
      
      	void snd_soc_dai_link_set_capabilities(xxx)
      	{
      		...
      		for_each_pcm_streams(direction) {
      			...
      			for_each_link_cpus(dai_link, i, cpu) {
      (A)				dai = snd_soc_find_dai(cpu);
      				...
      			}
      			...
      			for_each_link_codecs(dai_link, i, codec) {
      (A)				dai = snd_soc_find_dai(codec);
      				...
      			}
      		}
      		...
      	}
      
      Because of these background, we will get WARNING if .config has CONFIG_LOCKDEP.
      
      	WARNING: CPU: 2 PID: 53 at sound/soc/soc-core.c:814 snd_soc_find_dai+0xf8/0x100
      	CPU: 2 PID: 53 Comm: kworker/2:1 Not tainted 5.7.0-rc1+ #328
      	Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT)
      	Workqueue: events deferred_probe_work_func
      	pstate: 60000005 (nZCv daif -PAN -UAO)
      	pc : snd_soc_find_dai+0xf8/0x100
      	lr : snd_soc_find_dai+0xf4/0x100
      	...
      	Call trace:
      	 snd_soc_find_dai+0xf8/0x100
      	 snd_soc_dai_link_set_capabilities+0xa0/0x16c
      	 graph_dai_link_of_dpcm+0x390/0x3c0
      	 graph_for_each_link+0x134/0x200
      	 graph_probe+0x144/0x230
      	 platform_drv_probe+0x5c/0xb0
      	 really_probe+0xe4/0x430
      	 driver_probe_device+0x60/0xf4
      
      snd_soc_find_dai() will be used from (X) CPU/Codec/Platform driver with
      mutex lock, and (Y) Card driver without mutex lock.
      This snd_soc_dai_link_set_capabilities() is for Card driver,
      this means called without mutex.
      This patch adds snd_soc_find_dai_with_mutex() to solve it.
      
      Fixes: 25612477 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87blixvuab.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      20d9fdee
  7. 27 8月, 2020 1 次提交
    • K
      ASoC: soc-core: add snd_soc_find_dai_with_mutex() · c1c277b2
      Kuninori Morimoto 提交于
      commit 25612477 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
      added snd_soc_dai_link_set_capabilities().
      But it is using snd_soc_find_dai() (A) which is required client_mutex (B).
      And client_mutex is soc-core.c local.
      
      	struct snd_soc_dai *snd_soc_find_dai(xxx)
      	{
      		...
      (B)		lockdep_assert_held(&client_mutex);
      		...
      	}
      
      	void snd_soc_dai_link_set_capabilities(xxx)
      	{
      		...
      		for_each_pcm_streams(direction) {
      			...
      			for_each_link_cpus(dai_link, i, cpu) {
      (A)				dai = snd_soc_find_dai(cpu);
      				...
      			}
      			...
      			for_each_link_codecs(dai_link, i, codec) {
      (A)				dai = snd_soc_find_dai(codec);
      				...
      			}
      		}
      		...
      	}
      
      Because of these background, we will get WARNING if .config has CONFIG_LOCKDEP.
      
      	WARNING: CPU: 2 PID: 53 at sound/soc/soc-core.c:814 snd_soc_find_dai+0xf8/0x100
      	CPU: 2 PID: 53 Comm: kworker/2:1 Not tainted 5.7.0-rc1+ #328
      	Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT)
      	Workqueue: events deferred_probe_work_func
      	pstate: 60000005 (nZCv daif -PAN -UAO)
      	pc : snd_soc_find_dai+0xf8/0x100
      	lr : snd_soc_find_dai+0xf4/0x100
      	...
      	Call trace:
      	 snd_soc_find_dai+0xf8/0x100
      	 snd_soc_dai_link_set_capabilities+0xa0/0x16c
      	 graph_dai_link_of_dpcm+0x390/0x3c0
      	 graph_for_each_link+0x134/0x200
      	 graph_probe+0x144/0x230
      	 platform_drv_probe+0x5c/0xb0
      	 really_probe+0xe4/0x430
      	 driver_probe_device+0x60/0xf4
      
      snd_soc_find_dai() will be used from (X) CPU/Codec/Platform driver with
      mutex lock, and (Y) Card driver without mutex lock.
      This snd_soc_dai_link_set_capabilities() is for Card driver,
      this means called without mutex.
      This patch adds snd_soc_find_dai_with_mutex() to solve it.
      
      Fixes: 25612477 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87blixvuab.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: NMark Brown <broonie@kernel.org>
      c1c277b2
  8. 18 8月, 2020 1 次提交
  9. 01 8月, 2020 3 次提交
  10. 24 7月, 2020 1 次提交
  11. 07 7月, 2020 1 次提交
    • M
      ASoC: core: Remove only the registered component in devm functions · 58f30150
      Maxime Ripard 提交于
      The ASoC devm_ functions that register a component
      (devm_snd_soc_register_component and devm_snd_dmaengine_pcm_register) will
      clean their component by running snd_soc_unregister_component.
      
      snd_soc_unregister_component will then remove all the components for the
      device that was used to register the component in the first place.
      
      However, some drivers register several components (such as a DAI and a
      dmaengine PCM) on the same device, and if the dmaengine PCM is registered
      first, then the DAI will be cleaned up first and
      snd_dmaengine_pcm_unregister will be called next.
      
      snd_dmaengine_pcm_unregister will then lookup the dmaengine PCM component
      on the device, and if there's one unregister that component and release its
      dmaengine channels. That doesn't happen in practice though since the first
      call to snd_soc_unregister_component removed all the components, so we
      never get the chance to release the dmaengine channels.
      
      In order to fix this, instead of removing all the components for a given
      device, we can simply remove the component that was registered in the first
      place. We should have the same number of component registration than we
      have components, so it should work just fine.
      Signed-off-by: NMaxime Ripard <maxime@cerno.tech>
      Link: https://lore.kernel.org/r/20200707074237.287171-1-maxime@cerno.techSigned-off-by: NMark Brown <broonie@kernel.org>
      58f30150
  12. 26 6月, 2020 1 次提交
  13. 23 6月, 2020 1 次提交
  14. 15 6月, 2020 1 次提交
  15. 12 6月, 2020 1 次提交
  16. 30 5月, 2020 8 次提交
  17. 27 5月, 2020 1 次提交
  18. 18 5月, 2020 1 次提交
  19. 08 5月, 2020 1 次提交
    • G
      ASoC: soc-core: Replace zero-length array with flexible-array · 2d6201ee
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Link: https://lore.kernel.org/r/20200507192228.GA16355@embeddedorSigned-off-by: NMark Brown <broonie@kernel.org>
      2d6201ee
  20. 29 4月, 2020 1 次提交
  21. 22 4月, 2020 1 次提交
  22. 14 4月, 2020 3 次提交
  23. 27 3月, 2020 1 次提交
  24. 21 3月, 2020 1 次提交
  25. 10 3月, 2020 3 次提交