Re: [PATCH v2 07/17] hwmon: Fix Intel Family-model checks to include extended Families

From: Dave Hansen
Date: Wed Feb 12 2025 - 11:57:31 EST


On 2/12/25 05:43, Zhang, Rui wrote:
> I agree.
> adjust_tjmax() contains a list of quirks based on PCI-
> ID/x86_vendor_id/x86_model/x86_stepping. The common problem is that all
> the quirks are for Fam6 processors but the family id is not checked. So
> the fix is sufficient. In fact, I think it is better to move the check
> to the very beginning of adjust_tjmax().

Or, heck, just remove the model list. dev_warn_once() if the rdmsr
fails. Who cares about one more line in dmesg?

Why not do the attached patch?

---

b/drivers/hwmon/coretemp.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff -puN drivers/hwmon/coretemp.c~coretemp-1 drivers/hwmon/coretemp.c
--- a/drivers/hwmon/coretemp.c~coretemp-1 2025-02-12 08:52:48.782731226 -0800
+++ b/drivers/hwmon/coretemp.c 2025-02-12 08:53:43.867617505 -0800
@@ -258,18 +258,6 @@ static int adjust_tjmax(struct cpuinfo_x
return tjmax;
}

-static bool cpu_has_tjmax(struct cpuinfo_x86 *c)
-{
- u8 model = c->x86_model;
-
- return model > 0xe &&
- model != 0x1c &&
- model != 0x26 &&
- model != 0x27 &&
- model != 0x35 &&
- model != 0x36;
-}
-
static int get_tjmax(struct temp_data *tdata, struct device *dev)
{
struct cpuinfo_x86 *c = &cpu_data(tdata->cpu);
@@ -287,8 +275,7 @@ static int get_tjmax(struct temp_data *t
*/
err = rdmsr_safe_on_cpu(tdata->cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
if (err) {
- if (cpu_has_tjmax(c))
- dev_warn(dev, "Unable to read TjMax from CPU %u\n", tdata->cpu);
+ dev_warn_once(dev, "Unable to read TjMax from CPU %u\n", tdata->cpu);
} else {
val = (eax >> 16) & 0xff;
if (val)
_