public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Geoff Levand <geoffrey.levand@am.sony.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: dwalker@mvista.com, matthias.kaehlcke@gmail.com,
	linux-kernel@vger.kernel.org, linux@bohmer.net,
	linuxppc-dev@ozlabs.org, mingo@elte.hu, kjwinchester@gmail.com
Subject: Re: [PATCH 1/3] ps3: vuart: fix error path locking
Date: Tue, 18 Dec 2007 19:04:58 -0800	[thread overview]
Message-ID: <47688A5A.1090902@am.sony.com> (raw)
In-Reply-To: <20071218171050.5bf220fa.akpm@linux-foundation.org>

On 12/18/2007 05:10 PM, Andrew Morton wrote:
> On Wed, 12 Dec 2007 18:00:12 -0800
> Geoff Levand <geoffrey.levand@am.sony.com> wrote:
> 
>> > This stray down would cause a permanent sleep which doesn't seem correct. 
>> > The other uses of this semaphore appear fairly mutex like it's even initialized
>> > with init_MUTEX() ..  So here a patch for removing this one down().
>> > 
>> > Signed-off-by: Daniel Walker <dwalker@mvista.com>
>> > 
>> > ---
>> >  drivers/ps3/ps3-vuart.c |    1 -
>> >  1 file changed, 1 deletion(-)
>> 
>> 
>> Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
>> 
>> 
>> Looks, good. 
> 
> Looks bad to me.

Hi Andrew,

Unfortunately there wasn't enough context in the patch to see
that there is a down() earlier in the routine, and that the patch
does indeed remove an incorrectly placed down().  Here is the
entire routine, marked with what the patch removes.

static int ps3_vuart_probe(struct ps3_system_bus_device *dev)
{
	int result;
	struct ps3_vuart_port_driver *drv;
	struct ps3_vuart_port_priv *priv = NULL;

	dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__);

	drv = ps3_system_bus_dev_to_vuart_drv(dev);

	dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__,
		drv->core.core.name);

	BUG_ON(!drv);

	if (dev->port_number >= PORT_COUNT) {
		BUG();
		return -EINVAL;
	}

	down(&vuart_bus_priv.probe_mutex);

	result = ps3_vuart_bus_interrupt_get();

	if (result)
		goto fail_setup_interrupt;

	if (vuart_bus_priv.devices[dev->port_number]) {
		dev_dbg(&dev->core, "%s:%d: port busy (%d)\n", __func__,
			__LINE__, dev->port_number);
		result = -EBUSY;
		goto fail_busy;
	}

	vuart_bus_priv.devices[dev->port_number] = dev;

	/* Setup dev->driver_priv. */

	dev->driver_priv = kzalloc(sizeof(struct ps3_vuart_port_priv),
		GFP_KERNEL);

	if (!dev->driver_priv) {
		result = -ENOMEM;
		goto fail_dev_malloc;
	}

	priv = to_port_priv(dev);

	INIT_LIST_HEAD(&priv->tx_list.head);
	spin_lock_init(&priv->tx_list.lock);

	INIT_LIST_HEAD(&priv->rx_list.head);
	spin_lock_init(&priv->rx_list.lock);

	INIT_WORK(&priv->rx_list.work.work, NULL);
	priv->rx_list.work.trigger = 0;
	priv->rx_list.work.dev = dev;

	/* clear stale pending interrupts */

	ps3_vuart_clear_rx_bytes(dev, 0);

	ps3_vuart_set_interrupt_mask(dev, INTERRUPT_MASK_RX);

	ps3_vuart_set_triggers(dev, 1, 1);

	if (drv->probe)
		result = drv->probe(dev);
	else {
		result = 0;
		dev_info(&dev->core, "%s:%d: no probe method\n", __func__,
			__LINE__);
	}

	if (result) {
		dev_dbg(&dev->core, "%s:%d: drv->probe failed\n",
			__func__, __LINE__);
removed >>>>>>	down(&vuart_bus_priv.probe_mutex); <<<<<<<<<<<
		goto fail_probe;
	}

	up(&vuart_bus_priv.probe_mutex);

	return result;

fail_probe:
	ps3_vuart_set_interrupt_mask(dev, 0);
	kfree(dev->driver_priv);
	dev->driver_priv = NULL;
fail_dev_malloc:
	vuart_bus_priv.devices[dev->port_number] = NULL;
fail_busy:
	ps3_vuart_bus_interrupt_put();
fail_setup_interrupt:
	up(&vuart_bus_priv.probe_mutex);
	dev_dbg(&dev->core, "%s:%d: failed\n", __func__, __LINE__);
	return result;
}

Thanks for taking the time to scrutinize.

