]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/radeon: use common cs packet parse function
authorIlija Hadzic <ihadzic@research.bell-labs.com>
Wed, 2 Jan 2013 23:27:41 +0000 (18:27 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 31 Jan 2013 21:24:42 +0000 (16:24 -0500)
We now have a common radeon_cs_packet_parse function
that is good for all ASICs. Hook it up and eliminate
ASIC-specific versions.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/evergreen_cs.c
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/r300.c
drivers/gpu/drm/radeon/r600_cs.c
drivers/gpu/drm/radeon/radeon.h

index 7a445666e71f1221ca92cd07bcdea61b29867ded..1ba4ca38f4f9fd06e5d30311eea4a4b15cf33edd 100644 (file)
@@ -1008,53 +1008,6 @@ static int evergreen_cs_track_check(struct radeon_cs_parser *p)
        return 0;
 }
 
-/**
- * evergreen_cs_packet_parse() - parse cp packet and point ib index to next packet
- * @parser:    parser structure holding parsing context.
- * @pkt:       where to store packet informations
- *
- * Assume that chunk_ib_index is properly set. Will return -EINVAL
- * if packet is bigger than remaining ib size. or if packets is unknown.
- **/
-static int evergreen_cs_packet_parse(struct radeon_cs_parser *p,
-                             struct radeon_cs_packet *pkt,
-                             unsigned idx)
-{
-       struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx];
-       uint32_t header;
-
-       if (idx >= ib_chunk->length_dw) {
-               DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
-                         idx, ib_chunk->length_dw);
-               return -EINVAL;
-       }
-       header = radeon_get_ib_value(p, idx);
-       pkt->idx = idx;
-       pkt->type = CP_PACKET_GET_TYPE(header);
-       pkt->count = CP_PACKET_GET_COUNT(header);
-       pkt->one_reg_wr = 0;
-       switch (pkt->type) {
-       case PACKET_TYPE0:
-               pkt->reg = CP_PACKET0_GET_REG(header);
-               break;
-       case PACKET_TYPE3:
-               pkt->opcode = CP_PACKET3_GET_OPCODE(header);
-               break;
-       case PACKET_TYPE2:
-               pkt->count = -1;
-               break;
-       default:
-               DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx);
-               return -EINVAL;
-       }
-       if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) {
-               DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n",
-                         pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw);
-               return -EINVAL;
-       }
-       return 0;
-}
-
 /**
  * evergreen_cs_packet_next_reloc() - parse next packet which should be reloc packet3
  * @parser:            parser structure holding parsing context.
@@ -1080,7 +1033,7 @@ static int evergreen_cs_packet_next_reloc(struct radeon_cs_parser *p,
        }
        *cs_reloc = NULL;
        relocs_chunk = &p->chunks[p->chunk_relocs_idx];
-       r = evergreen_cs_packet_parse(p, &p3reloc, p->idx);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx);
        if (r) {
                return r;
        }
@@ -1112,7 +1065,7 @@ static bool evergreen_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser *p)
        struct radeon_cs_packet p3reloc;
        int r;
 
-       r = evergreen_cs_packet_parse(p, &p3reloc, p->idx);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx);
        if (r) {
                return false;
        }
@@ -1150,7 +1103,7 @@ static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p)
        ib = p->ib.ptr;
 
        /* parse the WAIT_REG_MEM */
-       r = evergreen_cs_packet_parse(p, &wait_reg_mem, p->idx);
+       r = radeon_cs_packet_parse(p, &wait_reg_mem, p->idx);
        if (r)
                return r;
 
@@ -1183,7 +1136,7 @@ static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p)
        }
 
        /* jump over the NOP */
-       r = evergreen_cs_packet_parse(p, &p3reloc, p->idx + wait_reg_mem.count + 2);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx + wait_reg_mem.count + 2);
        if (r)
                return r;
 
