<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/include/linux/spi/spi.h, branch linux-5.11.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.11.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.11.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2021-05-14T08:49:45Z</updated>
<entry>
<title>spi: Fix use-after-free with devm_spi_alloc_*</title>
<updated>2021-05-14T08:49:45Z</updated>
<author>
<name>William A. Kennington III</name>
<email>wak@google.com</email>
</author>
<published>2021-04-07T09:55:27Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=cee78aa24578edac8cf00513dca618c0acc17cd7'/>
<id>urn:sha1:cee78aa24578edac8cf00513dca618c0acc17cd7</id>
<content type='text'>
[ Upstream commit 794aaf01444d4e765e2b067cba01cc69c1c68ed9 ]

We can't rely on the contents of the devres list during
spi_unregister_controller(), as the list is already torn down at the
time we perform devres_find() for devm_spi_release_controller. This
causes devices registered with devm_spi_alloc_{master,slave}() to be
mistakenly identified as legacy, non-devm managed devices and have their
reference counters decremented below 0.

------------[ cut here ]------------
WARNING: CPU: 1 PID: 660 at lib/refcount.c:28 refcount_warn_saturate+0x108/0x174
[&lt;b0396f04&gt;] (refcount_warn_saturate) from [&lt;b03c56a4&gt;] (kobject_put+0x90/0x98)
[&lt;b03c5614&gt;] (kobject_put) from [&lt;b0447b4c&gt;] (put_device+0x20/0x24)
 r4:b6700140
[&lt;b0447b2c&gt;] (put_device) from [&lt;b07515e8&gt;] (devm_spi_release_controller+0x3c/0x40)
[&lt;b07515ac&gt;] (devm_spi_release_controller) from [&lt;b045343c&gt;] (release_nodes+0x84/0xc4)
 r5:b6700180 r4:b6700100
[&lt;b04533b8&gt;] (release_nodes) from [&lt;b0454160&gt;] (devres_release_all+0x5c/0x60)
 r8:b1638c54 r7:b117ad94 r6:b1638c10 r5:b117ad94 r4:b163dc10
[&lt;b0454104&gt;] (devres_release_all) from [&lt;b044e41c&gt;] (__device_release_driver+0x144/0x1ec)
 r5:b117ad94 r4:b163dc10
[&lt;b044e2d8&gt;] (__device_release_driver) from [&lt;b044f70c&gt;] (device_driver_detach+0x84/0xa0)
 r9:00000000 r8:00000000 r7:b117ad94 r6:b163dc54 r5:b1638c10 r4:b163dc10
[&lt;b044f688&gt;] (device_driver_detach) from [&lt;b044d274&gt;] (unbind_store+0xe4/0xf8)

Instead, determine the devm allocation state as a flag on the
controller which is guaranteed to be stable during cleanup.

Fixes: 5e844cc37a5c ("spi: Introduce device-managed SPI controller allocation")
Signed-off-by: William A. Kennington III &lt;wak@google.com&gt;
Link: https://lore.kernel.org/r/20210407095527.2771582-1-wak@google.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-5.10' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-5.11</title>
<updated>2020-11-27T16:18:32Z</updated>
<author>
<name>Mark Brown</name>
<email>broonie@kernel.org</email>
</author>
<published>2020-11-27T16:18:32Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=db4a831997047809229152261a462c17cb857c84'/>
<id>urn:sha1:db4a831997047809229152261a462c17cb857c84</id>
<content type='text'>
</content>
</entry>
<entry>
<title>spi: Introduce device-managed SPI controller allocation</title>
<updated>2020-11-12T15:05:34Z</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2020-11-11T19:07:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=5e844cc37a5cbaa460e68f9a989d321d63088a89'/>
<id>urn:sha1:5e844cc37a5cbaa460e68f9a989d321d63088a89</id>
<content type='text'>
SPI driver probing currently comprises two steps, whereas removal
comprises only one step:

    spi_alloc_master()
    spi_register_controller()

    spi_unregister_controller()

That's because spi_unregister_controller() calls device_unregister()
instead of device_del(), thereby releasing the reference on the
spi_controller which was obtained by spi_alloc_master().

An SPI driver's private data is contained in the same memory allocation
as the spi_controller struct.  Thus, once spi_unregister_controller()
has been called, the private data is inaccessible.  But some drivers
need to access it after spi_unregister_controller() to perform further
teardown steps.

Introduce devm_spi_alloc_master() and devm_spi_alloc_slave(), which
release a reference on the spi_controller struct only after the driver
has unbound, thereby keeping the memory allocation accessible.  Change
spi_unregister_controller() to not release a reference if the
spi_controller was allocated by one of these new devm functions.

The present commit is small enough to be backportable to stable.
It allows fixing drivers which use the private data in their -&gt;remove()
hook after it's been freed.  It also allows fixing drivers which neglect
to release a reference on the spi_controller in the probe error path.

Long-term, most SPI drivers shall be moved over to the devm functions
introduced herein.  The few that can't shall be changed in a treewide
commit to explicitly release the last reference on the controller.
That commit shall amend spi_unregister_controller() to no longer release
a reference, thereby completing the migration.

As a result, the behaviour will be less surprising and more consistent
with subsystems such as IIO, which also includes the private data in the
allocation of the generic iio_dev struct, but calls device_del() in
iio_device_unregister().

Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Link: https://lore.kernel.org/r/272bae2ef08abd21388c98e23729886663d19192.1605121038.git.lukas@wunner.de
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: introduce SPI_MODE_X_MASK macro</title>
<updated>2020-11-11T12:39:30Z</updated>
<author>
<name>Oleksij Rempel</name>
<email>o.rempel@pengutronix.de</email>
</author>
<published>2020-10-27T09:57:23Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=029b42d8519cef70c4fb5fcaccd08f1053ed2bf0'/>
<id>urn:sha1:029b42d8519cef70c4fb5fcaccd08f1053ed2bf0</id>
<content type='text'>
Provide a macro to filter all SPI_MODE_0,1,2,3 mode in one run.

The latest SPI framework will parse the devicetree in following call
sequence: of_register_spi_device() -&gt; of_spi_parse_dt()
So, driver do not need to pars the devicetree and will get prepared
flags in the probe.

On one hand it is good far most drivers. On other hand some drivers need to
filter flags provide by SPI framework and apply know to work flags. This drivers
may use SPI_MODE_X_MASK to filter MODE flags and set own, known flags:
  spi-&gt;flags &amp;= ~SPI_MODE_X_MASK;
  spi-&gt;flags |= SPI_MODE_0;

Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
Link: https://lore.kernel.org/r/20201027095724.18654-2-o.rempel@pengutronix.de
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: correct kernel-doc inconsistency</title>
<updated>2020-07-27T13:55:22Z</updated>
<author>
<name>Colton Lewis</name>
<email>colton.w.lewis@protonmail.com</email>
</author>
<published>2020-07-25T05:02:57Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=cfd97f94d036bf36122fa19d075c5741347aa178'/>
<id>urn:sha1:cfd97f94d036bf36122fa19d075c5741347aa178</id>
<content type='text'>
Silence documentation build warnings by correcting kernel-doc comment
for spi_transfer struct.

Signed-off-by: Colton Lewis &lt;colton.w.lewis@protonmail.com&gt;
Link: https://lore.kernel.org/r/20200725050242.279548-1-colton.w.lewis@protonmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: fix duplicated word in &lt;linux/spi/spi.h&gt;</title>
<updated>2020-07-16T23:55:22Z</updated>
<author>
<name>Randy Dunlap</name>
<email>rdunlap@infradead.org</email>
</author>
<published>2020-07-16T01:30:48Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2ae3de10abfe0be40c9d93ebc2f429b969abf008'/>
<id>urn:sha1:2ae3de10abfe0be40c9d93ebc2f429b969abf008</id>
<content type='text'>
Change doubled word "as" to "as a".

Change "Return: Return:" in kernel-doc notation to have only one
"Return:".

