Skip to content

Commit

Permalink
Fix bug in prussd.py that causes kernel oops while sending message th…
Browse files Browse the repository at this point in the history
…rough rpmsg channel

A kernel oops (NULL pointer dereference) was thrown when the pruss_api driver hadn't already been probed because there was no check that the rpmsg device file in /dev was being created before sending messages to the PRU.
Sometimes the oops wasn't thrown but there was a loss of some initial data sent to PRU before the rpmsg device file gets initialized.
Now, the code waits before sending messages to PRU until the appropriate device file is created to ensure no loss of data. No kernel oops is thrown now.
The device file creation is timed out after 3 seconds otherwise the function might get stuck in an infinite loop if rpmsg isn't being used and function gets called.
  • Loading branch information
pratimugale committed Aug 24, 2019
1 parent 8c29fe9 commit bc4ba90
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions prussd/prussd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import threading
import mmap # For memory functions
import struct # For memory functions
import time

PRU_ICSS = 0x4a300000 # This is the address of the PRU Subsystem on the RAM
PRU_ICSS_SIZE = 512*1024 # This is the length of the PRU subsystem ie it is of 512 K
Expand Down Expand Up @@ -168,8 +169,15 @@ def send_msg(cmd):
rpmsg_dev = rpmsg_devnode(chan_name, chan_port)
if chan_name not in paths.RPMSG_CHANNELS:
return -errno.EPERM
if not os.path.exists(rpmsg_dev):
return -errno.ENODEV

time_to_wait = 3
time_counter = 0

while not os.path.exists(rpmsg_dev):
time.sleep(1)
time_counter += 1
if (time_counter >= time_to_wait):
return -errno.ENODEV

if mode == 's':
try:
Expand Down

0 comments on commit bc4ba90

Please sign in to comment.