2021-11-30 12:58:12

by Jeya R

[permalink] [raw]
Subject: [PATCH 0/3] Add vmid property and mapping attribute

Add virtual machine ID DT property which would be used to set up memory
protections for remote processor. Also add implementation to handle
mapping of invoke arguments with attribute.

Jeya R (3):
dt-bindings: misc: add fastrpc domain vmid property
misc: fastrpc: Read virtual machine IDs during probe
misc: fastrpc: Handle mapping of invoke argument with attribute

.../devicetree/bindings/misc/qcom,fastrpc.txt | 78 ---------------
.../devicetree/bindings/misc/qcom,fastrpc.yaml | 109 +++++++++++++++++++++
drivers/misc/fastrpc.c | 48 +++++++--
include/uapi/misc/fastrpc.h | 5 +-
4 files changed, 151 insertions(+), 89 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
create mode 100644 Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml

--
2.7.4



2021-11-30 12:58:14

by Jeya R

[permalink] [raw]
Subject: [PATCH 2/3] misc: fastrpc: Read virtual machine IDs during probe

Read virtual machine IDs DT property during rpmsg probe. This property is used
to set up memory protection for remote processor.

Signed-off-by: Jeya R <[email protected]>
---
drivers/misc/fastrpc.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 39aca77..a9adfa4d 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -17,6 +17,7 @@
#include <linux/rpmsg.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
+#include <linux/qcom_scm.h>
#include <uapi/misc/fastrpc.h>

#define ADSP_DOMAIN_ID (0)
@@ -25,6 +26,7 @@
#define CDSP_DOMAIN_ID (3)
#define FASTRPC_DEV_MAX 4 /* adsp, mdsp, slpi, cdsp*/
#define FASTRPC_MAX_SESSIONS 13 /*12 compute, 1 cpz*/
+#define FASTRPC_MAX_VMIDS 16
#define FASTRPC_ALIGN 128
#define FASTRPC_MAX_FDLIST 16
#define FASTRPC_MAX_CRCLIST 64
@@ -207,6 +209,9 @@ struct fastrpc_session_ctx {
struct fastrpc_channel_ctx {
int domain_id;
int sesscount;
+ int vmcount;
+ u32 perms;
+ struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
struct rpmsg_device *rpdev;
struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
spinlock_t lock;
@@ -1610,8 +1615,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
{
struct device *rdev = &rpdev->dev;
struct fastrpc_channel_ctx *data;
- int i, err, domain_id = -1;
+ int i, err, domain_id = -1, vmcount;
const char *domain;
+ unsigned int vmids[FASTRPC_MAX_VMIDS];

err = of_property_read_string(rdev->of_node, "label", &domain);
if (err) {
@@ -1631,9 +1637,24 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
return -EINVAL;
}

+ vmcount = of_property_read_variable_u32_array(rdev->of_node,
+ "qcom,vmids", &vmids[0], 0, FASTRPC_MAX_VMIDS);
+ if (vmcount < 0)
+ vmcount = 0;
+ else if (!qcom_scm_is_available())
+ return -EPROBE_DEFER;
+
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
+ if (vmcount) {
+ data->vmcount = vmcount;
+ data->perms = BIT(QCOM_SCM_VMID_HLOS);
+ for (i = 0; i < data->vmcount; i++) {
+ data->vmperms[i].vmid = vmids[i];
+ data->vmperms[i].perm = QCOM_SCM_PERM_RWX;
+ }
+ }

data->miscdev.minor = MISC_DYNAMIC_MINOR;
data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s",
--
2.7.4


2021-11-30 12:58:15

by Jeya R

[permalink] [raw]
Subject: [PATCH 2/2] misc: fastrpc: Add dma handle implementation

Add dma handle instructions to remote arguments.

Signed-off-by: Jeya R <[email protected]>
---
drivers/misc/fastrpc.c | 75 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 55 insertions(+), 20 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 3c937ff..77071ee3 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -92,9 +92,20 @@ struct fastrpc_invoke_buf {
u32 pgidx; /* index to start of contiguous region */
};

-struct fastrpc_remote_arg {
- u64 pv;
- u64 len;
+struct fastrpc_remote_dmahandle {
+ s32 fd; /* dma handle fd */
+ u32 offset; /* dma handle offset */
+ u32 len; /* dma handle length */
+};
+
+struct fastrpc_remote_buf {
+ u64 pv; /* buffer pointer */
+ u64 len; /* length of buffer */
+};
+
+union fastrpc_remote_arg {
+ struct fastrpc_remote_buf buf;
+ struct fastrpc_remote_dmahandle dma;
};

struct fastrpc_mmap_rsp_msg {
@@ -189,7 +200,7 @@ struct fastrpc_invoke_ctx {
struct work_struct put_work;
struct fastrpc_msg msg;
struct fastrpc_user *fl;
- struct fastrpc_remote_arg *rpra;
+ union fastrpc_remote_arg *rpra;
struct fastrpc_map **maps;
struct fastrpc_buf *buf;
struct fastrpc_invoke_args *args;
@@ -760,12 +771,26 @@ static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)
return 0;
}

+static struct fastrpc_invoke_buf *fastrpc_invoke_buf_start(union fastrpc_remote_arg *pra, u32 sc)
+{
+ unsigned int len = REMOTE_SCALARS_LENGTH(sc);
+
+ return (struct fastrpc_invoke_buf *)(&pra[len]);
+}
+
+static struct fastrpc_phy_page *fastrpc_phy_page_start(u32 sc, struct fastrpc_invoke_buf *buf)
+{
+ unsigned int len = REMOTE_SCALARS_LENGTH(sc);
+
+ return (struct fastrpc_phy_page *)(&buf[len]);
+}
+
static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
{
struct device *dev = ctx->fl->sctx->dev;
- struct fastrpc_remote_arg *rpra;
+ union fastrpc_remote_arg *rpra = NULL;
struct fastrpc_invoke_buf *list;
- struct fastrpc_phy_page *pages;
+ struct fastrpc_phy_page *pages, *ipage;
int inbufs, i, oix, err = 0;
u64 len, rlen, pkt_size;
u64 pg_start, pg_end;
@@ -773,7 +798,13 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
int metalen;

inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
- metalen = fastrpc_get_meta_size(ctx);
+ list = fastrpc_invoke_buf_start(rpra, ctx->sc);
+ pages = fastrpc_phy_page_start(ctx->sc, list);
+ ipage = pages;
+ ipage += ctx->nscalars;
+ metalen = (size_t)&ipage[0] +
+ sizeof(u64) * FASTRPC_MAX_FDLIST +
+ sizeof(u32) * FASTRPC_MAX_CRCLIST;
pkt_size = fastrpc_get_payload_size(ctx, metalen);

err = fastrpc_create_maps(ctx);
@@ -788,12 +819,11 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
memset(ctx->buf->virt, 0, pkt_size);

rpra = ctx->buf->virt;
- list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
- pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
- sizeof(*rpra));
+ ctx->rpra = rpra;
+ list = fastrpc_invoke_buf_start(rpra, ctx->sc);
+ pages = fastrpc_phy_page_start(ctx->sc, list);
args = (uintptr_t)ctx->buf->virt + metalen;
rlen = pkt_size - metalen;
- ctx->rpra = rpra;

for (oix = 0; oix < ctx->nbufs; ++oix) {
int mlen;
@@ -801,8 +831,8 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
i = ctx->olaps[oix].raix;
len = ctx->args[i].length;

- rpra[i].pv = 0;
- rpra[i].len = len;
+ rpra[i].buf.pv = 0;
+ rpra[i].buf.len = len;
list[i].num = len ? 1 : 0;
list[i].pgidx = i;

@@ -812,7 +842,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
if (ctx->maps[i]) {
struct vm_area_struct *vma = NULL;

- rpra[i].pv = (u64) ctx->args[i].ptr;
+ rpra[i].buf.pv = (u64) ctx->args[i].ptr;
pages[i].addr = ctx->maps[i]->phys;

mmap_read_lock(current->mm);
@@ -839,7 +869,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
if (rlen < mlen)
goto bail;

- rpra[i].pv = args - ctx->olaps[oix].offset;
+ rpra[i].buf.pv = args - ctx->olaps[oix].offset;
pages[i].addr = ctx->buf->phys -
ctx->olaps[oix].offset +
(pkt_size - rlen);
@@ -853,7 +883,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
}

if (i < inbufs && !ctx->maps[i]) {
- void *dst = (void *)(uintptr_t)rpra[i].pv;
+ void *dst = (void *)(uintptr_t)rpra[i].buf.pv;
void *src = (void *)(uintptr_t)ctx->args[i].ptr;

if (!kernel) {
@@ -869,12 +899,17 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
}

for (i = ctx->nbufs; i < ctx->nscalars; ++i) {
- rpra[i].pv = (u64) ctx->args[i].ptr;
- rpra[i].len = ctx->args[i].length;
+ rpra[i].buf.pv = (u64) ctx->args[i].ptr;
+ rpra[i].buf.len = ctx->args[i].length;
list[i].num = ctx->args[i].length ? 1 : 0;
list[i].pgidx = i;
- pages[i].addr = ctx->maps[i]->phys;
- pages[i].size = ctx->maps[i]->size;
+ if (ctx->maps[i]) {
+ pages[i].addr = ctx->maps[i]->phys;
+ pages[i].size = ctx->maps[i]->size;
+ }
+ rpra[i].dma.fd = ctx->args[i].fd;
+ rpra[i].dma.len = ctx->args[i].length;
+ rpra[i].dma.offset = (u64) ctx->args[i].ptr;
}

bail:
--
2.7.4


2021-11-30 12:58:18

by Jeya R

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: misc: add fastrpc domain vmid property

Add fastrpc domain virtual machine IDs property. This property is used
to setup memory protection for remote processor.

"This patch depends on “dt-bindings: misc: fastrpc convert bindings to yaml"
(https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/)"

Signed-off-by: Jeya R <[email protected]>
---
.../devicetree/bindings/misc/qcom,fastrpc.txt | 78 ---------------
.../devicetree/bindings/misc/qcom,fastrpc.yaml | 109 +++++++++++++++++++++
2 files changed, 109 insertions(+), 78 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
create mode 100644 Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml

diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.txt b/Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
deleted file mode 100644
index 2a1827a..0000000
--- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-Qualcomm Technologies, Inc. FastRPC Driver
-
-The FastRPC implements an IPC (Inter-Processor Communication)
-mechanism that allows for clients to transparently make remote method
-invocations across DSP and APPS boundaries. This enables developers
-to offload tasks to the DSP and free up the application processor for
-other tasks.
-
-- compatible:
- Usage: required
- Value type: <stringlist>
- Definition: must be "qcom,fastrpc"
-
-- label
- Usage: required
- Value type: <string>
- Definition: should specify the dsp domain name this fastrpc
- corresponds to. must be one of this: "adsp", "mdsp", "sdsp", "cdsp"
-
-- #address-cells
- Usage: required
- Value type: <u32>
- Definition: Must be 1
-
-- #size-cells
- Usage: required
- Value type: <u32>
- Definition: Must be 0
-
-= COMPUTE BANKS
-Each subnode of the Fastrpc represents compute context banks available
-on the dsp.
-- All Compute context banks MUST contain the following properties:
-
-- compatible:
- Usage: required
- Value type: <stringlist>
- Definition: must be "qcom,fastrpc-compute-cb"
-
-- reg
- Usage: required
- Value type: <u32>
- Definition: Context Bank ID.
-
-- qcom,nsessions:
- Usage: Optional
- Value type: <u32>
- Defination: A value indicating how many sessions can share this
- context bank. Defaults to 1 when this property
- is not specified.
-
-Example:
-
-adsp-pil {
- compatible = "qcom,msm8996-adsp-pil";
- ...
- smd-edge {
- label = "lpass";
- fastrpc {
- compatible = "qcom,fastrpc";
- qcom,smd-channels = "fastrpcsmd-apps-dsp";
- label = "adsp";
- #address-cells = <1>;
- #size-cells = <0>;
-
- cb@1 {
- compatible = "qcom,fastrpc-compute-cb";
- reg = <1>;
- };
-
- cb@2 {
- compatible = "qcom,fastrpc-compute-cb";
- reg = <2>;
- };
- ...
- };
- };
-};
diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
new file mode 100644
index 0000000..a9fd93c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/misc/qcom,fastrpc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Qualcomm Technologies, Inc. FastRPC Driver
+
+maintainers:
+ - Srinivas Kandagatla <[email protected]>
+
+description: |
+ This binding describes Qualcomm FastRPC an IPC (Inter-Processor Communication)
+ mechanism that allows for clients to transparently make remote method
+ invocations across DSP and APPS boundaries. This enables developers
+ to offload tasks to the DSP and free up the application processor for
+ other tasks.
+
+properties:
+ compatible:
+ const: qcom,fastrpc
+
+ label:
+ enum:
+ - adsp
+ - mdsp
+ - sdsp
+ - cdsp
+
+ qcom,nsessions:
+ $ref: "/schemas/types.yaml#/definitions/uint32-array"
+ description: Virtual machine IDs of remote processor which is used to
+ setup memory protection.
+
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+patternProperties:
+ "^cb@[0-9a-f]$":
+ type: object
+ description: |
+ Compute context bank
+
+ properties:
+ compatible:
+ const: qcom,fastrpc-compute-cb
+
+ reg:
+ maxItems: 1
+ description: Context Bank ID
+
+ qcom,nsessions:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: How many sessions can share this context bank.
+ Defaults to 1 when this property is not specified.
+
+ required:
+ - compatible
+ - reg
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - label
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ adsp {
+ compatible = "qcom,msm8996-adsp-pil";
+ interrupts-extended = <&intc 0 162 IRQ_TYPE_EDGE_RISING>,
+ <&smp2p_adsp_in 0 IRQ_TYPE_EDGE_RISING>,
+ <&smp2p_adsp_in 1 IRQ_TYPE_EDGE_RISING>,
+ <&smp2p_adsp_in 2 IRQ_TYPE_EDGE_RISING>,
+ <&smp2p_adsp_in 3 IRQ_TYPE_EDGE_RISING>;
+ interrupt-names = "wdog", "fatal", "ready", "handover", "stop-ack";
+ clocks = <&xo_board>;
+ clock-names = "xo";
+ memory-region = <&adsp_region>;
+ qcom,smem-states = <&smp2p_adsp_out 0>;
+ qcom,smem-state-names = "stop";
+
+ smd-edge {
+ label = "lpass";
+
+ fastrpc {
+ compatible = "qcom,fastrpc";
+ label = "adsp";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cb@1 {
+ compatible = "qcom,fastrpc-compute-cb";
+ reg = <1>;
+ };
+
+ cb@2 {
+ compatible = "qcom,fastrpc-compute-cb";
+ reg = <2>;
+ };
+ };
+ };
+ };
--
2.7.4


2021-11-30 12:58:23

by Jeya R

[permalink] [raw]
Subject: [PATCH 3/3] misc: fastrpc: Handle mapping of invoke argument with attribute

Allow mapping of arguments for remote invocations with attribute.

Signed-off-by: Jeya R <[email protected]>
---
drivers/misc/fastrpc.c | 25 ++++++++++++++++---------
include/uapi/misc/fastrpc.h | 5 ++++-
2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index a9adfa4d..f6a6e4d 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -172,6 +172,7 @@ struct fastrpc_map {
u64 size;
void *va;
u64 len;
+ u32 attr;
struct kref refcount;
};

@@ -246,6 +247,10 @@ static void fastrpc_free_map(struct kref *ref)
map = container_of(ref, struct fastrpc_map, refcount);

if (map->table) {
+ if (map->attr & FASTRPC_SECUREMAP) {
+ /* Invoke qcom_scm API to assign memory access
+ * back to HLOS
+ */
dma_buf_unmap_attachment(map->attach, map->table,
DMA_BIDIRECTIONAL);
dma_buf_detach(map->buf, map->attach);
@@ -622,7 +627,7 @@ static const struct dma_buf_ops fastrpc_dma_buf_ops = {
};

static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
- u64 len, struct fastrpc_map **ppmap)
+ u64 len, u32 attr, struct fastrpc_map **ppmap)
{
struct fastrpc_session_ctx *sess = fl->sctx;
struct fastrpc_map *map = NULL;
@@ -664,6 +669,14 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
map->len = len;
kref_init(&map->refcount);

+ if (attr & FASTRPC_SECUREMAP) {
+ map->attr = attr;
+ /*
+ * If subsystem VMIDs are defined in DTSI, then do
+ * hyp_assign from HLOS to those VM(s).
+ */
+ }
+
spin_lock(&fl->lock);
list_add_tail(&map->node, &fl->maps);
spin_unlock(&fl->lock);
@@ -746,16 +759,12 @@ static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)
int i, err;

for (i = 0; i < ctx->nscalars; ++i) {
- /* Make sure reserved field is set to 0 */
- if (ctx->args[i].reserved)
- return -EINVAL;
-
if (ctx->args[i].fd == 0 || ctx->args[i].fd == -1 ||
ctx->args[i].length == 0)
continue;

err = fastrpc_map_create(ctx->fl, ctx->args[i].fd,
- ctx->args[i].length, &ctx->maps[i]);
+ ctx->args[i].length, ctx->args[i].attr, x->maps[i]);
if (err) {
dev_err(dev, "Error Creating map %d\n", err);
return -EINVAL;
@@ -1062,7 +1071,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
fl->pd = USER_PD;

if (init.filelen && init.filefd) {
- err = fastrpc_map_create(fl, init.filefd, init.filelen, &map);
+ err = fastrpc_map_create(fl, init.filefd, init.filelen, 0, &map);
if (err)
goto err;
}
@@ -1171,7 +1180,6 @@ static int fastrpc_release_current_dsp_process(struct fastrpc_user *fl)
args[0].ptr = (u64)(uintptr_t) &tgid;
args[0].length = sizeof(tgid);
args[0].fd = -1;
- args[0].reserved = 0;
sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_RELEASE, 1, 0);

return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
@@ -1307,7 +1315,6 @@ static int fastrpc_init_attach(struct fastrpc_user *fl, int pd)
args[0].ptr = (u64)(uintptr_t) &tgid;
args[0].length = sizeof(tgid);
args[0].fd = -1;
- args[0].reserved = 0;
sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
fl->pd = pd;

diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h
index 0a89f95..4dd4a9e 100644
--- a/include/uapi/misc/fastrpc.h
+++ b/include/uapi/misc/fastrpc.h
@@ -14,11 +14,14 @@
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)

+/* Fastrpc attribute for memory protection of buffers */
+#define FASTRPC_SECUREMAP (1)
+
struct fastrpc_invoke_args {
__u64 ptr;
__u64 length;
__s32 fd;
- __u32 reserved;
+ __u32 attr;
};

struct fastrpc_invoke {
--
2.7.4


2021-11-30 12:58:25

by Jeya R

[permalink] [raw]
Subject: [PATCH 1/2] misc: fastrpc: Add fdlist implementation

Add fdlist implementation to support dma handles. fdlist is populated
by DSP if any map is no longer used and it is freed during put_args.

Signed-off-by: Jeya R <[email protected]>
---
drivers/misc/fastrpc.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 39aca77..3c937ff 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -353,7 +353,7 @@ static void fastrpc_context_free(struct kref *ref)
ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
cctx = ctx->cctx;

- for (i = 0; i < ctx->nscalars; i++)
+ for (i = 0; i < ctx->nbufs; i++)
fastrpc_map_put(ctx->maps[i]);

if (ctx->buf)
@@ -785,6 +785,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
if (err)
return err;
+ memset(ctx->buf->virt, 0, pkt_size);

rpra = ctx->buf->virt;
list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
@@ -887,9 +888,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
u32 kernel)
{
struct fastrpc_remote_arg *rpra = ctx->rpra;
- int i, inbufs;
+ struct fastrpc_map *mmap = NULL;
+ struct fastrpc_invoke_buf *list;
+ struct fastrpc_phy_page *pages;
+ u64 *fdlist;
+ int i, inbufs, outbufs, handles;

inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
+ outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
+ handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
+ list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
+ pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
+ sizeof(*rpra));
+ fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);

for (i = inbufs; i < ctx->nbufs; ++i) {
if (!ctx->maps[i]) {
@@ -906,6 +917,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
}
}

+ for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
+ if (!fdlist[i])
+ break;
+ if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
+ fastrpc_map_put(mmap);
+ }
+
return 0;
}

--
2.7.4


2021-11-30 13:17:34

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: misc: add fastrpc domain vmid property



On 30/11/2021 12:57, Jeya R wrote:
> Add fastrpc domain virtual machine IDs property. This property is used
> to setup memory protection for remote processor.
>
> "This patch depends on “dt-bindings: misc: fastrpc convert bindings to yaml"
> (https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/)"
>


This comment should go after ---


There is something wrong with the patch, You seems to have send wrong
patch which does not match the subject line nor I see vmid property.

--srini

> Signed-off-by: Jeya R <[email protected]>
> ---
> .../devicetree/bindings/misc/qcom,fastrpc.txt | 78 ---------------
> .../devicetree/bindings/misc/qcom,fastrpc.yaml | 109 +++++++++++++++++++++
> 2 files changed, 109 insertions(+), 78 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
> create mode 100644 Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
>
> diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.txt b/Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
> deleted file mode 100644
> index 2a1827a..0000000
> --- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.txt
> +++ /dev/null
> @@ -1,78 +0,0 @@
> -Qualcomm Technologies, Inc. FastRPC Driver
> -
> -The FastRPC implements an IPC (Inter-Processor Communication)
> -mechanism that allows for clients to transparently make remote method
> -invocations across DSP and APPS boundaries. This enables developers
> -to offload tasks to the DSP and free up the application processor for
> -other tasks.
> -
> -- compatible:
> - Usage: required
> - Value type: <stringlist>
> - Definition: must be "qcom,fastrpc"
> -
> -- label
> - Usage: required
> - Value type: <string>
> - Definition: should specify the dsp domain name this fastrpc
> - corresponds to. must be one of this: "adsp", "mdsp", "sdsp", "cdsp"
> -
> -- #address-cells
> - Usage: required
> - Value type: <u32>
> - Definition: Must be 1
> -
> -- #size-cells
> - Usage: required
> - Value type: <u32>
> - Definition: Must be 0
> -
> -= COMPUTE BANKS
> -Each subnode of the Fastrpc represents compute context banks available
> -on the dsp.
> -- All Compute context banks MUST contain the following properties:
> -
> -- compatible:
> - Usage: required
> - Value type: <stringlist>
> - Definition: must be "qcom,fastrpc-compute-cb"
> -
> -- reg
> - Usage: required
> - Value type: <u32>
> - Definition: Context Bank ID.
> -
> -- qcom,nsessions:
> - Usage: Optional
> - Value type: <u32>
> - Defination: A value indicating how many sessions can share this
> - context bank. Defaults to 1 when this property
> - is not specified.
> -
> -Example:
> -
> -adsp-pil {
> - compatible = "qcom,msm8996-adsp-pil";
> - ...
> - smd-edge {
> - label = "lpass";
> - fastrpc {
> - compatible = "qcom,fastrpc";
> - qcom,smd-channels = "fastrpcsmd-apps-dsp";
> - label = "adsp";
> - #address-cells = <1>;
> - #size-cells = <0>;
> -
> - cb@1 {
> - compatible = "qcom,fastrpc-compute-cb";
> - reg = <1>;
> - };
> -
> - cb@2 {
> - compatible = "qcom,fastrpc-compute-cb";
> - reg = <2>;
> - };
> - ...
> - };
> - };
> -};
> diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
> new file mode 100644
> index 0000000..a9fd93c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
> @@ -0,0 +1,109 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/misc/qcom,fastrpc.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Qualcomm Technologies, Inc. FastRPC Driver
> +
> +maintainers:
> + - Srinivas Kandagatla <[email protected]>
> +
> +description: |
> + This binding describes Qualcomm FastRPC an IPC (Inter-Processor Communication)
> + mechanism that allows for clients to transparently make remote method
> + invocations across DSP and APPS boundaries. This enables developers
> + to offload tasks to the DSP and free up the application processor for
> + other tasks.
> +
> +properties:
> + compatible:
> + const: qcom,fastrpc
> +
> + label:
> + enum:
> + - adsp
> + - mdsp
> + - sdsp
> + - cdsp
> +
> + qcom,nsessions:
> + $ref: "/schemas/types.yaml#/definitions/uint32-array"
> + description: Virtual machine IDs of remote processor which is used to
> + setup memory protection.
> +
> + "#address-cells":
> + const: 1
> +
> + "#size-cells":
> + const: 0
> +
> +patternProperties:
> + "^cb@[0-9a-f]$":
> + type: object
> + description: |
> + Compute context bank
> +
> + properties:
> + compatible:
> + const: qcom,fastrpc-compute-cb
> +
> + reg:
> + maxItems: 1
> + description: Context Bank ID
> +
> + qcom,nsessions:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: How many sessions can share this context bank.
> + Defaults to 1 when this property is not specified.
> +
> + required:
> + - compatible
> + - reg
> +
> + additionalProperties: false
> +
> +required:
> + - compatible
> + - label
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/irq.h>
> + adsp {
> + compatible = "qcom,msm8996-adsp-pil";
> + interrupts-extended = <&intc 0 162 IRQ_TYPE_EDGE_RISING>,
> + <&smp2p_adsp_in 0 IRQ_TYPE_EDGE_RISING>,
> + <&smp2p_adsp_in 1 IRQ_TYPE_EDGE_RISING>,
> + <&smp2p_adsp_in 2 IRQ_TYPE_EDGE_RISING>,
> + <&smp2p_adsp_in 3 IRQ_TYPE_EDGE_RISING>;
> + interrupt-names = "wdog", "fatal", "ready", "handover", "stop-ack";
> + clocks = <&xo_board>;
> + clock-names = "xo";
> + memory-region = <&adsp_region>;
> + qcom,smem-states = <&smp2p_adsp_out 0>;
> + qcom,smem-state-names = "stop";
> +
> + smd-edge {
> + label = "lpass";
> +
> + fastrpc {
> + compatible = "qcom,fastrpc";
> + label = "adsp";
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + cb@1 {
> + compatible = "qcom,fastrpc-compute-cb";
> + reg = <1>;
> + };
> +
> + cb@2 {
> + compatible = "qcom,fastrpc-compute-cb";
> + reg = <2>;
> + };
> + };
> + };
> + };
>

2021-11-30 18:26:59

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 3/3] misc: fastrpc: Handle mapping of invoke argument with attribute

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on robh/for-next linux/master linus/master v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Jeya-R/Add-vmid-property-and-mapping-attribute/20211130-205941
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: alpha-randconfig-r025-20211130 (https://download.01.org/0day-ci/archive/20211201/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d8dfc6d253cf3fe6c952b900243caf9b0b120ddf
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeya-R/Add-vmid-property-and-mapping-attribute/20211130-205941
git checkout d8dfc6d253cf3fe6c952b900243caf9b0b120ddf
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All error/warnings (new ones prefixed by >>):

drivers/misc/fastrpc.c: In function 'fastrpc_free_map':
>> drivers/misc/fastrpc.c:263:13: error: invalid storage class for function 'fastrpc_map_put'
263 | static void fastrpc_map_put(struct fastrpc_map *map)
| ^~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:263:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
263 | static void fastrpc_map_put(struct fastrpc_map *map)
| ^~~~~~
>> drivers/misc/fastrpc.c:269:13: error: invalid storage class for function 'fastrpc_map_get'
269 | static void fastrpc_map_get(struct fastrpc_map *map)
| ^~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:275:12: error: invalid storage class for function 'fastrpc_map_find'
275 | static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
| ^~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:294:13: error: invalid storage class for function 'fastrpc_buf_free'
294 | static void fastrpc_buf_free(struct fastrpc_buf *buf)
| ^~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:301:12: error: invalid storage class for function 'fastrpc_buf_alloc'
301 | static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
| ^~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:337:13: error: invalid storage class for function 'fastrpc_channel_ctx_free'
337 | static void fastrpc_channel_ctx_free(struct kref *ref)
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:346:13: error: invalid storage class for function 'fastrpc_channel_ctx_get'
346 | static void fastrpc_channel_ctx_get(struct fastrpc_channel_ctx *cctx)
| ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:351:13: error: invalid storage class for function 'fastrpc_channel_ctx_put'
351 | static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx)
| ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:356:13: error: invalid storage class for function 'fastrpc_context_free'
356 | static void fastrpc_context_free(struct kref *ref)
| ^~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:383:13: error: invalid storage class for function 'fastrpc_context_get'
383 | static void fastrpc_context_get(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:388:13: error: invalid storage class for function 'fastrpc_context_put'
388 | static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:393:13: error: invalid storage class for function 'fastrpc_context_put_wq'
393 | static void fastrpc_context_put_wq(struct work_struct *work)
| ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:402:12: error: invalid storage class for function 'olaps_cmp'
402 | static int olaps_cmp(const void *a, const void *b)
| ^~~~~~~~~
>> drivers/misc/fastrpc.c:414:13: error: invalid storage class for function 'fastrpc_get_buff_overlaps'
414 | static void fastrpc_get_buff_overlaps(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:450:35: error: invalid storage class for function 'fastrpc_context_alloc'
450 | static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
| ^~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:528:1: error: invalid storage class for function 'fastrpc_map_dma_buf'
528 | fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
| ^~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:543:13: error: invalid storage class for function 'fastrpc_unmap_dma_buf'
543 | static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach,
| ^~~~~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:550:13: error: invalid storage class for function 'fastrpc_release'
550 | static void fastrpc_release(struct dma_buf *dmabuf)
| ^~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:557:12: error: invalid storage class for function 'fastrpc_dma_buf_attach'
557 | static int fastrpc_dma_buf_attach(struct dma_buf *dmabuf,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:587:13: error: invalid storage class for function 'fastrpc_dma_buf_detatch'
587 | static void fastrpc_dma_buf_detatch(struct dma_buf *dmabuf,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:600:12: error: invalid storage class for function 'fastrpc_vmap'
600 | static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
| ^~~~~~~~~~~~
drivers/misc/fastrpc.c:609:12: error: invalid storage class for function 'fastrpc_mmap'
609 | static int fastrpc_mmap(struct dma_buf *dmabuf,
| ^~~~~~~~~~~~
drivers/misc/fastrpc.c:620:19: error: initializer element is not constant
620 | .attach = fastrpc_dma_buf_attach,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:620:19: note: (near initialization for 'fastrpc_dma_buf_ops.attach')
drivers/misc/fastrpc.c:621:19: error: initializer element is not constant
621 | .detach = fastrpc_dma_buf_detatch,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:621:19: note: (near initialization for 'fastrpc_dma_buf_ops.detach')
drivers/misc/fastrpc.c:622:24: error: initializer element is not constant
622 | .map_dma_buf = fastrpc_map_dma_buf,
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:622:24: note: (near initialization for 'fastrpc_dma_buf_ops.map_dma_buf')
drivers/misc/fastrpc.c:623:26: error: initializer element is not constant
623 | .unmap_dma_buf = fastrpc_unmap_dma_buf,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:623:26: note: (near initialization for 'fastrpc_dma_buf_ops.unmap_dma_buf')
drivers/misc/fastrpc.c:624:17: error: initializer element is not constant
624 | .mmap = fastrpc_mmap,
| ^~~~~~~~~~~~
drivers/misc/fastrpc.c:624:17: note: (near initialization for 'fastrpc_dma_buf_ops.mmap')
drivers/misc/fastrpc.c:625:17: error: initializer element is not constant
625 | .vmap = fastrpc_vmap,
| ^~~~~~~~~~~~
drivers/misc/fastrpc.c:625:17: note: (near initialization for 'fastrpc_dma_buf_ops.vmap')
drivers/misc/fastrpc.c:626:20: error: initializer element is not constant
626 | .release = fastrpc_release,
| ^~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:626:20: note: (near initialization for 'fastrpc_dma_buf_ops.release')
drivers/misc/fastrpc.c:629:12: error: invalid storage class for function 'fastrpc_map_create'
629 | static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
| ^~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:724:12: error: invalid storage class for function 'fastrpc_get_meta_size'
724 | static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:737:12: error: invalid storage class for function 'fastrpc_get_payload_size'
737 | static u64 fastrpc_get_payload_size(struct fastrpc_invoke_ctx *ctx, int metalen)
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:756:12: error: invalid storage class for function 'fastrpc_create_maps'
756 | static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c: In function 'fastrpc_create_maps':
drivers/misc/fastrpc.c:767:82: error: 'x' undeclared (first use in this function)
767 | ctx->args[i].length, ctx->args[i].attr, x->maps[i]);
| ^
drivers/misc/fastrpc.c:767:82: note: each undeclared identifier is reported only once for each function it appears in
drivers/misc/fastrpc.c: In function 'fastrpc_free_map':
drivers/misc/fastrpc.c:777:12: error: invalid storage class for function 'fastrpc_get_args'
777 | static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:900:12: error: invalid storage class for function 'fastrpc_put_args'
900 | static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
| ^~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:926:12: error: invalid storage class for function 'fastrpc_invoke_send'
926 | static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:958:12: error: invalid storage class for function 'fastrpc_internal_invoke'
958 | static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1031:12: error: invalid storage class for function 'fastrpc_init_create_process'
1031 | static int fastrpc_init_create_process(struct fastrpc_user *fl,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1143:36: error: invalid storage class for function 'fastrpc_session_alloc'
1143 | static struct fastrpc_session_ctx *fastrpc_session_alloc(
| ^~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1163:13: error: invalid storage class for function 'fastrpc_session_free'
1163 | static void fastrpc_session_free(struct fastrpc_channel_ctx *cctx,
| ^~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1173:12: error: invalid storage class for function 'fastrpc_release_current_dsp_process'
1173 | static int fastrpc_release_current_dsp_process(struct fastrpc_user *fl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1189:12: error: invalid storage class for function 'fastrpc_device_release'
1189 | static int fastrpc_device_release(struct inode *inode, struct file *file)
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1232:12: error: invalid storage class for function 'fastrpc_device_open'
1232 | static int fastrpc_device_open(struct inode *inode, struct file *filp)
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1271:12: error: invalid storage class for function 'fastrpc_dmabuf_alloc'
1271 | static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp)
| ^~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1309:12: error: invalid storage class for function 'fastrpc_init_attach'
1309 | static int fastrpc_init_attach(struct fastrpc_user *fl, int pd)
| ^~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1325:12: error: invalid storage class for function 'fastrpc_invoke'
1325 | static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)
| ^~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1355:12: error: invalid storage class for function 'fastrpc_req_munmap_impl'
1355 | static int fastrpc_req_munmap_impl(struct fastrpc_user *fl,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:1401:12: error: invalid storage class for function 'fastrpc_req_munmap'


vim +/fastrpc_map_put +263 drivers/misc/fastrpc.c

c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 262
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @263 static void fastrpc_map_put(struct fastrpc_map *map)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 264 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 265 if (map)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 266 kref_put(&map->refcount, fastrpc_free_map);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 267 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 268
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @269 static void fastrpc_map_get(struct fastrpc_map *map)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 270 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 271 if (map)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 272 kref_get(&map->refcount);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 273 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 274
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @275 static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 276 struct fastrpc_map **ppmap)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 277 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 278 struct fastrpc_map *map = NULL;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 279
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 280 mutex_lock(&fl->mutex);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 281 list_for_each_entry(map, &fl->maps, node) {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 282 if (map->fd == fd) {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 283 fastrpc_map_get(map);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 284 *ppmap = map;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 285 mutex_unlock(&fl->mutex);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 286 return 0;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 287 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 288 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 289 mutex_unlock(&fl->mutex);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 290
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 291 return -ENOENT;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 292 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 293
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @294 static void fastrpc_buf_free(struct fastrpc_buf *buf)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 295 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 296 dma_free_coherent(buf->dev, buf->size, buf->virt,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 297 FASTRPC_PHYS(buf->phys));
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 298 kfree(buf);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 299 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 300
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @301 static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 302 u64 size, struct fastrpc_buf **obuf)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 303 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 304 struct fastrpc_buf *buf;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 305
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 306 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 307 if (!buf)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 308 return -ENOMEM;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 309
6cffd79504ce040 Srinivas Kandagatla 2019-02-08 310 INIT_LIST_HEAD(&buf->attachments);
2419e55e532de14 Jorge Ramirez-Ortiz 2019-10-09 311 INIT_LIST_HEAD(&buf->node);
6cffd79504ce040 Srinivas Kandagatla 2019-02-08 312 mutex_init(&buf->lock);
6cffd79504ce040 Srinivas Kandagatla 2019-02-08 313
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 314 buf->fl = fl;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 315 buf->virt = NULL;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 316 buf->phys = 0;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 317 buf->size = size;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 318 buf->dev = dev;
2419e55e532de14 Jorge Ramirez-Ortiz 2019-10-09 319 buf->raddr = 0;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 320
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 321 buf->virt = dma_alloc_coherent(dev, buf->size, (dma_addr_t *)&buf->phys,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 322 GFP_KERNEL);
41db5f8397eee75 Jorge Ramirez-Ortiz 2019-07-05 323 if (!buf->virt) {
41db5f8397eee75 Jorge Ramirez-Ortiz 2019-07-05 324 mutex_destroy(&buf->lock);
41db5f8397eee75 Jorge Ramirez-Ortiz 2019-07-05 325 kfree(buf);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 326 return -ENOMEM;
41db5f8397eee75 Jorge Ramirez-Ortiz 2019-07-05 327 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 328
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 329 if (fl->sctx && fl->sctx->sid)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 330 buf->phys += ((u64)fl->sctx->sid << 32);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 331
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 332 *obuf = buf;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 333
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 334 return 0;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 335 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 336
278d56f970ae6e0 Bjorn Andersson 2019-08-29 @337 static void fastrpc_channel_ctx_free(struct kref *ref)
278d56f970ae6e0 Bjorn Andersson 2019-08-29 338 {
278d56f970ae6e0 Bjorn Andersson 2019-08-29 339 struct fastrpc_channel_ctx *cctx;
278d56f970ae6e0 Bjorn Andersson 2019-08-29 340
278d56f970ae6e0 Bjorn Andersson 2019-08-29 341 cctx = container_of(ref, struct fastrpc_channel_ctx, refcount);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 342
278d56f970ae6e0 Bjorn Andersson 2019-08-29 343 kfree(cctx);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 344 }
278d56f970ae6e0 Bjorn Andersson 2019-08-29 345
278d56f970ae6e0 Bjorn Andersson 2019-08-29 @346 static void fastrpc_channel_ctx_get(struct fastrpc_channel_ctx *cctx)
278d56f970ae6e0 Bjorn Andersson 2019-08-29 347 {
278d56f970ae6e0 Bjorn Andersson 2019-08-29 348 kref_get(&cctx->refcount);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 349 }
278d56f970ae6e0 Bjorn Andersson 2019-08-29 350
278d56f970ae6e0 Bjorn Andersson 2019-08-29 @351 static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx)
278d56f970ae6e0 Bjorn Andersson 2019-08-29 352 {
278d56f970ae6e0 Bjorn Andersson 2019-08-29 353 kref_put(&cctx->refcount, fastrpc_channel_ctx_free);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 354 }
278d56f970ae6e0 Bjorn Andersson 2019-08-29 355
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @356 static void fastrpc_context_free(struct kref *ref)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 357 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 358 struct fastrpc_invoke_ctx *ctx;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 359 struct fastrpc_channel_ctx *cctx;
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 360 unsigned long flags;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 361 int i;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 362
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 363 ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 364 cctx = ctx->cctx;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 365
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 366 for (i = 0; i < ctx->nscalars; i++)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 367 fastrpc_map_put(ctx->maps[i]);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 368
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 369 if (ctx->buf)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 370 fastrpc_buf_free(ctx->buf);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 371
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 372 spin_lock_irqsave(&cctx->lock, flags);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 373 idr_remove(&cctx->ctx_idr, ctx->ctxid >> 4);
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 374 spin_unlock_irqrestore(&cctx->lock, flags);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 375
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 376 kfree(ctx->maps);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 377 kfree(ctx->olaps);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 378 kfree(ctx);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 379
278d56f970ae6e0 Bjorn Andersson 2019-08-29 380 fastrpc_channel_ctx_put(cctx);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 381 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 382
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @383 static void fastrpc_context_get(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 384 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 385 kref_get(&ctx->refcount);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 386 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 387
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @388 static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 389 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 390 kref_put(&ctx->refcount, fastrpc_context_free);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 391 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 392
8e7389c79b40ed4 Thierry Escande 2019-03-07 @393 static void fastrpc_context_put_wq(struct work_struct *work)
8e7389c79b40ed4 Thierry Escande 2019-03-07 394 {
8e7389c79b40ed4 Thierry Escande 2019-03-07 395 struct fastrpc_invoke_ctx *ctx =
8e7389c79b40ed4 Thierry Escande 2019-03-07 396 container_of(work, struct fastrpc_invoke_ctx, put_work);
8e7389c79b40ed4 Thierry Escande 2019-03-07 397
8e7389c79b40ed4 Thierry Escande 2019-03-07 398 fastrpc_context_put(ctx);
8e7389c79b40ed4 Thierry Escande 2019-03-07 399 }
8e7389c79b40ed4 Thierry Escande 2019-03-07 400
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 401 #define CMP(aa, bb) ((aa) == (bb) ? 0 : (aa) < (bb) ? -1 : 1)
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 @402 static int olaps_cmp(const void *a, const void *b)
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 403 {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 404 struct fastrpc_buf_overlap *pa = (struct fastrpc_buf_overlap *)a;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 405 struct fastrpc_buf_overlap *pb = (struct fastrpc_buf_overlap *)b;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 406 /* sort with lowest starting buffer first */
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 407 int st = CMP(pa->start, pb->start);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 408 /* sort with highest ending buffer first */
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 409 int ed = CMP(pb->end, pa->end);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 410
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 411 return st == 0 ? ed : st;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 412 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 413
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 @414 static void fastrpc_get_buff_overlaps(struct fastrpc_invoke_ctx *ctx)
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 415 {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 416 u64 max_end = 0;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 417 int i;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 418
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 419 for (i = 0; i < ctx->nbufs; ++i) {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 420 ctx->olaps[i].start = ctx->args[i].ptr;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 421 ctx->olaps[i].end = ctx->olaps[i].start + ctx->args[i].length;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 422 ctx->olaps[i].raix = i;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 423 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 424
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 425 sort(ctx->olaps, ctx->nbufs, sizeof(*ctx->olaps), olaps_cmp, NULL);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 426
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 427 for (i = 0; i < ctx->nbufs; ++i) {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 428 /* Falling inside previous range */
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 429 if (ctx->olaps[i].start < max_end) {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 430 ctx->olaps[i].mstart = max_end;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 431 ctx->olaps[i].mend = ctx->olaps[i].end;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 432 ctx->olaps[i].offset = max_end - ctx->olaps[i].start;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 433
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 434 if (ctx->olaps[i].end > max_end) {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 435 max_end = ctx->olaps[i].end;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 436 } else {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 437 ctx->olaps[i].mend = 0;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 438 ctx->olaps[i].mstart = 0;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 439 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 440
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 441 } else {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 442 ctx->olaps[i].mend = ctx->olaps[i].end;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 443 ctx->olaps[i].mstart = ctx->olaps[i].start;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 444 ctx->olaps[i].offset = 0;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 445 max_end = ctx->olaps[i].end;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 446 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 447 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 448 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 449
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 @450 static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 451 struct fastrpc_user *user, u32 kernel, u32 sc,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 452 struct fastrpc_invoke_args *args)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 453 {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 454 struct fastrpc_channel_ctx *cctx = user->cctx;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 455 struct fastrpc_invoke_ctx *ctx = NULL;
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 456 unsigned long flags;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 457 int ret;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 458
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 459 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 460 if (!ctx)
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 461 return ERR_PTR(-ENOMEM);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 462
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 463 INIT_LIST_HEAD(&ctx->node);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 464 ctx->fl = user;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 465 ctx->nscalars = REMOTE_SCALARS_LENGTH(sc);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 466 ctx->nbufs = REMOTE_SCALARS_INBUFS(sc) +
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 467 REMOTE_SCALARS_OUTBUFS(sc);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 468
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 469 if (ctx->nscalars) {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 470 ctx->maps = kcalloc(ctx->nscalars,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 471 sizeof(*ctx->maps), GFP_KERNEL);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 472 if (!ctx->maps) {
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 473 kfree(ctx);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 474 return ERR_PTR(-ENOMEM);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 475 }
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 476 ctx->olaps = kcalloc(ctx->nscalars,
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 477 sizeof(*ctx->olaps), GFP_KERNEL);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 478 if (!ctx->olaps) {
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 479 kfree(ctx->maps);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 480 kfree(ctx);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 481 return ERR_PTR(-ENOMEM);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 482 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 483 ctx->args = args;
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 484 fastrpc_get_buff_overlaps(ctx);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 485 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 486
278d56f970ae6e0 Bjorn Andersson 2019-08-29 487 /* Released in fastrpc_context_put() */
278d56f970ae6e0 Bjorn Andersson 2019-08-29 488 fastrpc_channel_ctx_get(cctx);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 489
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 490 ctx->sc = sc;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 491 ctx->retval = -1;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 492 ctx->pid = current->pid;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 493 ctx->tgid = user->tgid;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 494 ctx->cctx = cctx;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 495 init_completion(&ctx->work);
8e7389c79b40ed4 Thierry Escande 2019-03-07 496 INIT_WORK(&ctx->put_work, fastrpc_context_put_wq);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 497
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 498 spin_lock(&user->lock);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 499 list_add_tail(&ctx->node, &user->pending);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 500 spin_unlock(&user->lock);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 501
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 502 spin_lock_irqsave(&cctx->lock, flags);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 503 ret = idr_alloc_cyclic(&cctx->ctx_idr, ctx, 1,
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 504 FASTRPC_CTX_MAX, GFP_ATOMIC);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 505 if (ret < 0) {
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 506 spin_unlock_irqrestore(&cctx->lock, flags);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 507 goto err_idr;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 508 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 509 ctx->ctxid = ret << 4;
977e6c8d1d18061 Srinivas Kandagatla 2019-03-07 510 spin_unlock_irqrestore(&cctx->lock, flags);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 511
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 512 kref_init(&ctx->refcount);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 513
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 514 return ctx;
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 515 err_idr:
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 516 spin_lock(&user->lock);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 517 list_del(&ctx->node);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 518 spin_unlock(&user->lock);
278d56f970ae6e0 Bjorn Andersson 2019-08-29 519 fastrpc_channel_ctx_put(cctx);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 520 kfree(ctx->maps);
25e8dfb83cda0a1 Srinivas Kandagatla 2019-03-07 521 kfree(ctx->olaps);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 522 kfree(ctx);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 523
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 524 return ERR_PTR(ret);
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 525 }
c68cfb718c8f97b Srinivas Kandagatla 2019-02-08 526

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

2021-11-30 20:21:12

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20211201/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d9eaed76074c94c9751c3a587ef2409fa7ce153e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
git checkout d9eaed76074c94c9751c3a587ef2409fa7ce153e
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
>> drivers/misc/fastrpc.c:923:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
923 | if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
| ^~
| fd
drivers/misc/fastrpc.c:923:39: note: each undeclared identifier is reported only once for each function it appears in


vim +923 drivers/misc/fastrpc.c

886
887 static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
888 u32 kernel)
889 {
890 struct fastrpc_remote_arg *rpra = ctx->rpra;
891 struct fastrpc_map *mmap = NULL;
892 struct fastrpc_invoke_buf *list;
893 struct fastrpc_phy_page *pages;
894 u64 *fdlist;
895 int i, inbufs, outbufs, handles;
896
897 inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
898 outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
899 handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
900 list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
901 pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
902 sizeof(*rpra));
903 fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
904
905 for (i = inbufs; i < ctx->nbufs; ++i) {
906 if (!ctx->maps[i]) {
907 void *src = (void *)(uintptr_t)rpra[i].pv;
908 void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
909 u64 len = rpra[i].len;
910
911 if (!kernel) {
912 if (copy_to_user((void __user *)dst, src, len))
913 return -EFAULT;
914 } else {
915 memcpy(dst, src, len);
916 }
917 }
918 }
919
920 for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
921 if (!fdlist[i])
922 break;
> 923 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
924 fastrpc_map_put(mmap);
925 }
926
927 return 0;
928 }
929

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

2021-11-30 22:44:55

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] misc: fastrpc: Add dma handle implementation

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: x86_64-buildonly-randconfig-r004-20211130 (https://download.01.org/0day-ci/archive/20211201/[email protected]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/b29c5611eb2bd23a416730b8067a107bcc8594a7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
git checkout b29c5611eb2bd23a416730b8067a107bcc8594a7
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/misc/fastrpc.c: In function 'fastrpc_get_meta_size':
drivers/misc/fastrpc.c:721:24: error: 'fastrpc_remote_arg' defined as wrong kind of tag
721 | size = (sizeof(struct fastrpc_remote_arg) +
| ^~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:721:17: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
721 | size = (sizeof(struct fastrpc_remote_arg) +
| ^~~~~~
drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
drivers/misc/fastrpc.c:925:9: error: 'fastrpc_remote_arg' defined as wrong kind of tag
925 | struct fastrpc_remote_arg *rpra = ctx->rpra;
| ^~~~~~~~~~~~~~~~~~
drivers/misc/fastrpc.c:925:36: error: initialization of 'struct fastrpc_remote_arg *' from incompatible pointer type 'union fastrpc_remote_arg *' [-Werror=incompatible-pointer-types]
925 | struct fastrpc_remote_arg *rpra = ctx->rpra;
| ^~~
>> drivers/misc/fastrpc.c:935:49: error: dereferencing pointer to incomplete type 'struct fastrpc_remote_arg'
935 | list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
| ^~~~~
drivers/misc/fastrpc.c:942:39: error: invalid use of undefined type 'struct fastrpc_remote_arg'
942 | void *src = (void *)(uintptr_t)rpra[i].pv;
| ^
drivers/misc/fastrpc.c:944:18: error: invalid use of undefined type 'struct fastrpc_remote_arg'
944 | u64 len = rpra[i].len;
| ^
drivers/misc/fastrpc.c:958:25: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
958 | if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
| ^~
| fd
drivers/misc/fastrpc.c:958:25: note: each undeclared identifier is reported only once for each function it appears in
At top level:
drivers/misc/fastrpc.c:717:12: warning: 'fastrpc_get_meta_size' defined but not used [-Wunused-function]
717 | static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +935 drivers/misc/fastrpc.c

c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 921
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 922 static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 923 u32 kernel)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 924 {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 925 struct fastrpc_remote_arg *rpra = ctx->rpra;
d9eaed76074c94 Jeya R 2021-11-30 926 struct fastrpc_map *mmap = NULL;
d9eaed76074c94 Jeya R 2021-11-30 927 struct fastrpc_invoke_buf *list;
d9eaed76074c94 Jeya R 2021-11-30 928 struct fastrpc_phy_page *pages;
d9eaed76074c94 Jeya R 2021-11-30 929 u64 *fdlist;
d9eaed76074c94 Jeya R 2021-11-30 930 int i, inbufs, outbufs, handles;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 931
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 932 inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
d9eaed76074c94 Jeya R 2021-11-30 933 outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
d9eaed76074c94 Jeya R 2021-11-30 934 handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
d9eaed76074c94 Jeya R 2021-11-30 @935 list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
d9eaed76074c94 Jeya R 2021-11-30 936 pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
d9eaed76074c94 Jeya R 2021-11-30 937 sizeof(*rpra));
d9eaed76074c94 Jeya R 2021-11-30 938 fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 939
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 940 for (i = inbufs; i < ctx->nbufs; ++i) {
847afd7bd5607c Jeya R 2021-09-23 941 if (!ctx->maps[i]) {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 942 void *src = (void *)(uintptr_t)rpra[i].pv;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 943 void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 944 u64 len = rpra[i].len;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 945
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 946 if (!kernel) {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 947 if (copy_to_user((void __user *)dst, src, len))
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 948 return -EFAULT;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 949 } else {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 950 memcpy(dst, src, len);
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 951 }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 952 }
847afd7bd5607c Jeya R 2021-09-23 953 }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 954
d9eaed76074c94 Jeya R 2021-11-30 955 for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
d9eaed76074c94 Jeya R 2021-11-30 956 if (!fdlist[i])
d9eaed76074c94 Jeya R 2021-11-30 957 break;
d9eaed76074c94 Jeya R 2021-11-30 958 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
d9eaed76074c94 Jeya R 2021-11-30 959 fastrpc_map_put(mmap);
d9eaed76074c94 Jeya R 2021-11-30 960 }
d9eaed76074c94 Jeya R 2021-11-30 961
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 962 return 0;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 963 }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 964

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

2021-11-30 23:53:09

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211201/[email protected]/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 25eb7fa01d7ebbe67648ea03841cda55b4239ab2)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d9eaed76074c94c9751c3a587ef2409fa7ce153e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
git checkout d9eaed76074c94c9751c3a587ef2409fa7ce153e
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:923:25: error: use of undeclared identifier 'fl'
if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
^
1 error generated.


vim +/fl +923 drivers/misc/fastrpc.c

886
887 static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
888 u32 kernel)
889 {
890 struct fastrpc_remote_arg *rpra = ctx->rpra;
891 struct fastrpc_map *mmap = NULL;
892 struct fastrpc_invoke_buf *list;
893 struct fastrpc_phy_page *pages;
894 u64 *fdlist;
895 int i, inbufs, outbufs, handles;
896
897 inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
898 outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
899 handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
900 list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
901 pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
902 sizeof(*rpra));
903 fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
904
905 for (i = inbufs; i < ctx->nbufs; ++i) {
906 if (!ctx->maps[i]) {
907 void *src = (void *)(uintptr_t)rpra[i].pv;
908 void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
909 u64 len = rpra[i].len;
910
911 if (!kernel) {
912 if (copy_to_user((void __user *)dst, src, len))
913 return -EFAULT;
914 } else {
915 memcpy(dst, src, len);
916 }
917 }
918 }
919
920 for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
921 if (!fdlist[i])
922 break;
> 923 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
924 fastrpc_map_put(mmap);
925 }
926
927 return 0;
928 }
929

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

2021-12-01 00:24:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] misc: fastrpc: Add dma handle implementation

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20211201/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/b29c5611eb2bd23a416730b8067a107bcc8594a7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
git checkout b29c5611eb2bd23a416730b8067a107bcc8594a7
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/misc/fastrpc.c: In function 'fastrpc_get_meta_size':
>> drivers/misc/fastrpc.c:721:31: error: 'fastrpc_remote_arg' defined as wrong kind of tag
721 | size = (sizeof(struct fastrpc_remote_arg) +
| ^~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:721:24: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
721 | size = (sizeof(struct fastrpc_remote_arg) +
| ^~~~~~
drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
drivers/misc/fastrpc.c:925:16: error: 'fastrpc_remote_arg' defined as wrong kind of tag
925 | struct fastrpc_remote_arg *rpra = ctx->rpra;
| ^~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:925:43: error: initialization of 'struct fastrpc_remote_arg *' from incompatible pointer type 'union fastrpc_remote_arg *' [-Werror=incompatible-pointer-types]
925 | struct fastrpc_remote_arg *rpra = ctx->rpra;
| ^~~
drivers/misc/fastrpc.c:935:55: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
935 | list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
| ^
drivers/misc/fastrpc.c:937:23: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
937 | sizeof(*rpra));
| ^
>> drivers/misc/fastrpc.c:942:60: error: invalid use of undefined type 'struct fastrpc_remote_arg'
942 | void *src = (void *)(uintptr_t)rpra[i].pv;
| ^
drivers/misc/fastrpc.c:942:63: error: invalid use of undefined type 'struct fastrpc_remote_arg'
942 | void *src = (void *)(uintptr_t)rpra[i].pv;
| ^
drivers/misc/fastrpc.c:944:39: error: invalid use of undefined type 'struct fastrpc_remote_arg'
944 | u64 len = rpra[i].len;
| ^
drivers/misc/fastrpc.c:944:42: error: invalid use of undefined type 'struct fastrpc_remote_arg'
944 | u64 len = rpra[i].len;
| ^
drivers/misc/fastrpc.c:958:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
958 | if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
| ^~
| fd
drivers/misc/fastrpc.c:958:39: note: each undeclared identifier is reported only once for each function it appears in
At top level:
drivers/misc/fastrpc.c:717:12: warning: 'fastrpc_get_meta_size' defined but not used [-Wunused-function]
717 | static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/fastrpc_remote_arg +721 drivers/misc/fastrpc.c

c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 689
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 690 /*
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 691 * Fastrpc payload buffer with metadata looks like:
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 692 *
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 693 * >>>>>> START of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 694 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 695 * | Arguments |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 696 * | type:(struct fastrpc_remote_arg)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 697 * | (0 - N) |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 698 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 699 * | Invoke Buffer list |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 700 * | type:(struct fastrpc_invoke_buf)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 701 * | (0 - N) |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 702 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 703 * | Page info list |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 704 * | type:(struct fastrpc_phy_page) |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 705 * | (0 - N) |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 706 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 707 * | Optional info |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 708 * |(can be specific to SoC/Firmware)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 709 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 710 * >>>>>>>> END of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 711 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 712 * | Inline ARGS |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 713 * | (0-N) |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 714 * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 715 */
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 716
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 717 static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 718 {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 719 int size = 0;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 720
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 @721 size = (sizeof(struct fastrpc_remote_arg) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 722 sizeof(struct fastrpc_invoke_buf) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 723 sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 724 sizeof(u64) * FASTRPC_MAX_FDLIST +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 725 sizeof(u32) * FASTRPC_MAX_CRCLIST;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 726
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 727 return size;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 728 }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 729

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]