Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1776906imm; Thu, 19 Jul 2018 07:43:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdH9vtdJ1guVv1vVcVWoFoISpLUBWuiVOaqY2G/YVnCzMXocL3TjENmSrP39OSbVXciFGOv X-Received: by 2002:a63:7e1a:: with SMTP id z26-v6mr10248561pgc.278.1532011418829; Thu, 19 Jul 2018 07:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532011418; cv=none; d=google.com; s=arc-20160816; b=YeJSBZnjxQQXlvl9wR4/BMBE8TuRKJBsvEeTamwG3ZUvJq6zn53MoVHS3z1Zey7naf WUIWi0dfNJ5epz+mEQPmAxflTUfYrz9pfcf37pl75RDIadZouz2lf8sbGsp4Hc0tC+5L ot1XeMfST77d+SCzjESVuxKymYwRQXSj2kBR1akFHSKJkFRAx1uq2Vmcmh6qlbRQL31v WlL9xwEtT17tiU/u+Lui5HaIQgtsWR7Y7YRnzkbb+NOOB554ahDrpv6vbjlKEHf6auB2 ZmGoL/xh7M6PLEUG2DMhSGyL8MihQCwvJFeg6UC4gNo/SRdd/4KZaPYH3pdAy7OlsnDQ MOwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:arc-authentication-results; bh=vWkRTtbsev7zG9FQK3Kd6QjbwU++fIiW3sKwoAfOgNE=; b=PAd3G+Zcut0w0+56fyLRtgmznO53/HPwZ25kq7mz+iNfcoJIbbYbr9t46RQjBhdWbY S2dB/7s/EJAQM0yXIZ3ooarUYW7n2gdafwtsNMp20guvCx77//yUBCePql3yNUgdXpjp tdie8jyb23y4ZCRBscpbzXgKu2+XOdAVs+KNkTkjD0pE/GNSO6r21fq7NA5ZUV1PpOXd BWZGRUhjM5mldeFvjIqaAW2k29+cCbaj3pROOWASVrf1Pktf8Ows+vC3j1+lyCFOsmwU Nml+uTm7yglGAOKrStPj/0/HPBrRp8G/v4GOJxxKAx290Xf0n7al4ymAcj3i+PP0OtM9 9LLQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14-v6si6082026pgc.179.2018.07.19.07.43.24; Thu, 19 Jul 2018 07:43:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731856AbeGSPZR (ORCPT + 99 others); Thu, 19 Jul 2018 11:25:17 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:17209 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727441AbeGSPZR (ORCPT ); Thu, 19 Jul 2018 11:25:17 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1, AES128-SHA) id ; Thu, 19 Jul 2018 07:41:56 -0700 Received: from HQMAIL101.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 19 Jul 2018 07:41:48 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 19 Jul 2018 07:41:48 -0700 Received: from [10.21.132.122] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 19 Jul 2018 14:41:46 +0000 From: Jon Hunter Subject: Re: [PATCH] gpio: tegra: Fix tegra_gpio_irq_set_type() To: Dmitry Osipenko , Linus Walleij , Thierry Reding CC: , , References: <20180717161038.21500-1-digetx@gmail.com> Message-ID: <2384dc28-52ba-a415-9787-6ba985f767c2@nvidia.com> Date: Thu, 19 Jul 2018 15:41:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180717161038.21500-1-digetx@gmail.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL108.nvidia.com (172.18.146.13) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry On 17/07/18 17:10, Dmitry Osipenko wrote: > Commit 36b312792b97 ("gpiolib: Respect error code of ->get_direction()") > broke tegra_gpio_irq_set_type() because requesting of GPIO direction must > be done after enabling GPIO function for a pin. > > This patch fixes drivers probe failure like this: > > gpio gpiochip0: (tegra-gpio): gpiochip_lock_as_irq: cannot get GPIO direction > tegra-gpio 6000d000.gpio: unable to lock Tegra GPIO 144 as IRQ > > Fixes: 36b312792b97 ("gpiolib: Respect error code of ->get_direction()") > Signed-off-by: Dmitry Osipenko > --- > drivers/gpio/gpio-tegra.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c > index 94396caaca75..22e7c99ed69e 100644 > --- a/drivers/gpio/gpio-tegra.c > +++ b/drivers/gpio/gpio-tegra.c > @@ -323,13 +323,6 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) > return -EINVAL; > } > > - ret = gpiochip_lock_as_irq(&tgi->gc, gpio); > - if (ret) { > - dev_err(tgi->dev, > - "unable to lock Tegra GPIO %u as IRQ\n", gpio); > - return ret; > - } > - > spin_lock_irqsave(&bank->lvl_lock[port], flags); > > val = tegra_gpio_readl(tgi, GPIO_INT_LVL(tgi, gpio)); > @@ -342,6 +335,14 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) > tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, gpio), gpio, 0); > tegra_gpio_enable(tgi, gpio); > > + ret = gpiochip_lock_as_irq(&tgi->gc, gpio); > + if (ret) { > + dev_err(tgi->dev, > + "unable to lock Tegra GPIO %u as IRQ\n", gpio); > + tegra_gpio_disable(tgi, gpio); > + return ret; > + } > + > if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) > irq_set_handler_locked(d, handle_level_irq); > else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) Thanks for reporting this. I am seeing this as well on Tegra20 Ventana and Tegra30 Cardhu looking at the boot log. Given that gpiochip_lock_as_irq is checking the direction, the above fix looks good to me. So ... Acked-by: Jon Hunter Tested-by: Jon Hunter Cheers Jon -- nvpublic