mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: broonie@kernel.org, gregkh@linuxfoundation.org,
	rafael@kernel.org, songjun.wu@microchip.com,
	architt@codeaurora.org
Cc: linux-kernel@vger.kernel.org
Subject: [BUG] Possible sleep-in-atomic-context bugs involving regmap_lock_mutex()
Date: Tue, 28 Aug 2018 16:57:51 +0800	[thread overview]
Message-ID: <ffbd81ae-fd30-dc57-c3ac-463f7fadb9ac@gmail.com> (raw)

Hello,

My static tool DSAC reports many sleep-in-atomic-context bugs involving 
regmap_lock_mutex(), so I wonder whether this function is possible to be 
executed in atomic context.

Here are some example bugs and their call paths in Linux-4.16 (from 
bottom to top, and [FUNC_PTR] means that there is a function pointer call):

[FUNC] mutex_lock_nested
drivers/base/regmap/regmap.c, 468:
     mutex_lock_nested in regmap_lock_mutex
drivers/base/regmap/regmap.c, 2503:
     [FUNC_PTR]regmap_lock_mutex in regmap_read
drivers/clk/clk-aspeed.c, 215:
     regmap_read in aspeed_clk_is_enabled
drivers/clk/clk-aspeed.c, 230:
     aspeed_clk_is_enabled in aspeed_clk_enable
drivers/clk/clk-aspeed.c, 228:
     _raw_spin_lock_irqsave in aspeed_clk_enable

[FUNC] mutex_lock_nested
drivers/base/regmap/regmap.c, 468:
     mutex_lock_nested in regmap_lock_mutex
drivers/base/regmap/regmap.c, 2821:
     [FUNC_PTR]regmap_lock_mutex in regmap_update_bits_base
drivers/clk/clk-aspeed.c, 270:
     regmap_update_bits_base in aspeed_clk_disable
drivers/clk/clk-aspeed.c, 267:
     _raw_spin_lock_irqsave in aspeed_clk_disable

[FUNC] mutex_lock_nested
drivers/base/regmap/regmap.c, 468:
     mutex_lock_nested in regmap_lock_mutex
drivers/base/regmap/regmap.c, 2503:
     [FUNC_PTR]regmap_lock_mutex in regmap_read
drivers/char/ipmi/bt-bmc.c, 385:
     regmap_read in bt_bmc_irq

[FUNC] mutex_lock_nested
drivers/base/regmap/regmap.c, 468:
     mutex_lock_nested in regmap_lock_mutex
drivers/base/regmap/regmap.c, 2821:
     [FUNC_PTR]regmap_lock_mutex in regmap_update_bits_base
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c, 213:
     regmap_update_bits_base in hdmi_modb
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c, 429:
     hdmi_modb in hdmi_set_cts_n
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c, 527:
     hdmi_set_cts_n in hdmi_set_clk_regenerator
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c, 524:
     spin_lock_irq in hdmi_set_clk_regenerator

[FUNC] mutex_lock_nested
drivers/base/regmap/regmap.c, 468:
     mutex_lock_nested in regmap_lock_mutex
drivers/base/regmap/regmap.c, 2503:
     [FUNC_PTR]regmap_lock_mutex in regmap_read
drivers/media/platform/atmel/atmel-isc.c, 1603:
     regmap_read in isc_interrupt (interrupt handler)

I find the code about the assignment of regmap_lock_mutex():
         if ((bus && bus->fast_io) ||
             config->fast_io) {
             spin_lock_init(&map->spinlock);
             map->lock = regmap_lock_spinlock;
             map->unlock = regmap_unlock_spinlock;
             lockdep_set_class_and_name(&map->spinlock,
                            lock_key, lock_name);
         } else {
             mutex_init(&map->mutex);
             map->lock = regmap_lock_mutex;
             map->unlock = regmap_unlock_mutex;
             lockdep_set_class_and_name(&map->mutex,
                            lock_key, lock_name);
         }

But after reading the code, I cannot find the relationship between the 
if condition and atomic context.

I am looking forward to your reply, thanks in advance :)


Best wishes,
Jia-Ju Bai

                 reply	other threads:[~2018-08-28  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ffbd81ae-fd30-dc57-c3ac-463f7fadb9ac@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=architt@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=songjun.wu@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®