Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp602193imm; Fri, 21 Sep 2018 05:26:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZyUnIM4e39q+df1TuqZ4Z8/Y4XBb0kTwD8AkwS347hO9FEL1OpW0oXHo4peLJsmmnx2G14 X-Received: by 2002:a17:902:6e4:: with SMTP id 91-v6mr2575917plh.226.1537532788874; Fri, 21 Sep 2018 05:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537532788; cv=none; d=google.com; s=arc-20160816; b=0VpLXO7njCTHZC1/y+MZGpunGI6s9OOQv5u+yLvXYUhPy/nioTQKsOsa1hHxN8ExgD yjIMjuG8+B79Ri0S0FAkDc6axfNPGyjC20ncMGh09v2zrmO+/Cq9PY05kjEjS/gi+bkj 2RJP5lqYLX1+kWQzYCgOuVBnSI0KdPAIpTcfS2NkEX5CfNW/Egfb1nLh/BhnrzwdOktM FHB5pPLPtEjQOEkcgI7zwA59Q1OlMnWO1+IeXkzSubQPxTKEHh/IUXq9MDdPfOI13Kl1 udVyJhTzaXIG7XCyBcqT1MCopkYJ9v+mOySkmXXS3uPbByZojTzH1Mqa/Dwrasmg1ZWr Y8OA== 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:cc:references:to:subject:dkim-signature; bh=apBxaWY+pdbGXN6L+ou2TM/U11K/W40rnGirlRVaqbw=; b=zj5lNpBrltX5Qh036eVx5CNCeTWtko8Njb2mOMiepF3tEMrKwL54h2bKBUAgZLLG1u Dl6l8CDrTYBd1arnMmasjt8Dihv6+Gmch5Zh6tjergFvUQipn2dVVS+5u2zZ64YNP72P xg8sEwa8GwwLQPFYmLvv2T+MSYUqkgmmBQOTiQaqbIM0bXOv8OC02rOay5i9xUS/vKMV 3I4MxZY6fYtVgog6e5+kX2hlJ6/NW3sX8+qooEFtiJh1cDN2Y87O+0Hm4v3i10rI+r8j gpD+y0qzJu30B/6VYjVvJMf4Eg1RVAWq+m+AjNvbPxOl0+8J1wxrGOnUSg3Kh5iHn5Et M0Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Xke/41zr"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si25777668pgc.210.2018.09.21.05.26.11; Fri, 21 Sep 2018 05:26:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b="Xke/41zr"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389770AbeIUSN7 (ORCPT + 99 others); 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 >