| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * libata-core.c - helper library for ATA |
|---|
| 3 | 4 | * |
|---|
| 4 | | - * Maintained by: Tejun Heo <tj@kernel.org> |
|---|
| 5 | | - * Please ALWAYS copy linux-ide@vger.kernel.org |
|---|
| 6 | | - * on emails. |
|---|
| 7 | | - * |
|---|
| 8 | 5 | * Copyright 2003-2004 Red Hat, Inc. All rights reserved. |
|---|
| 9 | 6 | * Copyright 2003-2004 Jeff Garzik |
|---|
| 10 | | - * |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 14 | | - * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 15 | | - * any later version. |
|---|
| 16 | | - * |
|---|
| 17 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | | - * GNU General Public License for more details. |
|---|
| 21 | | - * |
|---|
| 22 | | - * You should have received a copy of the GNU General Public License |
|---|
| 23 | | - * along with this program; see the file COPYING. If not, write to |
|---|
| 24 | | - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 25 | | - * |
|---|
| 26 | 7 | * |
|---|
| 27 | 8 | * libata documentation is available via 'make {ps|pdf}docs', |
|---|
| 28 | 9 | * as Documentation/driver-api/libata.rst |
|---|
| .. | .. |
|---|
| 38 | 19 | * http://www.qic.org (QIC157 - Tape and DSC) |
|---|
| 39 | 20 | * http://www.ce-ata.org (CE-ATA: not supported) |
|---|
| 40 | 21 | * |
|---|
| 22 | + * libata is essentially a library of internal helper functions for |
|---|
| 23 | + * low-level ATA host controller drivers. As such, the API/ABI is |
|---|
| 24 | + * likely to change as new drivers are added and updated. |
|---|
| 25 | + * Do not depend on ABI/API stability. |
|---|
| 41 | 26 | */ |
|---|
| 42 | 27 | |
|---|
| 43 | 28 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 71 | 56 | #include <linux/leds.h> |
|---|
| 72 | 57 | #include <linux/pm_runtime.h> |
|---|
| 73 | 58 | #include <linux/platform_device.h> |
|---|
| 59 | +#include <asm/setup.h> |
|---|
| 74 | 60 | |
|---|
| 75 | 61 | #define CREATE_TRACE_POINTS |
|---|
| 76 | 62 | #include <trace/events/libata.h> |
|---|
| 77 | 63 | |
|---|
| 78 | 64 | #include "libata.h" |
|---|
| 79 | 65 | #include "libata-transport.h" |
|---|
| 80 | | - |
|---|
| 81 | | -/* debounce timing parameters in msecs { interval, duration, timeout } */ |
|---|
| 82 | | -const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 }; |
|---|
| 83 | | -const unsigned long sata_deb_timing_hotplug[] = { 25, 500, 2000 }; |
|---|
| 84 | | -const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; |
|---|
| 85 | 66 | |
|---|
| 86 | 67 | const struct ata_port_operations ata_base_port_ops = { |
|---|
| 87 | 68 | .prereset = ata_std_prereset, |
|---|
| .. | .. |
|---|
| 97 | 78 | .qc_defer = ata_std_qc_defer, |
|---|
| 98 | 79 | .hardreset = sata_std_hardreset, |
|---|
| 99 | 80 | }; |
|---|
| 81 | +EXPORT_SYMBOL_GPL(sata_port_ops); |
|---|
| 100 | 82 | |
|---|
| 101 | 83 | static unsigned int ata_dev_init_params(struct ata_device *dev, |
|---|
| 102 | 84 | u16 heads, u16 sectors); |
|---|
| .. | .. |
|---|
| 106 | 88 | |
|---|
| 107 | 89 | atomic_t ata_print_id = ATOMIC_INIT(0); |
|---|
| 108 | 90 | |
|---|
| 91 | +#ifdef CONFIG_ATA_FORCE |
|---|
| 109 | 92 | struct ata_force_param { |
|---|
| 110 | 93 | const char *name; |
|---|
| 111 | | - unsigned int cbl; |
|---|
| 112 | | - int spd_limit; |
|---|
| 94 | + u8 cbl; |
|---|
| 95 | + u8 spd_limit; |
|---|
| 113 | 96 | unsigned long xfer_mask; |
|---|
| 114 | 97 | unsigned int horkage_on; |
|---|
| 115 | 98 | unsigned int horkage_off; |
|---|
| 116 | | - unsigned int lflags; |
|---|
| 99 | + u16 lflags; |
|---|
| 117 | 100 | }; |
|---|
| 118 | 101 | |
|---|
| 119 | 102 | struct ata_force_ent { |
|---|
| .. | .. |
|---|
| 125 | 108 | static struct ata_force_ent *ata_force_tbl; |
|---|
| 126 | 109 | static int ata_force_tbl_size; |
|---|
| 127 | 110 | |
|---|
| 128 | | -static char ata_force_param_buf[PAGE_SIZE] __initdata; |
|---|
| 111 | +static char ata_force_param_buf[COMMAND_LINE_SIZE] __initdata; |
|---|
| 129 | 112 | /* param_buf is thrown away after initialization, disallow read */ |
|---|
| 130 | 113 | module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0); |
|---|
| 131 | 114 | MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/admin-guide/kernel-parameters.rst for details)"); |
|---|
| 115 | +#endif |
|---|
| 132 | 116 | |
|---|
| 133 | 117 | static int atapi_enabled = 1; |
|---|
| 134 | 118 | module_param(atapi_enabled, int, 0444); |
|---|
| .. | .. |
|---|
| 206 | 190 | case ATA_LITER_PMP_FIRST: |
|---|
| 207 | 191 | if (sata_pmp_attached(ap)) |
|---|
| 208 | 192 | return ap->pmp_link; |
|---|
| 209 | | - /* fall through */ |
|---|
| 193 | + fallthrough; |
|---|
| 210 | 194 | case ATA_LITER_HOST_FIRST: |
|---|
| 211 | 195 | return &ap->link; |
|---|
| 212 | 196 | } |
|---|
| .. | .. |
|---|
| 217 | 201 | case ATA_LITER_HOST_FIRST: |
|---|
| 218 | 202 | if (sata_pmp_attached(ap)) |
|---|
| 219 | 203 | return ap->pmp_link; |
|---|
| 220 | | - /* fall through */ |
|---|
| 204 | + fallthrough; |
|---|
| 221 | 205 | case ATA_LITER_PMP_FIRST: |
|---|
| 222 | 206 | if (unlikely(ap->slave_link)) |
|---|
| 223 | 207 | return ap->slave_link; |
|---|
| 224 | | - /* fall through */ |
|---|
| 208 | + fallthrough; |
|---|
| 225 | 209 | case ATA_LITER_EDGE: |
|---|
| 226 | 210 | return NULL; |
|---|
| 227 | 211 | } |
|---|
| .. | .. |
|---|
| 239 | 223 | |
|---|
| 240 | 224 | return NULL; |
|---|
| 241 | 225 | } |
|---|
| 226 | +EXPORT_SYMBOL_GPL(ata_link_next); |
|---|
| 242 | 227 | |
|---|
| 243 | 228 | /** |
|---|
| 244 | 229 | * ata_dev_next - device iteration helper |
|---|
| .. | .. |
|---|
| 292 | 277 | goto next; |
|---|
| 293 | 278 | return dev; |
|---|
| 294 | 279 | } |
|---|
| 280 | +EXPORT_SYMBOL_GPL(ata_dev_next); |
|---|
| 295 | 281 | |
|---|
| 296 | 282 | /** |
|---|
| 297 | 283 | * ata_dev_phys_link - find physical link for a device |
|---|
| .. | .. |
|---|
| 318 | 304 | return ap->slave_link; |
|---|
| 319 | 305 | } |
|---|
| 320 | 306 | |
|---|
| 307 | +#ifdef CONFIG_ATA_FORCE |
|---|
| 321 | 308 | /** |
|---|
| 322 | 309 | * ata_force_cbl - force cable type according to libata.force |
|---|
| 323 | 310 | * @ap: ATA port of interest |
|---|
| .. | .. |
|---|
| 498 | 485 | fe->param.name); |
|---|
| 499 | 486 | } |
|---|
| 500 | 487 | } |
|---|
| 488 | +#else |
|---|
| 489 | +static inline void ata_force_link_limits(struct ata_link *link) { } |
|---|
| 490 | +static inline void ata_force_xfermask(struct ata_device *dev) { } |
|---|
| 491 | +static inline void ata_force_horkage(struct ata_device *dev) { } |
|---|
| 492 | +#endif |
|---|
| 501 | 493 | |
|---|
| 502 | 494 | /** |
|---|
| 503 | 495 | * atapi_cmd_type - Determine ATAPI command type from SCSI opcode |
|---|
| .. | .. |
|---|
| 531 | 523 | case ATA_12: |
|---|
| 532 | 524 | if (atapi_passthru16) |
|---|
| 533 | 525 | return ATAPI_PASS_THRU; |
|---|
| 534 | | - /* fall thru */ |
|---|
| 526 | + fallthrough; |
|---|
| 535 | 527 | default: |
|---|
| 536 | 528 | return ATAPI_MISC; |
|---|
| 537 | 529 | } |
|---|
| 538 | 530 | } |
|---|
| 539 | | - |
|---|
| 540 | | -/** |
|---|
| 541 | | - * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure |
|---|
| 542 | | - * @tf: Taskfile to convert |
|---|
| 543 | | - * @pmp: Port multiplier port |
|---|
| 544 | | - * @is_cmd: This FIS is for command |
|---|
| 545 | | - * @fis: Buffer into which data will output |
|---|
| 546 | | - * |
|---|
| 547 | | - * Converts a standard ATA taskfile to a Serial ATA |
|---|
| 548 | | - * FIS structure (Register - Host to Device). |
|---|
| 549 | | - * |
|---|
| 550 | | - * LOCKING: |
|---|
| 551 | | - * Inherited from caller. |
|---|
| 552 | | - */ |
|---|
| 553 | | -void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis) |
|---|
| 554 | | -{ |
|---|
| 555 | | - fis[0] = 0x27; /* Register - Host to Device FIS */ |
|---|
| 556 | | - fis[1] = pmp & 0xf; /* Port multiplier number*/ |
|---|
| 557 | | - if (is_cmd) |
|---|
| 558 | | - fis[1] |= (1 << 7); /* bit 7 indicates Command FIS */ |
|---|
| 559 | | - |
|---|
| 560 | | - fis[2] = tf->command; |
|---|
| 561 | | - fis[3] = tf->feature; |
|---|
| 562 | | - |
|---|
| 563 | | - fis[4] = tf->lbal; |
|---|
| 564 | | - fis[5] = tf->lbam; |
|---|
| 565 | | - fis[6] = tf->lbah; |
|---|
| 566 | | - fis[7] = tf->device; |
|---|
| 567 | | - |
|---|
| 568 | | - fis[8] = tf->hob_lbal; |
|---|
| 569 | | - fis[9] = tf->hob_lbam; |
|---|
| 570 | | - fis[10] = tf->hob_lbah; |
|---|
| 571 | | - fis[11] = tf->hob_feature; |
|---|
| 572 | | - |
|---|
| 573 | | - fis[12] = tf->nsect; |
|---|
| 574 | | - fis[13] = tf->hob_nsect; |
|---|
| 575 | | - fis[14] = 0; |
|---|
| 576 | | - fis[15] = tf->ctl; |
|---|
| 577 | | - |
|---|
| 578 | | - fis[16] = tf->auxiliary & 0xff; |
|---|
| 579 | | - fis[17] = (tf->auxiliary >> 8) & 0xff; |
|---|
| 580 | | - fis[18] = (tf->auxiliary >> 16) & 0xff; |
|---|
| 581 | | - fis[19] = (tf->auxiliary >> 24) & 0xff; |
|---|
| 582 | | -} |
|---|
| 583 | | - |
|---|
| 584 | | -/** |
|---|
| 585 | | - * ata_tf_from_fis - Convert SATA FIS to ATA taskfile |
|---|
| 586 | | - * @fis: Buffer from which data will be input |
|---|
| 587 | | - * @tf: Taskfile to output |
|---|
| 588 | | - * |
|---|
| 589 | | - * Converts a serial ATA FIS structure to a standard ATA taskfile. |
|---|
| 590 | | - * |
|---|
| 591 | | - * LOCKING: |
|---|
| 592 | | - * Inherited from caller. |
|---|
| 593 | | - */ |
|---|
| 594 | | - |
|---|
| 595 | | -void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf) |
|---|
| 596 | | -{ |
|---|
| 597 | | - tf->command = fis[2]; /* status */ |
|---|
| 598 | | - tf->feature = fis[3]; /* error */ |
|---|
| 599 | | - |
|---|
| 600 | | - tf->lbal = fis[4]; |
|---|
| 601 | | - tf->lbam = fis[5]; |
|---|
| 602 | | - tf->lbah = fis[6]; |
|---|
| 603 | | - tf->device = fis[7]; |
|---|
| 604 | | - |
|---|
| 605 | | - tf->hob_lbal = fis[8]; |
|---|
| 606 | | - tf->hob_lbam = fis[9]; |
|---|
| 607 | | - tf->hob_lbah = fis[10]; |
|---|
| 608 | | - |
|---|
| 609 | | - tf->nsect = fis[12]; |
|---|
| 610 | | - tf->hob_nsect = fis[13]; |
|---|
| 611 | | -} |
|---|
| 531 | +EXPORT_SYMBOL_GPL(atapi_cmd_type); |
|---|
| 612 | 532 | |
|---|
| 613 | 533 | static const u8 ata_rw_cmds[] = { |
|---|
| 614 | 534 | /* pio multi */ |
|---|
| .. | .. |
|---|
| 883 | 803 | ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) | |
|---|
| 884 | 804 | ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA); |
|---|
| 885 | 805 | } |
|---|
| 806 | +EXPORT_SYMBOL_GPL(ata_pack_xfermask); |
|---|
| 886 | 807 | |
|---|
| 887 | 808 | /** |
|---|
| 888 | 809 | * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks |
|---|
| .. | .. |
|---|
| 938 | 859 | return ent->base + highbit - ent->shift; |
|---|
| 939 | 860 | return 0xff; |
|---|
| 940 | 861 | } |
|---|
| 862 | +EXPORT_SYMBOL_GPL(ata_xfer_mask2mode); |
|---|
| 941 | 863 | |
|---|
| 942 | 864 | /** |
|---|
| 943 | 865 | * ata_xfer_mode2mask - Find matching xfer_mask for XFER_* |
|---|
| .. | .. |
|---|
| 961 | 883 | & ~((1 << ent->shift) - 1); |
|---|
| 962 | 884 | return 0; |
|---|
| 963 | 885 | } |
|---|
| 886 | +EXPORT_SYMBOL_GPL(ata_xfer_mode2mask); |
|---|
| 964 | 887 | |
|---|
| 965 | 888 | /** |
|---|
| 966 | 889 | * ata_xfer_mode2shift - Find matching xfer_shift for XFER_* |
|---|
| .. | .. |
|---|
| 983 | 906 | return ent->shift; |
|---|
| 984 | 907 | return -1; |
|---|
| 985 | 908 | } |
|---|
| 909 | +EXPORT_SYMBOL_GPL(ata_xfer_mode2shift); |
|---|
| 986 | 910 | |
|---|
| 987 | 911 | /** |
|---|
| 988 | 912 | * ata_mode_string - convert xfer_mask to string |
|---|
| .. | .. |
|---|
| 1029 | 953 | return xfer_mode_str[highbit]; |
|---|
| 1030 | 954 | return "<n/a>"; |
|---|
| 1031 | 955 | } |
|---|
| 956 | +EXPORT_SYMBOL_GPL(ata_mode_string); |
|---|
| 1032 | 957 | |
|---|
| 1033 | 958 | const char *sata_spd_string(unsigned int spd) |
|---|
| 1034 | 959 | { |
|---|
| .. | .. |
|---|
| 1109 | 1034 | DPRINTK("unknown device\n"); |
|---|
| 1110 | 1035 | return ATA_DEV_UNKNOWN; |
|---|
| 1111 | 1036 | } |
|---|
| 1037 | +EXPORT_SYMBOL_GPL(ata_dev_classify); |
|---|
| 1112 | 1038 | |
|---|
| 1113 | 1039 | /** |
|---|
| 1114 | 1040 | * ata_id_string - Convert IDENTIFY DEVICE page into string |
|---|
| .. | .. |
|---|
| 1145 | 1071 | len -= 2; |
|---|
| 1146 | 1072 | } |
|---|
| 1147 | 1073 | } |
|---|
| 1074 | +EXPORT_SYMBOL_GPL(ata_id_string); |
|---|
| 1148 | 1075 | |
|---|
| 1149 | 1076 | /** |
|---|
| 1150 | 1077 | * ata_id_c_string - Convert IDENTIFY DEVICE page into C string |
|---|
| .. | .. |
|---|
| 1172 | 1099 | p--; |
|---|
| 1173 | 1100 | *p = '\0'; |
|---|
| 1174 | 1101 | } |
|---|
| 1102 | +EXPORT_SYMBOL_GPL(ata_id_c_string); |
|---|
| 1175 | 1103 | |
|---|
| 1176 | 1104 | static u64 ata_id_n_sectors(const u16 *id) |
|---|
| 1177 | 1105 | { |
|---|
| .. | .. |
|---|
| 1529 | 1457 | |
|---|
| 1530 | 1458 | return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask); |
|---|
| 1531 | 1459 | } |
|---|
| 1460 | +EXPORT_SYMBOL_GPL(ata_id_xfermask); |
|---|
| 1532 | 1461 | |
|---|
| 1533 | 1462 | static void ata_qc_complete_internal(struct ata_queued_cmd *qc) |
|---|
| 1534 | 1463 | { |
|---|
| .. | .. |
|---|
| 1786 | 1715 | return 1; |
|---|
| 1787 | 1716 | return 0; |
|---|
| 1788 | 1717 | } |
|---|
| 1718 | +EXPORT_SYMBOL_GPL(ata_pio_need_iordy); |
|---|
| 1789 | 1719 | |
|---|
| 1790 | 1720 | /** |
|---|
| 1791 | 1721 | * ata_pio_mask_no_iordy - Return the non IORDY mask |
|---|
| .. | .. |
|---|
| 1826 | 1756 | return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE, |
|---|
| 1827 | 1757 | id, sizeof(id[0]) * ATA_ID_WORDS, 0); |
|---|
| 1828 | 1758 | } |
|---|
| 1759 | +EXPORT_SYMBOL_GPL(ata_do_dev_read_id); |
|---|
| 1829 | 1760 | |
|---|
| 1830 | 1761 | /** |
|---|
| 1831 | 1762 | * ata_dev_read_id - Read ID data from the specified device |
|---|
| .. | .. |
|---|
| 1869 | 1800 | switch (class) { |
|---|
| 1870 | 1801 | case ATA_DEV_SEMB: |
|---|
| 1871 | 1802 | class = ATA_DEV_ATA; /* some hard drives report SEMB sig */ |
|---|
| 1872 | | - /* fall through */ |
|---|
| 1803 | + fallthrough; |
|---|
| 1873 | 1804 | case ATA_DEV_ATA: |
|---|
| 1874 | 1805 | case ATA_DEV_ZAC: |
|---|
| 1875 | 1806 | tf.command = ATA_CMD_ID_ATA; |
|---|
| .. | .. |
|---|
| 2299 | 2230 | desc[0] = '\0'; |
|---|
| 2300 | 2231 | return 0; |
|---|
| 2301 | 2232 | } |
|---|
| 2233 | + if (!IS_ENABLED(CONFIG_SATA_HOST)) |
|---|
| 2234 | + return 0; |
|---|
| 2302 | 2235 | if (dev->horkage & ATA_HORKAGE_NONCQ) { |
|---|
| 2303 | 2236 | snprintf(desc, desc_sz, "NCQ (not used)"); |
|---|
| 2304 | 2237 | return 0; |
|---|
| .. | .. |
|---|
| 2824 | 2757 | { |
|---|
| 2825 | 2758 | return ATA_CBL_PATA40; |
|---|
| 2826 | 2759 | } |
|---|
| 2760 | +EXPORT_SYMBOL_GPL(ata_cable_40wire); |
|---|
| 2827 | 2761 | |
|---|
| 2828 | 2762 | /** |
|---|
| 2829 | 2763 | * ata_cable_80wire - return 80 wire cable type |
|---|
| .. | .. |
|---|
| 2837 | 2771 | { |
|---|
| 2838 | 2772 | return ATA_CBL_PATA80; |
|---|
| 2839 | 2773 | } |
|---|
| 2774 | +EXPORT_SYMBOL_GPL(ata_cable_80wire); |
|---|
| 2840 | 2775 | |
|---|
| 2841 | 2776 | /** |
|---|
| 2842 | 2777 | * ata_cable_unknown - return unknown PATA cable. |
|---|
| .. | .. |
|---|
| 2849 | 2784 | { |
|---|
| 2850 | 2785 | return ATA_CBL_PATA_UNK; |
|---|
| 2851 | 2786 | } |
|---|
| 2787 | +EXPORT_SYMBOL_GPL(ata_cable_unknown); |
|---|
| 2852 | 2788 | |
|---|
| 2853 | 2789 | /** |
|---|
| 2854 | 2790 | * ata_cable_ignore - return ignored PATA cable. |
|---|
| .. | .. |
|---|
| 2861 | 2797 | { |
|---|
| 2862 | 2798 | return ATA_CBL_PATA_IGN; |
|---|
| 2863 | 2799 | } |
|---|
| 2800 | +EXPORT_SYMBOL_GPL(ata_cable_ignore); |
|---|
| 2864 | 2801 | |
|---|
| 2865 | 2802 | /** |
|---|
| 2866 | 2803 | * ata_cable_sata - return SATA cable type |
|---|
| .. | .. |
|---|
| 2873 | 2810 | { |
|---|
| 2874 | 2811 | return ATA_CBL_SATA; |
|---|
| 2875 | 2812 | } |
|---|
| 2813 | +EXPORT_SYMBOL_GPL(ata_cable_sata); |
|---|
| 2876 | 2814 | |
|---|
| 2877 | 2815 | /** |
|---|
| 2878 | 2816 | * ata_bus_probe - Reset and probe ATA bus |
|---|
| .. | .. |
|---|
| 2995 | 2933 | case -ENODEV: |
|---|
| 2996 | 2934 | /* give it just one more chance */ |
|---|
| 2997 | 2935 | tries[dev->devno] = min(tries[dev->devno], 1); |
|---|
| 2998 | | - /* fall through */ |
|---|
| 2936 | + fallthrough; |
|---|
| 2999 | 2937 | case -EIO: |
|---|
| 3000 | 2938 | if (tries[dev->devno] == 1) { |
|---|
| 3001 | 2939 | /* This is the last chance, better to slow |
|---|
| .. | .. |
|---|
| 3055 | 2993 | return NULL; |
|---|
| 3056 | 2994 | return pair; |
|---|
| 3057 | 2995 | } |
|---|
| 2996 | +EXPORT_SYMBOL_GPL(ata_dev_pair); |
|---|
| 3058 | 2997 | |
|---|
| 3059 | 2998 | /** |
|---|
| 3060 | 2999 | * sata_down_spd_limit - adjust SATA spd limit downward |
|---|
| .. | .. |
|---|
| 3136 | 3075 | return 0; |
|---|
| 3137 | 3076 | } |
|---|
| 3138 | 3077 | |
|---|
| 3139 | | -static int __sata_set_spd_needed(struct ata_link *link, u32 *scontrol) |
|---|
| 3140 | | -{ |
|---|
| 3141 | | - struct ata_link *host_link = &link->ap->link; |
|---|
| 3142 | | - u32 limit, target, spd; |
|---|
| 3143 | | - |
|---|
| 3144 | | - limit = link->sata_spd_limit; |
|---|
| 3145 | | - |
|---|
| 3146 | | - /* Don't configure downstream link faster than upstream link. |
|---|
| 3147 | | - * It doesn't speed up anything and some PMPs choke on such |
|---|
| 3148 | | - * configuration. |
|---|
| 3149 | | - */ |
|---|
| 3150 | | - if (!ata_is_host_link(link) && host_link->sata_spd) |
|---|
| 3151 | | - limit &= (1 << host_link->sata_spd) - 1; |
|---|
| 3152 | | - |
|---|
| 3153 | | - if (limit == UINT_MAX) |
|---|
| 3154 | | - target = 0; |
|---|
| 3155 | | - else |
|---|
| 3156 | | - target = fls(limit); |
|---|
| 3157 | | - |
|---|
| 3158 | | - spd = (*scontrol >> 4) & 0xf; |
|---|
| 3159 | | - *scontrol = (*scontrol & ~0xf0) | ((target & 0xf) << 4); |
|---|
| 3160 | | - |
|---|
| 3161 | | - return spd != target; |
|---|
| 3162 | | -} |
|---|
| 3163 | | - |
|---|
| 3164 | | -/** |
|---|
| 3165 | | - * sata_set_spd_needed - is SATA spd configuration needed |
|---|
| 3166 | | - * @link: Link in question |
|---|
| 3167 | | - * |
|---|
| 3168 | | - * Test whether the spd limit in SControl matches |
|---|
| 3169 | | - * @link->sata_spd_limit. This function is used to determine |
|---|
| 3170 | | - * whether hardreset is necessary to apply SATA spd |
|---|
| 3171 | | - * configuration. |
|---|
| 3172 | | - * |
|---|
| 3173 | | - * LOCKING: |
|---|
| 3174 | | - * Inherited from caller. |
|---|
| 3175 | | - * |
|---|
| 3176 | | - * RETURNS: |
|---|
| 3177 | | - * 1 if SATA spd configuration is needed, 0 otherwise. |
|---|
| 3178 | | - */ |
|---|
| 3179 | | -static int sata_set_spd_needed(struct ata_link *link) |
|---|
| 3180 | | -{ |
|---|
| 3181 | | - u32 scontrol; |
|---|
| 3182 | | - |
|---|
| 3183 | | - if (sata_scr_read(link, SCR_CONTROL, &scontrol)) |
|---|
| 3184 | | - return 1; |
|---|
| 3185 | | - |
|---|
| 3186 | | - return __sata_set_spd_needed(link, &scontrol); |
|---|
| 3187 | | -} |
|---|
| 3188 | | - |
|---|
| 3189 | | -/** |
|---|
| 3190 | | - * sata_set_spd - set SATA spd according to spd limit |
|---|
| 3191 | | - * @link: Link to set SATA spd for |
|---|
| 3192 | | - * |
|---|
| 3193 | | - * Set SATA spd of @link according to sata_spd_limit. |
|---|
| 3194 | | - * |
|---|
| 3195 | | - * LOCKING: |
|---|
| 3196 | | - * Inherited from caller. |
|---|
| 3197 | | - * |
|---|
| 3198 | | - * RETURNS: |
|---|
| 3199 | | - * 0 if spd doesn't need to be changed, 1 if spd has been |
|---|
| 3200 | | - * changed. Negative errno if SCR registers are inaccessible. |
|---|
| 3201 | | - */ |
|---|
| 3202 | | -int sata_set_spd(struct ata_link *link) |
|---|
| 3203 | | -{ |
|---|
| 3204 | | - u32 scontrol; |
|---|
| 3205 | | - int rc; |
|---|
| 3206 | | - |
|---|
| 3207 | | - if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) |
|---|
| 3208 | | - return rc; |
|---|
| 3209 | | - |
|---|
| 3210 | | - if (!__sata_set_spd_needed(link, &scontrol)) |
|---|
| 3211 | | - return 0; |
|---|
| 3212 | | - |
|---|
| 3213 | | - if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) |
|---|
| 3214 | | - return rc; |
|---|
| 3215 | | - |
|---|
| 3216 | | - return 1; |
|---|
| 3217 | | -} |
|---|
| 3218 | | - |
|---|
| 3219 | | -/* |
|---|
| 3220 | | - * This mode timing computation functionality is ported over from |
|---|
| 3221 | | - * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik |
|---|
| 3222 | | - */ |
|---|
| 3223 | | -/* |
|---|
| 3224 | | - * PIO 0-4, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). |
|---|
| 3225 | | - * These were taken from ATA/ATAPI-6 standard, rev 0a, except |
|---|
| 3226 | | - * for UDMA6, which is currently supported only by Maxtor drives. |
|---|
| 3227 | | - * |
|---|
| 3228 | | - * For PIO 5/6 MWDMA 3/4 see the CFA specification 3.0. |
|---|
| 3229 | | - */ |
|---|
| 3230 | | - |
|---|
| 3231 | | -static const struct ata_timing ata_timing[] = { |
|---|
| 3232 | | -/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 0, 960, 0 }, */ |
|---|
| 3233 | | - { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 0, 600, 0 }, |
|---|
| 3234 | | - { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 0, 383, 0 }, |
|---|
| 3235 | | - { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 0, 240, 0 }, |
|---|
| 3236 | | - { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 0, 180, 0 }, |
|---|
| 3237 | | - { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 0, 120, 0 }, |
|---|
| 3238 | | - { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 0, 100, 0 }, |
|---|
| 3239 | | - { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 0, 80, 0 }, |
|---|
| 3240 | | - |
|---|
| 3241 | | - { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 50, 960, 0 }, |
|---|
| 3242 | | - { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 30, 480, 0 }, |
|---|
| 3243 | | - { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 20, 240, 0 }, |
|---|
| 3244 | | - |
|---|
| 3245 | | - { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 20, 480, 0 }, |
|---|
| 3246 | | - { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 5, 150, 0 }, |
|---|
| 3247 | | - { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 5, 120, 0 }, |
|---|
| 3248 | | - { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 5, 100, 0 }, |
|---|
| 3249 | | - { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 5, 80, 0 }, |
|---|
| 3250 | | - |
|---|
| 3251 | | -/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 0, 150 }, */ |
|---|
| 3252 | | - { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 0, 120 }, |
|---|
| 3253 | | - { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 0, 80 }, |
|---|
| 3254 | | - { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 0, 60 }, |
|---|
| 3255 | | - { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 0, 45 }, |
|---|
| 3256 | | - { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 0, 30 }, |
|---|
| 3257 | | - { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 0, 20 }, |
|---|
| 3258 | | - { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 0, 15 }, |
|---|
| 3259 | | - |
|---|
| 3260 | | - { 0xFF } |
|---|
| 3261 | | -}; |
|---|
| 3262 | | - |
|---|
| 3263 | | -#define ENOUGH(v, unit) (((v)-1)/(unit)+1) |
|---|
| 3264 | | -#define EZ(v, unit) ((v)?ENOUGH(((v) * 1000), unit):0) |
|---|
| 3265 | | - |
|---|
| 3266 | | -static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT) |
|---|
| 3267 | | -{ |
|---|
| 3268 | | - q->setup = EZ(t->setup, T); |
|---|
| 3269 | | - q->act8b = EZ(t->act8b, T); |
|---|
| 3270 | | - q->rec8b = EZ(t->rec8b, T); |
|---|
| 3271 | | - q->cyc8b = EZ(t->cyc8b, T); |
|---|
| 3272 | | - q->active = EZ(t->active, T); |
|---|
| 3273 | | - q->recover = EZ(t->recover, T); |
|---|
| 3274 | | - q->dmack_hold = EZ(t->dmack_hold, T); |
|---|
| 3275 | | - q->cycle = EZ(t->cycle, T); |
|---|
| 3276 | | - q->udma = EZ(t->udma, UT); |
|---|
| 3277 | | -} |
|---|
| 3278 | | - |
|---|
| 3279 | | -void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b, |
|---|
| 3280 | | - struct ata_timing *m, unsigned int what) |
|---|
| 3281 | | -{ |
|---|
| 3282 | | - if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup); |
|---|
| 3283 | | - if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b); |
|---|
| 3284 | | - if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b); |
|---|
| 3285 | | - if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b); |
|---|
| 3286 | | - if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active); |
|---|
| 3287 | | - if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover); |
|---|
| 3288 | | - if (what & ATA_TIMING_DMACK_HOLD) m->dmack_hold = max(a->dmack_hold, b->dmack_hold); |
|---|
| 3289 | | - if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle); |
|---|
| 3290 | | - if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma); |
|---|
| 3291 | | -} |
|---|
| 3292 | | - |
|---|
| 3293 | | -const struct ata_timing *ata_timing_find_mode(u8 xfer_mode) |
|---|
| 3294 | | -{ |
|---|
| 3295 | | - const struct ata_timing *t = ata_timing; |
|---|
| 3296 | | - |
|---|
| 3297 | | - while (xfer_mode > t->mode) |
|---|
| 3298 | | - t++; |
|---|
| 3299 | | - |
|---|
| 3300 | | - if (xfer_mode == t->mode) |
|---|
| 3301 | | - return t; |
|---|
| 3302 | | - |
|---|
| 3303 | | - WARN_ONCE(true, "%s: unable to find timing for xfer_mode 0x%x\n", |
|---|
| 3304 | | - __func__, xfer_mode); |
|---|
| 3305 | | - |
|---|
| 3306 | | - return NULL; |
|---|
| 3307 | | -} |
|---|
| 3308 | | - |
|---|
| 3309 | | -int ata_timing_compute(struct ata_device *adev, unsigned short speed, |
|---|
| 3310 | | - struct ata_timing *t, int T, int UT) |
|---|
| 3311 | | -{ |
|---|
| 3312 | | - const u16 *id = adev->id; |
|---|
| 3313 | | - const struct ata_timing *s; |
|---|
| 3314 | | - struct ata_timing p; |
|---|
| 3315 | | - |
|---|
| 3316 | | - /* |
|---|
| 3317 | | - * Find the mode. |
|---|
| 3318 | | - */ |
|---|
| 3319 | | - |
|---|
| 3320 | | - if (!(s = ata_timing_find_mode(speed))) |
|---|
| 3321 | | - return -EINVAL; |
|---|
| 3322 | | - |
|---|
| 3323 | | - memcpy(t, s, sizeof(*s)); |
|---|
| 3324 | | - |
|---|
| 3325 | | - /* |
|---|
| 3326 | | - * If the drive is an EIDE drive, it can tell us it needs extended |
|---|
| 3327 | | - * PIO/MW_DMA cycle timing. |
|---|
| 3328 | | - */ |
|---|
| 3329 | | - |
|---|
| 3330 | | - if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ |
|---|
| 3331 | | - memset(&p, 0, sizeof(p)); |
|---|
| 3332 | | - |
|---|
| 3333 | | - if (speed >= XFER_PIO_0 && speed < XFER_SW_DMA_0) { |
|---|
| 3334 | | - if (speed <= XFER_PIO_2) |
|---|
| 3335 | | - p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO]; |
|---|
| 3336 | | - else if ((speed <= XFER_PIO_4) || |
|---|
| 3337 | | - (speed == XFER_PIO_5 && !ata_id_is_cfa(id))) |
|---|
| 3338 | | - p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY]; |
|---|
| 3339 | | - } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) |
|---|
| 3340 | | - p.cycle = id[ATA_ID_EIDE_DMA_MIN]; |
|---|
| 3341 | | - |
|---|
| 3342 | | - ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B); |
|---|
| 3343 | | - } |
|---|
| 3344 | | - |
|---|
| 3345 | | - /* |
|---|
| 3346 | | - * Convert the timing to bus clock counts. |
|---|
| 3347 | | - */ |
|---|
| 3348 | | - |
|---|
| 3349 | | - ata_timing_quantize(t, t, T, UT); |
|---|
| 3350 | | - |
|---|
| 3351 | | - /* |
|---|
| 3352 | | - * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, |
|---|
| 3353 | | - * S.M.A.R.T * and some other commands. We have to ensure that the |
|---|
| 3354 | | - * DMA cycle timing is slower/equal than the fastest PIO timing. |
|---|
| 3355 | | - */ |
|---|
| 3356 | | - |
|---|
| 3357 | | - if (speed > XFER_PIO_6) { |
|---|
| 3358 | | - ata_timing_compute(adev, adev->pio_mode, &p, T, UT); |
|---|
| 3359 | | - ata_timing_merge(&p, t, t, ATA_TIMING_ALL); |
|---|
| 3360 | | - } |
|---|
| 3361 | | - |
|---|
| 3362 | | - /* |
|---|
| 3363 | | - * Lengthen active & recovery time so that cycle time is correct. |
|---|
| 3364 | | - */ |
|---|
| 3365 | | - |
|---|
| 3366 | | - if (t->act8b + t->rec8b < t->cyc8b) { |
|---|
| 3367 | | - t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2; |
|---|
| 3368 | | - t->rec8b = t->cyc8b - t->act8b; |
|---|
| 3369 | | - } |
|---|
| 3370 | | - |
|---|
| 3371 | | - if (t->active + t->recover < t->cycle) { |
|---|
| 3372 | | - t->active += (t->cycle - (t->active + t->recover)) / 2; |
|---|
| 3373 | | - t->recover = t->cycle - t->active; |
|---|
| 3374 | | - } |
|---|
| 3375 | | - |
|---|
| 3376 | | - /* In a few cases quantisation may produce enough errors to |
|---|
| 3377 | | - leave t->cycle too low for the sum of active and recovery |
|---|
| 3378 | | - if so we must correct this */ |
|---|
| 3379 | | - if (t->active + t->recover > t->cycle) |
|---|
| 3380 | | - t->cycle = t->active + t->recover; |
|---|
| 3381 | | - |
|---|
| 3382 | | - return 0; |
|---|
| 3383 | | -} |
|---|
| 3384 | | - |
|---|
| 3078 | +#ifdef CONFIG_ATA_ACPI |
|---|
| 3385 | 3079 | /** |
|---|
| 3386 | 3080 | * ata_timing_cycle2mode - find xfer mode for the specified cycle duration |
|---|
| 3387 | 3081 | * @xfer_shift: ATA_SHIFT_* value for transfer type to examine. |
|---|
| .. | .. |
|---|
| 3432 | 3126 | |
|---|
| 3433 | 3127 | return last_mode; |
|---|
| 3434 | 3128 | } |
|---|
| 3129 | +#endif |
|---|
| 3435 | 3130 | |
|---|
| 3436 | 3131 | /** |
|---|
| 3437 | 3132 | * ata_down_xfermask_limit - adjust dev xfer masks downward |
|---|
| .. | .. |
|---|
| 3489 | 3184 | |
|---|
| 3490 | 3185 | case ATA_DNXFER_FORCE_PIO0: |
|---|
| 3491 | 3186 | pio_mask &= 1; |
|---|
| 3492 | | - /* fall through */ |
|---|
| 3187 | + fallthrough; |
|---|
| 3493 | 3188 | case ATA_DNXFER_FORCE_PIO: |
|---|
| 3494 | 3189 | mwdma_mask = 0; |
|---|
| 3495 | 3190 | udma_mask = 0; |
|---|
| .. | .. |
|---|
| 3703 | 3398 | *r_failed_dev = dev; |
|---|
| 3704 | 3399 | return rc; |
|---|
| 3705 | 3400 | } |
|---|
| 3401 | +EXPORT_SYMBOL_GPL(ata_do_set_mode); |
|---|
| 3706 | 3402 | |
|---|
| 3707 | 3403 | /** |
|---|
| 3708 | 3404 | * ata_wait_ready - wait for link to become ready |
|---|
| .. | .. |
|---|
| 3812 | 3508 | |
|---|
| 3813 | 3509 | return ata_wait_ready(link, deadline, check_ready); |
|---|
| 3814 | 3510 | } |
|---|
| 3815 | | - |
|---|
| 3816 | | -/** |
|---|
| 3817 | | - * sata_link_debounce - debounce SATA phy status |
|---|
| 3818 | | - * @link: ATA link to debounce SATA phy status for |
|---|
| 3819 | | - * @params: timing parameters { interval, duration, timeout } in msec |
|---|
| 3820 | | - * @deadline: deadline jiffies for the operation |
|---|
| 3821 | | - * |
|---|
| 3822 | | - * Make sure SStatus of @link reaches stable state, determined by |
|---|
| 3823 | | - * holding the same value where DET is not 1 for @duration polled |
|---|
| 3824 | | - * every @interval, before @timeout. Timeout constraints the |
|---|
| 3825 | | - * beginning of the stable state. Because DET gets stuck at 1 on |
|---|
| 3826 | | - * some controllers after hot unplugging, this functions waits |
|---|
| 3827 | | - * until timeout then returns 0 if DET is stable at 1. |
|---|
| 3828 | | - * |
|---|
| 3829 | | - * @timeout is further limited by @deadline. The sooner of the |
|---|
| 3830 | | - * two is used. |
|---|
| 3831 | | - * |
|---|
| 3832 | | - * LOCKING: |
|---|
| 3833 | | - * Kernel thread context (may sleep) |
|---|
| 3834 | | - * |
|---|
| 3835 | | - * RETURNS: |
|---|
| 3836 | | - * 0 on success, -errno on failure. |
|---|
| 3837 | | - */ |
|---|
| 3838 | | -int sata_link_debounce(struct ata_link *link, const unsigned long *params, |
|---|
| 3839 | | - unsigned long deadline) |
|---|
| 3840 | | -{ |
|---|
| 3841 | | - unsigned long interval = params[0]; |
|---|
| 3842 | | - unsigned long duration = params[1]; |
|---|
| 3843 | | - unsigned long last_jiffies, t; |
|---|
| 3844 | | - u32 last, cur; |
|---|
| 3845 | | - int rc; |
|---|
| 3846 | | - |
|---|
| 3847 | | - t = ata_deadline(jiffies, params[2]); |
|---|
| 3848 | | - if (time_before(t, deadline)) |
|---|
| 3849 | | - deadline = t; |
|---|
| 3850 | | - |
|---|
| 3851 | | - if ((rc = sata_scr_read(link, SCR_STATUS, &cur))) |
|---|
| 3852 | | - return rc; |
|---|
| 3853 | | - cur &= 0xf; |
|---|
| 3854 | | - |
|---|
| 3855 | | - last = cur; |
|---|
| 3856 | | - last_jiffies = jiffies; |
|---|
| 3857 | | - |
|---|
| 3858 | | - while (1) { |
|---|
| 3859 | | - ata_msleep(link->ap, interval); |
|---|
| 3860 | | - if ((rc = sata_scr_read(link, SCR_STATUS, &cur))) |
|---|
| 3861 | | - return rc; |
|---|
| 3862 | | - cur &= 0xf; |
|---|
| 3863 | | - |
|---|
| 3864 | | - /* DET stable? */ |
|---|
| 3865 | | - if (cur == last) { |
|---|
| 3866 | | - if (cur == 1 && time_before(jiffies, deadline)) |
|---|
| 3867 | | - continue; |
|---|
| 3868 | | - if (time_after(jiffies, |
|---|
| 3869 | | - ata_deadline(last_jiffies, duration))) |
|---|
| 3870 | | - return 0; |
|---|
| 3871 | | - continue; |
|---|
| 3872 | | - } |
|---|
| 3873 | | - |
|---|
| 3874 | | - /* unstable, start over */ |
|---|
| 3875 | | - last = cur; |
|---|
| 3876 | | - last_jiffies = jiffies; |
|---|
| 3877 | | - |
|---|
| 3878 | | - /* Check deadline. If debouncing failed, return |
|---|
| 3879 | | - * -EPIPE to tell upper layer to lower link speed. |
|---|
| 3880 | | - */ |
|---|
| 3881 | | - if (time_after(jiffies, deadline)) |
|---|
| 3882 | | - return -EPIPE; |
|---|
| 3883 | | - } |
|---|
| 3884 | | -} |
|---|
| 3885 | | - |
|---|
| 3886 | | -/** |
|---|
| 3887 | | - * sata_link_resume - resume SATA link |
|---|
| 3888 | | - * @link: ATA link to resume SATA |
|---|
| 3889 | | - * @params: timing parameters { interval, duration, timeout } in msec |
|---|
| 3890 | | - * @deadline: deadline jiffies for the operation |
|---|
| 3891 | | - * |
|---|
| 3892 | | - * Resume SATA phy @link and debounce it. |
|---|
| 3893 | | - * |
|---|
| 3894 | | - * LOCKING: |
|---|
| 3895 | | - * Kernel thread context (may sleep) |
|---|
| 3896 | | - * |
|---|
| 3897 | | - * RETURNS: |
|---|
| 3898 | | - * 0 on success, -errno on failure. |
|---|
| 3899 | | - */ |
|---|
| 3900 | | -int sata_link_resume(struct ata_link *link, const unsigned long *params, |
|---|
| 3901 | | - unsigned long deadline) |
|---|
| 3902 | | -{ |
|---|
| 3903 | | - int tries = ATA_LINK_RESUME_TRIES; |
|---|
| 3904 | | - u32 scontrol, serror; |
|---|
| 3905 | | - int rc; |
|---|
| 3906 | | - |
|---|
| 3907 | | - if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) |
|---|
| 3908 | | - return rc; |
|---|
| 3909 | | - |
|---|
| 3910 | | - /* |
|---|
| 3911 | | - * Writes to SControl sometimes get ignored under certain |
|---|
| 3912 | | - * controllers (ata_piix SIDPR). Make sure DET actually is |
|---|
| 3913 | | - * cleared. |
|---|
| 3914 | | - */ |
|---|
| 3915 | | - do { |
|---|
| 3916 | | - scontrol = (scontrol & 0x0f0) | 0x300; |
|---|
| 3917 | | - if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) |
|---|
| 3918 | | - return rc; |
|---|
| 3919 | | - /* |
|---|
| 3920 | | - * Some PHYs react badly if SStatus is pounded |
|---|
| 3921 | | - * immediately after resuming. Delay 200ms before |
|---|
| 3922 | | - * debouncing. |
|---|
| 3923 | | - */ |
|---|
| 3924 | | - if (!(link->flags & ATA_LFLAG_NO_DB_DELAY)) |
|---|
| 3925 | | - ata_msleep(link->ap, 200); |
|---|
| 3926 | | - |
|---|
| 3927 | | - /* is SControl restored correctly? */ |
|---|
| 3928 | | - if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) |
|---|
| 3929 | | - return rc; |
|---|
| 3930 | | - } while ((scontrol & 0xf0f) != 0x300 && --tries); |
|---|
| 3931 | | - |
|---|
| 3932 | | - if ((scontrol & 0xf0f) != 0x300) { |
|---|
| 3933 | | - ata_link_warn(link, "failed to resume link (SControl %X)\n", |
|---|
| 3934 | | - scontrol); |
|---|
| 3935 | | - return 0; |
|---|
| 3936 | | - } |
|---|
| 3937 | | - |
|---|
| 3938 | | - if (tries < ATA_LINK_RESUME_TRIES) |
|---|
| 3939 | | - ata_link_warn(link, "link resume succeeded after %d retries\n", |
|---|
| 3940 | | - ATA_LINK_RESUME_TRIES - tries); |
|---|
| 3941 | | - |
|---|
| 3942 | | - if ((rc = sata_link_debounce(link, params, deadline))) |
|---|
| 3943 | | - return rc; |
|---|
| 3944 | | - |
|---|
| 3945 | | - /* clear SError, some PHYs require this even for SRST to work */ |
|---|
| 3946 | | - if (!(rc = sata_scr_read(link, SCR_ERROR, &serror))) |
|---|
| 3947 | | - rc = sata_scr_write(link, SCR_ERROR, serror); |
|---|
| 3948 | | - |
|---|
| 3949 | | - return rc != -EINVAL ? rc : 0; |
|---|
| 3950 | | -} |
|---|
| 3951 | | - |
|---|
| 3952 | | -/** |
|---|
| 3953 | | - * sata_link_scr_lpm - manipulate SControl IPM and SPM fields |
|---|
| 3954 | | - * @link: ATA link to manipulate SControl for |
|---|
| 3955 | | - * @policy: LPM policy to configure |
|---|
| 3956 | | - * @spm_wakeup: initiate LPM transition to active state |
|---|
| 3957 | | - * |
|---|
| 3958 | | - * Manipulate the IPM field of the SControl register of @link |
|---|
| 3959 | | - * according to @policy. If @policy is ATA_LPM_MAX_POWER and |
|---|
| 3960 | | - * @spm_wakeup is %true, the SPM field is manipulated to wake up |
|---|
| 3961 | | - * the link. This function also clears PHYRDY_CHG before |
|---|
| 3962 | | - * returning. |
|---|
| 3963 | | - * |
|---|
| 3964 | | - * LOCKING: |
|---|
| 3965 | | - * EH context. |
|---|
| 3966 | | - * |
|---|
| 3967 | | - * RETURNS: |
|---|
| 3968 | | - * 0 on success, -errno otherwise. |
|---|
| 3969 | | - */ |
|---|
| 3970 | | -int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy, |
|---|
| 3971 | | - bool spm_wakeup) |
|---|
| 3972 | | -{ |
|---|
| 3973 | | - struct ata_eh_context *ehc = &link->eh_context; |
|---|
| 3974 | | - bool woken_up = false; |
|---|
| 3975 | | - u32 scontrol; |
|---|
| 3976 | | - int rc; |
|---|
| 3977 | | - |
|---|
| 3978 | | - rc = sata_scr_read(link, SCR_CONTROL, &scontrol); |
|---|
| 3979 | | - if (rc) |
|---|
| 3980 | | - return rc; |
|---|
| 3981 | | - |
|---|
| 3982 | | - switch (policy) { |
|---|
| 3983 | | - case ATA_LPM_MAX_POWER: |
|---|
| 3984 | | - /* disable all LPM transitions */ |
|---|
| 3985 | | - scontrol |= (0x7 << 8); |
|---|
| 3986 | | - /* initiate transition to active state */ |
|---|
| 3987 | | - if (spm_wakeup) { |
|---|
| 3988 | | - scontrol |= (0x4 << 12); |
|---|
| 3989 | | - woken_up = true; |
|---|
| 3990 | | - } |
|---|
| 3991 | | - break; |
|---|
| 3992 | | - case ATA_LPM_MED_POWER: |
|---|
| 3993 | | - /* allow LPM to PARTIAL */ |
|---|
| 3994 | | - scontrol &= ~(0x1 << 8); |
|---|
| 3995 | | - scontrol |= (0x6 << 8); |
|---|
| 3996 | | - break; |
|---|
| 3997 | | - case ATA_LPM_MED_POWER_WITH_DIPM: |
|---|
| 3998 | | - case ATA_LPM_MIN_POWER_WITH_PARTIAL: |
|---|
| 3999 | | - case ATA_LPM_MIN_POWER: |
|---|
| 4000 | | - if (ata_link_nr_enabled(link) > 0) |
|---|
| 4001 | | - /* no restrictions on LPM transitions */ |
|---|
| 4002 | | - scontrol &= ~(0x7 << 8); |
|---|
| 4003 | | - else { |
|---|
| 4004 | | - /* empty port, power off */ |
|---|
| 4005 | | - scontrol &= ~0xf; |
|---|
| 4006 | | - scontrol |= (0x1 << 2); |
|---|
| 4007 | | - } |
|---|
| 4008 | | - break; |
|---|
| 4009 | | - default: |
|---|
| 4010 | | - WARN_ON(1); |
|---|
| 4011 | | - } |
|---|
| 4012 | | - |
|---|
| 4013 | | - rc = sata_scr_write(link, SCR_CONTROL, scontrol); |
|---|
| 4014 | | - if (rc) |
|---|
| 4015 | | - return rc; |
|---|
| 4016 | | - |
|---|
| 4017 | | - /* give the link time to transit out of LPM state */ |
|---|
| 4018 | | - if (woken_up) |
|---|
| 4019 | | - msleep(10); |
|---|
| 4020 | | - |
|---|
| 4021 | | - /* clear PHYRDY_CHG from SError */ |
|---|
| 4022 | | - ehc->i.serror &= ~SERR_PHYRDY_CHG; |
|---|
| 4023 | | - return sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG); |
|---|
| 4024 | | -} |
|---|
| 3511 | +EXPORT_SYMBOL_GPL(ata_wait_after_reset); |
|---|
| 4025 | 3512 | |
|---|
| 4026 | 3513 | /** |
|---|
| 4027 | 3514 | * ata_std_prereset - prepare for reset |
|---|
| .. | .. |
|---|
| 4067 | 3554 | |
|---|
| 4068 | 3555 | return 0; |
|---|
| 4069 | 3556 | } |
|---|
| 4070 | | - |
|---|
| 4071 | | -/** |
|---|
| 4072 | | - * sata_link_hardreset - reset link via SATA phy reset |
|---|
| 4073 | | - * @link: link to reset |
|---|
| 4074 | | - * @timing: timing parameters { interval, duration, timeout } in msec |
|---|
| 4075 | | - * @deadline: deadline jiffies for the operation |
|---|
| 4076 | | - * @online: optional out parameter indicating link onlineness |
|---|
| 4077 | | - * @check_ready: optional callback to check link readiness |
|---|
| 4078 | | - * |
|---|
| 4079 | | - * SATA phy-reset @link using DET bits of SControl register. |
|---|
| 4080 | | - * After hardreset, link readiness is waited upon using |
|---|
| 4081 | | - * ata_wait_ready() if @check_ready is specified. LLDs are |
|---|
| 4082 | | - * allowed to not specify @check_ready and wait itself after this |
|---|
| 4083 | | - * function returns. Device classification is LLD's |
|---|
| 4084 | | - * responsibility. |
|---|
| 4085 | | - * |
|---|
| 4086 | | - * *@online is set to one iff reset succeeded and @link is online |
|---|
| 4087 | | - * after reset. |
|---|
| 4088 | | - * |
|---|
| 4089 | | - * LOCKING: |
|---|
| 4090 | | - * Kernel thread context (may sleep) |
|---|
| 4091 | | - * |
|---|
| 4092 | | - * RETURNS: |
|---|
| 4093 | | - * 0 on success, -errno otherwise. |
|---|
| 4094 | | - */ |
|---|
| 4095 | | -int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, |
|---|
| 4096 | | - unsigned long deadline, |
|---|
| 4097 | | - bool *online, int (*check_ready)(struct ata_link *)) |
|---|
| 4098 | | -{ |
|---|
| 4099 | | - u32 scontrol; |
|---|
| 4100 | | - int rc; |
|---|
| 4101 | | - |
|---|
| 4102 | | - DPRINTK("ENTER\n"); |
|---|
| 4103 | | - |
|---|
| 4104 | | - if (online) |
|---|
| 4105 | | - *online = false; |
|---|
| 4106 | | - |
|---|
| 4107 | | - if (sata_set_spd_needed(link)) { |
|---|
| 4108 | | - /* SATA spec says nothing about how to reconfigure |
|---|
| 4109 | | - * spd. To be on the safe side, turn off phy during |
|---|
| 4110 | | - * reconfiguration. This works for at least ICH7 AHCI |
|---|
| 4111 | | - * and Sil3124. |
|---|
| 4112 | | - */ |
|---|
| 4113 | | - if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) |
|---|
| 4114 | | - goto out; |
|---|
| 4115 | | - |
|---|
| 4116 | | - scontrol = (scontrol & 0x0f0) | 0x304; |
|---|
| 4117 | | - |
|---|
| 4118 | | - if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) |
|---|
| 4119 | | - goto out; |
|---|
| 4120 | | - |
|---|
| 4121 | | - sata_set_spd(link); |
|---|
| 4122 | | - } |
|---|
| 4123 | | - |
|---|
| 4124 | | - /* issue phy wake/reset */ |
|---|
| 4125 | | - if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) |
|---|
| 4126 | | - goto out; |
|---|
| 4127 | | - |
|---|
| 4128 | | - scontrol = (scontrol & 0x0f0) | 0x301; |
|---|
| 4129 | | - |
|---|
| 4130 | | - if ((rc = sata_scr_write_flush(link, SCR_CONTROL, scontrol))) |
|---|
| 4131 | | - goto out; |
|---|
| 4132 | | - |
|---|
| 4133 | | - /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 |
|---|
| 4134 | | - * 10.4.2 says at least 1 ms. |
|---|
| 4135 | | - */ |
|---|
| 4136 | | - ata_msleep(link->ap, 1); |
|---|
| 4137 | | - |
|---|
| 4138 | | - /* bring link back */ |
|---|
| 4139 | | - rc = sata_link_resume(link, timing, deadline); |
|---|
| 4140 | | - if (rc) |
|---|
| 4141 | | - goto out; |
|---|
| 4142 | | - /* if link is offline nothing more to do */ |
|---|
| 4143 | | - if (ata_phys_link_offline(link)) |
|---|
| 4144 | | - goto out; |
|---|
| 4145 | | - |
|---|
| 4146 | | - /* Link is online. From this point, -ENODEV too is an error. */ |
|---|
| 4147 | | - if (online) |
|---|
| 4148 | | - *online = true; |
|---|
| 4149 | | - |
|---|
| 4150 | | - if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) { |
|---|
| 4151 | | - /* If PMP is supported, we have to do follow-up SRST. |
|---|
| 4152 | | - * Some PMPs don't send D2H Reg FIS after hardreset if |
|---|
| 4153 | | - * the first port is empty. Wait only for |
|---|
| 4154 | | - * ATA_TMOUT_PMP_SRST_WAIT. |
|---|
| 4155 | | - */ |
|---|
| 4156 | | - if (check_ready) { |
|---|
| 4157 | | - unsigned long pmp_deadline; |
|---|
| 4158 | | - |
|---|
| 4159 | | - pmp_deadline = ata_deadline(jiffies, |
|---|
| 4160 | | - ATA_TMOUT_PMP_SRST_WAIT); |
|---|
| 4161 | | - if (time_after(pmp_deadline, deadline)) |
|---|
| 4162 | | - pmp_deadline = deadline; |
|---|
| 4163 | | - ata_wait_ready(link, pmp_deadline, check_ready); |
|---|
| 4164 | | - } |
|---|
| 4165 | | - rc = -EAGAIN; |
|---|
| 4166 | | - goto out; |
|---|
| 4167 | | - } |
|---|
| 4168 | | - |
|---|
| 4169 | | - rc = 0; |
|---|
| 4170 | | - if (check_ready) |
|---|
| 4171 | | - rc = ata_wait_ready(link, deadline, check_ready); |
|---|
| 4172 | | - out: |
|---|
| 4173 | | - if (rc && rc != -EAGAIN) { |
|---|
| 4174 | | - /* online is set iff link is online && reset succeeded */ |
|---|
| 4175 | | - if (online) |
|---|
| 4176 | | - *online = false; |
|---|
| 4177 | | - ata_link_err(link, "COMRESET failed (errno=%d)\n", rc); |
|---|
| 4178 | | - } |
|---|
| 4179 | | - DPRINTK("EXIT, rc=%d\n", rc); |
|---|
| 4180 | | - return rc; |
|---|
| 4181 | | -} |
|---|
| 3557 | +EXPORT_SYMBOL_GPL(ata_std_prereset); |
|---|
| 4182 | 3558 | |
|---|
| 4183 | 3559 | /** |
|---|
| 4184 | 3560 | * sata_std_hardreset - COMRESET w/o waiting or classification |
|---|
| .. | .. |
|---|
| 4205 | 3581 | rc = sata_link_hardreset(link, timing, deadline, &online, NULL); |
|---|
| 4206 | 3582 | return online ? -EAGAIN : rc; |
|---|
| 4207 | 3583 | } |
|---|
| 3584 | +EXPORT_SYMBOL_GPL(sata_std_hardreset); |
|---|
| 4208 | 3585 | |
|---|
| 4209 | 3586 | /** |
|---|
| 4210 | 3587 | * ata_std_postreset - standard postreset callback |
|---|
| .. | .. |
|---|
| 4233 | 3610 | |
|---|
| 4234 | 3611 | DPRINTK("EXIT\n"); |
|---|
| 4235 | 3612 | } |
|---|
| 3613 | +EXPORT_SYMBOL_GPL(ata_std_postreset); |
|---|
| 4236 | 3614 | |
|---|
| 4237 | 3615 | /** |
|---|
| 4238 | 3616 | * ata_dev_same_device - Determine whether new ID matches configured device |
|---|
| .. | .. |
|---|
| 4505 | 3883 | |
|---|
| 4506 | 3884 | /* drives which fail FPDMA_AA activation (some may freeze afterwards) |
|---|
| 4507 | 3885 | the ST disks also have LPM issues */ |
|---|
| 4508 | | - { "ST1000LM024 HN-M101MBB", "2AR10001", ATA_HORKAGE_BROKEN_FPDMA_AA | |
|---|
| 4509 | | - ATA_HORKAGE_NOLPM, }, |
|---|
| 4510 | | - { "ST1000LM024 HN-M101MBB", "2BA30001", ATA_HORKAGE_BROKEN_FPDMA_AA | |
|---|
| 3886 | + { "ST1000LM024 HN-M101MBB", NULL, ATA_HORKAGE_BROKEN_FPDMA_AA | |
|---|
| 4511 | 3887 | ATA_HORKAGE_NOLPM, }, |
|---|
| 4512 | 3888 | { "VB0250EAVER", "HPG7", ATA_HORKAGE_BROKEN_FPDMA_AA }, |
|---|
| 4513 | 3889 | |
|---|
| .. | .. |
|---|
| 4560 | 3936 | { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, |
|---|
| 4561 | 3937 | { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, |
|---|
| 4562 | 3938 | |
|---|
| 3939 | + /* These specific Pioneer models have LPM issues */ |
|---|
| 3940 | + { "PIONEER BD-RW BDR-207M", NULL, ATA_HORKAGE_NOLPM }, |
|---|
| 3941 | + { "PIONEER BD-RW BDR-205", NULL, ATA_HORKAGE_NOLPM }, |
|---|
| 3942 | + |
|---|
| 4563 | 3943 | /* Crucial BX100 SSD 500GB has broken LPM support */ |
|---|
| 4564 | 3944 | { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM }, |
|---|
| 4565 | 3945 | |
|---|
| .. | .. |
|---|
| 4597 | 3977 | { "Crucial_CT*M550*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | |
|---|
| 4598 | 3978 | ATA_HORKAGE_ZERO_AFTER_TRIM, }, |
|---|
| 4599 | 3979 | { "Crucial_CT*MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | |
|---|
| 3980 | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, |
|---|
| 3981 | + { "Samsung SSD 840 EVO*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | |
|---|
| 3982 | + ATA_HORKAGE_NO_DMA_LOG | |
|---|
| 4600 | 3983 | ATA_HORKAGE_ZERO_AFTER_TRIM, }, |
|---|
| 4601 | 3984 | { "Samsung SSD 840*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | |
|---|
| 4602 | 3985 | ATA_HORKAGE_ZERO_AFTER_TRIM, }, |
|---|
| .. | .. |
|---|
| 5030 | 4413 | |
|---|
| 5031 | 4414 | return ATA_DEFER_LINK; |
|---|
| 5032 | 4415 | } |
|---|
| 4416 | +EXPORT_SYMBOL_GPL(ata_std_qc_defer); |
|---|
| 5033 | 4417 | |
|---|
| 5034 | 4418 | enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc) |
|---|
| 5035 | 4419 | { |
|---|
| 5036 | 4420 | return AC_ERR_OK; |
|---|
| 5037 | 4421 | } |
|---|
| 4422 | +EXPORT_SYMBOL_GPL(ata_noop_qc_prep); |
|---|
| 5038 | 4423 | |
|---|
| 5039 | 4424 | /** |
|---|
| 5040 | 4425 | * ata_sg_init - Associate command with scatter-gather table. |
|---|
| .. | .. |
|---|
| 5350 | 4735 | qc->tf.feature != SETFEATURES_RA_ON && |
|---|
| 5351 | 4736 | qc->tf.feature != SETFEATURES_RA_OFF) |
|---|
| 5352 | 4737 | break; |
|---|
| 5353 | | - /* fall through */ |
|---|
| 4738 | + fallthrough; |
|---|
| 5354 | 4739 | case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ |
|---|
| 5355 | 4740 | case ATA_CMD_SET_MULTI: /* multi_count changed */ |
|---|
| 5356 | 4741 | /* revalidate device */ |
|---|
| .. | .. |
|---|
| 5378 | 4763 | __ata_qc_complete(qc); |
|---|
| 5379 | 4764 | } |
|---|
| 5380 | 4765 | } |
|---|
| 4766 | +EXPORT_SYMBOL_GPL(ata_qc_complete); |
|---|
| 5381 | 4767 | |
|---|
| 5382 | 4768 | /** |
|---|
| 5383 | 4769 | * ata_qc_get_active - get bitmask of active qcs |
|---|
| .. | .. |
|---|
| 5402 | 4788 | return qc_active; |
|---|
| 5403 | 4789 | } |
|---|
| 5404 | 4790 | EXPORT_SYMBOL_GPL(ata_qc_get_active); |
|---|
| 5405 | | - |
|---|
| 5406 | | -/** |
|---|
| 5407 | | - * ata_qc_complete_multiple - Complete multiple qcs successfully |
|---|
| 5408 | | - * @ap: port in question |
|---|
| 5409 | | - * @qc_active: new qc_active mask |
|---|
| 5410 | | - * |
|---|
| 5411 | | - * Complete in-flight commands. This functions is meant to be |
|---|
| 5412 | | - * called from low-level driver's interrupt routine to complete |
|---|
| 5413 | | - * requests normally. ap->qc_active and @qc_active is compared |
|---|
| 5414 | | - * and commands are completed accordingly. |
|---|
| 5415 | | - * |
|---|
| 5416 | | - * Always use this function when completing multiple NCQ commands |
|---|
| 5417 | | - * from IRQ handlers instead of calling ata_qc_complete() |
|---|
| 5418 | | - * multiple times to keep IRQ expect status properly in sync. |
|---|
| 5419 | | - * |
|---|
| 5420 | | - * LOCKING: |
|---|
| 5421 | | - * spin_lock_irqsave(host lock) |
|---|
| 5422 | | - * |
|---|
| 5423 | | - * RETURNS: |
|---|
| 5424 | | - * Number of completed commands on success, -errno otherwise. |
|---|
| 5425 | | - */ |
|---|
| 5426 | | -int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active) |
|---|
| 5427 | | -{ |
|---|
| 5428 | | - u64 done_mask, ap_qc_active = ap->qc_active; |
|---|
| 5429 | | - int nr_done = 0; |
|---|
| 5430 | | - |
|---|
| 5431 | | - /* |
|---|
| 5432 | | - * If the internal tag is set on ap->qc_active, then we care about |
|---|
| 5433 | | - * bit0 on the passed in qc_active mask. Move that bit up to match |
|---|
| 5434 | | - * the internal tag. |
|---|
| 5435 | | - */ |
|---|
| 5436 | | - if (ap_qc_active & (1ULL << ATA_TAG_INTERNAL)) { |
|---|
| 5437 | | - qc_active |= (qc_active & 0x01) << ATA_TAG_INTERNAL; |
|---|
| 5438 | | - qc_active ^= qc_active & 0x01; |
|---|
| 5439 | | - } |
|---|
| 5440 | | - |
|---|
| 5441 | | - done_mask = ap_qc_active ^ qc_active; |
|---|
| 5442 | | - |
|---|
| 5443 | | - if (unlikely(done_mask & qc_active)) { |
|---|
| 5444 | | - ata_port_err(ap, "illegal qc_active transition (%08llx->%08llx)\n", |
|---|
| 5445 | | - ap->qc_active, qc_active); |
|---|
| 5446 | | - return -EINVAL; |
|---|
| 5447 | | - } |
|---|
| 5448 | | - |
|---|
| 5449 | | - while (done_mask) { |
|---|
| 5450 | | - struct ata_queued_cmd *qc; |
|---|
| 5451 | | - unsigned int tag = __ffs64(done_mask); |
|---|
| 5452 | | - |
|---|
| 5453 | | - qc = ata_qc_from_tag(ap, tag); |
|---|
| 5454 | | - if (qc) { |
|---|
| 5455 | | - ata_qc_complete(qc); |
|---|
| 5456 | | - nr_done++; |
|---|
| 5457 | | - } |
|---|
| 5458 | | - done_mask &= ~(1ULL << tag); |
|---|
| 5459 | | - } |
|---|
| 5460 | | - |
|---|
| 5461 | | - return nr_done; |
|---|
| 5462 | | -} |
|---|
| 5463 | 4791 | |
|---|
| 5464 | 4792 | /** |
|---|
| 5465 | 4793 | * ata_qc_issue - issue taskfile to device |
|---|
| .. | .. |
|---|
| 5537 | 4865 | } |
|---|
| 5538 | 4866 | |
|---|
| 5539 | 4867 | /** |
|---|
| 5540 | | - * sata_scr_valid - test whether SCRs are accessible |
|---|
| 5541 | | - * @link: ATA link to test SCR accessibility for |
|---|
| 5542 | | - * |
|---|
| 5543 | | - * Test whether SCRs are accessible for @link. |
|---|
| 5544 | | - * |
|---|
| 5545 | | - * LOCKING: |
|---|
| 5546 | | - * None. |
|---|
| 5547 | | - * |
|---|
| 5548 | | - * RETURNS: |
|---|
| 5549 | | - * 1 if SCRs are accessible, 0 otherwise. |
|---|
| 5550 | | - */ |
|---|
| 5551 | | -int sata_scr_valid(struct ata_link *link) |
|---|
| 5552 | | -{ |
|---|
| 5553 | | - struct ata_port *ap = link->ap; |
|---|
| 5554 | | - |
|---|
| 5555 | | - return (ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read; |
|---|
| 5556 | | -} |
|---|
| 5557 | | - |
|---|
| 5558 | | -/** |
|---|
| 5559 | | - * sata_scr_read - read SCR register of the specified port |
|---|
| 5560 | | - * @link: ATA link to read SCR for |
|---|
| 5561 | | - * @reg: SCR to read |
|---|
| 5562 | | - * @val: Place to store read value |
|---|
| 5563 | | - * |
|---|
| 5564 | | - * Read SCR register @reg of @link into *@val. This function is |
|---|
| 5565 | | - * guaranteed to succeed if @link is ap->link, the cable type of |
|---|
| 5566 | | - * the port is SATA and the port implements ->scr_read. |
|---|
| 5567 | | - * |
|---|
| 5568 | | - * LOCKING: |
|---|
| 5569 | | - * None if @link is ap->link. Kernel thread context otherwise. |
|---|
| 5570 | | - * |
|---|
| 5571 | | - * RETURNS: |
|---|
| 5572 | | - * 0 on success, negative errno on failure. |
|---|
| 5573 | | - */ |
|---|
| 5574 | | -int sata_scr_read(struct ata_link *link, int reg, u32 *val) |
|---|
| 5575 | | -{ |
|---|
| 5576 | | - if (ata_is_host_link(link)) { |
|---|
| 5577 | | - if (sata_scr_valid(link)) |
|---|
| 5578 | | - return link->ap->ops->scr_read(link, reg, val); |
|---|
| 5579 | | - return -EOPNOTSUPP; |
|---|
| 5580 | | - } |
|---|
| 5581 | | - |
|---|
| 5582 | | - return sata_pmp_scr_read(link, reg, val); |
|---|
| 5583 | | -} |
|---|
| 5584 | | - |
|---|
| 5585 | | -/** |
|---|
| 5586 | | - * sata_scr_write - write SCR register of the specified port |
|---|
| 5587 | | - * @link: ATA link to write SCR for |
|---|
| 5588 | | - * @reg: SCR to write |
|---|
| 5589 | | - * @val: value to write |
|---|
| 5590 | | - * |
|---|
| 5591 | | - * Write @val to SCR register @reg of @link. This function is |
|---|
| 5592 | | - * guaranteed to succeed if @link is ap->link, the cable type of |
|---|
| 5593 | | - * the port is SATA and the port implements ->scr_read. |
|---|
| 5594 | | - * |
|---|
| 5595 | | - * LOCKING: |
|---|
| 5596 | | - * None if @link is ap->link. Kernel thread context otherwise. |
|---|
| 5597 | | - * |
|---|
| 5598 | | - * RETURNS: |
|---|
| 5599 | | - * 0 on success, negative errno on failure. |
|---|
| 5600 | | - */ |
|---|
| 5601 | | -int sata_scr_write(struct ata_link *link, int reg, u32 val) |
|---|
| 5602 | | -{ |
|---|
| 5603 | | - if (ata_is_host_link(link)) { |
|---|
| 5604 | | - if (sata_scr_valid(link)) |
|---|
| 5605 | | - return link->ap->ops->scr_write(link, reg, val); |
|---|
| 5606 | | - return -EOPNOTSUPP; |
|---|
| 5607 | | - } |
|---|
| 5608 | | - |
|---|
| 5609 | | - return sata_pmp_scr_write(link, reg, val); |
|---|
| 5610 | | -} |
|---|
| 5611 | | - |
|---|
| 5612 | | -/** |
|---|
| 5613 | | - * sata_scr_write_flush - write SCR register of the specified port and flush |
|---|
| 5614 | | - * @link: ATA link to write SCR for |
|---|
| 5615 | | - * @reg: SCR to write |
|---|
| 5616 | | - * @val: value to write |
|---|
| 5617 | | - * |
|---|
| 5618 | | - * This function is identical to sata_scr_write() except that this |
|---|
| 5619 | | - * function performs flush after writing to the register. |
|---|
| 5620 | | - * |
|---|
| 5621 | | - * LOCKING: |
|---|
| 5622 | | - * None if @link is ap->link. Kernel thread context otherwise. |
|---|
| 5623 | | - * |
|---|
| 5624 | | - * RETURNS: |
|---|
| 5625 | | - * 0 on success, negative errno on failure. |
|---|
| 5626 | | - */ |
|---|
| 5627 | | -int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) |
|---|
| 5628 | | -{ |
|---|
| 5629 | | - if (ata_is_host_link(link)) { |
|---|
| 5630 | | - int rc; |
|---|
| 5631 | | - |
|---|
| 5632 | | - if (sata_scr_valid(link)) { |
|---|
| 5633 | | - rc = link->ap->ops->scr_write(link, reg, val); |
|---|
| 5634 | | - if (rc == 0) |
|---|
| 5635 | | - rc = link->ap->ops->scr_read(link, reg, &val); |
|---|
| 5636 | | - return rc; |
|---|
| 5637 | | - } |
|---|
| 5638 | | - return -EOPNOTSUPP; |
|---|
| 5639 | | - } |
|---|
| 5640 | | - |
|---|
| 5641 | | - return sata_pmp_scr_write(link, reg, val); |
|---|
| 5642 | | -} |
|---|
| 5643 | | - |
|---|
| 5644 | | -/** |
|---|
| 5645 | 4868 | * ata_phys_link_online - test whether the given link is online |
|---|
| 5646 | 4869 | * @link: ATA link to test |
|---|
| 5647 | 4870 | * |
|---|
| .. | .. |
|---|
| 5714 | 4937 | return ata_phys_link_online(link) || |
|---|
| 5715 | 4938 | (slave && ata_phys_link_online(slave)); |
|---|
| 5716 | 4939 | } |
|---|
| 4940 | +EXPORT_SYMBOL_GPL(ata_link_online); |
|---|
| 5717 | 4941 | |
|---|
| 5718 | 4942 | /** |
|---|
| 5719 | 4943 | * ata_link_offline - test whether the given link is offline |
|---|
| .. | .. |
|---|
| 5740 | 4964 | return ata_phys_link_offline(link) && |
|---|
| 5741 | 4965 | (!slave || ata_phys_link_offline(slave)); |
|---|
| 5742 | 4966 | } |
|---|
| 4967 | +EXPORT_SYMBOL_GPL(ata_link_offline); |
|---|
| 5743 | 4968 | |
|---|
| 5744 | 4969 | #ifdef CONFIG_PM |
|---|
| 5745 | 4970 | static void ata_port_request_pm(struct ata_port *ap, pm_message_t mesg, |
|---|
| .. | .. |
|---|
| 5926 | 5151 | host->dev->power.power_state = mesg; |
|---|
| 5927 | 5152 | return 0; |
|---|
| 5928 | 5153 | } |
|---|
| 5154 | +EXPORT_SYMBOL_GPL(ata_host_suspend); |
|---|
| 5929 | 5155 | |
|---|
| 5930 | 5156 | /** |
|---|
| 5931 | 5157 | * ata_host_resume - resume host |
|---|
| .. | .. |
|---|
| 5937 | 5163 | { |
|---|
| 5938 | 5164 | host->dev->power.power_state = PMSG_ON; |
|---|
| 5939 | 5165 | } |
|---|
| 5166 | +EXPORT_SYMBOL_GPL(ata_host_resume); |
|---|
| 5940 | 5167 | #endif |
|---|
| 5941 | 5168 | |
|---|
| 5942 | 5169 | const struct device_type ata_port_type = { |
|---|
| .. | .. |
|---|
| 6022 | 5249 | * sata_link_init_spd - Initialize link->sata_spd_limit |
|---|
| 6023 | 5250 | * @link: Link to configure sata_spd_limit for |
|---|
| 6024 | 5251 | * |
|---|
| 6025 | | - * Initialize @link->[hw_]sata_spd_limit to the currently |
|---|
| 5252 | + * Initialize ``link->[hw_]sata_spd_limit`` to the currently |
|---|
| 6026 | 5253 | * configured value. |
|---|
| 6027 | 5254 | * |
|---|
| 6028 | 5255 | * LOCKING: |
|---|
| .. | .. |
|---|
| 6156 | 5383 | { |
|---|
| 6157 | 5384 | kref_put(&host->kref, ata_host_release); |
|---|
| 6158 | 5385 | } |
|---|
| 5386 | +EXPORT_SYMBOL_GPL(ata_host_put); |
|---|
| 6159 | 5387 | |
|---|
| 6160 | 5388 | /** |
|---|
| 6161 | 5389 | * ata_host_alloc - allocate and init basic ATA host resources |
|---|
| .. | .. |
|---|
| 6229 | 5457 | kfree(host); |
|---|
| 6230 | 5458 | return NULL; |
|---|
| 6231 | 5459 | } |
|---|
| 5460 | +EXPORT_SYMBOL_GPL(ata_host_alloc); |
|---|
| 6232 | 5461 | |
|---|
| 6233 | 5462 | /** |
|---|
| 6234 | 5463 | * ata_host_alloc_pinfo - alloc host and init with port_info array |
|---|
| .. | .. |
|---|
| 6250 | 5479 | const struct ata_port_info * const * ppi, |
|---|
| 6251 | 5480 | int n_ports) |
|---|
| 6252 | 5481 | { |
|---|
| 6253 | | - const struct ata_port_info *pi; |
|---|
| 5482 | + const struct ata_port_info *pi = &ata_dummy_port_info; |
|---|
| 6254 | 5483 | struct ata_host *host; |
|---|
| 6255 | 5484 | int i, j; |
|---|
| 6256 | 5485 | |
|---|
| .. | .. |
|---|
| 6258 | 5487 | if (!host) |
|---|
| 6259 | 5488 | return NULL; |
|---|
| 6260 | 5489 | |
|---|
| 6261 | | - for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) { |
|---|
| 5490 | + for (i = 0, j = 0; i < host->n_ports; i++) { |
|---|
| 6262 | 5491 | struct ata_port *ap = host->ports[i]; |
|---|
| 6263 | 5492 | |
|---|
| 6264 | 5493 | if (ppi[j]) |
|---|
| .. | .. |
|---|
| 6277 | 5506 | |
|---|
| 6278 | 5507 | return host; |
|---|
| 6279 | 5508 | } |
|---|
| 6280 | | - |
|---|
| 6281 | | -/** |
|---|
| 6282 | | - * ata_slave_link_init - initialize slave link |
|---|
| 6283 | | - * @ap: port to initialize slave link for |
|---|
| 6284 | | - * |
|---|
| 6285 | | - * Create and initialize slave link for @ap. This enables slave |
|---|
| 6286 | | - * link handling on the port. |
|---|
| 6287 | | - * |
|---|
| 6288 | | - * In libata, a port contains links and a link contains devices. |
|---|
| 6289 | | - * There is single host link but if a PMP is attached to it, |
|---|
| 6290 | | - * there can be multiple fan-out links. On SATA, there's usually |
|---|
| 6291 | | - * a single device connected to a link but PATA and SATA |
|---|
| 6292 | | - * controllers emulating TF based interface can have two - master |
|---|
| 6293 | | - * and slave. |
|---|
| 6294 | | - * |
|---|
| 6295 | | - * However, there are a few controllers which don't fit into this |
|---|
| 6296 | | - * abstraction too well - SATA controllers which emulate TF |
|---|
| 6297 | | - * interface with both master and slave devices but also have |
|---|
| 6298 | | - * separate SCR register sets for each device. These controllers |
|---|
| 6299 | | - * need separate links for physical link handling |
|---|
| 6300 | | - * (e.g. onlineness, link speed) but should be treated like a |
|---|
| 6301 | | - * traditional M/S controller for everything else (e.g. command |
|---|
| 6302 | | - * issue, softreset). |
|---|
| 6303 | | - * |
|---|
| 6304 | | - * slave_link is libata's way of handling this class of |
|---|
| 6305 | | - * controllers without impacting core layer too much. For |
|---|
| 6306 | | - * anything other than physical link handling, the default host |
|---|
| 6307 | | - * link is used for both master and slave. For physical link |
|---|
| 6308 | | - * handling, separate @ap->slave_link is used. All dirty details |
|---|
| 6309 | | - * are implemented inside libata core layer. From LLD's POV, the |
|---|
| 6310 | | - * only difference is that prereset, hardreset and postreset are |
|---|
| 6311 | | - * called once more for the slave link, so the reset sequence |
|---|
| 6312 | | - * looks like the following. |
|---|
| 6313 | | - * |
|---|
| 6314 | | - * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) -> |
|---|
| 6315 | | - * softreset(M) -> postreset(M) -> postreset(S) |
|---|
| 6316 | | - * |
|---|
| 6317 | | - * Note that softreset is called only for the master. Softreset |
|---|
| 6318 | | - * resets both M/S by definition, so SRST on master should handle |
|---|
| 6319 | | - * both (the standard method will work just fine). |
|---|
| 6320 | | - * |
|---|
| 6321 | | - * LOCKING: |
|---|
| 6322 | | - * Should be called before host is registered. |
|---|
| 6323 | | - * |
|---|
| 6324 | | - * RETURNS: |
|---|
| 6325 | | - * 0 on success, -errno on failure. |
|---|
| 6326 | | - */ |
|---|
| 6327 | | -int ata_slave_link_init(struct ata_port *ap) |
|---|
| 6328 | | -{ |
|---|
| 6329 | | - struct ata_link *link; |
|---|
| 6330 | | - |
|---|
| 6331 | | - WARN_ON(ap->slave_link); |
|---|
| 6332 | | - WARN_ON(ap->flags & ATA_FLAG_PMP); |
|---|
| 6333 | | - |
|---|
| 6334 | | - link = kzalloc(sizeof(*link), GFP_KERNEL); |
|---|
| 6335 | | - if (!link) |
|---|
| 6336 | | - return -ENOMEM; |
|---|
| 6337 | | - |
|---|
| 6338 | | - ata_link_init(ap, link, 1); |
|---|
| 6339 | | - ap->slave_link = link; |
|---|
| 6340 | | - return 0; |
|---|
| 6341 | | -} |
|---|
| 5509 | +EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); |
|---|
| 6342 | 5510 | |
|---|
| 6343 | 5511 | static void ata_host_stop(struct device *gendev, void *res) |
|---|
| 6344 | 5512 | { |
|---|
| .. | .. |
|---|
| 6487 | 5655 | devres_free(start_dr); |
|---|
| 6488 | 5656 | return rc; |
|---|
| 6489 | 5657 | } |
|---|
| 5658 | +EXPORT_SYMBOL_GPL(ata_host_start); |
|---|
| 6490 | 5659 | |
|---|
| 6491 | 5660 | /** |
|---|
| 6492 | | - * ata_sas_host_init - Initialize a host struct for sas (ipr, libsas) |
|---|
| 5661 | + * ata_host_init - Initialize a host struct for sas (ipr, libsas) |
|---|
| 6493 | 5662 | * @host: host to initialize |
|---|
| 6494 | 5663 | * @dev: device host is attached to |
|---|
| 6495 | 5664 | * @ops: port_ops |
|---|
| .. | .. |
|---|
| 6505 | 5674 | host->ops = ops; |
|---|
| 6506 | 5675 | kref_init(&host->kref); |
|---|
| 6507 | 5676 | } |
|---|
| 5677 | +EXPORT_SYMBOL_GPL(ata_host_init); |
|---|
| 6508 | 5678 | |
|---|
| 6509 | 5679 | void __ata_port_probe(struct ata_port *ap) |
|---|
| 6510 | 5680 | { |
|---|
| .. | .. |
|---|
| 6660 | 5830 | return rc; |
|---|
| 6661 | 5831 | |
|---|
| 6662 | 5832 | } |
|---|
| 5833 | +EXPORT_SYMBOL_GPL(ata_host_register); |
|---|
| 6663 | 5834 | |
|---|
| 6664 | 5835 | /** |
|---|
| 6665 | 5836 | * ata_host_activate - start host, request IRQ and register it |
|---|
| .. | .. |
|---|
| 6722 | 5893 | |
|---|
| 6723 | 5894 | return rc; |
|---|
| 6724 | 5895 | } |
|---|
| 5896 | +EXPORT_SYMBOL_GPL(ata_host_activate); |
|---|
| 6725 | 5897 | |
|---|
| 6726 | 5898 | /** |
|---|
| 6727 | 5899 | * ata_port_detach - Detach ATA port in preparation of device removal |
|---|
| .. | .. |
|---|
| 6797 | 5969 | /* the host is dead now, dissociate ACPI */ |
|---|
| 6798 | 5970 | ata_acpi_dissociate(host); |
|---|
| 6799 | 5971 | } |
|---|
| 5972 | +EXPORT_SYMBOL_GPL(ata_host_detach); |
|---|
| 6800 | 5973 | |
|---|
| 6801 | 5974 | #ifdef CONFIG_PCI |
|---|
| 6802 | 5975 | |
|---|
| .. | .. |
|---|
| 6817 | 5990 | |
|---|
| 6818 | 5991 | ata_host_detach(host); |
|---|
| 6819 | 5992 | } |
|---|
| 5993 | +EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
|---|
| 6820 | 5994 | |
|---|
| 6821 | 5995 | void ata_pci_shutdown_one(struct pci_dev *pdev) |
|---|
| 6822 | 5996 | { |
|---|
| .. | .. |
|---|
| 6837 | 6011 | ap->ops->port_stop(ap); |
|---|
| 6838 | 6012 | } |
|---|
| 6839 | 6013 | } |
|---|
| 6014 | +EXPORT_SYMBOL_GPL(ata_pci_shutdown_one); |
|---|
| 6840 | 6015 | |
|---|
| 6841 | 6016 | /* move to PCI subsystem */ |
|---|
| 6842 | 6017 | int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) |
|---|
| .. | .. |
|---|
| 6871 | 6046 | |
|---|
| 6872 | 6047 | return (tmp == bits->val) ? 1 : 0; |
|---|
| 6873 | 6048 | } |
|---|
| 6049 | +EXPORT_SYMBOL_GPL(pci_test_config_bits); |
|---|
| 6874 | 6050 | |
|---|
| 6875 | 6051 | #ifdef CONFIG_PM |
|---|
| 6876 | 6052 | void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg) |
|---|
| .. | .. |
|---|
| 6881 | 6057 | if (mesg.event & PM_EVENT_SLEEP) |
|---|
| 6882 | 6058 | pci_set_power_state(pdev, PCI_D3hot); |
|---|
| 6883 | 6059 | } |
|---|
| 6060 | +EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend); |
|---|
| 6884 | 6061 | |
|---|
| 6885 | 6062 | int ata_pci_device_do_resume(struct pci_dev *pdev) |
|---|
| 6886 | 6063 | { |
|---|
| .. | .. |
|---|
| 6899 | 6076 | pci_set_master(pdev); |
|---|
| 6900 | 6077 | return 0; |
|---|
| 6901 | 6078 | } |
|---|
| 6079 | +EXPORT_SYMBOL_GPL(ata_pci_device_do_resume); |
|---|
| 6902 | 6080 | |
|---|
| 6903 | 6081 | int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) |
|---|
| 6904 | 6082 | { |
|---|
| .. | .. |
|---|
| 6913 | 6091 | |
|---|
| 6914 | 6092 | return 0; |
|---|
| 6915 | 6093 | } |
|---|
| 6094 | +EXPORT_SYMBOL_GPL(ata_pci_device_suspend); |
|---|
| 6916 | 6095 | |
|---|
| 6917 | 6096 | int ata_pci_device_resume(struct pci_dev *pdev) |
|---|
| 6918 | 6097 | { |
|---|
| .. | .. |
|---|
| 6924 | 6103 | ata_host_resume(host); |
|---|
| 6925 | 6104 | return rc; |
|---|
| 6926 | 6105 | } |
|---|
| 6106 | +EXPORT_SYMBOL_GPL(ata_pci_device_resume); |
|---|
| 6927 | 6107 | #endif /* CONFIG_PM */ |
|---|
| 6928 | | - |
|---|
| 6929 | 6108 | #endif /* CONFIG_PCI */ |
|---|
| 6930 | 6109 | |
|---|
| 6931 | 6110 | /** |
|---|
| .. | .. |
|---|
| 6947 | 6126 | |
|---|
| 6948 | 6127 | return 0; |
|---|
| 6949 | 6128 | } |
|---|
| 6129 | +EXPORT_SYMBOL_GPL(ata_platform_remove_one); |
|---|
| 6950 | 6130 | |
|---|
| 6131 | +#ifdef CONFIG_ATA_FORCE |
|---|
| 6951 | 6132 | static int __init ata_parse_force_one(char **cur, |
|---|
| 6952 | 6133 | struct ata_force_ent *force_ent, |
|---|
| 6953 | 6134 | const char **reason) |
|---|
| .. | .. |
|---|
| 7129 | 6310 | ata_force_tbl_size = idx; |
|---|
| 7130 | 6311 | } |
|---|
| 7131 | 6312 | |
|---|
| 6313 | +static void ata_free_force_param(void) |
|---|
| 6314 | +{ |
|---|
| 6315 | + kfree(ata_force_tbl); |
|---|
| 6316 | +} |
|---|
| 6317 | +#else |
|---|
| 6318 | +static inline void ata_parse_force_param(void) { } |
|---|
| 6319 | +static inline void ata_free_force_param(void) { } |
|---|
| 6320 | +#endif |
|---|
| 6321 | + |
|---|
| 7132 | 6322 | static int __init ata_init(void) |
|---|
| 7133 | 6323 | { |
|---|
| 7134 | 6324 | int rc; |
|---|
| .. | .. |
|---|
| 7137 | 6327 | |
|---|
| 7138 | 6328 | rc = ata_sff_init(); |
|---|
| 7139 | 6329 | if (rc) { |
|---|
| 7140 | | - kfree(ata_force_tbl); |
|---|
| 6330 | + ata_free_force_param(); |
|---|
| 7141 | 6331 | return rc; |
|---|
| 7142 | 6332 | } |
|---|
| 7143 | 6333 | |
|---|
| .. | .. |
|---|
| 7161 | 6351 | ata_release_transport(ata_scsi_transport_template); |
|---|
| 7162 | 6352 | libata_transport_exit(); |
|---|
| 7163 | 6353 | ata_sff_exit(); |
|---|
| 7164 | | - kfree(ata_force_tbl); |
|---|
| 6354 | + ata_free_force_param(); |
|---|
| 7165 | 6355 | } |
|---|
| 7166 | 6356 | |
|---|
| 7167 | 6357 | subsys_initcall(ata_init); |
|---|
| .. | .. |
|---|
| 7173 | 6363 | { |
|---|
| 7174 | 6364 | return __ratelimit(&ratelimit); |
|---|
| 7175 | 6365 | } |
|---|
| 6366 | +EXPORT_SYMBOL_GPL(ata_ratelimit); |
|---|
| 7176 | 6367 | |
|---|
| 7177 | 6368 | /** |
|---|
| 7178 | 6369 | * ata_msleep - ATA EH owner aware msleep |
|---|
| .. | .. |
|---|
| 7205 | 6396 | if (owns_eh) |
|---|
| 7206 | 6397 | ata_eh_acquire(ap); |
|---|
| 7207 | 6398 | } |
|---|
| 6399 | +EXPORT_SYMBOL_GPL(ata_msleep); |
|---|
| 7208 | 6400 | |
|---|
| 7209 | 6401 | /** |
|---|
| 7210 | 6402 | * ata_wait_register - wait until register value changes |
|---|
| .. | .. |
|---|
| 7251 | 6443 | |
|---|
| 7252 | 6444 | return tmp; |
|---|
| 7253 | 6445 | } |
|---|
| 7254 | | - |
|---|
| 7255 | | -/** |
|---|
| 7256 | | - * sata_lpm_ignore_phy_events - test if PHY event should be ignored |
|---|
| 7257 | | - * @link: Link receiving the event |
|---|
| 7258 | | - * |
|---|
| 7259 | | - * Test whether the received PHY event has to be ignored or not. |
|---|
| 7260 | | - * |
|---|
| 7261 | | - * LOCKING: |
|---|
| 7262 | | - * None: |
|---|
| 7263 | | - * |
|---|
| 7264 | | - * RETURNS: |
|---|
| 7265 | | - * True if the event has to be ignored. |
|---|
| 7266 | | - */ |
|---|
| 7267 | | -bool sata_lpm_ignore_phy_events(struct ata_link *link) |
|---|
| 7268 | | -{ |
|---|
| 7269 | | - unsigned long lpm_timeout = link->last_lpm_change + |
|---|
| 7270 | | - msecs_to_jiffies(ATA_TMOUT_SPURIOUS_PHY); |
|---|
| 7271 | | - |
|---|
| 7272 | | - /* if LPM is enabled, PHYRDY doesn't mean anything */ |
|---|
| 7273 | | - if (link->lpm_policy > ATA_LPM_MAX_POWER) |
|---|
| 7274 | | - return true; |
|---|
| 7275 | | - |
|---|
| 7276 | | - /* ignore the first PHY event after the LPM policy changed |
|---|
| 7277 | | - * as it is might be spurious |
|---|
| 7278 | | - */ |
|---|
| 7279 | | - if ((link->flags & ATA_LFLAG_CHANGED) && |
|---|
| 7280 | | - time_before(jiffies, lpm_timeout)) |
|---|
| 7281 | | - return true; |
|---|
| 7282 | | - |
|---|
| 7283 | | - return false; |
|---|
| 7284 | | -} |
|---|
| 7285 | | -EXPORT_SYMBOL_GPL(sata_lpm_ignore_phy_events); |
|---|
| 6446 | +EXPORT_SYMBOL_GPL(ata_wait_register); |
|---|
| 7286 | 6447 | |
|---|
| 7287 | 6448 | /* |
|---|
| 7288 | 6449 | * Dummy port_ops |
|---|
| .. | .. |
|---|
| 7304 | 6465 | .sched_eh = ata_std_sched_eh, |
|---|
| 7305 | 6466 | .end_eh = ata_std_end_eh, |
|---|
| 7306 | 6467 | }; |
|---|
| 6468 | +EXPORT_SYMBOL_GPL(ata_dummy_port_ops); |
|---|
| 7307 | 6469 | |
|---|
| 7308 | 6470 | const struct ata_port_info ata_dummy_port_info = { |
|---|
| 7309 | 6471 | .port_ops = &ata_dummy_port_ops, |
|---|
| 7310 | 6472 | }; |
|---|
| 6473 | +EXPORT_SYMBOL_GPL(ata_dummy_port_info); |
|---|
| 7311 | 6474 | |
|---|
| 7312 | 6475 | /* |
|---|
| 7313 | 6476 | * Utility print functions |
|---|
| .. | .. |
|---|
| 7375 | 6538 | dev_printk(KERN_DEBUG, dev, "version %s\n", version); |
|---|
| 7376 | 6539 | } |
|---|
| 7377 | 6540 | EXPORT_SYMBOL(ata_print_version); |
|---|
| 7378 | | - |
|---|
| 7379 | | -/* |
|---|
| 7380 | | - * libata is essentially a library of internal helper functions for |
|---|
| 7381 | | - * low-level ATA host controller drivers. As such, the API/ABI is |
|---|
| 7382 | | - * likely to change as new drivers are added and updated. |
|---|
| 7383 | | - * Do not depend on ABI/API stability. |
|---|
| 7384 | | - */ |
|---|
| 7385 | | -EXPORT_SYMBOL_GPL(sata_deb_timing_normal); |
|---|
| 7386 | | -EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); |
|---|
| 7387 | | -EXPORT_SYMBOL_GPL(sata_deb_timing_long); |
|---|
| 7388 | | -EXPORT_SYMBOL_GPL(ata_base_port_ops); |
|---|
| 7389 | | -EXPORT_SYMBOL_GPL(sata_port_ops); |
|---|
| 7390 | | -EXPORT_SYMBOL_GPL(ata_dummy_port_ops); |
|---|
| 7391 | | -EXPORT_SYMBOL_GPL(ata_dummy_port_info); |
|---|
| 7392 | | -EXPORT_SYMBOL_GPL(ata_link_next); |
|---|
| 7393 | | -EXPORT_SYMBOL_GPL(ata_dev_next); |
|---|
| 7394 | | -EXPORT_SYMBOL_GPL(ata_std_bios_param); |
|---|
| 7395 | | -EXPORT_SYMBOL_GPL(ata_scsi_unlock_native_capacity); |
|---|
| 7396 | | -EXPORT_SYMBOL_GPL(ata_host_init); |
|---|
| 7397 | | -EXPORT_SYMBOL_GPL(ata_host_alloc); |
|---|
| 7398 | | -EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); |
|---|
| 7399 | | -EXPORT_SYMBOL_GPL(ata_slave_link_init); |
|---|
| 7400 | | -EXPORT_SYMBOL_GPL(ata_host_start); |
|---|
| 7401 | | -EXPORT_SYMBOL_GPL(ata_host_register); |
|---|
| 7402 | | -EXPORT_SYMBOL_GPL(ata_host_activate); |
|---|
| 7403 | | -EXPORT_SYMBOL_GPL(ata_host_detach); |
|---|
| 7404 | | -EXPORT_SYMBOL_GPL(ata_sg_init); |
|---|
| 7405 | | -EXPORT_SYMBOL_GPL(ata_qc_complete); |
|---|
| 7406 | | -EXPORT_SYMBOL_GPL(ata_qc_complete_multiple); |
|---|
| 7407 | | -EXPORT_SYMBOL_GPL(atapi_cmd_type); |
|---|
| 7408 | | -EXPORT_SYMBOL_GPL(ata_tf_to_fis); |
|---|
| 7409 | | -EXPORT_SYMBOL_GPL(ata_tf_from_fis); |
|---|
| 7410 | | -EXPORT_SYMBOL_GPL(ata_pack_xfermask); |
|---|
| 7411 | | -EXPORT_SYMBOL_GPL(ata_unpack_xfermask); |
|---|
| 7412 | | -EXPORT_SYMBOL_GPL(ata_xfer_mask2mode); |
|---|
| 7413 | | -EXPORT_SYMBOL_GPL(ata_xfer_mode2mask); |
|---|
| 7414 | | -EXPORT_SYMBOL_GPL(ata_xfer_mode2shift); |
|---|
| 7415 | | -EXPORT_SYMBOL_GPL(ata_mode_string); |
|---|
| 7416 | | -EXPORT_SYMBOL_GPL(ata_id_xfermask); |
|---|
| 7417 | | -EXPORT_SYMBOL_GPL(ata_do_set_mode); |
|---|
| 7418 | | -EXPORT_SYMBOL_GPL(ata_std_qc_defer); |
|---|
| 7419 | | -EXPORT_SYMBOL_GPL(ata_noop_qc_prep); |
|---|
| 7420 | | -EXPORT_SYMBOL_GPL(ata_dev_disable); |
|---|
| 7421 | | -EXPORT_SYMBOL_GPL(sata_set_spd); |
|---|
| 7422 | | -EXPORT_SYMBOL_GPL(ata_wait_after_reset); |
|---|
| 7423 | | -EXPORT_SYMBOL_GPL(sata_link_debounce); |
|---|
| 7424 | | -EXPORT_SYMBOL_GPL(sata_link_resume); |
|---|
| 7425 | | -EXPORT_SYMBOL_GPL(sata_link_scr_lpm); |
|---|
| 7426 | | -EXPORT_SYMBOL_GPL(ata_std_prereset); |
|---|
| 7427 | | -EXPORT_SYMBOL_GPL(sata_link_hardreset); |
|---|
| 7428 | | -EXPORT_SYMBOL_GPL(sata_std_hardreset); |
|---|
| 7429 | | -EXPORT_SYMBOL_GPL(ata_std_postreset); |
|---|
| 7430 | | -EXPORT_SYMBOL_GPL(ata_dev_classify); |
|---|
| 7431 | | -EXPORT_SYMBOL_GPL(ata_dev_pair); |
|---|
| 7432 | | -EXPORT_SYMBOL_GPL(ata_ratelimit); |
|---|
| 7433 | | -EXPORT_SYMBOL_GPL(ata_msleep); |
|---|
| 7434 | | -EXPORT_SYMBOL_GPL(ata_wait_register); |
|---|
| 7435 | | -EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); |
|---|
| 7436 | | -EXPORT_SYMBOL_GPL(ata_scsi_slave_config); |
|---|
| 7437 | | -EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); |
|---|
| 7438 | | -EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth); |
|---|
| 7439 | | -EXPORT_SYMBOL_GPL(__ata_change_queue_depth); |
|---|
| 7440 | | -EXPORT_SYMBOL_GPL(sata_scr_valid); |
|---|
| 7441 | | -EXPORT_SYMBOL_GPL(sata_scr_read); |
|---|
| 7442 | | -EXPORT_SYMBOL_GPL(sata_scr_write); |
|---|
| 7443 | | -EXPORT_SYMBOL_GPL(sata_scr_write_flush); |
|---|
| 7444 | | -EXPORT_SYMBOL_GPL(ata_link_online); |
|---|
| 7445 | | -EXPORT_SYMBOL_GPL(ata_link_offline); |
|---|
| 7446 | | -#ifdef CONFIG_PM |
|---|
| 7447 | | -EXPORT_SYMBOL_GPL(ata_host_suspend); |
|---|
| 7448 | | -EXPORT_SYMBOL_GPL(ata_host_resume); |
|---|
| 7449 | | -#endif /* CONFIG_PM */ |
|---|
| 7450 | | -EXPORT_SYMBOL_GPL(ata_id_string); |
|---|
| 7451 | | -EXPORT_SYMBOL_GPL(ata_id_c_string); |
|---|
| 7452 | | -EXPORT_SYMBOL_GPL(ata_do_dev_read_id); |
|---|
| 7453 | | -EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
|---|
| 7454 | | - |
|---|
| 7455 | | -EXPORT_SYMBOL_GPL(ata_pio_need_iordy); |
|---|
| 7456 | | -EXPORT_SYMBOL_GPL(ata_timing_find_mode); |
|---|
| 7457 | | -EXPORT_SYMBOL_GPL(ata_timing_compute); |
|---|
| 7458 | | -EXPORT_SYMBOL_GPL(ata_timing_merge); |
|---|
| 7459 | | -EXPORT_SYMBOL_GPL(ata_timing_cycle2mode); |
|---|
| 7460 | | - |
|---|
| 7461 | | -#ifdef CONFIG_PCI |
|---|
| 7462 | | -EXPORT_SYMBOL_GPL(pci_test_config_bits); |
|---|
| 7463 | | -EXPORT_SYMBOL_GPL(ata_pci_shutdown_one); |
|---|
| 7464 | | -EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
|---|
| 7465 | | -#ifdef CONFIG_PM |
|---|
| 7466 | | -EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend); |
|---|
| 7467 | | -EXPORT_SYMBOL_GPL(ata_pci_device_do_resume); |
|---|
| 7468 | | -EXPORT_SYMBOL_GPL(ata_pci_device_suspend); |
|---|
| 7469 | | -EXPORT_SYMBOL_GPL(ata_pci_device_resume); |
|---|
| 7470 | | -#endif /* CONFIG_PM */ |
|---|
| 7471 | | -#endif /* CONFIG_PCI */ |
|---|
| 7472 | | - |
|---|
| 7473 | | -EXPORT_SYMBOL_GPL(ata_platform_remove_one); |
|---|
| 7474 | | - |
|---|
| 7475 | | -EXPORT_SYMBOL_GPL(__ata_ehi_push_desc); |
|---|
| 7476 | | -EXPORT_SYMBOL_GPL(ata_ehi_push_desc); |
|---|
| 7477 | | -EXPORT_SYMBOL_GPL(ata_ehi_clear_desc); |
|---|
| 7478 | | -EXPORT_SYMBOL_GPL(ata_port_desc); |
|---|
| 7479 | | -#ifdef CONFIG_PCI |
|---|
| 7480 | | -EXPORT_SYMBOL_GPL(ata_port_pbar_desc); |
|---|
| 7481 | | -#endif /* CONFIG_PCI */ |
|---|
| 7482 | | -EXPORT_SYMBOL_GPL(ata_port_schedule_eh); |
|---|
| 7483 | | -EXPORT_SYMBOL_GPL(ata_link_abort); |
|---|
| 7484 | | -EXPORT_SYMBOL_GPL(ata_port_abort); |
|---|
| 7485 | | -EXPORT_SYMBOL_GPL(ata_port_freeze); |
|---|
| 7486 | | -EXPORT_SYMBOL_GPL(sata_async_notification); |
|---|
| 7487 | | -EXPORT_SYMBOL_GPL(ata_eh_freeze_port); |
|---|
| 7488 | | -EXPORT_SYMBOL_GPL(ata_eh_thaw_port); |
|---|
| 7489 | | -EXPORT_SYMBOL_GPL(ata_eh_qc_complete); |
|---|
| 7490 | | -EXPORT_SYMBOL_GPL(ata_eh_qc_retry); |
|---|
| 7491 | | -EXPORT_SYMBOL_GPL(ata_eh_analyze_ncq_error); |
|---|
| 7492 | | -EXPORT_SYMBOL_GPL(ata_do_eh); |
|---|
| 7493 | | -EXPORT_SYMBOL_GPL(ata_std_error_handler); |
|---|
| 7494 | | - |
|---|
| 7495 | | -EXPORT_SYMBOL_GPL(ata_cable_40wire); |
|---|
| 7496 | | -EXPORT_SYMBOL_GPL(ata_cable_80wire); |
|---|
| 7497 | | -EXPORT_SYMBOL_GPL(ata_cable_unknown); |
|---|
| 7498 | | -EXPORT_SYMBOL_GPL(ata_cable_ignore); |
|---|
| 7499 | | -EXPORT_SYMBOL_GPL(ata_cable_sata); |
|---|
| 7500 | | -EXPORT_SYMBOL_GPL(ata_host_get); |
|---|
| 7501 | | -EXPORT_SYMBOL_GPL(ata_host_put); |
|---|