Skip to contentSkip to conversation

ASoC: Intel: more modulartion of init and add ACPI

PATCH In review Vinod Koul 3 participants 25 messages Oct 30, 2014 – Oct 31, 2014

Subsystems (3)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover ASoC: Intel: more modulartion of init and add ACPI

The first patch is a fix of mfld-pcm driver
Rest of the series is devoted to ACPI support with 7 patch moving the probe routine and sperating into common and PCI and later moving PCI code to sst-pci file so that it can be shared with ACPI
Lats patch adds support for ACPI with BYT driver support.

This series is dependent upon the PM and compressed series sent earlier today

Subhransu S. Prusty (9):
ASoC: Intel: mfld-pcm: Fix to Store device context in sst_data
ASoC: Intel: move the driver wq init to a routine
ASoC: Intel: move the lock and wq initialization to routine
ASoC: Intel: move the driver context allocation to routine
ASoC: Intel: modularize driver probe and remove
ASoC: Intel: more probe modularization for sst
ASoC: Intel: move PCI probe to a seprate file
ASoC: Intel: add shim save context and restore routines
ASoC: Intel: Add ACPI driver for SST

 sound/soc/intel/Kconfig                 |    7 +
 sound/soc/intel/sst-mfld-platform-pcm.c |    1 +
 sound/soc/intel/sst/Makefile            |    8 +
 sound/soc/intel/sst/sst.c               |  391 ++++++++++++-------------------
 sound/soc/intel/sst/sst.h               |    7 +
 sound/soc/intel/sst/sst_acpi.c          |  387 ++++++++++++++++++++++++++++++
 sound/soc/intel/sst/sst_pci.c           |  225 ++++++++++++++++++
 sound/soc/intel/sst/sst_pvt.c           |    2 +
 8 files changed, 793 insertions(+), 235 deletions(-)
 create mode 100644 sound/soc/intel/sst/sst_acpi.c
 create mode 100644 sound/soc/intel/sst/sst_pci.c
author
#1 lore raw

PATCH 1/9 ASoC: Intel: mfld-pcm: Fix to Store device context in sst_data

From: Subhransu S. Prusty <[email protected]>

Some debug prints use dev context in sst_data. Store the device context for the same.

---
 sound/soc/intel/sst-mfld-platform-pcm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
sound/soc/intel/sst-mfld-platform-pcm.c +1 -0
index e7cf18d..6032f18 100644
@@ -706,6 +706,7 @@ static int sst_platform_probe(struct platform_device *pdev)
 	pdata->pdev_strm_map = dpcm_strm_map;
 	pdata->strm_map_size = ARRAY_SIZE(dpcm_strm_map);
 	drv->pdata = pdata;
+	drv->pdev = pdev;
 	mutex_init(&drv->lock);
 	dev_set_drvdata(&pdev->dev, drv);
 
Signature · 1 line
1.7.0.4
author
#2 lore raw

PATCH 2/9 ASoC: Intel: move the driver wq init to a routine

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This will be used by APCI code as well, so moving to common routine helps

---
 sound/soc/intel/sst/sst.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)
sound/soc/intel/sst/sst.c +19 -15
index ff0ff9f..253b917 100644
@@ -206,6 +206,22 @@ void sst_process_pending_msg(struct work_struct *work)
 	ctx->ops->post_message(ctx, NULL, false);
 }
 
+static int sst_workqueue_init(struct intel_sst_drv *ctx)
+{
+	INIT_LIST_HEAD(&ctx->memcpy_list);
+	INIT_LIST_HEAD(&ctx->rx_list);
+	INIT_LIST_HEAD(&ctx->ipc_dispatch_list);
+	INIT_LIST_HEAD(&ctx->block_list);
+	INIT_WORK(&ctx->ipc_post_msg_wq, sst_process_pending_msg);
+	init_waitqueue_head(&ctx->wait_queue);
+
+	ctx->post_msg_wq =
+		create_singlethread_workqueue("sst_post_msg_wq");
+	if (!ctx->post_msg_wq)
+		return -EBUSY;
+	return 0;
+}
+
 /*
 * intel_sst_probe - PCI probe function
 *
@@ -254,24 +270,13 @@ static int intel_sst_probe(struct pci_dev *pci,
 	sst_drv_ctx->use_dma = 0;
 	sst_drv_ctx->use_lli = 0;
 
-	INIT_LIST_HEAD(&sst_drv_ctx->memcpy_list);
-	INIT_LIST_HEAD(&sst_drv_ctx->ipc_dispatch_list);
-	INIT_LIST_HEAD(&sst_drv_ctx->block_list);
-	INIT_LIST_HEAD(&sst_drv_ctx->rx_list);
-
-	sst_drv_ctx->post_msg_wq =
-		create_singlethread_workqueue("sst_post_msg_wq");
-	if (!sst_drv_ctx->post_msg_wq) {
-		ret = -EINVAL;
-		goto do_free_drv_ctx;
-	}
-	INIT_WORK(&sst_drv_ctx->ipc_post_msg_wq, sst_process_pending_msg);
-	init_waitqueue_head(&sst_drv_ctx->wait_queue);
-
 	spin_lock_init(&sst_drv_ctx->ipc_spin_lock);
 	spin_lock_init(&sst_drv_ctx->block_lock);
 	spin_lock_init(&sst_drv_ctx->rx_msg_lock);
 
+	if (sst_workqueue_init(sst_drv_ctx))
+		return -EINVAL;
+
 	dev_info(sst_drv_ctx->dev, "Got drv data max stream %d\n",
 				sst_drv_ctx->info.max_streams);
 	for (i = 1; i <= sst_drv_ctx->info.max_streams; i++) {
@@ -414,7 +419,6 @@ do_release_regions:
 	pci_release_regions(pci);
 do_free_mem:
 	destroy_workqueue(sst_drv_ctx->post_msg_wq);
-do_free_drv_ctx:
 	dev_err(sst_drv_ctx->dev, "Probe failed with %d\n", ret);
 	return ret;
 }
Signature · 1 line
1.7.0.4
author
#3 lore raw

PATCH 3/9 ASoC: Intel: move the lock and wq initialization to routine

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This will be used by APCI code as well, so moving to common routine helps

---
 sound/soc/intel/sst/sst.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
sound/soc/intel/sst/sst.c +9 -5
index 253b917..7c9c65a 100644
@@ -222,6 +222,14 @@ static int sst_workqueue_init(struct intel_sst_drv *ctx)
 	return 0;
 }
 
+static void sst_init_locks(struct intel_sst_drv *ctx)
+{
+	mutex_init(&ctx->sst_lock);
+	spin_lock_init(&ctx->rx_msg_lock);
+	spin_lock_init(&ctx->ipc_spin_lock);
+	spin_lock_init(&ctx->block_lock);
+}
+
 /*
 * intel_sst_probe - PCI probe function
 *
@@ -259,7 +267,7 @@ static int intel_sst_probe(struct pci_dev *pci,
 		return -EINVAL;
 
 	ops = sst_drv_ctx->ops;
-	mutex_init(&sst_drv_ctx->sst_lock);
+	sst_init_locks(sst_drv_ctx);
 
 	/* pvt_id 0 reserved for async messages */
 	sst_drv_ctx->pvt_id = 1;
