Patchwork scsi: Fix SCSI bus reset

login
register
mail settings
Submitter Jan Kiszka
Date July 6, 2010, 8:58 a.m.
Message ID <4C32F01B.7080101@siemens.com>
Download mbox | patch
Permalink /patch/57988/
State New
Headers show

Comments

Jan Kiszka - July 6, 2010, 8:58 a.m.
When the controller raises the SCSI reset line, we have to perform the
requested reset on all disks attached to the controller's bus. Moreover,
reset is edge triggered, so avoid repeating it if the line was already
high.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/lsi53c895a.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
Anthony Liguori - July 6, 2010, 3:47 p.m.
On 07/06/2010 03:58 AM, Jan Kiszka wrote:
> When the controller raises the SCSI reset line, we have to perform the
> requested reset on all disks attached to the controller's bus. Moreover,
> reset is edge triggered, so avoid repeating it if the line was already
> high.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   hw/lsi53c895a.c |   15 +++++++++++++--
>   1 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
> index 9a37fed..249c6bf 100644
> --- a/hw/lsi53c895a.c
> +++ b/hw/lsi53c895a.c
> @@ -1590,8 +1590,19 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
>               BADF("Immediate Arbritration not implemented\n");
>           }
>           if (val&  LSI_SCNTL1_RST) {
> -            s->sstat0 |= LSI_SSTAT0_RST;
> -            lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
> +            if (!(s->sstat0&  LSI_SSTAT0_RST)) {
> +                DeviceState *dev;
> +                int id;
> +
> +                for (id = 0; id<  s->bus.ndev; id++) {
> +                    if (s->bus.devs[id]) {
> +                        dev =&s->bus.devs[id]->qdev;
> +                        dev->info->reset(dev);
> +                    }
> +                }
> +                s->sstat0 |= LSI_SSTAT0_RST;
> +                lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
> +            }
>           } else {
>               s->sstat0&= ~LSI_SSTAT0_RST;
>           }
>

Patch

diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 9a37fed..249c6bf 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -1590,8 +1590,19 @@  static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
             BADF("Immediate Arbritration not implemented\n");
         }
         if (val & LSI_SCNTL1_RST) {
-            s->sstat0 |= LSI_SSTAT0_RST;
-            lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
+            if (!(s->sstat0 & LSI_SSTAT0_RST)) {
+                DeviceState *dev;
+                int id;
+
+                for (id = 0; id < s->bus.ndev; id++) {
+                    if (s->bus.devs[id]) {
+                        dev = &s->bus.devs[id]->qdev;
+                        dev->info->reset(dev);
+                    }
+                }
+                s->sstat0 |= LSI_SSTAT0_RST;
+                lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
+            }
         } else {
             s->sstat0 &= ~LSI_SSTAT0_RST;
         }