From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Mateusz Jończyk" <mat.jonczyk@o2.pl>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Mario Limonciello <mario.limonciello@amd.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
Joy Chakraborty <joychakr@google.com>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: cmos: avoid taking rtc_lock for extended period of time
Date: Fri, 25 Oct 2024 13:07:50 -0700 [thread overview]
Message-ID: <Zxv6ltPBWfWs957R@google.com> (raw)
In-Reply-To: <B8A0CC86-7C24-4154-B8F3-69CD6B6C94BD@o2.pl>
On Fri, Oct 25, 2024 at 08:01:37AM +0200, Mateusz Jończyk wrote:
> Dnia 24 października 2024 22:37:08 CEST, Dmitry Torokhov <dmitry.torokhov@gmail.com> napisał/a:
> >On my device reading entirety of /sys/devices/pnp0/00:03/cmos_nvram0/nvmem
> >takes about 9 msec during which time interrupts are off on the CPU that
> >does the read and the thread that performs the read can not be migrated
> >or preempted by another higher priority thread (RT or not).
> >
> >Allow readers and writers be preempted by taking and releasing rtc_lock
> >spinlock for each individual byte read or written rather than once per
> >read/write request.
>
> Hello,
> A nice idea!
> (sorry for any formatting problems, I'm on a train right now)
>
> >
> >Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >---
> > drivers/rtc/rtc-cmos.c | 31 +++++++++++++++----------------
> > 1 file changed, 15 insertions(+), 16 deletions(-)
> >
> >diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> >index 35dca2accbb8..e8f2fe0d8560 100644
> >--- a/drivers/rtc/rtc-cmos.c
> >+++ b/drivers/rtc/rtc-cmos.c
> >@@ -645,18 +645,17 @@ static int cmos_nvram_read(void *priv, unsigned int off, void *val,
> > unsigned char *buf = val;
> >
> > off += NVRAM_OFFSET;
> >- spin_lock_irq(&rtc_lock);
> >- for (; count; count--, off++) {
> >+ for (; count; count--, off++, buf++) {
> >+ guard(spinlock_irq)(&rtc_lock);
> > if (off < 128)
> >- *buf++ = CMOS_READ(off);
> >+ *buf = CMOS_READ(off);
> > else if (can_bank2)
> >- *buf++ = cmos_read_bank2(off);
> >+ *buf = cmos_read_bank2(off);
> > else
> >- break;
> >+ return -EIO;
> > }
> >- spin_unlock_irq(&rtc_lock);
> >
> >- return count ? -EIO : 0;
> >+ return count;
>
> return 0;
Oh, yes, of course, thank you.
--
Dmitry
next prev parent reply other threads:[~2024-10-25 20:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 20:37 [PATCH] rtc: cmos: avoid taking rtc_lock for extended period of time Dmitry Torokhov
2024-10-25 6:01 ` Mateusz Jończyk
2024-10-25 20:07 ` Dmitry Torokhov [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-10-25 20:14 Dmitry Torokhov
2024-10-25 20:52 ` Mateusz Jończyk
2024-10-31 23:19 ` Alexandre Belloni
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=Zxv6ltPBWfWs957R@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=dan.carpenter@linaro.org \
--cc=joychakr@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mat.jonczyk@o2.pl \
/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