NetBSD Problem Report #54167

From tsutsui@ceres.dti.ne.jp  Mon May  6 07:42:38 2019
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E30F37A186
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  6 May 2019 07:42:38 +0000 (UTC)
Message-Id: <201905060742.x467gYQP007669@ceres.dti.ne.jp>
Date: Mon, 6 May 2019 16:42:34 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Xorg wsfb server "Rotate" does not work on NetBSD 8.0
X-Send-Pr-Version: 3.95

>Number:         54167
>Category:       xsrc
>Synopsis:       Xorg wsfb server "Rotate" does not work on NetBSD 8.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 06 07:45:00 +0000 2019
>Closed-Date:    Sun Dec 29 11:17:19 +0000 2019
>Last-Modified:  Sun Dec 29 11:17:19 +0000 2019
>Originator:     Izumi Tsutsui
>Release:        NetBSD 8.0
>Organization:
>Environment:
System: NetBSD wzero3 8.0 NetBSD 8.0 (WZERO3) #0: Tue Jul 17 14:59:51 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/hpcarm/compile/WZERO3 hpcarm
Architecture: earmv4
Machine: hpcarm
>Description:
It looks Xorg wsfb server in NetBSD 8.0 does not draw windows correctly.
src/external/mit/xorg/etc/etc.hpcarm/xorg.conf.ws003sh has
the following lines:
---
Section "Device"
        Identifier      "Wsdisplay0"
        Driver          "wsfb"

        Option          "Rotate"        "CCW"
EndSection
---
and it worked on NetBSD/hpcarm 6.1.5.

However on NetBSD/hpcarm 8.0 Xorg draws windows as the following:
 https://gist.githubusercontent.com/tsutsui/13ac0181ec87d4685a384e9f6d885040/raw/03c850680a41081f7bdae194cc62ac571d4dce14/NetBSD-hpcarm-Xorg-server-Rotate-CCW.png

It looks stride width is not handled correctly.

Note without the "Rotate" option it works as expected:
 https://gist.githubusercontent.com/tsutsui/13ac0181ec87d4685a384e9f6d885040/raw/03c850680a41081f7bdae194cc62ac571d4dce14/NetBSD-hpcarm-Xorg-server-Rotate-normal.png

and wsfb driver with "Rotate" CCW on NetBSD/i386 8.0
with "vesa 1024x768x16" settings on bootloader
seems also work as expected:
 https://gist.githubusercontent.com/tsutsui/13ac0181ec87d4685a384e9f6d885040/raw/d6f0b9d99b3f5e7bad1594bca2edfdbefb0a44a4/NetBSD-i386-8.0-QEMU-vesa_1024x768x16_wsfb-CCW.png

>How-To-Repeat:
Install NetBSD/hpcarm 8.0 and start Xorg server with
src/external/mit/xorg/etc/etc.hpcarm/xorg.conf.ws003sh etc.

>Fix:
No idea.
Check xorg server API changes since netbsd-6?

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: xsrc/54167: Xorg wsfb server "Rotate" does not work on NetBSD 8.0
Date: Mon, 6 May 2019 18:44:56 +0900

 One more info:
 Xorg server binaries from NetBSD/hpcarm 7.2 on NetBSD/hpcarm 8.0
 environments (including kernel and userland binaries) work properly.
  https://gist.githubusercontent.com/tsutsui/13ac0181ec87d4685a384e9f6d885040/raw/fc56d28c141f3fed7d9ed216be717639b49c6f1d/NetBSD-hpcarm-7.2-Xorg-server-Rotate-CCW-1.png

 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: macallan@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: xsrc/54167: Xorg wsfb server "Rotate" does not work on NetBSD 8.0
