All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Adrian McMenamin <lkmladrian@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org,
	Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH - SH/Dreamcast] Add support for GD-Rom device
Date: Fri, 21 Dec 2007 13:14:42 +0100	[thread overview]
Message-ID: <20071221121441.GB11583@kernel.dk> (raw)
In-Reply-To: <8b67d60712201607k66d67fa2la8b21fc698fdb3ab@mail.gmail.com>

On Fri, Dec 21 2007, Adrian McMenamin wrote:
> On 20/12/2007, Adrian McMenamin <lkmladrian@gmail.com> wrote:
> > This patch adds support for the CD Rom device (called a "GD Rom") on
> > the SEGA Dreamcast.This device has a command block similar to a
> > standard ATA-3 device, though implements Sega's proprietary packet
> > interface - the so-called "Sega Packet Interface".
> >
> 
> Fairly typically, I noticed I had chopped the final line from the
> patch as soon as I had sent it.
> 
> I've also fixed a small difference in the Kconfig

You should properly protect gdrom_deferred, the locking is not clear
there. In gdrom_readdisk_dma() I would do:

static void gdrom_readdisk_dma(struct work_struct *work)
{
        ...

        read_command = kzalloc(sizeof(struct packet_command), GFP_KERNEL);
        if (!read_command)
                probably just defer the work to some time later

        spin_lock(&gdrom_lock);
        while (!list_empty(&gdrom_deferred)) {
                req = list_entry(gdrom_deferred.next, struct request, queuelist);
                list_del_init(&req->queuelist);
                spin_unlock(&gdrom_lock);

                ...

                spin_lock(&gdrom_lock);
        };

        kfree(read_command);
}

That's a lot more obvious imho and doesn't suffer from potential races
or list reordering. Your read_command allocation and free for every
command also seems pretty pointless, so move that outside the loop.

What is pages doing in gdrom_request()?

Your design is also heavily geared towards there just being a single
CDROM, I'm assuming this wont be a problem given your hw (it sets a bad
example for others to follow though, lots of violations against normal
programming practice for multiple devices and smp).

-- 
Jens Axboe


  reply	other threads:[~2007-12-21 12:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-20 23:59 [PATCH - SH/Dreamcast] Add support for GD-Rom device Adrian McMenamin
2007-12-21  0:07 ` Adrian McMenamin
2007-12-21 12:14   ` Jens Axboe [this message]
2007-12-21 12:26     ` Jens Axboe
2007-12-21 14:11     ` Adrian McMenamin
2007-12-21 14:22       ` Jens Axboe
2007-12-21 14:43         ` Adrian McMenamin
2007-12-21 15:01           ` Jens Axboe
2007-12-21 19:12     ` Adrian McMenamin
2007-12-21 19:35       ` Jens Axboe
2007-12-21 19:53         ` Adrian McMenamin
2007-12-22 10:44   ` Mike Frysinger

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=20071221121441.GB11583@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=lkmladrian@gmail.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.