ASoC: renesas: Use guard() for spin locks

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark, Iwai-san

This patch-set follows Iwai-san's guard() update on Renesas drivers.

Kuninori Morimoto (4):
  ASoC: renesas: msiof: Use guard() for spin locks
  ASoC: renesas: rsnd: Use guard() for spin locks
  ASoC: renesas: fsi: Use guard() for spin locks
  ASoC: renesas: rz-ssi: Use guard() for spin locks

 sound/soc/renesas/fsi.c        | 30 ++++++++---------------------
 sound/soc/renesas/rcar/core.c  | 18 +++++------------
 sound/soc/renesas/rcar/msiof.c | 26 ++++++++-----------------
 sound/soc/renesas/rcar/src.c   | 19 ++++++++----------
 sound/soc/renesas/rcar/ssi.c   | 35 +++++++++++++++++-----------------
 sound/soc/renesas/rz-ssi.c     | 14 ++++----------
 6 files changed, 50 insertions(+), 92 deletions(-)

--
2.43.0
This commit is contained in:
Mark Brown 2025-09-09 16:16:07 +01:00
commit 6917b595f5
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
6 changed files with 51 additions and 93 deletions

View File

@ -343,14 +343,9 @@ static void __fsi_reg_mask_set(u32 __iomem *reg, u32 mask, u32 data)
#define fsi_core_read(p, r) _fsi_master_read(p, p->core->r)
static u32 _fsi_master_read(struct fsi_master *master, u32 reg)
{
u32 ret;
unsigned long flags;
guard(spinlock_irqsave)(&master->lock);
spin_lock_irqsave(&master->lock, flags);
ret = __fsi_reg_read(master->base + reg);
spin_unlock_irqrestore(&master->lock, flags);
return ret;
return __fsi_reg_read(master->base + reg);
}
#define fsi_master_mask_set(p, r, m, d) _fsi_master_mask_set(p, MST_##r, m, d)
@ -358,11 +353,9 @@ static u32 _fsi_master_read(struct fsi_master *master, u32 reg)
static void _fsi_master_mask_set(struct fsi_master *master,
u32 reg, u32 mask, u32 data)
{
unsigned long flags;
guard(spinlock_irqsave)(&master->lock);
spin_lock_irqsave(&master->lock, flags);
__fsi_reg_mask_set(master->base + reg, mask, data);
spin_unlock_irqrestore(&master->lock, flags);
}
/*
@ -499,14 +492,10 @@ static int fsi_stream_is_working(struct fsi_priv *fsi,
struct fsi_stream *io)
{
struct fsi_master *master = fsi_get_master(fsi);
unsigned long flags;
int ret;
spin_lock_irqsave(&master->lock, flags);
ret = !!(io->substream && io->substream->runtime);
spin_unlock_irqrestore(&master->lock, flags);
guard(spinlock_irqsave)(&master->lock);
return ret;
return !!(io->substream && io->substream->runtime);
}
static struct fsi_priv *fsi_stream_to_priv(struct fsi_stream *io)
@ -520,9 +509,9 @@ static void fsi_stream_init(struct fsi_priv *fsi,
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct fsi_master *master = fsi_get_master(fsi);
unsigned long flags;
spin_lock_irqsave(&master->lock, flags);
guard(spinlock_irqsave)(&master->lock);
io->substream = substream;
io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size);
io->buff_sample_pos = 0;
@ -533,16 +522,14 @@ static void fsi_stream_init(struct fsi_priv *fsi,
io->oerr_num = -1; /* ignore 1st err */
io->uerr_num = -1; /* ignore 1st err */
fsi_stream_handler_call(io, init, fsi, io);
spin_unlock_irqrestore(&master->lock, flags);
}
static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io)
{
struct snd_soc_dai *dai = fsi_get_dai(io->substream);
struct fsi_master *master = fsi_get_master(fsi);
unsigned long flags;
spin_lock_irqsave(&master->lock, flags);
guard(spinlock_irqsave)(&master->lock);
if (io->oerr_num > 0)
dev_err(dai->dev, "over_run = %d\n", io->oerr_num);
@ -560,7 +547,6 @@ static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io)
io->bus_option = 0;
io->oerr_num = 0;
io->uerr_num = 0;
spin_unlock_irqrestore(&master->lock, flags);
}
static int fsi_stream_transfer(struct fsi_stream *io)

View File

@ -696,25 +696,21 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
int ret;
unsigned long flags;
spin_lock_irqsave(&priv->lock, flags);
guard(spinlock_irqsave)(&priv->lock);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
ret = rsnd_dai_call(init, io, priv);
if (ret < 0)
goto dai_trigger_end;
break;
ret = rsnd_dai_call(start, io, priv);
if (ret < 0)
goto dai_trigger_end;
break;
ret = rsnd_dai_call(irq, io, priv, 1);
if (ret < 0)
goto dai_trigger_end;
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
@ -729,9 +725,6 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
ret = -EINVAL;
}
dai_trigger_end:
spin_unlock_irqrestore(&priv->lock, flags);
return ret;
}
@ -1545,15 +1538,14 @@ static int rsnd_hw_update(struct snd_pcm_substream *substream,
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
struct rsnd_priv *priv = rsnd_io_to_priv(io);
unsigned long flags;
int ret;
spin_lock_irqsave(&priv->lock, flags);
guard(spinlock_irqsave)(&priv->lock);
if (hw_params)
ret = rsnd_dai_call(hw_params, io, substream, hw_params);
else
ret = rsnd_dai_call(hw_free, io, substream);
spin_unlock_irqrestore(&priv->lock, flags);
return ret;
}

