Re: [PATCH v4 1/3] EDAC/loongson: Encode node and MC info into mc_idx

From: Borislav Petkov

Date: Tue Sep 29 2026 - 20:34:46 EST


On Wed, Sep 02, 2026 at 04:48:25PM +0800, Qunqin Zhao wrote:
> @@ -23,6 +24,8 @@ struct loongson_edac_pvt {
> * register state.
> */
> int last_ce_count;
> + u32 mcs_per_node;
> + bool mc_idx_valid;

Why do you need a silly bool if you have valid indices in any case?

You either get it from edac_device_alloc_index() and in that case, the node
number is always 0 and when you get it from ACPI, you get the right thing
anyway?

IOW, you init mc_idx properly in the probe function and then you're all set.

> static int read_ecc(struct mem_ctl_info *mci)
> @@ -44,7 +47,8 @@ static int read_ecc(struct mem_ctl_info *mci)
> static void edac_check(struct mem_ctl_info *mci)

In a prepatch, please remove the "edac_" prefix from all your driver-local
definitions like edac_probe() or loongson_edac_pvt. The edac_ namespace
belongs to the EDAC core functions. Since your functions are static, you can
simply call them probe(), check() etc.

> struct loongson_edac_pvt *pvt = mci->pvt_info;
> - int new, add;
> + char other_detail[64] = {0};
> + int new, add, node, mc;
>
> new = read_ecc(mci);
> add = new - pvt->last_ce_count;

...

> static int edac_probe(struct platform_device *pdev)
> {
> struct edac_mc_layer layers[2];
> struct mem_ctl_info *mci;
> + struct device *dev = &pdev->dev;
> void __iomem *vbase;
> + u32 mcs_per_node;
> int ret;
> + bool mc_idx_valid = true;

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;

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette