Re: Sleep during spinlock in TPM driver

From: Andrew Morton
Date: Wed Apr 25 2007 - 21:34:57 EST


On Mon, 23 Apr 2007 08:14:03 -0400 (EDT) Parag Warudkar <pwarudkar@xxxxxxx> wrote:

> --- linux-2.6-us/drivers/char/tpm/tpm.c 2007-04-21 14:55:03.134975360 -0400
> +++ linux-2.6-wk/drivers/char/tpm/tpm.c 2007-04-22 14:58:51.957999963 -0400
> @@ -942,12 +942,12 @@
> {
> struct tpm_chip *chip = file->private_data;
>
> + flush_scheduled_work();
> 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);

btw, this driver has a timer handler which does:

static void user_reader_timeout(unsigned long ptr)
{
struct tpm_chip *chip = (struct tpm_chip *) ptr;

schedule_work(&chip->work);
}

which appears to duplicate schedule_delayed_work()'s functionality.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/