From: Zhao Qunqin <zhaoqunqin@loongson.cn>
To: Borislav Petkov <bp@alien8.de>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
chenhuacai@kernel.org, linux-edac@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@xen0n.name, tony.luck@intel.com, james.morse@arm.com,
mchehab@kernel.org, rric@kernel.org, loongarch@lists.linux.dev
Subject: Re: [PATCH v4 2/2] Loongarch: EDAC driver for loongson memory controller
Date: Sat, 14 Sep 2024 10:18:02 +0800 [thread overview]
Message-ID: <2ca97c7c-2fd4-3ce5-9e8c-426c418ebcf5@loongson.cn> (raw)
In-Reply-To: <20240913101137.GHZuQP2WzlkvJ5gG2F@fat_crate.local>
在 2024/9/13 下午6:11, Borislav Petkov 写道:
> On Mon, Sep 09, 2024 at 11:21:24AM +0800, Zhao Qunqin wrote:
>> Subject: Re: [PATCH v4 2/2] Loongarch: EDAC driver for loongson memory controller
> EDAC/loongson: Add EDAC driver ...
>
>> Reports single bit errors (CE) only.
>>
>> Signed-off-by: Zhao Qunqin <zhaoqunqin@loongson.cn>
>> ---
> ...
>
>> diff --git a/drivers/edac/loongson_edac.c b/drivers/edac/loongson_edac.c
>> new file mode 100644
>> index 000000000..b89d6e0e7
>> --- /dev/null
>> +++ b/drivers/edac/loongson_edac.c
>> @@ -0,0 +1,182 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2024 Loongson Technology Corporation Limited.
>> + */
>> +
>> +#include <linux/edac.h>
>> +#include <linux/module.h>
>> +#include <linux/init.h>
>> +#include <linux/platform_device.h>
>> +
>> +#include "edac_module.h"
>> +
>> +enum ecc_index {
>> + ECC_SET = 0,
>> + ECC_RESERVED,
>> + ECC_COUNT,
>> + ECC_CS_COUNT,
>> + ECC_CODE,
>> + ECC_ADDR,
>> + ECC_DATA0,
>> + ECC_DATA1,
>> + ECC_DATA2,
>> + ECC_DATA3,
>> +};
>> +
>> +struct loongson_edac_pvt {
>> + u64 *ecc_base;
>> + int last_ce_count;
>> +};
>> +
>> +static void loongson_update_ce_count(struct mem_ctl_info *mci,
> Drop the loongson_ prefix from all static functions.
>
> Also, align function arguments on the opening brace.
>
>> + int chan,
>> + int new)
>> +{
>> + int add;
>> + struct loongson_edac_pvt *pvt = mci->pvt_info;
> The EDAC tree preferred ordering of variable declarations at the
> beginning of a function is reverse fir tree order::
>
> struct long_struct_name *descriptive_name;
> unsigned long foo, bar;
> unsigned int tmp;
> int ret;
>
> The above is faster to parse than the reverse ordering::
>
> int ret;
> unsigned int tmp;
> unsigned long foo, bar;
> struct long_struct_name *descriptive_name;
>
> And even more so than random ordering::
>
> unsigned long foo, bar;
> int ret;
> struct long_struct_name *descriptive_name;
> unsigned int tmp;
>
>> +
>> + add = new - pvt->last_ce_count;
>> +
>> + /* Store the new value */
> Drop all those obvious comments.
>
>> + pvt->last_ce_count = new;
>> +
>> + /* device resume or any other exceptions*/
> No clue what that means.
The CE value of the memory controller should only increase,
but it will return to its initial value when resuming from S3 or S4
sleep state,
then the new ce count may be smaller than the last ce count.
>
> Also, the check goes right under the assignment.
>
>> + if (add < 0)
>> + return;
>> +
>> + /*updated the edac core */
> Useless comment.
>
>> + if (add != 0) {
> if (!add)
> return;
>
> and now you can save yourself an indentation level:
>
> edac_mc_...(
>
>> + edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, add,
>> + 0, 0, 0,
>> + chan, 0, -1, "error", "");
>> + edac_mc_printk(mci, KERN_INFO, "add: %d", add);
>> + }
>> +}
>> +
>> +static int loongson_read_ecc(struct mem_ctl_info *mci)
>> +{
>> + u64 ecc;
>> + int cs = 0;
>> + struct loongson_edac_pvt *pvt = mci->pvt_info;
>> +
>> + if (!pvt->ecc_base)
>> + return pvt->last_ce_count;
>> +
>> + ecc = pvt->ecc_base[ECC_CS_COUNT];
>> + cs += ecc & 0xff; // cs0
>> + cs += (ecc >> 8) & 0xff; // cs1
>> + cs += (ecc >> 16) & 0xff; // cs2
>> + cs += (ecc >> 24) & 0xff; // cs3
> No side comments pls - put them over the line.
>
>> +
>> + return cs;
>> +}
>> +
>> +static void loongson_edac_check(struct mem_ctl_info *mci)
>> +{
>> + loongson_update_ce_count(mci, 0, loongson_read_ecc(mci));
> Drop this silly wrapper.
>
>> +}
>> +
>> +static int get_dimm_config(struct mem_ctl_info *mci)
>> +{
>> + u32 size, npages;
>> + struct dimm_info *dimm;
>> +
>> + /* size not used */
>> + size = -1;
>> + npages = MiB_TO_PAGES(size);
>> +
>> + dimm = edac_get_dimm(mci, 0, 0, 0);
>> + dimm->nr_pages = npages;
>> + snprintf(dimm->label, sizeof(dimm->label),
>> + "MC#%uChannel#%u_DIMM#%u",
>> + mci->mc_idx, 0, 0);
> Align arguments on the opening brace.
>
>> + dimm->grain = 8;
>> +
>> + return 0;
>> +}
Will address above comments. Thanks for taking the time to review.
Best regards,
Zhao Qunqin.
>
>
prev parent reply other threads:[~2024-09-14 2:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 3:21 [PATCH v4 0/2] Add " Zhao Qunqin
2024-09-09 3:21 ` [PATCH v4 1/2] dt-bindings: EDAC for ls3a5000 " Zhao Qunqin
2024-09-09 3:21 ` [PATCH v4 2/2] Loongarch: EDAC driver for loongson " Zhao Qunqin
2024-09-13 10:11 ` Borislav Petkov
2024-09-14 2:18 ` Zhao Qunqin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ca97c7c-2fd4-3ce5-9e8c-426c418ebcf5@loongson.cn \
--to=zhaoqunqin@loongson.cn \
--cc=bp@alien8.de \
--cc=chenhuacai@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=james.morse@arm.com \
--cc=kernel@xen0n.name \
--cc=krzk+dt@kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=rric@kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®