Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3430065pxb; Mon, 18 Oct 2021 15:17:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlLSwYlfidVTAFXAFS8kyn1Qj951uh92Yl0/fN1QhOGTJnmsb4bIY9kSmWK0yjwByuuwHA X-Received: by 2002:a63:380e:: with SMTP id f14mr26175421pga.267.1634595457022; Mon, 18 Oct 2021 15:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634595457; cv=none; d=google.com; s=arc-20160816; b=SW7NptbMa8g7oKszGK3pyiv4S8Q2ywdn0eWmkFAp3rLgkUB79G/clvhmHdm512knve p7dAgGgG0dX86nQHKSIDmtBXXrqX46iRPcg4PzCvaeKaqZujIceAn+0JBCAoHIIp3e2f e0X8epFkEp3zHx4PWajxs73I9R8B+K/kJPacdZBhBN/ebPOTaL2Iy+vlEyzK8a1mT48n UgVfhUVYgc9CUYlC4r2xDYeyF11S+3fcVh6xngxZzjriATjtcYexaHgvDKbVxVXj2Cfj E+OmOZIGjVQymK/8RpeJ8kpNYjuDmGOs9E2lu+s/brJGToib5oswRjr0+yQr12OHO7yd dAYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=jhxLoLGAaXMagG35vknLHpwCy8O6UXvrfljSNFLbgC0=; b=g4x74lLvnLQzIa9yjOx+Z05eTqv/GBPbKP5mCw2amo2csM6WKJsQf7CRQzc5FZYXuS 3eUtpuRsRxC4+j/7RP1wxPO/dOZglwgIX9Pffyx7PHiVPuksrqajaOviEEhVg20HCAdw wDmOFpQxbUfBrz4HaC5Y4qAIYY5QvwGsIe32GqwfoF6flMq6PcbOUKsWhXc+XPVgKAjJ MP7spCAgP0AucIRi9hqOcsGSmSHhusieGlnRRYMOqoP5YhQ8i/hPvEb8VPuBAGx6PfIH ozN97zUul+8n5O4VA+P7h6ip13aoK2pIzpeaZ86xG11PCQgyxpdNRykgRxZgrf1LRlus i7sA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lw6si1119600pjb.95.2021.10.18.15.17.24; Mon, 18 Oct 2021 15:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232161AbhJRWRH (ORCPT + 99 others); Mon, 18 Oct 2021 18:17:07 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39640 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhJRWRH (ORCPT ); Mon, 18 Oct 2021 18:17:07 -0400 Received: from [IPv6:2401:4900:1c20:2044:d49c:4fd9:7471:bb74] (unknown [IPv6:2401:4900:1c20:2044:d49c:4fd9:7471:bb74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shreeya) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 2CD7D1F4128C; Mon, 18 Oct 2021 23:14:53 +0100 (BST) Subject: Re: [PATCH] gpio: Return EPROBE_DEFER if gc->to_irq is NULL To: Linus Walleij Cc: Bartosz Golaszewski , Wolfram Sang , "open list:GPIO SUBSYSTEM" , linux-kernel , linux-i2c , kernel@collabora.com References: <20211014110437.64764-1-shreeya.patel@collabora.com> From: Shreeya Patel Message-ID: Date: Tue, 19 Oct 2021 03:44:48 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/10/21 10:21 pm, Linus Walleij wrote: > On Thu, Oct 14, 2021 at 1:05 PM Shreeya Patel > wrote: > >> We are racing the registering of .to_irq when probing the >> i2c driver. This results in random failure of touchscreen >> devices. >> >> Following errors could be seen in dmesg logs when gc->to_irq is NULL >> >> [2.101857] i2c_hid i2c-FTS3528:00: HID over i2c has not been provided an Int IRQ >> [2.101953] i2c_hid: probe of i2c-FTS3528:00 failed with error -22 >> >> To avoid this situation, defer probing until to_irq is registered. >> >> This issue has been reported many times in past and people have been >> using workarounds like changing the pinctrl_amd to built-in instead >> of loading it as a module or by adding a softdep for pinctrl_amd into >> the config file. >> >> References :- >> https://bugzilla.kernel.org/show_bug.cgi?id=209413 >> https://github.com/Syniurge/i2c-amd-mp2/issues/3 >> >> Signed-off-by: Shreeya Patel > I understand the issue. > > There is one problem. > >> @@ -3084,7 +3084,7 @@ int gpiod_to_irq(const struct gpio_desc *desc) >> >> return retirq; >> } >> - return -ENXIO; >> + return -EPROBE_DEFER; > If you after five minutes plug in a USB FTDI or similar UART thing > with a GPIO expander, and someone request an IRQ from > one of those lines (they do not support interrupts), why should > it return -EPROBE_DEFER? > > The point is that I think this will in certain circumstances return > a bogus error. I was worried about the same but didn't really know under what scenario this could occur. Thanks for pointing this out. > > We cannot merge this other than with a fat comment above: > > /* > * This is semantically WRONG because the -EPROBE_DEFER > * is really just applicable during system bring-up. > */ > return -EPROBE_DEFER; > > Can we use some kind of late_initcall() to just switch this over > to -ENXIO after a while? I have sent a v2 which tries to fix this in an easy way. Let me know what do you think about that approach or else we could also think about using late_initcall(). Thanks, Shreeya Patel > Yours, > Linus Walleij