diff mbox

rombios/ata: Wait for BSY to clear after write

Message ID 20170613083432.5418-1-ross.lagerwall@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ross Lagerwall June 13, 2017, 8:34 a.m. UTC
After rombios transfers the data for a write, it checks the status and
fails if BSY is set. qemu-trad doesn't set BSY for PIO writes, but QEMU
upstream does, and this causes rombios to fail writes because they are
marked as BSY. Instead, wait for BSY to clear after a write.

INT 13 writes are probably rarely used these days, but they are used by
GRUB 2 to write to its environment file which happens by default on
Ubuntu.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 tools/firmware/rombios/rombios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Cooper June 13, 2017, 8:56 a.m. UTC | #1
On 13/06/17 09:34, Ross Lagerwall wrote:
> After rombios transfers the data for a write, it checks the status and
> fails if BSY is set. qemu-trad doesn't set BSY for PIO writes, but QEMU
> upstream does, and this causes rombios to fail writes because they are
> marked as BSY. Instead, wait for BSY to clear after a write.
>
> INT 13 writes are probably rarely used these days, but they are used by
> GRUB 2 to write to its environment file which happens by default on
> Ubuntu.
>
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

Ian/Wei: RomBIOS should probably join hvmloader under x86
maintainership, if you don't object?

> ---
>  tools/firmware/rombios/rombios.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/firmware/rombios/rombios.c b/tools/firmware/rombios/rombios.c
> index 58ace9b..51558ee 100644
> --- a/tools/firmware/rombios/rombios.c
> +++ b/tools/firmware/rombios/rombios.c
> @@ -3226,7 +3226,7 @@ ASM_END
>      current++;
>      write_word(ebda_seg, &EbdaData->ata.trsfsectors,current);
>      count--;
> -    status = inb(iobase1 + ATA_CB_STAT);
> +    status = await_ide(NOT_BSY, iobase1, IDE_TIMEOUT);
>      if (count == 0) {
>        if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
>            != ATA_CB_STAT_RDY ) {
Wei Liu June 13, 2017, 10:13 a.m. UTC | #2
On Tue, Jun 13, 2017 at 09:56:32AM +0100, Andrew Cooper wrote:
> On 13/06/17 09:34, Ross Lagerwall wrote:
> > After rombios transfers the data for a write, it checks the status and
> > fails if BSY is set. qemu-trad doesn't set BSY for PIO writes, but QEMU
> > upstream does, and this causes rombios to fail writes because they are
> > marked as BSY. Instead, wait for BSY to clear after a write.
> >
> > INT 13 writes are probably rarely used these days, but they are used by
> > GRUB 2 to write to its environment file which happens by default on
> > Ubuntu.
> >
> > Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> 
> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Ian/Wei: RomBIOS should probably join hvmloader under x86
> maintainership, if you don't object?
> 

No I don't.
diff mbox

Patch

diff --git a/tools/firmware/rombios/rombios.c b/tools/firmware/rombios/rombios.c
index 58ace9b..51558ee 100644
--- a/tools/firmware/rombios/rombios.c
+++ b/tools/firmware/rombios/rombios.c
@@ -3226,7 +3226,7 @@  ASM_END
     current++;
     write_word(ebda_seg, &EbdaData->ata.trsfsectors,current);
     count--;
-    status = inb(iobase1 + ATA_CB_STAT);
+    status = await_ide(NOT_BSY, iobase1, IDE_TIMEOUT);
     if (count == 0) {
       if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
           != ATA_CB_STAT_RDY ) {