* [PATCH 1/2] drm/vram: store dumb bo dimensions. [not found] <20190626065551.12956-1-kraxel@redhat.com> @ 2019-06-26 6:55 ` Gerd Hoffmann 2019-06-26 14:40 ` Sam Ravnborg 2019-06-27 7:57 ` Thomas Zimmermann 2019-06-26 6:55 ` [PATCH 2/2] drm/bochs: fix framebuffer setup Gerd Hoffmann 1 sibling, 2 replies; 9+ messages in thread From: Gerd Hoffmann @ 2019-06-26 6:55 UTC (permalink / raw) To: dri-devel Cc: tzimmermann, Gerd Hoffmann, Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie, Daniel Vetter, open list Store width and height of the bo. Needed in case userspace sets up a framebuffer with fb->width != bo->width.. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- include/drm/drm_gem_vram_helper.h | 1 + drivers/gpu/drm/drm_gem_vram_helper.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h index 1a0ea18e7a74..3692dba167df 100644 --- a/include/drm/drm_gem_vram_helper.h +++ b/include/drm/drm_gem_vram_helper.h @@ -39,6 +39,7 @@ struct drm_gem_vram_object { struct drm_gem_object gem; struct ttm_buffer_object bo; struct ttm_bo_kmap_obj kmap; + unsigned int width, height; /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ struct ttm_placement placement; diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 4de782ca26b2..c02bf7694117 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -377,6 +377,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); if (IS_ERR(gbo)) return PTR_ERR(gbo); + gbo->width = args->width; + gbo->height = args->height; ret = drm_gem_handle_create(file, &gbo->gem, &handle); if (ret) -- 2.18.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] drm/vram: store dumb bo dimensions. 2019-06-26 6:55 ` [PATCH 1/2] drm/vram: store dumb bo dimensions Gerd Hoffmann @ 2019-06-26 14:40 ` Sam Ravnborg 2019-06-26 16:27 ` Daniel Vetter 2019-06-27 7:57 ` Thomas Zimmermann 1 sibling, 1 reply; 9+ messages in thread From: Sam Ravnborg @ 2019-06-26 14:40 UTC (permalink / raw) To: Gerd Hoffmann Cc: dri-devel, Maxime Ripard, open list, David Airlie, tzimmermann, Sean Paul Hi Gerd. On Wed, Jun 26, 2019 at 08:55:50AM +0200, Gerd Hoffmann wrote: > Store width and height of the bo. Needed in case userspace > sets up a framebuffer with fb->width != bo->width.. > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > include/drm/drm_gem_vram_helper.h | 1 + > drivers/gpu/drm/drm_gem_vram_helper.c | 2 ++ > 2 files changed, 3 insertions(+) > > diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h > index 1a0ea18e7a74..3692dba167df 100644 > --- a/include/drm/drm_gem_vram_helper.h > +++ b/include/drm/drm_gem_vram_helper.h > @@ -39,6 +39,7 @@ struct drm_gem_vram_object { > struct drm_gem_object gem; > struct ttm_buffer_object bo; > struct ttm_bo_kmap_obj kmap; > + unsigned int width, height; > > /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ > struct ttm_placement placement; > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > index 4de782ca26b2..c02bf7694117 100644 > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > @@ -377,6 +377,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, > gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); > if (IS_ERR(gbo)) > return PTR_ERR(gbo); > + gbo->width = args->width; > + gbo->height = args->height; > > ret = drm_gem_handle_create(file, &gbo->gem, &handle); > if (ret) Be warned, I may have missed something in the bigger picture. Your patch will set width and height only for dumb bo's But we have several users of drm_gem_vram_create() that will not set the width and height. So only in some cases can we rely on them being set. Should this be refactored so we always set width, height. Or maybe say in a small comment that width,height are only set for dumb bo's? Sam ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] drm/vram: store dumb bo dimensions. 2019-06-26 14:40 ` Sam Ravnborg @ 2019-06-26 16:27 ` Daniel Vetter 2019-07-08 13:39 ` Pekka Paalanen 0 siblings, 1 reply; 9+ messages in thread From: Daniel Vetter @ 2019-06-26 16:27 UTC (permalink / raw) To: Sam Ravnborg Cc: Gerd Hoffmann, Maxime Ripard, open list, dri-devel, David Airlie, tzimmermann, Sean Paul On Wed, Jun 26, 2019 at 04:40:13PM +0200, Sam Ravnborg wrote: > Hi Gerd. > > On Wed, Jun 26, 2019 at 08:55:50AM +0200, Gerd Hoffmann wrote: > > Store width and height of the bo. Needed in case userspace > > sets up a framebuffer with fb->width != bo->width.. > > > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > > --- > > include/drm/drm_gem_vram_helper.h | 1 + > > drivers/gpu/drm/drm_gem_vram_helper.c | 2 ++ > > 2 files changed, 3 insertions(+) > > > > diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h > > index 1a0ea18e7a74..3692dba167df 100644 > > --- a/include/drm/drm_gem_vram_helper.h > > +++ b/include/drm/drm_gem_vram_helper.h > > @@ -39,6 +39,7 @@ struct drm_gem_vram_object { > > struct drm_gem_object gem; > > struct ttm_buffer_object bo; > > struct ttm_bo_kmap_obj kmap; > > + unsigned int width, height; > > > > /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ > > struct ttm_placement placement; > > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > > index 4de782ca26b2..c02bf7694117 100644 > > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > > @@ -377,6 +377,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, > > gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); > > if (IS_ERR(gbo)) > > return PTR_ERR(gbo); > > + gbo->width = args->width; > > + gbo->height = args->height; > > > > ret = drm_gem_handle_create(file, &gbo->gem, &handle); > > if (ret) > > Be warned, I may have missed something in the bigger picture. > > Your patch will set width and height only for dumb bo's > But we have several users of drm_gem_vram_create() that will > not set the width and height. > > So only in some cases can we rely on them being set. > Should this be refactored so we always set width, height. > Or maybe say in a small comment that width,height are only > set for dumb bo's? Also for dumb bo allocated buffers if userspace gets the dimensions wrong between dumb_create and the addfb, something is wrong. Papering over that by remembering the right dimensions doesn't look like a good solution. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] drm/vram: store dumb bo dimensions. 2019-06-26 16:27 ` Daniel Vetter @ 2019-07-08 13:39 ` Pekka Paalanen 2019-07-10 15:26 ` Daniel Vetter 0 siblings, 1 reply; 9+ messages in thread From: Pekka Paalanen @ 2019-07-08 13:39 UTC (permalink / raw) To: Daniel Vetter Cc: Sam Ravnborg, Maxime Ripard, open list, dri-devel, David Airlie, Gerd Hoffmann, tzimmermann, Sean Paul [-- Attachment #1: Type: text/plain, Size: 3000 bytes --] On Wed, 26 Jun 2019 18:27:54 +0200 Daniel Vetter <daniel@ffwll.ch> wrote: > On Wed, Jun 26, 2019 at 04:40:13PM +0200, Sam Ravnborg wrote: > > Hi Gerd. > > > > On Wed, Jun 26, 2019 at 08:55:50AM +0200, Gerd Hoffmann wrote: > > > Store width and height of the bo. Needed in case userspace > > > sets up a framebuffer with fb->width != bo->width.. > > > > > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > > > --- > > > include/drm/drm_gem_vram_helper.h | 1 + > > > drivers/gpu/drm/drm_gem_vram_helper.c | 2 ++ > > > 2 files changed, 3 insertions(+) > > > > > > diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h > > > index 1a0ea18e7a74..3692dba167df 100644 > > > --- a/include/drm/drm_gem_vram_helper.h > > > +++ b/include/drm/drm_gem_vram_helper.h > > > @@ -39,6 +39,7 @@ struct drm_gem_vram_object { > > > struct drm_gem_object gem; > > > struct ttm_buffer_object bo; > > > struct ttm_bo_kmap_obj kmap; > > > + unsigned int width, height; > > > > > > /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ > > > struct ttm_placement placement; > > > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > > > index 4de782ca26b2..c02bf7694117 100644 > > > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > > > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > > > @@ -377,6 +377,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, > > > gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); > > > if (IS_ERR(gbo)) > > > return PTR_ERR(gbo); > > > + gbo->width = args->width; > > > + gbo->height = args->height; > > > > > > ret = drm_gem_handle_create(file, &gbo->gem, &handle); > > > if (ret) > > > > Be warned, I may have missed something in the bigger picture. > > > > Your patch will set width and height only for dumb bo's > > But we have several users of drm_gem_vram_create() that will > > not set the width and height. > > > > So only in some cases can we rely on them being set. > > Should this be refactored so we always set width, height. > > Or maybe say in a small comment that width,height are only > > set for dumb bo's? > > Also for dumb bo allocated buffers if userspace gets the dimensions wrong > between dumb_create and the addfb, something is wrong. Papering over that > by remembering the right dimensions doesn't look like a good solution. Hi, just a note irrelevant to this particular driver: I have deliberately allocated a too high dumb buffer in userspace and created multiple smaller DRM FBs out of it with different offsets (i * 128 * stride). This has been a very useful hack to see that a GPU-less driver actually honours fences correctly, because if it doesn't, the whole image will be off by the offset delta, which is epileptically easy to see. So I'm not getting the height wrong, I am deliberately overallocating and aliasing. Thanks, pq [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] drm/vram: store dumb bo dimensions. 2019-07-08 13:39 ` Pekka Paalanen @ 2019-07-10 15:26 ` Daniel Vetter 0 siblings, 0 replies; 9+ messages in thread From: Daniel Vetter @ 2019-07-10 15:26 UTC (permalink / raw) To: Pekka Paalanen Cc: Daniel Vetter, Sam Ravnborg, Maxime Ripard, open list, dri-devel, David Airlie, Gerd Hoffmann, tzimmermann, Sean Paul On Mon, Jul 08, 2019 at 04:39:45PM +0300, Pekka Paalanen wrote: > On Wed, 26 Jun 2019 18:27:54 +0200 > Daniel Vetter <daniel@ffwll.ch> wrote: > > > On Wed, Jun 26, 2019 at 04:40:13PM +0200, Sam Ravnborg wrote: > > > Hi Gerd. > > > > > > On Wed, Jun 26, 2019 at 08:55:50AM +0200, Gerd Hoffmann wrote: > > > > Store width and height of the bo. Needed in case userspace > > > > sets up a framebuffer with fb->width != bo->width.. > > > > > > > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > > > > --- > > > > include/drm/drm_gem_vram_helper.h | 1 + > > > > drivers/gpu/drm/drm_gem_vram_helper.c | 2 ++ > > > > 2 files changed, 3 insertions(+) > > > > > > > > diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h > > > > index 1a0ea18e7a74..3692dba167df 100644 > > > > --- a/include/drm/drm_gem_vram_helper.h > > > > +++ b/include/drm/drm_gem_vram_helper.h > > > > @@ -39,6 +39,7 @@ struct drm_gem_vram_object { > > > > struct drm_gem_object gem; > > > > struct ttm_buffer_object bo; > > > > struct ttm_bo_kmap_obj kmap; > > > > + unsigned int width, height; > > > > > > > > /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ > > > > struct ttm_placement placement; > > > > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > > > > index 4de782ca26b2..c02bf7694117 100644 > > > > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > > > > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > > > > @@ -377,6 +377,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, > > > > gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); > > > > if (IS_ERR(gbo)) > > > > return PTR_ERR(gbo); > > > > + gbo->width = args->width; > > > > + gbo->height = args->height; > > > > > > > > ret = drm_gem_handle_create(file, &gbo->gem, &handle); > > > > if (ret) > > > > > > Be warned, I may have missed something in the bigger picture. > > > > > > Your patch will set width and height only for dumb bo's > > > But we have several users of drm_gem_vram_create() that will > > > not set the width and height. > > > > > > So only in some cases can we rely on them being set. > > > Should this be refactored so we always set width, height. > > > Or maybe say in a small comment that width,height are only > > > set for dumb bo's? > > > > Also for dumb bo allocated buffers if userspace gets the dimensions wrong > > between dumb_create and the addfb, something is wrong. Papering over that > > by remembering the right dimensions doesn't look like a good solution. > > Hi, > > just a note irrelevant to this particular driver: > > I have deliberately allocated a too high dumb buffer in userspace and > created multiple smaller DRM FBs out of it with different offsets > (i * 128 * stride). This has been a very useful hack to see that a > GPU-less driver actually honours fences correctly, because if it > doesn't, the whole image will be off by the offset delta, which is > epileptically easy to see. > > So I'm not getting the height wrong, I am deliberately overallocating > and aliasing. Yeah that's the other reason for why this patch is wrong: It would break things like this trickery here :-) The separation between backing storage and drm_fb is intentional, multiple fb in one overall fb is explicitly ok. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] drm/vram: store dumb bo dimensions. 2019-06-26 6:55 ` [PATCH 1/2] drm/vram: store dumb bo dimensions Gerd Hoffmann 2019-06-26 14:40 ` Sam Ravnborg @ 2019-06-27 7:57 ` Thomas Zimmermann 2019-06-27 12:10 ` Gerd Hoffmann 1 sibling, 1 reply; 9+ messages in thread From: Thomas Zimmermann @ 2019-06-27 7:57 UTC (permalink / raw) To: Gerd Hoffmann, dri-devel Cc: Maxime Ripard, open list, David Airlie, Sean Paul [-- Attachment #1.1: Type: text/plain, Size: 1866 bytes --] Hi Am 26.06.19 um 08:55 schrieb Gerd Hoffmann: > Store width and height of the bo. Needed in case userspace > sets up a framebuffer with fb->width != bo->width.. This seems like bug. I'd rather return an error to userspace if the BO is incompatible. For the Gnome issue, a fix would be to program the display HW's line pitch to the correct value. Best regards Thomas > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > include/drm/drm_gem_vram_helper.h | 1 + > drivers/gpu/drm/drm_gem_vram_helper.c | 2 ++ > 2 files changed, 3 insertions(+) > > diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h > index 1a0ea18e7a74..3692dba167df 100644 > --- a/include/drm/drm_gem_vram_helper.h > +++ b/include/drm/drm_gem_vram_helper.h > @@ -39,6 +39,7 @@ struct drm_gem_vram_object { > struct drm_gem_object gem; > struct ttm_buffer_object bo; > struct ttm_bo_kmap_obj kmap; > + unsigned int width, height; > > /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ > struct ttm_placement placement; > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > index 4de782ca26b2..c02bf7694117 100644 > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > @@ -377,6 +377,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, > gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); > if (IS_ERR(gbo)) > return PTR_ERR(gbo); > + gbo->width = args->width; > + gbo->height = args->height; > > ret = drm_gem_handle_create(file, &gbo->gem, &handle); > if (ret) > -- Thomas Zimmermann Graphics Driver Developer SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] drm/vram: store dumb bo dimensions. 2019-06-27 7:57 ` Thomas Zimmermann @ 2019-06-27 12:10 ` Gerd Hoffmann 0 siblings, 0 replies; 9+ messages in thread From: Gerd Hoffmann @ 2019-06-27 12:10 UTC (permalink / raw) To: Thomas Zimmermann Cc: dri-devel, Maxime Ripard, open list, David Airlie, Sean Paul Hi, > For the Gnome issue, a fix would be to program the display HW's line > pitch to the correct value. Yes, and drm_framebuffer actually has the pitches, so no need for this patch indeed. cheers, Gerd ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] drm/bochs: fix framebuffer setup. [not found] <20190626065551.12956-1-kraxel@redhat.com> 2019-06-26 6:55 ` [PATCH 1/2] drm/vram: store dumb bo dimensions Gerd Hoffmann @ 2019-06-26 6:55 ` Gerd Hoffmann 2019-06-26 16:29 ` Daniel Vetter 1 sibling, 1 reply; 9+ messages in thread From: Gerd Hoffmann @ 2019-06-26 6:55 UTC (permalink / raw) To: dri-devel Cc: tzimmermann, Gerd Hoffmann, David Airlie, Daniel Vetter, open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list If bo->width doesn't match fb->width the driver fails to configure the display correctly, resulting in a scrambled display. Fix it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- drivers/gpu/drm/bochs/bochs.h | 2 +- drivers/gpu/drm/bochs/bochs_hw.c | 13 +++++++++---- drivers/gpu/drm/bochs/bochs_kms.c | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h index cc35d492142c..78c0283496cc 100644 --- a/drivers/gpu/drm/bochs/bochs.h +++ b/drivers/gpu/drm/bochs/bochs.h @@ -86,7 +86,7 @@ void bochs_hw_setmode(struct bochs_device *bochs, void bochs_hw_setformat(struct bochs_device *bochs, const struct drm_format_info *format); void bochs_hw_setbase(struct bochs_device *bochs, - int x, int y, u64 addr); + int x, int y, int fbwidth, u64 addr); int bochs_hw_load_edid(struct bochs_device *bochs); /* bochs_mm.c */ diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c index 791ab2f79947..141aa02962d3 100644 --- a/drivers/gpu/drm/bochs/bochs_hw.c +++ b/drivers/gpu/drm/bochs/bochs_hw.c @@ -255,16 +255,21 @@ void bochs_hw_setformat(struct bochs_device *bochs, } void bochs_hw_setbase(struct bochs_device *bochs, - int x, int y, u64 addr) + int x, int y, int fbwidth, u64 addr) { - unsigned long offset = (unsigned long)addr + + unsigned long offset; + unsigned int vx, vy; + + bochs->stride = fbwidth * (bochs->bpp / 8); + offset = (unsigned long)addr + y * bochs->stride + x * (bochs->bpp / 8); - int vy = offset / bochs->stride; - int vx = (offset % bochs->stride) * 8 / bochs->bpp; + vy = offset / bochs->stride; + vx = (offset % bochs->stride) * 8 / bochs->bpp; DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n", x, y, addr, offset, vx, vy); + bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, fbwidth); bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx); bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy); } diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c index 5904eddc83a5..1f6aa11a1dc9 100644 --- a/drivers/gpu/drm/bochs/bochs_kms.c +++ b/drivers/gpu/drm/bochs/bochs_kms.c @@ -36,6 +36,7 @@ static void bochs_plane_update(struct bochs_device *bochs, bochs_hw_setbase(bochs, state->crtc_x, state->crtc_y, + gbo->width, gbo->bo.offset); bochs_hw_setformat(bochs, state->fb->format); } -- 2.18.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] drm/bochs: fix framebuffer setup. 2019-06-26 6:55 ` [PATCH 2/2] drm/bochs: fix framebuffer setup Gerd Hoffmann @ 2019-06-26 16:29 ` Daniel Vetter 0 siblings, 0 replies; 9+ messages in thread From: Daniel Vetter @ 2019-06-26 16:29 UTC (permalink / raw) To: Gerd Hoffmann Cc: dri-devel, tzimmermann, David Airlie, Daniel Vetter, open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list On Wed, Jun 26, 2019 at 08:55:51AM +0200, Gerd Hoffmann wrote: > If bo->width doesn't match fb->width the driver fails to configure > the display correctly, resulting in a scrambled display. Fix it. > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > drivers/gpu/drm/bochs/bochs.h | 2 +- > drivers/gpu/drm/bochs/bochs_hw.c | 13 +++++++++---- > drivers/gpu/drm/bochs/bochs_kms.c | 1 + > 3 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h > index cc35d492142c..78c0283496cc 100644 > --- a/drivers/gpu/drm/bochs/bochs.h > +++ b/drivers/gpu/drm/bochs/bochs.h > @@ -86,7 +86,7 @@ void bochs_hw_setmode(struct bochs_device *bochs, > void bochs_hw_setformat(struct bochs_device *bochs, > const struct drm_format_info *format); > void bochs_hw_setbase(struct bochs_device *bochs, > - int x, int y, u64 addr); > + int x, int y, int fbwidth, u64 addr); > int bochs_hw_load_edid(struct bochs_device *bochs); > > /* bochs_mm.c */ > diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c > index 791ab2f79947..141aa02962d3 100644 > --- a/drivers/gpu/drm/bochs/bochs_hw.c > +++ b/drivers/gpu/drm/bochs/bochs_hw.c > @@ -255,16 +255,21 @@ void bochs_hw_setformat(struct bochs_device *bochs, > } > > void bochs_hw_setbase(struct bochs_device *bochs, > - int x, int y, u64 addr) > + int x, int y, int fbwidth, u64 addr) > { > - unsigned long offset = (unsigned long)addr + > + unsigned long offset; > + unsigned int vx, vy; > + > + bochs->stride = fbwidth * (bochs->bpp / 8); > + offset = (unsigned long)addr + > y * bochs->stride + > x * (bochs->bpp / 8); > - int vy = offset / bochs->stride; > - int vx = (offset % bochs->stride) * 8 / bochs->bpp; > + vy = offset / bochs->stride; > + vx = (offset % bochs->stride) * 8 / bochs->bpp; > > DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n", > x, y, addr, offset, vx, vy); > + bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, fbwidth); > bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx); > bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy); > } > diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c > index 5904eddc83a5..1f6aa11a1dc9 100644 > --- a/drivers/gpu/drm/bochs/bochs_kms.c > +++ b/drivers/gpu/drm/bochs/bochs_kms.c > @@ -36,6 +36,7 @@ static void bochs_plane_update(struct bochs_device *bochs, > bochs_hw_setbase(bochs, > state->crtc_x, > state->crtc_y, > + gbo->width, You want the dimensions of the drm_framebuffer here, not something from the underlying gem bo. > gbo->bo.offset); I think same here, or at least additionally take into account both drm_framebuffer offset _and_ vram offset. -Daniel > bochs_hw_setformat(bochs, state->fb->format); > } > -- > 2.18.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-07-10 15:26 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20190626065551.12956-1-kraxel@redhat.com> 2019-06-26 6:55 ` [PATCH 1/2] drm/vram: store dumb bo dimensions Gerd Hoffmann 2019-06-26 14:40 ` Sam Ravnborg 2019-06-26 16:27 ` Daniel Vetter 2019-07-08 13:39 ` Pekka Paalanen 2019-07-10 15:26 ` Daniel Vetter 2019-06-27 7:57 ` Thomas Zimmermann 2019-06-27 12:10 ` Gerd Hoffmann 2019-06-26 6:55 ` [PATCH 2/2] drm/bochs: fix framebuffer setup Gerd Hoffmann 2019-06-26 16:29 ` Daniel Vetter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).