2.6.22-rc regression: smartctl does not work with SATA disk

2007-06-10 Thread Kai Makisara
The command 'smartctl -a /dev/sdb' fails with 2.6.22-rc4 kernel. The 
disk /dev/sdb is a SATA disk. The command does work still with a real SCSI 
disk.

The computer has Athlon64 X2 and it is running x86_64 SMP kernel. The 
chipset is Nvidia CK804 and the sata_nv driver is used.

The following output from 'smartctl -a -r ioctl,1 /dev/sdb' tells the disk 
details and shows where the regression is:

-
smartctl version 5.38 [x86_64-suse-linux-gnu] Copyright (C) 2002-7 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

 [inquiry: 12 00 00 00 24 00 ]
  scsi_status=0x0, host_status=0x0, driver_status=0x0
  info=0x0  duration=0 milliseconds  resid=0
  status=0x0
 [ata pass-through(16): 85 08 0e 00 00 00 01 00 00 00 00 00 00 00 ec 00 ]
  scsi_status=0x0, host_status=0x0, driver_status=0x0
  info=0x0  duration=4 milliseconds  resid=0
  status=0x0
Detected SAT interface, switch to device type 'sat'

REPORT-IOCTL: DeviceFD=3 Command=IDENTIFY DEVICE
 [ata pass-through(16): 85 08 0e 00 00 00 01 00 00 00 00 00 00 00 ec 00 ]
  scsi_status=0x0, host_status=0x0, driver_status=0x0
  info=0x0  duration=0 milliseconds  resid=0
  status=0x0
REPORT-IOCTL: DeviceFD=3 Command=IDENTIFY DEVICE returned 0
=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 7200.10 family
Device Model: ST3320620AS
Serial Number:9QF22KAP
Firmware Version: 3.AAJ
User Capacity:320,072,933,376 bytes
Device is:In smartctl database [for details use: -P show]
ATA Version is:   7
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:Sun Jun 10 10:47:30 2007 EEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled


REPORT-IOCTL: DeviceFD=3 Command=SMART STATUS
 [ata pass-through(16): 85 06 2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00 ]
  scsi_status=0x2, host_status=0x0, driver_status=0x8
  info=0x1  duration=44 milliseconds  resid=0
  status=2: [desc] sense_key=0 asc=0 ascq=0
REPORT-IOCTL: DeviceFD=3 Command=SMART STATUS returned 0

REPORT-IOCTL: DeviceFD=3 Command=SMART STATUS CHECK
 [ata pass-through(16): 85 06 2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00 ]
  scsi_status=0x2, host_status=0x0, driver_status=0x8
  info=0x1  duration=44 milliseconds  resid=0
  status=2: [desc] sense_key=0 asc=0 ascq=0
Error SMART Status command failed
Please get assistance from http://smartmontools.sourceforge.net/
Values from ATA status return descriptor are:
 00 09 0c 00 00 00 00 00 00  00 00 00 00 00 50  
REPORT-IOCTL: DeviceFD=3 Command=SMART STATUS CHECK returned -1
A mandatory SMART command failed: exiting. To continue, add one or more '-T 
permissive' options.


This is smartctl from cvs a few days ago but the smartctl shipping with 
SuSE 10.2 fails in the same way.


I ran 'git bisect' and it suggests that the problem was introduced by

1e999736cafdffc374f22eed37b291129ef82e4e is first bad commit
commit 1e999736cafdffc374f22eed37b291129ef82e4e
Author: Alan Cox [EMAIL PROTECTED]
Date:   Wed Apr 11 00:23:13 2007 +0100

libata: HPA support

i.e., before 2.6.22-rc1. At this point I find best to leave the problem to 
experts.

-- 
Kai
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] ide: add short cables support

2007-06-10 Thread Bartlomiej Zolnierkiewicz

This patch allows users to override both host and device side cable detection
with ideX=ata66 kernel parameter.  Thanks to this it should be now possible
to use UDMA  2 modes on systems (laptops mainly) which use short 40-pin cable
instead of 80-pin one.

Next patches add automatic detection of some systems using short cables.

Changes:

* Rename hwif-udma_four to hwif-cbl and make it u8.

* Convert all existing users accordingly (use ATA_CBL_* defines while at it).  

* Add ATA_CBL_PATA40_SHORT support to ide-iops.c:eighty_ninty_three().

* Use ATA_CBL_PATA40_SHORT for ideX=ata66 kernel parameter.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/cris/ide-cris.c|2 +-
 drivers/ide/ide-iops.c |8 ++--
 drivers/ide/ide.c  |9 +++--
 drivers/ide/pci/aec62xx.c  |5 +++--
 drivers/ide/pci/alim15x3.c |9 +
 drivers/ide/pci/amd74xx.c  |9 +++--
 drivers/ide/pci/atiixp.c   |5 +++--
 drivers/ide/pci/cmd64x.c   |   10 +-
 drivers/ide/pci/cs5535.c   |6 +++---
 drivers/ide/pci/hpt366.c   |4 ++--
 drivers/ide/pci/it8213.c   |8 
 drivers/ide/pci/it821x.c   |9 +
 drivers/ide/pci/jmicron.c  |   20 +++-
 drivers/ide/pci/pdc202xx_new.c |9 ++---
 drivers/ide/pci/pdc202xx_old.c |9 ++---
 drivers/ide/pci/piix.c |8 
 drivers/ide/pci/scc_pata.c |2 +-
 drivers/ide/pci/serverworks.c  |   26 +-
 drivers/ide/pci/siimage.c  |   18 ++
 drivers/ide/pci/sis5513.c  |9 +
 drivers/ide/pci/slc90e66.c |5 ++---
 drivers/ide/pci/tc86c001.c |4 ++--
 drivers/ide/pci/via82cxxx.c|9 +++--
 drivers/ide/ppc/pmac.c |6 +++---
 include/linux/ide.h|3 ++-
 25 files changed, 123 insertions(+), 89 deletions(-)

Index: b/drivers/ide/cris/ide-cris.c
===
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -819,7 +819,7 @@ init_e100_ide (void)
hwif-dma_host_off = cris_dma_off;
hwif-dma_host_on = cris_dma_on;
hwif-dma_off_quietly = cris_dma_off;
-   hwif-udma_four = 0;
+   hwif-cbl = ATA_CBL_PATA40;
hwif-ultra_mask = cris_ultra_mask;
hwif-mwdma_mask = 0x07; /* Multiword DMA 0-2 */
hwif-autodma = 1;
Index: b/drivers/ide/ide-iops.c
===
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -574,7 +574,10 @@ u8 eighty_ninty_three (ide_drive_t *driv
ide_hwif_t *hwif = drive-hwif;
struct hd_driveid *id = drive-id;
 
-   if (hwif-udma_four == 0)
+   if (hwif-cbl == ATA_CBL_PATA40_SHORT)
+   return 1;
+
+   if (hwif-cbl != ATA_CBL_PATA80)
goto no_80w;
 
/* Check for SATA but only if we are ATA5 or higher */
@@ -600,7 +603,8 @@ no_80w:
 
printk(KERN_WARNING %s: %s side 80-wire cable detection failed, 
limiting max speed to UDMA33\n,
-   drive-name, hwif-udma_four ? drive : host);
+   drive-name,
+   hwif-cbl == ATA_CBL_PATA80 ? drive : host);
 
drive-udma33_warned = 1;
 
Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -460,6 +460,8 @@ static void ide_hwif_restore(ide_hwif_t 
hwif-mwdma_mask= tmp_hwif-mwdma_mask;
hwif-swdma_mask= tmp_hwif-swdma_mask;
 
+   hwif-cbl   = tmp_hwif-cbl;
+
hwif-chipset   = tmp_hwif-chipset;
hwif-hold  = tmp_hwif-hold;
 
@@ -533,7 +535,6 @@ static void ide_hwif_restore(ide_hwif_t 
hwif-extra_base= tmp_hwif-extra_base;
hwif-extra_ports   = tmp_hwif-extra_ports;
hwif-autodma   = tmp_hwif-autodma;
-   hwif-udma_four = tmp_hwif-udma_four;
 
hwif-hwif_data = tmp_hwif-hwif_data;
 }
@@ -1545,7 +1546,11 @@ static int __init ide_setup(char *s)
goto bad_option;
case -7: /* ata66 */
 #ifdef CONFIG_BLK_DEV_IDEPCI
-   hwif-udma_four = 1;
+   /*
+* Use ATA_CBL_PATA40_SHORT so drive side
+* cable detection is also overriden.
+*/
+   hwif-cbl = ATA_CBL_PATA40_SHORT;
goto obsolete_option;
 #else
goto bad_hwif;
Index: b/drivers/ide/pci/aec62xx.c

[PATCH 3/5] alim15x3: backport short cables support from pata_ali.c

2007-06-10 Thread Bartlomiej Zolnierkiewicz

Backport short cables support from pata_ali.c and while at it cleanup
existing cable detection code.

This patch should allow UDMA  2 modes on HP Pavilion N5430 and Fujitsu P2000.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/pci/alim15x3.c |   73 ++---
 1 file changed, 49 insertions(+), 24 deletions(-)

Index: b/drivers/ide/pci/alim15x3.c
===
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/alim15x3.cVersion 0.212007/02/03
+ * linux/drivers/ide/pci/alim15x3.cVersion 0.25Jun 9 2007
  *
  *  Copyright (C) 1998-2000 Michel Aubry, Maintainer
  *  Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer
@@ -10,6 +10,7 @@
  *  Copyright (C) 2002 Alan Cox [EMAIL PROTECTED]
  *  ALi (now ULi M5228) support by Clear Zhang [EMAIL PROTECTED]
  *  Copyright (C) 2007 MontaVista Software, Inc. [EMAIL PROTECTED]
+ *  Copyright (C) 2007 Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
  *
  *  (U)DMA capable version of ali 1533/1543(C), 1535(D)
  *
@@ -36,6 +37,7 @@
 #include linux/hdreg.h
 #include linux/ide.h
 #include linux/init.h
+#include linux/dmi.h
 
 #include asm/io.h
 
@@ -583,6 +585,35 @@ out:
return 0;
 }
 
+/*
+ * Cable special cases
+ */
+
+static struct dmi_system_id cable_dmi_table[] = {
+   {
+   .ident = HP Pavilion N5430,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Hewlett-Packard),
+   DMI_MATCH(DMI_BOARD_NAME, OmniBook N32N-736),
+   },
+   },
+   { }
+};
+
+static int ali_cable_override(struct pci_dev *pdev)
+{
+   /* Fujitsu P2000 */
+   if (pdev-subsystem_vendor == 0x10CF 
+   pdev-subsystem_device == 0x10AF)
+   return 1;
+
+   /* Systems by DMI */
+   if (dmi_check_system(cable_dmi_table))
+   return 1;
+
+   return 0;
+}
+
 /**
  * ata66_ali15x3   -   check for UDMA 66 support
  * @hwif: IDE interface
@@ -597,34 +628,28 @@ out:
 static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
 {
struct pci_dev *dev = hwif-pci_dev;
-   unsigned int ata66  = 0;
-   u8 cable_80_pin[2]  = { 0, 0 };
-
unsigned long flags;
-   u8 tmpbyte;
+   u8 cbl = ATA_CBL_PATA40, tmpbyte;
 
local_irq_save(flags);
 
if (m5229_revision = 0xC2) {
/*
-* Ultra66 cable detection (from Host View)
-* m5229, 0x4a, bit0: primary, bit1: secondary 80 pin
-*/
-   pci_read_config_byte(dev, 0x4a, tmpbyte);
-   /*
-* 0x4a, bit0 is 0 = primary channel
-* has 80-pin (from host view)
-*/
-   if (!(tmpbyte  0x01)) cable_80_pin[0] = 1;
-   /*
-* 0x4a, bit1 is 0 = secondary channel
-* has 80-pin (from host view)
-*/
-   if (!(tmpbyte  0x02)) cable_80_pin[1] = 1;
-   /*
-* Allow ata66 if cable of current channel has 80 pins
-*/
-   ata66 = (hwif-channel)?cable_80_pin[1]:cable_80_pin[0];
+* m5229 80-pin cable detection (from Host View)
+*
+* 0x4a bit0 is 0 = primary channel has 80-pin
+* 0x4a bit1 is 0 = secondary channel has 80-pin
+*
+* Certain laptops use short but suitable cables
+* and don't implement the detect logic.
+*/
+   if (ali_cable_override(dev))
+   cbl = ATA_CBL_PATA40_SHORT;
+   else {
+   pci_read_config_byte(dev, 0x4a, tmpbyte);
+   if ((tmpbyte  (1  hwif-channel)) == 0)
+   cbl = ATA_CBL_PATA80;
+   }
} else {
/*
 * check m1533, 0x5e, bit 1~4 == 1001 =  0000 = 00010010
@@ -657,7 +682,7 @@ static u8 __devinit ata66_ali15x3(ide_hw
 
local_irq_restore(flags);
 
-   return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
+   return cbl;
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] sis5513: backport short cables support from pata_sis.c

2007-06-10 Thread Bartlomiej Zolnierkiewicz

Backport short cables support from pata_sis.c.

This patch should allow UDMA  2 modes on ASUS A6K.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/pci/sis5513.c |   25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

Index: b/drivers/ide/pci/sis5513.c
===
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/sis5513.c Version 0.20Mar 4, 2007
+ * linux/drivers/ide/pci/sis5513.c Version 0.25Jun 10, 2007
  *
  * Copyright (C) 1999-2000 Andre Hedrick [EMAIL PROTECTED]
  * Copyright (C) 2002  Lionel Bouton [EMAIL PROTECTED], Maintainer
@@ -796,10 +796,33 @@ static unsigned int __devinit init_chips
return 0;
 }
 
+struct sis_laptop {
+   u16 device;
+   u16 subvendor;
+   u16 subdevice;
+};
+
+static const struct sis_laptop sis_laptop[] = {
+   /* devid, subvendor, subdev */
+   { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */
+   /* end marker */
+   { 0, }
+};
+
 static u8 __devinit ata66_sis5513(ide_hwif_t *hwif)
 {
+   struct pci_dev *pdev = hwif-pci_dev;
+   const struct sis_laptop *lap = sis_laptop[0];
u8 ata66 = 0;
 
+   while (lap-device) {
+   if (lap-device == pdev-device 
+   lap-subvendor == pdev-subsystem_vendor 
+   lap-subdevice == pdev-subsystem_device)
+   return ATA_CBL_PATA40_SHORT;
+   lap++;
+   }
+
if (chipset_family = ATA_133) {
u16 regw = 0;
u16 reg_addr = hwif-channel ? 0x52: 0x50;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] via82cxxx: backport short cables support from pata_via.c

2007-06-10 Thread Bartlomiej Zolnierkiewicz

Backport short cables support from pata_via.c.

This patch should allow UDMA  2 modes on Acer Ferrari 3400.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/pci/via82cxxx.c |   48 +---
 1 file changed, 41 insertions(+), 7 deletions(-)

Index: b/drivers/ide/pci/via82cxxx.c
===
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -1,6 +1,6 @@
 /*
  *
- * Version 3.40
+ * Version 3.45
  *
  * VIA IDE driver for Linux. Supported southbridges:
  *
@@ -34,6 +34,8 @@
 #include linux/pci.h
 #include linux/init.h
 #include linux/ide.h
+#include linux/dmi.h
+
 #include asm/io.h
 
 #ifdef CONFIG_PPC_CHRP
@@ -415,6 +417,42 @@ static unsigned int __devinit init_chips
return 0;
 }
 
+/*
+ * Cable special cases
+ */
+
+static struct dmi_system_id cable_dmi_table[] = {
+   {
+   .ident = Acer Ferrari 3400,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Acer,Inc.),
+   DMI_MATCH(DMI_BOARD_NAME, Ferrari 3400),
+   },
+   },
+   { }
+};
+
+static int via_cable_override(void)
+{
+   /* Systems by DMI */
+   if (dmi_check_system(cable_dmi_table))
+   return 1;
+   return 0;
+}
+
+static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif)
+{
+   struct via82cxxx_dev *vdev = pci_get_drvdata(hwif-pci_dev);
+
+   if (via_cable_override())
+   return ATA_CBL_PATA40_SHORT;
+
+   if ((vdev-via_80w  hwif-channel)  1)
+   return ATA_CBL_PATA80;
+   else
+   return ATA_CBL_PATA40;
+}
+
 static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
 {
struct via82cxxx_dev *vdev = pci_get_drvdata(hwif-pci_dev);
@@ -448,12 +486,8 @@ static void __devinit init_hwif_via82cxx
hwif-mwdma_mask = 0x07;
hwif-swdma_mask = 0x07;
 
-   if (hwif-cbl != ATA_CBL_PATA40_SHORT) {
-   if ((vdev-via_80w  hwif-channel)  1)
-   hwif-cbl = ATA_CBL_PATA80;
-   else
-   hwif-cbl = ATA_CBL_PATA40;
-   }
+   if (hwif-cbl != ATA_CBL_PATA40_SHORT)
+   hwif-cbl = via82cxxx_cable_detect(hwif);
 
hwif-ide_dma_check = via82cxxx_ide_dma_check;
if (!noautodma)
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH libata-dev#upstream-fixes] libata: force PIO on IOMEGA ZIP 250 ATAPI

2007-06-10 Thread Alan Cox
On Sun, 10 Jun 2007 14:52:36 +0900
Tejun Heo [EMAIL PROTECTED] wrote:

 IOMEGA ZIP 250 ATAPI claims MWDMA0 support but fails SETXFERMODE if
 asked to configure itself to MWDMA0.  Force PIO.

This is only really a temporary fix. It appears to manage MWDMA0 in some
cases with old IDE..
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_it821x: sync with IDE it821x driver

2007-06-10 Thread Alan Cox
 Hmmm... indeed.  Alan, is there any reason we do that in -set_piomode
 not -mode_filter?  We end up with mismatching configuration between the
 controller and the higher speed drive.

We always talk more slowly than the drive which is just fine. Just about
every device on every controller does some variant of this, usually just
for the address setup timings. Our current behaviour (both old and new
IDE) may actually not be conservative enough for register rather than
data timings, which quite possibly should always be at the lower speed.

Currently the PATA drivers use mode_filter to remove modes not allowed
due to hardware issues/flaws/etc and a mix of their own timer merging and
the intelligence in the ata_timing functions to work out what timing
pattern should be used.

Beyond looking further into the register load timings and maybe making
the 8bit timings more conseratively merged (as Sergei I think feels they
should be) I don't plan to change this.

Alan

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_it821x: sync with IDE it821x driver

2007-06-10 Thread Alan Cox
 @@ -258,8 +259,14 @@ static void it821x_passthru_set_piomode(
   static const u8 pio_want[]= { ATA_66, ATA_66, ATA_66, ATA_66, 
 ATA_ANY };
  
   struct it821x_dev *itdev = ap-private_data;
 + struct ata_device *pair = ata_dev_pair(adev);
   int unit = adev-devno;
 - int mode_wanted = adev-pio_mode - XFER_PIO_0;
 + int mode_wanted = adev-pio_mode;
 +
 + if (pair  adev-pio_mode  pair-pio_mode)
 + mode_wanted = pair-pio_mode;
 +
 + mode_wanted -= XFER_PIO_0;

NAK this too

Please see it821x_program.

it821x_passthru_set_piomode computes the required mode and the preferred
clock for the mode
it821x_clock_strategy the computes the best clock to use
it821x_program the programs the device

Whenever we issue a command it821x_passthru_dev_select then does a timing
mode switch and loads the PIO timing before doing the dev_select. The
same is also done when doing a qc_issue_prot so each qc_issue will have
the right timings loaded for the device.

So if you've got a problem case your diagnosis isn't one that makes a lot
of sense, and the fix is clearly wrong but I've not seen most of the
discussion between you and whoever you worked with to judge why.

One obvious possibility is that we are not currently doing timing
clipping for the address setup and merge for the 8bit timings. However
the docs I have strongly imply that the IT821x PIO/MWDMA timing register
is for data cycles only.

The other would be that there is some kind of pattern of interaction
between the ATA midlayer and the driver causing the wrong timings to get
loaded at some point.

Your fix would happen to work for both of these cases, but is wrong for
both of them.

If the register is switching all the timings then the fix is to switch
the PIO timing loaded to the lowest of the two initially (in _program)
and flip it back to the correct value at the start of the data transfer
sequence. We can then flip it back next qc_issue or indeed at the end of
the data xfer

If we've got an interaction problem then we need proper traces with
LIBATA debug turned right up so we can fix the actual case where the
switching occurs wrongly.

Alan
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] libata: limit post SRST nsect/lbal wait to ~100ms

2007-06-10 Thread Jeff Garzik

Tejun Heo wrote:

After SRST, libata used to wait for nsect/lbal to be set to 1/1 for
the slave device.  However, some ATAPI devices don't set nsect/lbal
after SRST and the wait itself isn't too useful as we're gonna wait
for !BSY right after that anyway.

Before reset-seq update, nsect/lbal wait failure used to be ignored
and caused 30sec delay during detection.  After reset-seq, all
timeouts are considered error conditions making libata fail to detect
such ATAPI devices.

This patch limits nsect/lbal wait to around 100ms.  This should give
acceptable behavior to such ATAPI devices while not disturbing the
heavily used code path too much.

Signed-off-by: Tejun Heo [EMAIL PROTECTED]
---
Okay, here it is.  Sorry for the delay.

 drivers/ata/libata-core.c |   32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)


Thanks.  Maybe Gregor can confirm this fixes his problem?

I'll ACK and push upstream then...


-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_it821x: sync with IDE it821x driver

2007-06-10 Thread Bartlomiej Zolnierkiewicz

Hi Alan!

On Sunday 10 June 2007, Alan Cox wrote:
  @@ -258,8 +259,14 @@ static void it821x_passthru_set_piomode(
  static const u8 pio_want[]= { ATA_66, ATA_66, ATA_66, ATA_66, 
  ATA_ANY };
   
  struct it821x_dev *itdev = ap-private_data;
  +   struct ata_device *pair = ata_dev_pair(adev);
  int unit = adev-devno;
  -   int mode_wanted = adev-pio_mode - XFER_PIO_0;
  +   int mode_wanted = adev-pio_mode;
  +
  +   if (pair  adev-pio_mode  pair-pio_mode)
  +   mode_wanted = pair-pio_mode;
  +
  +   mode_wanted -= XFER_PIO_0;
 
 NAK this too

OK, I'm able to understand the meaning of NAK [1] but this too?

[1] http://ozlabs.org/~rusty/index.cgi/2007/05/04

;)

 Please see it821x_program.
 
 it821x_passthru_set_piomode computes the required mode and the preferred
 clock for the mode
 it821x_clock_strategy the computes the best clock to use
 it821x_program the programs the device
 
 Whenever we issue a command it821x_passthru_dev_select then does a timing
 mode switch and loads the PIO timing before doing the dev_select. The
 same is also done when doing a qc_issue_prot so each qc_issue will have
 the right timings loaded for the device.
 
 So if you've got a problem case your diagnosis isn't one that makes a lot
 of sense, and the fix is clearly wrong but I've not seen most of the
 discussion between you and whoever you worked with to judge why.
 
 One obvious possibility is that we are not currently doing timing
 clipping for the address setup and merge for the 8bit timings. However
 the docs I have strongly imply that the IT821x PIO/MWDMA timing register
 is for data cycles only.
 
 The other would be that there is some kind of pattern of interaction
 between the ATA midlayer and the driver causing the wrong timings to get
 loaded at some point.
 
 Your fix would happen to work for both of these cases, but is wrong for
 both of them.
 
 If the register is switching all the timings then the fix is to switch
 the PIO timing loaded to the lowest of the two initially (in _program)
 and flip it back to the correct value at the start of the data transfer
 sequence. We can then flip it back next qc_issue or indeed at the end of
 the data xfer
 
 If we've got an interaction problem then we need proper traces with
 LIBATA debug turned right up so we can fix the actual case where the
 switching occurs wrongly.

PIO fix was directly ported from my it821x.c patch.  I now see that thanks
to it821x_passthru_dev_select() it is not really needeed in pata_it821x.c.

OTOH DMA fixes are pata_it821x.c unique, I will respin the patch.

Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pata_it821x: (partially) fix DMA in RAID mode

2007-06-10 Thread Bartlomiej Zolnierkiewicz

Code intended to check DMA status was checking DMA command register.

Moreover firmware seems to forget to set DMA capable bit for the
slave device (at least in RAID mode but without ITE RAID volumes) so
check device ID for DMA capable bit when deciding whether to use DMA
and remove DMA status check completely.

Thanks to Pavol Šimo for the bugreport and testing the initial fix.

This change unfortunately still doesn't fix DMA in RAID mode (which
works fine with IDE it821x) but Alan is working on the missing pieces
(pata_it821x vs libata EH issues).

Cc: Alan Cox [EMAIL PROTECTED]
Cc: Tejun Heo [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---

 drivers/ata/pata_it821x.c |   11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

Index: b/drivers/ata/pata_it821x.c
===
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -2,6 +2,7 @@
  * pata_it821x.c   - IT821x PATA for new ATA layer
  *   (C) 2005 Red Hat Inc
  *   Alan Cox [EMAIL PROTECTED]
+ *   (C) 2007 Bartlomiej Zolnierkiewicz
  *
  * based upon
  *
@@ -79,7 +80,7 @@
 
 
 #define DRV_NAME pata_it821x
-#define DRV_VERSION 0.3.6
+#define DRV_VERSION 0.3.7
 
 struct it821x_dev
 {
@@ -460,14 +461,8 @@ static unsigned int it821x_passthru_qc_i
 
 static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device 
**unused)
 {
-   int dma_enabled = 0;
int i;
 
-   /* Bits 5 and 6 indicate if DMA is active on master/slave */
-   /* It is possible that BMDMA isn't allocated */
-   if (ap-ioaddr.bmdma_addr)
-   dma_enabled = ioread8(ap-ioaddr.bmdma_addr + ATA_DMA_CMD);
-
for (i = 0; i  ATA_MAX_DEVICES; i++) {
struct ata_device *dev = ap-device[i];
if (ata_dev_enabled(dev)) {
@@ -476,7 +471,7 @@ static int it821x_smart_set_mode(struct 
dev-dma_mode = XFER_MW_DMA_0;
/* We do need the right mode information for DMA or PIO
   and this comes from the current configuration flags 
*/
-   if (dma_enabled  (1  (5 + i))) {
+   if (ata_id_has_dma(dev-id)) {
ata_dev_printk(dev, KERN_INFO, configured for 
DMA\n);
dev-xfer_mode = XFER_MW_DMA_0;
dev-xfer_shift = ATA_SHIFT_MWDMA;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH libata-dev#upstream-fixes] libata: force PIO on IOMEGA ZIP 250 ATAPI

2007-06-10 Thread Bartlomiej Zolnierkiewicz
On Sunday 10 June 2007, Alan Cox wrote:
 On Sun, 10 Jun 2007 14:52:36 +0900
 Tejun Heo [EMAIL PROTECTED] wrote:
 
  IOMEGA ZIP 250 ATAPI claims MWDMA0 support but fails SETXFERMODE if
  asked to configure itself to MWDMA0.  Force PIO.
 
 This is only really a temporary fix. It appears to manage MWDMA0 in some
 cases with old IDE..

Tejun, please add the comment that this is a libata issue so nobody ever
tries to sync this blacklist entry with ide-dma.c.

Thanks,
Bart
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_it821x: sync with IDE it821x driver

2007-06-10 Thread Alan Cox
  NAK this too
 
 OK, I'm able to understand the meaning of NAK [1] but this too?

That was me being confusing with something else I NAKked that wasn't
from you. It may have made sense to Jeff but not you - sorry

 PIO fix was directly ported from my it821x.c patch.  I now see that thanks
 to it821x_passthru_dev_select() it is not really needeed in pata_it821x.c.

I don't think its needed but if we see problems with some drive mixes its
worth further debug. One nice thing about libata is the qc interfaces
make it possibly to do clock switches very cleanly.

Alan
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: libata and legacy ide pcmcia failure

2007-06-10 Thread Mark Lord

Robert de Rooy wrote:

Mark Lord wrote:

Oh crap.  I did test it a couple of months ago, but my boot/root drive
is libata not IDE -- so no panic on boot with it.  After booting, it 
worked

just fine talking to PC-CARD CF devices using the polling.


Ok, no problem. I recompiled the kernel with libata (but without the 
libata pcmcia support), and made legacy ide (only ide-core and ide-cs) 
modular.
This allowed me to boot my PATA HDD with libata, and when I plugged in 
the PCMCIA card it picked it up automatically with the legacy ide drivers.


Good stuff!


Jun 10 02:40:06 localhost kernel: pccard: PCMCIA card inserted into slot 0
Jun 10 02:40:07 localhost kernel: cs: memory probe 
0xe800-0xefff: excluding 0xe800-0xefff
Jun 10 02:40:07 localhost kernel: cs: memory probe 
0xc020-0xcfff: excluding 0xc020-0xc11f 
0xc1a0-0xc21f 0xc2a0-0xc31f 0xc3a0-0xcc1f 
0xcca0-0xcd1f 0xcda0-0xce1f 0xcea0-0xcf1f 
0xcfa0-0xd01f

Jun 10 02:40:07 localhost kernel: pcmcia: registering new device pcmcia0.0
Jun 10 02:40:07 localhost kernel: Uniform Multi-Platform E-IDE driver 
Revision: 7.00alpha2
Jun 10 02:40:07 localhost kernel: ide: Assuming 33MHz system bus speed 
for PIO modes; override with idebus=xx

Jun 10 02:40:07 localhost kernel: hda: Memory Card Adapter, CFA DISK drive
Jun 10 02:40:08 localhost kernel: ide0 at 0x4100-0x4107,0x410e on irq 3
Jun 10 02:40:08 localhost kernel: ide-cs: hda: Vpp = 0.0
Jun 10 02:40:08 localhost udevd-event[2630]: udev_rules_apply_format: 
unknown format variable '$modalias'


At this point I noticed no /dev/hda* devices existed, so I created them 
manually with mknod. But regardless I was not able to actually mount a 
filesystem, getting an error from mount that the device did not exist.


Yeah, I don't see any parition table messages there,
so it must've hung on the I/O somehow.
Bummer, but it was worth trying, I suppose.


When pulling the card I also got the following..


..
Jun 10 02:41:53 localhost kernel: [ INFO: soft-safe - soft-unsafe lock 
order detected ]

..
That's probably some weird interaction with the simple polling patch,
so I think we can disregard it, unless it pops up again someday on
an unpatched kernel.

Well, at this point, I think the only way to make progress is for one of
the IDE/libata gurus to actually get hold of the same card you have,
meaning Alan Cox (best choice), or myself, or Bart.  Or maybe Tejun.

Without that, this isn't likely to improve much.  


Cheers
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/6] libata: update protocol numbers

2007-06-10 Thread Mark Lord

Jeff Garzik wrote:

Albert Lee wrote:

Patch 1/6:
 Update the ATA passthru protocol numbers according to the new spec.

Signed-off-by: Albert Lee [EMAIL PROTECTED]


applied 1-4, 6 to #upstream-fixes


What about this one:  [PATCH 5/6] libata: support ATAPI devices  ??

I'm quite happy to let Albert run with that,
as he's busily maintaining the rest of the passthrough stuff.

Cheers

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 2.6.22-rc regression: smartctl does not work with SATA disk

2007-06-10 Thread Mark Lord

Kai Makisara wrote:
The command 'smartctl -a /dev/sdb' fails with 2.6.22-rc4 kernel. The 
disk /dev/sdb is a SATA disk. The command does work still with a real SCSI 
disk.


Last time I checked, one must supply the -d ata parameter to smartctl
for it to work with libata drives.  Has this changed?
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 2.6.22-rc regression: smartctl does not work with SATA disk

2007-06-10 Thread Justin Piszcz



On Sun, 10 Jun 2007, Mark Lord wrote:


Kai Makisara wrote:
The command 'smartctl -a /dev/sdb' fails with 2.6.22-rc4 kernel. The disk 
/dev/sdb is a SATA disk. The command does work still with a real SCSI disk.


Last time I checked, one must supply the -d ata parameter to smartctl
for it to work with libata drives.  Has this changed?
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html



Wow, apparently it has, I just tried it here:

p34:~# smartctl -a /dev/sda | head -n 5
smartctl version 5.37 [x86_64-unknown-linux-gnu] Copyright (C) 2002-6 
Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Model Family: Western Digital Raptor family
.. [snip] ..

p34:~# echo $?
0
p34:~#

Normally you always had to use the -d ata parameter.

Justin.
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_it821x: (partially) fix DMA in RAID mode

2007-06-10 Thread Jeff Garzik

Bartlomiej Zolnierkiewicz wrote:

Code intended to check DMA status was checking DMA command register.

Moreover firmware seems to forget to set DMA capable bit for the
slave device (at least in RAID mode but without ITE RAID volumes) so
check device ID for DMA capable bit when deciding whether to use DMA
and remove DMA status check completely.

Thanks to Pavol Šimo for the bugreport and testing the initial fix.

This change unfortunately still doesn't fix DMA in RAID mode (which
works fine with IDE it821x) but Alan is working on the missing pieces
(pata_it821x vs libata EH issues).

Cc: Alan Cox [EMAIL PROTECTED]
Cc: Tejun Heo [EMAIL PROTECTED]
Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---

 drivers/ata/pata_it821x.c |   11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)


Patch is OK but it's mangled by your mailer:

@@ -79,7 +80,7 @@
=20
=20
 #define DRV_NAME pata_it821x
=2D#define DRV_VERSION 0.3.6
+#define DRV_VERSION 0.3.7
=20
 struct it821x_dev
 {
@@ -460,14 +461,8 @@ static unsigned int it821x_passthru_qc_i
=20

=2D int dma_enabled =3D 0;
int i;
=20

etc.

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[git patches] more libata fixes

2007-06-10 Thread Jeff Garzik

The following is CUMULATIVE to the previous push, but in the same linear
history.  IOW, pulling 'linus-plus-plus' also gets you 'upstream-linus'.
But if you have already pulled 'upstream-linus', you will only receive
these two changesets.

Please pull from branch 'linus-plus-plus' of
master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git 
linus-plus-plus

to receive the following changes:

 drivers/ata/libata-core.c |   33 -
 1 files changed, 20 insertions(+), 13 deletions(-)

Tejun Heo (2):
  libata: force PIO on IOMEGA ZIP 250 ATAPI
  libata: limit post SRST nsect/lbal wait to ~100ms

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4b3c45e..047eabd 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3061,22 +3061,28 @@ static int ata_bus_post_reset(struct ata_port *ap, 
unsigned int devmask,
}
}
 
-   /* if device 1 was found in ata_devchk, wait for
-* register access, then wait for BSY to clear
+   /* if device 1 was found in ata_devchk, wait for register
+* access briefly, then wait for BSY to clear.
 */
-   while (dev1) {
-   u8 nsect, lbal;
+   if (dev1) {
+   int i;
 
ap-ops-dev_select(ap, 1);
-   nsect = ioread8(ioaddr-nsect_addr);
-   lbal = ioread8(ioaddr-lbal_addr);
-   if ((nsect == 1)  (lbal == 1))
-   break;
-   if (time_after(jiffies, deadline))
-   return -EBUSY;
-   msleep(50); /* give drive a breather */
-   }
-   if (dev1) {
+
+   /* Wait for register access.  Some ATAPI devices fail
+* to set nsect/lbal after reset, so don't waste too
+* much time on it.  We're gonna wait for !BSY anyway.
+*/
+   for (i = 0; i  2; i++) {
+   u8 nsect, lbal;
+
+   nsect = ioread8(ioaddr-nsect_addr);
+   lbal = ioread8(ioaddr-lbal_addr);
+   if ((nsect == 1)  (lbal == 1))
+   break;
+   msleep(50); /* give drive a breather */
+   }
+
rc = ata_wait_ready(ap, deadline);
if (rc) {
if (rc != -ENODEV)
@@ -3771,6 +3777,7 @@ static const struct ata_blacklist_entry 
ata_device_blacklist [] = {
{ _NEC DV5800A,   NULL,   ATA_HORKAGE_NODMA },
{ SAMSUNG CD-ROM SN-124,N001,   ATA_HORKAGE_NODMA },
{ Seagate STT2A, NULL,ATA_HORKAGE_NODMA },
+   { IOMEGA  ZIP 250   ATAPI, NULL,  ATA_HORKAGE_NODMA }, /* 
temporary fix */
 
/* Weird ATAPI devices */
{ TORiSAN DVD-ROM DRD-N216, NULL, ATA_HORKAGE_MAX_SEC_128 |
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] libata: limit post SRST nsect/lbal wait to ~100ms

2007-06-10 Thread Jeff Garzik

Tejun Heo wrote:

After SRST, libata used to wait for nsect/lbal to be set to 1/1 for
the slave device.  However, some ATAPI devices don't set nsect/lbal
after SRST and the wait itself isn't too useful as we're gonna wait
for !BSY right after that anyway.

Before reset-seq update, nsect/lbal wait failure used to be ignored
and caused 30sec delay during detection.  After reset-seq, all
timeouts are considered error conditions making libata fail to detect
such ATAPI devices.

This patch limits nsect/lbal wait to around 100ms.  This should give
acceptable behavior to such ATAPI devices while not disturbing the
heavily used code path too much.

Signed-off-by: Tejun Heo [EMAIL PROTECTED]
---
Okay, here it is.  Sorry for the delay.


applied


-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH libata-dev#upstream-fixes] libata: force PIO on IOMEGA ZIP 250 ATAPI

2007-06-10 Thread Jeff Garzik

Tejun Heo wrote:

IOMEGA ZIP 250 ATAPI claims MWDMA0 support but fails SETXFERMODE if
asked to configure itself to MWDMA0.  Force PIO.

This fixes bugzilla bug#8497.

Signed-off-by: Tejun Heo [EMAIL PROTECTED]
Cc: Calvin Walton [EMAIL PROTECTED]
---
There was another proposed patch which lowers transfer mode if device
rejects transfer mode but I'm not sure whether that's the right thing
to do.  Such behavior change might affect other devices, so I'm opting
for blacklisting for now.

Thanks.

 drivers/ata/libata-core.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4733f00..6312a21 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3769,6 +3769,7 @@ static const struct ata_blacklist_entry 
ata_device_blacklist [] = {
{ _NEC DV5800A, NULL,   ATA_HORKAGE_NODMA },
{ SAMSUNG CD-ROM SN-124,N001,   ATA_HORKAGE_NODMA },
{ Seagate STT2A, NULL,  ATA_HORKAGE_NODMA },
+   { IOMEGA  ZIP 250   ATAPI, NULL,ATA_HORKAGE_NODMA }, /* 
temporary fix */


applied, after adding the temporary fix comment based on Alan's comments


-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH libata-dev#upstream-fixes] libata: force PIO on IOMEGA ZIP 250 ATAPI

2007-06-10 Thread Tejun Heo
Jeff Garzik wrote:
 Tejun Heo wrote:
 @@ -3769,6 +3769,7 @@ static const struct ata_blacklist_entry
 ata_device_blacklist [] = {
  { _NEC DV5800A, NULL,ATA_HORKAGE_NODMA },
  { SAMSUNG CD-ROM SN-124,N001,ATA_HORKAGE_NODMA },
  { Seagate STT2A, NULL,ATA_HORKAGE_NODMA },
 +{ IOMEGA  ZIP 250   ATAPI, NULL,ATA_HORKAGE_NODMA }, /*
 temporary fix */
 
 applied, after adding the temporary fix comment based on Alan's comments

Thanks.

-- 
tejun
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html