* [PATCH v2] usb: typec: tcpci: Request IRQ with IRQF_SHARED
@ 2022-12-14 2:23 Xu Yang
2022-12-14 17:04 ` Guenter Roeck
2023-01-02 9:36 ` Heikki Krogerus
0 siblings, 2 replies; 3+ messages in thread
From: Xu Yang @ 2022-12-14 2:23 UTC (permalink / raw)
To: linux, heikki.krogerus; +Cc: gregkh, linux-usb, linux-imx, jun.li, xu.yang_2
Under resource constraints, this interrupt may use other interrupt line
or this interrupt line may be shared with other devices as long as they
meet the sharing requirements. Besides, This irq flag will not cause other
side effect if tcpci driver is the only user.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes since v1:
- return IRQ_NONE if the interrupt doesn't belong to this device
---
drivers/usb/typec/tcpm/tcpci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index fe781a38dc82..c7796511695d 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -33,6 +33,7 @@ struct tcpci {
struct tcpm_port *port;
struct regmap *regmap;
+ unsigned int alert_mask;
bool controls_vbus;
@@ -632,6 +633,9 @@ static int tcpci_init(struct tcpc_dev *tcpc)
if (ret < 0)
return ret;
}
+
+ tcpci->alert_mask = reg;
+
return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg);
}
@@ -715,7 +719,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
else if (status & TCPC_ALERT_TX_FAILED)
tcpm_pd_transmit_complete(tcpci->port, TCPC_TX_FAILED);
- return IRQ_HANDLED;
+ return IRQ_RETVAL(status & tcpci->alert_mask);
}
EXPORT_SYMBOL_GPL(tcpci_irq);
@@ -838,7 +842,7 @@ static int tcpci_probe(struct i2c_client *client)
err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
_tcpci_irq,
- IRQF_ONESHOT | IRQF_TRIGGER_LOW,
+ IRQF_SHARED | IRQF_ONESHOT | IRQF_TRIGGER_LOW,
dev_name(&client->dev), chip);
if (err < 0) {
tcpci_unregister_port(chip->tcpci);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] usb: typec: tcpci: Request IRQ with IRQF_SHARED
2022-12-14 2:23 [PATCH v2] usb: typec: tcpci: Request IRQ with IRQF_SHARED Xu Yang
@ 2022-12-14 17:04 ` Guenter Roeck
2023-01-02 9:36 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2022-12-14 17:04 UTC (permalink / raw)
To: Xu Yang, heikki.krogerus; +Cc: gregkh, linux-usb, linux-imx, jun.li
On 12/13/22 18:23, Xu Yang wrote:
> Under resource constraints, this interrupt may use other interrupt line
> or this interrupt line may be shared with other devices as long as they
> meet the sharing requirements. Besides, This irq flag will not cause other
> side effect if tcpci driver is the only user.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Note: I initially thought that introducing alert_mask is overkill, but
the tcpci specification suggests that alert bits may be set even for
alerts disabled with the alert mask. So this code is ultimately simpler
than trying to determine in the interrupt handler which bits are actually
set in the alert mask.
Thanks,
Guenter
>
> ---
> Changes since v1:
> - return IRQ_NONE if the interrupt doesn't belong to this device
> ---
> drivers/usb/typec/tcpm/tcpci.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index fe781a38dc82..c7796511695d 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -33,6 +33,7 @@ struct tcpci {
> struct tcpm_port *port;
>
> struct regmap *regmap;
> + unsigned int alert_mask;
>
> bool controls_vbus;
>
> @@ -632,6 +633,9 @@ static int tcpci_init(struct tcpc_dev *tcpc)
> if (ret < 0)
> return ret;
> }
> +
> + tcpci->alert_mask = reg;
> +
> return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg);
> }
>
> @@ -715,7 +719,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
> else if (status & TCPC_ALERT_TX_FAILED)
> tcpm_pd_transmit_complete(tcpci->port, TCPC_TX_FAILED);
>
> - return IRQ_HANDLED;
> + return IRQ_RETVAL(status & tcpci->alert_mask); > }
> EXPORT_SYMBOL_GPL(tcpci_irq);
>
> @@ -838,7 +842,7 @@ static int tcpci_probe(struct i2c_client *client)
>
> err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> _tcpci_irq,
> - IRQF_ONESHOT | IRQF_TRIGGER_LOW,
> + IRQF_SHARED | IRQF_ONESHOT | IRQF_TRIGGER_LOW,
> dev_name(&client->dev), chip);
> if (err < 0) {
> tcpci_unregister_port(chip->tcpci);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] usb: typec: tcpci: Request IRQ with IRQF_SHARED
2022-12-14 2:23 [PATCH v2] usb: typec: tcpci: Request IRQ with IRQF_SHARED Xu Yang
2022-12-14 17:04 ` Guenter Roeck
@ 2023-01-02 9:36 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2023-01-02 9:36 UTC (permalink / raw)
To: Xu Yang; +Cc: linux, gregkh, linux-usb, linux-imx, jun.li
On Wed, Dec 14, 2022 at 10:23:34AM +0800, Xu Yang wrote:
> Under resource constraints, this interrupt may use other interrupt line
> or this interrupt line may be shared with other devices as long as they
> meet the sharing requirements. Besides, This irq flag will not cause other
> side effect if tcpci driver is the only user.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Changes since v1:
> - return IRQ_NONE if the interrupt doesn't belong to this device
> ---
> drivers/usb/typec/tcpm/tcpci.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index fe781a38dc82..c7796511695d 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -33,6 +33,7 @@ struct tcpci {
> struct tcpm_port *port;
>
> struct regmap *regmap;
> + unsigned int alert_mask;
>
> bool controls_vbus;
>
> @@ -632,6 +633,9 @@ static int tcpci_init(struct tcpc_dev *tcpc)
> if (ret < 0)
> return ret;
> }
> +
> + tcpci->alert_mask = reg;
> +
> return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg);
> }
>
> @@ -715,7 +719,7 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
> else if (status & TCPC_ALERT_TX_FAILED)
> tcpm_pd_transmit_complete(tcpci->port, TCPC_TX_FAILED);
>
> - return IRQ_HANDLED;
> + return IRQ_RETVAL(status & tcpci->alert_mask);
> }
> EXPORT_SYMBOL_GPL(tcpci_irq);
>
> @@ -838,7 +842,7 @@ static int tcpci_probe(struct i2c_client *client)
>
> err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> _tcpci_irq,
> - IRQF_ONESHOT | IRQF_TRIGGER_LOW,
> + IRQF_SHARED | IRQF_ONESHOT | IRQF_TRIGGER_LOW,
> dev_name(&client->dev), chip);
> if (err < 0) {
> tcpci_unregister_port(chip->tcpci);
> --
> 2.34.1
thanks,
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-02 9:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-14 2:23 [PATCH v2] usb: typec: tcpci: Request IRQ with IRQF_SHARED Xu Yang
2022-12-14 17:04 ` Guenter Roeck
2023-01-02 9:36 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox