summaryrefslogtreecommitdiffstats
path: root/drivers/edac/altera_edac.c
diff options
context:
space:
mode:
authorRobert Richter <rrichter@marvell.com>2019-06-24 15:08:55 +0000
committerBorislav Petkov <bp@suse.de>2019-08-03 12:05:51 +0200
commit3724ace582d9f675134985727fd5e9811f23c059 (patch)
tree784cb7a16e46b0d37ddefca44fc96534b57ed267 /drivers/edac/altera_edac.c
parent3123c5c4ca157edc518102ee5385f60cb90f93f5 (diff)
downloadlinux-3724ace582d9f675134985727fd5e9811f23c059.tar.gz
linux-3724ace582d9f675134985727fd5e9811f23c059.tar.bz2
linux-3724ace582d9f675134985727fd5e9811f23c059.zip
EDAC/mc: Fix grain_bits calculation
The grain in EDAC is defined as "minimum granularity for an error report, in bytes". The following calculation of the grain_bits in edac_mc is wrong: grain_bits = fls_long(e->grain) + 1; Where grain_bits is defined as: grain = 1 << grain_bits Example: grain = 8 # 64 bit (8 bytes) grain_bits = fls_long(8) + 1 grain_bits = 4 + 1 = 5 grain = 1 << grain_bits grain = 1 << 5 = 32 Replace it with the correct calculation: grain_bits = fls_long(e->grain - 1); The example gives now: grain_bits = fls_long(8 - 1) grain_bits = fls_long(7) grain_bits = 3 grain = 1 << 3 = 8 Also, check if the hardware reports a reasonable grain != 0 and fallback with a warning to 1 byte granularity otherwise. [ bp: massage a bit. ] Signed-off-by: Robert Richter <rrichter@marvell.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org> Cc: James Morse <james.morse@arm.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Tony Luck <tony.luck@intel.com> Link: https://lkml.kernel.org/r/20190624150758.6695-2-rrichter@marvell.com
Diffstat (limited to 'drivers/edac/altera_edac.c')
0 files changed, 0 insertions, 0 deletions