Re: 2.6.21-mm1: many processes end up in D state

2007-05-05 Thread Tejun Heo
Mikael Pettersson wrote:
>> I.e. no freezing of ports...
> 
> Your patch to delete the 'return 1;' on error is correct,
> and makes the code match exactly the behaviour of previous
> versions of sata_promise, except for the additional error
> decoding.
> 
> ahci and sata_sil24 do the return in this situation. I don't
> yet understand why they can get away with it while sata_promise
> cannot, but for now the return should be removed.

That's because sata_sil24 and ahci call either ata_port_abort() or
ata_port_freeze() prior to finishing error_intr routine.  Both functions
abort all in-flight command and schedule EH.

--
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


Re: Data corruption with sata_sil (Sil 3112)

2007-05-05 Thread Tejun Heo
Hello, Simon, Jim.

Jim Paris wrote:
>> I've been having problems with Sil 3112 cards I purchased for additional
>> SATA ports resulting in read data corruption, about 3-5 instances over
>> 2 GB of data, 100% reproducible.
> ..
>> I just rebuilt the entire box with the remains of another (went from
>> A7V8X (VIA) to A7N8X (NVidia), new CPU, new RAM, new power supply),
>> thinking the problem was related to the motherboard.  The issue followed
>> to the new box.
> 
> Have you tried different disks?  I recently spent a long time trying
> to track down the same sort of problem and it ended up being a bad
> HD (not a media failure, so SMART didn't report it).

Hmm... that's interesting.

>> This new motherboard has an onboard Sil 3112 as well.  The old onboard
>> was VIA SATA, which did not corrupt anything.  The Sil 3112 onboard now
>> does too.
> 
> Maybe the VIA controller was only 1.5 Gbps and your 3112 controllers
> are running at 3.0 Gbps?  Some drives have a jumper that lets you
> limit their operation to 1.5, which you could try.

3112 doesn't to 3.0 Gbps and SATA auto-negotiates transfer speed when
PHY goes online.  The jumper helps detection on some dump controllers
but shouldn't cause data corruption.

>> Scipt used to md5sum to find corruption:
>>
>>  find $* -type f -print0 | sort -z | xargs -0 md5sum
> 
> Can you figure out the nature of the corruption?  Flipped bit, entire
> blocks corrupted, etc?  Maybe make two big identical files and use
> "cmp -l" to see how they read differently.

Yeap, please.

-- 
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


[PATCH 06/11] libata-acpi: implement ata_acpi_associate()

2007-05-05 Thread Tejun Heo
* Add acpi_handle to ata_host and ata_port.  Rename
  ata_device->obj_handle to ->acpi_handle and move it above such that
  it doesn't get cleared on reconfiguration.

* Replace ACPI node association which ata_acpi_associate() which is
  called once during host initialization.  Unlike the previous
  implementation, ata_acpi_associate() uses ATA_FLAG_ACPI_SATA to
  choose between IDE or SATA ACPI hierarchy and uses simple child look
  up instead of recursive walk to match the nodes.  This is way safer
  and simpler.  Please read the following message for more info.

  http://article.gmane.org/gmane.linux.ide/17554

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |  369 ++---
 drivers/ata/libata-core.c |3 +
 drivers/ata/libata.h  |2 +
 include/linux/libata.h|   13 +-
 4 files changed, 63 insertions(+), 324 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 0223673..eda4263 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -24,10 +24,8 @@
 #include 
 #include 
 
-#define SATA_ROOT_PORT(x)  (((x) >> 16) & 0x)
-#define SATA_PORT_NUMBER(x)((x) & 0x)  /* or NO_PORT_MULT */
 #define NO_PORT_MULT   0x
-#define SATA_ADR_RSVD  0x
+#define SATA_ADR(root,pmp) (((root) << 16) | (pmp))
 
 #define REGS_PER_GTF   7
 struct taskfile_array {
@@ -42,230 +40,64 @@ static int is_pci_dev(struct device *dev)
return (dev->bus == &pci_bus_type);
 }
 
-/**
- * sata_get_dev_handle - finds acpi_handle and PCI device.function
- * @dev: device to locate
- * @handle: returned acpi_handle for @dev
- * @pcidevfn: return PCI device.func for @dev
- *
- * This function is somewhat SATA-specific.  Or at least the
- * PATA & SATA versions of this function are different,
- * so it's not entirely generic code.
- *
- * Returns 0 on success, <0 on error.
- */
-static int sata_get_dev_handle(struct device *dev, acpi_handle *handle,
-   acpi_integer *pcidevfn)
+static void ata_acpi_associate_sata_port(struct ata_port *ap)
 {
-   struct pci_dev  *pci_dev;
-   acpi_integeraddr;
-
-   if (!is_pci_dev(dev))
-   return -ENODEV;
-
-   pci_dev = to_pci_dev(dev);  /* NOTE: PCI-specific */
-   /* Please refer to the ACPI spec for the syntax of _ADR. */
-   addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
-   *pcidevfn = addr;
-   *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
-   if (!*handle)
-   return -ENODEV;
-   return 0;
+   acpi_integer adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
+
+   ap->device->acpi_handle = acpi_get_child(ap->host->acpi_handle, adr);
 }
 
-/**
- * pata_get_dev_handle - finds acpi_handle and PCI device.function
- * @dev: device to locate
- * @handle: returned acpi_handle for @dev
- * @pcidevfn: return PCI device.func for @dev
- *
- * The PATA and SATA versions of this function are different.
- *
- * Returns 0 on success, <0 on error.
- */
-static int pata_get_dev_handle(struct device *dev, acpi_handle *handle,
-   acpi_integer *pcidevfn)
+static void ata_acpi_associate_ide_port(struct ata_port *ap)
 {
-   unsigned int bus, devnum, func;
-   acpi_integer addr;
-   acpi_handle dev_handle, parent_handle;
-   struct acpi_buffer buffer = {.length = ACPI_ALLOCATE_BUFFER,
-   .pointer = NULL};
-   acpi_status status;
-   struct acpi_device_info *dinfo = NULL;
-   int ret = -ENODEV;
-   struct pci_dev *pdev;
-
-   if (!is_pci_dev(dev))
-   return -ENODEV;
-
-   pdev = to_pci_dev(dev);
-
-   bus = pdev->bus->number;
-   devnum = PCI_SLOT(pdev->devfn);
-   func = PCI_FUNC(pdev->devfn);
-
-   dev_handle = DEVICE_ACPI_HANDLE(dev);
-   parent_handle = DEVICE_ACPI_HANDLE(dev->parent);
-
-   status = acpi_get_object_info(parent_handle, &buffer);
-   if (ACPI_FAILURE(status))
-   goto err;
-
-   dinfo = buffer.pointer;
-   if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
-   dinfo->address == bus) {
-   /* ACPI spec for _ADR for PCI bus: */
-   addr = (acpi_integer)(devnum << 16 | func);
-   *pcidevfn = addr;
-   *handle = dev_handle;
-   } else {
-   goto err;
-   }
+   int max_devices, i;
 
-   if (!*handle)
-   goto err;
-   ret = 0;
-err:
-   kfree(dinfo);
-   return ret;
-}
-
-struct walk_info { /* can be trimmed some */
-   struct device   *dev;
-   struct acpi_device *adev;
-   acpi_handle handle;
-   acpi_integerpcidevfn;
-   unsigned intdrivenum;
-   acpi_handle obj_handle;
-   struct ata_port *ataport;
-   struct ata_device *atadev;
-   u32 sata

[PATCH 03/11] libata-acpi: s/CONFIG_SATA_ACPI/CONFIG_ATA_ACPI/

2007-05-05 Thread Tejun Heo
ACPI applies to both SATA and PATA.  Drop the 'S' from the config
variable.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/Kconfig|   26 +-
 drivers/ata/Makefile   |2 +-
 drivers/ata/libata.h   |2 +-
 include/linux/libata.h |2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 365c306..6ee8f42 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -23,6 +23,19 @@ config ATA_NONSTANDARD
bool
default n
 
+config ATA_ACPI
+   bool
+   depends on ACPI && PCI
+   default y
+   help
+ This option adds support for ATA-related ACPI objects.
+ These ACPI objects add the ability to retrieve taskfiles
+ from the ACPI BIOS and write them to the disk controller.
+ These objects may be related to performance, security,
+ power management, or other areas.
+ You can disable this at kernel boot time by using the
+ option libata.noacpi=1
+
 config SATA_AHCI
tristate "AHCI SATA support"
depends on PCI
@@ -156,19 +169,6 @@ config SATA_INIC162X
help
  This option enables support for Initio 162x Serial ATA.
 
-config SATA_ACPI
-   bool
-   depends on ACPI && PCI
-   default y
-   help
- This option adds support for SATA-related ACPI objects.
- These ACPI objects add the ability to retrieve taskfiles
- from the ACPI BIOS and write them to the disk controller.
- These objects may be related to performance, security,
- power management, or other areas.
- You can disable this at kernel boot time by using the
- option libata.noacpi=1
-
 config PATA_ALI
tristate "ALi PATA support (Experimental)"
depends on PCI && EXPERIMENTAL
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b7055e3..f9e53c1 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -68,4 +68,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o
 obj-$(CONFIG_PATA_LEGACY)  += pata_legacy.o
 
 libata-objs:= libata-core.o libata-scsi.o libata-sff.o libata-eh.o
-libata-$(CONFIG_SATA_ACPI) += libata-acpi.o
+libata-$(CONFIG_ATA_ACPI)  += libata-acpi.o
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index c40665a..122bc16 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -97,7 +97,7 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void 
__user *arg);
 extern struct ata_port *ata_port_alloc(struct ata_host *host);
 
 /* libata-acpi.c */
-#ifdef CONFIG_SATA_ACPI
+#ifdef CONFIG_ATA_ACPI
 extern int ata_acpi_exec_tfs(struct ata_port *ap);
 extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix);
 #else
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 3cffbf6..8a577c2 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -474,7 +474,7 @@ struct ata_device {
struct ata_eringering;
int spdn_cnt;
unsigned inthorkage;/* List of broken features */
-#ifdef CONFIG_SATA_ACPI
+#ifdef CONFIG_ATA_ACPI
/* ACPI objects info */
acpi_handle obj_handle;
 #endif
-- 
1.5.0.3


-
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 07/11] libata-acpi: clean up ata_acpi_exec_tfs()

2007-05-05 Thread Tejun Heo
This patch cleans up ata_acpi_exec_tfs() and its friends.

* Rename taskfile_array to ata_acpi_gtf and make it __packed as it's
  used as argument to ACPI method, and use pointer to ata_acpi_gtf and
  number of taskfiles to represent _GTF taskfiles instead of a pointer
  casted into unsigned long and byte count.  This makes argument
  re-checking in do_drive_set_taskfiles() unnecessary.

* Pointer in void * not in unsigned long.

* Clean up do_drive_get_GTF() error handling and make
  do_drive_get_GTF() return number of taskfiles on success, 0 if _GTF
  doesn't exist or doesn't contain valid ata.  -errno on other errors.

* Remove superflous check for acpi->buffer.pointer.

* Update taskfile_load_raw() such that printed messages look similar
  to the messages printed by ata_eh_report().

* s/do_drive_get_GTF/ata_dev_get_GTF/
  s/do_drive_set_taskfiles/ata_dev_set_taskfiles/

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |  226 ++---
 1 files changed, 111 insertions(+), 115 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index eda4263..4d36d25 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -28,9 +28,9 @@
 #define SATA_ADR(root,pmp) (((root) << 16) | (pmp))
 
 #define REGS_PER_GTF   7
-struct taskfile_array {
-   u8  tfa[REGS_PER_GTF];  /* regs. 0x1f1 - 0x1f7 */
-};
+struct ata_acpi_gtf {
+   u8  tf[REGS_PER_GTF];   /* regs. 0x1f1 - 0x1f7 */
+} __packed;
 
 /*
  * Helper - belongs in the PCI layer somewhere eventually
@@ -101,10 +101,10 @@ void ata_acpi_associate(struct ata_host *host)
 }
 
 /**
- * do_drive_get_GTF - get the drive bootup default taskfile settings
+ * ata_dev_get_GTF - get the drive bootup default taskfile settings
  * @dev: target ATA device
- * @gtf_length: number of bytes of _GTF data returned at @gtf_address
- * @gtf_address: buffer containing _GTF taskfile arrays
+ * @gtf: output parameter for buffer containing _GTF taskfile arrays
+ * @ptr_to_free: pointer which should be freed
  *
  * This applies to both PATA and SATA drives.
  *
@@ -114,24 +114,28 @@ void ata_acpi_associate(struct ata_host *host)
  * The  is not known in advance, so have ACPI-CA
  * allocate the buffer as needed and return it, then free it later.
  *
- * The returned @gtf_length and @gtf_address are only valid if the
- * function return value is 0.
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * Number of taskfiles on success, 0 if _GTF doesn't exist or doesn't
+ * contain valid data.  -errno on other errors.
  */
-static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
-   unsigned long *gtf_address, unsigned long *obj_loc)
+static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf,
+  void **ptr_to_free)
 {
struct ata_port *ap = dev->ap;
acpi_status status;
struct acpi_buffer output;
union acpi_object *out_obj;
-   int err = -ENODEV;
+   int rc = 0;
 
-   *gtf_length = 0;
-   *gtf_address = 0UL;
-   *obj_loc = 0UL;
+   /* set up output buffer */
+   output.length = ACPI_ALLOCATE_BUFFER;
+   output.pointer = NULL;  /* ACPI-CA sets this; save/free it later */
 
if (!dev->acpi_handle)
-   return 0;
+   goto out_free;
 
if (ata_msg_probe(ap))
ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
@@ -143,23 +147,20 @@ static int do_drive_get_GTF(struct ata_device *dev, 
unsigned int *gtf_length,
"ata_dev_present: %d, PORT_DISABLED: %lu\n",
__FUNCTION__, ata_dev_enabled(dev),
ap->flags & ATA_FLAG_DISABLED);
-   goto out;
+   goto out_free;
}
 
-   /* Setting up output buffer */
-   output.length = ACPI_ALLOCATE_BUFFER;
-   output.pointer = NULL;  /* ACPI-CA sets this; save/free it later */
-
/* _GTF has no input parameters */
-   err = -EIO;
-   status = acpi_evaluate_object(dev->acpi_handle, "_GTF",
- NULL, &output);
+   status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output);
+
if (ACPI_FAILURE(status)) {
-   if (ata_msg_probe(ap))
-   ata_dev_printk(dev, KERN_DEBUG,
-   "%s: Run _GTF error: status = 0x%x\n",
-   __FUNCTION__, status);
-   goto out;
+   if (status != AE_NOT_FOUND) {
+   ata_dev_printk(dev, KERN_WARNING,
+  "_GTF evaluation failed (AE 0x%x)\n",
+  status);
+   rc = -EIO;
+   }
+   goto out_free;
}
 
if (!output.length || !output.pointer) {
@@ -169,43 

[PATCH 10/11] libata-acpi: remove redundant checks

2007-05-05 Thread Tejun Heo
Remove remaining unnecessary feature and status checks.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |   23 ---
 1 files changed, 0 insertions(+), 23 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index e09df44..78db2e6 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -134,22 +134,10 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct 
ata_acpi_gtf **gtf,
output.length = ACPI_ALLOCATE_BUFFER;
output.pointer = NULL;  /* ACPI-CA sets this; save/free it later */
 
-   if (!dev->acpi_handle)
-   goto out_free;
-
if (ata_msg_probe(ap))
ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
   __FUNCTION__, ap->port_no);
 
-   if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) {
-   if (ata_msg_probe(ap))
-   ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: "
-   "ata_dev_present: %d, PORT_DISABLED: %lu\n",
-   __FUNCTION__, ata_dev_enabled(dev),
-   ap->flags & ATA_FLAG_DISABLED);
-   goto out_free;
-   }
-
/* _GTF has no input parameters */
status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output);
 
@@ -340,21 +328,10 @@ static int ata_acpi_push_id(struct ata_device *dev)
struct acpi_object_list input;
union acpi_object in_params[1];
 
-   if (!dev->acpi_handle)
-   return 0;
-
if (ata_msg_probe(ap))
ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n",
   __FUNCTION__, dev->devno, ap->port_no);
 
-   /* Don't continue if not a SATA device. */
-   if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
-   if (ata_msg_probe(ap))
-   ata_dev_printk(dev, KERN_DEBUG,
-   "%s: Not a SATA device\n", __FUNCTION__);
-   return 0;
-   }
-
/* Give the drive Identify data to the drive via the _SDD method */
/* _SDD: set up input parameters */
input.count = 1;
-- 
1.5.0.3


-
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 09/11] libata: reimplement ACPI invocation

2007-05-05 Thread Tejun Heo
This patch reimplements ACPI invocation such that, instead of
exporting ACPI details to the rest of libata, ACPI event handlers -
ata_acpi_on_resume() and ata_acpi_on_devcfg() - are used.  These two
functions are responsible for determining whether specific ACPI method
is used and when.

On resume, _GTF is scheduled by setting ATA_DFLAG_ACPI_PENDING device
flag.  This is done this way to avoid performing the action on wrong
device device (device swapping while suspended).

On every ata_dev_configure(), ata_acpi_on_devcfg() is called, which
performs _SDD and _GTF.  _GTF is performed only after resuming and, if
SATA, hardreset as the ACPI spec specifies.  As _GTF may contain
arbitrary commands, IDENTIFY page is re-read after _GTF taskfiles are
executed.

If one of ACPI methods fails, ata_acpi_on_devcfg() retries on the
first failure.  If it fails again on the second try, ACPI is disabled
on the device.  Note that successful configuration clears ACPI failed
status.

