* [PATCH] can: flexcan: disable transceiver during system PM
@ 2025-03-04 3:37 haibo.chen
2025-03-04 4:06 ` Vincent Mailhol
0 siblings, 1 reply; 3+ messages in thread
From: haibo.chen @ 2025-03-04 3:37 UTC (permalink / raw)
To: mkl, mailhol.vincent
Cc: ciprianmarian.costea, haibo.chen, u.kleine-koenig, linux-can,
linux-kernel, imx
From: Haibo Chen <haibo.chen@nxp.com>
During system PM, if no wakeup requirement, disable transceiver to
save power.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
drivers/net/can/flexcan/flexcan-core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index b347a1c93536..74f3137295fb 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -2292,6 +2292,7 @@ static int __maybe_unused flexcan_suspend(struct device *device)
return err;
flexcan_chip_interrupts_disable(dev);
+ flexcan_transceiver_disable(priv);
err = pinctrl_pm_select_sleep_state(device);
if (err)
@@ -2325,6 +2326,10 @@ static int __maybe_unused flexcan_resume(struct device *device)
if (err)
return err;
+ err = flexcan_transceiver_enable(priv);
+ if (err)
+ return err;
+
err = flexcan_chip_start(dev);
if (err)
return err;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] can: flexcan: disable transceiver during system PM
2025-03-04 3:37 [PATCH] can: flexcan: disable transceiver during system PM haibo.chen
@ 2025-03-04 4:06 ` Vincent Mailhol
2025-03-04 4:24 ` Bough Chen
0 siblings, 1 reply; 3+ messages in thread
From: Vincent Mailhol @ 2025-03-04 4:06 UTC (permalink / raw)
To: haibo.chen, mkl
Cc: ciprianmarian.costea, u.kleine-koenig, linux-can, linux-kernel, imx
On 04/03/2025 at 12:37, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
>
> During system PM, if no wakeup requirement, disable transceiver to
> save power.
>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>> ---
> drivers/net/can/flexcan/flexcan-core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
> index b347a1c93536..74f3137295fb 100644
> --- a/drivers/net/can/flexcan/flexcan-core.c
> +++ b/drivers/net/can/flexcan/flexcan-core.c
> @@ -2292,6 +2292,7 @@ static int __maybe_unused flexcan_suspend(struct device *device)
> return err;
>
> flexcan_chip_interrupts_disable(dev);
> + flexcan_transceiver_disable(priv);
flexcan_transceiver_disable() may return an error. Can you check its
return value?
> err = pinctrl_pm_select_sleep_state(device);
> if (err)
> @@ -2325,6 +2326,10 @@ static int __maybe_unused flexcan_resume(struct device *device)
> if (err)
> return err;
>
> + err = flexcan_transceiver_enable(priv);
> + if (err)
> + return err;
> +
> err = flexcan_chip_start(dev);
> if (err)
> return err;
If flexcan_chip_start() fails, shouldn't you have a clean-up branch that
will flexcan_transceiver_disable()? Or do you consider that it is
acceptable to keep the transceiver enabled if an error occurs?
Speaking of which, if flexcan_resume() fails, priv->can.state would
still be set to CAN_STATE_ERROR_ACTIVE.
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] can: flexcan: disable transceiver during system PM
2025-03-04 4:06 ` Vincent Mailhol
@ 2025-03-04 4:24 ` Bough Chen
0 siblings, 0 replies; 3+ messages in thread
From: Bough Chen @ 2025-03-04 4:24 UTC (permalink / raw)
To: Vincent Mailhol, mkl
Cc: Ciprian Marian Costea (OSS),
u.kleine-koenig, linux-can, linux-kernel, imx
> -----Original Message-----
> From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> Sent: 2025年3月4日 12:06
> To: Bough Chen <haibo.chen@nxp.com>; mkl@pengutronix.de
> Cc: Ciprian Marian Costea (OSS) <ciprianmarian.costea@oss.nxp.com>;
> u.kleine-koenig@baylibre.com; linux-can@vger.kernel.org;
> linux-kernel@vger.kernel.org; imx@lists.linux.dev
> Subject: Re: [PATCH] can: flexcan: disable transceiver during system PM
>
> On 04/03/2025 at 12:37, haibo.chen@nxp.com wrote:
> > From: Haibo Chen <haibo.chen@nxp.com>
> >
> > During system PM, if no wakeup requirement, disable transceiver to
> > save power.
> >
> > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>> ---
> > drivers/net/can/flexcan/flexcan-core.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/can/flexcan/flexcan-core.c
> > b/drivers/net/can/flexcan/flexcan-core.c
> > index b347a1c93536..74f3137295fb 100644
> > --- a/drivers/net/can/flexcan/flexcan-core.c
> > +++ b/drivers/net/can/flexcan/flexcan-core.c
> > @@ -2292,6 +2292,7 @@ static int __maybe_unused flexcan_suspend(struct
> device *device)
> > return err;
> >
> > flexcan_chip_interrupts_disable(dev);
> > + flexcan_transceiver_disable(priv);
>
> flexcan_transceiver_disable() may return an error. Can you check its return
> value?
Yes, sure.
>
> > err = pinctrl_pm_select_sleep_state(device);
> > if (err)
> > @@ -2325,6 +2326,10 @@ static int __maybe_unused flexcan_resume(struct
> device *device)
> > if (err)
> > return err;
> >
> > + err = flexcan_transceiver_enable(priv);
> > + if (err)
> > + return err;
> > +
> > err = flexcan_chip_start(dev);
> > if (err)
> > return err;
>
> If flexcan_chip_start() fails, shouldn't you have a clean-up branch that will
> flexcan_transceiver_disable()? Or do you consider that it is acceptable to keep
> the transceiver enabled if an error occurs?
Good suggestion, I will add a clean-up branch.
>
> Speaking of which, if flexcan_resume() fails, priv->can.state would still be set to
> CAN_STATE_ERROR_ACTIVE.
Thanks for your quick response, I will take all these suggestions into consideration and prepare v2 patch.
Regards
Haibo Chen
>
>
> Yours sincerely,
> Vincent Mailhol
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-04 4:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-04 3:37 [PATCH] can: flexcan: disable transceiver during system PM haibo.chen
2025-03-04 4:06 ` Vincent Mailhol
2025-03-04 4:24 ` Bough Chen
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®