Date: Tue, 13 Sep 2022 17:03:58 +0100 From: Johannes Totz <jo@bruelltuete.com> To: freebsd-hackers@FreeBSD.org Subject: How to sync/mutex with acpi_tz_get_temperature() Message-ID: <9b87dd66-de57-f363-279e-dc33134c0fa6@bruelltuete.com>
next in thread | raw e-mail | index | archive | help
Hi there, I would like to make sure that some of my code does not run concurrently with acpi_tz_get_temperature() [https://github.com/freebsd/freebsd-src/blob/main/sys/dev/acpica/acpi_thermal.c#L465]. What's the best way to achieve that? I wrote a small driver for one of those SuperIO hardware monitors that measures fan speed, voltage, temperature etc. That works fine. But looking at my board/BIOS's ASL, invoking _TMP is not safe to do concurrently with my driver. [see footnote] Ultimately, acpi_tz_thread() [https://github.com/freebsd/freebsd-src/blob/main/sys/dev/acpica/acpi_thermal.c#L949] is calling acpi_tz_get_temperature() with a few hops in-between. There are a few instances of ACPI_LOCK(thermal) etc but nothing that guards acpi_tz_get_temperature() specifically. Anyone have ideas/pointers? thanks, Johannes footnote: Reading from that chip is stateful, as in you need to do I/O to select which register you want to read/write and then read/write from another location to access the value of that register. Try to do that from 2 threads at the same time, one of them will read/write the wrong register, thus you can glitch ACPI into doing something disruptive/destructive.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9b87dd66-de57-f363-279e-dc33134c0fa6>