With all feature checks moved to the above two functions,
do_drive_set_taskfiles() is trivial and thus collapsed into
ata_acpi_exec_tfs(), which is now static and converted to return the
number of executed taskfiles to be used by ata_acpi_on_resume().  As
failures are handled properly, ata_acpi_push_id() now returns -errno
on errors instead of unconditional zero.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |  204 +++-
 drivers/ata/libata-core.c |   16 ++--
 drivers/ata/libata-eh.c   |3 +
 drivers/ata/libata.h  |   14 +--
 include/linux/libata.h|2 +
 5 files changed, 140 insertions(+), 99 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ae2077e..e09df44 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -273,91 +273,47 @@ static int taskfile_load_raw(struct ata_device *dev,
 }
 
 /**
- * ata_dev_set_taskfiles - write the drive taskfile settings from _GTF
- * @dev: target ATA device
- * @gtf: pointer to array of _GTF taskfiles to execute
- * @gtf_count: number of taskfiles
- *
- * This applies to both PATA and SATA drives.
- *
- * Execute taskfiles in @gtf.
- *
- * LOCKING:
- * EH context.
- *
- * RETURNS:
- * 0 on success, -errno on failure.
- */
-static int ata_dev_set_taskfiles(struct ata_device *dev,
-struct ata_acpi_gtf *gtf, int gtf_count)
-{
-   struct ata_port *ap = dev->ap;
-   int ix;
-
-   if (ata_msg_probe(ap))
-   ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
-  __FUNCTION__, ap->port_no);
-
-   if (!(ap->flags & ATA_FLAG_ACPI_SATA))
-   return 0;
-
-   if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED))
-   return -ENODEV;
-
-   /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */
-   for (ix = 0; ix < gtf_count; ix++)
-taskfile_load_raw(dev, gtf++);
-
-   return 0;
-}
-
-/**
  * ata_acpi_exec_tfs - get then write drive taskfile settings
- * @ap: the ata_port for the drive
+ * @dev: target ATA device
  *
- * This applies to both PATA and SATA drives.
+ * Evaluate _GTF and excute returned taskfiles.
  *
  * LOCKING:
  * EH context.
  *
  * RETURNS:
- * 0 on success, -errno on failure.
+ * Number of executed taskfiles on success, 0 if _GTF doesn't exist or
+ * doesn't contain valid data.  -errno on other errors.
  */
