From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8635BECE562 for ; Fri, 21 Sep 2018 12:25:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38D9121479 for ; Fri, 21 Sep 2018 12:25:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xke/41zr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38D9121479 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389789AbeIUSN7 (ORCPT ); Fri, 21 Sep 2018 14:13:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbeIUSN6 (ORCPT ); Fri, 21 Sep 2018 14:13:58 -0400 Received: from [192.168.1.75] (cpe-24-28-70-126.austin.res.rr.com [24.28.70.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F345920858; Fri, 21 Sep 2018 12:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1537532720; bh=79R6M3Ob2o3wZzMWL1qN/+PWKInW57a1zlLVLLowHzU=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From; b=Xke/41zrhn+WCDwCBSChR4rdFDzMK5QXiF+LsPrXiAJSqqko3LdCJN3CSDDmZdO97 Bfg4xDUyyNYfW1Jx/VVdFJWYUsCXFqF03samlhzPwxU13BXSZmez/aJj8hskFnaKub 7DmPWsriOLy1UM0xp0U6wySl/FA34KIXvmThWcIk= Subject: Re: [PATCH v2] gpiolib: Show correct direction from the beginning To: Jeffrey Hugo References: <20180921103604.13361-1-ricardo.ribalda@gmail.com> <20180921103604.13361-2-ricardo.ribalda@gmail.com> Cc: Ricardo Ribalda Delgado , Linus Walleij , swboyd@chromium.org, linux-gpio@vger.kernel.org, LKML From: Timur Tabi Message-ID: <7bda989e-3a7d-8a95-78b0-60b79e414245@kernel.org> Date: Fri, 21 Sep 2018 07:25:14 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180921103604.13361-2-ricardo.ribalda@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed 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 Jeff, can you test these two patches on Amberwing to make sure that they don't cause an XPU violation on boot? The call to gpiochip_line_is_valid() should return false on any GPIOs that aren't listed in the ACPI table. My concern is that this patch might be calling gpiochip_line_is_valid() too early, before all the arrays have been set up. Thanks. On 9/21/18 5:36 AM, Ricardo Ribalda Delgado wrote: > Current code assumes that the direction is input if direction_input > function is set. > This might not be the case on GPIOs with programmable direction. > > Signed-off-by: Ricardo Ribalda Delgado > --- > drivers/gpio/gpiolib.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 4b45de883ada..00c17f64d9ff 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -1352,7 +1352,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, > * it does, and in case chip->get_direction is not set, we may > * expose the wrong direction in sysfs. > */ > - desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; > + if (chip->get_direction && gpiochip_line_is_valid(chip, i)) > + desc->flags = !chip->get_direction(chip, i) ? > + (1 << FLAG_IS_OUT) : 0; > + else > + desc->flags = !chip->direction_input ? > + (1 << FLAG_IS_OUT) : 0; > } > > #ifdef CONFIG_PINCTRL >