Re: [PATCH v17 7/9] usb: dwc3: qcom: Refactor IRQ handling in glue driver

From: Johan Hovold
Date: Tue Mar 26 2024 - 06:44:08 EST


On Tue, Mar 26, 2024 at 03:58:07PM +0530, Krishna Kurapati wrote:
> On multiport supported controllers, each port has its own DP/DM
> and SS (if super speed capable) interrupts. As per the bindings,
> their interrupt names differ from standard ones having "_x" added
> as suffix (x indicates port number). Identify from the interrupt
> names whether the controller is a multiport controller or not.
> Refactor dwc3_qcom_setup_irq() call to parse multiport interrupts
> along with non-multiport ones accordingly..
>
> Signed-off-by: Krishna Kurapati <quic_kriskura@xxxxxxxxxxx>
> Reviewed-by: Johan Hovold <johan+linaro@xxxxxxxxxx>
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 137 ++++++++++++++++++++++++++---------
> 1 file changed, 103 insertions(+), 34 deletions(-)

> -static int dwc3_qcom_setup_irq(struct platform_device *pdev)
> +static int dwc3_qcom_setup_port_irq(struct platform_device *pdev, int port_num, bool is_multiport)

Here you use "port_num", when it's really a (zero-based) port index.

Please change to "port_index".

> {
> struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
> + const char *irq_name;
> int irq;
> int ret;
>
> - irq = platform_get_irq_byname_optional(pdev, "qusb2_phy");
> + if (is_multiport)
> + irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "dp_hs_phy_%d", port_num + 1);
> + else
> + irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "dp_hs_phy_irq");
> + if (!irq_name)
> + return -ENOMEM;

> +static int dwc3_qcom_find_num_ports(struct platform_device *pdev)
> +{
> + char irq_name[14];
> + int port_index;
> + int irq;
> +
> + irq = platform_get_irq_byname_optional(pdev, "dp_hs_phy_1");
> + if (irq <= 0)
> + return 1;
> +
> + for (port_index = 2; port_index <= DWC3_MAX_PORTS; port_index++) {

And here you use port_index, when it's really a one-based port number.

I explicitly used "port" when we discussed the update here for this
reason ("port_num" works too).

Please fix this last thing in a v18 and we're good to go.

> + sprintf(irq_name, "dp_hs_phy_%d", port_index);
> +
> + irq = platform_get_irq_byname_optional(pdev, irq_name);
> + if (irq <= 0)
> + return port_index - 1;
> + }
> +
> + return DWC3_MAX_PORTS;
> +}

Johan