diff mbox

[RFC,10/11] ide: corrected ATAPI checks to be ignored by ATAPI-SCSI bridge

Message ID 1439854945-5597-11-git-send-email-abezzubikov@ispras.ru
State New
Headers show

Commit Message

Aleksandr Bezzubikov Aug. 17, 2015, 11:42 p.m. UTC
Signed-off-by: Alexander Bezzubikov <abezzubikov@ispras.ru>
---
 hw/ide/atapi.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

Hannes Reinecke Aug. 18, 2015, 6:19 a.m. UTC | #1
On 08/18/2015 01:42 AM, Alexander Bezzubikov wrote:
> Signed-off-by: Alexander Bezzubikov <abezzubikov@ispras.ru>
> ---
>  hw/ide/atapi.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
> index 6e73910..896f595 100644
> --- a/hw/ide/atapi.c
> +++ b/hw/ide/atapi.c
> @@ -1230,7 +1230,8 @@ void ide_atapi_cmd(IDEState *s)
>       * states rely on this behavior.
>       */
>      if (!(atapi_cmd_table[s->io_buffer[0]].flags & ALLOW_UA) &&
> -        !s->tray_open && blk_is_inserted(s->blk) && s->cdrom_changed) {
> +        (s->drive_kind != IDE_BRIDGE && !s->tray_open &&
> +        blk_is_inserted(s->blk) && s->cdrom_changed)) {
>  
>          if (s->cdrom_changed == 1) {
>              ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
> @@ -1245,18 +1246,13 @@ void ide_atapi_cmd(IDEState *s)
>  
>      /* Report a Not Ready condition if appropriate for the command */
>      if ((atapi_cmd_table[s->io_buffer[0]].flags & CHECK_READY) &&
> -        (!media_present(s) || !blk_is_inserted(s->blk)))
> +        (s->drive_kind != IDE_BRIDGE &&
> +            (!media_present(s) || !blk_is_inserted(s->blk))))
>      {
>          ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
>          return;
>      }
>  
> -    /* Execute the command */
> -    if (atapi_cmd_table[s->io_buffer[0]].handler) {
> -        atapi_cmd_table[s->io_buffer[0]].handler(s, buf);
> -        return;
> -    }
> -
>      if (s->drive_kind == IDE_BRIDGE) {
>          IDEDevice *dev = s->bus->master;
>          SCSIDevice *scsi_dev = scsi_device_find(&dev->scsi_bus, 0, 0, 0);
> @@ -1273,5 +1269,11 @@ void ide_atapi_cmd(IDEState *s)
>          return;
>      }
>  
> +    /* Execute the command */
> +    if (atapi_cmd_table[s->io_buffer[0]].handler) {
> +        atapi_cmd_table[s->io_buffer[0]].handler(s, buf);
> +        return;
> +    }
> +
>      ide_atapi_cmd_error(s, ILLEGAL_REQUEST, ASC_ILLEGAL_OPCODE);
>  }
> 
Please merge it with patch 3.

Cheers,

Hannes
diff mbox

Patch

diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 6e73910..896f595 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -1230,7 +1230,8 @@  void ide_atapi_cmd(IDEState *s)
      * states rely on this behavior.
      */
     if (!(atapi_cmd_table[s->io_buffer[0]].flags & ALLOW_UA) &&
-        !s->tray_open && blk_is_inserted(s->blk) && s->cdrom_changed) {
+        (s->drive_kind != IDE_BRIDGE && !s->tray_open &&
+        blk_is_inserted(s->blk) && s->cdrom_changed)) {
 
         if (s->cdrom_changed == 1) {
             ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
@@ -1245,18 +1246,13 @@  void ide_atapi_cmd(IDEState *s)
 
     /* Report a Not Ready condition if appropriate for the command */
     if ((atapi_cmd_table[s->io_buffer[0]].flags & CHECK_READY) &&
-        (!media_present(s) || !blk_is_inserted(s->blk)))
+        (s->drive_kind != IDE_BRIDGE &&
+            (!media_present(s) || !blk_is_inserted(s->blk))))
     {
         ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
         return;
     }
 
-    /* Execute the command */
-    if (atapi_cmd_table[s->io_buffer[0]].handler) {
-        atapi_cmd_table[s->io_buffer[0]].handler(s, buf);
-        return;
-    }
-
     if (s->drive_kind == IDE_BRIDGE) {
         IDEDevice *dev = s->bus->master;
         SCSIDevice *scsi_dev = scsi_device_find(&dev->scsi_bus, 0, 0, 0);
@@ -1273,5 +1269,11 @@  void ide_atapi_cmd(IDEState *s)
         return;
     }
 
+    /* Execute the command */
+    if (atapi_cmd_table[s->io_buffer[0]].handler) {
+        atapi_cmd_table[s->io_buffer[0]].handler(s, buf);
+        return;
+    }
+
     ide_atapi_cmd_error(s, ILLEGAL_REQUEST, ASC_ILLEGAL_OPCODE);
 }