Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp509402imm; Fri, 8 Jun 2018 00:06:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJo3rhz8YC3LuTYzk8OpTRc6HiL6XYSg8gBE8rBumrYwRMLveWzgEc1k3BOODJQmrKqdXk9 X-Received: by 2002:a62:10c2:: with SMTP id 63-v6mr4778037pfq.229.1528441564122; Fri, 08 Jun 2018 00:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528441564; cv=none; d=google.com; s=arc-20160816; b=pjDtYjTs1wcSvx7vNB3Xc7ndkMDzeMJoPLWxm3H3P1a1m22o7LMXsILBbAFuSbLgOY rIGyQWqfi3ivZB8ytyXM6mX/Fxj57/SexnV4fZVjECK033x9adueYMtL5UMknM0qMwk9 lJK8lsY2Rzl1OAihpitgMn14YsColGMYk+BMG6PzM1OUfxulZ2QYFO939qwL82rp4wXi e0MQWgYQt69HvQcxrjFTTanL+JIMUzhXgmdmz2bXizTWtUql0yPmPrG8pjXkAEVFNZF6 yGm6NeCiLNpzP6wsdyS3KRCw30pqZ1D55yD0ieO2jOhNY8U9E+IcTxPEr/8oT9MEI/8O LzrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=odXg538ORH3kvz+OqwPYJ89zkj+f5TgrwVwf8UHs2lY=; b=m5uF7ELMsoR4kLJ1ZJSfuga4ysrz3DaViTS07OG6C9HlYUxwCCXMS03PcHy1bH93m5 f8KNEN080UR9ugGG70kyqUOSC1QTZd5tQ/hatKoX622rPQdktzdhE8/OiMSLxyUsFsMG vVB9NqGJv9CBM8d7WEHTflcdocYTX8Jl637ry4AaD3joXVtOOVN6uXZ3WiJdKV4KxUPk 8CcKx41m/XTFphFQ/eHlssCRqcaKDaLH23ejbpamsDaVRu8c3Ecef2dBRd+zEYkIZxhL NeWO45VUoIoaIz5yf2oVikN+y6GDzw3sUbo2shSXIwvziwbFShEcn20b+R/3y2pgWeJ7 /JhQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 134-v6si24395001pgc.116.2018.06.08.00.05.49; Fri, 08 Jun 2018 00:06:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbeFHHFO (ORCPT + 99 others); Fri, 8 Jun 2018 03:05:14 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:45417 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbeFHHFK (ORCPT ); Fri, 8 Jun 2018 03:05:10 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRBSM-0004rw-0c; Fri, 08 Jun 2018 09:05:06 +0200 Received: from ore by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fRBSL-0003WX-BB; Fri, 08 Jun 2018 09:05:05 +0200 Date: Fri, 8 Jun 2018 09:05:05 +0200 From: Oleksij Rempel To: "Jonas Mark (BT-FIR/ENG1)" Cc: Andy Shevchenko , Wolfgang Grandegger , Marc Kleine-Budde , "linux-can@vger.kernel.org" , netdev , Linux Kernel Mailing List , Heiko Schocher , "ZHU Yi (BT-FIR/ENG1-Zhu)" Subject: Re: [PATCH 2/5] spi: implement companion-spi driver Message-ID: <20180608070505.gmirhvtqdr2uzvtw@pengutronix.de> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="g2iqv75r7rvnlvzl" Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:00:42 up 168 days, 19:38, 88 users, load average: 0.26, 0.14, 0.04 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --g2iqv75r7rvnlvzl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 08, 2018 at 06:56:23AM +0000, Jonas Mark (BT-FIR/ENG1) wrote: > Hi Oleksij, >=20 > > > > > + if (slave_is_not_busy(priv)) > > > > > + return 0; > > > > > + > > > > > > > > > + udelay(READY_POLL_US_GRAN); > > > > > > > > Should it be atomic? > > > > Can it use read_poll_* type of helpers instead? > > > > > > Yes, it shall be atomic because we need to reduce the latency at > > > detecting the de-assertion of the busy signal. We accept that this wi= ll > > > cost CPU time. > > > > > > In case the Companion itself is very busy and does not reply quickly = we > > > are have second polling loop below which sleeps longer and is non-ato= mic. > >=20 > > I can confirm, this make huge impact on protocol performance. And this > > protocol is not really the speed runner. >=20 > The challenge is that the protocol is synchronous and without back to > back transfers. >=20 > > you can send dummy message to set CS. > > + struct spi_transfer t =3D { > > + .len =3D 0, > > + .cs_change =3D 1, > > + }; > >=20 > > + /* send dummy to trigger CS */ > > + reinit_completion(&priv->fc_complete); > > + spi_sync_locked(spi, &m); > >=20 > > see my ancient unfinished code: > > https://patchwork.kernel.org/patch/9418511/ >=20 > We will check it out. >=20 > > In general, this part of the code, can be provided as separate driver > > which should be called as "SPI 5wire protocol". 3 wires for data, 1 - > > chip select, 1 - busy state. Since, the slave cant fit to normal SPI > > requirements, and can't be ready within predictable time, busy signal is > > needed. Providing this as separate driver or part of SPI framework > > should reduce the code for many different drivers. > >=20 > > The actual datagram on top of your spi companion should go to > > separate driver. There are similar (almost identical designs) > >=20 > > can :+ > > char:+ > > dw: + > > gpio:+--->some_multi_end_mux_protocol--->spi_5wire_protocol->spi---> > >=20 > > In my knowledge, only data format on top of spi_5wire_protocol is > > different. See my notes for similar topics: > > https://github.com/olerem/icc > > https://github.com/olerem/spi-5wire >=20 > With 5-wire protocol you are referencing to CLK, MISO, MOSI, CS (all > standard SPI signals) and an extra BUSY signal. What we implemented is > a 6-wire protocol. There is an additional REQUEST line where the SPI > slave requests a transfer. It is like a level triggered interrupt > request. >=20 > Yes, for making it more generic the code in drivers/spi/companion > could be split into a generic 6-wire protocol driver and a multiplexing > protocol on top of it. >=20 > How does a slave signal that it has data to be picked up with the > 5-wire protocol? The request and busy signals are multiplexed to one wire. So, it should be easy to implement both, 5 and 6 wire protocol in one driver. --=20 Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --g2iqv75r7rvnlvzl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEpENFL0P3hvQ7p0DDdQOiSHVI77QFAlsaKpcACgkQdQOiSHVI 77SLVQgAsKUqGPKHriKUVOOkpbR1bLA+4sdqYwgj3oxuRFwKxw1aCiGWsV4r3tZj C2wkzpXdHn0rN2ddX7vHscfB9/3+hKJWlTXP9g3b/69ZjGEGS8rfsSYqLf+rysQ4 C9VtrvxqbhFdU/IvNTUDYJUFF+pAWDDQOBXu8LhlUnaB9ppO9kpDnFDt9d9I9yn9 cf9EvzFMrS0obQJm0SECPAwI3B/IyAJxUYaUh5leOnsTSlBJO9Tj1FgvRAlSITsU Vbxpleq6x7t+Z3RqwyNKUPBzZwPZJxUeDzauZcWjmLdx4ExyJBPSrzEmkHVd2j+z JAy7nBstyT3zu8dkQMc1WajABMPETw== =Oh2u -----END PGP SIGNATURE----- --g2iqv75r7rvnlvzl--