@@ -2819,7 +2772,7 @@ int evergreen_cs_parse(struct radeon_cs_parser *p)
                p->track = track;
        }
        do {
-               r = evergreen_cs_packet_parse(p, &pkt, p->idx);
+               r = radeon_cs_packet_parse(p, &pkt, p->idx);
                if (r) {
                        kfree(p->track);
                        p->track = NULL;
index 40c0318b1eefedadcdb39cc9ee6b8af4dcc695aa..7842447da4fb6e6ebc0e820a00ed87a43f7e6dfc 100644 (file)
@@ -1369,53 +1369,6 @@ void r100_cs_dump_packet(struct radeon_cs_parser *p,
        }
 }
 
-/**
- * r100_cs_packet_parse() - parse cp packet and point ib index to next packet
- * @parser:    parser structure holding parsing context.
- * @pkt:       where to store packet informations
- *
- * Assume that chunk_ib_index is properly set. Will return -EINVAL
- * if packet is bigger than remaining ib size. or if packets is unknown.
- **/
-int r100_cs_packet_parse(struct radeon_cs_parser *p,
-                        struct radeon_cs_packet *pkt,
-                        unsigned idx)
-{
-       struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx];
-       uint32_t header;
-
-       if (idx >= ib_chunk->length_dw) {
-               DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
-                         idx, ib_chunk->length_dw);
-               return -EINVAL;
-       }
-       header = radeon_get_ib_value(p, idx);
-       pkt->idx = idx;
-       pkt->type = CP_PACKET_GET_TYPE(header);
-       pkt->count = CP_PACKET_GET_COUNT(header);
-       switch (pkt->type) {
-       case PACKET_TYPE0:
-               pkt->reg = CP_PACKET0_GET_REG(header);
-               pkt->one_reg_wr = CP_PACKET0_GET_ONE_REG_WR(header);
-               break;
-       case PACKET_TYPE3:
-               pkt->opcode = CP_PACKET3_GET_OPCODE(header);
-               break;
-       case PACKET_TYPE2:
-               pkt->count = -1;
-               break;
-       default:
-               DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx);
-               return -EINVAL;
-       }
-       if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) {
-               DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n",
-                         pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw);
-               return -EINVAL;
-       }
-       return 0;
-}
-
 /**
  * r100_cs_packet_next_vline() - parse userspace VLINE packet
  * @parser:            parser structure holding parsing context.
@@ -1444,7 +1397,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
        ib = p->ib.ptr;
 
        /* parse the wait until */
-       r = r100_cs_packet_parse(p, &waitreloc, p->idx);
+       r = radeon_cs_packet_parse(p, &waitreloc, p->idx);
        if (r)
                return r;
 
@@ -1461,7 +1414,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
        }
 
        /* jump over the NOP */
-       r = r100_cs_packet_parse(p, &p3reloc, p->idx + waitreloc.count + 2);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx + waitreloc.count + 2);
        if (r)
                return r;
 
@@ -1531,7 +1484,7 @@ int r100_cs_packet_next_reloc(struct radeon_cs_parser *p,
        }
        *cs_reloc = NULL;
        relocs_chunk = &p->chunks[p->chunk_relocs_idx];
-       r = r100_cs_packet_parse(p, &p3reloc, p->idx);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx);
        if (r) {
                return r;
        }
@@ -2100,7 +2053,7 @@ int r100_cs_parse(struct radeon_cs_parser *p)
        r100_cs_track_clear(p->rdev, track);
        p->track = track;
        do {
-               r = r100_cs_packet_parse(p, &pkt, p->idx);
+               r = radeon_cs_packet_parse(p, &pkt, p->idx);
                if (r) {
                        return r;
                }
index d0ba6023a1f8b3f3aca1898988cf8bed8d71e665..34ca46e463477f0f7b45c35cb2c21dc52a43cd4f 100644 (file)
@@ -1257,7 +1257,7 @@ int r300_cs_parse(struct radeon_cs_parser *p)
        r100_cs_track_clear(p->rdev, track);
        p->track = track;
        do {
-               r = r100_cs_packet_parse(p, &pkt, p->idx);
+               r = radeon_cs_packet_parse(p, &pkt, p->idx);
                if (r) {
                        return r;
                }
index 69ec24ab8d636453dfa7e2ab313588786341c977..3870bf8c1bc77e8246c93e6386d30c93499afac4 100644 (file)
@@ -783,53 +783,6 @@ static int r600_cs_track_check(struct radeon_cs_parser *p)
        return 0;
 }
 
-/**
- * r600_cs_packet_parse() - parse cp packet and point ib index to next packet
- * @parser:    parser structure holding parsing context.
- * @pkt:       where to store packet informations
- *
- * Assume that chunk_ib_index is properly set. Will return -EINVAL
- * if packet is bigger than remaining ib size. or if packets is unknown.
- **/
-static int r600_cs_packet_parse(struct radeon_cs_parser *p,
-                       struct radeon_cs_packet *pkt,
-                       unsigned idx)
-{
-       struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx];
-       uint32_t header;
-
-       if (idx >= ib_chunk->length_dw) {
-               DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
-                         idx, ib_chunk->length_dw);
-               return -EINVAL;
-       }
-       header = radeon_get_ib_value(p, idx);
-       pkt->idx = idx;
-       pkt->type = CP_PACKET_GET_TYPE(header);
-       pkt->count = CP_PACKET_GET_COUNT(header);
-       pkt->one_reg_wr = 0;
-       switch (pkt->type) {
-       case PACKET_TYPE0:
-               pkt->reg = CP_PACKET0_GET_REG(header);
-               break;
-       case PACKET_TYPE3:
-               pkt->opcode = CP_PACKET3_GET_OPCODE(header);
-               break;
-       case PACKET_TYPE2:
-               pkt->count = -1;
-               break;
-       default:
-               DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx);
-               return -EINVAL;
-       }
-       if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) {
-               DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n",
-                         pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw);
-               return -EINVAL;
-       }
-       return 0;
-}
-
 /**
  * r600_cs_packet_next_reloc_mm() - parse next packet which should be reloc packet3
  * @parser:            parser structure holding parsing context.
@@ -855,7 +808,7 @@ static int r600_cs_packet_next_reloc_mm(struct radeon_cs_parser *p,
        }
        *cs_reloc = NULL;
        relocs_chunk = &p->chunks[p->chunk_relocs_idx];
-       r = r600_cs_packet_parse(p, &p3reloc, p->idx);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx);
        if (r) {
                return r;
        }
@@ -901,7 +854,7 @@ static int r600_cs_packet_next_reloc_nomm(struct radeon_cs_parser *p,
        }
        *cs_reloc = NULL;
        relocs_chunk = &p->chunks[p->chunk_relocs_idx];
-       r = r600_cs_packet_parse(p, &p3reloc, p->idx);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx);
        if (r) {
                return r;
        }
@@ -935,7 +888,7 @@ static int r600_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser *p)
        struct radeon_cs_packet p3reloc;
        int r;
 
-       r = r600_cs_packet_parse(p, &p3reloc, p->idx);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx);
        if (r) {
                return 0;
        }
@@ -973,7 +926,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p)
        ib = p->ib.ptr;
 
        /* parse the WAIT_REG_MEM */
-       r = r600_cs_packet_parse(p, &wait_reg_mem, p->idx);
+       r = radeon_cs_packet_parse(p, &wait_reg_mem, p->idx);
        if (r)
                return r;
 
@@ -1006,7 +959,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p)
        }
 
        /* jump over the NOP */
-       r = r600_cs_packet_parse(p, &p3reloc, p->idx + wait_reg_mem.count + 2);
+       r = radeon_cs_packet_parse(p, &p3reloc, p->idx + wait_reg_mem.count + 2);
        if (r)
                return r;
 
@@ -2410,7 +2363,7 @@ int r600_cs_parse(struct radeon_cs_parser *p)
                p->track = track;
        }
        do {
-               r = r600_cs_packet_parse(p, &pkt, p->idx);
+               r = radeon_cs_packet_parse(p, &pkt, p->idx);
                if (r) {
                        kfree(p->track);
                        p->track = NULL;
index a08f657329a0e821d681678a6e1f74de357b042e..b8d1c5c0c2c67b61f80a706c138b6f836c2e4471 100644 (file)
@@ -1972,6 +1972,10 @@ static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
 static inline void radeon_acpi_fini(struct radeon_device *rdev) { }
 #endif
 
+int radeon_cs_packet_parse(struct radeon_cs_parser *p,
+                          struct radeon_cs_packet *pkt,
+                          unsigned idx);
+
 #include "radeon_object.h"
 
 #endif