Skip to content

Commit c75be25

Browse files
committed
Merge branch 'drm-fixes-3.8' of git://people.freedesktop.org/~agd5f/linux into drm-next
Alex writes: A few more fixes for DMA and a mac quirk. * 'drm-fixes-3.8' of git://people.freedesktop.org/~agd5f/linux: drm/radeon: add quirk for d3 delay during switcheroo poweron for apple macbooks drm/radeon: fix DMA CS parser for r6xx linear copy packet drm/radeon: split r6xx and r7xx copy_dma functions
2 parents be8a42a + d1f9809 commit c75be25

File tree

6 files changed

+135
-16
lines changed

6 files changed

+135
-16
lines changed

drivers/gpu/drm/radeon/r600.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ int r600_copy_blit(struct radeon_device *rdev,
26462646
* @num_gpu_pages: number of GPU pages to xfer
26472647
* @fence: radeon fence object
26482648
*
2649-
* Copy GPU paging using the DMA engine (r6xx-r7xx).
2649+
* Copy GPU paging using the DMA engine (r6xx).
26502650
* Used by the radeon ttm implementation to move pages if
26512651
* registered as the asic copy callback.
26522652
*/
@@ -2669,8 +2669,8 @@ int r600_copy_dma(struct radeon_device *rdev,
26692669
}
26702670

26712671
size_in_dw = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT) / 4;
2672-
num_loops = DIV_ROUND_UP(size_in_dw, 0xffff);
2673-
r = radeon_ring_lock(rdev, ring, num_loops * 5 + 8);
2672+
num_loops = DIV_ROUND_UP(size_in_dw, 0xFFFE);
2673+
r = radeon_ring_lock(rdev, ring, num_loops * 4 + 8);
26742674
if (r) {
26752675
DRM_ERROR("radeon: moving bo (%d).\n", r);
26762676
radeon_semaphore_free(rdev, &sem, NULL);
@@ -2693,8 +2693,8 @@ int r600_copy_dma(struct radeon_device *rdev,
26932693
radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_COPY, 0, 0, cur_size_in_dw));
26942694
radeon_ring_write(ring, dst_offset & 0xfffffffc);
26952695
radeon_ring_write(ring, src_offset & 0xfffffffc);
2696-
radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff);
2697-
radeon_ring_write(ring, upper_32_bits(src_offset) & 0xff);
2696+
radeon_ring_write(ring, (((upper_32_bits(dst_offset) & 0xff) << 16) |
2697+
(upper_32_bits(src_offset) & 0xff)));
26982698
src_offset += cur_size_in_dw * 4;
26992699
dst_offset += cur_size_in_dw * 4;
27002700
}

drivers/gpu/drm/radeon/r600_cs.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,16 +2677,29 @@ int r600_dma_cs_parse(struct radeon_cs_parser *p)
26772677
}
26782678
p->idx += 7;
26792679
} else {
2680-
src_offset = ib[idx+2];
2681-
src_offset |= ((u64)(ib[idx+4] & 0xff)) << 32;
2682-
dst_offset = ib[idx+1];
2683-
dst_offset |= ((u64)(ib[idx+3] & 0xff)) << 32;
2680+
if (p->family >= CHIP_RV770) {
2681+
src_offset = ib[idx+2];
2682+
src_offset |= ((u64)(ib[idx+4] & 0xff)) << 32;
2683+
dst_offset = ib[idx+1];
2684+
dst_offset |= ((u64)(ib[idx+3] & 0xff)) << 32;
26842685

2685-
ib[idx+1] += (u32)(dst_reloc->lobj.gpu_offset & 0xfffffffc);
2686-
ib[idx+2] += (u32)(src_reloc->lobj.gpu_offset & 0xfffffffc);
2687-
ib[idx+3] += upper_32_bits(dst_reloc->lobj.gpu_offset) & 0xff;
2688-
ib[idx+4] += upper_32_bits(src_reloc->lobj.gpu_offset) & 0xff;
2689-
p->idx += 5;
2686+
ib[idx+1] += (u32)(dst_reloc->lobj.gpu_offset & 0xfffffffc);
2687+
ib[idx+2] += (u32)(src_reloc->lobj.gpu_offset & 0xfffffffc);
2688+
ib[idx+3] += upper_32_bits(dst_reloc->lobj.gpu_offset) & 0xff;
2689+
ib[idx+4] += upper_32_bits(src_reloc->lobj.gpu_offset) & 0xff;
2690+
p->idx += 5;
2691+
} else {
2692+
src_offset = ib[idx+2];
2693+
src_offset |= ((u64)(ib[idx+3] & 0xff)) << 32;
2694+
dst_offset = ib[idx+1];
2695+
dst_offset |= ((u64)(ib[idx+3] & 0xff0000)) << 16;
2696+
2697+
ib[idx+1] += (u32)(dst_reloc->lobj.gpu_offset & 0xfffffffc);
2698+
ib[idx+2] += (u32)(src_reloc->lobj.gpu_offset & 0xfffffffc);
2699+
ib[idx+3] += upper_32_bits(src_reloc->lobj.gpu_offset) & 0xff;
2700+
ib[idx+3] += (upper_32_bits(dst_reloc->lobj.gpu_offset) & 0xff) << 16;
2701+
p->idx += 4;
2702+
}
26902703
}
26912704
if ((src_offset + (count * 4)) > radeon_bo_size(src_reloc->robj)) {
26922705
dev_warn(p->dev, "DMA copy src buffer too small (%llu %lu)\n",

drivers/gpu/drm/radeon/radeon_asic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,9 @@ static struct radeon_asic rv770_asic = {
11401140
.copy = {
11411141
.blit = &r600_copy_blit,
11421142
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1143-
.dma = &r600_copy_dma,
1143+
.dma = &rv770_copy_dma,
11441144
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
1145-
.copy = &r600_copy_dma,
1145+
.copy = &rv770_copy_dma,
11461146
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
11471147
},
11481148
.surface = {

drivers/gpu/drm/radeon/radeon_asic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ u32 rv770_page_flip(struct radeon_device *rdev, int crtc, u64 crtc_base);
403403
void r700_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
404404
void r700_cp_stop(struct radeon_device *rdev);
405405
void r700_cp_fini(struct radeon_device *rdev);
406+
int rv770_copy_dma(struct radeon_device *rdev,
407+
uint64_t src_offset, uint64_t dst_offset,
408+
unsigned num_gpu_pages,
409+
struct radeon_fence **fence);
406410

407411
/*
408412
* evergreen

drivers/gpu/drm/radeon/radeon_device.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,25 @@ static void radeon_check_arguments(struct radeon_device *rdev)
896896
}
897897
}
898898

899+
/**
900+
* radeon_switcheroo_quirk_long_wakeup - return true if longer d3 delay is
901+
* needed for waking up.
902+
*
903+
* @pdev: pci dev pointer
904+
*/
905+
static bool radeon_switcheroo_quirk_long_wakeup(struct pci_dev *pdev)
906+
{
907+
908+
/* 6600m in a macbook pro */
909+
if (pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE &&
910+
pdev->subsystem_device == 0x00e2) {
911+
printk(KERN_INFO "radeon: quirking longer d3 wakeup delay\n");
912+
return true;
913+
}
914+
915+
return false;
916+
}
917+
899918
/**
900919
* radeon_switcheroo_set_state - set switcheroo state
901920
*
@@ -910,10 +929,19 @@ static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
910929
struct drm_device *dev = pci_get_drvdata(pdev);
911930
pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
912931
if (state == VGA_SWITCHEROO_ON) {
932+
unsigned d3_delay = dev->pdev->d3_delay;
933+
913934
printk(KERN_INFO "radeon: switched on\n");
914935
/* don't suspend or resume card normally */
915936
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
937+
938+
if (d3_delay < 20 && radeon_switcheroo_quirk_long_wakeup(pdev))
939+
dev->pdev->d3_delay = 20;
940+
916941
radeon_resume_kms(dev);
942+
943+
dev->pdev->d3_delay = d3_delay;
944+
917945
dev->switch_power_state = DRM_SWITCH_POWER_ON;
918946
drm_kms_helper_poll_enable(dev);
919947
} else {

drivers/gpu/drm/radeon/rv770.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,80 @@ static int rv770_mc_init(struct radeon_device *rdev)
887887
return 0;
888888
}
889889

890+
/**
891+
* rv770_copy_dma - copy pages using the DMA engine
892+
*
893+
* @rdev: radeon_device pointer
894+
* @src_offset: src GPU address
895+
* @dst_offset: dst GPU address
896+
* @num_gpu_pages: number of GPU pages to xfer
897+
* @fence: radeon fence object
898+
*
899+
* Copy GPU paging using the DMA engine (r7xx).
900+
* Used by the radeon ttm implementation to move pages if
901+
* registered as the asic copy callback.
902+
*/
903+
int rv770_copy_dma(struct radeon_device *rdev,
904+
uint64_t src_offset, uint64_t dst_offset,
905+
unsigned num_gpu_pages,
906+
struct radeon_fence **fence)
907+
{
908+
struct radeon_semaphore *sem = NULL;
909+
int ring_index = rdev->asic->copy.dma_ring_index;
910+
struct radeon_ring *ring = &rdev->ring[ring_index];
911+
u32 size_in_dw, cur_size_in_dw;
912+
int i, num_loops;
913+
int r = 0;
914+
915+
r = radeon_semaphore_create(rdev, &sem);
916+
if (r) {
917+
DRM_ERROR("radeon: moving bo (%d).\n", r);
918+
return r;
919+
}
920+
921+
size_in_dw = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT) / 4;
922+
num_loops = DIV_ROUND_UP(size_in_dw, 0xFFFF);
923+
r = radeon_ring_lock(rdev, ring, num_loops * 5 + 8);
924+
if (r) {
925+
DRM_ERROR("radeon: moving bo (%d).\n", r);
926+
radeon_semaphore_free(rdev, &sem, NULL);
927+
return r;
928+
}
929+
930+
if (radeon_fence_need_sync(*fence, ring->idx)) {
931+
radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring,
932+
ring->idx);
933+
radeon_fence_note_sync(*fence, ring->idx);
934+
} else {
935+
radeon_semaphore_free(rdev, &sem, NULL);
936+
}
937+
938+
for (i = 0; i < num_loops; i++) {
939+
cur_size_in_dw = size_in_dw;
940+
if (cur_size_in_dw > 0xFFFF)
941+
cur_size_in_dw = 0xFFFF;
942+
size_in_dw -= cur_size_in_dw;
943+
radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_COPY, 0, 0, cur_size_in_dw));
944+
radeon_ring_write(ring, dst_offset & 0xfffffffc);
945+
radeon_ring_write(ring, src_offset & 0xfffffffc);
946+
radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff);
947+
radeon_ring_write(ring, upper_32_bits(src_offset) & 0xff);
948+
src_offset += cur_size_in_dw * 4;
949+
dst_offset += cur_size_in_dw * 4;
950+
}
951+
952+
r = radeon_fence_emit(rdev, fence, ring->idx);
953+
if (r) {
954+
radeon_ring_unlock_undo(rdev, ring);
955+
return r;
956+
}
957+
958+
radeon_ring_unlock_commit(rdev, ring);
959+
radeon_semaphore_free(rdev, &sem, *fence);
960+
961+
return r;
962+
}
963+
890964
static int rv770_startup(struct radeon_device *rdev)
891965
{
892966
struct radeon_ring *ring;

0 commit comments

Comments
 (0)