From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0joO-0004fO-3D for qemu-devel@nongnu.org; Thu, 13 Nov 2008 16:33:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0joM-0004fC-K5 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 16:33:10 -0500 Received: from [199.232.76.173] (port=34626 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0joM-0004f9-GM for qemu-devel@nongnu.org; Thu, 13 Nov 2008 16:33:10 -0500 Received: from savannah.gnu.org ([199.232.41.3]:43360 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0joM-0000Nk-6g for qemu-devel@nongnu.org; Thu, 13 Nov 2008 16:33:10 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L0joL-0004pU-KR for qemu-devel@nongnu.org; Thu, 13 Nov 2008 21:33:09 +0000 Received: from edgar_igl by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L0joL-0004pQ-D4 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 21:33:09 +0000 MIME-Version: 1.0 Errors-To: edgar_igl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: "Edgar E. Iglesias" Message-Id: Date: Thu, 13 Nov 2008 21:33:09 +0000 Subject: [Qemu-devel] [5720] ETRAX-FS: Don't schedule DMA processing without active channels. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5720 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5720 Author: edgar_igl Date: 2008-11-13 21:33:08 +0000 (Thu, 13 Nov 2008) Log Message: ----------- ETRAX-FS: Don't schedule DMA processing without active channels. Avoid scheduling DMA processing when all channels are stopped or at end-of-list. Signed-off-by: Edgar E. Iglesias Modified Paths: -------------- trunk/hw/etraxfs_dma.c Modified: trunk/hw/etraxfs_dma.c =================================================================== --- trunk/hw/etraxfs_dma.c 2008-11-13 21:10:25 UTC (rev 5719) +++ trunk/hw/etraxfs_dma.c 2008-11-13 21:33:08 UTC (rev 5720) @@ -318,6 +318,8 @@ ctrl->channels[c].state = RUNNING; } else printf("WARNING: starting DMA ch %d with no client\n", c); + + qemu_bh_schedule_idle(ctrl->bh); } static void channel_continue(struct fs_dma_ctrl *ctrl, int c) @@ -391,13 +393,16 @@ qemu_irq_lower(ctrl->channels[c].irq[0]); } -static void channel_out_run(struct fs_dma_ctrl *ctrl, int c) +static int channel_out_run(struct fs_dma_ctrl *ctrl, int c) { uint32_t len; uint32_t saved_data_buf; unsigned char buf[2 * 1024]; - while (ctrl->channels[c].eol != 1) { + if (ctrl->channels[c].eol) + return 0; + + do { saved_data_buf = channel_reg(ctrl, c, RW_SAVED_DATA_BUF); D(printf("ch=%d buf=%x after=%x saved_data_buf=%x\n", @@ -466,7 +471,8 @@ D(dump_d(c, &ctrl->channels[c].current_d)); } ctrl->channels[c].regs[RW_SAVED_DATA_BUF] = saved_data_buf; - } + } while (!ctrl->channels[c].eol); + return 1; } static int channel_in_process(struct fs_dma_ctrl *ctrl, int c, @@ -539,11 +545,14 @@ return len; } -static inline void channel_in_run(struct fs_dma_ctrl *ctrl, int c) +static inline int channel_in_run(struct fs_dma_ctrl *ctrl, int c) { - if (ctrl->channels[c].client->client.pull) + if (ctrl->channels[c].client->client.pull) { ctrl->channels[c].client->client.pull( ctrl->channels[c].client->client.opaque); + return 1; + } else + return 0; } static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr) @@ -673,7 +682,7 @@ &dma_writel, }; -static void etraxfs_dmac_run(void *opaque) +static int etraxfs_dmac_run(void *opaque) { struct fs_dma_ctrl *ctrl = opaque; int i; @@ -685,13 +694,14 @@ { if (ctrl->channels[i].state == RUNNING) { - p++; - if (ctrl->channels[i].input) - channel_in_run(ctrl, i); - else - channel_out_run(ctrl, i); + if (ctrl->channels[i].input) { + p += channel_in_run(ctrl, i); + } else { + p += channel_out_run(ctrl, i); + } } } + return p; } int etraxfs_dmac_input(struct etraxfs_dma_client *client, @@ -722,9 +732,13 @@ static void DMA_run(void *opaque) { struct fs_dma_ctrl *etraxfs_dmac = opaque; + int p = 1; + if (vm_running) - etraxfs_dmac_run(etraxfs_dmac); - qemu_bh_schedule_idle(etraxfs_dmac->bh); + p = etraxfs_dmac_run(etraxfs_dmac); + + if (p) + qemu_bh_schedule_idle(etraxfs_dmac->bh); } void *etraxfs_dmac_init(CPUState *env, @@ -738,7 +752,6 @@ return NULL; ctrl->bh = qemu_bh_new(DMA_run, ctrl); - qemu_bh_schedule_idle(ctrl->bh); ctrl->base = base; ctrl->env = env;