Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2450477imw; Wed, 6 Jul 2022 06:14:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vH1ulbL/zC6BulybVQd0LOD4cvGYUE/Z/juGqX+LjyJKcYAeczhdFb0659PQ0XjiS6MLNb X-Received: by 2002:a17:907:3e86:b0:6f5:917:10cc with SMTP id hs6-20020a1709073e8600b006f5091710ccmr39568348ejc.53.1657113269496; Wed, 06 Jul 2022 06:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657113269; cv=none; d=google.com; s=arc-20160816; b=CWK99p8lPGp3/KZF3nCxiGeBBluGwpDP3uCPodatTn+0YbXZy6cRk3zy4Zi0LiUk5O j/oT56vPlpnoUYDgOzJs/QtWR+JWbZlBmQzlXYRIK4VkbiQi11tvhr0MsGvQOb8g7pt2 6TwW2mspsfdChEhp2NhClTefhMzGRRngzSJiqwX4D9UK4xP0rG0kTkKVZO1boc14DJ1d ntTTlEEQ7wkFtEO/bQpicVp5vGsKQAa0ZXiAePpEZVt3VQVkjqw8guUAsb2rFz7TzyY7 orN6/g/b08bbdEP8WJZC0XeqQjMM4O52NDkfFvmiEj8OW5L1HzCfN6OYMTSIgnra/yhS ZIog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:to :content-language:user-agent:mime-version:date:message-id :dkim-signature; bh=0ZwsMZMEyuVmYUY6BiNm7d/QmUV/8RywgdDZkvjd/Jk=; b=e8sD/z971dhvydY8aYBnrkaRKOflz1/v3epXoEOq7N5ehOC/kdrNZpRPP4afF5bf0T ZPab9J45f1ojKcdI4jn5FpVhahbmqGwH9gnBfshxGzp6mbgRRgd3bjzsHhEms/TyeD5b iPInnJpkErfRALQpD3TuEjHP66GdeVUvtdU4/jOGl06yeT9VWYz2CT4VpnNwGjbBOvPI 6XA2dZXTOjUN79yNYu1HnJkJvkdQz4kSNgYJt6EjX6vVX3rq40wFZoU/9lLOgzyjKYFw QJ2jfqSnw6kIOcoOQunHXIjVC+sQY1u5RdCRoms7gzLjv3BOrIG+L30vy89WUPdmR/Ye Bfeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rQ+B62nG; 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 r7-20020a05640251c700b004377a1786c2si25439298edd.581.2022.07.06.06.14.03; Wed, 06 Jul 2022 06:14:29 -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=rQ+B62nG; 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 S232825AbiGFMzB (ORCPT + 99 others); Wed, 6 Jul 2022 08:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbiGFMzA (ORCPT ); Wed, 6 Jul 2022 08:55:00 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B939D1E3 for ; Wed, 6 Jul 2022 05:54:58 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id h14-20020a1ccc0e000000b0039eff745c53so8922923wmb.5 for ; Wed, 06 Jul 2022 05:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:content-language:to:from :subject:content-transfer-encoding; bh=0ZwsMZMEyuVmYUY6BiNm7d/QmUV/8RywgdDZkvjd/Jk=; b=rQ+B62nGB6xChlmZFu1bTH9LmHJjTUoGj4I6bEx1BvCxbRejV01VUmmSmmWdHTEUlH hsZlDlidJou7qij/3V28XMyYrNg/2ARbQqR54RZlv5KAtRPgLXQeplPCpUV9ktDRtSCT XyXzUSMQsIiKuT5djVNxLMY9HHhouao0EvOsETvKsM/4OwFOroAB49XCT64SoTFNjW+7 rGHlrhg3+8mvCsx0T9V+5GKArKmWzKV8QVRP6msyTx0YkTKRv1z2fnLjjRkAgZvx0FjO L91S8NjhiTfY2+BLTE3n0pO6GU3Grl+Qz3KbaMI2LgF6w6nzkMrVFwbp/GoNt04RDOXT asUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:from:subject:content-transfer-encoding; bh=0ZwsMZMEyuVmYUY6BiNm7d/QmUV/8RywgdDZkvjd/Jk=; b=fs5lltLuS12UxCRc+TdEq4ZzXk064uNL8w53uS4U6pS3s2L2BgNsyG6tph6ETevNuh 2miVWWSrwzsH6URnbiOjh6oSH/F11ftJz64yii0d/k8k3A5Rm8aT3GljlcXoHb8lT4Cc FXzpKXYaUhH859mXhd2Z8ZyH0XGEpT204z2pVUkQU7eJUylBt0V4CrvhTYaaRfm6DzCK uKFoLy8A8NAwt13XSx9aY79y68i1h9syokVr1UPlOctuTm4cW7xrjyEmU0VTyw18FELx XKlhneU1lx8/xIqOO5ckqnMG+3Jq0L6Va/NIYCDO30/ScbAov3p5jRG2VGb0QllpBsR3 N+AQ== X-Gm-Message-State: AJIora/QDZRxENGizpe4BqQtDSJfp/NEqLjlmpW9rOZIN4CGt0GKJ3YC kPSd1UtojScojNCaAr6/tGxAQA== X-Received: by 2002:a05:600c:5028:b0:3a0:524c:2aa2 with SMTP id n40-20020a05600c502800b003a0524c2aa2mr43303412wmr.66.1657112097293; Wed, 06 Jul 2022 05:54:57 -0700 (PDT) Received: from [192.168.1.12] (88-107-17-60.dynamic.dsl.as9105.com. [88.107.17.60]) by smtp.gmail.com with ESMTPSA id m10-20020adff38a000000b0021d6de18f68sm6931761wro.22.2022.07.06.05.54.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Jul 2022 05:54:56 -0700 (PDT) Message-ID: <164f2458-fb66-f238-7143-bdbe1e200870@linaro.org> Date: Wed, 6 Jul 2022 13:54:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-US To: Sebastian Reichel , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm From: Caleb Connolly Subject: power_supply cooling interface Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Hi, I've been working on a driver for the charger found in most Snapdragon 845 phones (the OnePlus 6, SHIFT6mq, PocoPhone F1, etc). I wanted to include support for the POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT property. My understanding is that it exposes the current limit as a cooling device so that userspace (or frameworks like DTPM) can optimise for performance in a thermally constrained device by limiting the input current and thus reducing the heat generated by the charger circuitry, a similar idea was applied on the Pixel C: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a4496d52b3430cb3c4c16d03cdd5f4ee97ad1241 However, reading through the sysfs docs for cooling devices, and looking at the implementation in power_supply_core.c, it seems like the behavior here is wrong in a few ways: 1. The values should scale from 0: no cooling to max_state: max cooling, but the power_supply docs and the only existing implementation (the smbb driver) just export the current_limit, such that increasing cur_state would increase the current limit, not decrease it. 2. (unsure?)The scale is completely different to most other cooling devices, most cooling devices don't seem to have a max state much beyond the double digits, but CHARGE_CONTROL_LIMIT is on the scale of uA, so approaches like incrementing the cooling state by 1 don't really work. 3. The value exposed is current, not power, making it tricky for something like the DTPM framework to make good use of it, and making it harder to correlate a particular "amount" of cooling with a change in thermal headroom. I don't really know what the right approach is here, one idea might be to have the power_supply cooling device implementation try and be more intelligent. Scaling based on the power rather than current and exposing some smaller range so that at maximum cooling the device doesn't just stop charging entirely (unless we've hit some thermal trip?). Maybe a way to determine the amount of thermal headroom you can expect by adjusting the current limit on a particular charger / device like a power efficiency curve might be useful too, although gathering that data might be difficult to do. I'll include the POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT and POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX properties in my driver, as the maximum current allowed and whatever the maximum is right now. -- Kind Regards, Caleb (they/he)