Skip to content

Commit 96c28dd

Browse files
jsunintelsysopenci
authored andcommitted
Revert NPU FW5.0 Kernel Driver upgrading patches
From Commit df8ec74 to Commit 1f3bded Tracked-On: OAM-134080 Signed-off-by: Sun, Jing <jing.a.sun@intel.com>
1 parent 1f3bded commit 96c28dd

31 files changed

Lines changed: 343 additions & 847 deletions

drivers/accel/ivpu/Kconfig

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,10 @@ config DRM_ACCEL_IVPU
88
select FW_LOADER
99
select DRM_GEM_SHMEM_HELPER
1010
select GENERIC_ALLOCATOR
11-
select WANT_DEV_COREDUMP
1211
help
1312
Choose this option if you have a system with an 14th generation
1413
Intel CPU (Meteor Lake) or newer. Intel NPU (formerly called Intel VPU)
1514
is a CPU-integrated inference accelerator for Computer Vision
1615
and Deep Learning applications.
1716

1817
If "M" is selected, the module will be called intel_vpu.
19-
20-
config DRM_ACCEL_IVPU_DEBUG
21-
bool "Intel NPU debug mode"
22-
depends on DRM_ACCEL_IVPU
23-
help
24-
Choose this option to enable additional
25-
debug features for the Intel NPU driver:
26-
- Always print debug messages regardless of dyndbg config,
27-
- Enable unsafe module params.

drivers/accel/ivpu/Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@ intel_vpu-y := \
1616
ivpu_mmu_context.o \
1717
ivpu_ms.o \
1818
ivpu_pm.o \
19-
ivpu_sysfs.o \
20-
ivpu_trace_points.o
19+
ivpu_sysfs.o
2120

2221
intel_vpu-$(CONFIG_DEBUG_FS) += ivpu_debugfs.o
23-
intel_vpu-$(CONFIG_DEV_COREDUMP) += ivpu_coredump.o
2422

2523
obj-$(CONFIG_DRM_ACCEL_IVPU) += intel_vpu.o
26-
27-
subdir-ccflags-$(CONFIG_DRM_ACCEL_IVPU_DEBUG) += -DDEBUG
28-
29-
CFLAGS_ivpu_trace_points.o = -I$(src)

drivers/accel/ivpu/ivpu_coredump.c

Lines changed: 0 additions & 39 deletions
This file was deleted.

drivers/accel/ivpu/ivpu_coredump.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

drivers/accel/ivpu/ivpu_debugfs.c

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ static int fw_name_show(struct seq_file *s, void *v)
4545
return 0;
4646
}
4747

