lkml.org 
[lkml]   [2013]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio
From
On Thu, Aug 22, 2013 at 5:41 AM, Axel Lin <axel.lin@ingics.com> wrote:
> 2013/8/22 Linus Walleij <linus.walleij@linaro.org>:

>>> + mutex_lock(&pctldev->mutex);
>>> +
>>> /* Convert to the pin controllers number space */
>>> pin = gpio_to_pin(range, gpio);
>>>
>>> ret = pinmux_request_gpio(pctldev, range, pin, gpio);
>>>
>>> + mutex_unlock(&pctldev->mutex);
>>> +
>>> return ret;
>>
>> What is this protecting against?
>>
>> I'm not sure I follow this so better ask.
>
> I think this fixes the race between pin_free() and pin_request() calls.
> (Well, I don't have a h/w to test at this moment.)
> It protects accessing the members of pctldev->desc.
> (e.g. update desc->mux_usecount, desc->gpio_owner, desc->mux_owner, etc)
> Current code grabs pctldev->mutex before calling pinmux_free_gpio(),
> but did not grab the mutex while calling pinmux_request_gpio().

OK you won me over, patch applied!

I also edited in some of the above text into the commit.

Yours,
Linus Walleij


\
 
 \ /
  Last update: 2013-08-28 14:01    [W:0.125 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site