* [PATCH v2] can: c_can: don't call pm_runtime_get_sync() from IRQ handler
@ 2013-11-25 20:34 Glen, Andrew
2013-11-25 20:42 ` Marc Kleine-Budde
0 siblings, 1 reply; 3+ messages in thread
From: Glen, Andrew @ 2013-11-25 20:34 UTC (permalink / raw)
To: linux-can@vger.kernel.org; +Cc: kernel@pengutronix.de, Marc Kleine-Budde
From: <mkl@pengutronix.de>
The c_can driver contains a callpath (c_can_poll -> c_can_state_change ->
c_can_get_berr_counter) which may call pm_runtime_get_sync() from the IRQ handler, which is not allowed.
This problem is fixed by introducing __c_can_get_berr_counter, which will not call pm_runtime_get_sync().
Reported-by: Andrew Glen <AGlen@bepmarine.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Andrew Glen <AGlen@bepmarine.com>
Tested-by: Andrew Glen <AGlen@bepmarine.com>
---
Changes since v1: Fixed missing semi-colon and missing call to 'struct c_can_priv *priv = netdev_priv(dev);' in ' c_can_get_berr_counter()'
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index a668cd4..a58ea45 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -712,22 +712,32 @@ static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
return 0;
}
-static int c_can_get_berr_counter(const struct net_device *dev,
+static int __c_can_get_berr_counter(const struct net_device *dev,
struct can_berr_counter *bec)
{
unsigned int reg_err_counter;
struct c_can_priv *priv = netdev_priv(dev);
- c_can_pm_runtime_get_sync(priv);
-
reg_err_counter = priv->read_reg(priv, C_CAN_ERR_CNT_REG);
bec->rxerr = (reg_err_counter & ERR_CNT_REC_MASK) >>
ERR_CNT_REC_SHIFT;
bec->txerr = reg_err_counter & ERR_CNT_TEC_MASK;
+ return 0;
+
+}
+
+static int c_can_get_berr_counter(const struct net_device *dev,
+ struct can_berr_counter *bec)
+{
+ int err;
+ struct c_can_priv *priv = netdev_priv(dev);
+
+ c_can_pm_runtime_get_sync(priv);
+ err = __c_can_get_berr_counter(dev, bec);
c_can_pm_runtime_put_sync(priv);
- return 0;
+ return err;
}
/*
@@ -872,7 +882,7 @@ static int c_can_handle_state_change(struct net_device *dev,
if (unlikely(!skb))
return 0;
- c_can_get_berr_counter(dev, &bec);
+ __c_can_get_berr_counter(dev, &bec);
reg_err_counter = priv->read_reg(priv, C_CAN_ERR_CNT_REG);
rx_err_passive = (reg_err_counter & ERR_CNT_RP_MASK) >>
ERR_CNT_RP_SHIFT;
________________________________
Actuant Corporation Email Notice
This message is intended only for the use of the Addressee and may contain information that is PRIVILEGED and/or CONFIDENTIAL.
This email is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this email is not an intended recipient, you have received this email in error and any review, dissemination, distribution or copying is strictly prohibited.
If you have received this email in error, please notify the sender immediately by return mail and permanently delete the copy you received.
Thank you.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] can: c_can: don't call pm_runtime_get_sync() from IRQ handler
2013-11-25 20:34 [PATCH v2] can: c_can: don't call pm_runtime_get_sync() from IRQ handler Glen, Andrew
@ 2013-11-25 20:42 ` Marc Kleine-Budde
2013-11-26 2:15 ` Glen, Andrew
0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2013-11-25 20:42 UTC (permalink / raw)
To: Glen, Andrew; +Cc: linux-can@vger.kernel.org, kernel@pengutronix.de
[-- Attachment #1: Type: text/plain, Size: 900 bytes --]
On 11/25/2013 09:34 PM, Glen, Andrew wrote:
> From: <mkl@pengutronix.de>
>
> The c_can driver contains a callpath (c_can_poll -> c_can_state_change ->
> c_can_get_berr_counter) which may call pm_runtime_get_sync() from the IRQ handler, which is not allowed.
>
> This problem is fixed by introducing __c_can_get_berr_counter, which will not call pm_runtime_get_sync().
>
> Reported-by: Andrew Glen <AGlen@bepmarine.com>
> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Andrew Glen <AGlen@bepmarine.com>
> Tested-by: Andrew Glen <AGlen@bepmarine.com>
Thanks for fixing and testing.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] can: c_can: don't call pm_runtime_get_sync() from IRQ handler
2013-11-25 20:42 ` Marc Kleine-Budde
@ 2013-11-26 2:15 ` Glen, Andrew
0 siblings, 0 replies; 3+ messages in thread
From: Glen, Andrew @ 2013-11-26 2:15 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can@vger.kernel.org, kernel@pengutronix.de
Cheers, thank you for being patient. This was my first ever contribution to the Linux community.
-----Original Message-----
From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
Sent: Tuesday, 26 November 2013 9:43 a.m.
To: Glen, Andrew
Cc: linux-can@vger.kernel.org; kernel@pengutronix.de
Subject: Re: [PATCH v2] can: c_can: don't call pm_runtime_get_sync() from IRQ handler
On 11/25/2013 09:34 PM, Glen, Andrew wrote:
> From: <mkl@pengutronix.de>
>
> The c_can driver contains a callpath (c_can_poll -> c_can_state_change ->
> c_can_get_berr_counter) which may call pm_runtime_get_sync() from the IRQ handler, which is not allowed.
>
> This problem is fixed by introducing __c_can_get_berr_counter, which will not call pm_runtime_get_sync().
>
> Reported-by: Andrew Glen <AGlen@bepmarine.com>
> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Andrew Glen <AGlen@bepmarine.com>
> Tested-by: Andrew Glen <AGlen@bepmarine.com>
Thanks for fixing and testing.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
________________________________
Actuant Corporation Email Notice
This message is intended only for the use of the Addressee and may contain information that is PRIVILEGED and/or CONFIDENTIAL.
This email is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this email is not an intended recipient, you have received this email in error and any review, dissemination, distribution or copying is strictly prohibited.
If you have received this email in error, please notify the sender immediately by return mail and permanently delete the copy you received.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-26 2:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 20:34 [PATCH v2] can: c_can: don't call pm_runtime_get_sync() from IRQ handler Glen, Andrew
2013-11-25 20:42 ` Marc Kleine-Budde
2013-11-26 2:15 ` Glen, Andrew
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.