From nobody Fri May 5 05:51:31 2023 X-Original-To: freebsd-acpi@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QCKZ05tY2z49hj6 for ; Fri, 5 May 2023 05:51:36 +0000 (UTC) (envelope-from georg.lindenberg@web.de) Received: from mout.web.de (mout.web.de [212.227.17.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.web.de", Issuer "Telekom Security ServerID OV Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QCKYz0Hyfz42Wh for ; Fri, 5 May 2023 05:51:34 +0000 (UTC) (envelope-from georg.lindenberg@web.de) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=web.de header.s=s29768273 header.b=qdEWz+zL; spf=pass (mx1.freebsd.org: domain of georg.lindenberg@web.de designates 212.227.17.12 as permitted sender) smtp.mailfrom=georg.lindenberg@web.de; dmarc=pass (policy=none) header.from=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1683265891; i=georg.lindenberg@web.de; bh=nDVz6im83lXcpSEKB68GIcaab3vLADwpJx4XraYAN8M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=qdEWz+zL+EvLLv0IAXVt8PnX2fgE2Ru5gNgP9lL/1ZOFSl2RWxKIaLvFGoO+MSetK ALk560Xl2ejj4gtGIe37cED+PFCG39xB97lRI1/++XJZ7bZFdDS+bklAv9YlYIV/tV K503YkB+5znwfZG7y6AYAVifAyqHFvX8kcb40keOegjWimoBYkNF8UgLPok3YOknCt L11bMNsAFKcBzY9/pAQpS8MunqGRwlb2GcC3aeZG5eMhOsqYLzfYDXGUtPGR6q+UPy 5F5EXNZZWSnLXyU/gIxX0z12C8FNQ5tacVdGkMACDFWGXajukiagJHyYOfEsW65OG5 TJMPAHhmJxraQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [10.236.203.2] ([10.236.203.2]) by msvc-mesg-web102.server.lan (via HTTP); Fri, 5 May 2023 07:51:31 +0200 List-Id: ACPI and power management development List-Archive: https://lists.freebsd.org/archives/freebsd-acpi List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-acpi@freebsd.org MIME-Version: 1.0 Message-ID: From: Georg Lindenberg To: "Dmitry N. Medvedev" Cc: freebsd-acpi@freebsd.org Subject: Aw: Re: Re: managing a fan speed via memory address Content-Type: text/plain; charset=UTF-8 Importance: normal Sensitivity: Normal Content-Transfer-Encoding: quoted-printable Date: Fri, 5 May 2023 07:51:31 +0200 In-Reply-To: References: X-Priority: 3 X-Provags-ID: V03:K1:+Si87OPcc9hGihgMlsffNpgQC5MHirys055PSqPNAv6Xc8AjXPYDyj20WDY0xDiG2uHNZ /lFARCPoT92UF59mTFgfbHpH1QaJtwCYarTRCnnrcKyPgVWhRfiWObzIUe1xIudTIgBS1GWKBMe9 Vt3GubEeiStH0uVBFIYUrinNx3Q85kw0rm5jbmMO3BHE1sYHxPMcp1pzhqtjd08HB8G2zpmv5BYf /CmdDVsiQs5m3VToKgOzeC2N1D0fliogNr0dmU0rRy+JJboP/59zF2tT4Djd+FQdUIreZAVZzDzN og= X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:vuNIImFfVbk=;XngRCRgeuNVzMCN8ZdYurhXKbAs QgZ0rzgTHBGbaF2pSYE46aSkQjFnxe2n1S9JyRsOhzI1yIDpRm1lfLgCp4+GNH26WS+UjrqTJ epitc2VDprLlORroQTRWaTynfqaf04V8KJGxRb3TScafSCbQbhhnoLfiA04kjN8p7lNbNKvnx cBpD9ZzXjMeWVCb6zgOLRprm63Uxc+14JKF9S5yOh0SkzqimQZ1QDrkckwnN1HJkhfvnI8NDm spWHHkuAZhnKyEYPJ3BaqWmhaCaDcbUqQ7I5vJ/8aSRoakBeAcfzAWkULNRvPHdeWi52m1QCh MWUYuky8e3QIlwJGQUe1xakLNfGQi4fqOVneXf2ecPihPtyaY4ldzHfShNyHQIzGGsl8gV2Qo 0uwR/a7bYq87iaWwwT4MYcM7WtGFa6H0zhBRCmnlgT5/DYbXEI3ef/To+tFUbPs8r1vlTEIse ICXqSmaAIGYCxQfiuzJgbt1vnGCz37j3phl+E1CbeExUggpKgsh3gOXE6nG7D92mvpUaqo+dM x9jnhPUcAaO1VvXhJsuX8/HZAu+6yG+z+KVzCsJU+LDauB5OXDQUrxCX75WdeQCKLVzW35hcO /JcdngmFWKJbvVl0NvyZeE3s/6Bs5eUxJpeOZVe5tVN+mkJH3wuvIffkNf4fxH9EaX++QOAmF ycqh8ESJeFApYZIf+YlVp0Vo6gaFd744lEOyxZAmg4JYUN/yx8TXdZl+QJo2vZlonmlCU9cNo yZR+Zl9KTA/9N8ry43uIrHuNCZ1laIsf/RhFEaaYd73bFEIPzPj8cfeCnHkQSa2W6pUQNXJF0 6aNwNAhwPcNJ/zRiJp0FlBgZ2YBe01drTrR2tRsFR77PA= X-Spamd-Result: default: False [-4.56 / 15.00]; DWL_DNSWL_LOW(-1.00)[web.de:dkim]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.96)[-0.960]; DMARC_POLICY_ALLOW(-0.50)[web.de,none]; MID_RHS_NOT_FQDN(0.50)[]; R_DKIM_ALLOW(-0.20)[web.de:s=s29768273]; R_SPF_ALLOW(-0.20)[+ip4:212.227.17.0/27]; MIME_GOOD(-0.10)[text/plain]; RWL_MAILSPIKE_GOOD(-0.10)[212.227.17.12:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TAGGED_RCPT(0.00)[]; MLMMJ_DEST(0.00)[freebsd-acpi@freebsd.org]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[web.de]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[web.de:+]; FREEMAIL_FROM(0.00)[web.de]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; HAS_X_PRIO_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4QCKYz0Hyfz42Wh X-Spamd-Bar: ---- X-ThisMailContainsUnwantedMimeParts: N If the fan ID is not present in acpidump, then the fan is not in the acpi n= amespace, and thus it is not visible to the operating system (aka FreeBSD)= =2E At least according to the acpi documentation=2E :-) Maybe there is a another way to access the fan (bios?), that I am not awar= e of=2E Good luck=2E > Gesendet: Donnerstag, den 04=2E05=2E2023 um 15:45 Uhr > Von: "Dmitry N=2E Medvedev" > An: "Georg Lindenberg" > Cc: freebsd-acpi@freebsd=2Eorg > Betreff: Re: Re: managing a fan speed via memory address >=20 > hi Georg, >=20 > it's become even more confusing -- none of the IDs from #1 exist in > acpidump output :( >=20 > researching further >=20 > On Wed, May 3, 2023 at 8:02=E2=80=AFPM Georg Lindenberg > wrote: >=20 > > > > Hello, > > > > ACPI can control fans, but it is up to the hardware manufacturer (OEM)= to > > implement it=2E > > > > _______________________________ > > Step 1=2E Check for ACPI fan control > > > > The OEM needs to add a device with id "PNP0C0B" to the acpi namespace= =2E > > In FreeBSD, you can test this with the command: acpidump -d -t | grep > > PNP0C0B > > > > On Windows, you can download acpi tools at > > https://acpica=2Eorg/downloads/binary-tools > > Then use the command: acpidump=2Eexe | findstr PNP0C0B > > > > Some fans use IDs which are not documented in the ACPI specification: > > "PNP0C0B", /* Generic Fan */ \ > > "INT3404", /* Fan */ \ > > "INTC1044", /* Fan for Tiger Lake generation */ > > "INTC1048", /* Fan for Alder Lake generation */ > > "INTC1063", /* Fan for Meteor Lake generation */ > > "INTC10A2", /* Fan for Raptor Lake generation */ > > > > You might want to search for these strings as well=2E > > > > __________________________ > > Step 2=2E Check for version of ACPI > > > > Fan version is either 1=2E0 or 4=2E0=2E > > > > a) Acpi version 1=2E0 > > > > If you suceed with step 1=2E, then you can communicate with the fan=2E= You can > > turn it on and off > > by putting it in power state D0 or D3=2E > > In C, you would probably use acpi_set_powerstate(dev, ACPI_STATE_D3), > > or maybe use acpi power methods, like _ON, _OFF, _PR3, _PR0 (haven't > > tested it)=2E > > > > Or maybe an alternative: There is a suggestion on FreeBSD acpi wiki: > > device_power -- Add a "power" argument to devctl(8) that allows a devi= ce > > to be set into various low power or off states=2E > > Noone has implemented that yet ("not done")=2E :) > > > > b) ACPI version 4=2E0 > > > > To check, whether your fan supports fan levels, you can do this: > > > > OEM _must_ provide four predefined acpi methods=2E They are described = in > > detail in the acpi > > specification=2E They are called: _FIF, _FPS, _FSL, _FST > > So just use: > > acpidump -d -t | grep _FPS > > and so on=2E If all four are present, you can use fan levels! :-) > > > > In your source code, it could look like this: > > > > ACPI_HANDLE handle; > > ACPI_HANDLE tmp; > > > > /* fans are either acpi 1=2E0 or 4=2E0 compatible, so check now=2E= */ > > if (ACPI_SUCCESS(acpi_get_handle(handle, "_FIF", &tmp)) && > > ACPI_SUCCESS(acpi_get_handle(handle, "_FPS", &tmp)) && > > ACPI_SUCCESS(acpi_get_handle(handle, "_FSL", &tmp)) && > > ACPI_SUCCESS(acpi_get_handle(handle, "_FST", &tmp))) > > acpi_fan_initiate_acpi4(dev); > > > > else /* nothing to do in acpi version 1, really */ > > acpi_fan_softc=2Eversion =3D 1; > > > > 3=2E How to set fan levels > > > > As a driver author, you'd need to decide how you'd want to implement t= he > > fan level=2E It can be done > > via /dev/acpi (and also add code to acpiconf (8))=2E Or it can be done= via > > systctls=2E > > > > So in your code, you could add a proc sysctl=2E There are multiple way= s to > > implement sysctls, > > one way could be this: > > > > sysctl_ctx_init(&clist); /* sysctl context */ > > > > struct sysctl_oid *fan_oid =3D device_get_sysctl_tree(dev); > > SYSCTL_ADD_PROC(&clist, SYSCTL_CHILDREN(fan_oid), OID_AUTO, > > "Fan level", CTLTYPE_INT | CTLFLAG_RW, 0, 0, > > acpi_fan_level_sysctl, "I" ,"Fan level"); > > > > Or whatever code you like=2E > > > > Then you need a sysctl handler: > > > > static int > > acpi_fan_level_sysctl(SYSCTL_HANDLER_ARGS) { > > > > =2E=2E=2E > > } > > > > In the handler function you could "handle" the fan level, and probably= call > > acpi_evaluate_object() on the _FIF, _FPS, _FSL, and _FST methods=2E > > > > Unfortunately, my laptops don't support fans at all=2E So I can't real= ly > > write a fan driver=2E > > I think it is a good beginners task=2E > > > > Basically, if your fan has three or four pins, it might support fan > > levels=2E The first two pins are > > used for electricity=2E The third pin is used to upscale or downscale = the > > power (voltage?), > > thus increasing or decreasing the fan speed=2E There is no magic to th= is=2E > > > > 4=2E Sceleton acpi driver > > > > If you need a sceleton acpi driver, that shouldn't be a problem=2E > > FreeBSD puts all acpi drivers (modules) into the acpi subsystem > > (sys/dev/acpica), instead > > of giving them a separate makefile in sys/modules=2E > > > > This was my first attempt, without ever testing anything (bugs to be > > expected): :-) > > > > #include "opt_acpi=2Eh" > > #include > > #include > > #include > > > > /* for testing, aka printf */ > > #include > > #include > > > > #include > > #include > > #include > > > > /* Hooks for the ACPI CA debugging infrastructure */ > > #define _COMPONENT ACPI_FAN > > ACPI_MODULE_NAME("FAN") > > > > /* driver software context */ > > struct acpi_fan_softc { > > device_t dev; > > int version; /* either ACPI 1=2E0 or 4=2E0 */ > > }; > > > > static device_method_t acpi_fan_methods[] =3D { > > /* Device interface */ > > DEVMETHOD(device_probe, acpi_fan_probe), > > DEVMETHOD(device_attach, acpi_fan_attach), > > DEVMETHOD(device_detach, acpi_fan_detach), > > DEVMETHOD_END > > }; > > > > static int > > acpi_fan_probe(device_t dev) > > { > > static char *fan_ids[] =3D { \ > > "PNP0C0B", /* Generic Fan */ \ > > "INT3404", /* Fan */ \ > > "INTC1044", /* Fan for Tiger Lake generation */ \ > > "INTC1048", /* Fan for Alder Lake generation */ \ > > "INTC1063", /* Fan for Meteor Lake generation */ \ > > "INTC10A2", /* Fan for Raptor Lake generation */ \ > > NULL }; > > int rv; > > > > if (acpi_disabled("fan")) > > return (ENXIO); > > rv =3D ACPI_ID_PROBE(device_get_parent(dev), dev, fan_ids, NULL); > > if (rv <=3D 0) > > device_set_desc(dev, "ACPI FAN"); > > return (rv); > > } > > > > static int > > acpi_fan_attach(device_t dev) > > { > > int error; > > ACPI_HANDLE handle; > > ACPI_HANDLE tmp; > > struct acpi_fan_softc *sc; > > > > sc =3D device_get_softc(dev); > > handle =3D acpi_get_handle(dev); > > > > /* fans are either acpi 1=2E0 or 4=2E0 compatible, so check now=2E= */ > > if (ACPI_SUCCESS(acpi_get_handle(handle, "_FIF", &tmp)) && > > ACPI_SUCCESS(acpi_get_handle(handle, "_FPS", &tmp)) && > > ACPI_SUCCESS(acpi_get_handle(handle, "_FSL", &tmp)) && > > ACPI_SUCCESS(acpi_get_handle(handle, "_FST", &tmp))) > > acpi_fan_softc=2Eversion =3D 4; > > > > else /* nothing to do in acpi version 1, really */ > > acpi_fan_softc=2Eversion =3D 1; > > > > return 0; > > } > > > > static int > > acpi_fan_detach(device_t dev) { > > sysctl_ctx_free(&clist); > > return 0; > > } > > > > > > static driver_t acpi_fan_driver =3D { > > "fan", > > acpi_fan_methods, > > sizeof(struct acpi_fan_softc), > > }; > > DRIVER_MODULE(acpi_fan, acpi, acpi_fan_driver, 0, 0); > > MODULE_DEPEND(acpi_fan, acpi, 1, 1, 1); > > > > _____________________ > > 5=2E How linux does it > > > > You can check linux fan driver on github: > > https://github=2Ecom/torvalds/linux/tree/master/drivers/acpi > > > > They separate the driver into three files=2E > > fan=2Eh > > fan_attr=2Ec > > fan_core=2Ec > > > > It's ok to learn from linux=2E :-) > > > > > > Sorry for long message=2E > > Georg=2E > > *Gesendet:* Mittwoch, 03=2E Mai 2023 um 02:26 Uhr > > *Von:* "Dmitry N=2E Medvedev" > > *An:* "Adrian Chadd" > > *Cc:* freebsd-acpi@freebsd=2Eorg > > *Betreff:* Re: managing a fan speed via memory address > > good morning Adrian, > > > > 1=2E I am just learning :) Not 100% sure ACPI has anything to do with = fan > > control ( still it looks that it actually does ) > > -- found the Advanced Configuration and Power Interface Specification = PDF=2E > > Will spend some time grasping the ideas > > 2=2E to quickly write any driver I will have to first find out how to = do it > > :) any guidance ( preferable in textual form will be greatly appreciat= ed ) > > will learn it :) > > 3=2E there isn't a single thermal sensor, but the SAS disks report the= ir > > temperatures > > ( via dmidecode if I am not mistaken, or some other program -- I will = be > > more sure tomorrow morning )=2E > > so, theoretically I could be able to read their temperature and decide= if > > I would like to send more power to the fan=2E > > > > On Wed, May 3, 2023 at 2:14=E2=80=AFAM Adrian Chadd wrote: > > > >> Is it not an ACPI driver? If not, you could write a quick fan driver! > >> > >> Is there a thermal sensor(s) you could read to see how warm they get? > >> > >> > >> > >> -adrian > >> > >> > >> On Tue, 2 May 2023 at 17:06, Dmitry N=2E Medvedev < > >> dmitry=2Emedvedev@gmail=2Ecom> wrote: > >> > >>> good morning, > >>> > >>> Recently I have learned about the dmidecode program and found the > >>> address of the FRNTFAN port in my HP Z420 machine: 0x0037=2E > >>> Since I am a complete newbie, I would like to learn if there is a wa= y to > >>> read and change the value at this address=2E > >>> I need a bit of guidance=2E > >>> > >>> *The context*: I have added 8 SAS disks to the machine, put noctua f= an > >>> in front of them and connected the fan to the FRNTFAN port on the > >>> motherboard=2E > >>> It looks like the fan works, but I am sure the disks would benefit i= f > >>> the fan produced more pressure=2E Which I fantasize I could do via c= hanging > >>> the value at the said address=2E > >>> Not sure, of course=2E > >>> > >>> best regards, > >>> Dmitry N=2E Medvedev > >>> > >>