Skip to contentSkip to conversation

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

PATCH Applied Loic Poulain 3 participants 7 messages Sep 21, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 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.

---
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(-)
drivers/bus/mhi/core/init.c +7 -0
index 19ade8a..31961af 100644
@@ -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,
drivers/bus/mhi/core/pm.c +1 -1
index ce4d969..3de7b16 100644
@@ -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 */
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/2 bus: mhi: Remove unused nr_irqs_req variable

nr_irqs_req is unused in MHI stack.

---
v2: add this patch to the series

 drivers/bus/mhi/core/init.c | 3 ---
 include/linux/mhi.h         | 2 --
 2 files changed, 5 deletions(-)
drivers/bus/mhi/core/init.c +0 -3
index 31961af..8798deb 100644
@@ -643,9 +643,6 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
 		mhi_event++;
 	}
 
-	/* We need IRQ for each event ring + additional one for BHI */
-	mhi_cntrl->nr_irqs_req = mhi_cntrl->total_ev_rings + 1;
-
 	return 0;
 
 error_ev_cfg:
include/linux/mhi.h +0 -2
index 742dabe..0d277c7 100644
@@ -309,7 +309,6 @@ struct mhi_controller_config {
  * @total_ev_rings: Total # of event rings allocated
  * @hw_ev_rings: Number of hardware event rings
  * @sw_ev_rings: Number of software event rings
- * @nr_irqs_req: Number of IRQs required to operate (optional)
  * @nr_irqs: Number of IRQ allocated by bus master (required)
  * @family_number: MHI controller family number
  * @device_number: MHI controller device number
@@ -389,7 +388,6 @@ struct mhi_controller {
 	u32 total_ev_rings;
 	u32 hw_ev_rings;
 	u32 sw_ev_rings;
-	u32 nr_irqs_req;
 	u32 nr_irqs;
 	u32 family_number;
 	u32 device_number;
Signature · 1 line
2.7.4
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] bus: mhi: Remove unused nr_irqs_req variable

Quoted 3 lines · Loic Poulain

nr_irqs_req is unused in MHI stack.

Thanks,
Mani

Quoted 44 lines

---
v2: add this patch to the series

 drivers/bus/mhi/core/init.c | 3 ---
 include/linux/mhi.h         | 2 --
 2 files changed, 5 deletions(-)
drivers/bus/mhi/core/init.c +0 -3
index 31961af..8798deb 100644
@@ -643,9 +643,6 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
 		mhi_event++;
 	}
 
-	/* We need IRQ for each event ring + additional one for BHI */
-	mhi_cntrl->nr_irqs_req = mhi_cntrl->total_ev_rings + 1;
-
 	return 0;
 
 error_ev_cfg:
include/linux/mhi.h +0 -2
index 742dabe..0d277c7 100644
@@ -309,7 +309,6 @@ struct mhi_controller_config {
  * @total_ev_rings: Total # of event rings allocated
  * @hw_ev_rings: Number of hardware event rings
  * @sw_ev_rings: Number of software event rings
- * @nr_irqs_req: Number of IRQs required to operate (optional)
  * @nr_irqs: Number of IRQ allocated by bus master (required)
  * @family_number: MHI controller family number
  * @device_number: MHI controller device number
@@ -389,7 +388,6 @@ struct mhi_controller {
 	u32 total_ev_rings;
 	u32 hw_ev_rings;
 	u32 sw_ev_rings;
-	u32 nr_irqs_req;
 	u32 nr_irqs;
 	u32 family_number;
 	u32 device_number;
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v2 2/2] bus: mhi: Remove unused nr_irqs_req variable

In reply to Loic Poulain
Quoted 3 lines · Loic Poulain

nr_irqs_req is unused in MHI stack.

Applied to mhi-next!

Thanks,
Mani

Quoted 44 lines

---
v2: add this patch to the series

 drivers/bus/mhi/core/init.c | 3 ---
 include/linux/mhi.h         | 2 --
 2 files changed, 5 deletions(-)
drivers/bus/mhi/core/init.c +0 -3
index 31961af..8798deb 100644
@@ -643,9 +643,6 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
 		mhi_event++;
 	}
 
-	/* We need IRQ for each event ring + additional one for BHI */
-	mhi_cntrl->nr_irqs_req = mhi_cntrl->total_ev_rings + 1;
-
 	return 0;
 
 error_ev_cfg:
include/linux/mhi.h +0 -2
index 742dabe..0d277c7 100644
@@ -309,7 +309,6 @@ struct mhi_controller_config {
  * @total_ev_rings: Total # of event rings allocated
  * @hw_ev_rings: Number of hardware event rings
  * @sw_ev_rings: Number of software event rings
- * @nr_irqs_req: Number of IRQs required to operate (optional)
  * @nr_irqs: Number of IRQ allocated by bus master (required)
  * @family_number: MHI controller family number
  * @device_number: MHI controller device number
@@ -389,7 +388,6 @@ struct mhi_controller {
 	u32 total_ev_rings;
 	u32 hw_ev_rings;
 	u32 sw_ev_rings;
-	u32 nr_irqs_req;
 	u32 nr_irqs;
 	u32 family_number;
 	u32 device_number;
Signature · 1 line
2.7.4
Reviewed-by on v2 1/2
#4 lore raw
In reply to Loic Poulain
Quoted 9 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.

Thanks,
Mani

Quoted 41 lines

---
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(-)
drivers/bus/mhi/core/init.c +7 -0
index 19ade8a..31961af 100644
@@ -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,
drivers/bus/mhi/core/pm.c +1 -1
index ce4d969..3de7b16 100644
@@ -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 */
Signature · 1 line
2.7.4
#5 lore raw
In reply to Loic Poulain
Quoted 9 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.

Applied to mhi-next!

Thanks,
Mani

Quoted 41 lines

---
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(-)
drivers/bus/mhi/core/init.c +7 -0
index 19ade8a..31961af 100644
@@ -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,
drivers/bus/mhi/core/pm.c +1 -1
index ce4d969..3de7b16 100644
@@ -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 */
Signature · 1 line
2.7.4
#6 lore raw
In reply to Loic Poulain
Quoted 48 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.

---
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(-)
drivers/bus/mhi/core/init.c +7 -0
index 19ade8a..31961af 100644
@@ -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,
drivers/bus/mhi/core/init.c +0 -0
 				  IRQF_SHARED | IRQF_NO_SUSPEND,
drivers/bus/mhi/core/pm.c +1 -1
index ce4d969..3de7b16 100644
@@ -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;
 
Quoted 2 lines

/* 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