Subject: [PATCH v5 00/27] ata: optimize core code size on PATA only setups

Hi,

There have been reports in the past of libata core code size
being a problem in migration from deprecated IDE subsystem on
legacy PATA only systems, i.e.:

https://lore.kernel.org/linux-ide/[email protected]/

This patchset re-organizes libata core code to exclude SATA
specific code from being built for PATA only setups.

The end result is up to 24% (by 23949 bytes, from 101769 bytes to
77820 bytes) smaller libata core code size (as measured for m68k
arch using modified atari_defconfig) on affected setups.

I've tested this patchset using pata_falcon driver under ARAnyM
emulator.


patches #1-11 are general fixes/cleanups done in the process of
making the patchset (there should be no inter-dependencies between
them except patch #10 which depends on patch #9)

patch #12 separates PATA timings code to libata-pata-timings.c file

patches #13-15 let compiler optimize out SATA specific code on
non-SATA hosts by adding !IS_ENABLED(CONFIG_SATA_HOST) instances

patches #16-22 separate SATA only code from libata-core.c file to
libata-sata.c one

patches #23-24 separate SATA only code from libata-scsi.c file to
libata-sata.c one

patches #25-26 separate SATA only code from libata-eh.c file to
libata-sata.c one

patch #27 makes "libata.force" kernel parameter optional


Changes since v4
(https://lore.kernel.org/linux-ide/[email protected]/):
- rebased on top of next-20200326
- added Reviewed-by tags from Christoph

Changes since v3
(https://lore.kernel.org/linux-ide/[email protected]/):
- rebased on top of next-20200317
- fixed sdev_attrs initializer entry defined twice issue found by
kbuild-test-robot/sparse in "ata: expose ncq_enable_prio sysfs
attribute only on NCQ capable hosts" patch

Changes since v2
(https://lore.kernel.org/linux-ide/[email protected]/):
- rebased on top of next-20200227
- added "ata: optimize ata_scsi_rbuf[] size" patch

Changes since v1
(https://lore.kernel.org/linux-ide/[email protected]/):
- added Acked-by: tag from Tejun to "ata: remove stale maintainership
information from core code" patch
- added Reviewed-by: tag from Martin to "ata: make SATA_PMP option
selectable only if any SATA host driver is enabled" patch
- added Reviewed-by: tag from Christoph to following patches:
- "ata: simplify ata_scsiop_inq_89()"
- "ata: use COMMAND_LINE_SIZE for ata_force_param_buf[] size"
- "ata: optimize struct ata_force_param size"
- "ata: move EXPORT_SYMBOL_GPL()s close to exported code"
- "ata: remove EXPORT_SYMBOL_GPL()s not used by modules"
- converted "ata: add CONFIG_SATA_HOST=n version of ata_ncq_enabled()"
patch to use IS_ENABLED()
- added "ata: let compiler optimize out ata_dev_config_ncq() on
non-SATA hosts" and "ata: let compiler optimize out ata_eh_set_lpm()
on non-SATA hosts" patches
- moved "ata: move sata_scr_*() to libata-core-sata.c" patch just
after "ata: start separating SATA specific code from libata-core.c"
one
- dropped no longer needed patches (code savings <= 8 bytes):
- "ata: move ata_do_link_spd_horkage() to libata-core-sata.c"
- "ata: move ata_dev_config_ncq*() to libata-core-sata.c"
- "ata: move sata_print_link_status() to libata-core-sata.c"
- "ata: move sata_down_spd_limit() to libata-core-sata.c"
- "ata: move sata_link_init_spd() to libata-core-sata.c"
- "ata: move ata_eh_set_lpm() to libata-core-sata.c"
- removed superfluos ifdefs
- dropped file names in top of file headers
- merged libata-scsi-sata.c and libata-eh-sata.c into libata-sata.c
- emphasised in patch descriptions that atari_defconfig used for
measurements has been modified (original one is still using
deprecated IDE subsystem)
- added "ata: make "libata.force" kernel parameter optional" patch

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


Bartlomiej Zolnierkiewicz (27):
ata: remove stale maintainership information from core code
ata: expose ncq_enable_prio sysfs attribute only on NCQ capable hosts
ata: make SATA_PMP option selectable only if any SATA host driver is
enabled
sata_promise: use ata_cable_sata()
ata: simplify ata_scsiop_inq_89()
ata: use COMMAND_LINE_SIZE for ata_force_param_buf[] size
ata: optimize struct ata_force_param size
ata: optimize ata_scsi_rbuf[] size
ata: move EXPORT_SYMBOL_GPL()s close to exported code
ata: remove EXPORT_SYMBOL_GPL()s not used by modules
ata: fix CodingStyle issues in PATA timings code
ata: separate PATA timings code from libata-core.c
ata: add CONFIG_SATA_HOST=n version of ata_ncq_enabled()
ata: let compiler optimize out ata_dev_config_ncq() on non-SATA hosts
ata: let compiler optimize out ata_eh_set_lpm() on non-SATA hosts
ata: start separating SATA specific code from libata-core.c
ata: move sata_scr_*() to libata-sata.c
ata: move *sata_set_spd*() to libata-sata.c
ata: move sata_link_{debounce,resume}() to libata-sata.c
ata: move sata_link_hardreset() to libata-sata.c
ata: move ata_qc_complete_multiple() to libata-sata.c
ata: move sata_deb_timing_*() to libata-sata.c
ata: start separating SATA specific code from libata-scsi.c
ata: move ata_sas_*() to libata-sata.c
ata: start separating SATA specific code from libata-eh.c
ata: move ata_eh_analyze_ncq_error() & co. to libata-sata.c
ata: make "libata.force" kernel parameter optional

drivers/ata/Kconfig | 77 ++
drivers/ata/Makefile | 2 +
drivers/ata/libata-core.c | 1126 ++--------------------
drivers/ata/libata-eh.c | 224 +----
drivers/ata/libata-pata-timings.c | 192 ++++
drivers/ata/libata-sata.c | 1483 +++++++++++++++++++++++++++++
drivers/ata/libata-scsi.c | 544 +----------
drivers/ata/libata-sff.c | 4 -
drivers/ata/libata.h | 25 +-
drivers/ata/sata_promise.c | 8 +-
drivers/scsi/Kconfig | 1 +
drivers/scsi/libsas/Kconfig | 1 +
include/linux/libata.h | 172 ++--
13 files changed, 2015 insertions(+), 1844 deletions(-)
create mode 100644 drivers/ata/libata-pata-timings.c
create mode 100644 drivers/ata/libata-sata.c

--
2.24.1


Subject: [PATCH v5 04/27] sata_promise: use ata_cable_sata()

Use core helper instead of open-coding it.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
---
drivers/ata/sata_promise.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index c451d7d1c817..8729f78cef5f 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -157,7 +157,6 @@ static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class,
static void pdc_error_handler(struct ata_port *ap);
static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
static int pdc_pata_cable_detect(struct ata_port *ap);
-static int pdc_sata_cable_detect(struct ata_port *ap);

static struct scsi_host_template pdc_ata_sht = {
ATA_BASE_SHT(DRV_NAME),
@@ -183,7 +182,7 @@ static const struct ata_port_operations pdc_common_ops = {

static struct ata_port_operations pdc_sata_ops = {
.inherits = &pdc_common_ops,
- .cable_detect = pdc_sata_cable_detect,
+ .cable_detect = ata_cable_sata,
.freeze = pdc_sata_freeze,
.thaw = pdc_sata_thaw,
.scr_read = pdc_sata_scr_read,
@@ -459,11 +458,6 @@ static int pdc_pata_cable_detect(struct ata_port *ap)
return ATA_CBL_PATA80;
}

-static int pdc_sata_cable_detect(struct ata_port *ap)
-{
- return ATA_CBL_SATA;
-}
-
static int pdc_sata_scr_read(struct ata_link *link,
unsigned int sc_reg, u32 *val)
{
--
2.24.1

2020-03-26 16:30:02

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH v5 00/27] ata: optimize core code size on PATA only setups

On 3/26/20 9:57 AM, Bartlomiej Zolnierkiewicz wrote:
> Hi,
>
> There have been reports in the past of libata core code size
> being a problem in migration from deprecated IDE subsystem on
> legacy PATA only systems, i.e.:
>
> https://lore.kernel.org/linux-ide/[email protected]/
>
> This patchset re-organizes libata core code to exclude SATA
> specific code from being built for PATA only setups.
>
> The end result is up to 24% (by 23949 bytes, from 101769 bytes to
> 77820 bytes) smaller libata core code size (as measured for m68k
> arch using modified atari_defconfig) on affected setups.
>
> I've tested this patchset using pata_falcon driver under ARAnyM
> emulator.

Thanks, applied.

--
Jens Axboe