All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] bus: mhi: core: Add missing checks for MMIO register entries
@ 2021-03-04 22:14 Bhaumik Bhatt
  2021-03-05 17:11 ` Loic Poulain
  0 siblings, 1 reply; 3+ messages in thread
From: Bhaumik Bhatt @ 2021-03-04 22:14 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, loic.poulain,
	carl.yin, naveen.kumar, Bhaumik Bhatt

As per documentation, fields marked as (required) in an MHI
controller structure need to be populated by the controller driver
before calling mhi_register_controller(). Ensure all required
pointers and non-zero fields are present in the controller before
proceeding with registration.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/init.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 272f350..fed8a25 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -879,10 +879,9 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,
 	u32 soc_info;
 	int ret, i;
 
-	if (!mhi_cntrl)
-		return -EINVAL;
-
-	if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
+	if (!mhi_cntrl || !mhi_cntrl->cntrl_dev || !mhi_cntrl->regs ||
+	    !mhi_cntrl->fw_image || !mhi_cntrl->irq ||
+	    !mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
 	    !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
 	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)
 		return -EINVAL;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] bus: mhi: core: Add missing checks for MMIO register entries
  2021-03-05 17:11 ` Loic Poulain
@ 2021-03-05 17:06   ` Bhaumik Bhatt
  0 siblings, 0 replies; 3+ messages in thread
From: Bhaumik Bhatt @ 2021-03-05 17:06 UTC (permalink / raw)
  To: Loic Poulain
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar

On 2021-03-05 09:11 AM, Loic Poulain wrote:
> On Thu, 4 Mar 2021 at 23:14, Bhaumik Bhatt <bbhatt@codeaurora.org> 
> wrote:
>> 
>> As per documentation, fields marked as (required) in an MHI
>> controller structure need to be populated by the controller driver
>> before calling mhi_register_controller(). Ensure all required
>> pointers and non-zero fields are present in the controller before
>> proceeding with registration.
>> 
>> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
>> ---
>>  drivers/bus/mhi/core/init.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
>> index 272f350..fed8a25 100644
>> --- a/drivers/bus/mhi/core/init.c
>> +++ b/drivers/bus/mhi/core/init.c
>> @@ -879,10 +879,9 @@ int mhi_register_controller(struct mhi_controller 
>> *mhi_cntrl,
>>         u32 soc_info;
>>         int ret, i;
>> 
>> -       if (!mhi_cntrl)
>> -               return -EINVAL;
>> -
>> -       if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
>> +       if (!mhi_cntrl || !mhi_cntrl->cntrl_dev || !mhi_cntrl->regs ||
>> +           !mhi_cntrl->fw_image || !mhi_cntrl->irq ||
> 
> Can we make fw_image optional, not all MHI devices are flashless, some
> directly boot into AMSS without firmware loading.
> 
Haha. Just as I posted this, I thought of the same thing. I agree. v3 
incoming.

Also, that patch will be a separate one so I can just remove FW image 
from here
and post the patch to make FW image optional.
>> +           !mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
>>             !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
>>             !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)
>>                 return -EINVAL;
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
>> Forum,
>> a Linux Foundation Collaborative Project
>> 

Thanks,
Bhaumik
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] bus: mhi: core: Add missing checks for MMIO register entries
  2021-03-04 22:14 [PATCH v2] bus: mhi: core: Add missing checks for MMIO register entries Bhaumik Bhatt
@ 2021-03-05 17:11 ` Loic Poulain
  2021-03-05 17:06   ` Bhaumik Bhatt
  0 siblings, 1 reply; 3+ messages in thread
From: Loic Poulain @ 2021-03-05 17:11 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar

On Thu, 4 Mar 2021 at 23:14, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> As per documentation, fields marked as (required) in an MHI
> controller structure need to be populated by the controller driver
> before calling mhi_register_controller(). Ensure all required
> pointers and non-zero fields are present in the controller before
> proceeding with registration.
>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> ---
>  drivers/bus/mhi/core/init.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 272f350..fed8a25 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -879,10 +879,9 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,
>         u32 soc_info;
>         int ret, i;
>
> -       if (!mhi_cntrl)
> -               return -EINVAL;
> -
> -       if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
> +       if (!mhi_cntrl || !mhi_cntrl->cntrl_dev || !mhi_cntrl->regs ||
> +           !mhi_cntrl->fw_image || !mhi_cntrl->irq ||

Can we make fw_image optional, not all MHI devices are flashless, some
directly boot into AMSS without firmware loading.

> +           !mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
>             !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
>             !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)
>                 return -EINVAL;
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-05 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 22:14 [PATCH v2] bus: mhi: core: Add missing checks for MMIO register entries Bhaumik Bhatt
2021-03-05 17:11 ` Loic Poulain
2021-03-05 17:06   ` Bhaumik Bhatt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.