<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">Dear Ohad,<div>    </div><div>                When enable this config to check kernel, kernel will complain panic at slab.c(kmem_cache_alloc function): "BUG: sleeping function called from invalid context".</div>


<div>                 The Backtrace is: hwspin_lock_register -> radix_tree_insert -> kmem_cache_alloc -> __might_sleep -> BUG</div><div><br></div><div>                 Hwspinlock has been inited in postcore_initcall phase, but kernel sleep check has enable in early_initcall phase(__might_sleep_init_called ==1 in sched.c)</div>


<div><br></div><div>                 I think the the same problem is in __hwspin_lock_request function, this function use pm_runtime_get _sync interface, so might seep that flag don't have RPM_ASYNC value.</div><div>

<br>
</div><div>Do you hae some good suggestions Or comments about this?</div><div><br> </div><div><div>diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c</div><div>index db713c0..49ff54a 100644</div>


<div>--- a/drivers/hwspinlock/hwspinlock_core.c</div><div>+++ b/drivers/hwspinlock/hwspinlock_core.c</div><div>@@ -50,7 +50,7 @@</div><div>  * tree, looking for an unused hwspinlock instance, is now reduced to a</div><div>


  * single radix tree API call.</div><div>  */</div><div>-static RADIX_TREE(hwspinlock_tree, GFP_KERNEL);</div><div>+static RADIX_TREE(hwspinlock_tree, GFP_ATOMIC);</div><div><br></div><div> /*</div><div>  * Synchronization of access to the tree is achieved using this mutex,</div>


<div>@@ -413,7 +413,7 @@ static int __hwspin_lock_request(struct hwspinlock *hwlock)</div><div>        }</div><div><br></div><div>        /* notify PM core that power is now needed */</div><div>-       ret = pm_runtime_get_sync(dev);</div>


<div>+       ret = pm_runtime_get(dev);</div><div>        if (ret < 0) {</div><div>                dev_err(dev, "%s: can't power on device\n", __func__);</div><div>                return ret;</div></div>

<span class="HOEnZb"><font color="#888888"><div>
<br></div><div>-- <br>Steve Zhan
</div></font></span></div>
</div><br><br clear="all"><div><br></div>-- <br>Steve Zhan
</div>