[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHv-k_-AKvXqXVhxGKLr0R_UW6Tdc_4gm9DxcLXVamNhOrF9UQ@mail.gmail.com>
Date: Fri, 9 Jun 2017 10:07:17 +0530
From: Binoy Jayan <binoy.jayan@...aro.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Rajendra <rnayak@...eaurora.org>,
Mark Brown <broonie@...nel.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Julia Lawall <Julia.Lawall@...6.fr>,
"Michael S. Tsirkin" <mst@...hat.com>,
Cao jin <caoj.fnst@...fujitsu.com>,
Linux Media Mailing List <linux-media@...r.kernel.org>
Subject: Re: [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex
On 8 June 2017 at 20:40, Arnd Bergmann <arnd@...db.de> wrote:
> On Thu, Jun 8, 2017 at 12:04 PM, Binoy Jayan <binoy.jayan@...aro.org> wrote:
>> The semaphore 'cmd_mutex' is used as a simple mutex, so
>> it should be written as one. Semaphores are going away in the future.
>>
>> Signed-off-by: Binoy Jayan <binoy.jayan@...aro.org>
>> ---
>
>> @@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev)
>>
>> static void ngene_stop(struct ngene *dev)
>> {
>> - down(&dev->cmd_mutex);
>> + mutex_lock(&dev->cmd_mutex);
>> i2c_del_adapter(&(dev->channel[0].i2c_adapter));
>> i2c_del_adapter(&(dev->channel[1].i2c_adapter));
>> ngwritel(0, NGENE_INT_ENABLE);
>
> Are you sure about this one? There is only one mutex_lock() and
> then the structure gets freed without a corresponding mutex_unlock().
>
> I suspect this violates some rules of mutexes, either when compile
> testing with "make C=1", or when running with lockdep enabled.
>
> Can we actually have a concurrently held mutex at the time we
> get here? If not, using mutex_destroy() in place of the down()
> may be the right answer.
I noticed the missing 'up' here, but may be semaphores do not have
to adhere to that rule? Thank you for pointing out that. I'll check the
concurrency part. By the way why do we need mutex_destoy?
To debug an aberrate condition?
Thanks,
Binoy
Powered by blists - more mailing lists