Skip to content

sh1106-spi invalid buffer alignment on 6.12 kernel #6733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gtrainavicius opened this issue Mar 20, 2025 · 10 comments
Closed

sh1106-spi invalid buffer alignment on 6.12 kernel #6733

gtrainavicius opened this issue Mar 20, 2025 · 10 comments

Comments

@gtrainavicius
Copy link
Contributor

Describe the bug

Trying to load the DT overlay and module for sh1106 display (possibly other SPI displays are affected too), fails with invalid buffer alignment.

It is not necessary to have the actual display to be hooked up to reproduce the problem.

Doesn't happen on 6.6 kernel versions.

Steps to reproduce the behaviour

Execute:

sudo dtoverlay sh1106-spi,reset_pin=17,dc_pin=27

Device (s)

Raspberry Pi 5

System

patch@patchbox:~ $ cat /etc/rpi-issue
Raspberry Pi reference 2024-04-04
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 64e3efc023558a4d4634a702c467f513d5b2bca1, stage-patchbox
patch@patchbox:~ $ vcgencmd version
2025/03/19 13:41:26
Copyright (c) 2012 Broadcom
version cec1d3ae (release) (embedded)
patch@patchbox:~ $ uname -a
Linux patchbox 6.12.19-v8-16k+ #1865 SMP PREEMPT Wed Mar 19 13:48:20 GMT 2025 aarch64 GNU/Linux

Logs

6.12_error.log

6.6 success log for comparison:

6.6_success.log

Additional context

No response

@6by9
Copy link
Contributor

6by9 commented Mar 20, 2025

Upstream have managed to configure two different kernel modules to have the same compatible string
https://elixir.bootlin.com/linux/v6.13.7/source/drivers/gpu/drm/solomon/ssd130x-spi.c#L113
https://elixir.bootlin.com/linux/v6.13.7/source/drivers/staging/fbtft/fb_sh1106.c#L173

Both are getting loaded, and it's the gpu/drm/solomon driver that is crashing.

If you want the deprecated fbtf version (which is what you appeared to have in 6.6), then create a file /etc/modprobe.d/blacklist-ssd130x-spi.conf with the contents blacklist ssd130x-spi.

@P33M
Copy link
Contributor

P33M commented Mar 20, 2025

The splat after that is from the AXI DMAC driver - presumably this error path hasn't been called before...

Also, I'm not entirely sure that the DMAC requires a word-aligned start address. It should only need naturally-aligned buffers with a length of integer multiples of SRC_WIDTH.

@6by9
Copy link
Contributor

6by9 commented Mar 20, 2025

The solomon driver hasn't set a dma_mask, hence the

[   71.879798] ------------[ cut here ]------------
[   71.879804] WARNING: CPU: 1 PID: 1136 at kernel/dma/mapping.c:209 __dma_map_sg_attrs+0x164/0x178

@pelwell
Copy link
Contributor

pelwell commented Mar 20, 2025

The solomon driver is passing in an odd address for the transfer, which is not very friendly. The problem with the error path is that axi_desc_put assumes that the LLIs have been allocated and calls dma_pool_free on them. I'll fix the latter.

pelwell added a commit to pelwell/linux that referenced this issue Mar 20, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: raspberrypi#6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
pelwell added a commit to pelwell/linux that referenced this issue Mar 20, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: raspberrypi#6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@pelwell
Copy link
Contributor

pelwell commented Mar 20, 2025

See #6734.

pelwell added a commit that referenced this issue Mar 20, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
pelwell added a commit that referenced this issue Mar 20, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
pelwell added a commit that referenced this issue Mar 21, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
pelwell added a commit that referenced this issue Mar 21, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
pelwell added a commit that referenced this issue Mar 21, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
pelwell added a commit that referenced this issue Mar 21, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@pelwell
Copy link
Contributor

pelwell commented Mar 24, 2025

Please close the issue if it has been resolved.

popcornmix pushed a commit that referenced this issue Mar 24, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Mar 24, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@gtrainavicius
Copy link
Contributor Author

Blacklisting the ssd130x-spi driver worked as a workaround for now, I will get around to testing a newer kernel version again hopefully by the end of the week.

popcornmix pushed a commit that referenced this issue Mar 25, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Mar 25, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Mar 25, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Mar 25, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@gtrainavicius
Copy link
Contributor Author

The overlay and module loads now without problems, however, the ssd130x-spi module does not work well with sh1106 OLED, I will stick to the older module for now.

@6by9
Copy link
Contributor

6by9 commented Mar 27, 2025

Have you tried blacklisting fb_sh1106 instead of ssd130x-spi?

With the recent fixes that have been applied (use sudo rpi-update to grab the latest kernel), loading the overlay doesn't cause an issue for me (I don't have the hardware to confirm the output).

However you don't want two modules trying to implement the same functionality. If ssd130x-spi works, then dropping fb_sh1106 from the defconfigs would be a good move. All the FBTFT drivers are orphaned and stuck in staging.

@gtrainavicius
Copy link
Contributor Author

This is a one off use case where I'll pretty much lock the software versions, so I'm just happy fb_sh1106 works fine. :) If I have to come across this again in the future, I'll look for better solutions.

Thank you for your help!

popcornmix pushed a commit that referenced this issue Mar 31, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Mar 31, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 7, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 7, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 24, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 24, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 24, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 24, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 28, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 28, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 28, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Apr 28, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 6, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 6, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 6, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 6, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 14, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 14, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 14, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 14, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 20, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 20, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 20, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 20, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 23, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 23, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 27, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue May 27, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Jun 3, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Jun 3, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Jun 5, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Jun 5, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Jun 5, 2025
axi_desc_put often gets called in error paths, and so can't assume that
the descriptor passed in has been completely initialised. Guard against
unallocated LLIs.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
popcornmix pushed a commit that referenced this issue Jun 5, 2025
Remove a bogus memory alignment check - transfers will be run bytewise
if needed - and add a check that the overall length is multiple of the
register size, otherwise there is residue.

See: #6733

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants