diff options
author | Chunming Zhou <David1.Zhou@amd.com> | 2015-11-04 22:28:28 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-11-16 11:05:50 -0500 |
commit | b49c84a5765cf68b8e2fdb1dc4eded9c208e6d58 (patch) | |
tree | 7641ed829091bb8f1605a31057dc372af09688e2 /drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |
parent | 451f698bcac84c49dd4e25dd8e89dbd66796b4cd (diff) |
drm/amdgpu: add kmem cache for amdgpu fence
Change-Id: I5ad8dd156ccf27a6f18004aa0a215a0925b6e67b
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 257fce356319..3671f9f220bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |||
@@ -47,6 +47,9 @@ | |||
47 | * that the the relevant GPU caches have been flushed. | 47 | * that the the relevant GPU caches have been flushed. |
48 | */ | 48 | */ |
49 | 49 | ||
50 | static struct kmem_cache *amdgpu_fence_slab; | ||
51 | static atomic_t amdgpu_fence_slab_ref = ATOMIC_INIT(0); | ||
52 | |||
50 | /** | 53 | /** |
51 | * amdgpu_fence_write - write a fence value | 54 | * amdgpu_fence_write - write a fence value |
52 | * | 55 | * |
@@ -100,7 +103,7 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, void *owner, | |||
100 | struct amdgpu_device *adev = ring->adev; | 103 | struct amdgpu_device *adev = ring->adev; |
101 | 104 | ||
102 | /* we are protected by the ring emission mutex */ | 105 | /* we are protected by the ring emission mutex */ |
103 | *fence = kmalloc(sizeof(struct amdgpu_fence), GFP_KERNEL); | 106 | *fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL); |
104 | if ((*fence) == NULL) { | 107 | if ((*fence) == NULL) { |
105 | return -ENOMEM; | 108 | return -ENOMEM; |
106 | } | 109 | } |
@@ -522,6 +525,13 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring) | |||
522 | */ | 525 | */ |
523 | int amdgpu_fence_driver_init(struct amdgpu_device *adev) | 526 | int amdgpu_fence_driver_init(struct amdgpu_device *adev) |
524 | { | 527 | { |
528 | if (atomic_inc_return(&amdgpu_fence_slab_ref) == 1) { | ||
529 | amdgpu_fence_slab = kmem_cache_create( | ||
530 | "amdgpu_fence", sizeof(struct amdgpu_fence), 0, | ||
531 | SLAB_HWCACHE_ALIGN, NULL); | ||
532 | if (!amdgpu_fence_slab) | ||
533 | return -ENOMEM; | ||
534 | } | ||
525 | if (amdgpu_debugfs_fence_init(adev)) | 535 | if (amdgpu_debugfs_fence_init(adev)) |
526 | dev_err(adev->dev, "fence debugfs file creation failed\n"); | 536 | dev_err(adev->dev, "fence debugfs file creation failed\n"); |
527 | 537 | ||
@@ -540,6 +550,8 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) | |||
540 | { | 550 | { |
541 | int i, r; | 551 | int i, r; |
542 | 552 | ||
553 | if (atomic_dec_and_test(&amdgpu_fence_slab_ref)) | ||
554 | kmem_cache_destroy(amdgpu_fence_slab); | ||
543 | mutex_lock(&adev->ring_lock); | 555 | mutex_lock(&adev->ring_lock); |
544 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | 556 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { |
545 | struct amdgpu_ring *ring = adev->rings[i]; | 557 | struct amdgpu_ring *ring = adev->rings[i]; |
@@ -745,13 +757,19 @@ static bool amdgpu_fence_enable_signaling(struct fence *f) | |||
745 | return true; | 757 | return true; |
746 | } | 758 | } |
747 | 759 | ||
760 | static void amdgpu_fence_release(struct fence *f) | ||
761 | { | ||
762 | struct amdgpu_fence *fence = to_amdgpu_fence(f); | ||
763 | kmem_cache_free(amdgpu_fence_slab, fence); | ||
764 | } | ||
765 | |||
748 | const struct fence_ops amdgpu_fence_ops = { | 766 | const struct fence_ops amdgpu_fence_ops = { |
749 | .get_driver_name = amdgpu_fence_get_driver_name, | 767 | .get_driver_name = amdgpu_fence_get_driver_name, |
750 | .get_timeline_name = amdgpu_fence_get_timeline_name, | 768 | .get_timeline_name = amdgpu_fence_get_timeline_name, |
751 | .enable_signaling = amdgpu_fence_enable_signaling, | 769 | .enable_signaling = amdgpu_fence_enable_signaling, |
752 | .signaled = amdgpu_fence_is_signaled, | 770 | .signaled = amdgpu_fence_is_signaled, |
753 | .wait = fence_default_wait, | 771 | .wait = fence_default_wait, |
754 | .release = NULL, | 772 | .release = amdgpu_fence_release, |
755 | }; | 773 | }; |
756 | 774 | ||
757 | /* | 775 | /* |