From nobody Wed Oct 22 15:42:05 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 1519399743179933.3711171814457; Fri, 23 Feb 2018 07:29:03 -0800 (PST) Received: from localhost ([::1]:45180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFHS-0006GY-Br for importer@patchew.org; Fri, 23 Feb 2018 10:29:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFFK-0004aM-PI 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-0005VQ-Mw for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:26:50 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54270 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 1epFFE-0005QJ-Ms; Fri, 23 Feb 2018 10:26:44 -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 515A6F63FE; Fri, 23 Feb 2018 15:26:44 +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 3970020A846E; Fri, 23 Feb 2018 15:26:43 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 23 Feb 2018 16:26:36 +0100 Message-Id: <20180223152640.11459-2-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.1]); Fri, 23 Feb 2018 15:26:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 23 Feb 2018 15:26:44 +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 1/5] ide: push call to end_transfer_func out of start_transfer callback 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" Split the PIO transfer across two callbacks, thus pushing the (possibly recursive) call to end_transfer_func up one level and out of the AHCI-specific code. Signed-off-by: Paolo Bonzini --- hw/ide/ahci.c | 7 ++++++- hw/ide/core.c | 9 ++++++--- include/hw/ide/internal.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index e22d7be05f..937bad55fb 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1321,8 +1321,12 @@ out: =20 /* Update number of transferred bytes, destroy sglist */ dma_buf_commit(s, size); +} =20 - s->end_transfer_func(s); +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 */ @@ -1444,6 +1448,7 @@ static const IDEDMAOps ahci_dma_ops =3D { .restart =3D ahci_restart, .restart_dma =3D ahci_restart_dma, .start_transfer =3D ahci_start_transfer, + .end_transfer =3D ahci_end_transfer, .prepare_buf =3D ahci_dma_prepare_buf, .commit_buf =3D ahci_commit_buf, .rw_buf =3D ahci_dma_rw_buf, diff --git a/hw/ide/core.c b/hw/ide/core.c index 257b429381..92f4424dc3 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -532,16 +532,19 @@ static void ide_clear_retry(IDEState *s) void ide_transfer_start(IDEState *s, uint8_t *buf, int size, EndTransferFunc *end_transfer_func) { - s->end_transfer_func =3D end_transfer_func; s->data_ptr =3D buf; s->data_end =3D buf + size; ide_set_retry(s); if (!(s->status & ERR_STAT)) { s->status |=3D DRQ_STAT; } - if (s->bus->dma->ops->start_transfer) { - s->bus->dma->ops->start_transfer(s->bus->dma); + if (!s->bus->dma->ops->start_transfer) { + s->end_transfer_func =3D end_transfer_func; + return; } + 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) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 88212f59df..efaabbd815 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -445,6 +445,7 @@ struct IDEState { struct IDEDMAOps { DMAStartFunc *start_dma; DMAVoidFunc *start_transfer; + DMAVoidFunc *end_transfer; DMAInt32Func *prepare_buf; DMAu32Func *commit_buf; DMAIntFunc *rw_buf; --=20 2.14.3