Skip to contentSkip to conversation

SCSI: STARTSTOPUNIT fix for PWRCND!=0

PATCH New Ronnie Sahlberg 3 participants 6 messages Jul 28, 2012 – Jul 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SCSI: STARTSTOPUNIT fix for PWRCND!=0

Paolo, List

Please find a trivial fix for the STARTSTOPUNIT emulation. This command will only eject/load media if powercondition is 0.

With this patch, QEMU SCSI emulation now pass all my SSU tests :

$ ./bin/iscsi-test --dataloss --test="*startstop*" iscsi://127.0.0.1:32601/iqn.qemu.scsi-test/3
0360_startstopunit_simple:
===================
Media is removable. STARTSTOPUNIT should work
Try to eject the media ... [OK]
Try to mount the media again ... [OK]
TEST T0360_startstopunit_simple [OK]

0361_startstopunit_pwrcnd:
===================
Media is removable. STARTSTOPUNIT should work
Try to eject media with PC != 0 ... [OK]
Try to mount the media again ... [OK]
TEST T0361_startstopunit_pwrcnd [OK]

regards
ronnie sahlberg

#1 lore raw

PATCH 1/1 SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0

The START STOP UNIT command will only eject/load media if power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

Quoted 1 line

From MMC (sbc contains similar wordings too)

The Power Conditions field requests the block device to be placed in the power condition defined in
Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored.

---
 hw/scsi-disk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/scsi-disk.c +6 -0
index 525816c..5426990 100644
@@ -1244,6 +1244,12 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
     bool start = req->cmd.buf[4] & 1;
     bool loej = req->cmd.buf[4] & 2; /* load on start, eject on !start */
+    int pwrcnd = req->cmd.buf[4] & 0xf0;
+
+    if (pwrcnd) {
+        /* eject/load only happens for power condition == 0 */
+        return 0;
+    }
 
     if (s->qdev.type == TYPE_ROM && loej) {
         if (!start && !s->tray_open && s->tray_locked) {
Signature · 1 line
1.7.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0

Il 28/07/2012 03:14, Ronnie Sahlberg ha scritto:

Quoted 5 lines

The START STOP UNIT command will only eject/load media if power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

Quoted 7 lines

From MMC (sbc contains similar wordings too)
The Power Conditions field requests the block device to be placed in the power condition defined in
Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored.

Applied, thanks.

Paolo

#3 lore raw

Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0

In reply to Ronnie Sahlberg

Am 28.07.2012 03:14, schrieb Ronnie Sahlberg:

Quoted 5 lines

The START STOP UNIT command will only eject/load media if power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

Quoted 7 lines

From MMC (sbc contains similar wordings too)
The Power Conditions field requests the block device to be placed in the power condition defined in
Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored.

Does ATAPI need the same?

Kevin

#4 lore raw

Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0

Il 30/07/2012 10:20, Kevin Wolf ha scritto:

Quoted 6 lines

Am 28.07.2012 03:14, schrieb Ronnie Sahlberg:

Quoted 5 lines
Quoted 5 lines

The START STOP UNIT command will only eject/load media if power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

From MMC (sbc contains similar wordings too)
The Power Conditions field requests the block device to be placed in the power condition defined in
Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored.

Does ATAPI need the same?

Yes, I already asked Ronnie to redo these two patches for ATAPI as well.

Paolo

#5 lore raw

Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0

In reply to Kevin Wolf

I will create a patch for ATAPI for this.

Quoted 17 lines · Kevin Wolf

Am 28.07.2012 03:14, schrieb Ronnie Sahlberg:

Quoted 5 lines

The START STOP UNIT command will only eject/load media if power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

Quoted 7 lines

From MMC (sbc contains similar wordings too)
The Power Conditions field requests the block device to be placed in the power condition defined in
Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored.

Does ATAPI need the same?

Kevin