All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] accel/ivpu: Remove sched_mode module parameter
@ 2026-11-17 20:44 Andrzej Kacprowski
  2026-11-17 20:52 ` Jeff Hugo
  0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Kacprowski @ 2026-11-17 20:44 UTC (permalink / raw)
  To: dri-devel
  Cc: oded.gabbay, jeff.hugo, karol.wachowski, lizhi.hou,
	dawid.osuchowski, Andrzej Kacprowski

OS scheduling supports only a limited subset of NPU functionality and
is not intended for production use. However, the sched_mode module
parameter exposes it as a regular configuration option, and the driver
silently falls back to it when the firmware JSM API is older than 3.24.

Make hardware scheduling the only production mode:
- remove the sched_mode module parameter,
- require BOOT API 3.17 and JSM API 3.24 or newer, and fail probe with
  a message requesting a firmware update otherwise,
- allow OS scheduling on pre-60XX devices only through the
  IVPU_TEST_MODE_HWS_DISABLE test_mode bit, for debugging.

The initial 37xx and 40xx firmware added to linux-firmware in March 2025
reports BOOT and JSM APIs 3.27, meeting both minimum requirements.

Extend IVPU_FW_CHECK_API_COMPAT() to accept minimum major and minor
versions so both API requirements can be checked explicitly.

Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
---
Change in v2
- Resent the patch from the @linux.intel.com address, the @intel.com
  account adds a confidentiality notice.

 drivers/accel/ivpu/ivpu_drv.c |  4 --
 drivers/accel/ivpu/ivpu_drv.h |  4 +-
 drivers/accel/ivpu/ivpu_fw.c  | 84 ++++++++++++++++-------------------
 3 files changed, 39 insertions(+), 53 deletions(-)

diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
index 28cb18dcfa9b..2c761a6aa6ca 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -55,10 +55,6 @@ u8 ivpu_pll_max_ratio = U8_MAX;
 module_param_named(pll_max_ratio, ivpu_pll_max_ratio, byte, 0644);
 MODULE_PARM_DESC(pll_max_ratio, "Maximum PLL ratio used to set NPU frequency");
 
-int ivpu_sched_mode = IVPU_SCHED_MODE_AUTO;
-module_param_named(sched_mode, ivpu_sched_mode, int, 0444);
-MODULE_PARM_DESC(sched_mode, "Scheduler mode: -1 - Use default scheduler, 0 - Use OS scheduler (supported on 27XX - 50XX), 1 - Use HW scheduler");
-
 bool ivpu_disable_mmu_cont_pages;
 module_param_named(disable_mmu_cont_pages, ivpu_disable_mmu_cont_pages, bool, 0444);
 MODULE_PARM_DESC(disable_mmu_cont_pages, "Disable MMU contiguous pages optimization");
diff --git a/drivers/accel/ivpu/ivpu_drv.h b/drivers/accel/ivpu/ivpu_drv.h
index fe8b66e779a7..9b24d6c9d864 100644
--- a/drivers/accel/ivpu/ivpu_drv.h
+++ b/drivers/accel/ivpu/ivpu_drv.h
@@ -56,8 +56,6 @@
 #define IVPU_PLATFORM_HSLE    4
 #define IVPU_PLATFORM_INVALID 8
 
-#define IVPU_SCHED_MODE_AUTO -1
-
 #define IVPU_DBG_REG	 BIT(0)
 #define IVPU_DBG_IRQ	 BIT(1)
 #define IVPU_DBG_MMU	 BIT(2)
@@ -224,7 +222,6 @@ struct ivpu_file_priv {
 extern int ivpu_dbg_mask;
 extern u8 ivpu_pll_min_ratio;
 extern u8 ivpu_pll_max_ratio;
-extern int ivpu_sched_mode;
 extern bool ivpu_disable_mmu_cont_pages;
 extern bool ivpu_force_snoop;
 
@@ -233,6 +230,7 @@ extern bool ivpu_force_snoop;
 #define IVPU_TEST_MODE_NULL_SUBMISSION    BIT(2)
 #define IVPU_TEST_MODE_FREQ_CHANGE_ENABLE BIT(3)
 #define IVPU_TEST_MODE_MIP_DISABLE        BIT(6)
+#define IVPU_TEST_MODE_HWS_DISABLE        BIT(7)
 #define IVPU_TEST_MODE_DISABLE_TIMEOUTS   BIT(8)
 #define IVPU_TEST_MODE_TURBO_ENABLE       BIT(9)
 #define IVPU_TEST_MODE_TURBO_DISABLE      BIT(10)
diff --git a/drivers/accel/ivpu/ivpu_fw.c b/drivers/accel/ivpu/ivpu_fw.c
index 6607a5da1934..eaf7a193e305 100644
--- a/drivers/accel/ivpu/ivpu_fw.c
+++ b/drivers/accel/ivpu/ivpu_fw.c
@@ -33,15 +33,11 @@
 #define ADDR_TO_L2_CACHE_CFG(addr) ((addr) >> 31)
 
 /* Check if FW API is compatible with the driver */
-#define IVPU_FW_CHECK_API_COMPAT(vdev, name, min_major) \
+#define IVPU_FW_CHECK_API_COMPAT(vdev, name, min_major, min_minor) \
 	ivpu_fw_check_api(vdev, #name, \
 			  VPU_##name##_API_VER_INDEX, \
 			  VPU_##name##_API_VER_MAJOR, \
-			  VPU_##name##_API_VER_MINOR, min_major)
-
-/* Check if API version is lower that the given version */
-#define IVPU_FW_CHECK_API_VER_LT(vdev, name, major, minor) \
-	ivpu_fw_check_api_ver_lt(vdev, #name, VPU_##name##_API_VER_INDEX, major, minor)
+			  VPU_##name##_API_VER_MINOR, min_major, min_minor)
 
 #define IVPU_FOCUS_PRESENT_TIMER_MS 1000
 
@@ -97,28 +93,6 @@ static int ivpu_fw_request(struct ivpu_device *vdev)
 	return ret;
 }
 
-static int
-ivpu_fw_check_api(struct ivpu_device *vdev, const char *str, int index, u16 expected_major,
-		  u16 expected_minor, u16 min_major)
-{
-	u16 major = (u16)(vdev->fw->api_version[index] >> 16);
-	u16 minor = (u16)(vdev->fw->api_version[index]);
-
-	if (major < min_major) {
-		ivpu_err(vdev, "Incompatible FW %s API version: %d.%d, required %d.0 or later\n",
-			 str, major, minor, min_major);
-		return -EINVAL;
-	}
-	if (major != expected_major) {
-		ivpu_warn(vdev, "Major FW %s API version different: %d.%d (expected %d.%d)\n",
-			  str, major, minor, expected_major, expected_minor);
-	}
-	ivpu_dbg(vdev, FW_BOOT, "FW %s API version: %d.%d (expected %d.%d)\n",
-		 str, major, minor, expected_major, expected_minor);
-
-	return 0;
-}
-
 static bool
 ivpu_fw_check_api_ver_lt(struct ivpu_device *vdev, const char *str, int index, u16 major, u16 minor)
 {
@@ -131,6 +105,29 @@ ivpu_fw_check_api_ver_lt(struct ivpu_device *vdev, const char *str, int index, u
 	return false;
 }
 
+static int
+ivpu_fw_check_api(struct ivpu_device *vdev, const char *str, int index, u16 drv_major,
+		  u16 drv_minor, u16 min_major, u16 min_minor)
+{
+	u16 fw_major = (u16)(vdev->fw->api_version[index] >> 16);
+	u16 fw_minor = (u16)(vdev->fw->api_version[index]);
+
+	if (ivpu_fw_check_api_ver_lt(vdev, str, index, min_major, min_minor)) {
+		ivpu_err(vdev, "Firmware %s API version %u.%u is too old; minimum supported version is %u.%u\n",
+			 str, fw_major, fw_minor, min_major, min_minor);
+		ivpu_err(vdev, "Update firmware %s before using this device\n", vdev->fw->name);
+		return -EINVAL;
+	}
+	if (fw_major != drv_major) {
+		ivpu_warn(vdev, "Major %s API version different: firmware %u.%u, driver %u.%u\n",
+			  str, fw_major, fw_minor, drv_major, drv_minor);
+	}
+	ivpu_dbg(vdev, FW_BOOT, "%s API version: firmware %u.%u, driver %u.%u\n",
+		 str, fw_major, fw_minor, drv_major, drv_minor);
+
+	return 0;
+}
+
 bool ivpu_is_within_range(u64 addr, size_t size, struct ivpu_addr_range *range)
 {
 	u64 addr_end;
@@ -144,22 +141,18 @@ bool ivpu_is_within_range(u64 addr, size_t size, struct ivpu_addr_range *range)
 	return true;
 }
 
-static u32
-ivpu_fw_sched_mode_select(struct ivpu_device *vdev)
+static void ivpu_fw_sched_mode_init(struct ivpu_device *vdev)
 {
-	if (ivpu_hw_ip_gen(vdev) >= IVPU_HW_IP_60XX &&
-	    ivpu_sched_mode == VPU_SCHEDULING_MODE_OS) {
-		ivpu_warn(vdev, "OS sched mode is not supported, using HW mode\n");
-		return VPU_SCHEDULING_MODE_HW;
+	if (ivpu_test_mode & IVPU_TEST_MODE_HWS_DISABLE) {
+		if (ivpu_hw_ip_gen(vdev) < IVPU_HW_IP_60XX) {
+			vdev->fw->sched_mode = VPU_SCHEDULING_MODE_OS;
+			ivpu_warn(vdev, "OS scheduling mode enabled. Use for debug only!\n");
+			return;
+		}
+		ivpu_warn(vdev, "OS scheduling mode is not supported, using HW mode\n");
 	}
-
-	if (ivpu_sched_mode != IVPU_SCHED_MODE_AUTO)
-		return ivpu_sched_mode;
-
-	if (IVPU_FW_CHECK_API_VER_LT(vdev, JSM, 3, 24))
-		return VPU_SCHEDULING_MODE_OS;
-
-	return VPU_SCHEDULING_MODE_HW;
+	vdev->fw->sched_mode = VPU_SCHEDULING_MODE_HW;
+	ivpu_dbg(vdev, FW_BOOT, "Scheduling mode: HW\n");
 }
 
 static void
@@ -306,9 +299,9 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
 
 	memcpy(fw->api_version, fw_hdr->api_version, sizeof(fw->api_version));
 
-	if (IVPU_FW_CHECK_API_COMPAT(vdev, BOOT, 3))
+	if (IVPU_FW_CHECK_API_COMPAT(vdev, BOOT, 3, 17))
 		return -EINVAL;
-	if (IVPU_FW_CHECK_API_COMPAT(vdev, JSM, 3))
+	if (IVPU_FW_CHECK_API_COMPAT(vdev, JSM, 3, 24))
 		return -EINVAL;
 
 	fw->boot_params_addr = boot_params_addr;
@@ -322,8 +315,7 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
 	fw->shave_nn_size = PAGE_ALIGN(fw_hdr->shave_nn_fw_size);
 	fw->cold_boot_entry_point = fw_hdr->entry_point;
 
-	fw->sched_mode = ivpu_fw_sched_mode_select(vdev);
-	ivpu_info(vdev, "Scheduler mode: %s\n", fw->sched_mode ? "HW" : "OS");
+	ivpu_fw_sched_mode_init(vdev);
 
 	ivpu_preemption_config_parse(vdev, fw_hdr);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] accel/ivpu: Remove sched_mode module parameter
  2026-11-17 20:44 [PATCH v2] accel/ivpu: Remove sched_mode module parameter Andrzej Kacprowski
@ 2026-11-17 20:52 ` Jeff Hugo
  2026-11-18  8:04   ` Karol Wachowski
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Hugo @ 2026-11-17 20:52 UTC (permalink / raw)
  To: Andrzej Kacprowski, dri-devel
  Cc: oded.gabbay, karol.wachowski, lizhi.hou, dawid.osuchowski

On 11/17/2026 1:44 PM, Andrzej Kacprowski wrote:
> OS scheduling supports only a limited subset of NPU functionality and
> is not intended for production use. However, the sched_mode module
> parameter exposes it as a regular configuration option, and the driver
> silently falls back to it when the firmware JSM API is older than 3.24.
> 
> Make hardware scheduling the only production mode:
> - remove the sched_mode module parameter,
> - require BOOT API 3.17 and JSM API 3.24 or newer, and fail probe with
>    a message requesting a firmware update otherwise,
> - allow OS scheduling on pre-60XX devices only through the
>    IVPU_TEST_MODE_HWS_DISABLE test_mode bit, for debugging.
> 
> The initial 37xx and 40xx firmware added to linux-firmware in March 2025
> reports BOOT and JSM APIs 3.27, meeting both minimum requirements.
> 
> Extend IVPU_FW_CHECK_API_COMPAT() to accept minimum major and minor
> versions so both API requirements can be checked explicitly.
> 
> Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] accel/ivpu: Remove sched_mode module parameter
  2026-11-17 20:52 ` Jeff Hugo
