mhi: use irq_flags if client driver configures it
Subsystems (2)
PATCH 1/1 mhi: use irq_flags if client driver configures it
If client driver has specified the irq_flags, mhi uses this specified irq_flags. Otherwise, mhi uses default irq_flags.
The purpose of this change is to support one MSI vector for QCA6390. MHI will use one same MSI vector too in this scenario.
In case of one MSI vector, IRQ_NO_BALANCING is needed when irq handler is requested. The reason is if irq migration happens, the msi_data may change too. However, the msi_data is already programmed to QCA6390 hardware during initialization phase. This msi_data inconsistence will result in crash in kernel.
Another issue is in case of one MSI vector, IRQF_NO_SUSPEND will trigger WARNINGS because QCA6390 wants to disable the IRQ during the suspend.
To avoid above two issues, QCA6390 driver specifies the irq_flags in case of one MSI vector when mhi_register_controller is called.
--- drivers/bus/mhi/core/init.c | 9 +++++++-- include/linux/mhi.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/bus/mhi/core/init.c +7 -2
@@ -148,12 +148,17 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) {struct mhi_event *mhi_event = mhi_cntrl->mhi_event;struct device *dev = &mhi_cntrl->mhi_dev->dev; +unsigned long irq_flags =IRQF_SHARED |IRQF_NO_SUSPEND ;int i, ret; +/* if client driver has set irq_flags, use it */ +if (mhi_cntrl->irq_flags) + irq_flags = mhi_cntrl->irq_flags; +/* Setup BHI_INTVEC IRQ */ ret =request_threaded_irq (mhi_cntrl->irq[0 ], mhi_intvec_handler, mhi_intvec_threaded_handler, -IRQF_SHARED |IRQF_NO_SUSPEND , + irq_flags,"bhi" , mhi_cntrl);if (ret)return ret;
@@ -171,7 +176,7 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) ret =request_irq (mhi_cntrl->irq[mhi_event->irq], mhi_irq_handler, -IRQF_SHARED |IRQF_NO_SUSPEND , + irq_flags,"mhi" , mhi_event);if (ret) { dev_err(dev, "Error requesting irq:%d for ev:%d\n",
include/linux/mhi.h +1 -0
@@ -442,6 +442,7 @@ struct mhi_controller {bool fbc_download;bool pre_init;bool wake_set; +unsigned long irq_flags; };/**
Signature · 1 line
2.7.4
Quoted 29 lines · Carl Huang
If client driver has specified the
irq_flags, mhi uses this specifiedirq_flags. Otherwise, mhi uses defaultirq_flags.The purpose of this change is to support one MSI vector for QCA6390. MHI will use one same MSI vector too in this scenario.
In case of one MSI vector,
IRQ_NO_BALANCINGis needed when irq handler is requested. The reason is if irq migration happens, themsi_datamay change too. However, themsi_datais already programmed to QCA6390 hardware during initialization phase. Thismsi_datainconsistence will result in crash in kernel.Another issue is in case of one MSI vector,
IRQF_NO_SUSPENDwill trigger WARNINGS because QCA6390 wants to disable the IRQ during the suspend.To avoid above two issues, QCA6390 driver specifies the
irq_flagsin case of one MSI vector whenmhi_register_controlleris called.Signed-off-by Carl Huang <[email protected]>--- drivers/bus/mhi/core/init.c | 9 +++++++-- include/linux/mhi.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-)drivers/bus/mhi/core/init.c +0
-0
drivers/bus/mhi/core/init.c int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) · line 156
Quoted 9 lines
drivers/bus/mhi/core/init.c +4
-0@@ -148,12 +148,17 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) {struct mhi_event *mhi_event = mhi_cntrl->mhi_event;struct device *dev = &mhi_cntrl->mhi_dev->dev; +unsigned long irq_flags =IRQF_SHARED |IRQF_NO_SUSPEND ;int i, ret; +/* if client driver has set irq_flags, use it */ +if (mhi_cntrl->irq_flags) + irq_flags = mhi_cntrl->irq_flags;
Jeff if i remember correctly your use case also have one dedicated irq line for all the MSIs, just want to confirm if you are fine with this change ? i was wondering if any input check is required for irq_flags passed by controller, or responsibility is on controller for any undesired behavior. Like passing IRQF_SHARED and IRQF_ONESHOT when one irq line is shared among multiple MSIs.
Quoted 24 lines
drivers/bus/mhi/core/init.c +3
-2+/* Setup BHI_INTVEC IRQ */ ret =request_threaded_irq (mhi_cntrl->irq[0 ], mhi_intvec_handler, mhi_intvec_threaded_handler, -IRQF_SHARED |IRQF_NO_SUSPEND , + irq_flags,"bhi" , mhi_cntrl);if (ret)return ret;@@ -171,7 +176,7 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) ret =request_irq (mhi_cntrl->irq[mhi_event->irq], mhi_irq_handler, -IRQF_SHARED |IRQF_NO_SUSPEND , + irq_flags,"mhi" , mhi_event);if (ret) { dev_err(dev, "Error requesting irq:%d for ev:%d\n",include/linux/mhi.h +0
-0
include/linux/mhi.h struct mhi_controller { · line 448
Quoted 7 lines
include/linux/mhi.h +1
-0@@ -442,6 +442,7 @@ struct mhi_controller {bool fbc_download;bool pre_init;bool wake_set; +unsigned long irq_flags; };/**
Thanks,
Hemant
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 6 lines · Hemant Kumar
Quoted 3 lines · Carl Huang
If client driver has specified the
irq_flags, mhi uses this specifiedirq_flags. Otherwise, mhi uses defaultirq_flags.
Quoted 8 lines
Quoted 8 lines
The purpose of this change is to support one MSI vector for QCA6390. MHI will use one same MSI vector too in this scenario.
In case of one MSI vector,
IRQ_NO_BALANCINGis needed when irq handler is requested. The reason is if irq migration happens, themsi_datamay change too. However, themsi_datais already programmed to QCA6390 hardware during initialization phase. Thismsi_datainconsistence will result in crash in kernel.
I'm confused as to how this happens.
Quoted 6 lines
Quoted 6 lines
Another issue is in case of one MSI vector,
IRQF_NO_SUSPENDwill trigger WARNINGS because QCA6390 wants to disable the IRQ during the suspend.To avoid above two issues, QCA6390 driver specifies the
irq_flagsin case of one MSI vector whenmhi_register_controlleris called.
Surely this change should be in a series where there is a following change which updates the QCA6390 driver?
Quoted 7 lines
Quoted 7 lines
Signed-off-by Carl Huang <[email protected]>---
drivers/bus/mhi/core/init.c| 9 +++++++--
include/linux/mhi.h | 1 +2 files changed, 8 insertions(+), 2 deletions(-)
Quoted 15 lines
Quoted 5 lines
drivers/bus/mhi/core/init.c +0
-0drivers/bus/mhi/core/init.c int mhi_init_irq_setup(struct mhi_controller · line 156
Quoted 9 lines
drivers/bus/mhi/core/init.c +4
-0@@ -148,12 +148,17 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) { struct mhi_event *mhi_event = mhi_cntrl->mhi_event; struct device *dev = &mhi_cntrl->mhi_dev->dev; + unsigned long irq_flags = IRQF_SHARED | IRQF_NO_SUSPEND; int i, ret; + /* if client driver has set irq_flags, use it */ + if (mhi_cntrl->irq_flags) + irq_flags = mhi_cntrl->irq_flags;Jeff if i remember correctly your use case also have one dedicated irq line for all the MSIs, just want to confirm if you are fine with this change ? i was wondering if any input check is required for
irq_flagspassed by controller, or responsibility is on controller for any undesired behavior. Like passingIRQF_SHAREDandIRQF_ONESHOTwhen one irq line is shared among multiple MSIs.
This feels a bit weird to me, but I don't think it'll cause a problem.
If we are allowing the controller to specify flags, should they be in a per irq manner?
Quoted 19 lines
Quoted 19 lines
drivers/bus/mhi/core/init.c +3
-2+ /* Setup BHI_INTVEC IRQ */ ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handler, mhi_intvec_threaded_handler, - IRQF_SHARED | IRQF_NO_SUSPEND, + irq_flags, "bhi", mhi_cntrl); if (ret) return ret;@@ -171,7 +176,7 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) ret = request_irq(mhi_cntrl->irq[mhi_event->irq], mhi_irq_handler, - IRQF_SHARED | IRQF_NO_SUSPEND, + irq_flags, "mhi", mhi_event); if (ret) { dev_err(dev, "Error requesting irq:%d for ev:%d\n",include/linux/mhi.h +0
-0
Quoted 8 lines
include/linux/mhi.h struct mhi_controller { · line 445
Quoted 8 lines
index d4841e5..f039e58 100644
include/linux/mhi.h +1
-0@@ -442,6 +442,7 @@ struct mhi_controller { bool fbc_download; bool pre_init; bool wake_set; + unsigned long irq_flags;
You don't document this. That gets a NACK from me.
Quoted 7 lines
include/linux/mhi.h struct mhi_controller { · line 448
Quoted 3 lines
include/linux/mhi.h +0
-0}; /**Thanks,
Hemant
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 10 lines · Jeffrey Hugo
Quoted 9 lines · Hemant Kumar
Quoted 6 lines · Carl Huang
If client driver has specified the
irq_flags, mhi uses this specifiedirq_flags. Otherwise, mhi uses defaultirq_flags.The purpose of this change is to support one MSI vector for QCA6390. MHI will use one same MSI vector too in this scenario.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
In case of one MSI vector,
IRQ_NO_BALANCINGis needed when irq handler is requested. The reason is if irq migration happens, themsi_datamay change too. However, themsi_datais already programmed to QCA6390 hardware during initialization phase. Thismsi_datainconsistence will result in crash in kernel.I'm confused as to how this happens.
Host needs to program msi_data to QCA6390 hardware components(lots of standard rings), and this msi_data is used to generate MSI interrupt. If kernel has re-assigned msi_data to QCA6390 when irq migration happens, and this re-assigned msi_data is written to QCA6390 PCIe config space only, standard rings still use previous msi_data.
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Another issue is in case of one MSI vector,
IRQF_NO_SUSPENDwill trigger WARNINGS because QCA6390 wants to disable the IRQ during the suspend.To avoid above two issues, QCA6390 driver specifies the
irq_flagsin case of one MSI vector whenmhi_register_controlleris called.Surely this change should be in a series where there is a following change which updates the QCA6390 driver?
Yes. This patch involves MHI module, so send it separately. There is another patch set for QCA6390 to support one MSI vector.
Quoted 23 lines
Quoted 7 lines
Quoted 7 lines
Signed-off-by Carl Huang <[email protected]>---
drivers/bus/mhi/core/init.c| 9 +++++++--
include/linux/mhi.h | 1 +2 files changed, 8 insertions(+), 2 deletions(-)Quoted 15 lines
Quoted 5 lines
drivers/bus/mhi/core/init.c +0
-0drivers/bus/mhi/core/init.c int mhi_init_irq_setup(struct mhi_controller · line 156
Quoted 9 lines
drivers/bus/mhi/core/init.c +4
-0@@ -148,12 +148,17 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) { struct mhi_event *mhi_event = mhi_cntrl->mhi_event; struct device *dev = &mhi_cntrl->mhi_dev->dev; + unsigned long irq_flags = IRQF_SHARED | IRQF_NO_SUSPEND; int i, ret; + /* if client driver has set irq_flags, use it */ + if (mhi_cntrl->irq_flags) + irq_flags = mhi_cntrl->irq_flags;Jeff if i remember correctly your use case also have one dedicated irq line for all the MSIs, just want to confirm if you are fine with this change ? i was wondering if any input check is required for
irq_flagspassed by controller, or responsibility is on controller for any undesired behavior. Like passingIRQF_SHAREDandIRQF_ONESHOTwhen one irq line is shared among multiple MSIs.
Quoted 5 lines
This feels a bit weird to me, but I don't think it'll cause a problem.
If we are allowing the controller to specify flags, should they be in a per irq manner?
Not sure if per irq manner is needed for others, but ath11k doesn't need per irq manner.
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/bus/mhi/core/init.c +3
-2+ /* Setup BHI_INTVEC IRQ */ ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handler, mhi_intvec_threaded_handler, - IRQF_SHARED | IRQF_NO_SUSPEND, + irq_flags, "bhi", mhi_cntrl); if (ret) return ret;@@ -171,7 +176,7 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) ret = request_irq(mhi_cntrl->irq[mhi_event->irq], mhi_irq_handler, - IRQF_SHARED | IRQF_NO_SUSPEND, + irq_flags, "mhi", mhi_event); if (ret) { dev_err(dev, "Error requesting irq:%d for ev:%d\n",include/linux/mhi.h +0
-1--- a/include/linux/mhi.h
Quoted 9 lines
Quoted 6 lines
include/linux/mhi.h struct mhi_controller { · line 445
Quoted 6 lines
+++
b/include/linux/mhi.hinclude/linux/mhi.h +1
-0@@ -442,6 +442,7 @@ struct mhi_controller { bool fbc_download; bool pre_init; bool wake_set; + unsigned long irq_flags;You don't document this. That gets a NACK from me.
Yes, will document this field in V2.
Quoted 7 lines
Quoted 7 lines
include/linux/mhi.h struct mhi_controller { · line 448
Quoted 3 lines
include/linux/mhi.h +0
-0}; /**Thanks,
Hemant