From: Greg Kroah-Hartman Date: Wed, 4 Jan 2017 09:38:59 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v4.9.1~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a99486c49282cf322676fe4d550bfd190a7d4bc;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: btrfs-bail-out-if-block-group-has-different-mixed-flag.patch btrfs-don-t-bug-during-drop-snapshot.patch btrfs-don-t-leak-reloc-root-nodes-on-error.patch btrfs-fix-memory-leak-in-do_walk_down.patch btrfs-fix-memory-leak-in-reading-btree-blocks.patch btrfs-make-file-clone-aware-of-fatal-signals.patch btrfs-return-gracefully-from-balance-if-fs-tree-is-corrupted.patch clk-ti-omap36xx-work-around-sprz319-advisory-2.1.patch --- diff --git a/queue-4.4/btrfs-bail-out-if-block-group-has-different-mixed-flag.patch b/queue-4.4/btrfs-bail-out-if-block-group-has-different-mixed-flag.patch new file mode 100644 index 00000000000..ee8d022c93c --- /dev/null +++ b/queue-4.4/btrfs-bail-out-if-block-group-has-different-mixed-flag.patch @@ -0,0 +1,62 @@ +From 49303381f19ab16a371a061b67e783d3f570d56e Mon Sep 17 00:00:00 2001 +From: Liu Bo +Date: Thu, 25 Aug 2016 18:08:27 -0700 +Subject: Btrfs: bail out if block group has different mixed flag + +From: Liu Bo + +commit 49303381f19ab16a371a061b67e783d3f570d56e upstream. + +Currently we allow inconsistence about mixed flag + (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA). + +We'd get ENOSPC if block group has mixed flag and btrfs doesn't. +If that happens, we have one space_info with mixed flag and another +space_info only with BTRFS_BLOCK_GROUP_METADATA, and +global_block_rsv.space_info points to the latter one, but all bytes +from block_group contributes to the mixed space_info, thus all the +allocation will fail with ENOSPC. + +This adds a check for the above case. + +Reported-by: Vegard Nossum +Signed-off-by: Liu Bo +[ updated message ] +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/extent-tree.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +--- a/fs/btrfs/extent-tree.c ++++ b/fs/btrfs/extent-tree.c +@@ -9686,6 +9686,11 @@ int btrfs_read_block_groups(struct btrfs + struct extent_buffer *leaf; + int need_clear = 0; + u64 cache_gen; ++ u64 feature; ++ int mixed; ++ ++ feature = btrfs_super_incompat_flags(info->super_copy); ++ mixed = !!(feature & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS); + + root = info->extent_root; + key.objectid = 0; +@@ -9739,6 +9744,15 @@ int btrfs_read_block_groups(struct btrfs + btrfs_item_ptr_offset(leaf, path->slots[0]), + sizeof(cache->item)); + cache->flags = btrfs_block_group_flags(&cache->item); ++ if (!mixed && ++ ((cache->flags & BTRFS_BLOCK_GROUP_METADATA) && ++ (cache->flags & BTRFS_BLOCK_GROUP_DATA))) { ++ btrfs_err(info, ++"bg %llu is a mixed block group but filesystem hasn't enabled mixed block groups", ++ cache->key.objectid); ++ ret = -EINVAL; ++ goto error; ++ } + + key.objectid = found_key.objectid + found_key.offset; + btrfs_release_path(path); diff --git a/queue-4.4/btrfs-don-t-bug-during-drop-snapshot.patch b/queue-4.4/btrfs-don-t-bug-during-drop-snapshot.patch new file mode 100644 index 00000000000..9d3668f0087 --- /dev/null +++ b/queue-4.4/btrfs-don-t-bug-during-drop-snapshot.patch @@ -0,0 +1,98 @@ +From 4867268c57ff709a7b6b86ae6f6537d846d1443a Mon Sep 17 00:00:00 2001 +From: Josef Bacik +Date: Fri, 23 Sep 2016 13:23:28 +0200 +Subject: Btrfs: don't BUG() during drop snapshot + +From: Josef Bacik + +commit 4867268c57ff709a7b6b86ae6f6537d846d1443a upstream. + +Really there's lots of things that can go wrong here, kill all the +BUG_ON()'s and replace the logic ones with ASSERT()'s and return EIO +instead. + +Signed-off-by: Josef Bacik +[ switched to btrfs_err, errors go to common label ] +Reviewed-by: Liu Bo +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/extent-tree.c | 38 +++++++++++++++++++++++++++----------- + 1 file changed, 27 insertions(+), 11 deletions(-) + +--- a/fs/btrfs/extent-tree.c ++++ b/fs/btrfs/extent-tree.c +@@ -8486,15 +8486,13 @@ static noinline int do_walk_down(struct + ret = btrfs_lookup_extent_info(trans, root, bytenr, level - 1, 1, + &wc->refs[level - 1], + &wc->flags[level - 1]); +- if (ret < 0) { +- btrfs_tree_unlock(next); +- free_extent_buffer(next); +- return ret; +- } ++ if (ret < 0) ++ goto out_unlock; + + if (unlikely(wc->refs[level - 1] == 0)) { + btrfs_err(root->fs_info, "Missing references."); +- BUG(); ++ ret = -EIO; ++ goto out_unlock; + } + *lookup_info = 0; + +@@ -8546,7 +8544,12 @@ static noinline int do_walk_down(struct + } + + level--; +- BUG_ON(level != btrfs_header_level(next)); ++ ASSERT(level == btrfs_header_level(next)); ++ if (level != btrfs_header_level(next)) { ++ btrfs_err(root->fs_info, "mismatched level"); ++ ret = -EIO; ++ goto out_unlock; ++ } + path->nodes[level] = next; + path->slots[level] = 0; + path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING; +@@ -8561,8 +8564,15 @@ skip: + if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) { + parent = path->nodes[level]->start; + } else { +- BUG_ON(root->root_key.objectid != ++ ASSERT(root->root_key.objectid == + btrfs_header_owner(path->nodes[level])); ++ if (root->root_key.objectid != ++ btrfs_header_owner(path->nodes[level])) { ++ btrfs_err(root->fs_info, ++ "mismatched block owner"); ++ ret = -EIO; ++ goto out_unlock; ++ } + parent = 0; + } + +@@ -8579,12 +8589,18 @@ skip: + } + ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent, + root->root_key.objectid, level - 1, 0); +- BUG_ON(ret); /* -ENOMEM */ ++ if (ret) ++ goto out_unlock; + } ++ ++ *lookup_info = 1; ++ ret = 1; ++ ++out_unlock: + btrfs_tree_unlock(next); + free_extent_buffer(next); +- *lookup_info = 1; +- return 1; ++ ++ return ret; + } + + /* diff --git a/queue-4.4/btrfs-don-t-leak-reloc-root-nodes-on-error.patch b/queue-4.4/btrfs-don-t-leak-reloc-root-nodes-on-error.patch new file mode 100644 index 00000000000..7bed9cba485 --- /dev/null +++ b/queue-4.4/btrfs-don-t-leak-reloc-root-nodes-on-error.patch @@ -0,0 +1,35 @@ +From 6bdf131fac2336adb1a628f992ba32384f653a55 Mon Sep 17 00:00:00 2001 +From: Josef Bacik +Date: Fri, 2 Sep 2016 15:25:43 -0400 +Subject: Btrfs: don't leak reloc root nodes on error + +From: Josef Bacik + +commit 6bdf131fac2336adb1a628f992ba32384f653a55 upstream. + +We don't track the reloc roots in any sort of normal way, so the only way the +root/commit_root nodes get free'd is if the relocation finishes successfully and +the reloc root is deleted. Fix this by free'ing them in free_reloc_roots. +Thanks, + +Signed-off-by: Josef Bacik +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/relocation.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/fs/btrfs/relocation.c ++++ b/fs/btrfs/relocation.c +@@ -2350,6 +2350,10 @@ void free_reloc_roots(struct list_head * + while (!list_empty(list)) { + reloc_root = list_entry(list->next, struct btrfs_root, + root_list); ++ free_extent_buffer(reloc_root->node); ++ free_extent_buffer(reloc_root->commit_root); ++ reloc_root->node = NULL; ++ reloc_root->commit_root = NULL; + __del_reloc_root(reloc_root); + } + } diff --git a/queue-4.4/btrfs-fix-memory-leak-in-do_walk_down.patch b/queue-4.4/btrfs-fix-memory-leak-in-do_walk_down.patch new file mode 100644 index 00000000000..947165a7c0b --- /dev/null +++ b/queue-4.4/btrfs-fix-memory-leak-in-do_walk_down.patch @@ -0,0 +1,30 @@ +From a958eab0ed7fdc1b977bc25d3af6efedaa945488 Mon Sep 17 00:00:00 2001 +From: Liu Bo +Date: Tue, 13 Sep 2016 19:02:27 -0700 +Subject: Btrfs: fix memory leak in do_walk_down + +From: Liu Bo + +commit a958eab0ed7fdc1b977bc25d3af6efedaa945488 upstream. + +The extent buffer 'next' needs to be free'd conditionally. + +Signed-off-by: Liu Bo +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/extent-tree.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/fs/btrfs/extent-tree.c ++++ b/fs/btrfs/extent-tree.c +@@ -8488,6 +8488,7 @@ static noinline int do_walk_down(struct + &wc->flags[level - 1]); + if (ret < 0) { + btrfs_tree_unlock(next); ++ free_extent_buffer(next); + return ret; + } + diff --git a/queue-4.4/btrfs-fix-memory-leak-in-reading-btree-blocks.patch b/queue-4.4/btrfs-fix-memory-leak-in-reading-btree-blocks.patch new file mode 100644 index 00000000000..fc1d34b3413 --- /dev/null +++ b/queue-4.4/btrfs-fix-memory-leak-in-reading-btree-blocks.patch @@ -0,0 +1,79 @@ +From 2571e739677f1e4c0c63f5ed49adcc0857923625 Mon Sep 17 00:00:00 2001 +From: Liu Bo +Date: Wed, 3 Aug 2016 12:33:01 -0700 +Subject: Btrfs: fix memory leak in reading btree blocks + +From: Liu Bo + +commit 2571e739677f1e4c0c63f5ed49adcc0857923625 upstream. + +So we can read a btree block via readahead or intentional read, +and we can end up with a memory leak when something happens as +follows, +1) readahead starts to read block A but does not wait for read + completion, +2) btree_readpage_end_io_hook finds that block A is corrupted, + and it needs to clear all block A's pages' uptodate bit. +3) meanwhile an intentional read kicks in and checks block A's + pages' uptodate to decide which page needs to be read. +4) when some pages have the uptodate bit during 3)'s check so + 3) doesn't count them for eb->io_pages, but they are later + cleared by 2) so we has to readpage on the page, we get + the wrong eb->io_pages which results in a memory leak of + this block. + +This fixes the problem by firstly getting all pages's locking and +then checking pages' uptodate bit. + + t1(readahead) t2(readahead endio) t3(the following read) +read_extent_buffer_pages end_bio_extent_readpage + for pg in eb: for page 0,1,2 in eb: + if pg is uptodate: btree_readpage_end_io_hook(pg) + num_reads++ if uptodate: + eb->io_pages = num_reads SetPageUptodate(pg) _______________ + for pg in eb: for page 3 in eb: read_extent_buffer_pages + if pg is NOT uptodate: btree_readpage_end_io_hook(pg) for pg in eb: + __extent_read_full_page(pg) sanity check reports something wrong if pg is uptodate: + clear_extent_buffer_uptodate(eb) num_reads++ + for pg in eb: eb->io_pages = num_reads + ClearPageUptodate(page) _______________ + for pg in eb: + if pg is NOT uptodate: + __extent_read_full_page(pg) + +So t3's eb->io_pages is not consistent with the number of pages it's reading, +and during endio(), atomic_dec_and_test(&eb->io_pages) will get a negative +number so that we're not able to free the eb. + +Signed-off-by: Liu Bo +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/extent_io.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -5294,11 +5294,20 @@ int read_extent_buffer_pages(struct exte + lock_page(page); + } + locked_pages++; ++ } ++ /* ++ * We need to firstly lock all pages to make sure that ++ * the uptodate bit of our pages won't be affected by ++ * clear_extent_buffer_uptodate(). ++ */ ++ for (i = start_i; i < num_pages; i++) { ++ page = eb->pages[i]; + if (!PageUptodate(page)) { + num_reads++; + all_uptodate = 0; + } + } ++ + if (all_uptodate) { + if (start_i == 0) + set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); diff --git a/queue-4.4/btrfs-make-file-clone-aware-of-fatal-signals.patch b/queue-4.4/btrfs-make-file-clone-aware-of-fatal-signals.patch new file mode 100644 index 00000000000..28687dbe5fc --- /dev/null +++ b/queue-4.4/btrfs-make-file-clone-aware-of-fatal-signals.patch @@ -0,0 +1,35 @@ +From 69ae5e4459e43e56f03d0987e865fbac2b05af2a Mon Sep 17 00:00:00 2001 +From: Wang Xiaoguang +Date: Thu, 13 Oct 2016 09:23:39 +0800 +Subject: btrfs: make file clone aware of fatal signals + +From: Wang Xiaoguang + +commit 69ae5e4459e43e56f03d0987e865fbac2b05af2a upstream. + +Indeed this just make the behavior similar to xfs when process has +fatal signals pending, and it'll make fstests/generic/298 happy. + +Signed-off-by: Wang Xiaoguang +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/ioctl.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/fs/btrfs/ioctl.c ++++ b/fs/btrfs/ioctl.c +@@ -3825,6 +3825,11 @@ process_slot: + } + btrfs_release_path(path); + key.offset = next_key_min_offset; ++ ++ if (fatal_signal_pending(current)) { ++ ret = -EINTR; ++ goto out; ++ } + } + ret = 0; + diff --git a/queue-4.4/btrfs-return-gracefully-from-balance-if-fs-tree-is-corrupted.patch b/queue-4.4/btrfs-return-gracefully-from-balance-if-fs-tree-is-corrupted.patch new file mode 100644 index 00000000000..550a8641080 --- /dev/null +++ b/queue-4.4/btrfs-return-gracefully-from-balance-if-fs-tree-is-corrupted.patch @@ -0,0 +1,69 @@ +From 3561b9db70928f207be4570b48fc19898eeaef54 Mon Sep 17 00:00:00 2001 +From: Liu Bo +Date: Wed, 14 Sep 2016 08:51:46 -0700 +Subject: Btrfs: return gracefully from balance if fs tree is corrupted + +From: Liu Bo + +commit 3561b9db70928f207be4570b48fc19898eeaef54 upstream. + +When relocating tree blocks, we firstly get block information from +back references in the extent tree, we then search fs tree to try to +find all parents of a block. + +However, if fs tree is corrupted, eg. if there're some missing +items, we could come across these WARN_ONs and BUG_ONs. + +This makes us print some error messages and return gracefully +from balance. + +Signed-off-by: Liu Bo +Reviewed-by: Josef Bacik +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/relocation.c | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) + +--- a/fs/btrfs/relocation.c ++++ b/fs/btrfs/relocation.c +@@ -921,9 +921,16 @@ again: + path2->slots[level]--; + + eb = path2->nodes[level]; +- WARN_ON(btrfs_node_blockptr(eb, path2->slots[level]) != +- cur->bytenr); +- ++ if (btrfs_node_blockptr(eb, path2->slots[level]) != ++ cur->bytenr) { ++ btrfs_err(root->fs_info, ++ "couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)", ++ cur->bytenr, level - 1, root->objectid, ++ node_key->objectid, node_key->type, ++ node_key->offset); ++ err = -ENOENT; ++ goto out; ++ } + lower = cur; + need_check = true; + for (; level < BTRFS_MAX_LEVEL; level++) { +@@ -2676,11 +2683,15 @@ static int do_relocation(struct btrfs_tr + + if (!upper->eb) { + ret = btrfs_search_slot(trans, root, key, path, 0, 1); +- if (ret < 0) { +- err = ret; ++ if (ret) { ++ if (ret < 0) ++ err = ret; ++ else ++ err = -ENOENT; ++ ++ btrfs_release_path(path); + break; + } +- BUG_ON(ret > 0); + + if (!upper->eb) { + upper->eb = path->nodes[upper->level]; diff --git a/queue-4.4/clk-ti-omap36xx-work-around-sprz319-advisory-2.1.patch b/queue-4.4/clk-ti-omap36xx-work-around-sprz319-advisory-2.1.patch new file mode 100644 index 00000000000..a6bf47de918 --- /dev/null +++ b/queue-4.4/clk-ti-omap36xx-work-around-sprz319-advisory-2.1.patch @@ -0,0 +1,215 @@ +From 035cd485a47dda64f25ccf8a90b11a07d0b7aa7a Mon Sep 17 00:00:00 2001 +From: Richard Watts +Date: Fri, 2 Dec 2016 23:14:38 +0200 +Subject: clk: ti: omap36xx: Work around sprz319 advisory 2.1 + +From: Richard Watts + +commit 035cd485a47dda64f25ccf8a90b11a07d0b7aa7a upstream. + +The OMAP36xx DPLL5, driving EHCI USB, can be subject to a long-term +frequency drift. The frequency drift magnitude depends on the VCO update +rate, which is inversely proportional to the PLL divider. The kernel +DPLL configuration code results in a high value for the divider, leading +to a long term drift high enough to cause USB transmission errors. In +the worst case the USB PHY's ULPI interface can stop responding, +breaking USB operation completely. This manifests itself on the +Beagleboard xM by the LAN9514 reporting 'Cannot enable port 2. Maybe the +cable is bad?' in the kernel log. + +Errata sprz319 advisory 2.1 documents PLL values that minimize the +drift. Use them automatically when DPLL5 is used for USB operation, +which we detect based on the requested clock rate. The clock framework +will still compute the PLL parameters and resulting rate as usual, but +the PLL M and N values will then be overridden. This can result in the +effective clock rate being slightly different than the rate cached by +the clock framework, but won't cause any adverse effect to USB +operation. + +Signed-off-by: Richard Watts +[Upported from v3.2 to v4.9] +Signed-off-by: Laurent Pinchart +Tested-by: Ladislav Michl +Signed-off-by: Stephen Boyd +Cc: Adam Ford +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/clk/ti/clk-3xxx.c | 20 ++++++------- + drivers/clk/ti/clock.h | 9 ++++++ + drivers/clk/ti/dpll.c | 19 ++++++++++++- + drivers/clk/ti/dpll3xxx.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 104 insertions(+), 11 deletions(-) + +--- a/drivers/clk/ti/clk-3xxx.c ++++ b/drivers/clk/ti/clk-3xxx.c +@@ -22,13 +22,6 @@ + + #include "clock.h" + +-/* +- * DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks +- * that are sourced by DPLL5, and both of these require this clock +- * to be at 120 MHz for proper operation. +- */ +-#define DPLL5_FREQ_FOR_USBHOST 120000000 +- + #define OMAP3430ES2_ST_DSS_IDLE_SHIFT 1 + #define OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT 5 + #define OMAP3430ES2_ST_SSI_IDLE_SHIFT 8 +@@ -546,14 +539,21 @@ void __init omap3_clk_lock_dpll5(void) + struct clk *dpll5_clk; + struct clk *dpll5_m2_clk; + ++ /* ++ * Errata sprz319f advisory 2.1 documents a USB host clock drift issue ++ * that can be worked around using specially crafted dpll5 settings ++ * with a dpll5_m2 divider set to 8. Set the dpll5 rate to 8x the USB ++ * host clock rate, its .set_rate handler() will detect that frequency ++ * and use the errata settings. ++ */ + dpll5_clk = clk_get(NULL, "dpll5_ck"); +- clk_set_rate(dpll5_clk, DPLL5_FREQ_FOR_USBHOST); ++ clk_set_rate(dpll5_clk, OMAP3_DPLL5_FREQ_FOR_USBHOST * 8); + clk_prepare_enable(dpll5_clk); + +- /* Program dpll5_m2_clk divider for no division */ ++ /* Program dpll5_m2_clk divider */ + dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck"); + clk_prepare_enable(dpll5_m2_clk); +- clk_set_rate(dpll5_m2_clk, DPLL5_FREQ_FOR_USBHOST); ++ clk_set_rate(dpll5_m2_clk, OMAP3_DPLL5_FREQ_FOR_USBHOST); + + clk_disable_unprepare(dpll5_m2_clk); + clk_disable_unprepare(dpll5_clk); +--- a/drivers/clk/ti/clock.h ++++ b/drivers/clk/ti/clock.h +@@ -257,11 +257,20 @@ long omap2_dpll_round_rate(struct clk_hw + unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw, + unsigned long parent_rate); + ++/* ++ * OMAP3_DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks ++ * that are sourced by DPLL5, and both of these require this clock ++ * to be at 120 MHz for proper operation. ++ */ ++#define OMAP3_DPLL5_FREQ_FOR_USBHOST 120000000 ++ + unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate); + int omap3_dpll4_set_rate(struct clk_hw *clk, unsigned long rate, + unsigned long parent_rate); + int omap3_dpll4_set_rate_and_parent(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate, u8 index); ++int omap3_dpll5_set_rate(struct clk_hw *hw, unsigned long rate, ++ unsigned long parent_rate); + void omap3_clk_lock_dpll5(void); + + unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, +--- a/drivers/clk/ti/dpll.c ++++ b/drivers/clk/ti/dpll.c +@@ -114,6 +114,18 @@ static const struct clk_ops omap3_dpll_c + .round_rate = &omap2_dpll_round_rate, + }; + ++static const struct clk_ops omap3_dpll5_ck_ops = { ++ .enable = &omap3_noncore_dpll_enable, ++ .disable = &omap3_noncore_dpll_disable, ++ .get_parent = &omap2_init_dpll_parent, ++ .recalc_rate = &omap3_dpll_recalc, ++ .set_rate = &omap3_dpll5_set_rate, ++ .set_parent = &omap3_noncore_dpll_set_parent, ++ .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent, ++ .determine_rate = &omap3_noncore_dpll_determine_rate, ++ .round_rate = &omap2_dpll_round_rate, ++}; ++ + static const struct clk_ops omap3_dpll_per_ck_ops = { + .enable = &omap3_noncore_dpll_enable, + .disable = &omap3_noncore_dpll_disable, +@@ -461,7 +473,12 @@ static void __init of_ti_omap3_dpll_setu + .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), + }; + +- of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd); ++ if ((of_machine_is_compatible("ti,omap3630") || ++ of_machine_is_compatible("ti,omap36xx")) && ++ !strcmp(node->name, "dpll5_ck")) ++ of_ti_dpll_setup(node, &omap3_dpll5_ck_ops, &dd); ++ else ++ of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd); + } + CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock", + of_ti_omap3_dpll_setup); +--- a/drivers/clk/ti/dpll3xxx.c ++++ b/drivers/clk/ti/dpll3xxx.c +@@ -815,3 +815,70 @@ int omap3_dpll4_set_rate_and_parent(stru + return omap3_noncore_dpll_set_rate_and_parent(hw, rate, parent_rate, + index); + } ++ ++/* Apply DM3730 errata sprz319 advisory 2.1. */ ++static bool omap3_dpll5_apply_errata(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct omap3_dpll5_settings { ++ unsigned int rate, m, n; ++ }; ++ ++ static const struct omap3_dpll5_settings precomputed[] = { ++ /* ++ * From DM3730 errata advisory 2.1, table 35 and 36. ++ * The N value is increased by 1 compared to the tables as the ++ * errata lists register values while last_rounded_field is the ++ * real divider value. ++ */ ++ { 12000000, 80, 0 + 1 }, ++ { 13000000, 443, 5 + 1 }, ++ { 19200000, 50, 0 + 1 }, ++ { 26000000, 443, 11 + 1 }, ++ { 38400000, 25, 0 + 1 } ++ }; ++ ++ const struct omap3_dpll5_settings *d; ++ struct clk_hw_omap *clk = to_clk_hw_omap(hw); ++ struct dpll_data *dd; ++ unsigned int i; ++ ++ for (i = 0; i < ARRAY_SIZE(precomputed); ++i) { ++ if (parent_rate == precomputed[i].rate) ++ break; ++ } ++ ++ if (i == ARRAY_SIZE(precomputed)) ++ return false; ++ ++ d = &precomputed[i]; ++ ++ /* Update the M, N and rounded rate values and program the DPLL. */ ++ dd = clk->dpll_data; ++ dd->last_rounded_m = d->m; ++ dd->last_rounded_n = d->n; ++ dd->last_rounded_rate = div_u64((u64)parent_rate * d->m, d->n); ++ omap3_noncore_dpll_program(clk, 0); ++ ++ return true; ++} ++ ++/** ++ * omap3_dpll5_set_rate - set rate for omap3 dpll5 ++ * @hw: clock to change ++ * @rate: target rate for clock ++ * @parent_rate: rate of the parent clock ++ * ++ * Set rate for the DPLL5 clock. Apply the sprz319 advisory 2.1 on OMAP36xx if ++ * the DPLL is used for USB host (detected through the requested rate). ++ */ ++int omap3_dpll5_set_rate(struct clk_hw *hw, unsigned long rate, ++ unsigned long parent_rate) ++{ ++ if (rate == OMAP3_DPLL5_FREQ_FOR_USBHOST * 8) { ++ if (omap3_dpll5_apply_errata(hw, parent_rate)) ++ return 0; ++ } ++ ++ return omap3_noncore_dpll_set_rate(hw, rate, parent_rate); ++} diff --git a/queue-4.4/series b/queue-4.4/series index 436ba77a593..ea92807d004 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -17,3 +17,11 @@ alsa-hda-ignore-the-assoc-and-seq-when-comparing-pin-configurations.patch alsa-hda-fix-headset-mic-problem-on-a-dell-laptop.patch alsa-hda-gate-the-mic-jack-on-hp-z1-gen3-aio.patch alsa-hda-when-comparing-pin-configurations-ignore-assoc-in-addition-to-seq.patch +clk-ti-omap36xx-work-around-sprz319-advisory-2.1.patch +btrfs-fix-memory-leak-in-reading-btree-blocks.patch +btrfs-bail-out-if-block-group-has-different-mixed-flag.patch +btrfs-return-gracefully-from-balance-if-fs-tree-is-corrupted.patch +btrfs-don-t-leak-reloc-root-nodes-on-error.patch +btrfs-fix-memory-leak-in-do_walk_down.patch +btrfs-don-t-bug-during-drop-snapshot.patch +btrfs-make-file-clone-aware-of-fatal-signals.patch