public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
	linux-kernel@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	maddy@linux.ibm.com, arnd@arndb.de,
	Christophe Leroy <chleroy@kernel.org>,
	Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Subject: Re: [PATCH v4] char/nvram: Remove redundant nvram_mutex
Date: Tue, 31 Mar 2026 07:19:54 +0530	[thread overview]
Message-ID: <qzp0n4xp.ritesh.list@gmail.com> (raw)
In-Reply-To: <20260330103530.6873-1-venkat88@linux.ibm.com>

Venkat Rao Bagalkote <venkat88@linux.ibm.com> writes:

> The global nvram_mutex in drivers/char/nvram.c is redundant and unused,
> and this triggers compiler warnings on some configurations.
>
> All platform-specific nvram operations already provide their own internal
> synchronization, meaning the wrapper-level mutex does not provide any
> additional safety.
>
> Remove the nvram_mutex definition along with all remaining lock/unlock
> users across PPC32, x86, and m68k code paths, and rely entirely on the
> per-architecture nvram implementations for locking.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> ---
> v4:
>   - Remove all remaining nvram_mutex call sites, completing the mutex removal
>

Let me cut paste the review from Sashiko here..

    Does this removal expose the underlying raw spinlock to concurrent userspace
    contention?
    Looking at ppc_md.nvram_sync() implementations like core99_nvram_sync() on
    PowerMac, the code acquires a raw spinlock (nv_lock) and performs hardware
    flash memory operations with polling loops and udelay() calls that can take
    hundreds of milliseconds to complete.
    Because IOC_NVRAM_SYNC does not require CAP_SYS_ADMIN, any user with access
    to the device can call this ioctl.
    Previously, nvram_mutex provided a sleepable barrier for concurrent
    IOC_NVRAM_SYNC callers. Without it, won't secondary callers spin on the raw
    spinlock with interrupts disabled for the entire duration of the first
    caller's slow flash I/O?
    Could this prolonged spinning with IRQs disabled completely freeze the
    waiting CPUs and trigger NMI watchdog timeouts or system lockups?

First of all the above problem is only being talked about PowerMAC and
not for x86 / m68k. In there I think, we just read/write few bytes under
the spinlock.

On PowerMac too, I don't think the above problem gives a reason, to keep
a redundant locking at a generic wrapper layer which can affects other
platforms/archs. And the comment in PowerMac code above nv_lock says:
    // XXX Turn that into a sem
    static DEFINE_RAW_SPINLOCK(nv_lock);

So, it looks like Sashiko review comment can be ignored, and the patch
looks right to me, which kills the redundant mutex lock from here. So as
for this patch please feel free to add...

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

... But I would also let Chrisptophe comment from ppc32 / PowerMac perspective.

-ritesh


  reply	other threads:[~2026-03-31  2:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 10:35 [PATCH v4] char/nvram: Remove redundant nvram_mutex Venkat Rao Bagalkote
2026-03-31  1:49 ` Ritesh Harjani [this message]
2026-04-02 16:03 ` Tellakula Yeswanth Krishna
2026-04-07  6:41   ` Tellakula Yeswanth Krishna
2026-04-07  9:02     ` Venkat

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=qzp0n4xp.ritesh.list@gmail.com \
    --to=ritesh.list@gmail.com \
    --cc=arnd@arndb.de \
    --cc=chleroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=venkat88@linux.ibm.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