linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Linux Software RAID is really RAID?
@ 2007-06-26 17:43 Johny Mail list
  2007-06-26 18:34 ` Brad Campbell
  0 siblings, 1 reply; 10+ messages in thread
From: Johny Mail list @ 2007-06-26 17:43 UTC (permalink / raw)
  To: linux-raid

Hello list,
I have a little question about software RAID on Linux.
I have installed Software Raid on all my SC1425 servers DELL by
believing that the md raid was a strong driver.
And recently i make some test on a server and try to view if the RAID
hard drive power failure work fine, so i power up my server and after
booting and the prompt appear I disconnected the power cable of my
SATA hard drive. Normaly the MD should eleminate the failure hard
drive of the logical drive it build, and the server continue to work
fine like nothing happen. Oddly the server stop to respond and i get
this messages :
ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
ata4.00: cmd e7/00:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x0 data 0
              res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata4: port is slow to respond, please be patient (Status 0xd0)
ata4: port failed to respond (30sec, Status 0xd0)
ata4: soft resetting port

After that my system is frozen. Normaly in a basic RAID the device is
"disable" in the logical RAID device (md0) and it only use the last
disk.

I have make the same test on Windows with the fakeraid in the
bios/sata chip and with one disk disconnected the system is always up
with a logical device.

I use Linux RAID + LVM + ext3 a basic combinaison, i have make this
test on debian etch defautl kernel and with the last version of the
kernel. If anyone have an idea why the driver don't manage electric
failure of an hard drive ...

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-06-26 17:43 Linux Software RAID is really RAID? Johny Mail list
@ 2007-06-26 18:34 ` Brad Campbell
  2007-06-27 11:54   ` Johny Mail list
  2007-07-03  8:15   ` Tejun Heo
  0 siblings, 2 replies; 10+ messages in thread
From: Brad Campbell @ 2007-06-26 18:34 UTC (permalink / raw)
  To: Johny Mail list; +Cc: linux-raid, linux-ide

Johny Mail list wrote:
> Hello list,
> I have a little question about software RAID on Linux.
> I have installed Software Raid on all my SC1425 servers DELL by
> believing that the md raid was a strong driver.
> And recently i make some test on a server and try to view if the RAID
> hard drive power failure work fine, so i power up my server and after
> booting and the prompt appear I disconnected the power cable of my
> SATA hard drive. Normaly the MD should eleminate the failure hard
> drive of the logical drive it build, and the server continue to work
> fine like nothing happen. Oddly the server stop to respond and i get
> this messages :
> ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
> ata4.00: cmd e7/00:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x0 data 0
>              res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
> ata4: port is slow to respond, please be patient (Status 0xd0)
> ata4: port failed to respond (30sec, Status 0xd0)
> ata4: soft resetting port
> 
> After that my system is frozen. Normaly in a basic RAID the device is
> "disable" in the logical RAID device (md0) and it only use the last
> disk.

cc to linux-ide added.

Unfortunately this is not an artifact of the linux raid driver, rather it appears to be an issue 
with the SATA driver and related error recovery. Some information about what kernel, configuration, 
drives, controller cards and other relevant system information would be good.

See the information at this URL for the sort of extra information that would be handy.

http://www.kernel.org/pub/linux/docs/lkml/reporting-bugs.html


Regards,
Brad
-- 
"Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so." -- Douglas Adams

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-06-26 18:34 ` Brad Campbell
@ 2007-06-27 11:54   ` Johny Mail list
  2007-07-03  8:15   ` Tejun Heo
  1 sibling, 0 replies; 10+ messages in thread
From: Johny Mail list @ 2007-06-27 11:54 UTC (permalink / raw)
  To: Brad Campbell; +Cc: linux-raid, linux-ide

2007/6/26, Brad Campbell <brad@wasp.net.au>:
> Johny Mail list wrote:
> > Hello list,
> > I have a little question about software RAID on Linux.
> > I have installed Software Raid on all my SC1425 servers DELL by
> > believing that the md raid was a strong driver.
> > And recently i make some test on a server and try to view if the RAID
> > hard drive power failure work fine, so i power up my server and after
> > booting and the prompt appear I disconnected the power cable of my
> > SATA hard drive. Normaly the MD should eleminate the failure hard
> > drive of the logical drive it build, and the server continue to work
> > fine like nothing happen. Oddly the server stop to respond and i get
> > this messages :
> > ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
> > ata4.00: cmd e7/00:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x0 data 0
> >              res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
> > ata4: port is slow to respond, please be patient (Status 0xd0)
> > ata4: port failed to respond (30sec, Status 0xd0)
> > ata4: soft resetting port
> >
> > After that my system is frozen. Normaly in a basic RAID the device is
> > "disable" in the logical RAID device (md0) and it only use the last
> > disk.
>
> cc to linux-ide added.
>
> Unfortunately this is not an artifact of the linux raid driver, rather it appears to be an issue
> with the SATA driver and related error recovery. Some information about what kernel, configuration,
> drives, controller cards and other relevant system information would be good.
>
> See the information at this URL for the sort of extra information that would be handy.
>
> http://www.kernel.org/pub/linux/docs/lkml/reporting-bugs.html
>
>
> Regards,
> Brad
> --
> "Human beings, who are almost unique in having the ability
> to learn from the experience of others, are also remarkable
> for their apparent disinclination to do so." -- Douglas Adams
>

Ok no problem.
I have a DELL SC1425 with a no card controler, only chipset for SATA
and FakeRAID (Intel Chipset and Adaptec for FakeRAID but i have
disable this function) :
00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE
Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801EB (ICH5) SATA Controller (rev 02)
Specs of the server here :
http://www.dell.com/downloads/global/products/pedge/en/sc1425_specs.pdf

Hard Drivers are 2 S-ATA Model=WDC WD800JD-75LSA0.

I use , in my kernel configuration 2.6.21.5 :
- "ATA device support" (CONFIG_ATA)
-- "Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support" Driver (CONFIG_ATA_PIIX)

And get this messages during my boot :
[   30.961007] libata version 2.20 loaded.
[   31.867977] Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
[   31.868037] ide: Assuming 33MHz system bus speed for PIO modes;
override with idebus=xx
[   31.868369] Probing IDE interface ide0...
[   32.432715] Probing IDE interface ide1...
[   32.995829] ata_piix 0000:00:1f.1: version 2.10ac1
[   32.995843] PCI: Enabling device 0000:00:1f.1 (0000 -> 0003)
[   32.995905] ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level,
low) -> IRQ 18
[   32.996027] PCI: Setting latency timer of device 0000:00:1f.1 to 64
[   32.996094] ata1: PATA max UDMA/133 cmd 0x00000000000101f0 ctl
0x00000000000103f6 bmdma 0x000000000001fc00 irq 14
[   32.996213] ata2: PATA max UDMA/133 cmd 0x0000000000010170 ctl
0x0000000000010376 bmdma 0x000000000001fc08 irq 15
[   32.996305] scsi0 : ata_piix
[   32.996443] ata1: port disabled. ignoring.
[   32.996467] scsi1 : ata_piix
[   32.996582] ata2: port disabled. ignoring.
[   32.996613] ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
[   32.996858] ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level,
low) -> IRQ 18
[   32.996977] PCI: Setting latency timer of device 0000:00:1f.2 to 64
[   32.997014] ata3: SATA max UDMA/133 cmd 0x000000000001ccb8 ctl
0x000000000001ccb2 bmdma 0x000000000001cc80 irq 18
[   32.997125] ata4: SATA max UDMA/133 cmd 0x000000000001cca0 ctl
0x000000000001cc9a bmdma 0x000000000001cc88 irq 18
[   32.997210] scsi2 : ata_piix
[   33.167491] ata3.00: ATA-7: WDC WD800JD-75LSA0, 09.01D09, max UDMA/133
[   33.167551] ata3.00: 156250000 sectors, multi 8: LBA48
[   33.179467] ata3.00: configured for UDMA/133
[   33.179527] scsi3 : ata_piix
[   33.351130] ata4.00: ATA-7: WDC WD800JD-75LSA0, 09.01D09, max UDMA/133
[   33.351190] ata4.00: 156250000 sectors, multi 8: LBA48
[   33.363112] ata4.00: configured for UDMA/133
[   33.363277] scsi 2:0:0:0: Direct-Access     ATA      WDC
WD800JD-75LS 09.0 PQ: 0 ANSI: 5
[   33.363476] SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB)
[   33.363550] sda: Write Protect is off
[   33.363606] sda: Mode Sense: 00 3a 00 00
[   33.363635] SCSI device sda: write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[   33.363770] SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB)
[   33.363843] sda: Write Protect is off
[   33.363899] sda: Mode Sense: 00 3a 00 00
[   33.363928] SCSI device sda: write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[   33.364002]  sda: sda1 sda2 sda3
[   33.369982] sd 2:0:0:0: Attached scsi disk sda
[   33.370118] sd 2:0:0:0: Attached scsi generic sg0 type 0
[   33.370262] scsi 3:0:0:0: Direct-Access     ATA      WDC
WD800JD-75LS 09.0 PQ: 0 ANSI: 5
[   33.370450] SCSI device sdb: 156250000 512-byte hdwr sectors (80000 MB)
[   33.370524] sdb: Write Protect is off
[   33.370580] sdb: Mode Sense: 00 3a 00 00
[   33.370609] SCSI device sdb: write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[   33.370729] SCSI device sdb: 156250000 512-byte hdwr sectors (80000 MB)
[   33.370802] sdb: Write Protect is off
[   33.370858] sdb: Mode Sense: 00 3a 00 00
[   33.370886] SCSI device sdb: write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[   33.370967]  sdb: sdb1 sdb2
[   33.375935] sd 3:0:0:0: Attached scsi disk sdb
[   33.376068] sd 3:0:0:0: Attached scsi generic sg1 type 0


If you want all my .config, i can post it.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-06-26 18:34 ` Brad Campbell
  2007-06-27 11:54   ` Johny Mail list
@ 2007-07-03  8:15   ` Tejun Heo
  2007-07-03 12:17     ` Johny Mail list
  1 sibling, 1 reply; 10+ messages in thread
From: Tejun Heo @ 2007-07-03  8:15 UTC (permalink / raw)
  To: Brad Campbell; +Cc: Johny Mail list, linux-raid, linux-ide

Brad Campbell wrote:
> Johny Mail list wrote:
>> Hello list,
>> I have a little question about software RAID on Linux.
>> I have installed Software Raid on all my SC1425 servers DELL by
>> believing that the md raid was a strong driver.
>> And recently i make some test on a server and try to view if the RAID
>> hard drive power failure work fine, so i power up my server and after
>> booting and the prompt appear I disconnected the power cable of my
>> SATA hard drive. Normaly the MD should eleminate the failure hard
>> drive of the logical drive it build, and the server continue to work
>> fine like nothing happen. Oddly the server stop to respond and i get
>> this messages :
>> ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
>> ata4.00: cmd e7/00:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x0 data 0
>>              res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
>> ata4: port is slow to respond, please be patient (Status 0xd0)
>> ata4: port failed to respond (30sec, Status 0xd0)
>> ata4: soft resetting port
>>
>> After that my system is frozen.

How hard is it frozen?  Can you blink the Numlock LED?

-- 
tejun

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-07-03  8:15   ` Tejun Heo
@ 2007-07-03 12:17     ` Johny Mail list
  2007-07-03 23:08       ` Mark Lord
  0 siblings, 1 reply; 10+ messages in thread
From: Johny Mail list @ 2007-07-03 12:17 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Brad Campbell, linux-raid, linux-ide

2007/7/3, Tejun Heo <htejun@gmail.com>:
> Brad Campbell wrote:
> > Johny Mail list wrote:
> >> Hello list,
> >> I have a little question about software RAID on Linux.
> >> I have installed Software Raid on all my SC1425 servers DELL by
> >> believing that the md raid was a strong driver.
> >> And recently i make some test on a server and try to view if the RAID
> >> hard drive power failure work fine, so i power up my server and after
> >> booting and the prompt appear I disconnected the power cable of my
> >> SATA hard drive. Normaly the MD should eleminate the failure hard
> >> drive of the logical drive it build, and the server continue to work
> >> fine like nothing happen. Oddly the server stop to respond and i get
> >> this messages :
> >> ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
> >> ata4.00: cmd e7/00:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x0 data 0
> >>              res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
> >> ata4: port is slow to respond, please be patient (Status 0xd0)
> >> ata4: port failed to respond (30sec, Status 0xd0)
> >> ata4: soft resetting port
> >>
> >> After that my system is frozen.
>
> How hard is it frozen?  Can you blink the Numlock LED?
>
> --
> tejun
>
Hello tejun
It froze just when the "ata4: port failed to respond (30sec, Status
0xd0)" is printed and yes my Numblock LED not respond when i press the
numlock key.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-07-03 12:17     ` Johny Mail list
@ 2007-07-03 23:08       ` Mark Lord
  2007-07-04  1:20         ` Tejun Heo
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Lord @ 2007-07-03 23:08 UTC (permalink / raw)
  To: Johny Mail list; +Cc: Tejun Heo, Brad Campbell, linux-raid, linux-ide

Johny Mail list wrote:
> 2007/7/3, Tejun Heo <htejun@gmail.com>:
>> Brad Campbell wrote:
>> > Johny Mail list wrote:
>> >> Hello list,
>> >> I have a little question about software RAID on Linux.
>> >> I have installed Software Raid on all my SC1425 servers DELL by
>> >> believing that the md raid was a strong driver.
>> >> And recently i make some test on a server and try to view if the RAID
>> >> hard drive power failure work fine, so i power up my server and after
>> >> booting and the prompt appear I disconnected the power cable of my
>> >> SATA hard drive. Normaly the MD should eleminate the failure hard
>> >> drive of the logical drive it build, and the server continue to work
>> >> fine like nothing happen. Oddly the server stop to respond and i get
>> >> this messages :
>> >> ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
>> >> ata4.00: cmd e7/00:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x0 data 0
>> >>              res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 
>> (timeout)
>> >> ata4: port is slow to respond, please be patient (Status 0xd0)
>> >> ata4: port failed to respond (30sec, Status 0xd0)
>> >> ata4: soft resetting port
>> >>
>> >> After that my system is frozen.
>>
>> How hard is it frozen?  Can you blink the Numlock LED?

I believe he said it was ICH5 (different post/thread).

My observation on ICH5 is that if one unplugs a drive,
then the chipset/cpu locks up hard when toggling SRST
in the EH code.

Specifically, it locks up at the instruction
which restores SRST back to the non-asserted state,
which likely corresponds to the chipset finally actually
sending a FIS to the drive.

A hard(ware) lockup, not software.
That's why Intel says ICH5 doesn't do hotplug.

Cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-07-03 23:08       ` Mark Lord
@ 2007-07-04  1:20         ` Tejun Heo
  2007-07-04  9:14           ` Alan Cox
  2007-07-04 18:56           ` Mark Lord
  0 siblings, 2 replies; 10+ messages in thread
From: Tejun Heo @ 2007-07-04  1:20 UTC (permalink / raw)
  To: Mark Lord; +Cc: Johny Mail list, Brad Campbell, linux-raid, linux-ide

Mark Lord wrote:
> I believe he said it was ICH5 (different post/thread).
> 
> My observation on ICH5 is that if one unplugs a drive,
> then the chipset/cpu locks up hard when toggling SRST
> in the EH code.
> 
> Specifically, it locks up at the instruction
> which restores SRST back to the non-asserted state,
> which likely corresponds to the chipset finally actually
> sending a FIS to the drive.
> 
> A hard(ware) lockup, not software.
> That's why Intel says ICH5 doesn't do hotplug.

OIC.  I don't think there's much left to do from the driver side then.
Or is there any workaround?

-- 
tejun

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-07-04  1:20         ` Tejun Heo
@ 2007-07-04  9:14           ` Alan Cox
  2007-07-04 18:56           ` Mark Lord
  1 sibling, 0 replies; 10+ messages in thread
From: Alan Cox @ 2007-07-04  9:14 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Mark Lord, Johny Mail list, Brad Campbell, linux-raid, linux-ide

> > A hard(ware) lockup, not software.
> > That's why Intel says ICH5 doesn't do hotplug.
> 
> OIC.  I don't think there's much left to do from the driver side then.
> Or is there any workaround?

I'm not familiar with the ICH5 SATA side but on the PATA side we also
need to run code to fix up chips on a hotplug (and *before* the plug in
some cases) - eg the ICH2 requires we turn off IORDY.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-07-04  1:20         ` Tejun Heo
  2007-07-04  9:14           ` Alan Cox
@ 2007-07-04 18:56           ` Mark Lord
  2007-07-12 16:27             ` Johny Mail list
  1 sibling, 1 reply; 10+ messages in thread
From: Mark Lord @ 2007-07-04 18:56 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Johny Mail list, Brad Campbell, linux-raid, linux-ide

Tejun Heo wrote:
> Mark Lord wrote:
>> I believe he said it was ICH5 (different post/thread).
>>
>> My observation on ICH5 is that if one unplugs a drive,
>> then the chipset/cpu locks up hard when toggling SRST
>> in the EH code.
>>
>> Specifically, it locks up at the instruction
>> which restores SRST back to the non-asserted state,
>> which likely corresponds to the chipset finally actually
>> sending a FIS to the drive.
>>
>> A hard(ware) lockup, not software.
>> That's why Intel says ICH5 doesn't do hotplug.
> 
> OIC.  I don't think there's much left to do from the driver side then.
> Or is there any workaround?

The workaround I have, for 2.6.18.8, is to provide an "offline()" method
for ICH5 that polls for device present before attempting SRST.

I hope to eventually clean this up and submit it for you,
after your existing polling-hp code goes upstream.

Here's my present hack (below).  Feel free to use/ignore.

***

Implement ICH5 chipset handling for drive hot insertion/removal.
This cannot go upstream, as it conflicts with a more generic
polled-hotplug framework that is currently in development.

Hot-inserted drives are automatically detected within a second or two,
and are ready-to-use within 30 seconds or so.

Hot-removed drives are *not* noticed by the kernel until the next
time they are accessed.  If you want this to happen quickly,
then just launch a script like this from /etc/inittab at boot time:

   #!/bin/bash
   ( while ( /bin/true ) ; do /sbin/hdparm -C /dev/sd[a-z] ; sleep 5 ; done ) &>/dev/null &

Signed-off-by: Mark Lord <mlord@pobox.com>
---

diff -u --recursive --new-file --exclude-from=old/Documentation/dontdiff old/drivers/scsi/ata_piix.c linux/drivers/scsi/ata_piix.c
--- old/drivers/scsi/ata_piix.c	2007-04-20 14:08:46.000000000 -0400
+++ linux/drivers/scsi/ata_piix.c	2007-06-26 07:23:21.000000000 -0400
@@ -106,6 +106,8 @@
 	PIIX_FLAG_AHCI		= (1 << 27), /* AHCI possible */
 	PIIX_FLAG_CHECKINTR	= (1 << 28), /* make sure PCI INTx enabled */
 
+	PIIX_HOTPLUG_POLL_TM	= (2 * (HZ)),	/* polling interval for hotplug */
+
 	/* combined mode.  if set, PATA is channel 0.
 	 * if clear, PATA is channel 1.
 	 */
@@ -150,6 +152,171 @@
 	const struct piix_map_db *map_db;
 };
 
+struct piix_port_priv {
+	int pcs_hotplug_supported;
+	struct timer_list hotplug_timer;
+	u16 old_pcs;
+};
+
+static u32 ich_scr_read (struct ata_port *ap, unsigned int reg)
+{
+	u32 scr = 0;
+
+	if (reg == SCR_STATUS) {
+		struct piix_port_priv *pp = ap->private_data;
+		if (pp && pp->pcs_hotplug_supported) {
+			u16 pcs, port_bit = (1 << ap->hard_port_no);
+			struct pci_dev *pdev = to_pci_dev(ap->dev);
+
+			pci_read_config_word(pdev, ICH5_PCS, &pcs);
+			if (pcs & (port_bit << 4))
+				scr = 0x113;
+		}
+	}
+	return scr;
+}
+
+static int ich_port_offline (struct ata_port *ap)
+{
+	struct pci_dev *pdev;
+	u16 pcs, port_bit = (1 << ap->hard_port_no);
+	struct piix_port_priv *pp = ap->private_data;
+	u8 ostatus;
+	unsigned int offline;
+
+	if (!pp || !pp->pcs_hotplug_supported) {
+		u32 sstatus;
+		if (!sata_scr_read(ap, SCR_STATUS, &sstatus) && (sstatus & 0xf) != 0x3)
+			return 1;
+		return 0;
+	}
+
+	/*
+	 * ICH5 with a mostly good/working PCS register.
+	 * The only flaw is, it doesn't seem to detect *removed* drives
+	 * unless we toggle the enable line before checking.
+	 */
+	ostatus = ata_altstatus(ap);
+	pdev = to_pci_dev(ap->dev);
+	pci_read_config_word(pdev, ICH5_PCS, &pcs);
+	offline = ((pcs & (port_bit << 4)) == 0);
+
+	if (!offline) {
+		unsigned int usecs;
+
+		/* Cycle PCS register to force it to redetect devices: */
+		pci_write_config_word(pdev, ICH5_PCS, pcs & ~port_bit);
+		udelay(1);
+		pci_write_config_word(pdev, ICH5_PCS, 0x0003);
+
+		/* Wait for SATA PHY to sync up; typically 5->6 usecs */
+		for (usecs = 0; usecs < 100; ++usecs) {
+			pci_read_config_word(pdev,  ICH5_PCS, &pcs);
+			offline = ((pcs & (port_bit << 4)) == 0);
+			if (!offline)
+				break;
+			udelay(1);
+		}
+		if (!offline) {
+			unsigned int msecs;
+			/* Wait for drive to become not-BUSY, typically 10->62 msecs */
+			for (msecs = 1; msecs < 150; msecs += 3) {
+				u8 status;
+				msleep(3);
+				status = ata_altstatus(ap);
+				if (status && !(status & ATA_BUSY))
+					break;
+			}
+			usecs += msecs * 1000;
+		}
+		printk("ata%u (port %u): status=%02x pcs=0x%04x offline=%u delay=%u usecs\n",
+			ap->id, ap->hard_port_no, ostatus, pcs, offline, usecs);
+	}
+	if (offline)
+		ata_port_disable(ap);
+	return offline;
+}
+
+static void pcs_hotplug_poll (unsigned long data)
+{
+	struct ata_port *ap = (void *)data;
+	struct pci_dev *pdev = to_pci_dev(ap->dev);
+	u16 old, new, port_bit = ((1 << ap->hard_port_no) << 4);
+	struct piix_port_priv *pp = ap->private_data;
+	int check_hotplug = 0;
+	unsigned long flags;
+
+	spin_lock_irqsave(ap->lock, flags);
+
+	if (!ap->qc_active) {
+		pci_read_config_word(pdev, ICH5_PCS, &new);
+		old = pp->old_pcs;
+		pp->old_pcs = new;
+
+		//printk("pcs_hotplug_poll(%d.%d) old=%04x new=%04x\n", ap->id, ap->hard_port_no, old, new);
+
+		if ((new & port_bit) != (old & port_bit)) {
+			check_hotplug = 1;
+		} else if (old & port_bit) {
+			//if (ap->hard_port_no == 1)	//FIXME FIXME FIXME
+			//	check_hotplug = 1;
+		}
+
+		if (check_hotplug) {
+			struct ata_eh_info *ehi = &ap->eh_info;
+
+			ata_port_printk(ap, KERN_INFO, "pcs_hotplug_poll: old=%04x new=%04x\n", old, new);
+			ata_ehi_clear_desc(ehi);
+			ata_ehi_hotplugged(ehi);
+			ata_ehi_push_desc(ehi, "hotplug event");
+			ata_port_freeze(ap);
+		}
+	}
+	if (pp->pcs_hotplug_supported)
+		mod_timer(&pp->hotplug_timer, jiffies + PIIX_HOTPLUG_POLL_TM);
+	spin_unlock_irqrestore(ap->lock, flags);
+}
+
+static int ich_port_start (struct ata_port *ap)
+{
+	struct pci_dev *pdev = to_pci_dev(ap->dev);
+	int rc;
+
+	rc = ata_port_start(ap);
+	if (rc == 0) {
+		if (pdev->vendor == 0x8086 && pdev->device == 0x24d1) {
+			struct piix_port_priv *pp;
+			pp = kzalloc(sizeof(*pp), GFP_KERNEL);
+			if (pp) {
+				pp->pcs_hotplug_supported = 1;
+				if (ap->private_data)
+					printk(KERN_ERR "port_start: huh? private_data=%p instead of NULL\n", ap->private_data);
+				ap->private_data = pp;
+				setup_timer(&pp->hotplug_timer, pcs_hotplug_poll, (unsigned long)ap);
+				pp->hotplug_timer.expires = jiffies + PIIX_HOTPLUG_POLL_TM;
+				add_timer(&pp->hotplug_timer);
+			} else {
+				printk(KERN_ERR "ich_port_start: failed to alloc %d bytes for port_priv\n", sizeof(*pp));
+			}
+		}
+	} else {
+		printk(KERN_ERR "ich_port_start: ata_port_start failed, rc=%d\n", rc);
+	}
+	return rc;
+}
+
+static void ich_port_stop (struct ata_port *ap)
+{
+	struct piix_port_priv *pp = ap->private_data;
+
+	if (pp) {
+		pp->pcs_hotplug_supported = 0;
+		del_timer_sync(&pp->hotplug_timer);
+		ap->private_data = NULL;
+		kfree(pp);
+	}
+}
+
 static int piix_init_one (struct pci_dev *pdev,
 				    const struct pci_device_id *ent);
 static void piix_host_stop(struct ata_host_set *host_set);
@@ -289,8 +456,11 @@
 	.irq_handler		= ata_interrupt,
 	.irq_clear		= ata_bmdma_irq_clear,
 
-	.port_start		= ata_port_start,
-	.port_stop		= ata_port_stop,
+	.scr_read		= ich_scr_read,
+
+	.port_offline		= ich_port_offline,
+	.port_start		= ich_port_start,
+	.port_stop		= ich_port_stop,
 	.host_stop		= piix_host_stop,
 };
 
diff -u --recursive --new-file --exclude-from=old/Documentation/dontdiff old/drivers/scsi/libata-core.c linux/drivers/scsi/libata-core.c
--- old/drivers/scsi/libata-core.c	2007-04-20 14:08:45.000000000 -0400
+++ linux/drivers/scsi/libata-core.c	2007-06-26 07:22:19.000000000 -0400
@@ -4914,7 +4914,7 @@
  */
 int sata_scr_write(struct ata_port *ap, int reg, u32 val)
 {
-	if (sata_scr_valid(ap)) {
+	if (sata_scr_valid(ap) && ap->ops->scr_write) {
 		ap->ops->scr_write(ap, reg, val);
 		return 0;
 	}
@@ -4987,6 +4987,8 @@
 {
 	u32 sstatus;
 
+	if (ap->ops->port_offline)
+		return ap->ops->port_offline(ap);
 	if (!sata_scr_read(ap, SCR_STATUS, &sstatus) && (sstatus & 0xf) != 0x3)
 		return 1;
 	return 0;
diff -u --recursive --new-file --exclude-from=old/Documentation/dontdiff old/include/linux/libata.h linux/include/linux/libata.h
--- old/include/linux/libata.h	2007-06-26 07:22:26.000000000 -0400
+++ linux/include/linux/libata.h	2007-06-26 07:22:19.000000000 -0400
@@ -614,6 +614,7 @@
 
 	int (*port_start) (struct ata_port *ap);
 	void (*port_stop) (struct ata_port *ap);
+	int (*port_offline) (struct ata_port *ap);
 
 	void (*host_stop) (struct ata_host_set *host_set);
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Linux Software RAID is really RAID?
  2007-07-04 18:56           ` Mark Lord
@ 2007-07-12 16:27             ` Johny Mail list
  0 siblings, 0 replies; 10+ messages in thread
From: Johny Mail list @ 2007-07-12 16:27 UTC (permalink / raw)
  To: Mark Lord; +Cc: Tejun Heo, Brad Campbell, linux-raid, linux-ide

2007/7/4, Mark Lord <liml@rtr.ca>:
> Tejun Heo wrote:
> > Mark Lord wrote:
> >> I believe he said it was ICH5 (different post/thread).
> >>
> >> My observation on ICH5 is that if one unplugs a drive,
> >> then the chipset/cpu locks up hard when toggling SRST
> >> in the EH code.
> >>
> >> Specifically, it locks up at the instruction
> >> which restores SRST back to the non-asserted state,
> >> which likely corresponds to the chipset finally actually
> >> sending a FIS to the drive.
> >>
> >> A hard(ware) lockup, not software.
> >> That's why Intel says ICH5 doesn't do hotplug.
> >
> > OIC.  I don't think there's much left to do from the driver side then.
> > Or is there any workaround?
>
> The workaround I have, for 2.6.18.8, is to provide an "offline()" method
> for ICH5 that polls for device present before attempting SRST.
>
> I hope to eventually clean this up and submit it for you,
> after your existing polling-hp code goes upstream.
>
> Here's my present hack (below).  Feel free to use/ignore.
>
> ***
>
> Implement ICH5 chipset handling for drive hot insertion/removal.
> This cannot go upstream, as it conflicts with a more generic
> polled-hotplug framework that is currently in development.
>
> Hot-inserted drives are automatically detected within a second or two,
> and are ready-to-use within 30 seconds or so.
>
> Hot-removed drives are *not* noticed by the kernel until the next
> time they are accessed.  If you want this to happen quickly,
> then just launch a script like this from /etc/inittab at boot time:
>
>    #!/bin/bash
>    ( while ( /bin/true ) ; do /sbin/hdparm -C /dev/sd[a-z] ; sleep 5 ; done ) &>/dev/null &
>
> Signed-off-by: Mark Lord <mlord@pobox.com>
> ---
>

Hello,
Thanks this patch work in my case after unplug-in my hard drive.
But the situation is strange.
The first time it functioned fine and i get this messages :
[  290.452296] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
[  290.452378] ata2.00: tag 0 cmd 0xea Emask 0x4 stat 0x40 err 0x0 (timeout)
[  290.452635] ata2 (port 1): status=d0 pcs=0x0013 offline=1 delay=100 usecs
[  290.452697] ata2: soft resetting port
[  290.452787] ata2: SATA link down (SStatus 0 SControl 0)
[  290.463065] ATA: abnormal status 0x7F on port 0xCCA7
[  290.463154] ata2: EH complete
[  290.463224] sd 1:0:0:0: SCSI error: return code = 0x00040000
[  290.463286] end_request: I/O error, dev sdb, sector 156248058
[  290.463362] raid1: Disk failure on sdb2, disabling device.
[  290.463365]  Operation continuing on 1 devices
[  290.465590] RAID1 conf printout:
[  290.465651]  --- wd:1 rd:2
[  290.465710]  disk 0, wo:0, o:1, dev:sda3
[  290.465767]  disk 1, wo:1, o:0, dev:sdb2
[  290.480225] RAID1 conf printout:
[  290.480281]  --- wd:1 rd:2
[  290.480370]  disk 0, wo:0, o:1, dev:sda3
[  290.619960] ata2: pcs_hotplug_poll: old=0033 new=0013
[  290.620045] ata2: exception Emask 0x10 SAct 0x0 SErr 0x0 action 0x2 frozen
[  290.620114] ata2: (hotplug event)
[  290.620178] ata2: soft resetting port
[  290.620242] ata2: SATA link down (SStatus 0 SControl 0)
[  290.630518] ATA: abnormal status 0x7F on port 0xCCA7
[  290.630588] ata2: EH complete
[  290.630652] ata2.00: detaching (SCSI 1:0:0:0)

But with a second try when i unplug the disk (with the while loop in
background task) the unplug function wad not started, i need to change
the partition table with fdisk to get the disk offline :
[  397.764666] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
[  397.770229] ata2.00: (BMDMA stat 0x21)
[  397.775771] ata2.00: tag 0 cmd 0xc8 Emask 0x4 stat 0x40 err 0x0 (timeout)
[  397.781502] ata2 (port 1): status=d0 pcs=0x0013 offline=1 delay=100 usecs
[  397.787046] ata2: soft resetting port
[  397.792614] ata2: SATA link up <unknown> (SStatus 0 SControl 0)
[  397.808327] ATA: abnormal status 0x7F on port 0xCCA7
[  397.813910] ata2: EH complete
[  397.819501] sd 1:0:0:0: SCSI error: return code = 0x00040000
[  397.825049] end_request: I/O error, dev sdb, sector 32
[  397.830613] Buffer I/O error on device sdb, logical block 4
[  397.836177] Buffer I/O error on device sdb, logical block 5
[  397.841748] Buffer I/O error on device sdb, logical block 6
[  397.847315] Buffer I/O error on device sdb, logical block 7
[  397.852874] Buffer I/O error on device sdb, logical block 8
[  397.858440] Buffer I/O error on device sdb, logical block 9
[  397.864021] Buffer I/O error on device sdb, logical block 10
[  397.869579] Buffer I/O error on device sdb, logical block 11
[  397.875177] sd 1:0:0:0: SCSI error: return code = 0x00040000
[  397.880734] end_request: I/O error, dev sdb, sector 0
[  397.886312] Buffer I/O error on device sdb, logical block 0
[  397.891889] lost page write due to I/O error on sdb
[  398.283654] ata2: pcs_hotplug_poll: old=0033 new=0013
[  398.289250] ata2: exception Emask 0x10 SAct 0x0 SErr 0x0 action 0x2 frozen
[  398.294843] ata2: (hotplug event)
[  398.300433] ata2: soft resetting port
[  398.305997] ata2: SATA link up <unknown> (SStatus 0 SControl 0)
[  398.321732] ATA: abnormal status 0x7F on port 0xCCA7
[  398.327329] ata2: EH complete
[  398.332904] ata2.00: detaching (SCSI 1:0:0:0)

Before i do the change in the partition table my system was normal,
and a fdisk -l /dev/sdb give me the right table (but my disk was
disconnected ...).

Thanks for paying attention of my problem :)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-12 16:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-26 17:43 Linux Software RAID is really RAID? Johny Mail list
2007-06-26 18:34 ` Brad Campbell
2007-06-27 11:54   ` Johny Mail list
2007-07-03  8:15   ` Tejun Heo
2007-07-03 12:17     ` Johny Mail list
2007-07-03 23:08       ` Mark Lord
2007-07-04  1:20         ` Tejun Heo
2007-07-04  9:14           ` Alan Cox
2007-07-04 18:56           ` Mark Lord
2007-07-12 16:27             ` Johny Mail list

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).