View File

@ -372,10 +372,9 @@ static int msiof_trigger(struct snd_soc_component *component,
{
struct device *dev = component->dev;
struct msiof_priv *priv = dev_get_drvdata(dev);
unsigned long flags;
int ret = -EINVAL;
spin_lock_irqsave(&priv->lock, flags);
guard(spinlock_irqsave)(&priv->lock);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
@ -392,8 +391,6 @@ static int msiof_trigger(struct snd_soc_component *component,
break;
}
spin_unlock_irqrestore(&priv->lock, flags);
return ret;
}
@ -404,23 +401,18 @@ static int msiof_hw_params(struct snd_soc_component *component,
struct msiof_priv *priv = dev_get_drvdata(component->dev);
struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
struct dma_slave_config cfg = {};
unsigned long flags;
int ret;
spin_lock_irqsave(&priv->lock, flags);
guard(spinlock_irqsave)(&priv->lock);
ret = snd_hwparams_to_dma_slave_config(substream, params, &cfg);
if (ret < 0)
goto hw_params_out;
return ret;
cfg.dst_addr = priv->phy_addr + SITFDR;
cfg.src_addr = priv->phy_addr + SIRFDR;
ret = dmaengine_slave_config(chan, &cfg);
hw_params_out:
spin_unlock_irqrestore(&priv->lock, flags);
return ret;
return dmaengine_slave_config(chan, &cfg);
}
static const struct snd_soc_component_driver msiof_component_driver = {
@ -439,12 +431,10 @@ static irqreturn_t msiof_interrupt(int irq, void *data)
struct snd_pcm_substream *substream;
u32 sistr;
spin_lock(&priv->lock);
sistr = msiof_read(priv, SISTR);
msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX);
spin_unlock(&priv->lock);
scoped_guard(spinlock, &priv->lock) {
sistr = msiof_read(priv, SISTR);
msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX);
}
/* overflow/underflow error */
substream = priv->substream[SNDRV_PCM_STREAM_PLAYBACK];

View File

@ -558,19 +558,16 @@ static void __rsnd_src_interrupt(struct rsnd_mod *mod,
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
bool stop = false;
spin_lock(&priv->lock);
scoped_guard(spinlock, &priv->lock) {
/* ignore all cases if not working */
if (!rsnd_io_is_working(io))
break;
/* ignore all cases if not working */
if (!rsnd_io_is_working(io))
goto rsnd_src_interrupt_out;
if (rsnd_src_error_occurred(mod))
stop = true;
if (rsnd_src_error_occurred(mod))
stop = true;
rsnd_src_status_clear(mod);
rsnd_src_interrupt_out:
spin_unlock(&priv->lock);
rsnd_src_status_clear(mod);
}
if (stop)
snd_pcm_stop_xrun(io->substream);

View File

@ -680,32 +680,31 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
bool elapsed = false;
bool stop = false;
spin_lock(&priv->lock);
scoped_guard(spinlock, &priv->lock) {
/* ignore all cases if not working */
if (!rsnd_io_is_working(io))
goto rsnd_ssi_interrupt_out;
/* ignore all cases if not working */
if (!rsnd_io_is_working(io))
break;
status = rsnd_ssi_status_get(mod);
status = rsnd_ssi_status_get(mod);
/* PIO only */
if (!is_dma && (status & DIRQ))
elapsed = rsnd_ssi_pio_interrupt(mod, io);
/* PIO only */
if (!is_dma && (status & DIRQ))
elapsed = rsnd_ssi_pio_interrupt(mod, io);
/* DMA only */
if (is_dma && (status & (UIRQ | OIRQ))) {
rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
rsnd_mod_name(mod), status);
/* DMA only */
if (is_dma && (status & (UIRQ | OIRQ))) {
rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
rsnd_mod_name(mod), status);
stop = true;
stop = true;
}
stop |= rsnd_ssiu_busif_err_status_clear(mod);
rsnd_ssi_status_clear(mod);
}
stop |= rsnd_ssiu_busif_err_status_clear(mod);
rsnd_ssi_status_clear(mod);
rsnd_ssi_interrupt_out:
spin_unlock(&priv->lock);
if (elapsed)
snd_pcm_period_elapsed(io->substream);

View File

@ -188,24 +188,18 @@ static void rz_ssi_set_substream(struct rz_ssi_stream *strm,
struct snd_pcm_substream *substream)
{
struct rz_ssi_priv *ssi = strm->priv;
unsigned long flags;
spin_lock_irqsave(&ssi->lock, flags);
guard(spinlock_irqsave)(&ssi->lock);
strm->substream = substream;
spin_unlock_irqrestore(&ssi->lock, flags);
}
static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi,
struct rz_ssi_stream *strm)
{
unsigned long flags;
bool ret;
guard(spinlock_irqsave)(&ssi->lock);
spin_lock_irqsave(&ssi->lock, flags);
ret = strm->substream && strm->substream->runtime;
spin_unlock_irqrestore(&ssi->lock, flags);
return ret;
return strm->substream && strm->substream->runtime;
}
static inline bool rz_ssi_is_stream_running(struct rz_ssi_stream *strm)