Skip to contentSkip to conversation

bus: mhi: core: Allow shared IRQ for event rings

PATCH Superseded Loic Poulain 2 participants 3 messages Sep 18, 2020 – Sep 21, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: mhi: core: Allow shared IRQ for event rings

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.

---
 drivers/bus/mhi/core/init.c | 10 ++++++++++
 drivers/bus/mhi/core/pm.c   |  3 ---
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/bus/mhi/core/init.c +10 -0
index d232938..ac19067 100644
@@ -113,6 +113,9 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl)
 	struct device *dev = &mhi_cntrl->mhi_dev->dev;
 	int i, ret;
 
+	if (mhi_cntrl->nr_irqs < 1)
+		return -EINVAL;
+
 	/* Setup BHI_INTVEC IRQ */
 	ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handler,
 				   mhi_intvec_threaded_handler,
@@ -125,6 +128,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,
drivers/bus/mhi/core/pm.c +0 -3
index ce4d969..07efdbc 100644
@@ -918,9 +918,6 @@ 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)
-		return -EINVAL;
-
 	/* Supply default wake routines if not provided by controller driver */
 	if (!mhi_cntrl->wake_get || !mhi_cntrl->wake_put ||
 	    !mhi_cntrl->wake_toggle) {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 19 lines · Loic Poulain

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.

---
 drivers/bus/mhi/core/init.c | 10 ++++++++++
 drivers/bus/mhi/core/pm.c   |  3 ---
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/bus/mhi/core/init.c +0 -0
index d232938..ac19067 100644

drivers/bus/mhi/core/init.c int mhi_init_irq_setup(struct mhi_controller · line 119

Quoted 7 lines
drivers/bus/mhi/core/init.c +3 -0
@@ -113,6 +113,9 @@ int mhi_init_irq_setup(struct mhi_controller 
 *mhi_cntrl)
 	struct device *dev = &mhi_cntrl->mhi_dev->dev;
 	int i, ret;
 
+	if (mhi_cntrl->nr_irqs < 1)
+		return -EINVAL;
+

It would be better to move this check earlier in mhi_register_controller() because if the resource is not available, we do not have to proceed to even allow power up.

Quoted 32 lines
drivers/bus/mhi/core/init.c +0 -0
 	/* Setup BHI_INTVEC IRQ */
 	ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handler,
drivers/bus/mhi/core/init.c +7 -0
 				   mhi_intvec_threaded_handler,
@@ -125,6 +128,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,
drivers/bus/mhi/core/init.c +0 -0
 				  IRQF_SHARED | IRQF_NO_SUSPEND,
drivers/bus/mhi/core/pm.c +0 -3
index ce4d969..07efdbc 100644
@@ -918,9 +918,6 @@ 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)
-		return -EINVAL;
-
 	/* Supply default wake routines if not provided by controller driver 
 */

drivers/bus/mhi/core/pm.c int mhi_async_power_up(struct mhi_controller *mhi_cntrl) · line 923

Quoted 2 lines
drivers/bus/mhi/core/pm.c +0 -0
 	if (!mhi_cntrl->wake_get || !mhi_cntrl->wake_put ||
 	    !mhi_cntrl->wake_toggle) {

Maybe another clean-up patch is also good to remove usage of "mhi_cntrl->nr_irqs_req" as it is deemed optional anyway and is unused in the driver.

Thanks,
Bhaumik

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

#2 lore raw

Hi Bhaumik,

Quoted 25 lines · On Sat, 19 Sep 2020 at 04:43, <[email protected]> wrote:
Quoted 23 lines · Loic Poulain

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.

---
 drivers/bus/mhi/core/init.c | 10 ++++++++++
 drivers/bus/mhi/core/pm.c   |  3 ---
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/bus/mhi/core/init.c +0 -0
index d232938..ac19067 100644
@@ -113,6 +113,9 @@ int mhi_init_irq_setup(struct mhi_controller
 *mhi_cntrl)
      struct device *dev = &mhi_cntrl->mhi_dev->dev;
      int i, ret;
 
Quoted 8 lines

drivers/bus/mhi/core/init.c int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) · line 118

Quoted 3 lines
drivers/bus/mhi/core/init.c +3 -0
+     if (mhi_cntrl->nr_irqs < 1)
+             return -EINVAL;
+

It would be better to move this check earlier in mhi_register_controller() because if
the resource is not available, we do not have to proceed to even allow power up.

Ok, will do in V2.

Quoted 29 lines
Quoted 29 lines
drivers/bus/mhi/core/init.c +0 -0
      /* Setup BHI_INTVEC IRQ */
      ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handler,

mhi_intvec_threaded_handler,

drivers/bus/mhi/core/init.c +7 -0
@@ -125,6 +128,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,

drivers/bus/mhi/core/pm.c +0 -0
index ce4d969..07efdbc 100644
@@ -918,9 +918,6 @@ int mhi_async_power_up(struct mhi_controller
 *mhi_cntrl)
 
      dev_info(dev, "Requested to power ON\n");
 
Quoted 11 lines
Quoted 7 lines
drivers/bus/mhi/core/pm.c +0 -3
-     if (mhi_cntrl->nr_irqs < mhi_cntrl->total_ev_rings)
-             return -EINVAL;
-
      /* Supply default wake routines if not provided by controller driver
 */
      if (!mhi_cntrl->wake_get || !mhi_cntrl->wake_put ||
          !mhi_cntrl->wake_toggle) {

Maybe another clean-up patch is also good to remove usage of "mhi_cntrl->nr_irqs_req"
as it is deemed optional anyway and is unused in the driver.

OK, I'll submit an additional patch for that.

Regards,
Loic