From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH] spi: Fix hang on spi_sync() when driver does not support transfer() call
Date: Fri, 10 Jan 2025 10:50:10 +0300 [thread overview]
Message-ID: <20250110075010.28030-1-eagle.alexander923@gmail.com> (raw)
When a driver does not support transfer() call, such as most QSPI drivers,
calling spi_sync() (e.g. with the "spi" command) will cause the system
to hang. Fix this by adding a function check.
barebox@Mega-Milas Informer SAMA5D2:/ spi -b 1 -c 0 0xaa
prefetch abort
pc : [<00000004>] lr : [<27e266a4>]
sp : 27ff7c78 ip : 27ff7ce8 fp : 27e87410
r10: 27ff7d20 r9 : 00000000 r8 : 23f58128
r7 : 23f33c30 r6 : 27ff7c90 r5 : 27ff7d20 r4 : 27ff7c7c
r3 : 00000000 r2 : 27ff7cc4 r1 : 27ff7c90 r0 : 27ff7d20
Flags: nzCv IRQs off FIQs off Mode SVC_32
[<27e266a4>] (spi_sync+0xc8/0xdc) from [<27e2675c>] (spi_write_then_read+0xa4/0xac)
[<27e2675c>] (spi_write_then_read+0xa4/0xac) from [<27e438e4>] (do_spi+0x288/0x3e8)
[<27e438e4>] (do_spi+0x288/0x3e8) from [<27e05c38>] (execute_command+0x3c/0x80)
[<27e05c38>] (execute_command+0x3c/0x80) from [<27e0ee48>] (run_list_real+0x9a8/0xad8)
[<27e0ee48>] (run_list_real+0x9a8/0xad8) from [<27e0e2b4>] (parse_stream_outer+0x138/0x200)
[<27e0e2b4>] (parse_stream_outer+0x138/0x200) from [<27e0f180>] (run_shell+0x5c/0x90)
[<27e0f180>] (run_shell+0x5c/0x90) from [<27e018b4>] (run_init+0x108/0x288)
[<27e018b4>] (run_init+0x108/0x288) from [<27e01a8c>] (start_barebox+0x58/0xb4)
[<27e01a8c>] (start_barebox+0x58/0xb4) from [<27e5ee18>] (barebox_non_pbl_start+0xc8/0xe0)
[<27e5ee18>] (barebox_non_pbl_start+0xc8/0xe0) from [<27e00004>] (__bare_init_start+0x0/0x10)
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
drivers/spi/spi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c627d88954..c354c00e72 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -357,6 +357,9 @@ int spi_sync(struct spi_device *spi, struct spi_message *message)
int status;
int ret;
+ if (!spi->controller->transfer)
+ return -ENOTSUPP;
+
status = __spi_validate(spi, message);
if (status != 0)
return status;
--
2.39.1
next reply other threads:[~2025-01-10 7:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 7:50 Alexander Shiyan [this message]
2025-01-10 8:28 ` Sascha Hauer
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=20250110075010.28030-1-eagle.alexander923@gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox