From: Jaehoon Chung <jh80.chung@samsung.com>
To: James Hogan <james.hogan@imgtec.com>,
Doug Anderson <dianders@chromium.org>
Cc: Chris Ball <cjb@laptop.org>, Seungwon Jeon <tgih.jun@samsung.com>,
Grant Grundler <grundler@chromium.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Abhilash Kesavan <a.kesavan@samsung.com>,
Tomasz Figa <tomasz.figa@gmail.com>,
Olof Johansson <olof@lixom.net>,
Sonny Rao <sonnyrao@chromium.org>, Bing Zhao <bzhao@marvell.com>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] mmc: dw_mmc: Protect read-modify-write of INTMASK with a lock
Date: Fri, 18 Oct 2013 18:51:15 +0900 [thread overview]
Message-ID: <52610493.1000909@samsung.com> (raw)
In-Reply-To: <CAAG0J98c6eA_c2McSvFcQUMUfPy-DgdHi7Te1tZqpT8XjjMQvw@mail.gmail.com>
On 10/17/2013 05:23 AM, James Hogan wrote:
> Hi Doug,
>
> On 16 October 2013 17:43, Doug Anderson <dianders@chromium.org> wrote:
>> On Wed, Oct 16, 2013 at 2:49 AM, James Hogan <james.hogan@imgtec.com> wrote:
>>>> We can't just use the standard host->lock since that lock is not irq
>>>> safe and mmc_signal_sdio_irq() (called from interrupt context) calls
>>>> dw_mci_enable_sdio_irq(). Add a new irq-safe lock to protect INTMASK.
>>>>
>>>> An alternate solution to this is to punt mmc_signal_sdio_irq() to the
>>>> tasklet and then protect INTMASK modifications by the standard host
>>>> lock. This seemed like a bit more of a high-latency change.
>>>
>>> A probably lighter-weight alternative to that alternative is to just
>>> make the existing lock irq safe. Has this been considered?
>>>
>>> I'm not entirely convinced it's worth having a separate lock rather than
>>> changing the existing one, but the patch still appears to be correct, so:
>>> Reviewed-by: James Hogan <james.hogan@imgtec.com>
>>
>> I did look at that alternate solution and rejected it, but am happy to
>> send that up if people think it's better. Here's why I rejected it:
>>
>> 1. It looks like someone has gone through quite a bit of work to _not_
>> grab the existing lock in the IRQ handler. The IRQ handler always
>> pushes all real work over to the tasklet. I can only assume that they
>> did this for some good reason and I'd hate to switch it without
>> knowing for sure why.
>>
>> 2. We might have performance problems if we blindly changed the
>> existing code to an IRQ-safe spinlock. We hold the existing
>> "host->lock" spinlock for the entire duration of
>> dw_mci_tasklet_func(). That's a pretty intense chunk of code, full of
>> nested loops (some with 500ms timeouts!), mdelay(20) calls to handle
>> some errors, etc. I say "might" because I think that the expected
>> case is that code runs pretty quickly. I ran some brief tests on one
>> system and saw a worst case time of 170us and an common case time of
>> ~10us. Are we OK with having interrupts disabled for that long? Are
>> we OK with having the dw_mci interrupt handler potentially spin on a
>> spinlock for that long?
>>
>
> Fair enough, I'm convinced now. That code did look pretty heavy when I
> looked at it too.
>
>>
>> I don't think it would be terrible to look at reworking the way that
>> dw_mmc handles interrupts, but that seems pretty major.
Yes, Reworking is pretty major.
but if we need to rework, i think we can rework it in future.
>
> Yeh, I suppose at least the potentially large delays are all for
> exceptional cases, so it's not a critical problem.
>
>> BTW: is the cost of an extra lock actually that high?
>
> I don't know tbh. In this case the spinlock usage doesn't appear to
> actually overlap.
>
>> ...or are you talking the cost in terms of code complexity?
>
> In this case it'd only be a space and code complexity thing I think. I
> suppose in some cases the benefit of finer-grained locking is probably
> pretty marginal, but there's a good case for it here. It might be
> worth renaming the lock to irq_lock or something like that so it's
> clear it doesn't have to protect only for INTMASK in the future - up
> to you.
It seems good that use the irq_lock than intmask_lock. (It's just naming)
>
> Cheers
> James
>
next prev parent reply other threads:[~2013-10-18 9:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-15 22:39 [PATCH 0/2] Prevent races when doing read-modify-write of INTMASK Doug Anderson
2013-10-15 22:39 ` [PATCH 1/2] mmc: dw_mmc: Cleanup disable of low power mode w/ SDIO interrupts Doug Anderson
2013-10-18 9:42 ` Jaehoon Chung
2013-10-18 20:09 ` Doug Anderson
2013-10-23 11:25 ` Seungwon Jeon
2013-10-24 7:28 ` Doug Anderson
2013-10-25 9:29 ` Seungwon Jeon
2013-10-28 22:39 ` Doug Anderson
2013-11-01 5:23 ` Seungwon Jeon
2013-10-15 22:39 ` [PATCH 2/2] mmc: dw_mmc: Protect read-modify-write of INTMASK with a lock Doug Anderson
2013-10-16 9:49 ` James Hogan
2013-10-16 16:43 ` Doug Anderson
2013-10-16 20:23 ` James Hogan
2013-10-18 9:51 ` Jaehoon Chung [this message]
2013-10-18 20:09 ` Doug Anderson
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=52610493.1000909@samsung.com \
--to=jh80.chung@samsung.com \
--cc=a.kesavan@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=bzhao@marvell.com \
--cc=cjb@laptop.org \
--cc=dianders@chromium.org \
--cc=grundler@chromium.org \
--cc=james.hogan@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=olof@lixom.net \
--cc=sonnyrao@chromium.org \
--cc=tgih.jun@samsung.com \
--cc=tomasz.figa@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