diff options
author | David S. Miller <davem@davemloft.net> | 2008-04-03 17:33:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-03 17:33:42 -0400 |
commit | 3bb5da3837cc1aa17736b05139c9a22c3794851a (patch) | |
tree | c92d5684a866542b1cb20641607ac1643ce03a47 /drivers/char/drm/via_dma.c | |
parent | 7feb49c82a74bc7c091b8ab2a3f96baa33d08ece (diff) | |
parent | 9597362d354f8655ece324b01d0c640a0e99c077 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'drivers/char/drm/via_dma.c')
-rw-r--r-- | drivers/char/drm/via_dma.c | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c index 94baec692b57..7a339dba6a69 100644 --- a/drivers/char/drm/via_dma.c +++ b/drivers/char/drm/via_dma.c | |||
@@ -126,6 +126,8 @@ via_cmdbuf_wait(drm_via_private_t * dev_priv, unsigned int size) | |||
126 | hw_addr, cur_addr, next_addr); | 126 | hw_addr, cur_addr, next_addr); |
127 | return -1; | 127 | return -1; |
128 | } | 128 | } |
129 | if ((cur_addr < hw_addr) && (next_addr >= hw_addr)) | ||
130 | msleep(1); | ||
129 | } while ((cur_addr < hw_addr) && (next_addr >= hw_addr)); | 131 | } while ((cur_addr < hw_addr) && (next_addr >= hw_addr)); |
130 | return 0; | 132 | return 0; |
131 | } | 133 | } |
@@ -416,27 +418,50 @@ static int via_hook_segment(drm_via_private_t * dev_priv, | |||
416 | int paused, count; | 418 | int paused, count; |
417 | volatile uint32_t *paused_at = dev_priv->last_pause_ptr; | 419 | volatile uint32_t *paused_at = dev_priv->last_pause_ptr; |
418 | uint32_t reader,ptr; | 420 | uint32_t reader,ptr; |
421 | uint32_t diff; | ||
419 | 422 | ||
420 | paused = 0; | 423 | paused = 0; |
421 | via_flush_write_combine(); | 424 | via_flush_write_combine(); |
422 | (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1); | 425 | (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1); |
426 | |||
423 | *paused_at = pause_addr_lo; | 427 | *paused_at = pause_addr_lo; |
424 | via_flush_write_combine(); | 428 | via_flush_write_combine(); |
425 | (void) *paused_at; | 429 | (void) *paused_at; |
430 | |||
426 | reader = *(dev_priv->hw_addr_ptr); | 431 | reader = *(dev_priv->hw_addr_ptr); |
427 | ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + | 432 | ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + |
428 | dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; | 433 | dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; |
434 | |||
429 | dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1; | 435 | dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1; |
430 | 436 | ||
431 | if ((ptr - reader) <= dev_priv->dma_diff ) { | 437 | /* |
432 | count = 10000000; | 438 | * If there is a possibility that the command reader will |
433 | while (!(paused = (VIA_READ(0x41c) & 0x80000000)) && count--); | 439 | * miss the new pause address and pause on the old one, |
440 | * In that case we need to program the new start address | ||
441 | * using PCI. | ||
442 | */ | ||
443 | |||
444 | diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff; | ||
445 | count = 10000000; | ||
446 | while(diff == 0 && count--) { | ||
447 | paused = (VIA_READ(0x41c) & 0x80000000); | ||
448 | if (paused) | ||
449 | break; | ||
450 | reader = *(dev_priv->hw_addr_ptr); | ||
451 | diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff; | ||
434 | } | 452 | } |
435 | 453 | ||
454 | paused = VIA_READ(0x41c) & 0x80000000; | ||
455 | |||
436 | if (paused && !no_pci_fire) { | 456 | if (paused && !no_pci_fire) { |
437 | reader = *(dev_priv->hw_addr_ptr); | 457 | reader = *(dev_priv->hw_addr_ptr); |
438 | if ((ptr - reader) == dev_priv->dma_diff) { | 458 | diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff; |
439 | 459 | diff &= (dev_priv->dma_high - 1); | |
460 | if (diff != 0 && diff < (dev_priv->dma_high >> 1)) { | ||
461 | DRM_ERROR("Paused at incorrect address. " | ||
462 | "0x%08x, 0x%08x 0x%08x\n", | ||
463 | ptr, reader, dev_priv->dma_diff); | ||
464 | } else if (diff == 0) { | ||
440 | /* | 465 | /* |
441 | * There is a concern that these writes may stall the PCI bus | 466 | * There is a concern that these writes may stall the PCI bus |
442 | * if the GPU is not idle. However, idling the GPU first | 467 | * if the GPU is not idle. However, idling the GPU first |
@@ -577,6 +602,7 @@ static void via_cmdbuf_jump(drm_via_private_t * dev_priv) | |||
577 | uint32_t pause_addr_lo, pause_addr_hi; | 602 | uint32_t pause_addr_lo, pause_addr_hi; |
578 | uint32_t jump_addr_lo, jump_addr_hi; | 603 | uint32_t jump_addr_lo, jump_addr_hi; |
579 | volatile uint32_t *last_pause_ptr; | 604 | volatile uint32_t *last_pause_ptr; |
605 | uint32_t dma_low_save1, dma_low_save2; | ||
580 | 606 | ||
581 | agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr; | 607 | agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr; |
582 | via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi, | 608 | via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi, |
@@ -603,8 +629,29 @@ static void via_cmdbuf_jump(drm_via_private_t * dev_priv) | |||
603 | &pause_addr_lo, 0); | 629 | &pause_addr_lo, 0); |
604 | 630 | ||
605 | *last_pause_ptr = pause_addr_lo; | 631 | *last_pause_ptr = pause_addr_lo; |
632 | dma_low_save1 = dev_priv->dma_low; | ||
606 | 633 | ||
607 | via_hook_segment( dev_priv, jump_addr_hi, jump_addr_lo, 0); | 634 | /* |
635 | * Now, set a trap that will pause the regulator if it tries to rerun the old | ||
636 | * command buffer. (Which may happen if via_hook_segment detecs a command regulator pause | ||
637 | * and reissues the jump command over PCI, while the regulator has already taken the jump | ||
638 | * and actually paused at the current buffer end). | ||
639 | * There appears to be no other way to detect this condition, since the hw_addr_pointer | ||
640 | * does not seem to get updated immediately when a jump occurs. | ||
641 | */ | ||
642 | |||
643 | last_pause_ptr = | ||
644 | via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, | ||
645 | &pause_addr_lo, 0) - 1; | ||
646 | via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, | ||
647 | &pause_addr_lo, 0); | ||
648 | *last_pause_ptr = pause_addr_lo; | ||
649 | |||
650 | dma_low_save2 = dev_priv->dma_low; | ||
651 | dev_priv->dma_low = dma_low_save1; | ||
652 | via_hook_segment(dev_priv, jump_addr_hi, jump_addr_lo, 0); | ||
653 | dev_priv->dma_low = dma_low_save2; | ||
654 | via_hook_segment(dev_priv, pause_addr_hi, pause_addr_lo, 0); | ||
608 | } | 655 | } |
609 | 656 | ||
610 | 657 | ||