diff mbox

[3/3] UBUNTU: [Upstream] drm/nouveau: Fix fbcon corruption with font width not divisible by 8

Message ID 1269555956-3532-3-git-send-email-raof@ubuntu.com
State Accepted
Delegated to: Andy Whitcroft
Headers show

Commit Message

Christopher James Halse Rogers March 25, 2010, 10:25 p.m. UTC
From: Christopher James Halse Rogers <raof@ubuntu.com>

NV50 is nice and has a switch that autoaligns stuff for us. Pre-NV50, we need to align input bitmap width manually.

BugLink: http://bugs.launchpad.net/bugs/544739
OriginalLocation: http://cgit.freedesktop.org/nouveau/linux-2.6/commit/?id=8af16649e7290eb361e9cf6724d050150e16a993

Signed-off-by: Marcin Kościelnicki <koriakin@0x04.net>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com>
---
 drivers/gpu/drm/nouveau/nv04_fbcon.c |    6 +++---
 drivers/gpu/drm/nouveau/nv50_fbcon.c |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Stefan Bader March 29, 2010, 1:12 p.m. UTC | #1
Actually I was probably mislead by upstream. These patches are not in Linus tree
as far as I can see. So they should get sent there as soon as possible (with CC:
stable@kernel.org in the s-o-b area).
For this one, changing to the ALIGN macro seems simple enough. Moving the later
code and changing the arguments, we have to take your word about it being tested.

Chris Halse Rogers wrote:
> From: Christopher James Halse Rogers <raof@ubuntu.com>
> 
> NV50 is nice and has a switch that autoaligns stuff for us. Pre-NV50, we need to align input bitmap width manually.
> 
> BugLink: http://bugs.launchpad.net/bugs/544739
> OriginalLocation: http://cgit.freedesktop.org/nouveau/linux-2.6/commit/?id=8af16649e7290eb361e9cf6724d050150e16a993
> 
> Signed-off-by: Marcin Ko�cielnicki <koriakin@0x04.net>
> Signed-off-by: Francisco Jerez <currojerez@riseup.net>
> Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/gpu/drm/nouveau/nv04_fbcon.c |    6 +++---
>  drivers/gpu/drm/nouveau/nv50_fbcon.c |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c
> index fd01caa..813b25c 100644
> --- a/drivers/gpu/drm/nouveau/nv04_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c
> @@ -118,8 +118,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
>  		return;
>  	}
>  
> -	width = (image->width + 31) & ~31;
> -	dsize = (width * image->height) >> 5;
> +	width = ALIGN(image->width, 8);
> +	dsize = ALIGN(width * image->height, 32) >> 5;
>  
>  	if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
>  	    info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
> @@ -136,8 +136,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
>  			 ((image->dx + image->width) & 0xffff));
>  	OUT_RING(chan, bg);
>  	OUT_RING(chan, fg);
> -	OUT_RING(chan, (image->height << 16) | image->width);
>  	OUT_RING(chan, (image->height << 16) | width);
> +	OUT_RING(chan, (image->height << 16) | image->width);
>  	OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
>  
>  	while (dsize) {
> diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c
> index 0f57cdf..195c866 100644
> --- a/drivers/gpu/drm/nouveau/nv50_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c
> @@ -233,7 +233,7 @@ nv50_fbcon_accel_init(struct fb_info *info)
>  	BEGIN_RING(chan, NvSub2D, 0x0808, 3);
>  	OUT_RING(chan, 0);
>  	OUT_RING(chan, 0);
> -	OUT_RING(chan, 0);
> +	OUT_RING(chan, 1);
>  	BEGIN_RING(chan, NvSub2D, 0x081c, 1);
>  	OUT_RING(chan, 1);
>  	BEGIN_RING(chan, NvSub2D, 0x0840, 4);
>
Andy Whitcroft March 30, 2010, 1:21 p.m. UTC | #2
On Fri, Mar 26, 2010 at 09:25:56AM +1100, Chris Halse Rogers wrote:
> From: Christopher James Halse Rogers <raof@ubuntu.com>
> 
> NV50 is nice and has a switch that autoaligns stuff for us. Pre-NV50, we need to align input bitmap width manually.
> 
> BugLink: http://bugs.launchpad.net/bugs/544739
> OriginalLocation: http://cgit.freedesktop.org/nouveau/linux-2.6/commit/?id=8af16649e7290eb361e9cf6724d050150e16a993
> 
> Signed-off-by: Marcin Kościelnicki <koriakin@0x04.net>
> Signed-off-by: Francisco Jerez <currojerez@riseup.net>
> Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com>
> ---
>  drivers/gpu/drm/nouveau/nv04_fbcon.c |    6 +++---
>  drivers/gpu/drm/nouveau/nv50_fbcon.c |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c
> index fd01caa..813b25c 100644
> --- a/drivers/gpu/drm/nouveau/nv04_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c
> @@ -118,8 +118,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
>  		return;
>  	}
>  
> -	width = (image->width + 31) & ~31;
> -	dsize = (width * image->height) >> 5;
> +	width = ALIGN(image->width, 8);
> +	dsize = ALIGN(width * image->height, 32) >> 5;
>  
>  	if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
>  	    info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
> @@ -136,8 +136,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
>  			 ((image->dx + image->width) & 0xffff));
>  	OUT_RING(chan, bg);
>  	OUT_RING(chan, fg);
> -	OUT_RING(chan, (image->height << 16) | image->width);
>  	OUT_RING(chan, (image->height << 16) | width);
> +	OUT_RING(chan, (image->height << 16) | image->width);
>  	OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
>  
>  	while (dsize) {
> diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c
> index 0f57cdf..195c866 100644
> --- a/drivers/gpu/drm/nouveau/nv50_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c
> @@ -233,7 +233,7 @@ nv50_fbcon_accel_init(struct fb_info *info)
>  	BEGIN_RING(chan, NvSub2D, 0x0808, 3);
>  	OUT_RING(chan, 0);
>  	OUT_RING(chan, 0);
> -	OUT_RING(chan, 0);
> +	OUT_RING(chan, 1);

I do wish upstream would _comment_ things like this.  Clearly this is
the 'align stuff for me' bit, yet they don't ... sigh.

>  	BEGIN_RING(chan, NvSub2D, 0x081c, 1);
>  	OUT_RING(chan, 1);
>  	BEGIN_RING(chan, NvSub2D, 0x0840, 4);

Other than the slightly inobvious second chunk here it looks fine.  I am
inclined to assume its right as it has a visible effect.

Acked-by: Andy Whitcroft <apw@canonical.com>

-apw
diff mbox

Patch

diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c
index fd01caa..813b25c 100644
--- a/drivers/gpu/drm/nouveau/nv04_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c
@@ -118,8 +118,8 @@  nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
 		return;
 	}
 
-	width = (image->width + 31) & ~31;
-	dsize = (width * image->height) >> 5;
+	width = ALIGN(image->width, 8);
+	dsize = ALIGN(width * image->height, 32) >> 5;
 
 	if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
 	    info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
@@ -136,8 +136,8 @@  nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
 			 ((image->dx + image->width) & 0xffff));
 	OUT_RING(chan, bg);
 	OUT_RING(chan, fg);
-	OUT_RING(chan, (image->height << 16) | image->width);
 	OUT_RING(chan, (image->height << 16) | width);
+	OUT_RING(chan, (image->height << 16) | image->width);
 	OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
 
 	while (dsize) {
diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c
index 0f57cdf..195c866 100644
--- a/drivers/gpu/drm/nouveau/nv50_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c
@@ -233,7 +233,7 @@  nv50_fbcon_accel_init(struct fb_info *info)
 	BEGIN_RING(chan, NvSub2D, 0x0808, 3);
 	OUT_RING(chan, 0);
 	OUT_RING(chan, 0);
-	OUT_RING(chan, 0);
+	OUT_RING(chan, 1);
 	BEGIN_RING(chan, NvSub2D, 0x081c, 1);
 	OUT_RING(chan, 1);
 	BEGIN_RING(chan, NvSub2D, 0x0840, 4);