From: Arnd Bergmann <arnd@arndb.de>
To: outreachy-kernel@googlegroups.com
Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Subject: Re: [Outreachy kernel] [PATCH] Staging: mt29f_spinand: Replace udelay function with usleep_range
Date: Mon, 02 Nov 2015 21:12:10 +0100 [thread overview]
Message-ID: <8309352.N5ZdtU6YYI@wuerfel> (raw)
In-Reply-To: <20151031085329.GA25133@Socrates-Mint>
On Saturday 31 October 2015 16:53:31 Eva Rachel Retuya wrote:
> On Fri, Oct 30, 2015 at 10:32:40PM +0100, Arnd Bergmann wrote:
> > On Sunday 25 October 2015 01:24:51 Eva Rachel Retuya wrote:
> > > Use 'usleep_range' instead of 'udelay' to elapse time. For
> > > spinand_reset, define the upper limit by a factor of 2 to keep the wait
> > > short while still allowing a "good enough" range for wakeup. Define the
> > > range 250us - 1ms for spinand_cmdfunc to provide enough leeway before
> > > issuing spinand_reset. Checkpatch found this issue.
> > >
> > > CHECK: usleep_range is preferred over udelay; see
> > > Documentation/timers/timers-howto.txt
> >
> > You are missing here an explanation about how you verified that the
> > conversion is safe: Are you sure that the spinand_reset() function
> > is never called from "atomic" context?
>
> Please correct me if I'm wrong. I look up similar patches before this
> and scanned the code taking into consideration what was discussed. In
> this case, I didn't see any indication that it is not allowed to sleep
> and also by looking at the probe function containing
> "devm_kzalloc(..., GFP_KERNEL). The caller/s of the reset function does
> not indicate whether it is on "lock status" and from my analysis, the
> use of "udelay()" simply wants to elapse time before proceeding.
Your analysis is a bit flawed, because you look at the probe function
that uses a pointer to spinand_reset(), and the probe function can clearly
sleep as you describe here, but it is not obvious whether the callers
of the 'cmdfunc' pointers are allowed to sleep as well.
> Do you think it operates in atomic context?
I was commenting on the fact that your changelog text did not describe
whether you checked at all, or how you came to the conclusion that it
was safe.
I have checked the code myself now, and found that the function already
sleeps, so it is safe to add other sleeping function calls, and the
change in your patch is good.
This is important to get right, especially when you modify someone
else's code, because whether code is called in atomic context or not
is fundamental knowledge in the kernel, and getting it wrong can
result in bugs that are hard to find.
Can you try again to figure out why this is a safe conversion?
Arnd
next prev parent reply other threads:[~2015-11-02 20:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-24 17:24 [PATCH] Staging: mt29f_spinand: Replace udelay function with usleep_range Eva Rachel Retuya
2015-10-30 21:32 ` [Outreachy kernel] " Arnd Bergmann
2015-10-31 8:53 ` Eva Rachel Retuya
2015-11-02 20:12 ` Arnd Bergmann [this message]
2015-11-05 18:19 ` Eva Rachel Retuya
2015-11-05 18:48 ` Arnd Bergmann
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=8309352.N5ZdtU6YYI@wuerfel \
--to=arnd@arndb.de \
--cc=eraretuya@gmail.com \
--cc=outreachy-kernel@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.