From patchwork Mon May 30 15:14:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 68847 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1458165qge; Mon, 30 May 2016 08:14:29 -0700 (PDT) X-Received: by 10.66.186.70 with SMTP id fi6mr46875926pac.3.1464621269305; Mon, 30 May 2016 08:14:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ux3si2056653pac.195.2016.05.30.08.14.29; Mon, 30 May 2016 08:14:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754704AbcE3PO2 (ORCPT + 4 others); Mon, 30 May 2016 11:14:28 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34904 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736AbcE3PO1 (ORCPT ); Mon, 30 May 2016 11:14:27 -0400 Received: by mail-lf0-f50.google.com with SMTP id w16so61767962lfd.2 for ; Mon, 30 May 2016 08:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ozYL6mggTDT3HYG8f+sZV5CgdLAd0qCaYM7BtATQ9uI=; b=WE8a75F1xur4HLPkEjxx2HDkaNmH1RJbQNZSRFyTGifhsITqWq2q0Ii1n9SNDZvIhA 7DEFLKWDOPaGqN8lRW7iRSV+/VxPatWPQpRie+smDX8cJwSqA43HJyZN2bsMNFlGLAGg ict8N6wfz7vH83qu4//JQKe5UIUaTUwSBTIwg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ozYL6mggTDT3HYG8f+sZV5CgdLAd0qCaYM7BtATQ9uI=; b=lcCetjMmCkpeiXHILjvqzOxC+NvZL3FLo9acvQnStc/yXvOS00u2mhc4D5UkFggLYm QeoEdIJPIGq90naWXsfrueD3S/mLyOaJ2ITNrTZzjEvRKNPx7xuD8vlJaQshXk5mxg5B Qw/36vyLgdZerZjzsMlzW+iFzLKJ9FCdVxLWh2q2zvUORPRZ8ntrN/UsjwHwSGDT76BP QZjKTZmI+gwERECKcF/UWHOpngKSo/Pb571Z0dtBOtrHy75GmsWbPr4HXVg0+Z3oEbfD c0pOWwOWRW9LJq+8vdfk3qC5N5P/9tWtSf0RjCF2h2Y+tkzYiA2/ATFFXEM/ms4kclbL jUjQ== X-Gm-Message-State: ALyK8tJL35iS0STrmq3DbU2Cr8GDmGa4C05pKb9CLLiFBSmsU/cYCdv7f7O0/qkECBFEgNiD X-Received: by 10.25.214.156 with SMTP id p28mr6987212lfi.95.1464621265599; Mon, 30 May 2016 08:14:25 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n3sm4597525lbd.40.2016.05.30.08.14.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 08:14:24 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH] gpio: drop lock before reading GPIO direction Date: Mon, 30 May 2016 17:14:22 +0200 Message-Id: <1464621262-32689-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When adding the gpiochip, the GPIO HW drivers' callback get_direction() could get called in atomic context. Some of the GPIO HW drivers may sleep when accessing the register. Move the lock before initializing the descriptors. Reported-by: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 246b6b051b0d..24f60d28f0c0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -629,6 +629,8 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) goto err_free_label; } + spin_unlock_irqrestore(&gpio_lock, flags); + for (i = 0; i < chip->ngpio; i++) { struct gpio_desc *desc = &gdev->descs[i]; @@ -660,8 +662,6 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) } } - spin_unlock_irqrestore(&gpio_lock, flags); - #ifdef CONFIG_PINCTRL INIT_LIST_HEAD(&gdev->pin_ranges); #endif