[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9f03470a-99a3-0f98-8057-bc07b0c869a5@pengutronix.de>
Date: Mon, 5 Sep 2022 09:38:04 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Csókás Bence <csokas.bence@...lan.hu>,
netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Richard Cochran <richardcochran@...il.com>,
kernel@...gutronix.de,
Francesco Dolcini <francesco.dolcini@...adex.com>,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH v2] net: fec: Use a spinlock to guard `fep->ptp_clk_on`
On 9/1/22 4:04 PM, Csókás Bence wrote:
> Mutexes cannot be taken in a non-preemptible context,
> causing a panic in `fec_ptp_save_state()`. Replacing
> `ptp_clk_mutex` by `tmreg_lock` fixes this.
I was on holidays, but this doesn't look good.
> Fixes: 6a4d7234ae9a ("net: fec: ptp: avoid register access when ipg clock is disabled")
> Fixes: f79959220fa5 ("fec: Restart PPS after link state change")
> Reported-by: Marc Kleine-Budde <mkl@...gutronix.de>
> Link: https://lore.kernel.org/all/20220827160922.642zlcd5foopozru@pengutronix.de/
> Signed-off-by: Csókás Bence <csokas.bence@...lan.hu>
> ---
> drivers/net/ethernet/freescale/fec.h | 1 -
> drivers/net/ethernet/freescale/fec_main.c | 17 +++++++-------
> drivers/net/ethernet/freescale/fec_ptp.c | 28 ++++++++---------------
> 3 files changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
> index 0cebe4b63adb..38f095260e1f 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -557,7 +557,6 @@ struct fec_enet_private {
> struct clk *clk_2x_txclk;
>
> bool ptp_clk_on;
> - struct mutex ptp_clk_mutex;
> unsigned int num_tx_queues;
> unsigned int num_rx_queues;
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index b0d60f898249..ab1ee9508f76 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -2028,6 +2028,7 @@ static void fec_enet_phy_reset_after_clk_enable(struct net_device *ndev)
> static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
> {
> struct fec_enet_private *fep = netdev_priv(ndev);
> + unsigned long flags;
> int ret;
>
> if (enable) {
> @@ -2036,15 +2037,15 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
> return ret;
>
> if (fep->clk_ptp) {
> - mutex_lock(&fep->ptp_clk_mutex);
> + spin_lock_irqsave(&fep->tmreg_lock, flags);
> ret = clk_prepare_enable(fep->clk_ptp);
clock_prepare() (and thus clk_prepare_enable()) must not be called from atomic
context.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists