Re: [PATCH v3] mtd: rawnand: r852: preserve card changes during detection work
From: Miquel Raynal
Date: Fri Dec 04 2026 - 16:14:42 EST
On 08/11/2026 at 17:22:18 -07, James Hilliard <james.hilliard1@xxxxxxxxx> wrote:
> r852_update_card_detect() reads and writes the card interrupt enable
> register without holding irqlock. A card interrupt can mask detection
> interrupts and mark the card unstable between those accesses, only for
> the worker to overwrite the mask with its saved value.
>
> The worker also calls this helper before and after registering or
> unregistering a card. An interrupt between these calls starts a new
> debounce interval, but the second call clears card_unstable and enables
> interrupts again before that interval has elapsed. The interrupt can
> also change card_detected between the worker's registration checks and
> its media-property update.
>
> Hold irqlock across the interrupt mask update and leave the mask alone
> while the card is unstable. Move the transition to stable state into
> the locked card sample, and return that sample for both of the worker's
> registration decisions. Sample the write-protect and media-type fields
> there as well when a present card is not yet registered, so a later IRQ
> cannot make registration use properties left over from a previous card.
> Keep the properties of an already registered card unchanged.
>
> Keep registration failure from overwriting a newer interrupt's card
> state, so the next delayed work invocation can process that change.
>
> Fixes: 67e054e91924 ("mtd: nand: Add driver for Ricoh xD/SmartMedia reader")
> Cc: stable@xxxxxxxxxxxxxxx
> Closes: https://lore.kernel.org/r/sashiko-outbox-204068@xxxxxxxxxx/
> Closes: https://lore.kernel.org/r/sashiko-outbox-204135@xxxxxxxxxx/
> Link: https://lore.kernel.org/r/sashiko-outbox-204169@xxxxxxxxxx/
> Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
Same, after applying the first patch, these do not apply. Please make a
series for all the r852 fixes.