From patchwork Fri Jun 20 14:29:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 362290 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 E00C4140092 for ; Sat, 21 Jun 2014 00:33:04 +1000 (EST) Received: from localhost ([::1]:41387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxzsF-0002d8-0C for incoming@patchwork.ozlabs.org; Fri, 20 Jun 2014 10:33:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxzrs-0002Ik-Rk for qemu-devel@nongnu.org; Fri, 20 Jun 2014 10:32:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wxzrn-0006Vq-B4 for qemu-devel@nongnu.org; Fri, 20 Jun 2014 10:32:40 -0400 Received: from s16892447.onlinehome-server.info ([82.165.15.123]:51910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxzrc-0006SA-5V; Fri, 20 Jun 2014 10:32:24 -0400 Received: from 5ec2b745.skybroadband.com ([94.194.183.69] helo=[192.168.1.78]) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1WxzrL-0000Xx-HX; Fri, 20 Jun 2014 15:32:15 +0100 Message-ID: <53A44548.7020605@ilande.co.uk> Date: Fri, 20 Jun 2014 15:29:28 +0100 From: Mark Cave-Ayland User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 MIME-Version: 1.0 To: Alexander Graf , BALATON Zoltan References: <1401885899-16524-1-git-send-email-agraf@suse.de> <1401885899-16524-76-git-send-email-agraf@suse.de> In-Reply-To: <1401885899-16524-76-git-send-email-agraf@suse.de> X-SA-Exim-Connect-IP: 94.194.183.69 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 Cc: "qemu-ppc@nongnu.org" , qemu-devel Subject: Re: [Qemu-devel] [PULL 075/118] macio: handle non-block ATAPI 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 On 04/06/14 13:44, Alexander Graf wrote: > From: Mark Cave-Ayland > > Currently the macio DMA routines assume that all DMA requests are for read/write > block transfers. This is not always the case for ATAPI, for example when > requesting a TOC where the response is generated directly in the IDE buffer. > > Detect these non-block ATAPI DMA transfers (where no lba is specified in the > command) and copy the results directly into RAM as indicated by the DBDMA > descriptor. This fixes CDROM access under MorphOS. > > Signed-off-by: Mark Cave-Ayland > Signed-off-by: Alexander Graf I've just done a complete round of OpenBIOS tests and it looks as if this patch introduces random hang failures (60% or so) into my Darwin image boot tests. The issue seems to be related as to the timing of the DMA callback relative to reception of the IDE command; if the IDE transfer is invoked first (as happens in Darwin) then we hang after sending the IDE command which is likely because the DMA is not being completed correctly. There is also another difference with MorphOS in that when the IDE transfer callback is invoked first then s->packet_transfer_size == 0 and so the memory copy would always copy 0 bytes. After some experimentation, I've come up with the attached patch which should retain the DMA memory copy, but instead invokes a further round of pmac_ide_atapi_transfer_cb() with io->len == 0 and s->io_buffer_size == 0 which should terminate the DMA request correctly. At the very least it seems to fix the hang on boot with my Darwin images. Zoltan, please can you test the attached patch to see if this still allows MorphOS to boot? ATB, Mark. diff --git a/hw/ide/macio.c b/hw/ide/macio.c index c14a1dd..39bc7fd 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -367,27 +367,21 @@ static void pmac_ide_transfer(DBDMA_io *io) s->io_buffer_size = 0; if (s->drive_kind == IDE_CD) { + bdrv_acct_start(s->bs, &s->acct, io->len, BDRV_ACCT_READ); + /* Handle non-block ATAPI DMA transfers */ if (s->lba == -1) { - s->io_buffer_size = MIN(io->len, s->packet_transfer_size); - bdrv_acct_start(s->bs, &s->acct, s->io_buffer_size, - BDRV_ACCT_READ); MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n", - s->io_buffer_size); + io->len); - /* Copy ATAPI buffer directly to RAM and finish */ + /* Copy ATAPI buffer directly to RAM */ cpu_physical_memory_write(io->addr, s->io_buffer, - s->io_buffer_size); - ide_atapi_cmd_ok(s); - m->dma_active = false; - - MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n"); - bdrv_acct_done(s->bs, &s->acct); - io->dma_end(io); - return; + io->len); + + /* Finish on next callback */ + io->len = 0; } - bdrv_acct_start(s->bs, &s->acct, io->len, BDRV_ACCT_READ); pmac_ide_atapi_transfer_cb(io, 0); return; }