diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2006-02-11 18:02:04 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2006-02-11 18:02:04 -0500 |
commit | 1cb9d721d9df9182a42d1ff59427a100c6522efc (patch) | |
tree | 3c7d47828f89853de49e979f97ffe78fd1dba7d6 /drivers/scsi/libata-core.c | |
parent | ca7d5e42d783e54f0057317c9226262d68ab7717 (diff) | |
parent | bef4a456b8dc8b3638f4d49a25a89e1467da9483 (diff) |
Merge branch 'upstream'
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 120 |
1 files changed, 56 insertions, 64 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 592d3a86c840..3fd55ef5410f 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -897,8 +897,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
897 | 897 | ||
898 | DPRINTK("ENTER, host %u, dev %u\n", ap->id, device); | 898 | DPRINTK("ENTER, host %u, dev %u\n", ap->id, device); |
899 | 899 | ||
900 | assert (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ATAPI || | 900 | WARN_ON(dev->class != ATA_DEV_ATA && dev->class != ATA_DEV_ATAPI && |
901 | dev->class == ATA_DEV_NONE); | 901 | dev->class != ATA_DEV_NONE); |
902 | 902 | ||
903 | ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ | 903 | ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ |
904 | 904 | ||
@@ -1926,11 +1926,20 @@ static int sata_phy_resume(struct ata_port *ap) | |||
1926 | * | 1926 | * |
1927 | * @ap is about to be probed. Initialize it. This function is | 1927 | * @ap is about to be probed. Initialize it. This function is |
1928 | * to be used as standard callback for ata_drive_probe_reset(). | 1928 | * to be used as standard callback for ata_drive_probe_reset(). |
1929 | * | ||
1930 | * NOTE!!! Do not use this function as probeinit if a low level | ||
1931 | * driver implements only hardreset. Just pass NULL as probeinit | ||
1932 | * in that case. Using this function is probably okay but doing | ||
1933 | * so makes reset sequence different from the original | ||
1934 | * ->phy_reset implementation and Jeff nervous. :-P | ||
1929 | */ | 1935 | */ |
1930 | extern void ata_std_probeinit(struct ata_port *ap) | 1936 | extern void ata_std_probeinit(struct ata_port *ap) |
1931 | { | 1937 | { |
1932 | if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read) | 1938 | if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read) { |
1933 | sata_phy_resume(ap); | 1939 | sata_phy_resume(ap); |
1940 | if (sata_dev_present(ap)) | ||
1941 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | ||
1942 | } | ||
1934 | } | 1943 | } |
1935 | 1944 | ||
1936 | /** | 1945 | /** |
@@ -1956,20 +1965,17 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
1956 | 1965 | ||
1957 | DPRINTK("ENTER\n"); | 1966 | DPRINTK("ENTER\n"); |
1958 | 1967 | ||
1968 | if (ap->ops->scr_read && !sata_dev_present(ap)) { | ||
1969 | classes[0] = ATA_DEV_NONE; | ||
1970 | goto out; | ||
1971 | } | ||
1972 | |||
1959 | /* determine if device 0/1 are present */ | 1973 | /* determine if device 0/1 are present */ |
1960 | if (ata_devchk(ap, 0)) | 1974 | if (ata_devchk(ap, 0)) |
1961 | devmask |= (1 << 0); | 1975 | devmask |= (1 << 0); |
1962 | if (slave_possible && ata_devchk(ap, 1)) | 1976 | if (slave_possible && ata_devchk(ap, 1)) |
1963 | devmask |= (1 << 1); | 1977 | devmask |= (1 << 1); |
1964 | 1978 | ||
1965 | /* devchk reports device presence without actual device on | ||
1966 | * most SATA controllers. Check SStatus and turn devmask off | ||
1967 | * if link is offline. Note that we should continue resetting | ||
1968 | * even when it seems like there's no device. | ||
1969 | */ | ||
1970 | if (ap->ops->scr_read && !sata_dev_present(ap)) | ||
1971 | devmask = 0; | ||
1972 | |||
1973 | /* select device 0 again */ | 1979 | /* select device 0 again */ |
1974 | ap->ops->dev_select(ap, 0); | 1980 | ap->ops->dev_select(ap, 0); |
1975 | 1981 | ||
@@ -1991,6 +1997,7 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
1991 | if (slave_possible && err != 0x81) | 1997 | if (slave_possible && err != 0x81) |
1992 | classes[1] = ata_dev_try_classify(ap, 1, &err); | 1998 | classes[1] = ata_dev_try_classify(ap, 1, &err); |
1993 | 1999 | ||
2000 | out: | ||
1994 | DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); | 2001 | DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); |
1995 | return 0; | 2002 | return 0; |
1996 | } | 2003 | } |
@@ -2013,8 +2020,6 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
2013 | */ | 2020 | */ |
2014 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | 2021 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) |
2015 | { | 2022 | { |
2016 | u32 serror; | ||
2017 | |||
2018 | DPRINTK("ENTER\n"); | 2023 | DPRINTK("ENTER\n"); |
2019 | 2024 | ||
2020 | /* Issue phy wake/reset */ | 2025 | /* Issue phy wake/reset */ |
@@ -2029,10 +2034,6 @@ int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
2029 | /* Bring phy back */ | 2034 | /* Bring phy back */ |
2030 | sata_phy_resume(ap); | 2035 | sata_phy_resume(ap); |
2031 | 2036 | ||
2032 | /* Clear SError */ | ||
2033 | serror = scr_read(ap, SCR_ERROR); | ||
2034 | scr_write(ap, SCR_ERROR, serror); | ||
2035 | |||
2036 | /* TODO: phy layer with polling, timeouts, etc. */ | 2037 | /* TODO: phy layer with polling, timeouts, etc. */ |
2037 | if (!sata_dev_present(ap)) { | 2038 | if (!sata_dev_present(ap)) { |
2038 | *class = ATA_DEV_NONE; | 2039 | *class = ATA_DEV_NONE; |
@@ -2049,6 +2050,8 @@ int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
2049 | return -EIO; | 2050 | return -EIO; |
2050 | } | 2051 | } |
2051 | 2052 | ||
2053 | ap->ops->dev_select(ap, 0); /* probably unnecessary */ | ||
2054 | |||
2052 | *class = ata_dev_try_classify(ap, 0, NULL); | 2055 | *class = ata_dev_try_classify(ap, 0, NULL); |
2053 | 2056 | ||
2054 | DPRINTK("EXIT, class=%u\n", *class); | 2057 | DPRINTK("EXIT, class=%u\n", *class); |
@@ -2083,11 +2086,9 @@ void ata_std_postreset(struct ata_port *ap, unsigned int *classes) | |||
2083 | if (ap->cbl == ATA_CBL_SATA) | 2086 | if (ap->cbl == ATA_CBL_SATA) |
2084 | sata_print_link_status(ap); | 2087 | sata_print_link_status(ap); |
2085 | 2088 | ||
2086 | /* bail out if no device is present */ | 2089 | /* re-enable interrupts */ |
2087 | if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { | 2090 | if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */ |
2088 | DPRINTK("EXIT, no device\n"); | 2091 | ata_irq_on(ap); |
2089 | return; | ||
2090 | } | ||
2091 | 2092 | ||
2092 | /* is double-select really necessary? */ | 2093 | /* is double-select really necessary? */ |
2093 | if (classes[0] != ATA_DEV_NONE) | 2094 | if (classes[0] != ATA_DEV_NONE) |
@@ -2095,9 +2096,19 @@ void ata_std_postreset(struct ata_port *ap, unsigned int *classes) | |||
2095 | if (classes[1] != ATA_DEV_NONE) | 2096 | if (classes[1] != ATA_DEV_NONE) |
2096 | ap->ops->dev_select(ap, 0); | 2097 | ap->ops->dev_select(ap, 0); |
2097 | 2098 | ||
2098 | /* re-enable interrupts & set up device control */ | 2099 | /* bail out if no device is present */ |
2099 | if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */ | 2100 | if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { |
2100 | ata_irq_on(ap); | 2101 | DPRINTK("EXIT, no device\n"); |
2102 | return; | ||
2103 | } | ||
2104 | |||
2105 | /* set up device control */ | ||
2106 | if (ap->ioaddr.ctl_addr) { | ||
2107 | if (ap->flags & ATA_FLAG_MMIO) | ||
2108 | writeb(ap->ctl, (void __iomem *) ap->ioaddr.ctl_addr); | ||
2109 | else | ||
2110 | outb(ap->ctl, ap->ioaddr.ctl_addr); | ||
2111 | } | ||
2101 | 2112 | ||
2102 | DPRINTK("EXIT\n"); | 2113 | DPRINTK("EXIT\n"); |
2103 | } | 2114 | } |
@@ -2292,7 +2303,7 @@ static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift) | |||
2292 | master = &ap->device[0]; | 2303 | master = &ap->device[0]; |
2293 | slave = &ap->device[1]; | 2304 | slave = &ap->device[1]; |
2294 | 2305 | ||
2295 | assert (ata_dev_present(master) || ata_dev_present(slave)); | 2306 | WARN_ON(!ata_dev_present(master) && !ata_dev_present(slave)); |
2296 | 2307 | ||
2297 | if (shift == ATA_SHIFT_UDMA) { | 2308 | if (shift == ATA_SHIFT_UDMA) { |
2298 | mask = ap->udma_mask; | 2309 | mask = ap->udma_mask; |
@@ -2538,11 +2549,11 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2538 | int dir = qc->dma_dir; | 2549 | int dir = qc->dma_dir; |
2539 | void *pad_buf = NULL; | 2550 | void *pad_buf = NULL; |
2540 | 2551 | ||
2541 | assert(qc->flags & ATA_QCFLAG_DMAMAP); | 2552 | WARN_ON(!(qc->flags & ATA_QCFLAG_DMAMAP)); |
2542 | assert(sg != NULL); | 2553 | WARN_ON(sg == NULL); |
2543 | 2554 | ||
2544 | if (qc->flags & ATA_QCFLAG_SINGLE) | 2555 | if (qc->flags & ATA_QCFLAG_SINGLE) |
2545 | assert(qc->n_elem == 1); | 2556 | WARN_ON(qc->n_elem != 1); |
2546 | 2557 | ||
2547 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); | 2558 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); |
2548 | 2559 | ||
@@ -2597,8 +2608,8 @@ static void ata_fill_sg(struct ata_queued_cmd *qc) | |||
2597 | struct scatterlist *sg; | 2608 | struct scatterlist *sg; |
2598 | unsigned int idx; | 2609 | unsigned int idx; |
2599 | 2610 | ||
2600 | assert(qc->__sg != NULL); | 2611 | WARN_ON(qc->__sg == NULL); |
2601 | assert(qc->n_elem > 0); | 2612 | WARN_ON(qc->n_elem == 0); |
2602 | 2613 | ||
2603 | idx = 0; | 2614 | idx = 0; |
2604 | ata_for_each_sg(sg, qc) { | 2615 | ata_for_each_sg(sg, qc) { |
@@ -2750,7 +2761,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2750 | void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); | 2761 | void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); |
2751 | struct scatterlist *psg = &qc->pad_sgent; | 2762 | struct scatterlist *psg = &qc->pad_sgent; |
2752 | 2763 | ||
2753 | assert(qc->dev->class == ATA_DEV_ATAPI); | 2764 | WARN_ON(qc->dev->class != ATA_DEV_ATAPI); |
2754 | 2765 | ||
2755 | memset(pad_buf, 0, ATA_DMA_PAD_SZ); | 2766 | memset(pad_buf, 0, ATA_DMA_PAD_SZ); |
2756 | 2767 | ||
@@ -2812,7 +2823,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2812 | int n_elem, pre_n_elem, dir, trim_sg = 0; | 2823 | int n_elem, pre_n_elem, dir, trim_sg = 0; |
2813 | 2824 | ||
2814 | VPRINTK("ENTER, ata%u\n", ap->id); | 2825 | VPRINTK("ENTER, ata%u\n", ap->id); |
2815 | assert(qc->flags & ATA_QCFLAG_SG); | 2826 | WARN_ON(!(qc->flags & ATA_QCFLAG_SG)); |
2816 | 2827 | ||
2817 | /* we must lengthen transfers to end on a 32-bit boundary */ | 2828 | /* we must lengthen transfers to end on a 32-bit boundary */ |
2818 | qc->pad_len = lsg->length & 3; | 2829 | qc->pad_len = lsg->length & 3; |
@@ -2821,7 +2832,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2821 | struct scatterlist *psg = &qc->pad_sgent; | 2832 | struct scatterlist *psg = &qc->pad_sgent; |
2822 | unsigned int offset; | 2833 | unsigned int offset; |
2823 | 2834 | ||
2824 | assert(qc->dev->class == ATA_DEV_ATAPI); | 2835 | WARN_ON(qc->dev->class != ATA_DEV_ATAPI); |
2825 | 2836 | ||
2826 | memset(pad_buf, 0, ATA_DMA_PAD_SZ); | 2837 | memset(pad_buf, 0, ATA_DMA_PAD_SZ); |
2827 | 2838 | ||
@@ -2914,7 +2925,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
2914 | unsigned int reg_state = HSM_ST_UNKNOWN; | 2925 | unsigned int reg_state = HSM_ST_UNKNOWN; |
2915 | 2926 | ||
2916 | qc = ata_qc_from_tag(ap, ap->active_tag); | 2927 | qc = ata_qc_from_tag(ap, ap->active_tag); |
2917 | assert(qc != NULL); | 2928 | WARN_ON(qc == NULL); |
2918 | 2929 | ||
2919 | switch (ap->hsm_task_state) { | 2930 | switch (ap->hsm_task_state) { |
2920 | case HSM_ST: | 2931 | case HSM_ST: |
@@ -2983,7 +2994,7 @@ static int ata_pio_complete (struct ata_port *ap) | |||
2983 | } | 2994 | } |
2984 | 2995 | ||
2985 | qc = ata_qc_from_tag(ap, ap->active_tag); | 2996 | qc = ata_qc_from_tag(ap, ap->active_tag); |
2986 | assert(qc != NULL); | 2997 | WARN_ON(qc == NULL); |
2987 | 2998 | ||
2988 | drv_stat = ata_wait_idle(ap); | 2999 | drv_stat = ata_wait_idle(ap); |
2989 | if (!ata_ok(drv_stat)) { | 3000 | if (!ata_ok(drv_stat)) { |
@@ -2994,7 +3005,7 @@ static int ata_pio_complete (struct ata_port *ap) | |||
2994 | 3005 | ||
2995 | ap->hsm_task_state = HSM_ST_IDLE; | 3006 | ap->hsm_task_state = HSM_ST_IDLE; |
2996 | 3007 | ||
2997 | assert(qc->err_mask == 0); | 3008 | WARN_ON(qc->err_mask); |
2998 | ata_poll_qc_complete(qc); | 3009 | ata_poll_qc_complete(qc); |
2999 | 3010 | ||
3000 | /* another command may start at this point */ | 3011 | /* another command may start at this point */ |
@@ -3517,7 +3528,7 @@ static void ata_pio_block(struct ata_port *ap) | |||
3517 | } | 3528 | } |
3518 | 3529 | ||
3519 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3530 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3520 | assert(qc != NULL); | 3531 | WARN_ON(qc == NULL); |
3521 | 3532 | ||
3522 | /* check error */ | 3533 | /* check error */ |
3523 | if (status & (ATA_ERR | ATA_DF)) { | 3534 | if (status & (ATA_ERR | ATA_DF)) { |
@@ -3554,7 +3565,7 @@ static void ata_pio_error(struct ata_port *ap) | |||
3554 | struct ata_queued_cmd *qc; | 3565 | struct ata_queued_cmd *qc; |
3555 | 3566 | ||
3556 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3567 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3557 | assert(qc != NULL); | 3568 | WARN_ON(qc == NULL); |
3558 | 3569 | ||
3559 | if (qc->tf.command != ATA_CMD_PACKET) | 3570 | if (qc->tf.command != ATA_CMD_PACKET) |
3560 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); | 3571 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); |
@@ -3562,7 +3573,7 @@ static void ata_pio_error(struct ata_port *ap) | |||
3562 | /* make sure qc->err_mask is available to | 3573 | /* make sure qc->err_mask is available to |
3563 | * know what's wrong and recover | 3574 | * know what's wrong and recover |
3564 | */ | 3575 | */ |
3565 | assert(qc->err_mask); | 3576 | WARN_ON(qc->err_mask == 0); |
3566 | 3577 | ||
3567 | ap->hsm_task_state = HSM_ST_IDLE; | 3578 | ap->hsm_task_state = HSM_ST_IDLE; |
3568 | 3579 | ||
@@ -3776,7 +3787,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
3776 | struct ata_port *ap = qc->ap; | 3787 | struct ata_port *ap = qc->ap; |
3777 | unsigned int tag; | 3788 | unsigned int tag; |
3778 | 3789 | ||
3779 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | 3790 | WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ |
3780 | 3791 | ||
3781 | qc->flags = 0; | 3792 | qc->flags = 0; |
3782 | tag = qc->tag; | 3793 | tag = qc->tag; |
@@ -3788,10 +3799,10 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
3788 | } | 3799 | } |
3789 | } | 3800 | } |
3790 | 3801 | ||
3791 | inline void __ata_qc_complete(struct ata_queued_cmd *qc) | 3802 | void __ata_qc_complete(struct ata_queued_cmd *qc) |
3792 | { | 3803 | { |
3793 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | 3804 | WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ |
3794 | assert(qc->flags & ATA_QCFLAG_ACTIVE); | 3805 | WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); |
3795 | 3806 | ||
3796 | if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) | 3807 | if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) |
3797 | ata_sg_clean(qc); | 3808 | ata_sg_clean(qc); |
@@ -3806,25 +3817,6 @@ inline void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
3806 | qc->complete_fn(qc); | 3817 | qc->complete_fn(qc); |
3807 | } | 3818 | } |
3808 | 3819 | ||
3809 | /** | ||
3810 | * ata_qc_complete - Complete an active ATA command | ||
3811 | * @qc: Command to complete | ||
3812 | * @err_mask: ATA Status register contents | ||
3813 | * | ||
3814 | * Indicate to the mid and upper layers that an ATA | ||
3815 | * command has completed, with either an ok or not-ok status. | ||
3816 | * | ||
3817 | * LOCKING: | ||
3818 | * spin_lock_irqsave(host_set lock) | ||
3819 | */ | ||
3820 | void ata_qc_complete(struct ata_queued_cmd *qc) | ||
3821 | { | ||
3822 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) | ||
3823 | return; | ||
3824 | |||
3825 | __ata_qc_complete(qc); | ||
3826 | } | ||
3827 | |||
3828 | static inline int ata_should_dma_map(struct ata_queued_cmd *qc) | 3820 | static inline int ata_should_dma_map(struct ata_queued_cmd *qc) |
3829 | { | 3821 | { |
3830 | struct ata_port *ap = qc->ap; | 3822 | struct ata_port *ap = qc->ap; |
@@ -5143,7 +5135,7 @@ EXPORT_SYMBOL_GPL(ata_device_add); | |||
5143 | EXPORT_SYMBOL_GPL(ata_host_set_remove); | 5135 | EXPORT_SYMBOL_GPL(ata_host_set_remove); |
5144 | EXPORT_SYMBOL_GPL(ata_sg_init); | 5136 | EXPORT_SYMBOL_GPL(ata_sg_init); |
5145 | EXPORT_SYMBOL_GPL(ata_sg_init_one); | 5137 | EXPORT_SYMBOL_GPL(ata_sg_init_one); |
5146 | EXPORT_SYMBOL_GPL(ata_qc_complete); | 5138 | EXPORT_SYMBOL_GPL(__ata_qc_complete); |
5147 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); | 5139 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); |
5148 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | 5140 | EXPORT_SYMBOL_GPL(ata_eng_timeout); |
5149 | EXPORT_SYMBOL_GPL(ata_tf_load); | 5141 | EXPORT_SYMBOL_GPL(ata_tf_load); |