From: Andrew Morton <akpm@linux-foundation.org>
To: "David Kyle" <dsk6@pitt.edu>
Cc: linux-kernel@vger.kernel.org, Kylene Jo Hall <kjhall@us.ibm.com>,
tpm@selhorst.net, tpmdd-devel@lists.sourceforge.net
Subject: Re: Sleep during spinlock in TPM driver
Date: Sat, 21 Apr 2007 15:50:55 -0700 [thread overview]
Message-ID: <20070421155055.242d22dc.akpm@linux-foundation.org> (raw)
In-Reply-To: <361d23520704201511j6d345d57u9f6dd6658c78d178@mail.gmail.com>
On Fri, 20 Apr 2007 18:11:10 -0400 "David Kyle" <dsk6@pitt.edu> wrote:
> I've been working with the TPM driver, and I found that if I opened,
> used, then closed the TPM char device very frequently, I would get a
> kernel BUG message saying that the kernel tried to sleep while holding
> a spinlock. I think I've isolated the problem to this function, in
> drivers/char/tpm/tpm.c:
>
> int tpm_release(struct inode *inode, struct file *file)
> {
> struct tpm_chip *chip = file->private_data;
> spin_lock(&driver_lock);
> file->private_data = NULL;
> chip->num_opens--;
> del_singleshot_timer_sync(&chip->user_read_timer);
> flush_scheduled_work();
> atomic_set(&chip->data_pending, 0);
> put_device(chip->dev);
> kfree(chip->data_buffer);
> spin_unlock(&driver_lock);
> return 0;
> }
> EXPORT_SYMBOL_GPL(tpm_release);
>
> I believe that flush_scheduled_work can sleep, correct? Does anyone
> know why this function is called while the spinlock is held?
>
yup, that's a bug. It's not immediately clear to e what driver_lock is
protecting. Some global things, some per-device things, it appears.
A suitable fix might be to make driver_lock a mutex.
next prev parent reply other threads:[~2007-04-21 22:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-20 22:11 Sleep during spinlock in TPM driver David Kyle
2007-04-21 22:50 ` Andrew Morton [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-04-22 19:06 Parag Warudkar
2007-04-23 7:42 ` Jiri Kosina
2007-04-23 12:04 ` Parag Warudkar
2007-04-23 12:14 ` Parag Warudkar
2007-04-26 1:33 ` Andrew Morton
2007-04-23 12:42 ` Jiri Slaby
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=20070421155055.242d22dc.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dsk6@pitt.edu \
--cc=kjhall@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tpm@selhorst.net \
--cc=tpmdd-devel@lists.sourceforge.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox