CV-Bowen opened a new pull request, #21314:
URL: https://github.com/apache/nuttx/pull/21314

   ## Summary
   
   The two cores of a BMP link share one resource table and only one of
   them initializes it; which one depends on the board.
   `rptun_bmp_get_resource()` returned the table right away, so the core
   that does not own it could start parsing an uninitialized table, find
   no vdev and never bring up the link.
   
   Wait in `rptun_bmp_get_resource()` until the table header has a non-zero
   version. Both roles wait, because the table can be set up by either the
   master or the slave.
   
   ## Impact
   
   `rptun_bmp_get_resource()` blocks until the peer has initialized the
   resource table, instead of returning a table that may not be ready. No
   API or Kconfig change.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   No in-tree board uses rptun_bmp. It was run on an out-of-tree QEMU
   armv7-a TrustZone setup (`-machine virt,secure=on`): the secure world
   (TEE, rptun_bmp slave) initializes the resource table and the
   non-secure world (AP, rptun_bmp master) reads it. The images were built
   from a tree whose `rptun_bmp_get_resource()` is identical to this PR.
   The link comes up and rpmsg works across it:
   
   <details><summary>AP console</summary>
   
   ```
   ap> ls /dev/rptun
   /dev/rptun:
    tee
   ap> rpmsg dump all
   [   18.536112] [12] [ EMERG] [ap] rpmsg_virtio_dump: Local: ap Remote: tee 
Headrx 20 Headtx 12
   [   18.536264] [12] [ EMERG] [ap] rpmsg_virtio_dump: Dump rpmsg info between 
cpu (master: yes)ap <==> tee:
   [   18.536323] [12] [ EMERG] [ap] rpmsg_dump_epts: rpmsg ept list:
   [   18.536382] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept NS 0x404bfc40: s=53 
d=53 r=1 pr=127 p=0x404bfc38
   [   18.536449] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept rpmsg-rtc 
0x404a05e0: s=1024 d=1029 r=1 pr=127 p=0x4049bf00
   [   18.536480] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept rpmsg-ttyTEE 
0x404a2e90: s=1025 d=1025 r=1 pr=255 p=0x4049ed58
   [   18.536508] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept rpmsg-sensor 
0x404a2628: s=1026 d=4294967295 r=1 pr=127 p=0x404a2620
   [   18.536722] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept rpmsg-ping 
0x404bfb88: s=1027 d=1027 r=1 pr=127 p=0
   [   18.536766] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept rpmsg-ping-rt 
0x404bfbd8: s=1028 d=1028 r=1 pr=255 p=0
   [   18.536793] [12] [ EMERG] [ap] rpmsg_dump_epts:   ept rpmsg-syslog 
0x404c34a0: s=1029 d=1024 r=1 pr=126 p=0x404c34a0
   ap> rpmsg ping all 3 64 3 0
   [   24.593303] [12] [ EMERG] [ap] rpmsg_ping: core info: ap <-> tee
   [   24.593341] [12] [ EMERG] [ap] rpmsg_ping: ping times: 3
   [   24.593370] [12] [ EMERG] [ap] rpmsg_ping: buffer_len: 496, send_len: 64
   [   24.593514] [12] [ EMERG] [ap] rpmsg_ping_logout: avg: 0 s, 5908464 ns
   [   24.593563] [12] [ EMERG] [ap] rpmsg_ping_logout: min: 0 s, 1543152 ns
   [   24.593611] [12] [ EMERG] [ap] rpmsg_ping_logout: max: 0 s, 13517232 ns
   [   24.593752] [12] [ EMERG] [ap] rpmsg_ping_logout_rate: rate: 0.086655 
Mbits/sec
   ```
   </details>
   
   In this setup the secure side initializes the table before it starts
   the non-secure side, so the wait returns at once; the case it protects
   against is the owner of the table starting after its peer.
   
   `rptun_bmp.c` was also built for qemu-armv8a:rpserver with
   `CONFIG_RPTUN_BMP=y` added, without warnings. Baseline:
   
   Baseline (`test.sh`, cases: baseline.yaml):
   
   - host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   - tested: nuttx ea042dd8c39 apps 35cdcc9a8
   - qemu-armv8a built with test-only overlay: disabled LIBC_ENVPATH 
BINFMT_CHECKEXEC
   - sim:rpserver + sim:rpproxy: PASS
     - [x] `uname -a` (server)
     - [x] `rpmsg dump all` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (server)
     - [x] `uname -a` (proxy)
     - [x] `rpmsg ping all 10 1024 3 0` (proxy)
     - [x] `mount -t rpmsgfs -o cpu=server,fs=/proc /sp` (proxy)
     - [x] `cat /sp/version` (proxy)
     - [x] `rpmsg dump all` (proxy)
   - qemu-armv8a:rpserver + qemu-armv8a:rpproxy: PASS
     - [x] `uname -a` (server)
     - [x] `uname -a` (proxy)
     - [x] `rpmsg dump all` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (proxy)
     - [x] `mount -t rpmsgfs -o cpu=server,fs=/proc /sp` (proxy)
     - [x] `cat /sp/version` (proxy)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to