diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-15 15:45:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-15 15:45:33 -0500 |
commit | 7ae8c5ec122e4e909193dbbdb2ad2de349e307c9 (patch) | |
tree | 42ef1a96f9286f8ddab8edd6d037506a9cbe889f | |
parent | e1f1def6ef3f0c71d0df302c3759f6937adaf9ae (diff) | |
parent | 9f68a24853dd37d18f2cfa979cf4e131f5a10e8f (diff) |
Merge branch 'upstream-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
-rw-r--r-- | drivers/scsi/ahci.c | 31 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 64 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 77 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 2 | ||||
-rw-r--r-- | include/linux/libata.h | 14 |
5 files changed, 111 insertions, 77 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 4e96ec5f2ff9..894e7113e0b3 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -565,6 +565,17 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat) | |||
565 | u32 tmp; | 565 | u32 tmp; |
566 | int work; | 566 | int work; |
567 | 567 | ||
568 | printk(KERN_WARNING "ata%u: port reset, " | ||
569 | "p_is %x is %x pis %x cmd %x tf %x ss %x se %x\n", | ||
570 | ap->id, | ||
571 | irq_stat, | ||
572 | readl(mmio + HOST_IRQ_STAT), | ||
573 | readl(port_mmio + PORT_IRQ_STAT), | ||
574 | readl(port_mmio + PORT_CMD), | ||
575 | readl(port_mmio + PORT_TFDATA), | ||
576 | readl(port_mmio + PORT_SCR_STAT), | ||
577 | readl(port_mmio + PORT_SCR_ERR)); | ||
578 | |||
568 | /* stop DMA */ | 579 | /* stop DMA */ |
569 | tmp = readl(port_mmio + PORT_CMD); | 580 | tmp = readl(port_mmio + PORT_CMD); |
570 | tmp &= ~PORT_CMD_START; | 581 | tmp &= ~PORT_CMD_START; |
@@ -602,8 +613,6 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat) | |||
602 | tmp |= PORT_CMD_START; | 613 | tmp |= PORT_CMD_START; |
603 | writel(tmp, port_mmio + PORT_CMD); | 614 | writel(tmp, port_mmio + PORT_CMD); |
604 | readl(port_mmio + PORT_CMD); /* flush */ | 615 | readl(port_mmio + PORT_CMD); /* flush */ |
605 | |||
606 | printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->id); | ||
607 | } | 616 | } |
608 | 617 | ||
609 | static void ahci_eng_timeout(struct ata_port *ap) | 618 | static void ahci_eng_timeout(struct ata_port *ap) |
@@ -614,17 +623,17 @@ static void ahci_eng_timeout(struct ata_port *ap) | |||
614 | struct ata_queued_cmd *qc; | 623 | struct ata_queued_cmd *qc; |
615 | unsigned long flags; | 624 | unsigned long flags; |
616 | 625 | ||
617 | DPRINTK("ENTER\n"); | 626 | printk(KERN_WARNING "ata%u: handling error/timeout\n", ap->id); |
618 | 627 | ||
619 | spin_lock_irqsave(&host_set->lock, flags); | 628 | spin_lock_irqsave(&host_set->lock, flags); |
620 | 629 | ||
621 | ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT)); | ||
622 | |||
623 | qc = ata_qc_from_tag(ap, ap->active_tag); | 630 | qc = ata_qc_from_tag(ap, ap->active_tag); |
624 | if (!qc) { | 631 | if (!qc) { |
625 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | 632 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", |
626 | ap->id); | 633 | ap->id); |
627 | } else { | 634 | } else { |
635 | ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT)); | ||
636 | |||
628 | /* hack alert! We cannot use the supplied completion | 637 | /* hack alert! We cannot use the supplied completion |
629 | * function from inside the ->eh_strategy_handler() thread. | 638 | * function from inside the ->eh_strategy_handler() thread. |
630 | * libata is the only user of ->eh_strategy_handler() in | 639 | * libata is the only user of ->eh_strategy_handler() in |
@@ -659,9 +668,19 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
659 | } | 668 | } |
660 | 669 | ||
661 | if (status & PORT_IRQ_FATAL) { | 670 | if (status & PORT_IRQ_FATAL) { |
671 | unsigned int err_mask; | ||
672 | if (status & PORT_IRQ_TF_ERR) | ||
673 | err_mask = AC_ERR_DEV; | ||
674 | else if (status & PORT_IRQ_IF_ERR) | ||
675 | err_mask = AC_ERR_ATA_BUS; | ||
676 | else | ||
677 | err_mask = AC_ERR_HOST_BUS; | ||
678 | |||
679 | /* command processing has stopped due to error; restart */ | ||
662 | ahci_intr_error(ap, status); | 680 | ahci_intr_error(ap, status); |
681 | |||
663 | if (qc) | 682 | if (qc) |
664 | ata_qc_complete(qc, AC_ERR_OTHER); | 683 | ata_qc_complete(qc, err_mask); |
665 | } | 684 | } |
666 | 685 | ||
667 | return 1; | 686 | return 1; |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index d81db3a3d4b9..ba1eb8b38e00 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -1263,7 +1263,7 @@ retry: | |||
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | /* ATAPI-specific feature tests */ | 1265 | /* ATAPI-specific feature tests */ |
1266 | else { | 1266 | else if (dev->class == ATA_DEV_ATAPI) { |
1267 | if (ata_id_is_ata(dev->id)) /* sanity check */ | 1267 | if (ata_id_is_ata(dev->id)) /* sanity check */ |
1268 | goto err_out_nosup; | 1268 | goto err_out_nosup; |
1269 | 1269 | ||
@@ -2399,7 +2399,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2399 | if (qc->flags & ATA_QCFLAG_SINGLE) | 2399 | if (qc->flags & ATA_QCFLAG_SINGLE) |
2400 | assert(qc->n_elem == 1); | 2400 | assert(qc->n_elem == 1); |
2401 | 2401 | ||
2402 | DPRINTK("unmapping %u sg elements\n", qc->n_elem); | 2402 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); |
2403 | 2403 | ||
2404 | /* if we padded the buffer out to 32-bit bound, and data | 2404 | /* if we padded the buffer out to 32-bit bound, and data |
2405 | * xfer direction is from-device, we must copy from the | 2405 | * xfer direction is from-device, we must copy from the |
@@ -2409,7 +2409,8 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2409 | pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); | 2409 | pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); |
2410 | 2410 | ||
2411 | if (qc->flags & ATA_QCFLAG_SG) { | 2411 | if (qc->flags & ATA_QCFLAG_SG) { |
2412 | dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir); | 2412 | if (qc->n_elem) |
2413 | dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir); | ||
2413 | /* restore last sg */ | 2414 | /* restore last sg */ |
2414 | sg[qc->orig_n_elem - 1].length += qc->pad_len; | 2415 | sg[qc->orig_n_elem - 1].length += qc->pad_len; |
2415 | if (pad_buf) { | 2416 | if (pad_buf) { |
@@ -2419,8 +2420,10 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2419 | kunmap_atomic(psg->page, KM_IRQ0); | 2420 | kunmap_atomic(psg->page, KM_IRQ0); |
2420 | } | 2421 | } |
2421 | } else { | 2422 | } else { |
2422 | dma_unmap_single(ap->host_set->dev, sg_dma_address(&sg[0]), | 2423 | if (sg_dma_len(&sg[0]) > 0) |
2423 | sg_dma_len(&sg[0]), dir); | 2424 | dma_unmap_single(ap->host_set->dev, |
2425 | sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), | ||
2426 | dir); | ||
2424 | /* restore sg */ | 2427 | /* restore sg */ |
2425 | sg->length += qc->pad_len; | 2428 | sg->length += qc->pad_len; |
2426 | if (pad_buf) | 2429 | if (pad_buf) |
@@ -2619,6 +2622,11 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2619 | sg->length, qc->pad_len); | 2622 | sg->length, qc->pad_len); |
2620 | } | 2623 | } |
2621 | 2624 | ||
2625 | if (!sg->length) { | ||
2626 | sg_dma_address(sg) = 0; | ||
2627 | goto skip_map; | ||
2628 | } | ||
2629 | |||
2622 | dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, | 2630 | dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, |
2623 | sg->length, dir); | 2631 | sg->length, dir); |
2624 | if (dma_mapping_error(dma_address)) { | 2632 | if (dma_mapping_error(dma_address)) { |
@@ -2628,6 +2636,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2628 | } | 2636 | } |
2629 | 2637 | ||
2630 | sg_dma_address(sg) = dma_address; | 2638 | sg_dma_address(sg) = dma_address; |
2639 | skip_map: | ||
2631 | sg_dma_len(sg) = sg->length; | 2640 | sg_dma_len(sg) = sg->length; |
2632 | 2641 | ||
2633 | DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), | 2642 | DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), |
@@ -2655,7 +2664,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2655 | struct ata_port *ap = qc->ap; | 2664 | struct ata_port *ap = qc->ap; |
2656 | struct scatterlist *sg = qc->__sg; | 2665 | struct scatterlist *sg = qc->__sg; |
2657 | struct scatterlist *lsg = &sg[qc->n_elem - 1]; | 2666 | struct scatterlist *lsg = &sg[qc->n_elem - 1]; |
2658 | int n_elem, dir; | 2667 | int n_elem, pre_n_elem, dir, trim_sg = 0; |
2659 | 2668 | ||
2660 | VPRINTK("ENTER, ata%u\n", ap->id); | 2669 | VPRINTK("ENTER, ata%u\n", ap->id); |
2661 | assert(qc->flags & ATA_QCFLAG_SG); | 2670 | assert(qc->flags & ATA_QCFLAG_SG); |
@@ -2689,13 +2698,24 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2689 | sg_dma_len(psg) = ATA_DMA_PAD_SZ; | 2698 | sg_dma_len(psg) = ATA_DMA_PAD_SZ; |
2690 | /* trim last sg */ | 2699 | /* trim last sg */ |
2691 | lsg->length -= qc->pad_len; | 2700 | lsg->length -= qc->pad_len; |
2701 | if (lsg->length == 0) | ||
2702 | trim_sg = 1; | ||
2692 | 2703 | ||
2693 | DPRINTK("padding done, sg[%d].length=%u pad_len=%u\n", | 2704 | DPRINTK("padding done, sg[%d].length=%u pad_len=%u\n", |
2694 | qc->n_elem - 1, lsg->length, qc->pad_len); | 2705 | qc->n_elem - 1, lsg->length, qc->pad_len); |
2695 | } | 2706 | } |
2696 | 2707 | ||
2708 | pre_n_elem = qc->n_elem; | ||
2709 | if (trim_sg && pre_n_elem) | ||
2710 | pre_n_elem--; | ||
2711 | |||
2712 | if (!pre_n_elem) { | ||
2713 | n_elem = 0; | ||
2714 | goto skip_map; | ||
2715 | } | ||
2716 | |||
2697 | dir = qc->dma_dir; | 2717 | dir = qc->dma_dir; |
2698 | n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir); | 2718 | n_elem = dma_map_sg(ap->host_set->dev, sg, pre_n_elem, dir); |
2699 | if (n_elem < 1) { | 2719 | if (n_elem < 1) { |
2700 | /* restore last sg */ | 2720 | /* restore last sg */ |
2701 | lsg->length += qc->pad_len; | 2721 | lsg->length += qc->pad_len; |
@@ -2704,6 +2724,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2704 | 2724 | ||
2705 | DPRINTK("%d sg elements mapped\n", n_elem); | 2725 | DPRINTK("%d sg elements mapped\n", n_elem); |
2706 | 2726 | ||
2727 | skip_map: | ||
2707 | qc->n_elem = n_elem; | 2728 | qc->n_elem = n_elem; |
2708 | 2729 | ||
2709 | return 0; | 2730 | return 0; |
@@ -3263,32 +3284,11 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3263 | { | 3284 | { |
3264 | struct ata_port *ap = qc->ap; | 3285 | struct ata_port *ap = qc->ap; |
3265 | struct ata_host_set *host_set = ap->host_set; | 3286 | struct ata_host_set *host_set = ap->host_set; |
3266 | struct ata_device *dev = qc->dev; | ||
3267 | u8 host_stat = 0, drv_stat; | 3287 | u8 host_stat = 0, drv_stat; |
3268 | unsigned long flags; | 3288 | unsigned long flags; |
3269 | 3289 | ||
3270 | DPRINTK("ENTER\n"); | 3290 | DPRINTK("ENTER\n"); |
3271 | 3291 | ||
3272 | /* FIXME: doesn't this conflict with timeout handling? */ | ||
3273 | if (qc->dev->class == ATA_DEV_ATAPI && qc->scsicmd) { | ||
3274 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
3275 | |||
3276 | if (!(cmd->eh_eflags & SCSI_EH_CANCEL_CMD)) { | ||
3277 | |||
3278 | /* finish completing original command */ | ||
3279 | spin_lock_irqsave(&host_set->lock, flags); | ||
3280 | __ata_qc_complete(qc); | ||
3281 | spin_unlock_irqrestore(&host_set->lock, flags); | ||
3282 | |||
3283 | atapi_request_sense(ap, dev, cmd); | ||
3284 | |||
3285 | cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16); | ||
3286 | scsi_finish_command(cmd); | ||
3287 | |||
3288 | goto out; | ||
3289 | } | ||
3290 | } | ||
3291 | |||
3292 | spin_lock_irqsave(&host_set->lock, flags); | 3292 | spin_lock_irqsave(&host_set->lock, flags); |
3293 | 3293 | ||
3294 | /* hack alert! We cannot use the supplied completion | 3294 | /* hack alert! We cannot use the supplied completion |
@@ -3327,7 +3327,6 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3327 | 3327 | ||
3328 | spin_unlock_irqrestore(&host_set->lock, flags); | 3328 | spin_unlock_irqrestore(&host_set->lock, flags); |
3329 | 3329 | ||
3330 | out: | ||
3331 | DPRINTK("EXIT\n"); | 3330 | DPRINTK("EXIT\n"); |
3332 | } | 3331 | } |
3333 | 3332 | ||
@@ -3411,16 +3410,11 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | |||
3411 | 3410 | ||
3412 | qc = ata_qc_new(ap); | 3411 | qc = ata_qc_new(ap); |
3413 | if (qc) { | 3412 | if (qc) { |
3414 | qc->__sg = NULL; | ||
3415 | qc->flags = 0; | ||
3416 | qc->scsicmd = NULL; | 3413 | qc->scsicmd = NULL; |
3417 | qc->ap = ap; | 3414 | qc->ap = ap; |
3418 | qc->dev = dev; | 3415 | qc->dev = dev; |
3419 | qc->cursect = qc->cursg = qc->cursg_ofs = 0; | ||
3420 | qc->nsect = 0; | ||
3421 | qc->nbytes = qc->curbytes = 0; | ||
3422 | 3416 | ||
3423 | ata_tf_init(ap, &qc->tf, dev->devno); | 3417 | ata_qc_reinit(qc); |
3424 | } | 3418 | } |
3425 | 3419 | ||
3426 | return qc; | 3420 | return qc; |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 0df4b682965d..3b4ca55a3332 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -1955,22 +1955,44 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 | |||
1955 | done(cmd); | 1955 | done(cmd); |
1956 | } | 1956 | } |
1957 | 1957 | ||
1958 | void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | 1958 | static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask) |
1959 | struct scsi_cmnd *cmd) | ||
1960 | { | 1959 | { |
1961 | DECLARE_COMPLETION(wait); | 1960 | if (err_mask && ((err_mask & AC_ERR_DEV) == 0)) |
1962 | struct ata_queued_cmd *qc; | 1961 | /* FIXME: not quite right; we don't want the |
1963 | unsigned long flags; | 1962 | * translation of taskfile registers into |
1964 | int rc; | 1963 | * a sense descriptors, since that's only |
1964 | * correct for ATA, not ATAPI | ||
1965 | */ | ||
1966 | ata_gen_ata_desc_sense(qc); | ||
1965 | 1967 | ||
1966 | DPRINTK("ATAPI request sense\n"); | 1968 | qc->scsidone(qc->scsicmd); |
1969 | return 0; | ||
1970 | } | ||
1967 | 1971 | ||
1968 | qc = ata_qc_new_init(ap, dev); | 1972 | /* is it pointless to prefer PIO for "safety reasons"? */ |
1969 | BUG_ON(qc == NULL); | 1973 | static inline int ata_pio_use_silly(struct ata_port *ap) |
1974 | { | ||
1975 | return (ap->flags & ATA_FLAG_PIO_DMA); | ||
1976 | } | ||
1977 | |||
1978 | static void atapi_request_sense(struct ata_queued_cmd *qc) | ||
1979 | { | ||
1980 | struct ata_port *ap = qc->ap; | ||
1981 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
1982 | |||
1983 | DPRINTK("ATAPI request sense\n"); | ||
1970 | 1984 | ||
1971 | /* FIXME: is this needed? */ | 1985 | /* FIXME: is this needed? */ |
1972 | memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); | 1986 | memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); |
1973 | 1987 | ||
1988 | ap->ops->tf_read(ap, &qc->tf); | ||
1989 | |||
1990 | /* fill these in, for the case where they are -not- overwritten */ | ||
1991 | cmd->sense_buffer[0] = 0x70; | ||
1992 | cmd->sense_buffer[2] = qc->tf.feature >> 4; | ||
1993 | |||
1994 | ata_qc_reinit(qc); | ||
1995 | |||
1974 | ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); | 1996 | ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); |
1975 | qc->dma_dir = DMA_FROM_DEVICE; | 1997 | qc->dma_dir = DMA_FROM_DEVICE; |
1976 | 1998 | ||
@@ -1981,22 +2003,20 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | |||
1981 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2003 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
1982 | qc->tf.command = ATA_CMD_PACKET; | 2004 | qc->tf.command = ATA_CMD_PACKET; |
1983 | 2005 | ||
1984 | qc->tf.protocol = ATA_PROT_ATAPI; | 2006 | if (ata_pio_use_silly(ap)) { |
1985 | qc->tf.lbam = (8 * 1024) & 0xff; | 2007 | qc->tf.protocol = ATA_PROT_ATAPI_DMA; |
1986 | qc->tf.lbah = (8 * 1024) >> 8; | 2008 | qc->tf.feature |= ATAPI_PKT_DMA; |
2009 | } else { | ||
2010 | qc->tf.protocol = ATA_PROT_ATAPI; | ||
2011 | qc->tf.lbam = (8 * 1024) & 0xff; | ||
2012 | qc->tf.lbah = (8 * 1024) >> 8; | ||
2013 | } | ||
1987 | qc->nbytes = SCSI_SENSE_BUFFERSIZE; | 2014 | qc->nbytes = SCSI_SENSE_BUFFERSIZE; |
1988 | 2015 | ||
1989 | qc->waiting = &wait; | 2016 | qc->complete_fn = atapi_sense_complete; |
1990 | qc->complete_fn = ata_qc_complete_noop; | ||
1991 | 2017 | ||
1992 | spin_lock_irqsave(&ap->host_set->lock, flags); | 2018 | if (ata_qc_issue(qc)) |
1993 | rc = ata_qc_issue(qc); | 2019 | ata_qc_complete(qc, AC_ERR_OTHER); |
1994 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1995 | |||
1996 | if (rc) | ||
1997 | ata_port_disable(ap); | ||
1998 | else | ||
1999 | wait_for_completion(&wait); | ||
2000 | 2020 | ||
2001 | DPRINTK("EXIT\n"); | 2021 | DPRINTK("EXIT\n"); |
2002 | } | 2022 | } |
@@ -2008,19 +2028,8 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
2008 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); | 2028 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); |
2009 | 2029 | ||
2010 | if (unlikely(err_mask & AC_ERR_DEV)) { | 2030 | if (unlikely(err_mask & AC_ERR_DEV)) { |
2011 | DPRINTK("request check condition\n"); | ||
2012 | |||
2013 | /* FIXME: command completion with check condition | ||
2014 | * but no sense causes the error handler to run, | ||
2015 | * which then issues REQUEST SENSE, fills in the sense | ||
2016 | * buffer, and completes the command (for the second | ||
2017 | * time). We need to issue REQUEST SENSE some other | ||
2018 | * way, to avoid completing the command twice. | ||
2019 | */ | ||
2020 | cmd->result = SAM_STAT_CHECK_CONDITION; | 2031 | cmd->result = SAM_STAT_CHECK_CONDITION; |
2021 | 2032 | atapi_request_sense(qc); | |
2022 | qc->scsidone(cmd); | ||
2023 | |||
2024 | return 1; | 2033 | return 1; |
2025 | } | 2034 | } |
2026 | 2035 | ||
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index fad051ca4672..74a84e0ec0a4 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -54,8 +54,6 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | |||
54 | 54 | ||
55 | 55 | ||
56 | /* libata-scsi.c */ | 56 | /* libata-scsi.c */ |
57 | extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | ||
58 | struct scsi_cmnd *cmd); | ||
59 | extern void ata_scsi_scan_host(struct ata_port *ap); | 57 | extern void ata_scsi_scan_host(struct ata_port *ap); |
60 | extern int ata_scsi_error(struct Scsi_Host *host); | 58 | extern int ata_scsi_error(struct Scsi_Host *host); |
61 | extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, | 59 | extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, |
diff --git a/include/linux/libata.h b/include/linux/libata.h index ad5996183ec2..f2dbb684ce9e 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -59,6 +59,8 @@ | |||
59 | #define VPRINTK(fmt, args...) | 59 | #define VPRINTK(fmt, args...) |
60 | #endif /* ATA_DEBUG */ | 60 | #endif /* ATA_DEBUG */ |
61 | 61 | ||
62 | #define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) | ||
63 | |||
62 | #ifdef ATA_NDEBUG | 64 | #ifdef ATA_NDEBUG |
63 | #define assert(expr) | 65 | #define assert(expr) |
64 | #else | 66 | #else |
@@ -119,6 +121,7 @@ enum { | |||
119 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 121 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ |
120 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 122 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once |
121 | * proper HSM is in place. */ | 123 | * proper HSM is in place. */ |
124 | ATA_FLAG_DEBUGMSG = (1 << 10), | ||
122 | 125 | ||
123 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 126 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ |
124 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 127 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ |
@@ -659,6 +662,17 @@ static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, uns | |||
659 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 662 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
660 | } | 663 | } |
661 | 664 | ||
665 | static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | ||
666 | { | ||
667 | qc->__sg = NULL; | ||
668 | qc->flags = 0; | ||
669 | qc->cursect = qc->cursg = qc->cursg_ofs = 0; | ||
670 | qc->nsect = 0; | ||
671 | qc->nbytes = qc->curbytes = 0; | ||
672 | |||
673 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); | ||
674 | } | ||
675 | |||
662 | 676 | ||
663 | /** | 677 | /** |
664 | * ata_irq_on - Enable interrupts on a port. | 678 | * ata_irq_on - Enable interrupts on a port. |