summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdkfd/kfd_device.c
diff options
context:
space:
mode:
authorOded Gabbay <oded.gabbay@amd.com>2014-07-16 22:25:31 +0200
committerOded Gabbay <oded.gabbay@amd.com>2014-07-16 22:25:31 +0200
commit19f6d2a660340d01bcdb7a09557efeeee28d1517 (patch)
treec19d39c617ea7afe653169e36cf570b03cb4d94b /drivers/gpu/drm/amd/amdkfd/kfd_device.c
parentamdkfd: Add topology module to amdkfd (diff)
downloadlinux-19f6d2a660340d01bcdb7a09557efeeee28d1517.tar.xz
linux-19f6d2a660340d01bcdb7a09557efeeee28d1517.zip
amdkfd: Add basic modules to amdkfd
This patch adds the process module and three helper modules: - kfd_process, which handles process which open /dev/kfd - kfd_doorbell, which provides helper functions for doorbell allocation, release and mapping to userspace - kfd_pasid, which provides helper functions for pasid allocation and release - kfd_aperture, which provides helper functions for managing the LDS, Local GPU memory and Scratch memory apertures of the process This patch only contains the basic kfd_process module, which doesn't contain the reference to the queue scheduler. This was done to allow easier code review. Also, this patch doesn't contain the calls to the IOMMU driver for binding the pasid to the device. Again, this was done to allow easier code review The kfd_process object is created when a process opens /dev/kfd and is closed when the mm_struct of that process is teared-down. v3: Removed kfd_vidmem.c file Replaced direct mmput call to mmu_notifier release Removed typedefs Moved bool field to end of the structure Added new kernel params for gart usage limitation Added initialization of sa manager Fixed debug messages Remove support for LDS in 32 bit Changed code to support mmap of doorbell pages from userspace Added documentation for apertures v4: Replaced RCU by SRCU for kfd_process list management v5: Move amdkfd from drm/radeon/ to drm/amd/ Rename kfd_aperture.c to kfd_flat_memory.c Protect against multiple init calls MQD size is H/W dependent so moved it to device info structure Rename kfd_mem_obj structure's members Use delayed function for process tear-down Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdkfd/kfd_device.c')
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index 53b2e19cabe0..71a03f7b0049 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -26,8 +26,11 @@
#include <linux/slab.h>
#include "kfd_priv.h"
+#define MQD_SIZE_ALIGNED 768
+
static const struct kfd_device_info kaveri_device_info = {
.max_pasid_bits = 16,
+ .mqd_size_aligned = MQD_SIZE_ALIGNED
};
struct kfd_deviceid {
@@ -92,6 +95,7 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev)
kfd->kgd = kgd;
kfd->device_info = device_info;
kfd->pdev = pdev;
+ kfd->init_complete = false;
return kfd;
}
@@ -99,23 +103,53 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev)
bool kgd2kfd_device_init(struct kfd_dev *kfd,
const struct kgd2kfd_shared_resources *gpu_resources)
{
+ unsigned int size;
+
kfd->shared_resources = *gpu_resources;
- if (kfd_topology_add_device(kfd) != 0)
- return false;
+ /* calculate max size of mqds needed for queues */
+ size = max_num_of_processes *
+ max_num_of_queues_per_process *
+ kfd->device_info->mqd_size_aligned;
+
+ /* add another 512KB for all other allocations on gart */
+ size += 512 * 1024;
+
+ if (kfd2kgd->init_sa_manager(kfd->kgd, size)) {
+ dev_err(kfd_device,
+ "Error initializing sa manager for device (%x:%x)\n",
+ kfd->pdev->vendor, kfd->pdev->device);
+ goto out;
+ }
+
+ kfd_doorbell_init(kfd);
+
+ if (kfd_topology_add_device(kfd) != 0) {
+ dev_err(kfd_device,
+ "Error adding device (%x:%x) to topology\n",
+ kfd->pdev->vendor, kfd->pdev->device);
+ goto kfd_topology_add_device_error;
+ }
+
kfd->init_complete = true;
dev_info(kfd_device, "added device (%x:%x)\n", kfd->pdev->vendor,
kfd->pdev->device);
- return true;
+ goto out;
+
+kfd_topology_add_device_error:
+ kfd2kgd->fini_sa_manager(kfd->kgd);
+ dev_err(kfd_device,
+ "device (%x:%x) NOT added due to errors\n",
+ kfd->pdev->vendor, kfd->pdev->device);
+out:
+ return kfd->init_complete;
}
void kgd2kfd_device_exit(struct kfd_dev *kfd)
{
- int err = kfd_topology_remove_device(kfd);
-
- BUG_ON(err != 0);
+ kfd_topology_remove_device(kfd);
kfree(kfd);
}