aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2011-10-13 19:08:47 -0400
committerDave Airlie <airlied@redhat.com>2011-10-18 04:53:05 -0400
commitce580fab739c815e25d13bae62f96ba7251f6e2e (patch)
treefb8d0e0e4c678b5a14198a0c65cd579aca039ad1 /drivers/gpu/drm/radeon
parentcbdd45015af78ec9e75ed7a3df8b76048c4d289f (diff)
drm/radeon: Move more code out of line
With this patch I'm only about 50k larger with DRM debugging enables (why is that enabled by default?!?), and slightly smaller without. [airlied: moved r100.c additions to radeon_ring.c] Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/r300_cmdbuf.c2
-rw-r--r--drivers/gpu/drm/radeon/r600.c4
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon.h39
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_tv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c42
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.h42
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c38
-rw-r--r--drivers/gpu/drm/radeon/radeon_state.c16
11 files changed, 106 insertions, 87 deletions
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
index c5c2742e4140..1fe98b421c9b 100644
--- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
+++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
@@ -791,7 +791,7 @@ static __inline__ int r300_emit_packet3(drm_radeon_private_t *dev_priv,
791/** 791/**
792 * Emit the sequence to pacify R300. 792 * Emit the sequence to pacify R300.
793 */ 793 */
794static __inline__ void r300_pacify(drm_radeon_private_t *dev_priv) 794static void r300_pacify(drm_radeon_private_t *dev_priv)
795{ 795{
796 uint32_t cache_z, cache_3d, cache_2d; 796 uint32_t cache_z, cache_3d, cache_2d;
797 RING_LOCALS; 797 RING_LOCALS;
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 334aee6eab7c..c4de1610088c 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3138,7 +3138,7 @@ int r600_irq_set(struct radeon_device *rdev)
3138 return 0; 3138 return 0;
3139} 3139}
3140 3140
3141static inline void r600_irq_ack(struct radeon_device *rdev) 3141static void r600_irq_ack(struct radeon_device *rdev)
3142{ 3142{
3143 u32 tmp; 3143 u32 tmp;
3144 3144
@@ -3239,7 +3239,7 @@ void r600_irq_disable(struct radeon_device *rdev)
3239 r600_disable_interrupt_state(rdev); 3239 r600_disable_interrupt_state(rdev);
3240} 3240}
3241 3241
3242static inline u32 r600_get_ih_wptr(struct radeon_device *rdev) 3242static u32 r600_get_ih_wptr(struct radeon_device *rdev)
3243{ 3243{
3244 u32 wptr, tmp; 3244 u32 wptr, tmp;
3245 3245
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c
index 9aa74c3f8cb6..bbbafe685543 100644
--- a/drivers/gpu/drm/radeon/r600_blit_kms.c
+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
@@ -450,7 +450,7 @@ set_default_state(struct radeon_device *rdev)
450 radeon_ring_write(rdev, sq_stack_resource_mgmt_2); 450 radeon_ring_write(rdev, sq_stack_resource_mgmt_2);
451} 451}
452 452
453static inline uint32_t i2f(uint32_t input) 453static uint32_t i2f(uint32_t input)
454{ 454{
455 u32 result, i, exponent, fraction; 455 u32 result, i, exponent, fraction;
456 456
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index ff5424e43d1b..f3260f7136a9 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -600,32 +600,7 @@ struct radeon_cs_parser {
600 600
601extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx); 601extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx);
602extern int radeon_cs_finish_pages(struct radeon_cs_parser *p); 602extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
603 603extern u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx);
604
605static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
606{
607 struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
608 u32 pg_idx, pg_offset;
609 u32 idx_value = 0;
610 int new_page;
611
612 pg_idx = (idx * 4) / PAGE_SIZE;
613 pg_offset = (idx * 4) % PAGE_SIZE;
614
615 if (ibc->kpage_idx[0] == pg_idx)
616 return ibc->kpage[0][pg_offset/4];
617 if (ibc->kpage_idx[1] == pg_idx)
618 return ibc->kpage[1][pg_offset/4];
619
620 new_page = radeon_cs_update_pages(p, pg_idx);
621 if (new_page < 0) {
622 p->parser_error = new_page;
623 return 0;
624 }
625
626 idx_value = ibc->kpage[new_page][pg_offset/4];
627 return idx_value;
628}
629 604
630struct radeon_cs_packet { 605struct radeon_cs_packet {
631 unsigned idx; 606 unsigned idx;
@@ -1414,19 +1389,19 @@ void radeon_atombios_fini(struct radeon_device *rdev);
1414/* 1389/*
1415 * RING helpers. 1390 * RING helpers.
1416 */ 1391 */
1392
1393#if DRM_DEBUG_CODE == 0
1417static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) 1394static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
1418{ 1395{
1419#if DRM_DEBUG_CODE
1420 if (rdev->cp.count_dw <= 0) {
1421 DRM_ERROR("radeon: writting more dword to ring than expected !\n");
1422 }
1423#endif
1424 rdev->cp.ring[rdev->cp.wptr++] = v; 1396 rdev->cp.ring[rdev->cp.wptr++] = v;
1425 rdev->cp.wptr &= rdev->cp.ptr_mask; 1397 rdev->cp.wptr &= rdev->cp.ptr_mask;
1426 rdev->cp.count_dw--; 1398 rdev->cp.count_dw--;
1427 rdev->cp.ring_free_dw--; 1399 rdev->cp.ring_free_dw--;
1428} 1400}
1429 1401#else
1402/* With debugging this is just too big to inline */
1403void radeon_ring_write(struct radeon_device *rdev, uint32_t v);
1404#endif
1430 1405
1431/* 1406/*
1432 * ASICs macro. 1407 * ASICs macro.
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index bf2b61584cdb..08d0b94332e6 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -62,7 +62,7 @@ union atom_supported_devices {
62 struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1; 62 struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1;
63}; 63};
64 64
65static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev, 65static struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev,
66 uint8_t id) 66 uint8_t id)
67{ 67{
68 struct atom_context *ctx = rdev->mode_info.atom_context; 68 struct atom_context *ctx = rdev->mode_info.atom_context;
@@ -228,7 +228,7 @@ void radeon_atombios_i2c_init(struct radeon_device *rdev)
228 } 228 }
229} 229}
230 230
231static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev, 231static struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev,
232 u8 id) 232 u8 id)
233{ 233{
234 struct atom_context *ctx = rdev->mode_info.atom_context; 234 struct atom_context *ctx = rdev->mode_info.atom_context;
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 465746bd51b7..00da38424dfc 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -129,7 +129,7 @@ void radeon_disable_vblank(struct drm_device *dev, int crtc)
129 } 129 }
130} 130}
131 131
132static inline u32 radeon_acknowledge_irqs(drm_radeon_private_t *dev_priv, u32 *r500_disp_int) 132static u32 radeon_acknowledge_irqs(drm_radeon_private_t *dev_priv, u32 *r500_disp_int)
133{ 133{
134 u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS); 134 u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS);
135 u32 irq_mask = RADEON_SW_INT_TEST; 135 u32 irq_mask = RADEON_SW_INT_TEST;
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_tv.c b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
index c7b6cb428d09..b37ec0f1413a 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_tv.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
@@ -864,7 +864,7 @@ void radeon_legacy_tv_adjust_crtc_reg(struct drm_encoder *encoder,
864 *v_sync_strt_wid = tmp; 864 *v_sync_strt_wid = tmp;
865} 865}
866 866
867static inline int get_post_div(int value) 867static int get_post_div(int value)
868{ 868{
869 int post_div; 869 int post_div;
870 switch (value) { 870 switch (value) {
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 976c3b1b1b6e..138839312e8b 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -515,3 +515,45 @@ int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
515 } 515 }
516 return 0; 516 return 0;
517} 517}
518
519int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, bool no_wait,
520 enum ttm_buffer_usage usage)
521{
522 int r;
523
524 r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
525 if (unlikely(r != 0))
526 return r;
527 spin_lock(&bo->tbo.bdev->fence_lock);
528 if (mem_type)
529 *mem_type = bo->tbo.mem.mem_type;
530 if (bo->tbo.sync_obj)
531 r = ttm_bo_wait(&bo->tbo, true, true, no_wait, usage);
532 spin_unlock(&bo->tbo.bdev->fence_lock);
533 ttm_bo_unreserve(&bo->tbo);
534 return r;
535}
536
537
538/**
539 * radeon_bo_reserve - reserve bo
540 * @bo: bo structure
541 * @no_wait: don't sleep while trying to reserve (return -EBUSY)
542 *
543 * Returns:
544 * -EBUSY: buffer is busy and @no_wait is true
545 * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
546 * a signal. Release all buffer reservations and return to user-space.
547 */
548int radeon_bo_reserve(struct radeon_bo *bo, bool no_wait)
549{
550 int r;
551
552 r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
553 if (unlikely(r != 0)) {
554 if (r != -ERESTARTSYS)
555 dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
556 return r;
557 }
558 return 0;
559}
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
index a057a8e5a6e6..c6c8e43e6d9a 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -52,28 +52,7 @@ static inline unsigned radeon_mem_type_to_domain(u32 mem_type)
52 return 0; 52 return 0;
53} 53}
54 54
55/** 55int radeon_bo_reserve(struct radeon_bo *bo, bool no_wait);
56 * radeon_bo_reserve - reserve bo
57 * @bo: bo structure
58 * @no_wait: don't sleep while trying to reserve (return -EBUSY)
59 *
60 * Returns:
61 * -EBUSY: buffer is busy and @no_wait is true
62 * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
63 * a signal. Release all buffer reservations and return to user-space.
64 */
65static inline int radeon_bo_reserve(struct radeon_bo *bo, bool no_wait)
66{
67 int r;
68
69 r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
70 if (unlikely(r != 0)) {
71 if (r != -ERESTARTSYS)
72 dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
73 return r;
74 }
75 return 0;
76}
77 56
78static inline void radeon_bo_unreserve(struct radeon_bo *bo) 57static inline void radeon_bo_unreserve(struct radeon_bo *bo)
79{ 58{
@@ -118,23 +97,8 @@ static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo)
118 return bo->tbo.addr_space_offset; 97 return bo->tbo.addr_space_offset;
119} 98}
120 99
121static inline int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, 100extern int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type,
122 bool no_wait, enum ttm_buffer_usage usage) 101 bool no_wait, enum ttm_buffer_usage usage);
123{
124 int r;
125
126 r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
127 if (unlikely(r != 0))
128 return r;
129 spin_lock(&bo->tbo.bdev->fence_lock);
130 if (mem_type)
131 *mem_type = bo->tbo.mem.mem_type;
132 if (bo->tbo.sync_obj)
133 r = ttm_bo_wait(&bo->tbo, true, true, no_wait, usage);
134 spin_unlock(&bo->tbo.bdev->fence_lock);
135 ttm_bo_unreserve(&bo->tbo);
136 return r;
137}
138 102
139extern int radeon_bo_create(struct radeon_device *rdev, 103extern int radeon_bo_create(struct radeon_device *rdev,
140 unsigned long size, int byte_align, 104 unsigned long size, int byte_align,
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 08c0233db1b8..49d58202202c 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -35,6 +35,44 @@
35 35
36int radeon_debugfs_ib_init(struct radeon_device *rdev); 36int radeon_debugfs_ib_init(struct radeon_device *rdev);
37 37
38u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
39{
40 struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
41 u32 pg_idx, pg_offset;
42 u32 idx_value = 0;
43 int new_page;
44
45 pg_idx = (idx * 4) / PAGE_SIZE;
46 pg_offset = (idx * 4) % PAGE_SIZE;
47
48 if (ibc->kpage_idx[0] == pg_idx)
49 return ibc->kpage[0][pg_offset/4];
50 if (ibc->kpage_idx[1] == pg_idx)
51 return ibc->kpage[1][pg_offset/4];
52
53 new_page = radeon_cs_update_pages(p, pg_idx);
54 if (new_page < 0) {
55 p->parser_error = new_page;
56 return 0;
57 }
58
59 idx_value = ibc->kpage[new_page][pg_offset/4];
60 return idx_value;
61}
62
63void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
64{
65#if DRM_DEBUG_CODE
66 if (rdev->cp.count_dw <= 0) {
67 DRM_ERROR("radeon: writting more dword to ring than expected !\n");
68 }
69#endif
70 rdev->cp.ring[rdev->cp.wptr++] = v;
71 rdev->cp.wptr &= rdev->cp.ptr_mask;
72 rdev->cp.count_dw--;
73 rdev->cp.ring_free_dw--;
74}
75
38void radeon_ib_bogus_cleanup(struct radeon_device *rdev) 76void radeon_ib_bogus_cleanup(struct radeon_device *rdev)
39{ 77{
40 struct radeon_ib *ib, *n; 78 struct radeon_ib *ib, *n;
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 92e7ea73b7c5..e8422ae7fe74 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -272,12 +272,12 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
272 return 0; 272 return 0;
273} 273}
274 274
275static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t * 275static int radeon_check_and_fixup_packet3(drm_radeon_private_t *
276 dev_priv, 276 dev_priv,
277 struct drm_file *file_priv, 277 struct drm_file *file_priv,
278 drm_radeon_kcmd_buffer_t * 278 drm_radeon_kcmd_buffer_t *
279 cmdbuf, 279 cmdbuf,
280 unsigned int *cmdsz) 280 unsigned int *cmdsz)
281{ 281{
282 u32 *cmd = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0); 282 u32 *cmd = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0);
283 u32 offset, narrays; 283 u32 offset, narrays;
@@ -446,8 +446,8 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
446 * CP hardware state programming functions 446 * CP hardware state programming functions
447 */ 447 */
448 448
449static __inline__ void radeon_emit_clip_rect(drm_radeon_private_t * dev_priv, 449static void radeon_emit_clip_rect(drm_radeon_private_t * dev_priv,
450 struct drm_clip_rect * box) 450 struct drm_clip_rect * box)
451{ 451{
452 RING_LOCALS; 452 RING_LOCALS;
453 453