/*
* Silicon Motion SM712 frame buffer device
*
* Copyright (C) 2006 Silicon Motion Technology Corp.
* Authors: Ge Wang, gewang@siliconmotion.com
* Boyod boyod.yang@siliconmotion.com.cn
*
* Copyright (C) 2009 Lemote, Inc.
* Author: Wu Zhangjin, wuzhangjin@gmail.com
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#define FB_ACCEL_SMI_LYNX 88
#define SCREEN_X_RES 1024
#define SCREEN_Y_RES 600
#define SCREEN_BPP 16
/*Assume SM712 graphics chip has 4MB VRAM */
#define SM712_VIDEOMEMORYSIZE 0x00400000
/*Assume SM722 graphics chip has 8MB VRAM */
#define SM722_VIDEOMEMORYSIZE 0x00800000
#define dac_reg (0x3c8)
#define dac_val (0x3c9)
extern void __iomem *smtc_regbaseaddress;
#define smtc_mmiowb(dat, reg) writeb(dat, smtc_regbaseaddress + reg)
#define smtc_mmiorb(reg) readb(smtc_regbaseaddress + reg)
#define SIZE_SR00_SR04 (0x04 - 0x00 + 1)
#define SIZE_SR10_SR24 (0x24 - 0x10 + 1)
#define SIZE_SR30_SR75 (0x75 - 0x30 + 1)
#define SIZE_SR80_SR93 (0x93 - 0x80 + 1)
#define SIZE_SRA0_SRAF (0xAF - 0xA0 + 1)
#define SIZE_GR00_GR08 (0x08 - 0x00 + 1)
#define SIZE_AR00_AR14 (0x14 - 0x00 + 1)
#define SIZE_CR00_CR18 (0x18 - 0x00 + 1)
#define SIZE_CR30_CR4D (0x4D - 0x30 + 1)
#define SIZE_CR90_CRA7 (0xA7 - 0x90 + 1)
static inline void smtc_crtcw(int reg, int val)
{
smtc_mmiowb(reg, 0x3d4);
smtc_mmiowb(val, 0x3d5);
}
static inline void smtc_grphw(int reg, int val)
{
smtc_mmiowb(reg, 0x3ce);
smtc_mmiowb(val, 0x3cf);
}
static inline void smtc_attrw(int reg, int val)
{
smtc_mmiorb(0x3da);
smtc_mmiowb(reg, 0x3c0);
smtc_mmiorb(0x3c1);
smtc_mmiowb(val, 0x3c0);
}
static inline void smtc_seqw(int reg, int val)
{
smtc_mmiowb(reg, 0x3c4);
smtc_mmiowb(val, 0x3c5);
}
static inline unsigned int smtc_seqr(int reg)
{
smtc_mmiowb(reg, 0x3c4);
return smtc_mmiorb(0x3c5);
}
/* The next structure holds all information relevant for a specific video mode.
*/
struct modeinit {
int mmsizex;
int mmsizey;
int bpp;
int hz;
unsigned char init_misc;
unsigned char init_sr00_sr04[SIZE_SR00_SR04];
unsigned char init_sr10_sr24[SIZE_SR10_SR24];
unsigned char init_sr30_sr75[SIZE_SR30_SR75];
unsigned char init_sr80_sr93[SIZE_SR80_SR93];
unsigned char init_sra0_sraf[SIZE_SRA0_SRAF];
unsigned char init_gr00_gr08[SIZE_GR00_GR08];
unsigned char init_ar00_ar14[SIZE_AR00_AR14];
unsigned char init_cr00_cr18[SIZE_CR00_CR18];
unsigned char init_cr30_cr4d[SIZE_CR30_CR4D];
unsigned char init_cr90_cra7[SIZE_CR90_CRA7];
};
#ifdef __BIG_ENDIAN
#define pal_rgb(r, g, b, val) (((r & 0xf800) >> 8) | \
((g & 0xe000) >> 13) | \
((g & 0x1c00) << 3) | \
((b & 0xf800) >> 3))
#define big_addr 0x800000
#define mmio_addr 0x00800000
#define seqw17() smtc_seqw(0x17, 0x30)
#define big_pixel_depth(p, d) {if (p == 24) {p = 32; d = 32; } }
#define big_swap(p) ((p & 0xff00ff00 >> 8) | (p & 0x00ff00ff << 8))
#else
#define pal_rgb(r, g, b, val) val
#define big_addr 0
#define mmio_addr 0x00c00000
#define seqw17() do { } while (0)
#define big_pixel_depth(p, d) do { } while (0)
#define big_swap(p) p
#endif
ove&id=39cb2c9a316e77f6dfba96c543e55b6672d5a37e'>audit_tree.c
drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj()
I've seen this trigger twice now, where the i915_gem_object_to_ggtt()
call in intel_unpin_fb_obj() returns NULL, resulting in an oops
immediately afterwards as the (inlined) call to i915_vma_unpin_fence()
tries to dereference it.
It seems to be some race condition where the object is going away at
shutdown time, since both times happened when shutting down the X
server. The call chains were different:
- VT ioctl(KDSETMODE, KD_TEXT):
intel_cleanup_plane_fb+0x5b/0xa0 [i915]
drm_atomic_helper_cleanup_planes+0x6f/0x90 [drm_kms_helper]
intel_atomic_commit_tail+0x749/0xfe0 [i915]
intel_atomic_commit+0x3cb/0x4f0 [i915]
drm_atomic_commit+0x4b/0x50 [drm]
restore_fbdev_mode+0x14c/0x2a0 [drm_kms_helper]
drm_fb_helper_restore_fbdev_mode_unlocked+0x34/0x80 [drm_kms_helper]
drm_fb_helper_set_par+0x2d/0x60 [drm_kms_helper]
intel_fbdev_set_par+0x18/0x70 [i915]
fb_set_var+0x236/0x460
fbcon_blank+0x30f/0x350
do_unblank_screen+0xd2/0x1a0
vt_ioctl+0x507/0x12a0
tty_ioctl+0x355/0xc30
do_vfs_ioctl+0xa3/0x5e0
SyS_ioctl+0x79/0x90
entry_SYSCALL_64_fastpath+0x13/0x94
- i915 unpin_work workqueue:
intel_unpin_work_fn+0x58/0x140 [i915]
process_one_work+0x1f1/0x480
worker_thread+0x48/0x4d0
kthread+0x101/0x140
and this patch purely papers over the issue by adding a NULL pointer
check and a WARN_ON_ONCE() to avoid the oops that would then generally
make the machine unresponsive.
Other callers of i915_gem_object_to_ggtt() seem to also check for the
returned pointer being NULL and warn about it, so this clearly has
happened before in other places.
[ Reported it originally to the i915 developers on Jan 8, applying the
ugly workaround on my own now after triggering the problem for the
second time with no feedback.
This is likely to be the same bug reported as
https://bugs.freedesktop.org/show_bug.cgi?id=98829
https://bugs.freedesktop.org/show_bug.cgi?id=99134
which has a patch for the underlying problem, but it hasn't gotten to
me, so I'm applying the workaround. ]
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>