• Yifeng Li's avatar
    fbdev: sm712fb: fix crashes during framebuffer writes by correctly mapping VRAM · fb294796
    Yifeng Li authored
    commit 9e0e5999 upstream.
    
    On a Thinkpad s30 (Pentium III / i440MX, Lynx3DM), running fbtest or X
    will crash the machine instantly, because the VRAM/framebuffer is not
    mapped correctly.
    
    On SM712, the framebuffer starts at the beginning of address space, but
    SM720's framebuffer starts at the 1 MiB offset from the beginning. However,
    sm712fb fails to take this into account, as a result, writing to the
    framebuffer will destroy all the registers and kill the system immediately.
    Another problem is the driver assumes 8 MiB of VRAM for SM720, but some
    SM720 system, such as this IBM Thinkpad, only has 4 MiB of VRAM.
    
    Fix this problem by removing the hardcoded VRAM size, adding a function to
    query the amount of VRAM from register MCR76 on SM720, and adding proper
    framebuffer offset.
    
    Please note that the memory map may have additional problems on Big-Endian
    system, which is not available for testing by myself. But I highly suspect
    that the original code is also broken on Big-Endian machines for SM720, so
    at least we are not making the problem worse. More, the driver also assumed
    SM710/SM712 has 4 MiB of VRAM, but it has a 2 MiB version as well, and used
    in earlier laptops, such as IBM Thinkpad 240X, the driver would probably
    crash on them. I've never seen one of those machines and cannot fix it, but
    I have documented these problems in the comments.
    Signed-off-by: default avatarYifeng Li <tomli@tomli.me>
    Tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
    Cc: Teddy Wang <teddy.wang@siliconmotion.com>
    Cc: <stable@vger.kernel.org>  # v4.4+
    Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    fb294796
sm712fb.c 45.6 KB