All of lore.kernel.org
 help / color / mirror / Atom feed
From: fixed-term.Oleksij.Rempel <fixed-term.Oleksij.Rempel@de.bosch.com>
To: Mark Brown <broonie@kernel.org>, Oleksij Rempel <linux@rempel-privat.de>
Cc: geert@linux-m68k.org, dirk.behme@de.bosch.com,
	linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
	robh+dt@kernel.org
Subject: Re: [PATCH 1/6] spi: add flow controll support
Date: Wed, 2 Mar 2016 07:48:55 +0100	[thread overview]
Message-ID: <56D68CD7.8000203@de.bosch.com> (raw)
In-Reply-To: <20160302024656.GR18327@sirena.org.uk>

[-- Attachment #1: Type: text/plain, Size: 3485 bytes --]



On 02.03.2016 03:46, Mark Brown wrote:
> On Tue, Mar 01, 2016 at 03:43:15PM +0100, Oleksij Rempel wrote:
> 
> At a high level I think this needs splitting up quite a bit - this is
> defining a new DT binding, a new core interface for controlling flow
> control and a bitbanging flow control implementation.  At least those
> three bits should probably be separate patches, it may make sense to
> split up the bitbanging implementation some more too.

ok

>> Different HW implement different variants of SPI based flow control (FC).
>> To flexible FC implementation a spited it to fallowing common parts:
>> Flow control: Request Sequence
>> Master CS   |-------2\_____________________|
>> Slave  FC   |-----1\_______________________|
>> DATA        |-----------3\_________________|
> 
> I don't know what these pictures mean since you don't say what "slave
> FC" is - I'm assuming you mean a separate pin but you need to specify
> that.  It really looks like this would be clearer with words rather than
> ASCII art.

Ok, Slave FC means a flow control line controlled by Slave - MISO

> 
> In the case above this looks like a normal interrupt from a device, I'm
> not clear what is different here or why this is in the core?

At least our HW use tree different signals for flow control. One of it
is Request Signal.

>> Flow control: ACK End of Data
>> Master CS   |______________________/2------|
>> Slave  FC   |________________________/3----|
>> DATA        |__________________/1----------|
> 
> Why would anything care about this case and why is it part of the SPI
> protocol rather than something that the device driver would do?

This case covers real bugs and in our case we need to detect if master
or slave stalls under one second. If communication problem is detected,
some of recovery scenarios is initiated. Like i said, this protocol is
used for automotive industry.
Please see two attached screen shots of Master and Slave initiated
transfers.

>> +	if (atomic_read(&spi->active_rq)) {
>> +		if (!spi_fc_equal_cs(spi))
>> +			dev_warn(&spi->dev, "Got request, but device is not ready\n");
>> +		atomic_set(&spi->active_rq, 0);
>> +		return ret;
>> +	}
> 
> Atomic operations are very hard to use safely, you need to really spell
> out what you think this is doing from a synchronization point of view
> and why it's safe.

I'm trying to detect if we are on Master or Slave initiated transfer,
which was detected by spi_fc_rq. Normally there should be no other
interrupts on FC line and active_rq should not be changed until this
transfer was processed. The "if (!spi_fc_equal_cs(spi))" check is in
case my assumption is wrong or there is some HW issue. Do you have other
suggestions?

> 
>> +	if (spi->mode | SPI_FC_REQUEST &&
>> +			!spi->cs_enabled && fc_enabled) {
>> +		atomic_set(&spi->active_rq, 1);
>> +		if (spi->request_cb)
>> +			spi->request_cb(spi);
> 
> This logic is all too complicated for me to follow.  Why are we oring
> things with spi->mode?

I'm trying to checking here if fallowing case is actually expected by
slave device. Other suggestions?

>> +	struct device_node *np = spi->dev.of_node;
>> +	int ret;
>> +
>> +	if (!np)
>> +		return 0;
> 
> We can't support things only for DT, we need a way for things to be used
> on other systemms.

I have nothing against it, but i even do not have other HW to test if my
assumptions are correct. Would you accept untested code? :)

This code was tested on Banana Pi with spi-sun4i and spi-gpio drivers.

[-- Attachment #2: spi_fc_ready.jpg --]
[-- Type: image/jpeg, Size: 32734 bytes --]

[-- Attachment #3: spi_fc_request.jpg --]
[-- Type: image/jpeg, Size: 32604 bytes --]

  reply	other threads:[~2016-03-02  6:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 12:04 [PATCH RFC] spi: add flow controll support Oleksij Rempel
     [not found] ` <1456747459-8559-1-git-send-email-linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
2016-02-29 12:14   ` Geert Uytterhoeven
     [not found]     ` <56D448E1.6090006@de.bosch.com>
     [not found]       ` <56D448E1.6090006-V5te9oGctAVWk0Htik3J/w@public.gmane.org>
2016-02-29 13:46         ` Geert Uytterhoeven
2016-03-01 14:43         ` [PATCH 1/6] " Oleksij Rempel
     [not found]           ` <1456843400-20696-1-git-send-email-linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
2016-03-01 14:43             ` [PATCH 2/6] spi: add add flow control test driver Oleksij Rempel
2016-03-01 14:43             ` [PATCH 3/6] DT: add documentation for spi-fc-test driver Oleksij Rempel
     [not found]               ` <1456843400-20696-3-git-send-email-linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
2016-03-02  2:17                 ` Mark Brown
2016-03-02  6:24                   ` fixed-term.Oleksij.Rempel
2016-03-01 14:43             ` [PATCH 4/6] spi: davinci: set new SPI_FC_* flags Oleksij Rempel
     [not found]               ` <1456843400-20696-4-git-send-email-linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
2016-03-02  2:16                 ` Mark Brown
2016-03-02  6:25                   ` fixed-term.Oleksij.Rempel
     [not found]                     ` <56D68754.3090405-V5te9oGctAVWk0Htik3J/w@public.gmane.org>
2016-03-02 10:48                       ` Mark Brown
2016-03-02  6:57                   ` fixed-term.Oleksij.Rempel
2016-03-01 14:43             ` [PATCH 5/6] spi: sun4i: " Oleksij Rempel
2016-03-01 14:43             ` [PATCH 6/6] spi: bitbang: " Oleksij Rempel
2016-03-02  1:32             ` [PATCH 1/6] spi: add flow controll support Mark Brown
2016-03-02  2:46             ` Mark Brown
2016-03-02  6:48               ` fixed-term.Oleksij.Rempel [this message]
     [not found]                 ` <56D68CD7.8000203-V5te9oGctAVWk0Htik3J/w@public.gmane.org>
2016-03-02 10:55                   ` Mark Brown
2016-03-02 11:21                     ` fixed-term.Oleksij.Rempel
2016-03-02 12:26             ` Martin Sperl
2016-03-02 14:26               ` fixed-term.Oleksij.Rempel
2016-02-29 13:11   ` [PATCH RFC] " Martin Sperl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56D68CD7.8000203@de.bosch.com \
    --to=fixed-term.oleksij.rempel@de.bosch.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dirk.behme@de.bosch.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.