diff mbox series

[v2,1/2] bus: mhi: core: Allow shared IRQ for event rings

Message ID 1600673819-1698-1-git-send-email-loic.poulain@linaro.org
State New
Headers show
Series [v2,1/2] bus: mhi: core: Allow shared IRQ for event rings | expand

Commit Message

Loic Poulain Sept. 21, 2020, 7:36 a.m. UTC
There is no requirement for using a dedicated IRQ per event ring.
Some systems does not support multiple MSI vectors (e.g. intel
without CONFIG_IRQ_REMAP), In that case the MHI controller can
configure all the event rings to use the same interrupt (as fallback).

Allow this by removing the nr_irqs = ev_ring test and add extra check
in the irq_setup function.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 v2: keep nr_irqs check early in init sequence

 drivers/bus/mhi/core/init.c | 7 +++++++
 drivers/bus/mhi/core/pm.c   | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Manivannan Sadhasivam Sept. 21, 2020, 2:22 p.m. UTC | #1
On Mon, Sep 21, 2020 at 09:36:58AM +0200, Loic Poulain wrote:
> There is no requirement for using a dedicated IRQ per event ring.

> Some systems does not support multiple MSI vectors (e.g. intel

> without CONFIG_IRQ_REMAP), In that case the MHI controller can

> configure all the event rings to use the same interrupt (as fallback).

> 

> Allow this by removing the nr_irqs = ev_ring test and add extra check

> in the irq_setup function.

> 

> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>


Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>


Thanks,
Mani

> ---

>  v2: keep nr_irqs check early in init sequence

> 

>  drivers/bus/mhi/core/init.c | 7 +++++++

>  drivers/bus/mhi/core/pm.c   | 2 +-

>  2 files changed, 8 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c

> index 19ade8a..31961af 100644

> --- a/drivers/bus/mhi/core/init.c

> +++ b/drivers/bus/mhi/core/init.c

> @@ -125,6 +125,13 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl)

>  		if (mhi_event->offload_ev)

>  			continue;

>  

> +		if (mhi_event->irq >= mhi_cntrl->nr_irqs) {

> +			dev_err(dev, "irq %d not available for event ring\n",

> +				mhi_event->irq);

> +			ret = -EINVAL;

> +			goto error_request;

> +		}

> +

>  		ret = request_irq(mhi_cntrl->irq[mhi_event->irq],

>  				  mhi_irq_handler,

>  				  IRQF_SHARED | IRQF_NO_SUSPEND,

> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c

> index ce4d969..3de7b16 100644

> --- a/drivers/bus/mhi/core/pm.c

> +++ b/drivers/bus/mhi/core/pm.c

> @@ -918,7 +918,7 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)

>  

>  	dev_info(dev, "Requested to power ON\n");

>  

> -	if (mhi_cntrl->nr_irqs < mhi_cntrl->total_ev_rings)

> +	if (mhi_cntrl->nr_irqs < 1)

>  		return -EINVAL;

>  

>  	/* Supply default wake routines if not provided by controller driver */

> -- 

> 2.7.4

>
Manivannan Sadhasivam Sept. 21, 2020, 3:40 p.m. UTC | #2
On Mon, Sep 21, 2020 at 09:36:58AM +0200, Loic Poulain wrote:
> There is no requirement for using a dedicated IRQ per event ring.

> Some systems does not support multiple MSI vectors (e.g. intel

> without CONFIG_IRQ_REMAP), In that case the MHI controller can

> configure all the event rings to use the same interrupt (as fallback).

> 

> Allow this by removing the nr_irqs = ev_ring test and add extra check

> in the irq_setup function.

> 

> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>


Applied to mhi-next!

Thanks,
Mani

> ---

>  v2: keep nr_irqs check early in init sequence

> 

>  drivers/bus/mhi/core/init.c | 7 +++++++

>  drivers/bus/mhi/core/pm.c   | 2 +-

>  2 files changed, 8 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c

> index 19ade8a..31961af 100644

> --- a/drivers/bus/mhi/core/init.c

> +++ b/drivers/bus/mhi/core/init.c

> @@ -125,6 +125,13 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl)

>  		if (mhi_event->offload_ev)

>  			continue;

>  

> +		if (mhi_event->irq >= mhi_cntrl->nr_irqs) {

> +			dev_err(dev, "irq %d not available for event ring\n",

> +				mhi_event->irq);

> +			ret = -EINVAL;

> +			goto error_request;

> +		}

> +

