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

Refactor and fix RPC library. #814

Closed
wants to merge 2 commits into from

Conversation

iabdalkader
Copy link
Contributor

@iabdalkader iabdalkader commented Dec 28, 2023

Main changes in this PR:

  • Fix the memory corruption caused by the wrong MPU region configuration, which enabled caching of the shared memory region, without any cache maintenance in libmetal.
  • Fix the MPU region's TEX level, which was setting the shared memory region as a device and/or strongly-ordered memory, which caused usage faults on unaligned accesses.
  • Fix a deadlock that occurs if the main thread (sketch) makes a remote call and holds the virtqueue's mutex, and then gets preempted by the event thread, which in turn tries to acquire the same mutex. Note that libmetal's mutex implementation doesn't yield the CPU, it can be changed to do so, but for now the queues are protected with an OS mutex.
  • Fix RPCLIB msgpack unpacker memory overflow if RPMSG endpoint buffer > 512.
  • Optimize RPCLIB msgpack unpacker usage by allocating once and extending on demand.
  • Remove extra request/response threads, locking and callbacks, that were causing all sorts of concurrency issues, and were detrimental to performance.
  • Remove the redundant copy of messages to ring buffer, to boost the performance.
  • Remove many smaller dynamic allocation to improve the performance.
  • Use a single endpoint for message packs requests/responses ("RPC"), and another one dedicated for raw (non-packed) data.
  • General refactoring and cleanups, removal of dead code and variables, debugging code, etc...
  • Add MD5 checksum example and RAW ping-pong example.
  • Fixes RPC library deadlock and/or vring memory corruption on Giga R1 (possibly other boards too). #802.

This PR depends on the following:

@iabdalkader iabdalkader force-pushed the refactor_rpc_library branch 4 times, most recently from 7c7d1ad to b7bb1ab Compare December 29, 2023 10:27
@iabdalkader iabdalkader force-pushed the refactor_rpc_library branch 2 times, most recently from bbd094b to 6f79f00 Compare January 10, 2024 12:12
- Fix the memory corruption caused by the wrong MPU region configuration, which
enabled caching of the shared memory region, without any cache maintenance in
libmetal.
- Fix the MPU region's TEX level, which was setting the shared memory region as
a device and/or strongly-ordered memory, which caused usage faults on unaligned
accesses.
- Fix a deadlock that occurs if the main thread (sketch) makes a remote call
and holds the virtqueue's mutex, and then gets preempted by the event thread,
which in turn tries to acquire the same mutex. Note that libmetal's mutex
implementation doesn't yield the CPU, it can be changed to do so, but for now
the queues are protected with an OS mutex.
- Fix RPCLIB msgpack unpacker memory overflow if RPMSG endpoint buffer > 512.
- Optimize RPCLIB msgpack unpacker usage by allocating once and extending on
demand.
- Remove extra request/response threads, locking and callbacks, that were
causing all sorts of concurrency issues, and were detrimental to performance.
- Remove the redundant copy of messages to ring buffer, to boost the performance.
- Remove many smaller dynamic allocation to improve the performance.
- Use a single endpoint for message packs requests/responses ("RPC"), and
another one dedicated for raw (non-packed) data.
- General refactoring and cleanups, removal of dead code and variables,
debugging code, etc...

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
- Fix serial pass-through example.
- Add MD5 checksum example.
- Add RAW-channel ping-pong example.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
@facchinm
Copy link
Member

Manually merged in main

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

Successfully merging this pull request may close these issues.

RPC library deadlock and/or vring memory corruption on Giga R1 (possibly other boards too).
2 participants