diff mbox

[v2,5/6] ide: Add silent DRQ cancellation

Message ID 1453225191-11871-6-git-send-email-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

John Snow Jan. 19, 2016, 5:39 p.m. UTC
Split apart the ide_transfer_stop function into two versions: one that
interrupts and one that doesn't. The one that doesn't can be used to
halt any PIO transfers that are in the DRQ phase. It will not halt
any PIO transfers that are currently in the process of buffering data
for the guest to read.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 hw/ide/core.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Stefan Hajnoczi Feb. 8, 2016, 4:09 p.m. UTC | #1
On Tue, Jan 19, 2016 at 12:39:50PM -0500, John Snow wrote:
> Split apart the ide_transfer_stop function into two versions: one that
> interrupts and one that doesn't. The one that doesn't can be used to
> halt any PIO transfers that are in the DRQ phase. It will not halt
> any PIO transfers that are currently in the process of buffering data
> for the guest to read.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  hw/ide/core.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/ide/core.c b/hw/ide/core.c
> index cf0b5ec..9bc8e58 100644
> --- a/hw/ide/core.c
> +++ b/hw/ide/core.c
> @@ -486,13 +486,26 @@ static void ide_cmd_done(IDEState *s)
>      }
>  }
>  
> -void ide_transfer_stop(IDEState *s)
> +static void ide_transfer_halt(IDEState *s, void(*etf)(IDEState *), bool notify)
>  {
> -    s->end_transfer_func = ide_transfer_stop;
> +    s->end_transfer_func = etf;

Please keep using full names so the code is easier to understand:
s/etc/end_transfer_func/
John Snow Feb. 8, 2016, 5:08 p.m. UTC | #2
On 02/08/2016 11:09 AM, Stefan Hajnoczi wrote:
> On Tue, Jan 19, 2016 at 12:39:50PM -0500, John Snow wrote:
>> Split apart the ide_transfer_stop function into two versions: one that
>> interrupts and one that doesn't. The one that doesn't can be used to
>> halt any PIO transfers that are in the DRQ phase. It will not halt
>> any PIO transfers that are currently in the process of buffering data
>> for the guest to read.
>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>> ---
>>  hw/ide/core.c | 19 ++++++++++++++++---
>>  1 file changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/ide/core.c b/hw/ide/core.c
>> index cf0b5ec..9bc8e58 100644
>> --- a/hw/ide/core.c
>> +++ b/hw/ide/core.c
>> @@ -486,13 +486,26 @@ static void ide_cmd_done(IDEState *s)
>>      }
>>  }
>>  
>> -void ide_transfer_stop(IDEState *s)
>> +static void ide_transfer_halt(IDEState *s, void(*etf)(IDEState *), bool notify)
>>  {
>> -    s->end_transfer_func = ide_transfer_stop;
>> +    s->end_transfer_func = etf;
> 
> Please keep using full names so the code is easier to understand:
> s/etc/end_transfer_func/
> 

If this is the only feedback, I'll just clean this up in the PR, thanks.

--js
Stefan Hajnoczi Feb. 9, 2016, 1:21 p.m. UTC | #3
On Mon, Feb 08, 2016 at 12:08:08PM -0500, John Snow wrote:
> 
> 
> On 02/08/2016 11:09 AM, Stefan Hajnoczi wrote:
> > On Tue, Jan 19, 2016 at 12:39:50PM -0500, John Snow wrote:
> >> Split apart the ide_transfer_stop function into two versions: one that
> >> interrupts and one that doesn't. The one that doesn't can be used to
> >> halt any PIO transfers that are in the DRQ phase. It will not halt
> >> any PIO transfers that are currently in the process of buffering data
> >> for the guest to read.
> >>
> >> Signed-off-by: John Snow <jsnow@redhat.com>
> >> ---
> >>  hw/ide/core.c | 19 ++++++++++++++++---
> >>  1 file changed, 16 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/hw/ide/core.c b/hw/ide/core.c
> >> index cf0b5ec..9bc8e58 100644
> >> --- a/hw/ide/core.c
> >> +++ b/hw/ide/core.c
> >> @@ -486,13 +486,26 @@ static void ide_cmd_done(IDEState *s)
> >>      }
> >>  }
> >>  
> >> -void ide_transfer_stop(IDEState *s)
> >> +static void ide_transfer_halt(IDEState *s, void(*etf)(IDEState *), bool notify)
> >>  {
> >> -    s->end_transfer_func = ide_transfer_stop;
> >> +    s->end_transfer_func = etf;
> > 
> > Please keep using full names so the code is easier to understand:
> > s/etc/end_transfer_func/
> > 
> 
> If this is the only feedback, I'll just clean this up in the PR, thanks.

Yes, that's fine.
diff mbox

Patch

diff --git a/hw/ide/core.c b/hw/ide/core.c
index cf0b5ec..9bc8e58 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -486,13 +486,26 @@  static void ide_cmd_done(IDEState *s)
     }
 }
 
-void ide_transfer_stop(IDEState *s)
+static void ide_transfer_halt(IDEState *s, void(*etf)(IDEState *), bool notify)
 {
-    s->end_transfer_func = ide_transfer_stop;
+    s->end_transfer_func = etf;
     s->data_ptr = s->io_buffer;
     s->data_end = s->io_buffer;
     s->status &= ~DRQ_STAT;
-    ide_cmd_done(s);
+    if (notify) {
+        ide_cmd_done(s);
+    }
+}
+
+void ide_transfer_stop(IDEState *s)
+{
+    ide_transfer_halt(s, ide_transfer_stop, true);
+}
+
+__attribute__((__unused__))
+static void ide_transfer_cancel(IDEState *s)
+{
+    ide_transfer_halt(s, ide_transfer_cancel, false);
 }
 
 int64_t ide_get_sector(IDEState *s)