From nobody Sat May 18 12:05:11 2024 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 0D77315B56E; Wed, 24 Apr 2024 13:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713963925; cv=none; b=EVvwHcCenfiWP+CIvF4OSCdFLEQlMs0sg+t1nWQKDjiA+KN2uScNSpFiwOz7W7hRdoDWmoHK85gPiDV53o7Jt0Pg8p7ZjjHcKw30OsGr3LoJQIaoLm4DIdSPWviOKQ3TqXa9zlj26v2/vQAIRkIo4QlIGmZFBeRVOcwazoiXF48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713963925; c=relaxed/simple; bh=aYUiQjx5T2telvYeBW2h9mlyvfpkugk6HRhiYmiCzf8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GKIJOlISQbhQWLGe5ZSWlrS7TA3G+l3MT1Qk+gGSaqtoTOkT281U4TJhtSKWhWxKq1Jyz5UolLA+SucyDGxVMMopKsg+GT22vT2nwIbIGP7VJdtgu8Cyh0wBhVhvdP+GqTWATjhyY/fGdFwRJeqV5B4g9D5QiTD/YsRvEZZkVTE= 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=MZep/r7x; arc=none smtp.client-ip=198.47.23.248 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="MZep/r7x" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43OD5BEu037529; Wed, 24 Apr 2024 08:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1713963911; bh=2gw3G8wmP2kkhlSTaXmiw8IfW3uBJt595tILnxRdmys=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=MZep/r7xEKnF6WMBdjXNGO5JaM0CSR86P2ACedtaD+ssxkxYpdlPI0ENNwPGmDT61 lIDcdbjq07+Eu0Mdhvg0+C3gKYvJMOltxekE4qAC3/sc6XjDdi4w8bFEd7GUE319TA Xw6bd8mo3CRh5HEEG56Ok1UkSfs/B5K0Ngee8hMs= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43OD5BpN002842 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Apr 2024 08:05:11 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 24 Apr 2024 08:05:10 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 24 Apr 2024 08:05:10 -0500 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [10.24.69.66]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43OD54bQ029300; Wed, 24 Apr 2024 08:05:08 -0500 From: Beleswar Padhi To: CC: , , , , , , , Subject: [PATCH v2 1/2] remoteproc: k3-r5: Wait for core0 power-up before powering up core1 Date: Wed, 24 Apr 2024 18:35:03 +0530 Message-ID: <20240424130504.494916-2-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424130504.494916-1-b-padhi@ti.com> References: <20240424130504.494916-1-b-padhi@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-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" From: Apurva Nandan PSC controller has a limitation that it can only power-up the second core when the first core is in ON state. Power-state for core0 should be equal to or higher than core1, else the kernel is seen hanging during rproc loading. Make the powering up of cores sequential, by waiting for the current core to power-up before proceeding to the next core, with a timeout of 2sec. Add a wait queue event in k3_r5_cluster_rproc_init call, that will wait for the current core to be released from reset before proceeding with the next core. Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F su= bsystem") Signed-off-by: Apurva Nandan --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/= ti_k3_r5_remoteproc.c index ad3415a3851b..5a9bd5d4a2ea 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -103,12 +103,14 @@ struct k3_r5_soc_data { * @dev: cached device pointer * @mode: Mode to configure the Cluster - Split or LockStep * @cores: list of R5 cores within the cluster + * @core_transition: wait queue to sync core state changes * @soc_data: SoC-specific feature data for a R5FSS */ struct k3_r5_cluster { struct device *dev; enum cluster_mode mode; struct list_head cores; + wait_queue_head_t core_transition; const struct k3_r5_soc_data *soc_data; }; =20 @@ -128,6 +130,7 @@ struct k3_r5_cluster { * @atcm_enable: flag to control ATCM enablement * @btcm_enable: flag to control BTCM enablement * @loczrama: flag to dictate which TCM is at device address 0x0 + * @released_from_reset: flag to signal when core is out of reset */ struct k3_r5_core { struct list_head elem; @@ -144,6 +147,7 @@ struct k3_r5_core { u32 atcm_enable; u32 btcm_enable; u32 loczrama; + bool released_from_reset; }; =20 /** @@ -460,6 +464,8 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) ret); return ret; } + core->released_from_reset =3D true; + wake_up_interruptible(&cluster->core_transition); =20 /* * Newer IP revisions like on J7200 SoCs support h/w auto-initialization @@ -1140,6 +1146,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rp= roc *kproc) return ret; } =20 + core->released_from_reset =3D c_state; ret =3D ti_sci_proc_get_status(core->tsp, &boot_vec, &cfg, &ctrl, &stat); if (ret < 0) { @@ -1280,6 +1287,26 @@ static int k3_r5_cluster_rproc_init(struct platform_= device *pdev) cluster->mode =3D=3D CLUSTER_MODE_SINGLECPU || cluster->mode =3D=3D CLUSTER_MODE_SINGLECORE) break; + + /* + * R5 cores require to be powered on sequentially, core0 + * should be in higher power state than core1 in a cluster + * So, wait for current core to power up before proceeding + * to next core and put timeout of 2sec for each core. + * + * This waiting mechanism is necessary because + * rproc_auto_boot_callback() for core1 can be called before + * core0 due to thread execution order. + */ + ret =3D wait_event_interruptible_timeout(cluster->core_transition, + core->released_from_reset, + msecs_to_jiffies(2000)); + if (ret <=3D 0) { + dev_err(dev, + "Timed out waiting for %s core to power up!\n", + rproc->name); + return ret; + } } =20 return 0; @@ -1709,6 +1736,7 @@ static int k3_r5_probe(struct platform_device *pdev) cluster->dev =3D dev; cluster->soc_data =3D data; INIT_LIST_HEAD(&cluster->cores); + init_waitqueue_head(&cluster->core_transition); =20 ret =3D of_property_read_u32(np, "ti,cluster-mode", &cluster->mode); if (ret < 0 && ret !=3D -EINVAL) { --=20 2.34.1 From nobody Sat May 18 12:05:11 2024 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 7CD9315B159; Wed, 24 Apr 2024 13:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713963935; cv=none; b=rafroKhUM30dMkmpffjtM9VJV2DpAIZgLM0zn957f+6TMNtrIxDVXCfPyD+QhzaxqjHhZU89j0XQFwMh7L3zzvFajADCNJTGZbh8bKjKzFHJHweHA1nTTHEaqxcqg5AMzv0JNmlcGXpYlZyzB25SX5CLCts9soo1Th/+g85BN5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713963935; c=relaxed/simple; bh=xUkwDJI+0sKr7foO8qmRrScI6/JnFwKaztK/o/qF0as=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t7J5/Xuc6+OpFfin/2L3wIkRR1jtWMT9KVm/HWqlWuTwy/BCXE9mTXK2I2dbdee0hSMLzOsYp8/Q1GtM0iCMneYZvW9zW+2QP8woeNAVR9J0BlBGYx4tx8+4aukDSOmft5Wrkoox2SeSC9SiLwXFSGUHKrc+xfk/RyEEGjY57As= 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=Kj/qOvn6; arc=none smtp.client-ip=198.47.19.142 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="Kj/qOvn6" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43OD5EiY076780; Wed, 24 Apr 2024 08:05:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1713963914; bh=q3Fy/Ibc5qZtK2bfrQr32IluwMsanIJO4c82EsXkxL0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Kj/qOvn6kN5VnB/zMQivKw+b+2zBLDYTY/bdGWwdibm2gRovNIueZvAyY193a5uDI +s1IZhBDmU+cE367aTutztSdYTV74rtsi8NAFzhnIAH5fmYk+G8rYf0L+DgesRhTMv hLbxzwpr3MM1CAcEm54ksIMfl4dBiIXQg+kJIj8g= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43OD5DwI002947 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Apr 2024 08:05:13 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 24 Apr 2024 08:05:13 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 24 Apr 2024 08:05:13 -0500 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [10.24.69.66]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43OD54bR029300; Wed, 24 Apr 2024 08:05:11 -0500 From: Beleswar Padhi To: CC: , , , , , , , Subject: [PATCH v2 2/2] remoteproc: k3-r5: Do not allow core1 to power up before core0 via sysfs Date: Wed, 24 Apr 2024 18:35:04 +0530 Message-ID: <20240424130504.494916-3-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424130504.494916-1-b-padhi@ti.com> References: <20240424130504.494916-1-b-padhi@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-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" PSC controller has a limitation that it can only power-up the second core when the first core is in ON state. Power-state for core0 should be equal to or higher than core1. Therefore, prevent core1 from powering up before core0 during the start process from sysfs. Similarly, prevent core0 from shutting down before core1 has been shut down from sysfs. Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F su= bsystem") Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/= ti_k3_r5_remoteproc.c index 5a9bd5d4a2ea..b9d2a16af563 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -548,7 +548,7 @@ static int k3_r5_rproc_start(struct rproc *rproc) struct k3_r5_rproc *kproc =3D rproc->priv; struct k3_r5_cluster *cluster =3D kproc->cluster; struct device *dev =3D kproc->dev; - struct k3_r5_core *core; + struct k3_r5_core *core0, *core; u32 boot_addr; int ret; =20 @@ -574,6 +574,15 @@ static int k3_r5_rproc_start(struct rproc *rproc) goto unroll_core_run; } } else { + /* do not allow core 1 to start before core 0 */ + core0 =3D list_first_entry(&cluster->cores, struct k3_r5_core, + elem); + if (core !=3D core0 && core0->rproc->state =3D=3D RPROC_OFFLINE) { + dev_err(dev, "%s: can not start core 1 before core 0\n", + __func__); + return -EPERM; + } + ret =3D k3_r5_core_run(core); if (ret) goto put_mbox; @@ -619,7 +628,8 @@ static int k3_r5_rproc_stop(struct rproc *rproc) { struct k3_r5_rproc *kproc =3D rproc->priv; struct k3_r5_cluster *cluster =3D kproc->cluster; - struct k3_r5_core *core =3D kproc->core; + struct device *dev =3D kproc->dev; + struct k3_r5_core *core1, *core =3D kproc->core; int ret; =20 /* halt all applicable cores */ @@ -632,6 +642,15 @@ static int k3_r5_rproc_stop(struct rproc *rproc) } } } else { + /* do not allow core 0 to stop before core 1 */ + core1 =3D list_last_entry(&cluster->cores, struct k3_r5_core, + elem); + if (core !=3D core1 && core1->rproc->state !=3D RPROC_OFFLINE) { + dev_err(dev, "%s: can not stop core 0 before core 1\n", + __func__); + return -EPERM; + } + ret =3D k3_r5_core_halt(core); if (ret) goto out; --=20 2.34.1