<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/spi, branch v6.0.15</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.0.15</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.0.15'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2022-09-02T12:27:13Z</updated>
<entry>
<title>spi: mux: Fix mux interaction with fast path optimisations</title>
<updated>2022-09-02T12:27:13Z</updated>
<author>
<name>Mark Brown</name>
<email>broonie@kernel.org</email>
</author>
<published>2022-09-01T12:07:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b30f7c8eb0780e1479a9882526e838664271f4c9'/>
<id>urn:sha1:b30f7c8eb0780e1479a9882526e838664271f4c9</id>
<content type='text'>
The spi-mux driver is rather too clever and attempts to resubmit any
message that is submitted to it to the parent controller with some
adjusted callbacks.  This does not play at all nicely with the fast
path which now sets flags on the message indicating that it's being
handled through the fast path, we see async messages flagged as being on
the fast path.  Ideally the spi-mux code would duplicate the message but
that's rather invasive and a bit fragile in that it relies on the mux
knowing which fields in the message to copy.  Instead teach the core
that there are controllers which can't cope with the fast path and have
the mux flag itself as being such a controller, ensuring that messages
going via the mux don't get partially handled via the fast path.

This will reduce the performance of any spi-mux connected device since
we'll now always use the thread for both the actual controller and the
mux controller instead of just the actual controller but given that we
were always hitting the slow path anyway it's hopefully not too much of
an additional cost and it allows us to keep the fast path.

Fixes: ae7d2346dc89 ("spi: Don't use the message queue if possible in spi_sync")
Reported-by: Casper Andersson &lt;casper.casan@gmail.com&gt;
Tested-by: Casper Andersson &lt;casper.casan@gmail.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Link: https://lore.kernel.org/r/20220901120732.49245-1-broonie@kernel.org
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: spi.c: Fix comment style</title>
<updated>2022-06-30T12:40:35Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-29T14:25:18Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=95c8222f0e52b09b7607616274e7cae84d519a9b'/>
<id>urn:sha1:95c8222f0e52b09b7607616274e7cae84d519a9b</id>
<content type='text'>
Capitalize first word in comment where appropriate and add
parentheses to function names.

Reported-by: Andy Shevchenko &lt;andy.shevchenko@gmail.com&gt;
Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220629142519.3985486-3-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: opportunistically skip ctlr-&gt;cur_msg_completion</title>
<updated>2022-06-27T12:27:26Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-21T06:12:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=dc3029056b02414c29b6627e3dd7b16624725ae9'/>
<id>urn:sha1:dc3029056b02414c29b6627e3dd7b16624725ae9</id>
<content type='text'>
There are only a few drivers that do not call
spi_finalize_current_message() in the context of transfer_one_message(),
and even for those cases the completion ctlr-&gt;cur_msg_completion is not
needed always. The calls to complete() and wait_for_completion() each
take a spin-lock, which is costly. This patch makes it possible to avoid
those calls in the big majority of cases, by introducing two flags that
with the help of ordering via barriers can avoid using the completion
safely. In case of a race with the context calling
spi_finalize_current_message(), the scheme errs on the safe side and takes
the completion.
The impact of this patch is worth the effort: On a i.MX8MM SoC, the time
the SPI bus is idle between two consecutive calls to spi_sync(), is
reduced from 19.6us to 16.8us... roughly 15%.

Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220621061234.3626638-12-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: Ensure the io_mutex is held until spi_finalize_current_message()</title>
<updated>2022-06-27T12:27:25Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-21T06:12:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=69fa95905d40846756d22402690ddf5361a9d13b'/>
<id>urn:sha1:69fa95905d40846756d22402690ddf5361a9d13b</id>
<content type='text'>
This patch introduces a completion that is completed in
spi_finalize_current_message() and waited for in
__spi_pump_transfer_message(). This way all manipulation of ctlr-&gt;cur_msg
is done with the io_mutex held and strictly ordered:
__spi_pump_transfer_message() will not return until
spi_finalize_current_message() is done using ctlr-&gt;cur_msg, and its
calling context is only touching ctlr-&gt;cur_msg after returning.
Due to this, we can safely drop the spin-locks around ctlr-&gt;cur_msg.

Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220621061234.3626638-11-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: Remove the now unused ctlr-&gt;idling flag</title>
<updated>2022-06-27T12:27:22Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-21T06:12:30Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=66a221593cb26dd6aabba63bcd18173f4e69c7ab'/>
<id>urn:sha1:66a221593cb26dd6aabba63bcd18173f4e69c7ab</id>
<content type='text'>
The ctlr-&gt;idling flag is never checked now, so we don't need to set it
either.

Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220621061234.3626638-8-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: Don't use the message queue if possible in spi_sync</title>
<updated>2022-06-27T12:27:17Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-21T06:12:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ae7d2346dc89ae89a6e0aabe6037591a11e593c0'/>
<id>urn:sha1:ae7d2346dc89ae89a6e0aabe6037591a11e593c0</id>
<content type='text'>
The interaction with the controller message queue and its corresponding
auxiliary flags and variables requires the use of the queue_lock which is
costly. Since spi_sync will transfer the complete message anyway, and not
return until it is finished, there is no need to put the message into the
queue if the queue is empty. This can save a lot of overhead.

As an example of how significant this is, when using the MCP2518FD SPI CAN
controller on a i.MX8MM SoC, the time during which the interrupt line
stays active (during 3 relatively short spi_sync messages), is reduced
from 98us to 72us by this patch.

Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220621061234.3626638-3-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: Move ctlr-&gt;cur_msg_prepared to struct spi_message</title>
<updated>2022-06-27T12:27:16Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-21T06:12:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1714582a3a087eda8786d5a1b32b2ec86ca8a303'/>
<id>urn:sha1:1714582a3a087eda8786d5a1b32b2ec86ca8a303</id>
<content type='text'>
This enables the possibility to transfer a message that is not at the
current tip of the async message queue.
This is in preparation of the next patch(es) which enable spi_sync messages
to skip the queue altogether.

Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220621061234.3626638-2-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: Fix per-cpu stats access on 32 bit systems</title>
<updated>2022-06-10T12:33:17Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-09T12:13:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=67b9d64139e13621d3ab8bb0daad7602e5fe0778'/>
<id>urn:sha1:67b9d64139e13621d3ab8bb0daad7602e5fe0778</id>
<content type='text'>
On 32 bit systems, the following kernel BUG is hit:

BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
caller is debug_smp_processor_id+0x18/0x24
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-rc1-00001-g6ae0aec8a366 #181
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
Backtrace:
 dump_backtrace from show_stack+0x20/0x24
 r7:81024ffd r6:00000000 r5:81024ffd r4:60000013
 show_stack from dump_stack_lvl+0x60/0x78
 dump_stack_lvl from dump_stack+0x14/0x1c
 r7:81024ffd r6:80f652de r5:80bec180 r4:819a2500
 dump_stack from check_preemption_disabled+0xc8/0xf0
 check_preemption_disabled from debug_smp_processor_id+0x18/0x24
 r8:8119b7e0 r7:81205534 r6:819f5c00 r5:819f4c00 r4:c083d724
 debug_smp_processor_id from __spi_sync+0x78/0x220
 __spi_sync from spi_sync+0x34/0x4c
 r10:bb7bf4e0 r9:c083d724 r8:00000007 r7:81a068c0 r6:822a83c0 r5:c083d724
 r4:819f4c00
 spi_sync from spi_mem_exec_op+0x338/0x370
 r5:000000b4 r4:c083d910
 spi_mem_exec_op from spi_nor_read_id+0x98/0xdc
 r10:bb7bf4e0 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:82358040
 r4:819f7c40
 spi_nor_read_id from spi_nor_detect+0x38/0x114
 r7:82358040 r6:00000000 r5:819f7c40 r4:819f7c40
 spi_nor_detect from spi_nor_scan+0x11c/0xbec
 r10:bb7bf4e0 r9:00000000 r8:00000000 r7:c083da4c r6:00000000 r5:00010101
 r4:819f7c40
 spi_nor_scan from spi_nor_probe+0x10c/0x2d0
 r10:bb7bf4e0 r9:bb7bf4d0 r8:00000000 r7:819f4c00 r6:00000000 r5:00000000
 r4:819f7c40

per-cpu access needs to be guarded against preemption.

Fixes: 6598b91b5ac3 ("spi: spi.c: Convert statistics to per-cpu u64_stats_t")
Reported-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Tested-by: Nícolas F. R. A. Prado &lt;nfraprado@collabora.com&gt;
Link: https://lore.kernel.org/r/20220609121334.2984808-1-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: &lt;linux/spi/spi.h&gt;: Add missing documentation for struct members</title>
<updated>2022-06-08T16:45:42Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-06-08T15:33:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5dfac65b621733e69b789150a0a3f1bf2f9095a3'/>
<id>urn:sha1:5dfac65b621733e69b789150a0a3f1bf2f9095a3</id>
<content type='text'>
Fixes these "make htmldocs" warnings:

include/linux/spi/spi.h:82: warning: Function parameter or member 'syncp' not described in 'spi_statistics'
include/linux/spi/spi.h:213: warning: Function parameter or member 'pcpu_statistics' not described in 'spi_device'
include/linux/spi/spi.h:676: warning: Function parameter or member 'pcpu_statistics' not described in 'spi_controller'

Fixes: 6598b91b5ac3 ("spi: spi.c: Convert statistics to per-cpu u64_stats_t")
Reported-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Reviewed-by: Andy Shevchenko &lt;andy.shevchenko@gmail.com&gt;
Link: https://lore.kernel.org/r/20220608153309.2899565-1-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: spi.c: Convert statistics to per-cpu u64_stats_t</title>
<updated>2022-06-06T11:41:31Z</updated>
<author>
<name>David Jander</name>
<email>david@protonic.nl</email>
</author>
<published>2022-05-24T09:18:08Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6598b91b5ac32bc756d7c3000a31f775d4ead1c4'/>
<id>urn:sha1:6598b91b5ac32bc756d7c3000a31f775d4ead1c4</id>
<content type='text'>
This change gives a dramatic performance improvement in the hot path,
since many costly spin_lock_irqsave() calls can be avoided.

On an i.MX8MM system with a MCP2518FD CAN controller connected via SPI,
the time the driver takes to handle interrupts, or in other words the time
the IRQ line of the CAN controller stays low is mainly dominated by the
time it takes to do 3 relatively short sync SPI transfers. The effect of
this patch is a reduction of this time from 136us down to only 98us.

Suggested-by: Andrew Lunn &lt;andrew@lunn.ch&gt;
Signed-off-by: David Jander &lt;david@protonic.nl&gt;
Link: https://lore.kernel.org/r/20220524091808.2269898-1-david@protonic.nl
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
</feed>
