From: Greg Kroah-Hartman Date: Fri, 17 Apr 2015 13:05:37 +0000 (+0200) Subject: 3.19-stable patches X-Git-Tag: v3.10.75~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17b5f38bcca90cf12db33dcdc62fae6e41825318;p=thirdparty%2Fkernel%2Fstable-queue.git 3.19-stable patches added patches: clk-divider-fix-calculation-of-maximal-parent-rate-for-a-given-divider.patch clk-divider-fix-selection-of-divider-when-rounding-to-closest.patch ib-mlx4-saturate-roce-port-pma-counters-in-case-of-overflow.patch --- diff --git a/queue-3.19/clk-divider-fix-calculation-of-maximal-parent-rate-for-a-given-divider.patch b/queue-3.19/clk-divider-fix-calculation-of-maximal-parent-rate-for-a-given-divider.patch new file mode 100644 index 00000000000..1bdb61e8900 --- /dev/null +++ b/queue-3.19/clk-divider-fix-calculation-of-maximal-parent-rate-for-a-given-divider.patch @@ -0,0 +1,64 @@ +From da321133b53caf7889ed3ca1dabe4cc368db2604 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= +Date: Sat, 21 Feb 2015 11:40:23 +0100 +Subject: clk: divider: fix calculation of maximal parent rate for a given divider +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= + +commit da321133b53caf7889ed3ca1dabe4cc368db2604 upstream. + +The rate provided at the output of a clk-divider is calculated as: + + DIV_ROUND_UP(parent_rate, div) + +since commit b11d282dbea2 (clk: divider: fix rate calculation for +fractional rates). So to yield a rate not bigger than r parent_rate +must be <= r * div. + +The effect of choosing a parent rate that is too big as was done before +this patch results in wrongly ruling out good dividers. + +Note that this is not a complete fix as __clk_round_rate might return a +value >= its 2nd parameter. Also for dividers with +CLK_DIVIDER_ROUND_CLOSEST set the calculation is not accurate. But this +fixes the test case by Sascha Hauer that uses a chain of three dividers +under a fixed clock. + +Fixes: b11d282dbea2 (clk: divider: fix rate calculation for fractional rates) +Suggested-by: Sascha Hauer +Signed-off-by: Uwe Kleine-König +Acked-by: Sascha Hauer +Signed-off-by: Michael Turquette +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/clk/clk-divider.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +--- a/drivers/clk/clk-divider.c ++++ b/drivers/clk/clk-divider.c +@@ -129,12 +129,6 @@ static unsigned long clk_divider_recalc_ + return DIV_ROUND_UP(parent_rate, div); + } + +-/* +- * The reverse of DIV_ROUND_UP: The maximum number which +- * divided by m is r +- */ +-#define MULT_ROUND_UP(r, m) ((r) * (m) + (m) - 1) +- + static bool _is_valid_table_div(const struct clk_div_table *table, + unsigned int div) + { +@@ -304,7 +298,7 @@ static int clk_divider_bestdiv(struct cl + return i; + } + parent_rate = __clk_round_rate(__clk_get_parent(hw->clk), +- MULT_ROUND_UP(rate, i)); ++ rate * i); + now = DIV_ROUND_UP(parent_rate, i); + if (_is_best_div(divider, rate, now, best)) { + bestdiv = i; diff --git a/queue-3.19/clk-divider-fix-selection-of-divider-when-rounding-to-closest.patch b/queue-3.19/clk-divider-fix-selection-of-divider-when-rounding-to-closest.patch new file mode 100644 index 00000000000..27e9b224bc8 --- /dev/null +++ b/queue-3.19/clk-divider-fix-selection-of-divider-when-rounding-to-closest.patch @@ -0,0 +1,54 @@ +From 26bac95aa88c2b1747808c0b885abe7814c0165d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= +Date: Sat, 21 Feb 2015 11:40:24 +0100 +Subject: clk: divider: fix selection of divider when rounding to closest +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= + +commit 26bac95aa88c2b1747808c0b885abe7814c0165d upstream. + +It's an invalid approach to assume that among two divider values +the one nearer the exact divider is the better one. + +Assume a parent rate of 1000 Hz, a divider with CLK_DIVIDER_POWER_OF_TWO +and a target rate of 89 Hz. The exact divider is ~ 11.236 so 8 and 16 +are the candidates to choose from yielding rates 125 Hz and 62.5 Hz +respectivly. While 8 is nearer to 11.236 than 16 is, the latter is still +the better divider as 62.5 is nearer to 89 than 125 is. + +Fixes: 774b514390b1 (clk: divider: Add round to closest divider) +Signed-off-by: Uwe Kleine-König +Acked-by: Sascha Hauer +Acked-by: Maxime Coquelin +Signed-off-by: Michael Turquette +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/clk/clk-divider.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/clk/clk-divider.c ++++ b/drivers/clk/clk-divider.c +@@ -208,6 +208,7 @@ static int _div_round_closest(struct clk + unsigned long parent_rate, unsigned long rate) + { + int up, down, div; ++ unsigned long up_rate, down_rate; + + up = down = div = DIV_ROUND_CLOSEST(parent_rate, rate); + +@@ -219,7 +220,10 @@ static int _div_round_closest(struct clk + down = _round_down_table(divider->table, div); + } + +- return (up - div) <= (div - down) ? up : down; ++ up_rate = DIV_ROUND_UP(parent_rate, up); ++ down_rate = DIV_ROUND_UP(parent_rate, down); ++ ++ return (rate - up_rate) <= (down_rate - rate) ? up : down; + } + + static int _div_round(struct clk_divider *divider, unsigned long parent_rate, diff --git a/queue-3.19/ib-mlx4-saturate-roce-port-pma-counters-in-case-of-overflow.patch b/queue-3.19/ib-mlx4-saturate-roce-port-pma-counters-in-case-of-overflow.patch new file mode 100644 index 00000000000..5f4e69969a7 --- /dev/null +++ b/queue-3.19/ib-mlx4-saturate-roce-port-pma-counters-in-case-of-overflow.patch @@ -0,0 +1,61 @@ +From 61a3855bb726cbb062ef02a31a832dea455456e0 Mon Sep 17 00:00:00 2001 +From: Majd Dibbiny +Date: Wed, 18 Mar 2015 16:51:37 +0200 +Subject: IB/mlx4: Saturate RoCE port PMA counters in case of overflow + +From: Majd Dibbiny + +commit 61a3855bb726cbb062ef02a31a832dea455456e0 upstream. + +For RoCE ports, we set the u32 PMA values based on u64 HCA counters. In case of +overflow, according to the IB spec, we have to saturate a counter to its +max value, do that. + +Fixes: c37791349cc7 ('IB/mlx4: Support PMA counters for IBoE') +Signed-off-by: Majd Dibbiny +Signed-off-by: Eran Ben Elisha +Signed-off-by: Hadar Hen Zion +Signed-off-by: Or Gerlitz +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/infiniband/hw/mlx4/mad.c | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +--- a/drivers/infiniband/hw/mlx4/mad.c ++++ b/drivers/infiniband/hw/mlx4/mad.c +@@ -64,6 +64,14 @@ enum { + #define GUID_TBL_BLK_NUM_ENTRIES 8 + #define GUID_TBL_BLK_SIZE (GUID_TBL_ENTRY_SIZE * GUID_TBL_BLK_NUM_ENTRIES) + ++/* Counters should be saturate once they reach their maximum value */ ++#define ASSIGN_32BIT_COUNTER(counter, value) do {\ ++ if ((value) > U32_MAX) \ ++ counter = cpu_to_be32(U32_MAX); \ ++ else \ ++ counter = cpu_to_be32(value); \ ++} while (0) ++ + struct mlx4_mad_rcv_buf { + struct ib_grh grh; + u8 payload[256]; +@@ -806,10 +814,14 @@ static int ib_process_mad(struct ib_devi + static void edit_counter(struct mlx4_counter *cnt, + struct ib_pma_portcounters *pma_cnt) + { +- pma_cnt->port_xmit_data = cpu_to_be32((be64_to_cpu(cnt->tx_bytes)>>2)); +- pma_cnt->port_rcv_data = cpu_to_be32((be64_to_cpu(cnt->rx_bytes)>>2)); +- pma_cnt->port_xmit_packets = cpu_to_be32(be64_to_cpu(cnt->tx_frames)); +- pma_cnt->port_rcv_packets = cpu_to_be32(be64_to_cpu(cnt->rx_frames)); ++ ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data, ++ (be64_to_cpu(cnt->tx_bytes) >> 2)); ++ ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data, ++ (be64_to_cpu(cnt->rx_bytes) >> 2)); ++ ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets, ++ be64_to_cpu(cnt->tx_frames)); ++ ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets, ++ be64_to_cpu(cnt->rx_frames)); + } + + static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, diff --git a/queue-3.19/series b/queue-3.19/series index d24fefeb2db..b7f3d42e24e 100644 --- a/queue-3.19/series +++ b/queue-3.19/series @@ -91,3 +91,6 @@ cx23885-fix-querycap.patch soc-camera-fix-devm_kfree-in-soc_of_bind.patch vb2-fix-dma_dir-setting-for-dma-contig-mem-type.patch vb2-fix-unbalanced-warnings-when-calling-vb2_thread_stop.patch +clk-divider-fix-selection-of-divider-when-rounding-to-closest.patch +clk-divider-fix-calculation-of-maximal-parent-rate-for-a-given-divider.patch +ib-mlx4-saturate-roce-port-pma-counters-in-case-of-overflow.patch