Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp232695rwb; Wed, 7 Dec 2022 17:13:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf72kjXNoWcb3hv1DtlChsM7mbj3mx3B/jFE8CdB9/uYDV9EUOZflvtGKhv89cZEt2DMid5Y X-Received: by 2002:aa7:804d:0:b0:573:c701:4c80 with SMTP id y13-20020aa7804d000000b00573c7014c80mr75523392pfm.37.1670461997037; Wed, 07 Dec 2022 17:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670461997; cv=none; d=google.com; s=arc-20160816; b=qBDk6WHpmESeBJYvjtqTIXKTLdfe3+yy21CI0kH6uh/dAFJDn1ocxJnpr3WEZys11k FH3BL+5cWFY2gnh9ROakXBd0EexrCU2UNFyEzV9lJat68QQfEeTrP6HsJQCsReYRZxcd Zmab3aWF0kzdlbqVIu0JJ44r945A18xUByyU83mZNcVoeS3zNhUts80cz2TCxqt27rmd Rws86KaoXQZJ3Vsfor642yemeTQwRRIAeNI9anyPj0dOISSHP1Szm0VUXK0NKVn7zfhM ozWJx5p4DSpzcTY69ziGc0At+xmSU3wl4FemhEnnfxGox/EjBLZgGYCJXJt9z9C+0F0P r5cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vzFgktuwaRPidWb2pU12cG5dAs7LJ+oJf2cZXi+LxTI=; b=iy8Ah7Lnm03sHEIZzpjW8lb+ySI+ZThjR0PpEO52lKvuCkgO/DH9aY+q4lLVKKYDyB qvwa9Ec7irI+RZ9FTRo8NFqYjDXQHA3KnmQYGuW8LLfsesKr9c9L/xiIlEgyOzQVGkqK r+aui3t/ql4vJMp7mg+WpWW3tLLqgjfa0DB6H+RazkubTkZxk7FKMO3MhhcXBL9B6VBC ZAynjenIQriCXd8siG9gyuqDrvZ71zYRnROUzQ68+nZw5HGjS/9wy+xLOXlJ3AJnfYUk FVGlrSMSKIqwkkORJc+yJ+KzYbEVwiIFLixh3dSwkn3wgHob4GoQOlYz1fnMEaz8/N/W Gw/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MfQDnXLU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020a170903234f00b0017872bc9843si24964387plh.137.2022.12.07.17.13.07; Wed, 07 Dec 2022 17:13:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MfQDnXLU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230183AbiLGXoi (ORCPT + 74 others); Wed, 7 Dec 2022 18:44:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbiLGXog (ORCPT ); Wed, 7 Dec 2022 18:44:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D85388565C; Wed, 7 Dec 2022 15:44:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 76BB061CFD; Wed, 7 Dec 2022 23:44:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF14BC433D6; Wed, 7 Dec 2022 23:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670456674; bh=vzFgktuwaRPidWb2pU12cG5dAs7LJ+oJf2cZXi+LxTI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MfQDnXLUfgTMPTxCYCpzvXC+bUdxJGgb80VCx1DLHpAdJs2CV4KfymvzvO+WABwCy 3qIKnUm/Ux/kout40G7r9tA1qVUYd6OCukGhraq+FaAzpQ1EydVJdyYp/eprKGm6/3 fBkd/OFz2tLketcozQhKJ1O4P/jkrnJ1xZrmME7TXNSGbgtHVl5BZ2kwtRxcjiNZJl Bx8nyC2m6TYRkKRx69He3W+h/Olb0VD1MXE4ryPDV3pzIXIrCK8DrspEQ+rEUsLoc5 CybVG6Hv1H0HTRFJFli1+YmNSkvChh8fDkxDI9oPjP7PZcWOapRaUXrXaA4HKgVOfk 3+1bbrbJfOsGw== Date: Wed, 7 Dec 2022 23:44:30 +0000 From: Mark Brown To: Kris Bahnsen Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, mark@embeddedts.com Subject: Re: [PATCH] spi: spi-gpio: Don't set MOSI as an input if not 3WIRE mode Message-ID: References: <20221207230853.6174-1-kris@embeddedTS.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="56KIyPEz17IU8OgZ" Content-Disposition: inline In-Reply-To: <20221207230853.6174-1-kris@embeddedTS.com> X-Cookie: What!? Me worry? X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --56KIyPEz17IU8OgZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 07, 2022 at 03:08:53PM -0800, Kris Bahnsen wrote: > The addition of 3WIRE support would affect MOSI direction even > when still in standard (4 wire) mode. This can lead to MOSI being > at an invalid logic level when a device driver sets an SPI > message with a NULL tx_buf. >=20 > spi.h states that if tx_buf is NULL then "zeros will be shifted > out ... " If MOSI is tristated then the data shifted out is subject > to pull resistors, keepers, or in the absence of those, noise. >=20 > This issue came to light when using spi-gpio connected to an > ADS7843 touchscreen controller. MOSI pulled high when clocking > MISO data in caused the SPI device to interpret this as a command > which would put the device in an unexpected and non-functional > state. A cleaner fix which is probably marginally more performant would be to make the setting of spi_gpio_set_direction() conditional on SPI_3WIRE - then we won't call into the function at all when not doing 3 wire, avoiding the issue entirely. > As an aside, I wasn't sure how to best put down the Fixes: tags. > 4b859db2c606 ("spi: spi-gpio: add SPI_3WIRE support") introduced the > actual bug, but 5132b3d28371 ("spi: gpio: Support 3WIRE high-impedance tu= rn-around") > modified that commit slightly and is what this patch actually applies > to. Let me know if marking both as fixes is incorrect and I can > create another patch. That's fine, it doesn't really matter either way. --56KIyPEz17IU8OgZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmORJV0ACgkQJNaLcl1U h9Be+Qf+MxW4hMRQzDRJd9NFAhwkIiirk2ELo1vuSbRGPl/593kSW6wvsgXW+0zG EWFNMMbJ0cJqDUbCxSOGAC9MCg0Rg6gDoFeFf0JLWzB1A6a7bRQ/jkzUqyQV/R0H LqCAaAPvqFseiYJmoIinWc6Qb/5ANNC9/VEt6wFNefFY4gXDcqQBS2ccN29cay62 2I6rfBf3646lDLVbZOpJe00HKwn0mJV7Ga8Amol6lNu8qrVHXlgXOJz6rJggTI+T FbGtaTtzYwwBCGj9najlZKH0R1UVY+cdqnkBwGLwymyR6534+kDIGqG6D9d/dtx7 J9Ftqf+gqMSYxLpSAweFLrRGJHbtAg== =zBN5 -----END PGP SIGNATURE----- --56KIyPEz17IU8OgZ--