Skip to contentSkip to conversation

soundwire: intel: use a single module

PATCH Applied Bard Liao 3 participants 7 messages May 20, 2020 – May 21, 2020 SoundWire

lore
Share & tools
lore

Bard Liao

author maintainer
#0 lore raw

PATCH 1/2 soundwire: intel: use a single module

From: Rander Wang <[email protected]>

It's not clear why we have two modules for the Intel controller/master support when there is a single Kconfig. This adds complexity for no good reason, the two parts need to work together anyways.

---
 drivers/soundwire/Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/soundwire/Makefile +1 -4
index 7319918e0aec..4f6094767212 100644
@@ -16,12 +16,9 @@ soundwire-cadence-objs := cadence_master.o
 obj-$(CONFIG_SOUNDWIRE_CADENCE) += soundwire-cadence.o
 
 #Intel driver
-soundwire-intel-objs :=	intel.o
+soundwire-intel-objs :=	intel.o intel_init.o
 obj-$(CONFIG_SOUNDWIRE_INTEL) += soundwire-intel.o
 
-soundwire-intel-init-objs := intel_init.o
-obj-$(CONFIG_SOUNDWIRE_INTEL) += soundwire-intel-init.o
-
 #Qualcomm driver
 soundwire-qcom-objs :=	qcom.o
 obj-$(CONFIG_SOUNDWIRE_QCOM) += soundwire-qcom.o
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 2/2 soundwire: intel: transition to 3 steps initialization

From: Pierre-Louis Bossart <[email protected]>

Rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to detect platform support for SoundWire, allocate required resources as early as possible, and conversely help make the startup() callback lighter-weight with only hardware register setup.

---
 drivers/soundwire/intel.c      |  76 +++++-----
 drivers/soundwire/intel.h      |  15 ++
 drivers/soundwire/intel_init.c | 249 ++++++++++++++++++++++++++-------
 3 files changed, 250 insertions(+), 90 deletions(-)
drivers/soundwire/intel.c +36 -40
index 4cfdd074e310..48e5712fbdf9 100644
@@ -92,23 +92,12 @@
 #define SDW_ALH_STRMZCFG_DMAT		GENMASK(7, 0)
 #define SDW_ALH_STRMZCFG_CHN		GENMASK(19, 16)
 
-#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE	BIT(1)
-
 enum intel_pdi_type {
 	INTEL_PDI_IN = 0,
 	INTEL_PDI_OUT = 1,
 	INTEL_PDI_BD = 2,
 };
 
-struct sdw_intel {
-	struct sdw_cdns cdns;
-	int instance;
-	struct sdw_intel_link_res *link_res;
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *debugfs;
-#endif
-};
-
 #define cdns_to_intel(_cdns) container_of(_cdns, struct sdw_intel, cdns)
 
 /*
@@ -1083,20 +1072,18 @@ static int intel_init(struct sdw_intel *sdw)
 /*
  * probe and init
  */
-static int intel_probe(struct platform_device *pdev)
+static int intel_master_probe(struct platform_device *pdev)
 {
-	struct sdw_cdns_stream_config config;
+	struct device *dev = &pdev->dev;
 	struct sdw_intel *sdw;
 	int ret;
 
-	sdw = devm_kzalloc(&pdev->dev, sizeof(*sdw), GFP_KERNEL);
+	sdw = devm_kzalloc(dev, sizeof(*sdw), GFP_KERNEL);
 	if (!sdw)
 		return -ENOMEM;
 
 	sdw->instance = pdev->id;
-	sdw->link_res = dev_get_platdata(&pdev->dev);
-	sdw->cdns.dev = &pdev->dev;
-	sdw->cdns.registers = sdw->link_res->registers;
+	sdw->cdns.dev = dev;
 	sdw->cdns.instance = sdw->instance;
 	sdw->cdns.msg_count = 0;
 	sdw->cdns.bus.link_id = pdev->id;
@@ -1109,15 +1096,36 @@ static int intel_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, sdw);
 
