Re: [Qemu-devel] [PATCH v4] blizzard: Remove support for DEPTH != 32
CCing Eric Blake and Gerd Hoffmann. On Sat, Mar 26, 2016 at 11:27 AM, Pooja Dhannawat <dhannawatpoo...@gmail.com > wrote: > Removing support for DEPTH != 32 from blizzard template header > and file that includes it, as macro DEPTH == 32 only used. > > Reviewed-by: Eric Blake <ebl...@redhat.com> > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > --- > hw/display/blizzard.c | 41 > - > hw/display/blizzard_template.h | 30 +- > 2 files changed, 5 insertions(+), 66 deletions(-) > > diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c > index c231960..5684e49 100644 > --- a/hw/display/blizzard.c > +++ b/hw/display/blizzard.c > @@ -925,14 +925,6 @@ static void blizzard_update_display(void *opaque) > s->my[1] = 0; > } > > -#define DEPTH 8 > -#include "blizzard_template.h" > -#define DEPTH 15 > -#include "blizzard_template.h" > -#define DEPTH 16 > -#include "blizzard_template.h" > -#define DEPTH 24 > -#include "blizzard_template.h" > #define DEPTH 32 > #include "blizzard_template.h" > > @@ -951,35 +943,10 @@ void *s1d13745_init(qemu_irq gpio_int) > s->con = graphic_console_init(NULL, 0, _ops, s); > surface = qemu_console_surface(s->con); > > -switch (surface_bits_per_pixel(surface)) { > -case 0: > -s->line_fn_tab[0] = s->line_fn_tab[1] = > -g_malloc0(sizeof(blizzard_fn_t) * 0x10); > -break; > -case 8: > -s->line_fn_tab[0] = blizzard_draw_fn_8; > -s->line_fn_tab[1] = blizzard_draw_fn_r_8; > -break; > -case 15: > -s->line_fn_tab[0] = blizzard_draw_fn_15; > -s->line_fn_tab[1] = blizzard_draw_fn_r_15; > -break; > -case 16: > -s->line_fn_tab[0] = blizzard_draw_fn_16; > -s->line_fn_tab[1] = blizzard_draw_fn_r_16; > -break; > -case 24: > -s->line_fn_tab[0] = blizzard_draw_fn_24; > -s->line_fn_tab[1] = blizzard_draw_fn_r_24; > -break; > -case 32: > -s->line_fn_tab[0] = blizzard_draw_fn_32; > -s->line_fn_tab[1] = blizzard_draw_fn_r_32; > -break; > -default: > -fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__); > -exit(1); > -} > +assert(surface_bits_per_pixel(surface) == 32) > + > +s->line_fn_tab[0] = blizzard_draw_fn_32; > +s->line_fn_tab[1] = blizzard_draw_fn_r_32; > > blizzard_reset(s); > > diff --git a/hw/display/blizzard_template.h > b/hw/display/blizzard_template.h > index b7ef27c..bc38d7a 100644 > --- a/hw/display/blizzard_template.h > +++ b/hw/display/blizzard_template.h > @@ -19,31 +19,7 @@ > */ > > #define SKIP_PIXEL(to) (to += deststep) > -#if DEPTH == 8 > -# define PIXEL_TYPEuint8_t > -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while > (0) > -# define COPY_PIXEL1(to, from) (*to++ = from) > -#elif DEPTH == 15 || DEPTH == 16 > -# define PIXEL_TYPEuint16_t > -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while > (0) > -# define COPY_PIXEL1(to, from) (*to++ = from) > -#elif DEPTH == 24 > -# define PIXEL_TYPEuint8_t > -# define COPY_PIXEL(to, from) \ > -do { \ > -to[0] = from; \ > -to[1] = (from) >> 8; \ > -to[2] = (from) >> 16; \ > -SKIP_PIXEL(to); \ > -} while (0) > - > -# define COPY_PIXEL1(to, from) \ > -do { \ > -*to++ = from; \ > -*to++ = (from) >> 8; \ > -*to++ = (from) >> 16; \ > -} while (0) > -#elif DEPTH == 32 > +#if DEPTH == 32 > # define PIXEL_TYPEuint32_t > # define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while > (0) > # define COPY_PIXEL1(to, from) (*to++ = from) > @@ -58,9 +34,6 @@ > static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, > const uint16_t *src, unsigned int width) > { > -#if !defined(SWAP_WORDS) && DEPTH == 16 > -memcpy(dest, src, width); > -#else > uint16_t data; > unsigned int r, g, b; > const uint16_t *end = (const void *) src + width; > @@ -74,7 +47,6 @@ static void glue(blizzard_draw_line16_, > DEPTH)(PIXEL_TYPE *dest, > data >>= 5; > COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); > } > -#endif > } > > static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, > -- > 2.5.0 > >
Re: [Qemu-devel] [PATCH v2] omap_lcdc: Remove support for DEPTH != 32
CCing Peter Maydell. On Tue, Mar 29, 2016 at 7:32 PM, Pooja Dhannawat <dhannawatpoo...@gmail.com> wrote: > surface_bits_per_pixel() always returns 32 > so, removing other dead code which is > based on DEPTH !== 32 > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > --- > v2: As surface_bits_per_pixel() always returns 32, > so instead of relying on array : > > draw_line_table2[surface_bits_per_pixel(surface)] > > we can use directly : > > draw_line2_32 [Eric Blake] > --- > hw/display/omap_lcd_template.h | 10 ++--- > hw/display/omap_lcdc.c | 48 > +- > 2 files changed, 7 insertions(+), 51 deletions(-) > > diff --git a/hw/display/omap_lcd_template.h > b/hw/display/omap_lcd_template.h > index f0ce71f..1025ff3 100644 > --- a/hw/display/omap_lcd_template.h > +++ b/hw/display/omap_lcd_template.h > @@ -27,13 +27,7 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > > -#if DEPTH == 8 > -# define BPP 1 > -# define PIXEL_TYPE uint8_t > -#elif DEPTH == 15 || DEPTH == 16 > -# define BPP 2 > -# define PIXEL_TYPE uint16_t > -#elif DEPTH == 32 > +#if DEPTH == 32 > # define BPP 4 > # define PIXEL_TYPE uint32_t > #else > @@ -152,7 +146,7 @@ static void glue(draw_line12_, DEPTH)(void *opaque, > static void glue(draw_line16_, DEPTH)(void *opaque, > uint8_t *d, const uint8_t *s, int width, int deststep) > { > -#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == > defined(TARGET_WORDS_BIGENDIAN) > +#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) > memcpy(d, s, width * 2); > #else > uint16_t v; > diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c > index ce1058b..07a5eff 100644 > --- a/hw/display/omap_lcdc.c > +++ b/hw/display/omap_lcdc.c > @@ -71,47 +71,9 @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s > *s) > > #define draw_line_func drawfn > > -#define DEPTH 8 > -#include "omap_lcd_template.h" > -#define DEPTH 15 > -#include "omap_lcd_template.h" > -#define DEPTH 16 > -#include "omap_lcd_template.h" > #define DEPTH 32 > #include "omap_lcd_template.h" > > -static draw_line_func draw_line_table2[33] = { > -[0 ... 32] = NULL, > -[8]= draw_line2_8, > -[15] = draw_line2_15, > -[16] = draw_line2_16, > -[32] = draw_line2_32, > -}, draw_line_table4[33] = { > -[0 ... 32] = NULL, > -[8]= draw_line4_8, > -[15] = draw_line4_15, > -[16] = draw_line4_16, > -[32] = draw_line4_32, > -}, draw_line_table8[33] = { > -[0 ... 32] = NULL, > -[8]= draw_line8_8, > -[15] = draw_line8_15, > -[16] = draw_line8_16, > -[32] = draw_line8_32, > -}, draw_line_table12[33] = { > -[0 ... 32] = NULL, > -[8]= draw_line12_8, > -[15] = draw_line12_15, > -[16] = draw_line12_16, > -[32] = draw_line12_32, > -}, draw_line_table16[33] = { > -[0 ... 32] = NULL, > -[8]= draw_line16_8, > -[15] = draw_line16_15, > -[16] = draw_line16_16, > -[32] = draw_line16_32, > -}; > - > static void omap_update_display(void *opaque) > { > struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) > opaque; > @@ -143,25 +105,25 @@ static void omap_update_display(void *opaque) > /* Colour depth */ > switch ((omap_lcd->palette[0] >> 12) & 7) { > case 1: > -draw_line = draw_line_table2[surface_bits_per_pixel(surface)]; > +draw_line = draw_line2_32; > bpp = 2; > break; > > case 2: > -draw_line = draw_line_table4[surface_bits_per_pixel(surface)]; > +draw_line = draw_line4_32; > bpp = 4; > break; > > case 3: > -draw_line = draw_line_table8[surface_bits_per_pixel(surface)]; > +draw_line = draw_line8_32; > bpp = 8; > break; > > case 4 ... 7: > if (!omap_lcd->tft) > -draw_line = > draw_line_table12[surface_bits_per_pixel(surface)]; > +draw_line = draw_line12_32; > else > -draw_line = > draw_line_table16[surface_bits_per_pixel(surface)]; > +draw_line = draw_line16_32; > bpp = 16; > break; > > -- > 2.5.0 > >
Re: [Qemu-devel] [PATCH v5] net: Allocating Large sized arrays to heap
On Thu, Mar 31, 2016 at 3:28 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Mon, Mar 28, 2016 at 06:04:11PM +0530, Pooja Dhannawat wrote: > > nc_sendv_compat has a huge stack usage of 69680 bytes approx. > > Moving large arrays to heap to reduce stack usage. > > > > Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com> > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > --- > > net/net.c | 13 + > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/net/net.c b/net/net.c > > index b0c832e..663da13 100644 > > --- a/net/net.c > > +++ b/net/net.c > > @@ -709,23 +709,28 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, > const uint8_t *buf, int size) > > static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec > *iov, > > int iovcnt, unsigned flags) > > { > > -uint8_t buf[NET_BUFSIZE]; > > +uint8_t *buf = NULL; > > uint8_t *buffer; > > size_t offset; > > +ssize_t ret; > > > > if (iovcnt == 1) { > > buffer = iov[0].iov_base; > > offset = iov[0].iov_len; > > } else { > > +buf = g_new(uint8_t, NET_BUFSIZE); > > buffer = buf; > > -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); > > +offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); > > } > > > > if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { > > -return nc->info->receive_raw(nc, buffer, offset); > > +ret = nc->info->receive_raw(nc, buffer, offset); > > } else { > > -return nc->info->receive(nc, buffer, offset); > > +ret = nc->info->receive(nc, buffer, offset); > > } > > + > > +g_free(buf); > > +return ret; > > } > > > > ssize_t qemu_deliver_packet_iov(NetClientState *sender, > > -- > > 2.5.0 > > CCing Jason Wang, net subsystem maintainer. Please use > scripts/get_maintainer.pl to find the right people to CC in future > patches. > > Yes, I am sorry about that. Fam also pointed out this thing but I forgot this time also. I will keep that mind from onwards. > We may also want to keep a smaller stack buffer so that reasonably-sized > packets (e.g. up to 2 KB) can be send without the performance cost of > g_malloc(). >
[Qemu-devel] [PATCH v2] omap_lcdc: Remove support for DEPTH != 32
surface_bits_per_pixel() always returns 32 so, removing other dead code which is based on DEPTH !== 32 Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- v2: As surface_bits_per_pixel() always returns 32, so instead of relying on array : draw_line_table2[surface_bits_per_pixel(surface)] we can use directly : draw_line2_32 [Eric Blake] --- hw/display/omap_lcd_template.h | 10 ++--- hw/display/omap_lcdc.c | 48 +- 2 files changed, 7 insertions(+), 51 deletions(-) diff --git a/hw/display/omap_lcd_template.h b/hw/display/omap_lcd_template.h index f0ce71f..1025ff3 100644 --- a/hw/display/omap_lcd_template.h +++ b/hw/display/omap_lcd_template.h @@ -27,13 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if DEPTH == 8 -# define BPP 1 -# define PIXEL_TYPE uint8_t -#elif DEPTH == 15 || DEPTH == 16 -# define BPP 2 -# define PIXEL_TYPE uint16_t -#elif DEPTH == 32 +#if DEPTH == 32 # define BPP 4 # define PIXEL_TYPE uint32_t #else @@ -152,7 +146,7 @@ static void glue(draw_line12_, DEPTH)(void *opaque, static void glue(draw_line16_, DEPTH)(void *opaque, uint8_t *d, const uint8_t *s, int width, int deststep) { -#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) +#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) memcpy(d, s, width * 2); #else uint16_t v; diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c index ce1058b..07a5eff 100644 --- a/hw/display/omap_lcdc.c +++ b/hw/display/omap_lcdc.c @@ -71,47 +71,9 @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) #define draw_line_func drawfn -#define DEPTH 8 -#include "omap_lcd_template.h" -#define DEPTH 15 -#include "omap_lcd_template.h" -#define DEPTH 16 -#include "omap_lcd_template.h" #define DEPTH 32 #include "omap_lcd_template.h" -static draw_line_func draw_line_table2[33] = { -[0 ... 32] = NULL, -[8]= draw_line2_8, -[15] = draw_line2_15, -[16] = draw_line2_16, -[32] = draw_line2_32, -}, draw_line_table4[33] = { -[0 ... 32] = NULL, -[8]= draw_line4_8, -[15] = draw_line4_15, -[16] = draw_line4_16, -[32] = draw_line4_32, -}, draw_line_table8[33] = { -[0 ... 32] = NULL, -[8]= draw_line8_8, -[15] = draw_line8_15, -[16] = draw_line8_16, -[32] = draw_line8_32, -}, draw_line_table12[33] = { -[0 ... 32] = NULL, -[8]= draw_line12_8, -[15] = draw_line12_15, -[16] = draw_line12_16, -[32] = draw_line12_32, -}, draw_line_table16[33] = { -[0 ... 32] = NULL, -[8]= draw_line16_8, -[15] = draw_line16_15, -[16] = draw_line16_16, -[32] = draw_line16_32, -}; - static void omap_update_display(void *opaque) { struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; @@ -143,25 +105,25 @@ static void omap_update_display(void *opaque) /* Colour depth */ switch ((omap_lcd->palette[0] >> 12) & 7) { case 1: -draw_line = draw_line_table2[surface_bits_per_pixel(surface)]; +draw_line = draw_line2_32; bpp = 2; break; case 2: -draw_line = draw_line_table4[surface_bits_per_pixel(surface)]; +draw_line = draw_line4_32; bpp = 4; break; case 3: -draw_line = draw_line_table8[surface_bits_per_pixel(surface)]; +draw_line = draw_line8_32; bpp = 8; break; case 4 ... 7: if (!omap_lcd->tft) -draw_line = draw_line_table12[surface_bits_per_pixel(surface)]; +draw_line = draw_line12_32; else -draw_line = draw_line_table16[surface_bits_per_pixel(surface)]; +draw_line = draw_line16_32; bpp = 16; break; -- 2.5.0
Re: [Qemu-devel] [Patch 1/1] omap_lcdc: Remove support for DEPTH != 32
On Wed, Mar 23, 2016 at 11:35 AM, Pooja Dhannawat <dhannawatpoo...@gmail.com > wrote: > > > On Wed, Mar 23, 2016 at 3:55 AM, Eric Blake <ebl...@redhat.com> wrote: > >> On 03/12/2016 03:23 AM, Pooja Dhannawat wrote: >> > As only DEPTH ==32 case is used, removing other dead code >> > which is based on DEPTH !== 32 >> > >> > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> >> > --- >> >> > +++ b/hw/display/omap_lcdc.c >> > @@ -71,44 +71,23 @@ static void omap_lcd_interrupts(struct >> omap_lcd_panel_s *s) >> > >> > #define draw_line_func drawfn >> > >> > -#define DEPTH 8 >> > -#include "omap_lcd_template.h" >> > -#define DEPTH 15 >> > -#include "omap_lcd_template.h" >> > -#define DEPTH 16 >> > -#include "omap_lcd_template.h" >> > #define DEPTH 32 >> > #include "omap_lcd_template.h" >> >> Umm, the old code WAS using DEPTH != 32. I'm not a display expert, so >> there may be justification in nuking that code; but the commit message >> needs a better argument than "the code wasn't used" when it sure seems >> to be used. If the argument is that surface_bits_per_pixel() always >> returns 32, that would be a good argument. >> >>Correct me If I am wrong, I dig down on this and I found internally it > used PIXMAN_FORMAT which uses bits_per_pixel = 32 only. > > so surface_bits_per_pixel() always returns 32 (just for reference : Message-ID: <56f43a06.9090...@redhat.com> ) as discussed in this mail chain. I will make desired changed for this patch too. is it ok to go ahead with changes ? > > >> > static draw_line_func draw_line_table2[33] = { >> > [0 ... 32] = NULL, >> > -[8] = draw_line2_8, >> > -[15] = draw_line2_15, >> > -[16] = draw_line2_16, >> > [32] = draw_line2_32, >> >> This array is now wasteful. If surface_bits_per_pixel() always returns >> 32, then just ditch this array, and later on, change: >> >> Yes sure. > > >> /* Colour depth */ >> switch ((omap_lcd->palette[0] >> 12) & 7) { >> case 1: >> - draw_line = draw_line_table2[surface_bits_per_pixel(surface)]; >> + draw_line = draw_line2_32; >> bpp = 2; >> break; >> >> In other words, your cleanup, if justified, is incomplete. >> >> -- >> Eric Blake eblake redhat com+1-919-301-3266 >> Libvirt virtualization library http://libvirt.org >> >> >
[Qemu-devel] [PATCH v5] net: Allocating Large sized arrays to heap
nc_sendv_compat has a huge stack usage of 69680 bytes approx. Moving large arrays to heap to reduce stack usage. Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com> Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/net.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..663da13 100644 --- a/net/net.c +++ b/net/net.c @@ -709,23 +709,28 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { -uint8_t buf[NET_BUFSIZE]; +uint8_t *buf = NULL; uint8_t *buffer; size_t offset; +ssize_t ret; if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { +buf = g_new(uint8_t, NET_BUFSIZE); buffer = buf; -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); +offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { -return nc->info->receive_raw(nc, buffer, offset); +ret = nc->info->receive_raw(nc, buffer, offset); } else { -return nc->info->receive(nc, buffer, offset); +ret = nc->info->receive(nc, buffer, offset); } + +g_free(buf); +return ret; } ssize_t qemu_deliver_packet_iov(NetClientState *sender, -- 2.5.0
[Qemu-devel] [PATCH v4] blizzard: Remove support for DEPTH != 32
Removing support for DEPTH != 32 from blizzard template header and file that includes it, as macro DEPTH == 32 only used. Reviewed-by: Eric Blake <ebl...@redhat.com> Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- hw/display/blizzard.c | 41 - hw/display/blizzard_template.h | 30 +- 2 files changed, 5 insertions(+), 66 deletions(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index c231960..5684e49 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -925,14 +925,6 @@ static void blizzard_update_display(void *opaque) s->my[1] = 0; } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" #define DEPTH 32 #include "blizzard_template.h" @@ -951,35 +943,10 @@ void *s1d13745_init(qemu_irq gpio_int) s->con = graphic_console_init(NULL, 0, _ops, s); surface = qemu_console_surface(s->con); -switch (surface_bits_per_pixel(surface)) { -case 0: -s->line_fn_tab[0] = s->line_fn_tab[1] = -g_malloc0(sizeof(blizzard_fn_t) * 0x10); -break; -case 8: -s->line_fn_tab[0] = blizzard_draw_fn_8; -s->line_fn_tab[1] = blizzard_draw_fn_r_8; -break; -case 15: -s->line_fn_tab[0] = blizzard_draw_fn_15; -s->line_fn_tab[1] = blizzard_draw_fn_r_15; -break; -case 16: -s->line_fn_tab[0] = blizzard_draw_fn_16; -s->line_fn_tab[1] = blizzard_draw_fn_r_16; -break; -case 24: -s->line_fn_tab[0] = blizzard_draw_fn_24; -s->line_fn_tab[1] = blizzard_draw_fn_r_24; -break; -case 32: -s->line_fn_tab[0] = blizzard_draw_fn_32; -s->line_fn_tab[1] = blizzard_draw_fn_r_32; -break; -default: -fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__); -exit(1); -} +assert(surface_bits_per_pixel(surface) == 32) + +s->line_fn_tab[0] = blizzard_draw_fn_32; +s->line_fn_tab[1] = blizzard_draw_fn_r_32; blizzard_reset(s); diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h index b7ef27c..bc38d7a 100644 --- a/hw/display/blizzard_template.h +++ b/hw/display/blizzard_template.h @@ -19,31 +19,7 @@ */ #define SKIP_PIXEL(to) (to += deststep) -#if DEPTH == 8 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 15 || DEPTH == 16 -# define PIXEL_TYPEuint16_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 24 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) \ -do { \ -to[0] = from; \ -to[1] = (from) >> 8; \ -to[2] = (from) >> 16; \ -SKIP_PIXEL(to); \ -} while (0) - -# define COPY_PIXEL1(to, from) \ -do { \ -*to++ = from; \ -*to++ = (from) >> 8; \ -*to++ = (from) >> 16; \ -} while (0) -#elif DEPTH == 32 +#if DEPTH == 32 # define PIXEL_TYPEuint32_t # define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) # define COPY_PIXEL1(to, from) (*to++ = from) @@ -58,9 +34,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, const uint16_t *src, unsigned int width) { -#if !defined(SWAP_WORDS) && DEPTH == 16 -memcpy(dest, src, width); -#else uint16_t data; unsigned int r, g, b; const uint16_t *end = (const void *) src + width; @@ -74,7 +47,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, data >>= 5; COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); } -#endif } static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, -- 2.5.0
Re: [Qemu-devel] [PATCH v4] blizzard: Remove support for DEPTH != 32
On Fri, Mar 25, 2016 at 8:39 AM, Fam Zheng <f...@redhat.com> wrote: > On Thu, 03/24 23:48, Pooja Dhannawat wrote: > > Removing support for DEPTH != 32 from blizzard template header > > and file that includes it, as macro DEPTH == 32 only used. > > > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > Hi Pooja, a meta-comment: in the future, when post a subsequent revision, > please include what is changed since previous revision, in the cover > letter if > there are multiple patches, or under a "---" line in the commit message if > there is no cover letter. (Remember that the Signed-off-by line must still > stay > above the "---" line). > > The reason to use "---" line is for maintainers to avoid "git am" applying > the > revision changelog into git history (apparently it is meaningless out of > patch > review context). > > In this case, it would be like: > > 8<--- > > Removing support for DEPTH != 32 from blizzard template header > and file that includes it, as macro DEPTH == 32 only used. > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > --- > > v4: Changed foo to bar, and baz to qux. [$name_of_suggester] > > >8--- > Thank you Fam. I will keep this in mind from onward.
[Qemu-devel] [PATCH v4] blizzard: Remove support for DEPTH != 32
Removing support for DEPTH != 32 from blizzard template header and file that includes it, as macro DEPTH == 32 only used. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- hw/display/blizzard.c | 41 - hw/display/blizzard_template.h | 30 +- 2 files changed, 5 insertions(+), 66 deletions(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index c231960..5684e49 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -925,14 +925,6 @@ static void blizzard_update_display(void *opaque) s->my[1] = 0; } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" #define DEPTH 32 #include "blizzard_template.h" @@ -951,35 +943,10 @@ void *s1d13745_init(qemu_irq gpio_int) s->con = graphic_console_init(NULL, 0, _ops, s); surface = qemu_console_surface(s->con); -switch (surface_bits_per_pixel(surface)) { -case 0: -s->line_fn_tab[0] = s->line_fn_tab[1] = -g_malloc0(sizeof(blizzard_fn_t) * 0x10); -break; -case 8: -s->line_fn_tab[0] = blizzard_draw_fn_8; -s->line_fn_tab[1] = blizzard_draw_fn_r_8; -break; -case 15: -s->line_fn_tab[0] = blizzard_draw_fn_15; -s->line_fn_tab[1] = blizzard_draw_fn_r_15; -break; -case 16: -s->line_fn_tab[0] = blizzard_draw_fn_16; -s->line_fn_tab[1] = blizzard_draw_fn_r_16; -break; -case 24: -s->line_fn_tab[0] = blizzard_draw_fn_24; -s->line_fn_tab[1] = blizzard_draw_fn_r_24; -break; -case 32: -s->line_fn_tab[0] = blizzard_draw_fn_32; -s->line_fn_tab[1] = blizzard_draw_fn_r_32; -break; -default: -fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__); -exit(1); -} +assert(surface_bits_per_pixel(surface) == 32) + +s->line_fn_tab[0] = blizzard_draw_fn_32; +s->line_fn_tab[1] = blizzard_draw_fn_r_32; blizzard_reset(s); diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h index b7ef27c..bc38d7a 100644 --- a/hw/display/blizzard_template.h +++ b/hw/display/blizzard_template.h @@ -19,31 +19,7 @@ */ #define SKIP_PIXEL(to) (to += deststep) -#if DEPTH == 8 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 15 || DEPTH == 16 -# define PIXEL_TYPEuint16_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 24 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) \ -do { \ -to[0] = from; \ -to[1] = (from) >> 8; \ -to[2] = (from) >> 16; \ -SKIP_PIXEL(to); \ -} while (0) - -# define COPY_PIXEL1(to, from) \ -do { \ -*to++ = from; \ -*to++ = (from) >> 8; \ -*to++ = (from) >> 16; \ -} while (0) -#elif DEPTH == 32 +#if DEPTH == 32 # define PIXEL_TYPEuint32_t # define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) # define COPY_PIXEL1(to, from) (*to++ = from) @@ -58,9 +34,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, const uint16_t *src, unsigned int width) { -#if !defined(SWAP_WORDS) && DEPTH == 16 -memcpy(dest, src, width); -#else uint16_t data; unsigned int r, g, b; const uint16_t *end = (const void *) src + width; @@ -74,7 +47,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, data >>= 5; COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); } -#endif } static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, -- 2.5.0
Re: [Qemu-devel] [Patch 1/1] omap_lcdc: Remove support for DEPTH != 32
On Wed, Mar 23, 2016 at 3:55 AM, Eric Blake <ebl...@redhat.com> wrote: > On 03/12/2016 03:23 AM, Pooja Dhannawat wrote: > > As only DEPTH ==32 case is used, removing other dead code > > which is based on DEPTH !== 32 > > > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > --- > > > +++ b/hw/display/omap_lcdc.c > > @@ -71,44 +71,23 @@ static void omap_lcd_interrupts(struct > omap_lcd_panel_s *s) > > > > #define draw_line_func drawfn > > > > -#define DEPTH 8 > > -#include "omap_lcd_template.h" > > -#define DEPTH 15 > > -#include "omap_lcd_template.h" > > -#define DEPTH 16 > > -#include "omap_lcd_template.h" > > #define DEPTH 32 > > #include "omap_lcd_template.h" > > Umm, the old code WAS using DEPTH != 32. I'm not a display expert, so > there may be justification in nuking that code; but the commit message > needs a better argument than "the code wasn't used" when it sure seems > to be used. If the argument is that surface_bits_per_pixel() always > returns 32, that would be a good argument. > >Correct me If I am wrong, I dig down on this and I found internally it used PIXMAN_FORMAT which uses bits_per_pixel = 32 only. > > > static draw_line_func draw_line_table2[33] = { > > [0 ... 32] = NULL, > > -[8] = draw_line2_8, > > -[15] = draw_line2_15, > > -[16] = draw_line2_16, > > [32] = draw_line2_32, > > This array is now wasteful. If surface_bits_per_pixel() always returns > 32, then just ditch this array, and later on, change: > > Yes sure. > /* Colour depth */ > switch ((omap_lcd->palette[0] >> 12) & 7) { > case 1: > - draw_line = draw_line_table2[surface_bits_per_pixel(surface)]; > + draw_line = draw_line2_32; > bpp = 2; > break; > > In other words, your cleanup, if justified, is incomplete. > > -- > Eric Blake eblake redhat com+1-919-301-3266 > Libvirt virtualization library http://libvirt.org > >
Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
On Fri, Mar 18, 2016 at 4:20 AM, Paolo Bonzini <pbonz...@redhat.com> wrote: > > > On 17/03/2016 16:31, Pooja Dhannawat wrote: > > > > > > On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi <stefa...@gmail.com > > <mailto:stefa...@gmail.com>> wrote: > > > > On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dhannawat wrote: > > > @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) > > > s->index = 0; > > > s->packet_len = 0; > > > s->nc.link_down = true; > > > -memset(s->buf, 0, sizeof(s->buf)); > > > > This change is unrelated to allocating buf1 on the heap. What is the > > purpose of this line? > > > > > > I moved buf from stack to Heap, used g_new(), but I got your point if we > > need to initialize it with 0 then I have to keep that one. > > > > Other wise doing so it gets whatever garbage it has already. > > This is s->buf, not buf. Also, the BiteSizedTasks page says "Make the > stack array smaller and allocate on the heap in the rare case that the > data does not fit in the small array". > > So here, should I check with stack consumption(size of array) and if it is greater than accepted level, then only keep on heap? If no, Can you please help me with this one? > Paolo >
[Qemu-devel] [PATCH v4] net: Allocating Large sized arrays to heap
nc_sendv_compat has a huge stack usage of 69680 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/net.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..663da13 100644 --- a/net/net.c +++ b/net/net.c @@ -709,23 +709,28 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { -uint8_t buf[NET_BUFSIZE]; +uint8_t *buf = NULL; uint8_t *buffer; size_t offset; +ssize_t ret; if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { +buf = g_new(uint8_t, NET_BUFSIZE); buffer = buf; -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); +offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { -return nc->info->receive_raw(nc, buffer, offset); +ret = nc->info->receive_raw(nc, buffer, offset); } else { -return nc->info->receive(nc, buffer, offset); +ret = nc->info->receive(nc, buffer, offset); } + +g_free(buf); +return ret; } ssize_t qemu_deliver_packet_iov(NetClientState *sender, -- 2.5.0
Re: [Qemu-devel] [PATCH v3] net: Allocating Large sized arrays to heap
On Thu, Mar 17, 2016 at 8:23 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Tue, Mar 15, 2016 at 11:55:13PM +0530, Pooja Dhannawat wrote: > > nc_sendv_compat has a huge stack usage of 69680 bytes approx. > > Moving large arrays to heap to reduce stack usage. > > > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > --- > > net/net.c | 14 ++ > > 1 file changed, 10 insertions(+), 4 deletions(-) > > > > diff --git a/net/net.c b/net/net.c > > index b0c832e..f03c571 100644 > > --- a/net/net.c > > +++ b/net/net.c > > @@ -709,23 +709,29 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, > const uint8_t *buf, int size) > > static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec > *iov, > > int iovcnt, unsigned flags) > > { > > -uint8_t buf[NET_BUFSIZE]; > > +uint8_t *buf; > > uint8_t *buffer; > > size_t offset; > > +ssize_t ret; > > + > > +buf = g_new(uint8_t, NET_BUFSIZE); > > The linear buffer is only needed when iovcnt > 1. I suggest the > following instead: > > uint8_t *buf = NULL; > > if (iovcnt == 1) { > buffer = iov[0].iov_base; > offset = iov[0].iov_len; > } else { > buf = g_new(uint8_t, NET_BUFSIZE); > buffer = buf; > offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); > } > > This way the allocation is only made when we actually need to linearize > the buffer. > Thanks Stefan for pointing out this one :) I will make desired changes and push patch.
Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
On Fri, Mar 18, 2016 at 3:05 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Thu, Mar 17, 2016 at 11:50:15PM +0100, Paolo Bonzini wrote: > > > > > > On 17/03/2016 16:31, Pooja Dhannawat wrote: > > > > > > > > > On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi <stefa...@gmail.com > > > <mailto:stefa...@gmail.com>> wrote: > > > > > > On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dhannawat wrote: > > > > @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) > > > > s->index = 0; > > > > s->packet_len = 0; > > > > s->nc.link_down = true; > > > > -memset(s->buf, 0, sizeof(s->buf)); > > > > > > This change is unrelated to allocating buf1 on the heap. What is > the > > > purpose of this line? > > > > > > > > > I moved buf from stack to Heap, used g_new(), but I got your point if > we > > > need to initialize it with 0 then I have to keep that one. > > > > > > Other wise doing so it gets whatever garbage it has already. > > > > This is s->buf, not buf. > > Exactly, they are different variables. > > Yes. The line should not be removed. Extremely sorry for the noise and my terrible confusion. Will mail the updated patch. > Stefan >
Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
On Fri, Mar 18, 2016 at 6:59 PM, Jaya Tiwari <tiwari.jay...@gmail.com> wrote: > > On Fri, Mar 18, 2016 at 6:57 PM, Jaya Tiwari <tiwari.jay...@gmail.com> > wrote: > >> >> >> On Fri, Mar 18, 2016 at 5:21 PM, Paolo Bonzini <pbonz...@redhat.com> >> wrote: >> >>> >>> >>> On 18/03/2016 12:24, Pooja Dhannawat wrote: >>> > >>> > >>> > On Fri, Mar 18, 2016 at 4:20 AM, Paolo Bonzini <pbonz...@redhat.com >>> > <mailto:pbonz...@redhat.com>> wrote: >>> > >>> > >>> > >>> > On 17/03/2016 16:31, Pooja Dhannawat wrote: >>> > > >>> > > >>> > > On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi < >>> stefa...@gmail.com <mailto:stefa...@gmail.com> >>> > > <mailto:stefa...@gmail.com <mailto:stefa...@gmail.com>>> wrote: >>> > > >>> > > On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dhannawat >>> wrote: >>> > > > @@ -170,8 +170,8 @@ static void net_socket_send(void >>> *opaque) >>> > > > s->index = 0; >>> > > > s->packet_len = 0; >>> > > > s->nc.link_down = true; >>> > > > -memset(s->buf, 0, sizeof(s->buf)); >>> > > >>> > > This change is unrelated to allocating buf1 on the heap. >>> What is the >>> > > purpose of this line? >>> > > >>> > > >>> > > I moved buf from stack to Heap, used g_new(), but I got your >>> point if we >>> > > need to initialize it with 0 then I have to keep that one. >>> > > >>> > > Other wise doing so it gets whatever garbage it has already. >>> > >>> > This is s->buf, not buf. Also, the BiteSizedTasks page says "Make >>> the >>> > stack array smaller and allocate on the heap in the rare case that >>> the >>> > data does not fit in the small array". >>> > >>> > So here, should I check with stack consumption(size of array) and if it >>> > is greater than accepted level, then only keep on heap? >>> >>> If it is greater than the accepted level, the on-stack buffer is not >>> used and you allocate one that has the right size on the heap. >>> >> Yes Okay. Thank you for the comments. >> I had one more question. >> size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); >> The one above returns bytes read into buf1 (if large then bytes >> equivalent to len(buf1) is read) ? >> If true, size is the correct measure of buf1? Hence, I should compare the >> allowed stack size to "size" variable? >> >So isnt here size should be compared to "size" varibale paolo? > So instead of comparing with NET_BUFSIZE, should I compare with "size" variable? Can you help me with this? > >>> Paolo >>> >>> > If no, Can you please help me with this one? >>> > >>> > Paolo >>> > >>> > >>> >>> >> >> >> -- >> Regards, >> Jaya >> > > > > -- > Regards, > Jaya >
Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dhannawat wrote: > > @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) > > s->index = 0; > > s->packet_len = 0; > > s->nc.link_down = true; > > -memset(s->buf, 0, sizeof(s->buf)); > > This change is unrelated to allocating buf1 on the heap. What is the > purpose of this line? > I moved buf from stack to Heap, used g_new(), but I got your point if we need to initialize it with 0 then I have to keep that one. Other wise doing so it gets whatever garbage it has already.
Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
On Friday, March 18, 2016, Paolo Bonzini <pbonz...@redhat.com> wrote: > > > On 18/03/2016 14:49, Pooja Dhannawat wrote: >> >> >> If it is greater than the accepted level, the on-stack >> buffer is not >> used and you allocate one that has the right size on the heap. >> >> Yes Okay. Thank you for the comments. >> I had one more question. >> size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); >> The one above returns bytes read into buf1 (if large then bytes >> equivalent to len(buf1) is read) ? >> If true, size is the correct measure of buf1? Hence, I should >> compare the allowed stack size to "size" variable? >> >>So isnt here size should be compared to "size" varibale paolo? >> >> So instead of comparing with NET_BUFSIZE, should I compare with "size" >> variable? Can you help me with this? > > I was a bit confused myself; this function actually is a bit different > from the others because it does not really need a large buffer. The > function already takes care of moving data in pieces from buf1 to > s->buf. If you make the buffer smaller, the only change is that one > call to net_socket_send will process fewer bytes. > > So you can just send a trivial patch that changes the size of the array > to something like 2048. > > Thanks, and sorry for putting you on a false track! > No, it's completely fine, I really appreciate your help. > Paolo >
[Qemu-devel] [Patch v2 1/1] blizzard: Remove support for DEPTH != 32
On Friday, March 18, 2016, Gerd Hoffmann <kra...@redhat.com> wrote: > > On Mo, 2016-03-14 at 15:22 +, Peter Maydell wrote: > > On 14 March 2016 at 15:04, Pooja Dhannawat <dhannawatpoo...@gmail.com> wrote: > > > Removing support for DEPTH != 32 from blizzard template header > > > and file that includes it, as macro DEPTH == 32 only used. > > > > > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > > --- > > > hw/display/blizzard.c | 24 > > > hw/display/blizzard_template.h | 30 +- > > > 2 files changed, 1 insertion(+), 53 deletions(-) > > > So are there any cases now when > > surface_bits_per_pixel(qemu_console_surface(c)) can return > > zero? (I don't understand the 'case 0' code in this switch > > at all...) > > Looks like a somewhat strange way to zero-fill the function pointer > array. Looks like a historical leftover. > > As blizzard uses qemu_console_resize() you will always get a surface > with the default depth (32bpp). So dropping the whole "switch { ... }" > block (except for the "case 32:" lines) and adding an > "assert(surface_bits_per_pixel(surface)==32)" should work just fine. > Thank you Gerd, for clearing and helping with above question. > > cheers, > Gerd >
[Qemu-devel] [PATCH v3] net: Allocating Large sized arrays to heap
nc_sendv_compat has a huge stack usage of 69680 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/net.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..f03c571 100644 --- a/net/net.c +++ b/net/net.c @@ -709,23 +709,29 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { -uint8_t buf[NET_BUFSIZE]; +uint8_t *buf; uint8_t *buffer; size_t offset; +ssize_t ret; + +buf = g_new(uint8_t, NET_BUFSIZE); if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { buffer = buf; -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); +offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { -return nc->info->receive_raw(nc, buffer, offset); +ret = nc->info->receive_raw(nc, buffer, offset); } else { -return nc->info->receive(nc, buffer, offset); +ret = nc->info->receive(nc, buffer, offset); } + +g_free(buf); +return ret; } ssize_t qemu_deliver_packet_iov(NetClientState *sender, -- 2.5.0
[Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
net_socket_send has a huge stack usage of 69712 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/socket.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/socket.c b/net/socket.c index e32e3cb..fd7f39f 100644 --- a/net/socket.c +++ b/net/socket.c @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; -uint8_t buf1[NET_BUFSIZE]; +uint8_t *buf1 = g_new(uint8_t, NET_BUFSIZE); const uint8_t *buf; -size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); +size = qemu_recv(s->fd, buf1, NET_BUFSIZE, 0); if (size < 0) { err = socket_error(); if (err != EWOULDBLOCK) @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) s->index = 0; s->packet_len = 0; s->nc.link_down = true; -memset(s->buf, 0, sizeof(s->buf)); memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); +g_free(buf1); return; } @@ -222,6 +222,8 @@ static void net_socket_send(void *opaque) break; } } + +g_free(buf1); } static void net_socket_send_dgram(void *opaque) -- 2.5.0
[Qemu-devel] [PATCH v2] net: Allocating Large sized arrays to heap
nc_sendv_compat has a huge stack usage of 69680 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/net.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..89589c0 100644 --- a/net/net.c +++ b/net/net.c @@ -709,23 +709,29 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { -uint8_t buf[NET_BUFSIZE]; +uint8_t *buf; uint8_t *buffer; size_t offset; +ssize_t ret; + +buf = g_new(uint8_t, NET_BUFSIZE); if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { buffer = buf; -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); +offset = iov_to_buf(iov, iovcnt, 0, (uint8_t *)buf, NET_BUFSIZE); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { -return nc->info->receive_raw(nc, buffer, offset); +ret = nc->info->receive_raw(nc, buffer, offset); } else { -return nc->info->receive(nc, buffer, offset); +ret = nc->info->receive(nc, buffer, offset); } + +g_free(buf); +return ret; } ssize_t qemu_deliver_packet_iov(NetClientState *sender, -- 2.5.0
[Qemu-devel] [PATCH v3] socket: Allocating Large sized arrays to heap
net_socket_send has a huge stack usage of 69712 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/socket.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/socket.c b/net/socket.c index e32e3cb..d7fa8ce 100644 --- a/net/socket.c +++ b/net/socket.c @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; -uint8_t buf1[NET_BUFSIZE]; +uint8_t *buf1 = g_new(uint8_t, NET_BUFSIZE); const uint8_t *buf; -size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); +size = qemu_recv(s->fd, (uint8_t *)buf1, NET_BUFSIZE, 0); if (size < 0) { err = socket_error(); if (err != EWOULDBLOCK) @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) s->index = 0; s->packet_len = 0; s->nc.link_down = true; -memset(s->buf, 0, sizeof(s->buf)); memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); +g_free(buf1); return; } @@ -222,6 +222,8 @@ static void net_socket_send(void *opaque) break; } } + +g_free(buf1); } static void net_socket_send_dgram(void *opaque) -- 2.5.0
[Qemu-devel] [PATCH v3] blizzard: Remove support for DEPTH != 32
Removing support for DEPTH != 32 from blizzard template header and file that includes it, as macro DEPTH == 32 only used. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- hw/display/blizzard.c | 24 hw/display/blizzard_template.h | 30 +- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index c231960..a72e789 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -925,14 +925,6 @@ static void blizzard_update_display(void *opaque) s->my[1] = 0; } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" #define DEPTH 32 #include "blizzard_template.h" @@ -956,22 +948,6 @@ void *s1d13745_init(qemu_irq gpio_int) s->line_fn_tab[0] = s->line_fn_tab[1] = g_malloc0(sizeof(blizzard_fn_t) * 0x10); break; -case 8: -s->line_fn_tab[0] = blizzard_draw_fn_8; -s->line_fn_tab[1] = blizzard_draw_fn_r_8; -break; -case 15: -s->line_fn_tab[0] = blizzard_draw_fn_15; -s->line_fn_tab[1] = blizzard_draw_fn_r_15; -break; -case 16: -s->line_fn_tab[0] = blizzard_draw_fn_16; -s->line_fn_tab[1] = blizzard_draw_fn_r_16; -break; -case 24: -s->line_fn_tab[0] = blizzard_draw_fn_24; -s->line_fn_tab[1] = blizzard_draw_fn_r_24; -break; case 32: s->line_fn_tab[0] = blizzard_draw_fn_32; s->line_fn_tab[1] = blizzard_draw_fn_r_32; diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h index b7ef27c..bc38d7a 100644 --- a/hw/display/blizzard_template.h +++ b/hw/display/blizzard_template.h @@ -19,31 +19,7 @@ */ #define SKIP_PIXEL(to) (to += deststep) -#if DEPTH == 8 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 15 || DEPTH == 16 -# define PIXEL_TYPEuint16_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 24 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) \ -do { \ -to[0] = from; \ -to[1] = (from) >> 8; \ -to[2] = (from) >> 16; \ -SKIP_PIXEL(to); \ -} while (0) - -# define COPY_PIXEL1(to, from) \ -do { \ -*to++ = from; \ -*to++ = (from) >> 8; \ -*to++ = (from) >> 16; \ -} while (0) -#elif DEPTH == 32 +#if DEPTH == 32 # define PIXEL_TYPEuint32_t # define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) # define COPY_PIXEL1(to, from) (*to++ = from) @@ -58,9 +34,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, const uint16_t *src, unsigned int width) { -#if !defined(SWAP_WORDS) && DEPTH == 16 -memcpy(dest, src, width); -#else uint16_t data; unsigned int r, g, b; const uint16_t *end = (const void *) src + width; @@ -74,7 +47,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, data >>= 5; COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); } -#endif } static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, -- 2.5.0
[Qemu-devel] [PATCH v3] blizzard: Remove support for DEPTH != 32
Removing support for DEPTH != 32 from blizzard template header and file that includes it, as macro DEPTH == 32 only used. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- hw/display/blizzard.c | 24 hw/display/blizzard_template.h | 30 +- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index c231960..a72e789 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -925,14 +925,6 @@ static void blizzard_update_display(void *opaque) s->my[1] = 0; } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" #define DEPTH 32 #include "blizzard_template.h" @@ -956,22 +948,6 @@ void *s1d13745_init(qemu_irq gpio_int) s->line_fn_tab[0] = s->line_fn_tab[1] = g_malloc0(sizeof(blizzard_fn_t) * 0x10); break; -case 8: -s->line_fn_tab[0] = blizzard_draw_fn_8; -s->line_fn_tab[1] = blizzard_draw_fn_r_8; -break; -case 15: -s->line_fn_tab[0] = blizzard_draw_fn_15; -s->line_fn_tab[1] = blizzard_draw_fn_r_15; -break; -case 16: -s->line_fn_tab[0] = blizzard_draw_fn_16; -s->line_fn_tab[1] = blizzard_draw_fn_r_16; -break; -case 24: -s->line_fn_tab[0] = blizzard_draw_fn_24; -s->line_fn_tab[1] = blizzard_draw_fn_r_24; -break; case 32: s->line_fn_tab[0] = blizzard_draw_fn_32; s->line_fn_tab[1] = blizzard_draw_fn_r_32; diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h index b7ef27c..bc38d7a 100644 --- a/hw/display/blizzard_template.h +++ b/hw/display/blizzard_template.h @@ -19,31 +19,7 @@ */ #define SKIP_PIXEL(to) (to += deststep) -#if DEPTH == 8 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 15 || DEPTH == 16 -# define PIXEL_TYPEuint16_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 24 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) \ -do { \ -to[0] = from; \ -to[1] = (from) >> 8; \ -to[2] = (from) >> 16; \ -SKIP_PIXEL(to); \ -} while (0) - -# define COPY_PIXEL1(to, from) \ -do { \ -*to++ = from; \ -*to++ = (from) >> 8; \ -*to++ = (from) >> 16; \ -} while (0) -#elif DEPTH == 32 +#if DEPTH == 32 # define PIXEL_TYPEuint32_t # define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) # define COPY_PIXEL1(to, from) (*to++ = from) @@ -58,9 +34,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, const uint16_t *src, unsigned int width) { -#if !defined(SWAP_WORDS) && DEPTH == 16 -memcpy(dest, src, width); -#else uint16_t data; unsigned int r, g, b; const uint16_t *end = (const void *) src + width; @@ -74,7 +47,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, data >>= 5; COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); } -#endif } static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, -- 2.5.0
Re: [Qemu-devel] [PATCH v2 1/1] socket: Allocating Large sized arrays to heap
On Mon, Mar 14, 2016 at 10:20 PM, Daniel P. Berrange <berra...@redhat.com> wrote: > On Mon, Mar 14, 2016 at 10:07:53PM +0530, Pooja Dhannawat wrote: > > net_socket_send has a huge stack usage of 69712 bytes approx. > > Moving large arrays to heap to reduce stack usage. > > > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > --- > > net/socket.c | 8 +--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/net/socket.c b/net/socket.c > > index e32e3cb..3fcd7a6 100644 > > --- a/net/socket.c > > +++ b/net/socket.c > > @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) > > NetSocketState *s = opaque; > > int size, err; > > unsigned l; > > -uint8_t buf1[NET_BUFSIZE]; > > +uint8_t *buf1 = g_new(uint8_t, NET_BUFSIZE); > > You're allocating NET_BUFSIZE worth of uint8_t's > > I didn't get you clear. > > const uint8_t *buf; > > > > -size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); > > +size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); > > But only reading 1 byte which is clearly wrong. You likely wanted > NET_BUFSIZE here, not sizeof(uint8_t) > > Correct me If I am wrong. This should also work : size = qemu_recv(s->fd, (uint8_t *)buf1, NET_BUFSIZE * sizeof(uint8_t), 0); > Regards, > Daniel > -- > |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ > :| > |: http://libvirt.org -o- http://virt-manager.org > :| > |: http://autobuild.org -o- http://search.cpan.org/~danberr/ > :| > |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc > :| >
[Qemu-devel] [PATCH v2 1/1] socket: Allocating Large sized arrays to heap
net_socket_send has a huge stack usage of 69712 bytes approx. Moving large arrays to heap to reduce stack usage. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/socket.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/socket.c b/net/socket.c index e32e3cb..3fcd7a6 100644 --- a/net/socket.c +++ b/net/socket.c @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; -uint8_t buf1[NET_BUFSIZE]; +uint8_t *buf1 = g_new(uint8_t, NET_BUFSIZE); const uint8_t *buf; -size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); +size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); if (size < 0) { err = socket_error(); if (err != EWOULDBLOCK) @@ -170,8 +170,8 @@ static void net_socket_send(void *opaque) s->index = 0; s->packet_len = 0; s->nc.link_down = true; -memset(s->buf, 0, sizeof(s->buf)); memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); +g_free(buf1); return; } @@ -222,6 +222,8 @@ static void net_socket_send(void *opaque) break; } } + +g_free(buf1); } static void net_socket_send_dgram(void *opaque) -- 2.5.0
[Qemu-devel] [Patch v2 1/1] blizzard: Remove support for DEPTH != 32
Removing support for DEPTH != 32 from blizzard template header and file that includes it, as macro DEPTH == 32 only used. Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- hw/display/blizzard.c | 24 hw/display/blizzard_template.h | 30 +- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index c231960..a72e789 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -925,14 +925,6 @@ static void blizzard_update_display(void *opaque) s->my[1] = 0; } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" #define DEPTH 32 #include "blizzard_template.h" @@ -956,22 +948,6 @@ void *s1d13745_init(qemu_irq gpio_int) s->line_fn_tab[0] = s->line_fn_tab[1] = g_malloc0(sizeof(blizzard_fn_t) * 0x10); break; -case 8: -s->line_fn_tab[0] = blizzard_draw_fn_8; -s->line_fn_tab[1] = blizzard_draw_fn_r_8; -break; -case 15: -s->line_fn_tab[0] = blizzard_draw_fn_15; -s->line_fn_tab[1] = blizzard_draw_fn_r_15; -break; -case 16: -s->line_fn_tab[0] = blizzard_draw_fn_16; -s->line_fn_tab[1] = blizzard_draw_fn_r_16; -break; -case 24: -s->line_fn_tab[0] = blizzard_draw_fn_24; -s->line_fn_tab[1] = blizzard_draw_fn_r_24; -break; case 32: s->line_fn_tab[0] = blizzard_draw_fn_32; s->line_fn_tab[1] = blizzard_draw_fn_r_32; diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h index b7ef27c..bc38d7a 100644 --- a/hw/display/blizzard_template.h +++ b/hw/display/blizzard_template.h @@ -19,31 +19,7 @@ */ #define SKIP_PIXEL(to) (to += deststep) -#if DEPTH == 8 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 15 || DEPTH == 16 -# define PIXEL_TYPEuint16_t -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) -# define COPY_PIXEL1(to, from) (*to++ = from) -#elif DEPTH == 24 -# define PIXEL_TYPEuint8_t -# define COPY_PIXEL(to, from) \ -do { \ -to[0] = from; \ -to[1] = (from) >> 8; \ -to[2] = (from) >> 16; \ -SKIP_PIXEL(to); \ -} while (0) - -# define COPY_PIXEL1(to, from) \ -do { \ -*to++ = from; \ -*to++ = (from) >> 8; \ -*to++ = (from) >> 16; \ -} while (0) -#elif DEPTH == 32 +#if DEPTH == 32 # define PIXEL_TYPEuint32_t # define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) # define COPY_PIXEL1(to, from) (*to++ = from) @@ -58,9 +34,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, const uint16_t *src, unsigned int width) { -#if !defined(SWAP_WORDS) && DEPTH == 16 -memcpy(dest, src, width); -#else uint16_t data; unsigned int r, g, b; const uint16_t *end = (const void *) src + width; @@ -74,7 +47,6 @@ static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest, data >>= 5; COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b)); } -#endif } static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest, -- 2.5.0
Re: [Qemu-devel] [Patch 1/1] net/net: Allocating Large sized arrays to heap
On Mon, Mar 14, 2016 at 7:41 PM, Eric Blake <ebl...@redhat.com> wrote: > On 03/12/2016 01:39 AM, Pooja Dhannawat wrote: > > Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> > > --- > > net/net.c | 8 ++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/net/net.c b/net/net.c > > index b0c832e..5399758 100644 > > --- a/net/net.c > > +++ b/net/net.c > > @@ -709,16 +709,18 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, > const uint8_t *buf, int size) > > static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec > *iov, > > int iovcnt, unsigned flags) > > { > > -uint8_t buf[NET_BUFSIZE]; > > +uint8_t *buf; > > uint8_t *buffer; > > size_t offset; > > > > +buf = g_new(uint8_t, 1); > > If you're only going to malloc() one byte, it's more efficient to just > stack-allocate it: > > uint8_t buf[1]; > > Did you mean to do: > > buf = g_new(uint8_t, NET_BUFSIZE) > > instead? > > Yes, my bad, I meant NET_BUFSIZE. > > + > > if (iovcnt == 1) { > > buffer = iov[0].iov_base; > > offset = iov[0].iov_len; > > } else { > > buffer = buf; > > -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); > > +offset = iov_to_buf(iov, iovcnt, 0, (uint8_t *)buf, > sizeof(uint8_t)); > > This is wrong. The old code used NET_BUFSIZE bytes for iov_to_buf(), > the new code uses only one byte. By the way, sizeof(char) and > sizeof(uint8_t) are pointless in code, as they are strictly equivalent to > 1. > > I agree that the idea behind the patch is useful (NET_BUFSIZE is 68k, > which is too large for our goal of at most 4k stack allocation if we > never want to overflow a stack guard page), but you'll need a correct > working version of the patch. > > Yes, I will correct it and send next version of patch. > -- > Eric Blake eblake redhat com+1-919-301-3266 > Libvirt virtualization library http://libvirt.org > >
[Qemu-devel] [Patch 1/1] omap_lcdc: Remove support for DEPTH != 32
As only DEPTH ==32 case is used, removing other dead code which is based on DEPTH !== 32 Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- hw/display/omap_lcd_template.h | 10 ++ hw/display/omap_lcdc.c | 21 - 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/hw/display/omap_lcd_template.h b/hw/display/omap_lcd_template.h index f0ce71f..1025ff3 100644 --- a/hw/display/omap_lcd_template.h +++ b/hw/display/omap_lcd_template.h @@ -27,13 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if DEPTH == 8 -# define BPP 1 -# define PIXEL_TYPE uint8_t -#elif DEPTH == 15 || DEPTH == 16 -# define BPP 2 -# define PIXEL_TYPE uint16_t -#elif DEPTH == 32 +#if DEPTH == 32 # define BPP 4 # define PIXEL_TYPE uint32_t #else @@ -152,7 +146,7 @@ static void glue(draw_line12_, DEPTH)(void *opaque, static void glue(draw_line16_, DEPTH)(void *opaque, uint8_t *d, const uint8_t *s, int width, int deststep) { -#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) +#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) memcpy(d, s, width * 2); #else uint16_t v; diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c index ce1058b..4b3b810 100644 --- a/hw/display/omap_lcdc.c +++ b/hw/display/omap_lcdc.c @@ -71,44 +71,23 @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) #define draw_line_func drawfn -#define DEPTH 8 -#include "omap_lcd_template.h" -#define DEPTH 15 -#include "omap_lcd_template.h" -#define DEPTH 16 -#include "omap_lcd_template.h" #define DEPTH 32 #include "omap_lcd_template.h" static draw_line_func draw_line_table2[33] = { [0 ... 32] = NULL, -[8]= draw_line2_8, -[15] = draw_line2_15, -[16] = draw_line2_16, [32] = draw_line2_32, }, draw_line_table4[33] = { [0 ... 32] = NULL, -[8]= draw_line4_8, -[15] = draw_line4_15, -[16] = draw_line4_16, [32] = draw_line4_32, }, draw_line_table8[33] = { [0 ... 32] = NULL, -[8]= draw_line8_8, -[15] = draw_line8_15, -[16] = draw_line8_16, [32] = draw_line8_32, }, draw_line_table12[33] = { [0 ... 32] = NULL, -[8]= draw_line12_8, -[15] = draw_line12_15, -[16] = draw_line12_16, [32] = draw_line12_32, }, draw_line_table16[33] = { [0 ... 32] = NULL, -[8]= draw_line16_8, -[15] = draw_line16_15, -[16] = draw_line16_16, [32] = draw_line16_32, }; -- 2.5.0
[Qemu-devel] [Patch 1/1] net/net: Allocating Large sized arrays to heap
Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/net.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/net.c b/net/net.c index b0c832e..5399758 100644 --- a/net/net.c +++ b/net/net.c @@ -709,16 +709,18 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt, unsigned flags) { -uint8_t buf[NET_BUFSIZE]; +uint8_t *buf; uint8_t *buffer; size_t offset; +buf = g_new(uint8_t, 1); + if (iovcnt == 1) { buffer = iov[0].iov_base; offset = iov[0].iov_len; } else { buffer = buf; -offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf)); +offset = iov_to_buf(iov, iovcnt, 0, (uint8_t *)buf, sizeof(uint8_t)); } if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { @@ -726,6 +728,8 @@ static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, } else { return nc->info->receive(nc, buffer, offset); } + +g_free(buf); } ssize_t qemu_deliver_packet_iov(NetClientState *sender, -- 2.5.0
[Qemu-devel] [Patch 1/1] net/socket: Allocating Large sized arrays to heap
Signed-off-by: Pooja Dhannawat <dhannawatpoo...@gmail.com> --- net/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/socket.c b/net/socket.c index e32e3cb..483dcac 100644 --- a/net/socket.c +++ b/net/socket.c @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; -uint8_t buf1[NET_BUFSIZE]; +uint8_t *buf1 = g_new(uint8_t, 1); const uint8_t *buf; -size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); +size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); if (size < 0) { err = socket_error(); if (err != EWOULDBLOCK) @@ -170,7 +170,6 @@ static void net_socket_send(void *opaque) s->index = 0; s->packet_len = 0; s->nc.link_down = true; -memset(s->buf, 0, sizeof(s->buf)); memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); return; @@ -222,6 +221,7 @@ static void net_socket_send(void *opaque) break; } } +g_free(buf1); } static void net_socket_send_dgram(void *opaque) -- 2.5.0