// SPDX-License-Identifier: GPL-2.0-or-later /* * libata-core.c - helper library for ATA * * Copyright 2003-2004 Red Hat, Inc. All rights reserved. * Copyright 2003-2004 Jeff Garzik * * libata documentation is available via 'make {ps|pdf}docs', * as Documentation/driver-api/libata.rst * * Hardware documentation available from http://www.t13.org/ and * http://www.sata-io.org/ * * Standards documents from: * http://www.t13.org (ATA standards, PCI DMA IDE spec) * http://www.t10.org (SCSI MMC - for ATAPI MMC) * http://www.sata-io.org (SATA) * http://www.compactflash.org (CF) * http://www.qic.org (QIC157 - Tape and DSC) * http://www.ce-ata.org (CE-ATA: not supported) * * libata is essentially a library of internal helper functions for * low-level ATA host controller drivers. As such, the API/ABI is * likely to change as new drivers are added and updated. * Do not depend on ABI/API stability. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/list.h> #include <linux/mm.h> #include <linux/spinlock.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/timer.h> #include <linux/time.h> #include <linux/interrupt.h> #include <linux/completion.h> #include <linux/suspend.h> #include <linux/workqueue.h> #include <linux/scatterlist.h> #include <linux/io.h> #include <linux/log2.h> #include <linux/slab.h> #include <linux/glob.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_host.h> #include <linux/libata.h> #include <asm/byteorder.h> #include <asm/unaligned.h> #include <linux/cdrom.h> #include <linux/ratelimit.h> #include <linux/leds.h> #include <linux/pm_runtime.h> #include <linux/platform_device.h> #include <asm/setup.h> #define CREATE_TRACE_POINTS #include <trace/events/libata.h> #include "libata.h" #include "libata-transport.h" const struct ata_port_operations ata_base_port_ops = …; const struct ata_port_operations sata_port_ops = …; EXPORT_SYMBOL_GPL(…); 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); static void ata_dev_xfermask(struct ata_device *dev); static unsigned long ata_dev_blacklisted(const struct ata_device *dev); static DEFINE_IDA(ata_ida); #ifdef CONFIG_ATA_FORCE struct ata_force_param { … }; struct ata_force_ent { … }; static struct ata_force_ent *ata_force_tbl; static int ata_force_tbl_size; static char ata_force_param_buf[COMMAND_LINE_SIZE] __initdata; /* param_buf is thrown away after initialization, disallow read */ module_param_string(…); MODULE_PARM_DESC(…) …; #endif static int atapi_enabled = …; module_param(atapi_enabled, int, 0444); MODULE_PARM_DESC(…) …; static int atapi_dmadir = …; module_param(atapi_dmadir, int, 0444); MODULE_PARM_DESC(…) …; int atapi_passthru16 = …; module_param(atapi_passthru16, int, 0444); MODULE_PARM_DESC(…) …; int libata_fua = …; module_param_named(fua, libata_fua, int, 0444); MODULE_PARM_DESC(…) …; static int ata_ignore_hpa; module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); MODULE_PARM_DESC(…) …; static int libata_dma_mask = …; module_param_named(dma, libata_dma_mask, int, 0444); MODULE_PARM_DESC(…) …; static int ata_probe_timeout; module_param(ata_probe_timeout, int, 0444); MODULE_PARM_DESC(…) …; int libata_noacpi = …; module_param_named(noacpi, libata_noacpi, int, 0444); MODULE_PARM_DESC(…) …; int libata_allow_tpm = …; module_param_named(allow_tpm, libata_allow_tpm, int, 0444); MODULE_PARM_DESC(…) …; static int atapi_an; module_param(atapi_an, int, 0444); MODULE_PARM_DESC(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; MODULE_VERSION(…); static inline bool ata_dev_print_info(struct ata_device *dev) { … } static bool ata_sstatus_online(u32 sstatus) { … } /** * ata_link_next - link iteration helper * @link: the previous link, NULL to start * @ap: ATA port containing links to iterate * @mode: iteration mode, one of ATA_LITER_* * * LOCKING: * Host lock or EH context. * * RETURNS: * Pointer to the next link. */ struct ata_link *ata_link_next(struct ata_link *link, struct ata_port *ap, enum ata_link_iter_mode mode) { … } EXPORT_SYMBOL_GPL(…); /** * ata_dev_next - device iteration helper * @dev: the previous device, NULL to start * @link: ATA link containing devices to iterate * @mode: iteration mode, one of ATA_DITER_* * * LOCKING: * Host lock or EH context. * * RETURNS: * Pointer to the next device. */ struct ata_device *ata_dev_next(struct ata_device *dev, struct ata_link *link, enum ata_dev_iter_mode mode) { … } EXPORT_SYMBOL_GPL(…); /** * ata_dev_phys_link - find physical link for a device * @dev: ATA device to look up physical link for * * Look up physical link which @dev is attached to. Note that * this is different from @dev->link only when @dev is on slave * link. For all other cases, it's the same as @dev->link. * * LOCKING: * Don't care. * * RETURNS: * Pointer to the found physical link. */ struct ata_link *ata_dev_phys_link(struct ata_device *dev) { … } #ifdef CONFIG_ATA_FORCE /** * ata_force_cbl - force cable type according to libata.force * @ap: ATA port of interest * * Force cable type according to libata.force and whine about it. * The last entry which has matching port number is used, so it * can be specified as part of device force parameters. For * example, both "a:40c,1.00:udma4" and "1.00:40c,udma4" have the * same effect. * * LOCKING: * EH context. */ void ata_force_cbl(struct ata_port *ap) { … } /** * ata_force_link_limits - force link limits according to libata.force * @link: ATA link of interest * * Force link flags and SATA spd limit according to libata.force * and whine about it. When only the port part is specified * (e.g. 1:), the limit applies to all links connected to both * the host link and all fan-out ports connected via PMP. If the * device part is specified as 0 (e.g. 1.00:), it specifies the * first fan-out link not the host link. Device number 15 always * points to the host link whether PMP is attached or not. If the * controller has slave link, device number 16 points to it. * * LOCKING: * EH context. */ static void ata_force_link_limits(struct ata_link *link) { … } /** * ata_force_xfermask - force xfermask according to libata.force * @dev: ATA device of interest * * Force xfer_mask according to libata.force and whine about it. * For consistency with link selection, device number 15 selects * the first device connected to the host link. * * LOCKING: * EH context. */ static void ata_force_xfermask(struct ata_device *dev) { … } /** * ata_force_horkage - force horkage according to libata.force * @dev: ATA device of interest * * Force horkage according to libata.force and whine about it. * For consistency with link selection, device number 15 selects * the first device connected to the host link. * * LOCKING: * EH context. */ static void ata_force_horkage(struct ata_device *dev) { … } #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 * @opcode: SCSI opcode * * Determine ATAPI command type from @opcode. * * LOCKING: * None. * * RETURNS: * ATAPI_{READ|WRITE|READ_CD|PASS_THRU|MISC} */ int atapi_cmd_type(u8 opcode) { … } EXPORT_SYMBOL_GPL(…); static const u8 ata_rw_cmds[] = …; /** * ata_set_rwcmd_protocol - set taskfile r/w command and protocol * @dev: target device for the taskfile * @tf: taskfile to examine and configure * * Examine the device configuration and tf->flags to determine * the proper read/write command and protocol to use for @tf. * * LOCKING: * caller. */ static bool ata_set_rwcmd_protocol(struct ata_device *dev, struct ata_taskfile *tf) { … } /** * ata_tf_read_block - Read block address from ATA taskfile * @tf: ATA taskfile of interest * @dev: ATA device @tf belongs to * * LOCKING: * None. * * Read block address from @tf. This function can handle all * three address formats - LBA, LBA48 and CHS. tf->protocol and * flags select the address format to use. * * RETURNS: * Block address read from @tf. */ u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev) { … } /* * Set a taskfile command duration limit index. */ static inline void ata_set_tf_cdl(struct ata_queued_cmd *qc, int cdl) { … } /** * ata_build_rw_tf - Build ATA taskfile for given read/write request * @qc: Metadata associated with the taskfile to build * @block: Block address * @n_block: Number of blocks * @tf_flags: RW/FUA etc... * @cdl: Command duration limit index * @class: IO priority class * * LOCKING: * None. * * Build ATA taskfile for the command @qc for read/write request described * by @block, @n_block, @tf_flags and @class. * * RETURNS: * * 0 on success, -ERANGE if the request is too large for @dev, * -EINVAL if the request is invalid. */ int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block, unsigned int tf_flags, int cdl, int class) { … } /** * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask * @pio_mask: pio_mask * @mwdma_mask: mwdma_mask * @udma_mask: udma_mask * * Pack @pio_mask, @mwdma_mask and @udma_mask into a single * unsigned int xfer_mask. * * LOCKING: * None. * * RETURNS: * Packed xfer_mask. */ unsigned int ata_pack_xfermask(unsigned int pio_mask, unsigned int mwdma_mask, unsigned int udma_mask) { … } EXPORT_SYMBOL_GPL(…); /** * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks * @xfer_mask: xfer_mask to unpack * @pio_mask: resulting pio_mask * @mwdma_mask: resulting mwdma_mask * @udma_mask: resulting udma_mask * * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask. * Any NULL destination masks will be ignored. */ void ata_unpack_xfermask(unsigned int xfer_mask, unsigned int *pio_mask, unsigned int *mwdma_mask, unsigned int *udma_mask) { … } static const struct ata_xfer_ent { … } ata_xfer_tbl[] = …; /** * ata_xfer_mask2mode - Find matching XFER_* for the given xfer_mask * @xfer_mask: xfer_mask of interest * * Return matching XFER_* value for @xfer_mask. Only the highest * bit of @xfer_mask is considered. * * LOCKING: * None. * * RETURNS: * Matching XFER_* value, 0xff if no match found. */ u8 ata_xfer_mask2mode(unsigned int xfer_mask) { … } EXPORT_SYMBOL_GPL(…); /** * ata_xfer_mode2mask - Find matching xfer_mask for XFER_* * @xfer_mode: XFER_* of interest * * Return matching xfer_mask for @xfer_mode. * * LOCKING: * None. * * RETURNS: * Matching xfer_mask, 0 if no match found. */ unsigned int ata_xfer_mode2mask(u8 xfer_mode) { … } EXPORT_SYMBOL_GPL(…); /** * ata_xfer_mode2shift - Find matching xfer_shift for XFER_* * @xfer_mode: XFER_* of interest * * Return matching xfer_shift for @xfer_mode. * * LOCKING: * None. * * RETURNS: * Matching xfer_shift, -1 if no match found. */ int ata_xfer_mode2shift(u8 xfer_mode) { … } EXPORT_SYMBOL_GPL(…); /** * ata_mode_string - convert xfer_mask to string * @xfer_mask: mask of bits supported; only highest bit counts. * * Determine string which represents the highest speed * (highest bit in @modemask). * * LOCKING: * None. * * RETURNS: * Constant C string representing highest speed listed in * @mode_mask, or the constant C string "<n/a>". */ const char *ata_mode_string(unsigned int xfer_mask) { … } EXPORT_SYMBOL_GPL(…); const char *sata_spd_string(unsigned int spd) { … } /** * ata_dev_classify - determine device type based on ATA-spec signature * @tf: ATA taskfile register set for device to be identified * * Determine from taskfile register contents whether a device is * ATA or ATAPI, as per "Signature and persistence" section * of ATA/PI spec (volume 1, sect 5.14). * * LOCKING: * None. * * RETURNS: * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP, * %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure. */ unsigned int ata_dev_classify(const struct ata_taskfile *tf) { … } EXPORT_SYMBOL_GPL(…); /** * ata_id_string - Convert IDENTIFY DEVICE page into string * @id: IDENTIFY DEVICE results we will examine * @s: string into which data is output * @ofs: offset into identify device page * @len: length of string to return. must be an even number. * * The strings in the IDENTIFY DEVICE page are broken up into * 16-bit chunks. Run through the string, and output each * 8-bit chunk linearly, regardless of platform. * * LOCKING: * caller. */ void ata_id_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len) { … } EXPORT_SYMBOL_GPL(…); /** * ata_id_c_string - Convert IDENTIFY DEVICE page into C string * @id: IDENTIFY DEVICE results we will examine * @s: string into which data is output * @ofs: offset into identify device page * @len: length of string to return. must be an odd number. * * This function is identical to ata_id_string except that it * trims trailing spaces and terminates the resulting string with * null. @len must be actual maximum length (even number) + 1. * * LOCKING: * caller. */ void ata_id_c_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len) { … } EXPORT_SYMBOL_GPL(…); static u64 ata_id_n_sectors(const u16 *id) { … } u64 ata_tf_to_lba48(const struct ata_taskfile *tf) { … } u64 ata_tf_to_lba(const struct ata_taskfile *tf) { … } /** * ata_read_native_max_address - Read native max address * @dev: target device * @max_sectors: out parameter for the result native max address * * Perform an LBA48 or LBA28 native size query upon the device in * question. * * RETURNS: * 0 on success, -EACCES if command is aborted by the drive. * -EIO on other errors. */ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors) { … } /** * ata_set_max_sectors - Set max sectors * @dev: target device * @new_sectors: new max sectors value to set for the device * * Set max sectors of @dev to @new_sectors. * * RETURNS: * 0 on success, -EACCES if command is aborted or denied (due to * previous non-volatile SET_MAX) by the drive. -EIO on other * errors. */ static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors) { … } /** * ata_hpa_resize - Resize a device with an HPA set * @dev: Device to resize * * Read the size of an LBA28 or LBA48 disk with HPA features and resize * it if required to the full size of the media. The caller must check * the drive has the HPA feature set enabled. * * RETURNS: * 0 on success, -errno on failure. */ static int ata_hpa_resize(struct ata_device *dev) { … } /** * ata_dump_id - IDENTIFY DEVICE info debugging output * @dev: device from which the information is fetched * @id: IDENTIFY DEVICE page to dump * * Dump selected 16-bit words from the given IDENTIFY DEVICE * page. * * LOCKING: * caller. */ static inline void ata_dump_id(struct ata_device *dev, const u16 *id) { … } /** * ata_id_xfermask - Compute xfermask from the given IDENTIFY data * @id: IDENTIFY data to compute xfer mask from * * Compute the xfermask for this device. This is not as trivial * as it seems if we must consider early devices correctly. * * FIXME: pre IDE drive timing (do we care ?). * * LOCKING: * None. * * RETURNS: * Computed xfermask */ unsigned int ata_id_xfermask(const u16 *id) { … } EXPORT_SYMBOL_GPL(…); static void ata_qc_complete_internal(struct ata_queued_cmd *qc) { … } /** * ata_exec_internal - execute libata internal command * @dev: Device to which the command is sent * @tf: Taskfile registers for the command and the result * @cdb: CDB for packet command * @dma_dir: Data transfer direction of the command * @buf: Data buffer of the command * @buflen: Length of data buffer * @timeout: Timeout in msecs (0 for default) * * Executes libata internal command with timeout. @tf contains * the command on entry and the result on return. Timeout and error * conditions are reported via the return value. No recovery action * is taken after a command times out. It is the caller's duty to * clean up after timeout. * * LOCKING: * None. Should be called with kernel context, might sleep. * * RETURNS: * Zero on success, AC_ERR_* mask on failure */ unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf, const u8 *cdb, enum dma_data_direction dma_dir, void *buf, unsigned int buflen, unsigned int timeout) { … } /** * ata_pio_need_iordy - check if iordy needed * @adev: ATA device * * Check if the current speed of the device requires IORDY. Used * by various controllers for chip configuration. */ unsigned int ata_pio_need_iordy(const struct ata_device *adev) { … } EXPORT_SYMBOL_GPL(…); /** * ata_pio_mask_no_iordy - Return the non IORDY mask * @adev: ATA device * * Compute the highest mode possible if we are not using iordy. Return * -1 if no iordy mode is available. */ static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) { … } /** * ata_do_dev_read_id - default ID read method * @dev: device * @tf: proposed taskfile * @id: data buffer * * Issue the identify taskfile and hand back the buffer containing * identify data. For some RAID controllers and for pre ATA devices * this function is wrapped or replaced by the driver */ unsigned int ata_do_dev_read_id(struct ata_device *dev, struct ata_taskfile *tf, __le16 *id) { … } EXPORT_SYMBOL_GPL(…); /** * ata_dev_read_id - Read ID data from the specified device * @dev: target device * @p_class: pointer to class of the target device (may be changed) * @flags: ATA_READID_* flags * @id: buffer to read IDENTIFY data into * * Read ID data from the specified device. ATA_CMD_ID_ATA is * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI * devices. This function also issues ATA_CMD_INIT_DEV_PARAMS * for pre-ATA4 drives. * * FIXME: ATA_CMD_ID_ATA is optional for early drives and right * now we abort if we hit that case. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * 0 on success, -errno otherwise. */ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, unsigned int flags, u16 *id) { … } bool ata_dev_power_init_tf(struct ata_device *dev, struct ata_taskfile *tf, bool set_active) { … } static bool ata_dev_power_is_active(struct ata_device *dev) { … } /** * ata_dev_power_set_standby - Set a device power mode to standby * @dev: target device * * Issue a STANDBY IMMEDIATE command to set a device power mode to standby. * For an HDD device, this spins down the disks. * * LOCKING: * Kernel thread context (may sleep). */ void ata_dev_power_set_standby(struct ata_device *dev) { … } /** * ata_dev_power_set_active - Set a device power mode to active * @dev: target device * * Issue a VERIFY command to enter to ensure that the device is in the * active power mode. For a spun-down HDD (standby or idle power mode), * the VERIFY command will complete after the disk spins up. * * LOCKING: * Kernel thread context (may sleep). */ void ata_dev_power_set_active(struct ata_device *dev) { … } /** * ata_read_log_page - read a specific log page * @dev: target device * @log: log to read * @page: page to read * @buf: buffer to store read page * @sectors: number of sectors to read * * Read log page using READ_LOG_EXT command. * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, AC_ERR_* mask otherwise. */ unsigned int ata_read_log_page(struct ata_device *dev, u8 log, u8 page, void *buf, unsigned int sectors) { … } static int ata_log_supported(struct ata_device *dev, u8 log) { … } static bool ata_identify_page_supported(struct ata_device *dev, u8 page) { … } static int ata_do_link_spd_horkage(struct ata_device *dev) { … } static inline u8 ata_dev_knobble(struct ata_device *dev) { … } static void ata_dev_config_ncq_send_recv(struct ata_device *dev) { … } static void ata_dev_config_ncq_non_data(struct ata_device *dev) { … } static void ata_dev_config_ncq_prio(struct ata_device *dev) { … } static bool ata_dev_check_adapter(struct ata_device *dev, unsigned short vendor_id) { … } static int ata_dev_config_ncq(struct ata_device *dev, char *desc, size_t desc_sz) { … } static void ata_dev_config_sense_reporting(struct ata_device *dev) { … } static void ata_dev_config_zac(struct ata_device *dev) { … } static void ata_dev_config_trusted(struct ata_device *dev) { … } static void ata_dev_config_cdl(struct ata_device *dev) { … } static int ata_dev_config_lba(struct ata_device *dev) { … } static void ata_dev_config_chs(struct ata_device *dev) { … } static void ata_dev_config_fua(struct ata_device *dev) { … } static void ata_dev_config_devslp(struct ata_device *dev) { … } static void ata_dev_config_cpr(struct ata_device *dev) { … } static void ata_dev_print_features(struct ata_device *dev) { … } /** * ata_dev_configure - Configure the specified ATA/ATAPI device * @dev: Target device to configure * * Configure @dev according to @dev->id. Generic and low-level * driver specific fixups are also applied. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * 0 on success, -errno otherwise */ int ata_dev_configure(struct ata_device *dev) { … } /** * ata_cable_40wire - return 40 wire cable type * @ap: port * * Helper method for drivers which want to hardwire 40 wire cable * detection. */ int ata_cable_40wire(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * ata_cable_80wire - return 80 wire cable type * @ap: port * * Helper method for drivers which want to hardwire 80 wire cable * detection. */ int ata_cable_80wire(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * ata_cable_unknown - return unknown PATA cable. * @ap: port * * Helper method for drivers which have no PATA cable detection. */ int ata_cable_unknown(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * ata_cable_ignore - return ignored PATA cable. * @ap: port * * Helper method for drivers which don't use cable type to limit * transfer mode. */ int ata_cable_ignore(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * ata_cable_sata - return SATA cable type * @ap: port * * Helper method for drivers which have SATA cables */ int ata_cable_sata(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * sata_print_link_status - Print SATA link status * @link: SATA link to printk link status about * * This function prints link speed and status of a SATA link. * * LOCKING: * None. */ static void sata_print_link_status(struct ata_link *link) { … } /** * ata_dev_pair - return other device on cable * @adev: device * * Obtain the other device on the same cable, or if none is * present NULL is returned */ struct ata_device *ata_dev_pair(struct ata_device *adev) { … } EXPORT_SYMBOL_GPL(…); /** * sata_down_spd_limit - adjust SATA spd limit downward * @link: Link to adjust SATA spd limit for * @spd_limit: Additional limit * * Adjust SATA spd limit of @link downward. Note that this * function only adjusts the limit. The change must be applied * using sata_set_spd(). * * If @spd_limit is non-zero, the speed is limited to equal to or * lower than @spd_limit if such speed is supported. If * @spd_limit is slower than any supported speed, only the lowest * supported speed is allowed. * * LOCKING: * Inherited from caller. * * RETURNS: * 0 on success, negative errno on failure */ int sata_down_spd_limit(struct ata_link *link, u32 spd_limit) { … } #ifdef CONFIG_ATA_ACPI /** * ata_timing_cycle2mode - find xfer mode for the specified cycle duration * @xfer_shift: ATA_SHIFT_* value for transfer type to examine. * @cycle: cycle duration in ns * * Return matching xfer mode for @cycle. The returned mode is of * the transfer type specified by @xfer_shift. If @cycle is too * slow for @xfer_shift, 0xff is returned. If @cycle is faster * than the fastest known mode, the fasted mode is returned. * * LOCKING: * None. * * RETURNS: * Matching xfer_mode, 0xff if no match found. */ u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle) { … } #endif /** * ata_down_xfermask_limit - adjust dev xfer masks downward * @dev: Device to adjust xfer masks * @sel: ATA_DNXFER_* selector * * Adjust xfer masks of @dev downward. Note that this function * does not apply the change. Invoking ata_set_mode() afterwards * will apply the limit. * * LOCKING: * Inherited from caller. * * RETURNS: * 0 on success, negative errno on failure */ int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel) { … } static int ata_dev_set_mode(struct ata_device *dev) { … } /** * ata_do_set_mode - Program timings and issue SET FEATURES - XFER * @link: link on which timings will be programmed * @r_failed_dev: out parameter for failed device * * Standard implementation of the function used to tune and set * ATA device disk transfer mode (PIO3, UDMA6, etc.). If * ata_dev_set_mode() fails, pointer to the failing device is * returned in @r_failed_dev. * * LOCKING: * PCI/etc. bus probe sem. * * RETURNS: * 0 on success, negative errno otherwise */ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) { … } EXPORT_SYMBOL_GPL(…); /** * ata_wait_ready - wait for link to become ready * @link: link to be waited on * @deadline: deadline jiffies for the operation * @check_ready: callback to check link readiness * * Wait for @link to become ready. @check_ready should return * positive number if @link is ready, 0 if it isn't, -ENODEV if * link doesn't seem to be occupied, other errno for other error * conditions. * * Transient -ENODEV conditions are allowed for * ATA_TMOUT_FF_WAIT. * * LOCKING: * EH context. * * RETURNS: * 0 if @link is ready before @deadline; otherwise, -errno. */ int ata_wait_ready(struct ata_link *link, unsigned long deadline, int (*check_ready)(struct ata_link *link)) { … } /** * ata_wait_after_reset - wait for link to become ready after reset * @link: link to be waited on * @deadline: deadline jiffies for the operation * @check_ready: callback to check link readiness * * Wait for @link to become ready after reset. * * LOCKING: * EH context. * * RETURNS: * 0 if @link is ready before @deadline; otherwise, -errno. */ int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, int (*check_ready)(struct ata_link *link)) { … } EXPORT_SYMBOL_GPL(…); /** * ata_std_prereset - prepare for reset * @link: ATA link to be reset * @deadline: deadline jiffies for the operation * * @link is about to be reset. Initialize it. Failure from * prereset makes libata abort whole reset sequence and give up * that port, so prereset should be best-effort. It does its * best to prepare for reset sequence but if things go wrong, it * should just whine, not fail. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * Always 0. */ int ata_std_prereset(struct ata_link *link, unsigned long deadline) { … } EXPORT_SYMBOL_GPL(…); /** * sata_std_hardreset - COMRESET w/o waiting or classification * @link: link to reset * @class: resulting class of attached device * @deadline: deadline jiffies for the operation * * Standard SATA COMRESET w/o waiting or classification. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * 0 if link offline, -EAGAIN if link online, -errno on errors. */ int sata_std_hardreset(struct ata_link *link, unsigned int *class, unsigned long deadline) { … } EXPORT_SYMBOL_GPL(…); /** * ata_std_postreset - standard postreset callback * @link: the target ata_link * @classes: classes of attached devices * * This function is invoked after a successful reset. Note that * the device might have been reset more than once using * different reset methods before postreset is invoked. * * LOCKING: * Kernel thread context (may sleep) */ void ata_std_postreset(struct ata_link *link, unsigned int *classes) { … } EXPORT_SYMBOL_GPL(…); /** * ata_dev_same_device - Determine whether new ID matches configured device * @dev: device to compare against * @new_class: class of the new device * @new_id: IDENTIFY page of the new device * * Compare @new_class and @new_id against @dev and determine * whether @dev is the device indicated by @new_class and * @new_id. * * LOCKING: * None. * * RETURNS: * 1 if @dev matches @new_class and @new_id, 0 otherwise. */ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, const u16 *new_id) { … } /** * ata_dev_reread_id - Re-read IDENTIFY data * @dev: target ATA device * @readid_flags: read ID flags * * Re-read IDENTIFY page and make sure @dev is still attached to * the port. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * 0 on success, negative errno otherwise */ int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags) { … } /** * ata_dev_revalidate - Revalidate ATA device * @dev: device to revalidate * @new_class: new class code * @readid_flags: read ID flags * * Re-read IDENTIFY page, make sure @dev is still attached to the * port and reconfigure it according to the new IDENTIFY page. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * 0 on success, negative errno otherwise */ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, unsigned int readid_flags) { … } struct ata_blacklist_entry { … }; static const struct ata_blacklist_entry ata_device_blacklist [] = …; static unsigned long ata_dev_blacklisted(const struct ata_device *dev) { … } static int ata_dma_blacklisted(const struct ata_device *dev) { … } /** * ata_is_40wire - check drive side detection * @dev: device * * Perform drive side detection decoding, allowing for device vendors * who can't follow the documentation. */ static int ata_is_40wire(struct ata_device *dev) { … } /** * cable_is_40wire - 40/80/SATA decider * @ap: port to consider * * This function encapsulates the policy for speed management * in one place. At the moment we don't cache the result but * there is a good case for setting ap->cbl to the result when * we are called with unknown cables (and figuring out if it * impacts hotplug at all). * * Return 1 if the cable appears to be 40 wire. */ static int cable_is_40wire(struct ata_port *ap) { … } /** * ata_dev_xfermask - Compute supported xfermask of the given device * @dev: Device to compute xfermask for * * Compute supported xfermask of @dev and store it in * dev->*_mask. This function is responsible for applying all * known limits including host controller limits, device * blacklist, etc... * * LOCKING: * None. */ static void ata_dev_xfermask(struct ata_device *dev) { … } /** * ata_dev_set_xfermode - Issue SET FEATURES - XFER MODE command * @dev: Device to which command will be sent * * Issue SET FEATURES - XFER MODE command to device @dev * on port @ap. * * LOCKING: * PCI/etc. bus probe sem. * * RETURNS: * 0 on success, AC_ERR_* mask otherwise. */ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) { … } /** * ata_dev_set_feature - Issue SET FEATURES * @dev: Device to which command will be sent * @subcmd: The SET FEATURES subcommand to be sent * @action: The sector count represents a subcommand specific action * * Issue SET FEATURES command to device @dev on port @ap with sector count * * LOCKING: * PCI/etc. bus probe sem. * * RETURNS: * 0 on success, AC_ERR_* mask otherwise. */ unsigned int ata_dev_set_feature(struct ata_device *dev, u8 subcmd, u8 action) { … } EXPORT_SYMBOL_GPL(…); /** * ata_dev_init_params - Issue INIT DEV PARAMS command * @dev: Device to which command will be sent * @heads: Number of heads (taskfile parameter) * @sectors: Number of sectors (taskfile parameter) * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * 0 on success, AC_ERR_* mask otherwise. */ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors) { … } /** * atapi_check_dma - Check whether ATAPI DMA can be supported * @qc: Metadata associated with taskfile to check * * Allow low-level driver to filter ATA PACKET commands, returning * a status indicating whether or not it is OK to use DMA for the * supplied PACKET command. * * LOCKING: * spin_lock_irqsave(host lock) * * RETURNS: 0 when ATAPI DMA can be used * nonzero otherwise */ int atapi_check_dma(struct ata_queued_cmd *qc) { … } /** * ata_std_qc_defer - Check whether a qc needs to be deferred * @qc: ATA command in question * * Non-NCQ commands cannot run with any other command, NCQ or * not. As upper layer only knows the queue depth, we are * responsible for maintaining exclusion. This function checks * whether a new command @qc can be issued. * * LOCKING: * spin_lock_irqsave(host lock) * * RETURNS: * ATA_DEFER_* if deferring is needed, 0 otherwise. */ int ata_std_qc_defer(struct ata_queued_cmd *qc) { … } EXPORT_SYMBOL_GPL(…); enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc) { … } EXPORT_SYMBOL_GPL(…); /** * ata_sg_init - Associate command with scatter-gather table. * @qc: Command to be associated * @sg: Scatter-gather table. * @n_elem: Number of elements in s/g table. * * Initialize the data-related elements of queued_cmd @qc * to point to a scatter-gather table @sg, containing @n_elem * elements. * * LOCKING: * spin_lock_irqsave(host lock) */ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, unsigned int n_elem) { … } #ifdef CONFIG_HAS_DMA /** * ata_sg_clean - Unmap DMA memory associated with command * @qc: Command containing DMA memory to be released * * Unmap all mapped DMA memory associated with this command. * * LOCKING: * spin_lock_irqsave(host lock) */ static void ata_sg_clean(struct ata_queued_cmd *qc) { … } /** * ata_sg_setup - DMA-map the scatter-gather table associated with a command. * @qc: Command with scatter-gather table to be mapped. * * DMA-map the scatter-gather table associated with queued_cmd @qc. * * LOCKING: * spin_lock_irqsave(host lock) * * RETURNS: * Zero on success, negative on error. * */ static int ata_sg_setup(struct ata_queued_cmd *qc) { … } #else /* !CONFIG_HAS_DMA */ static inline void ata_sg_clean(struct ata_queued_cmd *qc) {} static inline int ata_sg_setup(struct ata_queued_cmd *qc) { return -1; } #endif /* !CONFIG_HAS_DMA */ /** * swap_buf_le16 - swap halves of 16-bit words in place * @buf: Buffer to swap * @buf_words: Number of 16-bit words in buffer. * * Swap halves of 16-bit words if needed to convert from * little-endian byte order to native cpu byte order, or * vice-versa. * * LOCKING: * Inherited from caller. */ void swap_buf_le16(u16 *buf, unsigned int buf_words) { … } /** * ata_qc_free - free unused ata_queued_cmd * @qc: Command to complete * * Designed to free unused ata_queued_cmd object * in case something prevents using it. * * LOCKING: * spin_lock_irqsave(host lock) */ void ata_qc_free(struct ata_queued_cmd *qc) { … } void __ata_qc_complete(struct ata_queued_cmd *qc) { … } static void fill_result_tf(struct ata_queued_cmd *qc) { … } static void ata_verify_xfer(struct ata_queued_cmd *qc) { … } /** * ata_qc_complete - Complete an active ATA command * @qc: Command to complete * * Indicate to the mid and upper layers that an ATA command has * completed, with either an ok or not-ok status. * * Refrain from calling this function multiple times when * successfully completing multiple NCQ commands. * ata_qc_complete_multiple() should be used instead, which will * properly update IRQ expect state. * * LOCKING: * spin_lock_irqsave(host lock) */ void ata_qc_complete(struct ata_queued_cmd *qc) { … } EXPORT_SYMBOL_GPL(…); /** * ata_qc_get_active - get bitmask of active qcs * @ap: port in question * * LOCKING: * spin_lock_irqsave(host lock) * * RETURNS: * Bitmask of active qcs */ u64 ata_qc_get_active(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * ata_qc_issue - issue taskfile to device * @qc: command to issue to device * * Prepare an ATA command to submission to device. * This includes mapping the data into a DMA-able * area, filling in the S/G table, and finally * writing the taskfile to hardware, starting the command. * * LOCKING: * spin_lock_irqsave(host lock) */ void ata_qc_issue(struct ata_queued_cmd *qc) { … } /** * ata_phys_link_online - test whether the given link is online * @link: ATA link to test * * Test whether @link is online. Note that this function returns * 0 if online status of @link cannot be obtained, so * ata_link_online(link) != !ata_link_offline(link). * * LOCKING: * None. * * RETURNS: * True if the port online status is available and online. */ bool ata_phys_link_online(struct ata_link *link) { … } /** * ata_phys_link_offline - test whether the given link is offline * @link: ATA link to test * * Test whether @link is offline. Note that this function * returns 0 if offline status of @link cannot be obtained, so * ata_link_online(link) != !ata_link_offline(link). * * LOCKING: * None. * * RETURNS: * True if the port offline status is available and offline. */ bool ata_phys_link_offline(struct ata_link *link) { … } /** * ata_link_online - test whether the given link is online * @link: ATA link to test * * Test whether @link is online. This is identical to * ata_phys_link_online() when there's no slave link. When * there's a slave link, this function should only be called on * the master link and will return true if any of M/S links is * online. * * LOCKING: * None. * * RETURNS: * True if the port online status is available and online. */ bool ata_link_online(struct ata_link *link) { … } EXPORT_SYMBOL_GPL(…); /** * ata_link_offline - test whether the given link is offline * @link: ATA link to test * * Test whether @link is offline. This is identical to * ata_phys_link_offline() when there's no slave link. When * there's a slave link, this function should only be called on * the master link and will return true if both M/S links are * offline. * * LOCKING: * None. * * RETURNS: * True if the port offline status is available and offline. */ bool ata_link_offline(struct ata_link *link) { … } EXPORT_SYMBOL_GPL(…); #ifdef CONFIG_PM static void ata_port_request_pm(struct ata_port *ap, pm_message_t mesg, unsigned int action, unsigned int ehi_flags, bool async) { … } static void ata_port_suspend(struct ata_port *ap, pm_message_t mesg, bool async) { … } static int ata_port_pm_suspend(struct device *dev) { … } static int ata_port_pm_freeze(struct device *dev) { … } static int ata_port_pm_poweroff(struct device *dev) { … } static void ata_port_resume(struct ata_port *ap, pm_message_t mesg, bool async) { … } static int ata_port_pm_resume(struct device *dev) { … } /* * For ODDs, the upper layer will poll for media change every few seconds, * which will make it enter and leave suspend state every few seconds. And * as each suspend will cause a hard/soft reset, the gain of runtime suspend * is very little and the ODD may malfunction after constantly being reset. * So the idle callback here will not proceed to suspend if a non-ZPODD capable * ODD is attached to the port. */ static int ata_port_runtime_idle(struct device *dev) { … } static int ata_port_runtime_suspend(struct device *dev) { … } static int ata_port_runtime_resume(struct device *dev) { … } static const struct dev_pm_ops ata_port_pm_ops = …; /* sas ports don't participate in pm runtime management of ata_ports, * and need to resume ata devices at the domain level, not the per-port * level. sas suspend/resume is async to allow parallel port recovery * since sas has multiple ata_port instances per Scsi_Host. */ void ata_sas_port_suspend(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); void ata_sas_port_resume(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); /** * ata_host_suspend - suspend host * @host: host to suspend * @mesg: PM message * * Suspend @host. Actual operation is performed by port suspend. */ void ata_host_suspend(struct ata_host *host, pm_message_t mesg) { … } EXPORT_SYMBOL_GPL(…); /** * ata_host_resume - resume host * @host: host to resume * * Resume @host. Actual operation is performed by port resume. */ void ata_host_resume(struct ata_host *host) { … } EXPORT_SYMBOL_GPL(…); #endif const struct device_type ata_port_type = …; /** * ata_dev_init - Initialize an ata_device structure * @dev: Device structure to initialize * * Initialize @dev in preparation for probing. * * LOCKING: * Inherited from caller. */ void ata_dev_init(struct ata_device *dev) { … } /** * ata_link_init - Initialize an ata_link structure * @ap: ATA port link is attached to * @link: Link structure to initialize * @pmp: Port multiplier port number * * Initialize @link. * * LOCKING: * Kernel thread context (may sleep) */ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp) { … } /** * sata_link_init_spd - Initialize link->sata_spd_limit * @link: Link to configure sata_spd_limit for * * Initialize ``link->[hw_]sata_spd_limit`` to the currently * configured value. * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno on failure. */ int sata_link_init_spd(struct ata_link *link) { … } /** * ata_port_alloc - allocate and initialize basic ATA port resources * @host: ATA host this allocated port belongs to * * Allocate and initialize basic ATA port resources. * * RETURNS: * Allocate ATA port on success, NULL on failure. * * LOCKING: * Inherited from calling layer (may sleep). */ struct ata_port *ata_port_alloc(struct ata_host *host) { … } EXPORT_SYMBOL_GPL(…); void ata_port_free(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); static void ata_devres_release(struct device *gendev, void *res) { … } static void ata_host_release(struct kref *kref) { … } void ata_host_get(struct ata_host *host) { … } void ata_host_put(struct ata_host *host) { … } EXPORT_SYMBOL_GPL(…); /** * ata_host_alloc - allocate and init basic ATA host resources * @dev: generic device this host is associated with * @n_ports: the number of ATA ports associated with this host * * Allocate and initialize basic ATA host resources. LLD calls * this function to allocate a host, initializes it fully and * attaches it using ata_host_register(). * * RETURNS: * Allocate ATA host on success, NULL on failure. * * LOCKING: * Inherited from calling layer (may sleep). */ struct ata_host *ata_host_alloc(struct device *dev, int n_ports) { … } EXPORT_SYMBOL_GPL(…); /** * ata_host_alloc_pinfo - alloc host and init with port_info array * @dev: generic device this host is associated with * @ppi: array of ATA port_info to initialize host with * @n_ports: number of ATA ports attached to this host * * Allocate ATA host and initialize with info from @ppi. If NULL * terminated, @ppi may contain fewer entries than @n_ports. The * last entry will be used for the remaining ports. * * RETURNS: * Allocate ATA host on success, NULL on failure. * * LOCKING: * Inherited from calling layer (may sleep). */ struct ata_host *ata_host_alloc_pinfo(struct device *dev, const struct ata_port_info * const * ppi, int n_ports) { … } EXPORT_SYMBOL_GPL(…); static void ata_host_stop(struct device *gendev, void *res) { … } /** * ata_finalize_port_ops - finalize ata_port_operations * @ops: ata_port_operations to finalize * * An ata_port_operations can inherit from another ops and that * ops can again inherit from another. This can go on as many * times as necessary as long as there is no loop in the * inheritance chain. * * Ops tables are finalized when the host is started. NULL or * unspecified entries are inherited from the closet ancestor * which has the method and the entry is populated with it. * After finalization, the ops table directly points to all the * methods and ->inherits is no longer necessary and cleared. * * Using ATA_OP_NULL, inheriting ops can force a method to NULL. * * LOCKING: * None. */ static void ata_finalize_port_ops(struct ata_port_operations *ops) { … } /** * ata_host_start - start and freeze ports of an ATA host * @host: ATA host to start ports for * * Start and then freeze ports of @host. Started status is * recorded in host->flags, so this function can be called * multiple times. Ports are guaranteed to get started only * once. If host->ops is not initialized yet, it is set to the * first non-dummy port ops. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: * 0 if all ports are started successfully, -errno otherwise. */ int ata_host_start(struct ata_host *host) { … } EXPORT_SYMBOL_GPL(…); /** * ata_host_init - Initialize a host struct for sas (ipr, libsas) * @host: host to initialize * @dev: device host is attached to * @ops: port_ops * */ void ata_host_init(struct ata_host *host, struct device *dev, struct ata_port_operations *ops) { … } EXPORT_SYMBOL_GPL(…); void ata_port_probe(struct ata_port *ap) { … } EXPORT_SYMBOL_GPL(…); static void async_port_probe(void *data, async_cookie_t cookie) { … } /** * ata_host_register - register initialized ATA host * @host: ATA host to register * @sht: template for SCSI host * * Register initialized ATA host. @host is allocated using * ata_host_alloc() and fully initialized by LLD. This function * starts ports, registers @host with ATA and SCSI layers and * probe registered devices. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: * 0 on success, -errno otherwise. */ int ata_host_register(struct ata_host *host, const struct scsi_host_template *sht) { … } EXPORT_SYMBOL_GPL(…); /** * ata_host_activate - start host, request IRQ and register it * @host: target ATA host * @irq: IRQ to request * @irq_handler: irq_handler used when requesting IRQ * @irq_flags: irq_flags used when requesting IRQ * @sht: scsi_host_template to use when registering the host * * After allocating an ATA host and initializing it, most libata * LLDs perform three steps to activate the host - start host, * request IRQ and register it. This helper takes necessary * arguments and performs the three steps in one go. * * An invalid IRQ skips the IRQ registration and expects the host to * have set polling mode on the port. In this case, @irq_handler * should be NULL. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: * 0 on success, -errno otherwise. */ int ata_host_activate(struct ata_host *host, int irq, irq_handler_t irq_handler, unsigned long irq_flags, const struct scsi_host_template *sht) { … } EXPORT_SYMBOL_GPL(…); /** * ata_port_detach - Detach ATA port in preparation of device removal * @ap: ATA port to be detached * * Detach all ATA devices and the associated SCSI devices of @ap; * then, remove the associated SCSI host. @ap is guaranteed to * be quiescent on return from this function. * * LOCKING: * Kernel thread context (may sleep). */ static void ata_port_detach(struct ata_port *ap) { … } /** * ata_host_detach - Detach all ports of an ATA host * @host: Host to detach * * Detach all ports of @host. * * LOCKING: * Kernel thread context (may sleep). */ void ata_host_detach(struct ata_host *host) { … } EXPORT_SYMBOL_GPL(…); #ifdef CONFIG_PCI /** * ata_pci_remove_one - PCI layer callback for device removal * @pdev: PCI device that was removed * * PCI layer indicates to libata via this hook that hot-unplug or * module unload event has occurred. Detach all ports. Resource * release is handled via devres. * * LOCKING: * Inherited from PCI layer (may sleep). */ void ata_pci_remove_one(struct pci_dev *pdev) { … } EXPORT_SYMBOL_GPL(…); void ata_pci_shutdown_one(struct pci_dev *pdev) { … } EXPORT_SYMBOL_GPL(…); /* move to PCI subsystem */ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) { … } EXPORT_SYMBOL_GPL(…); #ifdef CONFIG_PM void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg) { … } EXPORT_SYMBOL_GPL(…); int ata_pci_device_do_resume(struct pci_dev *pdev) { … } EXPORT_SYMBOL_GPL(…); int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) { … } EXPORT_SYMBOL_GPL(…); int ata_pci_device_resume(struct pci_dev *pdev) { … } EXPORT_SYMBOL_GPL(…); #endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ /** * ata_platform_remove_one - Platform layer callback for device removal * @pdev: Platform device that was removed * * Platform layer indicates to libata via this hook that hot-unplug or * module unload event has occurred. Detach all ports. Resource * release is handled via devres. * * LOCKING: * Inherited from platform layer (may sleep). */ void ata_platform_remove_one(struct platform_device *pdev) { … } EXPORT_SYMBOL_GPL(…); #ifdef CONFIG_ATA_FORCE #define force_cbl(name, flag) … #define force_spd_limit(spd, val) … #define force_xfer(mode, shift) … #define force_lflag_on(name, flags) … #define force_lflag_onoff(name, flags) … #define force_horkage_on(name, flag) … #define force_horkage_onoff(name, flag) … static const struct ata_force_param force_tbl[] __initconst = …; static int __init ata_parse_force_one(char **cur, struct ata_force_ent *force_ent, const char **reason) { … } static void __init ata_parse_force_param(void) { … } static void ata_free_force_param(void) { … } #else static inline void ata_parse_force_param(void) { } static inline void ata_free_force_param(void) { } #endif static int __init ata_init(void) { … } static void __exit ata_exit(void) { … } subsys_initcall(ata_init); module_exit(ata_exit); static DEFINE_RATELIMIT_STATE(ratelimit, HZ / 5, 1); int ata_ratelimit(void) { … } EXPORT_SYMBOL_GPL(…); /** * ata_msleep - ATA EH owner aware msleep * @ap: ATA port to attribute the sleep to * @msecs: duration to sleep in milliseconds * * Sleeps @msecs. If the current task is owner of @ap's EH, the * ownership is released before going to sleep and reacquired * after the sleep is complete. IOW, other ports sharing the * @ap->host will be allowed to own the EH while this task is * sleeping. * * LOCKING: * Might sleep. */ void ata_msleep(struct ata_port *ap, unsigned int msecs) { … } EXPORT_SYMBOL_GPL(…); /** * ata_wait_register - wait until register value changes * @ap: ATA port to wait register for, can be NULL * @reg: IO-mapped register * @mask: Mask to apply to read register value * @val: Wait condition * @interval: polling interval in milliseconds * @timeout: timeout in milliseconds * * Waiting for some bits of register to change is a common * operation for ATA controllers. This function reads 32bit LE * IO-mapped register @reg and tests for the following condition. * * (*@reg & mask) != val * * If the condition is met, it returns; otherwise, the process is * repeated after @interval_msec until timeout. * * LOCKING: * Kernel thread context (may sleep) * * RETURNS: * The final register value. */ u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask, u32 val, unsigned int interval, unsigned int timeout) { … } EXPORT_SYMBOL_GPL(…); /* * Dummy port_ops */ static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc) { … } static void ata_dummy_error_handler(struct ata_port *ap) { … } struct ata_port_operations ata_dummy_port_ops = …; EXPORT_SYMBOL_GPL(…); const struct ata_port_info ata_dummy_port_info = …; EXPORT_SYMBOL_GPL(…); void ata_print_version(const struct device *dev, const char *version) { … } EXPORT_SYMBOL(…); EXPORT_TRACEPOINT_SYMBOL_GPL(…); EXPORT_TRACEPOINT_SYMBOL_GPL(…); EXPORT_TRACEPOINT_SYMBOL_GPL(…); EXPORT_TRACEPOINT_SYMBOL_GPL(…); EXPORT_TRACEPOINT_SYMBOL_GPL(…);