From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D40D73A543F for ; Thu, 30 Jul 2026 06:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785392534; cv=none; b=PFQU//hUV54OvPEqXjdl41qC8A/YSMVBWmKes3tx1bZtZu04Npoq7XKsfn5hi5TtiNkDIXxDjRx8nlI7N7Dmt8MQh+P136nMy8n5YGdy+q6U4azbVW5PN+zfUFVkPn6sXEAJ68l1hde/bBjo0Kkr9TwidZimuChHUOmsmn+/5xU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785392534; c=relaxed/simple; bh=1ZJYHoHJ37ZZpsYH9NUMN2wGcABiworAjC/Sr2cVmOk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UhzwBJRq0LxDd1kQ2c3kVd2APah1LlwHpaoLAIIfBYhZKqLvcGnnpr3Mxu3VrTu+jQRmSrN+z4y6QRA7UWXr7nUpKzdum2MT1RXSKupdaHQ2ibZvS+eFslQfT0pejQOCg5HHPEVtPR2ptL0kDu4351z6b3PsKRFZnSUVNeinHUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=BZiQeIE7; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=bq99Vpkn; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="BZiQeIE7"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="bq99Vpkn" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66U6KfFd167119 for ; Thu, 30 Jul 2026 06:22:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= g+th42AJhFhfR2DwxCr52sTk8OWy30+SGiJN/KlR2cA=; b=BZiQeIE7PBFHb/4r YstZTjLNO52KXW72e9lbESjHl8/bKG3ZoPHWZQXAG+Hla1KvrWMyMGMjbVElv3KL 0XB5bYAcid2gDJt/Xf927dWxZSobF/GuiFVSx0sN4aTQ8oK1DhS7excxsgy+x+OT Uow20uPE/eAQrbksKF5dMh2ehzNlQsx4pctLf6UOsewZZET5Tw1bVZ/EAm8moah3 +im7Fb4FLQu61fsjNwq0zsuKZWk7PxHep4+rSOTqYh1TPX305VpzY5Ft1559QFpW aBR58h+jizstkp3blOlBk7lgN1460hTE6tjShIpIBjjwxq/fCoMy76ZxoHxiVFCL RLT3Og== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fr18wg06q-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 30 Jul 2026 06:22:05 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-8485b7e18b4so3069671b3a.1 for ; Wed, 29 Jul 2026 23:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785392525; x=1785997325; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=g+th42AJhFhfR2DwxCr52sTk8OWy30+SGiJN/KlR2cA=; b=bq99Vpknk9+TSI+K209y2LAT9gSiSwygnyAsD8acXjenrmg6eAy1VHTY7hEX8xq4X5 OJcfsz+nSUiXeZbDl+gbDHibJU50Y5ayoG/VezzsEmsssaAnu+NfEjRz12EFOnEXOWQo k8HLmGM5LdM0N/vI3Hzb59FEj2VYWqV0KxF3uEniYM+A/PXTQL0iVr16DS8bF6Ix1cRP t+NmNKCvnNDmVGX6VQK6rIWaQrS0JkvChPYvzUNEBzljRQ9st0LWsW3lYWnYoAquRLNq pRS/opdnCunWm3kw12cowDsUDb/MvNHqQv0HQE3vAv4VLmXty8tcjU0nSdJPO67Kfiua vfrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785392525; x=1785997325; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g+th42AJhFhfR2DwxCr52sTk8OWy30+SGiJN/KlR2cA=; b=JqVNK8OPD6XH8jU3kPOUcN/Akn4iWnXyXJknJsbmVfcKHJS/giCnoBnZd/O9r2QZQB AugoAcBCB3N41IuBJSg6I1YYNYEBlkGBXY7LiIjiwY1zLzkwdfd4TE9l1YvYSmAT6zFA xOYCO5yf8bw7S6Rniybg9pq2gddhXpkzXj8YPuyw8gexgffpOJNoL2slXLL8G/qNzfD5 1z0fsV0GpmgHhHI/oyW5f6naqqunSs44leF+wSeWKX6Q/BDNawae9lQqWKMZ8TN7gOzO niuH9Hky02YwUcGmqJeiCTmzYcqfUdey2t6h7+J1f4sjUEUs9dy7iqQgU42Jh/yaLP1S F2sA== X-Forwarded-Encrypted: i=1; AHgh+RqAx2ErQ8XvU+dLOWL5JAo4dinzJ4v0FPdMjlRwXGN2ZMHO+91grHm8JrvOU/Fpdb5abYfpAyvFiMOeiLE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy80A3BcoeCWTqS2xEd+BlzTokJb6emNCfzYwO3trtPOgvIQQgp PwsxglIbBMBONMIoeClLhev4zPUiJL4VWBJdq/IrqKHn6yjLLQq2DxpyHueiqVW9B571e0U1MTZ GlciF5Sd6LIVKl6fwRtm52k96irDLOTQtKlxtGztC0wnuaJHlfFmmrfdRPZhPqVrA4QE= X-Gm-Gg: AR+sD11pv7YgneriyI3xDFSWvbH3sSvloVN67Y0GITvKlrkBzWXO++d/6a/HkQdsw/t NOcxu6CNHhoxkgeqJ4DPRotoZ1F3xcjnyQK5IwddrXEAuNA0Li7dIXO8hagT8BHjmL+z29wuMiv TV7HBr2QpsSNDLlqzYQFzebnpbwYpcaXa6xwZEWOqxZW80mU8/VDj5NMTvpwVGUplDJdkQfbacG ux6O3B4DoTw16bnlgCFLb1m5USahUplNobZcGeZA1/++RnjafcYb7AHGnyC1mvY+mj8Qck6CEVa 202+LYMBENHIPIlpoj1nxxiAn99lOgzd2RRdr8SdYK8s0eGIu4C1eVbJXudChwmpcPdizI70UQS NkSTpKfKFA45PKi1PgtiU1iFMBMUY4fRfNBp+uaKZIhQLJqs3ZO++77qu5IowK1a/+IpRJVjXwe JDy1G4gDaThIrpyw== X-Received: by 2002:a05:6a00:1f0e:b0:845:d286:1fa8 with SMTP id d2e1a72fcca58-84ebc4218e2mr1460839b3a.55.1785392525091; Wed, 29 Jul 2026 23:22:05 -0700 (PDT) X-Received: by 2002:a05:6a00:1f0e:b0:845:d286:1fa8 with SMTP id d2e1a72fcca58-84ebc4218e2mr1460779b3a.55.1785392523752; Wed, 29 Jul 2026 23:22:03 -0700 (PDT) Received: from [10.190.200.192] (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84ea02f8473sm2413144b3a.31.2026.07.29.23.21.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2026 23:22:03 -0700 (PDT) Message-ID: <1612b46d-1291-4593-b24e-464ba2a180ed@oss.qualcomm.com> Date: Thu, 30 Jul 2026 11:51:58 +0530 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 3/8] platform: arm64: qcom-hamoa-ec: Switch fan profile based on power supply state To: Konrad Dybcio , Sibi Sankar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org References: <20260728-ec_add_more_commands-v1-0-771abd65ee1a@oss.qualcomm.com> <20260728-ec_add_more_commands-v1-3-771abd65ee1a@oss.qualcomm.com> Content-Language: en-US From: Anvesh Jain P In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: ZCT0oAuadxIvbrWocQyhS2HsROYR4p6o X-Authority-Analysis: v=2.4 cv=ItAutr/g c=1 sm=1 tr=0 ts=6a6aed92 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=zE2DOYl6_rrREHaYA3YA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzMwMDA0MiBTYWx0ZWRfX1rGJkKEyxCeT 9e2vCp3GRZQGQMhKR+y/rvuPn2mUaJfi/DVFyEuf1odvKMRdJCsFmKymydRmsE//9C2QflOwzU3 07KqJQL9wuBVF9IzcurMpbe3sdWO0srwZgEiuKvdv5rAy2hnpuShlzkpf5BUnlQpRYFlUEtB1rs L6VtvfCJK9UI3gAJjvgpW2OZKAgJ3REe/WAvTvlQBd8SpnNJrLdnZPeDd15MkN9xNuWsjCqdl1q UVbFUZirxaPnmHu2hcSCIuKiTPVwXKhDGBtFx7NEZox7ikYyaiAvgmgI+B1d003rZz10SRgMPw2 T9W2Y5uDRlabaQWwYxlT6R0f8Yr41L3v9SX9kgVn6mzPIApq5/AbmzPcPW3PkodD9WUg5uhh/um t9mc4fVB4K0NqKZU3O8OLNhxnLzlHGYOecCJujT73rCdGaxhnPN+iFO7ZKVYWvt8SOik52ifCKQ lM5XB4k5lPaGXr/pp6w== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzMwMDA0MiBTYWx0ZWRfX4ysGwnOXD78J eHEAKLQ7F6R7CcFdMO7Zt5HYxFKoxG4TW4tyCC7SCouHn1DnxhpQh2pSsnlsGACXGo9ArsqgbQN rX5oQ0uTo7fhnlhYuUKrdTXrR66m5+M= X-Proofpoint-GUID: ZCT0oAuadxIvbrWocQyhS2HsROYR4p6o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-30_01,2026-07-29_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607300042 On 7/29/2026 4:32 PM, Konrad Dybcio wrote: > On 7/28/26 7:44 PM, Anvesh Jain P wrote: >> Add the EC command definitions and handler functions for switching and >> reading the EC fan profile. >> >> Register a power supply notifier so the driver can react to AC/battery >> transitions: on each PSY_EVENT_PROP_CHANGED notification, queue work >> that checks power_supply_is_system_supplied() and, if the AC/battery >> state has actually changed, switches the fan profile to the >> performance profile on AC or the battery-saver profile on battery. >> Track the last-applied state in on_ac_power to avoid redundant EC >> writes. Run the initial sync once at probe time, and defer the actual >> switch to a work item since the notifier callback runs in atomic >> context. >> >> Serialize the fan profile write under the existing io_lock mutex, >> alongside the other EC command sequences. >> >> Signed-off-by: Anvesh Jain P >> --- > > [...] > >> +static int qcom_ec_set_fan_profile(struct qcom_ec *ec, u8 profile_id) >> +{ >> + int ret; >> + >> + ret = i2c_smbus_write_byte_data(ec->client, EC_FAN_PROFILE_CMD, profile_id); > > Shouldn't all the accesses be serialized after patch 2? > It already is, both call sites hold ec->io_lock around these calls, same as every other qcom_ec_read()/qcom_ec_write() site in the driver. None of these low-level accessors take the lock themselves; that's intentional so callers can wrap multi-command sequences atomically. No gap here. > [...] > >> +static int qcom_ec_update_profile_from_power_supply(struct qcom_ec *ec) >> +{ >> + int on_ac_power; >> + u8 profile; >> + int ret = 0; >> + >> + on_ac_power = power_supply_is_system_supplied() > 0 ? 1 : 0; > > Comparisons already return a boolean value (i.e. the ternary operator is > not necessary here) > Ack, will drop the ternary — on_ac_power = power_supply_is_system_supplied() > 0; is equivalent. >> + >> + profile = on_ac_power ? EC_FAN_PROFILE_BEST_PERF_PLUGGED_IN : >> + EC_FAN_PROFILE_BETTER_BATT_ON_BATT; > > Is being on a (powerful) charger a prerequisite for entering this profile? > Currently plugging in a 5W charger would trigger the switch as well. > > Should this instead be exposed as a fan profile for userspace? > > Konrad Fair point — power_supply_is_system_supplied() only checks mains presence, not charger wattage, so even a 5W charger triggers the "best performance" profile. And exposing this via platform_profile instead of an automatic AC/battery switch would let userspace make the call instead. Will check on the feasibility of making this possible. -- Best Regards, Anvesh