From: Andrew Lunn <andrew@lunn.ch>
To: "Csókás Bence" <csokas.bence@prolan.hu>
Cc: netdev@vger.kernel.org,
Richard Cochran <richardcochran@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
qiangqing.zhang@nxp.com, kernel@pengutronix.de,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: Re: [PATCH v2] net: fec: Use unlocked timecounter reads for saving state
Date: Tue, 30 Aug 2022 17:21:15 +0200 [thread overview]
Message-ID: <Yw4q616Nl4LJdy/a@lunn.ch> (raw)
In-Reply-To: <bbe8a924-7291-14f9-1e88-802a211ca0f4@prolan.hu>
On Tue, Aug 30, 2022 at 05:05:24PM +0200, Csókás Bence wrote:
>
>
> On 2022. 08. 30. 14:29, Andrew Lunn wrote:
> > > - fec_ptp_gettime(&fep->ptp_caps, &fep->ptp_saved_state.ts_phc);
> > > + if (preempt_count_equals(0)) {
> >
> > ~/linux/drivers$ grep -r preempt_count_equals *
> > ~/linux/drivers$
> >
> > No other driver plays games like this.
> >
> > Why not unconditionally take the lock?
>
> Because then we would be back at the original problem (see Marc's message):
>
> | [ 14.001542] BUG: sleeping function called from invalid context at
> kernel/locking/mutex.c:283
>
> | [ 14.010604] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 13,
> name: kworker/0:1
>
> | [ 14.018737] preempt_count: 201, expected: 0
>
> We cannot take a mutex in atomic context. However, we also don't *need to*
> take a mutex in atomic context.
You are not taking a mutex, you are taking a spinlock. You can do that
in atomic context. Can you protect everything which needs protecting
with a spinlock? And avoid sleeping...
Andrew
next prev parent reply other threads:[~2022-08-30 15:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 11:15 [PATCH v2] net: fec: Use unlocked timecounter reads for saving state Csókás Bence
2022-08-30 12:29 ` Andrew Lunn
2022-08-30 15:05 ` Csókás Bence
2022-08-30 15:21 ` Andrew Lunn [this message]
2022-08-31 13:09 ` Csókás Bence
2022-08-31 3:41 ` Richard Cochran
2022-08-31 10:20 ` kernel test robot
2022-09-01 21:52 ` kernel test robot
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=Yw4q616Nl4LJdy/a@lunn.ch \
--to=andrew@lunn.ch \
--cc=csokas.bence@prolan.hu \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=qiangqing.zhang@nxp.com \
--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).