* [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name
@ 2013-08-19 2:06 Axel Lin
2013-08-19 2:07 ` [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio Axel Lin
2013-08-21 21:31 ` [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name Linus Walleij
0 siblings, 2 replies; 6+ messages in thread
From: Axel Lin @ 2013-08-19 2:06 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-kernel
The implementation in pinctrl_register_one_pin() ensures pindesc->name is always
not NULL before insert the pindesc to radix tree.
If the desc return from pin_desc_get is not NULL, desc->name is always not NULL.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/pinctrl/core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 4adef2f..53c40d9 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -153,9 +153,7 @@ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)
pin = pctldev->desc->pins[i].number;
desc = pin_desc_get(pctldev, pin);
/* Pin space may be sparse */
- if (desc == NULL)
- continue;
- if (desc->name && !strcmp(name, desc->name))
+ if (desc && !strcmp(name, desc->name))
return pin;
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio
2013-08-19 2:06 [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name Axel Lin
@ 2013-08-19 2:07 ` Axel Lin
2013-08-21 21:42 ` Linus Walleij
2013-08-21 21:31 ` [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name Linus Walleij
1 sibling, 1 reply; 6+ messages in thread
From: Axel Lin @ 2013-08-19 2:07 UTC (permalink / raw)
To: Linus Walleij; +Cc: Patrice Chotard, linux-kernel
This one is missed in commit 42fed7ba "pinctrl: move subsystem mutex to
pinctrl_dev struct".
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/pinctrl/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 53c40d9..92f86ab 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -562,11 +562,15 @@ int pinctrl_request_gpio(unsigned gpio)
return ret;
}
+ 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;
}
EXPORT_SYMBOL_GPL(pinctrl_request_gpio);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name
2013-08-19 2:06 [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name Axel Lin
2013-08-19 2:07 ` [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio Axel Lin
@ 2013-08-21 21:31 ` Linus Walleij
1 sibling, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2013-08-21 21:31 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel@vger.kernel.org
On Mon, Aug 19, 2013 at 4:06 AM, Axel Lin <axel.lin@ingics.com> wrote:
> The implementation in pinctrl_register_one_pin() ensures pindesc->name is always
> not NULL before insert the pindesc to radix tree.
> If the desc return from pin_desc_get is not NULL, desc->name is always not NULL.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Good point. Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio
2013-08-19 2:07 ` [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio Axel Lin
@ 2013-08-21 21:42 ` Linus Walleij
2013-08-22 3:41 ` Axel Lin
0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2013-08-21 21:42 UTC (permalink / raw)
To: Axel Lin; +Cc: Patrice Chotard, linux-kernel@vger.kernel.org
On Mon, Aug 19, 2013 at 4:07 AM, Axel Lin <axel.lin@ingics.com> wrote:
> This one is missed in commit 42fed7ba "pinctrl: move subsystem mutex to
> pinctrl_dev struct".
I think this was never there.
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/pinctrl/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
> index 53c40d9..92f86ab 100644
> --- a/drivers/pinctrl/core.c
> +++ b/drivers/pinctrl/core.c
> @@ -562,11 +562,15 @@ int pinctrl_request_gpio(unsigned gpio)
> return ret;
> }
>
> + 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.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio
2013-08-21 21:42 ` Linus Walleij
@ 2013-08-22 3:41 ` Axel Lin
2013-08-28 11:13 ` Linus Walleij
0 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2013-08-22 3:41 UTC (permalink / raw)
To: Linus Walleij; +Cc: Patrice Chotard, linux-kernel@vger.kernel.org
2013/8/22 Linus Walleij <linus.walleij@linaro.org>:
> On Mon, Aug 19, 2013 at 4:07 AM, Axel Lin <axel.lin@ingics.com> wrote:
>
>> This one is missed in commit 42fed7ba "pinctrl: move subsystem mutex to
>> pinctrl_dev struct".
>
> I think this was never there.
I think it was protected by the global pinctrl_mutex in v3.9, you can check the
source code here:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/pinctrl/core.c?id=refs/tags/v3.9.11
However, commit 42fed7ba44 "pinctrl: move subsystem mutex to
pinctrl_dev struct" then
adds mutex_lock(&pinctrldev_list_mutex); but forgot to add
mutex_lock(&pctldev->mutex);
here although it adds mutex_lock(&pctldev->mutex) in pinctrl_free_gpio().
The mutex_lock(&pinctrldev_list_mutex) is then moved into
pinctrl_get_device_gpio_range()
and pinctrl_ready_for_gpio_range() by commit 44d5f7b "pinctrl: sink
pinctrldev_list_mutex".
>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>> drivers/pinctrl/core.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
>> index 53c40d9..92f86ab 100644
>> --- a/drivers/pinctrl/core.c
>> +++ b/drivers/pinctrl/core.c
>> @@ -562,11 +562,15 @@ int pinctrl_request_gpio(unsigned gpio)
>> return ret;
>> }
>>
>> + 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().
Regards,
Axel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio
2013-08-22 3:41 ` Axel Lin
@ 2013-08-28 11:13 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2013-08-28 11:13 UTC (permalink / raw)
To: Axel Lin; +Cc: Patrice Chotard, linux-kernel@vger.kernel.org
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-08-28 11:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 2:06 [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name Axel Lin
2013-08-19 2:07 ` [PATCH 2/2] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio Axel Lin
2013-08-21 21:42 ` Linus Walleij
2013-08-22 3:41 ` Axel Lin
2013-08-28 11:13 ` Linus Walleij
2013-08-21 21:31 ` [PATCH 1/2] pinctrl: core: Remove unnecessary test for desc->name Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).