Skip to contentSkip to conversation

ata: add CONFIG_SATA_HOST config option

PATCH Superseded Bartlomiej Zolnierkiewicz 2 participants 2 messages Feb 9, 2011 libata

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: add CONFIG_SATA_HOST config option

Add CONFIG_SATA_HOST config option (for selecting SATA Host support) to make setup easier on PATA-only systems.

Additionally this allows us to save ~9.5k of the output code size (x86-64) on such systems:

text data bss dec hex filename

  49909    6576      57   56542    dcde drivers/ata/libata-core.o.before
  31862      16       2   31880    7c88 drivers/ata/libata-eh.o.before
  20256       0      19   20275    4f33 drivers/ata/libata-sff.o.before
  44495    6576      57   51128    c7b8 drivers/ata/libata-core.o.after
  27831      16       2   27849    6cc9 drivers/ata/libata-eh.o.after
  20144       0      19   20163    4ec3 drivers/ata/libata-sff.o.after

---
I also wonder if SATA code should be moved to libata-sata.c (to avoid ifdefs)?

 drivers/ata/Kconfig       |   25 ++++++++--
 drivers/ata/libata-core.c |  107 +++++++++++++++++++++++++++++++++++++++-------
 drivers/ata/libata-eh.c   |   21 ++++++++-
 drivers/ata/libata-sff.c  |    8 +++
 4 files changed, 141 insertions(+), 20 deletions(-)
drivers/ata/Kconfig +20 -5
Index: b/drivers/ata/Kconfig
===================================================================
@@ -50,13 +50,22 @@ config ATA_ACPI
 	  You can disable this at kernel boot time by using the
 	  option libata.noacpi=1
 
+config SATA_HOST
+	bool "SATA Host support"
+	default y
+	help
+	  This option adds support for SATA Hosts.
+
 config SATA_PMP
 	bool "SATA Port Multiplier support"
+	depends on SATA_HOST
 	default y
 	help
 	  This option adds support for SATA Port Multipliers
 	  (the SATA version of an ethernet hub, or SAS expander).
 
+if SATA_HOST
+
 comment "Controllers with non-SFF native interface"
 
 config SATA_AHCI
@@ -98,6 +107,8 @@ config SATA_SIL24
 
 	  If unsure, say N.
 
+endif # SATA_HOST
+
 config ATA_SFF
 	bool "ATA SFF support"
 	default y
@@ -122,7 +133,7 @@ comment "SFF controllers with custom DMA
 
 config PDC_ADMA
 	tristate "Pacific Digital ADMA support"
-	depends on PCI
+	depends on PCI && SATA_HOST
 	help
 	  This option enables support for Pacific Digital ADMA controllers
 
@@ -139,7 +150,7 @@ config PATA_OCTEON_CF
 
 config SATA_QSTOR
 	tristate "Pacific Digital SATA QStor support"
-	depends on PCI
+	depends on PCI && SATA_HOST
 	help
 	  This option enables support for Pacific Digital Serial ATA QStor.
 
@@ -147,7 +158,7 @@ config SATA_QSTOR
 
 config SATA_SX4
 	tristate "Promise SATA SX4 support (Experimental)"
-	depends on PCI && EXPERIMENTAL
+	depends on PCI && SATA_HOST && EXPERIMENTAL
 	help
 	  This option enables support for Promise Serial ATA SX4.
 
@@ -165,8 +176,6 @@ config ATA_BMDMA
 
 if ATA_BMDMA
 
-comment "SATA SFF controllers with BMDMA"
-
 config ATA_PIIX
 	tristate "Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support"
 	depends on PCI
@@ -177,6 +186,10 @@ config ATA_PIIX
 
 	  If unsure, say N.
 
+if SATA_HOST
+
+comment "SATA/PATA SFF controllers with BMDMA"
+
 config SATA_DWC
 	tristate "DesignWare Cores SATA support"
 	depends on 460EX
@@ -263,6 +276,8 @@ config SATA_VITESSE
 
 	  If unsure, say N.
 
+endif # SATA_HOST
+
 comment "PATA SFF controllers with BMDMA"
 
 config PATA_ALI
drivers/ata/libata-core.c +93 -14

269 lines not on this page · raw message

drivers/ata/libata-eh.c +20 -1
Index: b/drivers/ata/libata-eh.c
===================================================================
@@ -1080,6 +1080,7 @@ int ata_port_freeze(struct ata_port *ap)
 	return nr_aborted;
 }
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	sata_async_notification - SATA async notification handler
  *	@ap: ATA port where async notification is received
@@ -1152,6 +1153,8 @@ int sata_async_notification(struct ata_p
 		return 0;
 	}
 }
+EXPORT_SYMBOL_GPL(sata_async_notification);
+#endif
 
 /**
  *	ata_eh_freeze_port - EH helper to freeze port
@@ -1406,6 +1409,7 @@ static const char *ata_err_string(unsign
 	return "unknown error";
 }
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	ata_read_log_page - read a specific log page
  *	@dev: target device
@@ -1497,6 +1501,7 @@ static int ata_eh_read_log_10h(struct at
 
 	return 0;
 }
+#endif
 
 /**
  *	atapi_eh_tur - perform ATAPI TEST_UNIT_READY
@@ -1583,6 +1588,7 @@ static unsigned int atapi_eh_request_sen
 				 sense_buf, SCSI_SENSE_BUFFERSIZE, 0);
 }
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	ata_eh_analyze_serror - analyze SError for a failed port
  *	@link: ATA link to analyze SError for
@@ -1694,6 +1700,11 @@ void ata_eh_analyze_ncq_error(struct ata
 	qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
 	ehc->i.err_mask &= ~AC_ERR_DEV;
 }
+#else
+static void ata_eh_analyze_serror(struct ata_link *link) { }
+void ata_eh_analyze_ncq_error(struct ata_link *link) { }
+#endif
+EXPORT_SYMBOL_GPL(ata_eh_analyze_ncq_error);
 
 /**
  *	ata_eh_analyze_tf - analyze taskfile of a failed qc
@@ -2349,7 +2360,7 @@ static void ata_eh_link_report(struct at
 			ata_link_printk(link, KERN_ERR, "%s\n", desc);
 	}
 
-#ifdef CONFIG_ATA_VERBOSE_ERROR
+#if defined(CONFIG_SATA_HOST) && defined(CONFIG_ATA_VERBOSE_ERROR)
 	if (ehc->i.serror)
 		ata_link_printk(link, KERN_ERR,
 		  "SError: { %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}\n",
@@ -3252,6 +3263,7 @@ static int ata_eh_maybe_retry_flush(stru
 	return rc;
 }
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	ata_eh_set_lpm - configure SATA interface power management
  *	@link: link to configure power management
@@ -3380,6 +3392,13 @@ fail:
 		*r_failed_dev = dev;
 	return rc;
 }
+#else
+static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
+			  struct ata_device **r_failed_dev)
+{
+	return 0;
+}
+#endif
 
 static int ata_link_nr_enabled(struct ata_link *link)
 {
drivers/ata/libata-sff.c +8 -0
Index: b/drivers/ata/libata-sff.c
===================================================================
@@ -2061,6 +2061,7 @@ int ata_sff_softreset(struct ata_link *l
 }
 EXPORT_SYMBOL_GPL(ata_sff_softreset);
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	sata_sff_hardreset - reset host port via SATA phy reset
  *	@link: link to reset
@@ -2092,6 +2093,13 @@ int sata_sff_hardreset(struct ata_link *
 	DPRINTK("EXIT, class=%u\n", *class);
 	return rc;
 }
+#else
+int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
+		       unsigned long deadline)
+{
+	return -EOPNOTSUPP;
+}
+#endif
 EXPORT_SYMBOL_GPL(sata_sff_hardreset);
 
 /**
#1 lore raw

Hello.

Quoted 6 lines · Bartlomiej Zolnierkiewicz

Add CONFIG_SATA_HOST config option (for selecting SATA Host support) to make setup easier on PATA-only systems.

Additionally this allows us to save ~9.5k of the output code size (x86-64) on such systems:

Quoted 7 lines

text data bss dec hex filename

  49909    6576      57   56542    dcde drivers/ata/libata-core.o.before
  31862      16       2   31880    7c88 drivers/ata/libata-eh.o.before
  20256       0      19   20275    4f33 drivers/ata/libata-sff.o.before
  44495    6576      57   51128    c7b8 drivers/ata/libata-core.o.after
  27831      16       2   27849    6cc9 drivers/ata/libata-eh.o.after
  20144       0      19   20163    4ec3 drivers/ata/libata-sff.o.after

Good job!

Quoted 14 lines

---
I also wonder if SATA code should be moved to libata-sata.c (to avoid ifdefs)?

 drivers/ata/Kconfig       |   25 ++++++++--
 drivers/ata/libata-core.c |  107 +++++++++++++++++++++++++++++++++++++++-------
 drivers/ata/libata-eh.c   |   21 ++++++++-
 drivers/ata/libata-sff.c  |    8 +++
 4 files changed, 141 insertions(+), 20 deletions(-)

Index: b/drivers/ata/Kconfig
===================================================================

drivers/ata/Kconfig +0 -0

[...]

drivers/ata/Kconfig comment "SFF controllers with custom DMA · line 136

Quoted 6 lines
drivers/ata/Kconfig +1 -1
@@ -122,7 +133,7 @@ comment "SFF controllers with custom DMA
 
 config PDC_ADMA
 	tristate "Pacific Digital ADMA support"
-	depends on PCI
+	depends on PCI && SATA_HOST

I thought ADMA spec. was designed for PATA... are you sure this should
depend on CONFIG_SATA_HOST?

Quoted 10 lines
drivers/ata/Kconfig +0 -2
@@ -165,8 +176,6 @@ config ATA_BMDMA
 
 if ATA_BMDMA
 
-comment "SATA SFF controllers with BMDMA"
-
 config ATA_PIIX
 	tristate "Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support"
 	depends on PCI

drivers/ata/Kconfig config ATA_PIIX · line 191

Quoted 6 lines
drivers/ata/Kconfig +3 -0
@@ -177,6 +186,10 @@ config ATA_PIIX
 
 	  If unsure, say N.
 
+if SATA_HOST
+
+comment "SATA/PATA SFF controllers with BMDMA"

How it can be "SATA/PATA" if it's only enabled when CONFIG_SATA_HOST=y?

Quoted 4 lines

Index: b/drivers/ata/libata-core.c
===================================================================

drivers/ata/libata-core.c +0 -0

[...]

drivers/ata/libata-core.c void ata_tf_from_fis(const u8 *fis, stru · line 614

Quoted 7 lines
drivers/ata/libata-core.c +3 -0
@@ -601,6 +609,9 @@ void ata_tf_from_fis(const u8 *fis, stru
 	tf->nsect	= fis[12];
 	tf->hob_nsect	= fis[13];
 }
+#else
+void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf) { }
+#endif

Is it really ever called by non-SATA code? Ah, it's exported at end of file
and so should be defined... isn't it better to carry over the export from the bottom of the file (and thus silence one of checkpatch.pl's warnings :-).

Quoted 13 lines
drivers/ata/libata-core.c +2 -0
@@ -2690,6 +2718,7 @@ struct ata_device *ata_dev_pair(struct a
 	return pair;
 }
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	sata_down_spd_limit - adjust SATA spd limit downward
  *	@link: Link to adjust SATA spd limit for
@@ -2843,6 +2872,18 @@ int sata_set_spd(struct ata_link *link)
 
 	return 1;
 }
+#else

[...]

drivers/ata/libata-core.c int sata_set_spd(struct ata_link *link) · line 2884

Quoted 4 lines
drivers/ata/libata-core.c +4 -0
+int sata_set_spd(struct ata_link *link)
+{
+	return 0;
+}

Again, I don't think that's called by non-SATA code...

drivers/ata/libata-core.c int sata_set_spd(struct ata_link *link) · line 2886

Quoted 2 lines
drivers/ata/libata-core.c +2 -0
+#endif
+EXPORT_SYMBOL_GPL(sata_set_spd);

Here you're carrying over the export...

Quoted 9 lines
drivers/ata/libata-core.c +1 -0
@@ -3436,6 +3477,7 @@ int ata_wait_after_reset(struct ata_link
 	return ata_wait_ready(link, deadline, check_ready);
 }
 
+#ifdef CONFIG_SATA_HOST
 /**
  *	sata_link_debounce - debounce SATA phy status
  *	@link: ATA link to debounce SATA phy status for

drivers/ata/libata-core.c int sata_link_scr_lpm(struct ata_link *l · line 3688

Quoted 9 lines
drivers/ata/libata-core.c +6 -0
@@ -3638,6 +3680,26 @@ int sata_link_scr_lpm(struct ata_link *l
 	ehc->i.serror &= ~SERR_PHYRDY_CHG;
 	return sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG);
 }
+#else
+int sata_link_debounce(struct ata_link *link, const unsigned long *params,
+		       unsigned long deadline)
+{
+	return -EOPNOTSUPP;
+}

Again, not called by non-SATA code...

drivers/ata/libata-core.c int sata_link_scr_lpm(struct ata_link *l · line 3693

Quoted 5 lines
drivers/ata/libata-core.c +5 -0
+int sata_link_resume(struct ata_link *link, const unsigned long *params,
+		     unsigned long deadline)
+{
+	return -EOPNOTSUPP;
+}

This one is not called by non-SATA code now either...

WBR, Sergei