All of lore.kernel.org
 help / color / mirror / Atom feed
From: biju.das@bp.renesas.com (Biju Das)
To: cip-dev@lists.cip-project.org
Subject: [cip-dev] [PATCH 4.19.y-cip 48/57] ASoC: rsnd: src: Avoid a potential deadlock
Date: Thu, 17 Oct 2019 08:05:20 +0100	[thread overview]
Message-ID: <1571295929-47286-49-git-send-email-biju.das@bp.renesas.com> (raw)
In-Reply-To: <1571295929-47286-1-git-send-email-biju.das@bp.renesas.com>

From: Jiada Wang <jiada_wang@mentor.com>

commit ba164a49f8f7390b036713bf8a70a150a938c670 upstream.

lockdep warns us that priv->lock and k->k_lock can cause a
deadlock when after acquire of k->k_lock, process is interrupted
by src, while in another routine of src .init, k->k_lock is
acquired with priv->lock held.

This patch avoids a potential deadlock by not calling soc_device_match()
in SRC .init callback, instead it adds new soc fields in priv->flags to
differentiate SoCs.

Fixes: linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 sound/soc/sh/rcar/core.c | 2 ++
 sound/soc/sh/rcar/rsnd.h | 5 +++++
 sound/soc/sh/rcar/src.c  | 9 +--------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 96d2b39..f361118 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -110,6 +110,8 @@ static const struct of_device_id rsnd_of_match[] = {
 	{ .compatible = "renesas,rcar_sound-gen1", .data = (void *)RSND_GEN1 },
 	{ .compatible = "renesas,rcar_sound-gen2", .data = (void *)RSND_GEN2 },
 	{ .compatible = "renesas,rcar_sound-gen3", .data = (void *)RSND_GEN3 },
+	/* Special Handling */
+	{ .compatible = "renesas,rcar_sound-r8a77990", .data = (void *)(RSND_GEN3 | RSND_SOC_E) },
 	{},
 };
 MODULE_DEVICE_TABLE(of, rsnd_of_match);
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 90625c5..0e6ef4e1 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -607,6 +607,8 @@ struct rsnd_priv {
 #define RSND_GEN1	(1 << 0)
 #define RSND_GEN2	(2 << 0)
 #define RSND_GEN3	(3 << 0)
+#define RSND_SOC_MASK	(0xFF << 4)
+#define RSND_SOC_E	(1 << 4) /* E1/E2/E3 */
 
 	/*
 	 * below value will be filled on rsnd_gen_probe()
@@ -679,6 +681,9 @@ struct rsnd_priv {
 #define rsnd_is_gen1(priv)	(((priv)->flags & RSND_GEN_MASK) == RSND_GEN1)
 #define rsnd_is_gen2(priv)	(((priv)->flags & RSND_GEN_MASK) == RSND_GEN2)
 #define rsnd_is_gen3(priv)	(((priv)->flags & RSND_GEN_MASK) == RSND_GEN3)
+#define rsnd_is_e3(priv)	(((priv)->flags & \
+					(RSND_GEN_MASK | RSND_SOC_MASK)) == \
+					(RSND_GEN3 | RSND_SOC_E))
 
 #define rsnd_flags_has(p, f) ((p)->flags & (f))
 #define rsnd_flags_set(p, f) ((p)->flags |= (f))
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index db81e06..45096a6 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -14,7 +14,6 @@
  */
 
 #include "rsnd.h"
-#include <linux/sys_soc.h>
 
 #define SRC_NAME "src"
 
@@ -189,18 +188,12 @@ const static u32 chan222222[] = {
 	0x00000006, /* 1 to 2 */
 };
 
-static const struct soc_device_attribute ov_soc[] = {
-	{ .soc_id = "r8a77990" }, /* E3 */
-	{ /* sentinel */ }
-};
-
 static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
 				      struct rsnd_mod *mod)
 {
 	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
-	const struct soc_device_attribute *soc = soc_device_match(ov_soc);
 	int is_play = rsnd_io_is_play(io);
 	int use_src = 0;
 	u32 fin, fout;
@@ -307,7 +300,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
 	/*
 	 * E3 need to overwrite
 	 */
-	if (soc)
+	if (rsnd_is_e3(priv))
 		switch (rsnd_mod_id(mod)) {
 		case 0:
 		case 4:
-- 
2.7.4

  parent reply	other threads:[~2019-10-17  7:05 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17  7:04 [cip-dev] [PATCH 4.19.y-cip 00/57] Audio improvements/SSIU BUSIF/ Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 01/57] ASoC: rsnd: add warning message to rsnd_kctrl_accept_runtime() Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 02/57] ASoC: rsnd: add support for 16/24 bit slot widths Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 03/57] ASoC: rsnd: add support for 8 bit S8 format Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 04/57] ASoC: rsnd: remove is_play parameter from hw_rule function Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 05/57] ASoC: rsnd: ssi: Fix issue in dma data address assignment Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 06/57] ASoC: rsnd: ssi: Check runtime channel number rather than hw_params Biju Das
2019-10-20  9:12   ` Pavel Machek
2019-10-21 12:10     ` Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 07/57] ASoc: rsnd: dma: Calculate dma address with consider of BUSIF Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 08/57] ASoc: rsnd: dma: Calculate PDMACHCRE " Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 09/57] ASoC: rsnd: ssiu: Support BUSIF other than BUSIF0 Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 10/57] ASoC: rsnd: ssiu: Support to init different BUSIF instance Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 11/57] ASoC: rsnd: merge .nolock_start and .prepare Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 12/57] ASoC: rsnd: gen: use tab instead of white-space Biju Das
2019-10-20  9:22   ` Pavel Machek
2019-10-21 12:12     ` Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 13/57] ASoC: rsnd: don't use %p for dev_dbg() Biju Das
2019-10-20  9:27   ` Pavel Machek
2019-10-21 12:17     ` Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 14/57] ASoC: add for_each_rtd_codec_dai() macro Biju Das
2019-10-20  9:36   ` Pavel Machek
2019-10-21 12:18     ` Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 15/57] ASoC: convert for_each_rtd_codec_dai() for missing part Biju Das
2019-10-20  9:41   ` Pavel Machek
2019-10-21 12:22     ` Biju Das
2019-10-23  1:20       ` Kuninori Morimoto
2019-10-23  6:47         ` Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 16/57] ASoC: add for_each_dpcm_fe() macro Biju Das
2019-10-20  9:48   ` Pavel Machek
2019-10-21 12:26     ` Biju Das
2019-10-23  1:28       ` Kuninori Morimoto
2019-11-18 15:30         ` Pavel Machek
2019-11-19  1:24           ` Kuninori Morimoto
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 17/57] ASoC: add for_each_dpcm_be() macro Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 18/57] ASoC: rsnd: fixup SSI clock during suspend/resume modes Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 19/57] ASoC: rsnd: use 32bit TDM width as default Biju Das
2019-10-20  9:49   ` Pavel Machek
2019-10-21 13:54     ` Biju Das
2019-10-23  1:45       ` Kuninori Morimoto
2019-11-18 15:32         ` Pavel Machek
2019-11-19  0:53           ` Kuninori Morimoto
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 20/57] ASoC: rsnd: enable TDM settings for SSI parent Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 21/57] ASoC: rsnd: tidyup SSICR::SWSP for TDM Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 22/57] ASoC: rsnd: move .get_status under rsnd_mod_ops Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 23/57] ASoC: rsnd: add .get_id/.get_id_sub Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 24/57] ASoC: rsnd: rsnd_mod_name() handles both name and ID Biju Das
2019-10-20 10:34   ` Pavel Machek
2019-10-21 13:26     ` Biju Das
2019-11-18 15:34       ` Pavel Machek
2019-11-18 15:41         ` Biju Das
2019-11-19  1:03           ` Kuninori Morimoto
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 25/57] ASoC: rsnd: remove endpoint bidirectional check Biju Das
2019-10-20 10:38   ` Pavel Machek
2019-10-21 13:40     ` Biju Das
2019-10-23  1:38       ` Kuninori Morimoto
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 26/57] ASoC: rsnd: rename rsnd_runtime_is_ssi_xxx() Biju Das
2019-10-17  7:04 ` [cip-dev] [PATCH 4.19.y-cip 27/57] ASoC: rsnd: use defined io_playback/io_capture Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 28/57] ASoC: rsnd: move HDMI information from ssi.c to core.c Biju Das
2019-10-20 10:40   ` Pavel Machek
2019-10-21 13:48     ` Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 29/57] ASoC: rsnd: handle DPCM converted rate/chan under core Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 30/57] ASoC: rsnd: add SSIU BUSIF support Biju Das
2019-10-20 10:50   ` Pavel Machek
2019-10-21 13:46     ` Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 31/57] ASoC: rsnd: add TDM Split mode support Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 32/57] ASoC: rsnd: use ring buffer for rsnd_mod_name() Biju Das
2019-10-20 10:54   ` Pavel Machek
2019-10-21 13:50     ` Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 33/57] ASoC: rsnd: tidyup rsnd_parse_connect_ssiu_compatible() Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 34/57] ASoC: rsnd: makes rsnd_ssi_is_dma_mode() static Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 35/57] ASoC: rsnd: tidyup registering method for rsnd_kctrl_new() Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 36/57] ASoC: rsnd: indicates Channel and Mode for debug Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 37/57] ASoC: rsnd: fixup mod ID for CTU regmap read/write Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 38/57] ASoC: rsnd: add missing TDM Split mode support for simple-card Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 39/57] ASoC: rsnd: remove RSND_REG_ from rsnd_reg Biju Das
2019-10-25 12:03   ` Pavel Machek
2019-10-28  0:36     ` Kuninori Morimoto
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 40/57] ASoC: rsnd: update BSDSR/BSDISR handling Biju Das
2019-10-27  7:33   ` Pavel Machek
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 41/57] ASoC: rsnd: fixup MIX kctrl registration Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 42/57] ASoC: rsnd: synchronize connection check for simple-card/audio-graph Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 43/57] ASoC: rsnd: fixup TDM Split mode check for CTU Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 44/57] ASoC: sh: Avoid passing NULL to memory allocators Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 45/57] ASoC: sh: Drop superfluous PCM preallocation error checks Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 46/57] ASoC: rsnd: ssiu: correct shift bit for ssiu9 Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 47/57] ASoC: rsnd: gen: fix SSI9 4/5/6/7 busif related register address Biju Das
2019-10-17  7:05 ` Biju Das [this message]
2019-10-27  7:45   ` [cip-dev] [PATCH 4.19.y-cip 48/57] ASoC: rsnd: src: Avoid a potential deadlock Pavel Machek
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 49/57] ASoC: rsnd: src: fix compiler warnings Biju Das
2019-10-27  7:47   ` Pavel Machek
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 50/57] ASoC: rsnd: fixup 6ch settings to 8ch Biju Das
2019-10-27  7:51   ` Pavel Machek
2019-10-28  0:43     ` Kuninori Morimoto
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 51/57] ASoC: rsnd: move pcm_new from snd_soc_component_driver to snd_soc_dai_driver Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 52/57] ASoC: rsnd: fixup mod ID calculation in rsnd_ctu_probe_ Biju Das
2019-10-27  7:56   ` Pavel Machek
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 53/57] ASoC: rsnd: ssiu: tidyup SSI_MODE1/2 settings Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 54/57] ASoC: rsnd: add missing pin sharing with SSI9 Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 55/57] ASoC: rsnd: Support hw_free() callback at DAI level Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 56/57] ASoC: rsnd: do error check after rsnd_channel_normalization() Biju Das
2019-10-17  7:05 ` [cip-dev] [PATCH 4.19.y-cip 57/57] arm64: dts: renesas: r8a774a1: Add SSIU support for sound Biju Das
2019-10-18 21:49 ` [cip-dev] [PATCH 4.19.y-cip 00/57] Audio improvements/SSIU BUSIF/ Pavel Machek
2019-11-14 16:20 ` Biju Das
2019-11-15 21:46   ` Pavel Machek
2019-11-18  7:43     ` Biju Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1571295929-47286-49-git-send-email-biju.das@bp.renesas.com \
    --to=biju.das@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.