[PATCH 0/2] soc: qcom: Add Qualcomm Memshare QMI service

From: nikitos . tr
Date: Fri Mar 19 2021 - 13:25:28 EST


From: Nikita Travkin <nikitos.tr@xxxxxxxxx>

This series adds memshare QMI service.
It receives messages from other subsystems (like modem subsystem) and
answers with a message that contains the memory address of the allocated
region. This is used on many msm8916 based devices for location service
which requests 2 MB region when the modem starts. If the memory isn't
provided, GPS doesn't work. Newer platforms may also use it in other
subsystems.

The driver implements:
- legacy alloc/free messages (known to be used by Samsung A2015 devices)
- generic alloc/free messages (used on most msm8916 devices)
- query_size message (sent by at least one modem firmware for msm8916)

Downstream driver [1] seems to use dynamic memory allocation but it
uses concept of "Guaranteed Memory" which means that the region is
allocated on driver probe and not released even after "free" request.
It also seems to support memory allocation "on demand" without prior
client description.

My driver implements "guaranteed" allocation using reserved-memory regions
and does not allow allocation for any request that was not described in
the device tree. It also additionally checks that qrtr node that sent
the message is correct (to prevent, for example, processing messages sent
from userspace).

memshare_qmi_msg.c/h files are mostly copied from [1] (query_size was
added from later version of the driver) and cleaned up. Those files keep
copyright line from the originals.

This driver is tested to work on multiple msm8916 devices, including
devices that have dts upstream (with an exception of mtp; db410c doesn't
use it).

[1] https://source.codeaurora.org/quic/la/kernel/msm-3.10/tree/drivers/soc/qcom/memshare?h=LA.BR.1.2.9.1-02310-8x16.0

Nikita Travkin (2):
dt-bindings: soc: qcom: Add bindings for Qualcomm Memshare service
soc: qcom: Add Qualcomm Memshare QMI service

.../bindings/soc/qcom/qcom,memshare.yaml | 109 ++++
drivers/soc/qcom/Kconfig | 8 +
drivers/soc/qcom/Makefile | 2 +
drivers/soc/qcom/memshare.c | 501 ++++++++++++++++++
drivers/soc/qcom/memshare_qmi_msg.c | 370 +++++++++++++
drivers/soc/qcom/memshare_qmi_msg.h | 228 ++++++++
include/dt-bindings/soc/qcom,memshare.h | 10 +
7 files changed, 1228 insertions(+)
create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,memshare.yaml
create mode 100644 drivers/soc/qcom/memshare.c
create mode 100644 drivers/soc/qcom/memshare_qmi_msg.c
create mode 100644 drivers/soc/qcom/memshare_qmi_msg.h
create mode 100644 include/dt-bindings/soc/qcom,memshare.h

--
2.27.0