-Geoff



  parent reply	other threads:[~2007-12-19  3:30 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071213003023.117964080@mvista.com>
2007-12-12  8:00 ` [PATCH 1/3] ps3: vuart: fix error path locking Daniel Walker
2007-12-13  2:00   ` Geoff Levand
2007-12-19  1:10     ` Andrew Morton
2007-12-19  1:54       ` Daniel Walker
2007-12-19  3:04       ` Geoff Levand [this message]
2007-12-20 19:32         ` Daniel Walker
2007-12-20 20:06           ` Andrew Morton
2007-12-20 20:13             ` Daniel Walker
2007-12-12  8:00 ` [PATCH 2/3] driver base: memory: semaphore to mutex Daniel Walker
2007-12-12  8:00 ` [PATCH 3/3] net: wireless: bcm43xx: big_buffer_sem " Daniel Walker
2007-12-13  0:48   ` Michael Buesch
2007-12-13  1:17     ` Ray Lee
2007-12-13 13:45       ` Michael Buesch
2007-12-14  0:05         ` Ray Lee
2007-12-14  0:43           ` Michael Buesch
2007-12-14  0:55             ` Harvey Harrison
2007-12-14 10:45               ` Michael Buesch
2007-12-14  1:12             ` Ray Lee
2007-12-14 10:49               ` Michael Buesch
2007-12-14 11:15                 ` Ingo Molnar
2007-12-14 11:39                   ` Michael Buesch
2007-12-14 12:16                     ` Ingo Molnar
2007-12-14 12:31                       ` Michael Buesch
2007-12-14 12:53                         ` Ingo Molnar
2007-12-14 13:08                           ` Michael Buesch
2007-12-14 16:06                             ` Ray Lee
2007-12-14 16:49                               ` Michael Buesch
2007-12-14 18:01                                 ` Ray Lee
2007-12-14 18:11                                   ` Ingo Molnar
2007-12-14 18:47                                     ` Ray Lee
2007-12-14 18:22                                   ` Michael Buesch
2007-12-14 18:45                                     ` Ray Lee
2007-12-14 19:05                                       ` Michael Buesch
2007-12-14 19:25                                         ` Ray Lee
2007-12-14 19:38                                           ` Michael Buesch
2007-12-14 19:55                                             ` Ray Lee
2007-12-14 20:13                                               ` Michael Buesch
2007-12-14 21:39                                                 ` Ray Lee
2007-12-14 12:59                         ` Simon Holm Thøgersen
2007-12-14 13:04                           ` Michael Buesch
2007-12-15  0:51                             ` Rafael J. Wysocki
2007-12-15  0:58                               ` Larry Finger
2007-12-15  1:59                                 ` mvtodevnull
2007-12-15  2:27                                   ` Larry Finger
2007-12-15  4:37                                     ` mvtodevnull
2007-12-15  4:39                                       ` mvtodevnull
2007-12-15  7:18                                         ` Larry Finger
2007-12-15 12:38                                           ` mvtodevnull
2007-12-17  2:17                                             ` mvtodevnull
2007-12-17  6:52                                               ` Larry Finger
2007-12-17  7:17                                                 ` mvtodevnull
2007-12-17  9:49                                                   ` Michael Buesch
2007-12-17 10:15                                                     ` mvtodevnull
2007-12-17 10:35                                                       ` mvtodevnull
2007-12-17 22:04                                                         ` mvtodevnull
2007-12-17 22:45                                                           ` Michael Buesch
2007-12-17 23:12                                                             ` mvtodevnull
2007-12-17 23:18                                                               ` Michael Buesch
2007-12-17 23:27                                                                 ` mvtodevnull
2007-12-18  1:16                                                   ` Larry Finger
2007-12-18  2:34                                                     ` mvtodevnull
2007-12-19  2:12                                                       ` mvtodevnull
2007-12-19  8:11                                                         ` Larry Finger
     [not found]                                                           ` <200712191046.54147.mb@bu3sch.de>
2007-12-19 13:48                                                             ` Ingo Molnar
2007-12-15 10:57                               ` Michael Buesch
2007-12-15 23:18                                 ` Rafael J. Wysocki
2007-12-15 23:27                                   ` Michael Buesch
2007-12-16  2:30                                     ` Larry Finger
2007-12-16 11:13                                       ` Michael Buesch
2007-12-16 13:56                                     ` Johannes Berg
2007-12-16 14:35                                       ` Rafael J. Wysocki
2007-12-16 14:18                                         ` Johannes Berg
2007-12-14  2:09             ` Larry Finger
2007-12-14 10:56             ` Ingo Molnar
2007-12-14 14:14               ` John W. Linville
2007-12-14 14:40                 ` stefano.brivio
2007-12-14 16:27                   ` Ray Lee
2007-12-14 16:45                     ` Ray Lee
2007-12-14 16:59                       ` Michael Buesch
2007-12-14 17:22                         ` Ray Lee
2007-12-14 17:59                         ` Ingo Molnar
2007-12-14 18:38                           ` Michael Buesch
2007-12-15  1:25                             ` Rafael J. Wysocki
2007-12-15 21:43                               ` John W. Linville
2007-12-15 23:26                                 ` Rafael J. Wysocki
2007-12-16  3:20                                   ` Stefan Lippers-Hollmann
2007-12-16  9:22                                 ` Ingo Molnar
2007-12-16 11:23                                   ` Michael Buesch
2007-12-13  1:20     ` Daniel Walker
2007-12-13 10:13       ` Ingo Molnar
2007-12-13 11:11         ` Michael Buesch
2007-12-13 14:23           ` John W. Linville

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=47688A5A.1090902@am.sony.com \
    --to=geoffrey.levand@am.sony.com \
    --cc=akpm@linux-foundation.org \
    --cc=dwalker@mvista.com \
    --cc=kjwinchester@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@bohmer.net \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=matthias.kaehlcke@gmail.com \
    --cc=mingo@elte.hu \
    /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