Skip to content

Commit

Permalink
ASoC: rsnd: merge .nolock_start and .prepare
Browse files Browse the repository at this point in the history
Main purpose of .nolock_start is we need to call
some function without spinlock.
OTOH we have .prepare which main purpose is
called under atomic context.
Then, it is called without spinlock.

In summary, our main callback init/quit, and start/stop
are called under "atomic context and with spinlock".
And some function need to be called under
"non-atomic context or without spinlock".
Let's merge .nolock_start and prepare to be more clear code.
Then, let's rename nolock_stop to cleanup

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Kuninori Morimoto authored and Mark Brown committed Sep 3, 2018
1 parent d47f958 commit 6ab6a24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
13 changes: 2 additions & 11 deletions sound/soc/sh/rcar/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,12 +881,10 @@ static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
struct snd_pcm_hw_constraint_list *constraint = &rdai->constraint;
struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int max_channels = rsnd_rdai_channels_get(rdai);
int ret;
int i;

rsnd_dai_stream_init(io, substream);
Expand Down Expand Up @@ -930,14 +928,7 @@ static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream,
SNDRV_PCM_HW_PARAM_RATE, -1);
}

/*
* call rsnd_dai_call without spinlock
*/
ret = rsnd_dai_call(nolock_start, io, priv);
if (ret < 0)
rsnd_dai_call(nolock_stop, io, priv);

return ret;
return 0;
}

static void rsnd_soc_dai_shutdown(struct snd_pcm_substream *substream,
Expand All @@ -950,7 +941,7 @@ static void rsnd_soc_dai_shutdown(struct snd_pcm_substream *substream,
/*
* call rsnd_dai_call without spinlock
*/
rsnd_dai_call(nolock_stop, io, priv);
rsnd_dai_call(cleanup, io, priv);

rsnd_dai_stream_quit(io);
}
Expand Down
20 changes: 10 additions & 10 deletions sound/soc/sh/rcar/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ static int rsnd_dmaen_stop(struct rsnd_mod *mod,
return 0;
}

static int rsnd_dmaen_nolock_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
static int rsnd_dmaen_cleanup(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);

/*
* DMAEngine release uses mutex lock.
* Thus, it shouldn't be called under spinlock.
* Let's call it under nolock_start
* Let's call it under prepare
*/
if (dmaen->chan)
dma_release_channel(dmaen->chan);
Expand All @@ -126,9 +126,9 @@ static int rsnd_dmaen_nolock_stop(struct rsnd_mod *mod,
return 0;
}

static int rsnd_dmaen_nolock_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
static int rsnd_dmaen_prepare(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
Expand All @@ -142,7 +142,7 @@ static int rsnd_dmaen_nolock_start(struct rsnd_mod *mod,
/*
* DMAEngine request uses mutex lock.
* Thus, it shouldn't be called under spinlock.
* Let's call it under nolock_start
* Let's call it under prepare
*/
dmaen->chan = rsnd_dmaen_request_channel(io,
dma->mod_from,
Expand Down Expand Up @@ -287,8 +287,8 @@ static int rsnd_dmaen_pointer(struct rsnd_mod *mod,

static struct rsnd_mod_ops rsnd_dmaen_ops = {
.name = "audmac",
.nolock_start = rsnd_dmaen_nolock_start,
.nolock_stop = rsnd_dmaen_nolock_stop,
.prepare = rsnd_dmaen_prepare,
.cleanup = rsnd_dmaen_cleanup,
.start = rsnd_dmaen_start,
.stop = rsnd_dmaen_stop,
.pointer= rsnd_dmaen_pointer,
Expand Down
26 changes: 10 additions & 16 deletions sound/soc/sh/rcar/rsnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,12 @@ struct rsnd_mod_ops {
int (*fallback)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
int (*nolock_start)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
int (*nolock_stop)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
int (*prepare)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
int (*cleanup)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
};

struct rsnd_dai_stream;
Expand All @@ -323,7 +320,7 @@ struct rsnd_mod {
*
* 0xH0000CBA
*
* A 0: nolock_start 1: nolock_stop
* A 0: prepare 1: cleanup
* B 0: init 1: quit
* C 0: start 1: stop
*
Expand All @@ -335,8 +332,8 @@ struct rsnd_mod {
* H 0: pointer
* H 0: prepare
*/
#define __rsnd_mod_shift_nolock_start 0
#define __rsnd_mod_shift_nolock_stop 0
#define __rsnd_mod_shift_prepare 0
#define __rsnd_mod_shift_cleanup 0
#define __rsnd_mod_shift_init 4
#define __rsnd_mod_shift_quit 4
#define __rsnd_mod_shift_start 8
Expand All @@ -348,12 +345,11 @@ struct rsnd_mod {
#define __rsnd_mod_shift_fallback 28 /* always called */
#define __rsnd_mod_shift_hw_params 28 /* always called */
#define __rsnd_mod_shift_pointer 28 /* always called */
#define __rsnd_mod_shift_prepare 28 /* always called */

#define __rsnd_mod_add_probe 0
#define __rsnd_mod_add_remove 0
#define __rsnd_mod_add_nolock_start 1
#define __rsnd_mod_add_nolock_stop -1
#define __rsnd_mod_add_prepare 1
#define __rsnd_mod_add_cleanup -1
#define __rsnd_mod_add_init 1
#define __rsnd_mod_add_quit -1
#define __rsnd_mod_add_start 1
Expand All @@ -363,10 +359,11 @@ struct rsnd_mod {
#define __rsnd_mod_add_fallback 0
#define __rsnd_mod_add_hw_params 0
#define __rsnd_mod_add_pointer 0
#define __rsnd_mod_add_prepare 0

#define __rsnd_mod_call_probe 0
#define __rsnd_mod_call_remove 0
#define __rsnd_mod_call_prepare 0
#define __rsnd_mod_call_cleanup 1
#define __rsnd_mod_call_init 0
#define __rsnd_mod_call_quit 1
#define __rsnd_mod_call_start 0
Expand All @@ -376,9 +373,6 @@ struct rsnd_mod {
#define __rsnd_mod_call_fallback 0
#define __rsnd_mod_call_hw_params 0
#define __rsnd_mod_call_pointer 0
#define __rsnd_mod_call_nolock_start 0
#define __rsnd_mod_call_nolock_stop 1
#define __rsnd_mod_call_prepare 0

#define rsnd_mod_to_priv(mod) ((mod)->priv)
#define rsnd_mod_name(mod) ((mod)->ops->name)
Expand Down

0 comments on commit 6ab6a24

Please sign in to comment.