From 3b69d4961c3d3cf8d26461e7ca8e442247d33e68 Mon Sep 17 00:00:00 2001 From: Sameer Pujar Date: Tue, 22 Sep 2020 18:46:19 +0530 Subject: [PATCH] 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 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2417919 Reviewed-by: automaticguardword Reviewed-by: Uday Gupta Reviewed-by: Mohan Kumar D Reviewed-by: Bitan Biswas Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/platform/tegra/nvadsp/adspff.c | 9 ++++++++- drivers/platform/tegra/nvadsp/emc_dfs.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/platform/tegra/nvadsp/adspff.c b/drivers/platform/tegra/nvadsp/adspff.c index 206ca7b9..79eaccd5 100644 --- a/drivers/platform/tegra/nvadsp/adspff.c +++ b/drivers/platform/tegra/nvadsp/adspff.c @@ -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, ¶m); +#else + sched_set_fifo_low(adspff_kthread); +#endif + get_task_struct(adspff_kthread); wake_up_process(adspff_kthread); diff --git a/drivers/platform/tegra/nvadsp/emc_dfs.c b/drivers/platform/tegra/nvadsp/emc_dfs.c index 0195497c..e0964e78 100644 --- a/drivers/platform/tegra/nvadsp/emc_dfs.c +++ b/drivers/platform/tegra/nvadsp/emc_dfs.c @@ -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, ¶m); +#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 */