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 791053803C8 for ; Wed, 29 Jul 2026 11:03:07 +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=1785322988; cv=none; b=bQqwYtL3YEmhY3fLzz9Kllw9pqTVa2A/IAko0K4nBPLD8C6A9BmcQQJOwLfYc78RPN72O1Fj25DKEkAY+0MVlvSleiuO85B9H3o9V26H3nNKulWHY2wCgdSII5iWayPiYFPf8CrOY8XFYZcV7rR17Wl60R1Q8991Lo67qc9IRw8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785322988; c=relaxed/simple; bh=PxOtOLx01FWwtuTSeEKZdDI2cMEM41pZ6VTI5diTbmw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AsTlsV6d2kqixl3AlMdZQ1WVWsFLv83cNwHD7cGskTamsPPOJOpi6GSrySIScZ34WBhFkwZnKrPYnE79n7swFw437NhBcAFgIZXdL2kURkPOZoIU9aQ0NXi/MBbJZH63TTUjCV/s4PKAWQZVl0FexAoQPRyrliwN+yRww27uDME= 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=idfMF46d; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ft6RS99g; 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="idfMF46d"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ft6RS99g" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66T7f9kq683452 for ; Wed, 29 Jul 2026 11:03:06 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= za0FHuojM5j39EDfBnNki699HVub6S3hVXHlAo6pnRc=; b=idfMF46dQbv0R6vl 2j12h7nz7rJUyx0Y8qkretvbs5ejVQsu9922KI9Wgxj8kFB+zTz+BwwBV20a4S1y YGrN3k4DhUqSKljMNJeH53VrBn6UOKdFLvqwfuN4COKLShTrhe6NI6S7W7gBnVaA nV6SSZOIjY9ZXxjSQ0wytBqVipFP6ok+sT6+8XUvydo0dq4WikxoD7H+5dSu1cZ+ xuH5uGOcppZ4uqGPvIsSO6lq/ik+K/IIwdX88LUa88PoJEh9SWftRIKl5G24c533 OH8COo5cY7R6zXo+cPObVYxy/qyFVZC6Z6H/H+ue0olvjVzs3ptafg4rUD15kI/w Cn4xZA== Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fqbn1s9vb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 29 Jul 2026 11:03:06 +0000 (GMT) Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-976fa12c2dfso8992241.1 for ; Wed, 29 Jul 2026 04:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785322985; x=1785927785; 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=za0FHuojM5j39EDfBnNki699HVub6S3hVXHlAo6pnRc=; b=ft6RS99gV0YCQrN0QM4BdKOowgyezcdv6C1ubAEZCUmvbGxmtUYtVb+oBLXD3Y4CF9 4DAY8lxiaPAGvbITGvX7L3JFo0H26ty/SKLwjfru8CsFGmY62YnwuCOWmHLEDpML+Otw FByCtG5Wm6vnPZDHAJR15LqUfNBhI02WpIosX6GBSluzXj1h37kV915kWhwTGtkk8eYJ rLZQIke4d58b8B/T2p8i11kElHw5pw9WhCqFnveuRBL6k3NrONNqO4dWjHkZPbW8WH4Q SBM5lcb++tLE6EaI8oJeVnymr33BgE4bKurbryQR7xrzYhdw4mb7mZ7sGTOVzeoJEFPm LcCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785322985; x=1785927785; 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=za0FHuojM5j39EDfBnNki699HVub6S3hVXHlAo6pnRc=; b=QvPkCgk6nHXps7Q2m89RMtdUtRRRz3cllqKMNwBq90pgtlSraoJ7J91R6B77B43ILp DzXAn9KZTVVGfywL5dk/AJpunQWfG0gmGcWFNZ0nAAGzfV29L2r1x/UPT9FFwUhFEIAi OnRIOeNDALSxfB+hWCxHm30mEFxAP05AGLAJt4Jcv5Li7IQbtHDnoRKyvZcdR9eoy1T2 hkpPW4aYyZrojOrNNcb0x9pUyXafiZwZQUPMuhI5kcdVewGmsPJ8yjMrf5OWvQ8QhbKq BwSb2t3ftYDVmIv2jUsPFQm68fYUmcERcJu6h6nxBNV5PJ/gWmGG+LXoyI3MLMHiAIz1 SmYw== X-Forwarded-Encrypted: i=1; AHgh+RpvXHmTPTGcZtE0CoYbVs45WsepZZaoU7OO1gFWX5Yre48ZXnBuG72s2IWp6LL9YdWhPOLCpCSEYp24GW8=@vger.kernel.org X-Gm-Message-State: AOJu0YzSMEJlpwt73LdaVngSIsPldAt4Q4U9qVsoqAeA7/kNlaw489oA IJmcsyYednsC2I4WW2SbzcWh8FIMaOR6GgYIGtRW4czh7R9njF+8yyJnoSz0YoX1aOy5fvRJyXV 17fQiXQUXcPp/zm1ZfER4+41LVI2kUqPhcp7Hin54vfgwcHZiVd3o3AvRb4WpJ+3/JWQ= X-Gm-Gg: AR+sD12oHxGke6URFqtcsVIA+OuUDcMbNdFXOQJVjXCov6Yy8c/fEC/BBwKtQ0ueNFo oEtztZea23+0LpKMdVz/QZCKQ12LwzwA0bKhKoi3EIFUCzyqOFdiH4GGx34QIGqnY357mdzW3h7 VGQGHz9c8kTWB2PzHrB9jYjILYtU7XYVxLvMIXRIvpVlpLRqXpOnONijLAz9H38EWmYSxRXi8o7 Zp2kUh8Tuifl1ri3jvkGhjLCKMS8JUogyZRmi+edL/OJf8g707irNJS/6AQUIv5wBgMKr/gMgcL NbIQq92JroQSyrutCxCjwQC+E0W73Ju+tW7KSF06IGEAp6cMSX/aBKM3yUq89m9pH7iej8otTlt Q1t09tD23gm7QomRJHztkVGza X-Received: by 2002:a05:6102:1485:b0:74d:ce65:3e8b with SMTP id ada2fe7eead31-7549f558f50mr1348668137.2.1785322985470; Wed, 29 Jul 2026 04:03:05 -0700 (PDT) X-Received: by 2002:a05:6102:1485:b0:74d:ce65:3e8b with SMTP id ada2fe7eead31-7549f558f50mr1347388137.2.1785322969721; Wed, 29 Jul 2026 04:02:49 -0700 (PDT) Received: from [192.168.120.193] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a050be9607sm743481a12.12.2026.07.29.04.02.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2026 04:02:49 -0700 (PDT) Message-ID: Date: Wed, 29 Jul 2026 13:02:46 +0200 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: Anvesh Jain P , 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: Konrad Dybcio In-Reply-To: <20260728-ec_add_more_commands-v1-3-771abd65ee1a@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI5MDA5MSBTYWx0ZWRfX+1EIEZccS4qV WFnIYPaasq+E4gaNxB4YysskeYUjlcLq/bdv0/sot4G1Vk2UklMaauKiYEvFwL6qVlV9u0NBB5y WlvVHSj2CJPbDrGCwzG93sNQHw8KWAI= X-Proofpoint-ORIG-GUID: bu7KbC0GUi_CDvx5_qPsqEPDgbruJry4 X-Authority-Analysis: v=2.4 cv=csCrVV4i c=1 sm=1 tr=0 ts=6a69ddea cx=c_pps a=ULNsgckmlI/WJG3HAyAuOQ==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=Cp8rfTUuKJJUPH2W_1oA:9 a=QEXdDO2ut3YA:10 a=1WsBpfsz9X-RYQiigVTh:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI5MDA5MSBTYWx0ZWRfX0rvK0pAAEEWf 7lEjgyA4GugUn439KQ08c7IksvUHFJHnQIwRAoXyVGXL0M4mjefdvSSKLcyaQmPj4CviHnNEfB4 HEeI94SpOTHjSFwuTkFhUOWcOvTRHnszXS3dNi/aMn6B7ImdAK/NJLClTafi+pdhaE9O+C0r+46 zaf7i7Bfcux5ZoYBsLlfolnbxZSfmx93sxdhcsvuliVFXmPQAYG6H4YlbnJQ2A02kx9SvTBhanr QLRluytEp40IOtztpcr9IFM1SUlTEOBXVtzjGrl1cXcb9J6coF4doDdvaQrDTs5loa0hA4GBoiZ SOs6KoU2mO4fv1XwNjyR8clUj6NCw1T/SdEf2zF/SKPFEGHBQJ/H4f9v6LobRmwlJDelNyRdpW9 8v/2BJ8Z52dQk1OvCsBvvg3rHx+aGvGnRDWtGrMPX1bwCiE3WnbC+LaajWYA7SkeeF3Y7uAJ9Nn e5EBKaDa4MNdvyw70Pg== X-Proofpoint-GUID: bu7KbC0GUi_CDvx5_qPsqEPDgbruJry4 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-29_03,2026-07-28_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607290091 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? [...] > +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) > + > + 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