mgag200: some cleanup and a fix for corrupted output
Subsystems (3)
PATCH 1/1 mgag200: some cleanup and a fix for corrupted output
Patches 1 to 4 are just cleanup. Maybe these should should be rolled into one patch?
Patch 5 is a bit more complicated.
On cards with very little video memory, (e.g 8MB) higher resolutions at 32bit framebuffer depths will get corrupted because the required memory is larger than what the framebuffer has. DRM has "max_height" and "max_width" but no "max_bytes" for limiting resolutions, so the patch is a little hacky. The first for loop tries to associate a connector with the mode being tested. From the connector I can get the bpp if the user specified one on the video= commandline. After that I do 2 things:
1) Invalidate the requested mode from the video= parameter
2) Return MODE_BAD if the framebuffer would be too large
I feel this patch plays with structures it shouldn't have to touch to get the bpp. An alternative fix would be to include a "max_bytes" in the DRM core and then do these checks there.
I'm also wondering, did I miss the 3.9.0 merge window?
Thanks,
Christopher Harvey (5):
drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used drm/mgag200: Cleanup: Pass driver specific mga_device in driver
functions
drm/mgag200: Cleanup: Remove extra variable assigns drm/mgag200: Reject modes that are too big for VRAM
drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 30 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.12.4
PATCH 1/1 drm/mgag200: Reject modes that are too big for VRAM
A monitor or a user could request a resolution greater than the available VRAM for the backing framebuffer. This change checks the required framebuffer size against the max VRAM size and rejects modes if they are too big. This change can also remove a mode request passed in via the video= parameter.
--- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/mgag200/mgag200_mode.c +27 -0
@@ -1405,6 +1405,14 @@ static int mga_vga_get_modes(struct drm_connector *connector)static int mga_vga_mode_valid (struct drm_connector *connector,struct drm_display_mode *mode) { +struct drm_device *dev = connector->dev; +struct mga_device *mdev = (struct mga_device *)dev->dev_private; +struct mga_fbdev *mfbdev = mdev->mfbdev; +struct drm_fb_helper *fb_helper = &mfbdev->helper; +struct drm_fb_helper_connector *fb_helper_conn =NULL ; +int bpp =32 ; +int i =0 ; +/* FIXME: Add bandwidth and g200se limitations */ if (mode->crtc_hdisplay > 2048 || mode->crtc_hsync_start > 4096 ||
@@ -1414,6 +1422,25 @@ static int mga_vga_mode_valid(struct drm_connector *connector,return MODE_BAD ; } +/* Validate the mode input by the user */ +for (i =0 ; i < fb_helper->connector_count; i++) { +if (fb_helper->connector_info[i]->connector == connector) { +/* Found the helper for this connector */ + fb_helper_conn = fb_helper->connector_info[i]; +if (fb_helper_conn->cmdline_mode.specified) { +if (fb_helper_conn->cmdline_mode.bpp_specified) { + bpp = fb_helper_conn->cmdline_mode.bpp; + } + } + } + } + +if ((mode->hdisplay * mode->vdisplay * (bpp/8 )) > mdev->mc.vram_size) { +if (fb_helper_conn) + fb_helper_conn->cmdline_mode.specified = false; +return MODE_BAD ; + } +return MODE_OK ; }
Signature · 1 line
1.7.12.4
Re: [PATCH] drm/mgag200: Reject modes that are too big for VRAM
Am Dienstag, den 26.02.2013, 10:55 -0500 schrieb Christopher Harvey:
Quoted 16 lines
A monitor or a user could request a resolution greater than the available VRAM for the backing framebuffer. This change checks the required framebuffer size against the max VRAM size and rejects modes if they are too big. This change can also remove a mode request passed in via the video= parameter.
Signed-off-by Christopher Harvey <[email protected]>--- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/gpu/drm/mgag200/mgag200_mode.c +0
-0
drivers/gpu/drm/mgag200/mgag200_mode.c static int mga_vga_get_modes(struct drm_connector *connector) · line 1414
Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +7
-0@@ -1405,6 +1405,14 @@ static int mga_vga_get_modes(struct drm_connector *connector)static int mga_vga_mode_valid (struct drm_connector *connector,struct drm_display_mode *mode) { +struct drm_device *dev = connector->dev; +struct mga_device *mdev = (struct mga_device *)dev->dev_private; +struct mga_fbdev *mfbdev = mdev->mfbdev; +struct drm_fb_helper *fb_helper = &mfbdev->helper; +struct drm_fb_helper_connector *fb_helper_conn =NULL ; +int bpp =32 ; +int i =0 ;
It is initialized in the for loop again.
Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +3
-0+/* FIXME: Add bandwidth and g200se limitations */ if (mode->crtc_hdisplay > 2048 || mode->crtc_hsync_start > 4096 ||@@ -1414,6 +1422,25 @@ static int mga_vga_mode_valid(struct drm_connector *connector,return MODE_BAD ; } +/* Validate the mode input by the user */ +for (i =0 ; i < fb_helper->connector_count; i++) {
drivers/gpu/drm/mgag200/mgag200_mode.c static int mga_vga_mode_valid(struct drm_connector *connector, · line 1436
Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +10
-0+if (fb_helper->connector_info[i]->connector == connector) { +/* Found the helper for this connector */ + fb_helper_conn = fb_helper->connector_info[i]; +if (fb_helper_conn->cmdline_mode.specified) { +if (fb_helper_conn->cmdline_mode.bpp_specified) { + bpp = fb_helper_conn->cmdline_mode.bpp; + } + } + } + }
Is such a function not used somewhere else already? Like get user_parameters or so?
drivers/gpu/drm/mgag200/mgag200_mode.c static int mga_vga_mode_valid(struct drm_connector *connector, · line 1440
Quoted 4 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +4
-0+ +if ((mode->hdisplay * mode->vdisplay * (bpp/8 )) > mdev->mc.vram_size) { +if (fb_helper_conn) + fb_helper_conn->cmdline_mode.specified = false;
A debug message specifying that this is due to VRAM size would be helpful I guess.
drivers/gpu/drm/mgag200/mgag200_mode.c static int mga_vga_mode_valid(struct drm_connector *connector, · line 1441
Quoted 1 line
drivers/gpu/drm/mgag200/mgag200_mode.c +1
-0+return MODE_BAD ;
I guess that will print the requested mode so it does not need to be specified above.
drivers/gpu/drm/mgag200/mgag200_mode.c static int mga_vga_mode_valid(struct drm_connector *connector, · line 1446
Quoted 5 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +2
-0+ } +return MODE_OK ; }
Thanks,
Paul
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH] drm/mgag200: Reject modes that are too big for VRAM
In reply to Christopher HarveyQuoted 5 lines · Christopher Harvey
A monitor or a user could request a resolution greater than the available VRAM for the backing framebuffer. This change checks the required framebuffer size against the max VRAM size and rejects modes if they are too big. This change can also remove a mode request passed in via the video= parameter.
I can't say I like the bpp finding code, but my brain is failing to come up with something better,
so yeah I think this is fine, those cards with 1.5MB VRAM always piss me off :-)
I'll apply these, send on any others!
Dave.
PATCH 1/1 drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth
In reply to Christopher Harvey--- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/mgag200/mgag200_fb.c +0 -3
@@ -104,12 +104,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) {struct drm_device *dev = afbdev->helper.dev; -u32 bpp, depth;u32 size;struct drm_gem_object *gobj; -int ret =0 ; -drm_fb_get_bpp_depth (mode_cmd->pixel_format, &depth, &bpp); size = mode_cmd->pitches[0 ] * mode_cmd->height; ret =mgag200_gem_create (dev, size, true, &gobj);
Signature · 1 line
1.7.12.4
Re: [PATCH] drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth
Dear Christopher,
thank you for your patches. Not sure if you should CC some maintainer (or if you did already).
Am Dienstag, den 26.02.2013, 10:53 -0500 schrieb Christopher Harvey:
1. I guess you can remove Cleanup from the commit summary.
2. Why is it »pointless«? I guess a compiler warning that bpp is unused? Please paste it into the commit message then. As otherwise this cannot be judged from just looking at the diff below.
Quoted 12 lines
Signed-off-by Christopher Harvey <[email protected]>--- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-)drivers/gpu/drm/mgag200/mgag200_fb.c +0
-0@@ -104,12 +104,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) {
drivers/gpu/drm/mgag200/mgag200_fb.c static int mgag200fb_create_object(struct mga_fbdev *afbdev, · line 112
Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_fb.c +0
-3struct drm_device *dev = afbdev->helper.dev; -u32 bpp, depth;u32 size;struct drm_gem_object *gobj; -int ret =0 ; -drm_fb_get_bpp_depth (mode_cmd->pixel_format, &depth, &bpp); size = mode_cmd->pitches[0 ] * mode_cmd->height; ret =mgag200_gem_create (dev, size, true, &gobj);
Thanks,
Paul
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/mgag200: Cleanup: Remove extra variable assigns
In reply to Christopher HarveyThese two variables are set again immediately in 'mgag200_modeset_init'
--- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/mgag200/mgag200_main.c +0 -2
@@ -240,8 +240,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)drm_mode_config_init (dev); dev->mode_config.funcs = (void *)&mga_mode_funcs; - dev->mode_config.min_width =0 ; - dev->mode_config.min_height =0 ; dev->mode_config.preferred_depth =24 ; dev->mode_config.prefer_shadow =1 ;
Signature · 1 line
1.7.12.4
Re: [PATCH] drm/mgag200: Cleanup: Remove extra variable assigns
Am Dienstag, den 26.02.2013, 10:55 -0500 schrieb Christopher Harvey:
*assignments
Quoted 1 line
These two variables are set again immediately in '
mgag200_modeset_init'
The compiler would optimize this anyway I guess. Though now it can warn us, if the code should ever change and these variable are not set anymore in all cases.
Quoted 10 lines
Signed-off-by Christopher Harvey <[email protected]>--- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/mgag200/mgag200_main.c +0
-0
drivers/gpu/drm/mgag200/mgag200_main.c int mgag200_driver_load(struct drm_device *dev, unsigned long flags) · line 244
Quoted 7 lines
drivers/gpu/drm/mgag200/mgag200_main.c +0
-2@@ -240,8 +240,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)drm_mode_config_init (dev); dev->mode_config.funcs = (void *)&mga_mode_funcs; - dev->mode_config.min_width =0 ; - dev->mode_config.min_height =0 ; dev->mode_config.preferred_depth =24 ; dev->mode_config.prefer_shadow =1 ;
Thanks,
Paul
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used
In reply to Christopher Harvey--- drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -1
@@ -112,7 +112,6 @@ struct mga_framebuffer {struct mga_fbdev {struct drm_fb_helper helper;struct mga_framebuffer mfb; -struct list_head fbdev_list;void *sysram;int size;struct ttm_bo_kmap_obj mapping;
Signature · 1 line
1.7.12.4
PATCH 1/1 drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions
In reply to Christopher Harvey--- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +3 -4
@@ -1261,9 +1261,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { };/* CRTC setup */ -static void mga_crtc_init (struct drm_device *dev) +static void mga_crtc_init (struct mga_device *mdev) { -struct mga_device *mdev = dev->dev_private;struct mga_crtc *mga_crtc;int i;
@@ -1274,7 +1273,7 @@ static void mga_crtc_init(struct drm_device *dev)if (mga_crtc ==NULL )return ; -drm_crtc_init (dev, &mga_crtc->base, &mga_crtc_funcs); +drm_crtc_init (mdev->dev, &mga_crtc->base, &mga_crtc_funcs);drm_mode_crtc_set_gamma_size (&mga_crtc->base,MGAG200_LUT_SIZE ); mdev->mode_info.crtc = mga_crtc;
@@ -1502,7 +1501,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev->dev->mode_config.fb_base = mdev->mc.vram_base; -mga_crtc_init (mdev->dev); +mga_crtc_init (mdev); encoder =mga_encoder_init (mdev->dev);if (!encoder) {
Signature · 1 line
1.7.12.4
Re: [PATCH] drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions
Am Dienstag, den 26.02.2013, 10:54 -0500 schrieb Christopher Harvey:
Quoted 4 lines
Signed-off-by Christopher Harvey <[email protected]>--- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
[…]
Thanks,
Paul
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 30 lines · Christopher Harvey
Patches 1 to 4 are just cleanup. Maybe these should should be rolled into one patch?
Patch 5 is a bit more complicated.
On cards with very little video memory, (e.g 8MB) higher resolutions at 32bit framebuffer depths will get corrupted because the required memory is larger than what the framebuffer has. DRM has "max_height" and "max_width" but no "max_bytes" for limiting resolutions, so the patch is a little hacky. The first for loop tries to associate a connector with the mode being tested. From the connector I can get the bpp if the user specified one on the video= commandline. After that I do 2 things:
1) Invalidate the requested mode from the video= parameter
2) ReturnMODE_BADif the framebuffer would be too large
I feel this patch plays with structures it shouldn't have to touch to get the bpp. An alternative fix would be to include a "max_bytes" in the DRM core and then do these checks there.I'm also wondering, did I miss the 3.9.0 merge window?
Thanks,
Christopher Harvey (5):
drm/mgag200: Cleanup: Remove pointless call todrm_fb_get_bpp_depthdrm/mgag200: Cleanup: 'fbdev_list' in 'structmga_fbdev' is not used drm/mgag200: Cleanup: Pass driver specificmga_devicein driver
functions
drm/mgag200: Cleanup: Remove extra variable assigns drm/mgag200: Reject modes that are too big for VRAM
Quoted 9 lines
drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 30 insertions(+), 10 deletions(-)Signature · 1 line
1.7.12.4
Ping.
I've got more patches queuing up. Should I re-submit these along with the new ones?
So far I've only gotten commit message feedback.
-Chris
Dave Airlie
maintainerQuoted 41 lines · Christopher Harvey
Quoted 30 lines · Christopher Harvey
Patches 1 to 4 are just cleanup. Maybe these should should be rolled into one patch?
Patch 5 is a bit more complicated.
On cards with very little video memory, (e.g 8MB) higher resolutions at 32bit framebuffer depths will get corrupted because the required memory is larger than what the framebuffer has. DRM has "max_height" and "max_width" but no "max_bytes" for limiting resolutions, so the patch is a little hacky. The first for loop tries to associate a connector with the mode being tested. From the connector I can get the bpp if the user specified one on the video= commandline. After that I do 2 things:
1) Invalidate the requested mode from the video= parameter
2) ReturnMODE_BADif the framebuffer would be too large
I feel this patch plays with structures it shouldn't have to touch to get the bpp. An alternative fix would be to include a "max_bytes" in the DRM core and then do these checks there.I'm also wondering, did I miss the 3.9.0 merge window?
Thanks,
Christopher Harvey (5):
drm/mgag200: Cleanup: Remove pointless call todrm_fb_get_bpp_depthdrm/mgag200: Cleanup: 'fbdev_list' in 'structmga_fbdev' is not used drm/mgag200: Cleanup: Pass driver specificmga_devicein driver
functions
drm/mgag200: Cleanup: Remove extra variable assigns drm/mgag200: Reject modes that are too big for VRAMQuoted 9 lines
drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 30 insertions(+), 10 deletions(-)--
1.7.12.4
Quoted 7 lines
Ping.
I've got more patches queuing up. Should I re-submit these along with the new ones?
So far I've only gotten commit message feedback.
Sorry been off sick, and this fell off my radar, I'll get to it today, the first 4 seem fine,
I'll check the last one today., they all look like fixes so I can probably merge them at any time.
Thanks,
Dave.