48-
static int fw_version_show(struct seq_file *s, void *v)
49-
{
50-
struct ivpu_device *vdev = seq_to_ivpu(s);
51-
52-
seq_printf(s, "%s\n", vdev->fw->version);
53-
return 0;
54-
}
55-
5648
static int fw_trace_capability_show(struct seq_file *s, void *v)
5749
{
5850
struct ivpu_device *vdev = seq_to_ivpu(s);
@@ -127,7 +119,6 @@ static int firewall_irq_counter_show(struct seq_file *s, void *v)
127119
static const struct drm_debugfs_info vdev_debugfs_list[] = {
128120
{"bo_list", bo_list_show, 0},
129121
{"fw_name", fw_name_show, 0},
130-
{"fw_version", fw_version_show, 0},
131122
{"fw_trace_capability", fw_trace_capability_show, 0},
132123
{"fw_trace_config", fw_trace_config_show, 0},
133124
{"last_bootmode", last_bootmode_show, 0},
@@ -136,23 +127,32 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
136127
{"firewall_irq_counter", firewall_irq_counter_show, 0},
137128
};
138129

139-
static int dvfs_mode_get(void *data, u64 *dvfs_mode)
130+
static ssize_t
131+
dvfs_mode_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
140132
{
141-
struct ivpu_device *vdev = (struct ivpu_device *)data;
133+
struct ivpu_device *vdev = file->private_data;
134+
struct ivpu_fw_info *fw = vdev->fw;
135+
u32 dvfs_mode;
136+
int ret;
142137

143-
*dvfs_mode = vdev->fw->dvfs_mode;
144-
return 0;
145-
}
138+
ret = kstrtou32_from_user(user_buf, size, 0, &dvfs_mode);
139+
if (ret < 0)
140+
return ret;
146141

147-
static int dvfs_mode_set(void *data, u64 dvfs_mode)
148-
{
149-
struct ivpu_device *vdev = (struct ivpu_device *)data;
142+
fw->dvfs_mode = dvfs_mode;
150143

151-
vdev->fw->dvfs_mode = (u32)dvfs_mode;
152-
return pci_try_reset_function(to_pci_dev(vdev->drm.dev));
144+
ret = pci_try_reset_function(to_pci_dev(vdev->drm.dev));
145+
if (ret)
146+
return ret;
147+
148+
return size;
153149
}
154150

155-
DEFINE_DEBUGFS_ATTRIBUTE(dvfs_mode_fops, dvfs_mode_get, dvfs_mode_set, "%llu\n");
151+
static const struct file_operations dvfs_mode_fops = {
152+
.owner = THIS_MODULE,
153+
.open = simple_open,
154+
.write = dvfs_mode_fops_write,
155+
};
156156

157157
static ssize_t
158158
fw_dyndbg_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
@@ -201,7 +201,7 @@ fw_log_fops_write(struct file *file, const char __user *user_buf, size_t size, l
201201
if (!size)
202202
return -EINVAL;
203203

204-
ivpu_fw_log_mark_read(vdev);
204+
ivpu_fw_log_clear(vdev);
205205
return size;
206206
}
207207

@@ -346,23 +346,49 @@ static const struct file_operations ivpu_force_recovery_fops = {
346346
.write = ivpu_force_recovery_fn,
347347
};
348348

349-
static int ivpu_reset_engine_fn(void *data, u64 val)
349+
static ssize_t
350+
ivpu_reset_engine_fn(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
350351
{
351-
struct ivpu_device *vdev = (struct ivpu_device *)data;
352+
struct ivpu_device *vdev = file->private_data;
353+
354+
if (!size)
355+
return -EINVAL;
352356

353-
return ivpu_jsm_reset_engine(vdev, (u32)val);
357+
if (ivpu_jsm_reset_engine(vdev, DRM_IVPU_ENGINE_COMPUTE))
358+
return -ENODEV;
359+
if (ivpu_jsm_reset_engine(vdev, DRM_IVPU_ENGINE_COPY))
360+
return -ENODEV;
361+
362+
return size;
354363
}
355364

356-
DEFINE_DEBUGFS_ATTRIBUTE(ivpu_reset_engine_fops, NULL, ivpu_reset_engine_fn, "0x%02llx\n");
365+
static const struct file_operations ivpu_reset_engine_fops = {
366+
.owner = THIS_MODULE,
367+
.open = simple_open,
368+
.write = ivpu_reset_engine_fn,
369+
};
357370

358-
static int ivpu_resume_engine_fn(void *data, u64 val)
371+
static ssize_t
372+
ivpu_resume_engine_fn(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
359373
{
360-
struct ivpu_device *vdev = (struct ivpu_device *)data;
374+
struct ivpu_device *vdev = file->private_data;
375+
376+
if (!size)
377+
return -EINVAL;
361378

362-
return ivpu_jsm_hws_resume_engine(vdev, (u32)val);
379+
if (ivpu_jsm_hws_resume_engine(vdev, DRM_IVPU_ENGINE_COMPUTE))
380+
return -ENODEV;
381+
if (ivpu_jsm_hws_resume_engine(vdev, DRM_IVPU_ENGINE_COPY))
382+
return -ENODEV;
383+
384+
return size;
363385
}
364386

365-
DEFINE_DEBUGFS_ATTRIBUTE(ivpu_resume_engine_fops, NULL, ivpu_resume_engine_fn, "0x%02llx\n");
387+
static const struct file_operations ivpu_resume_engine_fops = {
388+
.owner = THIS_MODULE,
389+
.open = simple_open,
390+
.write = ivpu_resume_engine_fn,
391+
};
366392

367393
static int dct_active_get(void *data, u64 *active_percent)
368394
{
@@ -406,7 +432,7 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)
406432
debugfs_create_file("force_recovery", 0200, debugfs_root, vdev,
407433
&ivpu_force_recovery_fops);
408434

409-
debugfs_create_file("dvfs_mode", 0644, debugfs_root, vdev,
435+
debugfs_create_file("dvfs_mode", 0200, debugfs_root, vdev,
410436
&dvfs_mode_fops);
411437

412438
debugfs_create_file("fw_dyndbg", 0200, debugfs_root, vdev,

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
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"
@@ -30,10 +29,10 @@
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

3938
static struct lock_class_key submitted_jobs_xa_lock_class_key;
@@ -43,10 +42,8 @@ module_param_named(dbg_mask, ivpu_dbg_mask, int, 0644);
4342
MODULE_PARM_DESC(dbg_mask, "Driver debug mask. See IVPU_DBG_* macros.");
4443

4544
int ivpu_test_mode;
46-
#if IS_ENABLED(CONFIG_DRM_ACCEL_IVPU_DEBUG)
4745
module_param_named_unsafe(test_mode, ivpu_test_mode, int, 0644);
4846
MODULE_PARM_DESC(test_mode, "Test mode mask. See IVPU_TEST_MODE_* macros.");
49-
#endif
5047

5148
u8 ivpu_pll_min_ratio;
5249
module_param_named(pll_min_ratio, ivpu_pll_min_ratio, byte, 0644);
@@ -56,9 +53,9 @@ u8 ivpu_pll_max_ratio = U8_MAX;
5653
module_param_named(pll_max_ratio, ivpu_pll_max_ratio, byte, 0644);
5754
MODULE_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;
6057
module_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

6360
bool ivpu_disable_mmu_cont_pages;
6461
module_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

416401
void 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

464449
static 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

Comments
 (0)