public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Xu Yang <xu.yang_2@nxp.com>
To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	andre.draszik@linaro.org, rdbabiera@google.com,
	m.felsch@pengutronix.de, dan.carpenter@linaro.org,
	emanuele.ghidoli@toradex.com, parth.pancholi@toradex.com,
	francesco.dolcini@toradex.com, u.kleine-koenig@baylibre.com
Cc: linux-usb@vger.kernel.org, imx@lists.linux.dev, jun.li@nxp.com
Subject: [PATCH v3 2/2] usb: typec: tcpci: set ALERT_MASK register after devm_request_threaded_irq()
Date: Tue, 17 Dec 2024 17:12:08 +0800	[thread overview]
Message-ID: <20241217091208.2416971-2-xu.yang_2@nxp.com> (raw)
In-Reply-To: <20241217091208.2416971-1-xu.yang_2@nxp.com>

With edge irq support, the ALERT event may be missed currently. The reason
is that ALERT_MASK register is written before devm_request_threaded_irq().
If ALERT event happens in this time gap, it will be missed and ALERT line
will not recover to high level. However, we don't meet this issue with
level irq. To avoid the issue, this will set ALERT_MASK register after
devm_request_threaded_irq() return.

Fixes: 77e85107a771 ("usb: typec: tcpci: support edge irq")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v3:
 - remove set_alert_mask flag
Changes in v2:
 - new patch
---
 drivers/usb/typec/tcpm/tcpci.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index db42f4bf3632..48762508cc86 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -700,7 +700,7 @@ static int tcpci_init(struct tcpc_dev *tcpc)
 
 	tcpci->alert_mask = reg;
 
-	return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg);
+	return 0;
 }
 
 irqreturn_t tcpci_irq(struct tcpci *tcpci)
@@ -931,12 +931,19 @@ static int tcpci_probe(struct i2c_client *client)
 					_tcpci_irq,
 					IRQF_SHARED | IRQF_ONESHOT,
 					dev_name(&client->dev), chip);
-	if (err < 0) {
-		tcpci_unregister_port(chip->tcpci);
-		return err;
-	}
+	if (err < 0)
+		goto unregister_port;
+
+	/* Enable chip interrupts at last */
+	err = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, chip->tcpci->alert_mask);
+	if (err < 0)
+		goto unregister_port;
 
 	return 0;
+
+unregister_port:
+	tcpci_unregister_port(chip->tcpci);
+	return err;
 }
 
 static void tcpci_remove(struct i2c_client *client)
-- 
2.34.1


  reply	other threads:[~2024-12-17  9:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17  9:12 [PATCH v3 1/2] usb: typec: tcpci: fix NULL pointer issue on shared irq case Xu Yang
2024-12-17  9:12 ` Xu Yang [this message]
2024-12-17  9:29   ` [PATCH v3 2/2] usb: typec: tcpci: set ALERT_MASK register after devm_request_threaded_irq() Francesco Dolcini
2024-12-17  9:41     ` Xu Yang
2024-12-17  9:45       ` Francesco Dolcini
2024-12-17  9:49         ` Xu Yang
2024-12-17 10:45   ` Dan Carpenter
2024-12-18  5:49     ` Xu Yang
2024-12-17 16:35   ` Francesco Dolcini
2024-12-17 20:29     ` Emanuele Ghidoli
2024-12-18  5:31       ` Xu Yang
2024-12-18  6:41         ` Emanuele Ghidoli
2024-12-18  7:11           ` Xu Yang
2024-12-17  9:56 ` [PATCH v3 1/2] usb: typec: tcpci: fix NULL pointer issue on shared irq case Dan Carpenter
2024-12-18  5:45   ` Xu Yang
2024-12-18  9:35     ` Dan Carpenter

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=20241217091208.2416971-2-xu.yang_2@nxp.com \
    --to=xu.yang_2@nxp.com \
    --cc=andre.draszik@linaro.org \
    --cc=dan.carpenter@linaro.org \
    --cc=emanuele.ghidoli@toradex.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=parth.pancholi@toradex.com \
    --cc=rdbabiera@google.com \
    --cc=u.kleine-koenig@baylibre.com \
    /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