Skip to content

Commit

Permalink
meta-lxatac-bsp: lxatac-net-switch-hacks: increase prio for SPI irq t…
Browse files Browse the repository at this point in the history
…hread

When the system is under high load some SPI transfers with the ethernet
switch will time out before they are handled.

Increase the priority of the kernel thread that handles the SPI transfer
to work around the issue.

It does not make a lot of sense for a SPI transfer, that is 100% under the
hosts control (it does not and can not wait for the device for example) to
time out in the first place.
This means we are only fighting symptoms here, which is why this change
is also marked as a hack.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
  • Loading branch information
hnez committed Nov 18, 2024
1 parent d83f63e commit ceae298
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBSYSTEM=="platform", DRIVER=="spi_stm32", TAG+="systemd"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Increase kernel thread priority for the SPI bus to prevent timeouts
Requires=sys-devices-platform-soc-5c007000.bus-44009000.spi.device
After=sys-devices-platform-soc-5c007000.bus-44009000.spi.device

[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c "chrt --pid 55 `pgrep irq/[0-9]+-44009000`"

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit allarch
inherit allarch systemd

SRC_URI += " \
file://01-increase-atomic-mem-pool-size.conf \
file://60-spi-device.rules \
file://spi-irq-prio-44009000.service \
"

do_install() {
Expand All @@ -14,8 +16,28 @@ do_install() {
# under high load.
install -D -m0600 ${WORKDIR}/01-increase-atomic-mem-pool-size.conf \
${D}${libdir}/sysctl.d/01-increase-atomic-mem-pool-size.conf

# Tag the SPI bus controllers with the `systemd` udev tag.
# This makes systemd create units like
# sys-devices-platform-soc-5c007000.bus-44009000.spi.device
# that we can use as `Requires=` and `After=` in other units.
install -D -m0644 ${WORKDIR}/60-spi-device.rules \
${D}${sysconfdir}/udev/rules.d/60-spi-device.rules

# Increase the priority of the kernel thread that handles the
# interrupts for the SPI controler the ethernet switch is connected to.
# This prevents timeouts when communicating with the switch while the
# system is under high load.
install -D -m0600 ${WORKDIR}/spi-irq-prio-44009000.service \
${D}${systemd_system_unitdir}/spi-irq-prio-44009000.service
}

SYSTEMD_SERVICE:${PN} = "spi-irq-prio-44009000.service"

# For chrt and pgrep in spi-irq-prio-44009000.service
RDEPENDS:${PN} += "util-linux busybox"

FILES:${PN} += "\
${libdir}/sysctl.d/ \
${sysconfdir} \
"

0 comments on commit ceae298

Please sign in to comment.