Date: Wed, 18 Dec 2019 01:33:48 +0900

 >Synopsis:       Xorg wsfb server "Rotate" does not work on NetBSD 8.0

 I've confirmed xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c
 rev 1.29 causes this problem in rotate cases:
  http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c#rev1.29

 >> support WSFB_VRAM_IS_SPLIT workaround for wildcat boards - use a shadow fb
 >> and copy dirty areas into both framebuffers
 >> now we can use X on Sun XVR-1200
 >> should work on XVR-500 and others as well

 ---
 @@ -957,8 +972,7 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  #endif

  	if (fPtr->shadowFB) {
 -		fPtr->shadow = calloc(1, pScrn->virtualX * pScrn->virtualY *
 -		    pScrn->bitsPerPixel/8);
 +		fPtr->shadow = calloc(1, fPtr->fbi.fbi_stride * pScrn->virtualY);

  		if (!fPtr->shadow) {
  			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 @@ -984,7 +998,9 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  		    fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart,
  		    pScrn->virtualX, pScrn->virtualY,
  		    pScrn->xDpi, pScrn->yDpi,
 -		    pScrn->displayWidth, pScrn->bitsPerPixel);
 +		    /* apparently fb wants stride in pixels, not bytes */
 +		    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3),
 +		    pScrn->bitsPerPixel);
  		break;
  	default:
  		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 ---

 The following patch (use pScrn->virtualX instead of hardware fbi_stride
 in "rotate" cases) fixes CW case on Zaurus SL-C1000 and SL-C3000.

 Michael, could you confirm?

 Index: external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c
 ===================================================================
 RCS file: /cvsroot/xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c,v
 retrieving revision 1.35
 diff -u -p -d -r1.35 wsfb_driver.c
 --- external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c	23 Jul 2019 12:01:53 -0000	1.35
 +++ external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c	17 Dec 2019 16:10:40 -0000
 @@ -875,6 +875,7 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  	int ret, flags, ncolors;
  	int wsmode = WSDISPLAYIO_MODE_DUMBFB;
  	int wstype;
 +	int width;
  	size_t len;

  	TRACE_ENTER("WsfbScreenInit");
 @@ -979,7 +980,17 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  	fPtr->fbstart = fPtr->fbmem + fPtr->fbi.fbi_fboffset;

  	if (fPtr->shadowFB) {
 -		fPtr->shadow = calloc(1, fPtr->fbi.fbi_stride * pScrn->virtualY);
 +		if (fPtr->rotate) {
 +			len = pScrn->virtualX * pScrn->virtualY;
 +			if (pScrn->bitsPerPixel > 8) {
 +				len *= (pScrn->bitsPerPixel >> 3);
 +			} else {
 +				len /= (8 / pScrn->bitsPerPixel);
 +			}
 +		} else {
 +			len = fPtr->fbi.fbi_stride * pScrn->virtualY;
 +		}
 +		fPtr->shadow = calloc(1, len);

  		if (!fPtr->shadow) {
  			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 @@ -988,13 +999,24 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  		}
  	}

 +	if (fPtr->rotate) {
 +		width = pScrn->displayWidth;
 +	} else {
 +		if (pScrn->bitsPerPixel > 8) {
 +			width =
 +			    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3);
 +		} else {
 +			width =
 +			    fPtr->fbi.fbi_stride * (8 / pScrn->bitsPerPixel);
 +		}
 +	}
  	switch (pScrn->bitsPerPixel) {
  	case 1:
  		ret = fbScreenInit(pScreen,
  		    fPtr->fbstart,
  		    pScrn->virtualX, pScrn->virtualY,
  		    pScrn->xDpi, pScrn->yDpi,
 -		    fPtr->fbi.fbi_stride * 8, pScrn->bitsPerPixel);
 +		    width, pScrn->bitsPerPixel);
  		break;
  	case 4:
  	case 8:
 @@ -1005,8 +1027,7 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  		    fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart,
  		    pScrn->virtualX, pScrn->virtualY,
  		    pScrn->xDpi, pScrn->yDpi,
 -		    /* apparently fb wants stride in pixels, not bytes */
 -		    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3),
 +		    width,
  		    pScrn->bitsPerPixel);
  		break;
  	default:
 ---

 Thanks,
 ---
 Izumi Tsutsui

From: Michael <macallan@netbsd.org>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: xsrc/54167: Xorg wsfb server "Rotate" does not work on NetBSD
 8.0
Date: Tue, 17 Dec 2019 12:06:00 -0500

 Hello,

 On Wed, 18 Dec 2019 01:33:48 +0900
 Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> wrote:

 > >Synopsis:       Xorg wsfb server "Rotate" does not work on NetBSD 8.0  
 > 
 > I've confirmed xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c
 > rev 1.29 causes this problem in rotate cases:
 >  http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c#rev1.29
 > 
 > >> support WSFB_VRAM_IS_SPLIT workaround for wildcat boards - use a shadow fb
 > >> and copy dirty areas into both framebuffers
 > >> now we can use X on Sun XVR-1200
 > >> should work on XVR-500 and others as well  
 > 
 > ---
 > @@ -957,8 +972,7 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
 >  #endif
 >  
 >  	if (fPtr->shadowFB) {
 > -		fPtr->shadow = calloc(1, pScrn->virtualX * pScrn->virtualY *
 > -		    pScrn->bitsPerPixel/8);
 > +		fPtr->shadow = calloc(1, fPtr->fbi.fbi_stride * pScrn->virtualY);
 >  
 >  		if (!fPtr->shadow) {
 >  			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 > @@ -984,7 +998,9 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
 >  		    fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart,
 >  		    pScrn->virtualX, pScrn->virtualY,
 >  		    pScrn->xDpi, pScrn->yDpi,
 > -		    pScrn->displayWidth, pScrn->bitsPerPixel);
 > +		    /* apparently fb wants stride in pixels, not bytes */
 > +		    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3),
 > +		    pScrn->bitsPerPixel);
 >  		break;
 >  	default:
 >  		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 > ---
 > 
 > The following patch (use pScrn->virtualX instead of hardware fbi_stride
 > in "rotate" cases) fixes CW case on Zaurus SL-C1000 and SL-C3000.
 > 
 > Michael, could you confirm?

 I'll dig up the wildcat and test. If I can't get to it please go ahead
 and commit, I think your use case is far more common than mine.

 > -		    /* apparently fb wants stride in pixels, not bytes */

 There has to be a reason why I left that comment in there, I'll investigate.

 thanks
 Michael

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: macallan@netbsd.org
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: xsrc/54167: Xorg wsfb server "Rotate" does not work on NetBSD8.0
Date: Sun, 22 Dec 2019 09:46:45 +0900

 Hi,

 > > The following patch (use pScrn->virtualX instead of hardware fbi_stride
 > > in "rotate" cases) fixes CW case on Zaurus SL-C1000 and SL-C3000.
 > > 
 > > Michael, could you confirm?
 > 
 > I'll dig up the wildcat and test. If I can't get to it please go ahead
 > and commit, I think your use case is far more common than mine.

 Thanks for your comment.

 I noticed "Rotate" and "ShadowFB" are valid only on depth >= 8,
 so I updated my patch to remove unnecessary cases.

 > > -		    /* apparently fb wants stride in pixels, not bytes */
 > 
 > There has to be a reason why I left that comment in there, I'll investigate.

 According to fbScreenInit() function in fbscreen.c,
 it seems to require "stride in pixel":
  https://cgit.freedesktop.org/xorg/xserver/tree/fb/fbscreen.c?h=xorg-server-1.10.6#n100
  https://cgit.freedesktop.org/xorg/xserver/tree/fb/fbscreen.c?h=xorg-server-1.10.6#n175

 I agree the "stride in pixels" is really weird, because
 stride is typically used to calculate VRAM size or address offsets
 (i.e. in bytes).  I also put a comment back for it.

 I'll commit the attached patch soon.

 ---
 Index: wsfb_driver.c
 ===================================================================
 RCS file: /cvsroot/xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c,v
 retrieving revision 1.35
 diff -u -p -d -r1.35 wsfb_driver.c
 --- wsfb_driver.c	23 Jul 2019 12:01:53 -0000	1.35
 +++ wsfb_driver.c	22 Dec 2019 00:34:28 -0000
 @@ -875,6 +875,7 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  	int ret, flags, ncolors;
  	int wsmode = WSDISPLAYIO_MODE_DUMBFB;
  	int wstype;
 +	int width;
  	size_t len;

  	TRACE_ENTER("WsfbScreenInit");
 @@ -979,7 +980,17 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  	fPtr->fbstart = fPtr->fbmem + fPtr->fbi.fbi_fboffset;

  	if (fPtr->shadowFB) {
 -		fPtr->shadow = calloc(1, fPtr->fbi.fbi_stride * pScrn->virtualY);
 +		if (fPtr->rotate) {
 +			/*
 +			 * Note Rotate and Shadow FB options are valid
 +			 * only on depth >= 8.
 +			 */
 +			len = pScrn->virtualX * pScrn->virtualY *
 +			    (pScrn->bitsPerPixel >> 3);
 +		} else {
 +			len = fPtr->fbi.fbi_stride * pScrn->virtualY;
 +		}
 +		fPtr->shadow = calloc(1, len);

  		if (!fPtr->shadow) {
  			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 @@ -988,13 +999,29 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  		}
  	}

 +	/*
 +	 * fbScreenInit() seems to require "pixel width of frame buffer"
 +	 * but it is actually "stride in pixel" of frame buffer,
 +	 * per xorg/xserver/tree/fb/fbscreen.c.
 +	 */
 +	if (fPtr->rotate) {
 +		width = pScrn->displayWidth;
 +	} else {
 +		if (pScrn->bitsPerPixel > 8) {
 +			width =
 +			    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3);
 +		} else {
 +			width =
 +			    fPtr->fbi.fbi_stride * (8 / pScrn->bitsPerPixel);
 +		}
 +	}
  	switch (pScrn->bitsPerPixel) {
  	case 1:
  		ret = fbScreenInit(pScreen,
  		    fPtr->fbstart,
  		    pScrn->virtualX, pScrn->virtualY,
  		    pScrn->xDpi, pScrn->yDpi,
 -		    fPtr->fbi.fbi_stride * 8, pScrn->bitsPerPixel);
 +		    width, pScrn->bitsPerPixel);
  		break;
  	case 4:
  	case 8:
 @@ -1005,8 +1032,7 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
  		    fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart,
  		    pScrn->virtualX, pScrn->virtualY,
  		    pScrn->xDpi, pScrn->yDpi,
 -		    /* apparently fb wants stride in pixels, not bytes */
 -		    fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3),
 +		    width,
  		    pScrn->bitsPerPixel);
  		break;
  	default:

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54167 CVS commit: xsrc/external/mit/xf86-video-wsfb/dist/src
Date: Wed, 25 Dec 2019 14:36:34 +0000

 Module Name:	xsrc
 Committed By:	tsutsui
 Date:		Wed Dec 25 14:36:34 UTC 2019

 Modified Files:
 	xsrc/external/mit/xf86-video-wsfb/dist/src: wsfb_driver.c

 Log Message:
 Fix Xorg wsfb server "Rotate" corruption problem.  PR xsrc/54167

 Confirmed on zaurus SL-C1000, SL-C3000 (CW) and hpcarm WS003SH (CCW).
 Should be pulled up to netbsd-8 and netbsd-9.


 To generate a diff of this commit:
 cvs rdiff -u -r1.35 -r1.36 \
     xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: xsrc-manager->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Wed, 25 Dec 2019 15:07:46 +0000
