Commit 4f52f225 authored by Felix Kuehling's avatar Felix Kuehling Committed by Oded Gabbay

drm/amdkfd: Remove BUG_ONs for NULL pointer arguments

Remove BUG_ONs that check for NULL pointer arguments that are
dereferenced in the same function. Dereferencing the NULL pointer
will generate a BUG anyway, so the explicit check is redundant and
unnecessary overhead.
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent dbf56ab1
...@@ -42,8 +42,6 @@ ...@@ -42,8 +42,6 @@
static void dbgdev_address_watch_disable_nodiq(struct kfd_dev *dev) static void dbgdev_address_watch_disable_nodiq(struct kfd_dev *dev)
{ {
BUG_ON(!dev || !dev->kfd2kgd);
dev->kfd2kgd->address_watch_disable(dev->kgd); dev->kfd2kgd->address_watch_disable(dev->kgd);
} }
...@@ -62,7 +60,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev, ...@@ -62,7 +60,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
unsigned int *ib_packet_buff; unsigned int *ib_packet_buff;
int status; int status;
BUG_ON(!dbgdev || !dbgdev->kq || !packet_buff || !size_in_bytes); BUG_ON(!size_in_bytes);
kq = dbgdev->kq; kq = dbgdev->kq;
...@@ -168,8 +166,6 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev, ...@@ -168,8 +166,6 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
static int dbgdev_register_nodiq(struct kfd_dbgdev *dbgdev) static int dbgdev_register_nodiq(struct kfd_dbgdev *dbgdev)
{ {
BUG_ON(!dbgdev);
/* /*
* no action is needed in this case, * no action is needed in this case,
* just make sure diq will not be used * just make sure diq will not be used
...@@ -187,8 +183,6 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev) ...@@ -187,8 +183,6 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
struct kernel_queue *kq = NULL; struct kernel_queue *kq = NULL;
int status; int status;
BUG_ON(!dbgdev || !dbgdev->pqm || !dbgdev->dev);
status = pqm_create_queue(dbgdev->pqm, dbgdev->dev, NULL, status = pqm_create_queue(dbgdev->pqm, dbgdev->dev, NULL,
&properties, 0, KFD_QUEUE_TYPE_DIQ, &properties, 0, KFD_QUEUE_TYPE_DIQ,
&qid); &qid);
...@@ -215,8 +209,6 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev) ...@@ -215,8 +209,6 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
static int dbgdev_unregister_nodiq(struct kfd_dbgdev *dbgdev) static int dbgdev_unregister_nodiq(struct kfd_dbgdev *dbgdev)
{ {
BUG_ON(!dbgdev || !dbgdev->dev);
/* disable watch address */ /* disable watch address */
dbgdev_address_watch_disable_nodiq(dbgdev->dev); dbgdev_address_watch_disable_nodiq(dbgdev->dev);
return 0; return 0;
...@@ -227,8 +219,6 @@ static int dbgdev_unregister_diq(struct kfd_dbgdev *dbgdev) ...@@ -227,8 +219,6 @@ static int dbgdev_unregister_diq(struct kfd_dbgdev *dbgdev)
/* todo - disable address watch */ /* todo - disable address watch */
int status; int status;
BUG_ON(!dbgdev || !dbgdev->pqm || !dbgdev->kq);
status = pqm_destroy_queue(dbgdev->pqm, status = pqm_destroy_queue(dbgdev->pqm,
dbgdev->kq->queue->properties.queue_id); dbgdev->kq->queue->properties.queue_id);
dbgdev->kq = NULL; dbgdev->kq = NULL;
...@@ -245,8 +235,6 @@ static void dbgdev_address_watch_set_registers( ...@@ -245,8 +235,6 @@ static void dbgdev_address_watch_set_registers(
{ {
union ULARGE_INTEGER addr; union ULARGE_INTEGER addr;
BUG_ON(!adw_info || !addrHi || !addrLo || !cntl);
addr.quad_part = 0; addr.quad_part = 0;
addrHi->u32All = 0; addrHi->u32All = 0;
addrLo->u32All = 0; addrLo->u32All = 0;
...@@ -287,8 +275,6 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev, ...@@ -287,8 +275,6 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
unsigned int i; unsigned int i;
BUG_ON(!dbgdev || !dbgdev->dev || !adw_info);
/* taking the vmid for that process on the safe way using pdd */ /* taking the vmid for that process on the safe way using pdd */
pdd = kfd_get_process_device_data(dbgdev->dev, pdd = kfd_get_process_device_data(dbgdev->dev,
adw_info->process); adw_info->process);
...@@ -362,8 +348,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev, ...@@ -362,8 +348,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
/* we do not control the vmid in DIQ mode, just a place holder */ /* we do not control the vmid in DIQ mode, just a place holder */
unsigned int vmid = 0; unsigned int vmid = 0;
BUG_ON(!dbgdev || !dbgdev->dev || !adw_info);
addrHi.u32All = 0; addrHi.u32All = 0;
addrLo.u32All = 0; addrLo.u32All = 0;
cntl.u32All = 0; cntl.u32All = 0;
...@@ -508,8 +492,6 @@ static int dbgdev_wave_control_set_registers( ...@@ -508,8 +492,6 @@ static int dbgdev_wave_control_set_registers(
union GRBM_GFX_INDEX_BITS reg_gfx_index; union GRBM_GFX_INDEX_BITS reg_gfx_index;
struct HsaDbgWaveMsgAMDGen2 *pMsg; struct HsaDbgWaveMsgAMDGen2 *pMsg;
BUG_ON(!wac_info || !in_reg_sq_cmd || !in_reg_gfx_index);
reg_sq_cmd.u32All = 0; reg_sq_cmd.u32All = 0;
reg_gfx_index.u32All = 0; reg_gfx_index.u32All = 0;
pMsg = &wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2; pMsg = &wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2;
...@@ -610,8 +592,6 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev, ...@@ -610,8 +592,6 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
struct pm4__set_config_reg *packets_vec; struct pm4__set_config_reg *packets_vec;
size_t ib_size = sizeof(struct pm4__set_config_reg) * 3; size_t ib_size = sizeof(struct pm4__set_config_reg) * 3;
BUG_ON(!dbgdev || !wac_info);
reg_sq_cmd.u32All = 0; reg_sq_cmd.u32All = 0;
status = dbgdev_wave_control_set_registers(wac_info, &reg_sq_cmd, status = dbgdev_wave_control_set_registers(wac_info, &reg_sq_cmd,
...@@ -725,8 +705,6 @@ static int dbgdev_wave_control_nodiq(struct kfd_dbgdev *dbgdev, ...@@ -725,8 +705,6 @@ static int dbgdev_wave_control_nodiq(struct kfd_dbgdev *dbgdev,
union GRBM_GFX_INDEX_BITS reg_gfx_index; union GRBM_GFX_INDEX_BITS reg_gfx_index;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
BUG_ON(!dbgdev || !dbgdev->dev || !wac_info);
reg_sq_cmd.u32All = 0; reg_sq_cmd.u32All = 0;
/* taking the VMID for that process on the safe way using PDD */ /* taking the VMID for that process on the safe way using PDD */
...@@ -851,8 +829,6 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p) ...@@ -851,8 +829,6 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
void kfd_dbgdev_init(struct kfd_dbgdev *pdbgdev, struct kfd_dev *pdev, void kfd_dbgdev_init(struct kfd_dbgdev *pdbgdev, struct kfd_dev *pdev,
enum DBGDEV_TYPE type) enum DBGDEV_TYPE type)
{ {
BUG_ON(!pdbgdev || !pdev);
pdbgdev->dev = pdev; pdbgdev->dev = pdev;
pdbgdev->kq = NULL; pdbgdev->kq = NULL;
pdbgdev->type = type; pdbgdev->type = type;
......
...@@ -44,8 +44,6 @@ struct mutex *kfd_get_dbgmgr_mutex(void) ...@@ -44,8 +44,6 @@ struct mutex *kfd_get_dbgmgr_mutex(void)
static void kfd_dbgmgr_uninitialize(struct kfd_dbgmgr *pmgr) static void kfd_dbgmgr_uninitialize(struct kfd_dbgmgr *pmgr)
{ {
BUG_ON(!pmgr);
kfree(pmgr->dbgdev); kfree(pmgr->dbgdev);
pmgr->dbgdev = NULL; pmgr->dbgdev = NULL;
...@@ -66,7 +64,6 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev) ...@@ -66,7 +64,6 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
enum DBGDEV_TYPE type = DBGDEV_TYPE_DIQ; enum DBGDEV_TYPE type = DBGDEV_TYPE_DIQ;
struct kfd_dbgmgr *new_buff; struct kfd_dbgmgr *new_buff;
BUG_ON(!pdev);
BUG_ON(!pdev->init_complete); BUG_ON(!pdev->init_complete);
new_buff = kfd_alloc_struct(new_buff); new_buff = kfd_alloc_struct(new_buff);
...@@ -96,8 +93,6 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev) ...@@ -96,8 +93,6 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p) long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
{ {
BUG_ON(!p || !pmgr || !pmgr->dbgdev);
if (pmgr->pasid != 0) { if (pmgr->pasid != 0) {
pr_debug("H/W debugger is already active using pasid %d\n", pr_debug("H/W debugger is already active using pasid %d\n",
pmgr->pasid); pmgr->pasid);
...@@ -118,8 +113,6 @@ long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p) ...@@ -118,8 +113,6 @@ long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p) long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
{ {
BUG_ON(!p || !pmgr || !pmgr->dbgdev);
/* Is the requests coming from the already registered process? */ /* Is the requests coming from the already registered process? */
if (pmgr->pasid != p->pasid) { if (pmgr->pasid != p->pasid) {
pr_debug("H/W debugger is not registered by calling pasid %d\n", pr_debug("H/W debugger is not registered by calling pasid %d\n",
...@@ -137,8 +130,6 @@ long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p) ...@@ -137,8 +130,6 @@ long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr, long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr,
struct dbg_wave_control_info *wac_info) struct dbg_wave_control_info *wac_info)
{ {
BUG_ON(!pmgr || !pmgr->dbgdev || !wac_info);
/* Is the requests coming from the already registered process? */ /* Is the requests coming from the already registered process? */
if (pmgr->pasid != wac_info->process->pasid) { if (pmgr->pasid != wac_info->process->pasid) {
pr_debug("H/W debugger support was not registered for requester pasid %d\n", pr_debug("H/W debugger support was not registered for requester pasid %d\n",
...@@ -152,9 +143,6 @@ long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr, ...@@ -152,9 +143,6 @@ long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr,
long kfd_dbgmgr_address_watch(struct kfd_dbgmgr *pmgr, long kfd_dbgmgr_address_watch(struct kfd_dbgmgr *pmgr,
struct dbg_address_watch_info *adw_info) struct dbg_address_watch_info *adw_info)
{ {
BUG_ON(!pmgr || !pmgr->dbgdev || !adw_info);
/* Is the requests coming from the already registered process? */ /* Is the requests coming from the already registered process? */
if (pmgr->pasid != adw_info->process->pasid) { if (pmgr->pasid != adw_info->process->pasid) {
pr_debug("H/W debugger support was not registered for requester pasid %d\n", pr_debug("H/W debugger support was not registered for requester pasid %d\n",
......
...@@ -341,8 +341,6 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd) ...@@ -341,8 +341,6 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)
void kgd2kfd_suspend(struct kfd_dev *kfd) void kgd2kfd_suspend(struct kfd_dev *kfd)
{ {
BUG_ON(!kfd);
if (kfd->init_complete) { if (kfd->init_complete) {
kfd->dqm->ops.stop(kfd->dqm); kfd->dqm->ops.stop(kfd->dqm);
amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL); amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL);
...@@ -356,8 +354,6 @@ int kgd2kfd_resume(struct kfd_dev *kfd) ...@@ -356,8 +354,6 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
unsigned int pasid_limit; unsigned int pasid_limit;
int err; int err;
BUG_ON(kfd == NULL);
pasid_limit = kfd_get_pasid_limit(); pasid_limit = kfd_get_pasid_limit();
if (kfd->init_complete) { if (kfd->init_complete) {
...@@ -394,8 +390,6 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size, ...@@ -394,8 +390,6 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
{ {
unsigned int num_of_bits; unsigned int num_of_bits;
BUG_ON(!kfd);
BUG_ON(!kfd->gtt_mem);
BUG_ON(buf_size < chunk_size); BUG_ON(buf_size < chunk_size);
BUG_ON(buf_size == 0); BUG_ON(buf_size == 0);
BUG_ON(chunk_size == 0); BUG_ON(chunk_size == 0);
...@@ -445,8 +439,6 @@ int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size, ...@@ -445,8 +439,6 @@ int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
{ {
unsigned int found, start_search, cur_size; unsigned int found, start_search, cur_size;
BUG_ON(!kfd);
if (size == 0) if (size == 0)
return -EINVAL; return -EINVAL;
...@@ -551,8 +543,6 @@ int kfd_gtt_sa_free(struct kfd_dev *kfd, struct kfd_mem_obj *mem_obj) ...@@ -551,8 +543,6 @@ int kfd_gtt_sa_free(struct kfd_dev *kfd, struct kfd_mem_obj *mem_obj)
{ {
unsigned int bit; unsigned int bit;
BUG_ON(!kfd);
/* Act like kfree when trying to free a NULL object */ /* Act like kfree when trying to free a NULL object */
if (!mem_obj) if (!mem_obj)
return 0; return 0;
......
...@@ -79,20 +79,17 @@ static bool is_pipe_enabled(struct device_queue_manager *dqm, int mec, int pipe) ...@@ -79,20 +79,17 @@ static bool is_pipe_enabled(struct device_queue_manager *dqm, int mec, int pipe)
unsigned int get_queues_num(struct device_queue_manager *dqm) unsigned int get_queues_num(struct device_queue_manager *dqm)
{ {
BUG_ON(!dqm || !dqm->dev);
return bitmap_weight(dqm->dev->shared_resources.queue_bitmap, return bitmap_weight(dqm->dev->shared_resources.queue_bitmap,
KGD_MAX_QUEUES); KGD_MAX_QUEUES);
} }
unsigned int get_queues_per_pipe(struct device_queue_manager *dqm) unsigned int get_queues_per_pipe(struct device_queue_manager *dqm)
{ {
BUG_ON(!dqm || !dqm->dev);
return dqm->dev->shared_resources.num_queue_per_pipe; return dqm->dev->shared_resources.num_queue_per_pipe;
} }
unsigned int get_pipes_per_mec(struct device_queue_manager *dqm) unsigned int get_pipes_per_mec(struct device_queue_manager *dqm)
{ {
BUG_ON(!dqm || !dqm->dev);
return dqm->dev->shared_resources.num_pipe_per_mec; return dqm->dev->shared_resources.num_pipe_per_mec;
} }
...@@ -152,8 +149,6 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, ...@@ -152,8 +149,6 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm,
{ {
int retval; int retval;
BUG_ON(!dqm || !q || !qpd || !allocated_vmid);
print_queue(q); print_queue(q);
mutex_lock(&dqm->lock); mutex_lock(&dqm->lock);
...@@ -259,8 +254,6 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, ...@@ -259,8 +254,6 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
int retval; int retval;
struct mqd_manager *mqd; struct mqd_manager *mqd;
BUG_ON(!dqm || !q || !qpd);
mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE); mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE);
if (!mqd) if (!mqd)
return -ENOMEM; return -ENOMEM;
...@@ -299,8 +292,6 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm, ...@@ -299,8 +292,6 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm,
int retval; int retval;
struct mqd_manager *mqd; struct mqd_manager *mqd;
BUG_ON(!dqm || !q || !q->mqd || !qpd);
retval = 0; retval = 0;
mutex_lock(&dqm->lock); mutex_lock(&dqm->lock);
...@@ -362,8 +353,6 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q) ...@@ -362,8 +353,6 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q)
struct mqd_manager *mqd; struct mqd_manager *mqd;
bool prev_active = false; bool prev_active = false;
BUG_ON(!dqm || !q || !q->mqd);
mutex_lock(&dqm->lock); mutex_lock(&dqm->lock);
mqd = dqm->ops.get_mqd_manager(dqm, mqd = dqm->ops.get_mqd_manager(dqm,
get_mqd_type_from_queue_type(q->properties.type)); get_mqd_type_from_queue_type(q->properties.type));
...@@ -399,7 +388,7 @@ static struct mqd_manager *get_mqd_manager_nocpsch( ...@@ -399,7 +388,7 @@ static struct mqd_manager *get_mqd_manager_nocpsch(
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
BUG_ON(!dqm || type >= KFD_MQD_TYPE_MAX); BUG_ON(type >= KFD_MQD_TYPE_MAX);
pr_debug("mqd type %d\n", type); pr_debug("mqd type %d\n", type);
...@@ -420,8 +409,6 @@ static int register_process_nocpsch(struct device_queue_manager *dqm, ...@@ -420,8 +409,6 @@ static int register_process_nocpsch(struct device_queue_manager *dqm,
struct device_process_node *n; struct device_process_node *n;
int retval; int retval;
BUG_ON(!dqm || !qpd);
n = kzalloc(sizeof(*n), GFP_KERNEL); n = kzalloc(sizeof(*n), GFP_KERNEL);
if (!n) if (!n)
return -ENOMEM; return -ENOMEM;
...@@ -446,8 +433,6 @@ static int unregister_process_nocpsch(struct device_queue_manager *dqm, ...@@ -446,8 +433,6 @@ static int unregister_process_nocpsch(struct device_queue_manager *dqm,
int retval; int retval;
struct device_process_node *cur, *next; struct device_process_node *cur, *next;
BUG_ON(!dqm || !qpd);
pr_debug("qpd->queues_list is %s\n", pr_debug("qpd->queues_list is %s\n",
list_empty(&qpd->queues_list) ? "empty" : "not empty"); list_empty(&qpd->queues_list) ? "empty" : "not empty");
...@@ -488,8 +473,6 @@ static void init_interrupts(struct device_queue_manager *dqm) ...@@ -488,8 +473,6 @@ static void init_interrupts(struct device_queue_manager *dqm)
{ {
unsigned int i; unsigned int i;
BUG_ON(!dqm);
for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++) for (i = 0 ; i < get_pipes_per_mec(dqm) ; i++)
if (is_pipe_enabled(dqm, 0, i)) if (is_pipe_enabled(dqm, 0, i))
dqm->dev->kfd2kgd->init_interrupts(dqm->dev->kgd, i); dqm->dev->kfd2kgd->init_interrupts(dqm->dev->kgd, i);
...@@ -499,8 +482,6 @@ static int initialize_nocpsch(struct device_queue_manager *dqm) ...@@ -499,8 +482,6 @@ static int initialize_nocpsch(struct device_queue_manager *dqm)
{ {
int pipe, queue; int pipe, queue;
BUG_ON(!dqm);
pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm)); pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm));
dqm->allocated_queues = kcalloc(get_pipes_per_mec(dqm), dqm->allocated_queues = kcalloc(get_pipes_per_mec(dqm),
...@@ -532,8 +513,6 @@ static void uninitialize_nocpsch(struct device_queue_manager *dqm) ...@@ -532,8 +513,6 @@ static void uninitialize_nocpsch(struct device_queue_manager *dqm)
{ {
int i; int i;
BUG_ON(!dqm);
BUG_ON(dqm->queue_count > 0 || dqm->processes_count > 0); BUG_ON(dqm->queue_count > 0 || dqm->processes_count > 0);
kfree(dqm->allocated_queues); kfree(dqm->allocated_queues);
...@@ -631,8 +610,6 @@ static int set_sched_resources(struct device_queue_manager *dqm) ...@@ -631,8 +610,6 @@ static int set_sched_resources(struct device_queue_manager *dqm)
int i, mec; int i, mec;
struct scheduling_resources res; struct scheduling_resources res;
BUG_ON(!dqm);
res.vmid_mask = (1 << VMID_PER_DEVICE) - 1; res.vmid_mask = (1 << VMID_PER_DEVICE) - 1;
res.vmid_mask <<= KFD_VMID_START_OFFSET; res.vmid_mask <<= KFD_VMID_START_OFFSET;
...@@ -674,8 +651,6 @@ static int initialize_cpsch(struct device_queue_manager *dqm) ...@@ -674,8 +651,6 @@ static int initialize_cpsch(struct device_queue_manager *dqm)
{ {
int retval; int retval;
BUG_ON(!dqm);
pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm)); pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm));
mutex_init(&dqm->lock); mutex_init(&dqm->lock);
...@@ -695,8 +670,6 @@ static int start_cpsch(struct device_queue_manager *dqm) ...@@ -695,8 +670,6 @@ static int start_cpsch(struct device_queue_manager *dqm)
struct device_process_node *node; struct device_process_node *node;
int retval; int retval;
BUG_ON(!dqm);
retval = 0; retval = 0;
retval = pm_init(&dqm->packets, dqm); retval = pm_init(&dqm->packets, dqm);
...@@ -741,8 +714,6 @@ static int stop_cpsch(struct device_queue_manager *dqm) ...@@ -741,8 +714,6 @@ static int stop_cpsch(struct device_queue_manager *dqm)
struct device_process_node *node; struct device_process_node *node;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
BUG_ON(!dqm);
destroy_queues_cpsch(dqm, true, true); destroy_queues_cpsch(dqm, true, true);
list_for_each_entry(node, &dqm->queues, list) { list_for_each_entry(node, &dqm->queues, list) {
...@@ -759,8 +730,6 @@ static int create_kernel_queue_cpsch(struct device_queue_manager *dqm, ...@@ -759,8 +730,6 @@ static int create_kernel_queue_cpsch(struct device_queue_manager *dqm,
struct kernel_queue *kq, struct kernel_queue *kq,
struct qcm_process_device *qpd) struct qcm_process_device *qpd)
{ {
BUG_ON(!dqm || !kq || !qpd);
mutex_lock(&dqm->lock); mutex_lock(&dqm->lock);
if (dqm->total_queue_count >= max_num_of_queues_per_device) { if (dqm->total_queue_count >= max_num_of_queues_per_device) {
pr_warn("Can't create new kernel queue because %d queues were already created\n", pr_warn("Can't create new kernel queue because %d queues were already created\n",
...@@ -790,8 +759,6 @@ static void destroy_kernel_queue_cpsch(struct device_queue_manager *dqm, ...@@ -790,8 +759,6 @@ static void destroy_kernel_queue_cpsch(struct device_queue_manager *dqm,
struct kernel_queue *kq, struct kernel_queue *kq,
struct qcm_process_device *qpd) struct qcm_process_device *qpd)
{ {
BUG_ON(!dqm || !kq);
mutex_lock(&dqm->lock); mutex_lock(&dqm->lock);
/* here we actually preempt the DIQ */ /* here we actually preempt the DIQ */
destroy_queues_cpsch(dqm, true, false); destroy_queues_cpsch(dqm, true, false);
...@@ -823,8 +790,6 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, ...@@ -823,8 +790,6 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
int retval; int retval;
struct mqd_manager *mqd; struct mqd_manager *mqd;
BUG_ON(!dqm || !q || !qpd);
retval = 0; retval = 0;
if (allocate_vmid) if (allocate_vmid)
...@@ -882,7 +847,6 @@ int amdkfd_fence_wait_timeout(unsigned int *fence_addr, ...@@ -882,7 +847,6 @@ int amdkfd_fence_wait_timeout(unsigned int *fence_addr,
unsigned int fence_value, unsigned int fence_value,
unsigned long timeout) unsigned long timeout)
{ {
BUG_ON(!fence_addr);
timeout += jiffies; timeout += jiffies;
while (*fence_addr != fence_value) { while (*fence_addr != fence_value) {
...@@ -911,8 +875,6 @@ static int destroy_queues_cpsch(struct device_queue_manager *dqm, ...@@ -911,8 +875,6 @@ static int destroy_queues_cpsch(struct device_queue_manager *dqm,
enum kfd_preempt_type_filter preempt_type; enum kfd_preempt_type_filter preempt_type;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
BUG_ON(!dqm);
retval = 0; retval = 0;
if (lock) if (lock)
...@@ -962,8 +924,6 @@ static int execute_queues_cpsch(struct device_queue_manager *dqm, bool lock) ...@@ -962,8 +924,6 @@ static int execute_queues_cpsch(struct device_queue_manager *dqm, bool lock)
{ {
int retval; int retval;
BUG_ON(!dqm);
if (lock) if (lock)
mutex_lock(&dqm->lock); mutex_lock(&dqm->lock);
...@@ -1004,8 +964,6 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm, ...@@ -1004,8 +964,6 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm,
struct mqd_manager *mqd; struct mqd_manager *mqd;
bool preempt_all_queues; bool preempt_all_queues;
BUG_ON(!dqm || !qpd || !q);
preempt_all_queues = false; preempt_all_queues = false;
retval = 0; retval = 0;
...@@ -1131,8 +1089,6 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) ...@@ -1131,8 +1089,6 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
{ {
struct device_queue_manager *dqm; struct device_queue_manager *dqm;
BUG_ON(!dev);
pr_debug("Loading device queue manager\n"); pr_debug("Loading device queue manager\n");
dqm = kzalloc(sizeof(*dqm), GFP_KERNEL); dqm = kzalloc(sizeof(*dqm), GFP_KERNEL);
...@@ -1197,8 +1153,6 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) ...@@ -1197,8 +1153,6 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
void device_queue_manager_uninit(struct device_queue_manager *dqm) void device_queue_manager_uninit(struct device_queue_manager *dqm)
{ {
BUG_ON(!dqm);
dqm->ops.uninitialize(dqm); dqm->ops.uninitialize(dqm);
kfree(dqm); kfree(dqm);
} }
...@@ -104,8 +104,6 @@ static int register_process_cik(struct device_queue_manager *dqm, ...@@ -104,8 +104,6 @@ static int register_process_cik(struct device_queue_manager *dqm,
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
unsigned int temp; unsigned int temp;
BUG_ON(!dqm || !qpd);
pdd = qpd_to_pdd(qpd); pdd = qpd_to_pdd(qpd);
/* check if sh_mem_config register already configured */ /* check if sh_mem_config register already configured */
......
...@@ -110,8 +110,6 @@ static int register_process_vi(struct device_queue_manager *dqm, ...@@ -110,8 +110,6 @@ static int register_process_vi(struct device_queue_manager *dqm,
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
unsigned int temp; unsigned int temp;
BUG_ON(!dqm || !qpd);
pdd = qpd_to_pdd(qpd); pdd = qpd_to_pdd(qpd);
/* check if sh_mem_config register already configured */ /* check if sh_mem_config register already configured */
......
...@@ -165,8 +165,6 @@ u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd, ...@@ -165,8 +165,6 @@ u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
{ {
u32 inx; u32 inx;
BUG_ON(!kfd || !doorbell_off);
mutex_lock(&kfd->doorbell_mutex); mutex_lock(&kfd->doorbell_mutex);
inx = find_first_zero_bit(kfd->doorbell_available_index, inx = find_first_zero_bit(kfd->doorbell_available_index,
KFD_MAX_NUM_OF_QUEUES_PER_PROCESS); KFD_MAX_NUM_OF_QUEUES_PER_PROCESS);
...@@ -196,8 +194,6 @@ void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr) ...@@ -196,8 +194,6 @@ void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr)
{ {
unsigned int inx; unsigned int inx;
BUG_ON(!kfd || !db_addr);
inx = (unsigned int)(db_addr - kfd->doorbell_kernel_ptr); inx = (unsigned int)(db_addr - kfd->doorbell_kernel_ptr);
mutex_lock(&kfd->doorbell_mutex); mutex_lock(&kfd->doorbell_mutex);
......
...@@ -41,7 +41,6 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev, ...@@ -41,7 +41,6 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
int retval; int retval;
union PM4_MES_TYPE_3_HEADER nop; union PM4_MES_TYPE_3_HEADER nop;
BUG_ON(!kq || !dev);
BUG_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ); BUG_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ);
pr_debug("Initializing queue type %d size %d\n", KFD_QUEUE_TYPE_HIQ, pr_debug("Initializing queue type %d size %d\n", KFD_QUEUE_TYPE_HIQ,
...@@ -180,8 +179,6 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev, ...@@ -180,8 +179,6 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
static void uninitialize(struct kernel_queue *kq) static void uninitialize(struct kernel_queue *kq)
{ {
BUG_ON(!kq);
if (kq->queue->properties.type == KFD_QUEUE_TYPE_HIQ) if (kq->queue->properties.type == KFD_QUEUE_TYPE_HIQ)
kq->mqd->destroy_mqd(kq->mqd, kq->mqd->destroy_mqd(kq->mqd,
NULL, NULL,
...@@ -211,8 +208,6 @@ static int acquire_packet_buffer(struct kernel_queue *kq, ...@@ -211,8 +208,6 @@ static int acquire_packet_buffer(struct kernel_queue *kq,
uint32_t wptr, rptr; uint32_t wptr, rptr;
unsigned int *queue_address; unsigned int *queue_address;
BUG_ON(!kq || !buffer_ptr);
rptr = *kq->rptr_kernel; rptr = *kq->rptr_kernel;
wptr = *kq->wptr_kernel; wptr = *kq->wptr_kernel;
queue_address = (unsigned int *)kq->pq_kernel_addr; queue_address = (unsigned int *)kq->pq_kernel_addr;
...@@ -252,11 +247,7 @@ static void submit_packet(struct kernel_queue *kq) ...@@ -252,11 +247,7 @@ static void submit_packet(struct kernel_queue *kq)
{ {
#ifdef DEBUG #ifdef DEBUG
int i; int i;
#endif
BUG_ON(!kq);
#ifdef DEBUG
for (i = *kq->wptr_kernel; i < kq->pending_wptr; i++) { for (i = *kq->wptr_kernel; i < kq->pending_wptr; i++) {
pr_debug("0x%2X ", kq->pq_kernel_addr[i]); pr_debug("0x%2X ", kq->pq_kernel_addr[i]);
if (i % 15 == 0) if (i % 15 == 0)
...@@ -272,7 +263,6 @@ static void submit_packet(struct kernel_queue *kq) ...@@ -272,7 +263,6 @@ static void submit_packet(struct kernel_queue *kq)
static void rollback_packet(struct kernel_queue *kq) static void rollback_packet(struct kernel_queue *kq)
{ {
BUG_ON(!kq);
kq->pending_wptr = *kq->queue->properties.write_ptr; kq->pending_wptr = *kq->queue->properties.write_ptr;
} }
...@@ -281,8 +271,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev, ...@@ -281,8 +271,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
{ {
struct kernel_queue *kq; struct kernel_queue *kq;
BUG_ON(!dev);
kq = kzalloc(sizeof(*kq), GFP_KERNEL); kq = kzalloc(sizeof(*kq), GFP_KERNEL);
if (!kq) if (!kq)
return NULL; return NULL;
...@@ -313,8 +301,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev, ...@@ -313,8 +301,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
void kernel_queue_uninit(struct kernel_queue *kq) void kernel_queue_uninit(struct kernel_queue *kq)
{ {
BUG_ON(!kq);
kq->ops.uninitialize(kq); kq->ops.uninitialize(kq);
kfree(kq); kfree(kq);
} }
...@@ -325,8 +311,6 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev) ...@@ -325,8 +311,6 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
uint32_t *buffer, i; uint32_t *buffer, i;
int retval; int retval;
BUG_ON(!dev);
pr_err("Starting kernel queue test\n"); pr_err("Starting kernel queue test\n");
kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_HIQ); kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_HIQ);
......
...@@ -44,8 +44,6 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, ...@@ -44,8 +44,6 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
struct cik_mqd *m; struct cik_mqd *m;
int retval; int retval;
BUG_ON(!mm || !q || !mqd);
retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd), retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd),
mqd_mem_obj); mqd_mem_obj);
...@@ -113,8 +111,6 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd, ...@@ -113,8 +111,6 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd,
int retval; int retval;
struct cik_sdma_rlc_registers *m; struct cik_sdma_rlc_registers *m;
BUG_ON(!mm || !mqd || !mqd_mem_obj);
retval = kfd_gtt_sa_allocate(mm->dev, retval = kfd_gtt_sa_allocate(mm->dev,
sizeof(struct cik_sdma_rlc_registers), sizeof(struct cik_sdma_rlc_registers),
mqd_mem_obj); mqd_mem_obj);
...@@ -138,14 +134,12 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd, ...@@ -138,14 +134,12 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd,
static void uninit_mqd(struct mqd_manager *mm, void *mqd, static void uninit_mqd(struct mqd_manager *mm, void *mqd,
struct kfd_mem_obj *mqd_mem_obj) struct kfd_mem_obj *mqd_mem_obj)
{ {
BUG_ON(!mm || !mqd);
kfd_gtt_sa_free(mm->dev, mqd_mem_obj); kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
} }
static void uninit_mqd_sdma(struct mqd_manager *mm, void *mqd, static void uninit_mqd_sdma(struct mqd_manager *mm, void *mqd,
struct kfd_mem_obj *mqd_mem_obj) struct kfd_mem_obj *mqd_mem_obj)
{ {
BUG_ON(!mm || !mqd);
kfd_gtt_sa_free(mm->dev, mqd_mem_obj); kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
} }
...@@ -168,8 +162,6 @@ static int update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -168,8 +162,6 @@ static int update_mqd(struct mqd_manager *mm, void *mqd,
{ {
struct cik_mqd *m; struct cik_mqd *m;
BUG_ON(!mm || !q || !mqd);
m = get_mqd(mqd); m = get_mqd(mqd);
m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE | m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE |
DEFAULT_MIN_AVAIL_SIZE | PQ_ATC_EN; DEFAULT_MIN_AVAIL_SIZE | PQ_ATC_EN;
...@@ -209,8 +201,6 @@ static int update_mqd_sdma(struct mqd_manager *mm, void *mqd, ...@@ -209,8 +201,6 @@ static int update_mqd_sdma(struct mqd_manager *mm, void *mqd,
{ {
struct cik_sdma_rlc_registers *m; struct cik_sdma_rlc_registers *m;
BUG_ON(!mm || !mqd || !q);
m = get_sdma_mqd(mqd); m = get_sdma_mqd(mqd);
m->sdma_rlc_rb_cntl = ffs(q->queue_size / sizeof(unsigned int)) << m->sdma_rlc_rb_cntl = ffs(q->queue_size / sizeof(unsigned int)) <<
SDMA0_RLC0_RB_CNTL__RB_SIZE__SHIFT | SDMA0_RLC0_RB_CNTL__RB_SIZE__SHIFT |
...@@ -296,8 +286,6 @@ static int init_mqd_hiq(struct mqd_manager *mm, void **mqd, ...@@ -296,8 +286,6 @@ static int init_mqd_hiq(struct mqd_manager *mm, void **mqd,
struct cik_mqd *m; struct cik_mqd *m;
int retval; int retval;
BUG_ON(!mm || !q || !mqd || !mqd_mem_obj);
retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd), retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd),
mqd_mem_obj); mqd_mem_obj);
...@@ -352,8 +340,6 @@ static int update_mqd_hiq(struct mqd_manager *mm, void *mqd, ...@@ -352,8 +340,6 @@ static int update_mqd_hiq(struct mqd_manager *mm, void *mqd,
{ {
struct cik_mqd *m; struct cik_mqd *m;
BUG_ON(!mm || !q || !mqd);
m = get_mqd(mqd); m = get_mqd(mqd);
m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE | m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE |
DEFAULT_MIN_AVAIL_SIZE | DEFAULT_MIN_AVAIL_SIZE |
...@@ -391,8 +377,6 @@ struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd) ...@@ -391,8 +377,6 @@ struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd)
{ {
struct cik_sdma_rlc_registers *m; struct cik_sdma_rlc_registers *m;
BUG_ON(!mqd);
m = (struct cik_sdma_rlc_registers *)mqd; m = (struct cik_sdma_rlc_registers *)mqd;
return m; return m;
...@@ -403,7 +387,6 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type, ...@@ -403,7 +387,6 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
BUG_ON(!dev);
BUG_ON(type >= KFD_MQD_TYPE_MAX); BUG_ON(type >= KFD_MQD_TYPE_MAX);
mqd = kzalloc(sizeof(*mqd), GFP_KERNEL); mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
......
...@@ -106,8 +106,6 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd, ...@@ -106,8 +106,6 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
{ {
struct vi_mqd *m; struct vi_mqd *m;
BUG_ON(!mm || !q || !mqd);
m = get_mqd(mqd); m = get_mqd(mqd);
m->cp_hqd_pq_control = 5 << CP_HQD_PQ_CONTROL__RPTR_BLOCK_SIZE__SHIFT | m->cp_hqd_pq_control = 5 << CP_HQD_PQ_CONTROL__RPTR_BLOCK_SIZE__SHIFT |
...@@ -186,7 +184,6 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd, ...@@ -186,7 +184,6 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd,
static void uninit_mqd(struct mqd_manager *mm, void *mqd, static void uninit_mqd(struct mqd_manager *mm, void *mqd,
struct kfd_mem_obj *mqd_mem_obj) struct kfd_mem_obj *mqd_mem_obj)
{ {
BUG_ON(!mm || !mqd);
kfd_gtt_sa_free(mm->dev, mqd_mem_obj); kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
} }
...@@ -236,7 +233,6 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, ...@@ -236,7 +233,6 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
{ {
struct mqd_manager *mqd; struct mqd_manager *mqd;
BUG_ON(!dev);
BUG_ON(type >= KFD_MQD_TYPE_MAX); BUG_ON(type >= KFD_MQD_TYPE_MAX);
mqd = kzalloc(sizeof(*mqd), GFP_KERNEL); mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
......
...@@ -58,8 +58,6 @@ static void pm_calc_rlib_size(struct packet_manager *pm, ...@@ -58,8 +58,6 @@ static void pm_calc_rlib_size(struct packet_manager *pm,
unsigned int process_count, queue_count; unsigned int process_count, queue_count;
unsigned int map_queue_size; unsigned int map_queue_size;
BUG_ON(!pm || !rlib_size || !over_subscription);
process_count = pm->dqm->processes_count; process_count = pm->dqm->processes_count;
queue_count = pm->dqm->queue_count; queue_count = pm->dqm->queue_count;
...@@ -96,9 +94,7 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm, ...@@ -96,9 +94,7 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm,
{ {
int retval; int retval;
BUG_ON(!pm);
BUG_ON(pm->allocated); BUG_ON(pm->allocated);
BUG_ON(!is_over_subscription);
pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription); pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription);
...@@ -123,7 +119,7 @@ static int pm_create_runlist(struct packet_manager *pm, uint32_t *buffer, ...@@ -123,7 +119,7 @@ static int pm_create_runlist(struct packet_manager *pm, uint32_t *buffer,
{ {
struct pm4_runlist *packet; struct pm4_runlist *packet;
BUG_ON(!pm || !buffer || !ib); BUG_ON(!ib);
packet = (struct pm4_runlist *)buffer; packet = (struct pm4_runlist *)buffer;
...@@ -148,8 +144,6 @@ static int pm_create_map_process(struct packet_manager *pm, uint32_t *buffer, ...@@ -148,8 +144,6 @@ static int pm_create_map_process(struct packet_manager *pm, uint32_t *buffer,
struct queue *cur; struct queue *cur;
uint32_t num_queues; uint32_t num_queues;
BUG_ON(!pm || !buffer || !qpd);
packet = (struct pm4_map_process *)buffer; packet = (struct pm4_map_process *)buffer;
memset(buffer, 0, sizeof(struct pm4_map_process)); memset(buffer, 0, sizeof(struct pm4_map_process));
...@@ -185,8 +179,6 @@ static int pm_create_map_queue_vi(struct packet_manager *pm, uint32_t *buffer, ...@@ -185,8 +179,6 @@ static int pm_create_map_queue_vi(struct packet_manager *pm, uint32_t *buffer,
struct pm4_mes_map_queues *packet; struct pm4_mes_map_queues *packet;
bool use_static = is_static; bool use_static = is_static;
BUG_ON(!pm || !buffer || !q);
packet = (struct pm4_mes_map_queues *)buffer; packet = (struct pm4_mes_map_queues *)buffer;
memset(buffer, 0, sizeof(struct pm4_map_queues)); memset(buffer, 0, sizeof(struct pm4_map_queues));
...@@ -247,8 +239,6 @@ static int pm_create_map_queue(struct packet_manager *pm, uint32_t *buffer, ...@@ -247,8 +239,6 @@ static int pm_create_map_queue(struct packet_manager *pm, uint32_t *buffer,
struct pm4_map_queues *packet; struct pm4_map_queues *packet;
bool use_static = is_static; bool use_static = is_static;
BUG_ON(!pm || !buffer || !q);
packet = (struct pm4_map_queues *)buffer; packet = (struct pm4_map_queues *)buffer;
memset(buffer, 0, sizeof(struct pm4_map_queues)); memset(buffer, 0, sizeof(struct pm4_map_queues));
...@@ -315,8 +305,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm, ...@@ -315,8 +305,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
struct kernel_queue *kq; struct kernel_queue *kq;
bool is_over_subscription; bool is_over_subscription;
BUG_ON(!pm || !queues || !rl_size_bytes || !rl_gpu_addr);
rl_wptr = retval = proccesses_mapped = 0; rl_wptr = retval = proccesses_mapped = 0;
retval = pm_allocate_runlist_ib(pm, &rl_buffer, rl_gpu_addr, retval = pm_allocate_runlist_ib(pm, &rl_buffer, rl_gpu_addr,
...@@ -416,8 +404,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm, ...@@ -416,8 +404,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm) int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm)
{ {
BUG_ON(!dqm);
pm->dqm = dqm; pm->dqm = dqm;
mutex_init(&pm->lock); mutex_init(&pm->lock);
pm->priv_queue = kernel_queue_init(dqm->dev, KFD_QUEUE_TYPE_HIQ); pm->priv_queue = kernel_queue_init(dqm->dev, KFD_QUEUE_TYPE_HIQ);
...@@ -432,8 +418,6 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm) ...@@ -432,8 +418,6 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm)
void pm_uninit(struct packet_manager *pm) void pm_uninit(struct packet_manager *pm)
{ {
BUG_ON(!pm);
mutex_destroy(&pm->lock); mutex_destroy(&pm->lock);
kernel_queue_uninit(pm->priv_queue); kernel_queue_uninit(pm->priv_queue);
} }
...@@ -444,8 +428,6 @@ int pm_send_set_resources(struct packet_manager *pm, ...@@ -444,8 +428,6 @@ int pm_send_set_resources(struct packet_manager *pm,
struct pm4_set_resources *packet; struct pm4_set_resources *packet;
int retval = 0; int retval = 0;
BUG_ON(!pm || !res);
mutex_lock(&pm->lock); mutex_lock(&pm->lock);
pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue, pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
sizeof(*packet) / sizeof(uint32_t), sizeof(*packet) / sizeof(uint32_t),
...@@ -489,8 +471,6 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues) ...@@ -489,8 +471,6 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
size_t rl_ib_size, packet_size_dwords; size_t rl_ib_size, packet_size_dwords;
int retval; int retval;
BUG_ON(!pm || !dqm_queues);
retval = pm_create_runlist_ib(pm, dqm_queues, &rl_gpu_ib_addr, retval = pm_create_runlist_ib(pm, dqm_queues, &rl_gpu_ib_addr,
&rl_ib_size); &rl_ib_size);
if (retval) if (retval)
...@@ -532,7 +512,7 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address, ...@@ -532,7 +512,7 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
int retval; int retval;
struct pm4_query_status *packet; struct pm4_query_status *packet;
BUG_ON(!pm || !fence_address); BUG_ON(!fence_address);
mutex_lock(&pm->lock); mutex_lock(&pm->lock);
retval = pm->priv_queue->ops.acquire_packet_buffer( retval = pm->priv_queue->ops.acquire_packet_buffer(
...@@ -572,8 +552,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type, ...@@ -572,8 +552,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
uint32_t *buffer; uint32_t *buffer;
struct pm4_unmap_queues *packet; struct pm4_unmap_queues *packet;
BUG_ON(!pm);
mutex_lock(&pm->lock); mutex_lock(&pm->lock);
retval = pm->priv_queue->ops.acquire_packet_buffer( retval = pm->priv_queue->ops.acquire_packet_buffer(
pm->priv_queue, pm->priv_queue,
...@@ -645,8 +623,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type, ...@@ -645,8 +623,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
void pm_release_ib(struct packet_manager *pm) void pm_release_ib(struct packet_manager *pm)
{ {
BUG_ON(!pm);
mutex_lock(&pm->lock); mutex_lock(&pm->lock);
if (pm->allocated) { if (pm->allocated) {
kfd_gtt_sa_free(pm->dqm->dev, pm->ib_buffer_obj); kfd_gtt_sa_free(pm->dqm->dev, pm->ib_buffer_obj);
......
...@@ -407,8 +407,6 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid) ...@@ -407,8 +407,6 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
struct kfd_process *p; struct kfd_process *p;
struct kfd_process_device *pdd; struct kfd_process_device *pdd;
BUG_ON(!dev);
/* /*
* Look for the process that matches the pasid. If there is no such * Look for the process that matches the pasid. If there is no such
* process, we either released it in amdkfd's own notifier, or there * process, we either released it in amdkfd's own notifier, or there
......
...@@ -32,8 +32,6 @@ static inline struct process_queue_node *get_queue_by_qid( ...@@ -32,8 +32,6 @@ static inline struct process_queue_node *get_queue_by_qid(
{ {
struct process_queue_node *pqn; struct process_queue_node *pqn;
BUG_ON(!pqm);
list_for_each_entry(pqn, &pqm->queues, process_queue_list) { list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
if ((pqn->q && pqn->q->properties.queue_id == qid) || if ((pqn->q && pqn->q->properties.queue_id == qid) ||
(pqn->kq && pqn->kq->queue->properties.queue_id == qid)) (pqn->kq && pqn->kq->queue->properties.queue_id == qid))
...@@ -48,8 +46,6 @@ static int find_available_queue_slot(struct process_queue_manager *pqm, ...@@ -48,8 +46,6 @@ static int find_available_queue_slot(struct process_queue_manager *pqm,
{ {
unsigned long found; unsigned long found;
BUG_ON(!pqm || !qid);
found = find_first_zero_bit(pqm->queue_slot_bitmap, found = find_first_zero_bit(pqm->queue_slot_bitmap,
KFD_MAX_NUM_OF_QUEUES_PER_PROCESS); KFD_MAX_NUM_OF_QUEUES_PER_PROCESS);
...@@ -69,8 +65,6 @@ static int find_available_queue_slot(struct process_queue_manager *pqm, ...@@ -69,8 +65,6 @@ static int find_available_queue_slot(struct process_queue_manager *pqm,
int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p) int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p)
{ {
BUG_ON(!pqm);
INIT_LIST_HEAD(&pqm->queues); INIT_LIST_HEAD(&pqm->queues);
pqm->queue_slot_bitmap = pqm->queue_slot_bitmap =
kzalloc(DIV_ROUND_UP(KFD_MAX_NUM_OF_QUEUES_PER_PROCESS, kzalloc(DIV_ROUND_UP(KFD_MAX_NUM_OF_QUEUES_PER_PROCESS,
...@@ -87,8 +81,6 @@ void pqm_uninit(struct process_queue_manager *pqm) ...@@ -87,8 +81,6 @@ void pqm_uninit(struct process_queue_manager *pqm)
int retval; int retval;
struct process_queue_node *pqn, *next; struct process_queue_node *pqn, *next;
BUG_ON(!pqm);
list_for_each_entry_safe(pqn, next, &pqm->queues, process_queue_list) { list_for_each_entry_safe(pqn, next, &pqm->queues, process_queue_list) {
retval = pqm_destroy_queue( retval = pqm_destroy_queue(
pqm, pqm,
...@@ -151,8 +143,6 @@ int pqm_create_queue(struct process_queue_manager *pqm, ...@@ -151,8 +143,6 @@ int pqm_create_queue(struct process_queue_manager *pqm,
int num_queues = 0; int num_queues = 0;
struct queue *cur; struct queue *cur;
BUG_ON(!pqm || !dev || !properties || !qid);
memset(&q_properties, 0, sizeof(struct queue_properties)); memset(&q_properties, 0, sizeof(struct queue_properties));
memcpy(&q_properties, properties, sizeof(struct queue_properties)); memcpy(&q_properties, properties, sizeof(struct queue_properties));
q = NULL; q = NULL;
...@@ -269,7 +259,6 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid) ...@@ -269,7 +259,6 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
dqm = NULL; dqm = NULL;
BUG_ON(!pqm);
retval = 0; retval = 0;
pqn = get_queue_by_qid(pqm, qid); pqn = get_queue_by_qid(pqm, qid);
...@@ -323,8 +312,6 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid, ...@@ -323,8 +312,6 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
int retval; int retval;
struct process_queue_node *pqn; struct process_queue_node *pqn;
BUG_ON(!pqm);
pqn = get_queue_by_qid(pqm, qid); pqn = get_queue_by_qid(pqm, qid);
if (!pqn) { if (!pqn) {
pr_debug("No queue %d exists for update operation\n", qid); pr_debug("No queue %d exists for update operation\n", qid);
...@@ -350,8 +337,6 @@ struct kernel_queue *pqm_get_kernel_queue( ...@@ -350,8 +337,6 @@ struct kernel_queue *pqm_get_kernel_queue(
{ {
struct process_queue_node *pqn; struct process_queue_node *pqn;
BUG_ON(!pqm);
pqn = get_queue_by_qid(pqm, qid); pqn = get_queue_by_qid(pqm, qid);
if (pqn && pqn->kq) if (pqn && pqn->kq)
return pqn->kq; return pqn->kq;
......
...@@ -67,8 +67,6 @@ int init_queue(struct queue **q, const struct queue_properties *properties) ...@@ -67,8 +67,6 @@ int init_queue(struct queue **q, const struct queue_properties *properties)
{ {
struct queue *tmp_q; struct queue *tmp_q;
BUG_ON(!q);
tmp_q = kzalloc(sizeof(*tmp_q), GFP_KERNEL); tmp_q = kzalloc(sizeof(*tmp_q), GFP_KERNEL);
if (!tmp_q) if (!tmp_q)
return -ENOMEM; return -ENOMEM;
......
...@@ -108,9 +108,6 @@ static int kfd_topology_get_crat_acpi(void *crat_image, size_t *size) ...@@ -108,9 +108,6 @@ static int kfd_topology_get_crat_acpi(void *crat_image, size_t *size)
static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev, static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev,
struct crat_subtype_computeunit *cu) struct crat_subtype_computeunit *cu)
{ {
BUG_ON(!dev);
BUG_ON(!cu);
dev->node_props.cpu_cores_count = cu->num_cpu_cores; dev->node_props.cpu_cores_count = cu->num_cpu_cores;
dev->node_props.cpu_core_id_base = cu->processor_id_low; dev->node_props.cpu_core_id_base = cu->processor_id_low;
if (cu->hsa_capability & CRAT_CU_FLAGS_IOMMU_PRESENT) if (cu->hsa_capability & CRAT_CU_FLAGS_IOMMU_PRESENT)
...@@ -123,9 +120,6 @@ static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev, ...@@ -123,9 +120,6 @@ static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev,
static void kfd_populated_cu_info_gpu(struct kfd_topology_device *dev, static void kfd_populated_cu_info_gpu(struct kfd_topology_device *dev,
struct crat_subtype_computeunit *cu) struct crat_subtype_computeunit *cu)
{ {
BUG_ON(!dev);
BUG_ON(!cu);
dev->node_props.simd_id_base = cu->processor_id_low; dev->node_props.simd_id_base = cu->processor_id_low;
dev->node_props.simd_count = cu->num_simd_cores; dev->node_props.simd_count = cu->num_simd_cores;
dev->node_props.lds_size_in_kb = cu->lds_size_in_kb; dev->node_props.lds_size_in_kb = cu->lds_size_in_kb;
...@@ -148,8 +142,6 @@ static int kfd_parse_subtype_cu(struct crat_subtype_computeunit *cu) ...@@ -148,8 +142,6 @@ static int kfd_parse_subtype_cu(struct crat_subtype_computeunit *cu)
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
int i = 0; int i = 0;
BUG_ON(!cu);
pr_info("Found CU entry in CRAT table with proximity_domain=%d caps=%x\n", pr_info("Found CU entry in CRAT table with proximity_domain=%d caps=%x\n",
cu->proximity_domain, cu->hsa_capability); cu->proximity_domain, cu->hsa_capability);
list_for_each_entry(dev, &topology_device_list, list) { list_for_each_entry(dev, &topology_device_list, list) {
...@@ -177,8 +169,6 @@ static int kfd_parse_subtype_mem(struct crat_subtype_memory *mem) ...@@ -177,8 +169,6 @@ static int kfd_parse_subtype_mem(struct crat_subtype_memory *mem)
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
int i = 0; int i = 0;
BUG_ON(!mem);
pr_info("Found memory entry in CRAT table with proximity_domain=%d\n", pr_info("Found memory entry in CRAT table with proximity_domain=%d\n",
mem->promixity_domain); mem->promixity_domain);
list_for_each_entry(dev, &topology_device_list, list) { list_for_each_entry(dev, &topology_device_list, list) {
...@@ -223,8 +213,6 @@ static int kfd_parse_subtype_cache(struct crat_subtype_cache *cache) ...@@ -223,8 +213,6 @@ static int kfd_parse_subtype_cache(struct crat_subtype_cache *cache)
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
uint32_t id; uint32_t id;
BUG_ON(!cache);
id = cache->processor_id_low; id = cache->processor_id_low;
pr_info("Found cache entry in CRAT table with processor_id=%d\n", id); pr_info("Found cache entry in CRAT table with processor_id=%d\n", id);
...@@ -274,8 +262,6 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink) ...@@ -274,8 +262,6 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink)
uint32_t id_from; uint32_t id_from;
uint32_t id_to; uint32_t id_to;
BUG_ON(!iolink);
id_from = iolink->proximity_domain_from; id_from = iolink->proximity_domain_from;
id_to = iolink->proximity_domain_to; id_to = iolink->proximity_domain_to;
...@@ -323,8 +309,6 @@ static int kfd_parse_subtype(struct crat_subtype_generic *sub_type_hdr) ...@@ -323,8 +309,6 @@ static int kfd_parse_subtype(struct crat_subtype_generic *sub_type_hdr)
struct crat_subtype_iolink *iolink; struct crat_subtype_iolink *iolink;
int ret = 0; int ret = 0;
BUG_ON(!sub_type_hdr);
switch (sub_type_hdr->type) { switch (sub_type_hdr->type) {
case CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY: case CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY:
cu = (struct crat_subtype_computeunit *)sub_type_hdr; cu = (struct crat_subtype_computeunit *)sub_type_hdr;
...@@ -368,8 +352,6 @@ static void kfd_release_topology_device(struct kfd_topology_device *dev) ...@@ -368,8 +352,6 @@ static void kfd_release_topology_device(struct kfd_topology_device *dev)
struct kfd_cache_properties *cache; struct kfd_cache_properties *cache;
struct kfd_iolink_properties *iolink; struct kfd_iolink_properties *iolink;
BUG_ON(!dev);
list_del(&dev->list); list_del(&dev->list);
while (dev->mem_props.next != &dev->mem_props) { while (dev->mem_props.next != &dev->mem_props) {
...@@ -763,8 +745,6 @@ static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev) ...@@ -763,8 +745,6 @@ static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev)
struct kfd_cache_properties *cache; struct kfd_cache_properties *cache;
struct kfd_mem_properties *mem; struct kfd_mem_properties *mem;
BUG_ON(!dev);
if (dev->kobj_iolink) { if (dev->kobj_iolink) {
list_for_each_entry(iolink, &dev->io_link_props, list) list_for_each_entry(iolink, &dev->io_link_props, list)
if (iolink->kobj) { if (iolink->kobj) {
...@@ -819,8 +799,6 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev, ...@@ -819,8 +799,6 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
int ret; int ret;
uint32_t i; uint32_t i;
BUG_ON(!dev);
/* /*
* Creating the sysfs folders * Creating the sysfs folders
*/ */
...@@ -1117,8 +1095,6 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu) ...@@ -1117,8 +1095,6 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
struct kfd_topology_device *out_dev = NULL; struct kfd_topology_device *out_dev = NULL;
BUG_ON(!gpu);
list_for_each_entry(dev, &topology_device_list, list) list_for_each_entry(dev, &topology_device_list, list)
if (!dev->gpu && (dev->node_props.simd_count > 0)) { if (!dev->gpu && (dev->node_props.simd_count > 0)) {
dev->gpu = gpu; dev->gpu = gpu;
...@@ -1143,8 +1119,6 @@ int kfd_topology_add_device(struct kfd_dev *gpu) ...@@ -1143,8 +1119,6 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
struct kfd_topology_device *dev; struct kfd_topology_device *dev;
int res; int res;
BUG_ON(!gpu);
gpu_id = kfd_generate_gpu_id(gpu); gpu_id = kfd_generate_gpu_id(gpu);
pr_debug("Adding new GPU (ID: 0x%x) to topology\n", gpu_id); pr_debug("Adding new GPU (ID: 0x%x) to topology\n", gpu_id);
...@@ -1210,8 +1184,6 @@ int kfd_topology_remove_device(struct kfd_dev *gpu) ...@@ -1210,8 +1184,6 @@ int kfd_topology_remove_device(struct kfd_dev *gpu)
uint32_t gpu_id; uint32_t gpu_id;
int res = -ENODEV; int res = -ENODEV;
BUG_ON(!gpu);
down_write(&topology_lock); down_write(&topology_lock);
list_for_each_entry(dev, &topology_device_list, list) list_for_each_entry(dev, &topology_device_list, list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment