]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sparc64: fix out of order spin_lock_irqsave and spin_unlock_restore
authorThomas Tai <thomas.tai@oracle.com>
Tue, 27 Jun 2017 15:21:44 +0000 (09:21 -0600)
committerAllen Pais <allen.pais@oracle.com>
Tue, 18 Jul 2017 12:24:04 +0000 (17:54 +0530)
commit44132dd8e62f9dfcb7f835aca930ae758baa5127
tree3111f2357036924591c8ead53b583631840e60ea
parenta8a87d58de171ebbba376259cc15d99b8983be7d
sparc64: fix out of order spin_lock_irqsave and spin_unlock_restore

After enabling spinlocks debug option, kernel prints out call trace
suggesting that the function ldom_req_sp_token executes a might_sleep
function while IRQs is disabled. IRQs is disabled because the
spin_lock_irqsave and spin_unlock_irqrestore are out of order.

Normal correct sequence is:

spin_lock_irqsave(ds_dev_list_lock, data_flags)

        LOCK_DS_DEV()/* spin_lock_irqsave(ds_lock, ds_flags) */
        .
        .
        UNLOCK_DS_DEV()/* spin_unlock_irqrestore(ds_lock, ds_flags) */

spin_unlock_irqrestore(ds_dev_list_lock, data_flags)

Out or order sequence:

spin_lock_irqsave(ds_dev_list_lock, data_flags)

        LOCK_DS_DEV()/* spin_lock_irqsave(ds_lock, ds_flags) */

spin_unlock_irqrestore(ds_dev_list_lock, data_flags)

        UNLOCK_DS_DEV()/* spin_unlock_irqrestore(ds_lock, ds_flags) */

The last UNLOCK_DS_DEV() ends up restoring IRQs to disabled state,
because the previous LOCK_DS_DEV() is in irqs_disabled().
To fix the issue, follows the order of irqsave()/irqrestore().

Orabug: 26265190
Orabug: 25421812

Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Aaron Young <aaron.young@oracle.com>
arch/sparc/kernel/ds.c