From patchwork Wed Dec 4 11:11:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13893594 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 33EA21B85DB; Wed, 4 Dec 2024 11:11:44 +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=1733310706; cv=none; b=ZBC6Am42doSxoZon9Bl2puIHwdmQQWNvNUFaLjlMh97qP1Ari/K8HkuahLcl9i3JetokRQayLtGSjK9776C2w9fqoVZc29ud1qCwWL5rw+1yW/ttdyOq+xLiCfGo4pW1ejgkEhm5k+lkAELnJqtXW3Nbhru7V+qiVZwPIQfI3UM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310706; c=relaxed/simple; bh=3zmW6MC5KD/bxXC+Ip1U5h9S7gKMYqLKBJ7ioNRc5Ik=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g/hua7E2ptfYmmUCljwIzDuedLWidDf8voPQqc9OZhWOc5teoxnFeVpRYuiMRDoFVSPjN3OzO1J0t8AQygZ+rrtk6RgSQML81sa/CxWjbW6AoWds+QYLW90o363P5ynaA0fxtxKOWnfx+VOmT+4R88zL+/QwM+8Mow0nnyKVfP8= 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=UFzQ9tpw; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UFzQ9tpw" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBcZr062435; Wed, 4 Dec 2024 05:11:38 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1733310698; bh=lstoYoTf3SJwGkrApo7In28oldN80V5FqTvJLxVMOww=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UFzQ9tpwdFNrYlvvTucI8ZTBZKHR5wDIKKf9A4GYlWZ3bhgvxOpUqj9wh5+hunDEI BUsWch9Is6j+zpwUZkGWY7PWuOHjxHKBkhN0U3LIepD5snvqxoJwwl/XR49mEiH31t OOmnEJX1d6Y5prbNflstmZIwcHSMXwuCnBel7GAU= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBceZ068069; Wed, 4 Dec 2024 05:11:38 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 4 Dec 2024 05:11:37 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE101.ent.ti.com (157.170.170.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, 4 Dec 2024 05:11:37 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBVUL083186; Wed, 4 Dec 2024 05:11:35 -0600 From: Beleswar Padhi To: , CC: , , , , , , , Subject: [PATCH 1/5] remoteproc: k3-r5: Add devm action to release reserved memory Date: Wed, 4 Dec 2024 16:41:26 +0530 Message-ID: <20241204111130.2218497-2-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241204111130.2218497-1-b-padhi@ti.com> References: <20241204111130.2218497-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Use a device lifecycle managed action to release reserved memory. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index 6560b7954027..d51f88a5abc1 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -955,6 +955,13 @@ static int k3_r5_rproc_configure(struct k3_r5_rproc *kproc) return ret; } +static void k3_r5_mem_release(void *data) +{ + struct device *dev = data; + + of_reserved_mem_device_release(dev); +} + static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) { struct device *dev = kproc->dev; @@ -985,12 +992,14 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) return ret; } + ret = devm_add_action_or_reset(dev, k3_r5_mem_release, dev); + if (ret) + return ret; + num_rmems--; kproc->rmem = kcalloc(num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); - if (!kproc->rmem) { - ret = -ENOMEM; - goto release_rmem; - } + if (!kproc->rmem) + return -ENOMEM; /* use remaining reserved memory regions for static carveouts */ for (i = 0; i < num_rmems; i++) { @@ -1041,8 +1050,6 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) for (i--; i >= 0; i--) iounmap(kproc->rmem[i].cpu_addr); kfree(kproc->rmem); -release_rmem: - of_reserved_mem_device_release(dev); return ret; } @@ -1053,8 +1060,6 @@ static void k3_r5_reserved_mem_exit(struct k3_r5_rproc *kproc) for (i = 0; i < kproc->num_rmems; i++) iounmap(kproc->rmem[i].cpu_addr); kfree(kproc->rmem); - - of_reserved_mem_device_release(kproc->dev); } /* From patchwork Wed Dec 4 11:11:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13893595 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (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 E86011B87F2; Wed, 4 Dec 2024 11:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310709; cv=none; b=ZM/ETQlvop4jLrdED18B3/cx1YRDkFxr9i7teWQvF1TJzAZ3KFduAbskDErzXBknTUuFteMHS0b4KuHyw9zJOx4B12ZODN3AO/uhqUj8q72/77hLCnUtFYapU7iME2l/UumMWpMH0e/AcTb4382HewUsBOi/7kXHtHJT6/Hkd2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310709; c=relaxed/simple; bh=SMNRB7yJd0csoHCLrx5jNYkQsSs1vlyrBpbRxrLd/70=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tEGJPeCchoP+/AHDgDFxzD+Qjs4f00GnSb6vOF2Goa1dT9Ea47TCQKHu+4VqCJGvq8SqEeT6r3l0H79ovh7nWcsrKJ11bF6r+xdouPL8pyy9XL+HPaD9/PagESisPAkai983lMmBgbG0urV/+wJ0OvF95CSnGYTqUz6rFKbbw1Q= 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=TnPCCNcz; arc=none smtp.client-ip=198.47.23.235 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="TnPCCNcz" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBfHS1779879 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Dec 2024 05:11:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1733310701; bh=4w5Yzsc4wGy4qYPeLwV0qn3uMFc2ikXQj2oq1xY3Y1A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TnPCCNczYhwOUOFAg1g6p6cAb9HKd6LSHQnFaPMtyo0uB5dEEmsMKaKeYEewUpvbH gQetXgcWf/z1hHUJjKhp/VmY/uTRw5aVl8T4t6IWXcgmvF8vwlb6+YH4f9e5cu7Jar v6WUOCvv+8IwRcH2bQppUnHYySq78MGvLxR+esgA= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBfp2044813 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Dec 2024 05:11:41 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 4 Dec 2024 05:11:40 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE103.ent.ti.com (10.64.6.24) 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, 4 Dec 2024 05:11:40 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBVUM083186; Wed, 4 Dec 2024 05:11:38 -0600 From: Beleswar Padhi To: , CC: , , , , , , , Subject: [PATCH 2/5] remoteproc: k3-r5: Use devm_kcalloc() helper Date: Wed, 4 Dec 2024 16:41:27 +0530 Message-ID: <20241204111130.2218497-3-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241204111130.2218497-1-b-padhi@ti.com> References: <20241204111130.2218497-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Use a device lifecycle managed action to free memory. This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index d51f88a5abc1..0753a5c35c7e 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -997,7 +997,7 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) return ret; num_rmems--; - kproc->rmem = kcalloc(num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); + kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); if (!kproc->rmem) return -ENOMEM; @@ -1049,7 +1049,6 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) unmap_rmem: for (i--; i >= 0; i--) iounmap(kproc->rmem[i].cpu_addr); - kfree(kproc->rmem); return ret; } @@ -1059,7 +1058,6 @@ static void k3_r5_reserved_mem_exit(struct k3_r5_rproc *kproc) for (i = 0; i < kproc->num_rmems; i++) iounmap(kproc->rmem[i].cpu_addr); - kfree(kproc->rmem); } /* From patchwork Wed Dec 4 11:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13893596 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 9C78D1F130E; Wed, 4 Dec 2024 11:11:50 +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=1733310712; cv=none; b=YSJgNHHTyEmd34jtSiManK/Z027tdHbybTIKBgaOFBCeap5bjMQDz8t7g5HpKW93aQkLJfYiE4ASZ1afanL7Qbgi3uP1BBZ2wNZXzY6ujRIuNfbZA3XlsI8OAAsxIam4Wp/M+X2n4JQKNiKLytLj0JA1MFIyI14Zn0IkrR4Do7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310712; c=relaxed/simple; bh=ZWkoSIpSq7/l2O91jG7cWPTcCkrNV0qWOb4ljATi3JU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kRwOAhPWjhQ6P6sBquxD9U3ry/QA3uq31awp/3kTydmQ1hAJ9m/Tp3Bz0AlaPDSRDu1ITs5OW08qwJMlfZYyJkqkfDJwevGa6HLP5YJikOmwV+cGD3to99OfVA2GJ5fWBUD2l/GEYynrv8ot+Ytsf7DA+PVP59fSzuSwTq7Zy9s= 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=SRDvPhST; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="SRDvPhST" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBiiq062446; Wed, 4 Dec 2024 05:11:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1733310704; bh=uBAF7xUFSeFheMZzMtXSi1X5ACBbVQYUQmHsTg1KUtw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SRDvPhSTA2AK6ja2Snw8ILIdI7QWI4vLkR40R5S+dO2/T2JfwCUl42luoW51KiykO 2hkXpBDyhMIfVGcRrrA+ZinumZAuEzYlye9xfwsac7pzIcKAs490k/CbcsvZb5Wx3f BLqhrn9ogy7ojhIqTpyPlwzf6FmjGkvPEe6R30ts= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBipd037572 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Dec 2024 05:11:44 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 4 Dec 2024 05:11:43 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE106.ent.ti.com (10.64.6.27) 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, 4 Dec 2024 05:11:43 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBVUN083186; Wed, 4 Dec 2024 05:11:41 -0600 From: Beleswar Padhi To: , CC: , , , , , , , Subject: [PATCH 3/5] remoteproc: k3-r5: Add devm action to release tsp Date: Wed, 4 Dec 2024 16:41:28 +0530 Message-ID: <20241204111130.2218497-4-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241204111130.2218497-1-b-padhi@ti.com> References: <20241204111130.2218497-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Use a device lifecycle managed action to release tsp ti_sci_proc handle. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index 0753a5c35c7e..2966cb210403 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -1513,6 +1513,13 @@ static int k3_r5_core_of_get_sram_memories(struct platform_device *pdev, return 0; } +static void k3_r5_release_tsp(void *data) +{ + struct ti_sci_proc *tsp = data; + + ti_sci_proc_release(tsp); +} + static int k3_r5_core_of_init(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1606,6 +1613,10 @@ static int k3_r5_core_of_init(struct platform_device *pdev) goto err; } + ret = devm_add_action_or_reset(dev, k3_r5_release_tsp, core->tsp); + if (ret) + goto err; + platform_set_drvdata(pdev, core); devres_close_group(dev, k3_r5_core_of_init); @@ -1622,13 +1633,7 @@ static int k3_r5_core_of_init(struct platform_device *pdev) */ static void k3_r5_core_of_exit(struct platform_device *pdev) { - struct k3_r5_core *core = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; - int ret; - - ret = ti_sci_proc_release(core->tsp); - if (ret) - dev_err(dev, "failed to release proc, ret = %d\n", ret); platform_set_drvdata(pdev, NULL); devres_release_group(dev, k3_r5_core_of_init); From patchwork Wed Dec 4 11:11:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13893597 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 49B8F1F6680; Wed, 4 Dec 2024 11:11:53 +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=1733310715; cv=none; b=XlCrND9qPRAW39NrSyVkErNGaPyL6DFuVax6TknlwTmKEA3pjaxItqvxLycf3Z/J3ATnX+GN1uHktnoug3JuqFVYsQaeZzMGzGZ/zNgmpRHxUGkHQGx1DWmmW4KX6aIrQtjej6FM48trYL9BjmshLjyd0y2FzVjrO8/WUhR9QLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310715; c=relaxed/simple; bh=FsUQzpLlESBToq4cj3LdWkpnyMvxTeQO7TkZ2B6Kzt8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S86uU2MOD7eJ1/ehghe1hE4Jd+qBdt33sSEyX5pR4t9Mi0Uo5ON3FjK8zWG/eKCL6HCsyiT67VpmwWTNGeLBuIE1smo+HJG6bs6+agR2QPo+n8LNxtyHrkVQTcswBFZL7jdWd5X71MkkeBqcPqyciwTDkjEme4vDctv3YlB6cng= 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=bj2C1lz/; 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="bj2C1lz/" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBlMh1593540 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Dec 2024 05:11:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1733310707; bh=yxTK74BG9onPeTZN2lVJE4j1Ooe6Fla/IoZvSgHbKgM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bj2C1lz/Et9x6RyMvXre/4LF7FZA7zGEzMDN7E+kBgcqu7ArzkduuGHkL5TpH+HcW YUrxodhkojQIztAGG2Bc7v5hoz4FS3gkJHeWpCr4R2OaX5EFFSLO/jgq5EOwg2zNuH TwKyG0ze7qivQfoG0i+v7vgjJXqxgq53nuQJVoCI= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBl1Y018456 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Dec 2024 05:11:47 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) 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; Wed, 4 Dec 2024 05:11:46 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE111.ent.ti.com (10.64.6.32) 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, 4 Dec 2024 05:11:46 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBVUO083186; Wed, 4 Dec 2024 05:11:44 -0600 From: Beleswar Padhi To: , CC: , , , , , , , Subject: [PATCH 4/5] remoteproc: k3-r5: Use devm_ioremap_wc() helper Date: Wed, 4 Dec 2024 16:41:29 +0530 Message-ID: <20241204111130.2218497-5-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241204111130.2218497-1-b-padhi@ti.com> References: <20241204111130.2218497-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Use a device lifecycle managed ioremap helper function. This helps prevent mistakes like unmapping out of order in cleanup functions and forgetting to unmap on all error paths. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 40 +++++------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index 2966cb210403..1a7681502f62 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -1004,17 +1004,13 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) /* use remaining reserved memory regions for static carveouts */ for (i = 0; i < num_rmems; i++) { rmem_np = of_parse_phandle(np, "memory-region", i + 1); - if (!rmem_np) { - ret = -EINVAL; - goto unmap_rmem; - } + if (!rmem_np) + return -EINVAL; rmem = of_reserved_mem_lookup(rmem_np); of_node_put(rmem_np); - if (!rmem) { - ret = -EINVAL; - goto unmap_rmem; - } + if (!rmem) + return -EINVAL; kproc->rmem[i].bus_addr = rmem->base; /* @@ -1029,12 +1025,11 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) */ kproc->rmem[i].dev_addr = (u32)rmem->base; kproc->rmem[i].size = rmem->size; - kproc->rmem[i].cpu_addr = ioremap_wc(rmem->base, rmem->size); + kproc->rmem[i].cpu_addr = devm_ioremap_wc(dev, rmem->base, rmem->size); if (!kproc->rmem[i].cpu_addr) { dev_err(dev, "failed to map reserved memory#%d at %pa of size %pa\n", i + 1, &rmem->base, &rmem->size); - ret = -ENOMEM; - goto unmap_rmem; + return -ENOMEM; } dev_dbg(dev, "reserved memory%d: bus addr %pa size 0x%zx va %pK da 0x%x\n", @@ -1045,19 +1040,6 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc) kproc->num_rmems = num_rmems; return 0; - -unmap_rmem: - for (i--; i >= 0; i--) - iounmap(kproc->rmem[i].cpu_addr); - return ret; -} - -static void k3_r5_reserved_mem_exit(struct k3_r5_rproc *kproc) -{ - int i; - - for (i = 0; i < kproc->num_rmems; i++) - iounmap(kproc->rmem[i].cpu_addr); } /* @@ -1285,10 +1267,8 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) } ret = rproc_add(rproc); - if (ret) { - dev_err(dev, "rproc_add failed, ret = %d\n", ret); - goto err_add; - } + if (ret) + dev_err_probe(dev, ret, "rproc_add failed\n"); /* create only one rproc in lockstep, single-cpu or * single core mode @@ -1333,8 +1313,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) err_powerup: rproc_del(rproc); -err_add: - k3_r5_reserved_mem_exit(kproc); out: /* undo core0 upon any failures on core1 in split-mode */ if (cluster->mode == CLUSTER_MODE_SPLIT && core == core1) { @@ -1379,8 +1357,6 @@ static void k3_r5_cluster_rproc_exit(void *data) mbox_free_channel(kproc->mbox); rproc_del(rproc); - - k3_r5_reserved_mem_exit(kproc); } } From patchwork Wed Dec 4 11:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13893598 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (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 92DDB1F707F; Wed, 4 Dec 2024 11:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310718; cv=none; b=A0kHADosSQL/LnUj0p68Jb+vTTr9yzzfirnOKTL3w4HEnLcwzwqQcxFQGEjn4NlQMGR86G+R867WCQEVgFb2/sTi9LhaUBdQP3uYaYnSIjWf/FrIBkVx0QKYtgJrApE+Vdf38m6cdGZ1NfEH56GUiklw7uD9gdgFebcmjBwRl/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310718; c=relaxed/simple; bh=STEa/wbUALAG7daocIHSS80vcnLrZ2hQirwRnWPcFOg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZJ5CTEhfE/Y1sjuYbJk5CAGcWeKFnXsZfxdyhmFyYG1cqUfmVtNbS9/ItMWTRPDANHrpBZB9LREU5o75ah3U+ztwiizXMWFizHfxS73ONFWw/dCfE+uwv+HwT7m6AJovGivgijVppIiPvmOUGNdl+CM3dIujpD8cL9eJ//axxE4= 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=zCen39Vb; arc=none smtp.client-ip=198.47.19.246 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="zCen39Vb" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBoEc1760343 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Dec 2024 05:11:50 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1733310710; bh=8bFN/ISdki5HaTn/nVQXGFgD7hL89N3eSbAm+Yj27z0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=zCen39VbHApvsajznLRN+L2Pd0C3EOiG+iIOHpA9lgY19G/MtiYlXluqJ5OH+lEi/ 7AIPrrY0dJRX7kgGzuYccNRDBfbt3VKOPWeeWMVFJ9ELU9DipaxL3fn2+ebWDr56y3 BeFaDOliNYc6RmEY4f1tcAs1+pJZ6UHAXUal8jsI= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4B4BBoLs018468 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Dec 2024 05:11:50 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) 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; Wed, 4 Dec 2024 05:11:49 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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.23 via Frontend Transport; Wed, 4 Dec 2024 05:11:49 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4B4BBVUP083186; Wed, 4 Dec 2024 05:11:47 -0600 From: Beleswar Padhi To: , CC: , , , , , , , Subject: [PATCH 5/5] remoteproc: k3-r5: Use devm_rproc_add() helper Date: Wed, 4 Dec 2024 16:41:30 +0530 Message-ID: <20241204111130.2218497-6-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241204111130.2218497-1-b-padhi@ti.com> References: <20241204111130.2218497-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Use device lifecycle managed devm_rproc_add() helper function. This helps prevent mistakes like deleting out of order in cleanup functions and forgetting to delete on all error paths. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_r5_remoteproc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index 1a7681502f62..1050f4a94a14 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -1266,7 +1266,7 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret = rproc_add(rproc); + ret = devm_rproc_add(dev, rproc); if (ret) dev_err_probe(dev, ret, "rproc_add failed\n"); @@ -1355,8 +1355,6 @@ static void k3_r5_cluster_rproc_exit(void *data) } mbox_free_channel(kproc->mbox); - - rproc_del(rproc); } }