* [PATCH linux-next v1 0/2] misc fix in src.c
@ 2019-03-07 2:34 Jiada Wang
2019-03-07 2:34 ` [PATCH linux-next v1 1/2] ASoC: rsnd: src: Avoid a potential deadlock Jiada Wang
2019-03-07 2:34 ` [PATCH linux-next v1 2/2] ASoC: rsnd: src: fix compiler warnings Jiada Wang
0 siblings, 2 replies; 5+ messages in thread
From: Jiada Wang @ 2019-03-07 2:34 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx
Cc: alsa-devel, linux-kernel
two issues were found due to linux-next commit
7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")
this patch-set address these two issues
Jiada Wang (2):
ASoC: rsnd: src: Avoid a potential deadlock
ASoC: rsnd: src: fix compiler warnings
sound/soc/sh/rcar/core.c | 3 +++
sound/soc/sh/rcar/rsnd.h | 5 +++++
sound/soc/sh/rcar/src.c | 21 +++++++--------------
3 files changed, 15 insertions(+), 14 deletions(-)
--
2.19.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH linux-next v1 1/2] ASoC: rsnd: src: Avoid a potential deadlock
2019-03-07 2:34 [PATCH linux-next v1 0/2] misc fix in src.c Jiada Wang
@ 2019-03-07 2:34 ` Jiada Wang
2019-03-07 2:47 ` Kuninori Morimoto
2019-03-07 2:34 ` [PATCH linux-next v1 2/2] ASoC: rsnd: src: fix compiler warnings Jiada Wang
1 sibling, 1 reply; 5+ messages in thread
From: Jiada Wang @ 2019-03-07 2:34 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx
Cc: alsa-devel, linux-kernel
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>
---
sound/soc/sh/rcar/core.c | 3 +++
sound/soc/sh/rcar/rsnd.h | 5 +++++
sound/soc/sh/rcar/src.c | 9 +--------
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 022996d2db13..c2d466fe191f 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1680,6 +1680,7 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv,
static int rsnd_probe(struct platform_device *pdev)
{
struct rsnd_priv *priv;
+ struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct rsnd_dai *rdai;
int (*probe_func[])(struct rsnd_priv *priv) = {
@@ -1706,6 +1707,8 @@ static int rsnd_probe(struct platform_device *pdev)
priv->pdev = pdev;
priv->flags = (unsigned long)of_device_get_match_data(dev);
+ if (of_device_is_compatible(np, "renesas,rcar_sound-r8a77990"))
+ priv->flags |= RSND_SOC_E;
spin_lock_init(&priv->lock);
/*
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 90625c57847b..0e6ef4e18400 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 db81e066b92e..45096a66c074 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.19.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH linux-next v1 2/2] ASoC: rsnd: src: fix compiler warnings
2019-03-07 2:34 [PATCH linux-next v1 0/2] misc fix in src.c Jiada Wang
2019-03-07 2:34 ` [PATCH linux-next v1 1/2] ASoC: rsnd: src: Avoid a potential deadlock Jiada Wang
@ 2019-03-07 2:34 ` Jiada Wang
2019-03-07 2:48 ` Kuninori Morimoto
1 sibling, 1 reply; 5+ messages in thread
From: Jiada Wang @ 2019-03-07 2:34 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx
Cc: alsa-devel, linux-kernel
compiler complains about following declarations
sound/soc/sh/rcar/src.c:174:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static u32 bsdsr_table_pattern1[] = {
^~~~~
sound/soc/sh/rcar/src.c:183:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static u32 bsdsr_table_pattern2[] = {
^~~~~
sound/soc/sh/rcar/src.c:192:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static u32 bsisr_table[] = {
^~~~~
sound/soc/sh/rcar/src.c:201:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static u32 chan288888[] = {
^~~~~
sound/soc/sh/rcar/src.c:210:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static u32 chan244888[] = {
^~~~~
sound/soc/sh/rcar/src.c:219:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static u32 chan222222[] = {
^~~~~
This patch moves the 'static' keyword to the front of the
declaration to fix the compiler warnings
Fixes: linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
sound/soc/sh/rcar/src.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index 45096a66c074..585ffba0244b 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -134,7 +134,7 @@ unsigned int rsnd_src_get_rate(struct rsnd_priv *priv,
return rate;
}
-const static u32 bsdsr_table_pattern1[] = {
+static const u32 bsdsr_table_pattern1[] = {
0x01800000, /* 6 - 1/6 */
0x01000000, /* 6 - 1/4 */
0x00c00000, /* 6 - 1/3 */
@@ -143,7 +143,7 @@ const static u32 bsdsr_table_pattern1[] = {
0x00400000, /* 6 - 1 */
};
-const static u32 bsdsr_table_pattern2[] = {
+static const u32 bsdsr_table_pattern2[] = {
0x02400000, /* 6 - 1/6 */
0x01800000, /* 6 - 1/4 */
0x01200000, /* 6 - 1/3 */
@@ -152,7 +152,7 @@ const static u32 bsdsr_table_pattern2[] = {
0x00600000, /* 6 - 1 */
};
-const static u32 bsisr_table[] = {
+static const u32 bsisr_table[] = {
0x00100060, /* 6 - 1/6 */
0x00100040, /* 6 - 1/4 */
0x00100030, /* 6 - 1/3 */
@@ -161,7 +161,7 @@ const static u32 bsisr_table[] = {
0x00100020, /* 6 - 1 */
};
-const static u32 chan288888[] = {
+static const u32 chan288888[] = {
0x00000006, /* 1 to 2 */
0x000001fe, /* 1 to 8 */
0x000001fe, /* 1 to 8 */
@@ -170,7 +170,7 @@ const static u32 chan288888[] = {
0x000001fe, /* 1 to 8 */
};
-const static u32 chan244888[] = {
+static const u32 chan244888[] = {
0x00000006, /* 1 to 2 */
0x0000001e, /* 1 to 4 */
0x0000001e, /* 1 to 4 */
@@ -179,7 +179,7 @@ const static u32 chan244888[] = {
0x000001fe, /* 1 to 8 */
};
-const static u32 chan222222[] = {
+static const u32 chan222222[] = {
0x00000006, /* 1 to 2 */
0x00000006, /* 1 to 2 */
0x00000006, /* 1 to 2 */
--
2.19.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH linux-next v1 1/2] ASoC: rsnd: src: Avoid a potential deadlock
2019-03-07 2:34 ` [PATCH linux-next v1 1/2] ASoC: rsnd: src: Avoid a potential deadlock Jiada Wang
@ 2019-03-07 2:47 ` Kuninori Morimoto
0 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2019-03-07 2:47 UTC (permalink / raw)
To: Jiada Wang; +Cc: lgirdwood, broonie, perex, tiwai, alsa-devel, linux-kernel
Hi Jiada
Thank you for your patch
> 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>
> ---
(snip)
> @@ -1706,6 +1707,8 @@ static int rsnd_probe(struct platform_device *pdev)
>
> priv->pdev = pdev;
> priv->flags = (unsigned long)of_device_get_match_data(dev);
> + if (of_device_is_compatible(np, "renesas,rcar_sound-r8a77990"))
> + priv->flags |= RSND_SOC_E;
> spin_lock_init(&priv->lock);
Updating rsnd_of_match is nice idea
Maybe like this (not tested)
------------
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 9834474..e7ebc75 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -107,9 +107,12 @@
SNDRV_PCM_FMTBIT_S24_LE)
static const struct of_device_id rsnd_of_match[] = {
+ /* General Handling */
{ .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) },
{},
};
------------
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH linux-next v1 2/2] ASoC: rsnd: src: fix compiler warnings
2019-03-07 2:34 ` [PATCH linux-next v1 2/2] ASoC: rsnd: src: fix compiler warnings Jiada Wang
@ 2019-03-07 2:48 ` Kuninori Morimoto
0 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2019-03-07 2:48 UTC (permalink / raw)
To: Jiada Wang; +Cc: lgirdwood, broonie, perex, tiwai, alsa-devel, linux-kernel
Hi Jiada
Thank you for your patch
> This patch moves the 'static' keyword to the front of the
> declaration to fix the compiler warnings
>
> 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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-07 2:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 2:34 [PATCH linux-next v1 0/2] misc fix in src.c Jiada Wang
2019-03-07 2:34 ` [PATCH linux-next v1 1/2] ASoC: rsnd: src: Avoid a potential deadlock Jiada Wang
2019-03-07 2:47 ` Kuninori Morimoto
2019-03-07 2:34 ` [PATCH linux-next v1 2/2] ASoC: rsnd: src: fix compiler warnings Jiada Wang
2019-03-07 2:48 ` Kuninori Morimoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).