Skip to contentSkip to conversation

spi: rockchip: avoid objtool warning

PATCH Superseded Arnd Bergmann 6 participants 9 messages Feb 25, 2021 – Mar 1, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: rockchip: avoid objtool warning

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +1 -1
index 936ef54e0903..972beac1169a 100644
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 		 * ctlr->bits_per_word_mask, so this shouldn't
 		 * happen
 		 */
-		unreachable();
+		BUG();
 	}
 
 	if (use_dma) {
Signature · 7 lines
2.29.2


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

Quoted 7 lines

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
Quoted 18 lines
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +1 -2
index 936ef54e0903..972beac1169a 100644
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
                 * ctlr->bits_per_word_mask, so this shouldn't
                 * happen
                 */
-               unreachable();
+               BUG();
        }
 
        if (use_dma) {
--
Quoted 2 lines

2.29.2

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Thanks for the patch!

Quoted 23 lines
Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +1 -2
index 936ef54e0903..972beac1169a 100644
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
                 * ctlr->bits_per_word_mask, so this shouldn't
                 * happen
                 */
-               unreachable();
+               BUG();
        }
 
        if (use_dma) {
--

2.29.2

Signature · 7 lines
Thanks,
~Nick Desaulniers

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Arnd Bergmann

Am Donnerstag, 25. Februar 2021, 13:55:34 CET schrieb Arnd Bergmann:

Quoted 5 lines

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

Quoted 7 lines

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
Quoted 10 lines
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +0 -0
index 936ef54e0903..972beac1169a 100644

drivers/spi/spi-rockchip.c static void rockchip_spi_config(struct rockchip_spi *rs, · line 527

Quoted 8 lines
drivers/spi/spi-rockchip.c +1 -1
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 		 * ctlr->bits_per_word_mask, so this shouldn't
 		 * happen
 		 */
-		unreachable();
+		BUG();
 	}
 
 	if (use_dma) {

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#4 lore raw
In reply to Arnd Bergmann

Hi,

Quoted 21 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +0 -0
index 936ef54e0903..972beac1169a 100644

drivers/spi/spi-rockchip.c static void rockchip_spi_config(struct rockchip_spi *rs, · line 524

Quoted 5 lines
drivers/spi/spi-rockchip.c +1 -1
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 		 * ctlr->bits_per_word_mask, so this shouldn't
 		 * happen
 		 */
-		unreachable();
+		BUG();

checkpatch says:

Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()

Which makes sense to me. This is not something bad enough to justify crashing the kernel.

Quoted 6 lines
drivers/spi/spi-rockchip.c +0 -0
 	}
 
 	if (use_dma) {
Signature · 1 line
2.29.2
Signature · 8 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#5 lore raw
Quoted 33 lines · Pratyush Yadav' via Clang Built Linux

Hi,

Quoted 21 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +0 -0
index 936ef54e0903..972beac1169a 100644

drivers/spi/spi-rockchip.c static void rockchip_spi_config(struct rockchip_spi *rs, · line 524

Quoted 5 lines
drivers/spi/spi-rockchip.c +1 -1
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
               * ctlr->bits_per_word_mask, so this shouldn't
               * happen
               */
-             unreachable();
+             BUG();

checkpatch says:

Quoted 5 lines

Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()

Which makes sense to me. This is not something bad enough to justify crashing the kernel.

I thought about rewriting it more thoroughly when I wrote the patch, but couldn't come up with a good alternative, so I did the simplest change in this direction, replacing the silent crash with a loud one.

Should we just dev_warn() and return instead, hoping that it won't do more harm?

The backtrace from WARN_ON() probably doesn't help here.

Arnd

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#6 lore raw
Quoted 41 lines · Arnd Bergmann
Quoted 33 lines · Pratyush Yadav' via Clang Built Linux

Hi,

Quoted 21 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Fixes 65498c6ae241 ("spi: rockchip: support 4bit words")
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +0 -0
index 936ef54e0903..972beac1169a 100644

drivers/spi/spi-rockchip.c static void rockchip_spi_config(struct rockchip_spi *rs, · line 524

Quoted 5 lines
drivers/spi/spi-rockchip.c +1 -1
@@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
               * ctlr->bits_per_word_mask, so this shouldn't
               * happen
               */
-             unreachable();
+             BUG();

checkpatch says:

Quoted 5 lines

Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()

Which makes sense to me. This is not something bad enough to justify crashing the kernel.

Quoted 6 lines

I thought about rewriting it more thoroughly when I wrote the patch, but couldn't come up with a good alternative, so I did the simplest change in this direction, replacing the silent crash with a loud one.

Should we just dev_warn() and return instead, hoping that it won't do more harm?

Hmm... I'm not very familiar with this device or driver so take what I say with a grain of salt. On the surface level it looks like it might end up doing something wrong or unexpected.

Returning an error code from this function (along with the dev_warn() or WARN_ON()) is the most sensible thing to do IMO. If the SPI layer sends an invalid value then the driver should be well within its rights to refuse the transaction. The function is currently void but making it return int seems fairly straightforward.

Quoted 4 lines

The backtrace from WARN_ON() probably doesn't help here.

Arnd

Signature · 8 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#7 lore raw
Quoted 9 lines · Pratyush Yadav' via Clang Built Linux
Quoted 1 line · Arnd Bergmann

On Fri, Feb 26, 2021 at 9:16 AM 'Pratyush Yadav' via Clang Built Linux <[email protected]> wrote:

Returning an error code from this function (along with the dev_warn() or WARN_ON()) is the most sensible thing to do IMO. If the SPI layer sends an invalid value then the driver should be well within its rights to refuse the transaction. The function is currently void but making it return int seems fairly straightforward.

Indeed, this seems like a clear -EINVAL case. I've updated my patch, will send after build testing.

Arnd

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#8 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

Building this file with clang leads to a an unreachable code path causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Use BUG() instead of unreachable() to avoid the undefined behavior if it does happen.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: rockchip: avoid objtool warning

      commit: d86e880f7a7c5b64a650146a1353f98750863f21

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip