From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brBgo-0002G7-RE for qemu-devel@nongnu.org; Mon, 03 Oct 2016 18:26:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brBgi-000103-SK for qemu-devel@nongnu.org; Mon, 03 Oct 2016 18:26:25 -0400 Date: Tue, 4 Oct 2016 00:26:17 +0200 From: "Edgar E. Iglesias" Message-ID: <20161003222617.GA11832@toto> References: <1475513785-30275-1-git-send-email-rutu.shah.26@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] Reducing stack frame size in stream_process_mem2s() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Rutuja Shah Cc: qemu-devel@nongnu.org, alistair.francis@xilinx.com, qemu-arm@nongnu.org, Stefan Hajnoczi On Mon, Oct 03, 2016 at 10:32:40PM +0530, Rutuja Shah wrote: > ++ stefan Sorry for the typo. > Regards > Rutuja Shah > > > On Mon, Oct 3, 2016 at 10:26 PM, wrote: > > From: Rutuja Shah > > > > This patch allocates memory for txbuf array on the heap rather than the stack. > > As a result, the stack frame size is reduced. > > > > Signed-off-by: Rutuja Shah > > --- > > hw/dma/xilinx_axidma.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c > > index b135a5f..6c63575 100644 > > --- a/hw/dma/xilinx_axidma.c > > +++ b/hw/dma/xilinx_axidma.c > > @@ -256,13 +256,14 @@ static void stream_process_mem2s(struct Stream *s, StreamSlave *tx_data_dev, > > StreamSlave *tx_control_dev) > > { > > uint32_t prev_d; > > - unsigned char txbuf[16 * 1024]; > > + unsigned char *txbuf; > > unsigned int txlen; > > > > if (!stream_running(s) || stream_idle(s)) { > > return; > > } > > > > + txbuf = g_malloc(16 * 1024); Hi, Two comments. We need to move the allocation from the data-path to initialization of the DMA objects. (e.g put txbuf into the Stream struct) We also need to fix up the use of sizeof txbuf. Best regards, Edgar > > while (1) { > > stream_desc_load(s, s->regs[R_CURDESC]); > > > > @@ -304,6 +305,7 @@ static void stream_process_mem2s(struct Stream *s, StreamSlave *tx_data_dev, > > break; > > } > > } > > + g_free(txbuf); > > } > > > > static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf, > > -- > > 1.9.1 > >