Skip to content

ata: recover SATAPI ports and revalidate optical media - #129

Merged
FengHeting merged 4 commits into
ViudiraTech:developfrom
FengHeting:atapi-hotplug
Nov 4, 2026
Merged

FengHeting merged 4 commits into
ViudiraTech:developfrom
FengHeting:atapi-hotplug

Conversation

@FengHeting

Copy link
Copy Markdown
Contributor

Summary

Stacked on the pata-dma branch; retarget to develop once that PR is merged.

  • SATAPI: a task-file error or timeout restarts the port engine to clear the failed command's PxCI bit instead of leaving the port stalled. After a media change, READ CAPACITY is retried with REQUEST SENSE on unit attention / becoming ready, and the device geometry is updated.
  • Block layer: blockdev_ops gains an optional revalidate hook. devtmpfs calls it when a block node is opened, so the node size and block size follow the inserted disc.
  • An empty ATAPI drive keeps its sr number with capacity 0; reads and writes return -ENOMEDIUM, and the block-open path propagates the refresh error so a mount reports no medium.

Testing

  • make -j$(nproc) passes.
  • QEMU QMP blockdev-change-medium on ide1-cd1: eject/insert updates capacity, mounts after insertion succeed, and reads on an empty drive report no medium.

FengHeting and others added 3 commits November 5, 2026 03:50
The firmware pairs its host timing with the drive's DMA mode.  Probe each
drive without sending SET FEATURES or programming vendor timing registers,
then compare a PIO and a DMA read of the same sectors once at boot.  A
failed check, a missing BAR4, or a runtime bus-master error drops the drive
to PIO; ATA retries the same request in PIO, ATAPI resumes from the
completed offset, and a stuck BSY resets the channel.

ATAPI capacity probing follows REQUEST SENSE retries and maps a missing
medium to -ENOMEDIUM.

Signed-off-by: MicroFish <2609948707@qq.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
A failed packet leaves the port's PxCI bit set and stalls every later
command.  Restart the port engine after a task-file error or timeout, and
poll READ CAPACITY with REQUEST SENSE retries after a media change so a new
disc is picked up after unit attention or becoming ready.

Signed-off-by: MicroFish <2609948707@qq.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Add an optional blockdev_ops.revalidate hook and call it from devtmpfs when
a block node is opened, refreshing the node geometry after a disc change.
Reads and writes on an empty ATAPI drive return -ENOMEDIUM, and the block
open path propagates the refresh error so a mount reports the drive as
having no medium.

Signed-off-by: MicroFish <2609948707@qq.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@FengHeting
FengHeting merged commit f8c60e0 into ViudiraTech:develop Nov 4, 2026
2 checks passed
@FengHeting
FengHeting deleted the atapi-hotplug branch November 5, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant