Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Pratyush Yadav <pratyush@kernel.org>,
	 Michael Walle <mwalle@kernel.org>,
	 Takahiro Kuwano <takahiro.kuwano@infineon.com>,
	Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	 linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	 Brian Norris <briannorris@chromium.org>
Subject: Re: [PATCH] mtd: spi-nor: Reschedule in spi_nor_wait_till_ready()
Date: Tue, 17 Nov 2026 09:47:56 +0100	[thread overview]
Message-ID: <87pkw3oncz.fsf@bootlin.com> (raw)
In-Reply-To: <534257c9-6f48-4a01-8589-330e4e4e41e1@acm.org> (Bart Van Assche's message of "Fri, 6 Nov 2026 13:11:08 -0800")

On 06/11/2026 at 13:11:08 -08, Bart Van Assche <bvanassche@acm.org> wrote:

> On 11/6/26 1:04 PM, Bart Van Assche wrote:
>> In spi_nor_wait_till_ready_with_timeout(), cond_resched() is only
>> called after spi_nor_ready() returns 0. If the flash is already ready on
>> the first status check, the function returns before reaching
>> cond_resched(). This happens e.g. under QEMU, where SPI NOR page
>> programs and sector erases complete synchronously during the MMIO write,
>> combined with a controller driver that polls without sleeping.
>> Consequently, multi-sector erases in spi_nor_erase() and multi-page
>> writes in spi_nor_write() may iterate over thousands of sectors or pages
>> without ever yielding the CPU on kernels built without
>> CONFIG_PREEMPTION, e.g. ARM32 kernels with CONFIG_PREEMPT_VOLUNTARY=y.
>> This triggers soft lockup and RCU stall reports.
>> Move cond_resched() to the start of the polling loop such that every
>> call reschedules if needed, even if the flash is ready on the first
>> check. Doing this in the shared wait helper instead of in the
>> spi_nor_erase() and spi_nor_write() loops covers all callers that wait
>> for a program or erase operation to complete.
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> ---

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2026-11-17  8:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 21:04 [PATCH] mtd: spi-nor: Reschedule in spi_nor_wait_till_ready() Bart Van Assche
2026-11-06 21:11 ` Bart Van Assche
2026-11-17  8:47   ` Miquel Raynal [this message]

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=87pkw3oncz.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=briannorris@chromium.org \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=takahiro.kuwano@infineon.com \
    --cc=vigneshr@ti.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