>  		ret = request_irq(mhi_cntrl->irq[mhi_event->irq],

>  				  mhi_irq_handler,

>  				  IRQF_SHARED | IRQF_NO_SUSPEND,

> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c

> index ce4d969..3de7b16 100644

> --- a/drivers/bus/mhi/core/pm.c

> +++ b/drivers/bus/mhi/core/pm.c

> @@ -918,7 +918,7 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)

>  

>  	dev_info(dev, "Requested to power ON\n");

>  

> -	if (mhi_cntrl->nr_irqs < mhi_cntrl->total_ev_rings)

> +	if (mhi_cntrl->nr_irqs < 1)

>  		return -EINVAL;

>  

>  	/* Supply default wake routines if not provided by controller driver */

> -- 

> 2.7.4

>
Bhaumik Bhatt Sept. 21, 2020, 5:06 p.m. UTC | #3
On 2020-09-21 00:36, Loic Poulain wrote:
> There is no requirement for using a dedicated IRQ per event ring.

> Some systems does not support multiple MSI vectors (e.g. intel

> without CONFIG_IRQ_REMAP), In that case the MHI controller can

> configure all the event rings to use the same interrupt (as fallback).

> 

> Allow this by removing the nr_irqs = ev_ring test and add extra check

> in the irq_setup function.

> 

> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

> ---

>  v2: keep nr_irqs check early in init sequence

> 

>  drivers/bus/mhi/core/init.c | 7 +++++++

>  drivers/bus/mhi/core/pm.c   | 2 +-

>  2 files changed, 8 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c

> index 19ade8a..31961af 100644

> --- a/drivers/bus/mhi/core/init.c

> +++ b/drivers/bus/mhi/core/init.c

> @@ -125,6 +125,13 @@ int mhi_init_irq_setup(struct mhi_controller 

> *mhi_cntrl)

>  		if (mhi_event->offload_ev)

>  			continue;

> 

> +		if (mhi_event->irq >= mhi_cntrl->nr_irqs) {

> +			dev_err(dev, "irq %d not available for event ring\n",

> +				mhi_event->irq);

> +			ret = -EINVAL;

> +			goto error_request;

> +		}

> +

>  		ret = request_irq(mhi_cntrl->irq[mhi_event->irq],

>  				  mhi_irq_handler,

>  				  IRQF_SHARED | IRQF_NO_SUSPEND,

> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c

> index ce4d969..3de7b16 100644

> --- a/drivers/bus/mhi/core/pm.c

> +++ b/drivers/bus/mhi/core/pm.c

> @@ -918,7 +918,7 @@ int mhi_async_power_up(struct mhi_controller 

> *mhi_cntrl)

> 

>  	dev_info(dev, "Requested to power ON\n");

> 

> -	if (mhi_cntrl->nr_irqs < mhi_cntrl->total_ev_rings)

> +	if (mhi_cntrl->nr_irqs < 1)

>  		return -EINVAL;

> 

>  	/* Supply default wake routines if not provided by controller driver 

> */

It would be better if we can remove this check altogether from the 
mhi_async_power_up()
function and instead place it as one of the checks in 
mhi_register_controller() in init.c.

That way, we don't have to wait until power up attempt to determine 
whether the provided
controller configuration is acceptable and can bail out early from the
mhi_register_controller() function itself.

if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
     !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
-    !mhi_cntrl->write_reg)
+    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)

Thanks,
Bhaumik
diff mbox series

Patch

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 19ade8a..31961af 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -125,6 +125,13 @@  int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl)
 		if (mhi_event->offload_ev)
 			continue;
 
+		if (mhi_event->irq >= mhi_cntrl->nr_irqs) {
+			dev_err(dev, "irq %d not available for event ring\n",
+				mhi_event->irq);
+			ret = -EINVAL;
+			goto error_request;
+		}
+
 		ret = request_irq(mhi_cntrl->irq[mhi_event->irq],
 				  mhi_irq_handler,
 				  IRQF_SHARED | IRQF_NO_SUSPEND,
diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index ce4d969..3de7b16 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -918,7 +918,7 @@  int mhi_async_power_up(struct mhi_controller *mhi_cntrl)
 
 	dev_info(dev, "Requested to power ON\n");
 
-	if (mhi_cntrl->nr_irqs < mhi_cntrl->total_ev_rings)
+	if (mhi_cntrl->nr_irqs < 1)
 		return -EINVAL;
 
 	/* Supply default wake routines if not provided by controller driver */