···58 </para>59 </chapter>6061- <chapter id="libataThanks">62- <title>Thanks</title>63- <para>64- The bulk of the ATA knowledge comes thanks to long conversations with65- Andre Hedrick (www.linux-ide.org), and long hours pondering the ATA66- and SCSI specifications.67- </para>68- <para>69- Thanks to Alan Cox for pointing out similarities 70- between SATA and SCSI, and in general for motivation to hack on71- libata.72- </para>73- <para>74- libata's device detection75- method, ata_pio_devchk, and in general all the early probing was76- based on extensive study of Hale Landis's probe/reset code in his77- ATADRVR driver (www.ata-atapi.com).78- </para>79- </chapter>80-81 <chapter id="libataDriverApi">82 <title>libata Driver API</title>83 <sect1>···292 <chapter id="SILInt">293 <title>sata_sil Internals</title>294!Idrivers/scsi/sata_sil.c00000000000000000000295 </chapter>296297</book>
···58 </para>59 </chapter>600000000000000000000061 <chapter id="libataDriverApi">62 <title>libata Driver API</title>63 <sect1>···312 <chapter id="SILInt">313 <title>sata_sil Internals</title>314!Idrivers/scsi/sata_sil.c315+ </chapter>316+317+ <chapter id="libataThanks">318+ <title>Thanks</title>319+ <para>320+ The bulk of the ATA knowledge comes thanks to long conversations with321+ Andre Hedrick (www.linux-ide.org), and long hours pondering the ATA322+ and SCSI specifications.323+ </para>324+ <para>325+ Thanks to Alan Cox for pointing out similarities 326+ between SATA and SCSI, and in general for motivation to hack on327+ libata.328+ </para>329+ <para>330+ libata's device detection331+ method, ata_pio_devchk, and in general all the early probing was332+ based on extensive study of Hale Landis's probe/reset code in his333+ ATADRVR driver (www.ata-atapi.com).334+ </para>335 </chapter>336337</book>
···663 return ata_pci_init_one(pdev, port_info, n_ports);664}665000000000666static int __init piix_init(void)667{668 int rc;···686 DPRINTK("done\n");687 return 0;688}0000000689690static void __exit piix_exit(void)691{
+117-33
drivers/scsi/libata-core.c
···1190 * ata_bus_probe - Reset and probe ATA bus1191 * @ap: Bus to probe1192 *00001193 * LOCKING:01194 *1195 * RETURNS:1196 * Zero on success, non-zero on error.···1234}12351236/**1237- * ata_port_probe -1238- * @ap:1239 *1240- * LOCKING:00001241 */12421243void ata_port_probe(struct ata_port *ap)···1257 * PHY registers, to wake up the phy (and device), and1258 * clear any reset condition.1259 *1260- * LOCKING: None. Serialized during ata_bus_probe().01261 *1262 */1263void __sata_phy_reset(struct ata_port *ap)···1309 * This function resets the SATA bus, and then probes1310 * the bus for devices.1311 *1312- * LOCKING: None. Serialized during ata_bus_probe().01313 *1314 */1315void sata_phy_reset(struct ata_port *ap)···1442 *1443 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.).1444 *1445- * LOCKING: None. Serialized during ata_bus_probe().01446 *1447 */1448static void ata_set_mode(struct ata_port *ap)···1583}15841585/**1586- * ata_bus_edd -1587- * @ap:1588 *1589- * LOCKING: None. Serialized during ata_bus_probe().00001590 *1591 */1592···1667 * the device is ATA or ATAPI.1668 *1669 * LOCKING:1670- * Inherited from caller. Some functions called by this function1671- * obtain the host_set lock.1672 *1673 * SIDE EFFECTS:1674 * Sets ATA_FLAG_PORT_DISABLED if bus reset fails.···1910 * @xfer_mode_out: (output) SET FEATURES - XFER MODE code1911 * @xfer_shift_out: (output) bit shift that selects this mode1912 *0001913 * LOCKING:01914 *1915 * RETURNS:1916 * Zero on success, negative on error.···1950 * Issue SET FEATURES - XFER MODE command to device @dev1951 * on port @ap.1952 *1953- * LOCKING: None. Serialized during ata_bus_probe().01954 */19551956static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)···1989}19901991/**1992- * ata_sg_clean -1993- * @qc:001994 *1995 * LOCKING:01996 */19971998static void ata_sg_clean(struct ata_queued_cmd *qc)···2082 * supplied PACKET command.2083 *2084 * LOCKING:002085 * RETURNS: 0 when ATAPI DMA can be used2086 * nonzero otherwise2087 */···2114 ata_fill_sg(qc);2115}211600000000000002117void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)2118{2119 struct scatterlist *sg;···2144 sg->length = buflen;2145}2146000000000000002147void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,2148 unsigned int n_elem)2149{···2167}21682169/**2170- * ata_sg_setup_one -2171- * @qc:002172 *2173 * LOCKING:2174 * spin_lock_irqsave(host_set lock)2175 *2176 * RETURNS:2177- *2178 */21792180static int ata_sg_setup_one(struct ata_queued_cmd *qc)···2201}22022203/**2204- * ata_sg_setup -2205- * @qc:002206 *2207 * LOCKING:2208 * spin_lock_irqsave(host_set lock)2209 *2210 * RETURNS:02211 *2212 */2213···2240 * @ap:2241 *2242 * LOCKING:02243 *2244 * RETURNS:2245 *···2288 * @ap:2289 *2290 * LOCKING:02291 */22922293static void ata_pio_complete (struct ata_port *ap)···2506 * @ap:2507 *2508 * LOCKING:02509 */25102511static void ata_pio_block(struct ata_port *ap)···2675 * transaction completed successfully.2676 *2677 * LOCKING:02678 */26792680static void ata_qc_timeout(struct ata_queued_cmd *qc)···2785 * @dev: Device from whom we request an available command structure2786 *2787 * LOCKING:02788 */27892790static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)···2811 * @dev: Device from whom we request an available command structure2812 *2813 * LOCKING:02814 */28152816struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,···2876 * in case something prevents using it.2877 *2878 * LOCKING:02879 *2880 */2881void ata_qc_free(struct ata_queued_cmd *qc)···2890/**2891 * ata_qc_complete - Complete an active ATA command2892 * @qc: Command to complete2893- * @drv_stat: ATA status register contents0002894 *2895 * LOCKING:02896 *2897 */2898···33033304/**3305 * ata_interrupt - Default ATA host interrupt handler3306- * @irq: irq line3307- * @dev_instance: pointer to our host information structure3308 * @regs: unused3309 *0003310 * LOCKING:03311 *3312 * RETURNS:03313 *3314 */3315···3455 * @ent: Probe information provided by low-level driver3456 * @port_no: Port number associated with this ata_port3457 *0003458 * LOCKING:03459 *3460 */3461···3514 * @host_set: Collections of ports to which we add3515 * @port_no: Port number associated with this host3516 *003517 * LOCKING:03518 *3519 * RETURNS:03520 *3521 */3522···3553}35543555/**3556- * ata_device_add -3557- * @ent:000000003558 *3559 * LOCKING:03560 *3561 * RETURNS:03562 *3563 */3564···3847 * Inherited from PCI layer (may sleep).3848 *3849 * RETURNS:03850 *3851 */3852···4066}4067#endif /* CONFIG_PCI */40684069-4070-/**4071- * ata_init -4072- *4073- * LOCKING:4074- *4075- * RETURNS:4076- *4077- */40784079static int __init ata_init(void)4080{
···1190 * ata_bus_probe - Reset and probe ATA bus1191 * @ap: Bus to probe1192 *1193+ * Master ATA bus probing function. Initiates a hardware-dependent1194+ * bus reset, then attempts to identify any devices found on1195+ * the bus.1196+ *1197 * LOCKING:1198+ * PCI/etc. bus probe sem.1199 *1200 * RETURNS:1201 * Zero on success, non-zero on error.···1229}12301231/**1232+ * ata_port_probe - Mark port as enabled1233+ * @ap: Port for which we indicate enablement1234 *1235+ * Modify @ap data structure such that the system1236+ * thinks that the entire port is enabled.1237+ *1238+ * LOCKING: host_set lock, or some other form of1239+ * serialization.1240 */12411242void ata_port_probe(struct ata_port *ap)···1248 * PHY registers, to wake up the phy (and device), and1249 * clear any reset condition.1250 *1251+ * LOCKING:1252+ * PCI/etc. bus probe sem.1253 *1254 */1255void __sata_phy_reset(struct ata_port *ap)···1299 * This function resets the SATA bus, and then probes1300 * the bus for devices.1301 *1302+ * LOCKING:1303+ * PCI/etc. bus probe sem.1304 *1305 */1306void sata_phy_reset(struct ata_port *ap)···1431 *1432 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.).1433 *1434+ * LOCKING:1435+ * PCI/etc. bus probe sem.1436 *1437 */1438static void ata_set_mode(struct ata_port *ap)···1571}15721573/**1574+ * ata_bus_edd - Issue EXECUTE DEVICE DIAGNOSTIC command.1575+ * @ap: Port to reset and probe1576 *1577+ * Use the EXECUTE DEVICE DIAGNOSTIC command to reset and1578+ * probe the bus. Not often used these days.1579+ *1580+ * LOCKING:1581+ * PCI/etc. bus probe sem.1582 *1583 */1584···1651 * the device is ATA or ATAPI.1652 *1653 * LOCKING:1654+ * PCI/etc. bus probe sem.1655+ * Obtains host_set lock.1656 *1657 * SIDE EFFECTS:1658 * Sets ATA_FLAG_PORT_DISABLED if bus reset fails.···1894 * @xfer_mode_out: (output) SET FEATURES - XFER MODE code1895 * @xfer_shift_out: (output) bit shift that selects this mode1896 *1897+ * Based on host and device capabilities, determine the1898+ * maximum transfer mode that is amenable to all.1899+ *1900 * LOCKING:1901+ * PCI/etc. bus probe sem.1902 *1903 * RETURNS:1904 * Zero on success, negative on error.···1930 * Issue SET FEATURES - XFER MODE command to device @dev1931 * on port @ap.1932 *1933+ * LOCKING:1934+ * PCI/etc. bus probe sem.1935 */19361937static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)···1968}19691970/**1971+ * ata_sg_clean - Unmap DMA memory associated with command1972+ * @qc: Command containing DMA memory to be released1973+ *1974+ * Unmap all mapped DMA memory associated with this command.1975 *1976 * LOCKING:1977+ * spin_lock_irqsave(host_set lock)1978 */19791980static void ata_sg_clean(struct ata_queued_cmd *qc)···2058 * supplied PACKET command.2059 *2060 * LOCKING:2061+ * spin_lock_irqsave(host_set lock)2062+ *2063 * RETURNS: 0 when ATAPI DMA can be used2064 * nonzero otherwise2065 */···2088 ata_fill_sg(qc);2089}20902091+/**2092+ * ata_sg_init_one - Associate command with memory buffer2093+ * @qc: Command to be associated2094+ * @buf: Memory buffer2095+ * @buflen: Length of memory buffer, in bytes.2096+ *2097+ * Initialize the data-related elements of queued_cmd @qc2098+ * to point to a single memory buffer, @buf of byte length @buflen.2099+ *2100+ * LOCKING:2101+ * spin_lock_irqsave(host_set lock)2102+ */2103+2104void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)2105{2106 struct scatterlist *sg;···2105 sg->length = buflen;2106}21072108+/**2109+ * ata_sg_init - Associate command with scatter-gather table.2110+ * @qc: Command to be associated2111+ * @sg: Scatter-gather table.2112+ * @n_elem: Number of elements in s/g table.2113+ *2114+ * Initialize the data-related elements of queued_cmd @qc2115+ * to point to a scatter-gather table @sg, containing @n_elem2116+ * elements.2117+ *2118+ * LOCKING:2119+ * spin_lock_irqsave(host_set lock)2120+ */2121+2122void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,2123 unsigned int n_elem)2124{···2114}21152116/**2117+ * ata_sg_setup_one - DMA-map the memory buffer associated with a command.2118+ * @qc: Command with memory buffer to be mapped.2119+ *2120+ * DMA-map the memory buffer associated with queued_cmd @qc.2121 *2122 * LOCKING:2123 * spin_lock_irqsave(host_set lock)2124 *2125 * RETURNS:2126+ * Zero on success, negative on error.2127 */21282129static int ata_sg_setup_one(struct ata_queued_cmd *qc)···2146}21472148/**2149+ * ata_sg_setup - DMA-map the scatter-gather table associated with a command.2150+ * @qc: Command with scatter-gather table to be mapped.2151+ *2152+ * DMA-map the scatter-gather table associated with queued_cmd @qc.2153 *2154 * LOCKING:2155 * spin_lock_irqsave(host_set lock)2156 *2157 * RETURNS:2158+ * Zero on success, negative on error.2159 *2160 */2161···2182 * @ap:2183 *2184 * LOCKING:2185+ * None. (executing in kernel thread context)2186 *2187 * RETURNS:2188 *···2229 * @ap:2230 *2231 * LOCKING:2232+ * None. (executing in kernel thread context)2233 */22342235static void ata_pio_complete (struct ata_port *ap)···2446 * @ap:2447 *2448 * LOCKING:2449+ * None. (executing in kernel thread context)2450 */24512452static void ata_pio_block(struct ata_port *ap)···2614 * transaction completed successfully.2615 *2616 * LOCKING:2617+ * Inherited from SCSI layer (none, can sleep)2618 */26192620static void ata_qc_timeout(struct ata_queued_cmd *qc)···2723 * @dev: Device from whom we request an available command structure2724 *2725 * LOCKING:2726+ * None.2727 */27282729static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)···2748 * @dev: Device from whom we request an available command structure2749 *2750 * LOCKING:2751+ * None.2752 */27532754struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,···2812 * in case something prevents using it.2813 *2814 * LOCKING:2815+ * spin_lock_irqsave(host_set lock)2816 *2817 */2818void ata_qc_free(struct ata_queued_cmd *qc)···2825/**2826 * ata_qc_complete - Complete an active ATA command2827 * @qc: Command to complete2828+ * @drv_stat: ATA Status register contents2829+ *2830+ * Indicate to the mid and upper layers that an ATA2831+ * command has completed, with either an ok or not-ok status.2832 *2833 * LOCKING:2834+ * spin_lock_irqsave(host_set lock)2835 *2836 */2837···32343235/**3236 * ata_interrupt - Default ATA host interrupt handler3237+ * @irq: irq line (unused)3238+ * @dev_instance: pointer to our ata_host_set information structure3239 * @regs: unused3240 *3241+ * Default interrupt handler for PCI IDE devices. Calls3242+ * ata_host_intr() for each port that is not disabled.3243+ *3244 * LOCKING:3245+ * Obtains host_set lock during operation.3246 *3247 * RETURNS:3248+ * IRQ_NONE or IRQ_HANDLED.3249 *3250 */3251···3381 * @ent: Probe information provided by low-level driver3382 * @port_no: Port number associated with this ata_port3383 *3384+ * Initialize a new ata_port structure, and its associated3385+ * scsi_host.3386+ *3387 * LOCKING:3388+ * Inherited from caller.3389 *3390 */3391···3436 * @host_set: Collections of ports to which we add3437 * @port_no: Port number associated with this host3438 *3439+ * Attach low-level ATA driver to system.3440+ *3441 * LOCKING:3442+ * PCI/etc. bus probe sem.3443 *3444 * RETURNS:3445+ * New ata_port on success, for NULL on error.3446 *3447 */3448···3471}34723473/**3474+ * ata_device_add - Register hardware device with ATA and SCSI layers3475+ * @ent: Probe information describing hardware device to be registered3476+ *3477+ * This function processes the information provided in the probe3478+ * information struct @ent, allocates the necessary ATA and SCSI3479+ * host information structures, initializes them, and registers3480+ * everything with requisite kernel subsystems.3481+ *3482+ * This function requests irqs, probes the ATA bus, and probes3483+ * the SCSI bus.3484 *3485 * LOCKING:3486+ * PCI/etc. bus probe sem.3487 *3488 * RETURNS:3489+ * Number of ports registered. Zero on error (no ports registered).3490 *3491 */3492···3755 * Inherited from PCI layer (may sleep).3756 *3757 * RETURNS:3758+ * Zero on success, negative on errno-based value on error.3759 *3760 */3761···3973}3974#endif /* CONFIG_PCI */397500000000039763977static int __init ata_init(void)3978{
+1-1
drivers/scsi/libata-scsi.c
···947}948949/**950- * ata_scsiop_noop -951 * @args: device IDENTIFY data / SCSI command of interest.952 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.953 * @buflen: Response buffer length.
···947}948949/**950+ * ata_scsiop_noop - Command handler that simply returns success.951 * @args: device IDENTIFY data / SCSI command of interest.952 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.953 * @buflen: Response buffer length.