mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@oss.qualcomm.com>
To: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3] usb: dwc3: qcom: Restore DP/DM wake IRQ trigger types on unbind
Date: Sun, 29 Nov 2026 19:02:50 -0800	[thread overview]
Message-ID: <awznWmBhOT9QL8-n@hu-petche-lv.qualcomm.com> (raw)
In-Reply-To: <20261127050938.2150497-1-felipe.infante.de.castro@gmail.com>

On 26-11-27 00:09:38, Felipe Infante de Castro wrote:
> On suspend, dwc3_qcom_enable_wakeup_irq() sets the DP and DM high-speed
> PHY interrupts to a single edge, chosen from the speed of the attached
> device. The IRQ mapping outlives the driver, so after an unbind the
> mapping keeps that single-edge type.
> 
> On the next probe the interrupt is looked up again from the device tree,
> which describes it as IRQ_TYPE_EDGE_BOTH. The lookup fails with a
> trigger type mismatch against the existing mapping. Because the wake
> interrupts are optional, probe still succeeds, but without the DP/DM
> wake handlers, and USB wakeup is lost until the next boot.
> 
> Record the trigger type of each DP/DM interrupt when it is requested and
> restore it from a devres action. The action is registered after the
> interrupts, so it runs while the driver still owns them. Unmapped
> interrupts, unspecified types and types that already match are left
> alone.
> 
> Seen on a Microsoft Surface Laptop 7 (x1e80100-microsoft-romulus15) on a
> 7.3 kernel: after unbinding and rebinding a controller the dp_hs_phy_irq
> and dm_hs_phy_irq handlers were absent from /proc/interrupts. With this
> change they return on every rebind.
> 
> Fixes: 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>

Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>

Peter
> ---
> Changes in v3:
> - Renamed the new fields to dp_hs_phy_irq_type and dm_hs_phy_irq_type,
>   to match the existing dp_hs_phy_irq and dm_hs_phy_irq (Peter Chen).
> - Added Cc: stable (Peter Chen).
> - Sent inline; v1 and v2 went out as attachments.
> 
> Changes in v2:
> - Resent with an empty mail body.
> - Added the Fixes tag suggested by the Sashiko review.
> 
>  drivers/usb/dwc3/dwc3-qcom.c | 38 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index a260841..548d69b 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -65,6 +65,8 @@ struct dwc3_qcom_port {
>  	int			dp_hs_phy_irq;
>  	int			dm_hs_phy_irq;
>  	int			ss_phy_irq;
> +	unsigned int		dp_hs_phy_irq_type;
> +	unsigned int		dm_hs_phy_irq_type;
>  	enum usb_device_speed	usb2_speed;
>  };
>  
> @@ -473,6 +475,7 @@ static int dwc3_qcom_setup_port_irq(struct dwc3_qcom *qcom,
>  		if (ret)
>  			return ret;
>  		qcom->ports[port_index].dp_hs_phy_irq = irq;
> +		qcom->ports[port_index].dp_hs_phy_irq_type = irq_get_trigger_type(irq);
>  	}
>  
>  	if (is_multiport)
> @@ -488,6 +491,7 @@ static int dwc3_qcom_setup_port_irq(struct dwc3_qcom *qcom,
>  		if (ret)
>  			return ret;
>  		qcom->ports[port_index].dm_hs_phy_irq = irq;
> +		qcom->ports[port_index].dm_hs_phy_irq_type = irq_get_trigger_type(irq);
>  	}
>  
>  	if (is_multiport)
> @@ -540,6 +544,38 @@ static int dwc3_qcom_find_num_ports(struct platform_device *pdev)
>  	return DWC3_QCOM_MAX_PORTS;
>  }
>  
> +static void dwc3_qcom_restore_irq_type(struct device *dev, int irq, unsigned int type)
> +{
> +	int ret;
> +
> +	if (!irq || !type || irq_get_trigger_type(irq) == type)
> +		return;
> +
> +	ret = irq_set_irq_type(irq, type);
> +	if (ret)
> +		dev_warn(dev, "failed to restore IRQ %d trigger type %#x: %d\n",
> +			 irq, type, ret);
> +}
> +
> +static void dwc3_qcom_restore_wake_irq_types(void *data)
> +{
> +	struct dwc3_qcom *qcom = data;
> +	int i;
> +
> +	/*
> +	 * The IRQ mappings survive unbind. Put their firmware triggers back
> +	 * before devres frees the handlers or the next probe can lose them.
> +	 */
> +	for (i = 0; i < qcom->num_ports; i++) {
> +		struct dwc3_qcom_port *port = &qcom->ports[i];
> +
> +		dwc3_qcom_restore_irq_type(qcom->dev, port->dp_hs_phy_irq,
> +					   port->dp_hs_phy_irq_type);
> +		dwc3_qcom_restore_irq_type(qcom->dev, port->dm_hs_phy_irq,
> +					   port->dm_hs_phy_irq_type);
> +	}
> +}
> +
>  static int dwc3_qcom_setup_irq(struct dwc3_qcom *qcom, struct platform_device *pdev)
>  {
>  	bool is_multiport;
> @@ -555,7 +591,7 @@ static int dwc3_qcom_setup_irq(struct dwc3_qcom *qcom, struct platform_device *p
>  			return ret;
>  	}
>  
> -	return 0;
> +	return devm_add_action_or_reset(qcom->dev, dwc3_qcom_restore_wake_irq_types, qcom);
>  }
>  
>  static void dwc3_qcom_set_role_notifier(struct dwc3 *dwc, enum usb_role next_role)
> -- 
> 2.56.1
> 

-- 

Thanks,
Peter Chen

      reply	other threads:[~2026-11-30  3:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  5:09 Felipe Infante de Castro
2026-11-30  3:02 ` Peter Chen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awznWmBhOT9QL8-n@hu-petche-lv.qualcomm.com \
    --to=peter.chen@oss.qualcomm.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=felipe.infante.de.castro@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®