public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aic94xx: fix smartctl utility problem
@ 2007-09-14 12:30 Gilbert Wu
  2007-09-14 17:26 ` Jeff Garzik
  0 siblings, 1 reply; 24+ messages in thread
From: Gilbert Wu @ 2007-09-14 12:30 UTC (permalink / raw)
  To: linux-scsi

Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does
not work on SATA device. ( The smartctl v5.38 does need "-d ata"
option.)
  The aic94xx need to return ATA output register for all ATA commands
except ATA Read/Write commands.
  The aic94xx also mark out the DRQ bit from status register which is
treated as AC_ERR_HSM (host state machine violation) error by top layer
if it set to one.
 The firmware of aic94xx chip handle all ATA handshaking, data transfer
and return ATA output register which is sent by the device.  So the DRQ
bit may not reflect the last state of device when the command finished
and it is no meaning for the caller.

Signed-off-by: Gilbert Wu <gilbert_wu@adaptec.com>


diff -urN a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
--- a/drivers/scsi/aic94xx/aic94xx_task.c	2007-09-13 04:46:00.000000000 -0700
+++ b/drivers/scsi/aic94xx/aic94xx_task.c	2007-09-13 04:46:31.000000000 -0700
@@ -25,6 +25,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/ata.h>
 #include "aic94xx.h"
 #include "aic94xx_sas.h"
 #include "aic94xx_hwi.h"
@@ -220,6 +221,7 @@
 			memcpy(&resp->ending_fis[0], r+16, 24);
 			ts->buf_valid_size = sizeof(*resp);
 		}
+		resp->ending_fis[2] &= ~ATA_DRQ;
 	}
 
 	asd_invalidate_edb(escb, edb_id);
@@ -257,6 +259,11 @@
 		ts->stat = SAS_PROTO_RESPONSE;
 		asd_get_response_tasklet(ascb, dl);
 		break;
+	case TC_CSMI:
+		ts->resp = SAS_TASK_COMPLETE;
+		ts->stat = SAM_GOOD;
+		asd_get_response_tasklet(ascb, dl);
+		break;
 	case TF_OPEN_REJECT:
 		ts->resp = SAS_TASK_UNDELIVERED;
 		ts->stat = SAS_OPEN_REJECT;
@@ -374,7 +381,32 @@
 }
 
 /* ---------- ATA ---------- */
+int is_ata_rw_cmd(u8 ata_cmd)
+{
 
+	switch (ata_cmd) {
+	case ATA_CMD_READ:
+	case ATA_CMD_READ_EXT:
+	case ATA_CMD_WRITE:
+	case ATA_CMD_WRITE_EXT:
+	case ATA_CMD_WRITE_FUA_EXT:
+	case ATA_CMD_FPDMA_READ:
+	case ATA_CMD_FPDMA_WRITE:
+	case ATA_CMD_PIO_READ:
+	case ATA_CMD_PIO_READ_EXT:
+	case ATA_CMD_PIO_WRITE:
+	case ATA_CMD_PIO_WRITE_EXT:
+	case ATA_CMD_READ_MULTI:
+	case ATA_CMD_READ_MULTI_EXT:
+	case ATA_CMD_WRITE_MULTI:
+	case ATA_CMD_WRITE_MULTI_EXT:
+	case ATA_CMD_WRITE_MULTI_FUA_EXT:
+	case ATA_CMD_VERIFY:
+	case ATA_CMD_VERIFY_EXT:
+		return 1;
+	}
+	return 0;
+}
 static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
 			      gfp_t gfp_flags)
 {
@@ -427,6 +459,9 @@
 			flags |= STP_AFFIL_POLICY;
 		scb->ata_task.flags = flags;
 	}
+	if (!is_ata_rw_cmd(scb->ata_task.fis.command))
+		scb->ata_task.ata_flags|=CSMI_TASK;
+
 	ascb->tasklet_complete = asd_task_tasklet_complete;
 
 	if (likely(!task->ata_task.device_control_reg_update))




^ permalink raw reply	[flat|nested] 24+ messages in thread
* [PATCH] aic94xx: fix smartctl utility problem
@ 2007-09-14 17:58 Gilbert Wu
  2007-09-14 18:14 ` Jeff Garzik
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Gilbert Wu @ 2007-09-14 17:58 UTC (permalink / raw)
  To: Linux-scsi

Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does
not work on SATA device. ( The smartctl v5.38 does need "-d ata"
option.)
  The aic94xx need to return ATA output register for all ATA commands
except ATA Read/Write commands.
  The aic94xx also mark out the DRQ bit from status register which is
treated as AC_ERR_HSM (host state machine violation) error by top layer
if it set to one.
 The firmware of aic94xx chip handle all ATA handshaking, data transfer
and return ATA output register which is sent by the device.  So the DRQ
bit may not reflect the last state of device when the command finished
and it is no meaning for the caller.

Signed-off-by: Gilbert Wu <gilbert_wu@adaptec.com>

diff -urN a/drivers/scsi/aic94xx/aic94xx_task.c
b/drivers/scsi/aic94xx/aic94xx_task.c
--- a/drivers/scsi/aic94xx/aic94xx_task.c	2007-09-13 04:46:00.000000000 -0700
+++ b/drivers/scsi/aic94xx/aic94xx_task.c	2007-09-14 06:06:52.000000000 -0700
@@ -25,6 +25,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/ata.h>
 #include "aic94xx.h"
 #include "aic94xx_sas.h"
 #include "aic94xx_hwi.h"
@@ -220,6 +221,7 @@
 			memcpy(&resp->ending_fis[0], r+16, 24);
 			ts->buf_valid_size = sizeof(*resp);
 		}
+		resp->ending_fis[2] &= ~ATA_DRQ;
 	}
 
 	asd_invalidate_edb(escb, edb_id);
@@ -257,6 +259,11 @@
 		ts->stat = SAS_PROTO_RESPONSE;
 		asd_get_response_tasklet(ascb, dl);
 		break;
+	case TC_CSMI:
+		ts->resp = SAS_TASK_COMPLETE;
+		ts->stat = SAM_GOOD;
+		asd_get_response_tasklet(ascb, dl);
+		break;
 	case TF_OPEN_REJECT:
 		ts->resp = SAS_TASK_UNDELIVERED;
 		ts->stat = SAS_OPEN_REJECT;
@@ -374,7 +381,32 @@
 }
 
 /* ---------- ATA ---------- */
+int is_ata_rw_cmd(u8 ata_cmd)
+{
 
+	switch (ata_cmd) {
+	case ATA_CMD_READ:
+	case ATA_CMD_READ_EXT:
+	case ATA_CMD_WRITE:
+	case ATA_CMD_WRITE_EXT:
+	case ATA_CMD_WRITE_FUA_EXT:
+	case ATA_CMD_FPDMA_READ:
+	case ATA_CMD_FPDMA_WRITE:
+	case ATA_CMD_PIO_READ:
+	case ATA_CMD_PIO_READ_EXT:
+	case ATA_CMD_PIO_WRITE:
+	case ATA_CMD_PIO_WRITE_EXT:
+	case ATA_CMD_READ_MULTI:
+	case ATA_CMD_READ_MULTI_EXT:
+	case ATA_CMD_WRITE_MULTI:
+	case ATA_CMD_WRITE_MULTI_EXT:
+	case ATA_CMD_WRITE_MULTI_FUA_EXT:
+	case ATA_CMD_VERIFY:
+	case ATA_CMD_VERIFY_EXT:
+		return 1;
+	}
+	return 0;
+}
 static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
 			      gfp_t gfp_flags)
 {
@@ -427,6 +459,9 @@
 			flags |= STP_AFFIL_POLICY;
 		scb->ata_task.flags = flags;
 	}
+	if (!is_ata_rw_cmd(scb->ata_task.fis.command))
+		scb->ata_task.ata_flags |= CSMI_TASK;
+
 	ascb->tasklet_complete = asd_task_tasklet_complete;
 
 	if (likely(!task->ata_task.device_control_reg_update))



