036-net-mvneta-fix-trivial-cut-off-issue-in-mvneta_ethto.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From: Jisheng Zhang <jszhang@marvell.com>
  2. Date: Wed, 20 Jan 2016 16:36:25 +0800
  3. Subject: [PATCH] net: mvneta: fix trivial cut-off issue in
  4. mvneta_ethtool_update_stats
  5. When s->type is T_REG_64, the high 32bits are lost in val. This patch
  6. fixes this trivial issue.
  7. Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
  8. Fixes: 9b0cdefa4cd5 ("net: mvneta: add ethtool statistics")
  9. Signed-off-by: David S. Miller <davem@davemloft.net>
  10. ---
  11. --- a/drivers/net/ethernet/marvell/mvneta.c
  12. +++ b/drivers/net/ethernet/marvell/mvneta.c
  13. @@ -3244,26 +3244,25 @@ static void mvneta_ethtool_update_stats(
  14. const struct mvneta_statistic *s;
  15. void __iomem *base = pp->base;
  16. u32 high, low, val;
  17. + u64 val64;
  18. int i;
  19. for (i = 0, s = mvneta_statistics;
  20. s < mvneta_statistics + ARRAY_SIZE(mvneta_statistics);
  21. s++, i++) {
  22. - val = 0;
  23. -
  24. switch (s->type) {
  25. case T_REG_32:
  26. val = readl_relaxed(base + s->offset);
  27. + pp->ethtool_stats[i] += val;
  28. break;
  29. case T_REG_64:
  30. /* Docs say to read low 32-bit then high */
  31. low = readl_relaxed(base + s->offset);
  32. high = readl_relaxed(base + s->offset + 4);
  33. - val = (u64)high << 32 | low;
  34. + val64 = (u64)high << 32 | low;
  35. + pp->ethtool_stats[i] += val64;
  36. break;
  37. }
  38. -
  39. - pp->ethtool_stats[i] += val;
  40. }
  41. }