All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Michal Piotrowski <michal.k.k.piotrowski@gmail.com>,
	Andrew Morton <akpm@osdl.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>, linux-kernel@vger.kernel.org
Subject: [patch, -rc5-mm3] fix IDE deadlock in error reporting code
Date: Mon, 5 Jun 2006 10:30:16 +0200	[thread overview]
Message-ID: <20060605083016.GA31013@elte.hu> (raw)
In-Reply-To: <6bffcb0e0606041535u10fdb7c2o9ac38d6fb80fd28d@mail.gmail.com>


* Michal Piotrowski <michal.k.k.piotrowski@gmail.com> wrote:

> >i've uploaded a fixed version - does that work for you?
> 
> Yes, thanks.
> 
> Here is dmesg 
> http://www.stardust.webpages.pl/files/mm/2.6.17-rc5-mm3/mm-dmesg
> Here is latency trace
> http://www.stardust.webpages.pl/files/mm/2.6.17-rc5-mm3/mm-latency.bz2
> Here is config 
> http://www.stardust.webpages.pl/files/mm/2.6.17-rc5-mm3/mm-config
> 
> Here is something new
> Jun  4 23:59:44 ltg01-fedora kernel: hdd: set_drive_speed_status:
> status=0x51 { DriveReady SeekComplete Error }
> Jun  4 23:59:44 ltg01-fedora kernel: hdd: set_drive_speed_status:
> error=0xb4 { AbortedCommand LastFailedSense=0x0b }
> Jun  4 23:59:44 ltg01-fedora kernel: (          hdparm-1821 |#0): new
> 164424143 us user-latency.
> Jun  4 23:59:44 ltg01-fedora kernel: stopped custom tracer.
> Jun  4 23:59:44 ltg01-fedora kernel:
> Jun  4 23:59:44 ltg01-fedora kernel: ============================
> Jun  4 23:59:44 ltg01-fedora kernel: [ BUG: illegal lock usage! ]
> Jun  4 23:59:44 ltg01-fedora kernel: ----------------------------
> Jun  4 23:59:44 ltg01-fedora kernel: illegal {in-hardirq-W} ->
> {hardirq-on-W} usage.
> Jun  4 23:59:44 ltg01-fedora kernel: hdparm/1821 [HC0[0]:SC0[0]:HE1:SE1] 
> takes:
> Jun  4 23:59:44 ltg01-fedora kernel:  (ide_lock){++..}, at:
> [<c0268388>] ide_dump_opcode+0x13/0x9b

ah. That's a real deadlock scenario. Does the patch below fix it? If yes 
then i think this is a candidate for 2.6.17 merging too.

	Ingo

--------------------------
Subject: [patch, -rc5-mm3] fix IDE deadlock in error reporting code
From: Ingo Molnar <mingo@elte.hu>

Michal Piotrowski reported the following validator assert:

 hdd: set_drive_speed_status: status=0x51 { DriveReady SeekComplete Error }
 hdd: set_drive_speed_status: error=0xb4 { AbortedCommand LastFailedSense=0x0b }

 ============================
 [ BUG: illegal lock usage! ]
 ----------------------------
 illegal {in-hardirq-W} -> {hardirq-on-W} usage.
 hdparm/1821 [HC0[0]:SC0[0]:HE1:SE1] takes:
  (ide_lock){++..}, at: [<c0268388>] ide_dump_opcode+0x13/0x9b

 [...]

 stack backtrace:
  [<c0104513>] show_trace+0x1b/0x20
  [<c01045f1>] dump_stack+0x1f/0x24
  [<c013976c>] print_usage_bug+0x1a5/0x1b1
  [<c0139e90>] mark_lock+0x2ca/0x4f7
  [<c013aa96>] __lockdep_acquire+0x47e/0xaa4
  [<c013b536>] lockdep_acquire+0x67/0x7f
  [<c030552d>] _spin_lock+0x24/0x32
  [<c0268388>] ide_dump_opcode+0x13/0x9b
  [<c02688b6>] ide_dump_status+0x4a6/0x4cc
  [<c0267ae6>] ide_config_drive_speed+0x32a/0x33a
  [<c0262dc5>] piix_tune_chipset+0x2ed/0x2f8
  [<c0262e31>] piix_config_drive_xfer_rate+0x61/0xb5
  [<c0263a82>] set_using_dma+0x2f/0x60
  [<c0263bee>] ide_write_setting+0x4a/0xc3
  [<c02647ca>] generic_ide_ioctl+0x8a/0x47f
  [<f886003a>] idecd_ioctl+0xfd/0x133 [ide_cd]
  [<c01f1fff>] blkdev_driver_ioctl+0x4b/0x5f
  [<c01f2783>] blkdev_ioctl+0x770/0x7bd
  [<c017dc0d>] block_ioctl+0x1f/0x21
  [<c0189353>] do_ioctl+0x27/0x6e
  [<c0189604>] vfs_ioctl+0x26a/0x280
  [<c0189667>] sys_ioctl+0x4d/0x7e
  [<c0305ed2>] sysenter_past_esp+0x63/0xa1

in ide_dump_opcode() takes the ide_lock in an irq-unsafe manner,
i.e. this function expects to be called with irqs disabled. But
ide_dump_ata[pi]_status() doesnt do that - it enables interrupts
specifically. That is a no-no - what guarantees that another IDE
port couldnt generate an IDE interrupt while we are dumping this
error? The fix is to turn the irq-enabling in these functions into
irq-disabling.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 drivers/ide/ide-lib.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux/drivers/ide/ide-lib.c
===================================================================
--- linux.orig/drivers/ide/ide-lib.c
+++ linux/drivers/ide/ide-lib.c
@@ -506,7 +506,7 @@ static u8 ide_dump_ata_status(ide_drive_
 	unsigned long flags;
 	u8 err = 0;
 
-	local_irq_set(flags);
+	local_irq_save(flags);
 	printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
 	if (stat & BUSY_STAT)
 		printk("Busy ");
@@ -588,7 +588,7 @@ static u8 ide_dump_atapi_status(ide_driv
 
 	status.all = stat;
 	error.all = 0;
-	local_irq_set(flags);
+	local_irq_save(flags);
 	printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
 	if (status.b.bsy)
 		printk("Busy ");

  reply	other threads:[~2006-06-05  8:30 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-04  6:20 2.6.17-rc5-mm3 Andrew Morton
2006-06-04  9:38 ` 2.6.17-rc5-mm3 Barry K. Nathan
2006-06-04  9:49   ` 2.6.17-rc5-mm3 Andrew Morton
2006-06-04 10:08     ` 2.6.17-rc5-mm3 Michal Piotrowski
2006-06-04 10:41       ` 2.6.17-rc5-mm3 Ingo Molnar
2006-06-04 20:38         ` 2.6.17-rc5-mm3 Valdis.Kletnieks
2006-06-04 21:49           ` [patch, -rc5-mm3] lock validator: early_init_irq_lock_type() build fix Ingo Molnar
     [not found]         ` <6bffcb0e0606040407u4f56f7fdyf5ec479314afc082@mail.gmail.com>
2006-06-04 21:38           ` 2.6.17-rc5-mm3 Ingo Molnar
2006-06-04 22:35             ` 2.6.17-rc5-mm3 Michal Piotrowski
2006-06-05  8:30               ` Ingo Molnar [this message]
2006-06-05  8:35                 ` [patch, -rc5-mm3] fix IDE deadlock in error reporting code Ingo Molnar
2006-06-05 11:33                   ` Michal Piotrowski
2006-06-05 12:24                     ` Ingo Molnar
2006-06-05 12:35                       ` Michal Piotrowski
2006-06-04 18:20 ` 2.6.17-rc5-mm3 Rafael J. Wysocki
2006-06-04 23:01 ` [trivial patch, rc5-mm3] fix typo in acpi pm info message Frederik Deweerdt
2006-06-04 23:15 ` 2.6.17-rc5-mm3 J.A. Magallón
2006-06-04 23:42   ` 2.6.17-rc5-mm3 Andrew Morton
2006-06-05  6:02   ` 2.6.17-rc5-mm3 Valdis.Kletnieks
2006-06-05  8:04   ` 2.6.17-rc5-mm3 Arjan van de Ven
2006-06-04 23:28 ` 2.6.17-rc5-mm3 J.A. Magallón
2006-06-05  0:06   ` 2.6.17-rc5-mm3 Barry K. Nathan
2006-06-05  0:25   ` 2.6.17-rc5-mm3 Grant Coady
2006-06-05  0:45   ` 2.6.17-rc5-mm3 Grant Coady
2006-06-05  9:12   ` 2.6.17-rc5-mm3 Ingo Molnar
2006-06-05 17:56 ` 2.6.17-rc5-mm3 Mel Gorman
2006-06-05 18:54   ` 2.6.17-rc5-mm3 Andrew Morton
2006-06-06  9:43     ` 2.6.17-rc5-mm3 Mel Gorman
2006-06-06 10:57     ` 2.6.17-rc5-mm3 Mel Gorman
2006-06-05 19:48 ` 2.6.17-rc5-mm3 Dave Jones
2006-06-05 20:06   ` 2.6.17-rc5-mm3 Andrew Morton
2006-06-05 20:09     ` 2.6.17-rc5-mm3 Dave Jones
2006-06-05 20:44       ` 2.6.17-rc5-mm3 Dave Jones
2006-06-05 20:53         ` 2.6.17-rc5-mm3 Andrew Morton
2006-06-05 21:02           ` 2.6.17-rc5-mm3 Dave Jones
2006-06-05 21:03         ` 2.6.17-rc5-mm3 Arjan van de Ven
2006-06-06 10:15     ` 2.6.17-rc5-mm3 Takashi Iwai
2006-06-05 23:02 ` 2.6.17-rc5-mm3 Dave Jones
2006-06-06  1:44   ` 2.6.17-rc5-mm3 Randy.Dunlap
2006-06-06  1:54     ` 2.6.17-rc5-mm3 Paul Fulghum
2006-06-06  2:03       ` 2.6.17-rc5-mm3 Randy.Dunlap
2006-06-06  2:19         ` 2.6.17-rc5-mm3 Randy.Dunlap
2006-06-06  2:35           ` 2.6.17-rc5-mm3 Paul Fulghum
2006-06-06 13:30           ` 2.6.17-rc5-mm3 Paul Fulghum
2006-06-06 19:40     ` [PATCH] fix missing hdlc symbols for synclink drivers Paul Fulghum
2006-06-06 20:27       ` Krzysztof Halasa
2006-06-06 20:35         ` Paul Fulghum
2006-06-06 21:09           ` Krzysztof Halasa
2006-06-06 21:20             ` Randy.Dunlap
2006-06-06 21:31               ` Krzysztof Halasa
2006-06-06 21:43               ` Paul Fulghum
2006-06-06 20:45         ` Randy.Dunlap
2006-06-06 20:48         ` Randy.Dunlap
2006-06-06 21:08           ` Randy.Dunlap
2006-06-06 22:44             ` Krzysztof Halasa
2006-06-06 22:52               ` Paul Fulghum
2006-06-06 23:07               ` Randy.Dunlap
2006-06-06 23:22                 ` Paul Fulghum
2006-06-06 23:37                 ` Krzysztof Halasa
2006-06-06 23:51                   ` Randy.Dunlap
2006-06-06 23:56                   ` Paul Fulghum
2006-06-07  0:12                     ` Randy.Dunlap
2006-06-07  0:31                       ` Paul Fulghum
2006-06-07  1:20                         ` Remove patch from 2.6.17-rc5-mm3 Paul Fulghum
2006-06-07  0:42                     ` [PATCH] fix missing hdlc symbols for synclink drivers Krzysztof Halasa
2006-06-07  1:09                       ` Paul Fulghum
2006-06-06 23:11               ` Randy.Dunlap
2006-06-06 21:11           ` Krzysztof Halasa
2006-06-06 21:25             ` Randy.Dunlap
2006-06-06  8:03 ` 2.6.17-rc5-mm3 J.A. Magallón
2006-06-06  8:09   ` [patch, -rc5-mm3] lock validator: add local_irq_enable_in_hardirq() to ide-floppy.c Ingo Molnar

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=20060605083016.GA31013@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=arjan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.k.k.piotrowski@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.