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: "Dr. David Alan Gilbert" X-Patchwork-Id: 3226 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2E94C23F46 for ; Tue, 2 Aug 2011 17:30:25 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id F292AA18901 for ; Tue, 2 Aug 2011 17:30:24 +0000 (UTC) Received: by qyk10 with SMTP id 10so2104468qyk.11 for ; Tue, 02 Aug 2011 10:30:24 -0700 (PDT) Received: by 10.229.231.66 with SMTP id jp2mr831226qcb.83.1312306224353; Tue, 02 Aug 2011 10:30:24 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.6.73 with SMTP id 9cs131671qcy; Tue, 2 Aug 2011 10:30:24 -0700 (PDT) Received: by 10.216.220.212 with SMTP id o62mr825453wep.75.1312306223469; Tue, 02 Aug 2011 10:30:23 -0700 (PDT) Received: from anchor-post-3.mail.demon.net (anchor-post-3.mail.demon.net [195.173.77.134]) by mx.google.com with ESMTP id y56si11735502wec.111.2011.08.02.10.30.23; Tue, 02 Aug 2011 10:30:23 -0700 (PDT) Received-SPF: neutral (google.com: 195.173.77.134 is neither permitted nor denied by best guess record for domain of david.gilbert@linaro.org) client-ip=195.173.77.134; Authentication-Results: mx.google.com; spf=neutral (google.com: 195.173.77.134 is neither permitted nor denied by best guess record for domain of david.gilbert@linaro.org) smtp.mail=david.gilbert@linaro.org 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 Cc: patches@linaro.org, balrogg@gmail.com Subject: [PATCH] Fix for soc-dma type code Message-ID: <20110802173020.GA26833@davesworkthinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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;