From 54c5848c214922e2c3bf07df6c5789767ff93893 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 2 Jun 2018 22:16:38 +0200 Subject: Thermal: Intel SoC DTS: Translate IO-APIC GSI number to linux irq number The Intel SoC DTS uses a hardcoded GSI number, before this commit it was passing it to request_irq as if it were a linux irq number, but there is no 1:1 mapping so in essence it was requesting a random interrupt. Besides this causing the DTS driver to not actually get an interrupt if the thermal thresholds are exceeded this also is causing an interrupt conflict on some devices since the linux irq 86 which is being requested is already in use, leading to oopses like this: genirq: Flags mismatch irq 86. 00002001 (soc_dts) vs. 00000083 (volume_down) CPU: 0 PID: 601 Comm: systemd-udevd Tainted: G C OE 4.17.0-rc6+ #45 Hardware name: Insyde i86/Type2 - Board Product Name, BIOS CHUWI.D86JLBNR03 01/14/2015 Call Trace: dump_stack+0x5c/0x80 __setup_irq.cold.50+0x4e/0xac ? request_threaded_irq+0xad/0x160 request_threaded_irq+0xf5/0x160 ? 0xffffffffc0a93000 intel_soc_thermal_init+0x74/0x1000 [intel_soc_dts_thermal] This commit makes the intel_soc_dts_thermal.c code call acpi_register_gsi() to translate the hardcoded IO-APIC GSI number (86) to a linux irq, so that the dts code uses the right interrupt and we no longer get an oops about an irq conflict. Signed-off-by: Hans de Goede Signed-off-by: Zhang Rui --- drivers/thermal/Kconfig | 2 +- drivers/thermal/intel_soc_dts_thermal.c | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 82979880f985..0e69edc77d18 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -360,7 +360,7 @@ config INTEL_SOC_DTS_IOSF_CORE config INTEL_SOC_DTS_THERMAL tristate "Intel SoCs DTS thermal driver" - depends on X86 && PCI + depends on X86 && PCI && ACPI select INTEL_SOC_DTS_IOSF_CORE select THERMAL_WRITABLE_TRIPS help diff --git a/drivers/thermal/intel_soc_dts_thermal.c b/drivers/thermal/intel_soc_dts_thermal.c index c27868b2c6af..1e47511a6bd5 100644 --- a/drivers/thermal/intel_soc_dts_thermal.c +++ b/drivers/thermal/intel_soc_dts_thermal.c @@ -15,6 +15,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -31,6 +32,7 @@ MODULE_PARM_DESC(crit_offset, /* IRQ 86 is a fixed APIC interrupt for BYT DTS Aux threshold notifications */ #define BYT_SOC_DTS_APIC_IRQ 86 +static int soc_dts_thres_gsi; static int soc_dts_thres_irq; static struct intel_soc_dts_sensors *soc_dts; @@ -65,7 +67,21 @@ static int __init intel_soc_thermal_init(void) return err; } - soc_dts_thres_irq = (int)match_cpu->driver_data; + soc_dts_thres_gsi = (int)match_cpu->driver_data; + if (soc_dts_thres_gsi) { + /* + * Note the flags here MUST match the firmware defaults, rather + * then the request_irq flags, otherwise we get an EBUSY error. + */ + soc_dts_thres_irq = acpi_register_gsi(NULL, soc_dts_thres_gsi, + ACPI_LEVEL_SENSITIVE, + ACPI_ACTIVE_LOW); + if (soc_dts_thres_irq < 0) { + pr_warn("intel_soc_dts: Could not get IRQ for GSI %d, err %d\n", + soc_dts_thres_gsi, soc_dts_thres_irq); + soc_dts_thres_irq = 0; + } + } if (soc_dts_thres_irq) { err = request_threaded_irq(soc_dts_thres_irq, NULL, @@ -90,8 +106,10 @@ static int __init intel_soc_thermal_init(void) return 0; error_trips: - if (soc_dts_thres_irq) + if (soc_dts_thres_irq) { free_irq(soc_dts_thres_irq, soc_dts); + acpi_unregister_gsi(soc_dts_thres_gsi); + } intel_soc_dts_iosf_exit(soc_dts); return err; @@ -99,8 +117,10 @@ error_trips: static void __exit intel_soc_thermal_exit(void) { - if (soc_dts_thres_irq) + if (soc_dts_thres_irq) { free_irq(soc_dts_thres_irq, soc_dts); + acpi_unregister_gsi(soc_dts_thres_gsi); + } intel_soc_dts_iosf_exit(soc_dts); } -- cgit v1.2.3-70-g09d2 From 5043f06ecec66410ba708e29ae0ab5333d2f15cb Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Tue, 31 Jul 2018 09:02:37 +0800 Subject: MAINTAINERS: Add Daniel Lezcano as designated reviewer for thermal Add Daniel Lezcano as the reviewer for thermal as he would like to participate in the review process effort for the thermal framework, especially the SoC part. Signed-off-by: Daniel Lezcano Acked-by: Eduardo Valentin Signed-off-by: Zhang Rui --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0fe4228f78cb..1890aadc7a3f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14119,6 +14119,7 @@ F: drivers/media/radio/radio-raremono.c THERMAL M: Zhang Rui M: Eduardo Valentin +R: Daniel Lezcano L: linux-pm@vger.kernel.org T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git -- cgit v1.2.3-70-g09d2 From d7a4303b8d1fa6f60b73ed91317a51764a2a412c Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 5 Jul 2018 10:39:23 +0530 Subject: dt-bindings: thermal: Allow multiple devices to share cooling map Allow cooling devices sharing same trip point with same contribution value to share the cooling map as well. Otherwise the same information will be duplicated for each device sharing the trip point. Signed-off-by: Viresh Kumar Reviewed-by: Rob Herring Signed-off-by: Zhang Rui --- Documentation/devicetree/bindings/thermal/thermal.txt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt index cc553f0952c5..eb7ee91556a5 100644 --- a/Documentation/devicetree/bindings/thermal/thermal.txt +++ b/Documentation/devicetree/bindings/thermal/thermal.txt @@ -97,8 +97,8 @@ get assigned to trip points of the zone. The cooling devices are expected to be loaded in the target system. Required properties: -- cooling-device: A phandle of a cooling device with its specifier, - Type: phandle + referring to which cooling device is used in this +- cooling-device: A list of phandles of cooling devices with their specifiers, + Type: phandle + referring to which cooling devices are used in this cooling specifier binding. In the cooling specifier, the first cell is the minimum cooling state and the second cell is the maximum cooling state used in this map. @@ -276,12 +276,7 @@ thermal-zones { }; map1 { trip = <&cpu_alert1>; - cooling-device = <&fan0 5 THERMAL_NO_LIMIT>; - }; - map2 { - trip = <&cpu_alert1>; - cooling-device = - <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + cooling-device = <&fan0 5 THERMAL_NO_LIMIT>, <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; }; }; }; -- cgit v1.2.3-70-g09d2