From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Anand Moon <linux.amoon@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
Thierry Reding <thierry.reding@gmail.com>,
Javier Martinez Canillas <javier@osg.samsung.com>,
linux-pwm@vger.kernel.org,
Linux Kernel <linux-kernel@vger.kernel.org>,
"linux-samsung-soc@vger.kernel.org"
<linux-samsung-soc@vger.kernel.org>,
Jonathan Richardson <jonathar@broadcom.com>
Subject: Re: [PATCH] pwm: Avoid double mutex lock on pwm_enable
Date: Fri, 11 Dec 2015 13:23:42 +0900 [thread overview]
Message-ID: <566A4FCE.2050303@samsung.com> (raw)
In-Reply-To: <CANAwSgTuTWntpdCrry4KNe9_b9ekJTM_gT-7-bsY53nmorb-tw@mail.gmail.com>
On 11.12.2015 13:07, Anand Moon wrote:
> Hi Krzysztof,
>
> On 22 November 2015 at 05:43, Krzysztof Kozlowski
> <k.kozlowski@samsung.com> wrote:
>> 2015-11-22 3:14 GMT+09:00 Anand Moon <linux.amoon@gmail.com>:
>>> Hi Krzysztof,
[...]
>> Yes, now you pasted the same warning I did...
>>
>> This is still the same issue. I already wrote it:
>>> 1. BUG: sleeping function called from invalid context
>>> 2. DEBUG_LOCKS_WARN_ON(in_interrupt())
>>
>> We can repeat it many times but that won't change anything...
>>
>> Best regards,
>> Krzysztof
>
> Would you consider below changes to fix the above issue.
> I have tested this change by enabling CONFIG_DEBUG_ATOMIC_SLEEP
> And I don't observed issue.
>
> 1. BUG: sleeping function called from invalid context
> 2. DEBUG_LOCKS_WARN_ON(in_interrupt())
>
> Please share your thought on this changes.
>
> root@odroidxu4:/usr/src/odroidxu3-4.y-devel# git diff drivers/pwm/core.c
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index d24ca5f..f3f6cf9 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -506,6 +506,9 @@ int pwm_enable(struct pwm_device *pwm)
> if (!pwm)
> return -EINVAL;
>
> + if (!mutex_is_locked(&pwm->lock))
> + return -EINVAL;
> +
> mutex_lock(&pwm->lock);
>
> if (!test_and_set_bit(PWMF_ENABLED, &pwm->flags)) {
First of all, Thierry suggested way of fixing this:
"Any objections to simply removing it and make all users use a workqueue
or some such if they need to control a PWM as a result of an interrupt
trigger?"
what is wrong with his approach?
Second, you are writing something that looks like mutex-try-lock...
which will fail the pwm_enable(). IMHO this *hides* the real issue and
does not solve anything (except hiding also the warning).
Best regards,
Krzysztof
next prev parent reply other threads:[~2015-12-11 4:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 16:59 [PATCH] pwm: Avoid double mutex lock on pwm_enable Anand Moon
2015-11-21 4:26 ` Krzysztof Kozlowski
2015-11-21 9:40 ` Anand Moon
2015-11-21 9:52 ` Krzysztof Kozlowski
2015-11-21 10:39 ` Anand Moon
2015-11-21 12:11 ` Anand Moon
2015-11-21 13:07 ` Krzysztof Kozlowski
2015-11-21 14:22 ` Anand Moon
2015-11-21 18:14 ` Anand Moon
2015-11-22 0:13 ` Krzysztof Kozlowski
2015-11-23 10:07 ` Thierry Reding
2015-11-23 20:09 ` Jonathan Richardson
2015-12-11 4:07 ` Anand Moon
2015-12-11 4:22 ` Anand Moon
2015-12-11 4:23 ` Krzysztof Kozlowski [this message]
2015-12-11 5:57 ` Anand Moon
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=566A4FCE.2050303@samsung.com \
--to=k.kozlowski@samsung.com \
--cc=javier@osg.samsung.com \
--cc=jonathar@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux.amoon@gmail.com \
--cc=linux@roeck-us.net \
--cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).