aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2008-03-16 20:07:20 -0400
committerDave Airlie <airlied@redhat.com>2008-03-16 20:07:20 -0400
commitf0fb6d7798e7e2d1f37a2c15892910661bdaba55 (patch)
tree41ede9d8c5b267700f8304a5299916c4b253986e /drivers
parent9df5808cca52f33e1deb52b5010c68c6ed1656fe (diff)
drm/via: attempt again to stabilise the AGP DMA command submission.
It's worth remembering that all new bright ideas on how to make this command reader work properly and according to docs will probably fail :( Bring in some old code. Also allow a larger SG-DMA download stride, and remove unnecessary waits for command regulators pauses. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/drm/via_dma.c59
-rw-r--r--drivers/char/drm/via_dmablit.c2
2 files changed, 54 insertions, 7 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
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 33c5197b73c4..409e00afdd07 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -603,7 +603,7 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
603 * (Not a big limitation anyway.) 603 * (Not a big limitation anyway.)
604 */ 604 */
605 605
606 if ((xfer->mem_stride - xfer->line_length) >= PAGE_SIZE) { 606 if ((xfer->mem_stride - xfer->line_length) > 2*PAGE_SIZE) {
607 DRM_ERROR("Too large system memory stride. Stride: %d, " 607 DRM_ERROR("Too large system memory stride. Stride: %d, "
608 "Length: %d\n", xfer->mem_stride, xfer->line_length); 608 "Length: %d\n", xfer->mem_stride, xfer->line_length);
609 return -EINVAL; 609 return -EINVAL;