Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp637642imm; Fri, 10 Aug 2018 19:14:53 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxSran0ocDP6aNjlXBA06tscQITzOcaqRwJ9Mq8d3vMFbG/rBj4+c0WidYHOL4OVrb5p+wL X-Received: by 2002:a63:8341:: with SMTP id h62-v6mr8357346pge.298.1533953693132; Fri, 10 Aug 2018 19:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533953693; cv=none; d=google.com; s=arc-20160816; b=O4TjuBo14CzIDibJxcntOZErBCnqsh51Hi8/NvhAzxDprnL+LfejaEW6XeuudGaC7j DkE/cCvlMgkx9o5fbEf0bJRvYDck1sOAR+KCjAMzTuj7Gq1+3Xv2E2fFLg5e38NIHHbA Uu2RMuveMp1utO+xuftwQk9KrAaeWdQp9xGMw9RtNqJwJS+EyJ+70G33ooqIuSqm50P6 hzkSzcajeNe1X/FLKKwpCnE8nLlvPsUfh4U6jXyfzxaoQ+F6lS8oNjjUhrOZmV8xwA6A RQcwfSnd7ba1tDjc1gNt7Xh4266ThZz1b4kmEx7eDDTgzlzJtd3ErCuwiJkJGoMGAZcA SDfA== 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 :subject:from:cc:to:dkim-signature:arc-authentication-results; bh=SKB3mU2M3TnxXODKB2dYqG5Sh5gfnx2BPLIKePnZE2A=; b=rUwXZ2He+oLhTja5WN+zdwF0VbTn9DWAvSNjQxL5M4HVQHZ2Y3W/eARDMYa3wjh1dw Kd7cJgWETCghFe10pjtxDq9xCaWqToC39+AyATWy2vdnOdsBRAhvTthonlxW0nLUEMSD FzsAmibGA36Ej8D9pjgamghVV6C1fTYDwxAKCEDWXx3pgL15Mlv3+7mgoTezhihaJLrX Xtl7ELUYg9iNL5JhHLOm47xJewpJajgSgVBI8ddCxdI9jVJhw3eETCoZli5PENnAWnS4 OM1Mln+9W/hg0A38/WWZqbmPp9TlMFCR9CPuEpBEt4Cn+9QMtPxvMufWfB2A4quRaM0F e8Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m+evvQxX; 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 w18-v6si11916915pfi.88.2018.08.10.19.14.38; Fri, 10 Aug 2018 19:14:53 -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=m+evvQxX; 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 S1727326AbeHKEpl (ORCPT + 99 others); Sat, 11 Aug 2018 00:45:41 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:33918 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbeHKEpk (ORCPT ); Sat, 11 Aug 2018 00:45:40 -0400 Received: by mail-pl0-f67.google.com with SMTP id f6-v6so4740462plo.1; Fri, 10 Aug 2018 19:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=SKB3mU2M3TnxXODKB2dYqG5Sh5gfnx2BPLIKePnZE2A=; b=m+evvQxX/skkJLXWB6bqp6OkgYwH+hLOG5lc6NJjn0pBVJtcHyMsWfmx8S93/2AyxM Pp7sF/TO/5BfzS1H2rHpfruLvhiTtOeVfIWyNeUI3lrUyK0pxrohTTmzhssZJXxoquHY 4aNdGk0YjDL3smo/wIml41k3Vuc1lCaEog5zQFBaSoiib7NH2czPKyBj5tc8gCXpXjpZ z8iyIqg2OQNAG8iXA58dciq50ACuU5WEYR6WTCQmqLzxogewHYe6BOeDYHXI+AyNJjsD AVf+JjvbL4d0JTxFWVJIYOn/tGa04zbQk1XOu65225U6vcKwjnBQjM2C0e4HwC+YtDv/ K8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=SKB3mU2M3TnxXODKB2dYqG5Sh5gfnx2BPLIKePnZE2A=; b=QKvGArT+6sm9/MGUDGHNmrSNDC5xF0jARHI12lstq0LHoyJHapIBaYy+uLOAHrRXhL yD0k9nnluSRaIldfqZfrOHa8lvR73eGPdxWm+ToMlxUuX2sc3kZjMaH8gsTC/58DQpwC qq08wFMj6PLNUry/Kdo7/2/9LzdshTUzE5vTxXEZrHdohpfyz3h/39kdjPHB5ULZcWln 0RhnaKHmy4OaCAzubLczSunJErz87rWYhJFfsK0/Lc47HOjfpCRtndru5tvrJYiTU8vR ftlEtJV5uPBjf5v+R5qylQjmFHdG1yiV665tdZH1JIQ4qqNMGs7r8cF/HU2fZlFCvclJ W2fg== X-Gm-Message-State: AOUpUlFMfONL5dCrnY2+fBEy3LVh3nAdwM/sszx5uCA87WCwzhj6jd40 /SstC4J/rHEQfz6fczhx1kHiCqhS X-Received: by 2002:a17:902:a5:: with SMTP id a34-v6mr8332534pla.60.1533953594433; Fri, 10 Aug 2018 19:13:14 -0700 (PDT) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.71.51? ([2402:f000:1:1501:200:5efe:a66f:4733]) by smtp.gmail.com with ESMTPSA id r19-v6sm19431547pgg.39.2018.08.10.19.13.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 19:13:14 -0700 (PDT) To: michael.hennerich@analog.com, linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, Linux Kernel Mailing List From: Jia-Ju Bai Subject: [BUG] gpio: gpio-adp5588: A possible sleep-in-atomic-context bug in adp5588_gpio_write() Message-ID: <93f77ccb-a478-fd72-5012-aeba5b6c8253@gmail.com> Date: Sat, 11 Aug 2018 10:13:08 +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 The driver may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16 are: [FUNC] schedule_timeout drivers/media/platform/marvell-ccic/cafe-driver.c, 206: schedule_timeout in cafe_smbus_write_data drivers/media/platform/marvell-ccic/cafe-driver.c, 307: cafe_smbus_write_data in cafe_smbus_xfer drivers/i2c/i2c-core-smbus.c, 541: [FUNC_PTR]cafe_smbus_xfer in i2c_smbus_xfer drivers/i2c/i2c-core-smbus.c, 156: i2c_smbus_xfer in i2c_smbus_write_byte_data drivers/gpio/gpio-adp5588.c, 58: i2c_smbus_write_byte_data in adp5588_gpio_write drivers/gpio/gpio-adp5588.c, 115: adp5588_gpio_write in adp5588_gpio_direction_input drivers/gpio/gpio-adp5588.c, 224: adp5588_gpio_direction_input in adp5588_irq_set_type kernel/irq/manage.c, 686: [FUNC_PTR]adp5588_irq_set_type in __irq_set_trigger kernel/irq/manage.c, 1350: __irq_set_trigger in __setup_irq kernel/irq/manage.c, 1238: _raw_spin_lock_irqsave in __setup_irq [FUNC] mutex_lock_nested drivers/i2c/busses/i2c-cht-wc.c, 138: mutex_lock_nested in cht_wc_i2c_adap_smbus_xfer drivers/i2c/i2c-core-smbus.c, 541: [FUNC_PTR]cht_wc_i2c_adap_smbus_xfer in i2c_smbus_xfer drivers/i2c/i2c-core-smbus.c, 156: i2c_smbus_xfer in i2c_smbus_write_byte_data drivers/gpio/gpio-adp5588.c, 58: i2c_smbus_write_byte_data in adp5588_gpio_write drivers/gpio/gpio-adp5588.c, 115: adp5588_gpio_write in adp5588_gpio_direction_input drivers/gpio/gpio-adp5588.c, 224: adp5588_gpio_direction_input in adp5588_irq_set_type kernel/irq/manage.c, 686: [FUNC_PTR]adp5588_irq_set_type in __irq_set_trigger kernel/irq/manage.c, 1350: __irq_set_trigger in __setup_irq kernel/irq/manage.c, 1238: _raw_spin_lock_irqsave in __setup_irq [FUNC] mutex_lock_nested drivers/i2c/busses/i2c-i801.c, 828: mutex_lock_nested in i801_access drivers/i2c/i2c-core-smbus.c, 541: [FUNC_PTR]i801_access in i2c_smbus_xfer drivers/i2c/i2c-core-smbus.c, 156: i2c_smbus_xfer in i2c_smbus_write_byte_data drivers/gpio/gpio-adp5588.c, 58: i2c_smbus_write_byte_data in adp5588_gpio_write drivers/gpio/gpio-adp5588.c, 115: adp5588_gpio_write in adp5588_gpio_direction_input drivers/gpio/gpio-adp5588.c, 224: adp5588_gpio_direction_input in adp5588_irq_set_type kernel/irq/manage.c, 686: [FUNC_PTR]adp5588_irq_set_type in __irq_set_trigger kernel/irq/manage.c, 1350: __irq_set_trigger in __setup_irq kernel/irq/manage.c, 1238: _raw_spin_lock_irqsave in __setup_irq Note that [FUNC_PTR] means a function pointer call is used. I do not find a good way to fix, so I only report. Maybe adp5588_gpio_direction_input() and adp5588_gpio_write() should not be called in adp5588_irq_set_type(). This is found by my static analysis tool (DSAC). Best wishes, Jia-Ju Bai