@@ -270,10 +278,6 @@ static int intel_sst_probe(struct pci_dev *pci,
 	sst_drv_ctx->use_dma = 0;
 	sst_drv_ctx->use_lli = 0;
 
-	spin_lock_init(&sst_drv_ctx->ipc_spin_lock);
-	spin_lock_init(&sst_drv_ctx->block_lock);
-	spin_lock_init(&sst_drv_ctx->rx_msg_lock);
-
 	if (sst_workqueue_init(sst_drv_ctx))
 		return -EINVAL;
 
Signature · 1 line
1.7.0.4
author
#4 lore raw

PATCH 4/9 ASoC: Intel: move the driver context allocation to routine

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This will be used by APCI code as well, so moving to common routine helps

---
 sound/soc/intel/sst/sst.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
sound/soc/intel/sst/sst.c +18 -5
index 7c9c65a..cbbe9a7 100644
@@ -230,6 +230,20 @@ static void sst_init_locks(struct intel_sst_drv *ctx)
 	spin_lock_init(&ctx->block_lock);
 }
 
+int sst_alloc_drv_context(struct intel_sst_drv **ctx,
+		struct device *dev, unsigned int dev_id)
+{
+	*ctx = devm_kzalloc(dev, sizeof(struct intel_sst_drv), GFP_KERNEL);
+	if (!(*ctx))
+		return -ENOMEM;
+
+	(*ctx)->dev = dev;
+	(*ctx)->dev_id = dev_id;
+
+	return 0;
+}
+
+
 /*
 * intel_sst_probe - PCI probe function
 *
@@ -247,12 +261,11 @@ static int intel_sst_probe(struct pci_dev *pci,
 	int ddr_base;
 
 	dev_dbg(&pci->dev, "Probe for DID %x\n", pci->device);
-	sst_drv_ctx = devm_kzalloc(&pci->dev, sizeof(*sst_drv_ctx), GFP_KERNEL);
-	if (!sst_drv_ctx)
-		return -ENOMEM;
 
-	sst_drv_ctx->dev = &pci->dev;
-	sst_drv_ctx->dev_id = pci->device;
+	ret = sst_alloc_drv_context(&sst_drv_ctx, &pci->dev, pci->device);
+	if (ret < 0)
+		return ret;
+
 	if (!sst_pdata)
 		return -EINVAL;
 
Signature · 1 line
1.7.0.4
author
#5 lore raw

PATCH 5/9 ASoC: Intel: modularize driver probe and remove

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

The driver probe which initializes driver and remove which cleans up can be shared with APCI as well, so move them to common init_context and cleanup_context routines which can be used by ACPI as well

---
 sound/soc/intel/sst/sst.c |  165 +++++++++++++++++++++++++-------------------
 1 files changed, 94 insertions(+), 71 deletions(-)
sound/soc/intel/sst/sst.c +94 -71
index cbbe9a7..e621922 100644
@@ -243,6 +243,94 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
 	return 0;
 }
 
+int sst_context_init(struct intel_sst_drv *ctx)
+{
+	int ret = 0, i;
+
+	if (!ctx->pdata)
+		return -EINVAL;
+
+	if (!ctx->pdata->probe_data)
+		return -EINVAL;
+
+	memcpy(&ctx->info, ctx->pdata->probe_data, sizeof(ctx->info));
+
+	ret = sst_driver_ops(ctx);
+	if (ret != 0)
+		return -EINVAL;
+
+	sst_init_locks(ctx);
+
+	/* pvt_id 0 reserved for async messages */
+	ctx->pvt_id = 1;
+	ctx->stream_cnt = 0;
+	ctx->fw_in_mem = NULL;
+	/* we use memcpy, so set to 0 */
+	ctx->use_dma = 0;
+	ctx->use_lli = 0;
+
+	if (sst_workqueue_init(ctx))
+		return -EINVAL;
+
+	ctx->mailbox_recv_offset = ctx->pdata->ipc_info->mbox_recv_off;
+	ctx->ipc_reg.ipcx = SST_IPCX + ctx->pdata->ipc_info->ipc_offset;
+	ctx->ipc_reg.ipcd = SST_IPCD + ctx->pdata->ipc_info->ipc_offset;
+
+	dev_info(ctx->dev, "Got drv data max stream %d\n",
+				ctx->info.max_streams);
+
+	for (i = 1; i <= ctx->info.max_streams; i++) {
+		struct stream_info *stream = &ctx->streams[i];
+
+		memset(stream, 0, sizeof(*stream));
+		stream->pipe_id = PIPE_RSVD;
+		mutex_init(&stream->lock);
+	}
+
+	/* Register the ISR */
+	ret = devm_request_threaded_irq(ctx->dev, ctx->irq_num, ctx->ops->interrupt,
+					ctx->ops->irq_thread, 0, SST_DRV_NAME,
+					ctx);
+	if (ret)
+		goto do_free_mem;
+
+	dev_dbg(ctx->dev, "Registered IRQ %#x\n", ctx->irq_num);
+
+	/* default intr are unmasked so set this as masked */
+	sst_shim_write64(ctx->shim, SST_IMRX, 0xFFFF0038);
+
+	ctx->qos = devm_kzalloc(ctx->dev,
+		sizeof(struct pm_qos_request), GFP_KERNEL);
+	if (!ctx->qos) {
+		ret = -ENOMEM;
+		goto do_free_mem;
+	}
+	pm_qos_add_request(ctx->qos, PM_QOS_CPU_DMA_LATENCY,
+				PM_QOS_DEFAULT_VALUE);
+	return 0;
+
+do_free_mem:
+	destroy_workqueue(ctx->post_msg_wq);
+	return ret;
+}
+
+void sst_context_cleanup(struct intel_sst_drv *ctx)
+{
+	pm_runtime_get_noresume(ctx->dev);
+	pm_runtime_forbid(ctx->dev);
+	sst_unregister(ctx->dev);
+	sst_set_fw_state_locked(ctx, SST_SHUTDOWN);
+	flush_scheduled_work();
+	destroy_workqueue(ctx->post_msg_wq);
+	pm_qos_remove_request(ctx->qos);
+	kfree(ctx->fw_sg_list.src);
+	kfree(ctx->fw_sg_list.dst);
+	ctx->fw_sg_list.list_len = 0;
+	kfree(ctx->fw_in_mem);
+	ctx->fw_in_mem = NULL;
+	sst_memcpy_free_resources(ctx);
+	ctx = NULL;
+}
 
 /*
 * intel_sst_probe - PCI probe function
@@ -254,9 +342,8 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
 static int intel_sst_probe(struct pci_dev *pci,
 			const struct pci_device_id *pci_id)
 {
-	int i, ret = 0;
+	int ret = 0;
 	struct intel_sst_drv *sst_drv_ctx;
-	struct intel_sst_ops *ops;
 	struct sst_platform_info *sst_pdata = pci->dev.platform_data;
 	int ddr_base;
 
@@ -266,43 +353,12 @@ static int intel_sst_probe(struct pci_dev *pci,
 	if (ret < 0)
 		return ret;
 
-	if (!sst_pdata)
-		return -EINVAL;
-
 	sst_drv_ctx->pdata = sst_pdata;
-	if (!sst_drv_ctx->pdata->probe_data)
-		return -EINVAL;
-
-	memcpy(&sst_drv_ctx->info, sst_drv_ctx->pdata->probe_data,
-					sizeof(sst_drv_ctx->info));
-
-	if (0 != sst_driver_ops(sst_drv_ctx))
-		return -EINVAL;
-
-	ops = sst_drv_ctx->ops;
-	sst_init_locks(sst_drv_ctx);
-
-	/* pvt_id 0 reserved for async messages */
-	sst_drv_ctx->pvt_id = 1;
-	sst_drv_ctx->stream_cnt = 0;
-	sst_drv_ctx->fw_in_mem = NULL;
-
-	/* we use memcpy, so set to 0 */
-	sst_drv_ctx->use_dma = 0;
-	sst_drv_ctx->use_lli = 0;
-
-	if (sst_workqueue_init(sst_drv_ctx))
-		return -EINVAL;
 
-	dev_info(sst_drv_ctx->dev, "Got drv data max stream %d\n",
-				sst_drv_ctx->info.max_streams);
-	for (i = 1; i <= sst_drv_ctx->info.max_streams; i++) {
-		struct stream_info *stream = &sst_drv_ctx->streams[i];
+	ret = sst_context_init(sst_drv_ctx);
+	if (ret < 0)
+		goto do_free_drv_ctx;
 
-		memset(stream, 0, sizeof(*stream));
-		stream->pipe_id = PIPE_RSVD;
-		mutex_init(&stream->lock);
-	}
 
 	/* Init the device */
 	ret = pcim_enable_device(pci);
@@ -402,18 +458,6 @@ static int intel_sst_probe(struct pci_dev *pci,
 	}
 
 	sst_drv_ctx->irq_num = pci->irq;
-	/* Register the ISR */
-	ret = devm_request_threaded_irq(&pci->dev, pci->irq,
-		sst_drv_ctx->ops->interrupt,
-		sst_drv_ctx->ops->irq_thread, 0, SST_DRV_NAME,
-		sst_drv_ctx);
-	if (ret)
-		goto do_release_regions;
-	dev_dbg(sst_drv_ctx->dev, "Registered IRQ 0x%x\n", pci->irq);
-
-	/* default intr are unmasked so set this as masked */
-	if (sst_drv_ctx->dev_id == SST_MRFLD_PCI_ID)
-		sst_shim_write64(sst_drv_ctx->shim, SST_IMRX, 0xFFFF0038);
 
 	pci_set_drvdata(pci, sst_drv_ctx);
 	pm_runtime_set_autosuspend_delay(sst_drv_ctx->dev, SST_SUSPEND_DELAY);
@@ -421,14 +465,6 @@ static int intel_sst_probe(struct pci_dev *pci,
 	pm_runtime_allow(sst_drv_ctx->dev);
 	pm_runtime_put_noidle(sst_drv_ctx->dev);
 	sst_register(sst_drv_ctx->dev);
-	sst_drv_ctx->qos = devm_kzalloc(&pci->dev,
-		sizeof(struct pm_qos_request), GFP_KERNEL);
-	if (!sst_drv_ctx->qos) {
-		ret = -ENOMEM;
-		goto do_release_regions;
-	}
-	pm_qos_add_request(sst_drv_ctx->qos, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
 
 	return ret;
 
@@ -436,6 +472,7 @@ do_release_regions:
 	pci_release_regions(pci);
 do_free_mem:
 	destroy_workqueue(sst_drv_ctx->post_msg_wq);
+do_free_drv_ctx:
 	dev_err(sst_drv_ctx->dev, "Probe failed with %d\n", ret);
 	return ret;
 }
@@ -452,22 +489,8 @@ static void intel_sst_remove(struct pci_dev *pci)
 {
 	struct intel_sst_drv *sst_drv_ctx = pci_get_drvdata(pci);
 
-	pm_runtime_get_noresume(sst_drv_ctx->dev);
-	pm_runtime_forbid(sst_drv_ctx->dev);
-	sst_unregister(sst_drv_ctx->dev);
+	sst_context_cleanup(sst_drv_ctx);
 	pci_dev_put(sst_drv_ctx->pci);
-	sst_set_fw_state_locked(sst_drv_ctx, SST_SHUTDOWN);
-
-	flush_scheduled_work();
-	destroy_workqueue(sst_drv_ctx->post_msg_wq);
-	pm_qos_remove_request(sst_drv_ctx->qos);
-	kfree(sst_drv_ctx->fw_sg_list.src);
-	kfree(sst_drv_ctx->fw_sg_list.dst);
-	sst_drv_ctx->fw_sg_list.list_len = 0;
-	kfree(sst_drv_ctx->fw_in_mem);
-	sst_drv_ctx->fw_in_mem = NULL;
-	sst_memcpy_free_resources(sst_drv_ctx);
-	sst_drv_ctx = NULL;
 	pci_release_regions(pci);
 	pci_set_drvdata(pci, NULL);
 }
Signature · 1 line
1.7.0.4
maintainer
#6 lore raw

Re: [PATCH 5/9] ASoC: Intel: modularize driver probe and remove

Quoted 4 lines · Vinod Koul

From: Subhransu S. Prusty <[email protected]>

The driver probe which initializes driver and remove which cleans up can be shared with APCI as well, so move them to common init_context and

APCI? :P (same typo in all these)

author
#7 lore raw

PATCH 6/9 ASoC: Intel: more probe modularization for sst

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

Move the PCI bar and resource initialization to a separate routine

---
 sound/soc/intel/sst/sst.c |  158 ++++++++++++++++++++++++--------------------
 1 files changed, 86 insertions(+), 72 deletions(-)
sound/soc/intel/sst/sst.c +86 -72
index e621922..ad16101 100644
@@ -332,114 +332,132 @@ void sst_context_cleanup(struct intel_sst_drv *ctx)
 	ctx = NULL;
 }
 
-/*
-* intel_sst_probe - PCI probe function
-*
-* @pci:	PCI device structure
-* @pci_id: PCI device ID structure
-*
-*/
-static int intel_sst_probe(struct pci_dev *pci,
-			const struct pci_device_id *pci_id)
+void sst_configure_runtime_pm(struct intel_sst_drv *ctx)
 {
-	int ret = 0;
-	struct intel_sst_drv *sst_drv_ctx;
-	struct sst_platform_info *sst_pdata = pci->dev.platform_data;
-	int ddr_base;
-
-	dev_dbg(&pci->dev, "Probe for DID %x\n", pci->device);
-
-	ret = sst_alloc_drv_context(&sst_drv_ctx, &pci->dev, pci->device);
-	if (ret < 0)
-		return ret;
-
-	sst_drv_ctx->pdata = sst_pdata;
-
-	ret = sst_context_init(sst_drv_ctx);
-	if (ret < 0)
-		goto do_free_drv_ctx;
-
+	pm_runtime_set_autosuspend_delay(ctx->dev, SST_SUSPEND_DELAY);
+	pm_runtime_use_autosuspend(ctx->dev);
+	pm_runtime_allow(ctx->dev);
+	pm_runtime_put_noidle(ctx->dev);
+}
 
-	/* Init the device */
-	ret = pcim_enable_device(pci);
-	if (ret) {
-		dev_err(sst_drv_ctx->dev,
-			"device can't be enabled. Returned err: %d\n", ret);
-		goto do_free_mem;
-	}
-	sst_drv_ctx->pci = pci_dev_get(pci);
+static int sst_platform_get_resources(struct intel_sst_drv *ctx)
+{
+	int ddr_base, ret = 0;
+	struct pci_dev *pci = ctx->pci;
 	ret = pci_request_regions(pci, SST_DRV_NAME);
 	if (ret)
-		goto do_free_mem;
+		return ret;
 
 	/* map registers */
 	/* DDR base */
-	if (sst_drv_ctx->dev_id == SST_MRFLD_PCI_ID) {
-		sst_drv_ctx->ddr_base = pci_resource_start(pci, 0);
+	if (ctx->dev_id == SST_MRFLD_PCI_ID) {
+		ctx->ddr_base = pci_resource_start(pci, 0);
 		/* check that the relocated IMR base matches with FW Binary */
-		ddr_base = relocate_imr_addr_mrfld(sst_drv_ctx->ddr_base);
-		if (!sst_drv_ctx->pdata->lib_info) {
-			dev_err(sst_drv_ctx->dev, "lib_info pointer NULL\n");
+		ddr_base = relocate_imr_addr_mrfld(ctx->ddr_base);
+		if (!ctx->pdata->lib_info) {
+			dev_err(ctx->dev, "lib_info pointer NULL\n");
 			ret = -EINVAL;
 			goto do_release_regions;
 		}
-		if (ddr_base != sst_drv_ctx->pdata->lib_info->mod_base) {
-			dev_err(sst_drv_ctx->dev,
+		if (ddr_base != ctx->pdata->lib_info->mod_base) {
+			dev_err(ctx->dev,
 					"FW LSP DDR BASE does not match with IFWI\n");
 			ret = -EINVAL;
 			goto do_release_regions;
 		}
-		sst_drv_ctx->ddr_end = pci_resource_end(pci, 0);
+		ctx->ddr_end = pci_resource_end(pci, 0);
 
-		sst_drv_ctx->ddr = pcim_iomap(pci, 0,
+		ctx->ddr = pcim_iomap(pci, 0,
 					pci_resource_len(pci, 0));
-		if (!sst_drv_ctx->ddr) {
+		if (!ctx->ddr) {
 			ret = -EINVAL;
 			goto do_release_regions;
 		}
-		dev_dbg(sst_drv_ctx->dev, "sst: DDR Ptr %p\n", sst_drv_ctx->ddr);
+		dev_dbg(ctx->dev, "sst: DDR Ptr %p\n", ctx->ddr);
 	} else {
-		sst_drv_ctx->ddr = NULL;
+		ctx->ddr = NULL;
 	}
-
 	/* SHIM */
-	sst_drv_ctx->shim_phy_add = pci_resource_start(pci, 1);
-	sst_drv_ctx->shim = pcim_iomap(pci, 1, pci_resource_len(pci, 1));
-	if (!sst_drv_ctx->shim) {
+	ctx->shim_phy_add = pci_resource_start(pci, 1);
+	ctx->shim = pcim_iomap(pci, 1, pci_resource_len(pci, 1));
+	if (!ctx->shim) {
 		ret = -EINVAL;
 		goto do_release_regions;
 	}
-	dev_dbg(sst_drv_ctx->dev, "SST Shim Ptr %p\n", sst_drv_ctx->shim);
+	dev_dbg(ctx->dev, "SST Shim Ptr %p\n", ctx->shim);
 
 	/* Shared SRAM */
-	sst_drv_ctx->mailbox_add = pci_resource_start(pci, 2);
-	sst_drv_ctx->mailbox = pcim_iomap(pci, 2, pci_resource_len(pci, 2));
-	if (!sst_drv_ctx->mailbox) {
+	ctx->mailbox_add = pci_resource_start(pci, 2);
+	ctx->mailbox = pcim_iomap(pci, 2, pci_resource_len(pci, 2));
+	if (!ctx->mailbox) {
 		ret = -EINVAL;
 		goto do_release_regions;
 	}
-	dev_dbg(sst_drv_ctx->dev, "SRAM Ptr %p\n", sst_drv_ctx->mailbox);
+	dev_dbg(ctx->dev, "SRAM Ptr %p\n", ctx->mailbox);
 
 	/* IRAM */
-	sst_drv_ctx->iram_end = pci_resource_end(pci, 3);
-	sst_drv_ctx->iram_base = pci_resource_start(pci, 3);
-	sst_drv_ctx->iram = pcim_iomap(pci, 3, pci_resource_len(pci, 3));
-	if (!sst_drv_ctx->iram) {
+	ctx->iram_end = pci_resource_end(pci, 3);
+	ctx->iram_base = pci_resource_start(pci, 3);
+	ctx->iram = pcim_iomap(pci, 3, pci_resource_len(pci, 3));
+	if (!ctx->iram) {
 		ret = -EINVAL;
 		goto do_release_regions;
 	}
-	dev_dbg(sst_drv_ctx->dev, "IRAM Ptr %p\n", sst_drv_ctx->iram);
+	dev_dbg(ctx->dev, "IRAM Ptr %p\n", ctx->iram);
 
 	/* DRAM */
-	sst_drv_ctx->dram_end = pci_resource_end(pci, 4);
-	sst_drv_ctx->dram_base = pci_resource_start(pci, 4);
-	sst_drv_ctx->dram = pcim_iomap(pci, 4, pci_resource_len(pci, 4));
-	if (!sst_drv_ctx->dram) {
+	ctx->dram_end = pci_resource_end(pci, 4);
+	ctx->dram_base = pci_resource_start(pci, 4);
+	ctx->dram = pcim_iomap(pci, 4, pci_resource_len(pci, 4));
+	if (!ctx->dram) {
 		ret = -EINVAL;
 		goto do_release_regions;
 	}
-	dev_dbg(sst_drv_ctx->dev, "DRAM Ptr %p\n", sst_drv_ctx->dram);
+	dev_dbg(ctx->dev, "DRAM Ptr %p\n", ctx->dram);
+do_release_regions:
+	pci_release_regions(pci);
+	return 0;
+}
+/*
+* intel_sst_probe - PCI probe function
+*
+* @pci:	PCI device structure
+* @pci_id: PCI device ID structure
+*
+*/
+static int intel_sst_probe(struct pci_dev *pci,
+			const struct pci_device_id *pci_id)
+{
+	int ret = 0;
+	struct intel_sst_drv *sst_drv_ctx;
+	struct sst_platform_info *sst_pdata = pci->dev.platform_data;
+
+	dev_dbg(&pci->dev, "Probe for DID %x\n", pci->device);
+
+	ret = sst_alloc_drv_context(&sst_drv_ctx, &pci->dev, pci->device);
+	if (ret < 0)
+		return ret;
+
+	sst_drv_ctx->pdata = sst_pdata;
+	sst_drv_ctx->irq_num = pci->irq;
+
+	ret = sst_context_init(sst_drv_ctx);
+	if (ret < 0)
+		goto do_free_drv_ctx;
+
+
+	/* Init the device */
+	ret = pcim_enable_device(pci);
+	if (ret) {
+		dev_err(sst_drv_ctx->dev,
+			"device can't be enabled. Returned err: %d\n", ret);
+		goto do_destroy_wq;
+	}
+	sst_drv_ctx->pci = pci_dev_get(pci);
 
+	ret = sst_platform_get_resources(sst_drv_ctx);
+	if (ret < 0)
+		goto do_destroy_wq;
 
 	sst_set_fw_state_locked(sst_drv_ctx, SST_RESET);
 	snprintf(sst_drv_ctx->firmware_name, sizeof(sst_drv_ctx->firmware_name),
@@ -457,20 +475,16 @@ static int intel_sst_probe(struct pci_dev *pci,
 		goto do_release_regions;
 	}
 
-	sst_drv_ctx->irq_num = pci->irq;
 
 	pci_set_drvdata(pci, sst_drv_ctx);
-	pm_runtime_set_autosuspend_delay(sst_drv_ctx->dev, SST_SUSPEND_DELAY);
-	pm_runtime_use_autosuspend(sst_drv_ctx->dev);
-	pm_runtime_allow(sst_drv_ctx->dev);
-	pm_runtime_put_noidle(sst_drv_ctx->dev);
+	sst_configure_runtime_pm(sst_drv_ctx);
 	sst_register(sst_drv_ctx->dev);
 
 	return ret;
 
 do_release_regions:
 	pci_release_regions(pci);
-do_free_mem:
+do_destroy_wq:
 	destroy_workqueue(sst_drv_ctx->post_msg_wq);
 do_free_drv_ctx:
 	dev_err(sst_drv_ctx->dev, "Probe failed with %d\n", ret);
Signature · 1 line
1.7.0.4
author
#8 lore raw

PATCH 7/9 ASoC: Intel: move PCI probe to a seprate file

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This allow the sst.c to be common across PCI and APCI usages

Author: Subhransu S. Prusty <[email protected]>

---
 sound/soc/intel/Kconfig       |    4 +
 sound/soc/intel/sst/Makefile  |    4 +
 sound/soc/intel/sst/sst.c     |  200 +------------------------------------
 sound/soc/intel/sst/sst.h     |    6 +
 sound/soc/intel/sst/sst_pci.c |  225 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 240 insertions(+), 199 deletions(-)
 create mode 100644 sound/soc/intel/sst/sst_pci.c
sound/soc/intel/Kconfig +4 -0
index 2a3af88..cbc987e 100644
@@ -4,6 +4,7 @@ config SND_MFLD_MACHINE
 	select SND_SOC_SN95031
 	select SND_SST_MFLD_PLATFORM
 	select SND_SST_IPC
+	select SND_SST_IPC_PCI
 	help
           This adds support for ASoC machine driver for Intel(R) MID Medfield platform
           used as alsa device in audio substem in Intel(R) MID devices
@@ -16,6 +17,9 @@ config SND_SST_MFLD_PLATFORM
 config SND_SST_IPC
 	tristate
 
+config SND_SST_IPC_PCI
+	bool
+
 config SND_SOC_INTEL_SST
 	tristate "ASoC support for Intel(R) Smart Sound Technology"
 	select SND_SOC_INTEL_SST_ACPI if ACPI
sound/soc/intel/sst/Makefile +4 -0
index 4d0e79b..b3fbccd 100644
@@ -1,3 +1,7 @@
 snd-intel-sst-objs := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o
 
+ifneq ($(CONFIG_SND_SST_IPC_PCI),)
+snd-intel-sst-objs += sst_pci.o
+endif
+
 obj-$(CONFIG_SND_SST_IPC) += snd-intel-sst.o
sound/soc/intel/sst/sst.c +1 -199

232 lines not on this page · raw message

sound/soc/intel/sst/sst.h +6 -0
index b65b9c0..3ee555e 100644
@@ -40,6 +40,7 @@
 #define MRFLD_FW_FEATURE_BASE_OFFSET 0x4
 #define MRFLD_FW_BSS_RESET_BIT 0
 
+extern const struct dev_pm_ops intel_sst_pm;
 enum sst_states {
 	SST_FW_LOADING = 1,
 	SST_FW_RUNNING,
@@ -537,4 +538,9 @@ void sst_fill_header_dsp(struct ipc_dsp_hdr *dsp, int msg,
 int sst_register(struct device *);
 int sst_unregister(struct device *);
 
+int sst_alloc_drv_context(struct intel_sst_drv **ctx,
+		struct device *dev, unsigned int dev_id);
+int sst_context_init(struct intel_sst_drv *ctx);
+void sst_context_cleanup(struct intel_sst_drv *ctx);
+void sst_configure_runtime_pm(struct intel_sst_drv *ctx);
 #endif
sound/soc/intel/sst/sst_pci.c new file +225 -0

225 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#9 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

At Thu, 30 Oct 2014 16:21:50 +0530,

Quoted 45 lines · Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This allow the sst.c to be common across PCI and APCI usages

Author: Subhransu S. Prusty <[email protected]>

---
 sound/soc/intel/Kconfig       |    4 +
 sound/soc/intel/sst/Makefile  |    4 +
 sound/soc/intel/sst/sst.c     |  200 +------------------------------------
 sound/soc/intel/sst/sst.h     |    6 +
 sound/soc/intel/sst/sst_pci.c |  225 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 240 insertions(+), 199 deletions(-)
 create mode 100644 sound/soc/intel/sst/sst_pci.c
sound/soc/intel/Kconfig +4 -0
index 2a3af88..cbc987e 100644
@@ -4,6 +4,7 @@ config SND_MFLD_MACHINE
 	select SND_SOC_SN95031
 	select SND_SST_MFLD_PLATFORM
 	select SND_SST_IPC
+	select SND_SST_IPC_PCI
 	help
           This adds support for ASoC machine driver for Intel(R) MID Medfield platform
           used as alsa device in audio substem in Intel(R) MID devices
@@ -16,6 +17,9 @@ config SND_SST_MFLD_PLATFORM
 config SND_SST_IPC
 	tristate
 
+config SND_SST_IPC_PCI
+	bool
+
 config SND_SOC_INTEL_SST
 	tristate "ASoC support for Intel(R) Smart Sound Technology"
 	select SND_SOC_INTEL_SST_ACPI if ACPI
sound/soc/intel/sst/Makefile +0 -0
index 4d0e79b..b3fbccd 100644

sound/soc/intel/sst/Makefile line 5

Quoted 5 lines
sound/soc/intel/sst/Makefile +3 -0
@@ -1,3 +1,7 @@
 snd-intel-sst-objs := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o
 
+ifneq ($(CONFIG_SND_SST_IPC_PCI),)
+snd-intel-sst-objs += sst_pci.o
+endif

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

Takashi

author
#10 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 55 lines · Takashi Iwai

At Thu, 30 Oct 2014 16:21:50 +0530,

Quoted 45 lines · Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This allow the sst.c to be common across PCI and APCI usages

Author: Subhransu S. Prusty <[email protected]>

---
 sound/soc/intel/Kconfig       |    4 +
 sound/soc/intel/sst/Makefile  |    4 +
 sound/soc/intel/sst/sst.c     |  200 +------------------------------------
 sound/soc/intel/sst/sst.h     |    6 +
 sound/soc/intel/sst/sst_pci.c |  225 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 240 insertions(+), 199 deletions(-)
 create mode 100644 sound/soc/intel/sst/sst_pci.c
sound/soc/intel/Kconfig +4 -0
index 2a3af88..cbc987e 100644
@@ -4,6 +4,7 @@ config SND_MFLD_MACHINE
 	select SND_SOC_SN95031
 	select SND_SST_MFLD_PLATFORM
 	select SND_SST_IPC
+	select SND_SST_IPC_PCI
 	help
           This adds support for ASoC machine driver for Intel(R) MID Medfield platform
           used as alsa device in audio substem in Intel(R) MID devices
@@ -16,6 +17,9 @@ config SND_SST_MFLD_PLATFORM
 config SND_SST_IPC
 	tristate
 
+config SND_SST_IPC_PCI
+	bool
+
 config SND_SOC_INTEL_SST
 	tristate "ASoC support for Intel(R) Smart Sound Technology"
 	select SND_SOC_INTEL_SST_ACPI if ACPI
sound/soc/intel/sst/Makefile +0 -0
index 4d0e79b..b3fbccd 100644

sound/soc/intel/sst/Makefile line 5

Quoted 5 lines
sound/soc/intel/sst/Makefile +3 -0
@@ -1,3 +1,7 @@
 snd-intel-sst-objs := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o
 
+ifneq ($(CONFIG_SND_SST_IPC_PCI),)
+snd-intel-sst-objs += sst_pci.o
+endif

The standard way is something like

Quoted 6 lines

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

Am okay to change if we have better method which works for both

Signature · 1 line
~Vinod
#11 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

At Thu, 30 Oct 2014 20:04:44 +0530,

Quoted 60 lines · Vinod Koul
Quoted 58 lines · Takashi Iwai

At Thu, 30 Oct 2014 16:21:50 +0530,

Quoted 45 lines · Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This allow the sst.c to be common across PCI and APCI usages

Author: Subhransu S. Prusty <[email protected]>

---
 sound/soc/intel/Kconfig       |    4 +
 sound/soc/intel/sst/Makefile  |    4 +
 sound/soc/intel/sst/sst.c     |  200 +------------------------------------
 sound/soc/intel/sst/sst.h     |    6 +
 sound/soc/intel/sst/sst_pci.c |  225 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 240 insertions(+), 199 deletions(-)
 create mode 100644 sound/soc/intel/sst/sst_pci.c
sound/soc/intel/Kconfig +4 -0
index 2a3af88..cbc987e 100644
@@ -4,6 +4,7 @@ config SND_MFLD_MACHINE
 	select SND_SOC_SN95031
 	select SND_SST_MFLD_PLATFORM
 	select SND_SST_IPC
+	select SND_SST_IPC_PCI
 	help
           This adds support for ASoC machine driver for Intel(R) MID Medfield platform
           used as alsa device in audio substem in Intel(R) MID devices
@@ -16,6 +17,9 @@ config SND_SST_MFLD_PLATFORM
 config SND_SST_IPC
 	tristate
 
+config SND_SST_IPC_PCI
+	bool
+
 config SND_SOC_INTEL_SST
 	tristate "ASoC support for Intel(R) Smart Sound Technology"
 	select SND_SOC_INTEL_SST_ACPI if ACPI
sound/soc/intel/sst/Makefile +0 -0
index 4d0e79b..b3fbccd 100644

sound/soc/intel/sst/Makefile line 5

Quoted 5 lines
sound/soc/intel/sst/Makefile +3 -0
@@ -1,3 +1,7 @@
 snd-intel-sst-objs := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o
 
+ifneq ($(CONFIG_SND_SST_IPC_PCI),)
+snd-intel-sst-objs += sst_pci.o
+endif

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Takashi

author
#12 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 16 lines · Takashi Iwai
Quoted 5 lines
Quoted 5 lines

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 6 lines
Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

And the machine will select required ones..

Signature · 1 line
~Vinod
maintainer
#13 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 8 lines · Vinod Koul

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

Quoted 5 lines

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

And the machine will select required ones..

That's what I would expect to see.

#14 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

In reply to Vinod Koul

At Thu, 30 Oct 2014 21:07:19 +0530,

Quoted 24 lines · Vinod Koul
Quoted 16 lines · Takashi Iwai
Quoted 5 lines
Quoted 5 lines

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 6 lines
Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Quoted 7 lines

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

This may compile both sst_pci.c and sst_acpi.c into snd-intel-sst module, so it doesn't work unless both Kconfigs are really exclusive.

Quoted 3 lines

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

This is wrong in two ways. First off, you can't link a module against another module.

Second, this causes the problem when user build one driver as a module and another as built-in. Then you'll get the doubly symbols.

So, snd-intel-sst.o must be an individual module.

Takashi

author
#15 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 41 lines · Takashi Iwai

At Thu, 30 Oct 2014 21:07:19 +0530,

Quoted 24 lines · Vinod Koul
Quoted 16 lines · Takashi Iwai
Quoted 5 lines
Quoted 5 lines

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 6 lines
Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Quoted 7 lines

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

This may compile both sst_pci.c and sst_acpi.c into snd-intel-sst module, so it doesn't work unless both Kconfigs are really exclusive.

Quoted 3 lines

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

Quoted 5 lines

This is wrong in two ways. First off, you can't link a module against another module.

Second, this causes the problem when user build one driver as a module and another as built-in. Then you'll get the doubly symbols.

oh no, the core is not a module. the PCI and ACPI will be modules and allowed to be selected.
Can we prevent the module/built-in by making depends. If one is built-in other cant be module. That way it would be okay

Quoted 1 line

So, snd-intel-sst.o must be an individual module.

Since only probe and apci/pci resource setup code is different I would still like to keep the core lib as same and PCI/ACPI as modules.

Signature · 1 line
~Vinod
#16 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

At Thu, 30 Oct 2014 21:29:47 +0530,

Quoted 43 lines · Vinod Koul
Quoted 41 lines · Takashi Iwai

At Thu, 30 Oct 2014 21:07:19 +0530,

Quoted 24 lines · Vinod Koul
Quoted 16 lines · Takashi Iwai
Quoted 5 lines
Quoted 5 lines

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 6 lines
Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Quoted 7 lines

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

This may compile both sst_pci.c and sst_acpi.c into snd-intel-sst module, so it doesn't work unless both Kconfigs are really exclusive.

Quoted 3 lines

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

Quoted 7 lines
Quoted 5 lines

This is wrong in two ways. First off, you can't link a module against another module.

Second, this causes the problem when user build one driver as a module and another as built-in. Then you'll get the doubly symbols.

oh no, the core is not a module. the PCI and ACPI will be modules and allowed to be selected.

Then you should have stripped snd- prefix from snd-intel-sst.o. snd-prefix is supposed to be used for the modules.

Quoted 2 lines

Can we prevent the module/built-in by making depends. If one is built-in other cant be module. That way it would be okay

As said, this isn't the best. It disallows the compile testing and other tests in a single shot. Testing with various Kconfigs is more difficult than catching with make allyesconfig (or such).

Takashi

author
#17 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 48 lines · Takashi Iwai

At Thu, 30 Oct 2014 21:29:47 +0530,

Quoted 46 lines · Vinod Koul
Quoted 44 lines · Takashi Iwai

At Thu, 30 Oct 2014 21:07:19 +0530,

Quoted 24 lines · Vinod Koul
Quoted 16 lines · Takashi Iwai
Quoted 5 lines
Quoted 5 lines

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 6 lines
Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Quoted 7 lines

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

This may compile both sst_pci.c and sst_acpi.c into snd-intel-sst module, so it doesn't work unless both Kconfigs are really exclusive.

Quoted 3 lines

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

This is wrong in two ways. First off, you can't link a module against another module.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Second, this causes the problem when user build one driver as a module and another as built-in. Then you'll get the doubly symbols.

oh no, the core is not a module. the PCI and ACPI will be modules and allowed to be selected.

Then you should have stripped snd- prefix from snd-intel-sst.o. snd-prefix is supposed to be used for the modules.

Sure I can do that

so we can have

sst-intel-core-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

and then

snd-intel-sst-pci-y += sst-intel-core.o sst_pci.o snd-intel-sst-acpi-y += st-intel-core.o sst_acpi.o

Quoted 6 lines
Quoted 2 lines

Can we prevent the module/built-in by making depends. If one is built-in other cant be module. That way it would be okay

As said, this isn't the best. It disallows the compile testing and other tests in a single shot. Testing with various Kconfigs is more difficult than catching with make allyesconfig (or such).

well both can be compile tested and we will put in symbols about limitation of having bpth apci and pci as built-in or module.

Signature · 1 line
~Vinod
#18 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

At Thu, 30 Oct 2014 21:44:28 +0530,

Quoted 59 lines · Vinod Koul
Quoted 48 lines · Takashi Iwai

At Thu, 30 Oct 2014 21:29:47 +0530,

Quoted 46 lines · Vinod Koul
Quoted 44 lines · Takashi Iwai

At Thu, 30 Oct 2014 21:07:19 +0530,

Quoted 24 lines · Vinod Koul
Quoted 16 lines · Takashi Iwai
Quoted 5 lines
Quoted 5 lines

The standard way is something like

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o

Quoted 7 lines
Quoted 3 lines

But, when looking at the later patch, you try to build ACPI stuff into snd-intel-sst, too, and both are implemented as exclusive. This doesn't work well in general.

The hardware, firmware so the driver is pretty same. So either it gets probed as PCI device is SFI platforms and as APCI device on ACPI ones. Since the probe method is the only one differing, the machine will select either PCI or ACPI. That one would get compiled in.

... and this exclusion mechanism is missing in your patches. Your current code doesn't allow to mix them.

Quoted 6 lines
Quoted 1 line

Am okay to change if we have better method which works for both

In general, it's better to provide individual modules for different interfaces and a common module that is referred by them. The selective build makes the build tests more difficult and is rather error-prone.

Quoted 7 lines

Hmmm, that makes me wonder why cant we do (based on your input above)

snd-intel-sst-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

then either this:
snd-intel-sst-$(CONFIG_SND_SST_IPC_PCI) += sst_pci.o snd-intel-sst-$(CONFIG_SND_SST_IPC_ACPI) += sst_acpi.o

This may compile both sst_pci.c and sst_acpi.c into snd-intel-sst module, so it doesn't work unless both Kconfigs are really exclusive.

Quoted 3 lines

Or:
snd-intel-sst-pci-y += snd-intel-sst.o sst_pci.o snd-intel-sst-acpi-y += snd-intel-sst.o sst_acpi.o

This is wrong in two ways. First off, you can't link a module against another module.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Second, this causes the problem when user build one driver as a module and another as built-in. Then you'll get the doubly symbols.

oh no, the core is not a module. the PCI and ACPI will be modules and allowed to be selected.

Then you should have stripped snd- prefix from snd-intel-sst.o. snd-prefix is supposed to be used for the modules.

Sure I can do that

Quoted 8 lines

so we can have

sst-intel-core-y := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_loader.o sst_pvt.o

and then

snd-intel-sst-pci-y += sst-intel-core.o sst_pci.o snd-intel-sst-acpi-y += st-intel-core.o sst_acpi.o

Kbuild doesn't allow this syntax, AFAIK.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Can we prevent the module/built-in by making depends. If one is built-in other cant be module. That way it would be okay

As said, this isn't the best. It disallows the compile testing and other tests in a single shot. Testing with various Kconfigs is more difficult than catching with make allyesconfig (or such).

well both can be compile tested and we will put in symbols about limitation of having bpth apci and pci as built-in or module.

No, the point is that the exclusiveness in Kconfig level gives more demerits. This makes impossible to build the both codes in a single shot, which makes also impossible to cover wider build tests, etc. My concern isn't about the actual operation but about testing.

That is: don't try to side step such a build issue. I bet it'll strike back later. Better to keep rather the simple and common approach other drivers take.

Takashi

maintainer
#19 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 6 lines · Takashi Iwai
Quoted 2 lines · Vinod Koul

snd-intel-sst-pci-y += sst-intel-core.o sst_pci.o snd-intel-sst-acpi-y += st-intel-core.o sst_acpi.o

Kbuild doesn't allow this syntax, AFAIK.

I've not followed the whole discussion but why not just have the core code as a separate module, this seems like an awful lot of trouble for something that's normally straightforward...

Quoted 11 lines
Quoted 2 lines

well both can be compile tested and we will put in symbols about limitation of having bpth apci and pci as built-in or module.

No, the point is that the exclusiveness in Kconfig level gives more demerits. This makes impossible to build the both codes in a single shot, which makes also impossible to cover wider build tests, etc. My concern isn't about the actual operation but about testing.

That is: don't try to side step such a build issue. I bet it'll strike back later. Better to keep rather the simple and common approach other drivers take.

Right.

author
#20 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

Quoted 11 lines · Mark Brown
Quoted 6 lines · Takashi Iwai
Quoted 2 lines · Vinod Koul

snd-intel-sst-pci-y += sst-intel-core.o sst_pci.o snd-intel-sst-acpi-y += st-intel-core.o sst_acpi.o

Kbuild doesn't allow this syntax, AFAIK.

I've not followed the whole discussion but why not just have the core code as a separate module, this seems like an awful lot of trouble for something that's normally straightforward...

Hmm seems like my attempt to have just two module is fraught with risks. I will convert core to module which can be linked either by PCI or ACPI.

Thats should clean this out :)
Thanks for all the points

Mark, please drop this patch, the ones before will still be required for module so pls do review them

Thanks

Signature · 1 line
~Vinod
Quoted 14 lines
Quoted 4 lines
Quoted 3 lines

well both can be compile tested and we will put in symbols about limitation of having bpth apci and pci as built-in or module.

Quoted 8 lines

No, the point is that the exclusiveness in Kconfig level gives more demerits. This makes impossible to build the both codes in a single shot, which makes also impossible to cover wider build tests, etc. My concern isn't about the actual operation but about testing.

That is: don't try to side step such a build issue. I bet it'll strike back later. Better to keep rather the simple and common approach other drivers take.

Right.

#21 lore raw

Re: [PATCH 7/9] ASoC: Intel: move PCI probe to a seprate file

In reply to Mark Brown

At Thu, 30 Oct 2014 17:31:12 +0000,

Quoted 4 lines · Mark Brown
Quoted 1 line · Takashi Iwai

Vinod Koul wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

snd-intel-sst-pci-y += sst-intel-core.o sst_pci.o snd-intel-sst-acpi-y += st-intel-core.o sst_acpi.o

Kbuild doesn't allow this syntax, AFAIK.

I've not followed the whole discussion but why not just have the core code as a separate module, this seems like an awful lot of trouble for something that's normally straightforward...

Yep, that's what I've suggested, too.

(Became so late response as we had (and maybe well have again) a
network problem...)

Takashi

author
#22 lore raw

PATCH 8/9 ASoC: Intel: add shim save context and restore routines

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

Some ACPI platform require the driver to save the shim register content and restore them after resume, so add the routines for these
The APCI patch will use these routines

---
 sound/soc/intel/sst/sst.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
sound/soc/intel/sst/sst.c +42 -0
index 97c737a..82346a0 100644
@@ -329,7 +329,49 @@ void sst_configure_runtime_pm(struct intel_sst_drv *ctx)
 	pm_runtime_put_noidle(ctx->dev);
 }
 
+inline void sst_save_shim64(struct intel_sst_drv *ctx,
+			    void __iomem *shim,
+			    struct sst_shim_regs64 *shim_regs)
+{
+	unsigned long irq_flags;
+
+	spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
+
+	shim_regs->csr = sst_shim_read64(shim, SST_CSR),
+	shim_regs->pisr = sst_shim_read64(shim, SST_PISR),
+	shim_regs->pimr = sst_shim_read64(shim, SST_PIMR),
+	shim_regs->isrx = sst_shim_read64(shim, SST_ISRX),
+	shim_regs->isrd = sst_shim_read64(shim, SST_ISRD),
+	shim_regs->imrx = sst_shim_read64(shim, SST_IMRX),
+	shim_regs->imrd = sst_shim_read64(shim, SST_IMRD),
+	shim_regs->ipcx = sst_shim_read64(shim, ctx->ipc_reg.ipcx),
+	shim_regs->ipcd = sst_shim_read64(shim, ctx->ipc_reg.ipcd),
+	shim_regs->isrsc = sst_shim_read64(shim, SST_ISRSC),
+	shim_regs->isrlpesc = sst_shim_read64(shim, SST_ISRLPESC),
+	shim_regs->imrsc = sst_shim_read64(shim, SST_IMRSC),
+	shim_regs->imrlpesc = sst_shim_read64(shim, SST_IMRLPESC),
+	shim_regs->ipcsc = sst_shim_read64(shim, SST_IPCSC),
+	shim_regs->ipclpesc = sst_shim_read64(shim, SST_IPCLPESC),
+	shim_regs->clkctl = sst_shim_read64(shim, SST_CLKCTL),
+	shim_regs->csr2 = sst_shim_read64(shim, SST_CSR2);
+
+	spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
+}
 
+static inline void sst_restore_shim64(struct intel_sst_drv *ctx,
+				      void __iomem *shim,
+				      struct sst_shim_regs64 *shim_regs)
+{
+	unsigned long irq_flags;
+
+	/*
+	 * we only need to restore IMRX for this case, rest will be
+	 * initialize by FW or driver when firmware is loaded
+	 */
+	spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
+	sst_shim_write64(shim, SST_IMRX, shim_regs->imrx),
+	spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
+}
 
 static int intel_sst_runtime_suspend(struct device *dev)
 {
Signature · 1 line
1.7.0.4
maintainer
#23 lore raw

Re: [PATCH 8/9] ASoC: Intel: add shim save context and restore routines

Quoted 5 lines · Vinod Koul

From: Subhransu S. Prusty <[email protected]>

Some ACPI platform require the driver to save the shim register content and restore them after resume, so add the routines for these
The APCI patch will use these routines

Applied everything up to here - this one doesn't apply, probably due to some interaction with one of the other serieses.

author
#24 lore raw

PATCH 9/9 ASoC: Intel: Add ACPI driver for SST

In reply to Vinod Koul

From: Subhransu S. Prusty <[email protected]>

This add support for ACPI platform and adds the BYT device ID to the supported machines

---
 sound/soc/intel/Kconfig        |    3 +
 sound/soc/intel/sst/Makefile   |    4 +
 sound/soc/intel/sst/sst.c      |   19 ++
 sound/soc/intel/sst/sst.h      |    1 +
 sound/soc/intel/sst/sst_acpi.c |  387 ++++++++++++++++++++++++++++++++++++++++
 sound/soc/intel/sst/sst_pvt.c  |    2 +
 6 files changed, 416 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/intel/sst/sst_acpi.c
sound/soc/intel/Kconfig +3 -0
index cbc987e..df489ea 100644
@@ -20,6 +20,9 @@ config SND_SST_IPC
 config SND_SST_IPC_PCI
 	bool
 
+config SND_SST_IPC_ACPI
+	bool
+
 config SND_SOC_INTEL_SST
 	tristate "ASoC support for Intel(R) Smart Sound Technology"
 	select SND_SOC_INTEL_SST_ACPI if ACPI
sound/soc/intel/sst/Makefile +4 -0
index b3fbccd..79accb5 100644
@@ -4,4 +4,8 @@ ifneq ($(CONFIG_SND_SST_IPC_PCI),)
 snd-intel-sst-objs += sst_pci.o
 endif
 
+ifneq ($(CONFIG_SND_SST_IPC_ACPI),)
+snd-intel-sst-objs += sst_acpi.o
+endif
+
 obj-$(CONFIG_SND_SST_IPC) += snd-intel-sst.o
sound/soc/intel/sst/sst.c +19 -0
index 82346a0..5434c23 100644
@@ -176,6 +176,7 @@ int sst_driver_ops(struct intel_sst_drv *sst)
 
 	switch (sst->dev_id) {
 	case SST_MRFLD_PCI_ID:
+	case SST_BYT_ACPI_ID:
 		sst->tstamp = SST_TIME_STAMP_MRFLD;
 		sst->ops = &mrfld_ops;
 		return 0;
@@ -306,7 +307,11 @@ do_free_mem:
 void sst_context_cleanup(struct intel_sst_drv *ctx)
 {
 	pm_runtime_get_noresume(ctx->dev);
+#if IS_ENABLED(CONFIG_ACPI)
+	pm_runtime_disable(ctx->dev);
+#else
 	pm_runtime_forbid(ctx->dev);
+#endif
 	sst_unregister(ctx->dev);
 	sst_set_fw_state_locked(ctx, SST_SHUTDOWN);
 	flush_scheduled_work();
@@ -325,8 +330,18 @@ void sst_configure_runtime_pm(struct intel_sst_drv *ctx)
 {
 	pm_runtime_set_autosuspend_delay(ctx->dev, SST_SUSPEND_DELAY);
 	pm_runtime_use_autosuspend(ctx->dev);
+#if IS_ENABLED(CONFIG_ACPI)
+	/*
+	 * For acpi devices, the actual physical device state is
+	 * initially active. So change the state to active before
+	 * enabling the pm
+	 */
+	pm_runtime_set_active(ctx->dev);
+	pm_runtime_enable(ctx->dev);
+#else
 	pm_runtime_allow(ctx->dev);
 	pm_runtime_put_noidle(ctx->dev);
+#endif
 }
 
 inline void sst_save_shim64(struct intel_sst_drv *ctx,
@@ -393,6 +408,10 @@ static int intel_sst_runtime_suspend(struct device *dev)
 	synchronize_irq(ctx->irq_num);
 	flush_workqueue(ctx->post_msg_wq);
 
+	/* save the shim registers because PMC doesn't save state */
+	if (ctx->dev_id == SST_BYT_ACPI_ID)
+		sst_save_shim64(ctx, ctx->shim, ctx->shim_regs64);
+
 	return ret;
 }
 
sound/soc/intel/sst/sst.h +1 -0
index 3ee555e..80630e5 100644
@@ -29,6 +29,7 @@
 /* driver names */
 #define SST_DRV_NAME "intel_sst_driver"
 #define SST_MRFLD_PCI_ID 0x119A
+#define SST_BYT_ACPI_ID	0x80860F28
 
 #define SST_SUSPEND_DELAY 2000
 #define FW_CONTEXT_MEM (64*1024)
sound/soc/intel/sst/sst_acpi.c new file +387 -0

387 lines not on this page · raw message

sound/soc/intel/sst/sst_pvt.c +2 -0
index 1c2e081..e8efdd0 100644
@@ -117,6 +117,7 @@ unsigned long long read_shim_data(struct intel_sst_drv *sst, int addr)
 
 	switch (sst->dev_id) {
 	case SST_MRFLD_PCI_ID:
+	case SST_BYT_ACPI_ID:
 		val = sst_shim_read64(sst->shim, addr);
 		break;
 	}
@@ -128,6 +129,7 @@ void write_shim_data(struct intel_sst_drv *sst, int addr,
 {
 	switch (sst->dev_id) {
 	case SST_MRFLD_PCI_ID:
+	case SST_BYT_ACPI_ID:
 		sst_shim_write64(sst->shim, addr, (u64) data);
 		break;
 	}
Signature · 1 line
1.7.0.4