Re: [PATCH] ata: libata-sff: replace kmap_atomic() with kmap_local_page()

From: Damien Le Moal

Date: Mon Sep 21 2026 - 23:18:13 EST


On 9/22/26 03:24, Danish Khateeb wrote:
> kmap_atomic() is deprecated in favour of kmap_local_page(), as described
> in Documentation/mm/highmem.rst.
>
> ata_pio_xfer() and __atapi_pio_bytes() each map a single page, pass the
> address to ->sff_data_xfer() for one transfer and unmap it again, so the
> mapping never leaves the function that created it.
>
> Neither needs the pagefault_disable() and preempt_disable() implied by
> kmap_atomic(). ->sff_data_xfer() only moves data between the device and
> the mapped buffer, and both functions are reached only through
> ata_sff_hsm_move() with the host lock held, whether from the PIO task,
> an interrupt handler or EH. kmap_local_page() is fine in all of these.
>
> Tested on i386 with CONFIG_HIGHMEM4G and CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP
> under QEMU, with the PIIX IDE controller limited to PIO by
> libata.force=pio4: O_DIRECT and buffered reads from an ATA disk and an
> ATAPI CD-ROM, and O_DIRECT writes to the disk, all checked against the
> image files. The O_DIRECT buffers were in highmem. Both call sites ran
> in hardirq context, and ata_pio_xfer() also from the PIO task. No
> warnings with lockdep and CONFIG_DEBUG_ATOMIC_SLEEP enabled.
>
> Assisted-by: LLM sparse
> Signed-off-by: Danish Khateeb <danishkhateeb03@xxxxxxxxx>

Looks OK.

Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>

--
Damien Le Moal
Western Digital Research