From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Tony Luck <tony.luck@intel.com>
Cc: Hans de Goede <hansg@kernel.org>, Borislav Petkov <bp@alien8.de>,
Breno Leitao <leitao@debian.org>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
patches@lists.linux.dev, Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Subject: Re: [PATCH 6/7] platform/x86/intel/bff: Compute unique ID for overflowed filter
Date: Wed, 26 Aug 2026 11:26:37 +0300 (EEST) [thread overview]
Message-ID: <c62f28a7-25a0-8b74-ae8c-9aca146c8ea9@linux.intel.com> (raw)
In-Reply-To: <20260825181526.13203-7-tony.luck@intel.com>
On Tue, 25 Aug 2026, Tony Luck wrote:
> Each L2 cache instance has its own bitfix filter, but always reports
> errors in machine check bank 3 (on Diamond Rapids).
>
> Compute a unique bitfix filter instance number based on the CPU that
> logged the error and the machine check bank number.
>
> Special case for banks associated with the Integrated Memory Hub (IMH).
> Here the "even" numbered CPU modules are associated with IMH0 and the
> "odd" modules with IMH1.
>
> The unique id will be used to store a time stamp of when the bitfix
> filter overflowed so that frequent overflows can be logged.
>
> Co-developed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
> drivers/platform/x86/intel/bff.c | 74 ++++++++++++++++++++++++++++++++
> 1 file changed, 74 insertions(+)
>
> diff --git a/drivers/platform/x86/intel/bff.c b/drivers/platform/x86/intel/bff.c
> index 8cc29d11e019..ae9dc0bf2777 100644
> --- a/drivers/platform/x86/intel/bff.c
> +++ b/drivers/platform/x86/intel/bff.c
> @@ -18,13 +18,18 @@
> #define pr_fmt(fmt) "bff: " fmt
>
> #include <linux/bits.h>
> +#include <linux/cacheinfo.h>
> +#include <linux/cleanup.h>
> #include <linux/cpufeature.h>
> +#include <linux/cpuhplock.h>
> #include <linux/device-id/x86_cpu.h>
> #include <linux/errno.h>
> #include <linux/init.h>
> +#include <linux/limits.h>
> #include <linux/module.h>
> #include <linux/notifier.h>
> #include <linux/printk.h>
> +#include <linux/topology.h>
> #include <linux/types.h>
>
> #include <asm/cpu_device_id.h>
> @@ -34,6 +39,8 @@
> #include <asm/msr.h>
> #include <asm/msr-index.h>
>
> +#define NUM_IMH_PER_SKT 2
> +
> /* Intel bitfix filter control register defines */
> #define MSR_MC0_BFF_CTL 0x000006c0
> #define MSR_MCx_BFF_CTL(x) (MSR_MC0_BFF_CTL + (x))
> @@ -67,11 +74,78 @@ MODULE_DEVICE_TABLE(x86cpu, bff_cpu_ids);
>
> static const enum bff_type *bank_types;
>
> +/* Diamond Rapids maps APICID[2] to the IMH instance. */
> +static void bff_set_imh_id(struct mce *mce, unsigned long *id)
> +{
> + int imh_num = (NUM_IMH_PER_SKT * topology_physical_package_id(mce->extcpu)) +
> + ((mce->apicid >> 2) & 0x1);
FIELD_GET(), I suggest moving comment where you define the field for that.
> +
> + *id |= imh_num;
> +}
> +
> +static bool bff_set_cache_id(int cpu, int level, unsigned long *id)
> +{
> + int cacheid;
> +
> + guard(cpus_read_lock)();
> +
> + cacheid = get_cpu_cacheinfo_id(cpu, level);
> + if (cacheid == -1) {
> + pr_warn("Could not get L%d cache id for CPU %d\n", level, cpu);
> + return false;
> + }
> +
> + *id |= cacheid;
> +
> + return true;
> +}
> +
> +#define BFF_ID_BANK_SHIFT 16
> +
> +/*
> + * Cache IDs are only unique within a cache level.
> + * Include the MCA bank number so each BFF-capable hardware
> + * resource has a unique tracking ID.
> + */
> +static unsigned long get_bff_id(struct mce *mce)
> +{
> + unsigned long id = (unsigned long)mce->bank << BFF_ID_BANK_SHIFT;
FIELD_PREP() ?
> +
> + switch (bank_types[mce->bank]) {
> + case BFF_BANK_DCU:
> + case BFF_BANK_DTLB:
> + if (!bff_set_cache_id(mce->extcpu, 1, &id))
> + return ULONG_MAX;
> + break;
> +
> + case BFF_BANK_MLC:
> + if (!bff_set_cache_id(mce->extcpu, 2, &id))
> + return ULONG_MAX;
> + break;
> +
> + case BFF_BANK_CCF:
> + if (!bff_set_cache_id(mce->extcpu, 3, &id))
> + return ULONG_MAX;
> + break;
> +
> + case BFF_BANK_HSF:
> + case BFF_BANK_IOCACHE:
> + bff_set_imh_id(mce, &id);
> + break;
> + default:
> + return ULONG_MAX;
> + }
> +
> + return id;
> +}
> +
> static void handle_bff(struct mce *mce)
> {
> /* The bitfix filter overflowed, get the target CPU to reset it. */
> if (wrmsrq_on_cpu(mce->extcpu, MSR_MCx_BFF_CTL(mce->bank), MCI_BFF_RESET))
> pr_warn("Failed to reset bitfix filter for CPU %d Bank %d\n", mce->extcpu, mce->bank);
> +
> + pr_debug("unique_id = 0x%lx\n", get_bff_id(mce));
> }
>
> static int bff_mce_notify(struct notifier_block *nb, unsigned long val, void *data)
>
--
i.
next prev parent reply other threads:[~2026-08-26 8:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 18:15 [PATCH 0/7] Intel platform driver to reset bitfix filters Tony Luck
2026-08-25 18:15 ` [PATCH 1/7] cacheinfo: Export get_cpu_cacheinfo_id() for loadable modules Tony Luck
2026-08-25 18:15 ` [PATCH 2/7] x86/mce: Enumeration updates for Intel bitfix filter reset Tony Luck
2026-08-26 8:15 ` Ilpo Järvinen
2026-08-25 18:15 ` [PATCH 3/7] platform/x86/intel/bff: Add stub Intel bitfix filter driver Tony Luck
2026-08-25 18:15 ` [PATCH 4/7] platform/x86/intel/bff: Add Diamond Rapids support Tony Luck
2026-08-26 8:17 ` Ilpo Järvinen
2026-08-26 16:10 ` Luck, Tony
2026-08-25 18:15 ` [PATCH 5/7] platform/x86/intel/bff: Reset bitfix filter when it overflows Tony Luck
2026-08-25 18:15 ` [PATCH 6/7] platform/x86/intel/bff: Compute unique ID for overflowed filter Tony Luck
2026-08-26 8:26 ` Ilpo Järvinen [this message]
2026-08-25 18:15 ` [PATCH 7/7] platform/x86/intel/bff: Report frequent filter resets Tony Luck
2026-08-26 8:39 ` Ilpo Järvinen
2026-08-25 18:28 ` [PATCH 0/7] Intel platform driver to reset bitfix filters Borislav Petkov
2026-08-25 18:55 ` Luck, Tony
2026-08-25 19:23 ` 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=c62f28a7-25a0-8b74-ae8c-9aca146c8ea9@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=bp@alien8.de \
--cc=hansg@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=qiuxu.zhuo@intel.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®