diff options
author | Christian König <christian.koenig@amd.com> | 2015-12-18 15:26:47 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-02-10 14:16:47 -0500 |
commit | 636ce25c30010a8f393f5a1e67d5d4b7b66739e7 (patch) | |
tree | 64601ad38f22541bcdd264857ddb9d9c8b6959f1 /drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |
parent | 2a7d9bdabec21825ef77f5705e463342a9d7fcea (diff) |
drm/amdgpu: cleanup bo list bucket handling
Move that into the BO list. No functional change.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 5986da26a492..d249e9e0a4ea 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -30,47 +30,6 @@ | |||
30 | #include "amdgpu.h" | 30 | #include "amdgpu.h" |
31 | #include "amdgpu_trace.h" | 31 | #include "amdgpu_trace.h" |
32 | 32 | ||
33 | #define AMDGPU_CS_MAX_PRIORITY 32u | ||
34 | #define AMDGPU_CS_NUM_BUCKETS (AMDGPU_CS_MAX_PRIORITY + 1) | ||
35 | |||
36 | /* This is based on the bucket sort with O(n) time complexity. | ||
37 | * An item with priority "i" is added to bucket[i]. The lists are then | ||
38 | * concatenated in descending order. | ||
39 | */ | ||
40 | struct amdgpu_cs_buckets { | ||
41 | struct list_head bucket[AMDGPU_CS_NUM_BUCKETS]; | ||
42 | }; | ||
43 | |||
44 | static void amdgpu_cs_buckets_init(struct amdgpu_cs_buckets *b) | ||
45 | { | ||
46 | unsigned i; | ||
47 | |||
48 | for (i = 0; i < AMDGPU_CS_NUM_BUCKETS; i++) | ||
49 | INIT_LIST_HEAD(&b->bucket[i]); | ||
50 | } | ||
51 | |||
52 | static void amdgpu_cs_buckets_add(struct amdgpu_cs_buckets *b, | ||
53 | struct list_head *item, unsigned priority) | ||
54 | { | ||
55 | /* Since buffers which appear sooner in the relocation list are | ||
56 | * likely to be used more often than buffers which appear later | ||
57 | * in the list, the sort mustn't change the ordering of buffers | ||
58 | * with the same priority, i.e. it must be stable. | ||
59 | */ | ||
60 | list_add_tail(item, &b->bucket[min(priority, AMDGPU_CS_MAX_PRIORITY)]); | ||
61 | } | ||
62 | |||
63 | static void amdgpu_cs_buckets_get_list(struct amdgpu_cs_buckets *b, | ||
64 | struct list_head *out_list) | ||
65 | { | ||
66 | unsigned i; | ||
67 | |||
68 | /* Connect the sorted buckets in the output list. */ | ||
69 | for (i = 0; i < AMDGPU_CS_NUM_BUCKETS; i++) { | ||
70 | list_splice(&b->bucket[i], out_list); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, | 33 | int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, |
75 | u32 ip_instance, u32 ring, | 34 | u32 ip_instance, u32 ring, |
76 | struct amdgpu_ring **out_ring) | 35 | struct amdgpu_ring **out_ring) |
@@ -382,22 +341,16 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
382 | union drm_amdgpu_cs *cs) | 341 | union drm_amdgpu_cs *cs) |
383 | { | 342 | { |
384 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; | 343 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; |
385 | struct amdgpu_cs_buckets buckets; | ||
386 | struct list_head duplicates; | 344 | struct list_head duplicates; |
387 | bool need_mmap_lock = false; | 345 | bool need_mmap_lock = false; |
388 | int i, r; | 346 | int r; |
389 | 347 | ||
390 | INIT_LIST_HEAD(&p->validated); | 348 | INIT_LIST_HEAD(&p->validated); |
391 | 349 | ||
392 | p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); | 350 | p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); |
393 | if (p->bo_list) { | 351 | if (p->bo_list) { |
394 | need_mmap_lock = p->bo_list->has_userptr; | 352 | need_mmap_lock = p->bo_list->has_userptr; |
395 | amdgpu_cs_buckets_init(&buckets); | 353 | amdgpu_bo_list_get_list(p->bo_list, &p->validated); |
396 | for (i = 0; i < p->bo_list->num_entries; i++) | ||
397 | amdgpu_cs_buckets_add(&buckets, &p->bo_list->array[i].tv.head, | ||
398 | p->bo_list->array[i].priority); | ||
399 | |||
400 | amdgpu_cs_buckets_get_list(&buckets, &p->validated); | ||
401 | } | 354 | } |
402 | 355 | ||
403 | INIT_LIST_HEAD(&duplicates); | 356 | INIT_LIST_HEAD(&duplicates); |