^ permalink raw reply	[flat|nested] 24+ messages in thread
* [PATCH] aic94xx: fix smartctl utility problem
@ 2007-09-05 22:25 Gilbert Wu
  2007-09-06 10:06 ` Jeff Garzik
  0 siblings, 1 reply; 24+ messages in thread
From: Gilbert Wu @ 2007-09-05 22:25 UTC (permalink / raw)
  To: Linux-scsi

   Fixed the problem that "smartctl -a /dev/some_sata_disk -d ata"  does not work on SATA device.
   ( The smartctl v5.38 does need "-d ata" option.)
   The root cause is the aic94xx driver does not return ATA output register due to performance reason.
   The aic94xx need check ATA command which need ATA output register and turn on internal flag to
   enable firmware to return ATA output register to top layer.
   It also add new ATA commands to ata.h sush as ATA_CMD_CHK_MEDIA_TYPE and ATA_CMD_SMART.

Signed-off-by: Gilbert Wu <gilbert_wu@adaptec.com>

diff -urN a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
--- a/drivers/scsi/aic94xx/aic94xx_task.c	2007-09-04 14:55:57.000000000 -0700
+++ b/drivers/scsi/aic94xx/aic94xx_task.c	2007-09-05 14:55:45.000000000 -0700
@@ -25,6 +25,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/hdreg.h>
 #include "aic94xx.h"
 #include "aic94xx_sas.h"
 #include "aic94xx_hwi.h"
@@ -152,6 +153,22 @@
 		pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
 			     task->data_dir);
 }
+static const struct ata_command_table {
+	u8 command;
+	u8 sub_command;
+} ata_command_tbl[] = {
+	{ATA_CMD_CHK_MEDIA_TYPE,         0},
+	{ATA_CMD_DEV_RESET,              0},
+	{ATA_CMD_EDD,                    0},
+	{ATA_CMD_IDLEIMMEDIATE,          0},
+	{ATA_CMD_READ_NATIVE_MAX,        0},
+	{ATA_CMD_READ_NATIVE_MAX_EXT,    0},
+	{ATA_CMD_SET_MAX,                0},
+	{ATA_CMD_SET_MAX_EXT,            0},
+	{ATA_CMD_SMART,                  SMART_STATUS},
+	{ATA_CMD_SMART,                  SMART_IMMEDIATE_OFFLINE}, 
+	{0,0} /* terminate list */
+};
 
 /* ---------- Task complete tasklet ---------- */
 
@@ -253,6 +270,7 @@
 		break;
 	case TC_SSP_RESP:
 	case TC_ATA_RESP:
+	case TC_CSMI:
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_PROTO_RESPONSE;
 		asd_get_response_tasklet(ascb, dl);
@@ -375,6 +393,21 @@
 
 /* ---------- ATA ---------- */
 
+int need_ata_output_reg(u8 command, u8 sub_command)
+{
+
+	int i;
+		
+	for (i = 0; ata_command_tbl[i].command != 0 ; i++) {
+
+		if (ata_command_tbl[i].command == command &&
+			(!ata_command_tbl[i].sub_command || 
+			  ata_command_tbl[i].sub_command == sub_command )) 
+		return 1;
+	}
+	return 0;
+}
+
 static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
 			      gfp_t gfp_flags)
 {
@@ -427,6 +460,9 @@
 			flags |= STP_AFFIL_POLICY;
 		scb->ata_task.flags = flags;
 	}
+	if (need_ata_output_reg(scb->ata_task.fis.command,scb->ata_task.fis.features))
+		scb->ata_task.ata_flags|=CSMI_TASK;
+
 	ascb->tasklet_complete = asd_task_tasklet_complete;
 
 	if (likely(!task->ata_task.device_control_reg_update))
diff -urN a/include/linux/ata.h b/include/linux/ata.h
--- a/include/linux/ata.h	2007-09-04 14:48:44.000000000 -0700
+++ b/include/linux/ata.h	2007-09-04 19:28:05.000000000 -0700
@@ -175,6 +175,8 @@
 	ATA_CMD_READ_LOG_EXT	= 0x2f,
 	ATA_CMD_PMP_READ	= 0xE4,
 	ATA_CMD_PMP_WRITE	= 0xE8,
+	ATA_CMD_CHK_MEDIA_TYPE	= 0xD1,
+	ATA_CMD_SMART		= 0xB0,
 
 	/* READ_LOG_EXT pages */
 	ATA_LOG_SATA_NCQ	= 0x10,



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

end of thread, other threads:[~2007-09-21 23:05 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-14 12:30 [PATCH] aic94xx: fix smartctl utility problem Gilbert Wu
2007-09-14 17:26 ` Jeff Garzik
2007-09-14 17:30   ` Wu, Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2007-09-14 17:58 Gilbert Wu
2007-09-14 18:14 ` Jeff Garzik
2007-09-15 17:05 ` James Bottomley
2007-09-16 16:37   ` James Bottomley
2007-09-16 19:43     ` Jeff Garzik
2007-09-16 23:01     ` Douglas Gilbert
2007-09-16 23:21       ` James Bottomley
2007-09-17 20:53         ` Wu, Gilbert
2007-09-17 22:59           ` James Bottomley
2007-09-18  1:43             ` Wu, Gilbert
2007-09-18  3:31               ` James Bottomley
2007-09-21 18:53             ` Wu, Gilbert
2007-09-21 20:40               ` James Bottomley
2007-09-21 23:05                 ` Wu, Gilbert
2007-09-20 18:52         ` Douglas Gilbert
2007-09-18 20:35 ` Luben Tuikov
2007-09-05 22:25 Gilbert Wu
2007-09-06 10:06 ` Jeff Garzik
2007-09-06 18:33   ` Wu, Gilbert
2007-09-07 23:00     ` Jeff Garzik
2007-09-07 23:58       ` Wu, Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox