Skip to content
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

[bpi-r2pro/linux 6.1] how to populate spi devices in /dev #112

Open
jssyan opened this issue Nov 21, 2023 · 1 comment
Open

[bpi-r2pro/linux 6.1] how to populate spi devices in /dev #112

jssyan opened this issue Nov 21, 2023 · 1 comment

Comments

@jssyan
Copy link

jssyan commented Nov 21, 2023

Would you please show some samples about how to populate spi devices under /dev for a bpi-r2-pro board?

Here is what I have done (but failed)

changed status from "disabled" to "okay" in rk3568-bpi-r2-pro.dts spi3

&spi3 {
   /* pin 19 (MO) + 21 (MI) + 23 (CK) of header con2 */
   /* shared with pwm12/14/15 and uart9 */
   pinctrl-0 = <&spi3m1_pins>;
   status = "okay";
};

compile & install & reboot

# lsmod
Module                  Size  Used by    Not tainted
spidev                 24576  0
nf_nat_ftp             20480  0
nf_conntrack_ftp       28672  1 nf_nat_ftp
ipt_REJECT             16384  1
nf_reject_ipv4         16384  1 ipt_REJECT
nf_log_syslog          24576  7
xt_LOG                 20480  7
xt_mark                16384  1
xt_conntrack           16384  3
iptable_filter         16384  1
iptable_mangle         16384  1
iptable_nat            16384  1
nf_nat                 65536  2 nf_nat_ftp,iptable_nat
nf_conntrack          155648  4 nf_nat_ftp,nf_conntrack_ftp,xt_conntrack,nf_nat
nf_defrag_ipv4         16384  1 nf_conntrack
nf_defrag_ipv6         24576  1 nf_conntrack
ip_tables              32768  3 iptable_filter,iptable_mangle,iptable_nat
x_tables               40960  8 ipt_REJECT,xt_LOG,xt_mark,xt_conntrack,iptable_filter,iptable_mangle,iptable_nat,ip_tables
polyval_ce             16384  0
polyval_generic        16384  1 polyval_ce
rockchip_rng           20480  0
rtc_hym8563            20480  1
spi_rockchip           20480  0
uio_pdrv_genirq        20480  0
uio                    20480  1 uio_pdrv_genirq
ath10k_pci             45056  0
ath10k_core           438272  1 ath10k_pci
mac80211              794624  1 ath10k_core
ath                    32768  1 ath10k_core
cfg80211              712704  3 ath10k_core,mac80211,ath

# ls -R /dev | grep spi
(nothing)

# find /sys/ -name spi3
/sys/class/spi_master/spi3
/sys/devices/platform/fe640000.spi/spi_master/spi3
/sys/firmware/devicetree/base/pinctrl/spi3
/sys/firmware/devicetree/base/aliases/spi3
/sys/firmware/devicetree/base/__symbols__/spi3

no spidevB.C device found under /dev

# cat /etc/mdev.conf
$MODALIAS=.* 0:0 660 @/sbin/modprobe -b "$MODALIAS"

null            0:0 666
zero            0:0 666
urandom         0:0 444

kmem            0:9 000
mem             0:9 640
port            0:9 640

console         0:5 600
ptmx            0:5 660
tty[0-9]*       0:5 660
ttyS[0-9]*      0:20 640

fd[0-9]*        0:11 660
sd[a-z]*        0:6 660
hd[a-z]*        0:6 660

rtc0            0:0 600 @/bin/ln -sf $MDEV rtc

usbdev.*          0:0 0660  */etc/mdev/usbdev.sh
SUBSYSTEM=usb;.*  0:0 0660  */etc/mdev/usbdev.sh

SUBSYSTEM=drivers;.* 0:0 0660  */etc/mdev/drivers.sh
@frank-w
Copy link
Owner

frank-w commented Jan 26, 2024

Hi sorry,missed this issue somehow. Have not done much with spi,but afaik you have to add your device (with the right compatible) to devicetree. Afair the spidev needs a special compatible as the spidev default compatible was dropped from mainline some time ago...you have to look into spidev driver which compatibles it supports

frank-w pushed a commit that referenced this issue Feb 10, 2024
[ Upstream commit b16904f ]

With latest upstream llvm18, the following test cases failed:

  $ ./test_progs -j
  #13/2    bpf_cookie/multi_kprobe_link_api:FAIL
  #13/3    bpf_cookie/multi_kprobe_attach_api:FAIL
  #13      bpf_cookie:FAIL
  #77      fentry_fexit:FAIL
  #78/1    fentry_test/fentry:FAIL
  #78      fentry_test:FAIL
  #82/1    fexit_test/fexit:FAIL
  #82      fexit_test:FAIL
  #112/1   kprobe_multi_test/skel_api:FAIL
  #112/2   kprobe_multi_test/link_api_addrs:FAIL
  [...]
  #112     kprobe_multi_test:FAIL
  #356/17  test_global_funcs/global_func17:FAIL
  #356     test_global_funcs:FAIL

Further analysis shows llvm upstream patch [1] is responsible for the above
failures. For example, for function bpf_fentry_test7() in net/bpf/test_run.c,
without [1], the asm code is:

  0000000000000400 <bpf_fentry_test7>:
     400: f3 0f 1e fa                   endbr64
     404: e8 00 00 00 00                callq   0x409 <bpf_fentry_test7+0x9>
     409: 48 89 f8                      movq    %rdi, %rax
     40c: c3                            retq
     40d: 0f 1f 00                      nopl    (%rax)

... and with [1], the asm code is:

  0000000000005d20 <bpf_fentry_test7.specialized.1>:
    5d20: e8 00 00 00 00                callq   0x5d25 <bpf_fentry_test7.specialized.1+0x5>
    5d25: c3                            retq

... and <bpf_fentry_test7.specialized.1> is called instead of <bpf_fentry_test7>
and this caused test failures for #13/#77 etc. except #356.

For test case #356/17, with [1] (progs/test_global_func17.c)), the main prog
looks like:

  0000000000000000 <global_func17>:
       0:       b4 00 00 00 2a 00 00 00 w0 = 0x2a
       1:       95 00 00 00 00 00 00 00 exit

... which passed verification while the test itself expects a verification
failure.

Let us add 'barrier_var' style asm code in both places to prevent function
specialization which caused selftests failure.

  [1] llvm/llvm-project#72903

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20231127050342.1945270-1-yonghong.song@linux.dev
Signed-off-by: Sasha Levin <sashal@kernel.org>
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

2 participants