Skip to content

Commit

Permalink
ata: make "libata.force" kernel parameter optional
Browse files Browse the repository at this point in the history
Add ATA_FORCE config option (visible only if EXPERT config
option is enabled) and make "libata.force" kernel parameter
optional.

Code size savings on m68k arch using (modified) atari_defconfig:

   text    data     bss     dec     hex filename
w/ CONFIG_ATA_FORCE=y:
  31983     572      40   32595    7f53 drivers/ata/libata-core.o
w/ CONFIG_ATA_FROCE=n:
  28958     316      32   29306    727a drivers/ata/libata-core.o

Suggested-by: Christoph Hellwig <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
bzolnier authored and axboe committed Mar 26, 2020
1 parent a0ccd25 commit bf89b0b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
16 changes: 16 additions & 0 deletions drivers/ata/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ config ATA_VERBOSE_ERROR

If unsure, say Y.

config ATA_FORCE
bool "\"libata.force=\" kernel parameter support" if EXPERT
default y
help
This option adds support for "libata.force=" kernel parameter for
forcing configuration settings.

For further information, please read
<file:Documentation/admin-guide/kernel-parameters.txt>.

This option will enlarge the kernel by approx. 3KB. Disable it if
kernel size is more important than ability to override the default
configuration settings.

If unsure, say Y.

config ATA_ACPI
bool "ATA ACPI Support"
depends on ACPI
Expand Down
22 changes: 20 additions & 2 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev);

atomic_t ata_print_id = ATOMIC_INIT(0);

#ifdef CONFIG_ATA_FORCE
struct ata_force_param {
const char *name;
u8 cbl;
Expand All @@ -112,6 +113,7 @@ static char ata_force_param_buf[COMMAND_LINE_SIZE] __initdata;
/* param_buf is thrown away after initialization, disallow read */
module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/admin-guide/kernel-parameters.rst for details)");
#endif

static int atapi_enabled = 1;
module_param(atapi_enabled, int, 0444);
Expand Down Expand Up @@ -303,6 +305,7 @@ struct ata_link *ata_dev_phys_link(struct ata_device *dev)
return ap->slave_link;
}

#ifdef CONFIG_ATA_FORCE
/**
* ata_force_cbl - force cable type according to libata.force
* @ap: ATA port of interest
Expand Down Expand Up @@ -483,6 +486,11 @@ static void ata_force_horkage(struct ata_device *dev)
fe->param.name);
}
}
#else
static inline void ata_force_link_limits(struct ata_link *link) { }
static inline void ata_force_xfermask(struct ata_device *dev) { }
static inline void ata_force_horkage(struct ata_device *dev) { }
#endif

/**
* atapi_cmd_type - Determine ATAPI command type from SCSI opcode
Expand Down Expand Up @@ -6080,6 +6088,7 @@ int ata_platform_remove_one(struct platform_device *pdev)
}
EXPORT_SYMBOL_GPL(ata_platform_remove_one);

#ifdef CONFIG_ATA_FORCE
static int __init ata_parse_force_one(char **cur,
struct ata_force_ent *force_ent,
const char **reason)
Expand Down Expand Up @@ -6259,6 +6268,15 @@ static void __init ata_parse_force_param(void)
ata_force_tbl_size = idx;
}

static void ata_free_force_param(void)
{
kfree(ata_force_tbl);
}
#else
static inline void ata_parse_force_param(void) { }
static inline void ata_free_force_param(void) { }
#endif

static int __init ata_init(void)
{
int rc;
Expand All @@ -6267,7 +6285,7 @@ static int __init ata_init(void)

rc = ata_sff_init();
if (rc) {
kfree(ata_force_tbl);
ata_free_force_param();
return rc;
}

Expand All @@ -6291,7 +6309,7 @@ static void __exit ata_exit(void)
ata_release_transport(ata_scsi_transport_template);
libata_transport_exit();
ata_sff_exit();
kfree(ata_force_tbl);
ata_free_force_param();
}

subsys_initcall(ata_init);
Expand Down
4 changes: 4 additions & 0 deletions drivers/ata/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ extern int libata_noacpi;
extern int libata_allow_tpm;
extern const struct device_type ata_port_type;
extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
#ifdef CONFIG_ATA_FORCE
extern void ata_force_cbl(struct ata_port *ap);
#else
static inline void ata_force_cbl(struct ata_port *ap) { }
#endif
extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
Expand Down

0 comments on commit bf89b0b

Please sign in to comment.