alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: amd: put off registering mach platform_dev to avoid -517 err
@ 2020-05-22  8:17 Hui Wang
  2020-05-22  9:16 ` Mukunda, Vijendar
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Hui Wang @ 2020-05-22  8:17 UTC (permalink / raw)
  To: alsa-devel, broonie, Vijendar.Mukunda

If the mach driver's probe is called ahead of codec driver's probe,
the kernel will print -517 error message although the audio still
works finally:
acp_pdm_mach acp_pdm_mach.0: snd_soc_register_card(acp) failed: -517

we could workaround this issue by moving the registration of mach
platform_dev to plat driver's probe.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/soc/amd/renoir/acp3x-pdm-dma.c | 13 +++++++++++++
 sound/soc/amd/renoir/rn-pci-acp3x.c  |  3 ---
 sound/soc/amd/renoir/rn_acp3x.h      |  3 ++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/sound/soc/amd/renoir/acp3x-pdm-dma.c b/sound/soc/amd/renoir/acp3x-pdm-dma.c
index 623dfd3ea705..46055c244998 100644
--- a/sound/soc/amd/renoir/acp3x-pdm-dma.c
+++ b/sound/soc/amd/renoir/acp3x-pdm-dma.c
@@ -402,6 +402,7 @@ static int acp_pdm_audio_probe(struct platform_device *pdev)
 	struct pdm_dev_data *adata;
 	unsigned int irqflags;
 	int status;
+	struct platform_device_info pdevinfo = {0};
 
 	if (!pdev->dev.platform_data) {
 		dev_err(&pdev->dev, "platform_data not retrieved\n");
@@ -448,6 +449,16 @@ static int acp_pdm_audio_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "ACP PDM IRQ request failed\n");
 		return -ENODEV;
 	}
+
+	pdevinfo.name = "acp_pdm_mach";
+	pdevinfo.id = 0;
+	pdevinfo.parent = &pdev->dev;
+	adata->m_pdev = platform_device_register_full(&pdevinfo);
+	if (IS_ERR(adata->m_pdev)) {
+		dev_err(&pdev->dev, "cannot register %s device\n",
+			pdevinfo.name);
+		return PTR_ERR(adata->m_pdev);
+	}
 	pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS);
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
@@ -457,7 +468,9 @@ static int acp_pdm_audio_probe(struct platform_device *pdev)
 
 static int acp_pdm_audio_remove(struct platform_device *pdev)
 {
+	struct pdm_dev_data *adata = dev_get_drvdata(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
+	platform_device_unregister(adata->m_pdev);
 	return 0;
 }
 
diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
index 859ed67b93cf..f5f450cbd249 100644
--- a/sound/soc/amd/renoir/rn-pci-acp3x.c
+++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
@@ -230,9 +230,6 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
 	pdevinfo[1].name = "dmic-codec";
 	pdevinfo[1].id = 0;
 	pdevinfo[1].parent = &pci->dev;
-	pdevinfo[2].name = "acp_pdm_mach";
-	pdevinfo[2].id = 0;
-	pdevinfo[2].parent = &pci->dev;
 	for (index = 0; index < ACP_DEVS; index++) {
 		adata->pdev[index] =
 				platform_device_register_full(&pdevinfo[index]);
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
index 75228e306e0b..232eda4db055 100644
--- a/sound/soc/amd/renoir/rn_acp3x.h
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -7,7 +7,7 @@
 
 #include "rn_chip_offset_byte.h"
 
-#define ACP_DEVS		3
+#define ACP_DEVS		2
 #define ACP_PHY_BASE_ADDRESS 0x1240000
 #define	ACP_REG_START	0x1240000
 #define	ACP_REG_END	0x1250200
@@ -59,6 +59,7 @@ struct pdm_dev_data {
 	u32 pdm_irq;
 	void __iomem *acp_base;
 	struct snd_pcm_substream *capture_stream;
+	struct platform_device *m_pdev;
 };
 
 struct pdm_stream_instance {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-25  3:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22  8:17 [PATCH v2] ASoC: amd: put off registering mach platform_dev to avoid -517 err Hui Wang
2020-05-22  9:16 ` Mukunda, Vijendar
2020-05-22 11:08 ` Mark Brown
2020-05-22 11:13   ` Mukunda, Vijendar
2020-05-22 11:22     ` Mark Brown
2020-05-22 11:28       ` Mukunda, Vijendar
2020-05-22 12:59         ` Hui Wang
2020-05-22 13:57           ` Hui Wang
2020-05-22 14:30             ` Mukunda, Vijendar
2020-05-22 15:14               ` Mukunda, Vijendar
2020-05-22 15:32                 ` Mark Brown
2020-05-23  0:11                   ` Mukunda, Vijendar
2020-05-25  3:32                     ` Hui Wang
2020-05-22 19:10 ` kbuild test robot

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).