@ 2026-11-18  8:04   ` Karol Wachowski
  0 siblings, 0 replies; 3+ messages in thread
From: Karol Wachowski @ 2026-11-18  8:04 UTC (permalink / raw)
  To: Jeff Hugo, Andrzej Kacprowski, dri-devel
  Cc: oded.gabbay, lizhi.hou, dawid.osuchowski

On 17-Nov-26 21:52, Jeff Hugo wrote:
> On 11/17/2026 1:44 PM, Andrzej Kacprowski wrote:
>> OS scheduling supports only a limited subset of NPU functionality and
>> is not intended for production use. However, the sched_mode module
>> parameter exposes it as a regular configuration option, and the driver
>> silently falls back to it when the firmware JSM API is older than 3.24.
>>
>> Make hardware scheduling the only production mode:
>> - remove the sched_mode module parameter,
>> - require BOOT API 3.17 and JSM API 3.24 or newer, and fail probe with
>>    a message requesting a firmware update otherwise,
>> - allow OS scheduling on pre-60XX devices only through the
>>    IVPU_TEST_MODE_HWS_DISABLE test_mode bit, for debugging.
>>
>> The initial 37xx and 40xx firmware added to linux-firmware in March 2025
>> reports BOOT and JSM APIs 3.27, meeting both minimum requirements.
>>
>> Extend IVPU_FW_CHECK_API_COMPAT() to accept minimum major and minor
>> versions so both API requirements can be checked explicitly.
>>
>> Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
> Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

Thanks, applied to drm-misc-next.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-18  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 20:44 [PATCH v2] accel/ivpu: Remove sched_mode module parameter Andrzej Kacprowski
2026-11-17 20:52 ` Jeff Hugo
2026-11-18  8:04   ` Karol Wachowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.