Commit 6333003b authored by Marek Olšák's avatar Marek Olšák Committed by Dave Airlie

drm/radeon/kms: compute GPU addresses correctly on r600

Signed-off-by: default avatarMarek Olšák <maraeo@gmail.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 747e42a1
...@@ -1538,6 +1538,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1538,6 +1538,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
{ {
int pred_op; int pred_op;
int tmp; int tmp;
uint64_t offset;
if (pkt->count != 1) { if (pkt->count != 1) {
DRM_ERROR("bad SET PREDICATION\n"); DRM_ERROR("bad SET PREDICATION\n");
return -EINVAL; return -EINVAL;
...@@ -1561,8 +1563,12 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1561,8 +1563,12 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
return -EINVAL; return -EINVAL;
} }
ib[idx + 0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff); offset = reloc->lobj.gpu_offset +
ib[idx + 1] = tmp + (upper_32_bits(reloc->lobj.gpu_offset) & 0xff); (idx_value & 0xfffffff0) +
((u64)(tmp & 0xff) << 32);
ib[idx + 0] = offset;
ib[idx + 1] = (tmp & 0xffffff00) | (upper_32_bits(offset) & 0xff);
} }
break; break;
...@@ -1586,6 +1592,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1586,6 +1592,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
} }
break; break;
case PACKET3_DRAW_INDEX: case PACKET3_DRAW_INDEX:
{
uint64_t offset;
if (pkt->count != 3) { if (pkt->count != 3) {
DRM_ERROR("bad DRAW_INDEX\n"); DRM_ERROR("bad DRAW_INDEX\n");
return -EINVAL; return -EINVAL;
...@@ -1595,14 +1603,21 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1595,14 +1603,21 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
DRM_ERROR("bad DRAW_INDEX\n"); DRM_ERROR("bad DRAW_INDEX\n");
return -EINVAL; return -EINVAL;
} }
ib[idx+0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
ib[idx+1] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; offset = reloc->lobj.gpu_offset +
idx_value +
((u64)(radeon_get_ib_value(p, idx+1) & 0xff) << 32);
ib[idx+0] = offset;
ib[idx+1] = upper_32_bits(offset) & 0xff;
r = r600_cs_track_check(p); r = r600_cs_track_check(p);
if (r) { if (r) {
dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__); dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
return r; return r;
} }
break; break;
}
case PACKET3_DRAW_INDEX_AUTO: case PACKET3_DRAW_INDEX_AUTO:
if (pkt->count != 1) { if (pkt->count != 1) {
DRM_ERROR("bad DRAW_INDEX_AUTO\n"); DRM_ERROR("bad DRAW_INDEX_AUTO\n");
...@@ -1633,13 +1648,20 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1633,13 +1648,20 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
} }
/* bit 4 is reg (0) or mem (1) */ /* bit 4 is reg (0) or mem (1) */
if (idx_value & 0x10) { if (idx_value & 0x10) {
uint64_t offset;
r = r600_cs_packet_next_reloc(p, &reloc); r = r600_cs_packet_next_reloc(p, &reloc);
if (r) { if (r) {
DRM_ERROR("bad WAIT_REG_MEM\n"); DRM_ERROR("bad WAIT_REG_MEM\n");
return -EINVAL; return -EINVAL;
} }
ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff);
ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; offset = reloc->lobj.gpu_offset +
(radeon_get_ib_value(p, idx+1) & 0xfffffff0) +
((u64)(radeon_get_ib_value(p, idx+2) & 0xff) << 32);
ib[idx+1] = (ib[idx+1] & 0x3) | (offset & 0xfffffff0);
ib[idx+2] = upper_32_bits(offset) & 0xff;
} }
break; break;
case PACKET3_SURFACE_SYNC: case PACKET3_SURFACE_SYNC:
...@@ -1664,16 +1686,25 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1664,16 +1686,25 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
return -EINVAL; return -EINVAL;
} }
if (pkt->count) { if (pkt->count) {
uint64_t offset;
r = r600_cs_packet_next_reloc(p, &reloc); r = r600_cs_packet_next_reloc(p, &reloc);
if (r) { if (r) {
DRM_ERROR("bad EVENT_WRITE\n"); DRM_ERROR("bad EVENT_WRITE\n");
return -EINVAL; return -EINVAL;
} }
ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff); offset = reloc->lobj.gpu_offset +
ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; (radeon_get_ib_value(p, idx+1) & 0xfffffff8) +
((u64)(radeon_get_ib_value(p, idx+2) & 0xff) << 32);
ib[idx+1] = offset & 0xfffffff8;
ib[idx+2] = upper_32_bits(offset) & 0xff;
} }
break; break;
case PACKET3_EVENT_WRITE_EOP: case PACKET3_EVENT_WRITE_EOP:
{
uint64_t offset;
if (pkt->count != 4) { if (pkt->count != 4) {
DRM_ERROR("bad EVENT_WRITE_EOP\n"); DRM_ERROR("bad EVENT_WRITE_EOP\n");
return -EINVAL; return -EINVAL;
...@@ -1683,9 +1714,15 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1683,9 +1714,15 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
DRM_ERROR("bad EVENT_WRITE\n"); DRM_ERROR("bad EVENT_WRITE\n");
return -EINVAL; return -EINVAL;
} }
ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff);
ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; offset = reloc->lobj.gpu_offset +
(radeon_get_ib_value(p, idx+1) & 0xfffffffc) +
((u64)(radeon_get_ib_value(p, idx+2) & 0xff) << 32);
ib[idx+1] = offset & 0xfffffffc;
ib[idx+2] = (ib[idx+2] & 0xffffff00) | (upper_32_bits(offset) & 0xff);
break; break;
}
case PACKET3_SET_CONFIG_REG: case PACKET3_SET_CONFIG_REG:
start_reg = (idx_value << 2) + PACKET3_SET_CONFIG_REG_OFFSET; start_reg = (idx_value << 2) + PACKET3_SET_CONFIG_REG_OFFSET;
end_reg = 4 * pkt->count + start_reg - 4; end_reg = 4 * pkt->count + start_reg - 4;
...@@ -1770,6 +1807,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1770,6 +1807,8 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
ib[idx+1+(i*7)+3] += mip_offset; ib[idx+1+(i*7)+3] += mip_offset;
break; break;
case SQ_TEX_VTX_VALID_BUFFER: case SQ_TEX_VTX_VALID_BUFFER:
{
uint64_t offset64;
/* vtx base */ /* vtx base */
r = r600_cs_packet_next_reloc(p, &reloc); r = r600_cs_packet_next_reloc(p, &reloc);
if (r) { if (r) {
...@@ -1782,11 +1821,15 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1782,11 +1821,15 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
/* force size to size of the buffer */ /* force size to size of the buffer */
dev_warn(p->dev, "vbo resource seems too big (%d) for the bo (%ld)\n", dev_warn(p->dev, "vbo resource seems too big (%d) for the bo (%ld)\n",
size + offset, radeon_bo_size(reloc->robj)); size + offset, radeon_bo_size(reloc->robj));
ib[idx+1+(i*7)+1] = radeon_bo_size(reloc->robj); ib[idx+1+(i*7)+1] = radeon_bo_size(reloc->robj) - offset;
} }
ib[idx+1+(i*7)+0] += (u32)((reloc->lobj.gpu_offset) & 0xffffffff);
ib[idx+1+(i*7)+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; offset64 = reloc->lobj.gpu_offset + offset;
ib[idx+1+(i*8)+0] = offset64;
ib[idx+1+(i*8)+2] = (ib[idx+1+(i*8)+2] & 0xffffff00) |
(upper_32_bits(offset64) & 0xff);
break; break;
}
case SQ_TEX_VTX_INVALID_TEXTURE: case SQ_TEX_VTX_INVALID_TEXTURE:
case SQ_TEX_VTX_INVALID_BUFFER: case SQ_TEX_VTX_INVALID_BUFFER:
default: default:
...@@ -1881,8 +1924,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1881,8 +1924,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
offset + 4, radeon_bo_size(reloc->robj)); offset + 4, radeon_bo_size(reloc->robj));
return -EINVAL; return -EINVAL;
} }
ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff); offset += reloc->lobj.gpu_offset;
ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; ib[idx+1] = offset;
ib[idx+2] = upper_32_bits(offset) & 0xff;
} }
/* Reading data from SRC_ADDRESS. */ /* Reading data from SRC_ADDRESS. */
if (((idx_value >> 1) & 0x3) == 2) { if (((idx_value >> 1) & 0x3) == 2) {
...@@ -1899,8 +1943,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1899,8 +1943,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
offset + 4, radeon_bo_size(reloc->robj)); offset + 4, radeon_bo_size(reloc->robj));
return -EINVAL; return -EINVAL;
} }
ib[idx+3] += (u32)(reloc->lobj.gpu_offset & 0xffffffff); offset += reloc->lobj.gpu_offset;
ib[idx+4] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; ib[idx+3] = offset;
ib[idx+4] = upper_32_bits(offset) & 0xff;
} }
break; break;
case PACKET3_COPY_DW: case PACKET3_COPY_DW:
...@@ -1923,8 +1968,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1923,8 +1968,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
offset + 4, radeon_bo_size(reloc->robj)); offset + 4, radeon_bo_size(reloc->robj));
return -EINVAL; return -EINVAL;
} }
ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff); offset += reloc->lobj.gpu_offset;
ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; ib[idx+1] = offset;
ib[idx+2] = upper_32_bits(offset) & 0xff;
} else { } else {
/* SRC is a reg. */ /* SRC is a reg. */
reg = radeon_get_ib_value(p, idx+1) << 2; reg = radeon_get_ib_value(p, idx+1) << 2;
...@@ -1946,8 +1992,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p, ...@@ -1946,8 +1992,9 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
offset + 4, radeon_bo_size(reloc->robj)); offset + 4, radeon_bo_size(reloc->robj));
return -EINVAL; return -EINVAL;
} }
ib[idx+3] += (u32)(reloc->lobj.gpu_offset & 0xffffffff); offset += reloc->lobj.gpu_offset;
ib[idx+4] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff; ib[idx+3] = offset;
ib[idx+4] = upper_32_bits(offset) & 0xff;
} else { } else {
/* DST is a reg. */ /* DST is a reg. */
reg = radeon_get_ib_value(p, idx+3) << 2; reg = radeon_get_ib_value(p, idx+3) << 2;
......
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