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 6F5043EB80E for ; Mon, 13 Jul 2026 10:26:23 +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=1783938388; cv=none; b=Qm9TV5TOQPEv3ZwdtphibRHGTC55Mhe5Jjs20Y/ojOu0yUYETEbQYqWB4VWgjZt7GwnpIebULr/AqBO6mJkd+Y9D5xyarqQGJv0Fi8Qu1OJtDpEf8Bsi3T0K1cwiFz0uOaFFutfj1R7VLLq8SNLUHBsuofN8r1hUv2LlOgsQ6rA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783938388; c=relaxed/simple; bh=uLoH9ML4xoEyk+JlPNhBQ9mrs8NyNN/05IZjbXRWkjc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QSmA2in4RltQ4q1VuUC0/gQqHf0hznY/vbQD+csh6xJTS/SzCijXR3vbrXEpWb+f5jqgnzxc5UmzH32txJJQVfSvg99lJQ9xam47KO9qhOWgYQdEQ1J/Ff6k7p6o59bkURmsLPi5mqvphPD1cgF/QTMJUdCKV/VnzvcBNZlCBNA= 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=pTWJDTsX; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=XFcW/mmU; 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="pTWJDTsX"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="XFcW/mmU" 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 66D995Xw793579 for ; Mon, 13 Jul 2026 10:26:22 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= JLsaqQqcvPq68co61oGckxg0SVVesE3Nua0OxWCKCZ4=; b=pTWJDTsXBaUmBHKP nO7qmhwSy76xQYBI2PQjJtKLfvnmHUbfQoJf6RWeBPw3Pt9yWUNjzd2BInOmSBFg CIxYG4bUoz7PnASysY+WUqaRDcQICSnWF3fA+OH+KDhhGkc3z9Vz2XoxHne12O6a GzvwHz158stXceZIBz7OXk91cUfx4me8ugJY/dAQ88ARpMoC4sgz7GKHuASOErif YEGl8s41Rqcac2nHjkvdQmBEvbSvGmGz8UXxUld/xYngiOq7yaDLEad92oW9ShgO i0TymRDwXxNGITyD0YLA//STeUCBHVem7txa8yqShJv1vdOwTwcSG7gw2cg2LYCY l6+/Lg== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fcw4qr8ru-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 13 Jul 2026 10:26:21 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-ca8aee88725so4266114a12.3 for ; Mon, 13 Jul 2026 03:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1783938381; x=1784543181; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JLsaqQqcvPq68co61oGckxg0SVVesE3Nua0OxWCKCZ4=; b=XFcW/mmUYr1R2B7R55CH2gsbcoRFWr2lfYvzOJ3J/k7Bdapb249zzWYkOB4gWWWVf6 VfCcAZe4ZamzWIgrHHlUqRzlJpzmHTYEHBDfmrR53f7MGGd5z0B9lHVTptkm5wWE3kEu D4baeVa4MoaqoLZ2TSLXkALnH7zrR5Q6j+w2cJ7K0loLqELsSCFIVbhP3/ZV0U9VWd6z xf9bnzzCoHkn6PtPHjIkBh072F4f9dpHnxfRWFPkSO6FrELj1yJn7ZFCyJDxXJbR/pzH 2W0g2Za03j+hrUkHyufh4GaMGtyfswrOjz7O4kJlmXf+Vbipm7tkITvm2R/Jy4hTDteI R5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783938381; x=1784543181; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=JLsaqQqcvPq68co61oGckxg0SVVesE3Nua0OxWCKCZ4=; b=DL7deIaILsSOdb0jXbS9I3bqpX9qv9PnBxVRvMgblIJJ8oz6wvzR1YBR+df6+RtApp SJAigT72wUwTsCjwyMDEo/yEqjLBgvO2WlrGWe3RkumUyXRs2T+nYKRaAvZW8yOMraqk a6vJW+SYVn9brD7xnnPpo0mMTdTM38Fw24TDC4E7JJYP9Dsivmn3dbb7yj0vFhh/rp8U DfBDrbraHwPw3dzSmNRYQMgwp7k10jNMi+E3VFJtjcNvrusL4QHknzqpG25q5N4pjVMh i2dxgmZ1DICSde/F4LZiDKjB+Rl6lRz5JqTphXQzV+y+lsV0TOgmjXGtfzcLfxOuQKFu Rv6w== X-Forwarded-Encrypted: i=1; AHgh+Rr3u2Ah543siuWcN54HGlJhQXsf9ei2rqoKt4VYZ2NrbC1rpESvG4mVCArbNY6rq20z2Ui2tTrp+gbQL6Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxS+uy12Z/K1JmTaXokqekzpl/v/uasCLJ57mEZxd498NGLZXtv mF2zqrEyPovZdgtB3ZW+gDNRThn2+IE5ZSwphBzbmBSP7mckuIIFCEaq7lifm89v5qbaFei8vuG yxbvWRtJZSigAHU/36zTeS2Z/wdyUfVImlvoRcZHZiGTGiUviY2bgD831aDzu+plEf4uIKXn597 Q= X-Gm-Gg: AfdE7clJ/rvx/8FjHlGWtCc6CWWVaynLC2RPNorLHlVJHLZV+wL9wQBBN+Mln/UvTOr NtBfkBmxwZq+0lTLAvQlAx/zb9ftuqYbGEHnzRXx+y4cpVUn30Aj5Z7f7AhqjHcYjArhUp2skjd sCUvDs0aPBJrTRJV+wufJUkFYvoXIqXBDTgFzkoHk5pdBGsg35pfLQi3cOJ/3CPOa4NSGgP3I9T mmEHZjknuEqbFCp46clFh0dEKSE5DPY0GN9guuJ1Rr7O2UwBTqyFLtRt2sTei0o8KZwYnyNO2Hk YWl4FmPjgLlxSY4LEgCWsBBR0MGLIH6BAM6fDE6CRO3G2BCQRe7rb0/bNPTJ8zgh/kXYP9qfF5+ fd9QlCg7G6UwlAzMraINxzG+4FVxyvpPl/y70uD89 X-Received: by 2002:a05:6a20:4322:b0:398:9379:d04d with SMTP id adf61e73a8af0-3c110a6e39fmr8192397637.24.1783938381325; Mon, 13 Jul 2026 03:26:21 -0700 (PDT) X-Received: by 2002:a05:6a20:4322:b0:398:9379:d04d with SMTP id adf61e73a8af0-3c110a6e39fmr8192384637.24.1783938380883; Mon, 13 Jul 2026 03:26:20 -0700 (PDT) Received: from hu-smankad-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b924258a2sm49010603c88.1.2026.07.13.03.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 03:26:20 -0700 (PDT) From: Sneh Mankad Date: Mon, 13 Jul 2026 15:55:44 +0530 Subject: [PATCH 4/7] irqchip/irq-qcom-mpm: Program wakeup timer when CPU cluster goes to LPM Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260713-b4-shikra_lpm_addition-v1-4-3d858df2cbbf@oss.qualcomm.com> References: <20260713-b4-shikra_lpm_addition-v1-0-3d858df2cbbf@oss.qualcomm.com> In-Reply-To: <20260713-b4-shikra_lpm_addition-v1-0-3d858df2cbbf@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Gleixner , Shawn Guo , Marc Zyngier Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sneh Mankad X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783938358; l=3481; i=sneh.mankad@oss.qualcomm.com; s=20250818; h=from:subject:message-id; bh=uLoH9ML4xoEyk+JlPNhBQ9mrs8NyNN/05IZjbXRWkjc=; b=sMuO9mLhY6GWDBg0jOsCEGp4lJzp0Gt2hYLVHKK8o8qkVXXyHhzXns+RDLbWWjMxgEqgBHo+1 qLDerscoz30CvPE7o930ilYxc/14C6UDYRDRpCencsnuWAdVQZiShkq X-Developer-Key: i=sneh.mankad@oss.qualcomm.com; a=ed25519; pk=sv57EGwdcfnp6xJmoBCIT1JFSqWI+gawRHkJWj/T2B0= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDEwOCBTYWx0ZWRfX5W3g3j3DCfeL pMxK3ojk9JI7NTLjHTbh5Gd/A2elIUJqslrtg92IrKuDhp72eXANfj/ouuwVCk2pmPK4SshpheV KJS71z1lecEyw4BJ/GBAvGmLi1xQWg+mabCaeNbbZoZMXn2Kwbg9MeSFIwqAQdUlS8pAgVQe1V5 yTnIMAI32fXuXTYoiijygpbUL0KMqaXXj6DEp4aWTX0afCg3TPGb8Qk/FDEWGVn2SULnip9RDXj qbKSzovx2khKL4cWpNpnwh83/u8gMX1sVLmasLyGEsJm5OoGlBoAUU9LNgM83Gi82nGpYYXEIjd NZXFs6Tk3GcPhbAxKJ0+ElHVJPQkTpdfKv7yRh8Bfqj7NR4eZxQw8DmqSLybrCMaBLFUVfkCR06 et348KrXc6+6MC/4mhv9Y5DHOKE1dGXMMAyTWO2S/OHQLM4Qup+n2uV4ScI06gqmhlTzlxOD21U a2gjb1VLdHJAC838NVg== X-Authority-Analysis: v=2.4 cv=HJrz0Itv c=1 sm=1 tr=0 ts=6a54bd4d cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=fChuTYTh2wq5r3m49p7fHw==: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=LbuWhw6SlANFRBx-Z0gA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: ED_9cKoAsRf3Y5zStkh7hsm_ucE33Uxd X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDEwOCBTYWx0ZWRfXwObyvXJvaUTb g6Lq0crqmwk51B6OnTMtnGETmtmIx/jfv62uJ5grG+6bh21hLmuVuhVf0QhoUdF+cHUeJaUbg0z i3+zg4hbbGMMtBkMtcvab/PnCkg6ze8= X-Proofpoint-ORIG-GUID: ED_9cKoAsRf3Y5zStkh7hsm_ucE33Uxd 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-13_02,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 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-2607130108 The next wakeup timer value needs to be set in MPM timer as the arch timer interrupt can not wakeup the SoC if after the deepest CPUidle states the SoC also enters deepest low power state. To wakeup the SoC in such scenarios the earliest wakeup time is set in MPM timer and the Resource Power Manager (RPM processor) takes care of setting the timer in HW. Add MPM timer programming when CPU cluster enters power collapse. Signed-off-by: Sneh Mankad --- drivers/irqchip/irq-qcom-mpm.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/irqchip/irq-qcom-mpm.c b/drivers/irqchip/irq-qcom-mpm.c index 763eddee99dc4cdd5edab22ce54808528f9ef165..f43c4a1c35f78b6cdae194dc7ae88c5c307ada94 100644 --- a/drivers/irqchip/irq-qcom-mpm.c +++ b/drivers/irqchip/irq-qcom-mpm.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,8 @@ #include #include +#include + /* * This is the driver for Qualcomm MPM (MSM Power Manager) interrupt controller, * which is commonly found on Qualcomm SoCs built on the RPM architecture. @@ -77,6 +80,13 @@ enum qcom_mpm_reg { MPM_REG_STATUS, }; +#define USECS_TO_CYCLES(time_usecs) xloops_to_cycles((time_usecs) * 0x10C7UL) + +static inline unsigned long xloops_to_cycles(u64 xloops) +{ + return (xloops * loops_per_jiffy * HZ) >> 32; +} + /* MPM pin map to GIC hwirq */ struct mpm_gic_map { int pin; @@ -84,6 +94,7 @@ struct mpm_gic_map { }; struct qcom_mpm_priv { + struct device *dev; void __iomem *base; raw_spinlock_t lock; struct mbox_client mbox_client; @@ -320,6 +331,36 @@ static irqreturn_t qcom_mpm_handler(int irq, void *dev_id) return ret; } +static void mpm_write_next_wakeup(struct qcom_mpm_priv *priv) +{ + ktime_t now, wakeup = KTIME_MAX; + u64 wakeup_us, wakeup_cycles = ~0; + u32 lo, hi; + + /* Set highest time when system (timekeeping) is suspended */ + if (system_state == SYSTEM_SUSPEND) + goto exit; + + /* Find the relative wakeup in kernel time scale */ + wakeup = dev_pm_genpd_get_next_hrtimer(priv->dev); + + /* Find the relative wakeup in kernel time scale */ + now = ktime_get(); + wakeup = ktime_sub(wakeup, now); + wakeup_us = ktime_to_us(wakeup); + + /* Convert the wakeup to arch timer scale */ + wakeup_cycles = USECS_TO_CYCLES(wakeup_us); + wakeup_cycles += arch_timer_read_counter(); + +exit: + lo = wakeup_cycles; + hi = wakeup_cycles >> 32; + + qcom_mpm_write(priv, MPM_REG_TIMER, 0, lo); + qcom_mpm_write(priv, MPM_REG_TIMER, 1, hi); +} + static int handle_rpm_notification(struct qcom_mpm_priv *priv) { int i, ret; @@ -332,6 +373,7 @@ static int handle_rpm_notification(struct qcom_mpm_priv *priv) if (ret < 0) return ret; + mpm_write_next_wakeup(priv); mbox_client_txdone(priv->mbox_chan, 0); return 0; } @@ -412,6 +454,8 @@ static int qcom_mpm_probe(struct platform_device *pdev, struct device_node *pare if (!priv) return -ENOMEM; + priv->dev = &pdev->dev; + ret = of_property_read_u32(np, "qcom,mpm-pin-count", &pin_cnt); if (ret) { dev_err(dev, "failed to read qcom,mpm-pin-count: %d\n", ret); -- 2.34.1