openwrt / telephony

The telephony packages feed
104 stars 240 forks source link

dahdi-linux: bump + fixes for linux>=5.18 and 6.1 build #786

Closed john-tho closed 9 months ago

john-tho commented 1 year ago

Maintainer: Compile tested: aarch64 kernel 6.1rc1 WIP Run tested: no

wait for upstream changes PR review: https://github.com/asterisk/dahdi-linux/pull/14

micmac1 commented 1 year ago

Hi there,

is this maybe already addressed in the "next" branch?

https://github.com/asterisk/dahdi-linux/commits/next

john-tho commented 1 year ago

Hi there, is this maybe already addressed in the "next" branch? https://github.com/asterisk/dahdi-linux/commits/next

oops… It does have the pci_ removed fix, but not the netif_napi_add fix yet.

switched to git source + next branch + 6.1 fix not for merge, just for testing/comment for now

Cheers

sbwml commented 1 year ago

On Linux 6.3 I get this logs 😔

/home/openwrt/build_dir/target-aarch64_generic_musl/linux-rockchip_armv8/dahdi-linux-3.1.0/drivers/dahdi/Kbuild:117: CPU Architecture 'arm64' does not support VPMADT032 or HPEC. Skipping.
  CC [M]  /home/openwrt/build_dir/target-aarch64_generic_musl/linux-rockchip_armv8/dahdi-linux-3.1.0/drivers/dahdi/wct4xxp/base.o
/home/openwrt/build_dir/target-aarch64_generic_musl/linux-rockchip_armv8/dahdi-linux-3.1.0/drivers/dahdi/wct4xxp/base.c:45:10: fatal error: stdbool.h: No such file or directory
   45 | #include <stdbool.h>
      |          ^~~~~~~~~~~
compilation terminated.
micmac1 commented 1 year ago

Hi @john-tho

Can we bump to 3.2.0 instead of going for next branch? And change PKG_RELEASE to "1" (that's where OpenWrt starts counting)?

Kind regards, Seb

john-tho commented 1 year ago

switched to the 3.2.0 release + backport 5.18 pci fix + pending 6.1 fix. Only compile tested 5.15 mt7621. Need to setup my 6.1 branch later to compile test that.

I also need to fix the ethernet address for 6.1:

                 from /mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.c:24:
/mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.c: In function 'wctc4xxp_net_register':
/mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.c:646:22: error: passing argument 1 of '__builtin_memcpy' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
  646 |         memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
      |                ~~~~~~^~~~~~~~~~
./include/linux/fortify-string.h:469:27: note: in definition of macro '__fortify_memcpy_chk'
  469 |         __underlying_##op(p, q, __fortify_size);                        \
      |                           ^
/mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.c:646:9: note: in expansion of macro 'memcpy'
  646 |         memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
      |         ^~~~~~
/mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.c:646:22: note: expected 'void *' but argument is of type 'const unsigned char *'
  646 |         memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
      |                ~~~~~~^~~~~~~~~~
./include/linux/fortify-string.h:469:27: note: in definition of macro '__fortify_memcpy_chk'
  469 |         __underlying_##op(p, q, __fortify_size);                        \
      |                           ^
/mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.c:646:9: note: in expansion of macro 'memcpy'
  646 |         memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
      |         ^~~~~~
cc1: all warnings being treated as errors
make[7]: *** [scripts/Makefile.build:250: /mnt/pool_ssd/code/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/dahdi-linux-3.2.0/drivers/dahdi/wctc4xxp/base.o] Error 1
micmac1 commented 1 year ago

switched to the 3.2.0 release + backport 5.18 pci fix + pending 6.1 fix. Only compile tested 5.15 mt7621. Need to setup my 6.1 branch later to compile test that.

Thanks! I have openwrt-sdk-bcm27xx-bcm2710_gcc-12.3.0_musl.Linux-x86_64 SDK here so will test compile against 6.1 tonight.

john-tho commented 1 year ago

Added 2 more fixes I ran into on mt7621 6.1 compile: dev_addr const & redefined ABS and quilt refreshed

micmac1 commented 1 year ago

Thanks @john-tho

Compiles fine for me, tried both a kernel 6.1 SDK and a kernel 5.15 SDK.

-rw-r--r-- 1 sk sk 3,4K 14. Jun 20:55 bin/targets/bcm27xx/bcm2710/packages/kmod-dahdi-dummy_6.1.33+3.2.0-1_aarch64_cortex-a53.ipk
-rw-r--r-- 1 sk sk 2,6K 14. Jun 20:55 bin/targets/bcm27xx/bcm2710/packages/kmod-dahdi-echocan-oslec_6.1.33+3.2.0-1_aarch64_cortex-a53.ipk
-rw-r--r-- 1 sk sk  12K 14. Jun 20:55 bin/targets/bcm27xx/bcm2710/packages/kmod-dahdi-hfcs_6.1.33+3.2.0-1_aarch64_cortex-a53.ipk
-rw-r--r-- 1 sk sk  63K 14. Jun 20:55 bin/targets/bcm27xx/bcm2710/packages/kmod-dahdi_6.1.33+3.2.0-1_aarch64_cortex-a53.ipk

-rw-r--r-- 1 sk sk 3,2K 14. Jun 21:11 bin/targets/ath79/generic/packages/kmod-dahdi-dummy_5.15.114+3.2.0-1_mips_24kc.ipk
-rw-r--r-- 1 sk sk 2,3K 14. Jun 21:11 bin/targets/ath79/generic/packages/kmod-dahdi-echocan-oslec_5.15.114+3.2.0-1_mips_24kc.ipk
-rw-r--r-- 1 sk sk  12K 14. Jun 21:11 bin/targets/ath79/generic/packages/kmod-dahdi-hfcs_5.15.114+3.2.0-1_mips_24kc.ipk
-rw-r--r-- 1 sk sk  63K 14. Jun 21:11 bin/targets/ath79/generic/packages/kmod-dahdi_5.15.114+3.2.0-1_mips_24kc.ipk

I'm not big on C code, as far as I can tell this looks fine to me. @john-tho are you OK with the current state of your pull request?

@jslachta Hi Jiri, are you OK with me merging this? OpenWrt promoted kernel 6.1 to standard kernel for a few targets, so compile failures are visible with dahdi-linux now. Hence I'd like to merge this soonish. :-)

Thanks all!

Seb

jslachta commented 1 year ago

@micmac1, sure!

pkgadd commented 1 year ago

I've been falling over this while working on bumping x86_64 to kernel v6.1 as well. In regards to kernel fixes, there seems to be quite some activity at https://gitea.osmocom.org/retronetworking/dahdi-linux/ (I've never used dadhi, just compile (tried to-) compile tested it with kernel v6.1).

micmac1 commented 1 year ago

Hi @john-tho

I've looked around at other projects and how they solved this. I found a buildroot patch, which buildroot seems to have gotten from a gentoo pull request: Link

Actually replacing your 206 patch directly with the one from Gentoo doesn't work. I get this:

/home/sk/tmp/sdk/openwrt-sdk-bcm27xx-bcm2710_gcc-12.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_bcm2710/dahdi-linux-3.2.0/drivers/dahdi/xpp/xbus-sysfs.c:466:19: error: initialization of 'int (*)(struct device *, struct kobj_uevent_env *)' from incompatible pointer type 'int (*)(const struct device *, struct kobj_uevent_env *)' [-Werror=incompatible-pointer-types]
  466 |         .uevent = astribank_uevent,
      |                   ^~~~~~~~~~~~~~~~

But when I just take a single line of that patch it compiles:

cat 206-dahdi-fix-const-dev_addr.patch 
--- a/drivers/dahdi/wctc4xxp/base.c
+++ b/drivers/dahdi/wctc4xxp/base.c
@@ -643,7 +643,7 @@ wctc4xxp_net_register(struct wcdte *wc)
        return -ENOMEM;
    priv = netdev_priv(netdev);
    priv->wc = wc;
-   memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
+   memcpy((void *)netdev->dev_addr, our_mac, sizeof(our_mac));

 #  ifdef HAVE_NET_DEVICE_OPS
    netdev->netdev_ops = &wctc4xxp_netdev_ops;

Does this make sense to you?

CharlesMengCA commented 1 year ago

Hi john-tho,

Could you rebase your branch with the master?

Thanks,

john-tho commented 1 year ago
cat 206-dahdi-fix-const-dev_addr.patch 
--- a/drivers/dahdi/wctc4xxp/base.c
+++ b/drivers/dahdi/wctc4xxp/base.c
@@ -643,7 +643,7 @@ wctc4xxp_net_register(struct wcdte *wc)
      return -ENOMEM;
  priv = netdev_priv(netdev);
  priv->wc = wc;
- memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
+ memcpy((void *)netdev->dev_addr, our_mac, sizeof(our_mac));

 #    ifdef HAVE_NET_DEVICE_OPS
  netdev->netdev_ops = &wctc4xxp_netdev_ops;

Does this make sense to you?

To me, this looks like a dodgy workaround, if the (Linux) intention is that nothing directly modifies dev_addr.

Linux 5.17 made dev_addr const adeef3e32146 ("net: constify netdev->dev_addr") As part of that series, there are runtime checks against this: d07b26f5bbea ("dev_addr: add a modification check") From https://lore.kernel.org/netdev/20211119142155.3779933-6-kuba@kernel.org/:

netdev->dev_addr should only be modified via helpers, but someone may be casting off the const. Add a runtime check to catch abuses.


Could you rebase your branch with the master?

I cannot see any conflicts, could you please let me know why you want the rebase?

Cheers,

micmac1 commented 1 year ago

Thanks john-tho!

john-tho commented 1 year ago

For a quick update: There has finally been some activity on the dahdi repo. Most of the 6.1 build issues have been addressed in the master branch, and I opened an issue to detail the dev_addr direct writes: https://github.com/asterisk/dahdi-linux/issues/31

micmac1 commented 9 months ago

Closing this, merged bump to head in another PR. @john-tho thanks for your work!