Signed-off-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Cc: Mark Brown &lt;broonie@kernel.org&gt;
Cc: linux-spi@vger.kernel.org
Link: https://lore.kernel.org/r/40354d64-be71-3952-a980-63a76a278145@infradead.org
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: use kthread_create_worker() helper</title>
<updated>2020-07-09T21:41:10Z</updated>
<author>
<name>Marek Szyprowski</name>
<email>m.szyprowski@samsung.com</email>
</author>
<published>2020-07-09T06:50:07Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=60a883d119ab9ef63f830c85bbd2f0e2e2314f4f'/>
<id>urn:sha1:60a883d119ab9ef63f830c85bbd2f0e2e2314f4f</id>
<content type='text'>
Use kthread_create_worker() helper to simplify the code. It uses
the kthread worker API the right way. It will eventually allow
to remove the FIXME in kthread_worker_fn() and add more consistency
checks in the future.

Signed-off-by: Marek Szyprowski &lt;m.szyprowski@samsung.com&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20200709065007.26896-1-m.szyprowski@samsung.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: Avoid setting the chip select if we don't need to</title>
<updated>2020-07-01T22:21:27Z</updated>
<author>
<name>Douglas Anderson</name>
<email>dianders@chromium.org</email>
</author>
<published>2020-06-29T23:41:06Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d40f0b6f2e21f2400ae8b1b120d11877d9ffd8ec'/>
<id>urn:sha1:d40f0b6f2e21f2400ae8b1b120d11877d9ffd8ec</id>
<content type='text'>
On some SPI controllers (like spi-geni-qcom) setting the chip select
is a heavy operation.  For instance on spi-geni-qcom, with the current
code, is was measured as taking upwards of 20 us.  Even on SPI
controllers that aren't as heavy, setting the chip select is at least
something like a MMIO operation over some peripheral bus which isn't
as fast as a RAM access.

While it would be good to find ways to mitigate problems like this in
the drivers for those SPI controllers, it can also be noted that the
SPI framework could also help out.  Specifically, in some situations,
we can see the SPI framework calling the driver's set_cs() with the
same parameter several times in a row.  This is specifically observed
when looking at the way the Chrome OS EC SPI driver (cros_ec_spi)
works but other drivers likely trip it to some extent.

Let's solve this by caching the chip select state in the core and only
calling into the controller if there was a change.  We check not only
the "enable" state but also the chip select mode (active high or
active low) since controllers may care about both the mode and the
enable flag in their callback.

Signed-off-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Link: https://lore.kernel.org/r/20200629164103.1.Ied8e8ad8bbb2df7f947e3bc5ea1c315e041785a2@changeid
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>spi: introduce fallback to pio</title>
<updated>2020-06-23T12:38:14Z</updated>
<author>
<name>Robin Gong</name>
<email>yibin.gong@nxp.com</email>
</author>
<published>2020-06-16T22:42:08Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=809b1b04df898b6d182069146231a3cbf5f2d9cc'/>
<id>urn:sha1:809b1b04df898b6d182069146231a3cbf5f2d9cc</id>
<content type='text'>
Add fallback to pio mode in case dma transfer failed with error status
SPI_TRANS_FAIL_NO_START.
If spi client driver want to enable this feature please set xfer-&gt;error in
the proper place such as dmaengine_prep_slave_sg() failure detect(but no
any data put into spi bus yet). Besides, add master-&gt;fallback checking in
its can_dma() so that spi core could switch to pio next time. Please refer
to spi-imx.c.

Signed-off-by: Robin Gong &lt;yibin.gong@nxp.com&gt;
Link: https://lore.kernel.org/r/1592347329-28363-2-git-send-email-yibin.gong@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
</entry>
<entry>
<title>docs: spi: spi.h: fix a doc building warning</title>
<updated>2020-04-20T21:45:23Z</updated>
<author>
<name>Mauro Carvalho Chehab</name>
<email>mchehab+huawei@kernel.org</email>
</author>
<published>2020-04-14T16:48:44Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ad89c8852fde7ab0c4007f5b753517cf508d12be'/>
<id>urn:sha1:ad89c8852fde7ab0c4007f5b753517cf508d12be</id>
<content type='text'>
We need to add a blank line to avoid this warning:

	./include/linux/spi/spi.h:401: WARNING: Unexpected indentation.

Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Link: https://lore.kernel.org/r/1c701b3ac903dc0bc304dca958fbdee53bd38dc3.1586881715.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet &lt;corbet@lwn.net&gt;
</content>
</entry>
</feed>
