diff mbox

[v2,1/2] fdc: fix relative seek

Message ID 9dc073c2eb42bb753565f23644bf449cb05ed4ed.1342440657.git.phrdina@redhat.com
State New
Headers show

Commit Message

Pavel Hrdina July 16, 2012, 12:25 p.m. UTC
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 hw/fdc.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Kevin Wolf July 16, 2012, 1:24 p.m. UTC | #1
Am 16.07.2012 14:25, schrieb Pavel Hrdina:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  hw/fdc.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

I applied both to the block branch for now. This restores the behaviour
as it was before 6be01b1e. However, I believe it is still wrong: The
direction should be interpreted the other way round, i.e. seek_out
should decrease the cylinder number and seek_in should increase it.

Do you have a guest that actually uses this command?

Kevin
Pavel Hrdina July 16, 2012, 1:26 p.m. UTC | #2
On 07/16/2012 03:24 PM, Kevin Wolf wrote:
> Am 16.07.2012 14:25, schrieb Pavel Hrdina:
>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>> ---
>>   hw/fdc.c |    6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
> I applied both to the block branch for now. This restores the behaviour
> as it was before 6be01b1e. However, I believe it is still wrong: The
> direction should be interpreted the other way round, i.e. seek_out
> should decrease the cylinder number and seek_in should increase it.
>
> Do you have a guest that actually uses this command?
>
> Kevin
I have host with real floppy device and I could send command directly, 
so I'll check this behavior.

Pavel
Pavel Hrdina July 16, 2012, 1:30 p.m. UTC | #3
On 07/16/2012 03:26 PM, Pavel Hrdina wrote:
> On 07/16/2012 03:24 PM, Kevin Wolf wrote:
>> Am 16.07.2012 14:25, schrieb Pavel Hrdina:
>>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>>> ---
>>>   hw/fdc.c |    6 ++++--
>>>   1 file changed, 4 insertions(+), 2 deletions(-)
>> I applied both to the block branch for now. This restores the behaviour
>> as it was before 6be01b1e. However, I believe it is still wrong: The
>> direction should be interpreted the other way round, i.e. seek_out
>> should decrease the cylinder number and seek_in should increase it.
>>
>> Do you have a guest that actually uses this command?
>>
>> Kevin
> I have host with real floppy device and I could send command directly, 
> so I'll check this behavior.
>
> Pavel
Well, you're right... seek in increase track and seek out decrease 
track. I suspect that it was correct.
I'll send v3 with this fix.

Pavel
diff mbox

Patch

diff --git a/hw/fdc.c b/hw/fdc.c
index edf0706..decb1f7 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1705,7 +1705,8 @@  static void fdctrl_handle_relative_seek_out(FDCtrl *fdctrl, int direction)
         fd_seek(cur_drv, cur_drv->head, cur_drv->max_track - 1,
                 cur_drv->sect, 1);
     } else {
-        fd_seek(cur_drv, cur_drv->head, fdctrl->fifo[2], cur_drv->sect, 1);
+        fd_seek(cur_drv, cur_drv->head,
+                cur_drv->track + fdctrl->fifo[2], cur_drv->sect, 1);
     }
     fdctrl_reset_fifo(fdctrl);
     /* Raise Interrupt */
@@ -1721,7 +1722,8 @@  static void fdctrl_handle_relative_seek_in(FDCtrl *fdctrl, int direction)
     if (fdctrl->fifo[2] > cur_drv->track) {
         fd_seek(cur_drv, cur_drv->head, 0, cur_drv->sect, 1);
     } else {
-        fd_seek(cur_drv, cur_drv->head, fdctrl->fifo[2], cur_drv->sect, 1);
+        fd_seek(cur_drv, cur_drv->head,
+                cur_drv->track - fdctrl->fifo[2], cur_drv->sect, 1);
     }
     fdctrl_reset_fifo(fdctrl);
     /* Raise Interrupt */