[SeaBIOS] [PATCH v3 0/3] floppy: detect an empty drive without waiting for a timeout

Christian Quante posted 3 patches 1 week, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/seabios tags/patchew/20260714164151.61002-1-christian@quante.one
src/hw/floppy.c | 77 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 70 insertions(+), 7 deletions(-)
[SeaBIOS] [PATCH v3 0/3] floppy: detect an empty drive without waiting for a timeout
Posted by Christian Quante 1 week, 4 days ago
Kevin, thanks again -- both points fixed, and the 0x0C/0xC0 transposition
you dug up is now in 3/3 where it belongs.

  2/3  A failed seek is passed up rather than reported as success, and the
       head goes back to cylinder 0 once a medium is found, so the READ ID
       in floppy_media_sense() runs on the same track it always did.  You
       were right to flag that -- it was a behaviour change I had waved
       through with a comment instead of fixing.

  3/3  Unchanged apart from the commit message, which now credits where
       0xC0 came from.

Changes since v2:
  - floppy_check_media() passes a seek error up (was: masked as success)
  - it seeks back to cylinder 0 when a medium is present
  - commit message of 2/3 no longer claims the head is simply left behind
  - commit message of 2/3 says where the ten-second figure comes from
  - commit message of 3/3 carries the Bochs 0x0C history

A clarification on the timing, because v2 conflated two things that are not
the same.  The ten-second wait is a real-hardware effect and does not appear
under QEMU at all: QEMU completes READ ID on an empty drive (a bug of its
own), and the fix on qemu-devel makes the command fail immediately rather
than never complete -- so neither of them shows the wait.  The figure comes
from a further change that makes QEMU leave READ ID unfinished the way
hardware does.  That one is local and not proposed upstream; it could not be
until this series is in place, or every access to an empty drive under QEMU
would cost ten seconds.

INT 13h AH=02h on an empty A:, SeaBIOS 1.17.0, each commit built and measured
on its own:

  QEMU made to behave like hardware (READ ID never completes)
    upstream                     10.13 s   AH = 0xC0
    1/3 floppy_drive_seek()      10.13 s   AH = 0xC0   (no functional change)
    2/3 disk change probe         0.11 s   AH = 0xC0
    3/3 not ready                 0.11 s   AH = 0x80

  QEMU as it stands today (READ ID succeeds on an empty drive)
    upstream                      0.11 s   AH = 0x20
    1/3                           0.11 s   AH = 0x20
    2/3                           0.11 s   AH = 0xC0
    3/3                           0.11 s   AH = 0x80

So on stock QEMU the series saves no time -- there is no wait to save -- but
it still turns "controller failure" into "not ready".  The wait it removes is
the one on real hardware.

The extra seek back to cylinder 0 costs no measurable time.  A diskette in
the drive is still read, and booting from one -- including the cold start
where the change line is set for a freshly inserted medium -- is unchanged.

Still not verified against real hardware; I have none with a floppy drive.

Christian Quante (3):
  floppy: add floppy_drive_seek()
  floppy: detect an empty drive via the disk change line
  floppy: report an empty drive as not ready

 src/hw/floppy.c | 77 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 70 insertions(+), 7 deletions(-)

-- 
2.53.0

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH v3 0/3] floppy: detect an empty drive without waiting for a timeout
Posted by Kevin O'Connor via SeaBIOS 3 days ago
On Tue, Jul 14, 2026 at 06:41:48PM +0200, Christian Quante wrote:
> Kevin, thanks again -- both points fixed, and the 0x0C/0xC0 transposition
> you dug up is now in 3/3 where it belongs.
> 
>   2/3  A failed seek is passed up rather than reported as success, and the
>        head goes back to cylinder 0 once a medium is found, so the READ ID
>        in floppy_media_sense() runs on the same track it always did.  You
>        were right to flag that -- it was a behaviour change I had waved
>        through with a comment instead of fixing.
> 
>   3/3  Unchanged apart from the commit message, which now credits where
>        0xC0 came from.
> 
> Changes since v2:
>   - floppy_check_media() passes a seek error up (was: masked as success)
>   - it seeks back to cylinder 0 when a medium is present
>   - commit message of 2/3 no longer claims the head is simply left behind
>   - commit message of 2/3 says where the ten-second figure comes from
>   - commit message of 3/3 carries the Bochs 0x0C history

Thanks.  I committed this series.

-Kevin

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH v3 0/3] floppy: detect an empty drive without waiting for a timeout
Posted by Kevin O'Connor via SeaBIOS 1 week, 4 days ago
On Tue, Jul 14, 2026 at 06:41:48PM +0200, Christian Quante wrote:
> Kevin, thanks again -- both points fixed, and the 0x0C/0xC0 transposition
> you dug up is now in 3/3 where it belongs.
> 
>   2/3  A failed seek is passed up rather than reported as success, and the
>        head goes back to cylinder 0 once a medium is found, so the READ ID
>        in floppy_media_sense() runs on the same track it always did.  You
>        were right to flag that -- it was a behaviour change I had waved
>        through with a comment instead of fixing.
> 
>   3/3  Unchanged apart from the commit message, which now credits where
>        0xC0 came from.
> 
> Changes since v2:
>   - floppy_check_media() passes a seek error up (was: masked as success)
>   - it seeks back to cylinder 0 when a medium is present
>   - commit message of 2/3 no longer claims the head is simply left behind
>   - commit message of 2/3 says where the ten-second figure comes from
>   - commit message of 3/3 carries the Bochs 0x0C history
> 
> A clarification on the timing, because v2 conflated two things that are not
> the same.  The ten-second wait is a real-hardware effect and does not appear
> under QEMU at all: QEMU completes READ ID on an empty drive (a bug of its
> own), and the fix on qemu-devel makes the command fail immediately rather
> than never complete -- so neither of them shows the wait.  The figure comes
> from a further change that makes QEMU leave READ ID unfinished the way
> hardware does.  That one is local and not proposed upstream; it could not be
> until this series is in place, or every access to an empty drive under QEMU
> would cost ten seconds.
> 
> INT 13h AH=02h on an empty A:, SeaBIOS 1.17.0, each commit built and measured
> on its own:
> 
>   QEMU made to behave like hardware (READ ID never completes)
>     upstream                     10.13 s   AH = 0xC0
>     1/3 floppy_drive_seek()      10.13 s   AH = 0xC0   (no functional change)
>     2/3 disk change probe         0.11 s   AH = 0xC0
>     3/3 not ready                 0.11 s   AH = 0x80
> 
>   QEMU as it stands today (READ ID succeeds on an empty drive)
>     upstream                      0.11 s   AH = 0x20
>     1/3                           0.11 s   AH = 0x20
>     2/3                           0.11 s   AH = 0xC0
>     3/3                           0.11 s   AH = 0x80
> 
> So on stock QEMU the series saves no time -- there is no wait to save -- but
> it still turns "controller failure" into "not ready".  The wait it removes is
> the one on real hardware.
> 
> The extra seek back to cylinder 0 costs no measurable time.  A diskette in
> the drive is still read, and booting from one -- including the cold start
> where the change line is set for a freshly inserted medium -- is unchanged.
> 
> Still not verified against real hardware; I have none with a floppy drive.

Thanks.  It seems fine to me.  I'll give a few days to see if there
are further comments and otherwise look to commit.

It'll be difficult to get testing on real floppy hardware given how
rare they are.  I don't think we need to wait for that.

Cheers,
-Kevin

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org