Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2521750rwo; Thu, 3 Aug 2023 10:32:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlEA60YA4MmqkQGz5ZeXuc1grWwMrkWQBvOZ18DabfWicXFB0318ePFQNrsHNx+ypWgshYZq X-Received: by 2002:a2e:990c:0:b0:2b7:3656:c594 with SMTP id v12-20020a2e990c000000b002b73656c594mr8506987lji.3.1691083929722; Thu, 03 Aug 2023 10:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691083929; cv=none; d=google.com; s=arc-20160816; b=sJrUnQnZLYL1tH3yHT2VyH+wuQm8X3a3FMpuQoJCyVQS+aK+eqPUY6qlGaRn4GAVYc BZSMapS3Z4hdrI0ikO2hJfxeCRoJPHkBXb5ocUU8KW2TuhIF8wUNJtNNnIaND9vYDNWN Yc5P+0Nsy4y6z7Tpkiq2m1vcMS/qdxB/hR8nTUcWtdWigmUZZWkkZocaCoEkaJoNM56V WRVAiv8RagzAsz6QIkXpywarIuN+ZBH7kWtWtIeDXmGVwT7IEbqqqKs0bpm42hx52/lX lycn9J4cQp4Rkoc7UUEP+ppGmzGRxranHDOI8Lg4SLdXpjgxCK9+8a4ubK5MkDOlG36z F/cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CRKQYTjj0CFOrgdAwpq3qfe246RqaR7qimHx7YtH0AI=; fh=nSKBlyqdkKNC6TThtUZnMmy3FM/UamNp3DF6XNwe6eQ=; b=qVqTeEyW9j4fnMWOrba90v3n2Wwrpi7mK89CLiWB+Xvn9AOhyHt+pLDOfpW4WIBVHN C9haC9udr8UmuZmJM1UwnNyfipjylJIiYCgBE5VYPQzPZfXgRngbKXbe7FWKXwnm82EL likNV1EyRFMuw5ab7xn41XSXktSgtmKa3tY+aE241GRqxW904WKuHwTKxjyD0OcrPpcB e3xWzX875WTXjM801J2TAy7hHa0Qx3n5dUWvXpHdHUJcAUTN3bx6ZA7W22S5pX4pf1hF 6WIyzu2X7RA2IYLza38OXBqfDHyF/DW8oyp0bYZQ0fzb6xPGQogmUnfiQORJ5M/BtCoq rsHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rfU25oyJ; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi13-20020a170906da0d00b0099bd0a03abesi149319ejb.931.2023.08.03.10.31.44; Thu, 03 Aug 2023 10:32:09 -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=@linaro.org header.s=google header.b=rfU25oyJ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234935AbjHCQUS (ORCPT + 99 others); Thu, 3 Aug 2023 12:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235173AbjHCQUQ (ORCPT ); Thu, 3 Aug 2023 12:20:16 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EABD8198A for ; Thu, 3 Aug 2023 09:20:08 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3179ed1dfbbso1043718f8f.1 for ; Thu, 03 Aug 2023 09:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691079607; x=1691684407; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CRKQYTjj0CFOrgdAwpq3qfe246RqaR7qimHx7YtH0AI=; b=rfU25oyJ5QoiyIrcdinKTQcvapOerJX5BqnFjnQpVQHbkp3MM4MocxKjaFxAxHzI2N qZZ/RixXllNlks7AaOLxXBdezK0/7du/QVkuaOsWnh0FtMl1tip5G912x8oPSt3kpxSk HKypbYZDeVjvCX8RAAsQzuBG/LdLK62Kkil+PhiL9DiZBdHhXbYGlIb+d2eZBjKUsmSJ Z6WeeTGLI+Ggd3E/EL/fDv7tcBz7bS/ELiZOS+XrAAQK8IRUFV6/finvC69IKtZME/2n QHB82cSDsv9ywMtOZddwOJU/5NNn32bB1wIk45FyjeNKRjPu4VSsnaohe9bL3Q51pzHZ m6jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691079607; x=1691684407; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CRKQYTjj0CFOrgdAwpq3qfe246RqaR7qimHx7YtH0AI=; b=d4rRD+j7xtaJcrac+3MlzKPSzH7fIgy8jM39Q1qdyk2y3BCJt8DYwWKAsd6XtF+ksU uWDHpqQvypKXnQXsgJzzLy5Gu38aG8afE82cO17ySJqVfFKS2GuAKNal4OsuXNV0anAZ ZfQ8jAMkoAKOfAmcPqvpLGKJClfv/PZddmfzsVgBwHVVUWIsWLT2EAj4czxlnTMP2U+9 sITNjNlR878jYbreYMV+0wgECIOZ422Exyzd49pL5yjUGpR6XmX9/LsOYHAPuEzwfKo6 3hnLODmRK7WegbEnIcT8GrddqiDvLRQnUhP1t1bH/lZ8XxDWItiKcDkYWgDRYdyJu9dl PHHA== X-Gm-Message-State: ABy/qLb7V6UU/gsqX9E4s5pQWRlGWcUoVIj+pcSAGpNoM7UBSzdMMpjL OOA7ZFkF2jAhOHOyGvzDh2rGuQ== X-Received: by 2002:a5d:457c:0:b0:314:385d:6099 with SMTP id a28-20020a5d457c000000b00314385d6099mr8174596wrc.35.1691079607325; Thu, 03 Aug 2023 09:20:07 -0700 (PDT) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id w14-20020adfec4e000000b003141e629cb6sm214343wrn.101.2023.08.03.09.20.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Aug 2023 09:20:06 -0700 (PDT) Message-ID: Date: Thu, 3 Aug 2023 18:20:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v3 1/8] thermal: core: Add mechanism for connecting trips with driver data Content-Language: en-US To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux ACPI , LKML , Linux PM , Michal Wilczynski , Zhang Rui , Srinivas Pandruvada References: <13318886.uLZWGnKmhe@kreacher> <12254967.O9o76ZdvQC@kreacher> <4501957.LvFx2qVVIh@kreacher> <2d0315d4-35b4-84db-4dcb-c9528abad825@linaro.org> <5c93d78d-835e-c740-280b-9d76456aaeda@linaro.org> From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 03/08/2023 16:15, Rafael J. Wysocki wrote: > On Thu, Aug 3, 2023 at 3:06 PM Daniel Lezcano wrote: >> >> On 02/08/2023 18:48, Rafael J. Wysocki wrote: >> >> [ ... ] >> >>>> Let me check if I can do something on top of your series to move it in >>>> the ACPI driver. >>> >>> It doesn't need to be on top of my series, so if you have an idea, >>> please just let me know what it is. >>> >>> It can't be entirely in the ACPI driver AFAICS, though, because >>> trips[i] need to be modified on updates and they belong to the core. >>> Hence, the driver needs some help from the core to get to them. It >>> can be something like "this is my trip tag and please give me the >>> address of the trip matching it" or similar, but it is needed, because >>> the driver has to assume that the trip indices used by it initially >>> may change. >> >> May be I'm missing something but driver_ref does not seems to be used >> except when assigning it, no? > > It is used on the other side. That is, the value assigned to the trip > field in it is accessed via trip_ref in the driver. > > The idea is that the driver puts a pointer to its local struct > thermal_trip_ref into a struct thermal_trip and the core stores the > address of that struct thermal_trip in there, which allows the driver > to access the struct thermal_trip via its local struct > thermal_trip_ref going forward. > > Admittedly, this is somewhat convoluted. > > I have an alternative approach in the works, just for illustration > purposes if nothing else, but I have encountered a problem that I > would like to ask you about. > > Namely, zone disabling is not particularly useful for preventing the > zone from being used while the trips are updated, because it has side > effects. First, it triggers __thermal_zone_device_update() and a > netlink message every time the mode changes, which can be kind of > overcome. Right > But second, if the mode is "disabled", it does not actually > prevent things like __thermal_zone_get_trip() from running and the > zone lock is the only thing that can be used for that AFAICS. > > So by "disabling" a thermal zone, did you mean changing its mode to > "disabled" or something else? Yes, that is what I meant. May be the initial proposal by updating the thermal trips pointer can solve that [1] IMO we can assume the trip point changes are very rare (if any), so rebuilding a new trip array and update the thermal zone with the pointer may solve the situation. The routine does a copy of the trips array, so it can reorder it without impacting the array passed as a parameter. And it can take the lock. We just have to constraint the update function to invalidate arrays with a number of trip points different from the one initially passed when creating the thermal zone. Alternatively, we can be smarter in the ACPI driver and update the corresponding temperature+hysteresis trip point by using the thermal_zone_set_trip() function. [1] https://lore.kernel.org/all/20230525140135.3589917-5-daniel.lezcano@linaro.org/ -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog