summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Kuehling <Felix.Kuehling@amd.com>2017-08-16 06:00:11 +0300
committerOded Gabbay <oded.gabbay@gmail.com>2017-08-16 06:00:11 +0300
commit8625ff9c0ba7db32ce4eb25f6032638c1f88c82f (patch)
treee115312f991c94e587ec69948f467814370b7273
parent735df2ba1d584e98a894680e29a813f9fde64a84 (diff)
downloadlinux-8625ff9c0ba7db32ce4eb25f6032638c1f88c82f.tar.xz
drm/amdkfd: Allocate gtt_sa_bitmap in long units
gtt_sa_bitmap is accessed by bitmap functions, which operate on longs. Therefore the array should be allocated in long units. Also round up in case the number of bits is not a multiple of BITS_PER_LONG. Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index cb7ed0294412..416955f7c7d4 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -395,7 +395,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry)
static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
unsigned int chunk_size)
{
- unsigned int num_of_bits;
+ unsigned int num_of_longs;
BUG_ON(buf_size < chunk_size);
BUG_ON(buf_size == 0);
@@ -404,10 +404,10 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
kfd->gtt_sa_chunk_size = chunk_size;
kfd->gtt_sa_num_of_chunks = buf_size / chunk_size;
- num_of_bits = kfd->gtt_sa_num_of_chunks / BITS_PER_BYTE;
- BUG_ON(num_of_bits == 0);
+ num_of_longs = (kfd->gtt_sa_num_of_chunks + BITS_PER_LONG - 1) /
+ BITS_PER_LONG;
- kfd->gtt_sa_bitmap = kzalloc(num_of_bits, GFP_KERNEL);
+ kfd->gtt_sa_bitmap = kcalloc(num_of_longs, sizeof(long), GFP_KERNEL);
if (!kfd->gtt_sa_bitmap)
return -ENOMEM;