77#include <linux/module.h>
88#include <linux/pci.h>
99#include <linux/pm_runtime.h>
10- #include <generated/utsrelease.h>
1110
1211#include <drm/drm_accel.h>
1312#include <drm/drm_file.h>
1413#include <drm/drm_gem.h>
1514#include <drm/drm_ioctl.h>
1615#include <drm/drm_prime.h>
1716
18- #include "ivpu_coredump .h"
17+ #include "vpu_boot_api .h"
1918#include "ivpu_debugfs.h"
2019#include "ivpu_drv.h"
2120#include "ivpu_fw.h"
3029#include "ivpu_ms.h"
3130#include "ivpu_pm.h"
3231#include "ivpu_sysfs.h"
33- #include "vpu_boot_api.h"
3432
3533#ifndef DRIVER_VERSION_STR
36- #define DRIVER_VERSION_STR "1.0.0 " UTS_RELEASE
34+ #define DRIVER_VERSION_STR __stringify(DRM_IVPU_DRIVER_MAJOR) "." \
35+ __stringify(DRM_IVPU_DRIVER_MINOR) "."
3736#endif
3837
3938static struct lock_class_key submitted_jobs_xa_lock_class_key ;
@@ -43,10 +42,8 @@ module_param_named(dbg_mask, ivpu_dbg_mask, int, 0644);
4342MODULE_PARM_DESC (dbg_mask , "Driver debug mask. See IVPU_DBG_* macros." );
4443
4544int ivpu_test_mode ;
46- #if IS_ENABLED (CONFIG_DRM_ACCEL_IVPU_DEBUG )
4745module_param_named_unsafe (test_mode , ivpu_test_mode , int , 0644 );
4846MODULE_PARM_DESC (test_mode , "Test mode mask. See IVPU_TEST_MODE_* macros." );
49- #endif
5047
5148u8 ivpu_pll_min_ratio ;
5249module_param_named (pll_min_ratio , ivpu_pll_min_ratio , byte , 0644 );
@@ -56,9 +53,9 @@ u8 ivpu_pll_max_ratio = U8_MAX;
5653module_param_named (pll_max_ratio , ivpu_pll_max_ratio , byte , 0644 );
5754MODULE_PARM_DESC (pll_max_ratio , "Maximum PLL ratio used to set NPU frequency" );
5855
59- int ivpu_sched_mode = IVPU_SCHED_MODE_AUTO ;
56+ int ivpu_sched_mode ;
6057module_param_named (sched_mode , ivpu_sched_mode , int , 0444 );
61- MODULE_PARM_DESC (sched_mode , "Scheduler mode: -1 - Use default scheduler, 0 - Use OS scheduler, 1 - Use HW scheduler" );
58+ MODULE_PARM_DESC (sched_mode , "Scheduler mode: 0 - Default scheduler, 1 - Force HW scheduler" );
6259
6360bool ivpu_disable_mmu_cont_pages ;
6461module_param_named (disable_mmu_cont_pages , ivpu_disable_mmu_cont_pages , bool , 0444 );
@@ -106,8 +103,6 @@ static void file_priv_release(struct kref *ref)
106103 pm_runtime_get_sync (vdev -> drm .dev );
107104 mutex_lock (& vdev -> context_list_lock );
108105 file_priv_unbind (vdev , file_priv );
109- drm_WARN_ON (& vdev -> drm , !xa_empty (& file_priv -> cmdq_xa ));
110- xa_destroy (& file_priv -> cmdq_xa );
111106 mutex_unlock (& vdev -> context_list_lock );
112107 pm_runtime_put_autosuspend (vdev -> drm .dev );
113108
@@ -121,6 +116,8 @@ void ivpu_file_priv_put(struct ivpu_file_priv **link)
121116 struct ivpu_file_priv * file_priv = * link ;
122117 struct ivpu_device * vdev = file_priv -> vdev ;
123118
119+ drm_WARN_ON (& vdev -> drm , !file_priv );
120+
124121 ivpu_dbg (vdev , KREF , "file_priv put: ctx %u refcount %u\n" ,
125122 file_priv -> ctx .id , kref_read (& file_priv -> ref ));
126123
@@ -260,13 +257,6 @@ static int ivpu_open(struct drm_device *dev, struct drm_file *file)
260257
261258 ivpu_mmu_context_init (vdev , & file_priv -> ctx , ctx_id );
262259
263- file_priv -> job_limit .min = FIELD_PREP (IVPU_JOB_ID_CONTEXT_MASK , (file_priv -> ctx .id - 1 ));
264- file_priv -> job_limit .max = file_priv -> job_limit .min | IVPU_JOB_ID_JOB_MASK ;
265-
266- xa_init_flags (& file_priv -> cmdq_xa , XA_FLAGS_ALLOC1 );
267- file_priv -> cmdq_limit .min = IVPU_CMDQ_MIN_ID ;
268- file_priv -> cmdq_limit .max = IVPU_CMDQ_MAX_ID ;
269-
270260 mutex_unlock (& vdev -> context_list_lock );
271261 drm_dev_exit (idx );
272262
@@ -352,7 +342,7 @@ static int ivpu_hw_sched_init(struct ivpu_device *vdev)
352342{
353343 int ret = 0 ;
354344
355- if (vdev -> fw -> sched_mode == VPU_SCHEDULING_MODE_HW ) {
345+ if (vdev -> hw -> sched_mode == VPU_SCHEDULING_MODE_HW ) {
356346 ret = ivpu_jsm_hws_setup_priority_bands (vdev );
357347 if (ret ) {
358348 ivpu_err (vdev , "Failed to enable hw scheduler: %d" , ret );
@@ -386,7 +376,10 @@ int ivpu_boot(struct ivpu_device *vdev)
386376 ret = ivpu_wait_for_ready (vdev );
387377 if (ret ) {
388378 ivpu_err (vdev , "Failed to boot the firmware: %d\n" , ret );
389- goto err_diagnose_failure ;
379+ ivpu_hw_diagnose_failure (vdev );
380+ ivpu_mmu_evtq_dump (vdev );
381+ ivpu_fw_log_dump (vdev );
382+ return ret ;
390383 }
391384
392385 ivpu_hw_irq_clear (vdev );
@@ -397,20 +390,12 @@ int ivpu_boot(struct ivpu_device *vdev)
397390 if (ivpu_fw_is_cold_boot (vdev )) {
398391 ret = ivpu_pm_dct_init (vdev );
399392 if (ret )
400- goto err_diagnose_failure ;
393+ return ret ;
401394
402- ret = ivpu_hw_sched_init (vdev );
403- if (ret )
404- goto err_diagnose_failure ;
395+ return ivpu_hw_sched_init (vdev );
405396 }
406397
407398 return 0 ;
408-
409- err_diagnose_failure :
410- ivpu_hw_diagnose_failure (vdev );
411- ivpu_mmu_evtq_dump (vdev );
412- ivpu_dev_coredump (vdev );
413- return ret ;
414399}
415400
416401void ivpu_prepare_for_reset (struct ivpu_device * vdev )
@@ -457,8 +442,8 @@ static const struct drm_driver driver = {
457442
458443 .name = DRIVER_NAME ,
459444 .desc = DRIVER_DESC ,
460-
461- .major = 1 ,
445+ . major = DRM_IVPU_DRIVER_MAJOR ,
446+ .minor = DRM_IVPU_DRIVER_MINOR ,
462447};
463448
464449static void ivpu_context_abort_invalid (struct ivpu_device * vdev )
@@ -616,9 +601,6 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
616601 lockdep_set_class (& vdev -> submitted_jobs_xa .xa_lock , & submitted_jobs_xa_lock_class_key );
617602 INIT_LIST_HEAD (& vdev -> bo_list );
618603
619- vdev -> db_limit .min = IVPU_MIN_DB ;
620- vdev -> db_limit .max = IVPU_MAX_DB ;
621-
622604 ret = drmm_mutex_init (& vdev -> drm , & vdev -> context_list_lock );
623605 if (ret )
624606 goto err_xa_destroy ;
0 commit comments