* [PATCH v3 0/3] ASoC: remove component->id
@ 2025-05-16 0:45 Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 1/3] ASoC: qcom: use drvdata instead of component to keep id Kuninori Morimoto
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2025-05-16 0:45 UTC (permalink / raw)
To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Srinivas Kandagatla,
Takashi Iwai, linux-arm-msm, linux-sound
Hi Mark, Srinivas, Qcom members
snd_soc_component has "id", but no one is using it except Qcom. It is
initialized at snd_soc_component_initialize(), but Qcom overwrites it.
According to Srinivas, unfortunately, current Qcom lpass is broken.
But we can update it and then, avoid to use component->id.
Let's do it, and remove it.
Kuninori Morimoto (2):
ASoC: soc-core: save ID if param was set in fmt_single_name()
ASoC: remove component->id
Srinivas Kandagatla (1):
ASoC: qcom: use drvdata instead of component to keep id
include/sound/soc-component.h | 1 -
sound/soc/qcom/lpass-platform.c | 27 +++++++++++++++++----------
sound/soc/soc-core.c | 14 +++++++++-----
3 files changed, 26 insertions(+), 16 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] ASoC: qcom: use drvdata instead of component to keep id
2025-05-16 0:45 [PATCH v3 0/3] ASoC: remove component->id Kuninori Morimoto
@ 2025-05-16 0:46 ` Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 2/3] ASoC: soc-core: save ID if param was set in fmt_single_name() Kuninori Morimoto
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2025-05-16 0:46 UTC (permalink / raw)
To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Srinivas Kandagatla,
Takashi Iwai, linux-arm-msm, linux-sound
From: Srinivas Kandagatla <srini@kernel.org>
Qcom lpass is using component->id to keep DAI ID (A).
(S) static int lpass_platform_pcmops_open(
sruct snd_soc_component *component,
struct snd_pcm_substream *substream)
{ ^^^^^^^^^(B0)
...
(B1) struct snd_soc_pcm_runtime *soc_runtime = snd_soc_substream_to_rtd(substream);
(B2) struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(soc_runtime, 0);
...
(B3) unsigned int dai_id = cpu_dai->driver->id;
(A) component->id = dai_id;
...
}
This driver can get dai_id from substream (B0 - B3).
In this driver, below functions get dai_id from component->id (A).
(X) lpass_platform_pcmops_suspend()
(Y) lpass_platform_pcmops_resume()
(Z) lpass_platform_copy()
Here, (Z) can get it from substream (B0 - B3), don't need to use
component->id (A). On suspend/resume (X)(Y), dai_id can only be obtained
from component->id (A), because there is no substream (B0) in function
parameter.
But, component->id (A) itself should not be used for such purpose.
It is intilialized at snd_soc_component_initialize(), and parsed its ID
(= component->id) from device name (a).
int snd_soc_component_initialize(...)
{
...
if (!component->name) {
(a) component->name = fmt_single_name(dev, &component->id);
... ^^^^^^^^^^^^^
}
...
}
Unfortunately, current code is broken to start with.
There are many regmaps that the driver cares about, however its only
managing one (either dp or i2s) in component suspend/resume path.
I2S regmap is mandatory however other regmaps are setup based on flags
like "hdmi_port_enable" and "codec_dma_enable".
Correct thing for suspend/resume path to handle is by checking these
flags, instead of using component->id.
Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/qcom/lpass-platform.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index 9946f12254b39..b456e096f138f 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -202,7 +202,6 @@ static int lpass_platform_pcmops_open(struct snd_soc_component *component,
struct regmap *map;
unsigned int dai_id = cpu_dai->driver->id;
- component->id = dai_id;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -1190,13 +1189,14 @@ static int lpass_platform_pcmops_suspend(struct snd_soc_component *component)
{
struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
struct regmap *map;
- unsigned int dai_id = component->id;
- if (dai_id == LPASS_DP_RX)
+ if (drvdata->hdmi_port_enable) {
map = drvdata->hdmiif_map;
- else
- map = drvdata->lpaif_map;
+ regcache_cache_only(map, true);
+ regcache_mark_dirty(map);
+ }
+ map = drvdata->lpaif_map;
regcache_cache_only(map, true);
regcache_mark_dirty(map);
@@ -1207,14 +1207,19 @@ static int lpass_platform_pcmops_resume(struct snd_soc_component *component)
{
struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
struct regmap *map;
- unsigned int dai_id = component->id;
+ int ret;
- if (dai_id == LPASS_DP_RX)
+ if (drvdata->hdmi_port_enable) {
map = drvdata->hdmiif_map;
- else
- map = drvdata->lpaif_map;
+ regcache_cache_only(map, false);
+ ret = regcache_sync(map);
+ if (ret)
+ return ret;
+ }
+ map = drvdata->lpaif_map;
regcache_cache_only(map, false);
+
return regcache_sync(map);
}
@@ -1224,7 +1229,9 @@ static int lpass_platform_copy(struct snd_soc_component *component,
unsigned long bytes)
{
struct snd_pcm_runtime *rt = substream->runtime;
- unsigned int dai_id = component->id;
+ struct snd_soc_pcm_runtime *soc_runtime = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(soc_runtime, 0);
+ unsigned int dai_id = cpu_dai->driver->id;
int ret = 0;
void __iomem *dma_buf = (void __iomem *) (rt->dma_area + pos +
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] ASoC: soc-core: save ID if param was set in fmt_single_name()
2025-05-16 0:45 [PATCH v3 0/3] ASoC: remove component->id Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 1/3] ASoC: qcom: use drvdata instead of component to keep id Kuninori Morimoto
@ 2025-05-16 0:46 ` Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 3/3] ASoC: remove component->id Kuninori Morimoto
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2025-05-16 0:46 UTC (permalink / raw)
To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Srinivas Kandagatla,
Takashi Iwai, linux-arm-msm, linux-sound
fmt_single_name() requests "ind *id" and not allow NULL for it.
But sometimes we don't need it. Allow NULL.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ab615ec113d22..80569209ce051 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2604,6 +2604,7 @@ static char *fmt_single_name(struct device *dev, int *id)
const char *devname = dev_name(dev);
char *found, *name;
unsigned int id1, id2;
+ int __id;
if (devname == NULL)
return NULL;
@@ -2616,10 +2617,10 @@ static char *fmt_single_name(struct device *dev, int *id)
found = strstr(name, dev->driver->name);
if (found) {
/* get ID */
- if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) {
+ if (sscanf(&found[strlen(dev->driver->name)], ".%d", &__id) == 1) {
/* discard ID from name if ID == -1 */
- if (*id == -1)
+ if (__id == -1)
found[strlen(dev->driver->name)] = '\0';
}
@@ -2627,16 +2628,19 @@ static char *fmt_single_name(struct device *dev, int *id)
} else if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
/* create unique ID number from I2C addr and bus */
- *id = ((id1 & 0xffff) << 16) + id2;
+ __id = ((id1 & 0xffff) << 16) + id2;
devm_kfree(dev, name);
/* sanitize component name for DAI link creation */
name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s", dev->driver->name, devname);
} else {
- *id = 0;
+ __id = 0;
}
+ if (id)
+ *id = __id;
+
return name;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] ASoC: remove component->id
2025-05-16 0:45 [PATCH v3 0/3] ASoC: remove component->id Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 1/3] ASoC: qcom: use drvdata instead of component to keep id Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 2/3] ASoC: soc-core: save ID if param was set in fmt_single_name() Kuninori Morimoto
@ 2025-05-16 0:46 ` Kuninori Morimoto
2025-05-16 10:58 ` [PATCH v3 0/3] " Bryan O'Donoghue
2025-06-09 21:00 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2025-05-16 0:46 UTC (permalink / raw)
To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Srinivas Kandagatla,
Takashi Iwai, linux-arm-msm, linux-sound
No one is using component->id.
One idea is we can re-use it as serial number for component.
But we have no usage, so far. Let's just remove it for now.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
include/sound/soc-component.h | 1 -
sound/soc/soc-core.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 61534ac0edd1d..2caa807c6249c 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -206,7 +206,6 @@ struct snd_soc_component_driver {
struct snd_soc_component {
const char *name;
- int id;
const char *name_prefix;
struct device *dev;
struct snd_soc_card *card;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 80569209ce051..39ecf0123a444 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2835,7 +2835,7 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
mutex_init(&component->io_mutex);
if (!component->name) {
- component->name = fmt_single_name(dev, &component->id);
+ component->name = fmt_single_name(dev, NULL);
if (!component->name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] ASoC: remove component->id
2025-05-16 0:45 [PATCH v3 0/3] ASoC: remove component->id Kuninori Morimoto
` (2 preceding siblings ...)
2025-05-16 0:46 ` [PATCH v3 3/3] ASoC: remove component->id Kuninori Morimoto
@ 2025-05-16 10:58 ` Bryan O'Donoghue
2025-06-09 21:00 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Bryan O'Donoghue @ 2025-05-16 10:58 UTC (permalink / raw)
To: Kuninori Morimoto, Jaroslav Kysela, Liam Girdwood, Mark Brown,
Srinivas Kandagatla, Takashi Iwai, linux-arm-msm, linux-sound
On 16/05/2025 01:45, Kuninori Morimoto wrote:
>
> Hi Mark, Srinivas, Qcom members
>
> snd_soc_component has "id", but no one is using it except Qcom. It is
> initialized at snd_soc_component_initialize(), but Qcom overwrites it.
>
> According to Srinivas, unfortunately, current Qcom lpass is broken.
> But we can update it and then, avoid to use component->id.
> Let's do it, and remove it.
>
> Kuninori Morimoto (2):
> ASoC: soc-core: save ID if param was set in fmt_single_name()
> ASoC: remove component->id
>
> Srinivas Kandagatla (1):
> ASoC: qcom: use drvdata instead of component to keep id
>
> include/sound/soc-component.h | 1 -
> sound/soc/qcom/lpass-platform.c | 27 +++++++++++++++++----------
> sound/soc/soc-core.c | 14 +++++++++-----
> 3 files changed, 26 insertions(+), 16 deletions(-)
>
Your commit log should contain what has changed between one version of
your series to the next.
V4:
- Added a description to my commit log cover letter
V3:
- Made the declarations of variables reverse christmas tree - Konrad
V2:
- Made changes to indentation - Konrad
V1:
- Awesome new silicon enabling code I wrote
---
bod
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] ASoC: remove component->id
2025-05-16 0:45 [PATCH v3 0/3] ASoC: remove component->id Kuninori Morimoto
` (3 preceding siblings ...)
2025-05-16 10:58 ` [PATCH v3 0/3] " Bryan O'Donoghue
@ 2025-06-09 21:00 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2025-06-09 21:00 UTC (permalink / raw)
To: Jaroslav Kysela, Liam Girdwood, Srinivas Kandagatla, Takashi Iwai,
linux-arm-msm, linux-sound, Kuninori Morimoto
On Fri, 16 May 2025 00:45:58 +0000, Kuninori Morimoto wrote:
> snd_soc_component has "id", but no one is using it except Qcom. It is
> initialized at snd_soc_component_initialize(), but Qcom overwrites it.
>
> According to Srinivas, unfortunately, current Qcom lpass is broken.
> But we can update it and then, avoid to use component->id.
> Let's do it, and remove it.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: qcom: use drvdata instead of component to keep id
commit: 8167f4f42572818fa8153be2b03e4c2120846603
[2/3] ASoC: soc-core: save ID if param was set in fmt_single_name()
commit: 6ada7351af0c4e295739adfa2c4b780c037b3d27
[3/3] ASoC: remove component->id
commit: d3de84858811ea2c501cb45f0aafcae5beba20b6
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-09 21:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 0:45 [PATCH v3 0/3] ASoC: remove component->id Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 1/3] ASoC: qcom: use drvdata instead of component to keep id Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 2/3] ASoC: soc-core: save ID if param was set in fmt_single_name() Kuninori Morimoto
2025-05-16 0:46 ` [PATCH v3 3/3] ASoC: remove component->id Kuninori Morimoto
2025-05-16 10:58 ` [PATCH v3 0/3] " Bryan O'Donoghue
2025-06-09 21:00 ` Mark Brown
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).