@@ -1093,7 +1093,6 @@ struct radeon_cs_parser {
int parser_error;
u32 cs_flags;
u32 ring;
- s32 priority;
struct ww_acquire_ctx ticket;
};
@@ -1122,6 +1121,7 @@ typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
struct radeon_cs_packet *pkt);
+int radeon_cs_get_ring(struct radeon_device *rdev, u32 ring, s32 priority);
/*
* AGP
@@ -187,47 +187,46 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
return r;
}
-static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority)
+int radeon_cs_get_ring(struct radeon_device *rdev, u32 ring, s32 priority)
{
- p->priority = priority;
-
switch (ring) {
default:
DRM_ERROR("unknown ring id: %d\n", ring);
- return -EINVAL;
- case RADEON_CS_RING_GFX:
- p->ring = RADEON_RING_TYPE_GFX_INDEX;
break;
+
+ case RADEON_CS_RING_GFX:
+ return RADEON_RING_TYPE_GFX_INDEX;
+
case RADEON_CS_RING_COMPUTE:
- if (p->rdev->family >= CHIP_TAHITI) {
- if (p->priority > 0)
- p->ring = CAYMAN_RING_TYPE_CP1_INDEX;
+ if (rdev->family >= CHIP_TAHITI) {
+ if (priority > 0)
+ return CAYMAN_RING_TYPE_CP1_INDEX;
else
- p->ring = CAYMAN_RING_TYPE_CP2_INDEX;
+ return CAYMAN_RING_TYPE_CP2_INDEX;
} else
- p->ring = RADEON_RING_TYPE_GFX_INDEX;
- break;
+ return RADEON_RING_TYPE_GFX_INDEX;
+
case RADEON_CS_RING_DMA:
- if (p->rdev->family >= CHIP_CAYMAN) {
- if (p->priority > 0)
- p->ring = R600_RING_TYPE_DMA_INDEX;
+ if (rdev->family >= CHIP_CAYMAN) {
+ if (priority > 0)
+ return R600_RING_TYPE_DMA_INDEX;
else
- p->ring = CAYMAN_RING_TYPE_DMA1_INDEX;
- } else if (p->rdev->family >= CHIP_RV770) {
- p->ring = R600_RING_TYPE_DMA_INDEX;
+ return CAYMAN_RING_TYPE_DMA1_INDEX;
+ } else if (rdev->family >= CHIP_RV770) {
+ return R600_RING_TYPE_DMA_INDEX;
} else {
return -EINVAL;
}
- break;
+
case RADEON_CS_RING_UVD:
- p->ring = R600_RING_TYPE_UVD_INDEX;
- break;
+ return R600_RING_TYPE_UVD_INDEX;
+
case RADEON_CS_RING_VCE:
/* TODO: only use the low priority ring for now */
- p->ring = TN_RING_TYPE_VCE1_INDEX;
- break;
+ return TN_RING_TYPE_VCE1_INDEX;
+
}
- return 0;
+ return -EINVAL;
}
static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
@@ -348,14 +347,18 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
/* these are KMS only */
if (p->rdev) {
+ int r;
+
if ((p->cs_flags & RADEON_CS_USE_VM) &&
!p->rdev->vm_manager.enabled) {
DRM_ERROR("VM not active on asic!\n");
return -EINVAL;
}
- if (radeon_cs_get_ring(p, ring, priority))
- return -EINVAL;
+ r = radeon_cs_get_ring(p->rdev, ring, priority);
+ if (r < 0)
+ return r;
+ p->ring = r;
/* we only support VM on some SI+ rings */
if ((p->cs_flags & RADEON_CS_USE_VM) == 0) {