linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET #upstream] libata: modularize PMP support, take #1
@ 2008-03-25 13:25 Tejun Heo
  2008-03-25 13:25 ` [PATCH 1/3] libata: separate PMP support code from core code Tejun Heo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tejun Heo @ 2008-03-25 13:25 UTC (permalink / raw)
  To: jeff, linux-ide, liml


Hello, all.

This patchset modularizes PMP support and contains the following three
patches.

  mails/0001-libata-separate-PMP-support-code-from-core-code.patch
  mails/0002-libata-implement-PMP-helpers.patch
  mails/0003-libata-make-PMP-support-optional.patch

LLDs which support PMP don't depend on PMP.  If PMP is turned on,
those LLDs support PMP, if PMP is off, they don't.  The size of
libata.ko on x86_64 w all debugging options off change like the
following.

		ON-DISK		LOADED
+SFF+PMP	226k		157k
+SFF-PMP	204k		141k
-SFF+PMP	193k		133k
-SFF-PMP	171k		117k

Both ahci and sata_sil24 have been verified to work w/ PMP turned on
and off.

This patchset is on top of

  upstream-fixes (4cde32fc4b32e96a99063af3183acdfd54c563f0)
+ prefer-hardreset (990d6db0af21830681157317ab58c10f80277cb8)
+ cleanup-sht-ops (ed75ba53c883bc7a63fa1b60c63f33fcf395e751)
+ [1] cleanup-pdc_adma
+ [2] modularize-SFF-support patchset, take #1

This patchset is available as git tree.

  http://git.kernel.org/?p=linux/kernel/git/tj/libata-dev.git;a=shortlog;h=modularize-PMP
  git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata-dev.git modularize-PMP

Thanks.

--
tejun

[1] http://thread.gmane.org/gmane.linux.ide/29978
[2] http://thread.gmane.org/gmane.linux.ide/29981

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

* [PATCH 1/3] libata: separate PMP support code from core code
  2008-03-25 13:25 [PATCHSET #upstream] libata: modularize PMP support, take #1 Tejun Heo
@ 2008-03-25 13:25 ` Tejun Heo
  2008-03-25 13:25 ` [PATCH 2/3] libata: implement PMP helpers Tejun Heo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2008-03-25 13:25 UTC (permalink / raw)
  To: jeff, linux-ide, liml; +Cc: Tejun Heo

Most of PMP support code is already in libata-pmp.c.  All that are in
libata-core.c are sata_pmp_port_ops and EXPORTs.  Move them to
libata-pmp.c.  Also, collect PMP related prototypes and declarations
in header files and move them right above of SFF stuff.

This change is to make PMP support optional.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 drivers/ata/libata-core.c |   13 -------------
 drivers/ata/libata-pmp.c  |   12 ++++++++++++
 drivers/ata/libata.h      |   10 +++++-----
 include/linux/libata.h    |   17 ++++++++++-------
 4 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 22f3140..51d7959 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -86,15 +86,6 @@ const struct ata_port_operations sata_port_ops = {
 	.hardreset		= sata_std_hardreset,
 };
 
-const struct ata_port_operations sata_pmp_port_ops = {
-	.inherits		= &sata_port_ops,
-
-	.pmp_prereset		= ata_std_prereset,
-	.pmp_hardreset		= sata_std_hardreset,
-	.pmp_postreset		= ata_std_postreset,
-	.error_handler		= sata_pmp_error_handler,
-};
-
 static unsigned int ata_dev_init_params(struct ata_device *dev,
 					u16 heads, u16 sectors);
 static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
@@ -6140,7 +6131,6 @@ EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
 EXPORT_SYMBOL_GPL(sata_deb_timing_long);
 EXPORT_SYMBOL_GPL(ata_base_port_ops);
 EXPORT_SYMBOL_GPL(sata_port_ops);
-EXPORT_SYMBOL_GPL(sata_pmp_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_info);
 EXPORT_SYMBOL_GPL(ata_std_bios_param);
@@ -6219,9 +6209,6 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);
 #endif /* CONFIG_PM */
 #endif /* CONFIG_PCI */
 
-EXPORT_SYMBOL_GPL(sata_pmp_qc_defer_cmd_switch);
-EXPORT_SYMBOL_GPL(sata_pmp_error_handler);
-
 EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_clear_desc);
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 9c99861..bb10c06 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -11,6 +11,14 @@
 #include <linux/libata.h>
 #include "libata.h"
 
+const struct ata_port_operations sata_pmp_port_ops = {
+	.inherits		= &sata_port_ops,
+	.pmp_prereset		= ata_std_prereset,
+	.pmp_hardreset		= sata_std_hardreset,
+	.pmp_postreset		= ata_std_postreset,
+	.error_handler		= sata_pmp_error_handler,
+};
+
 /**
  *	sata_pmp_read - read PMP register
  *	@link: link to read PMP register for
@@ -1012,3 +1020,7 @@ void sata_pmp_error_handler(struct ata_port *ap)
 	sata_pmp_eh_recover(ap);
 	ata_eh_finish(ap);
 }
+
+EXPORT_SYMBOL_GPL(sata_pmp_port_ops);
+EXPORT_SYMBOL_GPL(sata_pmp_qc_defer_cmd_switch);
+EXPORT_SYMBOL_GPL(sata_pmp_error_handler);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 45e1786..c6dbcfc 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -178,11 +178,6 @@ extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
 extern void ata_scsi_dev_rescan(struct work_struct *work);
 extern int ata_bus_probe(struct ata_port *ap);
 
-/* libata-pmp.c */
-extern int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val);
-extern int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val);
-extern int sata_pmp_attach(struct ata_device *dev);
-
 /* libata-eh.c */
 extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
 extern void ata_scsi_error(struct Scsi_Host *host);
@@ -206,6 +201,11 @@ extern int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 			  struct ata_link **r_failed_disk);
 extern void ata_eh_finish(struct ata_port *ap);
 
+/* libata-pmp.c */
+extern int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val);
+extern int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val);
+extern int sata_pmp_attach(struct ata_device *dev);
+
 /* libata-sff.c */
 #ifdef CONFIG_ATA_SFF
 extern void ata_dev_select(struct ata_port *ap, unsigned int device,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 817ecd5..a1a9f3f 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1024,12 +1024,6 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
 #endif
 
 /*
- * PMP - drivers/ata/libata-pmp.c
- */
-extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
-extern void sata_pmp_error_handler(struct ata_port *ap);
-
-/*
  * EH - drivers/ata/libata-eh.c
  */
 extern void ata_port_schedule_eh(struct ata_port *ap);
@@ -1072,7 +1066,6 @@ extern void ata_std_error_handler(struct ata_port *ap);
  */
 extern const struct ata_port_operations ata_base_port_ops;
 extern const struct ata_port_operations sata_port_ops;
-extern const struct ata_port_operations sata_pmp_port_ops;
 
 #define ATA_BASE_SHT(drv_name)					\
 	.module			= THIS_MODULE,			\
@@ -1370,6 +1363,16 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
 	return *(struct ata_port **)&host->hostdata[0];
 }
 
+
+/**************************************************************************
+ * PMP - drivers/ata/libata-pmp.c
+ */
+extern const struct ata_port_operations sata_pmp_port_ops;
+
+extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
+extern void sata_pmp_error_handler(struct ata_port *ap);
+
+
 /**************************************************************************
  * SFF - drivers/ata/libata-sff.c
  */
-- 
1.5.2.4


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

* [PATCH 2/3] libata: implement PMP helpers
  2008-03-25 13:25 [PATCHSET #upstream] libata: modularize PMP support, take #1 Tejun Heo
  2008-03-25 13:25 ` [PATCH 1/3] libata: separate PMP support code from core code Tejun Heo
