public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian McMenamin <adrian@newgolddream.dyndns.info>
To: "Jörn Engel" <joern@logfs.org>
Cc: Paul Mundt <lethal@linux-sh.org>, Greg KH <greg@kroah.com>,
	dwmw2 <dwmw2@infradead.org>, LKML <linux-kernel@vger.kernel.org>,
	MTD <linux-mtd@lists.infradead.org>,
	linux-sh <linux-sh@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] 3/3 maple: update bus driver to support Dreamcast VMU
Date: Mon, 24 Mar 2008 17:55:51 +0000	[thread overview]
Message-ID: <1206381351.7543.15.camel@localhost.localdomain> (raw)
In-Reply-To: <20080324173856.GI2899@logfs.org>


On Mon, 2008-03-24 at 18:38 +0100, Jörn Engel wrote:
> On Mon, 24 March 2008 18:07:07 +0100, Jörn Engel wrote:
> > 
> > The second rearranges the list locking a bit.  Previously it was
> > possible to touch maple_waitq or maple_sentq without holding the lock.
> > With my limited understanding of the driver, the second patch may
> > already be enough to prevent the type of corruption you've been seeing.
> 
> Limited understanding indeed.  The problem in the mtd driver is that it
> has no concept of ownership.  For example maple_vmu_read_block() does
> the following:
> 	mdev->mq->sendbuf = sendbuf;
> 	...
> 	maple_add_packet(mdev->mq);
> 
> It accesses some field in mdev->mq, then sends the structure off to
> maple_add_packet().  From this point on, mdev->mq belongs to the bus
> driver - until it calls the callback, vmu_blockread() in this case.
> 
> But a second thread can call into maple_vmu_read_block() again and
> access mdev->mq while it rightfully belongs to the bus driver.  Bad
> things will happen.
> 
> So these two patches try to close the race windows.  Please note the
> FIXME in the write patch - I didn't do all the work.  Real life calls
> for attention, so these will be the last patches for a while.
> 
> Jörn
> 

The problem is that the hardware does not support another callback. In
any case while you are right that the function might be called as second
time, in the original code it will sleep while waiting for the lock,
which is allocated per device.

On the second patch - aiui completions do an uninterruptible wait, that
means they are surely not a good choice for this - especially as the
device could be unplugged at any time. (Admittedly my documentation
migght be of date here)


  reply	other threads:[~2008-03-24 17:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-22 17:43 [PATCH] 0/3 - Add support for VMU flash memory and update maple bus driver on the SEGA Dreamcast Adrian McMenamin
2008-03-22 17:56 ` [PATCH] 1/3 mtd: add Kbuild support and makefile support for Dreamcast VMU Adrian McMenamin
2008-03-24  3:09   ` Paul Mundt
2008-03-22 18:03 ` [PATCH] 2/3 mtd: add support for flash on the SEGA Dreamcast Visual Memory Unit Adrian McMenamin
2008-03-22 18:32   ` Jörn Engel
2008-03-22 18:39     ` Adrian McMenamin
2008-03-22 18:56       ` Jörn Engel
2008-03-24  2:08       ` Paul Mundt
2008-03-24 11:21         ` Jörn Engel
2008-03-24 12:06         ` Adrian McMenamin
2008-03-24 13:21           ` Jörn Engel
2008-03-24 13:58             ` Adrian McMenamin
2008-03-24 14:10               ` Jörn Engel
2008-03-24 14:43                 ` Adrian McMenamin
2008-03-24 14:46                   ` Paul Mundt
2008-03-24 14:54                   ` Jörn Engel
2008-03-24 18:45                     ` Andrew Morton
2008-03-24 23:11                 ` Adrian McMenamin
2008-03-22 18:16 ` [PATCH] 3/3 maple: update bus driver to support Dreamcast VMU Adrian McMenamin
2008-03-24  3:33   ` Paul Mundt
2008-03-24 14:46     ` Jörn Engel
2008-03-24 15:06       ` Adrian McMenamin
2008-03-24 15:29         ` Jörn Engel
2008-03-24 15:51           ` Adrian McMenamin
2008-03-24 16:04             ` Jörn Engel
2008-03-24 17:07               ` Jörn Engel
2008-03-24 17:18                 ` Adrian McMenamin
2008-03-24 17:38                 ` Jörn Engel
2008-03-24 17:55                   ` Adrian McMenamin [this message]
2008-03-24 19:54                     ` Jörn Engel

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=1206381351.7543.15.camel@localhost.localdomain \
    --to=adrian@newgolddream.dyndns.info \
    --cc=akpm@osdl.org \
    --cc=dwmw2@infradead.org \
    --cc=greg@kroah.com \
    --cc=joern@logfs.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.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