All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Butsykin <pbutsykin@virtuozzo.com>
To: John Snow <jsnow@redhat.com>, "Denis V. Lunev" <den@openvz.org>,
	qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, rkagan@virtuozzo.com
Subject: Re: [Qemu-devel] [PATCH 2/3] ide: restart atapi dma by re-evaluating command packet
Date: Mon, 4 Apr 2016 13:32:21 +0300	[thread overview]
Message-ID: <570242B5.3080103@virtuozzo.com> (raw)
In-Reply-To: <56FEE1AF.2090102@redhat.com>

On 02.04.2016 00:01, John Snow wrote:
>
>
> On 04/01/2016 10:32 AM, Denis V. Lunev wrote:
>> From: Pavel Butsykin <pbutsykin@virtuozzo.com>
>>
>> ide_atapi_dma_restart() used to just complete the DMA with an error,
>> under the assumption that there isn't enough information to restart it.
>>
>> However, as the contents of the ->io_buffer is preserved, it looks safe to
>> just re-evaluate it and dispatch the ATAPI command again.
>>
>> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
>> Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
>> Signed-off-by: Denis V. Lunev <den@openvz.org>
>> ---
>>   hw/ide/atapi.c | 13 ++++++-------
>>   1 file changed, 6 insertions(+), 7 dweletions(-)
>>
>> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
>> index 1fe58ab..acc52cd 100644
>> --- a/hw/ide/atapi.c
>> +++ b/hw/ide/atapi.c
>> @@ -488,14 +488,13 @@ static void ide_atapi_cmd_read(IDEState *s, int lba, int nb_sectors,
>>   void ide_atapi_dma_restart(IDEState *s)
>>   {
>>       /*
>> -     * I'm not sure we have enough stored to restart the command
>> -     * safely, so give the guest an error it should recover from.
>> -     * I'm assuming most guests will try to recover from something
>> -     * listed as a medium error on a CD; it seems to work on Linux.
>> -     * This would be more of a problem if we did any other type of
>> -     * DMA operation.
>> +     * At this point we can just re-evaluate the packet command and start over.
>> +     * The presence of ->dma_cb callback in the pre_save ensures that the packet
>> +     * command has been completely sent and we can safely restart command.
>>        */
>> -    ide_atapi_cmd_error(s, MEDIUM_ERROR, ASC_NO_SEEK_COMPLETE);
>> +    s->unit = s->bus->retry_unit;
>> +    s->bus->dma->ops->restart_dma(s->bus->dma);
>> +    ide_atapi_cmd(s);
>>   }
>>
>>   static inline uint8_t ide_atapi_set_profile(uint8_t *buf, uint8_t *index,
>>
>
> Is it at all possible that a previous command may have edited the
> s->io_buffer that ide_atapi_cmd() uses for SCSI command dispatch?
>
> Let me try to answer my own question.
>
> Here's my understanding: On state change, ide_restart_bh is invoked
> unconditionally. If end_transfer_func is ide_atapi_cmd, we invoke
> ide_atapi_dma_restart.
>
> What are the conditions for end_transfer_func being set to ide_atapi_cmd
> on state change? well... mostly that any ATAPI command got interrupted
> before it finished, which is generally not possible with PIO or
> synchronous commands because the AIO flush on savevm or migrate should
> clear those requests out.
>
In general, it's impossible for ATAPI commands that don't need to set
the dma_cb for execution after bus mastering..

> I *think* the only time we run into this problem is with e.g. PCI HBAs
> where the DMA controller is programmed before we kick the HBA with the
> start signal... which I *think* means that we have no chance of actually
> editing the io_buffer before we attempt to "resume" this command --
> because if the command *starts* at all, it should *finish* and the only
> time we run into this migration case is if we didn't actually start the
> command.
>
> Did you audit this at all? Do I sound crazy or correct?

:) All looks correct to me! In the form in which there is now the
realization of the DMA ATAPI it should work. Although it doesn't
look so transparent.

> (I really should document this or clean up our restore/resume code, but
> that's not up to you. Just a passing thought...)
>
> Thanks,
> --js
>

  reply	other threads:[~2016-04-04 10:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 14:32 [Qemu-devel] [PATCH v3 0/3] ide: fix loss of the dma/atapi state during migration Denis V. Lunev
2016-04-01 14:32 ` [Qemu-devel] [PATCH 1/3] ide: don't lose pending dma state Denis V. Lunev
2016-04-01 14:32 ` [Qemu-devel] [PATCH 2/3] ide: restart atapi dma by re-evaluating command packet Denis V. Lunev
2016-04-01 21:01   ` John Snow
2016-04-04 10:32     ` Pavel Butsykin [this message]
2016-04-01 14:32 ` [Qemu-devel] [PATCH 3/3] ide: really restart pending and in-flight atapi dma Denis V. Lunev
2016-04-01 22:34   ` John Snow
2016-04-04 10:32     ` Pavel Butsykin
2016-04-04 16:24       ` John Snow
2016-04-04 16:54         ` Pavel Butsykin
2016-04-04 18:12           ` John Snow
  -- strict thread matches above, loose matches on Subject: below --
2016-04-06  6:40 [Qemu-devel] [PATCH for 2.6 v4 0/3] ide: fix loss of the dma/atapi state during migration Denis V. Lunev
2016-04-06  6:40 ` [Qemu-devel] [PATCH 2/3] ide: restart atapi dma by re-evaluating command packet Denis V. Lunev
2016-03-28 11:48 [Qemu-devel] [PATCH v2 for 2.6 0/3] ide: fix loss of the dma/atapi state during migration Denis V. Lunev
2016-03-28 11:48 ` [Qemu-devel] [PATCH 2/3] ide: restart atapi dma by re-evaluating command packet Denis V. Lunev
2016-03-23 10:26 [Qemu-devel] [PATCH for 2.6 0/3] ide: fix loss of the dma/atapi state during migration Denis V. Lunev
2016-03-23 10:26 ` [Qemu-devel] [PATCH 2/3] ide: restart atapi dma by re-evaluating command packet Denis V. Lunev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=570242B5.3080103@virtuozzo.com \
    --to=pbutsykin@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rkagan@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.