* [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags
@ 2020-04-13 12:07 Manivannan Sadhasivam
2020-04-13 12:07 ` [PATCH 2/2] bus: mhi: core: Fix double lock of 'mhi_chan->lock' Manivannan Sadhasivam
2020-04-16 19:01 ` [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Hemant Kumar
0 siblings, 2 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2020-04-13 12:07 UTC (permalink / raw)
To: hemantk, jhugo
Cc: linux-arm-msm, linux-kernel, smohanad, dan.carpenter,
Manivannan Sadhasivam
With the current parsing of mhi_flags, the following statement always
return false:
eob = !!(flags & MHI_EOB);
This is due to the fact that 'enum mhi_flags' starts with index 0 and we
are using direct AND operation to extract each bit. Fix this by using
BIT() macro to extract each bit and make the mhi_flags index start from 1.
Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/bus/mhi/core/main.c | 6 +++---
include/linux/mhi.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index eb4256b81406..4165a853c189 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -1090,9 +1090,9 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
if (ret)
return ret;
- eob = !!(flags & MHI_EOB);
- eot = !!(flags & MHI_EOT);
- chain = !!(flags & MHI_CHAIN);
+ eob = !!(flags & BIT(0));
+ eot = !!(flags & BIT(1));
+ chain = !!(flags & BIT(2));
bei = !!(mhi_chan->intmod);
mhi_tre = tre_ring->wp;
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index ad1996001965..22185fecbbf2 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -53,7 +53,7 @@ enum mhi_callback {
* @MHI_CHAIN: Linked transfer
*/
enum mhi_flags {
- MHI_EOB,
+ MHI_EOB = 1,
MHI_EOT,
MHI_CHAIN,
};
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] bus: mhi: core: Fix double lock of 'mhi_chan->lock'
2020-04-13 12:07 [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Manivannan Sadhasivam
@ 2020-04-13 12:07 ` Manivannan Sadhasivam
2020-04-16 19:01 ` [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Hemant Kumar
1 sibling, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2020-04-13 12:07 UTC (permalink / raw)
To: hemantk, jhugo
Cc: linux-arm-msm, linux-kernel, smohanad, dan.carpenter,
Manivannan Sadhasivam
mhi_queue_buf() will grab the 'mhi_chan->lock' for doing the doorbell
access. Hence the lock needs to be dropped before the call.
Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/bus/mhi/core/main.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index 4165a853c189..ed995137c3a0 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -538,6 +538,11 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
* from dropping the packet
*/
if (mhi_chan->pre_alloc) {
+ /*
+ * mhi_queue_buf() will grab the mhi_chan->lock
+ * so let's drop it here and grab it later
+ */
+ read_unlock_bh(&mhi_chan->lock);
if (mhi_queue_buf(mhi_chan->mhi_dev,
mhi_chan->dir,
buf_info->cb_buf,
@@ -547,6 +552,7 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
mhi_chan->chan);
kfree(buf_info->cb_buf);
}
+ read_lock_bh(&mhi_chan->lock);
}
}
break;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags
2020-04-13 12:07 [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Manivannan Sadhasivam
2020-04-13 12:07 ` [PATCH 2/2] bus: mhi: core: Fix double lock of 'mhi_chan->lock' Manivannan Sadhasivam
@ 2020-04-16 19:01 ` Hemant Kumar
2020-04-17 10:19 ` Manivannan Sadhasivam
1 sibling, 1 reply; 4+ messages in thread
From: Hemant Kumar @ 2020-04-16 19:01 UTC (permalink / raw)
To: Manivannan Sadhasivam, jhugo@codeaurora.org; dan.carpenter
Cc: linux-arm-msm, linux-kernel, smohanad, dan.carpenter
Hi Mani,
On 4/13/20 5:07 AM, Manivannan Sadhasivam wrote:
> With the current parsing of mhi_flags, the following statement always
> return false:
>
> eob = !!(flags & MHI_EOB);
>
> This is due to the fact that 'enum mhi_flags' starts with index 0 and we
> are using direct AND operation to extract each bit. Fix this by using
> BIT() macro to extract each bit and make the mhi_flags index start from 1.
>
> Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
> drivers/bus/mhi/core/main.c | 6 +++---
> include/linux/mhi.h | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> index eb4256b81406..4165a853c189 100644
> --- a/drivers/bus/mhi/core/main.c
> +++ b/drivers/bus/mhi/core/main.c
> @@ -1090,9 +1090,9 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
> if (ret)
> return ret;
>
> - eob = !!(flags & MHI_EOB);
> - eot = !!(flags & MHI_EOT);
> - chain = !!(flags & MHI_CHAIN);
> + eob = !!(flags & BIT(0));
> + eot = !!(flags & BIT(1));
> + chain = !!(flags & BIT(2));
How about setting enums with BIT macro and still use same enums above.
If flags is having MHI _CHAIN (enum value 3) but comparing with BIT(2)
(value 4) will not work.
> bei = !!(mhi_chan->intmod);
>
> mhi_tre = tre_ring->wp;
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index ad1996001965..22185fecbbf2 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -53,7 +53,7 @@ enum mhi_callback {
> * @MHI_CHAIN: Linked transfer
> */
> enum mhi_flags {
> - MHI_EOB,
> + MHI_EOB = 1,
> MHI_EOT,
> MHI_CHAIN,
> };
enum mhi_flags {
MHI_EOB = BIT(0),
MHI_EOT = BIT(1),
MHI_CHAIN = BIT(2),
}
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags
2020-04-16 19:01 ` [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Hemant Kumar
@ 2020-04-17 10:19 ` Manivannan Sadhasivam
0 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2020-04-17 10:19 UTC (permalink / raw)
To: Hemant Kumar; +Cc: jhugo, linux-arm-msm, linux-kernel, smohanad, dan.carpenter
On Thu, Apr 16, 2020 at 12:01:30PM -0700, Hemant Kumar wrote:
> Hi Mani,
>
> On 4/13/20 5:07 AM, Manivannan Sadhasivam wrote:
> > With the current parsing of mhi_flags, the following statement always
> > return false:
> >
> > eob = !!(flags & MHI_EOB);
> >
> > This is due to the fact that 'enum mhi_flags' starts with index 0 and we
> > are using direct AND operation to extract each bit. Fix this by using
> > BIT() macro to extract each bit and make the mhi_flags index start from 1.
> >
> > Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> > drivers/bus/mhi/core/main.c | 6 +++---
> > include/linux/mhi.h | 2 +-
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> > index eb4256b81406..4165a853c189 100644
> > --- a/drivers/bus/mhi/core/main.c
> > +++ b/drivers/bus/mhi/core/main.c
> > @@ -1090,9 +1090,9 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
> > if (ret)
> > return ret;
> > - eob = !!(flags & MHI_EOB);
> > - eot = !!(flags & MHI_EOT);
> > - chain = !!(flags & MHI_CHAIN);
> > + eob = !!(flags & BIT(0));
> > + eot = !!(flags & BIT(1));
> > + chain = !!(flags & BIT(2));
>
> How about setting enums with BIT macro and still use same enums above. If
> flags is having MHI _CHAIN (enum value 3) but comparing with BIT(2) (value
> 4) will not work.
>
Doh, you are right. Will fix it!
Thanks,
Mani
> > bei = !!(mhi_chan->intmod);
> > mhi_tre = tre_ring->wp;
> > diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> > index ad1996001965..22185fecbbf2 100644
> > --- a/include/linux/mhi.h
> > +++ b/include/linux/mhi.h
> > @@ -53,7 +53,7 @@ enum mhi_callback {
> > * @MHI_CHAIN: Linked transfer
> > */
> > enum mhi_flags {
> > - MHI_EOB,
> > + MHI_EOB = 1,
> > MHI_EOT,
> > MHI_CHAIN,
> > };
>
> enum mhi_flags {
>
> MHI_EOB = BIT(0),
>
> MHI_EOT = BIT(1),
>
> MHI_CHAIN = BIT(2),
>
> }
>
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-17 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 12:07 [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Manivannan Sadhasivam
2020-04-13 12:07 ` [PATCH 2/2] bus: mhi: core: Fix double lock of 'mhi_chan->lock' Manivannan Sadhasivam
2020-04-16 19:01 ` [PATCH 1/2] bus: mhi: core: Fix parsing of mhi_flags Hemant Kumar
2020-04-17 10:19 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).