diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-irq.c | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c index 9b4faf009196..9c29e964d400 100644 --- a/drivers/media/video/ivtv/ivtv-irq.c +++ b/drivers/media/video/ivtv/ivtv-irq.c | |||
@@ -628,22 +628,66 @@ static void ivtv_irq_enc_pio_complete(struct ivtv *itv) | |||
628 | static void ivtv_irq_dma_err(struct ivtv *itv) | 628 | static void ivtv_irq_dma_err(struct ivtv *itv) |
629 | { | 629 | { |
630 | u32 data[CX2341X_MBOX_MAX_DATA]; | 630 | u32 data[CX2341X_MBOX_MAX_DATA]; |
631 | u32 status; | ||
631 | 632 | ||
632 | del_timer(&itv->dma_timer); | 633 | del_timer(&itv->dma_timer); |
634 | |||
633 | ivtv_api_get_data(&itv->enc_mbox, IVTV_MBOX_DMA_END, 2, data); | 635 | ivtv_api_get_data(&itv->enc_mbox, IVTV_MBOX_DMA_END, 2, data); |
636 | status = read_reg(IVTV_REG_DMASTATUS); | ||
634 | IVTV_DEBUG_WARN("DMA ERROR %08x %08x %08x %d\n", data[0], data[1], | 637 | IVTV_DEBUG_WARN("DMA ERROR %08x %08x %08x %d\n", data[0], data[1], |
635 | read_reg(IVTV_REG_DMASTATUS), itv->cur_dma_stream); | 638 | status, itv->cur_dma_stream); |
636 | write_reg(read_reg(IVTV_REG_DMASTATUS) & 3, IVTV_REG_DMASTATUS); | 639 | /* |
640 | * We do *not* write back to the IVTV_REG_DMASTATUS register to | ||
641 | * clear the error status, if either the encoder write (0x02) or | ||
642 | * decoder read (0x01) bus master DMA operation do not indicate | ||
643 | * completed. We can race with the DMA engine, which may have | ||
644 | * transitioned to completed status *after* we read the register. | ||
645 | * Setting a IVTV_REG_DMASTATUS flag back to "busy" status, after the | ||
646 | * DMA engine has completed, will cause the DMA engine to stop working. | ||
647 | */ | ||
648 | status &= 0x3; | ||
649 | if (status == 0x3) | ||
650 | write_reg(status, IVTV_REG_DMASTATUS); | ||
651 | |||
637 | if (!test_bit(IVTV_F_I_UDMA, &itv->i_flags) && | 652 | if (!test_bit(IVTV_F_I_UDMA, &itv->i_flags) && |
638 | itv->cur_dma_stream >= 0 && itv->cur_dma_stream < IVTV_MAX_STREAMS) { | 653 | itv->cur_dma_stream >= 0 && itv->cur_dma_stream < IVTV_MAX_STREAMS) { |
639 | struct ivtv_stream *s = &itv->streams[itv->cur_dma_stream]; | 654 | struct ivtv_stream *s = &itv->streams[itv->cur_dma_stream]; |
640 | 655 | ||
641 | /* retry */ | 656 | if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) { |
642 | if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) | 657 | /* retry */ |
658 | /* | ||
659 | * FIXME - handle cases of DMA error similar to | ||
660 | * encoder below, except conditioned on status & 0x1 | ||
661 | */ | ||
643 | ivtv_dma_dec_start(s); | 662 | ivtv_dma_dec_start(s); |
644 | else | 663 | return; |
645 | ivtv_dma_enc_start(s); | 664 | } else { |
646 | return; | 665 | if ((status & 0x2) == 0) { |
666 | /* | ||
667 | * CX2341x Bus Master DMA write is ongoing. | ||
668 | * Reset the timer and let it complete. | ||
669 | */ | ||
670 | itv->dma_timer.expires = | ||
671 | jiffies + msecs_to_jiffies(600); | ||
672 | add_timer(&itv->dma_timer); | ||
673 | return; | ||
674 | } | ||
675 | |||
676 | if (itv->dma_retries < 3) { | ||
677 | /* | ||
678 | * CX2341x Bus Master DMA write has ended. | ||
679 | * Retry the write, starting with the first | ||
680 | * xfer segment. Just retrying the current | ||
681 | * segment is not sufficient. | ||
682 | */ | ||
683 | s->sg_processed = 0; | ||
684 | itv->dma_retries++; | ||
685 | ivtv_dma_enc_start_xfer(s); | ||
686 | return; | ||
687 | } | ||
688 | /* Too many retries, give up on this one */ | ||
689 | } | ||
690 | |||
647 | } | 691 | } |
648 | if (test_bit(IVTV_F_I_UDMA, &itv->i_flags)) { | 692 | if (test_bit(IVTV_F_I_UDMA, &itv->i_flags)) { |
649 | ivtv_udma_start(itv); | 693 | ivtv_udma_start(itv); |