From nobody Sat Feb 7 03:52:16 2026 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (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 6C34519597F; Fri, 27 Jun 2025 20:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751057345; cv=none; b=lsDkhiq176/WCropN61MlQgCNcfwRsONm3XCgiRGKGbMjvzXH1ST/sCZ4iQuSBTh6SzcdeC8EkPnUFtqHO6X/27nMJYySFdhu4kRHYA2ahyyXWOFk2sVGDcp85eglR6ZZ+5NfLhl2rj2DT4Tz/kl0K0YqVnQCVlyNSEVu1rEiNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751057345; c=relaxed/simple; bh=EA28T0swc+HCEaIWo4biGwZKTFdfdBsRsbWHkQC5Pxc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LisPcrWfVbotpXcBAUGckXYYvmVSziuEMxIGr6H059K6iPtWuWhXuIPY6vvIM6GC0RdA55neuUZA+IIL272LiGU6eV1cqMzDD5vRkM6mFqRumRUJn/NC4mctUJcoy7eV/D/oFXpiBlCBXZoLDHBVRyM+WCVqSAzxevFieldRMVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=OOk6C3ng; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="OOk6C3ng" Received: from fllvem-sh03.itg.ti.com ([10.64.41.86]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTP id 55RKmtqe2508631; Fri, 27 Jun 2025 15:48:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1751057335; bh=HluJQ8LptdTS6su8UuncXTZx769j4AJJg4ElkyPIcvo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OOk6C3ngM3CvLkx8ZjVG9iONNE2BRVfsrklBSqWReGrLGbBlIw0y4K2BipxuxRg3k NXAGSuASHbUI346BQp5r4y5xxA6H+YRJjXOLEIwUe24zRqbWcCWrMSFZBWE8B85MDf MGnVfdIueCpvMNsHkhyMAj3JFTBTrZgQ3GUZ8vgQ= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by fllvem-sh03.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 55RKmtsB3292478 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Fri, 27 Jun 2025 15:48:55 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55; Fri, 27 Jun 2025 15:48:55 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55 via Frontend Transport; Fri, 27 Jun 2025 15:48:55 -0500 Received: from uda0506412.dhcp.ti.com (uda0506412.dhcp.ti.com [128.247.81.19]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 55RKmpWW3421525; Fri, 27 Jun 2025 15:48:55 -0500 From: Kendall Willis To: , , , , , , CC: , , , , , Kendall Willis Subject: [PATCH 1/2] firmware: ti_sci: Enable abort handling of entry to LPM Date: Fri, 27 Jun 2025 15:48:20 -0500 Message-ID: <20250627204821.1150459-2-k-willis@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250627204821.1150459-1-k-willis@ti.com> References: <20250627204821.1150459-1-k-willis@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Introduce LPM abort call that enables the ti_sci driver to support aborting entry to a low power mode. The following power management operation defined in the TISCI Low Power Mode API [1] is implemented to enable aborting entry to LPM: TISCI_MSG_LPM_ABORT Abort the current low power mode entry by clearing the current mode selection. Additionally, add LPM abort message in ti_sci_suspend and ti_sci_suspend_noirq if there is a failure. [1] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/lpm.html Signed-off-by: Kendall Willis --- drivers/firmware/ti_sci.c | 67 ++++++++++++++++++++++++-- drivers/firmware/ti_sci.h | 3 +- include/linux/soc/ti/ti_sci_protocol.h | 2 + 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index ae5fd1936ad32..d5139428498d4 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -2015,6 +2015,58 @@ static int ti_sci_cmd_set_latency_constraint(const s= truct ti_sci_handle *handle, return ret; } =20 +/** + * ti_sci_cmd_lpm_abort() - Abort entry to LPM + * @handle: pointer to TI SCI handle + * + * Return: 0 if all went well, else returns appropriate error value. + */ +static int ti_sci_cmd_lpm_abort(const struct ti_sci_handle *handle) +{ + struct ti_sci_info *info; + struct ti_sci_msg_hdr *req; + struct ti_sci_msg_hdr *resp; + struct ti_sci_xfer *xfer; + struct device *dev; + int ret =3D 0; + + if (IS_ERR(handle)) + return PTR_ERR(handle); + if (!handle) + return -EINVAL; + + info =3D handle_to_ti_sci_info(handle); + dev =3D info->dev; + + xfer =3D ti_sci_get_one_xfer(info, TI_SCI_MSG_LPM_ABORT, + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, + sizeof(*req), sizeof(*resp)); + if (IS_ERR(xfer)) { + ret =3D PTR_ERR(xfer); + dev_err(dev, "Message alloc failed(%d)\n", ret); + return ret; + } + req =3D (struct ti_sci_msg_hdr *)xfer->xfer_buf; + + ret =3D ti_sci_do_xfer(info, xfer); + if (ret) { + dev_err(dev, "Mbox send fail %d\n", ret); + goto fail; + } + + resp =3D (struct ti_sci_msg_hdr *)xfer->xfer_buf; + + if (!ti_sci_is_response_ack(resp)) + ret =3D -ENODEV; + else + ret =3D 0; + +fail: + ti_sci_put_one_xfer(&info->minfo, xfer); + + return ret; +} + static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) { struct ti_sci_info *info; @@ -3202,6 +3254,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info) pmops->lpm_wake_reason =3D ti_sci_msg_cmd_lpm_wake_reason; pmops->set_device_constraint =3D ti_sci_cmd_set_device_constraint; pmops->set_latency_constraint =3D ti_sci_cmd_set_latency_constraint; + pmops->lpm_abort =3D ti_sci_cmd_lpm_abort; } =20 rm_core_ops->get_range =3D ti_sci_cmd_get_resource_range; @@ -3699,9 +3752,13 @@ static int __maybe_unused ti_sci_suspend(struct devi= ce *dev) } =20 ret =3D ti_sci_prepare_system_suspend(info); - if (ret) + if (ret) { + dev_err(dev, "%s: Failed to prepare sleep. Abort entering low power mode= .\n", + __func__); + if (ti_sci_cmd_lpm_abort(&info->handle)) + dev_err(dev, "%s: Failed to abort.\n", __func__); return ret; - + } return 0; } =20 @@ -3711,8 +3768,12 @@ static int __maybe_unused ti_sci_suspend_noirq(struc= t device *dev) int ret =3D 0; =20 ret =3D ti_sci_cmd_set_io_isolation(&info->handle, TISCI_MSG_VALUE_IO_ENA= BLE); - if (ret) + if (ret) { + dev_err(dev, "%s: Failed to suspend. Abort entering low power mode.\n", = __func__); + if (ti_sci_cmd_lpm_abort(&info->handle)) + dev_err(dev, "%s: Failed to abort.\n", __func__); return ret; + } =20 return 0; } diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index 053387d7baa06..51d77f90a32cc 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -6,7 +6,7 @@ * The system works in a message response protocol * See: https://software-dl.ti.com/tisci/esd/latest/index.html for details * - * Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.t= i.com/ + * Copyright (C) 2015-2025 Texas Instruments Incorporated - https://www.t= i.com/ */ =20 #ifndef __TI_SCI_H @@ -42,6 +42,7 @@ #define TI_SCI_MSG_SET_IO_ISOLATION 0x0307 #define TI_SCI_MSG_LPM_SET_DEVICE_CONSTRAINT 0x0309 #define TI_SCI_MSG_LPM_SET_LATENCY_CONSTRAINT 0x030A +#define TI_SCI_MSG_LPM_ABORT 0x0311 =20 /* Resource Management Requests */ #define TI_SCI_MSG_GET_RESOURCE_RANGE 0x1500 diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/= ti_sci_protocol.h index fd104b6668364..8c1815a9e8234 100644 --- a/include/linux/soc/ti/ti_sci_protocol.h +++ b/include/linux/soc/ti/ti_sci_protocol.h @@ -214,6 +214,7 @@ struct ti_sci_clk_ops { * @set_latency_constraint: Set LPM resume latency constraint * - latency: maximum acceptable latency to wake up from low power mode * - state: The desired state of latency constraint: set or clear. + * @lpm_abort: Abort entry to LPM by clearing the LPM selection */ struct ti_sci_pm_ops { int (*lpm_wake_reason)(const struct ti_sci_handle *handle, @@ -222,6 +223,7 @@ struct ti_sci_pm_ops { u32 id, u8 state); int (*set_latency_constraint)(const struct ti_sci_handle *handle, u16 latency, u8 state); + int (*lpm_abort)(const struct ti_sci_handle *handle); }; =20 /** --=20 2.34.1 From nobody Sat Feb 7 03:52:16 2026 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (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 CC19C255F39; Fri, 27 Jun 2025 20:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751057346; cv=none; b=JiJI5SbikS1UoNMQOS+7vUZEjmTUjuoYPsWze+DMddwgVys+Kc+yeutVLuxIjj1Eq8icUtYxy4qOIC1tqB7KdYRgh0KteHksUORKHbhGA/MNmUNeWC7xlVSswOuwnf6LmgBI3pQlVfTBMZ+HO+F4k8jC8AMC06+0S6SF3eCBglw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751057346; c=relaxed/simple; bh=sNnneumzgh8HpZ6dHQ/dWMjwjSBmUwK755TSQoE1p/A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cN0sU6htkN4KjuiXDjbplMjYAMCYaMhNwsWLNSMPM34/2R+ese5pqRLSgxAxyET8pCz/cV4aaxww9Ak+Hd7kBz2wTFjLAYaI1dgSESbZR2xpXZnUvdUUhWkwHQfelcG8k6mWeikCW/1bdrjd0Xft+FT4dpkBufwvzpu/Zy3sN/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=iwLKQmF/; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="iwLKQmF/" Received: from lelvem-sh01.itg.ti.com ([10.180.77.71]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTP id 55RKmwlK2112130; Fri, 27 Jun 2025 15:48:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1751057338; bh=l7Gdp8Nk60ZfRYhbL7kV9nXUPDhA4CVDa+kStehV06k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=iwLKQmF/0Z4iRQaqC2FBfdg22yRU7fTYaVG+Vcqh4jYXONpgyQo5X6mHl15R/C+ao 1np+r4hIv6he8nd5DXD0k8yy4GltBg/tcPhJceG70jPKq2Vwplmy5C0wrnTaKCJIIf X2Vkm0QxO9y6ii/0d54uM+0SBAAj5F0L+MX/wdY4= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelvem-sh01.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 55RKmw0T783155 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Fri, 27 Jun 2025 15:48:58 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55; Fri, 27 Jun 2025 15:48:57 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55 via Frontend Transport; Fri, 27 Jun 2025 15:48:57 -0500 Received: from uda0506412.dhcp.ti.com (uda0506412.dhcp.ti.com [128.247.81.19]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 55RKmpWX3421525; Fri, 27 Jun 2025 15:48:57 -0500 From: Kendall Willis To: , , , , , , CC: , , , , , Kendall Willis Subject: [PATCH 2/2] pmdomain: ti_sci: Add LPM abort sequence to suspend path Date: Fri, 27 Jun 2025 15:48:21 -0500 Message-ID: <20250627204821.1150459-3-k-willis@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250627204821.1150459-1-k-willis@ti.com> References: <20250627204821.1150459-1-k-willis@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Create ->suspend_late() and ->suspend_noirq() hooks to add abort sequence to any driver within the PM domain with either of those hooks. If a driver fails to suspend with those hooks, add a call to the DM to abort entering the LPM. The suspend hooks of the PM domains driver inserts itself into the suspend path of all devices connected to the TI SCI PM domain. So if any device in the PM domain with either a ->suspend_late() or ->suspend_noirq hook fails to suspend, the PM domain drivers suspend hook will send the abort call to the DM. Adding an abort call in the ->suspend() hook is not necessary. TI SCI suspend sends the message to the DM to prepare to enter a low power mode. TI SCI suspend ALWAYS occurs after the ->suspend() hook for all TI SCI devices has been called. Signed-off-by: Kendall Willis --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 46 ++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/= ti_sci_pm_domains.c index 82df7e44250bb..975defc16271d 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -2,7 +2,7 @@ /* * TI SCI Generic Power Domain Driver * - * Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.= com/ + * Copyright (C) 2015-2025 Texas Instruments Incorporated - http://www.ti.= com/ * J Keerthy * Dave Gerlach */ @@ -149,8 +149,47 @@ static int ti_sci_pd_suspend(struct device *dev) =20 return 0; } + +static int ti_sci_pd_suspend_late(struct device *dev) +{ + struct generic_pm_domain *genpd =3D pd_to_genpd(dev->pm_domain); + struct ti_sci_pm_domain *pd =3D genpd_to_ti_sci_pd(genpd); + const struct ti_sci_handle *ti_sci =3D pd->parent->ti_sci; + int ret; + + ret =3D pm_generic_suspend_late(dev); + if (ret) { + dev_err(dev, "%s: Failed to suspend. Abort entering low power mode.\n", = __func__); + if (ti_sci->ops.pm_ops.lpm_abort(ti_sci)) + dev_err(dev, "%s: Failed to abort.\n", __func__); + return ret; + } + + return 0; +} + +static int ti_sci_pd_suspend_noirq(struct device *dev) +{ + struct generic_pm_domain *genpd =3D pd_to_genpd(dev->pm_domain); + struct ti_sci_pm_domain *pd =3D genpd_to_ti_sci_pd(genpd); + const struct ti_sci_handle *ti_sci =3D pd->parent->ti_sci; + int ret; + + ret =3D pm_generic_suspend_noirq(dev); + if (ret) { + dev_err(dev, "%s: Failed to suspend. Abort entering low power mode.\n", = __func__); + if (ti_sci->ops.pm_ops.lpm_abort(ti_sci)) + dev_err(dev, "%s: Failed to abort.\n", __func__); + return ret; + } + + return 0; +} + #else #define ti_sci_pd_suspend NULL +#define ti_sci_pd_suspend_late NULL +#define ti_sci_pd_suspend_noirq NULL #endif =20 /* @@ -264,6 +303,11 @@ static int ti_sci_pm_domain_probe(struct platform_devi= ce *pdev) pd_provider->ti_sci->ops.pm_ops.set_latency_constraint) pd->pd.domain.ops.suspend =3D ti_sci_pd_suspend; =20 + if (pd_provider->ti_sci->ops.pm_ops.lpm_abort) { + pd->pd.domain.ops.suspend_late =3D ti_sci_pd_suspend_late; + pd->pd.domain.ops.suspend_noirq =3D ti_sci_pd_suspend_noirq; + } + pm_genpd_init(&pd->pd, NULL, true); =20 list_add(&pd->node, &pd_provider->pd_list); --=20 2.34.1