diff options
author | Jerome Glisse <jglisse@redhat.com> | 2011-12-21 12:13:46 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-01-05 05:03:33 -0500 |
commit | 69e130a6a42270f94e6ee0bce34c3480a6b9da61 (patch) | |
tree | 025e3a3d94400eb3f6dd15535544d569cc57b5ad /drivers/gpu | |
parent | 1f2e124df90cfc1347fd301409570fa9b0aed2c9 (diff) |
drm/radeon: make ib size variable
This avoid to waste ib pool size and avoid a bunch of wait for
previous ib to finish.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/r100.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r600.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r600_blit_kms.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_cs.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ring.c | 7 |
6 files changed, 21 insertions, 14 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index 657040b15b06..947ba22c4d86 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
@@ -3708,7 +3708,7 @@ int r100_ib_test(struct radeon_device *rdev) | |||
3708 | return r; | 3708 | return r; |
3709 | } | 3709 | } |
3710 | WREG32(scratch, 0xCAFEDEAD); | 3710 | WREG32(scratch, 0xCAFEDEAD); |
3711 | r = radeon_ib_get(rdev, RADEON_RING_TYPE_GFX_INDEX, &ib); | 3711 | r = radeon_ib_get(rdev, RADEON_RING_TYPE_GFX_INDEX, &ib, 256); |
3712 | if (r) { | 3712 | if (r) { |
3713 | return r; | 3713 | return r; |
3714 | } | 3714 | } |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 951566f1de9e..4f08e5e6ee9d 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -2711,7 +2711,7 @@ int r600_ib_test(struct radeon_device *rdev, int ring) | |||
2711 | return r; | 2711 | return r; |
2712 | } | 2712 | } |
2713 | WREG32(scratch, 0xCAFEDEAD); | 2713 | WREG32(scratch, 0xCAFEDEAD); |
2714 | r = radeon_ib_get(rdev, ring, &ib); | 2714 | r = radeon_ib_get(rdev, ring, &ib, 256); |
2715 | if (r) { | 2715 | if (r) { |
2716 | DRM_ERROR("radeon: failed to get ib (%d).\n", r); | 2716 | DRM_ERROR("radeon: failed to get ib (%d).\n", r); |
2717 | return r; | 2717 | return r; |
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c index 02a757470291..d996f4381130 100644 --- a/drivers/gpu/drm/radeon/r600_blit_kms.c +++ b/drivers/gpu/drm/radeon/r600_blit_kms.c | |||
@@ -619,16 +619,17 @@ void r600_blit_fini(struct radeon_device *rdev) | |||
619 | radeon_bo_unref(&rdev->r600_blit.shader_obj); | 619 | radeon_bo_unref(&rdev->r600_blit.shader_obj); |
620 | } | 620 | } |
621 | 621 | ||
622 | static int r600_vb_ib_get(struct radeon_device *rdev) | 622 | static int r600_vb_ib_get(struct radeon_device *rdev, unsigned size) |
623 | { | 623 | { |
624 | int r; | 624 | int r; |
625 | r = radeon_ib_get(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->r600_blit.vb_ib); | 625 | r = radeon_ib_get(rdev, RADEON_RING_TYPE_GFX_INDEX, |
626 | &rdev->r600_blit.vb_ib, size); | ||
626 | if (r) { | 627 | if (r) { |
627 | DRM_ERROR("failed to get IB for vertex buffer\n"); | 628 | DRM_ERROR("failed to get IB for vertex buffer\n"); |
628 | return r; | 629 | return r; |
629 | } | 630 | } |
630 | 631 | ||
631 | rdev->r600_blit.vb_total = 64*1024; | 632 | rdev->r600_blit.vb_total = size; |
632 | rdev->r600_blit.vb_used = 0; | 633 | rdev->r600_blit.vb_used = 0; |
633 | return 0; | 634 | return 0; |
634 | } | 635 | } |
@@ -693,10 +694,6 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages) | |||
693 | int num_loops = 0; | 694 | int num_loops = 0; |
694 | int dwords_per_loop = rdev->r600_blit.ring_size_per_loop; | 695 | int dwords_per_loop = rdev->r600_blit.ring_size_per_loop; |
695 | 696 | ||
696 | r = r600_vb_ib_get(rdev); | ||
697 | if (r) | ||
698 | return r; | ||
699 | |||
700 | /* num loops */ | 697 | /* num loops */ |
701 | while (num_gpu_pages) { | 698 | while (num_gpu_pages) { |
702 | num_gpu_pages -= | 699 | num_gpu_pages -= |
@@ -705,6 +702,11 @@ int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages) | |||
705 | num_loops++; | 702 | num_loops++; |
706 | } | 703 | } |
707 | 704 | ||
705 | /* 48 bytes for vertex per loop */ | ||
706 | r = r600_vb_ib_get(rdev, (num_loops*48)+256); | ||
707 | if (r) | ||
708 | return r; | ||
709 | |||
708 | /* calculate number of loops correctly */ | 710 | /* calculate number of loops correctly */ |
709 | ring_size = num_loops * dwords_per_loop; | 711 | ring_size = num_loops * dwords_per_loop; |
710 | ring_size += rdev->r600_blit.ring_size_common; | 712 | ring_size += rdev->r600_blit.ring_size_common; |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index f29edbf62962..0301896ac157 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -638,7 +638,8 @@ struct r600_blit { | |||
638 | 638 | ||
639 | void r600_blit_suspend(struct radeon_device *rdev); | 639 | void r600_blit_suspend(struct radeon_device *rdev); |
640 | 640 | ||
641 | int radeon_ib_get(struct radeon_device *rdev, int ring, struct radeon_ib **ib); | 641 | int radeon_ib_get(struct radeon_device *rdev, int ring, |
642 | struct radeon_ib **ib, unsigned size); | ||
642 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); | 643 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); |
643 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); | 644 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); |
644 | int radeon_ib_pool_init(struct radeon_device *rdev); | 645 | int radeon_ib_pool_init(struct radeon_device *rdev); |
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 09ef48636e53..6559cc455135 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
@@ -246,7 +246,9 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
246 | radeon_mutex_unlock(&rdev->cs_mutex); | 246 | radeon_mutex_unlock(&rdev->cs_mutex); |
247 | return r; | 247 | return r; |
248 | } | 248 | } |
249 | r = radeon_ib_get(rdev, RADEON_RING_TYPE_GFX_INDEX, &parser.ib); | 249 | ib_chunk = &parser.chunks[parser.chunk_ib_idx]; |
250 | r = radeon_ib_get(rdev, RADEON_RING_TYPE_GFX_INDEX, &parser.ib, | ||
251 | ib_chunk->length_dw * 4); | ||
250 | if (r) { | 252 | if (r) { |
251 | DRM_ERROR("Failed to get ib !\n"); | 253 | DRM_ERROR("Failed to get ib !\n"); |
252 | radeon_cs_parser_fini(&parser, r); | 254 | radeon_cs_parser_fini(&parser, r); |
@@ -264,7 +266,6 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
264 | /* Copy the packet into the IB, the parser will read from the | 266 | /* Copy the packet into the IB, the parser will read from the |
265 | * input memory (cached) and write to the IB (which can be | 267 | * input memory (cached) and write to the IB (which can be |
266 | * uncached). */ | 268 | * uncached). */ |
267 | ib_chunk = &parser.chunks[parser.chunk_ib_idx]; | ||
268 | parser.ib->length_dw = ib_chunk->length_dw; | 269 | parser.ib->length_dw = ib_chunk->length_dw; |
269 | r = radeon_cs_parse(&parser); | 270 | r = radeon_cs_parse(&parser); |
270 | if (r || parser.parser_error) { | 271 | if (r || parser.parser_error) { |
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index f6a4fbd102a0..bc844fe86ae6 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c | |||
@@ -93,13 +93,16 @@ static bool radeon_ib_try_free(struct radeon_device *rdev, | |||
93 | return done; | 93 | return done; |
94 | } | 94 | } |
95 | 95 | ||
96 | int radeon_ib_get(struct radeon_device *rdev, int ring, struct radeon_ib **ib) | 96 | int radeon_ib_get(struct radeon_device *rdev, int ring, |
97 | struct radeon_ib **ib, unsigned size) | ||
97 | { | 98 | { |
98 | struct radeon_fence *fence; | 99 | struct radeon_fence *fence; |
99 | unsigned cretry = 0; | 100 | unsigned cretry = 0; |
100 | int r = 0, i, idx; | 101 | int r = 0, i, idx; |
101 | 102 | ||
102 | *ib = NULL; | 103 | *ib = NULL; |
104 | /* align size on 256 bytes */ | ||
105 | size = ALIGN(size, 256); | ||
103 | 106 | ||
104 | r = radeon_fence_create(rdev, &fence, ring); | 107 | r = radeon_fence_create(rdev, &fence, ring); |
105 | if (r) { | 108 | if (r) { |
@@ -122,7 +125,7 @@ retry: | |||
122 | if (rdev->ib_pool.ibs[idx].fence == NULL) { | 125 | if (rdev->ib_pool.ibs[idx].fence == NULL) { |
123 | r = radeon_sa_bo_new(rdev, &rdev->ib_pool.sa_manager, | 126 | r = radeon_sa_bo_new(rdev, &rdev->ib_pool.sa_manager, |
124 | &rdev->ib_pool.ibs[idx].sa_bo, | 127 | &rdev->ib_pool.ibs[idx].sa_bo, |
125 | 64*1024, 64); | 128 | size, 256); |
126 | if (!r) { | 129 | if (!r) { |
127 | *ib = &rdev->ib_pool.ibs[idx]; | 130 | *ib = &rdev->ib_pool.ibs[idx]; |
128 | (*ib)->ptr = rdev->ib_pool.sa_manager.cpu_ptr; | 131 | (*ib)->ptr = rdev->ib_pool.sa_manager.cpu_ptr; |