Message ID | 20240606165939.12950-3-quic_ekangupt@quicinc.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | Add missing features to FastRPC driver | expand |
On Thu, Jun 06, 2024 at 10:29:22PM +0530, Ekansh Gupta wrote: > The DSP capability request call expects 2 arguments. First is the > information about the total number of attributes to be copied from > DSP and second is the information about the buffer where the DSP > needs to copy the information. The current design is passing the > information about te size to be copied from DSP which would be > considered as a bad argument to the call by DSP causing a failure > suggesting the same. The second argument carries the information > about the buffer where the DSP needs to copy the capability > information and the size to be copied. As the first entry of > capability attribute is getting skipped, same should also be > considered while sending the information to DSP. Add changes to > pass proper arguments to DSP. > > Fixes: 6c16fd8bdd40 ("misc: fastrpc: Add support to get DSP capabilities") > Cc: stable <stable@kernel.org> > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> > --- > drivers/misc/fastrpc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
On 06/06/2024 18:59, Ekansh Gupta wrote: > The DSP capability request call expects 2 arguments. First is the > information about the total number of attributes to be copied from > DSP and second is the information about the buffer where the DSP > needs to copy the information. The current design is passing the > information about te size to be copied from DSP which would be *the size > considered as a bad argument to the call by DSP causing a failure > suggesting the same. The second argument carries the information > about the buffer where the DSP needs to copy the capability > information and the size to be copied. As the first entry of > capability attribute is getting skipped, same should also be > considered while sending the information to DSP. Add changes to > pass proper arguments to DSP. > > Fixes: 6c16fd8bdd40 ("misc: fastrpc: Add support to get DSP capabilities") > Cc: stable <stable@kernel.org> > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> > --- > drivers/misc/fastrpc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index 4028cb96bcf2..abf7df7c0c85 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -1695,12 +1695,13 @@ static int fastrpc_get_info_from_dsp(struct fastrpc_user *fl, uint32_t *dsp_attr > > /* Capability filled in userspace */ > dsp_attr_buf[0] = 0; > + dsp_attr_buf_len -= 1; The commit message states "As the first entry of the capability attribute is getting skipped, same should also be considered while sending the information to the DSP.". But it doesn't explain *why* this is the case. Please add a comment here explaining why you subtract 1. With that change: Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org> > > args[0].ptr = (u64)(uintptr_t)&dsp_attr_buf_len; > args[0].length = sizeof(dsp_attr_buf_len); > args[0].fd = -1; > args[1].ptr = (u64)(uintptr_t)&dsp_attr_buf[1]; > - args[1].length = dsp_attr_buf_len; > + args[1].length = dsp_attr_buf_len * sizeof(u32); > args[1].fd = -1; > fl->pd = USER_PD; > > @@ -1730,7 +1731,7 @@ static int fastrpc_get_info_from_kernel(struct fastrpc_ioctl_capability *cap, > if (!dsp_attributes) > return -ENOMEM; > > - err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES_LEN); > + err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES); > if (err == DSP_UNSUPPORTED_API) { > dev_info(&cctx->rpdev->dev, > "Warning: DSP capabilities not supported on domain: %d\n", domain);
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 4028cb96bcf2..abf7df7c0c85 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1695,12 +1695,13 @@ static int fastrpc_get_info_from_dsp(struct fastrpc_user *fl, uint32_t *dsp_attr /* Capability filled in userspace */ dsp_attr_buf[0] = 0; + dsp_attr_buf_len -= 1; args[0].ptr = (u64)(uintptr_t)&dsp_attr_buf_len; args[0].length = sizeof(dsp_attr_buf_len); args[0].fd = -1; args[1].ptr = (u64)(uintptr_t)&dsp_attr_buf[1]; - args[1].length = dsp_attr_buf_len; + args[1].length = dsp_attr_buf_len * sizeof(u32); args[1].fd = -1; fl->pd = USER_PD; @@ -1730,7 +1731,7 @@ static int fastrpc_get_info_from_kernel(struct fastrpc_ioctl_capability *cap, if (!dsp_attributes) return -ENOMEM; - err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES_LEN); + err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES); if (err == DSP_UNSUPPORTED_API) { dev_info(&cctx->rpdev->dev, "Warning: DSP capabilities not supported on domain: %d\n", domain);
The DSP capability request call expects 2 arguments. First is the information about the total number of attributes to be copied from DSP and second is the information about the buffer where the DSP needs to copy the information. The current design is passing the information about te size to be copied from DSP which would be considered as a bad argument to the call by DSP causing a failure suggesting the same. The second argument carries the information about the buffer where the DSP needs to copy the capability information and the size to be copied. As the first entry of capability attribute is getting skipped, same should also be considered while sending the information to DSP. Add changes to pass proper arguments to DSP. Fixes: 6c16fd8bdd40 ("misc: fastrpc: Add support to get DSP capabilities") Cc: stable <stable@kernel.org> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> --- drivers/misc/fastrpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)