From patchwork Tue Aug 2 17:30:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gilbert X-Patchwork-Id: 107977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F3BB0B71CD for ; Wed, 3 Aug 2011 03:30:37 +1000 (EST) Received: from localhost ([::1]:52532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoInX-00071i-Jp for incoming@patchwork.ozlabs.org; Tue, 02 Aug 2011 13:30:31 -0400 Received: from eggs.gnu.org ([140.186.70.92]:57145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoInR-00071R-Kd for qemu-devel@nongnu.org; Tue, 02 Aug 2011 13:30:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoInQ-00083X-Fw for qemu-devel@nongnu.org; Tue, 02 Aug 2011 13:30:25 -0400 Received: from anchor-post-3.mail.demon.net ([195.173.77.134]:52641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoInQ-00083Q-BT for qemu-devel@nongnu.org; Tue, 02 Aug 2011 13:30:24 -0400 Received: from tu006.demon.co.uk ([83.105.84.125] helo=gort.home.treblig.org) by anchor-post-3.mail.demon.net with esmtp (Exim 4.69) id 1QoInO-0002mP-p8; Tue, 02 Aug 2011 17:30:22 +0000 Received: from [192.168.66.106] (helo=davesworkthinkpad) by gort.home.treblig.org with esmtp (Exim 4.72) (envelope-from ) id 1QoInN-0000Z5-Kv; Tue, 02 Aug 2011 18:30:21 +0100 Date: Tue, 2 Aug 2011 18:30:21 +0100 From: "Dr. David Alan Gilbert" To: qemu-devel@nongnu.org Message-ID: <20110802173020.GA26833@davesworkthinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 195.173.77.134 Cc: patches@linaro.org Subject: [Qemu-devel] [PATCH] Fix for soc-dma type code 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 Hi, I was looking at trying to get soc_dma to call a fifo routine using soc_dma_port_add_fifo_in and hit a few problems that are fixed by the following patch. 1) Where there are two entries matching an address (i.e. a fifo registered for both input and output) soc_dma_lookup finds the last one in the list however soc_dma_ch_update_type then searches forward missing any other cases. (It would be good for someone to cast another eye over soc_dma_lookup to check it always gets the last one in the list) 2) soc_dma_ch_update_type in the memory case was marking the area as 'other' when it wasn't a constant address - I believe this is actually intended to be if it isn't linearly addressed. 3) I'm suspicious of the address check around line 147: if (entry->addr > ch->vaddr[port] || entry->addr + entry->u.mem.size <= ch->vaddr[port]) won't that break if the entry describes a block of RAM at the top of the address space and the address space is as large as the type of entry->addr such that entry->addr+entry->u.mem.size wraps? (I'm not sure what the clean fix for that is, so I left that alone). Note: Users of soc_dma might find that fix (2) might now cause the soc_dma internal memory->memory case to correctly trigger if they try and dma from memory->memory where it might not have done before. Dave diff --git a/hw/soc_dma.c b/hw/soc_dma.c index 3f0f414..4ef5316 100644 --- a/hw/soc_dma.c +++ b/hw/soc_dma.c @@ -129,9 +129,10 @@ static inline enum soc_dma_port_type soc_dma_ch_update_type( struct memmap_entry_s *entry = soc_dma_lookup(dma, ch->vaddr[port]); if (entry->type == soc_dma_port_fifo) { - while (entry < dma->memmap + dma->memmap_size && + while (entry > dma->memmap && entry->u.fifo.out != port) - entry ++; + entry --; + if (entry->addr != ch->vaddr[port] || entry->u.fifo.out != port) return soc_dma_port_other; @@ -148,11 +149,12 @@ static inline enum soc_dma_port_type soc_dma_ch_update_type( /* TODO: support constant memory address for source port as used for * drawing solid rectangles by PalmOS(R). */ - if (ch->type[port] != soc_dma_access_const) + if (ch->type[port] != soc_dma_access_linear) return soc_dma_port_other; ch->paddr[port] = (uint8_t *) entry->u.mem.base + (ch->vaddr[port] - entry->addr); + /* TODO: save bytes left to the end of the mapping somewhere so we * can check we're not reading beyond it. */ return soc_dma_port_mem;