Commit f2e39221 authored by Jerome Glisse's avatar Jerome Glisse Committed by Dave Airlie

drm/radeon: make the ib an inline object

No need to malloc it any more.
Signed-off-by: default avatarJerome Glisse <jglisse@redhat.com>
Signed-off-by: default avatarChristian König <deathsimple@vodafone.de>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent f237750f
...@@ -1057,7 +1057,7 @@ static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p) ...@@ -1057,7 +1057,7 @@ static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p)
uint32_t header, h_idx, reg, wait_reg_mem_info; uint32_t header, h_idx, reg, wait_reg_mem_info;
volatile uint32_t *ib; volatile uint32_t *ib;
ib = p->ib->ptr; ib = p->ib.ptr;
/* parse the WAIT_REG_MEM */ /* parse the WAIT_REG_MEM */
r = evergreen_cs_packet_parse(p, &wait_reg_mem, p->idx); r = evergreen_cs_packet_parse(p, &wait_reg_mem, p->idx);
...@@ -1215,7 +1215,7 @@ static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) ...@@ -1215,7 +1215,7 @@ static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
if (!(evergreen_reg_safe_bm[i] & m)) if (!(evergreen_reg_safe_bm[i] & m))
return 0; return 0;
} }
ib = p->ib->ptr; ib = p->ib.ptr;
switch (reg) { switch (reg) {
/* force following reg to 0 in an attempt to disable out buffer /* force following reg to 0 in an attempt to disable out buffer
* which will need us to better understand how it works to perform * which will need us to better understand how it works to perform
...@@ -1896,7 +1896,7 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, ...@@ -1896,7 +1896,7 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p,
u32 idx_value; u32 idx_value;
track = (struct evergreen_cs_track *)p->track; track = (struct evergreen_cs_track *)p->track;
ib = p->ib->ptr; ib = p->ib.ptr;
idx = pkt->idx + 1; idx = pkt->idx + 1;
idx_value = radeon_get_ib_value(p, idx); idx_value = radeon_get_ib_value(p, idx);
...@@ -2610,8 +2610,8 @@ int evergreen_cs_parse(struct radeon_cs_parser *p) ...@@ -2610,8 +2610,8 @@ int evergreen_cs_parse(struct radeon_cs_parser *p)
} }
} while (p->idx < p->chunks[p->chunk_ib_idx].length_dw); } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
#if 0 #if 0
for (r = 0; r < p->ib->length_dw; r++) { for (r = 0; r < p->ib.length_dw; r++) {
printk(KERN_INFO "%05d 0x%08X\n", r, p->ib->ptr[r]); printk(KERN_INFO "%05d 0x%08X\n", r, p->ib.ptr[r]);
mdelay(1); mdelay(1);
} }
#endif #endif
......
...@@ -139,9 +139,9 @@ int r100_reloc_pitch_offset(struct radeon_cs_parser *p, ...@@ -139,9 +139,9 @@ int r100_reloc_pitch_offset(struct radeon_cs_parser *p,
} }
tmp |= tile_flags; tmp |= tile_flags;
p->ib->ptr[idx] = (value & 0x3fc00000) | tmp; p->ib.ptr[idx] = (value & 0x3fc00000) | tmp;
} else } else
p->ib->ptr[idx] = (value & 0xffc00000) | tmp; p->ib.ptr[idx] = (value & 0xffc00000) | tmp;
return 0; return 0;
} }
...@@ -156,7 +156,7 @@ int r100_packet3_load_vbpntr(struct radeon_cs_parser *p, ...@@ -156,7 +156,7 @@ int r100_packet3_load_vbpntr(struct radeon_cs_parser *p,
volatile uint32_t *ib; volatile uint32_t *ib;
u32 idx_value; u32 idx_value;
ib = p->ib->ptr; ib = p->ib.ptr;
track = (struct r100_cs_track *)p->track; track = (struct r100_cs_track *)p->track;
c = radeon_get_ib_value(p, idx++) & 0x1F; c = radeon_get_ib_value(p, idx++) & 0x1F;
if (c > 16) { if (c > 16) {
...@@ -1275,7 +1275,7 @@ void r100_cs_dump_packet(struct radeon_cs_parser *p, ...@@ -1275,7 +1275,7 @@ void r100_cs_dump_packet(struct radeon_cs_parser *p,
unsigned i; unsigned i;
unsigned idx; unsigned idx;
ib = p->ib->ptr; ib = p->ib.ptr;
idx = pkt->idx; idx = pkt->idx;
for (i = 0; i <= (pkt->count + 1); i++, idx++) { for (i = 0; i <= (pkt->count + 1); i++, idx++) {
DRM_INFO("ib[%d]=0x%08X\n", idx, ib[idx]); DRM_INFO("ib[%d]=0x%08X\n", idx, ib[idx]);
...@@ -1354,7 +1354,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p) ...@@ -1354,7 +1354,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
uint32_t header, h_idx, reg; uint32_t header, h_idx, reg;
volatile uint32_t *ib; volatile uint32_t *ib;
ib = p->ib->ptr; ib = p->ib.ptr;
/* parse the wait until */ /* parse the wait until */
r = r100_cs_packet_parse(p, &waitreloc, p->idx); r = r100_cs_packet_parse(p, &waitreloc, p->idx);
...@@ -1533,7 +1533,7 @@ static int r100_packet0_check(struct radeon_cs_parser *p, ...@@ -1533,7 +1533,7 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
u32 tile_flags = 0; u32 tile_flags = 0;
u32 idx_value; u32 idx_value;
ib = p->ib->ptr; ib = p->ib.ptr;
track = (struct r100_cs_track *)p->track; track = (struct r100_cs_track *)p->track;
idx_value = radeon_get_ib_value(p, idx); idx_value = radeon_get_ib_value(p, idx);
...@@ -1889,7 +1889,7 @@ static int r100_packet3_check(struct radeon_cs_parser *p, ...@@ -1889,7 +1889,7 @@ static int r100_packet3_check(struct radeon_cs_parser *p,
volatile uint32_t *ib; volatile uint32_t *ib;
int r; int r;
ib = p->ib->ptr; ib = p->ib.ptr;
idx = pkt->idx + 1; idx = pkt->idx + 1;
track = (struct r100_cs_track *)p->track; track = (struct r100_cs_track *)p->track;
switch (pkt->opcode) { switch (pkt->opcode) {
...@@ -3684,7 +3684,7 @@ void r100_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) ...@@ -3684,7 +3684,7 @@ void r100_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
{ {
struct radeon_ib *ib; struct radeon_ib ib;
uint32_t scratch; uint32_t scratch;
uint32_t tmp = 0; uint32_t tmp = 0;
unsigned i; unsigned i;
...@@ -3700,22 +3700,22 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ...@@ -3700,22 +3700,22 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
if (r) { if (r) {
return r; return r;
} }
ib->ptr[0] = PACKET0(scratch, 0); ib.ptr[0] = PACKET0(scratch, 0);
ib->ptr[1] = 0xDEADBEEF; ib.ptr[1] = 0xDEADBEEF;
ib->ptr[2] = PACKET2(0); ib.ptr[2] = PACKET2(0);
ib->ptr[3] = PACKET2(0); ib.ptr[3] = PACKET2(0);
ib->ptr[4] = PACKET2(0); ib.ptr[4] = PACKET2(0);
ib->ptr[5] = PACKET2(0); ib.ptr[5] = PACKET2(0);
ib->ptr[6] = PACKET2(0); ib.ptr[6] = PACKET2(0);
ib->ptr[7] = PACKET2(0); ib.ptr[7] = PACKET2(0);
ib->length_dw = 8; ib.length_dw = 8;
r = radeon_ib_schedule(rdev, ib); r = radeon_ib_schedule(rdev, &ib);
if (r) { if (r) {
radeon_scratch_free(rdev, scratch); radeon_scratch_free(rdev, scratch);
radeon_ib_free(rdev, &ib); radeon_ib_free(rdev, &ib);
return r; return r;
} }
r = radeon_fence_wait(ib->fence, false); r = radeon_fence_wait(ib.fence, false);
if (r) { if (r) {
return r; return r;
} }
......
...@@ -154,7 +154,7 @@ int r200_packet0_check(struct radeon_cs_parser *p, ...@@ -154,7 +154,7 @@ int r200_packet0_check(struct radeon_cs_parser *p,
u32 tile_flags = 0; u32 tile_flags = 0;
u32 idx_value; u32 idx_value;
ib = p->ib->ptr; ib = p->ib.ptr;
track = (struct r100_cs_track *)p->track; track = (struct r100_cs_track *)p->track;
idx_value = radeon_get_ib_value(p, idx); idx_value = radeon_get_ib_value(p, idx);
switch (reg) { switch (reg) {
......
...@@ -604,7 +604,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p, ...@@ -604,7 +604,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
int r; int r;
u32 idx_value; u32 idx_value;
ib = p->ib->ptr; ib = p->ib.ptr;
track = (struct r100_cs_track *)p->track; track = (struct r100_cs_track *)p->track;
idx_value = radeon_get_ib_value(p, idx); idx_value = radeon_get_ib_value(p, idx);
...@@ -1146,7 +1146,7 @@ static int r300_packet3_check(struct radeon_cs_parser *p, ...@@ -1146,7 +1146,7 @@ static int r300_packet3_check(struct radeon_cs_parser *p,
unsigned idx; unsigned idx;
int r; int r;
ib = p->ib->ptr; ib = p->ib.ptr;
idx = pkt->idx + 1; idx = pkt->idx + 1;
track = (struct r100_cs_track *)p->track; track = (struct r100_cs_track *)p->track;
switch(pkt->opcode) { switch(pkt->opcode) {
......
...@@ -2681,7 +2681,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) ...@@ -2681,7 +2681,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
{ {
struct radeon_ib *ib; struct radeon_ib ib;
uint32_t scratch; uint32_t scratch;
uint32_t tmp = 0; uint32_t tmp = 0;
unsigned i; unsigned i;
...@@ -2699,18 +2699,18 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ...@@ -2699,18 +2699,18 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
DRM_ERROR("radeon: failed to get ib (%d).\n", r); DRM_ERROR("radeon: failed to get ib (%d).\n", r);
return r; return r;
} }
ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1); ib.ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); ib.ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
ib->ptr[2] = 0xDEADBEEF; ib.ptr[2] = 0xDEADBEEF;
ib->length_dw = 3; ib.length_dw = 3;
r = radeon_ib_schedule(rdev, ib); r = radeon_ib_schedule(rdev, &ib);
if (r) { if (r) {
radeon_scratch_free(rdev, scratch); radeon_scratch_free(rdev, scratch);
radeon_ib_free(rdev, &ib); radeon_ib_free(rdev, &ib);
DRM_ERROR("radeon: failed to schedule ib (%d).\n", r); DRM_ERROR("radeon: failed to schedule ib (%d).\n", r);
return r; return r;
} }
r = radeon_fence_wait(ib->fence, false); r = radeon_fence_wait(ib.fence, false);
if (r) { if (r) {
DRM_ERROR("radeon: fence wait failed (%d).\n", r); DRM_ERROR("radeon: fence wait failed (%d).\n", r);
return r; return r;
...@@ -2722,7 +2722,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ...@@ -2722,7 +2722,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
DRM_UDELAY(1); DRM_UDELAY(1);
} }
if (i < rdev->usec_timeout) { if (i < rdev->usec_timeout) {
DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib->fence->ring, i); DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib.fence->ring, i);
} else { } else {
DRM_ERROR("radeon: ib test failed (scratch(0x%04X)=0x%08X)\n", DRM_ERROR("radeon: ib test failed (scratch(0x%04X)=0x%08X)\n",
scratch, tmp); scratch, tmp);
......
...@@ -345,7 +345,7 @@ static int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i) ...@@ -345,7 +345,7 @@ static int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
u32 height, height_align, pitch, pitch_align, depth_align; u32 height, height_align, pitch, pitch_align, depth_align;
u64 base_offset, base_align; u64 base_offset, base_align;
struct array_mode_checker array_check; struct array_mode_checker array_check;
volatile u32 *ib = p->ib->ptr; volatile u32 *ib = p->ib.ptr;
unsigned array_mode; unsigned array_mode;
u32 format; u32 format;
...@@ -471,7 +471,7 @@ static int r600_cs_track_validate_db(struct radeon_cs_parser *p) ...@@ -471,7 +471,7 @@ static int r600_cs_track_validate_db(struct radeon_cs_parser *p)
u64 base_offset, base_align; u64 base_offset, base_align;
struct array_mode_checker array_check; struct array_mode_checker array_check;
int array_mode; int array_mode;
volatile u32 *ib = p->ib->ptr; volatile u32 *ib = p->ib.ptr;
if (track->db_bo == NULL) { if (track->db_bo == NULL) {
...@@ -961,7 +961,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) ...@@ -961,7 +961,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p)
uint32_t header, h_idx, reg, wait_reg_mem_info; uint32_t header, h_idx, reg, wait_reg_mem_info;
volatile uint32_t *ib; volatile uint32_t *ib;
ib = p->ib->ptr; ib = p->ib.ptr;
/* parse the WAIT_REG_MEM */ /* parse the WAIT_REG_MEM */
r = r600_cs_packet_parse(p, &wait_reg_mem, p->idx); r = r600_cs_packet_parse(p, &wait_reg_mem, p->idx);
...@@ -1110,7 +1110,7 @@ static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) ...@@ -1110,7 +1110,7 @@ static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
m = 1 << ((reg >> 2) & 31); m = 1 << ((reg >> 2) & 31);
if (!(r600_reg_safe_bm[i] & m)) if (!(r600_reg_safe_bm[i] & m))
return 0; return 0;
ib = p->ib->ptr; ib = p->ib.ptr;
switch (reg) { switch (reg) {
/* force following reg to 0 in an attempt to disable out buffer /* force following reg to 0 in an attempt to disable out buffer
* which will need us to better understand how it works to perform * which will need us to better understand how it works to perform
...@@ -1714,7 +1714,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1714,7 +1714,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
u32 idx_value; u32 idx_value;
track = (struct r600_cs_track *)p->track; track = (struct r600_cs_track *)p->track;
ib = p->ib->ptr; ib = p->ib.ptr;
idx = pkt->idx + 1; idx = pkt->idx + 1;
idx_value = radeon_get_ib_value(p, idx); idx_value = radeon_get_ib_value(p, idx);
...@@ -2249,8 +2249,8 @@ int r600_cs_parse(struct radeon_cs_parser *p) ...@@ -2249,8 +2249,8 @@ int r600_cs_parse(struct radeon_cs_parser *p)
} }
} while (p->idx < p->chunks[p->chunk_ib_idx].length_dw); } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
#if 0 #if 0
for (r = 0; r < p->ib->length_dw; r++) { for (r = 0; r < p->ib.length_dw; r++) {
printk(KERN_INFO "%05d 0x%08X\n", r, p->ib->ptr[r]); printk(KERN_INFO "%05d 0x%08X\n", r, p->ib.ptr[r]);
mdelay(1); mdelay(1);
} }
#endif #endif
...@@ -2298,7 +2298,6 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp, ...@@ -2298,7 +2298,6 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
{ {
struct radeon_cs_parser parser; struct radeon_cs_parser parser;
struct radeon_cs_chunk *ib_chunk; struct radeon_cs_chunk *ib_chunk;
struct radeon_ib fake_ib;
struct r600_cs_track *track; struct r600_cs_track *track;
int r; int r;
...@@ -2314,9 +2313,8 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp, ...@@ -2314,9 +2313,8 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
parser.dev = &dev->pdev->dev; parser.dev = &dev->pdev->dev;
parser.rdev = NULL; parser.rdev = NULL;
parser.family = family; parser.family = family;
parser.ib = &fake_ib;
parser.track = track; parser.track = track;
fake_ib.ptr = ib; parser.ib.ptr = ib;
r = radeon_cs_parser_init(&parser, data); r = radeon_cs_parser_init(&parser, data);
if (r) { if (r) {
DRM_ERROR("Failed to initialize parser !\n"); DRM_ERROR("Failed to initialize parser !\n");
...@@ -2333,8 +2331,8 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp, ...@@ -2333,8 +2331,8 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
* input memory (cached) and write to the IB (which can be * input memory (cached) and write to the IB (which can be
* uncached). */ * uncached). */
ib_chunk = &parser.chunks[parser.chunk_ib_idx]; ib_chunk = &parser.chunks[parser.chunk_ib_idx];
parser.ib->length_dw = ib_chunk->length_dw; parser.ib.length_dw = ib_chunk->length_dw;
*l = parser.ib->length_dw; *l = parser.ib.length_dw;
r = r600_cs_parse(&parser); r = r600_cs_parse(&parser);
if (r) { if (r) {
DRM_ERROR("Invalid command stream !\n"); DRM_ERROR("Invalid command stream !\n");
......
...@@ -769,8 +769,8 @@ struct si_rlc { ...@@ -769,8 +769,8 @@ struct si_rlc {
}; };
int radeon_ib_get(struct radeon_device *rdev, int ring, int radeon_ib_get(struct radeon_device *rdev, int ring,
struct radeon_ib **ib, unsigned size); struct radeon_ib *ib, unsigned size);
void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib);
int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
int radeon_ib_pool_init(struct radeon_device *rdev); int radeon_ib_pool_init(struct radeon_device *rdev);
void radeon_ib_pool_fini(struct radeon_device *rdev); void radeon_ib_pool_fini(struct radeon_device *rdev);
...@@ -838,8 +838,8 @@ struct radeon_cs_parser { ...@@ -838,8 +838,8 @@ struct radeon_cs_parser {
int chunk_relocs_idx; int chunk_relocs_idx;
int chunk_flags_idx; int chunk_flags_idx;
int chunk_const_ib_idx; int chunk_const_ib_idx;
struct radeon_ib *ib; struct radeon_ib ib;
struct radeon_ib *const_ib; struct radeon_ib const_ib;
void *track; void *track;
unsigned family; unsigned family;
int parser_error; int parser_error;
......
...@@ -138,12 +138,12 @@ static int radeon_cs_sync_rings(struct radeon_cs_parser *p) ...@@ -138,12 +138,12 @@ static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
return 0; return 0;
} }
r = radeon_semaphore_create(p->rdev, &p->ib->semaphore); r = radeon_semaphore_create(p->rdev, &p->ib.semaphore);
if (r) { if (r) {
return r; return r;
} }
return radeon_semaphore_sync_rings(p->rdev, p->ib->semaphore, return radeon_semaphore_sync_rings(p->rdev, p->ib.semaphore,
sync_to_ring, p->ring); sync_to_ring, p->ring);
} }
...@@ -161,8 +161,10 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) ...@@ -161,8 +161,10 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
/* get chunks */ /* get chunks */
INIT_LIST_HEAD(&p->validated); INIT_LIST_HEAD(&p->validated);
p->idx = 0; p->idx = 0;
p->ib = NULL; p->ib.sa_bo = NULL;
p->const_ib = NULL; p->ib.semaphore = NULL;
p->const_ib.sa_bo = NULL;
p->const_ib.semaphore = NULL;
p->chunk_ib_idx = -1; p->chunk_ib_idx = -1;
p->chunk_relocs_idx = -1; p->chunk_relocs_idx = -1;
p->chunk_flags_idx = -1; p->chunk_flags_idx = -1;
...@@ -301,10 +303,9 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error) ...@@ -301,10 +303,9 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error)
{ {
unsigned i; unsigned i;
if (!error)
if (!error && parser->ib)
ttm_eu_fence_buffer_objects(&parser->validated, ttm_eu_fence_buffer_objects(&parser->validated,
parser->ib->fence); parser->ib.fence);
else else
ttm_eu_backoff_reservation(&parser->validated); ttm_eu_backoff_reservation(&parser->validated);
...@@ -327,9 +328,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error) ...@@ -327,9 +328,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error)
kfree(parser->chunks); kfree(parser->chunks);
kfree(parser->chunks_array); kfree(parser->chunks_array);
radeon_ib_free(parser->rdev, &parser->ib); radeon_ib_free(parser->rdev, &parser->ib);
if (parser->const_ib) {
radeon_ib_free(parser->rdev, &parser->const_ib); radeon_ib_free(parser->rdev, &parser->const_ib);
}
} }
static int radeon_cs_ib_chunk(struct radeon_device *rdev, static int radeon_cs_ib_chunk(struct radeon_device *rdev,
...@@ -355,7 +354,7 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev, ...@@ -355,7 +354,7 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev,
DRM_ERROR("Failed to get ib !\n"); DRM_ERROR("Failed to get ib !\n");
return r; return r;
} }
parser->ib->length_dw = ib_chunk->length_dw; parser->ib.length_dw = ib_chunk->length_dw;
r = radeon_cs_parse(rdev, parser->ring, parser); r = radeon_cs_parse(rdev, parser->ring, parser);
if (r || parser->parser_error) { if (r || parser->parser_error) {
DRM_ERROR("Invalid command stream !\n"); DRM_ERROR("Invalid command stream !\n");
...@@ -370,8 +369,8 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev, ...@@ -370,8 +369,8 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev,
if (r) { if (r) {
DRM_ERROR("Failed to synchronize rings !\n"); DRM_ERROR("Failed to synchronize rings !\n");
} }
parser->ib->vm_id = 0; parser->ib.vm_id = 0;
r = radeon_ib_schedule(rdev, parser->ib); r = radeon_ib_schedule(rdev, &parser->ib);
if (r) { if (r) {
DRM_ERROR("Failed to schedule IB !\n"); DRM_ERROR("Failed to schedule IB !\n");
} }
...@@ -422,14 +421,14 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, ...@@ -422,14 +421,14 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
DRM_ERROR("Failed to get const ib !\n"); DRM_ERROR("Failed to get const ib !\n");
return r; return r;
} }
parser->const_ib->is_const_ib = true; parser->const_ib.is_const_ib = true;
parser->const_ib->length_dw = ib_chunk->length_dw; parser->const_ib.length_dw = ib_chunk->length_dw;
/* Copy the packet into the IB */ /* Copy the packet into the IB */
if (DRM_COPY_FROM_USER(parser->const_ib->ptr, ib_chunk->user_ptr, if (DRM_COPY_FROM_USER(parser->const_ib.ptr, ib_chunk->user_ptr,
ib_chunk->length_dw * 4)) { ib_chunk->length_dw * 4)) {
return -EFAULT; return -EFAULT;
} }
r = radeon_ring_ib_parse(rdev, parser->ring, parser->const_ib); r = radeon_ring_ib_parse(rdev, parser->ring, &parser->const_ib);
if (r) { if (r) {
return r; return r;
} }
...@@ -446,13 +445,13 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, ...@@ -446,13 +445,13 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
DRM_ERROR("Failed to get ib !\n"); DRM_ERROR("Failed to get ib !\n");
return r; return r;
} }
parser->ib->length_dw = ib_chunk->length_dw; parser->ib.length_dw = ib_chunk->length_dw;
/* Copy the packet into the IB */ /* Copy the packet into the IB */
if (DRM_COPY_FROM_USER(parser->ib->ptr, ib_chunk->user_ptr, if (DRM_COPY_FROM_USER(parser->ib.ptr, ib_chunk->user_ptr,
ib_chunk->length_dw * 4)) { ib_chunk->length_dw * 4)) {
return -EFAULT; return -EFAULT;
} }
r = radeon_ring_ib_parse(rdev, parser->ring, parser->ib); r = radeon_ring_ib_parse(rdev, parser->ring, &parser->ib);
if (r) { if (r) {
return r; return r;
} }
...@@ -473,29 +472,29 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, ...@@ -473,29 +472,29 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
if ((rdev->family >= CHIP_TAHITI) && if ((rdev->family >= CHIP_TAHITI) &&
(parser->chunk_const_ib_idx != -1)) { (parser->chunk_const_ib_idx != -1)) {
parser->const_ib->vm_id = vm->id; parser->const_ib.vm_id = vm->id;
/* ib pool is bind at 0 in virtual address space to gpu_addr is the /* ib pool is bind at 0 in virtual address space to gpu_addr is the
* offset inside the pool bo * offset inside the pool bo
*/ */
parser->const_ib->gpu_addr = parser->const_ib->sa_bo->soffset; parser->const_ib.gpu_addr = parser->const_ib.sa_bo->soffset;
r = radeon_ib_schedule(rdev, parser->const_ib); r = radeon_ib_schedule(rdev, &parser->const_ib);
if (r) if (r)
goto out; goto out;
} }
parser->ib->vm_id = vm->id; parser->ib.vm_id = vm->id;
/* ib pool is bind at 0 in virtual address space to gpu_addr is the /* ib pool is bind at 0 in virtual address space to gpu_addr is the
* offset inside the pool bo * offset inside the pool bo
*/ */
parser->ib->gpu_addr = parser->ib->sa_bo->soffset; parser->ib.gpu_addr = parser->ib.sa_bo->soffset;
parser->ib->is_const_ib = false; parser->ib.is_const_ib = false;
r = radeon_ib_schedule(rdev, parser->ib); r = radeon_ib_schedule(rdev, &parser->ib);
out: out:
if (!r) { if (!r) {
if (vm->fence) { if (vm->fence) {
radeon_fence_unref(&vm->fence); radeon_fence_unref(&vm->fence);
} }
vm->fence = radeon_fence_ref(parser->ib->fence); vm->fence = radeon_fence_ref(parser->ib.fence);
} }
mutex_unlock(&fpriv->vm.mutex); mutex_unlock(&fpriv->vm.mutex);
return r; return r;
...@@ -573,7 +572,7 @@ int radeon_cs_finish_pages(struct radeon_cs_parser *p) ...@@ -573,7 +572,7 @@ int radeon_cs_finish_pages(struct radeon_cs_parser *p)
size = PAGE_SIZE; size = PAGE_SIZE;
} }
if (DRM_COPY_FROM_USER(p->ib->ptr + (i * (PAGE_SIZE/4)), if (DRM_COPY_FROM_USER(p->ib.ptr + (i * (PAGE_SIZE/4)),
ibc->user_ptr + (i * PAGE_SIZE), ibc->user_ptr + (i * PAGE_SIZE),
size)) size))
return -EFAULT; return -EFAULT;
...@@ -590,7 +589,7 @@ int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx) ...@@ -590,7 +589,7 @@ int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx)
bool copy1 = (p->rdev->flags & RADEON_IS_AGP) ? false : true; bool copy1 = (p->rdev->flags & RADEON_IS_AGP) ? false : true;
for (i = ibc->last_copied_page + 1; i < pg_idx; i++) { for (i = ibc->last_copied_page + 1; i < pg_idx; i++) {
if (DRM_COPY_FROM_USER(p->ib->ptr + (i * (PAGE_SIZE/4)), if (DRM_COPY_FROM_USER(p->ib.ptr + (i * (PAGE_SIZE/4)),
ibc->user_ptr + (i * PAGE_SIZE), ibc->user_ptr + (i * PAGE_SIZE),
PAGE_SIZE)) { PAGE_SIZE)) {
p->parser_error = -EFAULT; p->parser_error = -EFAULT;
...@@ -606,7 +605,7 @@ int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx) ...@@ -606,7 +605,7 @@ int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx)
new_page = ibc->kpage_idx[0] < ibc->kpage_idx[1] ? 0 : 1; new_page = ibc->kpage_idx[0] < ibc->kpage_idx[1] ? 0 : 1;
if (copy1) if (copy1)
ibc->kpage[new_page] = p->ib->ptr + (pg_idx * (PAGE_SIZE / 4)); ibc->kpage[new_page] = p->ib.ptr + (pg_idx * (PAGE_SIZE / 4));
if (DRM_COPY_FROM_USER(ibc->kpage[new_page], if (DRM_COPY_FROM_USER(ibc->kpage[new_page],
ibc->user_ptr + (pg_idx * PAGE_SIZE), ibc->user_ptr + (pg_idx * PAGE_SIZE),
...@@ -617,7 +616,7 @@ int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx) ...@@ -617,7 +616,7 @@ int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx)
/* copy to IB for non single case */ /* copy to IB for non single case */
if (!copy1) if (!copy1)
memcpy((void *)(p->ib->ptr+(pg_idx*(PAGE_SIZE/4))), ibc->kpage[new_page], size); memcpy((void *)(p->ib.ptr+(pg_idx*(PAGE_SIZE/4))), ibc->kpage[new_page], size);
ibc->last_copied_page = pg_idx; ibc->last_copied_page = pg_idx;
ibc->kpage_idx[new_page] = pg_idx; ibc->kpage_idx[new_page] = pg_idx;
......
...@@ -65,51 +65,36 @@ u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx) ...@@ -65,51 +65,36 @@ u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
} }
int radeon_ib_get(struct radeon_device *rdev, int ring, int radeon_ib_get(struct radeon_device *rdev, int ring,
struct radeon_ib **ib, unsigned size) struct radeon_ib *ib, unsigned size)
{ {
int r; int r;
*ib = kmalloc(sizeof(struct radeon_ib), GFP_KERNEL); r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo, &ib->sa_bo, size, 256, true);
if (*ib == NULL) {
return -ENOMEM;
}
r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo, &(*ib)->sa_bo, size, 256, true);
if (r) { if (r) {
dev_err(rdev->dev, "failed to get a new IB (%d)\n", r); dev_err(rdev->dev, "failed to get a new IB (%d)\n", r);
kfree(*ib);
*ib = NULL;
return r; return r;
} }
r = radeon_fence_create(rdev, &(*ib)->fence, ring); r = radeon_fence_create(rdev, &ib->fence, ring);
if (r) { if (r) {
dev_err(rdev->dev, "failed to create fence for new IB (%d)\n", r); dev_err(rdev->dev, "failed to create fence for new IB (%d)\n", r);
radeon_sa_bo_free(rdev, &(*ib)->sa_bo, NULL); radeon_sa_bo_free(rdev, &ib->sa_bo, NULL);
kfree(*ib);
*ib = NULL;
return r; return r;
} }
(*ib)->ptr = radeon_sa_bo_cpu_addr((*ib)->sa_bo); ib->ptr = radeon_sa_bo_cpu_addr(ib->sa_bo);
(*ib)->gpu_addr = radeon_sa_bo_gpu_addr((*ib)->sa_bo); ib->gpu_addr = radeon_sa_bo_gpu_addr(ib->sa_bo);
(*ib)->vm_id = 0; ib->vm_id = 0;
(*ib)->is_const_ib = false; ib->is_const_ib = false;
(*ib)->semaphore = NULL; ib->semaphore = NULL;
return 0; return 0;
} }
void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib) void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib)
{ {
struct radeon_ib *tmp = *ib; radeon_semaphore_free(rdev, ib->semaphore, ib->fence);
radeon_sa_bo_free(rdev, &ib->sa_bo, ib->fence);
*ib = NULL; radeon_fence_unref(&ib->fence);
if (tmp == NULL) {
return;
}
radeon_semaphore_free(rdev, tmp->semaphore, tmp->fence);
radeon_sa_bo_free(rdev, &tmp->sa_bo, tmp->fence);
radeon_fence_unref(&tmp->fence);
kfree(tmp);
} }
int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib) int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment