frank-w
(Frank W.)
April 17, 2018, 2:08pm
41
can anybody explain me, how from_timer-function works and which-params (1st+3rd) are needed?
i found some patches like https://www.spinics.net/lists/raid/msg59618.html
but the params are not clear…first can be the same var like assigned to, second is the timer_list and the last??
include/linux/timer.h
#define from_timer(var, callback_timer, timer_fieldname) \
container_of(callback_timer, typeof(*var), timer_fieldname)
here is the way i try to port:
frank-w
(Frank W.)
April 20, 2018, 11:06am
42
having now problems with the from_timer-macro, have anyone an idea?
In file included from ./include/linux/init.h:5:0,
from drivers/misc/mediatek/connectivity/common/conn_soc/linux/include/osal_typedef.h:25,
from drivers/misc/mediatek/connectivity/common/conn_soc/core/psm_core.c:14:
drivers/misc/mediatek/connectivity/common/conn_soc/core/psm_core.c: In function '_stp_psm_stp_is_idle':
./include/linux/compiler.h:314:20: error: call to '__compiletime_assert_1144' declared with attribute error: pointer type mismatch in container_of()
prefix ## suffix(); \
^
./include/linux/compiler.h:322:2: note: in expansion of macro '__compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
./include/linux/compiler.h:334:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
^
./include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^
./include/linux/kernel.h:930:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
./include/linux/timer.h:144:2: note: in expansion of macro 'container_of'
This file has been truncated. show original
frank-w
(Frank W.)
May 1, 2018, 8:22am
43
anyone here who can help? i guess it’s the last param i’ve set to from_timer…but also found no explaination of the from_timer-macro
dfiloni
(Devid)
May 8, 2018, 10:59pm
44
Hi Frank,
please apply attached patch to your 4.16-wifi branch, it does build but I don’t have an R2 board to test it.
patch.diff (3.8 KB)
1 Like
dsiq
May 9, 2018, 12:09am
45
Hi Frank,
sorry didn’t look in detail about what you are trying to accomplish but this is just a simple trick to find an entry in the structure.
So second parameter is the pointer to the struct list that the timer uses and the third parameter is the name of the variable embedded in the structure that you are trying to pull.
Does that make sense?
Thanks
dsiq
May 9, 2018, 12:30am
46
I just looked at the link you provided, that’s never going to work. You’re not initializing the structure correctly at the init time. Then you are trying to pull the wrong type and cast it.
This will either: crash, dump garbage or cause a memory corruption depending on what the rest of the code does with this variable.
What are you trying to do? Port something from 4.16 to 4.14?
I don’t have a ton of free time, but I do have about 24 years of linux kernel and drivers experience so maybe I can help here and there…
frank-w
(Frank W.)
May 9, 2018, 4:44am
47
I try to port the wifi-driver of r2 from 4.14 to 4.16
@dfiloni thank you…will try it when i’m at home
dsiq
May 9, 2018, 12:04pm
48
@dfiloni ’s patch seems better, let me know if you need help
frank-w
(Frank W.)
May 9, 2018, 1:30pm
49
there is a new problem:
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_kal.h:851:53: error: 'memset' writing 6 bytes into a region of size 5 overflows the destination [-Werror=stringop-overflow=]
#define kalMemZero(pvAddr, u4Size) memset(pvAddr, 0, u4Size)
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c:2084:5: note: in expansion of macro 'kalMemZero'
kalMemZero(prBowLinkConnected->aucPeerAddress, MAC_ADDR_LEN); /* @FIXME */
^~~~~~~~~~
dsiq
May 9, 2018, 3:06pm
50
@frank-w can you post the structure definition for: prBowLinkConnected->aucPeerAddress
frank-w
(Frank W.)
May 9, 2018, 3:11pm
51
Full code is in 4.16-wifi branch in my github…
the wifi-driver is in drivers/misc/mediatek
I’m currently not @home
edit:
drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_bow.c:1262: P_BOW_LINK_CONNECTED prBowLinkConnected;
drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/bow.h:252:
typedef struct _BOW_LINK_CONNECTED {
CHANNEL_DESC rChannel;
UINT_8 aucReserved;
UINT_8 aucPeerAddress[6];
} BOW_LINK_CONNECTED, *P_BOW_LINK_CONNECTED;
dsiq
May 9, 2018, 5:56pm
52
That’s a very interesting error. Can you paste output of “gcc -v” or whatever compiler you ran?
Thanks
dfiloni
(Devid)
May 9, 2018, 6:05pm
53
He’s using GCC 7, that’s why I was able to build it.
dsiq
May 9, 2018, 6:05pm
54
Also as a quick test, can you try and change it to this:
kalMemZero(&prBowLinkConnected->aucPeerAddress[0], MAC_ADDR_LEN);
frank-w
(Frank W.)
May 9, 2018, 6:08pm
55
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-16ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as --with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)
make crosscompile with gcc-arm-linux-gnueabihf, but this seems not to be a binary
find / -name '*-arm-linux-gnueabihf' 2>/dev/null
/usr/share/doc/binutils-arm-linux-gnueabihf
/usr/share/doc/gcc-7-arm-linux-gnueabihf
/usr/share/doc/cpp-arm-linux-gnueabihf
/usr/share/doc/gcc-arm-linux-gnueabihf
/usr/share/doc/cpp-7-arm-linux-gnueabihf
/usr/share/lintian/overrides/binutils-arm-linux-gnueabihf
/usr/share/lintian/overrides/gcc-7-arm-linux-gnueabihf
/usr/share/lintian/overrides/cpp-7-arm-linux-gnueabihf
dsiq
May 9, 2018, 6:13pm
56
Ah OK, so you are on Bionic (18.04), I don’t see the problem on xenial. I did see a couple of issues on gcc bug reports related to this flag.
But to just clarify, the cross compilation is the one that fails?
Also can you try changing the line as mentioned in my previous post.
dsiq
May 9, 2018, 6:28pm
57
If you are cross compiling for example in openwrt you’d have the compiler here:
staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-5.4.0_musl_eabi/bin/arm-openwrt-linux-muslgnueabi-gcc
frank-w
(Frank W.)
May 9, 2018, 6:32pm
58
with the change you’ve mentioned:
from drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c:812:
./arch/arm/include/asm/string.h:26:15: note: expected 'void *' but argument is of type 'UINT_8 {aka unsigned char}'
extern void * memset(void *, int, __kernel_size_t);
^~~~~~
diff --git a/drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c b/drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c
index ba4840414da8..24337520f79d 100644
--- a/drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c
+++ b/drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c
@@ -2081,7 +2081,7 @@ VOID nicRxProcessEventPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb
/* fill event body */
prBowLinkConnected = (P_BOW_LINK_CONNECTED) (prBowEvent->aucPayload);
prBowLinkConnected->rChannel.ucChannelNum = prEventBtOverWifi->ucSelectedChannel;
- kalMemZero(prBowLinkConnected->aucPeerAddress, MAC_ADDR_LEN); /* @FIXME */
+ kalMemZero(prBowLinkConnected->aucPeerAddress[0], MAC_ADDR_LEN); /* @FIXME */
kalIndicateBOWEvent(prAdapter->prGlueInfo, prBowEvent);
} else {
@@ -2093,7 +2093,7 @@ VOID nicRxProcessEventPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb
/* fill event body */
prBowLinkDisconnected = (P_BOW_LINK_DISCONNECTED) (prBowEvent->aucPayload);
prBowLinkDisconnected->ucReason = 0; /* @FIXME */
- kalMemZero(prBowLinkDisconnected->aucPeerAddress, MAC_ADDR_LEN); /* @FIXME */
+ kalMemZero(prBowLinkDisconnected->aucPeerAddress[0], MAC_ADDR_LEN); /* @FIXME */
kalIndicateBOWEvent(prAdapter->prGlueInfo, prBowEvent);
}
openwrt builds its own toolchain…have it not downloaded/built
dsiq
May 9, 2018, 6:36pm
59
Argh! OK then type cast it:
kalMemZero((void*)(&prBowLinkConnected->aucPeerAddress[0]), MAC_ADDR_LEN);
frank-w
(Frank W.)
May 9, 2018, 6:40pm
60
seems cast is not easy this way:
drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c:2084:16: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
kalMemZero((void*)(prBowLinkConnected->aucPeerAddress[0]), MAC_ADDR_LEN); /* @FIXME */
^
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_kal.h:851:60: note: in definition of macro 'kalMemZero'
#define kalMemZero(pvAddr, u4Size) memset(pvAddr, 0, u4Size)
^~~~~~
drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c:2096:16: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
kalMemZero((void*)(prBowLinkDisconnected->aucPeerAddress[0]), MAC_ADDR_LEN); /* @FIXME */
^
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_kal.h:851:60: note: in definition of macro 'kalMemZero'
#define kalMemZero(pvAddr, u4Size) memset(pvAddr, 0, u4Size)
^~~~~~