From nobody Wed Oct 22 15:42:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519399732895383.10770951786617; Fri, 23 Feb 2018 07:28:52 -0800 (PST) Received: from localhost ([::1]:45179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFHI-00068G-2W for importer@patchew.org; Fri, 23 Feb 2018 10:28:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFFK-0004aH-MD for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:26:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epFFJ-0005VH-K6 for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:26:50 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42646 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1epFFG-0005RT-1r; Fri, 23 Feb 2018 10:26:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F5EF8D6D6; Fri, 23 Feb 2018 15:26:45 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-249.ams2.redhat.com [10.36.117.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9332920A846E; Fri, 23 Feb 2018 15:26:44 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 23 Feb 2018 16:26:37 +0100 Message-Id: <20180223152640.11459-3-pbonzini@redhat.com> In-Reply-To: <20180223152640.11459-1-pbonzini@redhat.com> References: <20180223152640.11459-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 23 Feb 2018 15:26:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 23 Feb 2018 15:26:45 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/5] ide: push end_transfer callback to ide_transfer_halt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Lieven , John Snow , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The callback must be invoked once we get out of the DRQ phase; because all end_transfer_funcs end up invoking ide_transfer_stop, call it there. While at it, remove the "notify" argument from ide_transfer_halt; the code can simply be moved to ide_transfer_stop. Old PATA controllers have no end_transfer callback, so there is no change there. For AHCI the end_transfer_func already called ide_transfer_stop so the effect is that the PIO FIS is written before the D2H FIS rather than after, which is arguably an improvement. However, ahci_end_transfer is now called _after_ the DRQ_STAT has been cleared, so remove the status check in ahci_end_transfer; it was only there to ensure the FIS was not written more than once, and this cannot happen anymore. Signed-off-by: Paolo Bonzini --- hw/ide/ahci.c | 7 ++----- hw/ide/core.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 937bad55fb..c3c6843b76 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1326,12 +1326,9 @@ out: static void ahci_end_transfer(IDEDMA *dma) { AHCIDevice *ad =3D DO_UPCAST(AHCIDevice, dma, dma); - IDEState *s =3D &ad->port.ifs[0]; =20 - if (!(s->status & DRQ_STAT)) { - /* done with PIO send/receive */ - ahci_write_fis_pio(ad, le32_to_cpu(ad->cur_cmd->status)); - } + /* done with PIO send/receive */ + ahci_write_fis_pio(ad, le32_to_cpu(ad->cur_cmd->status)); } =20 static void ahci_start_dma(IDEDMA *dma, IDEState *s, diff --git a/hw/ide/core.c b/hw/ide/core.c index 92f4424dc3..c4710a6f55 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -544,7 +544,6 @@ void ide_transfer_start(IDEState *s, uint8_t *buf, int = size, } s->bus->dma->ops->start_transfer(s->bus->dma); end_transfer_func(s); - s->bus->dma->ops->end_transfer(s->bus->dma); } =20 static void ide_cmd_done(IDEState *s) @@ -555,26 +554,26 @@ static void ide_cmd_done(IDEState *s) } =20 static void ide_transfer_halt(IDEState *s, - void(*end_transfer_func)(IDEState *), - bool notify) + void(*end_transfer_func)(IDEState *)) { s->end_transfer_func =3D end_transfer_func; s->data_ptr =3D s->io_buffer; s->data_end =3D s->io_buffer; s->status &=3D ~DRQ_STAT; - if (notify) { - ide_cmd_done(s); - } } =20 void ide_transfer_stop(IDEState *s) { - ide_transfer_halt(s, ide_transfer_stop, true); + ide_transfer_halt(s, ide_transfer_stop); + if (s->bus->dma->ops->end_transfer) { + s->bus->dma->ops->end_transfer(s->bus->dma); + } + ide_cmd_done(s); } =20 static void ide_transfer_cancel(IDEState *s) { - ide_transfer_halt(s, ide_transfer_cancel, false); + ide_transfer_halt(s, ide_transfer_cancel); } =20 int64_t ide_get_sector(IDEState *s) --=20 2.14.3