From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, albertcc@tw.ibm.com,
axboe@suse.de, linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 07/14] libata: implement ata_eh_read_log_10h()
Date: Mon, 3 Apr 2006 17:32:39 +0900 [thread overview]
Message-ID: <114405315998-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <1144053158183-git-send-email-htejun@gmail.com>
Implement ata_eh_read_log_10h(). This will be used by NCQ EH.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/scsi/libata-eh.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
c70528a1ce4ae9f5dffb41986e56f349f4a172ca
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 3dadff8..94ecb0c 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -528,6 +528,113 @@ static unsigned int atapi_eh_request_sen
}
/**
+ * ata_read_log_page - read a specific log page
+ * @ap: port on which device we wish to probe resides
+ * @dev: target device
+ * @page: page to read
+ * @buf: buffer to store read page
+ * @sectors: number of sectors to read
+ *
+ * Read log page using READ_LOG_EXT command.
+ *
+ * LOCKING:
+ * Kernel thread context (may sleep)
+ *
+ * RETURNS:
+ * 0 on success, AC_ERR_* mask otherwise.
+ */
+static unsigned int ata_read_log_page(struct ata_port *ap,
+ struct ata_device *dev,
+ u8 page, void *buf, unsigned int sectors)
+{
+ struct ata_taskfile tf;
+ unsigned int err_mask;
+
+ DPRINTK("read log page - page %d\n", page);
+
+ ata_tf_init(ap, &tf, dev->devno);
+ tf.command = ATA_CMD_READ_LOG_EXT;
+ tf.lbal = page;
+ tf.nsect = sectors;
+ tf.hob_nsect = sectors >> 8;
+ tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_LBA48 | ATA_TFLAG_DEVICE;
+ tf.protocol = ATA_PROT_PIO;
+
+ err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_FROM_DEVICE,
+ buf, sectors * ATA_SECT_SIZE);
+
+ DPRINTK("EXIT, err_mask=%x\n", err_mask);
+ return err_mask;
+}
+
+/**
+ * ata_eh_read_log_10h - Read log page 10h for NCQ error details
+ * @ap: Port associated with device @dev
+ * @dev: Device to read log page 10h from
+ * @tag: Resulting tag of the failed command
+ * @tf: Resulting taskfile registers of the failed command
+ *
+ * Read log page 10h to obtain NCQ error details and clear error
+ * condition.
+ *
+ * LOCKING:
+ * Kernel thread context (may sleep)
+ *
+ * RETURNS:
+ * 0 on success, -errno otherwise.
+ */
+static int ata_eh_read_log_10h(struct ata_port *ap, struct ata_device *dev,
+ unsigned int *tag, struct ata_taskfile *tf)
+{
+ u8 *buf, csum;
+ unsigned int err_mask;
+ int i, rc;
+
+ buf = kmalloc(ATA_SECT_SIZE, GFP_KERNEL);
+ if (buf == NULL) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ err_mask = ata_read_log_page(ap, dev, ATA_LOG_SATA_NCQ, buf, 1);
+ if (err_mask) {
+ rc = -EIO;
+ goto out;
+ }
+
+ csum = 0;
+ for (i = 0; i < ATA_SECT_SIZE; i++)
+ csum += buf[i];
+ if (csum)
+ printk(KERN_WARNING "ata%u: dev %u invalid checksum 0x%x on "
+ "log page 10h\n", ap->id, dev->devno, csum);
+
+ if (buf[0] & 0x80) {
+ rc = -ENOENT;
+ goto out;
+ }
+
+ *tag = buf[0] & 0x1f;
+
+ tf->command = buf[2];
+ tf->feature = buf[3];
+ tf->lbal = buf[4];
+ tf->lbam = buf[5];
+ tf->lbah = buf[6];
+ tf->device = buf[7];
+ tf->hob_lbal = buf[8];
+ tf->hob_lbam = buf[9];
+ tf->hob_lbah = buf[10];
+ tf->nsect = buf[12];
+ tf->hob_nsect = buf[13];
+
+ rc = 0;
+ out:
+ kfree(buf);
+ return rc;
+}
+
+/**
* ata_eh_determine_qc - Determine which qc caused error
* @ap: port which failed
* @tf: resulting taskfile registers of the failed command
--
1.2.4
next prev parent reply other threads:[~2006-04-03 8:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-03 8:32 [PATCHSET] libata: add NCQ support Tejun Heo
2006-04-03 8:32 ` [PATCH 01/14] libata: add NCQ related ATA constants and id macros Tejun Heo
2006-04-03 8:32 ` Tejun Heo [this message]
2006-04-03 8:32 ` [PATCH 10/14] libata: implement ata_ncq_complete() Tejun Heo
2006-04-03 8:32 ` [PATCH 04/14] libata: implement ap->sactive Tejun Heo
2006-04-03 8:32 ` [PATCH 05/14] libata: implement command exclusion Tejun Heo
2006-04-03 8:32 ` [PATCH 09/14] libata: implement NCQ device configuration Tejun Heo
2006-04-03 8:32 ` [PATCH 08/14] libata: update EH to handle NCQ Tejun Heo
2006-04-03 8:32 ` [PATCH 06/14] libata: implement NCQ command translation Tejun Heo
2006-04-03 8:32 ` [PATCH 03/14] libata: pass ata_scsi_translate() return value to SCSI midlayer Tejun Heo
2006-04-03 8:32 ` [PATCH 02/14] libata: add NCQ related libata flags Tejun Heo
2006-04-03 8:32 ` [PATCH 13/14] ahci: kill pp->cmd_tbl_sg Tejun Heo
2006-04-03 8:32 ` [PATCH 12/14] ahci: add HOST_CAP_NCQ constant Tejun Heo
2006-04-03 8:32 ` [PATCH 14/14] ahci: implement NCQ suppport Tejun Heo
2006-04-03 8:32 ` [PATCH 11/14] libata: clean up AHCI constants in preparation for NCQ Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=114405315998-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=albertcc@tw.ibm.com \
--cc=axboe@suse.de \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).