Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1055090lqd; Thu, 25 Apr 2024 05:02:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUf+r+DVeUlUoZu5R++qcTRAvHOeZkij1tbfLy7M3MhLB+B5vvjlkiFxWxHo4g8BAYyF4zO2h5J6tQZ+wZQSZZH/rdXca7E9Y4URndp3A== X-Google-Smtp-Source: AGHT+IFPeoVeikdA82BmOGlpFI4ydMoDLkWbck8X4gOEEtrLlFDh1BgHVFC5adW+qngk47Tmd2Be X-Received: by 2002:a05:620a:414b:b0:790:9b9a:4c02 with SMTP id k11-20020a05620a414b00b007909b9a4c02mr2187232qko.18.1714046542517; Thu, 25 Apr 2024 05:02:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714046542; cv=pass; d=google.com; s=arc-20160816; b=RtoHNYiQbkmh8THh9s3YOKfSW9WKmXr6cdNdA1psm53yEjL3FTSa2mdjdSO+NveEdW hQikvBEwUsgM1M+/K5+yVqE1YbDvkS0IpbUqZeDMClhuam10S5I0WI2AABJTS8r5nizF E8cduo2kxVM8qafn43F9a6do1xq3HG5+T54Slgax/H570YVVb7udeIgzvfY9/NIN6h2t IVi9sJjLnzLpLgtVpAIM3rtCDHj3GgbGrR5NR/It07V4FptUjK10gypoHRJHVMjzmhyI RGNc3Mw3yvBDqJ7VTvwo861LOtJWuOW28v4e3opxgV48zkHewu5W75BGy+4+DHX5XHMv ihNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=aOQGVc2AXMNhwFugtq9I0wPiPL5PR7tEoxpIWOfUKjc=; fh=+Mg2Kj2NEITO1dL1pprHRL0yJ0Bd7LIsW3+Xol/yND8=; b=MtAo6fbnoQe0S1M0UWPNE78j75fusRS6erqd8USZqsqJRQHdOBY2hqUKhRfYmf0iA+ ajeDfYHmSJCMAGwC8iwv7eIKQDwqZcgQHP+ZfQlwhEDr1chFy5aGP8Df+Ct8dlXM+B4D +XiCCs8Z52SfbGqPm4cDLKT7ddpAHhWOascc9mCLi1MEpdoW6RTzsRK+xKApy7bSOzQp 3R7PB2+bwT01+ckVD04b9wZ+UxtDbWIHleFUWgjW0bRJ1hatY1rB7Bwrbt2qPIRZ2ISs TsW28i/A87Cd8wbfXOiYXcKlKurbdlMtSZL+BvuSdMVwVw+kHC4YWdG1GUGnzXkWLweW OWyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ssZnt+F6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t30-20020a05620a035e00b0078d632ee280si17019581qkm.673.2024.04.25.05.02.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 05:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ssZnt+F6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 345131C21802 for ; Thu, 25 Apr 2024 12:02:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE69317C91; Thu, 25 Apr 2024 12:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ssZnt+F6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDC9884E0E; Thu, 25 Apr 2024 12:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714046535; cv=none; b=LcW0FfjMglvyzK+P9A/2sz74AdHpYZmk5W23chi8/ocY6Zr0YqfEc3pSE8wNWy3kC8V0qKfSzW2l1Hh5Y8t3sghl9iw9AGYZabyX1rF85fUULVADoEXJZ88FPHWoxqh9l2YDE15UsooloBDRSMfP8wiqa1D1SNyEtIeIUDrwFeE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714046535; c=relaxed/simple; bh=IsokxEzMjspQdJ6vbgSWEZO+bwVScekTaycFJ/Dr5nM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FadfTfHAfGLJboiZmGniFIpW3JDMjvoVp1tz97fGMXMJCyqZ0CPWQZF0JgxOdvuxheheGOuFau418tbZWUudqyLz1xiDV2tSKpulI37YCX5Vw+G/cH5wyyPuOEl5NecqKd6V3iKZiqwyOv7BRzk+Im4hqxuajuZG6lxafkPjaBk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ssZnt+F6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D7DC113CC; Thu, 25 Apr 2024 12:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714046534; bh=IsokxEzMjspQdJ6vbgSWEZO+bwVScekTaycFJ/Dr5nM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ssZnt+F6c5C7fMP2Rv+zpjBsDZUzPNNQxiUU3+aKm/gMy76wi/kViatVTn0CwizWF GKQmIY/KZtpsqcd3hGGWRqVBKFxKqfg/qhEFgvkPtoQ1Ivpaij54PeyWnWD86GOw+a ETQQ/q97VlYlkalLlE2f1QK8rzoFmCIfRROFKBF8GkTtOEAtg3pTvxbwd7F6CjYsDs wYIImnz+C3zwgR/vFCMBBUwSGAHZyw9Ar48HwrAeH/dS3xzUEh87u1PeUlPfub/0qb ADx988KGvC5r/QxV6gr3xd8jHidY7Afv0fAUZA3fRMj9svI5UE6nozaR80ECjOqEnn GH0q3p3x2sheA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rzxnq-000000001yQ-0MAo; Thu, 25 Apr 2024 14:02:14 +0200 Date: Thu, 25 Apr 2024 14:02:14 +0200 From: Johan Hovold To: Bjorn Andersson Cc: Bjorn Andersson , Linus Walleij , Brian Norris , Jaiganesh Narayanan , Doug Anderson , linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] pinctrl: qcom: Fix behavior in abscense of open-drain support Message-ID: References: <20240424-tlmm-open-drain-v1-1-9dd2041f0532@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240424-tlmm-open-drain-v1-1-9dd2041f0532@quicinc.com> On Wed, Apr 24, 2024 at 08:45:31PM -0700, Bjorn Andersson wrote: > When a GPIO is configured as OPEN_DRAIN gpiolib will in > gpiod_direction_output() attempt to configure the open-drain property of > the hardware and if this fails fall back to software emulation of this > state. > > The TLMM block in most Qualcomm platform does not implement such > functionality, so this call would be expected to fail. But due to lack > of checks for this condition, the zero-initialized od_bit will cause > this request to silently corrupt the lowest bit in the config register > (which typically is part of the bias configuration) and happily continue > on. > > Fix this by checking if the od_bit value is unspecified and if so fail > the request to avoid the unexpected state, and to make sure the software > fallback actually kicks in. Fortunately, this is currently not a problem as the gpiochip driver does not implement the set_config() callback, which means that the attempt to change the pin configuration currently always fails with -ENOTSUP (see gpio_do_set_config()). Specifically, this means that the software fallback kicks in, which I had already verified. Now, perhaps there is some other path which can allow you to end up here, but it's at least not via gpiod_direction_output(). The msm pinctrl binding does not allow 'drive-open-drain' so that path should also be ok unless you have a non-conformant devicetree. > It is assumed for now that no implementation will come into existence > with BIT(0) being the open-drain bit, simply for convenience sake. > > Fixes: 13355ca35cd1 ("pinctrl: qcom: ipq4019: add open drain support") I guess hardware open-drain mode has never been properly tested on ipq4019. > Signed-off-by: Bjorn Andersson > --- > drivers/pinctrl/qcom/pinctrl-msm.c | 2 ++ > drivers/pinctrl/qcom/pinctrl-msm.h | 3 ++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c > index aeaf0d1958f5..329474dc21c0 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -313,6 +313,8 @@ static int msm_config_reg(struct msm_pinctrl *pctrl, > *mask |= BIT(g->i2c_pull_bit) >> *bit; > break; > case PIN_CONFIG_DRIVE_OPEN_DRAIN: > + if (!g->od_bit) > + return -EOPNOTSUPP; I believe this should be -ENOTSUPP, which the rest of the driver and subsystem appear to use. > *bit = g->od_bit; > *mask = 1; > break; Johan