From patchwork Wed Jan 6 16:08:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 42309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A424EB6EEB for ; Thu, 7 Jan 2010 03:16:22 +1100 (EST) Received: from localhost ([127.0.0.1]:49540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSYYV-0004Rm-FB for incoming@patchwork.ozlabs.org; Wed, 06 Jan 2010 11:16:19 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSYQk-0006aG-Hk for qemu-devel@nongnu.org; Wed, 06 Jan 2010 11:08:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSYQf-0006We-3j for qemu-devel@nongnu.org; Wed, 06 Jan 2010 11:08:18 -0500 Received: from [199.232.76.173] (port=54227 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSYQe-0006WV-Nb for qemu-devel@nongnu.org; Wed, 06 Jan 2010 11:08:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6405) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSYQe-0002Pn-6G for qemu-devel@nongnu.org; Wed, 06 Jan 2010 11:08:12 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o06G8BtI015774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Jan 2010 11:08:11 -0500 Received: from zweiblum.home.kraxel.org (vpn2-11-33.ams2.redhat.com [10.36.11.33]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o06G87Db003144; Wed, 6 Jan 2010 11:08:08 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id E938A70FCC; Wed, 6 Jan 2010 17:08:05 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 6 Jan 2010 17:08:03 +0100 Message-Id: <1262794084-8020-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1262794084-8020-1-git-send-email-kraxel@redhat.com> References: <1262794084-8020-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 4/5] lsi: move dma_len+dma_buf into lsi_request X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann --- hw/lsi53c895a.c | 45 +++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 22 deletions(-) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 8715b99..f28fc76 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -176,6 +176,8 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0) typedef struct lsi_request { uint32_t tag; SCSIDevice *dev; + uint32_t dma_len; + uint8_t *dma_buf; uint32_t pending; int out; QTAILQ_ENTRY(lsi_request) next; @@ -204,9 +206,7 @@ typedef struct { int current_lun; /* The tag is a combination of the device ID and the SCSI tag. */ uint32_t select_tag; - uint32_t current_dma_len; int command_complete; - uint8_t *dma_buf; QTAILQ_HEAD(, lsi_request) queue; lsi_request *current; @@ -509,15 +509,16 @@ static void lsi_do_dma(LSIState *s, int out) uint32_t count; target_phys_addr_t addr; - if (!s->current_dma_len) { + assert(s->current); + if (!s->current->dma_len) { /* Wait until data is available. */ DPRINTF("DMA no data available\n"); return; } count = s->dbc; - if (count > s->current_dma_len) - count = s->current_dma_len; + if (count > s->current->dma_len) + count = s->current->dma_len; addr = s->dnad; /* both 40 and Table Indirect 64-bit DMAs store upper bits in dnad64 */ @@ -533,20 +534,20 @@ static void lsi_do_dma(LSIState *s, int out) s->dnad += count; s->dbc -= count; - if (s->dma_buf == NULL) { - s->dma_buf = s->current->dev->info->get_buf(s->current->dev, - s->current->tag); + if (s->current->dma_buf == NULL) { + s->current->dma_buf = s->current->dev->info->get_buf(s->current->dev, + s->current->tag); } /* ??? Set SFBR to first data byte. */ if (out) { - cpu_physical_memory_read(addr, s->dma_buf, count); + cpu_physical_memory_read(addr, s->current->dma_buf, count); } else { - cpu_physical_memory_write(addr, s->dma_buf, count); + cpu_physical_memory_write(addr, s->current->dma_buf, count); } - s->current_dma_len -= count; - if (s->current_dma_len == 0) { - s->dma_buf = NULL; + s->current->dma_len -= count; + if (s->current->dma_len == 0) { + s->current->dma_buf = NULL; if (out) { /* Write the data. */ s->current->dev->info->write_data(s->current->dev, s->current->tag); @@ -555,7 +556,7 @@ static void lsi_do_dma(LSIState *s, int out) s->current->dev->info->read_data(s->current->dev, s->current->tag); } } else { - s->dma_buf += count; + s->current->dma_buf += count; lsi_resume_script(s); } } @@ -568,6 +569,7 @@ static void lsi_queue_command(LSIState *s) DPRINTF("Queueing tag=0x%x\n", s->current_tag); assert(s->current != NULL); + assert(s->current->dma_len == 0); QTAILQ_INSERT_TAIL(&s->queue, s->current, next); s->current = NULL; @@ -614,8 +616,7 @@ static void lsi_reselect(LSIState *s, uint32_t tag) s->scntl1 |= LSI_SCNTL1_CON; lsi_set_phase(s, PHASE_MI); s->msg_action = p->out ? 2 : 3; - s->current_dma_len = p->pending; - s->dma_buf = NULL; + s->current->dma_len = p->pending; lsi_add_msg_byte(s, 0x80); if (s->current->tag & LSI_TAG_VALID) { lsi_add_msg_byte(s, 0x20); @@ -695,7 +696,7 @@ static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag, /* host adapter (re)connected */ DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg); - s->current_dma_len = arg; + s->current->dma_len = arg; s->command_complete = 1; if (!s->waiting) return; @@ -910,8 +911,6 @@ static void lsi_wait_reselect(LSIState *s) lsi_request *p; DPRINTF("Wait Reselect\n"); - if (s->current_dma_len) - BADF("Reselect with pending DMA\n"); QTAILQ_FOREACH(p, &s->queue, next) { if (p->pending) { @@ -919,7 +918,7 @@ static void lsi_wait_reselect(LSIState *s) break; } } - if (s->current_dma_len == 0) { + if (s->current == NULL) { s->waiting = 1; } } @@ -2010,8 +2009,10 @@ static void lsi_pre_save(void *opaque) { LSIState *s = opaque; - assert(s->dma_buf == NULL); - assert(s->current_dma_len == 0); + if (s->current) { + assert(s->current->dma_buf == NULL); + assert(s->current->dma_len == 0); + } assert(QTAILQ_EMPTY(&s->queue)); }