Fix detection of dev_addr_set availability on 4.19 kernels
PATCH 1/1 Fix detection of dev_addr_set availability on 4.19 kernels
From: Jan Kiszka <[email protected]>
As the SUBLEVEL in LINUX_VERSION_CODE is 8-bits only and is clamped at 255, we cannot detect this way that 4.19.291 also gained support for dev_addr_set and eth_hw_addr_set. Upstream does not care about out-of-tree, so work around this limitation by extracting the true SUBLEVEL in prepare-kernel.sh and exporting it via Kconfig.
This is expected to remain limited to 4.19, thus is stable/v3.2.x only. And since 5.12, upstream has a KERNEL_VERSION_SUBLEVEL define in the generated version.h.
--- kernel/cobalt/include/asm-generic/xenomai/wrappers.h | 4 +++- scripts/Kconfig.frag | 4 ++++ scripts/prepare-kernel.sh | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)
kernel/cobalt/include/asm-generic/xenomai/wrappers.h +3 -1
@@ -258,7 +258,9 @@ devm_hwmon_device_register_with_groups(struct device *dev, const char *name, (LINUX_VERSION_CODE >=KERNEL_VERSION (5 ,5 ,0 ) || \LINUX_VERSION_CODE <KERNEL_VERSION (5 ,4 ,251 )) && \ (LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,20 ,0 ) || \ - LINUX_VERSION_CODE < KERNEL_VERSION(4,19,291)) +LINUX_VERSION_CODE <KERNEL_VERSION (4 ,19 ,255 ) || \ + (LINUX_VERSION_CODE ==KERNEL_VERSION (4 ,19 ,255 ) && \ + CONFIG_KVER_SUBLEVEL < 291))#define dev_addr_set (dev, addr) memcpy((dev)->dev_addr, addr, MAX_ADDR_LEN)#define eth_hw_addr_set (dev, addr) memcpy((dev)->dev_addr, addr, ETH_ALEN)#endif
scripts/Kconfig.frag +4 -0
@@ -47,3 +47,7 @@ config XENO_REVISION_LEVEL config XENO_VERSION_STRING string default "@VERSION_STRING@" + +config KVER_SUBLEVEL + int + default @KVER_SUBLEVEL@
scripts/prepare-kernel.sh +1 -0
@@ -399,6 +399,7 @@ case $linux_VERSION.$linux_PATCHLEVEL in -e "s,@VERSION_MINOR@,$version_minor,g" \ -e "s,@REVISION_LEVEL@,$revision_level,g" \ -e "s,@VERSION_STRING@,$version_string,g" \ + -e "s,@KVER_SUBLEVEL@,$linux_SUBLEVEL,g" \ -e "s,@SRCARCH@,$linux_arch,g" \ $xenomai_root/scripts/Kconfig.frag | patch_append init/Kconfig
Signature · 1 line
2.35.3
Quoted 11 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
As the SUBLEVEL in
LINUX_VERSION_CODEis 8-bits only and is clamped at 255, we cannot detect this way that 4.19.291 also gained support fordev_addr_setandeth_hw_addr_set. Upstream does not care about out-of-tree, so work around this limitation by extracting the true SUBLEVEL inprepare-kernel.shand exporting it viaKconfig.This is expected to remain limited to 4.19, thus is stable/v3.2.x only. And since 5.12, upstream has a
KERNEL_VERSION_SUBLEVELdefine in the generatedversion.h.
I'm not a fan of this solution, but I don't have a better idea ATM.
There is a strong feeling here that this problem will come back at some point in time. We enabled 6.1 support for stable/v3.2.x recently so it is not expected that this branch will disappear soon. Let's hope we manage to maintain it over time.
Best regards,
Florian
Quoted 49 lines
Signed-off-by Jan Kiszka <[email protected]>--- kernel/cobalt/include/asm-generic/xenomai/wrappers.h | 4 +++- scripts/Kconfig.frag | 4 ++++ scripts/prepare-kernel.sh | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)kernel/cobalt/include/asm-generic/xenomai/wrappers.h +3
-1@@ -258,7 +258,9 @@ devm_hwmon_device_register_with_groups(struct device *dev, const char *name, (LINUX_VERSION_CODE >=KERNEL_VERSION (5 ,5 ,0 ) || \LINUX_VERSION_CODE <KERNEL_VERSION (5 ,4 ,251 )) && \ (LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,20 ,0 ) || \ - LINUX_VERSION_CODE < KERNEL_VERSION(4,19,291)) +LINUX_VERSION_CODE <KERNEL_VERSION (4 ,19 ,255 ) || \ + (LINUX_VERSION_CODE ==KERNEL_VERSION (4 ,19 ,255 ) && \ + CONFIG_KVER_SUBLEVEL < 291))#define dev_addr_set (dev, addr) memcpy((dev)->dev_addr, addr, MAX_ADDR_LEN)#define eth_hw_addr_set (dev, addr) memcpy((dev)->dev_addr, addr, ETH_ALEN)#endif scripts/Kconfig.frag +4
-0@@ -47,3 +47,7 @@ config XENO_REVISION_LEVEL config XENO_VERSION_STRING string default "@VERSION_STRING@" + +config KVER_SUBLEVEL + int + default @KVER_SUBLEVEL@scripts/prepare-kernel.sh +1
-0@@ -399,6 +399,7 @@ case $linux_VERSION.$linux_PATCHLEVEL in -e "s,@VERSION_MINOR@,$version_minor,g" \ -e "s,@REVISION_LEVEL@,$revision_level,g" \ -e "s,@VERSION_STRING@,$version_string,g" \ + -e "s,@KVER_SUBLEVEL@,$linux_SUBLEVEL,g" \ -e "s,@SRCARCH@,$linux_arch,g" \ $xenomai_root/scripts/Kconfig.frag | patch_append init/KconfigSignature · 1 line
2.35.3
Quoted 13 lines · Florian Bezdeka
Quoted 11 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
As the SUBLEVEL in
LINUX_VERSION_CODEis 8-bits only and is clamped at 255, we cannot detect this way that 4.19.291 also gained support fordev_addr_setandeth_hw_addr_set. Upstream does not care about out-of-tree, so work around this limitation by extracting the true SUBLEVEL inprepare-kernel.shand exporting it viaKconfig.This is expected to remain limited to 4.19, thus is stable/v3.2.x only. And since 5.12, upstream has a
KERNEL_VERSION_SUBLEVELdefine in the generatedversion.h.
Quoted 6 lines
I'm not a fan of this solution, but I don't have a better idea ATM.
There is a strong feeling here that this problem will come back at some point in time. We enabled 6.1 support for stable/v3.2.x recently so it is not expected that this branch will disappear soon. Let's hope we manage to maintain it over time.
For this branch, we now have a solution. I think we won't need it anymore for master as only 5.10 could be affected there, and it also still takes a later breaking backport to actually trigger it. Nevertheless, I will split up this commit into infrastructure and the actual application to wrapper.h so that it would be easier to cherry-pick the infrastructure into master/3.3.x if needed in the future.
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center