Skip to content

Commit a82cf72

Browse files
committed
2 parents bb9ee1e + dcf08d0 commit a82cf72

File tree

8 files changed

+60
-27
lines changed

8 files changed

+60
-27
lines changed

sound/soc/codecs/wm8962.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,7 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
27882788

27892789
if (target % Fref == 0) {
27902790
fll_div->theta = 0;
2791-
fll_div->lambda = 0;
2791+
fll_div->lambda = 1;
27922792
} else {
27932793
gcd_fll = gcd(target, fratio * Fref);
27942794

@@ -2858,7 +2858,7 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
28582858
return -EINVAL;
28592859
}
28602860

2861-
if (fll_div.theta || fll_div.lambda)
2861+
if (fll_div.theta)
28622862
fll1 |= WM8962_FLL_FRAC;
28632863

28642864
/* Stop the FLL while we reconfigure */

sound/soc/fsl/fsl_audmix.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,22 +505,29 @@ static int fsl_audmix_probe(struct platform_device *pdev)
505505
ARRAY_SIZE(fsl_audmix_dai));
506506
if (ret) {
507507
dev_err(dev, "failed to register ASoC DAI\n");
508-
return ret;
508+
goto err_disable_pm;
509509
}
510510

511511
priv->pdev = platform_device_register_data(dev, mdrv, 0, NULL, 0);
512512
if (IS_ERR(priv->pdev)) {
513513
ret = PTR_ERR(priv->pdev);
514514
dev_err(dev, "failed to register platform %s: %d\n", mdrv, ret);
515+
goto err_disable_pm;
515516
}
516517

518+
return 0;
519+
520+
err_disable_pm:
521+
pm_runtime_disable(dev);
517522
return ret;
518523
}
519524

520525
static int fsl_audmix_remove(struct platform_device *pdev)
521526
{
522527
struct fsl_audmix *priv = dev_get_drvdata(&pdev->dev);
523528

529+
pm_runtime_disable(&pdev->dev);
530+
524531
if (priv->pdev)
525532
platform_device_unregister(priv->pdev);
526533

sound/soc/soc-core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
448448
goto free_rtd;
449449

450450
rtd->dev = dev;
451+
INIT_LIST_HEAD(&rtd->list);
452+
INIT_LIST_HEAD(&rtd->component_list);
453+
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients);
454+
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients);
455+
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients);
456+
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients);
451457
dev_set_drvdata(dev, rtd);
452458
INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
453459

@@ -463,12 +469,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
463469
/*
464470
* rtd remaining settings
465471
*/
466-
INIT_LIST_HEAD(&rtd->component_list);
467-
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients);
468-
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients);
469-
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients);
470-
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients);
471-
472472
rtd->card = card;
473473
rtd->dai_link = dai_link;
474474
if (!rtd->dai_link->ops)
@@ -1768,6 +1768,8 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
17681768

17691769
/* convert non BE into BE */
17701770
dai_link->no_pcm = 1;
1771+
dai_link->dpcm_playback = 1;
1772+
dai_link->dpcm_capture = 1;
17711773

17721774
/* override any BE fixups */
17731775
dai_link->be_hw_params_fixup =

sound/soc/soc-topology.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ static void remove_link(struct snd_soc_component *comp,
549549
dobj->ops->link_unload(comp, dobj);
550550

551551
list_del(&dobj->list);
552-
553552
snd_soc_remove_pcm_runtime(comp->card,
554553
snd_soc_get_pcm_runtime(comp->card, link));
555554

sound/soc/sof/imx/imx8.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int imx8_probe(struct snd_sof_dev *sdev)
209209

210210
priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
211211
sizeof(*priv->pd_dev), GFP_KERNEL);
212-
if (!priv)
212+
if (!priv->pd_dev)
213213
return -ENOMEM;
214214

215215
priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
@@ -304,6 +304,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
304304
}
305305
sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
306306

307+
/* set default mailbox offset for FW ready message */
308+
sdev->dsp_box.offset = MBOX_OFFSET;
309+
307310
return 0;
308311

309312
exit_pdev_unregister:

sound/soc/sof/intel/hda-dai.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
217217
link_dev = hda_link_stream_assign(bus, substream);
218218
if (!link_dev)
219219
return -EBUSY;
220+
221+
snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
220222
}
221223

222224
stream_tag = hdac_stream(link_dev)->stream_tag;
@@ -229,8 +231,6 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
229231
if (ret < 0)
230232
return ret;
231233

232-
snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
233-
234234
link = snd_hdac_ext_bus_get_link(bus, codec_dai->component->name);
235235
if (!link)
236236
return -EINVAL;
@@ -362,6 +362,13 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream,
362362
bus = hstream->bus;
363363
rtd = snd_pcm_substream_chip(substream);
364364
link_dev = snd_soc_dai_get_dma_data(dai, substream);
365+
366+
if (!link_dev) {
367+
dev_dbg(dai->dev,
368+
"%s: link_dev is not assigned\n", __func__);
369+
return -EINVAL;
370+
}
371+
365372
hda_stream = hstream_to_sof_hda_stream(link_dev);
366373

367374
/* free the link DMA channel in the FW */

sound/soc/sof/ipc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,9 @@ void snd_sof_ipc_free(struct snd_sof_dev *sdev)
823823
{
824824
struct snd_sof_ipc *ipc = sdev->ipc;
825825

826+
if (!ipc)
827+
return;
828+
826829
/* disable sending of ipc's */
827830
mutex_lock(&ipc->tx_mutex);
828831
ipc->disable_ipc_tx = true;

sound/soc/stm/stm32_spdifrx.c

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/delay.h>
1313
#include <linux/module.h>
1414
#include <linux/of_platform.h>
15-
#include <linux/pinctrl/consumer.h>
1615
#include <linux/regmap.h>
1716
#include <linux/reset.h>
1817

@@ -220,6 +219,7 @@
220219
* @slave_config: dma slave channel runtime config pointer
221220
* @phys_addr: SPDIFRX registers physical base address
222221
* @lock: synchronization enabling lock
222+
* @irq_lock: prevent race condition with IRQ on stream state
223223
* @cs: channel status buffer
224224
* @ub: user data buffer
225225
* @irq: SPDIFRX interrupt line
@@ -240,6 +240,7 @@ struct stm32_spdifrx_data {
240240
struct dma_slave_config slave_config;
241241
dma_addr_t phys_addr;
242242
spinlock_t lock; /* Sync enabling lock */
243+
spinlock_t irq_lock; /* Prevent race condition on stream state */
243244
unsigned char cs[SPDIFRX_CS_BYTES_NB];
244245
unsigned char ub[SPDIFRX_UB_BYTES_NB];
245246
int irq;
@@ -320,14 +321,15 @@ static void stm32_spdifrx_dma_ctrl_stop(struct stm32_spdifrx_data *spdifrx)
320321
static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx)
321322
{
322323
int cr, cr_mask, imr, ret;
324+
unsigned long flags;
323325

324326
/* Enable IRQs */
325327
imr = SPDIFRX_IMR_IFEIE | SPDIFRX_IMR_SYNCDIE | SPDIFRX_IMR_PERRIE;
326328
ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IMR, imr, imr);
327329
if (ret)
328330
return ret;
329331

330-
spin_lock(&spdifrx->lock);
332+
spin_lock_irqsave(&spdifrx->lock, flags);
331333

332334
spdifrx->refcount++;
333335

@@ -362,19 +364,20 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx)
362364
"Failed to start synchronization\n");
363365
}
364366

365-
spin_unlock(&spdifrx->lock);
367+
spin_unlock_irqrestore(&spdifrx->lock, flags);
366368

367369
return ret;
368370
}
369371

370372
static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx)
371373
{
372374
int cr, cr_mask, reg;
375+
unsigned long flags;
373376

374-
spin_lock(&spdifrx->lock);
377+
spin_lock_irqsave(&spdifrx->lock, flags);
375378

376379
if (--spdifrx->refcount) {
377-
spin_unlock(&spdifrx->lock);
380+
spin_unlock_irqrestore(&spdifrx->lock, flags);
378381
return;
379382
}
380383

@@ -393,7 +396,7 @@ static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx)
393396
regmap_read(spdifrx->regmap, STM32_SPDIFRX_DR, &reg);
394397
regmap_read(spdifrx->regmap, STM32_SPDIFRX_CSR, &reg);
395398

