nvadsp: Convert to set_sched_fifo*() for v5.9

While enabling 'CONFIG_TEGRA_ADSP_FILEIO' following build error
is seen with v5.9-rc4 build.

 ERROR: modpost: "sched_setscheduler" [drivers/platform/tegra/
   nvadsp/nvadsp.ko] undefined!

This happens because sched_setscheduler() export is removed with
commit 616d91b68cd5 ("sched: Remove sched_setscheduler*() EXPORTs")
in upstream. The reason for removal is below.

Upstream commit 7318d4cc14c8 ("sched: Provide sched_set_fifo()")
provides sched_set_*() functions and suggests to convert existing
sched_setscheduler_*() calls to sched_set_*(). As per this
following updates are made for ADSP driver to work for v5.9.

  - Use sched_set_fifo() whenever a high priority is required.
    (However by default priority is set to MAX_RT/2)
  - Use sched_set_fifo_low() whenever priority needs to be above
    SCHED_NORMAL.

Since it is a recent change in upstream kernel above changes are
not applicable for previous kernels (v4.14 and v4.9). Hence these
can continue to use existing calls. Thus above changes are protected
under kernel version checks.

Bug 200657500

Change-Id: I763fb7d1461e23e1eeb26d7c49a295172450e54d
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2417919
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sameer Pujar
2020-09-22 18:46:19 +05:30
committed by Laxman Dewangan
parent 86b6ccfd04
commit 3b69d4961c
2 changed files with 16 additions and 2 deletions

View File

@@ -511,10 +511,11 @@ send_ack:
kfree(msg_recv);
}
#if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
static const struct sched_param param = {
.sched_priority = 1,
};
#endif
static struct task_struct *adspff_kthread;
static struct list_head adspff_kthread_msgq_head;
static wait_queue_head_t wait_queue;
@@ -678,7 +679,13 @@ int adspff_init(struct platform_device *pdev)
init_waitqueue_head(&wait_queue);
adspff_kthread = kthread_create(adspff_kthread_fn,
NULL, "adspp_kthread");
#if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
sched_setscheduler(adspff_kthread, SCHED_FIFO, &param);
#else
sched_set_fifo_low(adspff_kthread);
#endif
get_task_struct(adspff_kthread);
wake_up_process(adspff_kthread);

View File

@@ -3,7 +3,7 @@
*
* Emc dynamic frequency scaling due to APE
*
* Copyright (C) 2014-2016, NVIDIA Corporation. All rights reserved.
* Copyright (C) 2014-2020, NVIDIA Corporation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -400,7 +400,9 @@ err_out:
status_t __init emc_dfs_init(struct platform_device *pdev)
{
struct nvadsp_drv_data *drv = platform_get_drvdata(pdev);
#if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 };
#endif
int ret = 0;
einfo = &global_emc_info;
@@ -442,7 +444,12 @@ status_t __init emc_dfs_init(struct platform_device *pdev)
if (IS_ERR(speedchange_task))
return PTR_ERR(speedchange_task);
#if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
sched_setscheduler_nocheck(speedchange_task, SCHED_FIFO, &param);
#else
sched_set_fifo(speedchange_task);
#endif
get_task_struct(speedchange_task);
/* NB: wake up so the thread does not look hung to the freezer */