Author Topic: Console Response After Running X  (Read 13804 times)

wilkes

  • Newbie
  • *
  • Posts: 9
    • View Profile
Console Response After Running X
« on: June 13, 2006, 10:11:57 am »
I'm running a 03-Jun-06 snap, but I noticed this behavior on the 3.9 release as well.

When I run startx (or startxfec4) from the console and subsequently quit X and return to the console, response sucks; noticeable lag echoing typed characters, etc.  It's bad enough that I have to reboot to get a normal acting console again.

Anyone else seeing this?  Is there a cure?  (Other than always rebooting after X, that is...)

-jw-
wilkes
--
Cosmo Commuicator w/ cracked screen :(
Astro Slide

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #1 on: June 13, 2006, 10:43:12 am »
Yes, it's well known. I don't know if anybody is tackling it.

I always use vt02 after running an X session since the second vt is unaffected. Ctrl-Alt-F2 for vt02, Ctrl-Alt-F1 to switch back to vt01.

Remember to switch back to vt01 before running X though.


p.s. you can switch to vt02 whilst running X on vt01 if you just want a text console quickly

-Andy
« Last Edit: June 13, 2006, 10:45:23 am by iamasmith »
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

TronDD

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Console Response After Running X
« Reply #2 on: June 13, 2006, 10:08:01 pm »
Cool!  I didn't know virtual terminal switching worked.  I didn't realize the program keys were just F keys until recently so I never even thought terminal switching was possible.

And yeah, using the terminal after X sucks.

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #3 on: June 14, 2006, 04:40:48 am »
zkbd(4) man page is well worth a read if you haven't already

-Andy
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

mathemajikian

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
    • http://exit3.i-55.com/~xikon/openbsdzaurus.html
Console Response After Running X
« Reply #4 on: July 30, 2006, 08:44:10 am »
This is still an issue. What could be the cause of this? Is X not flushing the framebuffer correctly when exiting?

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #5 on: July 31, 2006, 11:38:39 am »
It's not X specifically, the problem also occurs when using ztsscale.

I would like to get to the bottom of this and may have some time to devote to finding the culprit soon.

-Andy
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

mathemajikian

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
    • http://exit3.i-55.com/~xikon/openbsdzaurus.html
Console Response After Running X
« Reply #6 on: July 31, 2006, 03:34:43 pm »
I have noticed that if I just let the Z sit for about 5 minutes the console response returns to normal.



Quote
It's not X specifically, the problem also occurs when using ztsscale.

I would like to get to the bottom of this and may have some time to devote to finding the culprit soon.

-Andy
[div align=\"right\"][a href=\"index.php?act=findpost&pid=137067\"][{POST_SNAPBACK}][/a][/div]
« Last Edit: August 31, 2006, 05:32:49 pm by mathemajikian »

coreilly

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Console Response After Running X
« Reply #7 on: July 31, 2006, 08:04:11 pm »
Just tried it on my c3200, running last 3.9 snapshot before 4.0 was released... left it for 5-10 minutes.. still choppy.. a bit better. will leave it for longer and see.

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #8 on: August 02, 2006, 06:03:41 am »
mmmm, think I have found it. Thankfully it isn't a kernel problem... going to rebuild X and some stuff to test it out before I start pointing fingers though.
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #9 on: August 02, 2006, 06:28:49 am »
ah maybe that isn't the problem... digging a little deeper now.
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #10 on: August 02, 2006, 11:23:29 am »
Actually this does look like a kernel related issue.

The display is actually handled via DMA from certain memory mapped regions (one for eash wsdisplay screen).

It appears that following an access to the bitmap returned by mmap of the frame buffer (used to gain access to the memory map) of /dev/ttyC0 the cache coherency is swictched off. This essentially means that DMA transfer to the screen for this region is subject to cache rather than immediate write through from this point onwards.

Since the bitmap for ttyC1 hasn't been touched in this manner this appears to be why the second VT is unaffected.

Interestingly enough the mmap call handler for the lcd device does actually specify that DMA should be coherent. The coherency seems to be being dropped when the mmap is being freed.

I tested this with the following test program.

Code: [Select]
#include
#include
#include
#include
#include
#include

#include
#include
#include
#include
#include
#include
#include
#include

#include

#define WIDTH   640
#define HEIGHT  480

main()
{
        u_short         *mapaddr;
        u_short         *tptr;
        int fd;
        u_short nTval;
        int nCount1,nCount2,nCount3;
        int mode = WSDISPLAYIO_MODE_DUMBFB;

/* Open the display */
        fd = open("/dev/ttyC0", O_RDWR);
        if (fd < 0)
                err(2, "open /dev/ttyC0");

        if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) == -1)
                warn("ioctl SMODE");
        mapaddr = (void *)mmap(0, WIDTH*HEIGHT*sizeof(short),
            PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0);
        if (mapaddr == (void *)-1)
                err(2, "mmap");

/* Our simple test pattern flash 12 blue stripes 5 times with 2 second gaps */

        nTval=0;
        for (nCount1=0;nCount1<10;nCount1++) {
                nTval^=0x00ff;  /* toggle nTval */
                tptr=mapaddr;
                for (nCount2=0;nCount2<12;nCount2++) {
                        for (nCount3=0;nCount3<480;nCount3++)
                                *(tptr++)=nTval;
                        tptr+=25*2*480; /* Skip 25 raster lines */
                }
                sleep(2);
        }


        mode = WSDISPLAYIO_MODE_EMUL;

        munmap((void*) mapaddr,WIDTH*HEIGHT*sizeof(short));

        if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) == -1)
                warn("ioctl SMODE");
}

The stripes are there to generate some non sequential access so that the DMA controller doesn't simply burst the updates and generate a false test pattern. If the coherency was missing at this stage then we may expect to see some graphical artifacts in the stripes, potentially at the end of the stripes. We don't see this so I surmise that coherency is enabled for the DMA when the frame buffer is in bitmapped mode.

I am now looking at why coherency seems to be disabled when the region is unmapped... incidentally the X server seems to omit the unmap call (and for that matter the call to free the buffer that it uses to preserve the screen contents). This obviously has little bearing upon the issue being observed.

-Andy
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

coreilly

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Console Response After Running X
« Reply #11 on: August 02, 2006, 12:25:01 pm »
I have absolutely no idea what that means but thanks again for all your work Andy!

mathemajikian

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
    • http://exit3.i-55.com/~xikon/openbsdzaurus.html
Console Response After Running X
« Reply #12 on: August 02, 2006, 01:59:45 pm »
Term 2 is also affected. Login as root under Term 1 then as normal user under Term 2. Start X from Term 2 then exit X. Term 2 will then be jacked up. Now go back to Term 1 and just have root build some arbituary port. While this port is building switch back over to Term 2. Term 2 is now functioning correctly but stops functioning correctly once port has stopped building.



 

Quote
I have absolutely no idea what that means but thanks again for all your work Andy!
[div align=\"right\"][a href=\"index.php?act=findpost&pid=137258\"][{POST_SNAPBACK}][/a][/div]
« Last Edit: August 31, 2006, 05:33:03 pm by mathemajikian »

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
Console Response After Running X
« Reply #13 on: August 02, 2006, 02:34:01 pm »
Quote
Term 2 is also affected. Login as root under Term 1 then as normal user under Term 2. Start X from Term 2 then exit X. Term 2 will then be jacked up. Now go back to Term 1 and just have root build some arbituary port. While this port is building switch back over to Term 2. Term 2 is now functioning correctly but stops functioning correctly once port has stopped building.

Quote
I have absolutely no idea what that means but thanks again for all your work Andy!
[div align=\"right\"][a href=\"index.php?act=findpost&pid=137258\"][{POST_SNAPBACK}][/a][/div]
[div align=\"right\"][a href=\"index.php?act=findpost&pid=137268\"][{POST_SNAPBACK}][/a][/div]

Correct, you can make it barf term 2 easily by starting something graphical with term 2 active, this seems to be related to some of the LCD code which returns an mmap for the currently active screen instead of the screen associated with the process. This stuff has been 'inherited' from NetBSD and is probably due an overhaul.

The reason why your build seems to 'fix' the problem is probably because you are constantly filling the dma controller cache so it is forced to write the updates to the screen.

-Andy
« Last Edit: August 02, 2006, 02:34:29 pm by iamasmith »
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

Sequethin

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Console Response After Running X
« Reply #14 on: August 02, 2006, 03:05:59 pm »
Quote
I have absolutely no idea what that means but thanks again for all your work Andy!
[div align=\"right\"][a href=\"index.php?act=findpost&pid=137258\"][{POST_SNAPBACK}][/a][/div]


I second that!