Z-Pocket Game Pro(ZPG Pro)
解析"rockchip_drm_gem_object_mmap panic"問題
問題如下:
[ 6947.864554] Unable to handle kernel paging request at virtual address c0000000220 [ 6947.872077] pgd = ffffffc0380be000 [ 6947.875481] [c0000000220] *pgd=0000000000000000, *pud=0000000000000000 [ 6947.882121] Internal error: Oops: 96000004 [#1] SMP [ 6947.887001] Modules linked in: usb_f_ecm g_ether usb_f_rndis u_ether libcomposite sch_fq_codel ip_tables x_tables ipv6 [last unloaded: libcomposite] [ 6947.900500] CPU: 3 PID: 21911 Comm: sdltest Tainted: G B 4.4.189 #12 [ 6947.907978] Hardware name: MarsBoard (DT) [ 6947.911991] task: ffffffc038338000 task.stack: ffffffc036fd8000 [ 6947.917923] PC is at vm_insert_page+0x40/0x1dc [ 6947.922374] LR is at rockchip_drm_gem_object_mmap+0xf4/0x168 [ 6947.928035] pc : [<ffffff80081a975c>] lr : [<ffffff80085120d8>] pstate: 80000145 [ 6947.935430] sp : ffffffc036fdbbc0 [ 6947.938745] x29: ffffffc036fdbbc0 x28: ffffff800900c000 [ 6947.944097] x27: 0000000000000008 x26: 0000000000000000 [ 6947.949450] x25: 0000000000000000 x24: 0000000000000096 [ 6947.954800] x23: 0000007fb7c55000 x22: 0000000000000000 [ 6947.960152] x21: 0000007fb7c55000 x20: ffffffc038d34f20 [ 6947.965503] x19: 00000c0000000200 x18: 0000000000000000 [ 6947.970853] x17: 0000007fb7fa53f0 x16: ffffff8008087c64 [ 6947.976203] x15: 0000000000000040 x14: 0000000000000006 [ 6947.981554] x13: 0000000000000000 x12: 0000007fb7de3208 [ 6947.986904] x11: 0000000000000010 x10: 0000000000100000 [ 6947.992254] x9 : 0000000000000000 x8 : ffffffc038d34fd0 [ 6947.997608] x7 : 0000000000000000 x6 : 000000000000003f [ 6948.002959] x5 : ffffffc000291120 x4 : 0000000000000096 [ 6948.008311] x3 : 0000000000000000 x2 : 00000c0000000200 [ 6948.013661] x1 : 0000007fb7c55000 x0 : 0000007fb7ceb000 [ 6948.019015] [ 6948.019015] PC: 0xffffff80081a96dc: [ 6948.023977] 96dc a90153f3 f90013f5 aa0003f3 aa1e03e0 aa0103f4 aa0203f5 d503201f f9402663 [ 6948.032313] 96fc aa1503e2 aa1403e1 aa1303e0 97ffffc2 f94013f5 a94153f3 a8c37bfd d65f03c0 [ 6948.040646] 971c a9bb7bfd 910003fd a90153f3 a9025bf5 f9001bf7 aa0003f4 aa1e03e0 aa0103f5 [ 6948.048967] 973c aa0203f3 d503201f f9400280 eb15001f 54000ce8 f9400680 eb0002bf 54000c82 [ 6948.057289] 975c f9401261 d1000420 f240003f 9a931000 b9401c00 34000c00 f9402a80 37e00180 [ 6948.065621] 977c f9402280 91020000 97fd5e99 34000040 d4210000 f9402a80 36500060 d4210000 [ 6948.073943] 979c 17fffffd b2640000 f9002a80 f9400661 128002a0 a9445a97 370007e1 aa1303e0 [ 6948.082264] 97bc 97fbaa76 910123a2 aa1503e1 aa1703e0 97ffff03 aa0003f4 12800160 b40006d4 [ 6948.090574] [ 6948.090574] LR: 0xffffff8008512058: [ 6948.095536] 2058 128002b4 97ff6e9c aa1303e0 97ff5b75 14000011 7100041f f9404ea4 540003c1 [ 6948.103869] 2078 a9400277 d34cfc84 f9404e76 cb170000 d34cfc00 8b160018 b40005a0 eb24431f [ 6948.112191] 2098 54000568 2a1603e0 eb00031f 54000108 52800014 2a1403e0 a94153f3 a9425bf5 [ 6948.120514] 20b8 a94363f7 a8c47bfd d65f03c0 f940aea1 f8607822 aa1703e1 aa1303e0 97f25d92 [ 6948.128836] 20d8 2a0003f4 35fffc20 914006f7 110006d6 17ffffed f94006a0 f9406ea2 f94076a3 [ 6948.137158] 20f8 f9400c00 b4000060 f9413c01 b50000a1 f0004d61 91284021 b5000041 d4210000 [ 6948.145490] 2118 f9400826 b40000e6 9103c2a5 aa1303e1 d63f00c0 2a0003f4 34fffbc0 17ffffcb [ 6948.153838] 2138 aa1303e1 9401f190 17fffffb 128000b4 17ffffc6 a9bd7bfd 910003fd a90153f3 [ 6948.162152] [ 6948.162152] SP: 0xffffffc036fdbb40: [ 6948.167114] bb40 00000000 00000000 b7c55000 0000007f 00000096 00000000 00000000 00000000 [ 6948.175435] bb60 00000000 00000000 00000008 00000000 0900c000 ffffff80 36fdbbc0 ffffffc0 [ 6948.183757] bb80 085120d8 ffffff80 36fdbbc0 ffffffc0 081a975c ffffff80 80000145 00000000 [ 6948.192079] bba0 08fca000 ffffff80 ffffffff ffffffff 00000000 00000080 00000140 00000000 [ 6948.200404] bbc0 36fdbc10 ffffffc0 085120d8 ffffff80 38d34f20 ffffffc0 38d34f20 ffffffc0 [ 6948.208726] bbe0 31ac8000 ffffffc0 00000000 00000000 b7c55000 0000007f 00000002 00000000 [ 6948.217058] bc00 36fdbc20 ffffffc0 084e96dc ffffff80 36fdbc50 ffffffc0 08512cf4 ffffff80 [ 6948.225390] bc20 31ac8000 ffffffc0 38d34f20 ffffffc0 ffffffed 00000000 3e7fe850 ffffffc0 [ 6948.233726] [ 6948.233726] X5: 0xffffffc0002910a0: [ 6948.238688] 10a0 00291098 ffffffc0 00290da8 ffffffc0 002913a8 ffffffc0 39b0b788 ffffffc0 [ 6948.247022] 10c0 00000000 00000000 00000000 00000000 00000001 00000000 00000000 00000000 [ 6948.255342] 10e0 08a58090 ffffff80 00000000 00000000 00290f70 ffffffc0 00000000 02080020 [ 6948.263653] 1100 00000000 00000000 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff [ 6948.271985] 1120 00000001 00000000 00000000 00000000 00000000 00000000 00291138 ffffffc0 [ 6948.280308] 1140 00291138 ffffffc0 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff [ 6948.288640] 1160 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.296964] 1180 00000000 00000000 08a58680 ffffff80 024200ca 00000000 00000000 dead4ead [ 6948.305289] [ 6948.305289] X8: 0xffffffc038d34f50: [ 6948.310252] 4f50 00000000 00000000 00000000 00000000 374a7800 ffffffc0 00000f4f 00680000 [ 6948.318584] 4f70 040440bb 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.326915] 4f90 00000000 00000000 38d34f98 ffffffc0 38d34f98 ffffffc0 00000000 00000000 [ 6948.335236] 4fb0 08af41a0 ffffff80 00000000 00000000 37d1cf00 ffffffc0 31ac8000 ffffffc0 [ 6948.343558] 4fd0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.351889] 4ff0 00000000 00000000 00000000 00000000 38d35300 ffffffc0 38d35a89 ffffffc0 [ 6948.360222] 5010 00000000 00000000 37cbae88 ffffffc0 00000000 00000000 00020b54 79730122 [ 6948.368531] 5030 6d657473 6d742d64 6c696670 732d7365 70757465 7665642d 7265732e 65636976 [ 6948.376870] [ 6948.376870] X16: 0xffffff8008087be4: [ 6948.381916] 7be4 f9400681 d2c01000 eb00003f 54000100 90005e20 91242400 9403ecff d4210000 [ 6948.390229] 7c04 aa1403e1 52800120 9400ef50 52800080 d5384101 940e254a 36000073 aa1503e0 [ 6948.398550] 7c24 97fffe61 36100133 d5384114 aa1403e1 52800040 940e2542 d5033bbf f943d280 [ 6948.406873] 7c44 b4000040 94012681 36180053 97fff25c a94153f3 f94013f5 a8c37bfd d65f03c0 [ 6948.415206] 7c64 a9bc7bfd 910003fd a90153f3 a9025bf5 a90363f7 aa0003f4 aa1e03e0 aa0503f3 [ 6948.423519] 7c84 aa0103f5 aa0203f6 aa0303f7 aa0403f8 d503201f f2402e7f 928002a0 54000101 [ 6948.431851] 7ca4 aa1803e4 aa1703e3 aa1603e2 aa1503e1 aa1403e0 934cfe65 94049628 a94153f3 [ 6948.440172] 7cc4 a9425bf5 a94363f7 a8c47bfd d65f03c0 a9bd7bfd 910003fd a90153f3 f90013f5 [ 6948.448500] [ 6948.448500] X20: 0xffffffc038d34ea0: [ 6948.453547] 4ea0 00000000 00000000 00000000 00000000 374a4700 ffffffc0 00000f53 00200000 [ 6948.461871] 4ec0 00000875 00000000 38d34318 ffffffc0 00000000 00000000 00000000 00000000 [ 6948.470181] 4ee0 00000020 00000000 38d34ee8 ffffffc0 38d34ee8 ffffffc0 00000000 00000000 [ 6948.478492] 4f00 08a621d8 ffffff80 00000000 00000000 393828c0 ffffffc0 00000000 00000000 [ 6948.486814] 4f20 b7c55000 0000007f b7ceb000 0000007f 00000000 00000000 00000000 00000000 [ 6948.495125] 4f40 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.503448] 4f60 374a7800 ffffffc0 00000f4f 00680000 040440bb 00000000 00000000 00000000 [ 6948.511758] 4f80 00000000 00000000 00000000 00000000 00000000 00000000 38d34f98 ffffffc0 [ 6948.520086] [ 6948.520086] X28: 0xffffff800900bf80: [ 6948.525134] bf80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.533467] bfa0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.541797] bfc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.550108] bfe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.558439] c000 00000000 00000000 00000000 00000000 08c4a71c ffffff80 00000000 00000000 [ 6948.566751] c020 00000000 00000000 3ff838c0 ffffffc0 3ff83800 ffffffc0 3ff83740 ffffffc0 [ 6948.575072] c040 00000000 00000000 00000001 00000000 00000001 00000000 00000000 00000000 [ 6948.583392] c060 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6948.591704] [ 6948.591704] X29: 0xffffffc036fdbb40: [ 6948.596751] bb40 00000000 00000000 b7c55000 0000007f 00000096 00000000 00000000 00000000 [ 6948.605083] bb60 00000000 00000000 00000008 00000000 0900c000 ffffff80 36fdbbc0 ffffffc0 [ 6948.613415] bb80 085120d8 ffffff80 36fdbbc0 ffffffc0 081a975c ffffff80 80000145 00000000 [ 6948.621738] bba0 08fca000 ffffff80 ffffffff ffffffff 00000000 00000080 00000140 00000000 [ 6948.630058] bbc0 36fdbc10 ffffffc0 085120d8 ffffff80 38d34f20 ffffffc0 38d34f20 ffffffc0 [ 6948.638380] bbe0 31ac8000 ffffffc0 00000000 00000000 b7c55000 0000007f 00000002 00000000 [ 6948.646701] bc00 36fdbc20 ffffffc0 084e96dc ffffff80 36fdbc50 ffffffc0 08512cf4 ffffff80 [ 6948.655022] bc20 31ac8000 ffffffc0 38d34f20 ffffffc0 ffffffed 00000000 3e7fe850 ffffffc0 [ 6948.663353] [ 6948.664854] Process sdltest (pid: 21911, stack limit = 0xffffffc036fd8000) [ 6948.671724] Stack: (0xffffffc036fdbbc0 to 0xffffffc036fdc000) [ 6948.677472] bbc0: ffffffc036fdbc10 ffffff80085120d8 ffffffc038d34f20 ffffffc038d34f20 [ 6948.685301] bbe0: ffffffc031ac8000 0000000000000000 0000007fb7c55000 0000000000000002 [ 6948.693128] bc00: ffffffc036fdbc20 ffffff80084e96dc ffffffc036fdbc50 ffffff8008512cf4 [ 6948.700957] bc20: ffffffc031ac8000 ffffffc038d34f20 00000000ffffffed ffffffc03e7fe850 [ 6948.708785] bc40: ffffff8008f4ad10 0000000000000096 ffffffc036fdbc70 ffffff800852b02c [ 6948.716613] bc60: ffffffc038d34f20 ffffffc03e7fe800 ffffffc036fdbc90 ffffff8008480184 [ 6948.724442] bc80: ffffffc03e7fe800 ffffffc038d34f20 ffffffc036fdbce0 ffffff80081aea34 [ 6948.732269] bca0: ffffffc038d34f20 ffffffc037d1cf00 00000000000000bb 0000007fb7c55000 [ 6948.740097] bcc0: ffffffc0374a7800 0000000000000096 0000000000000000 0000000000000000 [ 6948.747925] bce0: ffffffc036fdbd70 ffffff80081aee8c 00000000000000bb 0000000000096000 [ 6948.755752] bd00: 0000000000000001 0000000000000000 ffffff8008eb8000 0000000000000003 [ 6948.763583] bd20: ffffffc0374a7800 0000000000000096 ffffffc037d1cf00 0000007fb7c55000 [ 6948.771412] bd40: 0000000000000000 0000000000000000 ffffffc036fdbd70 ffffffc038d34160 [ 6948.779241] bd60: ffffffc038d34188 ffffffc038d34180 ffffffc036fdbde0 ffffff800819c7e8 [ 6948.787071] bd80: ffffffc0374a7880 ffffffc037d1cf00 0000000000000000 0000000000096000 [ 6948.794899] bda0: 0000000000000003 0000000000000001 0000000000000000 00000000000000de [ 6948.802730] bdc0: ffffff8008a42000 ffffffc038338000 0000000000000070 ffffffc036fdbe38 [ 6948.810561] bde0: ffffffc036fdbe40 ffffff80081ad5e4 0000000000000001 ffffffc037d1cf00 [ 6948.818389] be00: 0000000000000000 0000000000096000 0000000000000003 0000000000000000 [ 6948.826217] be20: 000000000000011d ffffff80081ad59c 0000000000000001 0000000000000000 [ 6948.834045] be40: ffffffc036fdbe80 ffffff8008087cc0 0000000000000000 0000000000000000 [ 6948.841872] be60: 0000000000096000 0000000000000003 0000000000000001 0000000000000003 [ 6948.849700] be80: 0000000000000000 ffffff8008082f30 0000000000000000 00000040370e9000 [ 6948.857529] bea0: ffffffffffffffff 0000007fb7eac55c 0000000040000000 0000000000000015 [ 6948.865357] bec0: 0000000000000000 0000000000096000 0000000000000003 0000000000000001 [ 6948.873183] bee0: 0000000000000003 0000000000000000 fefefefeff4b4442 7f7f7f7f7f7f7f7f [ 6948.881011] bf00: 00000000000000de 0000005555568510 0000000000000000 0000000000000010 [ 6948.888839] bf20: 0000007fb7de3208 0000000000000000 0000000000000006 0000000000000040 [ 6948.896666] bf40: 0000007fb7eac540 0000007fb7fa53f0 0000000000000000 00000055555682a0 [ 6948.904493] bf60: 0000007ffffff898 0000000000096000 0000000000000000 0000007ffffff748 [ 6948.912321] bf80: 00000055555686b0 0000000000000003 0000007fb7fa4ce0 0000000000000000 [ 6948.920151] bfa0: 0000000000000000 0000007ffffff6b0 0000007fb7f832c8 0000007ffffff6b0 [ 6948.927980] bfc0: 0000007fb7eac55c 0000000040000000 0000000000000000 00000000000000de [ 6948.935807] bfe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 6948.943631] Call trace: [ 6948.946083] Exception stack(0xffffffc036fdb9f0 to 0xffffffc036fdbb20) [ 6948.952524] b9e0: 00000c0000000200 0000008000000000 [ 6948.960353] ba00: ffffffc036fdbbc0 ffffff80081a975c 0000000000000ec3 0000000000000000 [ 6948.968180] ba20: 0000000000000093 0000000000000092 0000000000000092 0000000000000092 [ 6948.976008] ba40: 00000000000003f8 000000000000008f 0000000000000001 0000000000000001 [ 6948.983835] ba60: 0000000000000000 0000000000000003 0000000000000003 0000000000000003 [ 6948.991665] ba80: ffffffc036fdbac0 ffffff80081894ec 0000007fb7ceb000 0000007fb7c55000 [ 6948.999493] baa0: 00000c0000000200 0000000000000000 0000000000000096 ffffffc000291120 [ 6949.007321] bac0: 000000000000003f 0000000000000000 ffffffc038d34fd0 0000000000000000 [ 6949.015152] bae0: 0000000000100000 0000000000000010 0000007fb7de3208 0000000000000000 [ 6949.022981] bb00: 0000000000000006 0000000000000040 ffffff8008087c64 0000007fb7fa53f0 [ 6949.030814] [<ffffff80081a975c>] vm_insert_page+0x40/0x1dc [ 6949.036300] [<ffffff80085120d8>] rockchip_drm_gem_object_mmap+0xf4/0x168 [ 6949.043007] [<ffffff8008512cf4>] rockchip_gem_mmap_buf+0x3c/0x48 [ 6949.049021] [<ffffff800852b02c>] rockchip_fbdev_mmap+0x34/0x40 [ 6949.054855] [<ffffff8008480184>] fb_mmap+0x64/0x118 [ 6949.059738] [<ffffff80081aea34>] mmap_region+0x334/0x48c [ 6949.065053] [<ffffff80081aee8c>] do_mmap+0x300/0x330 [ 6949.070020] [<ffffff800819c7e8>] vm_mmap_pgoff+0x70/0xac [ 6949.075336] [<ffffff80081ad5e4>] SyS_mmap_pgoff+0x88/0xa8 [ 6949.080743] [<ffffff8008087cc0>] sys_mmap+0x5c/0x70 [ 6949.085627] [<ffffff8008082f30>] el0_svc_naked+0x24/0x28 [ 6949.090945] Code: 54000ce8 f9400680 eb0002bf 54000c82 (f9401261) [ 6949.097042] ---[ end trace 21db0c5c97c655d9 ]---
程式主要使用SDL v1.2編寫,因此,使用gdb追蹤到src/video/fbcon/SDL_fbvideo.c,發現crash點位於do_mmap,如下所示
496 static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) ... 531 if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) { ... 579 /* Memory map the device, compensating for buggy PPC mmap() */ 580 mapped_offset = (((long)finfo.smem_start) - 581 (((long)finfo.smem_start)&~(pagesize-1))); 582 mapped_memlen = finfo.smem_len+mapped_offset; 583 mapped_mem = do_mmap(NULL, mapped_memlen, 584 PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
問題點在於RK3326顯示驅動沒有填寫smem_start位址,所以SDL v1.2拿到的指標是NULL,導致crash
static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes) { ... dev->mode_config.fb_base = 0; fbi->screen_base = rk_obj->kvaddr + offset; fbi->screen_size = rk_obj->base.size; fbi->fix.smem_len = rk_obj->base.size; fbi->skip_vt_switch = true; ... }