From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9F862D73AE for ; Wed, 8 Apr 2026 15:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775662366; cv=none; b=dXV8MihSW5NOcvhgXb3ad9aapkA4kI8tG9xZiwUfXv2FUKR4zjc5piSb6bLmyumyEgJfGUFWs8SzaWHLTCITEWtnKx5LujITBkiAoLr8HHbGMCfRNcOHmJvMiu2/hQzuwqKUP71+q+OXQ2LbTVjfmZx3uRItuAPdh6Sx/jbjLTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775662366; c=relaxed/simple; bh=HsdoKi1BR1a1PE/YWtiuPW5nAhnpoTcMvc/QZ5rtUqI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bnPw5h36M5DyBjraB9lxa40FJxvFz/t4Y45E+yngycUnQy/a+ruG18B5lgo33My8TiCsaxtUnd70YKr3VgHYnzg3r5ygK5J0hZlPDZzUPlIKhZGSzvvhQ2d1fIoZsaaRdHn4oztydPFReCZL4nvOZJl2Nk8jgscJHazRZhQjehI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jB3/k0n1; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jB3/k0n1" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-82748257f5fso683053b3a.1 for ; Wed, 08 Apr 2026 08:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775662364; x=1776267164; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=pP8mAGhbGndZoLmXPo55MB7Ai+9sL3BD4rXGUvg7Xm8=; b=jB3/k0n1JhLfQy+iEVwsrJZmXLAYTM7KUIPjaXNiwZi3Nw6vCR1lZBejnnxb2UCmg5 s3yTjphWjZrcz1YvjQFsNTPlXHZq3ZLpIaQSXmjpq2BYYeukF+MQuqdRRixpL0xYLAFI vqZFkMkp4ZN39VvTh3O8KG4aTIsZF4ed+oEjROnJaH6xqfKXU9EJZGNfCbVUbbMcJHEj htvk6XKFHvotYeddbMHauRAAT87xljclibzfWP3YIkD2/CorUdx8Ecp9eS30lHSlzhXq LTdlc8VvDxn6DywIAl6ZLLXUdp0s9kf9JV9XvfWnaiTsmcURX+8sBPmCi3gEpUdGgyeR uJ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775662364; x=1776267164; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pP8mAGhbGndZoLmXPo55MB7Ai+9sL3BD4rXGUvg7Xm8=; b=jOdPtWH5fwTFFnmRf3m/edr6971/iuMH59tayBaGbm3j5iNr7XUYCBL70EhqZ/qx5I czfGlhdPbLxWyP/XMnf81dTJd85/dlRHXNtlpsybQ9IK2cd1vDdXarkC3EnoJBYm7r+U bmyl9jws02p4WtHtVKByD0fIRMWtcyMpMcDOIiwe6M/y4tijG0VtUzCtEJyefc2oRRuK mZjKVPfe8U5qM9aBInXtki0SqOdlxoutqJTcpx1wTkU6qNNKdrfxzeO2YPwTe8cAbMo7 fgZrUKSTf4Q6HODiQn8nNakWdTgpSH0Hx0m/VnVjXB7bsEN/fDOpyk2ETOz+FTI9oSJM WJcw== X-Forwarded-Encrypted: i=1; AJvYcCV5TwdXyyJk/4hPn4XHXYiBhm9wgQOLL3nNYmL/taOHx+9bEKqLaoMykzY4aD5eR5ypkDATFdYt/U99ffU=@vger.kernel.org X-Gm-Message-State: AOJu0YyuecSOWzEaC9zd13PpjXaBb7bgnFN3gC4fSoJFkhdtZvdZJk2F jDseSlwhWg9B5bQN8ZZsuSxunFZD+Dk7dA/mRrOHKT30F4Yn8fF6W3Tb X-Gm-Gg: AeBDieu4RFpVqVGHjHDIf+WzSEEbeHvrUdwc2rwTgLRZ1nCI79M8w9S+DIhTve2y8rC eLdvvPyhlgy/4k5hrrYudDOlGPrpvIH3V9sWaTHqFDRuT0cSeNg1A89vFJFMHC9NAKgcrAaGHPY wOMXzKoaCePKuXRhGtlhOE5NWWGvxPYXr5jttnkeqd+wltzjboY+3bBqOhnSpfglW7Tt4chc2uY gp3chPdY51yfxxYOL+/gIuNHOzmpnLDhlkhabKegC/aZx0uEnN6PI9DK2r2pkrpfF4UDFOFzASc XBh3PgSNCwRsFNwaFAd5EXuXmnYG0PXOCKxRm6fi4fbF+zX+YTRuTJE8eDTqNXEh16tIMS1/TkL acog3e8Itt1RMUqHN8TiinqFoW/x8ZPLDFT0tBZtWKYD3bGu5Dw++3A5EEHZsf1RQcHOA/sdokG djitLE63nZ89qWAtjiopE5h0754Zf4FweQ9d/V428Q/EZGkAMWXdczEk8jeO5JCpt/2u0n0c60 X-Received: by 2002:a05:6a00:bc92:b0:827:2792:e401 with SMTP id d2e1a72fcca58-82d00268a73mr20001819b3a.15.1775662364210; Wed, 08 Apr 2026 08:32:44 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:da43:aeff:fecc:bfd5? ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9ca1f28sm22038089b3a.57.2026.04.08.08.32.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Apr 2026 08:32:43 -0700 (PDT) Sender: Guenter Roeck Message-ID: Date: Wed, 8 Apr 2026 08:32:42 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RESEND v1] thermal: core: fix blocking in unregistering zone To: "Rafael J. Wysocki" Cc: Jiajia Liu , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Armin Wolf , linux-hwmon@vger.kernel.org References: <20260402022742.17738-1-liujiajia@kylinos.cn> <2432224.ElGaqSPkdT@rafael.j.wysocki> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8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vm1nnoH4licaU5Y1nSkFR/j2douI5P7Cj687WuNMC6CcFd6j72kRfxklOqXw zvy+2NEcXyziiLXp84130yxAKXfluax9sZhhrhKT6VrD45S6N3HxJpXQ/RY/EX35neH2/F7B RgSloce2+zWfpELyS1qRkCUTt1tlGV2p+y2BPfXzrHn2vxvbhEn1QpQ6t+85FKN8YEhJEygJ F0WaMvQMNrk9UAUziVcUkLU52NS9SXqpVg8vgrO0JKx97IXFPcNh0DWsSj/0Y8HO/RDkGXYn FDMj7fZSPKyPQPmEHg+W/KzxSSfdgWIHF2QaQ0b2q1wOSec4Rti52ohmNSY+KNIW/zODhugJ np3900V20aS7eD9K8GTU0TGC1pyz6IVJwIE= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/8/26 08:05, Rafael J. Wysocki wrote: > On Sun, Apr 5, 2026 at 5:34 AM Guenter Roeck wrote: >> >> On 4/4/26 10:38, Rafael J. Wysocki wrote: >>> On Sat, Apr 4, 2026 at 4:02 PM Guenter Roeck wrote: >>>> >>>> On 4/4/26 05:58, Rafael J. Wysocki wrote: >>>>> On Fri, Apr 3, 2026 at 4:20 PM Guenter Roeck wrote: >>>>>> >>>>>> On 4/3/26 05:52, Rafael J. Wysocki wrote: >>>>>> .[ ... ] >>>>>>> It appears to work for me, but I'm not sure if having multiple hwmon class >>>>>>> devices with the same value in the name attribute is fine. >>>>>> >>>>>> Like this ? >>>>>> >>>>>> $ cd /sys/class/hwmon >>>>>> $ grep . */name >>>>>> hwmon0/name:r8169_0_c00:00 >>>>>> hwmon1/name:nvme >>>>>> hwmon2/name:nvme >>>>>> hwmon3/name:nct6687 >>>>>> hwmon4/name:k10temp >>>>>> hwmon5/name:spd5118 >>>>>> hwmon6/name:spd5118 >>>>>> hwmon7/name:spd5118 >>>>>> hwmon8/name:spd5118 >>>>>> hwmon9/name:mt7921_phy0 >>>>> >>>>> Yes. >>>>> >>>>>> Names such as "r8169_0_c00:00" and "mt7921_phy0" are actually overkill >>>>>> since the "sensors" command makes it >>>>>> >>>>>> r8169_0_c00:00-mdio-0 >>>>>> Adapter: MDIO adapter >>>>>> temp1: +36.0°C (high = +120.0°C) >>>>>> >>>>>> mt7921_phy0-pci-0d00 >>>>>> Adapter: PCI adapter >>>>>> temp1: +30.0°C >>>>>> >>>>>> essentially duplicating the device index. >>>>> >>>>> Well, with the patch posted by me, the output of sensors from a test >>>>> system looks like this: >>>>> >>>>> acpitz-acpi-0 >>>>> Adapter: ACPI interface >>>>> temp1: +16.8°C >>>>> >>>>> pch_cannonlake-virtual-0 >>>>> Adapter: Virtual device >>>>> temp1: +33.0°C >>>>> >>>>> acpitz-acpi-0 >>>>> Adapter: ACPI interface >>>>> temp1: +27.8°C >>>>> >>>>> (some further data excluded), which is kind of confusing (note the >>>>> duplicate acpitz-acpi-0 entries with different values of temp1). >>>>> >>>> >>>> Yes, agreed, that is confusing. I would have expected the second one >>>> to be identified as "acpitz-acpi-1". Do they both have the same parent ? >>> >>> No, they don't. >>> >>> The parent of each of them is a thermal zone device and both parents >>> have the same "type" value. >>> >>>>> That could be disambiguated by concatenating the thermal zone ID >>>>> (possibly after a '_') to the name. Or the "temp*" things for thermal >>>>> zones of the same type could carry different numbers. >>>>> >>>>> A less attractive alternative would be to register a special virtual >>>>> device serving as a parent for all hwmon interfaces registered >>>>> automatically for thermal zones. >>>> >>>> If they all have the same parent, technically it should be a single >>>> hwmon device with multiple sensors, as in: >>>> >>>> acpitz-acpi-0 >>>> Adapter: ACPI interface >>>> temp1: +16.8°C >>>> temp2: +27.8°C >>> >>> So somebody tried to make it look like that by registering hwmon >>> interfaces for all of the thermal zones of the same type under one of >>> them, but that (quite obviously) doesn't work. >> >> Not sure I understand why that doesn't work or why that is obvious, >> but I'll take you by your word (I would agree that the current >> _implementation_ looks problematic). > > For example, say that there are two ACPI thermal zones on a system > > /sys/devices/virtual/thermal/thermal_zone0/ > /sys/devices/virtual/thermal/thermal_zone1/ > > The current mainline code registers a hwmon class device for thermal_zone0 only: > > /sys/devices/virtual/thermal/thermal_zone0/hwmon0/ > > because the type is "acpitz" for both of them, but it adds a sysfs > attribute that belongs to thermal_zone1 under it: > > /sys/devices/virtual/thermal/thermal_zone0/hwmon0/temp2_input > > There is also > > /sys/devices/virtual/thermal/thermal_zone0/hwmon0/temp1_input > > but it belongs to thermal_zone0. > > Interesting things happen when thermal_zone0 is removed, for example > because the ACPI thermal driver is unbound from the underlying > platform device. Namely, the removal code skips the removal of hwmon0 > because of the temp2_input attribute belonging to thermal_zone1 which > effectively prevents thermal_zone0 removal from making progress. > > AFAICS, nothing particularly smart can be done to address this issue > while retaining the current design of the code. Reparenting hwmon0 to > thermal_zone1 may confuse user space as well as removing hwmon0 along > with temp2_input. That's why I think that this is a design issue. > The ACPI power meter driver has pretty much the same problem. A clear solution would require making hwmon sysfs attributes dynamic in nature (i.e., by adding the ability to change the visibility of attributes in runtime). I have started working on that, but did not have time to complete the work. The ACPI power meter driver uses a kludge around that: It unregisters the hwmon device whenever it gets a METER_NOTIFY_CONFIG event and re-registers it. Anyway, registering separate hwmon devices, one per thermal zone, is perfectly fine with me. Guenter