public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Vinod <vkoul@kernel.org>
To: Rohit Kumar <rohitkr@codeaurora.org>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	alsa-devel@alsa-project.org, bgoswami@codeaurora.org,
	linux-kernel@vger.kernel.org, plai@codeaurora.org,
	tiwai@suse.com, lgirdwood@gmail.com, robh+dt@kernel.org,
	broonie@kernel.org, srinivas.kandagatla@linaro.org
Subject: Re: [PATCH] ASoC: qcom: add sdm845 sound card support
Date: Wed, 20 Jun 2018 15:01:06 +0530	[thread overview]
Message-ID: <20180620093106.GI13316@vkoul-mobl> (raw)
In-Reply-To: <f7891675-4c98-7fc6-b80f-840ada9a1c5b@codeaurora.org>

Hi Rohit,

On 20-06-18, 13:07, Rohit Kumar wrote:
> > On 19-06-18, 19:20, Rohit Kumar wrote:
> > > On 6/19/2018 10:35 AM, Vinod wrote:
> > > > On 18-06-18, 16:46, Rohit kumar wrote:
> > > > 
> > > > > +struct sdm845_snd_data {
> > > > > +	struct snd_soc_card *card;
> > > > > +	struct regulator *vdd_supply;
> > > > > +	struct snd_soc_dai_link dai_link[];
> > > > > +};
> > > > > +
> > > > > +static struct mutex pri_mi2s_res_lock;
> > > > > +static struct mutex quat_tdm_res_lock;
> > > > any reason why the locks can't be part of sdm845_snd_data?
> > > > Also why do we need two locks ?
> > > No specific reason, I will move it to sdm845_snd_data.
> > > These locks are used to protect enable/disable of bit clocks. We have
> > > Primary MI2S RX/TX
> > > and Quaternary TDM RX/TX interfaces. For primary mi2s rx/tx, we have single
> > > clock which is
> > > synchronized with pri_mi2s_res_lock. For Quat TDM RX/TX, we are using
> > > quat_tdm_res_lock.
> > > We need two locks as we are protecting two different resources.
> > I think bigger question is why do you need any locks? What is the race
> > scenario you envision which needs protection
> > 
> 
> Below is one of the race condition:
> 
> Thread1                          |         Thread2
> ----------------------------------------------------------
> startup()                         |
> count++;                         |    startup()
> read count (count = 1) |
> enable_clock()               |    count++;   //count = 2
> shutdown()                    |
> count--;// count = 1      |
>                                          | read count (count = 1)
>                                          | enable_clock()
> 
> Here clock will be enabled twice but disable will be called only once when
> count = 0.
> 
> This will make the clock always enabled. So, I think we should keep either
> mutex lock or atomic variable to synchronize this.

we are using DPCM here right?

-- 
~Vinod

  reply	other threads:[~2018-06-20  9:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 11:16 [PATCH] ASoC: qcom: add sdm845 sound card support Rohit kumar
2018-06-19  5:05 ` [alsa-devel] " Vinod
2018-06-19 13:50   ` Rohit Kumar
2018-06-19 16:22     ` Vinod
2018-06-20  7:37       ` Rohit Kumar
2018-06-20  9:31         ` Vinod [this message]
2018-06-20  9:53           ` Srinivas Kandagatla
2018-06-20 10:28             ` Vinod
2018-06-19  8:46 ` Srinivas Kandagatla
2018-06-19 13:58   ` [alsa-devel] " Rohit Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180620093106.GI13316@vkoul-mobl \
    --to=vkoul@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=plai@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=rohitkr@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox