Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6848986imm; Tue, 28 Aug 2018 02:00:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbotVP1/myp7UyWH9WFPtRAwSDnmgpAgSK759XVnWf7VimU6IGxXkDU+rgJIGpwPWDaf+PB X-Received: by 2002:a62:f208:: with SMTP id m8-v6mr576275pfh.222.1535446801415; Tue, 28 Aug 2018 02:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535446801; cv=none; d=google.com; s=arc-20160816; b=utTl1nFcs/fL9rWHhKpCEnc8wS/OUAcUf5gYz446s/2PzQQa1qRlA904/jb8W8No7d RWuTNYc0Mf2g/z5mJfqgxOEZdImmaobQMgTE0addfvb9h6TO5X39wx7jKib2pgB/xH7a LlCeQXUDrNKL4GtHuM4qQ95djkGr4cj4HdPxBd+kWJau0YwMPepZLDWr2St8bEZNyB4k aj+TjalPcQ4KWY8EURT93bBl/IpV9GgMVBwYozliK+dSSKT+E3LJjG86w9HaemCTr8Ac xX4zkLn08IYJTPSiaRis7RNgEGN+Bf5vv+YRNqqCuWd5KOQWd8HaKTzaxkbIJIqg5k4x fQ9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :cc:to:subject:from:dkim-signature:arc-authentication-results; bh=kRGWbF5PV5VDlUc4xRxBoDDyYAs513RXkWYqdr5OSQ4=; b=nwNmCmSVqcYYEth2SnH2slgjzmF/SOch8gFn20gF6sSxoSRLVYKxRBCGVFtsxcJi05 vbdD3tyQuDmlWuMfSTvBdNpq3qHJotljKnkZ77vuBW2oDW857dzgp1D7AC3v6gyMIbEK dSZuI+0ArO9gS0Mzpl8MnEo5vGQK7t4SH6xPT8IkMI7JbHSdknYbLvMb5vX01Z26fI+O 4260xzGr6wBRh4AqGN88kdY+ucwCazJAFUHEeB4RP6cqtl1xPN5y3zg7Nz4EGJaCwzTI eGCRvE5LKXUgUGyEU8Gcgy6rKvPi9zD9Nb2FbkNF+PbK+/qHeBDQreLCCuJCQPDavqnl I+bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B1fpCNyz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z128-v6si559176pgb.185.2018.08.28.01.59.45; Tue, 28 Aug 2018 02:00:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B1fpCNyz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727442AbeH1Msg (ORCPT + 99 others); Tue, 28 Aug 2018 08:48:36 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:40984 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbeH1Msg (ORCPT ); Tue, 28 Aug 2018 08:48:36 -0400 Received: by mail-io0-f170.google.com with SMTP id q4-v6so753859iob.8 for ; Tue, 28 Aug 2018 01:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=kRGWbF5PV5VDlUc4xRxBoDDyYAs513RXkWYqdr5OSQ4=; b=B1fpCNyzknO5YHF7ETrKTJlBPaYX0TYcJiHwXtVd1IpD6t+SVWzSDfvf9hvRms/JLJ rhqhunl1tiyhDkujTH4hmo+pDy/Z6j2r9wresi6IC4SZSH+YSRJ90vHR1j8blrdRrfW0 rfWKVyYT8jS2n8aTyWjsCeZxY0xPhiPtrVhKMp1VmJbrwzObS8waNATNM0viaWKp3y43 RRP5rfvD0ihhaUEf7AQc4KHURydZnHjaASxjlL3qAqBsy22Qo4SsTKPH0Pzuet+SdbTZ 3leysOvm4maMqH/IWAU35FMjSTiQMXn0NcyThkK4qGZlvC/peHl1Yz9YiGTxVnVez1RX ki5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=kRGWbF5PV5VDlUc4xRxBoDDyYAs513RXkWYqdr5OSQ4=; b=iEaj6Jia/OQHfxs/QEdioKOTCWt/IGo8zJvp7NLSXtTUUA7CRWyi00H7DMl/lWfAEp eqEiTSzM2zzmAcEOCEmklj0qu61ve3Y9CHZmE8EGU2zvRPS7dUkv7OzrXteK3IAi2cnw QEI+eeoNrwJMkSEHA8tcGWrXebW6btiWYVBxkzPa/cfa9wqUPqUOm0RBlp0Lm+peYhHy F0usH3Jw1ptTNvl2gJlK9W2fFcTd+reyloonjfXca5IvOssZb34bksNROj/4P8JlJ63U bbvJLiQYGJGYZWEaMSTlIINz9kqZ8LHT376RHPdvOzFkuTX6OUvo4q6bb4tLRXeovSjy 9H0A== X-Gm-Message-State: APzg51B8QBuqttjAtjScd+BBfKn20ycMqDF2NFf0WE/+DATBBSf5vDXf glYxzTW+MDmE5r5JfU8VSaNmsobr X-Received: by 2002:a6b:3902:: with SMTP id g2-v6mr450140ioa.168.1535446676786; Tue, 28 Aug 2018 01:57:56 -0700 (PDT) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.71.15? ([2402:f000:1:1501:200:5efe:a66f:470f]) by smtp.gmail.com with ESMTPSA id z13-v6sm255087ioj.51.2018.08.28.01.57.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 01:57:56 -0700 (PDT) From: Jia-Ju Bai Subject: [BUG] Possible sleep-in-atomic-context bugs involving regmap_lock_mutex() To: broonie@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, songjun.wu@microchip.com, architt@codeaurora.org Cc: linux-kernel@vger.kernel.org Message-ID: Date: Tue, 28 Aug 2018 16:57:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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