From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796129300; b=Bfnzx4j+3E1ls2MDOsY/fUxaXOqBTDsXZGaylsxf9tV6PDR5KdTQpadxrunsmCIkPl4t I5ru0jetveisHUB4nG5jDSomFzgyPgCQI5YL2vmS2npUW79XCGMO3IQ8y5es2Eb5+4AYS z2bRIRNO5zGibwByfJBZV2jiyzdQVASHK5f6xfoiTNr/BfbdueWu18CCuEANAp2nQfp63 W8qu5x4Ez1gdKdAZlOtUNY8+xFXgq1W9dKMaf284d2+WvcP9VK4WOH32gQ0y0lW1QSNck kIW+bT8d20uETbQV1XiayRVavooMDD1fXtaWnXeaxjh3Iw6s5xfRfirZc0YUKFpOT1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129300; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=sHkeIm4RalRpZ4n87opkytrHR25vWnrE4cHamlKiGxU=; b=l2PLEFnLicihkQY5I5sN0o39vts6OD0MWn+ipEwgNErofhoAxIcWmk0kUtHVZl5SlEyT Hlwqcwe3//Pk6k/d3z15WHM9SVDDH53vKg4+oLx13z3BVIehUf/PPt3gDRwpbzgc+Xwi3 r/8FzFHV0Fb4g0iT5BQmMwkl7mLCxZ157eoxQg46ueugegOz58IoYASx4PAXLziPr1rgt Eo5HJqQ4a7+oWpGEQCfW0oZ1djts8NhBlcFjY4eOrkeUaOdGOdmU/XNqArwP78e4lyklh M47zctKOBcW/rwIDWeeGSwCGQubyXLMC8xUCOZnjUw4H6X/wlA96GlghhvzyNBuDkWg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=AIQb9XkD; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=djwr8Tos; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C12960A3809 for ; Tue, 1 Dec 2026 12:48:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0C12960A3809 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.a=rsa-sha256 header.s=qcppdkim1 header.b=AIQb9XkD; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=djwr8Tos Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1AQOps2313327 for ; Tue, 1 Dec 2026 12:48:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=sHkeIm4RalR pZ4n87opkytrHR25vWnrE4cHamlKiGxU=; b=AIQb9XkDL3zsxR41GwT5YNvP7fz 7osopUy4+Qb8x/YVHPoPyvVLHPwFyeTgWxT/mCQzHhrGoKvJAAvEZxm5S3IcP+Sm 7EU2fGj0Aif9Tflu2GIYMtACWOuB4mPekzc/HymVliEUkzuGeA5OZxHPGzH+Yv8t jUGqQ5gWnXmFlhcRaBV0SNu2km0rh8HU3UNhBJI1DubWHel4i0laut2m+ptMUPrK 0Jr4s9hlF+zXdY8e4h/qoieG7wl6cKKja4MdBwTTcd5ViOguEvDc1/M/5wttzH83 jGTHhJ+i18QUlEThGWFBYWqo554zpmbi5srG8kcbwTh3DUE0cxtekSi2H1Q== Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9nb62c5b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 12:48:19 +0000 (GMT) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-9213237a52eso183749806d6.1 for ; Tue, 01 Dec 2026 04:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796129298; x=1796734098; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sHkeIm4RalRpZ4n87opkytrHR25vWnrE4cHamlKiGxU=; b=djwr8TossqnI9ltMXfxhBNTuRBliy0OPmpdAYw7viGhYSX5AkBOh26jPrmzMFiwoZr gm3lrp5HpE82FtpECQwqEFksOMnyE3Gq1sdn9Tk4bx4h3MBKHjMXEinex45Yt9dzmPPT xn08BIUI7hL7FbnMx9bFMKDLMT3OsXWfXQs6LjzpgtW5bzsAFo+dCV97Vb4eDMWBjYS6 04QjbAtKkr17gFQ+D17IqfZ7+6AehIqmJcv7mfGekBp/MpSEnCBJbrcLqjm6PMo7YHmr DwI85zm0IEqxofIP047/+QenF2Ipak7FKPNxk6IU0NBBaF/AMFtORU+y5UtbRF11W8Js bExg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796129298; x=1796734098; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sHkeIm4RalRpZ4n87opkytrHR25vWnrE4cHamlKiGxU=; b=K8OTErlv+x0RJ1sYoXzVT1jlB4T/s82MjOa4XZYJtyf43QkCACO0oTl4ylAMFySx0G pSh9fN7liUWtPaesKR+LwE5VKYwAK65bLUQqH7idMrNbVCFfqZg34F20KIdD5L9N4haX zyc0QIoz6+koP/GJZMq7rEnM6CwdC/S/v3Zqne3DPdu2l5j8TRwKyjR2u4knXlzJcE+Y Nzo/QvM4j3/BSoc13hwowJ1RVNwZujza/O0uOgdvi8G2GzVdJ4/RRJxtnmoYn7hJftyK 50tqGGKnUXRTggjQCqldVb2YYTByQBAHfdYP/H4Lh6fW7FWefLoJjuM7ur7RzJ1nFIv+ BS9w== X-Forwarded-Encrypted: i=1; AL+hErGcq+c0UKX2iOfNLS+9um91JfstqhDAqCvVdKwMq4sMfUet+r0yZWTQ0g3hfnGmbFbFM79onuUrBWzSFqM=@vger.kernel.org X-Gm-Message-State: APuU4Z8Sf0XDY/PsAihb3RF7PpFqUPJ2NUUtLsH3wT/gXNz1heph6Bdu gpsXeI4rAjV/t7bQ7/4QeXIURXTEREUTMl7+lf28080/P4pLDJJaM4fJ+ZW4VQW/KG58fR2E0h+ PyOuOxKySpY3GKSU8pEWF6XqS33ww0oZcRaxrm/1egzixEajEQgmTahcQKWni0hgIvjg= X-Gm-Gg: AZFdTZe82cS4az7W1Zi0RGMhveWwAb6RFHvZayoRhOq/GrOfB3I8iBi/v7NxQDS+JYi HAwrQT00Lq0XM864e4f4+CBatbtz29X1NqimypwSDMTp8qc/Jky4SRGJeuhhvMo1/ucwIlWBxlO nZbB7uLUVFp4fmYBqc+P57Odw2kCrp5DlhogskBgOLnMniB7b9ZqGM8RX3D7YUBKBEBvnI0PAk+ NZgxYfcgxxyU9SBQHzd8867v9nhUiHv5Q9aOY2WhlSQkZU3XSaxQ/8+FxYIYwKXBTFMinq2xhUs Hms40ex8r4jh4BsRCIsRFRY2xIlGcye9eoBANrzrmLRwxl9l5n651mbbwth42U47tSX43UKUxt0 1+Hx1Gv8zrA+HNS4BycOxBb7oqQi1X/FTY/CwXUs3WWpi5tkwWe8QIWA+pfR9Wa4W X-Received: by 2002:a05:620a:700e:b0:949:b8b0:1b11 with SMTP id af79cd13be357-949bab1df30mr7453601585a.44.1796129298143; Tue, 01 Dec 2026 04:48:18 -0800 (PST) X-Received: by 2002:a05:620a:700e:b0:949:b8b0:1b11 with SMTP id af79cd13be357-949bab1df30mr7453596285a.44.1796129297597; Tue, 01 Dec 2026 04:48:17 -0800 (PST) Received: from debian ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9687sm1131892375e9.10.2026.12.01.04.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 04:48:16 -0800 (PST) From: Srinivas Kandagatla To: Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Pierre-Louis Bossart , Bjorn Andersson , Konrad Dybcio , Abel Vesa , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Randy Dunlap , Shuah Khan , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla , kernel test robot Subject: [PATCH v4 08/24] ASoC: codecs: wsa884x: register the die temperature as a thermal zone Date: Tue, 1 Dec 2026 12:47:37 +0000 Message-ID: <20261201124753.196748-9-srinivas.kandagatla@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> References: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA1MCBTYWx0ZWRfX4dOhqA1J5IQ9 Vp8buwmLNk6pmBWWyKgPMDS/O3PiWz/6nMNQVdVsYY2uzmwPMm2jWKOhZiMOcuB6xqoAm8Vs0si vEm94tKqau48yw9TtTof9cCDLnkZ32E= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA1MCBTYWx0ZWRfX+gvmD0YkuTLb zeVe78sXET+7XqyfWWm8nmvoKexS1iljdw6lFGRnHOFppSK81Bu6/LsP40TMUP2707oUwG2bvhX A6sM+z8LPmVcddLD97RBqDSvG6p3DvEQc4K5j7LLsPmbNCGrr/q5AVibyKYI++wf3L4zCPYBjkD hKswp4PCsM4BwMQv4TEfS+fKiytZZLIwXrxIcEocGBDl310x9hR1ACIPdzMrufoGiE1sn6zw1nE QBI3BjJA6P6FfF8tA/dz1QY39PqJGqJL+hG6YHo1gmk7OlpHM/uhkvl844yqWA4hiVLMcULrlCB QoIZsp8/ZxcAFSDdNkEAfOOEDrm3+GIA0ITVH2EUWL5OGxepE/uhdCj1HxutmaR22OJs3yJjSA8 YgD2mbyhMb6U/QVJSgVO3wrSBPdVlPt/XfR+aEnn12JP4EFHaA+y7NLALMJ+qNAzTFlkUYAnh6R agacFUqFe5Ild9zZV/A== X-Authority-Analysis: v=2.4 cv=fc44WEQF c=1 sm=1 tr=0 ts=6b0ec213 cx=c_pps a=oc9J++0uMp73DTRD5QyR2A==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=VwQbUJbxAAAA:8 a=QyXUC8HyAAAA:8 a=EUspDBNiAAAA:8 a=51jdShTR6rvD-JhUMxgA:9 a=iYH6xdkBrDN1Jqds4HTS:22 X-Proofpoint-ORIG-GUID: 1Ys4LBgg-BnIm9GBVr8V8dX9Ja6T8PLj X-Proofpoint-GUID: 1Ys4LBgg-BnIm9GBVr8V8dX9Ja6T8PLj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_02,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010050 Speaker protection pairs each speaker's calibrated resistance with the amplifier die temperature (T0) at the time, but an in-kernel user has no way to read that temperature. Register a tripless thermal zone over the existing temperature read, named "wsa--" so a user holding the codec's device can find it with thermal_zone_get_zone_by_name(). Until the codec is initialised, and while the PA is on with nothing cached yet, return -EAGAIN to hwmon and no valid temperature to the thermal zone, instead of a plausible looking zero. -EAGAIN would make the thermal core re-read the zone every 250 ms and keep the codec awake. Signed-off-by: Srinivas Kandagatla Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/20261124071812.oiRgQnHg-lkp@intel.com/ --- sound/soc/codecs/wsa884x.c | 70 +++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wsa884x.c b/sound/soc/codecs/wsa884x.c index 91aa004d7137..d0a00aced220 100644 --- a/sound/soc/codecs/wsa884x.c +++ b/sound/soc/codecs/wsa884x.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1935,8 +1936,10 @@ static int wsa884x_get_temp(struct wsa884x_priv *wsa884x, long *temp) if (wsa884x->pa_on) { /* * Reading temperature is possible only when Power Amplifier is - * off. Report last cached data. + * off. Report last cached data if we have one, -EAGAIN otherwise. */ + if (!wsa884x->temperature) + return -EAGAIN; *temp = wsa884x->temperature * 1000; return 0; } @@ -2058,6 +2061,42 @@ static const struct hwmon_chip_info wsa884x_hwmon_chip_info = { .info = wsa884x_hwmon_info, }; +static int wsa884x_tz_get_temp(struct thermal_zone_device *tz, int *temp_mdeg) +{ + struct wsa884x_priv *wsa884x = thermal_zone_device_priv(tz); + long mdeg; + int ret; + + /* + * OTP trims read back as zero until the codec is initialised. Report + * no reading rather than -EAGAIN, which makes the core poll the zone. + */ + if (!wsa884x->hw_init) { + *temp_mdeg = THERMAL_TEMP_INVALID; + return 0; + } + + ret = wsa884x_get_temp(wsa884x, &mdeg); + if (ret == -EAGAIN) { + *temp_mdeg = THERMAL_TEMP_INVALID; + return 0; + } + if (ret) + return ret; + + *temp_mdeg = (int)mdeg; + return 0; +} + +static struct thermal_zone_device_ops wsa884x_tz_ops = { + .get_temp = wsa884x_tz_get_temp, +}; + +static void wsa884x_tz_unregister(void *data) +{ + thermal_zone_device_unregister(data); +} + static void wsa884x_reset_powerdown(void *data) { struct wsa884x_priv *wsa884x = data; @@ -2194,6 +2233,35 @@ static int wsa884x_probe(struct sdw_slave *pdev, if (ret) return ret; + if (IS_REACHABLE(CONFIG_THERMAL)) { + char tz_name[THERMAL_NAME_LENGTH]; + struct thermal_zone_device *tz; + + /* + * Register after runtime PM is enabled, as the zone is read + * right away. dev_name() is too long for a zone name. + */ + scnprintf(tz_name, sizeof(tz_name), "wsa-%d-%u", + pdev->bus->id, pdev->id.unique_id); + tz = thermal_tripless_zone_device_register(tz_name, + wsa884x, + &wsa884x_tz_ops, + NULL); + if (IS_ERR(tz)) { + dev_warn(dev, + "thermal zone '%s' registration failed (%ld); SP T0 kcontrol will read 0 for this codec\n", + tz_name, PTR_ERR(tz)); + } else { + ret = devm_add_action_or_reset(dev, + wsa884x_tz_unregister, + tz); + if (ret) + return ret; + + thermal_zone_device_enable(tz); + } + } + return devm_snd_soc_register_component(dev, &wsa884x_component_drv, wsa884x_dais, -- 2.53.0