Go to file
David Lechner 5f323d5792 spi: add defer_optimize_message controller flag
[ Upstream commit ca52aa4c60 ]

Adding spi_optimize_message() broke the spi-mux driver because it
calls spi_async() from it's transfer_one_message() callback. This
resulted in passing an incorrectly optimized message to the controller.
For example, if the underlying controller has an optimize_message()
callback, this would have not been called and can cause a crash when
the underlying controller driver tries to transfer the message.

Also, since the spi-mux driver swaps out the controller pointer by
replacing msg->spi, __spi_unoptimize_message() was being called with a
different controller than the one used in __spi_optimize_message(). This
could cause a crash when attempting to free the message resources when
__spi_unoptimize_message() is called in spi_finalize_current_message()
since it is being called with a controller that did not allocate the
resources.

This is fixed by adding a defer_optimize_message flag for controllers.
This flag causes all of the spi_[maybe_][un]optimize_message() calls to
be a no-op (other than attaching a pointer to the spi device to the
message).

This allows the spi-mux driver to pass an unmodified message to
spi_async() in spi_mux_transfer_one_message() after the spi device has
been swapped out. This causes __spi_optimize_message() and
__spi_unoptimize_message() to be called only once per message and with
the correct/same controller in each case.

Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
Closes: https://lore.kernel.org/linux-spi/Zn6HMrYG2b7epUxT@pengutronix.de/
Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Closes: https://lore.kernel.org/linux-spi/20240628-awesome-discerning-bear-1621f9-mkl@pengutronix.de/
Fixes: 7b1d87af14 ("spi: add spi_optimize_message() APIs")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240708-spi-mux-fix-v1-2-6c8845193128@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:22:38 +02:00
arch arm64: dts: rockchip: Fix the DCDC_REG2 minimum voltage on Quartz64 Model B 2024-07-11 12:51:20 +02:00
block block: check for max_hw_sectors underflow 2024-07-11 12:51:22 +02:00
certs This update includes the following changes: 2023-11-02 16:15:30 -10:00
crypto crypto: aead,cipher - zeroize key buffer after use 2024-07-11 12:50:58 +02:00
Documentation kbuild: doc: Update default INSTALL_MOD_DIR from extra to updates 2024-07-05 09:38:06 +02:00
drivers spi: add defer_optimize_message controller flag 2024-07-18 13:22:38 +02:00
fs vfs: don't mod negative dentry count when on shrinker list 2024-07-18 13:22:37 +02:00
include spi: add defer_optimize_message controller flag 2024-07-18 13:22:38 +02:00
init printk: Fix LOG_CPU_MAX_BUF_SHIFT when BASE_SMALL is enabled 2024-06-12 11:39:35 +02:00
io_uring io_uring: signal SQPOLL task_work with TWA_SIGNAL_NO_IPI 2024-07-05 09:38:15 +02:00
ipc sysctl changes for v6.9-rc1 2024-03-18 14:59:13 -07:00
kernel swap: yield device immediately 2024-07-11 12:51:22 +02:00
lib kunit: Fix timeout message 2024-07-11 12:51:04 +02:00
LICENSES LICENSES: Add the copyleft-next-0.3.1 license 2022-11-08 15:44:01 +01:00
mm Revert "mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again" 2024-07-11 12:51:17 +02:00
net skmsg: Skip zero length skb in sk_msg_recvmsg 2024-07-18 13:22:38 +02:00
rust rust: remove params from module macro example 2024-04-25 17:34:33 +02:00
samples samples/landlock: Fix incorrect free in populate_ruleset_net 2024-05-30 09:45:01 +02:00
scripts kbuild: fix short log for AS in link-vmlinux.sh 2024-07-11 12:51:23 +02:00
security evm: Enforce signatures on unsupported filesystem for EVM_INIT_X509 2024-07-05 09:38:00 +02:00
sound ALSA: ump: Set default protocol when not given explicitly 2024-07-11 12:51:23 +02:00
tools libbpf: don't close(-1) in multi-uprobe feature detector 2024-07-11 12:51:24 +02:00
usr Kbuild updates for v6.8 2024-01-18 17:57:07 -08:00
virt virt: guest_memfd: fix reference leak on hwpoisoned page 2024-06-27 13:52:31 +02:00
.clang-format clang-format: Update with v6.7-rc4's for_each macro list 2023-12-08 23:54:38 +01:00
.cocciconfig
.editorconfig .editorconfig: remove trim_trailing_whitespace option 2024-06-21 14:40:11 +02:00
.get_maintainer.ignore Add Jeff Kirsher to .get_maintainer.ignore 2024-03-08 11:36:54 +00:00
.gitattributes .gitattributes: set diff driver for Rust source code files 2023-05-31 17:48:25 +02:00
.gitignore kbuild: create a list of all built DTB files 2024-02-19 18:20:39 +09:00
.mailmap 18 hotfixes, 7 of which are cc:stable. 2024-05-10 14:16:03 -07:00
.rustfmt.toml rust: add .rustfmt.toml 2022-09-28 09:02:20 +02:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS MAINTAINERS: Drop Gustavo Pimentel as PCI DWC Maintainer 2024-03-27 13:41:02 -05:00
Kbuild Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS cpufreq: amd-pstate: remove global header file 2024-06-21 14:40:00 +02:00
Makefile Linux 6.9.9 2024-07-11 12:51:24 +02:00
README README: Fix spelling 2024-03-18 03:36:32 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.