drm/radeon: use a single doorbell for cik kms compute
authorAndrew Lewycky <Andrew.Lewycky@amd.com>
Wed, 13 Nov 2013 20:54:17 +0000 (15:54 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 15 Nov 2013 20:56:22 +0000 (15:56 -0500)
A single doorbell page is plenty for cik kms compute.
Use a single page and manage doorbell allocation by
individual doorbells rather than pages.  Identify
doorbells by their index rather than byte offset.

Signed-off-by: Andrew Lewycky <Andrew.Lewycky@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_device.c

index c169897..08aa58e 100644 (file)
@@ -1560,17 +1560,17 @@ u32 cik_get_xclk(struct radeon_device *rdev)
  * cik_mm_rdoorbell - read a doorbell dword
  *
  * @rdev: radeon_device pointer
- * @offset: byte offset into the aperture
+ * @index: doorbell index
  *
  * Returns the value in the doorbell aperture at the
- * requested offset (CIK).
+ * requested doorbell index (CIK).
  */
-u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset)
+u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 index)
 {
-       if (offset < rdev->doorbell.size) {
-               return readl(((void __iomem *)rdev->doorbell.ptr) + offset);
+       if (index < rdev->doorbell.num_doorbells) {
+               return readl(rdev->doorbell.ptr + index);
        } else {
-               DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", offset);
+               DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index);
                return 0;
        }
 }
@@ -1579,18 +1579,18 @@ u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset)
  * cik_mm_wdoorbell - write a doorbell dword
  *
  * @rdev: radeon_device pointer
- * @offset: byte offset into the aperture
+ * @index: doorbell index
  * @v: value to write
  *
  * Writes @v to the doorbell aperture at the
- * requested offset (CIK).
+ * requested doorbell index (CIK).
  */
-void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v)
+void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v)
 {
-       if (offset < rdev->doorbell.size) {
-               writel(v, ((void __iomem *)rdev->doorbell.ptr) + offset);
+       if (index < rdev->doorbell.num_doorbells) {
+               writel(v, rdev->doorbell.ptr + index);
        } else {
-               DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", offset);
+               DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
        }
 }
 
@@ -4054,7 +4054,7 @@ void cik_compute_ring_set_wptr(struct radeon_device *rdev,
                               struct radeon_ring *ring)
 {
        rdev->wb.wb[ring->wptr_offs/4] = cpu_to_le32(ring->wptr);
-       WDOORBELL32(ring->doorbell_offset, ring->wptr);
+       WDOORBELL32(ring->doorbell_index, ring->wptr);
 }
 
 /**
@@ -4395,10 +4395,6 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
                        return r;
                }
 
-               /* doorbell offset */
-               rdev->ring[idx].doorbell_offset =
-                       (rdev->ring[idx].doorbell_page_num * PAGE_SIZE) + 0;
-
                /* init the mqd struct */
                memset(buf, 0, sizeof(struct bonaire_mqd));
 
@@ -4510,7 +4506,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
                                RREG32(CP_HQD_PQ_DOORBELL_CONTROL);
                        mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_OFFSET_MASK;
                        mqd->queue_state.cp_hqd_pq_doorbell_control |=
-                               DOORBELL_OFFSET(rdev->ring[idx].doorbell_offset / 4);
+                               DOORBELL_OFFSET(rdev->ring[idx].doorbell_index);
                        mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN;
                        mqd->queue_state.cp_hqd_pq_doorbell_control &=
                                ~(DOORBELL_SOURCE | DOORBELL_HIT);
@@ -7841,14 +7837,14 @@ int cik_init(struct radeon_device *rdev)
        ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
        ring->ring_obj = NULL;
        r600_ring_init(rdev, ring, 1024 * 1024);
-       r = radeon_doorbell_get(rdev, &ring->doorbell_page_num);
+       r = radeon_doorbell_get(rdev, &ring->doorbell_index);
        if (r)
                return r;
 
        ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
        ring->ring_obj = NULL;
        r600_ring_init(rdev, ring, 1024 * 1024);
-       r = radeon_doorbell_get(rdev, &ring->doorbell_page_num);
+       r = radeon_doorbell_get(rdev, &ring->doorbell_index);
        if (r)
                return r;
 
Simple merge