Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1933440lqa; Tue, 30 Apr 2024 03:56:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgVjc8sj+LhY6gAn5AnA6pneW4iMsdfXw68bQIrJMV2rTxQoyxyQ8NGLZ3JSkH1qiY44u14cW/AXclLXVCoN4xlLHPQaWfgcWrGie4QA== X-Google-Smtp-Source: AGHT+IHQG0Q39/jNm62NRl3wMeU4SCYDUl8qS7sooGJv0Rp059eGEyjYntyAO4x9bJCOBMz5Xvca X-Received: by 2002:a05:6a00:2e84:b0:6f3:ed26:e4f4 with SMTP id fd4-20020a056a002e8400b006f3ed26e4f4mr3975647pfb.1.1714474561705; Tue, 30 Apr 2024 03:56:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714474561; cv=pass; d=google.com; s=arc-20160816; b=puHxeeCyusC1QLfhIWUCH15SEZIbg16CxcUvFbHS6E/8miS4AIUbZrY61GlW1BGBz/ QvPDtc1FqL4Gkv+ccDB52/lk3RATVrS7GrkN3bCZo2621XpLO9WWXiUkqJvQ7Ge94kW4 AIiT9FlRmSUJeWmg5O7cIMLUC7HgJJmU0SHCw+9UKXSrgwKEEYs2Ua+XLaMud7cfBwCT OfzAYV/V05NXUbNj+7LwtkI/xOYJZrVR50YYsIle06JiNBLv8glHGQN0i6xuVvkyz2CZ OzBP5F8kxT+SAi7FCPJPRNVvmA4X8mqQHszeQ0KU4kEzysrw8+asEpQ9l278T1R3c25q aHSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Spp8DwEo94ypuslsSpe3rbYESBIGxpJMj7wMs5oqv9I=; fh=epinPfLfQ0hGyNd7Cj1Zem5kDPAg4Y3HQWsqHeWqiDI=; b=kSn13+f79nmdvrr9EwosvBu8YIVoN7Rm6J+PPo3MuLoSb+iOs7CgUePPcVk+V4sgyX hEzqErqTjPYWpla75sCsK2rPpThyez9vT+yaEmr7RV6RzwlwW1xvFVrJd1/PoHKUub3a fP44T708DC5f2HT9dvyE/Bmde2vHqbDxScYvNGwz0ofnX70947eQG+HId4qA4afWuNGR g/KZqGhubcm55yBEnjzuW1mfQ72poZkPMuzA/P3rLP87IaygjqJcNK/KhMLzDb4aUqv8 AEX1dO4hilXZaPXZv4uAg5FLpEJZL0wdd0nOPIlEIEGMuhz2xrf+KOQ9zPUDF9hK24Er BEwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JRA2KH8e; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-163804-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163804-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j8-20020a654308000000b005dbec3481efsi22221364pgq.91.2024.04.30.03.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 03:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163804-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JRA2KH8e; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-163804-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163804-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D7F34285D90 for ; Tue, 30 Apr 2024 10:54:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6322012DDBD; Tue, 30 Apr 2024 10:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="JRA2KH8e" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 055EE12CD96; Tue, 30 Apr 2024 10:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714474399; cv=none; b=PAvPhcnOZjE1OZAYM5duHIwK+y2wk569FJ8YMgjJetwl5DnNb6tcO3uuaJjZarNShY+kvTNS9D5pb2hZ/HbkqtY8hJNi6w8v+z3qrifzIfxNXass4p/kR82ZndrFkBpPFaVXYppOMh5cG2IO5XY+I78ruTueBFG7gMQvK/GPoGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714474399; c=relaxed/simple; bh=Vn8JGxfP5e3IroWDEVDTpj0Q24QXgvKYuWe3ktKkQAo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SZgX+tnpBvwZscRdHcx4F0DzV8ReMaZ3E7g2KSaXYqy8WvtYGXGcs+9/NdpZLH72yMTCXP6EfMcDdgKYCWM4ncsf/JFaG4S/XDPNgGjyt5Ui1XJwh9YXRUHligsl9bS0fISzLiirqwm44nN+TsGgUQCiUUcKVss8bG/Kmb/UsZk= 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=JRA2KH8e; arc=none smtp.client-ip=198.47.23.249 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 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43UArFA0056516; Tue, 30 Apr 2024 05:53:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714474395; bh=Spp8DwEo94ypuslsSpe3rbYESBIGxpJMj7wMs5oqv9I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=JRA2KH8enONVpC+Orqt91Ji2/bdJ9gmIUzmR7Ha+n5Zr/DSh4QMD89lUo0gDUcwCY PS3NNHFWL8Xy7c4Gad2Sk7UM5KqKf1hu7hVPlUAmRWBAk2FDyxMBIrfCl8EnTaMrGP eTL7F/DXVAdGuaE/3rO/l1TLm8SDCZ/hGpnG9nYI= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43UArFVF033817 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Apr 2024 05:53:15 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 30 Apr 2024 05:53:14 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) 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.23 via Frontend Transport; Tue, 30 Apr 2024 05:53:14 -0500 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [10.24.69.66]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43UAr8Dq038508; Tue, 30 Apr 2024 05:53:12 -0500 From: Beleswar Padhi To: CC: , , , , , , , Subject: [PATCH v3 1/2] remoteproc: k3-r5: Wait for core0 power-up before powering up core1 Date: Tue, 30 Apr 2024 16:23:06 +0530 Message-ID: <20240430105307.1190615-2-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240430105307.1190615-1-b-padhi@ti.com> References: <20240430105307.1190615-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: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 subsystem") Signed-off-by: Apurva Nandan [added comments and fixed code style] Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index ad3415a3851b..6d6afd6beb3a 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; }; @@ -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; }; /** @@ -460,6 +464,8 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) ret); return ret; } + core->released_from_reset = true; + wake_up_interruptible(&cluster->core_transition); /* * Newer IP revisions like on J7200 SoCs support h/w auto-initialization @@ -1140,6 +1146,12 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc) return ret; } + /* + * Skip the waiting mechanism for sequential power-on of cores if the + * core has already been booted by another entity. + */ + core->released_from_reset = c_state; + ret = ti_sci_proc_get_status(core->tsp, &boot_vec, &cfg, &ctrl, &stat); if (ret < 0) { @@ -1280,6 +1292,26 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) cluster->mode == CLUSTER_MODE_SINGLECPU || cluster->mode == 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 = wait_event_interruptible_timeout(cluster->core_transition, + core->released_from_reset, + msecs_to_jiffies(2000)); + if (ret <= 0) { + dev_err(dev, + "Timed out waiting for %s core to power up!\n", + rproc->name); + return ret; + } } return 0; @@ -1709,6 +1741,7 @@ static int k3_r5_probe(struct platform_device *pdev) cluster->dev = dev; cluster->soc_data = data; INIT_LIST_HEAD(&cluster->cores); + init_waitqueue_head(&cluster->core_transition); ret = of_property_read_u32(np, "ti,cluster-mode", &cluster->mode); if (ret < 0 && ret != -EINVAL) { -- 2.34.1