sched/walt: Fix scheduling while atomic

walt_init() is a function that could sleep and it should not be called
in an atomic context.
Introduce a work to do walt init.

Change-Id: Ief3e9500d7675b998220693ac1908ac74e876f50
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
This commit is contained in:
Sai Harshini Nimmala 2021-06-17 13:47:31 -07:00 committed by Rishabh Bhatnagar
parent 1b1ec2daf6
commit 4e9150549c

View File

@ -4211,12 +4211,14 @@ static void walt_init_tg_pointers(void)
rcu_read_unlock();
}
static void walt_init(void)
static void walt_init(struct work_struct *work)
{
struct ctl_table_header *hdr;
static atomic_t already_inited = ATOMIC_INIT(0);
int i;
might_sleep();
if (atomic_cmpxchg(&already_inited, 0, 1))
return;
@ -4252,9 +4254,10 @@ static void walt_init(void)
}
}
static DECLARE_WORK(walt_init_work, walt_init);
static void android_vh_update_topology_flags_workfn(void *unused, void *unused2)
{
walt_init();
schedule_work(&walt_init_work);
}
#define WALT_VENDOR_DATA_SIZE_TEST(wstruct, kstruct) \
@ -4272,7 +4275,7 @@ static int walt_module_init(void)
android_vh_update_topology_flags_workfn, NULL);
if (topology_update_done)
walt_init();
schedule_work(&walt_init_work);
return 0;
}