The ADSP default listener interface is an interface with which to
register the default listener for FastRPC reverse tunneling. Add the
interface for this so programs can advertise their ability to receive
FastRPC messages.
It was accidentally #include-ed in a previous commit.
Fixes: 2ba7bf1df6 ("fastrpc: rpcd: close remote handle")
If there are no 32-bit integers in the first input or output buffers,
then the argument pointer might be NULL or point out-of-bounds. Only
write to this pointer's target if the buffer was allocated, otherwise
the size of the corresponding first argument has a length of zero and
should be omitted.
A remotectl_open() procedure call should be mirrored with a
remotectl_close() procedure call. Add a definition for this remote
procedure so handles can be closed.
This is what happens when I push stuff that isn't quite ready...
FastRPC expects the client to attach to a protection domain and
communicate over a device node. Initialize these things so remote
procedure calls are sent to the remote processor.
The second 32-bit integer in the first output buffer is not the returned
length of the output buffer. Instead, it is an error code, as defined in
fastrpc.git/inc/AEEStdErr.h. Properly handle the output integer and pass
an appropriate string that represents the error.
A FastRPC function call does not necessarily return the amount of bytes
written in the output buffer. Implementing a field that makes these
sizes optional would require the function to keep track of the returned
sizes separately from any other output from this function. Since
returned lengths are interleaved and at the last part of the argument
list, it already needs an unnecessary pass to write back the lengths.
Move the returned lengths to the "returned numbers" part of the argument
list and assume that they are counted in the out_nums property of the
function definition.
The (maximum) sizes of the buffers should still be handled separately
because they need to be passed both to the kernel and to the remote
processor. Removing this special handling would just duplicate the size
arguments, while its implementation is more maintainable than the
returned lengths. The kernel API would need to change for this separate
handling to be unnecessary. Therefore, it is useless to introduce any
other breaking change while old code is already broken.
The function-level output buffers are passed with the assumption that
a first output buffer needs to be skipped. This is always true, given
that there is always a returned length of each buffer, but it is not
always the case. Calculate the offset instead of hardcoding it so the
first fixed-length output buffer is only skipped if it exists.
If there are no inputs, or if there are no outputs, one or more of these
buffers may be zero. Do not try to allocate or deallocate buffers that
have a length of zero and cause undefined behavior.
Fixes: 9adc9ea326 ("add fastrpc")
The first input buffer is skipped when passing the function-level input
buffers, but the first entry communicating the buffer's size is also
skipped. This is incorrect: the sizes for these buffers start at
inbuf[def->in_nums]. Start the iterator at zero and add one to the
argument index to make it clear that the argument buffers index is
offset and the first buffer index is not.
Fixes: 9adc9ea326 ("add fastrpc")
FastRPC is a communication protocol used to communicate with some remote
processors on Qualcomm SoC's. It might be needed to configure sensors
and to prevent an ADSP crash on the Pixel 3a.
The programs provided by Google and Linaro don't work out of the box to
set up an ADSP listener (even with kernel patches), and is a bit too
unpleasant to read for my tastes. Add a new FastRPC implementation that
will hopefully be more readable for everyone.