396-
spin_unlock(&spdifrx->lock);
399+
spin_unlock_irqrestore(&spdifrx->lock, flags);
397400
}
398401

399402
static int stm32_spdifrx_dma_ctrl_register(struct device *dev,
@@ -480,8 +483,6 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx)
480483
memset(spdifrx->cs, 0, SPDIFRX_CS_BYTES_NB);
481484
memset(spdifrx->ub, 0, SPDIFRX_UB_BYTES_NB);
482485

483-
pinctrl_pm_select_default_state(&spdifrx->pdev->dev);
484-
485486
ret = stm32_spdifrx_dma_ctrl_start(spdifrx);
486487
if (ret < 0)
487488
return ret;
@@ -513,7 +514,6 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx)
513514

514515
end:
515516
clk_disable_unprepare(spdifrx->kclk);
516-
pinctrl_pm_select_sleep_state(&spdifrx->pdev->dev);
517517

518518
return ret;
519519
}
@@ -665,7 +665,6 @@ static const struct regmap_config stm32_h7_spdifrx_regmap_conf = {
665665
static irqreturn_t stm32_spdifrx_isr(int irq, void *devid)
666666
{
667667
struct stm32_spdifrx_data *spdifrx = (struct stm32_spdifrx_data *)devid;
668-
struct snd_pcm_substream *substream = spdifrx->substream;
669668
struct platform_device *pdev = spdifrx->pdev;
670669
unsigned int cr, mask, sr, imr;
671670
unsigned int flags, sync_state;
@@ -745,14 +744,19 @@ static irqreturn_t stm32_spdifrx_isr(int irq, void *devid)
745744
return IRQ_HANDLED;
746745
}
747746

748-
if (substream)
749-
snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
747+
spin_lock(&spdifrx->irq_lock);
748+
if (spdifrx->substream)
749+
snd_pcm_stop(spdifrx->substream,
750+
SNDRV_PCM_STATE_DISCONNECTED);
751+
spin_unlock(&spdifrx->irq_lock);
750752

751753
return IRQ_HANDLED;
752754
}
753755

754-
if (err_xrun && substream)
755-
snd_pcm_stop_xrun(substream);
756+
spin_lock(&spdifrx->irq_lock);
757+
if (err_xrun && spdifrx->substream)
758+
snd_pcm_stop_xrun(spdifrx->substream);
759+
spin_unlock(&spdifrx->irq_lock);
756760

757761
return IRQ_HANDLED;
758762
}
@@ -761,9 +765,12 @@ static int stm32_spdifrx_startup(struct snd_pcm_substream *substream,
761765
struct snd_soc_dai *cpu_dai)
762766
{
763767
struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai);
768+
unsigned long flags;
764769
int ret;
765770

771+
spin_lock_irqsave(&spdifrx->irq_lock, flags);
766772
spdifrx->substream = substream;
773+
spin_unlock_irqrestore(&spdifrx->irq_lock, flags);
767774

768775
ret = clk_prepare_enable(spdifrx->kclk);
769776
if (ret)
@@ -839,8 +846,12 @@ static void stm32_spdifrx_shutdown(struct snd_pcm_substream *substream,
839846
struct snd_soc_dai *cpu_dai)
840847
{
841848
struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai);
849+
unsigned long flags;
842850

851+
spin_lock_irqsave(&spdifrx->irq_lock, flags);
843852
spdifrx->substream = NULL;
853+
spin_unlock_irqrestore(&spdifrx->irq_lock, flags);
854+
844855
clk_disable_unprepare(spdifrx->kclk);
845856
}
846857

@@ -944,6 +955,7 @@ static int stm32_spdifrx_probe(struct platform_device *pdev)
944955
spdifrx->pdev = pdev;
945956
init_completion(&spdifrx->cs_completion);
946957
spin_lock_init(&spdifrx->lock);
958+
spin_lock_init(&spdifrx->irq_lock);
947959

948960
platform_set_drvdata(pdev, spdifrx);
949961

0 commit comments

Comments
 (0)