From patchwork Mon Jun 10 15:17:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 13692236 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 55E18152181; Mon, 10 Jun 2024 15:17:30 +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=1718032651; cv=none; b=sP0TGYD7Uf4v4g9DW0KP8yGhXqrDn5BOb4nzXQsUBT0kiL4mK2V60iyf3OYIRVJF7ngfPppQXgqmMvQemqdw4O4TKjpq8rRUAKni0R953Zu30D+c4D7zda62YhTBgpyRRQi9gT3vaNJNN9uE+4MB6LZXN9GkyEeOD7CzS1l0Ew0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032651; c=relaxed/simple; bh=sOaNco+FLqlWFQZwJKUYmJayImHQHMM0GUxThvmlJUs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=nUBktXT3RUjHj4eK5gwWRlPOnqskjYz4vI8V8mk6+cE2tI4CofWFFXrOZLc9QZURKvgsX7AnCU4zC3OQl7YbDkxWFojpu7KA4SCxWH1DOGMHZ4qMFTEjREMeR7me18jEkGtAtd5kjGKy6MfTzqY/+NhDmdecwgeNk1XuApBmfyM= 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=OiWlFA5D; 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="OiWlFA5D" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHN1V015717; Mon, 10 Jun 2024 10:17:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718032643; bh=eEAzozxKjD70xYuPAE4Mv+i/JZ3PrMZUw5jNNClYHAA=; h=From:To:CC:Subject:Date; b=OiWlFA5DsDXCAcwtaFMZtJMOljmffZ9i9sGbcjhXABKl3nIm5z3zbTqRedfSqLmib eZRropmiqvuqv4eFrOmY5Yn1ruk30LZx6cQUAEwwWxoKbaqpOjP92B1uekPY/N/Z1V EyDWGgfKAzzNUmZl8i2GaG1HxFPmfeWUu4TjCfzQ= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45AFHNBj031333 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2024 10:17:23 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 10 Jun 2024 10:17:23 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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 via Frontend Transport; Mon, 10 Jun 2024 10:17:23 -0500 Received: from fllvsmtp7.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHMqb017714; Mon, 10 Jun 2024 10:17:22 -0500 From: Andrew Davis To: Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 1/6] remoteproc: omap: Use devm_rproc_alloc() helper Date: Mon, 10 Jun 2024 10:17:16 -0500 Message-ID: <20240610151721.189472-1-afd@ti.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use the device lifecycle managed allocation function. This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/omap_remoteproc.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 8f50ab80e56f4..e91e016583802 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -1305,8 +1305,8 @@ static int omap_rproc_probe(struct platform_device *pdev) return ret; } - rproc = rproc_alloc(&pdev->dev, dev_name(&pdev->dev), &omap_rproc_ops, - firmware, sizeof(*oproc)); + rproc = devm_rproc_alloc(&pdev->dev, dev_name(&pdev->dev), &omap_rproc_ops, + firmware, sizeof(*oproc)); if (!rproc) return -ENOMEM; @@ -1318,15 +1318,15 @@ static int omap_rproc_probe(struct platform_device *pdev) ret = omap_rproc_of_get_internal_memories(pdev, rproc); if (ret) - goto free_rproc; + return ret; ret = omap_rproc_get_boot_data(pdev, rproc); if (ret) - goto free_rproc; + return ret; ret = omap_rproc_of_get_timers(pdev, rproc); if (ret) - goto free_rproc; + return ret; init_completion(&oproc->pm_comp); oproc->autosuspend_delay = DEFAULT_AUTOSUSPEND_DELAY; @@ -1337,10 +1337,8 @@ static int omap_rproc_probe(struct platform_device *pdev) pm_runtime_set_autosuspend_delay(&pdev->dev, oproc->autosuspend_delay); oproc->fck = devm_clk_get(&pdev->dev, 0); - if (IS_ERR(oproc->fck)) { - ret = PTR_ERR(oproc->fck); - goto free_rproc; - } + if (IS_ERR(oproc->fck)) + return PTR_ERR(oproc->fck); ret = of_reserved_mem_device_init(&pdev->dev); if (ret) { @@ -1359,8 +1357,7 @@ static int omap_rproc_probe(struct platform_device *pdev) release_mem: of_reserved_mem_device_release(&pdev->dev); -free_rproc: - rproc_free(rproc); + return ret; } @@ -1369,7 +1366,6 @@ static void omap_rproc_remove(struct platform_device *pdev) struct rproc *rproc = platform_get_drvdata(pdev); rproc_del(rproc); - rproc_free(rproc); of_reserved_mem_device_release(&pdev->dev); } From patchwork Mon Jun 10 15:17:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 13692235 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 DD18D152503; Mon, 10 Jun 2024 15:17:29 +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=1718032651; cv=none; b=PhSl50J8mHi9Jf6Ubz59F3K/P5tBTDq8y586h3DGhk+8HACMK7aB9ulFtHGEXzugkOU4b/iBONYnBsPCvHWHKLMTnf+bqkq9DsFqpbIC7ibGFX+EhVIE1S/ytxuQSzhFoYtb+H7eaMQ0HAqzgtDAqKPXT5u+1CCqIl5fA2FZh04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032651; c=relaxed/simple; bh=6yYEdI23czqjygLKy/yvVQfBp63RgkYgqjvNiwla/W4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PjlqXSMGNdXv2/HcjrE80U5tYj/7bZMG/ND7ZcKVLbZDGcNX74LotcWOmBpI96obg5zkWIMXDtpND6UsvEUAEdJSm7BehNqYM8j2zO0FRCVMAWKfq9PXUHHqbE0sU1x9jwIfyqAG+0us3sU0yEPXI3QR2Vgk0kyJuop3vgmpB44= 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=Ok8BC50R; 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="Ok8BC50R" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHNiZ126245; Mon, 10 Jun 2024 10:17:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718032643; bh=N/XIQdrQKpNNnxZOsUxINN1I4bjjpDcOT/P/kILZnuA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Ok8BC50R+d9lTpqk3tysCurjS7dvP+VjzPghpiQiJaYgcVJY5o9iO6uKdyDBqPKo3 zg3VDS0uusZIYv91MEheyAaz93Ur97U5KzA5Rjt68qpKNqBsnUyaq7mHTHTqJ07fJS 4xns4G0uULOzps0VSmvXyjG8rDqbb/yvOQYBxUuE= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45AFHNn7014838 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2024 10:17:23 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) 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; Mon, 10 Jun 2024 10:17:23 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE111.ent.ti.com (157.170.170.22) 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; Mon, 10 Jun 2024 10:17:23 -0500 Received: from fllvsmtp7.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHMqc017714; Mon, 10 Jun 2024 10:17:23 -0500 From: Andrew Davis To: Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 2/6] remoteproc: omap: Use devm action to release reserved memory Date: Mon, 10 Jun 2024 10:17:17 -0500 Message-ID: <20240610151721.189472-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610151721.189472-1-afd@ti.com> References: <20240610151721.189472-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/omap_remoteproc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index e91e016583802..df46be84658f7 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -1277,6 +1277,13 @@ static int omap_rproc_of_get_timers(struct platform_device *pdev, return 0; } +static void omap_rproc_mem_release(void *data) +{ + struct device *dev = data; + + of_reserved_mem_device_release(dev); +} + static int omap_rproc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1346,19 +1353,17 @@ static int omap_rproc_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "Typically this should be provided,\n"); dev_warn(&pdev->dev, "only omit if you know what you are doing.\n"); } + ret = devm_add_action_or_reset(&pdev->dev, omap_rproc_mem_release, &pdev->dev); + if (ret) + return ret; platform_set_drvdata(pdev, rproc); ret = rproc_add(rproc); if (ret) - goto release_mem; + return ret; return 0; - -release_mem: - of_reserved_mem_device_release(&pdev->dev); - - return ret; } static void omap_rproc_remove(struct platform_device *pdev) @@ -1366,7 +1371,6 @@ static void omap_rproc_remove(struct platform_device *pdev) struct rproc *rproc = platform_get_drvdata(pdev); rproc_del(rproc); - of_reserved_mem_device_release(&pdev->dev); } static const struct dev_pm_ops omap_rproc_pm_ops = { From patchwork Mon Jun 10 15:17:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 13692231 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 873DF15218E; Mon, 10 Jun 2024 15:17:27 +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=1718032649; cv=none; b=Pp82xPDPN6MVQ4I4CVLVhnQokuFZCtTEUV4lMYpTBQ6kNnk9utrEgnWvq5cxYV600vM0ZQgBqiADp1sgoLXK8KzyKETBt8bFdFI4vPfyCqhBkLOAzgjl2TofsK7L/+0PiTd83M5igiWb8PTkEzz3dT5TfOOxT7O1lhXQgieUnfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032649; c=relaxed/simple; bh=34IBcVJRT9a1iGd/s4e2KmsiacQ/fwBWEn/GfLuaU84=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SWD/ZeVPJ+yXQk80QcWPTQXPrON2eOImTLiW4K9+Zz/qoBhKwyPjhTJ8nxUO1fSk9aKbG2TeudkudcAHSzE0r9utTGdUnfVYOKhHjm9PC9gCV6NVOH6zvz5cYyGH1uWP2p962jKphL308WL0GTOC+gJcpRmbR+SGL55g2ASsvhc= 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=BymZSzbP; 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="BymZSzbP" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHOmX126249; Mon, 10 Jun 2024 10:17:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718032644; bh=r0k+DvL6KY1JUyaLhso3b+X98/K/2Xw/JXU0kRkC/zo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BymZSzbPbO7i5E0wLt2YsTRQ40RnqIjnWrjxCVAp9JDcBa+deQnhZ2+f4MMCxHof7 OdrnI3DQIQkXMDzTcAUXXGvFtblS4GG8AZ605152jsG0Zzb3tMPYKF97MJX1OyZBV9 iZogwg5sqxDowAJSZ2mmoVQpGUvrhuz5BOePqg1s= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45AFHOjQ017905 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2024 10:17:24 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 10 Jun 2024 10:17:23 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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 via Frontend Transport; Mon, 10 Jun 2024 10:17:23 -0500 Received: from fllvsmtp7.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHMqd017714; Mon, 10 Jun 2024 10:17:23 -0500 From: Andrew Davis To: Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 3/6] remoteproc: omap: Use devm_rproc_add() helper Date: Mon, 10 Jun 2024 10:17:18 -0500 Message-ID: <20240610151721.189472-3-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610151721.189472-1-afd@ti.com> References: <20240610151721.189472-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use the device lifecycle managed add function. This helps prevent mistakes like deleting out of order in cleanup functions and forgetting to delete on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/omap_remoteproc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index df46be84658f7..9ae2e831456d5 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -1359,20 +1359,13 @@ static int omap_rproc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rproc); - ret = rproc_add(rproc); + ret = devm_rproc_add(&pdev->dev, rproc); if (ret) return ret; return 0; } -static void omap_rproc_remove(struct platform_device *pdev) -{ - struct rproc *rproc = platform_get_drvdata(pdev); - - rproc_del(rproc); -} - static const struct dev_pm_ops omap_rproc_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(omap_rproc_suspend, omap_rproc_resume) SET_RUNTIME_PM_OPS(omap_rproc_runtime_suspend, @@ -1381,7 +1374,6 @@ static const struct dev_pm_ops omap_rproc_pm_ops = { static struct platform_driver omap_rproc_driver = { .probe = omap_rproc_probe, - .remove_new = omap_rproc_remove, .driver = { .name = "omap-rproc", .pm = &omap_rproc_pm_ops, From patchwork Mon Jun 10 15:17:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 13692233 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 83D1813E8AF; Mon, 10 Jun 2024 15:17:28 +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=1718032651; cv=none; b=P6SqSd2fsFyUrN3oYIM7zwyYWfUXcvWrCqV/9rk+b0TYUecR3cMycuGQUZ86M9NP1u9fJtKGj88Sa+j8/0Z6mB0H+LX42UvEGmJXjYrqqEmwbQ6gST5il2ou5maOEAB7Po4bltML2VOozzSAju//D8MheRde6TR2j7HE/fXXdbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032651; c=relaxed/simple; bh=JAyHEY+j18HTYSYl1Aztg6T0nMyvI/Xbze+2yOXq6bQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CHq7IeHB0XtUDZ/RpcZWJtNHfascvp0B3/iyTQmt685yuuOvk9s4i1p2ZHcnr4zsjrGhzkvi4eVnTcxNLujZTV03yqduUwbRVE39wj+BJ9it1HOEaTSoooPbPXkQ/QTFOcgXIJfJfYdGbBEHEQAc1b6Hb16USOJa3dsvwZ5kTSI= 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=cHpSipvY; 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="cHpSipvY" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHOZc031194; Mon, 10 Jun 2024 10:17:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718032644; bh=UytDmNmxyZC8MU+aqCgHNCsUlOhqj7U+hI6dXupZkKo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cHpSipvYBMjdnsJn7DCQFrE9iK1sO6RP8bBJI35DJpZuYwIYFyFf+v1xMJbsA0/9k ETkc2CJfKkZtIKHTLJikjEWo+NIU3ZTKTQeKqx0O7VDm+D8Eu6TgLjISzFtrrlOnh7 sr8qZxvYCHMomreV/2GJfCP0OoPVcOW+hoRg2KHM= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45AFHOId017909 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2024 10:17:24 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) 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; Mon, 10 Jun 2024 10:17:23 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE107.ent.ti.com (10.64.6.28) 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; Mon, 10 Jun 2024 10:17:23 -0500 Received: from fllvsmtp7.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHMqe017714; Mon, 10 Jun 2024 10:17:23 -0500 From: Andrew Davis To: Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 4/6] remoteproc: da8xx: Use devm_rproc_alloc() helper Date: Mon, 10 Jun 2024 10:17:19 -0500 Message-ID: <20240610151721.189472-4-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610151721.189472-1-afd@ti.com> References: <20240610151721.189472-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use the device lifecycle managed allocation function. This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/da8xx_remoteproc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c index 9041a0e07fb25..c8b7576937733 100644 --- a/drivers/remoteproc/da8xx_remoteproc.c +++ b/drivers/remoteproc/da8xx_remoteproc.c @@ -295,8 +295,8 @@ static int da8xx_rproc_probe(struct platform_device *pdev) } } - rproc = rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name, - sizeof(*drproc)); + rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name, + sizeof(*drproc)); if (!rproc) { ret = -ENOMEM; goto free_mem; @@ -313,7 +313,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) ret = da8xx_rproc_get_internal_memories(pdev, drproc); if (ret) - goto free_rproc; + goto free_mem; platform_set_drvdata(pdev, rproc); @@ -323,7 +323,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) rproc); if (ret) { dev_err(dev, "devm_request_threaded_irq error: %d\n", ret); - goto free_rproc; + goto free_mem; } /* @@ -333,7 +333,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) */ ret = reset_control_assert(dsp_reset); if (ret) - goto free_rproc; + goto free_mem; drproc->chipsig = chipsig; drproc->bootreg = bootreg; @@ -344,13 +344,11 @@ static int da8xx_rproc_probe(struct platform_device *pdev) ret = rproc_add(rproc); if (ret) { dev_err(dev, "rproc_add failed: %d\n", ret); - goto free_rproc; + goto free_mem; } return 0; -free_rproc: - rproc_free(rproc); free_mem: if (dev->of_node) of_reserved_mem_device_release(dev); @@ -371,7 +369,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev) disable_irq(drproc->irq); rproc_del(rproc); - rproc_free(rproc); if (dev->of_node) of_reserved_mem_device_release(dev); } From patchwork Mon Jun 10 15:17:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 13692234 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 714F715219B; Mon, 10 Jun 2024 15:17:29 +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=1718032651; cv=none; b=S7+M/NHxEYYFsNAGWrQB8tbEuP0LIbbbZXiz8T4EowQuodJvWTcxpbxXfDB7QspqnUw/Xn5yPx30SXz/skGZVxinMC4szkRMBvadH8MIRmFn1gXYo6vredRrtGczfo+f534F9zP6rFIV5bWAMEYszA4Z+2b5v2XkDJXf5k0ObAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032651; c=relaxed/simple; bh=ZnwOh+9SPYsIoCA0Yw7ACXIruoaK3rUWGSzsDVyR7ag=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ckoWLJFZqsbiBGRhaMdssdt3Es+KWIn21Kz7MhRFnT2zNJYE6s+oJ4yjYe4UMPflZwSItfqolqD43pAY2FK5xHJ20fhzgwQ3E/gQBarn8RqMBJbEcdCrkasV3mteI7ib/nwmszfMFeoJDgBG0CeFDNYbam/OcweAPJuQv6ArYWg= 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=LWCto1tM; 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="LWCto1tM" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHOXj031236; Mon, 10 Jun 2024 10:17:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718032644; bh=zeFCvWKCEuu/FkgeqrdnamocS3kKPOcvswqy8fT7eUE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LWCto1tM0uSB7Atzu3REJRKvTGpRw+IqgRx7z+9Ti0HvvcpO/5ooyrTUqitBCzqaL 8UqHQ1ZfVaGynR/ghWoEXWl07vc5ewKPtTWUmfuDPR5ymFPLdxdlje+5ITUtzu62Cy fuU6CDaC+KWcDCz8jzn5ZUOgEuBN1rwaSy4Df7HQ= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45AFHOlq031337 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2024 10:17:24 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 10 Jun 2024 10:17:24 -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; Mon, 10 Jun 2024 10:17:24 -0500 Received: from fllvsmtp7.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHMqf017714; Mon, 10 Jun 2024 10:17:23 -0500 From: Andrew Davis To: Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 5/6] remoteproc: da8xx: Use devm action to release reserved memory Date: Mon, 10 Jun 2024 10:17:20 -0500 Message-ID: <20240610151721.189472-5-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610151721.189472-1-afd@ti.com> References: <20240610151721.189472-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/da8xx_remoteproc.c | 29 +++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c index c8b7576937733..1ce91516fc6e5 100644 --- a/drivers/remoteproc/da8xx_remoteproc.c +++ b/drivers/remoteproc/da8xx_remoteproc.c @@ -233,6 +233,13 @@ static int da8xx_rproc_get_internal_memories(struct platform_device *pdev, return 0; } +static void da8xx_rproc_mem_release(void *data) +{ + struct device *dev = data; + + of_reserved_mem_device_release(dev); +} + static int da8xx_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -293,14 +300,13 @@ static int da8xx_rproc_probe(struct platform_device *pdev) ret); return ret; } + devm_add_action_or_reset(&pdev->dev, da8xx_rproc_mem_release, &pdev->dev); } rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name, sizeof(*drproc)); - if (!rproc) { - ret = -ENOMEM; - goto free_mem; - } + if (!rproc) + return -ENOMEM; /* error recovery is not supported at present */ rproc->recovery_disabled = true; @@ -313,7 +319,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) ret = da8xx_rproc_get_internal_memories(pdev, drproc); if (ret) - goto free_mem; + return ret; platform_set_drvdata(pdev, rproc); @@ -323,7 +329,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) rproc); if (ret) { dev_err(dev, "devm_request_threaded_irq error: %d\n", ret); - goto free_mem; + return ret; } /* @@ -333,7 +339,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) */ ret = reset_control_assert(dsp_reset); if (ret) - goto free_mem; + return ret; drproc->chipsig = chipsig; drproc->bootreg = bootreg; @@ -344,15 +350,10 @@ static int da8xx_rproc_probe(struct platform_device *pdev) ret = rproc_add(rproc); if (ret) { dev_err(dev, "rproc_add failed: %d\n", ret); - goto free_mem; + return ret; } return 0; - -free_mem: - if (dev->of_node) - of_reserved_mem_device_release(dev); - return ret; } static void da8xx_rproc_remove(struct platform_device *pdev) @@ -369,8 +370,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev) disable_irq(drproc->irq); rproc_del(rproc); - if (dev->of_node) - of_reserved_mem_device_release(dev); } static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = { From patchwork Mon Jun 10 15:17:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 13692232 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 83D611420DD; Mon, 10 Jun 2024 15:17:28 +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=1718032650; cv=none; b=iwNqNeu3QY4SnOEQ6/3mjdIMhc3LGQnCXEQpcmxNe3E5+RyUEtuyuHJyDe67Uz89GQE5vGmAGKw3VZPBWiw40z7bZcIjAFIG22WbKLeLKI3zoJ9pIUJhvuglyH1G4zbq5jJB3v3lHCXze7/Wbt0G04HNQZ8qU8ImusaADne3mtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032650; c=relaxed/simple; bh=1+VmIOqLzP9/9IDW1FCErix7AzPjQR66MWqohWtZ9lc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OUpIOQjAne8AsQcSVvpTto6EbTEbeuO7ezzcRBIjyQq8NfFmfaqLqcfwaNGGhUNgLlMk3BKbl0YlehR6YQWtymUD1aSNX3xcx6N4qpKJcolZWtpbaWCvWbjBn8QQLWWm/VYvJvc74bSVQZ2yvouhFHagYc2pphF4AZ0l+CCSSqk= 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=nlJLHuRH; 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="nlJLHuRH" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHOIa031242; Mon, 10 Jun 2024 10:17:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1718032644; bh=S6CAbyqppimi4za1W8UTwhhlNLZYFkY8msmfDKM8H40=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nlJLHuRHVtECND7ftf8DJAwRs0ypOIgMSIN1UMiy8f649XLdiLQTr4dY9pxfvqM3y Yb1vD2d9Xjw0znAfZav6Mu7tHimIa62krNnF+apZgGL9wR7FYP2UeTtBN9a61eZChP swhZ5POZIun7tv7mT7kn4hd8pdjAokSbW0R5FDw8= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 45AFHOAj031340 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2024 10:17:24 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) 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; Mon, 10 Jun 2024 10:17:24 -0500 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; Mon, 10 Jun 2024 10:17:24 -0500 Received: from fllvsmtp7.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 45AFHMqg017714; Mon, 10 Jun 2024 10:17:24 -0500 From: Andrew Davis To: Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 6/6] remoteproc: da8xx: Use devm_rproc_add() helper Date: Mon, 10 Jun 2024 10:17:21 -0500 Message-ID: <20240610151721.189472-6-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610151721.189472-1-afd@ti.com> References: <20240610151721.189472-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use the device lifecycle managed add function. This helps prevent mistakes like deleting out of order in cleanup functions and forgetting to delete on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/da8xx_remoteproc.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c index 1ce91516fc6e5..c20cf33429da9 100644 --- a/drivers/remoteproc/da8xx_remoteproc.c +++ b/drivers/remoteproc/da8xx_remoteproc.c @@ -321,8 +321,6 @@ static int da8xx_rproc_probe(struct platform_device *pdev) if (ret) return ret; - platform_set_drvdata(pdev, rproc); - /* everything the ISR needs is now setup, so hook it up */ ret = devm_request_threaded_irq(dev, irq, da8xx_rproc_callback, handle_event, 0, "da8xx-remoteproc", @@ -347,7 +345,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) drproc->irq_data = irq_data; drproc->irq = irq; - ret = rproc_add(rproc); + ret = devm_rproc_add(dev, rproc); if (ret) { dev_err(dev, "rproc_add failed: %d\n", ret); return ret; @@ -356,22 +354,6 @@ static int da8xx_rproc_probe(struct platform_device *pdev) return 0; } -static void da8xx_rproc_remove(struct platform_device *pdev) -{ - struct rproc *rproc = platform_get_drvdata(pdev); - struct da8xx_rproc *drproc = rproc->priv; - struct device *dev = &pdev->dev; - - /* - * The devm subsystem might end up releasing things before - * freeing the irq, thus allowing an interrupt to sneak in while - * the device is being removed. This should prevent that. - */ - disable_irq(drproc->irq); - - rproc_del(rproc); -} - static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = { { .compatible = "ti,da850-dsp", }, { /* sentinel */ }, @@ -380,7 +362,6 @@ MODULE_DEVICE_TABLE(of, davinci_rproc_of_match); static struct platform_driver da8xx_rproc_driver = { .probe = da8xx_rproc_probe, - .remove_new = da8xx_rproc_remove, .driver = { .name = "davinci-rproc", .of_match_table = of_match_ptr(davinci_rproc_of_match),