-	ret = sdw_bus_master_add(&sdw->cdns.bus, &pdev->dev, pdev->dev.fwnode);
+	ret = sdw_bus_master_add(&sdw->cdns.bus, dev, dev->fwnode);
 	if (ret) {
-		dev_err(&pdev->dev, "sdw_bus_master_add fail: %d\n", ret);
+		dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
 		return ret;
 	}
 
-	if (sdw->cdns.bus.prop.hw_disabled) {
-		dev_info(&pdev->dev, "SoundWire master %d is disabled, ignoring\n",
+	if (sdw->cdns.bus.prop.hw_disabled)
+		dev_info(dev,
+			 "SoundWire master %d is disabled, ignoring\n",
 			 sdw->cdns.bus.link_id);
+
+	/* set driver data, accessed by snd_soc_dai_set_drvdata() */
+	dev_set_drvdata(sdw->cdns.bus.dev, &sdw->cdns);
+
+	return 0;
+}
+
+int intel_master_startup(struct platform_device *pdev)
+{
+	struct sdw_cdns_stream_config config;
+	struct device *dev = &pdev->dev;
+	struct sdw_intel *sdw;
+	int ret;
+
+	sdw = platform_get_drvdata(pdev);
+
+	if (sdw->cdns.bus.prop.hw_disabled) {
+		dev_info(dev,
+			 "SoundWire master %d is disabled, ignoring\n",
+			 sdw->instance);
 		return 0;
 	}
 
@@ -1134,25 +1142,15 @@ static int intel_probe(struct platform_device *pdev)
 
 	intel_pdi_ch_update(sdw);
 
-	/* Acquire IRQ */
-	ret = request_threaded_irq(sdw->link_res->irq,
-				   sdw_cdns_irq, sdw_cdns_thread,
-				   IRQF_SHARED, KBUILD_MODNAME, &sdw->cdns);
-	if (ret < 0) {
-		dev_err(sdw->cdns.dev, "unable to grab IRQ %d, disabling device\n",
-			sdw->link_res->irq);
-		goto err_init;
-	}
-
 	ret = sdw_cdns_enable_interrupt(&sdw->cdns, true);
 	if (ret < 0) {
-		dev_err(sdw->cdns.dev, "cannot enable interrupts\n");
+		dev_err(dev, "cannot enable interrupts\n");
 		goto err_init;
 	}
 
 	ret = sdw_cdns_exit_reset(&sdw->cdns);
 	if (ret < 0) {
-		dev_err(sdw->cdns.dev, "unable to exit bus reset sequence\n");
+		dev_err(dev, "unable to exit bus reset sequence\n");
 		goto err_interrupt;
 	}
 
@@ -1170,13 +1168,11 @@ static int intel_probe(struct platform_device *pdev)
 
 err_interrupt:
 	sdw_cdns_enable_interrupt(&sdw->cdns, false);
-	free_irq(sdw->link_res->irq, sdw);
 err_init:
-	sdw_bus_master_delete(&sdw->cdns.bus);
 	return ret;
 }
 
-static int intel_remove(struct platform_device *pdev)
+static int intel_master_remove(struct platform_device *pdev)
 {
 	struct sdw_intel *sdw;
 
@@ -1194,10 +1190,10 @@ static int intel_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver sdw_intel_drv = {
-	.probe = intel_probe,
-	.remove = intel_remove,
+	.probe = intel_master_probe,
+	.remove = intel_master_remove,
 	.driver = {
-		.name = "int-sdw",
+		.name = "intel-sdw",
 
 	},
 };
@@ -1205,5 +1201,5 @@ static struct platform_driver sdw_intel_drv = {
 module_platform_driver(sdw_intel_drv);
 
 MODULE_LICENSE("Dual BSD/GPL");
-MODULE_ALIAS("platform:int-sdw");
+MODULE_ALIAS("sdw:intel-sdw");
 MODULE_DESCRIPTION("Intel Soundwire Master Driver");
drivers/soundwire/intel.h +15 -0
index 38b7c125fb10..0ac7d764f58c 100644
@@ -15,6 +15,7 @@
  * @irq: Interrupt line
  * @ops: Shim callback ops
  * @dev: device implementing hw_params and free callbacks
+ * @clock_stop_quirks: mask defining requested behavior on pm_suspend
  */
 struct sdw_intel_link_res {
 	struct platform_device *pdev;
@@ -25,6 +26,20 @@ struct sdw_intel_link_res {
 	int irq;
 	const struct sdw_intel_ops *ops;
 	struct device *dev;
+	u32 clock_stop_quirks;
 };
 
+struct sdw_intel {
+	struct sdw_cdns cdns;
+	int instance;
+	struct sdw_intel_link_res *link_res;
+#ifdef CONFIG_DEBUG_FS
+	struct dentry *debugfs;
+#endif
+};
+
+#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE      BIT(1)
+
+int intel_master_startup(struct platform_device *pdev);
+
 #endif /* __SDW_INTEL_LOCAL_H */
drivers/soundwire/intel_init.c +199 -50

374 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 7 lines · Bard Liao

From: Pierre-Louis Bossart <[email protected]>

Rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to detect platform support for SoundWire, allocate required resources as early as possible, and conversely help make the startup() callback lighter-weight with only hardware register setup.

Okay but can you add details in changelog on what each step would do?

drivers/soundwire/intel.c static int intel_probe(struct platform_device *pdev) · line 1140

Quoted 8 lines
drivers/soundwire/intel.c +0 -4
@@ -1134,25 +1142,15 @@ static int intel_probe(struct platform_device *pdev)
 
 	intel_pdi_ch_update(sdw);
 
-	/* Acquire IRQ */
-	ret = request_threaded_irq(sdw->link_res->irq,
-				   sdw_cdns_irq, sdw_cdns_thread,
-				   IRQF_SHARED, KBUILD_MODNAME, &sdw->cdns);

This is removed here but not added anywhere else, do we have no irq after this patch?

drivers/soundwire/intel.c static struct platform_driver sdw_intel_drv = { · line 1204

Quoted 6 lines
drivers/soundwire/intel.c +1 -1
@@ -1205,5 +1201,5 @@ static struct platform_driver sdw_intel_drv = {
 module_platform_driver(sdw_intel_drv);
 
 MODULE_LICENSE("Dual BSD/GPL");
-MODULE_ALIAS("platform:int-sdw");
+MODULE_ALIAS("sdw:intel-sdw");

it is still a platform device, so does sdw: tag make sense? This is used by modprobe to load the driver!

drivers/soundwire/intel_init.c static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level, · line 337

Quoted 5 lines
drivers/soundwire/intel_init.c +5 -0
+/**
+ * sdw_intel_probe() - SoundWire Intel probe routine
+ * @res: resource data
+ *
+ * This creates SoundWire Master and Slave devices below the controller.

I dont think the comment is correct, this is done in intel_master_probe which is platform device probe...

drivers/soundwire/intel_init.c static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level, · line 346

Quoted 9 lines

+ * All the information necessary is stored in the context, and the res
+ * argument pointer can be freed after this step.
+ */

drivers/soundwire/intel_init.c +6 -0
+struct sdw_intel_ctx
+*sdw_intel_probe(struct sdw_intel_res *res)
+{
+	return sdw_intel_probe_controller(res);
+}
+EXPORT_SYMBOL(sdw_intel_probe);

I guess this would be called by SOF driver, question is when..?

drivers/soundwire/intel_init.c static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level, · line 357

Quoted 10 lines
drivers/soundwire/intel_init.c +10 -0
+/**
+ * sdw_intel_startup() - SoundWire Intel startup
+ * @ctx: SoundWire context allocated in the probe
+ *
+ */
+int sdw_intel_startup(struct sdw_intel_ctx *ctx)
+{
+	return sdw_intel_startup_controller(ctx);
+}
+EXPORT_SYMBOL(sdw_intel_startup);

when is this called, pls do document that

Signature · 1 line
~Vinod
#3 lore raw

RE: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 16 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: Wednesday, May 20, 2020 9:54 PM
To: Bard Liao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; Kale, Sanyog R <[email protected]>; Blauciak, Slawomir <[email protected]>; Lin, Mengdong <[email protected]>; Liao, Bard <[email protected]>
Subject: Re: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 2 lines · Bard Liao

From: Pierre-Louis Bossart <[email protected]>

Quoted 7 lines
Quoted 5 lines

Rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to detect platform support for SoundWire, allocate required resources as early as possible, and conversely help make the startup() callback lighter-weight with only hardware register setup.

Okay but can you add details in changelog on what each step would do?

Sure. Will do.

Quoted 6 lines

Review static int intel_probe(struct platform_device

Quoted 2 lines
(quoted diff) +0 -0
@@ -1134,25 +1142,15 @@ static int intel_probe(struct platform_device

*pdev)

Quoted 3 lines
drivers/soundwire/intel.c +0 -0
 	intel_pdi_ch_update(sdw);
 
Quoted 8 lines

drivers/soundwire/intel.c static int intel_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/soundwire/intel.c +0 -4
-	/* Acquire IRQ */
-	ret = request_threaded_irq(sdw->link_res->irq,
-				   sdw_cdns_irq, sdw_cdns_thread,
-				   IRQF_SHARED, KBUILD_MODNAME, &sdw-
 cdns);

This is removed here but not added anywhere else, do we have no irq after this patch?

We use a single irq for all Intel Audio DSP events and it will be requested in the SOF driver.

Quoted 10 lines

drivers/soundwire/intel.c static struct platform_driver sdw_intel_drv = { · line 1204

Quoted 7 lines
drivers/soundwire/intel.c +1 -1
@@ -1205,5 +1201,5 @@ static struct platform_driver sdw_intel_drv = {
 module_platform_driver(sdw_intel_drv);
 
 MODULE_LICENSE("Dual BSD/GPL");
-MODULE_ALIAS("platform:int-sdw");
+MODULE_ALIAS("sdw:intel-sdw");

it is still a platform device, so does sdw: tag make sense? This is used by modprobe to load the driver!

Will fix it

Quoted 9 lines

drivers/soundwire/intel_init.c static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level, · line 337

Quoted 6 lines
drivers/soundwire/intel_init.c +5 -0
+/**
+ * sdw_intel_probe() - SoundWire Intel probe routine
+ * @res: resource data
+ *
+ * This creates SoundWire Master and Slave devices below the controller.

I dont think the comment is correct, this is done in intel_master_probe which is platform device probe...

Thanks. Will fix it.

Quoted 12 lines

drivers/soundwire/intel_init.c static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level, · line 346

Quoted 10 lines

+ * All the information necessary is stored in the context, and the res
+ * argument pointer can be freed after this step.
+ */

drivers/soundwire/intel_init.c +6 -0
+struct sdw_intel_ctx
+*sdw_intel_probe(struct sdw_intel_res *res)
+{
+	return sdw_intel_probe_controller(res);
+}
+EXPORT_SYMBOL(sdw_intel_probe);

I guess this would be called by SOF driver, question is when..?

Will document it, thanks.

Quoted 13 lines

drivers/soundwire/intel_init.c static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level, · line 357

Quoted 11 lines
drivers/soundwire/intel_init.c +10 -0
+/**
+ * sdw_intel_startup() - SoundWire Intel startup
+ * @ctx: SoundWire context allocated in the probe
+ *
+ */
+int sdw_intel_startup(struct sdw_intel_ctx *ctx)
+{
+	return sdw_intel_startup_controller(ctx);
+}
+EXPORT_SYMBOL(sdw_intel_startup);

when is this called, pls do document that

Will document it, thanks.

Quoted 3 lines

--
~Vinod

maintainer
#4 lore raw

Re: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 41 lines · Bard
Quoted 16 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: Wednesday, May 20, 2020 9:54 PM
To: Bard Liao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; Kale, Sanyog R <[email protected]>; Blauciak, Slawomir <[email protected]>; Lin, Mengdong <[email protected]>; Liao, Bard <[email protected]>
Subject: Re: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 2 lines · Bard Liao

From: Pierre-Louis Bossart <[email protected]>

Quoted 7 lines
Quoted 5 lines

Rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to detect platform support for SoundWire, allocate required resources as early as possible, and conversely help make the startup() callback lighter-weight with only hardware register setup.

Okay but can you add details in changelog on what each step would do?

Sure. Will do.

Quoted 6 lines

Review static int intel_probe(struct platform_device

Quoted 2 lines
(quoted diff) +0 -0
@@ -1134,25 +1142,15 @@ static int intel_probe(struct platform_device

*pdev)

Quoted 3 lines
drivers/soundwire/intel.c +0 -0
 	intel_pdi_ch_update(sdw);
 
Quoted 8 lines

drivers/soundwire/intel.c static int intel_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/soundwire/intel.c +0 -4
-	/* Acquire IRQ */
-	ret = request_threaded_irq(sdw->link_res->irq,
-				   sdw_cdns_irq, sdw_cdns_thread,
-				   IRQF_SHARED, KBUILD_MODNAME, &sdw-
 cdns);

This is removed here but not added anywhere else, do we have no irq after this patch?

Quoted 2 lines

We use a single irq for all Intel Audio DSP events and it will be requested in the SOF driver.

And how will the irq be propagated to sdw/cdns drivers here?

Signature · 1 line
~Vinod
#5 lore raw

RE: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 59 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: Thursday, May 21, 2020 12:37 PM
To: Liao, Bard <[email protected]>
Cc: Bard Liao <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; Kale, Sanyog R <[email protected]>; Blauciak, Slawomir <[email protected]>; Lin, Mengdong <[email protected]>
Subject: Re: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 44 lines · Bard
Quoted 18 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: Wednesday, May 20, 2020 9:54 PM
To: Bard Liao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; Kale, Sanyog R <[email protected]>; Blauciak, Slawomir <[email protected]>; Lin, Mengdong <[email protected]>; Liao, Bard <[email protected]>
Subject: Re: [PATCH 2/2] soundwire: intel: transition to 3 steps initialization

Quoted 2 lines · Bard Liao

From: Pierre-Louis Bossart <[email protected]>

Quoted 7 lines
Quoted 5 lines

Rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to detect platform support for SoundWire, allocate required resources as early as possible, and conversely help make the startup() callback lighter-weight with only hardware register setup.

Okay but can you add details in changelog on what each step would do?

Sure. Will do.

Quoted 15 lines
Quoted 3 lines
(quoted diff) +0 -0
@@ -1134,25 +1142,15 @@ static int intel_probe(struct

platform_device

*pdev)

Quoted 8 lines
drivers/soundwire/intel.c +0 -4
 	intel_pdi_ch_update(sdw);
 
-	/* Acquire IRQ */
-	ret = request_threaded_irq(sdw->link_res->irq,
-				   sdw_cdns_irq, sdw_cdns_thread,
-				   IRQF_SHARED, KBUILD_MODNAME, &sdw-

cdns);

This is removed here but not added anywhere else, do we have no irq after this patch?

Quoted 4 lines
Quoted 2 lines

We use a single irq for all Intel Audio DSP events and it will be requested in the SOF driver.

And how will the irq be propagated to sdw/cdns drivers here?

We export the handler and call it on SOF driver.

Quoted 3 lines

--
~Vinod

maintainer Applied
#6 lore raw
In reply to Bard Liao
Quoted 5 lines · Bard Liao

From: Rander Wang <[email protected]>

It's not clear why we have two modules for the Intel controller/master support when there is a single Kconfig. This adds complexity for no good reason, the two parts need to work together anyways.

Applied, thanks

Signature · 1 line
~Vinod