From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbbHTOp6 (ORCPT ); Thu, 20 Aug 2015 10:45:58 -0400 Received: from down.free-electrons.com ([37.187.137.238]:41577 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753376AbbHTOpz (ORCPT ); Thu, 20 Aug 2015 10:45:55 -0400 Date: Thu, 20 Aug 2015 16:45:52 +0200 From: Maxime Ripard To: Michal Suchanek Cc: linux-sunxi@googlegroups.com, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Russell King , Mark Brown , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: Re: [PATCH 2/9] spi: sun4i: fix FIFO limit Message-ID: <20150820144552.GU30520@lukather> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sDhuxz86kt5qlkuV" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --sDhuxz86kt5qlkuV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 20, 2015 at 02:19:46PM -0000, Michal Suchanek wrote: > When testing SPI without DMA I noticed that filling the FIFO on the > spi controller causes timeout. >=20 > Always leave room for one byte in the FIFO. >=20 > Signed-off-by: Michal Suchanek > --- > drivers/spi/spi-sun4i.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c > index 48532ec..707f61b 100644 > --- a/drivers/spi/spi-sun4i.c > +++ b/drivers/spi/spi-sun4i.c > @@ -178,6 +178,8 @@ static int sun4i_spi_transfer_one(struct spi_master *= master, > /* We don't support transfer larger than the FIFO */ > if (tfr->len > SUN4I_FIFO_DEPTH) > return -EINVAL; > + if (tfr->tx_buf && tfr->len =3D> SUN4I_FIFO_DEPTH) > + return -EINVAL; Shouldn't you fix the condition just above instead? > =20 > reinit_completion(&sspi->done); > sspi->tx_buf =3D tfr->tx_buf; > @@ -271,7 +273,9 @@ static int sun4i_spi_transfer_one(struct spi_master *= master, > sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len)); > =20 > /* Fill the TX FIFO */ > - sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH); > + /* Filling the fifo fully causes timeout for some reason > + * at least on spi2 on a10s */ Please use the proper comment style. And it only happens on that particular SPI controller and SoC combination? > + sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH - 1); > =20 > /* Enable the interrupts */ > sun4i_spi_write(sspi, SUN4I_INT_CTL_REG, SUN4I_INT_CTL_TC); > --=20 > 2.1.4 >=20 --=20 Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com --sDhuxz86kt5qlkuV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV1eggAAoJEBx+YmzsjxAgOEkP/RHXkMH88o4VB/3982k0fzxn +qEVSerramxQl6u8aB6Xf5BzhhSEjXuxg0RFhdPShNOwNzJgyyqOHUdsRw9bE6tL DvDT8WmGT5qug6ep7+0m3apN//pV+5P8wjXlpdkd0cRP0Xq9XiB67PCPUalteq3r 6hzXfyPVpwlZ3opEEF+8GrR4AfXN6j5KxPHMY6nHmCVBjzZiQ0x7ZD84jaymVQeb odlUkaj9BKr5bXE/0M4bwyiA/xIpbUHdKo+g4Zp3NwfbRMTD8J2+1SxwDPGaozTR 5ea3a49ldW5eW/YLcirZY8Sscuns6q55V+XooDUVZ0tQ0CB7Olou+zSrFZELpiH9 AIT2pRbjDZ2HrZ5LDq9pZ0xuGE2W8XYAnCzqGihBpFNeFvit5kvyJLjCugHUakH/ 2tREA79N9KPCCcQL+DRa9EWw5cosTF9Hlh7TQPaov0Uuboh954XrZ1bTiu8w2pYz YBt2TG3r9ftAChsr51KDfpM2ZamsvG82/eqyQNRyIhOvGnHD/ore/QrXGPEszpeB nbfV6/zDP4gp9TeqhsN2WNTCznDqAgUUyHXonOZ2RP3W284DHyljZeZLP3s+lIkX DkeqDDv25W1LtOy3E2fK4Wk/gKUxVMavi+ueV8RKuMYJsu0ttYZYaIcy/jXX+6qY XTJovOJRs55a9VKAubCr =E/rm -----END PGP SIGNATURE----- --sDhuxz86kt5qlkuV--