Re: [PATCH v9 06/10] usb: dwc3: qcom: Add support to read IRQ's related to multiport

From: Krishna Kurapati PSSNV
Date: Wed Jul 12 2023 - 14:27:01 EST




On 7/12/2023 5:42 PM, Johan Hovold wrote:
On Wed, Jun 21, 2023 at 10:06:24AM +0530, Krishna Kurapati wrote:
Add support to read Multiport IRQ's related to quad port controller
of SA8295 Device.

Signed-off-by: Krishna Kurapati <quic_kriskura@xxxxxxxxxxx>
---
drivers/usb/dwc3/dwc3-qcom.c | 108 +++++++++++++++++++++++++++++------
1 file changed, 91 insertions(+), 17 deletions(-)

+static int dwc3_qcom_setup_mp_irq(struct platform_device *pdev)
+{
+ struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
+ char irq_name[15];

The interrupt device-name string can not be allocated on the stack or
reused as it is stored directly in each irqaction structure.

This can otherwise lead to random crashes when accessing
/proc/interrupts:

https://lore.kernel.org/lkml/ZK6IV_jJPICX5r53@xxxxxxxxxxxxxxxxxxxx/

Hi Johan,

Sure, will create a static array of names if possible in global section of file and use it to read interrupts.

Are you fine with seperating out setup_irq and setup_mp_irq functions ? Can you please review comments and suggestion on [1].

[1]: https://lore.kernel.org/all/bf62bdf4-cc9e-ba7b-2078-cfd60f5dd237@xxxxxxxxxxx/

Regards,
Krishna,

+ int irq;
+ int ret;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (qcom->dp_hs_phy_irq[i])
+ continue;
+
+ sprintf(irq_name, "dp%d_hs_phy_irq", i+1);
+ irq = dwc3_qcom_get_irq(pdev, irq_name, -1);
+ if (irq > 0) {
+ irq_set_status_flags(irq, IRQ_NOAUTOEN);
+ ret = devm_request_threaded_irq(qcom->dev, irq, NULL,
+ qcom_dwc3_resume_irq,
+ IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+ irq_name, qcom);
+ if (ret) {
+ dev_err(qcom->dev, "%s failed: %d\n", irq_name, ret);
+ return ret;
+ }
+ }
+
+ qcom->dp_hs_phy_irq[i] = irq;
+ }

Johan