linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, lkml@rtr.ca,
	forrest.zhao@intel.com, linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 05/12] libata-pmp: hook PMP support and enable it
Date: Sat, 8 Jul 2006 14:58:08 +0900	[thread overview]
Message-ID: <11523382883775-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11523382873130-git-send-email-htejun@gmail.com>

Hook PMP support into libata and enable it.  Connect SCR and probing
functions, and update ata_dev_classify() to detect PMP.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   92 ++++++++++++++++++++++++++++++--------------
 drivers/scsi/libata-eh.c   |   15 +++++++
 2 files changed, 78 insertions(+), 29 deletions(-)

7f13e180e59b2eeed428688536c0b476a08f4b16
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index c950435..7480b47 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -550,29 +550,46 @@ static unsigned int ata_devchk(struct at
  *	None.
  *
  *	RETURNS:
- *	Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, or %ATA_DEV_UNKNOWN
- *	the event of failure.
+ *	Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or
+ *	%ATA_DEV_UNKNOWN the event of failure.
  */
-
 unsigned int ata_dev_classify(const struct ata_taskfile *tf)
 {
 	/* Apple's open source Darwin code hints that some devices only
 	 * put a proper signature into the LBA mid/high registers,
 	 * So, we only check those.  It's sufficient for uniqueness.
+	 *
+	 * ATA/ATAPI-7 (d1532v1r1: Feb. 19, 2003) specified separate
+	 * signatures for ATA and ATAPI devices attached on SerialATA,
+	 * 0x3c/0xc3 and 0x69/0x96 respectively.  However, SerialATA
+	 * spec has never mentioned about using different signatures
+	 * for ATA/ATAPI devices.  Then, Serial ATA II: Port
+	 * Multiplier specification began to use 0x69/0x96 to identify
+	 * port multpliers.  ATA/ATAPI-7 dropped descriptions about
+	 * 0x3c/0xc3 and 0x69/0x96 shortly and described them as
+	 * reserved for SerialATA.
+	 *
+	 * We follow the current spec and consider that 0x69/0x96
+	 * identifies a port multiplier.  If there is an ATAPI device
+	 * which returns 0x69/0x96 as its signature, we'll have to
+	 * implement 'try PMP, then try ATAPI' logic.
 	 */
-
 	if (((tf->lbam == 0) && (tf->lbah == 0)) ||
 	    ((tf->lbam == 0x3c) && (tf->lbah == 0xc3))) {
 		DPRINTK("found ATA device by sig\n");
 		return ATA_DEV_ATA;
 	}
 
-	if (((tf->lbam == 0x14) && (tf->lbah == 0xeb)) ||
-	    ((tf->lbam == 0x69) && (tf->lbah == 0x96))) {
+	if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
 		DPRINTK("found ATAPI device by sig\n");
 		return ATA_DEV_ATAPI;
 	}
 
+	if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
+		DPRINTK("found PMP device by sig\n");
+		return ATA_DEV_PMP;
+	}
+
 	DPRINTK("unknown device\n");
 	return ATA_DEV_UNKNOWN;
 }
@@ -5043,24 +5060,29 @@ int sata_scr_valid(struct ata_link *link
  *	@val: Place to store read value
  *
  *	Read SCR register @reg of @link into *@val.  This function is
- *	guaranteed to succeed if the cable type of the port is SATA
- *	and the port implements ->scr_read.
+ *	guaranteed to succeed if @link is ap->link, the cable type of
+ *	the port is SATA and the port implements ->scr_read.
  *
  *	LOCKING:
- *	None.
+ *	None if @link is ap->link.  Kernel thread context otherwise.
  *
  *	RETURNS:
  *	0 on success, negative errno on failure.
  */
 int sata_scr_read(struct ata_link *link, int reg, u32 *val)
 {
-	struct ata_port *ap = link->ap;
+	if (ata_is_host_link(link)) {
+		struct ata_port *ap = link->ap;
 
-	if (sata_scr_valid(link)) {
-		*val = ap->ops->scr_read(ap, reg);
-		return 0;
+		if (sata_scr_valid(link)) {
+			*val = ap->ops->scr_read(ap, reg);
+			return 0;
+		}
+
+		return -EOPNOTSUPP;
 	}
-	return -EOPNOTSUPP;
+
+	return sata_pmp_scr_read(link, reg, val);
 }
 
 /**
@@ -5070,24 +5092,29 @@ int sata_scr_read(struct ata_link *link,
  *	@val: value to write
  *
  *	Write @val to SCR register @reg of @link.  This function is
- *	guaranteed to succeed if the cable type of the port is SATA
- *	and the port implements ->scr_read.
+ *	guaranteed to succeed if @link is ap->link, the cable type of
+ *	the port is SATA and the port implements ->scr_read.
  *
  *	LOCKING:
- *	None.
+ *	None if @link is ap->link.  Kernel thread context otherwise.
  *
  *	RETURNS:
  *	0 on success, negative errno on failure.
  */
 int sata_scr_write(struct ata_link *link, int reg, u32 val)
 {
-	struct ata_port *ap = link->ap;
+	if (ata_is_host_link(link)) {
+		struct ata_port *ap = link->ap;
 
-	if (sata_scr_valid(link)) {
-		ap->ops->scr_write(ap, reg, val);
-		return 0;
+		if (sata_scr_valid(link)) {
+			ap->ops->scr_write(ap, reg, val);
+			return 0;
+		}
+
+		return -EOPNOTSUPP;
 	}
-	return -EOPNOTSUPP;
+
+	return sata_pmp_scr_write(link, reg, val);
 }
 
 /**
@@ -5100,21 +5127,26 @@ int sata_scr_write(struct ata_link *link
  *	function performs flush after writing to the register.
  *
  *	LOCKING:
- *	None.
+ *	None if @link is ap->link.  Kernel thread context otherwise.
  *
  *	RETURNS:
  *	0 on success, negative errno on failure.
  */
 int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
 {
-	struct ata_port *ap = link->ap;
+	if (ata_is_host_link(link)) {
+		struct ata_port *ap = link->ap;
 
-	if (sata_scr_valid(link)) {
-		ap->ops->scr_write(ap, reg, val);
-		ap->ops->scr_read(ap, reg);
-		return 0;
+		if (sata_scr_valid(link)) {
+			ap->ops->scr_write(ap, reg, val);
+			ap->ops->scr_read(ap, reg);
+			return 0;
+		}
+
+		return -EOPNOTSUPP;
 	}
-	return -EOPNOTSUPP;
+
+	return sata_pmp_scr_write(link, reg, val);
 }
 
 /**
@@ -5905,6 +5937,8 @@ int ata_scsi_release(struct Scsi_Host *h
 	ap->ops->port_disable(ap);
 	ata_host_remove(ap, 0);
 
+	kfree(ap->pmp_link);
+
 	DPRINTK("EXIT\n");
 	return 1;
 }
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 0125c18..c4946cc 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -1730,6 +1730,8 @@ static int ata_eh_revalidate_and_attach(
 		unsigned int action = ata_eh_dev_action(dev);
 
 		if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) {
+			WARN_ON(dev->class == ATA_DEV_PMP);
+
 			if (ata_link_offline(dev->link)) {
 				rc = -EIO;
 				break;
@@ -1750,6 +1752,13 @@ static int ata_eh_revalidate_and_attach(
 			   ata_class_enabled(ehc->classes[dev->devno])) {
 			dev->class = ehc->classes[dev->devno];
 
+			if (dev->class == ATA_DEV_PMP) {
+				rc = sata_pmp_attach(dev);
+				if (rc)
+					dev->class = ATA_DEV_UNKNOWN;
+				break;
+			}
+
 			rc = ata_dev_read_id(dev, &dev->class, 1, dev->id);
 			if (rc == 0)
 				rc = ata_dev_configure(dev, 1);
@@ -2166,6 +2175,12 @@ int ata_eh_recover(struct ata_port *ap, 
 		if (rc)
 			goto dev_fail;
 
+		/* if PMP got attached, return, we don't know what to do */
+		if (link->device->class == ATA_DEV_PMP) {
+			ehc->i.action = 0;
+			return 0;
+		}
+
 		/* configure transfer mode if the port has been reset */
 		if (ehc->i.flags & ATA_EHI_DID_RESET) {
 			rc = ata_set_mode(link, &dev);
-- 
1.3.2



  parent reply	other threads:[~2006-07-08  5:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-08  5:58 [PATCHSET 3/3] implement PMP support, take 2 Tejun Heo
2006-07-08  5:58 ` [PATCH 03/12] libata-pmp: implement ATA_LFLAG_DISABLED Tejun Heo
2006-07-19 20:36   ` Jeff Garzik
2006-07-24  6:52     ` Tejun Heo
2006-07-08  5:58 ` [PATCH 04/12] libata-pmp: implement Port Multiplier support Tejun Heo
2006-07-08  5:58 ` [PATCH 01/12] libata-pmp: add PMP related constants, fields, ops and update helpers Tejun Heo
2006-07-19 20:34   ` Jeff Garzik
2006-07-08  5:58 ` [PATCH 02/12] libata-pmp: update ata_eh_reset() for PMP Tejun Heo
2006-07-08  5:58 ` [PATCH 09/12] sata_sil24: separate out sil24_exec_polled_cmd() Tejun Heo
2006-07-08  5:58 ` [PATCH 08/12] sata_sil24: replace sil24_update_tf() with sil24_read_tf() Tejun Heo
2006-07-08  5:58 ` Tejun Heo [this message]
2006-07-08  5:58 ` [PATCH 07/12] sata_sil24: add PMP related constants Tejun Heo
2006-07-08  5:58 ` [PATCH 06/12] sata_sil24: rename " Tejun Heo
2006-07-08  5:58 ` [PATCH 10/12] sata_sil24: separate out sil24_do_softreset() Tejun Heo
2006-07-08  5:58 ` [PATCH 12/12] sata_sil24: implement PORT_RST Tejun Heo
2006-07-08  5:58 ` [PATCH 11/12] sata_sil24: implement PMP support Tejun Heo
2006-07-19 20:37 ` [PATCHSET 3/3] implement PMP support, take 2 Jeff Garzik
2006-07-24  6:56   ` 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=11523382883775-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=forrest.zhao@intel.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=lkml@rtr.ca \
    /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).