Hi, On 2/22/22 19:51, Mark Pearson wrote: > Instead of having quirks for systems that have a second fan it would > be nice to detect this setup. > Unfortunately, confirmed by the Lenovo FW team, there is no way to > retrieve this information from the EC or BIOS. Recommendation was to > attempt to read the fan and if successful then assume a 2nd fan is > present. > > The fans are also supposed to spin up on boot for some time, so in > theory we could check for a speed > 0. In testing this seems to hold > true but as I couldn't test on all platforms I've avoided implementing > this. It also breaks for the corner case where you load the module > once the fans are idle. > > Tested on P1G4, P1G3, X1C9 and T14 (no fans) and it works correctly. > For the platforms with dual fans where it was confirmed to work I have > removed the quirks. Potentially this could be done for all platforms > but I've left untested platforms in for now. On these platforms the > fans will be enabled and then detected - so no impact. > > Signed-off-by: Mark Pearson <markpearson@xxxxxxxxxx> Thank you for your patch, I've applied this patch to my review-hans branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while. Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window. Regards, Hans > --- > drivers/platform/x86/thinkpad_acpi.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c > index e9b1574729b9..d0599e8a7b4d 100644 > --- a/drivers/platform/x86/thinkpad_acpi.c > +++ b/drivers/platform/x86/thinkpad_acpi.c > @@ -8698,10 +8698,7 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = { > TPACPI_Q_LNV3('N', '2', 'N', TPACPI_FAN_2CTL), /* P53 / P73 */ > TPACPI_Q_LNV3('N', '2', 'E', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (1st gen) */ > TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (2nd gen) */ > - TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (3nd gen) */ > - TPACPI_Q_LNV3('N', '4', '0', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (4nd gen) */ > TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL), /* P15 (1st gen) / P15v (1st gen) */ > - TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL), /* X1 Carbon (9th gen) */ > TPACPI_Q_LNV3('N', '3', '7', TPACPI_FAN_2CTL), /* T15g (2nd gen) */ > TPACPI_Q_LNV3('N', '1', 'O', TPACPI_FAN_NOFAN), /* X1 Tablet (2nd gen) */ > }; > @@ -8745,6 +8742,9 @@ static int __init fan_init(struct ibm_init_struct *iibm) > * ThinkPad ECs supports the fan control register */ > if (likely(acpi_ec_read(fan_status_offset, > &fan_control_initial_status))) { > + int res; > + unsigned int speed; > + > fan_status_access_mode = TPACPI_FAN_RD_TPEC; > if (quirks & TPACPI_FAN_Q1) > fan_quirk1_setup(); > @@ -8757,6 +8757,15 @@ static int __init fan_init(struct ibm_init_struct *iibm) > tp_features.second_fan_ctl = 1; > pr_info("secondary fan control enabled\n"); > } > + /* Try and probe the 2nd fan */ > + res = fan2_get_speed(&speed); > + if (res >= 0) { > + /* It responded - so let's assume it's there */ > + tp_features.second_fan = 1; > + tp_features.second_fan_ctl = 1; > + pr_info("secondary fan control detected & enabled\n"); > + } > + > } else { > pr_err("ThinkPad ACPI EC access misbehaving, fan status and control unavailable\n"); > return -ENODEV;