public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Adrian McMenamin <adrian@newgolddream.dyndns.info>
Cc: Jens Axboe <jens.axboe@oracle.com>,
	Paul Mundt <lethal@linux-sh.org>,
	linux-sh <linux-sh@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on
Date: Sat, 12 Jan 2008 19:15:20 +0000	[thread overview]
Message-ID: <20080112111520.abf625ce.akpm@linux-foundation.org> (raw)
In-Reply-To: <1200147241.6207.17.camel@localhost.localdomain>

On Sat, 12 Jan 2008 14:14:01 +0000 Adrian McMenamin <adrian@newgolddream.dyndns.info> wrote:

> 
> > > +	spin_command->cmd[0] = 0x70;
> > > +	spin_command->cmd[2] = 0x1f;
> > > +	spin_command->buflen = 0;
> > > +	gd.pending = 1;
> > > +	gdrom_packetcommand(gd.cd_info, spin_command);
> > > +	/* 60 second timeout */
> > > +	wait_event_interruptible_timeout(command_queue, gd.pending = 0, HZ * 60);
> > > +	gd.pending = 0;
> > > +	kfree(spin_command);
> > > +	if (gd.status & 0x01) {
> > > +		/* log an error */
> > > +		gdrom_getsense(NULL);
> > > +		return -EIO;
> > > +	}
> > > +	return 0;
> > > +}
> > 
> > If the wait_event_interruptible_timeout() indeed times out, we go ahead and
> > free spin_command.  But someone else could potentially be using it. 
> > 
> > Suppose gdrom_packetcommand() got stuck for a minute due to bad hardware,
> > or some SCHED_FIFO task preempting us here and running for 61 seconds without
> > yielding or something similarly weird.
> > 
> 
> 
> Maybe I am being stupid here, but I don't follow this. They'll get a
> non-fatal error, that's all. Who else would be using spin_command? It's
> just a series of bytes to plug into the GD Rom registers, that's all.
> 

After programming the registers we need to wait for the interrupt to clear
gd.pending, don't we?

<looks>

oh, I see.  gd is a global singleton and we only support one command at a
time and one device.  hrm.

> > > +
> > > +static int __devinit gdrom_set_interrupt_handlers(void)
> > > +{
> > > +	int err;
> > > +	init_waitqueue_head(&command_queue);
> > > +	err = request_irq(HW_EVENT_GDROM_CMD, gdrom_command_interrupt, IRQF_DISABLED, "gdrom_command", &gd);
> > > +	if (err)
> > > +		return err;
> > > +	init_waitqueue_head(&request_queue);
> > 
> > You can initialise command_queue and request_queue at compile-time with
> > DECLARE_WAIT_QUEUE_HEAD().
> > 
> 
> Are you saying that is better?

Yup.  Less source code, less object code, no startup-ordering issues.



  reply	other threads:[~2008-01-12 19:15 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-27  1:26 [PATCH] SH/Dreamcast - add support for GD-Rom device Adrian McMenamin
2007-12-27  8:18 ` Paul Mundt
2007-12-27 12:49   ` Adrian McMenamin
2007-12-27 19:52     ` Jens Axboe
2007-12-27 19:11   ` Mike Frysinger
2007-12-27 16:52 ` Adrian McMenamin
2007-12-27 20:56   ` Adrian McMenamin
2007-12-27 22:20   ` Paul Mundt
2007-12-27 22:58   ` Joe Perches
2007-12-28  0:18     ` Simon Holm Thøgersen
2007-12-29  1:57       ` Joe Perches
2007-12-29 12:03         ` Adrian McMenamin
2007-12-29 12:10           ` Adrian McMenamin
2007-12-29 18:07           ` Joe Perches
2007-12-28  0:49     ` Mike Frysinger
2007-12-28  3:41       ` Paul Mundt
2007-12-28 19:17     ` Gino Badouri
2007-12-28 22:09       ` Joe Perches
2007-12-30 13:38     ` Adrian McMenamin
2007-12-31  5:23       ` Paul Mundt
2008-01-10 23:25 ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Adrian McMenamin
2008-01-11 21:56   ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on Adrian McMenamin
2008-01-12 11:57     ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast Jens Axboe
2008-01-12 13:36     ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on Andrew Morton
2008-01-12 14:14       ` Adrian McMenamin
2008-01-12 19:15         ` Andrew Morton [this message]
2008-01-13 18:24           ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast Adrian McMenamin
2008-01-14 23:00       ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on Adrian McMenamin
2008-01-14 23:17         ` Adrian McMenamin
2008-01-15  0:29           ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast Paul Mundt
2008-01-15 20:41             ` Adrian McMenamin
2008-01-16 23:57           ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on Adrian McMenamin
2008-01-17  1:27             ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast Paul Mundt
2008-01-17 22:30               ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on Adrian McMenamin
2008-01-18  0:56                 ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast Paul Mundt
2008-01-28  5:33                   ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on Andrew Morton
2008-01-28  5:53                     ` [PATCH] SH/Dreamcast - add support for GD-Rom CDROM drive on SEGA Dreamcast Paul Mundt
2008-01-16  1:57       ` Paul Mundt

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=20080112111520.abf625ce.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=adrian@newgolddream.dyndns.info \
    --cc=jens.axboe@oracle.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    /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