-int ata_acpi_exec_tfs(struct ata_port *ap)
+static int ata_acpi_exec_tfs(struct ata_device *dev)
 {
-   int ix, ret = 0;
-
-   /*
-* TBD - implement PATA support.  For now,
-* we should not run GTF on PATA devices since some
-* PATA require execution of GTM/STM before GTF.
-*/
-   if (!(ap->flags & ATA_FLAG_ACPI_SATA))
-   return 0;
-
-   for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
-   struct ata_device *dev = &ap->device[ix];
-   struct ata_acpi_gtf *gtf = NULL;
-   int gtf_count;
-   void *ptr_to_free = NULL;
-
-   if (!ata_dev_enabled(dev))
-   continue;
-
-   ret = ata_dev_get_GTF(dev, >f, &ptr_to_free);
-   if (ret == 0)
-   continue;
-   if (ret < 0)
-   break;
-   gtf_count = ret;
-
-   ret = ata_dev_set_taskfiles(dev, gtf, gtf_count);
-   kfree(ptr_to_free);
-   if (ret < 0)
-   break;
+   struct ata_acpi_gtf *gtf = NULL;
+   void *ptr_to_free = NULL;
+   int gtf_count, i, rc;
+
+   /* get taskfiles */
+   rc = ata_dev_get_GTF(dev, >f, &ptr_to_free);
+   if (rc < 0)
+   return rc;
+   gtf_count = rc;
+
+   /* execute them */
+   for (i = 0, rc = 0; i < gtf_count; i++) {
+   int tmp;
+
+   /* ACPI errors are eventually ignored.  Run till the
+ 

[PATCH 02/11] libata: during revalidation, check n_sectors after device is configured

2007-05-05 Thread Tejun Heo
Device might be resized during ata_dev_configure() due to HPA or
(later) ACPI _GTF.  Currently it's worked around by caching n_sectors
before turning off HPA.  The cached original size is overwritten if
the device is reconfigured without being hardreset - which always
happens after configuring trasnfer mode.  If the device gets hardreset
for some reason after that, revalidation fails with -ENODEV.

This patch makes size checking more robust by moving n_sectors check
from ata_dev_reread_id() to ata_dev_revalidate() after the device is
fully configured.  No matter what happens during configuration, a
device must have the same n_sectors after fully configured to be
treated as the same device.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-core.c |   33 +++--
 include/linux/libata.h|1 -
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9d0d753..f53aa87 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1891,7 +1891,6 @@ int ata_dev_configure(struct ata_device *dev)
snprintf(revbuf, 7, "ATA-%d",  
ata_id_major_version(id));
 
dev->n_sectors = ata_id_n_sectors(id);
-   dev->n_sectors_boot = dev->n_sectors;
 
/* SCSI only uses 4-char revisions, dump full 8 chars from ATA 
*/
ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
@@ -3554,7 +3553,6 @@ static int ata_dev_same_device(struct ata_device *dev, 
unsigned int new_class,
const u16 *old_id = dev->id;
unsigned char model[2][ATA_ID_PROD_LEN + 1];
unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
-   u64 new_n_sectors;
 
if (dev->class != new_class) {
ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n",
@@ -3566,7 +3564,6 @@ static int ata_dev_same_device(struct ata_device *dev, 
unsigned int new_class,
ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
-   new_n_sectors = ata_id_n_sectors(new_id);
 
if (strcmp(model[0], model[1])) {
ata_dev_printk(dev, KERN_INFO, "model number mismatch "
@@ -3580,19 +3577,6 @@ static int ata_dev_same_device(struct ata_device *dev, 
unsigned int new_class,
return 0;
}
 
-   if (dev->class == ATA_DEV_ATA && dev->n_sectors != new_n_sectors) {
-   ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
-  "%llu != %llu\n",
-  (unsigned long long)dev->n_sectors,
-  (unsigned long long)new_n_sectors);
-   /* Are we the boot time size - if so we appear to be the
-  same disk at this point and our HPA got reapplied */
-   if (ata_ignore_hpa && dev->n_sectors_boot == new_n_sectors 
-   && ata_id_hpa_enabled(new_id))
-   return 1;
-   return 0;
-   }
-
return 1;
 }
 
@@ -3645,6 +3629,7 @@ int ata_dev_reread_id(struct ata_device *dev, unsigned 
int readid_flags)
  */
 int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
 {
+   u64 n_sectors = dev->n_sectors;
int rc;
 
if (!ata_dev_enabled(dev))
@@ -3657,8 +3642,20 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned 
int readid_flags)
 
/* configure device according to the new ID */
rc = ata_dev_configure(dev);
-   if (rc == 0)
-   return 0;
+   if (rc)
+   goto fail;
+
+   /* verify n_sectors hasn't changed */
+   if (dev->class == ATA_DEV_ATA && dev->n_sectors != n_sectors) {
+   ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
+  "%llu != %llu\n",
+  (unsigned long long)n_sectors,
+  (unsigned long long)dev->n_sectors);
+   rc = -ENODEV;
+   goto fail;
+   }
+
+   return 0;
 
  fail:
ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index d8cfc72..3cffbf6 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -448,7 +448,6 @@ struct ata_device {
struct scsi_device  *sdev;  /* attached SCSI device */
/* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
u64 n_sectors;  /* size of device, if ATA */
-   u64 n_sectors_boot; /* size of ATA device at 
startup */
unsigned intclass;  /* ATA_DEV_xxx */
u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
u8  pio_mode;
-- 

[PATCH 11/11] libata-acpi: implement _GTM/_STM support

2007-05-05 Thread Tejun Heo
Implement _GTM/_STM support.  acpi_gtm is added to ata_port which
stores _GTM parameters over suspend/resume cycle.  A new hook
ata_acpi_on_suspend() is responsible for storing _GTM parameters
during suspend.  _STM is executed in ata_acpi_on_resume().  With this
change, invoking _GTF is safe on IDE hierarchy and acpi_sata check
before _GTF is removed.

ata_acpi_gtm() and ata_acpi_stm() implementation is taken from Alan
Cox's pata_acpi implementation.  ata_acpi_gtm() is fixed such that the
result parameter is not shifted by sizeof(union acpi_object).

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
Cc: Alan Cox <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |  153 +++-
 drivers/ata/libata-eh.c   |8 ++-
 drivers/ata/libata.h  |2 +
 include/linux/libata.h|   13 
 4 files changed, 171 insertions(+), 5 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 78db2e6..c059f78 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -101,6 +101,108 @@ void ata_acpi_associate(struct ata_host *host)
 }
 
 /**
+ * ata_acpi_gtm - execute _GTM
+ * @ap: target ATA port
+ * @gtm: out parameter for _GTM result
+ *
+ * Evaluate _GTM and store the result in @gtm.
+ *
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
+ */
+static int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *gtm)
+{
+   struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
+   union acpi_object *out_obj;
+   acpi_status status;
+   int rc = 0;
+
+   status = acpi_evaluate_object(ap->acpi_handle, "_GTM", NULL, &output);
+
+   rc = -ENOENT;
+   if (status == AE_NOT_FOUND)
+   goto out_free;
+
+   rc = -EINVAL;
+   if (ACPI_FAILURE(status)) {
+   ata_port_printk(ap, KERN_ERR,
+   "ACPI get timing mode failed (AE 0x%x)\n",
+   status);
+   goto out_free;
+   }
+
+   out_obj = output.pointer;
+   if (out_obj->type != ACPI_TYPE_BUFFER) {
+   ata_port_printk(ap, KERN_WARNING,
+   "_GTM returned unexpected object type 0x%x\n",
+   out_obj->type);
+
+   goto out_free;
+   }
+
+   if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) {
+   ata_port_printk(ap, KERN_ERR,
+   "_GTM returned invalid length %d\n",
+   out_obj->buffer.length);
+   goto out_free;
+   }
+
+   memcpy(gtm, out_obj->buffer.pointer, sizeof(struct ata_acpi_gtm));
+   rc = 0;
+ out_free:
+   kfree(output.pointer);
+   return rc;
+}
+
+/**
+ * ata_acpi_stm - execute _STM
+ * @ap: target ATA port
+ * @stm: timing parameter to _STM
+ *
+ * Evaluate _STM with timing parameter @stm.
+ *
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * 0 on success, -ENOENT if _STM doesn't exist, -errno on failure.
+ */
+static int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm)
+{
+   acpi_status status;
+   struct acpi_object_list input;
+   union acpi_object   in_params[3];
+
+   in_params[0].type = ACPI_TYPE_BUFFER;
+   in_params[0].buffer.length = sizeof(struct ata_acpi_gtm);
+   in_params[0].buffer.pointer = (u8 *)stm;
+   /* Buffers for id may need byteswapping ? */
+   in_params[1].type = ACPI_TYPE_BUFFER;
+   in_params[1].buffer.length = 512;
+   in_params[1].buffer.pointer = (u8 *)ap->device[0].id;
+   in_params[2].type = ACPI_TYPE_BUFFER;
+   in_params[2].buffer.length = 512;
+   in_params[2].buffer.pointer = (u8 *)ap->device[1].id;
+
+   input.count = 3;
+   input.pointer = in_params;
+
+   status = acpi_evaluate_object(ap->acpi_handle, "_STM", &input, NULL);
+
+   if (status == AE_NOT_FOUND)
+   return -ENOENT;
+   if (ACPI_FAILURE(status)) {
+   ata_port_printk(ap, KERN_ERR,
+   "ACPI set timing mode failed (status=0x%x)\n", status);
+   return -EINVAL;
+   }
+   return 0;
+}
+
+/**
  * ata_dev_get_GTF - get the drive bootup default taskfile settings
  * @dev: target ATA device
  * @gtf: output parameter for buffer containing _GTF taskfile arrays
@@ -355,6 +457,46 @@ static int ata_acpi_push_id(struct ata_device *dev)
 }
 
 /**
+ * ata_acpi_on_suspend - ATA ACPI hook called on suspend
+ * @ap: target ATA port
+ *
+ * This function is called when @ap is about to be suspended.  All
+ * devices are already put to sleep but the port_suspend() callback
+ * hasn't been executed yet.  Error return from this function aborts
+ * suspend.
+ *
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int ata_acpi_on_suspend(struct ata_port *ap)
+{
+   unsigned long flags;
+   int rc;

[PATCH 08/11] libata-acpi: miscellaneous cleanups

2007-05-05 Thread Tejun Heo
* Add missing LOCKING: and RETURNS: to function comment.

* Don't conditionalize warning messages with ata_msg_probe().  Print
  directly with KERN_WARNING.

* Drop duplicate debug messages.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |   51 
 1 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 4d36d25..ae2077e 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -175,21 +175,17 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct 
ata_acpi_gtf **gtf,
 
out_obj = output.pointer;
if (out_obj->type != ACPI_TYPE_BUFFER) {
-   if (ata_msg_probe(ap))
-   ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
-   "error: expected object type of "
-   " ACPI_TYPE_BUFFER, got 0x%x\n",
-   __FUNCTION__, out_obj->type);
+   ata_dev_printk(dev, KERN_WARNING,
+  "_GTF unexpected object type 0x%x\n",
+  out_obj->type);
rc = -EINVAL;
goto out_free;
}
 
if (out_obj->buffer.length % REGS_PER_GTF) {
-   if (ata_msg_drv(ap))
-   ata_dev_printk(dev, KERN_ERR,
-   "%s: unexpected GTF length (%d) or addr 
(0x%p)\n",
-   __FUNCTION__, out_obj->buffer.length,
-   out_obj->buffer.pointer);
+   ata_dev_printk(dev, KERN_WARNING,
+  "unexpected _GTF length (%d)\n",
+  out_obj->buffer.length);
rc = -EINVAL;
goto out_free;
}
@@ -320,6 +316,12 @@ static int ata_dev_set_taskfiles(struct ata_device *dev,
  * @ap: the ata_port for the drive
  *
  * This applies to both PATA and SATA drives.
+ *
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
  */
 int ata_acpi_exec_tfs(struct ata_port *ap)
 {
@@ -345,24 +347,14 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
ret = ata_dev_get_GTF(dev, >f, &ptr_to_free);
if (ret == 0)
continue;
-   if (ret < 0) {
-   if (ata_msg_probe(ap))
-   ata_port_printk(ap, KERN_DEBUG,
-   "%s: get_GTF error (%d)\n",
-   __FUNCTION__, ret);
+   if (ret < 0)
break;
-   }
gtf_count = ret;
 
ret = ata_dev_set_taskfiles(dev, gtf, gtf_count);
kfree(ptr_to_free);
-   if (ret < 0) {
-   if (ata_msg_probe(ap))
-   ata_port_printk(ap, KERN_DEBUG,
-   "%s: set_taskfiles error (%d)\n",
-   __FUNCTION__, ret);
+   if (ret < 0)
break;
-   }
}
 
return ret;
@@ -377,6 +369,12 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
  * ATM this function never returns a failure.  It is an optional
  * method and if it fails for whatever reason, we should still
  * just keep going.
+ *
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
  */
 int ata_acpi_push_id(struct ata_device *dev)
 {
@@ -416,12 +414,9 @@ int ata_acpi_push_id(struct ata_device *dev)
swap_buf_le16(dev->id, ATA_ID_WORDS);
 
err = ACPI_FAILURE(status) ? -EIO : 0;
-   if (err < 0) {
-   if (ata_msg_probe(ap))
-   ata_dev_printk(dev, KERN_DEBUG,
-  "%s _SDD error: status = 0x%x\n",
-  __FUNCTION__, status);
-   }
+   if (err < 0)
+   ata_dev_printk(dev, KERN_WARNING,
+  "ACPI _SDD failed (AE 0x%x)\n", status);
 
/* always return success */
 out:
-- 
1.5.0.3


-
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


[PATCHSET] libata: improve ATA ACPI support, take#2

2007-05-05 Thread Tejun Heo
Hello, all.

This is the second take of improve-ATA-ACPI-support patchset.  Changes
from the last take[L] are...

* s/atadev/dev/
* s/do_drive_get_GTF/ata_dev_get_GTF/
* s/do_drive_set_taskfiles/ata_dev_set_taskfiles/

As I wrote in the previous thread, I don't think automatically
matching ACPI nodes to ATA ports and devices is a good idea or can be
done safely, so I left that part alone.  If you've got better ideas,
be my guest.  But with or without it, this patchset fixes a whole
bunch of problem and makes ATA ACPI support sane.  For more info,
please read the following message.

  http://article.gmane.org/gmane.linux.ide/17554

This patchset is against...

  libata-dev#upstream(225036314e768bbfe8331ea9b0e91ca101afe427)
  + [1] libata-acpi-fix-GTF-command-protocol-for-ATAPI

Thanks.

--
tejun

[L] http://thread.gmane.org/gmane.linux.ide/18127
[1] http://article.gmane.org/gmane.linux.ide/18122

-
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 01/11] libata: separate out ata_dev_reread_id()

2007-05-05 Thread Tejun Heo
Separate out ata_dev_reread_id() from ata_dev_revalidate().
ata_dev_reread_id() reads IDENTIFY page and determines whether the
same device is still there.  ata_dev_revalidate() reconfigures after
reread completes.  This will be used by ACPI update.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-core.c |   47 
 drivers/ata/libata.h  |3 +-
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ca67484..9d0d753 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3597,8 +3597,8 @@ static int ata_dev_same_device(struct ata_device *dev, 
unsigned int new_class,
 }
 
 /**
- * ata_dev_revalidate - Revalidate ATA device
- * @dev: device to revalidate
+ * ata_dev_reread_id - Re-read IDENTIFY data
+ * @adev: target ATA device
  * @readid_flags: read ID flags
  *
  * Re-read IDENTIFY page and make sure @dev is still attached to
@@ -3610,29 +3610,50 @@ static int ata_dev_same_device(struct ata_device *dev, 
unsigned int new_class,
  * RETURNS:
  * 0 on success, negative errno otherwise
  */
-int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
+int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags)
 {
unsigned int class = dev->class;
u16 *id = (void *)dev->ap->sector_buf;
int rc;
 
-   if (!ata_dev_enabled(dev)) {
-   rc = -ENODEV;
-   goto fail;
-   }
-
/* read ID data */
rc = ata_dev_read_id(dev, &class, readid_flags, id);
if (rc)
-   goto fail;
+   return rc;
 
/* is the device still there? */
-   if (!ata_dev_same_device(dev, class, id)) {
-   rc = -ENODEV;
-   goto fail;
-   }
+   if (!ata_dev_same_device(dev, class, id))
+   return -ENODEV;
 
memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS);
+   return 0;
+}
+
+/**
+ * ata_dev_revalidate - Revalidate ATA device
+ * @dev: device to revalidate
+ * @readid_flags: read ID flags
+ *
+ * Re-read IDENTIFY page, make sure @dev is still attached to the
+ * port and reconfigure it according to the new IDENTIFY page.
+ *
+ * LOCKING:
+ * Kernel thread context (may sleep)
+ *
+ * RETURNS:
+ * 0 on success, negative errno otherwise
+ */
+int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
+{
+   int rc;
+
+   if (!ata_dev_enabled(dev))
+   return -ENODEV;
+
+   /* re-read ID */
+   rc = ata_dev_reread_id(dev, readid_flags);
+   if (rc)
+   goto fail;
 
/* configure device according to the new ID */
rc = ata_dev_configure(dev);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 5f4d40c..c40665a 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -75,7 +75,8 @@ extern unsigned ata_exec_internal_sg(struct ata_device *dev,
 extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
 extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
   unsigned int flags, u16 *id);
-extern int ata_dev_revalidate(struct ata_device *dev, unsigned int flags);
+extern int ata_dev_reread_id(struct ata_device *dev, unsigned int 
readid_flags);
+extern int ata_dev_revalidate(struct ata_device *dev, unsigned int 
readid_flags);
 extern int ata_dev_configure(struct ata_device *dev);
 extern int sata_down_spd_limit(struct ata_port *ap);
 extern int sata_set_spd_needed(struct ata_port *ap);
-- 
1.5.0.3


-
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 04/11] libata-acpi: clean up parameters and misc stuff

2007-05-05 Thread Tejun Heo
This patch cleans up libata-acpi such that it looks similar to other
libata files.  This patch doesn't introuce any behavior changes.

* make libata-acpi functions take ata_device instead of ata_port +
  device index
* s/atadev/dev/
* de-indent local variable declarations

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/libata-acpi.c |  192 ++---
 drivers/ata/libata-core.c |2 +-
 drivers/ata/libata.h  |4 +-
 3 files changed, 98 insertions(+), 100 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index cb3eab6..ed4138e 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -270,8 +270,7 @@ out:
 
 /**
  * do_drive_get_GTF - get the drive bootup default taskfile settings
- * @ap: the ata_port for the drive
- * @ix: target ata_device (drive) index
+ * @dev: target ATA device
  * @gtf_length: number of bytes of _GTF data returned at @gtf_address
  * @gtf_address: buffer containing _GTF taskfile arrays
  *
@@ -286,20 +285,19 @@ out:
  * The returned @gtf_length and @gtf_address are only valid if the
  * function return value is 0.
  */
-static int do_drive_get_GTF(struct ata_port *ap, int ix,
-   unsigned int *gtf_length, unsigned long *gtf_address,
-   unsigned long *obj_loc)
+static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
+   unsigned long *gtf_address, unsigned long *obj_loc)
 {
-   acpi_status status;
-   acpi_handle dev_handle = NULL;
-   acpi_handle chan_handle, drive_handle;
-   acpi_integerpcidevfn = 0;
-   u32 dev_adr;
-   struct acpi_buffer  output;
-   union acpi_object   *out_obj;
-   struct device   *dev = ap->host->dev;
-   struct ata_device   *atadev = &ap->device[ix];
-   int err = -ENODEV;
+   struct ata_port *ap = dev->ap;
+   acpi_status status;
+   acpi_handle dev_handle = NULL;
+   acpi_handle chan_handle, drive_handle;
+   acpi_integer pcidevfn = 0;
+   u32 dev_adr;
+   struct acpi_buffer output;
+   union acpi_object *out_obj;
+   struct device *gdev = ap->host->dev;
+   int err = -ENODEV;
 
*gtf_length = 0;
*gtf_address = 0UL;
@@ -309,14 +307,14 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
return 0;
 
if (ata_msg_probe(ap))
-   ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
+   ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
   __FUNCTION__, ap->port_no);
 
-   if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) {
+   if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) {
if (ata_msg_probe(ap))
-   ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: "
+   ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: "
"ata_dev_present: %d, PORT_DISABLED: %lu\n",
-   __FUNCTION__, ata_dev_enabled(atadev),
+   __FUNCTION__, ata_dev_enabled(dev),
ap->flags & ATA_FLAG_DISABLED);
goto out;
}
@@ -324,19 +322,19 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
/* Don't continue if device has no _ADR method.
 * _GTF is intended for known motherboard devices. */
if (!(ap->cbl == ATA_CBL_SATA)) {
-   err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn);
+   err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
if (err < 0) {
if (ata_msg_probe(ap))
-   ata_dev_printk(atadev, KERN_DEBUG,
+   ata_dev_printk(dev, KERN_DEBUG,
"%s: pata_get_dev_handle failed (%d)\n",
__FUNCTION__, err);
goto out;
}
} else {
-   err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn);
+   err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
if (err < 0) {
if (ata_msg_probe(ap))
-   ata_dev_printk(atadev, KERN_DEBUG,
+   ata_dev_printk(dev, KERN_DEBUG,
"%s: sata_get_dev_handle failed (%d\n",
__FUNCTION__, err);
goto out;
@@ -344,7 +342,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
}
 
/* Get this drive's _ADR info. if not already known. */
-   if (!atadev->obj_handle) {
+   if (!d

[PATCH 05/11] libata-acpi: add ATA_FLAG_ACPI_SATA port flag

2007-05-05 Thread Tejun Heo
Whether a controller needs IDE or SATA ACPI hierarchy is determined by
the programming interface of the controller not by whether the
controller is SATA or PATA, or it supports slave device or not.  This
patch adds ATA_FLAG_ACPI_SATA port flags which tells libata-acpi that
the port needs SATA ACPI nodes, and sets the flag for ahci and
sata_sil24.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
 drivers/ata/ahci.c|3 ++-
 drivers/ata/libata-acpi.c |   10 +-
 drivers/ata/sata_sil24.c  |3 ++-
 include/linux/libata.h|1 +
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 34c5534..7f739e8 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -173,7 +173,8 @@ enum {
 
AHCI_FLAG_COMMON= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
  ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
- ATA_FLAG_SKIP_D2H_BSY,
+ ATA_FLAG_SKIP_D2H_BSY |
+ ATA_FLAG_ACPI_SATA,
 };
 
 struct ahci_cmd_hdr {
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ed4138e..0223673 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -321,7 +321,7 @@ static int do_drive_get_GTF(struct ata_device *dev, 
unsigned int *gtf_length,
 
/* Don't continue if device has no _ADR method.
 * _GTF is intended for known motherboard devices. */
-   if (!(ap->cbl == ATA_CBL_SATA)) {
+   if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
if (err < 0) {
if (ata_msg_probe(ap))
@@ -343,7 +343,7 @@ static int do_drive_get_GTF(struct ata_device *dev, 
unsigned int *gtf_length,
 
/* Get this drive's _ADR info. if not already known. */
if (!dev->obj_handle) {
-   if (!(ap->cbl == ATA_CBL_SATA)) {
+   if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
/* get child objects of dev_handle == channel objects,
 * + _their_ children == drive objects */
/* channel is ap->port_no */
@@ -528,7 +528,7 @@ static int do_drive_set_taskfiles(struct ata_device *dev,
ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
   __FUNCTION__, ap->port_no);
 
-   if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA))
+   if (libata_noacpi || !(ap->flags & ATA_FLAG_ACPI_SATA))
return 0;
 
if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED))
@@ -578,7 +578,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
 * we should not run GTF on PATA devices since some
 * PATA require execution of GTM/STM before GTF.
 */
-   if (!(ap->cbl == ATA_CBL_SATA))
+   if (!(ap->flags & ATA_FLAG_ACPI_SATA))
return 0;
 
for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
@@ -641,7 +641,7 @@ int ata_acpi_push_id(struct ata_device *dev)
   __FUNCTION__, dev->devno, ap->port_no);
 
/* Don't continue if not a SATA device. */
-   if (!(ap->cbl == ATA_CBL_SATA)) {
+   if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
if (ata_msg_probe(ap))
ata_dev_printk(dev, KERN_DEBUG,
"%s: Not a SATA device\n", __FUNCTION__);
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index e6223ba..a499369 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -237,7 +237,8 @@ enum {
/* host flags */
SIL24_COMMON_FLAGS  = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
  ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
- ATA_FLAG_NCQ | ATA_FLAG_SKIP_D2H_BSY,
+ ATA_FLAG_NCQ | ATA_FLAG_SKIP_D2H_BSY |
+ ATA_FLAG_ACPI_SATA,
SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */
 
IRQ_STAT_4PORTS = 0xf,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 8a577c2..a26bb7f 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -174,6 +174,7 @@ enum {
ATA_FLAG_SETXFER_POLLING= (1 << 14), /* use polling for SETXFER */
ATA_FLAG_IGN_SIMPLEX= (1 << 15), /* ignore SIMPLEX */
ATA_FLAG_NO_IORDY   = (1 << 16), /* controller lacks iordy */
+   ATA_FLAG_ACPI_SATA  = (1 << 17), /* need native SATA ACPI layout */
 
/* The following flag belongs to ap->pflags but is kept in
 * ap->flags because it's referenced in many LLDs and will be
-- 
1.5.0.3


-
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/2] ATA: sata_promise, do not freeze ports

2007-05-05 Thread Jiri Slaby
If no objections, here comes the revert of the return 1 issue.

--

sata_promise, do not freeze ports

revert return 1 thing in the error isr, that causes port freezing, so that the
system is unusable when exception is thrown.

See http://lkml.org/lkml/2007/4/30/268

Cc: Jeff Garzik <[EMAIL PROTECTED]>
Cc: Mikael Pettersson <[EMAIL PROTECTED]>
Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>

---
commit a38d21f4b5d5029b0b083fe2651e78c7657fda3b
tree 0a2019a34227906bc5fb0e60d90cc7f4759ee934
parent b5c1fc64195b18d3919bfa7dddfb76e9f2a05786
author Jiri Slaby <[EMAIL PROTECTED]> Sat, 05 May 2007 16:43:22 +0200
committer Jiri Slaby <[EMAIL PROTECTED]> Sat, 05 May 2007 16:43:22 +0200

 drivers/ata/sata_promise.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index f56549b..a0024ae 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -668,10 +668,8 @@ static inline unsigned int pdc_host_intr( struct ata_port 
*ap,
else
err_mask &= ~PDC2_ERR_MASK;
port_status = readl(port_mmio + PDC_GLOBAL_CTL);
-   if (unlikely(port_status & err_mask)) {
+   if (unlikely(port_status & err_mask))
pdc_error_intr(ap, qc, port_status, err_mask);
-   return 1;
-   }
 
switch (qc->tf.protocol) {
case ATA_PROT_DMA:
-
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: SATA SB600 works in 2.6.20.4 but not in 2.6.21-rc5 with irqpoll parameter

2007-05-05 Thread Tejun Heo
Matí­as Alejandro Torres wrote:
> May be it disables MSI for some other device/bridge/what ever:

Right, that device gotta be PCI-e or PCI-x bridge and the disk
controller lives in a different bus.  Please apply the attached patch.
This one really should fix the problem.  :-)

-- 
tejun
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3411483..1e3070e 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1624,18 +1624,20 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_N
quirk_nvidia_ck804_pcie_aer_ext_cap);
 
 #ifdef CONFIG_PCI_MSI
-/* The Serverworks PCI-X chipset does not support MSI. We cannot easily rely
- * on setting PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually
- * some other busses controlled by the chipset even if Linux is not aware of 
it.
- * Instead of setting the flag on all busses in the machine, simply disable MSI
- * globally.
+/* Some chipsets do not support MSI. We cannot easily rely on setting
+ * PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually
+ * some other busses controlled by the chipset even if Linux is not
+ * aware of it.  Instead of setting the flag on all busses in the
+ * machine, simply disable MSI globally.
  */
-static void __init quirk_svw_msi(struct pci_dev *dev)
+static void __init quirk_disable_all_msi(struct pci_dev *dev)
 {
pci_no_msi();
printk(KERN_WARNING "PCI: MSI quirk detected. MSI deactivated.\n");
 }
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, 
PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_svw_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, 
PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, 
quirk_disable_all_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, 
quirk_disable_all_msi);
 
 /* Disable MSI on chipsets that are known to not support it */
 static void __devinit quirk_disable_msi(struct pci_dev *dev)


Re: [PATCH 1/2 pata-2.6] ide: make void and rename ide_dma_lostirq() method

2007-05-05 Thread Bartlomiej Zolnierkiewicz

On Tuesday 24 April 2007, Sergei Shtylyov wrote:
> Since ide_dma_lostirq() method's result is discarded, make it return 'void'.
> While at it, rename the method to dma_lost_irq(), drop the '__' prefix from 
> the
> default method's name, and do some cleanups in this method driver-wise:
> 
> - in aec62xx.c, rename the method in accordance with other drivers, and get 
> rid
>   of unnecessary variables there;
> 
> - in pdc202xx_old.c, define/use 'hwif' variable;
> 
> - in sgiioc4.c, rearrange the code to call the resetproc() method directly.
> 
> Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

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 2/2 pata-2.6] ide: make void and rename ide_dma_timeout() method

2007-05-05 Thread Bartlomiej Zolnierkiewicz

On Tuesday 24 April 2007, Sergei Shtylyov wrote:
> Since ide_dma_timeout() method's result is discarded, make it return 'void'.
> While at it, drop 'ide_' from the method's name, drop the '__' prefix from
> the default method's name, and do some cleanups in this method driver-wise:
> 
> - in ide-dma.c, au1xxx-ide.c, and pdc202xx_old.c, define/use 'hwif' variable;
> 
> - in au1xxx-ide.c, get rid of commented out printk();
> 
> - in sl82c105.c, get rid of unnecessary variables.
> 
> Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

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] use mutex instead of semaphore in IDE driver

2007-05-05 Thread Bartlomiej Zolnierkiewicz

On Thursday 26 April 2007, Matthias Kaehlcke wrote:
> the IDE driver uses a semaphore as mutex. use the mutex API instead of
> the (binary) semaphore
> 
> Signed-off-by: Matthias Kaehlcke <[EMAIL PROTECTED]>

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 pata-2.6] hpt366: simplify UltraDMA filtering

2007-05-05 Thread Bartlomiej Zolnierkiewicz

On Monday 30 April 2007, Sergei Shtylyov wrote:
> Simplify UltraDMA mode filtering in the driver:
> 
> - make use of the newly introduced 'udma_mask' field of 'ide_pci_device_t' to
>   set the correct hwif->ultra_mask, modifying init_setup_hpt366() to select
>   the correct mask based on the chip revision;
> 
> - replace 'max_mode' field of the 'struct hpt_info' with 'max_ultra' 
> specifying
>   the maximum UltraDMA mode allowed;
> 
> - rewrite hpt3xx_udma_filter() to differ the filters based on the 'chip_type'
>   field, and only use it for HPT366 and HPT370[A] where it's really necessary.
> 
> Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

applied

I needed to fix some rejects because of the
"hpt366: don't check enablebits for HPT36x" patch
- please verify that I haven't broken anything.

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-2.6 fix queue] hpt366: don't check enablebits for HPT36x

2007-05-05 Thread Bartlomiej Zolnierkiewicz
On Friday 04 May 2007, Sergei Shtylyov wrote:
> HPT36x chip don't seem to have the channel enable bits, so prevent the IDE 
> core
> from checking them...
> 
> Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

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


[git patches] IDE updates

2007-05-05 Thread Bartlomiej Zolnierkiewicz

Updates/fixes for host drivers.


Please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 drivers/ide/cris/ide-cris.c|9 +-
 drivers/ide/legacy/ide-cs.c|1 +
 drivers/ide/pci/aec62xx.c  |   22 +--
 drivers/ide/pci/alim15x3.c |7 +-
 drivers/ide/pci/cmd64x.c   |  537 +---
 drivers/ide/pci/hpt366.c   |7 +-
 drivers/ide/pci/it821x.c   |  126 +-
 drivers/ide/pci/pdc202xx_new.c |3 -
 drivers/ide/pci/siimage.c  |   12 +-
 drivers/ide/pci/sl82c105.c |  247 ---
 include/linux/ide.h|1 -
 11 files changed, 459 insertions(+), 513 deletions(-)


Bartlomiej Zolnierkiewicz (5):
  alim15x3: PIO fallback fix
  pdc202xx_new: enable DMA for all ATAPI devices
  it821x: PIO mode setup fixes
  siimage: fix wrong ->swdma_mask
  ide-cris: fix ->speedproc and wrong ->swdma_mask

Fabrice Aeschbacher (1):
  ide-cs: recognize 2GB CompactFlash from Transcend

Sergei Shtylyov (9):
  sl82c105: rework PIO support (take 2)
  sl82c105: DMA support code cleanup (take 4)
  cmd64x: fix multiword and remove single-word DMA support
  cmd64x: interrupt status fixes (take 2)
  cmd64x: add/fix enablebits (take 2)
  cmd64x: procfs code fixes/cleanups (take 2)
  cmd64x: use interrupt status from MRDMODE register (take 2)
  aec62xx: fix PIO/DMA setup issues
  hpt366: don't check enablebits for HPT36x


diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 556455f..5e8efc8 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -730,7 +730,7 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
 
if (speed >= XFER_PIO_0 && speed <= XFER_PIO_4) {
tune_cris_ide(drive, speed - XFER_PIO_0);
-   return 0;
+   return ide_config_drive_speed(drive, speed);
}
 
switch(speed)
@@ -760,7 +760,8 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
hold = ATA_DMA2_HOLD;
break;
default:
-   return 0;
+   BUG();
+   break;
}
 
if (speed >= XFER_UDMA_0)
@@ -768,7 +769,7 @@ static int speed_cris_ide(ide_drive_t *drive, u8 speed)
else
cris_ide_set_speed(TYPE_DMA, 0, strobe, hold);
 
-   return 0;
+   return ide_config_drive_speed(drive, speed);
 }
 
 void __init
@@ -821,7 +822,6 @@ init_e100_ide (void)
hwif->udma_four = 0;
hwif->ultra_mask = cris_ultra_mask;
hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
-   hwif->swdma_mask = 0x07; /* Singleword DMA 0-2 */
hwif->autodma = 1;
hwif->drives[0].autodma = 1;
hwif->drives[1].autodma = 1;
@@ -1010,7 +1010,6 @@ static int cris_config_drive_for_dma (ide_drive_t *drive)
return 0;
 
speed_cris_ide(drive, speed);
-   ide_config_drive_speed(drive, speed);
 
return ide_dma_enable(drive);
 }
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index b08c37c..c6522a6 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -401,6 +401,7 @@ static struct pcmcia_device_id ide_ids[] = {
PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
PCMCIA_DEVICE_PROD_ID1("TRANSCEND512M   ", 0xd0909443),
PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 
0x2a54d4b1),
+   PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 
0x969aa4f2),
PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 
0xf54a91c8),
PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 990eafe..73bdf64 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -1,7 +1,8 @@
 /*
- * linux/drivers/ide/pci/aec62xx.c Version 0.11March 27, 2002
+ * linux/drivers/ide/pci/aec62xx.c Version 0.21Apr 21, 2007
  *
  * Copyright (C) 1999-2002 Andre Hedrick <[EMAIL PROTECTED]>
+ * Copyright (C) 2007  MontaVista Software, Inc. <[EMAIL PROTECTED]>
  *
  */
 
@@ -193,18 +194,8 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 
 static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
 {
-   u8 speed = 0;
-   u8 new_pio = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL);
-
-   switch(pio) {
-   case 5: speed = new_pio; break;
-   case 4: speed = XFER_PIO_4; break;
-   case 3: speed = XFER_PIO_3; break;
-   case 2: speed = XFER_PIO_2; break;
-   case 1

Re: [PATCH pata-2.6] hpt366: simplify UltraDMA filtering

2007-05-05 Thread Sergei Shtylyov

Hello.

Bartlomiej Zolnierkiewicz wrote:


Simplify UltraDMA mode filtering in the driver:



- make use of the newly introduced 'udma_mask' field of 'ide_pci_device_t' to
 set the correct hwif->ultra_mask, modifying init_setup_hpt366() to select
 the correct mask based on the chip revision;

- replace 'max_mode' field of the 'struct hpt_info' with 'max_ultra' specifying
 the maximum UltraDMA mode allowed;

- rewrite hpt3xx_udma_filter() to differ the filters based on the 'chip_type'
 field, and only use it for HPT366 and HPT370[A] where it's really necessary.

Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>



applied



I needed to fix some rejects because of the


   I was going to recast this patch once the fix below is verified...


"hpt366: don't check enablebits for HPT36x" patch
- please verify that I haven't broken anything.



Thanks,
Bart


MBR, Sergei
-
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-2.6 fix queue] hpt366: don't check enablebits for HPT36x

2007-05-05 Thread Sergei Shtylyov

Hello.

Bartlomiej Zolnierkiewicz wrote:


HPT36x chip don't seem to have the channel enable bits, so prevent the IDE core
from checking them...



Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>



applied


   I'm getting "403 Forbidden" trying to browse this patch (and 
ide-cs-recognize-2gb-compactflash-from-transcend.patch as well).


MBR, Sergei
-
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-2.6] hpt366: simplify UltraDMA filtering (take 2)

2007-05-05 Thread Sergei Shtylyov
Simplify UltraDMA mode filtering in the driver:

- make use of the newly introduced 'udma_mask' field of 'ide_pci_device_t' to
  set the correct hwif->ultra_mask, modifying init_setup_hpt366() to select
  the correct mask based on the chip revision;

- replace 'max_mode' field of the 'struct hpt_info' with 'max_ultra' specifying
  the maximum UltraDMA mode allowed;

- rewrite hpt3xx_udma_filter() to differ the filters based on the 'chip_type'
  field, and only use it for HPT366 and HPT370[A] where it's really necessary.

Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

---
This patch is against the top of the pata-2.6. I had to change it a bit due to
a fix going in ahead. Tested on HPT370, will try to test on HPT371N later...

 drivers/ide/pci/hpt366.c |  148 +--
 1 files changed, 80 insertions(+), 68 deletions(-)

Index: linux-2.6/drivers/ide/pci/hpt366.c
===
--- linux-2.6.orig/drivers/ide/pci/hpt366.c
+++ linux-2.6/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/hpt366.c  Version 1.03May 4, 2007
+ * linux/drivers/ide/pci/hpt366.c  Version 1.10May 5, 2007
  *
  * Copyright (C) 1999-2003 Andre Hedrick <[EMAIL PROTECTED]>
  * Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -77,7 +77,7 @@
  *   since they may tamper with its fields
  * - prefix the driver startup messages with the real chip name
  * - claim the extra 240 bytes of I/O space for all chips
- * - optimize the rate masking/filtering and the drive list lookup code
+ * - optimize the UltraDMA filtering and the drive list lookup code
  * - use pci_get_slot() to get to the function 1 of HPT36x/374
  * - cache offset of the channel's misc. control registers (MCRs) being used
  *   throughout the driver
@@ -99,9 +99,9 @@
  *   stop duplicating it for each channel by storing the pointer in the pci_dev
  *   structure: first, at the init_setup stage, point it to a static "template"
  *   with only the chip type and its specific base DPLL frequency, the highest
- *   supported DMA mode, and the chip settings table pointer filled, then, at
- *   the init_chipset stage, allocate per-chip instance  and fill it with the
- *   rest of the necessary information
+ *   UltraDMA mode, and the chip settings table pointer filled,  then, at the
+ *   init_chipset stage, allocate per-chip instance  and fill it with the rest
+ *   of the necessary information
  * - get rid of the constant thresholds in the HPT37x PCI clock detection code,
  *   switch  to calculating  PCI clock frequency based on the chip's base DPLL
  *   frequency
@@ -111,6 +111,7 @@
  *   also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips;
  *   unify HPT36x/37x timing setup code and the speedproc handlers by joining
  *   the register setting lists into the table indexed by the clock selected
+ * - set the correct hwif->ultra_mask for each individual chip
  * Sergei Shtylyov, <[EMAIL PROTECTED]> or <[EMAIL PROTECTED]>
  */
 
@@ -390,7 +391,7 @@ enum ata_clock {
 
 struct hpt_info {
u8 chip_type;   /* Chip type */
-   u8 max_mode;/* Speeds allowed */
+   u8 max_ultra;   /* Max. UltraDMA mode allowed */
u8 dpll_clk;/* DPLL clock in MHz */
u8 pci_clk; /* PCI  clock in MHz */
u32 **settings; /* Chipset settings table */
@@ -429,77 +430,77 @@ static u32 *hpt37x_settings[NUM_ATA_CLOC
 
 static struct hpt_info hpt36x __devinitdata = {
.chip_type  = HPT36x,
-   .max_mode   = (HPT366_ALLOW_ATA66_4 || HPT366_ALLOW_ATA66_3) ? 2 : 
1,
+   .max_ultra  = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? 4 : 3) 
: 2,
.dpll_clk   = 0,/* no DPLL */
.settings   = hpt36x_settings
 };
 
 static struct hpt_info hpt370 __devinitdata = {
.chip_type  = HPT370,
-   .max_mode   = HPT370_ALLOW_ATA100_5 ? 3 : 2,
+   .max_ultra  = HPT370_ALLOW_ATA100_5 ? 5 : 4,
.dpll_clk   = 48,
.settings   = hpt37x_settings
 };
 
 static struct hpt_info hpt370a __devinitdata = {
.chip_type  = HPT370A,
-   .max_mode   = HPT370_ALLOW_ATA100_5 ? 3 : 2,
+   .max_ultra  = HPT370_ALLOW_ATA100_5 ? 5 : 4,
.dpll_clk   = 48,
.settings   = hpt37x_settings
 };
 
 static struct hpt_info hpt374 __devinitdata = {
.chip_type  = HPT374,
-   .max_mode   = HPT374_ALLOW_ATA133_6 ? 4 : 3,
+   .max_ultra  = HPT374_ALLOW_ATA133_6 ? 6 : 5,
.dpll_clk   = 48,
.settings   = hpt37x_settings
 };
 
 static struct hpt_info hpt372 __devinitdata = {
.chip_type  = HPT372,
-   .max_mode   = HPT372_ALLOW_ATA133_6 ? 4 : 3,
+   .max_ultra  = HPT372_ALLOW_ATA133_6 ? 6 : 5,
.dpll_clk   = 55,
.settings   = hpt37x_se

Re: [PATCH pata-2.6] hpt366: simplify UltraDMA filtering (take 2)

2007-05-05 Thread Bartlomiej Zolnierkiewicz
On Saturday 05 May 2007, Sergei Shtylyov wrote:
> Simplify UltraDMA mode filtering in the driver:
> 
> - make use of the newly introduced 'udma_mask' field of 'ide_pci_device_t' to
>   set the correct hwif->ultra_mask, modifying init_setup_hpt366() to select
>   the correct mask based on the chip revision;
> 
> - replace 'max_mode' field of the 'struct hpt_info' with 'max_ultra' 
> specifying
>   the maximum UltraDMA mode allowed;
> 
> - rewrite hpt3xx_udma_filter() to differ the filters based on the 'chip_type'
>   field, and only use it for HPT366 and HPT370[A] where it's really necessary.
> 
> Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

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 pata-2.6 fix queue] hpt366: don't check enablebits for HPT36x

2007-05-05 Thread Bartlomiej Zolnierkiewicz
On Saturday 05 May 2007, Sergei Shtylyov wrote:
> Hello.
> 
> Bartlomiej Zolnierkiewicz wrote:
> 
> >>HPT36x chip don't seem to have the channel enable bits, so prevent the IDE 
> >>core
> >>from checking them...
> 
> >>Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>
> 
> > applied
> 
> I'm getting "403 Forbidden" trying to browse this patch (and 
> ide-cs-recognize-2gb-compactflash-from-transcend.patch as well).

Should be fixed now - sorry for that.

While at it I replaced mine version of "the hpt366: simplify UltraDMA
filtering (take 2)" with the official one ;) and fixed my damn scripts
to always do "chmod 644 pata-2.6/patches/*.patch" before pushing updates
to kernel.org.

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] sata_nv: fix ADMA freeze/thaw/irq_clear issues

2007-05-05 Thread Robert Hancock

This patch fixes some problems with ADMA-capable controllers with regard to 
freeze,
thaw and irq_clear libata callbacks. Freeze and thaw didn't switch the 
ADMA-specific
interrupts on or off, and more critically the irq_clear function didn't respect
the restriction that the notifier clear registers for both ports have to be 
written
at the same time even when only one port is being cleared. This could result in
timeouts on one port when error handling (i.e. as a result of hotplug)
occurred on the other port.

As well, this fixes some issues in the interrupt handler: we shouldn't check any
ADMA status if the port has ADMA switched off because of an ATAPI device, and
it also checks to see if any ADMA interrupt has been raised even when we are in
port-register mode.

Signed-off-by: Robert Hancock <[EMAIL PROTECTED]>

--- linux-2.6.21.1/drivers/ata/sata_nv.c2007-04-27 15:49:26.0 
-0600
+++ linux-2.6.21.1edit/drivers/ata/sata_nv.c2007-05-05 15:25:04.0 
-0600
@@ -257,6 +257,8 @@ static void nv_adma_port_stop(struct ata
static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg);
static int nv_adma_port_resume(struct ata_port *ap);
#endif
+static void nv_adma_freeze(struct ata_port *ap);
+static void nv_adma_thaw(struct ata_port *ap);
static void nv_adma_error_handler(struct ata_port *ap);
static void nv_adma_host_stop(struct ata_host *host);
static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc);
@@ -446,8 +448,8 @@ static const struct ata_port_operations 
	.bmdma_status		= ata_bmdma_status,

.qc_prep= nv_adma_qc_prep,
.qc_issue   = nv_adma_qc_issue,
-   .freeze = nv_ck804_freeze,
-   .thaw   = nv_ck804_thaw,
+   .freeze = nv_adma_freeze,
+   .thaw   = nv_adma_thaw,
.error_handler  = nv_adma_error_handler,
.post_internal_cmd  = nv_adma_post_internal_cmd,
.data_xfer  = ata_data_xfer,
@@ -810,8 +812,16 @@ static irqreturn_t nv_adma_interrupt(int
u16 status;
u32 gen_ctl;
u32 notifier, notifier_error;
+   
+   /* if ADMA is disabled, use standard ata interrupt 
handler */
+   if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) {
+   u8 irq_stat = readb(host->iomap[NV_MMIO_BAR] + 
NV_INT_STATUS_CK804)
+   >> (NV_INT_PORT_SHIFT * i);
+   handled += nv_host_intr(ap, irq_stat);
+   continue;
+   }

-   /* if in ATA register mode, use standard ata interrupt 
handler */
+   /* if in ATA register mode, check for standard 
interrupts */
if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) {
u8 irq_stat = readb(host->iomap[NV_MMIO_BAR] + 
NV_INT_STATUS_CK804)
>> (NV_INT_PORT_SHIFT * i);
@@ -821,7 +831,6 @@ static irqreturn_t nv_adma_interrupt(int
command is active, to prevent 
losing interrupts. */
irq_stat |= NV_INT_DEV;
handled += nv_host_intr(ap, irq_stat);
-   continue;
}

notifier = readl(mmio + NV_ADMA_NOTIFIER);
@@ -907,22 +916,77 @@ static irqreturn_t nv_adma_interrupt(int
return IRQ_RETVAL(handled);
}

+static void nv_adma_freeze(struct ata_port *ap)
+{
+   struct nv_adma_port_priv *pp = ap->private_data;
+   void __iomem *mmio = pp->ctl_block;
+   u16 tmp;
+
+   nv_ck804_freeze(ap);
+
+   if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)
+   return;
+
+   /* clear any outstanding CK804 notifications */
+   writeb( NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT),
+   ap->host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804);
+
+   /* Disable interrupt */
+   tmp = readw(mmio + NV_ADMA_CTL);
+   writew( tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN),
+   mmio + NV_ADMA_CTL);
+   readw( mmio + NV_ADMA_CTL );/* flush posted write */
+}
+
+static void nv_adma_thaw(struct ata_port *ap)
+{
+   struct nv_adma_port_priv *pp = ap->private_data;
+   void __iomem *mmio = pp->ctl_block;
+   u16 tmp;
+
+   nv_ck804_thaw(ap);
+
+   if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)
+   return;
+
+   /* Enable interrupt */
+   tmp = readw(mmio + NV_ADMA_CTL);
+   writew( tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN),
+   mmio + NV_ADMA_CTL);
+   readw( mmio + NV_ADMA_CTL );/* flush posted write */
+}
+
static void nv_adma_irq_clear(struct ata_port *ap)
{
struct nv_adma_port_priv *p

Re: 2.6.21-mm1: many processes end up in D state

2007-05-05 Thread Mikael Pettersson
On Sat, 05 May 2007 17:30:51 +0200, Tejun Heo wrote:
> Mikael Pettersson wrote:
> >> I.e. no freezing of ports...
> > 
> > Your patch to delete the 'return 1;' on error is correct,
> > and makes the code match exactly the behaviour of previous
> > versions of sata_promise, except for the additional error
> > decoding.
> > 
> > ahci and sata_sil24 do the return in this situation. I don't
> > yet understand why they can get away with it while sata_promise
> > cannot, but for now the return should be removed.
> 
> That's because sata_sil24 and ahci call either ata_port_abort() or
> ata_port_freeze() prior to finishing error_intr routine.  Both functions
> abort all in-flight command and schedule EH.

Ah. Thanks, that clarifies things.

Jiri: please test the patch below instead. That is, revert to
the original code _with_ the 'return 1;', and then add this
patch to it. It should have pretty much the same effect as
removing the 'return 1;', however calling ata_port_abort()
is more in line with libata's new-style error handling.

/Mikael

--- linux-2.6.21-mm1/drivers/ata/sata_promise.c.~1~ 2007-05-05 
22:24:41.0 +0200
+++ linux-2.6.21-mm1/drivers/ata/sata_promise.c 2007-05-05 22:25:21.0 
+0200
@@ -653,6 +653,8 @@ static void pdc_error_intr(struct ata_po
qc->err_mask |= ac_err_mask;
 
pdc_reset_port(ap);
+
+   ata_port_abort(ap);
 }
 
 static inline unsigned int pdc_host_intr( struct ata_port *ap,
-
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