* [PATCH 1/6] misc: fastrpc: Use memdup_user()
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 1/1] slimbus: Fix struct and documentation alignment in stream.c srinivas.kandagatla
` (5 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Thorsten Blum, Arnd Bergmann, Srinivas Kandagatla
From: Thorsten Blum <thorsten.blum@toblux.com>
Switching to memdup_user() overwrites the allocated memory only once,
whereas kzalloc() followed by copy_from_user() initializes the allocated
memory to zero and then immediately overwrites it.
Fixes the following Coccinelle/coccicheck warning reported by
memdup_user.cocci:
WARNING opportunity for memdup_user
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 4c67e2c5a82e..694fc083b1bd 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1259,17 +1259,12 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
goto err;
}
- name = kzalloc(init.namelen, GFP_KERNEL);
- if (!name) {
- err = -ENOMEM;
+ name = memdup_user(u64_to_user_ptr(init.name), init.namelen);
+ if (IS_ERR(name)) {
+ err = PTR_ERR(name);
goto err;
}
- if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) {
- err = -EFAULT;
- goto err_name;
- }
-
if (!fl->cctx->remote_heap) {
err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
&fl->cctx->remote_heap);
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 1/1] slimbus: Fix struct and documentation alignment in stream.c
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 1/6] misc: fastrpc: Use memdup_user() srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
2024-07-05 7:53 ` Greg KH
2024-07-05 7:40 ` [PATCH 2/6] misc: fastrpc: Add missing dev_err newlines srinivas.kandagatla
` (4 subsequent siblings)
6 siblings, 1 reply; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Amit Vadhavana, Ricardo B . Marliere,
Srinivas Kandagatla
From: Amit Vadhavana <av2082000@gmail.com>
The placement of the `segdist_codes` array documentation was corrected
to conform with kernel documentation guidelines. The `@segdist_codes`
was placed incorrectly within the struct `segdist_code` documentation
block, which led to a potential misinterpretation of the code structure.
The `segdist_codes` array documentation was moved outside the struct
block, and a separate comment block was provided for it. This change
ensures that clarity and proper alignment with kernel documentation
standards are maintained.
A kernel-doc warning was addressed:
./drivers/slimbus/stream.c:49: warning: Excess struct member 'segdist_codes' description in 'segdist_code'
Signed-off-by: Amit Vadhavana <av2082000@gmail.com>
Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/slimbus/stream.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/slimbus/stream.c b/drivers/slimbus/stream.c
index 1d6b38657917..863ab3075d7e 100644
--- a/drivers/slimbus/stream.c
+++ b/drivers/slimbus/stream.c
@@ -18,15 +18,17 @@
* and the first slot of the next consecutive Segment.
* @segdist_code: Segment Distribution Code SD[11:0]
* @seg_offset_mask: Segment offset mask in SD[11:0]
- * @segdist_codes: List of all possible Segmet Distribution codes.
*/
-static const struct segdist_code {
+struct segdist_code {
int ratem;
int seg_interval;
int segdist_code;
u32 seg_offset_mask;
-} segdist_codes[] = {
+};
+
+/* segdist_codes - List of all possible Segment Distribution codes. */
+static const struct segdist_code segdist_codes[] = {
{1, 1536, 0x200, 0xdff},
{2, 768, 0x100, 0xcff},
{4, 384, 0x080, 0xc7f},
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 1/1] slimbus: Fix struct and documentation alignment in stream.c
2024-07-05 7:40 ` [PATCH 1/1] slimbus: Fix struct and documentation alignment in stream.c srinivas.kandagatla
@ 2024-07-05 7:53 ` Greg KH
2024-07-05 7:55 ` Srinivas Kandagatla
0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2024-07-05 7:53 UTC (permalink / raw)
To: srinivas.kandagatla; +Cc: linux-kernel, Amit Vadhavana, Ricardo B . Marliere
On Fri, Jul 05, 2024 at 08:40:40AM +0100, srinivas.kandagatla@linaro.org wrote:
> From: Amit Vadhavana <av2082000@gmail.com>
>
> The placement of the `segdist_codes` array documentation was corrected
> to conform with kernel documentation guidelines. The `@segdist_codes`
> was placed incorrectly within the struct `segdist_code` documentation
> block, which led to a potential misinterpretation of the code structure.
>
> The `segdist_codes` array documentation was moved outside the struct
> block, and a separate comment block was provided for it. This change
> ensures that clarity and proper alignment with kernel documentation
> standards are maintained.
>
> A kernel-doc warning was addressed:
> ./drivers/slimbus/stream.c:49: warning: Excess struct member 'segdist_codes' description in 'segdist_code'
>
> Signed-off-by: Amit Vadhavana <av2082000@gmail.com>
> Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> drivers/slimbus/stream.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
I don't think this was ment to be sent as part of the fastrpc patch
series :(
Can you fix this up and resend a v2?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1] slimbus: Fix struct and documentation alignment in stream.c
2024-07-05 7:53 ` Greg KH
@ 2024-07-05 7:55 ` Srinivas Kandagatla
0 siblings, 0 replies; 11+ messages in thread
From: Srinivas Kandagatla @ 2024-07-05 7:55 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, Amit Vadhavana, Ricardo B . Marliere
On 05/07/2024 08:53, Greg KH wrote:
> On Fri, Jul 05, 2024 at 08:40:40AM +0100, srinivas.kandagatla@linaro.org wrote:
>> From: Amit Vadhavana <av2082000@gmail.com>
>>
>> The placement of the `segdist_codes` array documentation was corrected
>> to conform with kernel documentation guidelines. The `@segdist_codes`
>> was placed incorrectly within the struct `segdist_code` documentation
>> block, which led to a potential misinterpretation of the code structure.
>>
>> The `segdist_codes` array documentation was moved outside the struct
>> block, and a separate comment block was provided for it. This change
>> ensures that clarity and proper alignment with kernel documentation
>> standards are maintained.
>>
>> A kernel-doc warning was addressed:
>> ./drivers/slimbus/stream.c:49: warning: Excess struct member 'segdist_codes' description in 'segdist_code'
>>
>> Signed-off-by: Amit Vadhavana <av2082000@gmail.com>
>> Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>> drivers/slimbus/stream.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> I don't think this was ment to be sent as part of the fastrpc patch
> series :(
>
> Can you fix this up and resend a v2?
True, this patch ended up in the folder.. did not realize that!
will resend!
thanks,
Srini
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/6] misc: fastrpc: Add missing dev_err newlines
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 1/6] misc: fastrpc: Use memdup_user() srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 1/1] slimbus: Fix struct and documentation alignment in stream.c srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 3/6] misc: fastrpc: add missing MODULE_DESCRIPTION() macro srinivas.kandagatla
` (3 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Ekansh Gupta, Dmitry Baryshkov, Caleb Connolly,
Srinivas Kandagatla
From: Ekansh Gupta <quic_ekangupt@quicinc.com>
Few dev_err calls are missing newlines. This can result in unrelated
lines getting appended which might make logs difficult to understand.
Add trailing newlines to avoid this.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 694fc083b1bd..2653a193ff2f 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -325,7 +325,7 @@ static void fastrpc_free_map(struct kref *ref)
err = qcom_scm_assign_mem(map->phys, map->size,
&src_perms, &perm, 1);
if (err) {
- dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
+ dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d\n",
map->phys, map->size, err);
return;
}
@@ -816,7 +816,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
map->attr = attr;
err = qcom_scm_assign_mem(map->phys, (u64)map->size, &src_perms, dst_perms, 2);
if (err) {
- dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d",
+ dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d\n",
map->phys, map->size, err);
goto map_err;
}
@@ -1222,7 +1222,7 @@ static bool is_session_rejected(struct fastrpc_user *fl, bool unsigned_pd_reques
* that does not support unsigned PD offload
*/
if (!fl->cctx->unsigned_support || !unsigned_pd_request) {
- dev_err(&fl->cctx->rpdev->dev, "Error: Untrusted application trying to offload to signed PD");
+ dev_err(&fl->cctx->rpdev->dev, "Error: Untrusted application trying to offload to signed PD\n");
return true;
}
}
@@ -1280,7 +1280,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
&src_perms,
fl->cctx->vmperms, fl->cctx->vmcount);
if (err) {
- dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d",
+ dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d\n",
fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err);
goto err_map;
}
@@ -1332,7 +1332,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
(u64)fl->cctx->remote_heap->size,
&src_perms, &dst_perms, 1);
if (err)
- dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
+ dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d\n",
fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err);
}
err_map:
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 3/6] misc: fastrpc: add missing MODULE_DESCRIPTION() macro
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
` (2 preceding siblings ...)
2024-07-05 7:40 ` [PATCH 2/6] misc: fastrpc: Add missing dev_err newlines srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 4/6] misc: fastrpc: support complete DMA pool access to the DSP srinivas.kandagatla
` (2 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Jeff Johnson, Bryan O'Donoghue,
Srinivas Kandagatla
From: Jeff Johnson <quic_jjohnson@quicinc.com>
make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/misc/fastrpc.o
Add the missing invocation of the MODULE_DESCRIPTION() macro.
Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 2653a193ff2f..5fb302b8ae5d 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2473,5 +2473,6 @@ static void fastrpc_exit(void)
}
module_exit(fastrpc_exit);
+MODULE_DESCRIPTION("Qualcomm FastRPC");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS(DMA_BUF);
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 4/6] misc: fastrpc: support complete DMA pool access to the DSP
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
` (3 preceding siblings ...)
2024-07-05 7:40 ` [PATCH 3/6] misc: fastrpc: add missing MODULE_DESCRIPTION() macro srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 5/6] misc: fastrpc: use coherent pool for untranslated Compute Banks srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 6/6] MAINTAINERS: CC dri-devel list on Qualcomm FastRPC patches srinivas.kandagatla
6 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Dylan Van Assche, Caleb Connolly, Dmitry Baryshkov,
Ekansh Gupta, Srinivas Kandagatla
From: Dylan Van Assche <me@dylanvanassche.be>
To support FastRPC Context Banks which aren't mapped via the SMMU,
make the whole reserved memory region available to the DSP to allow
access to coherent buffers.
This is performed by assigning the memory to the DSP via a hypervisor
call to set the correct permissions for the Virtual Machines on the DSP.
This is only necessary when a memory region is provided for SLPI DSPs
so guard this with a domain ID check.
Signed-off-by: Dylan Van Assche <me@dylanvanassche.be>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 5fb302b8ae5d..1c045f9a75a4 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2250,6 +2250,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
int i, err, domain_id = -1, vmcount;
const char *domain;
bool secure_dsp;
+ struct device_node *rmem_node;
+ struct reserved_mem *rmem;
unsigned int vmids[FASTRPC_MAX_VMIDS];
err = of_property_read_string(rdev->of_node, "label", &domain);
@@ -2292,6 +2294,23 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
}
}
+ rmem_node = of_parse_phandle(rdev->of_node, "memory-region", 0);
+ if (domain_id == SDSP_DOMAIN_ID && rmem_node) {
+ u64 src_perms;
+
+ rmem = of_reserved_mem_lookup(rmem_node);
+ if (!rmem) {
+ err = -EINVAL;
+ goto fdev_error;
+ }
+
+ src_perms = BIT(QCOM_SCM_VMID_HLOS);
+
+ qcom_scm_assign_mem(rmem->base, rmem->size, &src_perms,
+ data->vmperms, data->vmcount);
+
+ }
+
secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
data->secure = secure_dsp;
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 5/6] misc: fastrpc: use coherent pool for untranslated Compute Banks
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
` (4 preceding siblings ...)
2024-07-05 7:40 ` [PATCH 4/6] misc: fastrpc: support complete DMA pool access to the DSP srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
2024-07-05 7:40 ` [PATCH 6/6] MAINTAINERS: CC dri-devel list on Qualcomm FastRPC patches srinivas.kandagatla
6 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh
Cc: linux-kernel, Dylan Van Assche, Caleb Connolly, Ekansh Gupta,
Dmitry Baryshkov, Srinivas Kandagatla
From: Dylan Van Assche <me@dylanvanassche.be>
Use fastrpc_remote_heap_alloc to allocate from the FastRPC device
instead of the Compute Bank when the session ID is 0. This ensures
that the allocation is inside the coherent DMA pool which is already
accessible to the DSP. This is necessary to support FastRPC devices
which do not have dedicated Compute Banks such as the SLPI on the SDM845.
The latter uses an allocated CMA region instead of FastRPC Compute Banks.
Signed-off-by: Dylan Van Assche <me@dylanvanassche.be>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Reviewed-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 1c045f9a75a4..95931abc3770 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -953,7 +953,10 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
ctx->msg_sz = pkt_size;
- err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
+ if (ctx->fl->sctx->sid)
+ err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
+ else
+ err = fastrpc_remote_heap_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
if (err)
return err;
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 6/6] MAINTAINERS: CC dri-devel list on Qualcomm FastRPC patches
2024-07-05 7:40 [PATCH 0/6] misc: fastrpc: patches for v6.11 srinivas.kandagatla
` (5 preceding siblings ...)
2024-07-05 7:40 ` [PATCH 5/6] misc: fastrpc: use coherent pool for untranslated Compute Banks srinivas.kandagatla
@ 2024-07-05 7:40 ` srinivas.kandagatla
6 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2024-07-05 7:40 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Dmitry Baryshkov, Bjorn Andersson,
Srinivas Kandagatla
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
FastRPC is a way to offload method invocation to the DSPs on Qualcomm
platforms. As the driver uses dma-bufs, add dri-devel mailing list to
the MAINTAINERS's entry, so that DRM maintainers are notified about the
uAPI changes. This follows the usual practice established by the "DMA
BUFFER SHARING FRAMEWORK" entry in the file.
Suggested-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index d6c90161c7bf..0b99543d9c6e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18499,6 +18499,7 @@ QUALCOMM FASTRPC DRIVER
M: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
M: Amol Maheshwari <amahesh@qti.qualcomm.com>
L: linux-arm-msm@vger.kernel.org
+L: dri-devel@lists.freedesktop.org
S: Maintained
F: Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
F: drivers/misc/fastrpc.c
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread