misc fix in src.c
Subsystems (3)
v2 cover misc fix in src.c
two issues were found due to linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling") this patch-set address these two issues
---
v2: Update rsnd_of_match table instead of set priv->flags in probe
v1: initial version
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(-)
Signature · 1 line
2.19.2
PATCH v2 1/2 ASoC: rsnd: src: Avoid a potential deadlock
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.
--- 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(-)
sound/soc/sh/rcar/core.c +2 -0
@@ -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);
sound/soc/sh/rcar/rsnd.h +5 -0
@@ -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))
sound/soc/sh/rcar/src.c +1 -8
@@ -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 :
Signature · 1 line
2.19.2
Mark Brown
maintainerApplied "ASoC: rsnd: src: Avoid a potential deadlock" to the asoc tree
The patch
ASoC: rsnd: src: Avoid a potential deadlock
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
ba164a49f8f7390b036713bf8a70a150a938c670Mon Sep 17 00:00:00 2001
From: Jiada Wang <[email protected]>
Date: Thu, 7 Mar 2019 15:15:53 +0900
Subject: [PATCH] ASoC: rsnd: src: Avoid a potential deadlock
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.
--- 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(-)
sound/soc/sh/rcar/core.c +2 -0
@@ -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);
sound/soc/sh/rcar/rsnd.h +5 -0
@@ -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))
sound/soc/sh/rcar/src.c +1 -8
@@ -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 :
Signature · 1 line
2.20.1
Re: [PATCH linux-next v2 1/2] ASoC: rsnd: src: Avoid a potential deadlock
In reply to Jiada WangHi Jiada, Fabrizio,
Quoted 22 lines · Jiada Wang
lockdep warns us that
priv->lockandk->k_lockcan cause a deadlock when after acquire ofk->k_lock, process is interrupted by src, while in another routine of src .init,k->k_lockis acquired withpriv->lockheld.This patch avoids a potential deadlock by not calling
soc_device_match()in SRC .init callback, instead it adds new soc fields inpriv->flagsto differentiate SoCs.Fixes linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")Signed-off-by Jiada Wang <[email protected]>--- 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(-)sound/soc/sh/rcar/core.c +0
-0
sound/soc/sh/rcar/core.c static const struct of_device_id rsnd_of_match[] = { · line 114
Quoted 5 lines
sound/soc/sh/rcar/core.c +2
-0@@ -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) },
I guess we need an entry for RZ/G2E, too?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH linux-next v2 1/2] ASoC: rsnd: src: Avoid a potential deadlock
Hi Geert
Quoted 20 lines · Geert Uytterhoeven
Hi Jiada, Fabrizio,
Quoted 17 lines · Jiada Wang
lockdep warns us that
priv->lockandk->k_lockcan cause a deadlock when after acquire ofk->k_lock, process is interrupted by src, while in another routine of src .init,k->k_lockis acquired withpriv->lockheld.This patch avoids a potential deadlock by not calling
soc_device_match()in SRC .init callback, instead it adds new soc fields inpriv->flagsto differentiate SoCs.Fixes linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")Signed-off-by Jiada Wang <[email protected]>--- 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(-)
Quoted 13 lines
sound/soc/sh/rcar/core.c static const struct of_device_id rsnd_of_match[] = { · line 114
Quoted 10 lines
sound/soc/sh/rcar/core.c +2
-0@@ -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) },I guess we need an entry for RZ/G2E, too?
Sorry, I don't have user manual for RZ/G2E,
if you can let me know where to find RZ/G2E's user manual, I can add entry for these SoCs
Thanks,
Jiada
Quoted 4 lines
Gr{oetje,eeting}s,
Geert
RE: [PATCH linux-next v2 1/2] ASoC: rsnd: src: Avoid a potential deadlock
Hello Jiada,
Quoted 4 lines
From: Jiada Wang <[email protected]>
Sent: 13 March 2019 11:56
Subject: Re: [PATCH linux-next v2 1/2] ASoC: rsnd: src: Avoid a potential deadlock
Quoted 35 lines
Hi Geert
Quoted 32 lines · Geert Uytterhoeven
Hi Jiada, Fabrizio,
Quoted 22 lines · Jiada Wang
lockdep warns us that
priv->lockandk->k_lockcan cause a deadlock when after acquire ofk->k_lock, process is interrupted by src, while in another routine of src .init,k->k_lockis acquired withpriv->lockheld.This patch avoids a potential deadlock by not calling
soc_device_match()in SRC .init callback, instead it adds new soc fields inpriv->flagsto differentiate SoCs.Fixes linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")Signed-off-by Jiada Wang <[email protected]>--- 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(-)sound/soc/sh/rcar/core.c +0
-0sound/soc/sh/rcar/core.c static const struct of_device_id rsnd_of_match[] = { · line 114
Quoted 5 lines
sound/soc/sh/rcar/core.c +2
-0@@ -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) },I guess we need an entry for RZ/G2E, too?
Geert has a point, I am looking at the User manual for the RZ/G2E and it looks like the implementation for the RZ/G2E is the same as the one for the r8a77990
Quoted 4 lines
Quoted 1 line
Sorry, I don't have user manual for RZ/G2E,
if you can let me know where to find RZ/G2E's user manual, I can add entry for these SoCs
If you prefer I could add that after running some tests? I do have a board with a RZ/G2E.
Thanks,
Fab
Quoted 7 lines
Thanks,
JiadaQuoted 4 lines
Gr{oetje,eeting}s,
Geert
Re: [PATCH linux-next v2 1/2] ASoC: rsnd: src: Avoid a potential deadlock
Hi Fabrizio
Quoted 46 lines · Fabrizio Castro
Hello Jiada,
Quoted 4 lines
From: Jiada Wang <[email protected]>
Sent: 13 March 2019 11:56
Subject: Re: [PATCH linux-next v2 1/2] ASoC: rsnd: src: Avoid a potential deadlockQuoted 35 lines
Hi Geert
Quoted 32 lines · Geert Uytterhoeven
Hi Jiada, Fabrizio,
Quoted 22 lines · Jiada Wang
lockdep warns us that
priv->lockandk->k_lockcan cause a deadlock when after acquire ofk->k_lock, process is interrupted by src, while in another routine of src .init,k->k_lockis acquired withpriv->lockheld.This patch avoids a potential deadlock by not calling
soc_device_match()in SRC .init callback, instead it adds new soc fields inpriv->flagsto differentiate SoCs.Fixes linux-next commit 7674bec4fc09 ("ASoC: rsnd: update BSDSR/BSDISR handling")Signed-off-by Jiada Wang <[email protected]>--- 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(-)sound/soc/sh/rcar/core.c +0
-0sound/soc/sh/rcar/core.c static const struct of_device_id rsnd_of_match[] = { · line 114
Quoted 5 lines
sound/soc/sh/rcar/core.c +2
-0@@ -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) },I guess we need an entry for RZ/G2E, too?
Geert has a point, I am looking at the User manual for the RZ/G2E and it looks like the implementation for the RZ/G2E is the same as the one for the r8a77990
Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Sorry, I don't have user manual for RZ/G2E,
if you can let me know where to find RZ/G2E's user manual, I can add entry for these SoCsIf you prefer I could add that after running some tests? I do have a board with a RZ/G2E.
Yes, please
since I have neither RZ/G2E board to test nor its user manual
Thanks,
Jiada
Quoted 10 lines
Thanks,
FabQuoted 7 lines
Thanks,
JiadaQuoted 4 lines
Gr{oetje,eeting}s,
Geert
PATCH v2 2/2 ASoC: rsnd: src: fix compiler warnings
In reply to Jiada Wangcompiler 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
--- sound/soc/sh/rcar/src.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/sh/rcar/src.c +6 -6
@@ -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 */
Signature · 1 line
2.19.2
Hi Jiada
Quoted 4 lines
two issues were found due to linux-next commit
7674bec4fc09("ASoC: rsnd: update BSDSR/BSDISR handling") this patch-set address these two issues
Quoted 8 lines
---
v2: Updatersnd_of_matchtable instead of setpriv->flagsin probev1: initial version
Jiada Wang (2):
ASoC: rsnd: src: Avoid a potential deadlock
ASoC: rsnd: src: fix compiler warnings
Thank you for your patches.
For both patches