All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT fix for PWRCND!=0
@ 2012-07-28  1:14 Ronnie Sahlberg
  2012-07-28  1:14 ` [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0 Ronnie Sahlberg
  0 siblings, 1 reply; 6+ messages in thread
From: Ronnie Sahlberg @ 2012-07-28  1:14 UTC (permalink / raw)
  To: qemu-devel, pbonzini

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
  2012-07-28  1:14 [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT fix for PWRCND!=0 Ronnie Sahlberg
@ 2012-07-28  1:14 ` Ronnie Sahlberg
  2012-07-30  7:42   ` Paolo Bonzini
  2012-07-30  8:20   ` Kevin Wolf
  0 siblings, 2 replies; 6+ messages in thread
From: Ronnie Sahlberg @ 2012-07-28  1:14 UTC (permalink / raw)
  To: qemu-devel, pbonzini; +Cc: Ronnie Sahlberg

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.

>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.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
---
 hw/scsi-disk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 525816c..5426990 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -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) {
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
  2012-07-28  1:14 ` [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0 Ronnie Sahlberg
@ 2012-07-30  7:42   ` Paolo Bonzini
  2012-07-30  8:20   ` Kevin Wolf
  1 sibling, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2012-07-30  7:42 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: qemu-devel

Il 28/07/2012 03:14, Ronnie Sahlberg ha scritto:
> 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.
> 
> 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.
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>

Applied, thanks.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
  2012-07-28  1:14 ` [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0 Ronnie Sahlberg
  2012-07-30  7:42   ` Paolo Bonzini
@ 2012-07-30  8:20   ` Kevin Wolf
  2012-07-30  8:25     ` Paolo Bonzini
  2012-07-30  8:46     ` ronnie sahlberg
  1 sibling, 2 replies; 6+ messages in thread
From: Kevin Wolf @ 2012-07-30  8:20 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: pbonzini, qemu-devel

Am 28.07.2012 03:14, schrieb Ronnie Sahlberg:
> 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.
> 
> 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.
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>

Does ATAPI need the same?

Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
  2012-07-30  8:20   ` Kevin Wolf
@ 2012-07-30  8:25     ` Paolo Bonzini
  2012-07-30  8:46     ` ronnie sahlberg
  1 sibling, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2012-07-30  8:25 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel, Ronnie Sahlberg

Il 30/07/2012 10:20, Kevin Wolf ha scritto:
> Am 28.07.2012 03:14, schrieb Ronnie Sahlberg:
>> > 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.
>> > 
>> > 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.
>> > 
>> > Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> Does ATAPI need the same?

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

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
  2012-07-30  8:20   ` Kevin Wolf
  2012-07-30  8:25     ` Paolo Bonzini
@ 2012-07-30  8:46     ` ronnie sahlberg
  1 sibling, 0 replies; 6+ messages in thread
From: ronnie sahlberg @ 2012-07-30  8:46 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: pbonzini, qemu-devel

I will create a patch for ATAPI for this.

On Mon, Jul 30, 2012 at 6:20 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 28.07.2012 03:14, schrieb Ronnie Sahlberg:
>> 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.
>>
>> 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.
>>
>> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
>
> Does ATAPI need the same?
>
> Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-30  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-28  1:14 [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT fix for PWRCND!=0 Ronnie Sahlberg
2012-07-28  1:14 ` [Qemu-devel] [PATCH] SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0 Ronnie Sahlberg
2012-07-30  7:42   ` Paolo Bonzini
2012-07-30  8:20   ` Kevin Wolf
2012-07-30  8:25     ` Paolo Bonzini
2012-07-30  8:46     ` ronnie sahlberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.