]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2015 13:05:37 +0000 (15:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2015 13:05:37 +0000 (15:05 +0200)
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

queue-3.19/clk-divider-fix-calculation-of-maximal-parent-rate-for-a-given-divider.patch [new file with mode: 0644]
queue-3.19/clk-divider-fix-selection-of-divider-when-rounding-to-closest.patch [new file with mode: 0644]
queue-3.19/ib-mlx4-saturate-roce-port-pma-counters-in-case-of-overflow.patch [new file with mode: 0644]
queue-3.19/series

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 (file)
index 0000000..1bdb61e
--- /dev/null
@@ -0,0 +1,64 @@
+From da321133b53caf7889ed3ca1dabe4cc368db2604 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+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?= <u.kleine-koenig@pengutronix.de>
+
+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 <s.hauer@pengutronix.de>
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
+Signed-off-by: Michael Turquette <mturquette@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..27e9b22
--- /dev/null
@@ -0,0 +1,54 @@
+From 26bac95aa88c2b1747808c0b885abe7814c0165d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+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?= <u.kleine-koenig@pengutronix.de>
+
+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 <u.kleine-koenig@pengutronix.de>
+Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
+Acked-by: Maxime Coquelin <maxime.coquelin@st.com>
+Signed-off-by: Michael Turquette <mturquette@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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 (file)
index 0000000..5f4e699
--- /dev/null
@@ -0,0 +1,61 @@
+From 61a3855bb726cbb062ef02a31a832dea455456e0 Mon Sep 17 00:00:00 2001
+From: Majd Dibbiny <majd@mellanox.com>
+Date: Wed, 18 Mar 2015 16:51:37 +0200
+Subject: IB/mlx4: Saturate RoCE port PMA counters in case of overflow
+
+From: Majd Dibbiny <majd@mellanox.com>
+
+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 <majd@mellanox.com>
+Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
+Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
+Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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,
index d24fefeb2dbefccc3692e41f1c2f286be6e2b969..b7f3d42e24ed505d54fc745f9366677364fa5b84 100644 (file)
@@ -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