Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1608948rwb; Fri, 23 Sep 2022 15:44:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7g1kZTdV5lP6h/GYYWlBwjXGdY/LuSg5i9f4scBxQXm/H+HnMuhxGp9SVJ+2GN6Kpywlej X-Received: by 2002:a17:906:eeca:b0:730:6880:c397 with SMTP id wu10-20020a170906eeca00b007306880c397mr8971864ejb.593.1663973057247; Fri, 23 Sep 2022 15:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663973057; cv=none; d=google.com; s=arc-20160816; b=nL9vQBgbL8uZxDpiOzfgi+UccVWYk6+PIQYi+I+6piuAX+s6jI8FytwzjsVl0c3JJY 4CPrNr3YYHqs3fto2uUtwvWkdEJYHjWz7h7iCS+RsMFsq+aS7GnEio2x4MBhpM9iTgVq ik5RM6cUebLPFiQV9+0I0aEQn9mTm1EoQaN50eGWfKCwm7LgqxFqDPleQeJZLk17Qwp3 6rDuvjpbupC3gAmoibzFLE3njldh7OtycFFWAlZ301wh5yw0YPGitLLMRST6SmzXmofI w396Jo2YnKSJwMBsuB3hDbuW1RnynZL9W5J8YncFbyX6tdKzicSr/MHh4/P22cA2K8JL UpNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=Y0nKIoUfaCsg/EXBd0afFa2cIruznfzPq/OchNG5aew=; b=NucQtvDeYoo7nUbZjGt6Y9TblfOB43HjBZFbjcyq4313/ruDcd5Fw1DcwpYfVqjM0o 3wS5x0r5KUSWQBkkmAPpELBOjI+5JwEsLgX+rT+wOgxRJ5dVhfyMI2O+xeJaBVyQJO6u LgTlxVKbVG2eK3XWIGiIXGW/ILvECIdQmZ410RCIMgRqkmnYJpOcml2Mil7Zv3PjbqgB PI0H3kWALR70OLCEyEgZ6j6zw7Z6Qv916m+++KCNgo1pkY6sEh/eY2gBIo3eBOlTeblF rxO6dJKgIjEJLPSxsxgvzGpVu8ZCdlF9HY55Xiib+ljZuHNUh8WAsTbMtV8LdPN8wiJe xudA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="uw/fUJ+i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb11-20020a170907960b00b006feb76dbd51si8387315ejc.289.2022.09.23.15.43.45; Fri, 23 Sep 2022 15:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="uw/fUJ+i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbiIWWTn (ORCPT + 99 others); Fri, 23 Sep 2022 18:19:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbiIWWTl (ORCPT ); Fri, 23 Sep 2022 18:19:41 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0697519C3D for ; Fri, 23 Sep 2022 15:19:39 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220923221937euoutp0152d3035f89f7f8cc9011c06436f90d2c~XnVVs5bS30972909729euoutp01e for ; Fri, 23 Sep 2022 22:19:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220923221937euoutp0152d3035f89f7f8cc9011c06436f90d2c~XnVVs5bS30972909729euoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1663971577; bh=Y0nKIoUfaCsg/EXBd0afFa2cIruznfzPq/OchNG5aew=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=uw/fUJ+iNNxawiiNEg+cFFYZybUtoV76QYldqlOdtJaIJcKEQC8ssV7fgt02VkjS3 RFLK+MD0oFtFmRu8uV3ceoxy4bfXDB2gypGKQ38n/ALKN5UEHT0Z16L7ICZqcxmq8H XDF3lPBuFNq5Vy4wLmrxU64Id72+b2kTjxFlYDek= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220923221936eucas1p242e1f6e807d036ec3872293ac6c52c24~XnVVCdF5Z1450914509eucas1p2n; Fri, 23 Sep 2022 22:19:36 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 0C.8A.07817.8F03E236; Fri, 23 Sep 2022 23:19:36 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220923221936eucas1p1e01148605c9aaf27d8d71969feb99144~XnVUyMwcb2541025410eucas1p1u; Fri, 23 Sep 2022 22:19:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220923221936eusmtrp12112bfd1533bb8855963fa0fa6589466~XnVUxje8b2319123191eusmtrp1i; Fri, 23 Sep 2022 22:19:36 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-af-632e30f84da1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AD.71.10862.8F03E236; Fri, 23 Sep 2022 23:19:36 +0100 (BST) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220923221936eusmtip109eab2a655d387ee53d23b068ea14331~XnVUZMguV0727107271eusmtip1g; Fri, 23 Sep 2022 22:19:36 +0000 (GMT) Message-ID: Date: Sat, 24 Sep 2022 00:19:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v4 01/30] thermal/core: Add a generic thermal_zone_get_trip() function Content-Language: en-US To: Daniel Lezcano , rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria From: Marek Szyprowski In-Reply-To: <20220921094244.606948-2-daniel.lezcano@linaro.org> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEKsWRmVeSWpSXmKPExsWy7djP87o/DPSSDR5c17M4PL/CYt5nWYvL u+awWXzuPcJoMffLVGaLJw/72BzYPBbvecnksWlVJ5vHnWt72Dw+b5ILYInisklJzcksSy3S t0vgynj9Yx1zwTXJihe3XjI1ML4X6WLk5JAQMJF4OO8CYxcjF4eQwApGiYtffrFCOF8YJRb2 drCAVAkJfGaUODElCq7j9EE2iKLljBLL989ghnA+Mko8W/0IrINXwE5iyfbd7CA2i4CqxMd/ h9gg4oISJ2c+AasRFUiWmHXsGCOILSwQI9F8to8JxGYWEJe49WQ+mC0i4Cjx5e8idoh4scTv Z81gNpuAoUTX2y6wmZwCDhLrf91hhaiRl9j+dg7YQRICJzgkfjQvYoY420Viwr0JULawxKvj W9ghbBmJ05N7WCAa2hklFvy+zwTh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4mutxA3cAo4SKz/dYcVot5Momtr FyOELS+x/e0c5gmMQrOQnDELybpZSFpmIWlZwMiyilEktbQ4Nz232EivODG3uDQvXS85P3cT IzC2th37uWUH48pXH/UOMTJxMB5ilOBgVhLhTbmomyzEm5JYWZValB9fVJqTWnyI0RQYFhOZ pUST84HRnVcSb2hmYGpoYmZpYGppZqwkzutZ0JEoJJCeWJKanZpakFoE08fEwSnVwCT++6D7 uRwxbmnW6qs566V3LdF5uJ3h4P2kwrOHOuKmbb0Vqac3W7AxO6TlmaxyC1PFi/a/QS8PavCW Z5YqGQWqpppcnM9m3tp6Mvu3atz/WdWCRoubvt/gfRN78JzAJ++oh5ckRJJ8v7YcuerB/vXx xhkeR/OPxLdd6og4z1vLd0V54ZKrjb0zfs2Zv8BmSsDb+UKKW09Zcz2Z9GGhfLTG48KpBkVz MgrMf07jWnqeh7W0gPXw6vlHU55p3Si067K4FH3gw+U3WnIx/6sWNq3/u8nxs4a32S+Lmof7 twhm3dzK2ZfGs+fCz/ly6oe4T9zJmzBtfp0k9+XEtdte5fn6Msyfv/6kxccLfof8tVcrsRRn JBpqMRcVJwIA3VYWuzYDAAA= X-CMS-MailID: 20220923221936eucas1p1e01148605c9aaf27d8d71969feb99144 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220923221936eucas1p1e01148605c9aaf27d8d71969feb99144 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220923221936eucas1p1e01148605c9aaf27d8d71969feb99144 References: <20220921094244.606948-1-daniel.lezcano@linaro.org> <20220921094244.606948-2-daniel.lezcano@linaro.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On 21.09.2022 11:42, Daniel Lezcano wrote: > The thermal_zone_device_ops structure defines a set of ops family, > get_trip_temp(), get_trip_hyst(), get_trip_type(). Each of them is > returning a property of a trip point. > > The result is the code is calling the ops everywhere to get a trip > point which is supposed to be defined in the backend driver. It is a > non-sense as a thermal trip can be generic and used by the backend > driver to declare its trip points. > > Part of the thermal framework has been changed and all the OF thermal > drivers are using the same definition for the trip point and use a > thermal zone registration variant to pass those trip points which are > part of the thermal zone device structure. > > Consequently, we can use a generic function to get the trip points > when they are stored in the thermal zone device structure. > > This approach can be generalized to all the drivers and we can get rid > of the ops->get_trip_*. That will result to a much more simpler code > and make possible to rework how the thermal trip are handled in the > thermal core framework as discussed previously. > > This change adds a function thermal_zone_get_trip() where we get the > thermal trip point structure which contains all the properties (type, > temp, hyst) instead of doing multiple calls to ops->get_trip_*. > > That opens the door for trip point extension with more attributes. For > instance, replacing the trip points disabled bitmask with a 'disabled' > field in the structure. > > Here we replace all the calls to ops->get_trip_* in the thermal core > code with a call to the thermal_zone_get_trip() function. > > While at it, add the thermal_zone_get_num_trips() to encapsulate the > code more and reduce the grip with the thermal framework internals. > > Signed-off-by: Daniel Lezcano This patch landed in linux next-20220923 as commit 78ffa3e58d93 ("thermal/core: Add a generic thermal_zone_get_trip() function"). Unfortunately it introduces a deadlock: thermal_zone_device_update() calls handle_thermal_trip() under the tz->lock, which in turn calls thermal_zone_get_trip(), which gathers again tz->lock. I've tried to fix this by switching handle_thermal_trip() to call __thermal_zone_get_trip(). This helps for fixing the issue in this change, but then I've tried to apply it on top of linux next-20220923. Unfortunately it fails again. It looks that the other changes also assumes that calling thermal_zone_get_trip() is possible under the tz->lock, because in my case it turned out that handle_non_critical_trips() called step_wise_throttle(), which in turn called thermal_zone_get_trip(). I gave up fixing this. Please re-check possible call paths and adjust locking to them. > --- > drivers/thermal/thermal_core.c | 87 +++++++++++++++++++++++-------- > drivers/thermal/thermal_helpers.c | 28 +++++----- > drivers/thermal/thermal_netlink.c | 21 ++++---- > drivers/thermal/thermal_sysfs.c | 66 +++++++++-------------- > include/linux/thermal.h | 5 ++ > 5 files changed, 118 insertions(+), 89 deletions(-) > > ... Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland