From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Brown Subject: Re: [PATCH] [RFC] spi: pxa2xx: Do cs if restart the SSP during pxa2xx_spi_transfer_one() Date: Thu, 7 Mar 2019 16:09:24 +0000 Message-ID: <20190307160924.GE6529@sirena.org.uk> References: <20190307072424.18820-1-jin.xiao@intel.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9crTWz/Z+Zyzu20v" Cc: xiao jin , daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, yanmin.zhang@intel.com, bo To: Jarkko Nikula Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-spi.vger.kernel.org --9crTWz/Z+Zyzu20v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 07, 2019 at 05:26:53PM +0200, Jarkko Nikula wrote: > On 3/7/19 9:24 AM, xiao jin wrote: > > The patch is to do cs again if spi-pxa2xx restar the SSP during > > pxa2xx_spi_transfer_one() > Hmm.. please correct me if I'm wrong but pxa2xx_spi_unprepare_transfer() = is > called always when there is no more messages pending and the spi core sho= uld > have deasserted the CS already? Yes. > > @@ -1056,6 +1057,11 @@ static int pxa2xx_spi_transfer_one(struct spi_co= ntroller *master, > > if ((pxa2xx_spi_read(drv_data, SSCR0) !=3D cr0) > > || (pxa2xx_spi_read(drv_data, SSCR1) & change_mask) > > !=3D (cr1 & change_mask)) { > > + /* It needs to deassert the chip selection > > + * firstly before restart the SPP */ > > + need_cs_change =3D true; > > + cs_deassert(spi); > I think code comes here at the beginning of each transfer so will be hit > multiple times before pxa2xx_spi_unprepare_transfer() if SPI message > consists of multiple transfers. > This makes me wondering if the device driver setting up the "struct > spi_transfer" is maybe missing the cs_change flag set for transfers before > last one in case HW needs CS toggling between transfers? For instance what > following drivers are doing with the cs_change flag: > drivers/char/tpm/tpm_tis_spi.c: tpm_tis_spi_transfer() > drivers/input/touchscreen/ad7877.c: ad7877_read(), ad7877_read_adc() Right, this really feels like it's fixing the wrong thing. =20 --9crTWz/Z+Zyzu20v Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlyBQjMACgkQJNaLcl1U h9D+IAf/RPJBHypK+ouTHdrAKEfxDNywJpo2oajUzbpOk+84L90tpxhXxJqmNkfO wBqnszhfTMXP/bPgFKBRxni3WdiHW8De4enQ0SrP3MPUEh4t6j1iUsbTTpbocxbl SsosvIJKdjFTvz0oE5rUM6OKl5wB6ENyk2AFZffJxY0I3ktHkEgdSYJ1bi006x5X uIwEUJwM8I/wwo151dQXsUOGu93b7j92P6p5iTEnPL+gbiE/0X8OxCxe1KVveCbY flsc/Sk6IFJ2p4Ll5qKooM6Ef+/fCXiTeFkSIolUXBwnR04R2sC404aelPR2zj7X /EQ3J6/PFUg4m9aV/HQNiJCKp6bmXw== =7VDL -----END PGP SIGNATURE----- --9crTWz/Z+Zyzu20v-- 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=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT 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 3B3E1C43381 for ; Thu, 7 Mar 2019 16:09:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A7B12064A for ; Thu, 7 Mar 2019 16:09:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HvlcAC//"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sirena.org.uk header.i=@sirena.org.uk header.b="WxrE/1wr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A7B12064A 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-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vBtf0qqctuumZNMsbop8FFk8pc6UG+s0lxnnDt0VR7Q=; b=HvlcAC//0nKOVg//R0GXhdqVw m+/vH7CJXBKG0JzZDm8C7zXWyfWzhoBgmlYtBh/8Fj/sR97BBq98R2T/mqwrStvD85Kytp6r31zXf kLq7ZRorxVjv0fgTdmcLMrr8aAJYm/xL9seeHzQ3V89rhSF/xuQ8Cwy1zuZ+RnoChjShe7zyIFvNn TsDiX9BzRVUlwJXm5kVRuG3/6Oq+olJLOhDCzAovpbCEFchqrq5CdIJvqt7kMVeuK4TkuBWKWGFaH q2vrKtsne/s+HLQajuQUdmvLPHawI4KYpDEpJh+mZ2ZF+59zdEoEwJ+HrzD7tvCDBa0ReHSX6BHCV UkHy0amvg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1vab-0002i4-HR; Thu, 07 Mar 2019 16:09:45 +0000 Received: from heliosphere.sirena.org.uk ([2a01:7e01::f03c:91ff:fed4:a3b6]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1vaT-0002VR-GN for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2019 16:09:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rV/JEOtQ34mI2W1JyeD2iMtK5Fe2tHJoIWT2YvMjkdY=; b=WxrE/1wryIiCnpx1GKWCtGF9v ZsKdYiUTx/0d2kG9ssUGID1mmHsZ/AEiZ2y5jA/MDysNDqMl4uV4BjXpTmmF8Wbey/18yxTjzn9Zu 2OrnqOl8nY0G3fYhvdbtkdeTSXheDnV3Hqu6KB9qi+O9N7P/mx3MIiHp8ZDl0gpbVK5cs=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1h1vaH-0006Nf-1U; Thu, 07 Mar 2019 16:09:25 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 630F61128841; Thu, 7 Mar 2019 16:09:24 +0000 (GMT) Date: Thu, 7 Mar 2019 16:09:24 +0000 From: Mark Brown To: Jarkko Nikula Subject: Re: [PATCH] [RFC] spi: pxa2xx: Do cs if restart the SSP during pxa2xx_spi_transfer_one() Message-ID: <20190307160924.GE6529@sirena.org.uk> References: <20190307072424.18820-1-jin.xiao@intel.com> MIME-Version: 1.0 In-Reply-To: X-Cookie: All celebrity voices impersonated. User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190307_080938_012067_1F121670 X-CRM114-Status: GOOD ( 16.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yanmin.zhang@intel.com, linux-kernel@vger.kernel.org, haojian.zhuang@gmail.com, linux-spi@vger.kernel.org, bo , linux-arm-kernel@lists.infradead.org, robert.jarzmik@free.fr, xiao jin , daniel@zonque.org Content-Type: multipart/mixed; boundary="===============2936178201304537537==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============2936178201304537537== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9crTWz/Z+Zyzu20v" Content-Disposition: inline --9crTWz/Z+Zyzu20v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 07, 2019 at 05:26:53PM +0200, Jarkko Nikula wrote: > On 3/7/19 9:24 AM, xiao jin wrote: > > The patch is to do cs again if spi-pxa2xx restar the SSP during > > pxa2xx_spi_transfer_one() > Hmm.. please correct me if I'm wrong but pxa2xx_spi_unprepare_transfer() = is > called always when there is no more messages pending and the spi core sho= uld > have deasserted the CS already? Yes. > > @@ -1056,6 +1057,11 @@ static int pxa2xx_spi_transfer_one(struct spi_co= ntroller *master, > > if ((pxa2xx_spi_read(drv_data, SSCR0) !=3D cr0) > > || (pxa2xx_spi_read(drv_data, SSCR1) & change_mask) > > !=3D (cr1 & change_mask)) { > > + /* It needs to deassert the chip selection > > + * firstly before restart the SPP */ > > + need_cs_change =3D true; > > + cs_deassert(spi); > I think code comes here at the beginning of each transfer so will be hit > multiple times before pxa2xx_spi_unprepare_transfer() if SPI message > consists of multiple transfers. > This makes me wondering if the device driver setting up the "struct > spi_transfer" is maybe missing the cs_change flag set for transfers before > last one in case HW needs CS toggling between transfers? For instance what > following drivers are doing with the cs_change flag: > drivers/char/tpm/tpm_tis_spi.c: tpm_tis_spi_transfer() > drivers/input/touchscreen/ad7877.c: ad7877_read(), ad7877_read_adc() Right, this really feels like it's fixing the wrong thing. =20 --9crTWz/Z+Zyzu20v Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlyBQjMACgkQJNaLcl1U h9D+IAf/RPJBHypK+ouTHdrAKEfxDNywJpo2oajUzbpOk+84L90tpxhXxJqmNkfO wBqnszhfTMXP/bPgFKBRxni3WdiHW8De4enQ0SrP3MPUEh4t6j1iUsbTTpbocxbl SsosvIJKdjFTvz0oE5rUM6OKl5wB6ENyk2AFZffJxY0I3ktHkEgdSYJ1bi006x5X uIwEUJwM8I/wwo151dQXsUOGu93b7j92P6p5iTEnPL+gbiE/0X8OxCxe1KVveCbY flsc/Sk6IFJ2p4Ll5qKooM6Ef+/fCXiTeFkSIolUXBwnR04R2sC404aelPR2zj7X /EQ3J6/PFUg4m9aV/HQNiJCKp6bmXw== =7VDL -----END PGP SIGNATURE----- --9crTWz/Z+Zyzu20v-- --===============2936178201304537537== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============2936178201304537537==--