From patchwork Sat Aug 1 16:11:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 502833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8FF571402A6 for ; Sun, 2 Aug 2015 02:12:10 +1000 (AEST) Received: from localhost ([::1]:54258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLZOK-0000nG-FJ for incoming@patchwork.ozlabs.org; Sat, 01 Aug 2015 12:12:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLZO7-0000Ud-QB for qemu-devel@nongnu.org; Sat, 01 Aug 2015 12:11:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZLZO4-0002ex-Vs for qemu-devel@nongnu.org; Sat, 01 Aug 2015 12:11:55 -0400 Received: from s16892447.onlinehome-server.info ([82.165.15.123]:52486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLZO4-0002ei-Pw for qemu-devel@nongnu.org; Sat, 01 Aug 2015 12:11:52 -0400 Received: from cpc2-slam8-2-0-cust642.2-4.cable.virginm.net ([82.24.206.131] helo=kentang.lan) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ZLZNw-0003YW-9D; Sat, 01 Aug 2015 17:11:45 +0100 From: Mark Cave-Ayland To: aurelien@aurel32.net, jsnow@redhat.com, agraf@suse.de, qemu-devel@nongnu.org Date: Sat, 1 Aug 2015 17:11:33 +0100 Message-Id: <1438445493-30610-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 X-SA-Exim-Connect-IP: 82.24.206.131 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH] macio: handle non-block ATAPI DMA transfers the same as block DMA transfers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The existing code incorrectly changes the dma_active flag when a non-block transfer has completed leading to a hang on newer versions of Linux because the IDE and DMA engines deadlock waiting for each other. Instead copy the buffer directly to RAM, set the remaining transfer size to 0 and then invoke the ATAPI callback manually once again to correctly finish the transfer in an identical manner to a block transfer. Signed-off-by: Mark Cave-Ayland --- hw/ide/macio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/ide/macio.c b/hw/ide/macio.c index a55a479..2384533 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -247,9 +247,12 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) /* Non-block ATAPI transfer - just copy to RAM */ s->io_buffer_size = MIN(s->io_buffer_size, io->len); cpu_physical_memory_write(io->addr, s->io_buffer, s->io_buffer_size); - ide_atapi_cmd_ok(s); - m->dma_active = false; - goto done; + + /* Invoke callback as we would at the end of a standard block + transfer */ + s->io_buffer_size = 0; + io->len = 0; + pmac_ide_atapi_transfer_cb(io, 0); } /* Calculate current offset */