Linux: Update user AF_RPMSG define for 5.15+ kernels IPC's Linux user space support contains a copy of a few kernel-defined structs and definitions including the socket address family used for rpmsg-based sockets - AF_RPMSG. This driver is currently out-of-tree and so it's definition is always 'one more' than the last address family defined by the mainline kernel's socket.h. A new address family was introduced in 5.15 (AF_MCTP), and as a result, the AF_RPMSG macro needs to be set to 46 post 5.15 kernel. The user space header has been updated to reflect on the kernel version and appropriately assign the value of AF_RPMSG. Do note that a specific value of AF_RPMSG can always be provided through the products.mak when KERNEL_INSTALL_DIR is not set. Signed-off-by: Sinthu Raja <sinthu.raja@ti.com>
Linux: Update user AF_RPMSG define for 4.18+ kernels IPC's Linux user space support contains a copy of a few kernel-defined structs and definitions including the socket address family used for rpmsg-based sockets - AF_RPMSG. This driver is currently out-of-tree and so it's definition is always 'one more' than the last address family defined by the mainline kernel's socket.h. A new address family was introduced in 4.18 (AF_XDP), and as a result, the AF_RPMSG macro needs to be set to 45 post 4.18 kernel. The user space header has been updated to reflect on the kernel version and appropriately assign the value of AF_RPMSG. Do note that a specific value of AF_RPMSG can always be provided through the products.mak when KERNEL_INSTALL_DIR is not set. Signed-off-by: Suman Anna <s-anna@ti.com>
tests: Cleanup for observed compiler warnings Removed typecast forcing pointer to UInt. With 64 bit pointer need to print with appropriate formatting - added type casts where needed Signed-off-by: Sam Nelson <sam.nelson@ti.com>
autotools: Update autotools generated files with K3 AM65XX support - autoreconf used to generate makefiles Signed-off-by: Sam Nelson <sam.nelson@ti.com>
K3: Add support for K3 AM65XX device - Adds support for A53 and R5F cores - Adds IPC VirtQueue, Interrupt & Notity drivers for AM65XX platform. - gates: Add V7R and v8A support Signed-off-by: Sam Nelson <sam.nelson@ti.com>
lad: Add Timeout waiting for Response FIFO Add a timeout to the logic which opens the client response FIFO in the LAD daemon during LAD_CONNECT. There are some corner cases that might result in this hanging forever waiting for the response FIFO, in which case, all other LAD communication will be blocked forever. Such cases might be: - Client application crashes after sending LAD_connect request - Communication with LAD through the LADCMDS fifo takes too long and the Client times out waiting for the response FIFO (5 seconds). If this happens, Client will never try to open the FIFO again due to failing when doing the stat() on the FIFO. With this patch, if the FIFO connection is not established within the timeout, the FIFO will be unlinked and the original state restored so that the connection can be attempted again. The timeout is chosen as 1 second so as not to block all other LAD communication for a long period of time. 1 second should (hopefully) be sufficient time for the Client and LAD to both open the FIFO. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Linux: Cleanup on Failure in Ipc_start Add the appropriate cleanup calls when Ipc_start fails, so that Ipc_start can be called again in a clean state. This allows retry of Ipc_start in case of failure due to various conditions including if reponses are delayed from the remote core for some reason. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Linux: GateMP: Fix Error Handling When defaultGate Not Found Due to Timeout In a corner case where remote NameServer requests take too long and time out, it is possible that remoteSystemGate may be de-referenced in GateMP_start when it wasn't allocated during GateMP_attach. This patch improves error checking in GateMP_start to avoid the potential NULL pointer de-reference. Before trying to access the remoteSystemGates pointer during GateMP_start, we should first make sure that the pointer is valid. Also check to make sure that the gate number does not exceed the number of allocated gates. If the corner case has been hit where the GateMP_attach failed but GateMP_open later passes during GateMP_start, GateMP_start will now return an error, resulting in Ipc_start returning an error. The application can then call Ipc_start again. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Android: Fix compilation warnings Fix compilation warnings seen with Android build. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Linux: Update user AF_RPMSG define for 4.11+ kernels IPC's Linux user space support contains a copy of a few kernel-defined structs and definitions including the socket address family used for rpmsg-based sockets - AF_RPMSG. This driver is currently out-of-tree and so it's definition is always 'one more' than the last address family defined by the mainline kernel's socket.h. A new address family was introduced in 4.11 (AF_SMC), and as a result, the AF_RPMSG macro needs to be set to 44 post 4.11 kernel. The user space header has been updated to reflect on the kernel version and appropriately assign the value of AF_RPMSG. Do note that a specific value of AF_RPMSG can always be provided through the products.mak when KERNEL_INSTALL_DIR is not set. Signed-off-by: Suman Anna <s-anna@ti.com>
Linux: LAD_client: Fix Race Condition with Command FIFO With the current implementation, there is a small window where the FIFO is closed by the client for writing while it is still open by the LAD daemon for reading. In this small window, if the LAD daemon attempts to do a read on the FIFO, it will get EOF and the LAD daemon will close it's own FIFO and re-open it. If the client then is able to open the FIFO again after the LAD daemon has received EOF from the read call, but before the LAD daemon has closed the FIFO, then there is now a situation where the client has a handle to a stale FIFO. If all these things happen, then when the client tries to write/flush to the FIFO, a SIGPIPE signal will happen, resulting in the client crash. To avoid this race condition, we must close the window where the FIFO is not open for writing by the client while it is already open for reading by the daemon. This patch closes the window by modifiying the client code to delay closing it's non-blocking FIFO handle (used for handshaking) until after it has successfully opened the regular FIFO. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Android: update version.h include path for AF_RPMSG handling Update include path of version.h for current Android setup. Previously (before O) we used to update the socket.h bionic header with AF_RPMSG definitions, so the KERNEL_VERSION check was not exercized. Now the kernel-headers of dra7xx in Android repo is updated to reflect the correct Kernel version and can be used to check the kernel version. For older Android versions that do not have version.h in kernel-headers, AF_RPMSG can still be taken from the socket.h bionic header if it is updated to include AF_RPMSG. Signed-off-by: Vishal Mahaveer <vishalm@ti.com> Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Linux: TransportRpmsg: Fix Mutex Deadlock Issue In an error recovery situation, it is possible that a mutex deadlock could occur when MessageQ_delete happened at the same time that an fd was being signaled about the remote core error in the same process. This error could occur if there are multiple MessageQs in the same process communicating with the remote core that is doing recovery. When MessageQ_delete grabs the lock, it then tries to communicate with rpmsgThreadFxn, sending a message and then waiting for a response. If at the same time, the thread is processing a shutdown notification for an fd, it will also try to grab the mutex, but will be blocked because MessageQ_delete is holding the mutex. The rpmsgThreadFxn will not continue until it gets the mutex, leading to the deadlock. The fix is to change the mutex_lock to a trylock when handling shutdown notifications in rpmsgThreadFxn. If the thread fails to acquire the lock, it continues processing commands and will try again later to process the shutdown request at a time when the lock is no longer being held. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
TransportRpmsg: Fix Check for Invalid Socket A check for sock in TransportRpmsg was incorrectly checking for sock != 0, when it should have been checking against INVALIDSOCKET (the value uninitialized socket are set to). This patch fixes the check. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
Linux: LAD_client: Avoid hang in fopen during connect If the application is started and calls Ipc_start before the LAD is started and created/opened the fifo, then the application can block in the fopen trying to connect to the command FIFO. This patch makes the sequence more robust by first checking if the fifo exists, then trying to open it as non-blocking, thereby getting an immediate success or error instead of blocking until it has been opened for reading by LAD. Once the non-blocking open returns successfully, the regular connect sequence can continue. If it returns with a failure, it will sleep and then try again for a period of time, eventually returning a timeout failure if it is unable to connect. This should prevent the application from hanging if LAD is not started before it calls Ipc_start. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>