Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758286AbcLPVNM (ORCPT ); Fri, 16 Dec 2016 16:13:12 -0500 Received: from gloria.sntech.de ([95.129.55.99]:51656 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756270AbcLPVNF (ORCPT ); Fri, 16 Dec 2016 16:13:05 -0500 From: Heiko Stuebner To: Andrew Morton , Matthew Wilcox , Matthew Wilcox , Zhang Rui , Eduardo Valentin Cc: linux-kernel@vger.kernel.org Subject: thermal zones break with patch "Reimplement IDR and IDA using the radix tree" (mainline+next) Date: Fri, 16 Dec 2016 22:12:53 +0100 Message-ID: <1758112.VgMJOyEgSu@phil> User-Agent: KMail/5.2.3 (Linux/4.8.0-1-amd64; KDE/5.27.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2306 Lines: 39 Hi, commit b05bbe3ea2db ("Reimplement IDR and IDA using the radix tree") seems to break thermal zone allocation. This happens both on todays mainline and linux-next-20161216 and produces errors like: [ 9.397201] WARNING: CPU: 1 PID: 165 at ../fs/sysfs/dir.c:31 sysfs_warn_dup+0x64/0x74 [ 9.405145] sysfs: cannot create duplicate filename '/devices/virtual/thermal/thermal_zone1' [ 9.514951] Hardware name: Rockchip (Device Tree) [ 9.522611] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 9.532925] [] (show_stack) from [] (dump_stack+0x88/0x9c) [ 9.542695] [] (dump_stack) from [] (__warn+0xe8/0x100) [ 9.552166] [] (__warn) from [] (warn_slowpath_fmt+0x38/0x48) [ 9.562154] [] (warn_slowpath_fmt) from [] (sysfs_warn_dup+0x64/0x74) [ 9.572834] [] (sysfs_warn_dup) from [] (sysfs_create_dir_ns+0x84/0x94) [ 9.583687] [] (sysfs_create_dir_ns) from [] (kobject_add_internal+0xac/0x2fc) [ 9.595149] [] (kobject_add_internal) from [] (kobject_add+0x48/0x98) [ 9.605829] [] (kobject_add) from [] (device_add+0xd4/0x5b0) [ 9.615714] [] (device_add) from [] (thermal_zone_device_register+0x174/0x5cc) [ 9.627173] [] (thermal_zone_device_register) from [] (__power_supply_register+0x374/0x44c) [ 9.639772] [] (__power_supply_register) from [] (devm_power_supply_register+0x4c/0x7c) System is a Rockchip rk3288-veyron and it has 4 thermal zones (3 from the thermal ip block of the soc and one from the battery). Reverting the patch mentioned above results in thermal zones being registered again. While I haven't looked to deeply into what idr exactly does, some findings: - thermal_zone0 and thermal_zone1 are allocated correctly - every further thermal_zone always gets allocated the number "1" - thermal core calls idr_alloc with 0 for both start and end - the rewrite-patch seems to change the semantics of idr_alloc where it orignally said "@end: the maximum id (exclusive, <= 0 for max)" the "<= 0" part is gone now, but I checked, simply setting INT_MAX as end in the thermal_core does not help Heiko