1. 10 Apr, 2015 11 commits
    • Changman Lee's avatar
      f2fs: add stat info for moved blocks by background gc · e1235983
      Changman Lee authored
      This patch is for looking into gc performance of f2fs in detail.
      Signed-off-by: default avatarChangman Lee <cm224.lee@samsung.com>
      [Jaegeuk Kim: fix build errors]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e1235983
    • Chao Yu's avatar
      f2fs: fix to issue small discard in real-time mode discard · b28c3f94
      Chao Yu authored
      Now in f2fs, we share functions and structures for batch mode and real-time mode
      discard. For real-time mode discard, in shared function add_discard_addrs, we
      will use uninitialized trim_minlen in struct cp_control to compare with length
      of contiguous free blocks to decide whether skipping discard fragmented freespace
      or not, this makes us ignore small discard sometimes. Fix it.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Reviewed-by : Changman Lee <cm224.lee@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b28c3f94
    • Sebastian Andrzej Siewior's avatar
      f2fs: add cond_resched() to sync_dirty_dir_inodes() · 7ecebe5e
      Sebastian Andrzej Siewior authored
      In a preempt-off enviroment a alot of FS activity (write/delete) I run
      into a CPU stall:
      
      | NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [kworker/u2:2:59]
      | Modules linked in:
      | CPU: 0 PID: 59 Comm: kworker/u2:2 Tainted: G        W      3.19.0-00010-g10c11c51ffed #153
      | Workqueue: writeback bdi_writeback_workfn (flush-179:0)
      | task: df230000 ti: df23e000 task.ti: df23e000
      | PC is at __submit_merged_bio+0x6c/0x110
      | LR is at f2fs_submit_merged_bio+0x74/0x80
      …
      | [<c00085c4>] (gic_handle_irq) from [<c0012e84>] (__irq_svc+0x44/0x5c)
      | Exception stack(0xdf23fb48 to 0xdf23fb90)
      | fb40:                   deef3484 ffff0001 ffff0001 00000027 deef3484 00000000
      | fb60: deef3440 00000000 de426000 deef34ec deefc440 df23fbb4 df23fbb8 df23fb90
      | fb80: c02191f0 c0218fa0 60000013 ffffffff
      | [<c0012e84>] (__irq_svc) from [<c0218fa0>] (__submit_merged_bio+0x6c/0x110)
      | [<c0218fa0>] (__submit_merged_bio) from [<c02191f0>] (f2fs_submit_merged_bio+0x74/0x80)
      | [<c02191f0>] (f2fs_submit_merged_bio) from [<c021624c>] (sync_dirty_dir_inodes+0x70/0x78)
      | [<c021624c>] (sync_dirty_dir_inodes) from [<c0216358>] (write_checkpoint+0x104/0xc10)
      | [<c0216358>] (write_checkpoint) from [<c021231c>] (f2fs_sync_fs+0x80/0xbc)
      | [<c021231c>] (f2fs_sync_fs) from [<c0221eb8>] (f2fs_balance_fs_bg+0x4c/0x68)
      | [<c0221eb8>] (f2fs_balance_fs_bg) from [<c021e9b8>] (f2fs_write_node_pages+0x40/0x110)
      | [<c021e9b8>] (f2fs_write_node_pages) from [<c00de620>] (do_writepages+0x34/0x48)
      | [<c00de620>] (do_writepages) from [<c0145714>] (__writeback_single_inode+0x50/0x228)
      | [<c0145714>] (__writeback_single_inode) from [<c0146184>] (writeback_sb_inodes+0x1a8/0x378)
      | [<c0146184>] (writeback_sb_inodes) from [<c01463e4>] (__writeback_inodes_wb+0x90/0xc8)
      | [<c01463e4>] (__writeback_inodes_wb) from [<c01465f8>] (wb_writeback+0x1dc/0x28c)
      | [<c01465f8>] (wb_writeback) from [<c0146dd8>] (bdi_writeback_workfn+0x2ac/0x460)
      | [<c0146dd8>] (bdi_writeback_workfn) from [<c003c3fc>] (process_one_work+0x11c/0x3a4)
      | [<c003c3fc>] (process_one_work) from [<c003c844>] (worker_thread+0x17c/0x490)
      | [<c003c844>] (worker_thread) from [<c0041398>] (kthread+0xec/0x100)
      | [<c0041398>] (kthread) from [<c000ed10>] (ret_from_fork+0x14/0x24)
      
      As it turns out, the code loops in sync_dirty_dir_inodes() and waits for
      others to make progress but since it never leaves the CPU there is no
      progress made. At the time of this stall, there is also a rm process
      blocked:
      | rm              R running      0  1989   1774 0x00000000
      | [<c047c55c>] (__schedule) from [<c00486dc>] (__cond_resched+0x30/0x4c)
      | [<c00486dc>] (__cond_resched) from [<c047c8c8>] (_cond_resched+0x4c/0x54)
      | [<c047c8c8>] (_cond_resched) from [<c00e1aec>] (truncate_inode_pages_range+0x1f0/0x5e8)
      | [<c00e1aec>] (truncate_inode_pages_range) from [<c00e1fd8>] (truncate_inode_pages+0x28/0x30)
      | [<c00e1fd8>] (truncate_inode_pages) from [<c00e2148>] (truncate_inode_pages_final+0x60/0x64)
      | [<c00e2148>] (truncate_inode_pages_final) from [<c020c92c>] (f2fs_evict_inode+0x4c/0x268)
      | [<c020c92c>] (f2fs_evict_inode) from [<c0137214>] (evict+0x94/0x140)
      | [<c0137214>] (evict) from [<c01377e8>] (iput+0xc8/0x134)
      | [<c01377e8>] (iput) from [<c01333e4>] (d_delete+0x154/0x180)
      | [<c01333e4>] (d_delete) from [<c0129870>] (vfs_rmdir+0x114/0x12c)
      | [<c0129870>] (vfs_rmdir) from [<c012d644>] (do_rmdir+0x158/0x168)
      | [<c012d644>] (do_rmdir) from [<c012dd90>] (SyS_unlinkat+0x30/0x3c)
      | [<c012dd90>] (SyS_unlinkat) from [<c000ec40>] (ret_fast_syscall+0x0/0x4c)
      
      As explained by Jaegeuk Kim:
      |This inode is the directory (c.f., do_rmdir) causing a infinite loop on
      |sync_dirty_dir_inodes.
      |The sync_dirty_dir_inodes tries to flush dirty dentry pages, but if the
      |inode is under eviction, it submits bios and do it again until eviction
      |is finished.
      
      This patch adds a cond_resched() (as suggested by Jaegeuk) after a BIO
      is submitted so other thread can make progress.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      [Jaegeuk Kim: change fs/f2fs to f2fs in subject as naming convention]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7ecebe5e
    • Wanpeng Li's avatar
      f2fs: fix max orphan inodes calculation · 14b42817
      Wanpeng Li authored
      cp_payload is introduced for sit bitmap to support large volume, and it is
      just after the block of f2fs_checkpoint + nat bitmap, so the first segment
      should include F2FS_CP_PACKS + NR_CURSEG_TYPE + cp_payload + orphan blocks.
      However, current max orphan inodes calculation don't consider cp_payload,
      this patch fix it by reducing the number of cp_payload from total blocks of
      the first segment when calculate max orphan inodes.
      Signed-off-by: default avatarWanpeng Li <wanpeng.li@linux.intel.com>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      14b42817
    • Wanpeng Li's avatar
      f2fs: don't need to collect dirty sit entries and flush journal when there's no dirty sit entries · 2b11a74b
      Wanpeng Li authored
       Don't need to collect dirty sit entries and flush sit journal to sit
       entries when there's no dirty sit entries. This patch check dirty_sentries
       earlier just like flush_nat_entries.
      Signed-off-by: default avatarWanpeng Li <wanpeng.li@linux.intel.com>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2b11a74b
    • Wanpeng Li's avatar
      f2fs: fix block_ops trace point · 2bda542d
      Wanpeng Li authored
      block operations is used to flush all dirty node and dentry blocks in
      the page cache and suspend ordinary writing activities, however, there
      are some facts such like cp error or mount read-only etc which lead to
      block operations can't be invoked. Current trace point print block_ops
      start premature even if block_ops doesn't have opportunity to execute.
      This patch fix it by move block_ops trace point just before block_ops.
      Signed-off-by: default avatarWanpeng Li <wanpeng.li@linux.intel.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2bda542d
    • Jaegeuk Kim's avatar
      f2fs: check its block allocation to avoid producing wrong dirty pages · b7f204cc
      Jaegeuk Kim authored
      If a page is cached but its block was deallocated, we don't need to make
      the page dirty again by gc and truncate_partial_data_page.
      
      In that case, it needs to check its block allocation all the time instead
      of giving up-to-date page.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b7f204cc
    • Jaegeuk Kim's avatar
      f2fs: clear page's up-to-date if block was deallocated · 2bca1e23
      Jaegeuk Kim authored
      If page's on-disk block was deallocated, let's remove up-to-date flag to avoid
      further access with wrong contents.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2bca1e23
    • Wanpeng Li's avatar
      f2fs: fix the number of orphan inode blocks · 3c642985
      Wanpeng Li authored
      cp_pack_start_sum is calculated in do_checkpoint and is equal to
      cpu_to_le32(1 + cp_payload_blks + orphan_blocks). The number of
      orphan inode blocks is take advantage of by recover_orphan_inodes
      to readahead meta pages and recovery inodes. However, current codes
      forget to reduce the number of cp payload blocks when calculate
      the number of orphan inode blocks. This patch fix it.
      Signed-off-by: default avatarWanpeng Li <wanpeng.li@linux.intel.com>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      3c642985
    • Wanpeng Li's avatar
      f2fs: introduce macro __cp_payload · 55141486
      Wanpeng Li authored
      This patch introduce macro __cp_payload.
      Signed-off-by: default avatarWanpeng Li <wanpeng.li@linux.intel.com>
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      55141486
    • Jaegeuk Kim's avatar
      f2fs: support fs shutdown · 1abff93d
      Jaegeuk Kim authored
      This patch introduces a generic ioctl for fs shutdown, which was used by xfs.
      
      If this shutdown is triggered, filesystem stops any further IOs according to the
      following options.
      
      1. FS_GOING_DOWN_FULLSYNC
       : this will flush all the data and dentry blocks, and do checkpoint before
         shutdown.
      
      2. FS_GOING_DOWN_METASYNC
       : this will do checkpoint before shutdown.
      
      3. FS_GOING_DOWN_NOSYNC
       : this will trigger shutdown as is.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      1abff93d
  2. 03 Mar, 2015 21 commits
    • Jaegeuk Kim's avatar
      f2fs: avoid wrong error during recovery · 8fbc418f
      Jaegeuk Kim authored
      During the roll-forward recovery, -ENOENT for f2fs_iget can be skipped.
      So, this error value should not be propagated.
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      8fbc418f
    • Jaegeuk Kim's avatar
      f2fs: remove obsolete code · 1614091d
      Jaegeuk Kim authored
      This patch removes obsolete code in which summary variable is not needed.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      1614091d
    • Chao Yu's avatar
      f2fs: use extent cache for dir · cb3bc9ee
      Chao Yu authored
      We update extent cache for all user inode of f2fs including dir inode, so this
      patch gives another chance to try to get physical address of page from extent
      cache for dir inode.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      cb3bc9ee
    • Chao Yu's avatar
      f2fs: switch to check FI_NO_EXTENT in f2fs_{lookup,update}_extent_cache · 91c5d9bc
      Chao Yu authored
      This patch switch to check FI_NO_EXTENT in f2fs_{lookup,update}_extent_cache
      instead of f2fs_{lookup,update}_extent_tree or {lookup,update}_extent_info.
      
      No functionality modification in this patch.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      91c5d9bc
    • Chao Yu's avatar
      f2fs: support fast lookup in extent cache · 62c8af65
      Chao Yu authored
      This patch adds a fast lookup path for rb-tree extent cache.
      
      In this patch we add a recently accessed extent node pointer 'cached_en' in
      extent tree. In lookup path of extent cache, we will firstly lookup the last
      accessed extent node which cached_en points, if we do not hit in this node,
      we will try to lookup extent node in rb-tree.
      
      By this way we can avoid unnecessary slow lookup in rb-tree sometimes.
      
      Note that, side-effect of this patch is that we will increase memory cost,
      because we will store a pointer variable in each struct extent tree
      additionally.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      62c8af65
    • Chao Yu's avatar
      f2fs: add trace for rb-tree extent cache ops · 1ec4610c
      Chao Yu authored
      This patch adds trace for lookup/update/shrink/destroy ops in rb-tree extent cache.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      1ec4610c
    • Chao Yu's avatar
      f2fs: show extent tree, node stat info in debugfs · 4bf6fd9f
      Chao Yu authored
      This patch add and show stat info of total memory footprint for extent tree,node
      in debugfs.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      4bf6fd9f
    • Chao Yu's avatar
      f2fs: enable rb-tree extent cache · 1dcc336b
      Chao Yu authored
      This patch enables rb-tree based extent cache in f2fs.
      
      When we mount with "-o extent_cache", f2fs will try to add recently accessed
      page-block mappings into rb-tree based extent cache as much as possible, instead
      of original one extent info cache.
      
      By this way, f2fs can support more effective cache between dnode page cache and
      disk. It will supply high hit ratio in the cache with fewer memory when dnode
      page cache are reclaimed in environment of low memory.
      
      Storage: Sandisk sd card 64g
      1.append write file (offset: 0, size: 128M);
      2.override write file (offset: 2M, size: 1M);
      3.override write file (offset: 4M, size: 1M);
      ...
      4.override write file (offset: 48M, size: 1M);
      ...
      5.override write file (offset: 112M, size: 1M);
      6.sync
      7.echo 3 > /proc/sys/vm/drop_caches
      8.read file (size:128M, unit: 4k, count: 32768)
      (time dd if=/mnt/f2fs/128m bs=4k count=32768)
      
      Extent Hit Ratio:
      		before		patched
      Hit Ratio	121 / 1071	1071 / 1071
      
      Performance:
      		before		patched
      real    	0m37.051s	0m35.556s
      user    	0m0.040s	0m0.026s
      sys     	0m2.990s	0m2.251s
      
      Memory Cost:
      		before		patched
      Tree Count:	0		1 (size: 24 bytes)
      Node Count:	0		45 (size: 1440 bytes)
      
      v3:
       o retest and given more details of test result.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      1dcc336b
    • Chao Yu's avatar
      f2fs: add a mount option for rb-tree extent cache · 89672159
      Chao Yu authored
      This patch adds a mount option 'extent_cache' in f2fs.
      
      It is try to use a rb-tree based extent cache to cache more mapping information
      with less memory if this option is set, otherwise we will use the original one
      extent info cache.
      Suggested-by: default avatarChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      89672159
    • Chao Yu's avatar
      f2fs: add core functions for rb-tree extent cache · 429511cd
      Chao Yu authored
      This patch adds core functions including slab cache init function and
      init/lookup/update/shrink/destroy function for rb-tree based extent cache.
      
      Thank Jaegeuk Kim and Changman Lee as they gave much suggestion about detail
      design and implementation of extent cache.
      
      Todo:
       * register rb-based extent cache shrink with mm shrink interface.
      
      v2:
       o move set_extent_info and __is_{extent,back,front}_mergeable into f2fs.h.
       o introduce __{attach,detach}_extent_node for code readability.
       o add cond_resched() when fail to invoke kmem_cache_alloc/radix_tree_insert.
       o fix some coding style and typo issues.
      
      v3:
       o fix oops due to using an unassigned pointer.
       o use list_del to remove extent node in shrink list.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarChangman Lee <cm224.lee@samsung.com>
      [Jaegeuk Kim: add static for some funcitons and declare in f2fs.h]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      429511cd
    • Chao Yu's avatar
      f2fs: introduce infra macro and data structure of rb-tree extent cache · 13054c54
      Chao Yu authored
      Introduce infra macro and data structure for rb-tree based extent cache:
      
      Macros:
       * EXT_TREE_VEC_SIZE: indicate vector size for gang lookup in extent tree.
       * F2FS_MIN_EXTENT_LEN: indicate minimum length of extent managed in cache.
       * EXTENT_CACHE_SHRINK_NUMBER: indicate number of extent in cache will be shrunk.
      
      Basic data structures for extent cache:
       * struct extent_tree: extent tree entry per inode.
       * struct extent_node: extent info node linked in extent tree.
      
      Besides, adding new extent cache related fields in f2fs_sb_info.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      13054c54
    • Chao Yu's avatar
      f2fs: introduce universal lookup/update interface for extent cache · 7e4dde79
      Chao Yu authored
      In this patch, we do these jobs:
      1. rename {check,update}_extent_cache to {lookup,update}_extent_info;
      2. introduce universal lookup/update interface of extent cache:
      f2fs_{lookup,update}_extent_cache including above two real functions, then
      export them to function callers.
      
      So after above cleanup, we can add new rb-tree based extent cache into exported
      interfaces.
      
      v2:
       o remove "f2fs_" for inner function {lookup,update}_extent_info suggested by
         Jaegeuk Kim.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7e4dde79
    • Chao Yu's avatar
      f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache · a2e7d1bf
      Chao Yu authored
      This patch introduces f2fs_map_bh to clean codes of check_extent_cache.
      
      v2:
       o cleanup f2fs_map_bh pointed out by Jaegeuk Kim.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      a2e7d1bf
    • Chao Yu's avatar
      f2fs: simplfy a field name in struct f2fs_extent,extent_info · 4d0b0bd4
      Chao Yu authored
      Rename a filed name from 'blk_addr' to 'blk' in struct {f2fs_extent,extent_info}
      as annotation of this field descripts its meaning well to us.
      
      By this way, we can avoid long statement in code of following patches.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      4d0b0bd4
    • Chao Yu's avatar
      f2fs: move ext_lock out of struct extent_info · 0c872e2d
      Chao Yu authored
      Move ext_lock out of struct extent_info, then in the following patches we can
      use variables with struct extent_info type as a parameter to pass pure data.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0c872e2d
    • Chao Yu's avatar
      f2fs: fix incorrectly stat number of inline data inode · 3c0d84d6
      Chao Yu authored
      We should stat inline data information for temp file in f2fs_tmpfile if we
      enable inline_data feature.
      
      Otherwise, inline data stat number will be wrong after this temp file is
      evicted.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      3c0d84d6
    • Chao Yu's avatar
      f2fs: use ->writepage in sync_meta_pages · 97dc3fd2
      Chao Yu authored
      This patch uses ->writepage of meta mapping in sync_meta_pages instead of
      f2fs_write_meta_page, by this way, in its caller we can ignore any changes
      (e.g. changing name) of this registered function.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      97dc3fd2
    • Chao Yu's avatar
      f2fs: introduce f2fs_update_dentry to clean up duplicated codes · 3b4d732a
      Chao Yu authored
      This patch introduces f2fs_update_dentry to remove redundant code in
      f2fs_add_inline_entry and __f2fs_add_link.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      3b4d732a
    • Chao Yu's avatar
      f2fs: remove unused inline_dentry_addr · 1753396a
      Chao Yu authored
      inline_dentry_addr is introduced with inline dentry feature without being used,
      now we do not need to keep it for any reason, so remove it.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      1753396a
    • Linus Torvalds's avatar
      Linux 4.0-rc2 · 13a7a6ac
      Linus Torvalds authored
      13a7a6ac
    • Daniel Vetter's avatar
      drm/i915: Fix modeset state confusion in the load detect code · 9128b040
      Daniel Vetter authored
      This is a tricky story of the new atomic state handling and the legacy
      code fighting over each another. The bug at hand is an underrun of the
      framebuffer reference with subsequent hilarity caused by the load
      detect code. Which is peculiar since the the exact same code works
      fine as the implementation of the legacy setcrtc ioctl.
      
      Let's look at the ingredients:
      
      - Currently our code is a crazy mix of legacy modeset interfaces to
        set the parameters and half-baked atomic state tracking underneath.
        While this transition is going we're using the transitional plane
        helpers to update the atomic side (drm_plane_helper_disable/update
        and friends), i.e. plane->state->fb. Since the state structure owns
        the fb those functions take care of that themselves.
      
        The legacy state (specifically crtc->primary->fb) is still managed
        by the old code (and mostly by the drm core), with the fb reference
        counting done by callers (core drm for the ioctl or the i915 load
        detect code). The relevant commit is
      
        commit ea2c67bb
        Author: Matt Roper <matthew.d.roper@intel.com>
        Date:   Tue Dec 23 10:41:52 2014 -0800
      
            drm/i915: Move to atomic plane helpers (v9)
      
      - drm_plane_helper_disable has special code to handle multiple calls
        in a row - it checks plane->crtc == NULL and bails out. This is to
        match the proper atomic implementation which needs the crtc to get
        at the implied locking context atomic updates always need. See
      
        commit acf24a39
        Author: Daniel Vetter <daniel.vetter@ffwll.ch>
        Date:   Tue Jul 29 15:33:05 2014 +0200
      
            drm/plane-helper: transitional atomic plane helpers
      
      - The universal plane code split out the implicit primary plane from
        the CRTC into it's own full-blown drm_plane object. As part of that
        the setcrtc ioctl (which updated both the crtc mode and primary
        plane) learned to set crtc->primary->crtc on modeset to make sure
        the plane->crtc assignments statate up to date in
      
        commit e13161af
        Author: Matt Roper <matthew.d.roper@intel.com>
        Date:   Tue Apr 1 15:22:38 2014 -0700
      
            drm: Add drm_crtc_init_with_planes() (v2)
      
        Unfortunately we've forgotten to update the load detect code. Which
        wasn't a problem since the load detect modeset is temporary and
        always undone before we drop the locks.
      
      - Finally there is a organically grown history (i.e. don't ask) around
        who sets the legacy plane->fb for the various driver entry points.
        Originally updating that was the drivers duty, but for almost all
        places we've moved that (plus updating the refcounts) into the core.
        Again the exception is the load detect code.
      
      Taking all together the following happens:
      - The load detect code doesn't set crtc->primary->crtc. This is only
        really an issue on crtcs never before used or when userspace
        explicitly disabled the primary plane.
      
      - The plane helper glue code short-circuits because of that and leaves
        a non-NULL fb behind in plane->state->fb and plane->fb. The state
        fb isn't a real problem (it's properly refcounted on its own), it's
        just the canary.
      
      - Load detect code drops the reference for that fb, but doesn't set
        plane->fb = NULL. This is ok since it's still living in that old
        world where drivers had to clear the pointer but the core/callers
        handled the refcounting.
      
      - On the next modeset the drm core notices plane->fb and takes care of
        refcounting it properly by doing another unref. This drops the
        refcount to zero, leaving state->plane now pointing at freed memory.
      
      - intel_plane_duplicate_state still assume it owns a reference to that
        very state->fb and bad things start to happen.
      
      Fix this all by applying the same duct-tape as for the legacy setcrtc
      ioctl code and set crtc->primary->crtc properly.
      
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Paul Bolle <pebolle@tiscali.nl>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Paulo Zanoni <przanoni@gmail.com>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Reported-and-tested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Reported-by: default avatarPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9128b040
  3. 02 Mar, 2015 4 commits
    • Linus Torvalds's avatar
      Merge tag 'gpio-v4.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio · 023a6007
      Linus Torvalds authored
      Pull GPIO fixes from Linus Walleij:
       "Two GPIO fixes:
      
         - Fix a translation problem in of_get_named_gpiod_flags()
      
         - Fix a long standing container_of() mistake in the TPS65912 driver"
      
      * tag 'gpio-v4.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
        gpio: tps65912: fix wrong container_of arguments
        gpiolib: of: allow of_gpiochip_find_and_xlate to find more than one chip per node
      023a6007
    • Linus Torvalds's avatar
      Merge branch 'fixes-for-4.0-rc2' of... · 10d6dfc1
      Linus Torvalds authored
      Merge branch 'fixes-for-4.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal
      
      Pull thermal management fixes from Eduardo Valentin:
       "Specifics:
      
         - Several fixes in tmon tool.
      
         - Fixes in intel int340x for _ART and _TRT tables.
      
         - Add id for Avoton SoC into powerclamp driver.
      
         - Fixes in RCAR thermal driver to remove race conditions and fix fail
           path
      
         - Fixes in TI thermal driver: removal of unnecessary code and build
           fix if !CONFIG_PM_SLEEP
      
         - Cleanups in exynos thermal driver
      
         - Add stubs for include/linux/thermal.h.  Now drivers using thermal
           calls but that also work without CONFIG_THERMAL will be able to
           compile for systems that don't care about thermal.
      
        Note: I am sending this pull on Rui's behalf while he fixes issues in
        his Linux box"
      
      * 'fixes-for-4.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal:
        thermal: int340x_thermal: Ignore missing _ART, _TRT tables
        thermal/intel_powerclamp: add id for Avoton SoC
        tools/thermal: tmon: silence 'set but not used' warnings
        tools/thermal: tmon: use pkg-config to determine library dependencies
        tools/thermal: tmon: support cross-compiling
        tools/thermal: tmon: add .gitignore
        tools/thermal: tmon: fixup tui windowing calculations
        tools/thermal: tmon: tui: don't hard-code dialog window size assumptions
        tools/thermal: tmon: add min/max macros
        tools/thermal: tmon: add --target-temp parameter
        thermal: exynos: Clean-up code to use oneline entry for exynos compatible table
        thermal: rcar: Make error and remove paths symmetrical with init
        thermal: rcar: Fix race condition between init and interrupt
        thermal: Introduce dummy functions when thermal is not defined
        ti-soc-thermal: Delete an unnecessary check before the function call "cpufreq_cooling_unregister"
        thermal: ti-soc-thermal: bandgap: Fix build warning if !CONFIG_PM_SLEEP
      10d6dfc1
    • Linus Torvalds's avatar
      Merge tag 'md/4.0-fixes' of git://neil.brown.name/md · 1a6f77ab
      Linus Torvalds authored
      Pull md fixes from Neil Brown:
       "Three md fixes:
      
         - fix a read-balance problem that was reported 2 years ago, but that
           I never noticed the report :-(
      
         - fix for rare RAID6 problem causing incorrect bitmap updates when
           two devices fail.
      
         - add __ATTR_PREALLOC annotation now that it is possible"
      
      * tag 'md/4.0-fixes' of git://neil.brown.name/md:
        md: mark some attributes as pre-alloc
        raid5: check faulty flag for array status during recovery.
        md/raid1: fix read balance when a drive is write-mostly.
      1a6f77ab
    • Linus Torvalds's avatar
      Merge tag 'metag-fixes-v4.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag · 49db1f0e
      Linus Torvalds authored
      Pull arch/metag fix from James Hogan:
       "This is just a single patch to fix the KSTK_EIP() and KSTK_ESP()
        macros for metag which have always been erronously returning the PC
        and stack pointer of the task's kernel context rather than from its
        user context saved at entry from userland into the kernel, which
        affects the contents of /proc/<pid>/maps and /proc/<pid>/stat"
      
      * tag 'metag-fixes-v4.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag:
        metag: Fix KSTK_EIP() and KSTK_ESP() macros
      49db1f0e
  4. 01 Mar, 2015 4 commits