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

   ## Summary
   
   Two rpmsg device ioctls for user space:
   
   - `RPMSGIOC_RUNNING`: stores whether the remote side of the rpmsg device
     is up (`rpmsg_is_running()`) into the `bool` the argument points to.
   - `CONFIG_RPMSG_WAKELOCK`: an rpmsg service that lets a CPU hold a PM
     wakelock on its peer. `RPMSGIOC_ACQUIRE_WAKELOCK` and
     `RPMSGIOC_RELEASE_WAKELOCK` send the wakelock name to the remote side,
     which creates a wakelock of that name on the first acquire, stays it on
     every acquire, relaxes it on every release and frees it once its count
     is back to zero.
   
   ## Impact
   
   Three new ioctl numbers in `include/nuttx/rpmsg/rpmsg.h`. The wakelock
   service is a new option, default off, depends on `PM`; both sides of a
   link must enable it.
   
   ## 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
   
   qemu-armv8a:rpserver/rpproxy with `CONFIG_PM`, `CONFIG_FS_PROCFS_REGISTER`,
   `CONFIG_PM_PROCFS` and `CONFIG_RPMSG_WAKELOCK` added on both sides, plus a
   test-only app that issues the ioctls:
   
   <details><summary>wltest (test only, not part of this PR)</summary>
   
   ```c
   /* Test only: wltest <acquire|release> <dev> <name> | wltest running <dev> */
   #include <nuttx/config.h>
   #include <fcntl.h>
   #include <stdbool.h>
   #include <stdio.h>
   #include <string.h>
   #include <unistd.h>
   #include <sys/ioctl.h>
   #include <nuttx/rpmsg/rpmsg.h>
   
   int main(int argc, char *argv[])
   {
     bool running = false;
     int cmd;
     int fd;
     int ret;
   
     if (argc < 3)
       {
         printf("usage: wltest <acquire|release> <dev> <name>\n"
                "       wltest running <dev>\n");
         return 1;
       }
   
     fd = open(argv[2], O_RDWR);
     if (fd < 0)
       {
         printf("open %s failed\n", argv[2]);
         return 1;
       }
   
     if (strcmp(argv[1], "running") == 0)
       {
         ret = ioctl(fd, RPMSGIOC_RUNNING, (unsigned long)&running);
         close(fd);
         printf("wltest running ret=%d running=%d\n", ret, running);
         return ret < 0;
       }
   
     cmd = strcmp(argv[1], "acquire") == 0 ? RPMSGIOC_ACQUIRE_WAKELOCK :
                                             RPMSGIOC_RELEASE_WAKELOCK;
     ret = ioctl(fd, cmd, (unsigned long)argv[3]);
     close(fd);
     printf("wltest %s %s ret=%d\n", argv[1], argv[3], ret);
     return ret < 0;
   }
   ```
   </details>
   
   The server checks both links are up, then acquires `wltest` on the proxy
   twice and releases it twice; the proxy's `/proc/pm/wakelock0` follows the
   count and drops the entry at zero:
   
   ```
   server> wltest running /dev/rpmsg/proxy
   wltest running ret=0 running=1
   server> wltest running /dev/rpmsg/proxy2
   wltest running ret=0 running=1
   proxy> cat /proc/pm/wakelock0
   DOMAIN0                   STATE          COUNT          TIME
   rpmsg-uart-rx-server2     idle           0              0s
   rpmsg-uart-tx-server2     idle           0              0s
   server> wltest acquire /dev/rpmsg/proxy wltest
   wltest acquire wltest ret=0
   server> wltest acquire /dev/rpmsg/proxy wltest
   wltest acquire wltest ret=0
   proxy> cat /proc/pm/wakelock0
   DOMAIN0                   STATE          COUNT          TIME
   rpmsg-uart-rx-server2     idle           0              0s
   rpmsg-uart-tx-server2     idle           0              0s
   wltest                    normal         2              2s
   server> wltest release /dev/rpmsg/proxy wltest
   wltest release wltest ret=0
   proxy> cat /proc/pm/wakelock0
   DOMAIN0                   STATE          COUNT          TIME
   rpmsg-uart-rx-server2     idle           0              0s
   rpmsg-uart-tx-server2     idle           0              0s
   wltest                    normal         1              5s
   server> wltest release /dev/rpmsg/proxy wltest
   wltest release wltest ret=0
   proxy> cat /proc/pm/wakelock0
   DOMAIN0                   STATE          COUNT          TIME
   rpmsg-uart-rx-server2     idle           0              0s
   rpmsg-uart-tx-server2     idle           0              0s
   ```
   
   Baseline with the option off:
   
   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 1aad732716e apps 54374b3b2
   - 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