Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1552137imm; Fri, 6 Jul 2018 02:07:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2Vkd4Q2Jl+qJqECDrwVcgx5pgNjL5pI73gGNb5+I7j0vNVnJk+ufERo0lMx7D619GQk78 X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr9883194pfh.141.1530868031646; Fri, 06 Jul 2018 02:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530868031; cv=none; d=google.com; s=arc-20160816; b=vtJE20X3z5Mkqd88aqSHPiUuP9nNj295z+JwYm7qH5brk7KEApLp8ao0AwgX2gfTcH Rvp25oHagYwsrOQES0MK5b6xaA37tt3IKDjlwauMO8HkHB6xyW4iRvnOs3oAN2itI2yM 0HcxxOqdurkz+8KFxZV4z80OwcEl1FaRsUdjjknQLH8CM+zQZhJIBMXcbr5BQH0clvQD ZeSp7iKQ9iAs9prCLruxxVWIrD6mZmkNaaTFiR+K641PACDCqz7oDS6XzL3IOzXXFTNZ JfWC6bf5/1M/i7+YADv59AoZA/YCc19Tve1uUjCyzHYdaxlcMpgCZ9aviS+jvnEHU+Pi c3Ag== 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:from:references:cc:to:subject:arc-authentication-results; bh=DM++fen+U4xur0DfpTF7/8j7qRib0NUHw/iDOOCNrCQ=; b=UvRcQj+FAdmjCSSSDrLMHbsIGjncjcoOpeth0nMOFmMhnZLu9R9pSTQsvi66SWbIpQ U3Gl11nPEJpn3+Y4fv0GbRR18bDicURxhqJIieBG4urHP5uy5ec3yidavVW7xRjH41a/ 0pdo2TgEIsk1wZ5pF2Gvb1PgHFZEhE67w1aKkimnaY6dSZgpyLoGzMvbaG7V08bS+n+e zuuffcZd2ftZISIchqZsAyLZDJzdEvoPIyr3vBB9gLUfGIe6/cs2xmMVUJRvBZTwWB1Z 7I4IGBtfrBc8RSdDLxUPTR+yPceHVKS9nF/cJqp3zy57M1ryOn6eWBGDiMG3cB4Z/jWZ faEw== 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=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k30-v6si7738533pgn.258.2018.07.06.02.06.55; Fri, 06 Jul 2018 02:07:11 -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=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753860AbeGFJGT (ORCPT + 99 others); Fri, 6 Jul 2018 05:06:19 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:56828 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753056AbeGFJGO (ORCPT ); Fri, 6 Jul 2018 05:06:14 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6693nmk006622; Fri, 6 Jul 2018 04:03:58 -0500 Authentication-Results: ppops.net; spf=none smtp.mailfrom=rf@opensource.cirrus.com Received: from mail3.cirrus.com ([87.246.76.56]) by mx0a-001ae601.pphosted.com with ESMTP id 2k0dnv3ecj-1; Fri, 06 Jul 2018 04:03:58 -0500 Received: from EX17.ad.cirrus.com (ex17.ad.cirrus.com [172.20.9.81]) by mail3.cirrus.com (Postfix) with ESMTP id 91D3C611C8AC; Fri, 6 Jul 2018 04:04:57 -0500 (CDT) Received: from imbe.wolfsonmicro.main (198.61.95.81) by EX17.ad.cirrus.com (172.20.9.81) with Microsoft SMTP Server id 14.3.301.0; Fri, 6 Jul 2018 10:03:57 +0100 Received: from [198.90.251.121] (edi-sw-dsktp006.ad.cirrus.com [198.90.251.121]) by imbe.wolfsonmicro.main (8.14.4/8.14.4) with ESMTP id w6693raW028179; Fri, 6 Jul 2018 10:03:54 +0100 Subject: Re: [PATCH] gpiolib: Defer on non-DT find_chip_by_name() failure To: Janusz Krzysztofik , Lee Jones CC: Boris Brezillon , Linus Walleij , , , Wolfram Sang , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Fabio Estevam , Phil Reid , Lucas Stach , Clemens Gruber , Peter Rosin , , References: <20180703172635.32508-1-jmkrzyszt@gmail.com> <7058252.SGNltMTCCa@z50> <20180705055037.GI496@dell> <1579112.qQSMXVQn9s@z50> From: Richard Fitzgerald Message-ID: <4ecc2072-3ec3-6e9b-576f-fd05559e7634@opensource.cirrus.com> Date: Fri, 6 Jul 2018 10:03:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1579112.qQSMXVQn9s@z50> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807060101 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/07/18 21:56, Janusz Krzysztofik wrote: > On Thursday, July 5, 2018 7:50:37 AM CEST Lee Jones wrote: >> On Wed, 04 Jul 2018, Janusz Krzysztofik wrote: >>> On Tuesday, July 3, 2018 7:31:41 PM CEST Boris Brezillon wrote: >>>> Hi Janusz, >>>> >>>> On Tue, 3 Jul 2018 19:26:35 +0200 >>>> >>>> Janusz Krzysztofik wrote: >>>>> Avoid replication of error code conversion in non-DT GPIO consumers' >>>>> code by returning -EPROBE_DEFER from gpiod_find() in case a chip >>>>> identified by its label in a registered lookup table is not ready. >>>>> >>>>> See https://lkml.org/lkml/2018/5/30/176 for example case. >>>>> >>>>> Signed-off-by: Janusz Krzysztofik >>>>> --- >>>>> If accepted, please add >>>>> >>>>> Suggested-by: Boris Brezillon >>>>> >>>>> if Boris doesn't mind. >>>>> >>>>> Thanks, >>>>> Janusz >>>>> >>>>> drivers/gpio/gpiolib.c | 13 ++++++++++--- >>>>> 1 file changed, 10 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c >>>>> index e11a3bb03820..15dc77c80328 100644 >>>>> --- a/drivers/gpio/gpiolib.c >>>>> +++ b/drivers/gpio/gpiolib.c >>>>> @@ -3639,9 +3639,16 @@ static struct gpio_desc *gpiod_find(struct >>>>> device >>>>> *dev, const char *con_id,> >>>>> >>>>> chip = find_chip_by_name(p->chip_label); >>>>> >>>>> if (!chip) { >>>>> >>>>> - dev_err(dev, "cannot find GPIO chip %s\n", >>>>> - p->chip_label); >>>>> - return ERR_PTR(-ENODEV); >>>>> + /* >>>>> + * As the lookup table indicates a chip with >>>>> + * p->chip_label should exist, assume it may >>>>> + * still appear latar and let the interested >>>>> >>>> ^ later >>>>> >>>>> + * consumer be probed again or let the Deferred >>>>> + * Probe infrastructure handle the error. >>>>> + */ >>>>> + dev_warn(dev, "cannot find GPIO chip %s, deferring\n", >>>>> + p->chip_label); >>>>> + return ERR_PTR(-EPROBE_DEFER); >>>>> >>>>> } >>>>> >>>>> if (chip->ngpio <= p->chip_hwnum) { >>>> >>>> Looks good otherwise. Let's hope we're not breaking implementations >>>> testing for -ENODEV... >>> >>> I've reviewed them all and found two which I think may be affected: >>> - drivers/mfd/arizona-core.c, >>> - drivers/i2c/busses/i2c-imx.c. >>> As far as I can understand the code, both depend on error != -EPROBE_DEFER >>> in order to continue in degraded mode. I'm adding their maintainers to >>> the loop. >> From a quick glance, the -EPROBE_DEFER handing in Arizona Core appears >> to be correct. Would you mind explaining what your concerns are in >> more detail please? > > Hi > > That's more about handling -ENODEV rather than -EPROBE_DEFER. > > Before the change, if GPIO chip supposed to provide "reset" pin was not ready > during arizona_dev_init(), devm_gpiod_get() returned -ENODEV and device was > initialized in degraded mode, i.e., with no control over the "reset" pin. > After the change, gpiod_get() will return -EPROBE_DEFER in such case and > arizona_dev_init() won't succeed in case the GPIO chip doesn't appear later > for some reason. > > Thanks, > Januszz > > The intention is that if the DT node is missing, the Arizona driver can run using only soft reset, though there are limitations in that mode. This should return -ENOENT so that the Arizona driver will continue without a GPIO. If the DT defines a GPIO it is effectively saying that this GPIO is required so it is valid for the Arizona driver never to come up if the GPIO it is defined to depend on doesn't come up.