From: Marc Kleine-Budde <mkl@pengutronix.de>
To: "Bence Csókás" <bence98@sch.bme.hu>
Cc: netdev@vger.kernel.org,
"Richard Cochran" <richardcochran@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Francesco Dolcini" <francesco.dolcini@toradex.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Guenter Roeck" <linux@roeck-us.net>,
kernel@pengutronix.de, "Csókás Bence" <csokas.bence@prolan.hu>
Subject: Re: [PATCH 1/2] Revert "net: fec: Use a spinlock to guard `fep->ptp_clk_on`"
Date: Mon, 12 Sep 2022 12:38:18 +0200 [thread overview]
Message-ID: <20220912103818.j2u6afz66tcxvnr6@pengutronix.de> (raw)
In-Reply-To: <20220912073106.2544207-1-bence98@sch.bme.hu>
[-- Attachment #1: Type: text/plain, Size: 2569 bytes --]
On 12.09.2022 07:31:04, Bence Csókás wrote:
> From: Csókás Bence <csokas.bence@prolan.hu>
>
> `clk_prepare_enable()` gets called in atomic context (holding a spinlock),
> which may sleep, causing a BUG on certain platforms.
>
> This reverts commit b353b241f1eb9b6265358ffbe2632fdcb563354f.
>
> Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Link: https://lore.kernel.org/all/20220907143915.5w65kainpykfobte@pengutronix.de/
> Signed-off-by: Csókás Bence <csokas.bence@prolan.hu>
This is not a 100% revert.
In b353b241f1eb ("net: fec: Use a spinlock to guard `fep->ptp_clk_on`")
the "struct fec_enet_private *fep" was renamed to "struct
fec_enet_private *adapter" for no apparent reason. The driver uses "fep"
everywhere else. This revert doesn't restore the original state.
This leads to the following diff against a 100% revert.
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index c99dff3c3422..c74d04f4b2fd 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -365,21 +365,21 @@ static int fec_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
*/
static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{
- struct fec_enet_private *fep =
+ struct fec_enet_private *adapter =
container_of(ptp, struct fec_enet_private, ptp_caps);
u64 ns;
unsigned long flags;
- mutex_lock(&fep->ptp_clk_mutex);
+ mutex_lock(&adapter->ptp_clk_mutex);
/* Check the ptp clock */
- if (!fep->ptp_clk_on) {
- mutex_unlock(&fep->ptp_clk_mutex);
+ if (!adapter->ptp_clk_on) {
+ mutex_unlock(&adapter->ptp_clk_mutex);
return -EINVAL;
}
- spin_lock_irqsave(&fep->tmreg_lock, flags);
- ns = timecounter_read(&fep->tc);
- spin_unlock_irqrestore(&fep->tmreg_lock, flags);
- mutex_unlock(&fep->ptp_clk_mutex);
+ spin_lock_irqsave(&adapter->tmreg_lock, flags);
+ ns = timecounter_read(&adapter->tc);
+ spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
+ mutex_unlock(&adapter->ptp_clk_mutex);
*ts = ns_to_timespec64(ns);
regards,
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 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-09-12 10:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-12 7:31 [PATCH 1/2] Revert "net: fec: Use a spinlock to guard `fep->ptp_clk_on`" Bence Csókás
2022-09-12 7:31 ` [PATCH 2/2] net: fec: Use unlocked timecounter reads for saving state Bence Csókás
2022-09-12 7:31 ` [PATCH v3 " Bence Csókás
2022-09-12 7:09 ` Csókás Bence
2022-09-12 10:38 ` Marc Kleine-Budde [this message]
2022-09-12 12:38 ` [PATCH 1/2] Revert "net: fec: Use a spinlock to guard `fep->ptp_clk_on`" Marc Kleine-Budde
2022-09-13 19:04 ` Csókás Bence
2022-09-14 8:38 ` Marc Kleine-Budde
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=20220912103818.j2u6afz66tcxvnr6@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=andrew@lunn.ch \
--cc=bence98@sch.bme.hu \
--cc=csokas.bence@prolan.hu \
--cc=davem@davemloft.net \
--cc=francesco.dolcini@toradex.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.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;
as well as URLs for NNTP newsgroup(s).