[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230116084557.GB1737564@quicinc.com>
Date: Mon, 16 Jan 2023 14:15:57 +0530
From: Srivatsa Vaddagiri <quic_svaddagi@...cinc.com>
To: Elliot Berman <quic_eberman@...cinc.com>
CC: Bjorn Andersson <quic_bjorande@...cinc.com>,
Murali Nalajala <quic_mnalajal@...cinc.com>,
Trilok Soni <quic_tsoni@...cinc.com>,
"Carl van Schaik" <quic_cvanscha@...cinc.com>,
Prakruthi Deepak Heragu <quic_pheragu@...cinc.com>,
Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@...aro.org>,
Jonathan Corbet <corbet@....net>,
Bagas Sanjaya <bagasdotme@...il.com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Jassi Brar <jassisinghbrar@...il.com>,
Sudeep Holla <sudeep.holla@....com>,
Mark Rutland <mark.rutland@....com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
"Dmitry Baryshkov" <dmitry.baryshkov@...aro.org>,
<linux-arm-msm@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-acpi@...r.kernel.org>
Subject: Re: [PATCH v8 13/28] gunyah: rsc_mgr: Add RPC for sharing memory
* Elliot Berman <quic_eberman@...cinc.com> [2022-12-19 14:58:34]:
> +static int _gh_rm_mem_append(struct gh_rm_rpc *rm, u32 mem_handle, bool end_append,
> + struct gh_rm_mem_entry *mem_entries, size_t n_mem_entries)
> +{
> + size_t msg_size = 0;
> + void *msg;
> + struct gh_mem_append_req_header *req_header;
> + struct gh_mem_share_req_mem_section *mem_section;
> + void *resp;
> + size_t resp_size;
> + int ret;
> +
> + msg_size += sizeof(struct gh_mem_append_req_header);
> + msg_size += offsetof(struct gh_mem_share_req_mem_section, entries[n_mem_entries]);
> +
> + msg = kzalloc(msg_size, GFP_KERNEL);
> + if (!msg)
> + return -ENOMEM;
> +
> + req_header = msg;
> + mem_section = (void *)req_header + sizeof(struct gh_mem_append_req_header);
> +
> + req_header->mem_handle = mem_handle;
cpu_to_le(mem_handle);
> + if (end_append)
> + req_header->flags |= GH_MEM_APPEND_REQ_FLAGS_END;
> +
> + mem_section->n_entries = n_mem_entries;
> + memcpy(mem_section->entries, mem_entries, sizeof(*mem_entries) * n_mem_entries);
> +
> + ret = gh_rm_call(rm, GH_RM_RPC_MEM_APPEND, msg, msg_size, &resp, &resp_size);
> + if (ret)
kfree(msg);
> + return ret;
> + kfree(resp);
kfree(msg);
> +
> + return ret;
> +}
> +
> +static int gh_rm_mem_append(struct gh_rm_rpc *rm, u32 mem_handle, bool allow_append,
Is there any scenario where allow_append will be 'true'? As of this patch
atleast, its always 'false', so maybe just avoid this input argument?
> +static int gh_rm_mem_lend_common(struct gh_rm_rpc *rm, u32 message_id, struct gh_rm_mem_parcel *p)
> +{
[snip]
> + acl_section->n_entries = p->n_acl_entries;
cpu_to_le32(p->n_acl_entries);
> + memcpy(acl_section->entries, p->acl_entries, sizeof(*(p->acl_entries)) * p->n_acl_entries);
> +
> + mem_section->n_entries = initial_n_mem_entries;
cpu_to_le32(initial_n_mem_entries);
> + memcpy(mem_section->entries, p->mem_entries,
> + sizeof(*(p->mem_entries)) * initial_n_mem_entries);
> +
> + /* Set n_entries for memory attribute section to 0 */
> + *mem_attr_section = 0;
> +
> + ret = gh_rm_call(rm, message_id, msg, msg_size, &resp, &resp_size);
> + if (ret)
kfree(msg)
> + return ret;
> +
> + if (resp_size != sizeof(__le32)) {
> + ret = -EIO;
> + goto out;
> + }
> +
> + p->mem_handle = le32_to_cpu(*(__le32 *)resp);
> +
> + if (initial_n_mem_entries != p->n_mem_entries) {
> + ret = gh_rm_mem_append(rm, p->mem_handle, false,
> + &p->mem_entries[initial_n_mem_entries],
> + p->n_mem_entries - initial_n_mem_entries);
> + if (ret)
> + gh_rm_mem_reclaim(rm, p);
p->mem_handle = GH_MEM_HANDLE_INVAL in this case?
> + }
> +
> +out:
kfree(msg) ?
Powered by blists - more mailing lists