Responsible-Changed-Why:
I've committed fix.


State-Changed-From-To: open->needs-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Wed, 25 Dec 2019 15:07:46 +0000
State-Changed-Why:
I'll send pullup requests later.


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Fri, 27 Dec 2019 16:38:46 +0000
State-Changed-Why:
[pullup-9 #585] [pullup-8 #1479]


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54167 CVS commit: [netbsd-8] xsrc/external/mit/xf86-video-wsfb/dist/src
Date: Sun, 29 Dec 2019 09:20:15 +0000

 Module Name:	xsrc
 Committed By:	martin
 Date:		Sun Dec 29 09:20:15 UTC 2019

 Modified Files:
 	xsrc/external/mit/xf86-video-wsfb/dist/src [netbsd-8]: wsfb_driver.c

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1479):

 	external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c: revision 1.36

 Fix Xorg wsfb server "Rotate" corruption problem.  PR xsrc/54167
 Confirmed on zaurus SL-C1000, SL-C3000 (CW) and hpcarm WS003SH (CCW).
 Should be pulled up to netbsd-8 and netbsd-9.


 To generate a diff of this commit:
 cvs rdiff -u -r1.29 -r1.29.2.1 \
     xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54167 CVS commit: [netbsd-9] xsrc/external/mit/xf86-video-wsfb/dist/src
Date: Sun, 29 Dec 2019 09:23:04 +0000

 Module Name:	xsrc
 Committed By:	martin
 Date:		Sun Dec 29 09:23:04 UTC 2019

 Modified Files:
 	xsrc/external/mit/xf86-video-wsfb/dist/src [netbsd-9]: wsfb_driver.c

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #585):

 	external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c: revision 1.36

 Fix Xorg wsfb server "Rotate" corruption problem.  PR xsrc/54167
 Confirmed on zaurus SL-C1000, SL-C3000 (CW) and hpcarm WS003SH (CCW).
 Should be pulled up to netbsd-8 and netbsd-9.


 To generate a diff of this commit:
 cvs rdiff -u -r1.35 -r1.35.2.1 \
     xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 29 Dec 2019 11:17:19 +0000
State-Changed-Why:
Pullups complete.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.45 2018/12/21 14:23:33 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.