From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: yazen.ghannam@amd.com, tony.luck@intel.com,
linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
avadhut.naik@amd.com, john.allen@amd.com, muralidhara.mk@amd.com,
naveenkrishna.chatradhi@amd.com, sathyapriya.k@amd.com
Subject: Re: [PATCH 2/2] RAS: Introduce the FRU Memory Poison Manager
Date: Wed, 14 Feb 2024 10:33:15 -0500 [thread overview]
Message-ID: <1a46d8cb-104f-4854-a09e-c60095e2dcd0@amd.com> (raw)
In-Reply-To: <20240214120214.GJZcyrxgyLLwQ8y19Z@fat_crate.local>
On 2/14/2024 7:02 AM, Borislav Petkov wrote:
> On Tue, Feb 13, 2024 at 09:35:16PM -0600, Yazen Ghannam wrote:
>> +static unsigned int get_cpu_for_fru_num(unsigned int i)
>> +{
>> + unsigned int cpu = 0;
>> +
>> + /* Should there be more robust error handling if none found? */
>> + for_each_online_cpu(cpu) {
>
> You need to block CPU hotplug operations before iterating over online
> CPUs: cpus_read_lock/unlock.
>
Okay.
>> + if (topology_physical_package_id(cpu) == i)
>> + return cpu;
>> + }
>> +
>> + return cpu;
>> +}
>
> Fold this one into its single callsite.
>
Ack.
>> +
>> +static void init_fmps(void)
>> +{
>> + struct fru_rec *rec;
>> + unsigned int i, cpu;
>> +
>> + for_each_fru(i, rec) {
>> + cpu = get_cpu_for_fru_num(i);
>> + set_fmp_fields(get_fmp(rec), cpu);
>> + }
>> +}
>> +
>> +static int get_system_info(void)
>> +{
>> + u8 model = boot_cpu_data.x86_model;
>
> No need for that local var - just use boot_cpu_data.x86_model.
>
Ack.
>> + /* Only load on MI300A systems for now. */
>> + if (!(model >= 0x90 && model <= 0x9f))
>> + return -ENODEV;
>> +
>> + if (!cpu_feature_enabled(X86_FEATURE_AMD_PPIN)) {
>> + pr_debug("PPIN feature not available");
>> + return -ENODEV;
>> + }
>> +
>> + /* Use CPU Package (Socket) as FRU for MI300 systems. */
>> + max_nr_fru = topology_max_packages();
>> + if (!max_nr_fru)
>> + return -ENODEV;
>> +
>> + if (!max_nr_entries)
>> + max_nr_entries = FMPM_DEFAULT_MAX_NR_ENTRIES;
>> +
>> + max_rec_len = sizeof(struct fru_rec);
>> + max_rec_len += sizeof(struct cper_fru_poison_desc) * max_nr_entries;
>> +
>> + pr_debug("max_nr_fru=%u max_nr_entries=%u, max_rec_len=%lu",
>> + max_nr_fru, max_nr_entries, max_rec_len);
>> + return 0;
>> +}
>> +
>> +static void deallocate_records(void)
>
> free_records
>
Ack.
>> +{
>> + struct fru_rec *rec;
>> + int i;
>> +
>> + for_each_fru(i, rec)
>> + kfree(rec);
>> +
>> + kfree(fru_records);
>> +}
>> +
>> +static int allocate_records(void)
>> +{
>> + int i, ret = 0;
>> +
>> + fru_records = kcalloc(max_nr_fru, sizeof(struct fru_rec *), GFP_KERNEL);
>> + if (!fru_records) {
>> + ret = -ENOMEM;
>> + goto out;
>> + }
>> +
>> + for (i = 0; i < max_nr_fru; i++) {
>> + fru_records[i] = kzalloc(max_rec_len, GFP_KERNEL);
>> + if (!fru_records[i]) {
>> + ret = -ENOMEM;
>> + goto out_free;
>> + }
>> + }
>> +
>> + return ret;
>> +
>> +out_free:
>> + for (; i >= 0; i--)
>> + kfree(fru_records[i]);
>> +
>> + kfree(fru_records);
>> +out:
>> + return ret;
>> +}
>> +
>> +static const struct x86_cpu_id fmpm_cpuids[] = {
>> + X86_MATCH_VENDOR_FAM(AMD, 0x19, NULL),
>
> This is why this should depend on AMD in Kconfig.
>
Okay.
I was also thinking that MODULE_DEVICE_TABLE shouldn't be used. Not all
MI300-based systems will need or can use this module. And it does depend
on specific platform configurations.
So the module should not autoload. Users will need to manually load it if
they know that it's usable on their platform. We can keep the cpuid[] and
model checks just for extra safety.
Thanks,
Yazen
next prev parent reply other threads:[~2024-02-14 15:33 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 3:35 [PATCH 0/2] " Yazen Ghannam
2024-02-14 3:35 ` [PATCH 1/2] RAS/AMD/ATL, EDAC/amd64: Move MI300 Row Retirement to ATL Yazen Ghannam
2024-02-14 8:36 ` Borislav Petkov
2024-02-14 14:19 ` Yazen Ghannam
2024-02-14 16:05 ` Borislav Petkov
2024-02-14 3:35 ` [PATCH 2/2] RAS: Introduce the FRU Memory Poison Manager Yazen Ghannam
2024-02-14 9:06 ` Borislav Petkov
2024-02-14 14:21 ` Yazen Ghannam
2024-02-14 15:49 ` Borislav Petkov
2024-02-14 16:01 ` Yazen Ghannam
2024-02-14 16:11 ` Borislav Petkov
2024-02-14 9:28 ` Borislav Petkov
2024-02-14 14:28 ` Yazen Ghannam
2024-02-14 17:50 ` Borislav Petkov
2024-02-14 18:21 ` Borislav Petkov
2024-02-14 10:29 ` Borislav Petkov
2024-02-14 14:45 ` Yazen Ghannam
2024-02-14 18:04 ` Borislav Petkov
2024-02-14 10:34 ` Borislav Petkov
2024-02-14 14:46 ` Yazen Ghannam
2024-02-14 18:29 ` Borislav Petkov
2024-02-14 10:51 ` Borislav Petkov
2024-02-14 14:49 ` Yazen Ghannam
2024-02-14 11:05 ` Borislav Petkov
2024-02-14 14:56 ` Yazen Ghannam
2024-02-14 18:44 ` Borislav Petkov
2024-02-14 11:10 ` Borislav Petkov
2024-02-14 14:57 ` Yazen Ghannam
2024-02-14 11:15 ` Borislav Petkov
2024-02-14 14:59 ` Yazen Ghannam
2024-02-14 11:36 ` Borislav Petkov
2024-02-14 15:26 ` Yazen Ghannam
2024-02-14 19:44 ` Borislav Petkov
2024-02-14 20:10 ` Borislav Petkov
2024-02-14 12:02 ` Borislav Petkov
2024-02-14 15:33 ` Yazen Ghannam [this message]
2024-02-14 20:18 ` Borislav Petkov
2024-02-14 18:47 ` Borislav Petkov
2024-02-14 7:52 ` [PATCH 0/2] " Borislav Petkov
2024-02-20 12:29 ` M K, Muralidhara
2024-02-20 17:10 ` M K, Muralidhara
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=1a46d8cb-104f-4854-a09e-c60095e2dcd0@amd.com \
--to=yazen.ghannam@amd.com \
--cc=avadhut.naik@amd.com \
--cc=bp@alien8.de \
--cc=john.allen@amd.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=muralidhara.mk@amd.com \
--cc=naveenkrishna.chatradhi@amd.com \
--cc=sathyapriya.k@amd.com \
--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®