[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190803100837.GB2100@zn.tnic>
Date: Sat, 3 Aug 2019 12:08:37 +0200
From: Borislav Petkov <bp@...en8.de>
To: Robert Richter <rrichter@...vell.com>
Cc: James Morse <james.morse@....com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
"linux-edac@...r.kernel.org" <linux-edac@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 01/24] EDAC, mc: Fix grain_bits calculation
On Mon, Jun 24, 2019 at 03:08:55PM +0000, Robert Richter wrote:
> 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
>
> Replacing 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(8 - 1)
> grain_bits = 3
>
> grain = 1 << 3 = 8
>
> Note: We need to check if the hardware reports a reasonable grain != 0
> and fallback with a warn_once and 1 byte granularity otherwise.
>
> Signed-off-by: Robert Richter <rrichter@...vell.com>
> ---
> drivers/edac/edac_mc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
Applied to the new EDAC repo:
https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git/log/?h=edac-for-next
Thx.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
Powered by blists - more mailing lists