Received: from eggs.gnu.org ([2001:4830:134:3::10]:39678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axLIf-0006GY-MR for qemu-devel@nongnu.org; Mon, 02 May 2016 17:22:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axLIT-00030K-Qk for qemu-devel@nongnu.org; Mon, 02 May 2016 17:22:36 -0400 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) From: Sylvain Garrigues In-Reply-To: <1461325343-24995-1-git-send-email-sylvain@sylvaingarrigues.com> Date: Tue, 3 May 2016 00:21:31 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <1B088DF8-FDE6-49AE-8C12-BA60B4D20BF6@gmail.com> References: <1461325343-24995-1-git-send-email-sylvain@sylvaingarrigues.com> Subject: Re: [Qemu-devel] [PATCH] bcm2835_property: use cached values when querying framebuffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Eric Blake , Markus Armbruster , Paolo Bonzini , "qemu-arm@nongnu.org" , qemu-devel@nongnu.org Hello, Shall we commit this patch? Very best, Sylvain > Le 22 avr. 2016 =C3=A0 14:42, Sylvain Garrigues a =C3=A9crit : >=20 > As the framebuffer settings are copied into the result message before it i= s > reconfigured, inconsistent behavior can happen when, for instance, you set= with > a single message the width, height, and depth, and ask at the same time to= > allocate the buffer and get the pitch and the size. >=20 > In this case, the reported pitch and size would be incorrect as they were > computed with the initial values of width, height and depth, not the ones t= he > client requested. >=20 > Signed-off-by: Sylvain Garrigues > Reviewed-by: Andrew Baumann > --- > hw/misc/bcm2835_property.c | 31 ++++++++++++++++++++++--------- > 1 file changed, 22 insertions(+), 9 deletions(-) >=20 > diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c > index 530411f..96e3b8f 100644 > --- a/hw/misc/bcm2835_property.c > +++ b/hw/misc/bcm2835_property.c > @@ -21,6 +21,7 @@ static void bcm2835_property_mbox_push(BCM2835PropertySt= ate *s, uint32_t value) > int n; > uint32_t offset, length, color; > uint32_t xres, yres, xoffset, yoffset, bpp, pixo, alpha; > + uint32_t tmp_xres, tmp_yres, tmp_xoffset, tmp_yoffset, tmp_bpp, tmp_p= ixo, tmp_alpha; > uint32_t *newxres =3D NULL, *newyres =3D NULL, *newxoffset =3D NULL, > *newyoffset =3D NULL, *newbpp =3D NULL, *newpixo =3D NULL, *newalp= ha =3D NULL; >=20 > @@ -139,7 +140,10 @@ static void bcm2835_property_mbox_push(BCM2835Propert= yState *s, uint32_t value) >=20 > case 0x00040001: /* Allocate buffer */ > stl_le_phys(&s->dma_as, value + 12, s->fbdev->base); > - stl_le_phys(&s->dma_as, value + 16, s->fbdev->size); > + tmp_xres =3D newxres !=3D NULL ? *newxres : s->fbdev->xres; > + tmp_yres =3D newyres !=3D NULL ? *newyres : s->fbdev->yres; > + tmp_bpp =3D newbpp !=3D NULL ? *newbpp : s->fbdev->bpp; > + stl_le_phys(&s->dma_as, value + 16, tmp_xres * tmp_yres * tmp= _bpp / 8); > resplen =3D 8; > break; > case 0x00048001: /* Release buffer */ > @@ -150,8 +154,10 @@ static void bcm2835_property_mbox_push(BCM2835Propert= yState *s, uint32_t value) > break; > case 0x00040003: /* Get display width/height */ > case 0x00040004: > - stl_le_phys(&s->dma_as, value + 12, s->fbdev->xres); > - stl_le_phys(&s->dma_as, value + 16, s->fbdev->yres); > + tmp_xres =3D newxres !=3D NULL ? *newxres : s->fbdev->xres; > + tmp_yres =3D newyres !=3D NULL ? *newyres : s->fbdev->yres; > + stl_le_phys(&s->dma_as, value + 12, tmp_xres); > + stl_le_phys(&s->dma_as, value + 16, tmp_yres); > resplen =3D 8; > break; > case 0x00044003: /* Test display width/height */ > @@ -167,7 +173,8 @@ static void bcm2835_property_mbox_push(BCM2835Property= State *s, uint32_t value) > resplen =3D 8; > break; > case 0x00040005: /* Get depth */ > - stl_le_phys(&s->dma_as, value + 12, s->fbdev->bpp); > + tmp_bpp =3D newbpp !=3D NULL ? *newbpp : s->fbdev->bpp; > + stl_le_phys(&s->dma_as, value + 12, tmp_bpp); > resplen =3D 4; > break; > case 0x00044005: /* Test depth */ > @@ -179,7 +186,8 @@ static void bcm2835_property_mbox_push(BCM2835Property= State *s, uint32_t value) > resplen =3D 4; > break; > case 0x00040006: /* Get pixel order */ > - stl_le_phys(&s->dma_as, value + 12, s->fbdev->pixo); > + tmp_pixo =3D newpixo !=3D NULL ? *newpixo : s->fbdev->pixo; > + stl_le_phys(&s->dma_as, value + 12, tmp_pixo); > resplen =3D 4; > break; > case 0x00044006: /* Test pixel order */ > @@ -191,7 +199,8 @@ static void bcm2835_property_mbox_push(BCM2835Property= State *s, uint32_t value) > resplen =3D 4; > break; > case 0x00040007: /* Get alpha */ > - stl_le_phys(&s->dma_as, value + 12, s->fbdev->alpha); > + tmp_alpha =3D newalpha !=3D NULL ? *newalpha : s->fbdev->alph= a; > + stl_le_phys(&s->dma_as, value + 12, tmp_alpha); > resplen =3D 4; > break; > case 0x00044007: /* Test pixel alpha */ > @@ -203,12 +212,16 @@ static void bcm2835_property_mbox_push(BCM2835Proper= tyState *s, uint32_t value) > resplen =3D 4; > break; > case 0x00040008: /* Get pitch */ > - stl_le_phys(&s->dma_as, value + 12, s->fbdev->pitch); > + tmp_xres =3D newxres !=3D NULL ? *newxres : s->fbdev->xres; > + tmp_bpp =3D newbpp !=3D NULL ? *newbpp : s->fbdev->bpp; > + stl_le_phys(&s->dma_as, value + 12, tmp_xres * tmp_bpp / 8); > resplen =3D 4; > break; > case 0x00040009: /* Get virtual offset */ > - stl_le_phys(&s->dma_as, value + 12, s->fbdev->xoffset); > - stl_le_phys(&s->dma_as, value + 16, s->fbdev->yoffset); > + tmp_xoffset =3D newxoffset !=3D NULL ? *newxoffset : s->fbdev= ->xoffset; > + tmp_yoffset =3D newyoffset !=3D NULL ? *newyoffset : s->fbdev= ->yoffset; > + stl_le_phys(&s->dma_as, value + 12, tmp_xoffset); > + stl_le_phys(&s->dma_as, value + 16, tmp_yoffset); > resplen =3D 8; > break; > case 0x00044009: /* Test virtual offset */ > --=20 > 2.8.1 >=20