drm/amdgpu: add number of hardware submissions to amdgpu_fence_driver_init_ring
authorChristian König <christian.koenig@amd.com>
Tue, 15 Mar 2016 13:52:26 +0000 (14:52 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 16 Mar 2016 21:59:12 +0000 (17:59 -0400)
Make this a parameter instead of using the global variable directly.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

index 7dee9af331967a1bfc8728b53af6b54ce0869685..26b137801aeaed8b0fbc1c4edaac782b189b91ea 100644 (file)
@@ -413,7 +413,8 @@ int amdgpu_fence_driver_init(struct amdgpu_device *adev);
 void amdgpu_fence_driver_fini(struct amdgpu_device *adev);
 void amdgpu_fence_driver_force_completion(struct amdgpu_device *adev);
 
-int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring);
+int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
+                                 unsigned num_hw_submission);
 int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
                                   struct amdgpu_irq_src *irq_src,
                                   unsigned irq_type);
index ec73ab1c177dc471da21bbba990a735ce00df408..4654113ecfae2f772383d2eeaccf901fc3b0468e 100644 (file)
@@ -355,15 +355,21 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
  * for the requested ring.
  *
  * @ring: ring to init the fence driver on
+ * @num_hw_submission: number of entries on the hardware queue
  *
  * Init the fence driver for the requested ring (all asics).
  * Helper function for amdgpu_fence_driver_init().
  */
-int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring)
+int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
+                                 unsigned num_hw_submission)
 {
        long timeout;
        int r;
 
+       /* Check that num_hw_submission is a power of two */
+       if ((num_hw_submission & (num_hw_submission - 1)) != 0)
+               return -EINVAL;
+
        ring->fence_drv.cpu_addr = NULL;
        ring->fence_drv.gpu_addr = 0;
        ring->fence_drv.sync_seq = 0;
@@ -387,7 +393,7 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring)
                timeout = MAX_SCHEDULE_TIMEOUT;
        }
        r = amd_sched_init(&ring->sched, &amdgpu_sched_ops,
-                          amdgpu_sched_hw_submission,
+                          num_hw_submission,
                           timeout, ring->name);
        if (r) {
                DRM_ERROR("Failed to create scheduler on ring %s.\n",
index cc3c7adb994c0444dd961867160b8f065d7ade99..972eed2ef787eff5a49028ae58f60f3a85c47690 100644 (file)
@@ -236,7 +236,8 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
                ring->adev = adev;
                ring->idx = adev->num_rings++;
                adev->rings[ring->idx] = ring;
-               r = amdgpu_fence_driver_init_ring(ring);
+               r = amdgpu_fence_driver_init_ring(ring,
+                       amdgpu_sched_hw_submission);
                if (r)
                        return r;
        }