@ 2008-03-25 13:25 ` Tejun Heo
  2008-03-25 13:25 ` [PATCH 3/3] libata: make PMP support optional Tejun Heo
  2008-04-04  7:47 ` [PATCHSET #upstream] libata: modularize PMP support, take #1 Jeff Garzik
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2008-03-25 13:25 UTC (permalink / raw)
  To: jeff, linux-ide, liml; +Cc: Tejun Heo

Implement helpers to test whether PMP is supported, attached and
determine pmp number to use when issuing SRST to a link.  While at it,
move ata_is_host_link() so that it's together with the two new PMP
helpers.

This change simplifies LLDs and helps making PMP support optional.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 drivers/ata/ahci.c        |   30 ++++++------------------------
 drivers/ata/libata-acpi.c |    2 +-
 drivers/ata/libata-core.c |    4 ++--
 drivers/ata/libata-eh.c   |   14 +++++++-------
 drivers/ata/libata-pmp.c  |    6 +++---
 drivers/ata/libata-scsi.c |    6 +++---
 drivers/ata/sata_sil24.c  |   27 +++++++--------------------
 include/linux/libata.h    |   38 +++++++++++++++++++++++++++++---------
 8 files changed, 58 insertions(+), 69 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6281f7f..0de6432 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -260,8 +260,6 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
 				unsigned long deadline);
 static void ahci_postreset(struct ata_link *link, unsigned int *class);
-static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
-			      unsigned long deadline);
 static void ahci_error_handler(struct ata_port *ap);
 static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
 static int ahci_port_resume(struct ata_port *ap);
@@ -301,7 +299,7 @@ static struct ata_port_operations ahci_ops = {
 	.softreset		= ahci_softreset,
 	.hardreset		= ahci_hardreset,
 	.postreset		= ahci_postreset,
-	.pmp_softreset		= ahci_pmp_softreset,
+	.pmp_softreset		= ahci_softreset,
 	.error_handler		= ahci_error_handler,
 	.post_internal_cmd	= ahci_post_internal_cmd,
 	.dev_config		= ahci_dev_config,
@@ -1263,10 +1261,11 @@ static int ahci_check_ready(struct ata_link *link)
 	return 0;
 }
 
-static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
-			     int pmp, unsigned long deadline)
+static int ahci_softreset(struct ata_link *link, unsigned int *class,
+			  unsigned long deadline)
 {
 	struct ata_port *ap = link->ap;
+	int pmp = sata_srst_pmp(link);
 	const char *reason = NULL;
 	unsigned long now, msecs;
 	struct ata_taskfile tf;
@@ -1326,17 +1325,6 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
 	return rc;
 }
 
-static int ahci_softreset(struct ata_link *link, unsigned int *class,
-			  unsigned long deadline)
-{
-	int pmp = 0;
-
-	if (link->ap->flags & ATA_FLAG_PMP)
-		pmp = SATA_PMP_CTRL_PORT;
-
-	return ahci_do_softreset(link, class, pmp, deadline);
-}
-
 static int ahci_hardreset(struct ata_link *link, unsigned int *class,
 			  unsigned long deadline)
 {
@@ -1457,12 +1445,6 @@ static void ahci_postreset(struct ata_link *link, unsigned int *class)
 	}
 }
 
-static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
-			      unsigned long deadline)
-{
-	return ahci_do_softreset(link, class, link->pmp, deadline);
-}
-
 static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
 {
 	struct scatterlist *sg;
@@ -1581,7 +1563,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
 				  unk[0], unk[1], unk[2], unk[3]);
 	}
 
-	if (ap->nr_pmp_links && (irq_stat & PORT_IRQ_BAD_PMP)) {
+	if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) {
 		active_ehi->err_mask |= AC_ERR_HSM;
 		active_ehi->action |= ATA_EH_RESET;
 		ata_ehi_push_desc(active_ehi, "incorrect PMP");
@@ -1847,7 +1829,7 @@ static int ahci_port_resume(struct ata_port *ap)
 	ahci_power_up(ap);
 	ahci_start_port(ap);
 
-	if (ap->nr_pmp_links)
+	if (sata_pmp_attached(ap))
 		ahci_pmp_attach(ap);
 	else
 		ahci_pmp_detach(ap);
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index bf98a56..f88a4f9 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -77,7 +77,7 @@ void ata_acpi_associate_sata_port(struct ata_port *ap)
 {
 	WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA));
 
-	if (!ap->nr_pmp_links) {
+	if (!sata_pmp_attached(ap)) {
 		acpi_integer adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
 
 		ap->link.device->acpi_handle =
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 51d7959..7646523 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2240,7 +2240,7 @@ int ata_dev_configure(struct ata_device *dev)
 		 * changed notifications and ATAPI ANs.
 		 */
 		if ((ap->flags & ATA_FLAG_AN) && ata_id_has_atapi_AN(id) &&
-		    (!ap->nr_pmp_links ||
+		    (!sata_pmp_attached(ap) ||
 		     sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf) == 0)) {
 			unsigned int err_mask;
 
@@ -3585,7 +3585,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
 	if (online)
 		*online = true;
 
-	if ((link->ap->flags & ATA_FLAG_PMP) && ata_is_host_link(link)) {
+	if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) {
 		/* If PMP is supported, we have to do follow-up SRST.
 		 * Some PMPs don't send D2H Reg FIS after hardreset if
 		 * the first port is empty.  Wait only for
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index ebcd73f..53d6cde 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -873,9 +873,9 @@ int sata_async_notification(struct ata_port *ap)
 	if (rc == 0)
 		sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf);
 
-	if (!ap->nr_pmp_links || rc) {
+	if (!sata_pmp_attached(ap) || rc) {
 		/* PMP is not attached or SNTF is not available */
-		if (!ap->nr_pmp_links) {
+		if (!sata_pmp_attached(ap)) {
 			/* PMP is not attached.  Check whether ATAPI
 			 * AN is configured.  If so, notify media
 			 * change.
@@ -1848,7 +1848,7 @@ void ata_eh_autopsy(struct ata_port *ap)
 	/* Autopsy of fanout ports can affect host link autopsy.
 	 * Perform host link autopsy last.
 	 */
-	if (ap->nr_pmp_links)
+	if (sata_pmp_attached(ap))
 		ata_eh_link_autopsy(&ap->link);
 }
 
@@ -2071,7 +2071,7 @@ static int ata_eh_followup_srst_needed(struct ata_link *link,
 	}
 	if (rc != 0)
 		return 0;
-	if ((link->ap->flags & ATA_FLAG_PMP) && ata_is_host_link(link))
+	if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
 		return 1;
 	return 0;
 }
@@ -2663,7 +2663,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 		/* if PMP is attached, this function only deals with
 		 * downstream links, port should stay thawed.
 		 */
-		if (!ap->nr_pmp_links)
+		if (!sata_pmp_attached(ap))
 			ata_eh_freeze_port(ap);
 
 		ata_port_for_each_link(link, ap) {
@@ -2682,7 +2682,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 			}
 		}
 
-		if (!ap->nr_pmp_links)
+		if (!sata_pmp_attached(ap))
 			ata_eh_thaw_port(ap);
 	}
 
@@ -2726,7 +2726,7 @@ dev_fail:
 			/* PMP reset requires working host port.
 			 * Can't retry if it's frozen.
 			 */
-			if (ap->nr_pmp_links)
+			if (sata_pmp_attached(ap))
 				goto out;
 			break;
 		}
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index bb10c06..ff1822a 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -411,7 +411,7 @@ int sata_pmp_attach(struct ata_device *dev)
 	int rc;
 
 	/* is it hanging off the right place? */
-	if (!(ap->flags & ATA_FLAG_PMP)) {
+	if (!sata_pmp_supported(ap)) {
 		ata_dev_printk(dev, KERN_ERR,
 			       "host does not support Port Multiplier\n");
 		return -EINVAL;
@@ -876,7 +876,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
 
  retry:
 	/* PMP attached? */
-	if (!ap->nr_pmp_links) {
+	if (!sata_pmp_attached(ap)) {
 		rc = ata_eh_recover(ap, ops->prereset, ops->softreset,
 				    ops->hardreset, ops->postreset, NULL);
 		if (rc) {
@@ -983,7 +983,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
 	if (ap->pflags & ATA_PFLAG_UNLOADING)
 		return rc;
 
-	if (!ap->nr_pmp_links)
+	if (!sata_pmp_attached(ap))
 		goto retry;
 
 	if (--pmp_tries) {
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index a70881c..fedf62d 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2617,7 +2617,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
 
 static struct ata_device *ata_find_dev(struct ata_port *ap, int devno)
 {
-	if (ap->nr_pmp_links == 0) {
+	if (!sata_pmp_attached(ap)) {
 		if (likely(devno < ata_link_max_devices(&ap->link)))
 			return &ap->link.device[devno];
 	} else {
@@ -2634,7 +2634,7 @@ static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap,
 	int devno;
 
 	/* skip commands not addressed to targets we simulate */
-	if (ap->nr_pmp_links == 0) {
+	if (!sata_pmp_attached(ap)) {
 		if (unlikely(scsidev->channel || scsidev->lun))
 			return NULL;
 		devno = scsidev->id;
@@ -3492,7 +3492,7 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
 	if (lun != SCAN_WILD_CARD && lun)
 		return -EINVAL;
 
-	if (ap->nr_pmp_links == 0) {
+	if (!sata_pmp_attached(ap)) {
 		if (channel != SCAN_WILD_CARD && channel)
 			return -EINVAL;
 		devno = id;
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 6039614..0687893 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -354,8 +354,6 @@ static int sil24_softreset(struct ata_link *link, unsigned int *class,
 			   unsigned long deadline);
 static int sil24_hardreset(struct ata_link *link, unsigned int *class,
 			   unsigned long deadline);
-static int sil24_pmp_softreset(struct ata_link *link, unsigned int *class,
-			       unsigned long deadline);
 static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class,
 			       unsigned long deadline);
 static void sil24_error_handler(struct ata_port *ap);
@@ -408,7 +406,7 @@ static struct ata_port_operations sil24_ops = {
 	.thaw			= sil24_thaw,
 	.softreset		= sil24_softreset,
 	.hardreset		= sil24_hardreset,
-	.pmp_softreset		= sil24_pmp_softreset,
+	.pmp_softreset		= sil24_softreset,
 	.pmp_hardreset		= sil24_pmp_hardreset,
 	.error_handler		= sil24_error_handler,
 	.post_internal_cmd	= sil24_post_internal_cmd,
@@ -588,7 +586,7 @@ static int sil24_init_port(struct ata_port *ap)
 	u32 tmp;
 
 	/* clear PMP error status */
-	if (ap->nr_pmp_links)
+	if (sata_pmp_attached(ap))
 		sil24_clear_pmp(ap);
 
 	writel(PORT_CS_INIT, port + PORT_CTRL_STAT);
@@ -653,10 +651,11 @@ static int sil24_exec_polled_cmd(struct ata_port *ap, int pmp,
 	return rc;
 }
 
-static int sil24_do_softreset(struct ata_link *link, unsigned int *class,
-			      int pmp, unsigned long deadline)
+static int sil24_softreset(struct ata_link *link, unsigned int *class,
+			   unsigned long deadline)
 {
 	struct ata_port *ap = link->ap;
+	int pmp = sata_srst_pmp(link);
 	unsigned long timeout_msec = 0;
 	struct ata_taskfile tf;
 	const char *reason;
@@ -706,12 +705,6 @@ static int sil24_do_softreset(struct ata_link *link, unsigned int *class,
 	return -EIO;
 }
 
-static int sil24_softreset(struct ata_link *link, unsigned int *class,
-			   unsigned long deadline)
-{
-	return sil24_do_softreset(link, class, SATA_PMP_CTRL_PORT, deadline);
-}
-
 static int sil24_hardreset(struct ata_link *link, unsigned int *class,
 			   unsigned long deadline)
 {
@@ -926,12 +919,6 @@ static void sil24_pmp_detach(struct ata_port *ap)
 	sil24_config_pmp(ap, 0);
 }
 
-static int sil24_pmp_softreset(struct ata_link *link, unsigned int *class,
-			       unsigned long deadline)
-{
-	return sil24_do_softreset(link, class, link->pmp, deadline);
-}
-
 static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class,
 			       unsigned long deadline)
 {
@@ -1034,7 +1021,7 @@ static void sil24_error_intr(struct ata_port *ap)
 		}
 
 		/* find out the offending link and qc */
-		if (ap->nr_pmp_links) {
+		if (sata_pmp_attached(ap)) {
 			context = readl(port + PORT_CONTEXT);
 			pmp = (context >> 5) & 0xf;
 
@@ -1082,7 +1069,7 @@ static void sil24_error_intr(struct ata_port *ap)
 		ehi->action |= action;
 
 		/* if PMP, resume */
-		if (ap->nr_pmp_links)
+		if (sata_pmp_attached(ap))
 			writel(PORT_CS_PMP_RESUME, port + PORT_CTRL_STAT);
 	}
 
diff --git a/include/linux/libata.h b/include/linux/libata.h
index a1a9f3f..fd73f05 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1087,13 +1087,38 @@ extern const struct ata_port_operations sata_port_ops;
 	.change_queue_depth	= ata_scsi_change_queue_depth
 
 /*
+ * PMP helpers
+ */
+static inline bool sata_pmp_supported(struct ata_port *ap)
+{
+	return ap->flags & ATA_FLAG_PMP;
+}
+
+static inline bool sata_pmp_attached(struct ata_port *ap)
+{
+	return ap->nr_pmp_links != 0;
+}
+
+static inline int ata_is_host_link(const struct ata_link *link)
+{
+	return link == &link->ap->link;
+}
+
+static inline int sata_srst_pmp(struct ata_link *link)
+{
+	if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
+		return SATA_PMP_CTRL_PORT;
+	return link->pmp;
+}
+
+/*
  * printk helpers
  */
 #define ata_port_printk(ap, lv, fmt, args...) \
 	printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
 
 #define ata_link_printk(link, lv, fmt, args...) do { \
-	if ((link)->ap->nr_pmp_links) \
+	if (sata_pmp_attached((link)->ap)) \
 		printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id,	\
 		       (link)->pmp , ##args); \
 	else \
@@ -1179,11 +1204,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
 /*
  * link helpers
  */
-static inline int ata_is_host_link(const struct ata_link *link)
-{
-	return link == &link->ap->link;
-}
-
 static inline int ata_link_max_devices(const struct ata_link *link)
 {
 	if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
@@ -1198,7 +1218,7 @@ static inline int ata_link_active(struct ata_link *link)
 
 static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
 {
-	if (ap->nr_pmp_links)
+	if (sata_pmp_attached(ap))
 		return ap->pmp_link;
 	return &ap->link;
 }
@@ -1207,8 +1227,8 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
 {
 	struct ata_port *ap = link->ap;
 
-	if (link == &ap->link) {
-		if (!ap->nr_pmp_links)
+	if (ata_is_host_link(link)) {
+		if (!sata_pmp_attached(ap))
 			return NULL;
 		return ap->pmp_link;
 	}
-- 
1.5.2.4


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

* [PATCH 3/3] libata: make PMP support optional
  2008-03-25 13:25 [PATCHSET #upstream] libata: modularize PMP support, take #1 Tejun Heo
  2008-03-25 13:25 ` [PATCH 1/3] libata: separate PMP support code from core code Tejun Heo
  2008-03-25 13:25 ` [PATCH 2/3] libata: implement PMP helpers Tejun Heo
@ 2008-03-25 13:25 ` Tejun Heo
  2008-04-04  7:47 ` [PATCHSET #upstream] libata: modularize PMP support, take #1 Jeff Garzik
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2008-03-25 13:25 UTC (permalink / raw)
  To: jeff, linux-ide, liml; +Cc: Tejun Heo

Make PMP support optional by adding CONFIG_SATA_PMP and leaving out
libata-pmp.c if it isn't set.  PMP helpers return constant values if
PMP support is not enabled and PMP declarations alias non-PMP
counterparts.  This makes the compiler to leave out PMP related part
out and LLDs to use non-PMP counterparts automatically.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 drivers/ata/Kconfig    |    6 ++++++
 drivers/ata/Makefile   |    3 ++-
 drivers/ata/libata.h   |   17 +++++++++++++++++
 include/linux/libata.h |   27 +++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index a3fcc4b..6bbcb93 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -41,6 +41,12 @@ config ATA_ACPI
 	  You can disable this at kernel boot time by using the
 	  option libata.noacpi=1
 
+config SATA_PMP
+	bool "SATA Port Multiplier support"
+	default y
+	help
+	  This option adds support for SATA Port Multipliers.
+
 config SATA_AHCI
 	tristate "AHCI SATA support"
 	depends on PCI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index e6e41b2..1fbc2aa 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -78,6 +78,7 @@ obj-$(CONFIG_ATA_GENERIC)	+= ata_generic.o
 # Should be last libata driver
 obj-$(CONFIG_PATA_LEGACY)	+= pata_legacy.o
 
-libata-objs	:= libata-core.o libata-scsi.o libata-eh.o libata-pmp.o
+libata-objs	:= libata-core.o libata-scsi.o libata-eh.o
 libata-$(CONFIG_ATA_SFF)	+= libata-sff.o
+libata-$(CONFIG_SATA_PMP)	+= libata-pmp.o
 libata-$(CONFIG_ATA_ACPI)	+= libata-acpi.o
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index c6dbcfc..6b71341 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -202,9 +202,26 @@ extern int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 extern void ata_eh_finish(struct ata_port *ap);
 
 /* libata-pmp.c */
+#ifdef CONFIG_SATA_PMP
 extern int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val);
 extern int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val);
 extern int sata_pmp_attach(struct ata_device *dev);
+#else /* CONFIG_SATA_PMP */
+static inline int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *val)
+{
+	return -EINVAL;
+}
+
+static inline int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val)
+{
+	return -EINVAL;
+}
+
+static inline int sata_pmp_attach(struct ata_device *dev)
+{
+	return -EINVAL;
+}
+#endif /* CONFIG_SATA_PMP */
 
 /* libata-sff.c */
 #ifdef CONFIG_ATA_SFF
diff --git a/include/linux/libata.h b/include/linux/libata.h
index fd73f05..c4d6625 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1089,6 +1089,7 @@ extern const struct ata_port_operations sata_port_ops;
 /*
  * PMP helpers
  */
+#ifdef CONFIG_SATA_PMP
 static inline bool sata_pmp_supported(struct ata_port *ap)
 {
 	return ap->flags & ATA_FLAG_PMP;
@@ -1103,6 +1104,22 @@ static inline int ata_is_host_link(const struct ata_link *link)
 {
 	return link == &link->ap->link;
 }
+#else /* CONFIG_SATA_PMP */
+static inline bool sata_pmp_supported(struct ata_port *ap)
+{
+	return false;
+}
+
+static inline bool sata_pmp_attached(struct ata_port *ap)
+{
+	return false;
+}
+
+static inline int ata_is_host_link(const struct ata_link *link)
+{
+	return 1;
+}
+#endif /* CONFIG_SATA_PMP */
 
 static inline int sata_srst_pmp(struct ata_link *link)
 {
@@ -1387,11 +1404,21 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
 /**************************************************************************
  * PMP - drivers/ata/libata-pmp.c
  */
+#ifdef CONFIG_SATA_PMP
+
 extern const struct ata_port_operations sata_pmp_port_ops;
 
 extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
 extern void sata_pmp_error_handler(struct ata_port *ap);
 
+#else /* CONFIG_SATA_PMP */
+
+#define sata_pmp_port_ops		sata_port_ops
+#define sata_pmp_qc_defer_cmd_switch	ata_std_qc_defer
+#define sata_pmp_error_handler		ata_std_error_handler
+
+#endif /* CONFIG_SATA_PMP */
+
 
 /**************************************************************************
  * SFF - drivers/ata/libata-sff.c
-- 
1.5.2.4


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

* Re: [PATCHSET #upstream] libata: modularize PMP support, take #1
  2008-03-25 13:25 [PATCHSET #upstream] libata: modularize PMP support, take #1 Tejun Heo
                   ` (2 preceding siblings ...)
  2008-03-25 13:25 ` [PATCH 3/3] libata: make PMP support optional Tejun Heo
@ 2008-04-04  7:47 ` Jeff Garzik
  3 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2008-04-04  7:47 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, liml

Tejun Heo wrote:
> Hello, all.
> 
> This patchset modularizes PMP support and contains the following three
> patches.
> 
>   mails/0001-libata-separate-PMP-support-code-from-core-code.patch
>   mails/0002-libata-implement-PMP-helpers.patch
>   mails/0003-libata-make-PMP-support-optional.patch
> 
> LLDs which support PMP don't depend on PMP.  If PMP is turned on,
> those LLDs support PMP, if PMP is off, they don't.  The size of
> libata.ko on x86_64 w all debugging options off change like the
> following.
> 
> 		ON-DISK		LOADED
> +SFF+PMP	226k		157k
> +SFF-PMP	204k		141k
> -SFF+PMP	193k		133k
> -SFF-PMP	171k		117k
> 
> Both ahci and sata_sil24 have been verified to work w/ PMP turned on
> and off.
> 
> This patchset is on top of
> 
>   upstream-fixes (4cde32fc4b32e96a99063af3183acdfd54c563f0)
> + prefer-hardreset (990d6db0af21830681157317ab58c10f80277cb8)
> + cleanup-sht-ops (ed75ba53c883bc7a63fa1b60c63f33fcf395e751)
> + [1] cleanup-pdc_adma
> + [2] modularize-SFF-support patchset, take #1
> 
> This patchset is available as git tree.
> 
>   http://git.kernel.org/?p=linux/kernel/git/tj/libata-dev.git;a=shortlog;h=modularize-PMP
>   git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata-dev.git modularize-PMP

ACK patchset

will pull after a resync with #upstream



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

end of thread, other threads:[~2008-04-04  7:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-25 13:25 [PATCHSET #upstream] libata: modularize PMP support, take #1 Tejun Heo
2008-03-25 13:25 ` [PATCH 1/3] libata: separate PMP support code from core code Tejun Heo
2008-03-25 13:25 ` [PATCH 2/3] libata: implement PMP helpers Tejun Heo
2008-03-25 13:25 ` [PATCH 3/3] libata: make PMP support optional Tejun Heo
2008-04-04  7:47 ` [PATCHSET #upstream] libata: modularize PMP support, take #1 Jeff Garzik

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