1. 11 11月, 2013 1 次提交
    • G
      fb: reorder the lock sequence to fix potential dead lock · 3a41c5db
      Gu Zheng 提交于
      Following commits:
      
      50e244cc fb: rework locking to fix lock ordering on takeover
      e93a9a86 fb: Yet another band-aid for fixing lockdep mess
      054430e7 fbcon: fix locking harder
      
      reworked locking to fix related lock ordering on takeover, and introduced console_lock
      into fbmem, but it seems that the new lock sequence(fb_info->lock ---> console_lock)
      is against with the one in console_callback(console_lock ---> fb_info->lock), and leads to
      a potential dead lock as following:
      
      [  601.079000] ======================================================
      [  601.079000] [ INFO: possible circular locking dependency detected ]
      [  601.079000] 3.11.0 #189 Not tainted
      [  601.079000] -------------------------------------------------------
      [  601.079000] kworker/0:3/619 is trying to acquire lock:
      [  601.079000]  (&fb_info->lock){+.+.+.}, at: [<ffffffff81397566>] lock_fb_info+0x26/0x60
      [  601.079000]
      but task is already holding lock:
      [  601.079000]  (console_lock){+.+.+.}, at: [<ffffffff8141aae3>] console_callback+0x13/0x160
      [  601.079000]
      which lock already depends on the new lock.
      
      [  601.079000]
      the existing dependency chain (in reverse order) is:
      [  601.079000]
      -> #1 (console_lock){+.+.+.}:
      [  601.079000]        [<ffffffff810dc971>] lock_acquire+0xa1/0x140
      [  601.079000]        [<ffffffff810c6267>] console_lock+0x77/0x80
      [  601.079000]        [<ffffffff81399448>] register_framebuffer+0x1d8/0x320
      [  601.079000]        [<ffffffff81cfb4c8>] efifb_probe+0x408/0x48f
      [  601.079000]        [<ffffffff8144a963>] platform_drv_probe+0x43/0x80
      [  601.079000]        [<ffffffff8144853b>] driver_probe_device+0x8b/0x390
      [  601.079000]        [<ffffffff814488eb>] __driver_attach+0xab/0xb0
      [  601.079000]        [<ffffffff814463bd>] bus_for_each_dev+0x5d/0xa0
      [  601.079000]        [<ffffffff81447e6e>] driver_attach+0x1e/0x20
      [  601.079000]        [<ffffffff81447a07>] bus_add_driver+0x117/0x290
      [  601.079000]        [<ffffffff81448fea>] driver_register+0x7a/0x170
      [  601.079000]        [<ffffffff8144a10a>] __platform_driver_register+0x4a/0x50
      [  601.079000]        [<ffffffff8144a12d>] platform_driver_probe+0x1d/0xb0
      [  601.079000]        [<ffffffff81cfb0a1>] efifb_init+0x273/0x292
      [  601.079000]        [<ffffffff81002132>] do_one_initcall+0x102/0x1c0
      [  601.079000]        [<ffffffff81cb80a6>] kernel_init_freeable+0x15d/0x1ef
      [  601.079000]        [<ffffffff8166d2de>] kernel_init+0xe/0xf0
      [  601.079000]        [<ffffffff816914ec>] ret_from_fork+0x7c/0xb0
      [  601.079000]
      -> #0 (&fb_info->lock){+.+.+.}:
      [  601.079000]        [<ffffffff810dc1d8>] __lock_acquire+0x1e18/0x1f10
      [  601.079000]        [<ffffffff810dc971>] lock_acquire+0xa1/0x140
      [  601.079000]        [<ffffffff816835ca>] mutex_lock_nested+0x7a/0x3b0
      [  601.079000]        [<ffffffff81397566>] lock_fb_info+0x26/0x60
      [  601.079000]        [<ffffffff813a4aeb>] fbcon_blank+0x29b/0x2e0
      [  601.079000]        [<ffffffff81418658>] do_blank_screen+0x1d8/0x280
      [  601.079000]        [<ffffffff8141ab34>] console_callback+0x64/0x160
      [  601.079000]        [<ffffffff8108d855>] process_one_work+0x1f5/0x540
      [  601.079000]        [<ffffffff8108e04c>] worker_thread+0x11c/0x370
      [  601.079000]        [<ffffffff81095fbd>] kthread+0xed/0x100
      [  601.079000]        [<ffffffff816914ec>] ret_from_fork+0x7c/0xb0
      [  601.079000]
      other info that might help us debug this:
      
      [  601.079000]  Possible unsafe locking scenario:
      
      [  601.079000]        CPU0                    CPU1
      [  601.079000]        ----                    ----
      [  601.079000]   lock(console_lock);
      [  601.079000]                                lock(&fb_info->lock);
      [  601.079000]                                lock(console_lock);
      [  601.079000]   lock(&fb_info->lock);
      [  601.079000]
       *** DEADLOCK ***
      
      so we reorder the lock sequence the same as it in console_callback() to
      avoid this issue. And following Tomi's suggestion, fix these similar
      issues all in fb subsystem.
      Signed-off-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
      Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      3a41c5db
  2. 08 2月, 2013 1 次提交
  3. 29 5月, 2012 1 次提交
  4. 03 9月, 2011 1 次提交
    • H
      fb: avoid possible deadlock caused by fb_set_suspend · 9e769ff3
      Herton Ronaldo Krzesinski 提交于
      A lock ordering issue can cause deadlocks: in framebuffer/console code,
      all needed struct fb_info locks are taken before acquire_console_sem(),
      in places which need to take console semaphore.
      
      But fb_set_suspend is always called with console semaphore held, and
      inside it we call lock_fb_info which gets the fb_info lock, inverse
      locking order of what the rest of the code does. This causes a real
      deadlock issue, when we write to state fb sysfs attribute (which calls
      fb_set_suspend) while a framebuffer is being unregistered by
      remove_conflicting_framebuffers, as can be shown by following show
      blocked state trace on a test program which loads i915 and runs another
      forked processes writing to state attribute:
      
      Test process with semaphore held and trying to get fb_info lock:
      ..
      fb-test2      D 0000000000000000     0   237    228 0x00000000
       ffff8800774f3d68 0000000000000082 00000000000135c0 00000000000135c0
       ffff880000000000 ffff8800774f3fd8 ffff8800774f3fd8 ffff880076ee4530
       00000000000135c0 ffff8800774f3fd8 ffff8800774f2000 00000000000135c0
      Call Trace:
       [<ffffffff8141287a>] __mutex_lock_slowpath+0x11a/0x1e0
       [<ffffffff814142f2>] ? _raw_spin_lock_irq+0x22/0x40
       [<ffffffff814123d3>] mutex_lock+0x23/0x50
       [<ffffffff8125dfc5>] lock_fb_info+0x25/0x60
       [<ffffffff8125e3f0>] fb_set_suspend+0x20/0x80
       [<ffffffff81263e2f>] store_fbstate+0x4f/0x70
       [<ffffffff812e7f70>] dev_attr_store+0x20/0x30
       [<ffffffff811c46b4>] sysfs_write_file+0xd4/0x160
       [<ffffffff81155a26>] vfs_write+0xc6/0x190
       [<ffffffff81155d51>] sys_write+0x51/0x90
       [<ffffffff8100c012>] system_call_fastpath+0x16/0x1b
      ..
      modprobe process stalled because has the fb_info lock (got inside
      unregister_framebuffer) but waiting for the semaphore held by the
      test process which is waiting to get the fb_info lock:
      ..
      modprobe      D 0000000000000000     0   230    218 0x00000000
       ffff880077a4d618 0000000000000082 0000000000000001 0000000000000001
       ffff880000000000 ffff880077a4dfd8 ffff880077a4dfd8 ffff8800775a2e20
       00000000000135c0 ffff880077a4dfd8 ffff880077a4c000 00000000000135c0
      Call Trace:
       [<ffffffff81411fe5>] schedule_timeout+0x215/0x310
       [<ffffffff81058051>] ? get_parent_ip+0x11/0x50
       [<ffffffff814130dd>] __down+0x6d/0xb0
       [<ffffffff81089f71>] down+0x41/0x50
       [<ffffffff810629ac>] acquire_console_sem+0x2c/0x50
       [<ffffffff812ca53d>] unbind_con_driver+0xad/0x2d0
       [<ffffffff8126f5f7>] fbcon_event_notify+0x457/0x890
       [<ffffffff814144ff>] ? _raw_spin_unlock_irqrestore+0x1f/0x50
       [<ffffffff81058051>] ? get_parent_ip+0x11/0x50
       [<ffffffff8141836d>] notifier_call_chain+0x4d/0x70
       [<ffffffff8108a3b8>] __blocking_notifier_call_chain+0x58/0x80
       [<ffffffff8108a3f6>] blocking_notifier_call_chain+0x16/0x20
       [<ffffffff8125dabb>] fb_notifier_call_chain+0x1b/0x20
       [<ffffffff8125e6ac>] unregister_framebuffer+0x7c/0x130
       [<ffffffff8125e8b3>] remove_conflicting_framebuffers+0x153/0x180
       [<ffffffff8125eef3>] register_framebuffer+0x93/0x2c0
       [<ffffffffa0331112>] drm_fb_helper_single_fb_probe+0x252/0x2f0 [drm_kms_helper]
       [<ffffffffa03314a3>] drm_fb_helper_initial_config+0x2f3/0x6d0 [drm_kms_helper]
       [<ffffffffa03318dd>] ? drm_fb_helper_single_add_all_connectors+0x5d/0x1c0 [drm_kms_helper]
       [<ffffffffa037b588>] intel_fbdev_init+0xa8/0x160 [i915]
       [<ffffffffa0343d74>] i915_driver_load+0x854/0x12b0 [i915]
       [<ffffffffa02f0e7e>] drm_get_pci_dev+0x19e/0x360 [drm]
       [<ffffffff8141821d>] ? sub_preempt_count+0x9d/0xd0
       [<ffffffffa0386f91>] i915_pci_probe+0x15/0x17 [i915]
       [<ffffffff8124481f>] local_pci_probe+0x5f/0xd0
       [<ffffffff81244f89>] pci_device_probe+0x119/0x120
       [<ffffffff812eccaa>] ? driver_sysfs_add+0x7a/0xb0
       [<ffffffff812ed003>] driver_probe_device+0xa3/0x290
       [<ffffffff812ed1f0>] ? __driver_attach+0x0/0xb0
       [<ffffffff812ed29b>] __driver_attach+0xab/0xb0
       [<ffffffff812ed1f0>] ? __driver_attach+0x0/0xb0
       [<ffffffff812ebd3e>] bus_for_each_dev+0x5e/0x90
       [<ffffffff812ecc2e>] driver_attach+0x1e/0x20
       [<ffffffff812ec6f2>] bus_add_driver+0xe2/0x320
       [<ffffffffa03aa000>] ? i915_init+0x0/0x96 [i915]
       [<ffffffff812ed536>] driver_register+0x76/0x140
       [<ffffffffa03aa000>] ? i915_init+0x0/0x96 [i915]
       [<ffffffff81245216>] __pci_register_driver+0x56/0xd0
       [<ffffffffa02f1264>] drm_pci_init+0xe4/0xf0 [drm]
       [<ffffffffa03aa000>] ? i915_init+0x0/0x96 [i915]
       [<ffffffffa02e84a8>] drm_init+0x58/0x70 [drm]
       [<ffffffffa03aa094>] i915_init+0x94/0x96 [i915]
       [<ffffffff81002194>] do_one_initcall+0x44/0x190
       [<ffffffff810a066b>] sys_init_module+0xcb/0x210
       [<ffffffff8100c012>] system_call_fastpath+0x16/0x1b
      ..
      
      fb-test2 which reproduces above is available on kernel.org bug #26232.
      To solve this issue, avoid calling lock_fb_info inside fb_set_suspend,
      and move it out to where needed (callers of fb_set_suspend must call
      lock_fb_info before if needed). So far, the only place which needs to
      call lock_fb_info is store_fbstate, all other places which calls
      fb_set_suspend are suspend/resume hooks that should not need the lock as
      they should be run only when processes are already frozen in
      suspend/resume.
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=26232Signed-off-by: NHerton Ronaldo Krzesinski <herton@mandriva.com.br>
      Signed-off-by: NFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Cc: stable@kernel.org
      9e769ff3
  5. 31 3月, 2011 1 次提交
  6. 26 1月, 2011 1 次提交
    • T
      console: rename acquire/release_console_sem() to console_lock/unlock() · ac751efa
      Torben Hohn 提交于
      The -rt patches change the console_semaphore to console_mutex.  As a
      result, a quite large chunk of the patches changes all
      acquire/release_console_sem() to acquire/release_console_mutex()
      
      This commit makes things use more neutral function names which dont make
      implications about the underlying lock.
      
      The only real change is the return value of console_trylock which is
      inverted from try_acquire_console_sem()
      
      This patch also paves the way to switching console_sem from a semaphore to
      a mutex.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: make console_trylock return 1 on success, per Geert]
      Signed-off-by: NTorben Hohn <torbenh@gmx.de>
      Cc: Thomas Gleixner <tglx@tglx.de>
      Cc: Greg KH <gregkh@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac751efa
  7. 18 5月, 2010 1 次提交
  8. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  9. 09 7月, 2009 1 次提交
  10. 07 7月, 2009 1 次提交
  11. 09 5月, 2007 1 次提交
  12. 20 2月, 2007 1 次提交
    • R
      backlight: Rework backlight/fb interaction simplifying, lots · 37ce69a5
      Richard Purdie 提交于
      fb_info->bl_mutex is badly thought out and the backlight class doesn't
      need it if the framebuffer/backlight register/unregister order is
      consistent, particularly after the backlight locking fixes.
      
      Fix the drivers to use the order:
      
      backlight_device_register()
      register_framebuffer()
      unregister_framebuffer()
      backlight_device_unregister()
      
      and turn bl_mutex into a lock for the bl_curve data only.
      Signed-off-by: NRichard Purdie <rpurdie@rpsys.net>
      37ce69a5
  13. 13 2月, 2007 1 次提交
  14. 02 12月, 2006 1 次提交
  15. 03 10月, 2006 1 次提交
  16. 26 9月, 2006 1 次提交
  17. 27 6月, 2006 2 次提交
  18. 26 6月, 2006 1 次提交
  19. 28 4月, 2006 1 次提交
  20. 28 3月, 2006 1 次提交
    • A
      [PATCH] framebuffer: cmap-setting return values · db77ec27
      Alan Curry 提交于
      A set of 3 small bugfixes, all of which are related to bogus return values
      of fb colormap-setting functions.
      
      First, fb_alloc_cmap returns -1 if memory allocation fails. This is a hard
      condition to reproduce since you'd have to be really low on memory, but from
      studying the contexts in which it is called, I think this function should be
      returning a negative errno, and the -1 will be seen as an EPERM. Switching it
      to -ENOMEM makes sense.
      
      Second, the store_cmap function which is called for writes to
      /sys/class/graphics/fb0/color_map returns 0 for success, but it should be
      returning the count of bytes written since its return value ends up in
      userspace as the result of the write() syscall.
      
      Third, radeonfb returns 1 instead of a negative errno when FBIOPUTCMAP is
      called with an oversized colormap.  This is seen in userspace as a return
      value of 1 from the ioctl() syscall with errno left unchanged.  A more
      useful return value would be -EINVAL.
      Signed-off-by: NAlan Curry <pacman@TheWorld.com>
      Cc: "Antonino A. Daplas" <adaplas@pol.net>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      db77ec27
  21. 11 1月, 2006 3 次提交
  22. 09 11月, 2005 1 次提交
    • A
      [PATCH] fbcon: Console Rotation - Add ability to control rotation via sysfs · a812c94b
      Antonino A. Daplas 提交于
      Add ability to set rotation via sysfs.  The attributes are located in
      /sys/class/graphics/fb[n] and accepts 0 - unrotated; 1 - clockwise; 2 - upside
      down; 3 - counterclockwise.
      
      The attributes are:
      
      con_rotate (r/w) -   set rotation of the active console
      con_rotate_all (w) - set rotation of all consoles
      rotate (r/w) -       set rotation of the framebuffer, if supported.
      Currently, none of the drivers support this.
      
      This is probably temporary, since con_rotate and con_rotate_all are
      console-specific and has no business being under the fb device.  However,
      until the console layer acquires it's own sysfs class, these attributes will
      temporarily reside here.
      Signed-off-by: NAntonino Daplas <adaplas@pol.net>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      a812c94b
  23. 25 10月, 2005 1 次提交
  24. 01 8月, 2005 1 次提交
  25. 29 7月, 2005 1 次提交
  26. 28 7月, 2005 1 次提交
  27. 08 7月, 2005 1 次提交
  28. 26 6月, 2005 1 次提交
  29. 14 6月, 2005 1 次提交
  30. 06 5月, 2005 1 次提交
  31. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4