mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qunqin Zhao <zhaoqunqin@loongson.cn>
To: Borislav Petkov <bp@alien8.de>, Qunqin Zhao <zhaoqunqin@163.com>
Cc: tony.luck@intel.com, linux-edac@vger.kernel.org,
	chenhuacai@kernel.org, linux-kernel@vger.kernel.org,
	Wang Jinwei <wangjinwei@loongson.cn>,
	Dongyan Qian <qiandongyan@loongson.cn>,
	Chao Li <lichao@loongson.cn>,
	Huacai Chen <chenhuacai@loongson.cn>
Subject: Re: [PATCH v8 3/4] EDAC/loongson: Get DIMM size from ACPI _DSM method
Date: Mon, 30 Nov 2026 10:47:24 +0800	[thread overview]
Message-ID: <cc592bb7-75fb-4b1d-8c83-6af643896ebd@loongson.cn> (raw)
In-Reply-To: <20261127232310.GQawoQ3plxyLGp8raz@fat_crate.local>


在 2026/11/28 07:23, Borislav Petkov 写道:
> On Wed, Nov 18, 2026 at 11:03:29AM +0800, Qunqin Zhao wrote:
>> From: Wang Jinwei <wangjinwei@loongson.cn>
>>
>> Add support to retrieve DIMM size from ACPI _DSM method instead
>> of using hardcoded values.
>>
>> 1. Add loongson_get_dimm_size_acpi() to call ACPI _DSM method
>>    to Get DIMM size in MB.
>>
>> 2. Update dimm_config_init() to use the size from ACPI, with
>>    fallback to default 1 MB if ACPI method fails.
>>
>> 3. Add ACPI UUID and DSM function definitions for EDAC.
>>
>> The DIMM size is passed from UEFI through ACPI OperationRegion
>> and _DSM method, enabling correct display of memory size in
>> /sys/devices/system/edac/mc/mc*/size_mb.
> Please, do not talk about *what* the patch is doing in the commit message
> - that should be obvious from the diff itself. Rather, concentrate on the
> *why* it needs to be done and why your patch exists.
>
> It is perfectly fine to explain non-trivial aspects of the code the patch is
> touching but do not regurgitate what it does.
>
> See also https://docs.kernel.org/process/submitting-patches.html for
> additional inspiration.
Understood, thanks.
>  
>> Cc: Dongyan Qian <qiandongyan@loongson.cn>
>> Cc: Chao Li <lichao@loongson.cn>
>> Signed-off-by: Wang Jinwei <wangjinwei@loongson.cn>
>> Signed-off-by: Qunqin Zhao <zhaoqunqin@loongson.cn>
>> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>> ---
>>  drivers/edac/loongson_edac.c | 32 ++++++++++++++++++++++++++++++--
>>  1 file changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/edac/loongson_edac.c b/drivers/edac/loongson_edac.c
>> index 4ee9dcb3d5..413ca654b4 100644
>> --- a/drivers/edac/loongson_edac.c
>> +++ b/drivers/edac/loongson_edac.c
>> @@ -13,6 +13,8 @@
>>  #include "edac_module.h"
>>  
>>  #define ECC_CS_COUNT_REG	0x18
>> +#define LOONGSON_EDAC_DSM_UUID "65d0431b-7eb8-46df-b914-b7d568553140"
>> +#define LOONGSON_EDAC_DSM_FUNC_GET_DIMM_SIZE   1
> Are you serious? Can you make that define longer?!?
DSM_UUID looks better. That's a nice cleanup.
> Didn't I already told you to zap all those "loongson" prefixes from static
> objects?
Sorry. Will keep that in mind.
>>  
>>  /* Memory controller index invalid due to inability to read it from ACPI, etc */
>>  #define MC_IDX_INVALID		BIT(16)
>> @@ -68,13 +70,39 @@ static void loongson_check(struct mem_ctl_info *mci)
>>  			     0, 0, 0, 0, 0, -1, "error", other_detail);
>>  }
>>  static void dimm_config_init(struct mem_ctl_info *mci)
>>  {
>>  	struct dimm_info *dimm;
>> +	struct device *dev = mci->pdev;
>>  	u32 size, npages;
> This tree's 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;
>
> I went and did it for you ontop again.
>
> Please make sure you go over the changes I did and keep them in mind next time
> you send patches.

Thanks. I've gone through your changes already and will keep them in mind for future patches.

[PATCH 1/4]:

1.  Drop text explaining what the patch does in the commit message

[PATCH 2/4]:

1.  Drop text explaining what the patch does in the commit message

2. Reorder the variable declarations

+ struct device *dev = &pdev->dev; struct edac_mc_layer layers[2];

[PATCH 3/4]: 

1.  Drop text explaining what the patch does in the commit message

2. Drop LOONGSON_EDAC_DSM_FUNC_GET_DIMM_SIZE macro

3. LOONGSON_EDAC_DSM_UUID -> DSM_UUID

4. loongson_get_dimm_size_acpi -> get_dimm_size_acpi

5. Reorder the variable declarations

+	struct device *dev = mci->pdev;
 	struct dimm_info *dimm;

Qunqin,
Thanks.

>
> ---
> From: Wang Jinwei <wangjinwei@loongson.cn>
> Date: Wed, 18 Nov 2026 11:03:29 +0800
> Subject: [PATCH] EDAC/loongson: Get DIMM size from ACPI _DSM method
>
> Retrieve DIMM size from the ACPI _DSM method instead of using hardcoded
> values.
>
> The DIMM size is passed from UEFI through ACPI OperationRegion and _DSM
> method, enabling correct display of memory size in:
>
>   /sys/devices/system/edac/mc/mc*/size_mb
>
>   [ bp:
>    - Massage commit message, drop text explaining what the patch does
>    - Zap insanely long define
>    - Zap loongson prefix from more static objects
>    ]
>
> Signed-off-by: Wang Jinwei <wangjinwei@loongson.cn>
> Signed-off-by: Qunqin Zhao <zhaoqunqin@loongson.cn>
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> Link: https://patch.msgid.link/20261118030330.25779-4-zhaoqunqin@163.com
> ---
>  drivers/edac/loongson_edac.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/edac/loongson_edac.c b/drivers/edac/loongson_edac.c
> index d9c86d7e721b..250eba136655 100644
> --- a/drivers/edac/loongson_edac.c
> +++ b/drivers/edac/loongson_edac.c
> @@ -13,6 +13,7 @@
>  #include "edac_module.h"
>  
>  #define ECC_CS_COUNT_REG	0x18
> +#define DSM_UUID		"65d0431b-7eb8-46df-b914-b7d568553140"
>  
>  /* Memory controller index invalid due to inability to read it from ACPI, etc */
>  #define MC_IDX_INVALID		BIT(16)
> @@ -68,13 +69,40 @@ static void loongson_check(struct mem_ctl_info *mci)
>  			     0, 0, 0, 0, 0, -1, "error", other_detail);
>  }
>  
> +static u32 get_dimm_size_acpi(struct device *dev)
> +{
> +	acpi_handle handle = ACPI_HANDLE(dev);
> +	union acpi_object *obj;
> +	u32 size_mb = 1;
> +	guid_t guid;
> +
> +	if (!handle)
> +		return size_mb;
> +
> +	if (guid_parse(DSM_UUID, &guid))
> +		return size_mb;
> +
> +	/* 1 = DSM get DIMM size */
> +	obj = acpi_evaluate_dsm(handle, &guid, 0, 1, NULL);
> +	if (!obj)
> +		return size_mb;
> +
> +	if (obj->type == ACPI_TYPE_INTEGER)
> +		size_mb = (u32)obj->integer.value;
> +
> +	ACPI_FREE(obj);
> +
> +	return size_mb;
> +}
> +
>  static void dimm_config_init(struct mem_ctl_info *mci)
>  {
> +	struct device *dev = mci->pdev;
>  	struct dimm_info *dimm;
>  	u32 size, npages;
>  
> -	/* size not used */
> -	size = -1;
> +	size = get_dimm_size_acpi(dev);
> +
>  	npages = MiB_TO_PAGES(size);
>  
>  	dimm = edac_get_dimm(mci, 0, 0, 0);


  reply	other threads:[~2026-11-30  2:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  3:03 [PATCH v8 0/4] EDAC/loongson: Improvements for Loongson EDAC driver Qunqin Zhao
2026-11-18  3:03 ` [PATCH v8 1/4] EDAC/loongson: Rename driver-local symbols Qunqin Zhao
2026-11-18  3:03 ` [PATCH v8 2/4] EDAC/loongson: Encode node and MC info into mc_idx Qunqin Zhao
2026-11-18  7:45   ` Huacai Chen
2026-11-18  3:03 ` [PATCH v8 3/4] EDAC/loongson: Get DIMM size from ACPI _DSM method Qunqin Zhao
2026-11-27 23:23   ` Borislav Petkov
2026-11-30  2:47     ` Qunqin Zhao [this message]
2026-11-18  3:03 ` [PATCH v8 4/4] EDAC/loongson: Add CS4-7 timeout filter for cross-node access Qunqin Zhao
2026-11-18  7:46   ` Huacai Chen
2026-11-27 23:25   ` Borislav Petkov
2026-11-30  3:25     ` Qunqin Zhao
2026-11-30 18:42       ` Borislav Petkov
2026-11-27 23:40 ` [PATCH v8 0/4] EDAC/loongson: Improvements for Loongson EDAC driver Borislav Petkov

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=cc592bb7-75fb-4b1d-8c83-6af643896ebd@loongson.cn \
    --to=zhaoqunqin@loongson.cn \
    --cc=bp@alien8.de \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=lichao@loongson.cn \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiandongyan@loongson.cn \
    --cc=tony.luck@intel.com \
    --cc=wangjinwei@loongson.cn \
    --cc=zhaoqunqin@163.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®