From: Greg KH <gregkh@linuxfoundation.org>
To: Duoming Zhou <duoming@zju.edu.cn>
Cc: linux-kernel@vger.kernel.org, laforge@gnumonks.org,
arnd@arndb.de, linux@dominikbrodowski.net,
baijiaju1990@gmail.com
Subject: Re: [PATCH] Revert "char: pcmcia: cm4000_cs: Replace mdelay with usleep_range in set_protocol"
Date: Sun, 18 Dec 2022 12:43:27 +0100 [thread overview]
Message-ID: <Y5783zWoitPPyoOG@kroah.com> (raw)
In-Reply-To: <20221128053915.90474-1-duoming@zju.edu.cn>
On Mon, Nov 28, 2022 at 01:39:15PM +0800, Duoming Zhou wrote:
> This reverts commit be826ada52f1fcabed5b5217c94609ebf5967211.
>
> The function monitor_card() is a timer handler that runs in an
> atomic context, but it calls usleep_range() that can sleep.
> As a result, the sleep-in-atomic-context bugs will happen.
> The process is shown below:
>
> (atomic context)
> monitor_card()
> set_protocol()
> usleep_range() //sleep
>
> The origin commit c1986ee9bea3 ("[PATCH] New Omnikey Cardman
> 4000 driver") works fine.
>
> Fixes: be826ada52f1 ("char: pcmcia: cm4000_cs: Replace mdelay with usleep_range in set_protocol")
> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
> ---
> drivers/char/pcmcia/cm4000_cs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
> index adaec8fd4b1..7125f89531f 100644
> --- a/drivers/char/pcmcia/cm4000_cs.c
> +++ b/drivers/char/pcmcia/cm4000_cs.c
> @@ -529,7 +529,7 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
> DEBUGP(5, dev, "NumRecBytes is valid\n");
> break;
> }
> - usleep_range(10000, 11000);
> + mdelay(10);
> }
> if (i == 100) {
> DEBUGP(5, dev, "Timeout waiting for NumRecBytes getting "
> @@ -549,7 +549,7 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
> }
> break;
> }
> - usleep_range(10000, 11000);
> + mdelay(10);
Can you add a comment that says "can not sleep as this is atomic
context" for these calls so that this doesn't get changed again in the
future?
thanks,
greg k-h
next prev parent reply other threads:[~2022-12-18 11:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 5:39 [PATCH] Revert "char: pcmcia: cm4000_cs: Replace mdelay with usleep_range in set_protocol" Duoming Zhou
2022-12-18 11:43 ` Greg KH [this message]
2022-12-18 13:11 ` duoming
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=Y5783zWoitPPyoOG@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=baijiaju1990@gmail.com \
--cc=duoming@zju.edu.cn \
--cc=laforge@gnumonks.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
/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.