From patchwork Mon Feb 5 18:27:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 196986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1062632dyb; Mon, 5 Feb 2024 10:30:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEflSe41SFn7r9I48MOSuCel3lBoa7Wp1YUcncw7ZAemixSIP0tfxtndQkd4ZIbFO3Hr6ba X-Received: by 2002:a05:620a:1125:b0:785:4ecd:116b with SMTP id p5-20020a05620a112500b007854ecd116bmr9931144qkk.11.1707157831558; Mon, 05 Feb 2024 10:30:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707157831; cv=pass; d=google.com; s=arc-20160816; b=F2MACi8Xzi3AFvg5HyPfKlbnDIVc8gLkTVyMGFC0caHk5rPLXwyOF5Kd2VEAFaTxTc ZAiLrMm9IR8qpeM/3g6XSZVWAlwjY7Q5OpfA4g0FBty1IorhJIaJxTNhLxGsQdYEi8UU guWHflKJgoQo2NNST0UwAcRKGkfEPO2PYDc89XJiQBV7SXjYk605OD9q352FZlljwlqw N6UeYpzxJN6m1JAOG/gIM+BP3dQe1rw7NEGb6xZBEh75pScMCn1etmBEb4zsg4mGnAGK ETdj2dtZmiy2lyEw/XkgXRkdj2cdz3cDGbNBAuK0cyz9iDNgjCd4IzxHZF1Gz/3d7yXV K5hw== 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=xaLWTIDjzfNp2P1XeVqQkeb9zL5PNKaNChxFw6CRZmI=; fh=Yr/l29DK3I4xmq+EFpEmz7oS1SByn2ipz7bJoSkDXPY=; b=AucjPZd3oPM7xVXUtUu/9mLLE+s7zMt2CFiez4ylamVwowKHCZtIhn81oe04Z3LflO kIA05f8e2Nozm5JiQoD/ZLyNHBQ+lBRq78PP27Kh+gOKXl/3T9Sy6OO2RTzgQ0LVMmq7 25S9M2rMQ3Wqd55i4KMyKpHV/L1xPnm6yy3DiEyxbyzAS8xgoXt3QA/MKwtB0O46zPof qq+5arh8hQz6S2wKa/cZ7mfM7SseV5TbE99yax0imnNDCEhNshngq1VICvWiSD1CASqn LhIorZSmZcWbZbPcq/Qze8wqGygAfBC2d3pA6K4JojLyWlscTr1t6oZVFPyYwJPB5G7L cH9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZBqxSjKq; 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-53214-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53214-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUrvlXv2iUwbwByUYA5SwXNuZlOxb5TE4Xw9RPwmA0fVPa0ra15PwD1yLdb+yFlqX596bI6W5oBECytGws6SuUJfTeE1A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k17-20020ac81411000000b0042c2f350bc2si364019qtj.744.2024.02.05.10.30.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:30:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53214-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZBqxSjKq; 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-53214-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53214-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 991C51C228FB for ; Mon, 5 Feb 2024 18:30:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D75144D10A; Mon, 5 Feb 2024 18:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZBqxSjKq" 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 33B62482FB; Mon, 5 Feb 2024 18:27:58 +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=1707157680; cv=none; b=EUrDSe7MLhO7X9AiiiO8zVccahYSXrd1sxSQl+ljvrss1mHFK8hWNSeoNU/5HlYYHxQsrDudv6ConAzDVKSmnJsArR+xpZ179vdI9T28NvlvRHbHJpLzMalKnVPwM3xLfWw4sOk1tUnl2neJi1EUdGTq15go+iOOS/i5FfRnB20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157680; c=relaxed/simple; bh=Kh9yRK3JG8JtXsrppNxzxgruosSYQ16G2fxHLif/Xfk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fFqhF/UM/27JShxzEXfrmiCCCiTk+GK6+H1MhvYVGIYDNUAtwmCdyHiiIsXy6TIfPgJcJ2HvGmbPE7W5nqXn3rmRoJEkXyAYDvV9qoSGsbODWk7all+1J9jdSvzEoaJUKz966i5AgLka6uZ7hBIX0kl2APsO7XiSfI3KaqjiEGs= 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=ZBqxSjKq; 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 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415IRtZ4119736; Mon, 5 Feb 2024 12:27:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707157675; bh=xaLWTIDjzfNp2P1XeVqQkeb9zL5PNKaNChxFw6CRZmI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZBqxSjKqt+FPjyT+9Ra4zUPQzOGGM/9FVnk3+rEUz/UVG89IwuLBJIq2YH09Odpzq Oo1OxDl9KHXbcVo64EZ4n+B8IrMEMMojPLRPjDj71+pCWK083S86aYBGIsuOoMpYFK SOaC9wbitxnwo72tg2EvZL5Ft4H0feYMIwUW+PIU= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415IRt2E120823 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 12:27:55 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) 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; Mon, 5 Feb 2024 12:27:54 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE115.ent.ti.com (157.170.170.26) 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, 5 Feb 2024 12:27:54 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 415IRsX5058567; Mon, 5 Feb 2024 12:27:54 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 1/5] remoteproc: k3-dsp: Use devm_ti_sci_get_by_phandle() helper Date: Mon, 5 Feb 2024 12:27:49 -0600 Message-ID: <20240205182753.36978-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205182753.36978-1-afd@ti.com> References: <20240205182753.36978-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790084730361576475 X-GMAIL-MSGID: 1790084730361576475 Use the device lifecycle managed TI-SCI get() function. This helps prevent mistakes like not put()'ing in the wrong order in cleanup functions and forgetting to put() on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 32 +++++++---------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index a13552c71f440..64ec5759c4ec1 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -708,30 +708,24 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) kproc->dev = dev; kproc->data = data; - kproc->ti_sci = ti_sci_get_by_phandle(np, "ti,sci"); + kproc->ti_sci = devm_ti_sci_get_by_phandle(dev, "ti,sci"); if (IS_ERR(kproc->ti_sci)) return dev_err_probe(dev, PTR_ERR(kproc->ti_sci), "failed to get ti-sci handle\n"); ret = of_property_read_u32(np, "ti,sci-dev-id", &kproc->ti_sci_id); - if (ret) { - dev_err_probe(dev, ret, "missing 'ti,sci-dev-id' property\n"); - goto put_sci; - } + if (ret) + return dev_err_probe(dev, ret, "missing 'ti,sci-dev-id' property\n"); kproc->reset = devm_reset_control_get_exclusive(dev, NULL); - if (IS_ERR(kproc->reset)) { - ret = dev_err_probe(dev, PTR_ERR(kproc->reset), - "failed to get reset\n"); - goto put_sci; - } + if (IS_ERR(kproc->reset)) + return dev_err_probe(dev, PTR_ERR(kproc->reset), + "failed to get reset\n"); kproc->tsp = k3_dsp_rproc_of_get_tsp(dev, kproc->ti_sci); - if (IS_ERR(kproc->tsp)) { - ret = dev_err_probe(dev, PTR_ERR(kproc->tsp), - "failed to construct ti-sci proc control\n"); - goto put_sci; - } + if (IS_ERR(kproc->tsp)) + return dev_err_probe(dev, PTR_ERR(kproc->tsp), + "failed to construct ti-sci proc control\n"); ret = ti_sci_proc_request(kproc->tsp); if (ret < 0) { @@ -805,10 +799,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret1)); free_tsp: kfree(kproc->tsp); -put_sci: - ret1 = ti_sci_put_handle(kproc->ti_sci); - if (ret1) - dev_err(dev, "failed to put ti_sci handle (%pe)\n", ERR_PTR(ret1)); return ret; } @@ -836,10 +826,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) kfree(kproc->tsp); - ret = ti_sci_put_handle(kproc->ti_sci); - if (ret) - dev_err(dev, "failed to put ti_sci handle (%pe)\n", ERR_PTR(ret)); - k3_dsp_reserved_mem_exit(kproc); } From patchwork Mon Feb 5 18:27:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 196987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1062667dyb; Mon, 5 Feb 2024 10:30:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdLCTX4jPB9L/wC0Q3zSo3vlG+WPTr9xmM/rGf6BZnV8YOnb1cIBc8DauMxjmjn0rl7TiD X-Received: by 2002:a17:906:7c4d:b0:a23:7633:59ae with SMTP id g13-20020a1709067c4d00b00a23763359aemr464234ejp.9.1707157834431; Mon, 05 Feb 2024 10:30:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707157834; cv=pass; d=google.com; s=arc-20160816; b=pN8TV8Lut/takX6n5fsuae/54ysH1xsoAwZ921W0al/5AtaVqBcROhn9mnhOLzUZy+ 4Bodrz4/fTJQSRYrCt53gAL51+qPXRfs9lkotvQuEEUNYlSsH0LuAgZ/B45PgidvJvzJ iekt3wbmhD7jq+A1K/Kmq6gdEz2/mmpzj4Pi+joxhAk1TmRjv9kYoBZjaWg9dkERzbqs nTsxKOT768QPv8aZLtKvkJRsns4CaiRLj2C8/CrE4VWInDQcYBYrRcl9A5ZhwRq1+z1i lcZSKJQqd6vluabmr7GZBoRgyu/nJSN8ScU4oVW4CUr7KFM0VbrXLhznztvdVA4MF9W8 P6PQ== 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=g1q4FekfzRMSbOBtJtjziYmh6/fEDmEyxKNCwbQkyVA=; fh=sxcI/PvGLfTJoA+LaB6L2p4pM3ofYBQuNyJWO+nguaE=; b=DQRIoY/nUKHU19i12Qdm6P6QbZfxFJecO6asmisAx45yGHyVPIe9Otq6lVAKPTzsup zJnl0hYi0NeBgwGnzOf6XmWpo3h1B5kSiKvnZ6WB1KKUDOUf6ns5uaYjWmuhPi73EiUJ lKq4lm2spt8wpvwMZ9gMdDglDgjcLnnRtIN3gBG5Ou0KgYdWYAHGjNZ5CBOqCge4/79o wah9VjTVfK2d8wC70o6oOJfZwgDL6Kl/s2Wruo6Z8IZlxrT81gj+4PMe+0GihSab8+63 2q6YUQLcXYQv6C8NN5Y2V1lxI64qP0IaUy306dRYzQ9cGEX3IgvzNjWUTbvNgHtzWxNz PmPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pwPX+TFq; 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-53216-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53216-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCV8oeoI4VsCD/lr1axEZ5tMQvLTz6gF+yksce+7nbwUZYZ4eDcibIJI1lvRgCUHjukkgDKnEtYXaVuACokJXWyBWPsGgg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v11-20020a1709064e8b00b00a35cf772d4asi103092eju.323.2024.02.05.10.30.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:30:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53216-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pwPX+TFq; 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-53216-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53216-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0FA0C1F239AB for ; Mon, 5 Feb 2024 18:30:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 645174DA0D; Mon, 5 Feb 2024 18:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="pwPX+TFq" 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 DD62A482EC; Mon, 5 Feb 2024 18:27:59 +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=1707157681; cv=none; b=oHz/ujxCjEzudUqO2vkXov//YFMz+3Cs2lysT4EIYhi/CHzMgM3AIqdE3MFSVr4vl8RY2j2ju77YOE77JnGjI3xbXQaGCe1TaZIlmAqaiaDwN2WwpN9EKWtLUMsBcM3AyT2yekyDfXBmf7jkzqntaHSHnc8ZUoa9YRA0kIaQHWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157681; c=relaxed/simple; bh=BZRn5HxmV1kTcaDGI1DqUA2GdRQp+wL20o190NF3od0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Om5SwrGsuA5ja+zxT5srhiciBT4F4vb3h6B9tdLrFfIB5nK7ZlZelssEIYt2kL5shtg/h0uFyOJS+7ZivV7yZ40uvRpFscttPMUkrD3HaJzuxbsBpo61/AJZfjwa74G6JOpr8eQJ0xCVlwu63Zje7LdA9yJVzv0l9XMtLYF2w7o= 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=pwPX+TFq; 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 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415IRtY3004117; Mon, 5 Feb 2024 12:27:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707157675; bh=g1q4FekfzRMSbOBtJtjziYmh6/fEDmEyxKNCwbQkyVA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=pwPX+TFqEibVAR0LKRl4aBT/N7JSyGxWWcF51fOkcpb1oczyj0iJQHqL06f6ERqId AFg0TBSY7vAmasMXGQoMq+xBYKb/K1/ChF3XH003f/E0Spp+/CRNNWhCEetrvwfeUI nNl+/tyH6hSHFjV27iNMFlj2xLIWhEhKHgdUqphY= 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 415IRt4I017727 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 12:27:55 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) 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, 5 Feb 2024 12:27:55 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE104.ent.ti.com (157.170.170.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, 5 Feb 2024 12:27:55 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 415IRsX6058567; Mon, 5 Feb 2024 12:27:54 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 2/5] remoteproc: k3-dsp: Use devm_kzalloc() helper Date: Mon, 5 Feb 2024 12:27:50 -0600 Message-ID: <20240205182753.36978-3-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205182753.36978-1-afd@ti.com> References: <20240205182753.36978-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790084733213060237 X-GMAIL-MSGID: 1790084733213060237 Use device lifecycle managed devm_kzalloc() helper function. This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on all error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 64ec5759c4ec1..b9332c66a52ab 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -659,7 +659,7 @@ struct ti_sci_proc *k3_dsp_rproc_of_get_tsp(struct device *dev, if (ret < 0) return ERR_PTR(ret); - tsp = kzalloc(sizeof(*tsp), GFP_KERNEL); + tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL); if (!tsp) return ERR_PTR(-ENOMEM); @@ -730,7 +730,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ret = ti_sci_proc_request(kproc->tsp); if (ret < 0) { dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); - goto free_tsp; + return ret; } ret = k3_dsp_rproc_of_get_memories(pdev, kproc); @@ -797,8 +797,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ret1 = ti_sci_proc_release(kproc->tsp); if (ret1) dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret1)); -free_tsp: - kfree(kproc->tsp); return ret; } @@ -824,8 +822,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) if (ret) dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret)); - kfree(kproc->tsp); - k3_dsp_reserved_mem_exit(kproc); } From patchwork Mon Feb 5 18:27:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 196989 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1062685dyb; Mon, 5 Feb 2024 10:30:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1F7Jmx2ANIeGrSle0VD/3Z4sKRU+/W1f1Sxu3ijTFhLoOyjL0CNiTIpVFf8YBXrlxQrTk X-Received: by 2002:a05:6830:1d94:b0:6dd:e00c:8350 with SMTP id y20-20020a0568301d9400b006dde00c8350mr433740oti.15.1707157836036; Mon, 05 Feb 2024 10:30:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707157836; cv=pass; d=google.com; s=arc-20160816; b=zSpP6JupuVitpei8zZjoT50K5+p9mwW8Qe6grPrxChWEQr0E1jLZe6veD5HjomFG7Z ameBjY94/OrId/3CfkB2aJHVxqrk5eIlEt1lJ2AsF9L92qJpN2kfH+qiyFQW+QtHxm9X CvTKN4TF3L5Vn1DRxcIxteduDM425W8YccBrjbVwIdp+6DxVrLADW8E76oQqv7WlFf1V wT+UUx3EXDNLeBmzGVMXgDeqPt9l0uSwS/dbG28mlhz5B0GRgGemmtfxHvNIhyXrSFlR ktgAHbwWbRJjvyOSEbVghef9H5PZ/vlR3O2t8ZINXHdOzew0ZB9qV4DiJF/LkxTKO4F/ 5Nvg== 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=iLQKTUIwbNg31poUm3Ar1AjBEmtluF3zLOK8jLkIqzE=; fh=rz4Za47mt/1qfa4x6H//paZm24k8+ZVcaD777qeGkZM=; b=MqdeI7XySsAkKp8CSmSQixuvqmd9srmVCcG1tpkaydwY8G/rbze382qF4kLfbEa0zk vwq9eVeNA+5A4PNv4z0Li3ZzrkAlUgdGDUdQoqrC48qMzoN7IA/flixbMUJjDY6vQgeS smz0znM88kKewKaNYLvYGcIaBLJbY85HhewnzIKYUIIqm+nWUE8imNOdKcRJEBu6fQBy p36aPoaQHXgu9rx0P3GAQ6pxHJMd3kJ5827afdzyudOJvSaZH3VA9F6/jXOsyY6YNCNd 5tJnFJEv11QIVYweZmh79BH5lplHQr6YFObHM0BnVi1noLd/nm7D0om9GoR07D1B9Get tL0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="v6BO4m/Y"; 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-53215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53215-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCU0bAlpTjd77AwtpXIzCbAScHPZAXInmYuAK6zGyqYYQN16IVqury2+PisrKycRSGae0to80o36AEks+hiEapCmrmOUkw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v17-20020a05622a131100b0042c12166016si431797qtk.300.2024.02.05.10.30.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:30:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="v6BO4m/Y"; 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-53215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53215-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4B7071C233CD for ; Mon, 5 Feb 2024 18:30:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43C774D5BF; Mon, 5 Feb 2024 18:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="v6BO4m/Y" 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 AD4D4482FC; Mon, 5 Feb 2024 18:27:59 +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=1707157681; cv=none; b=gqlRD9gqyVtI+3nR9P5egBAMgP1QkFyz2VhQxd1BF+pvwEweWL/tfrRu/Gb2eSuvfFc6o8O0G+gYBnZcit952jaSvscxxI+juqzdfWIr/BnEhUtNEkclLxBS7MBxddYTjsQpgtHgkLcC/gmvdMh7EE9bbsIPMhc0YEoHWNPDCGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157681; c=relaxed/simple; bh=9iDV+TWD82fWrLcAZkquAWHpDR8++tqogomRz7LQ/tw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EFa6mdd3oHBI+ASnBQGc4slgTNi40nWUZRRy/iNKrn5iZ1aGYp9YlBfrqOLb1la2vBQD4oIRNK+b31t1+Dkqv53gN0J9VG+QeubQ2nBFr7tIL3WfCRzyYT5A4md+evKa2REyC2h1HPdotjmg0ugHzqzgrf8py2jh0uyGoZlES/c= 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=v6BO4m/Y; 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415IRtVe084706; Mon, 5 Feb 2024 12:27:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707157675; bh=iLQKTUIwbNg31poUm3Ar1AjBEmtluF3zLOK8jLkIqzE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=v6BO4m/Yz2DvDtM2ldPW3ouwQDnwLvoQ19T/eKOQ5cuW+K46sHlyPKEWh+ybkTVcu G5AkL2T8bLkYYkxtX/03X9HGnNYnhZ+DN/KnNnl5ZD8aaizZhBZYGvWREqd/exY3dV LILFVMTkrfbaS75kvRRqrXIHU0sXkWj/haCqKd2I= 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 415IRtQ7017734 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 12:27:55 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) 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; Mon, 5 Feb 2024 12:27:55 -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; Mon, 5 Feb 2024 12:27:55 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 415IRsX7058567; Mon, 5 Feb 2024 12:27:55 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 3/5] remoteproc: k3-dsp: Add devm action to release tsp Date: Mon, 5 Feb 2024 12:27:51 -0600 Message-ID: <20240205182753.36978-4-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205182753.36978-1-afd@ti.com> References: <20240205182753.36978-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790084735061645027 X-GMAIL-MSGID: 1790084735061645027 Use a device lifecycle managed action to release tps 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: Andrew Davis --- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index b9332c66a52ab..800c8c6767086 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -646,6 +646,13 @@ static void k3_dsp_reserved_mem_exit(struct k3_dsp_rproc *kproc) iounmap(kproc->rmem[i].cpu_addr); } +static void k3_dsp_release_tsp(void *data) +{ + struct ti_sci_proc *tsp = data; + + ti_sci_proc_release(tsp); +} + static struct ti_sci_proc *k3_dsp_rproc_of_get_tsp(struct device *dev, const struct ti_sci_handle *sci) @@ -682,7 +689,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) const char *fw_name; bool p_state = false; int ret = 0; - int ret1; data = of_device_get_match_data(dev); if (!data) @@ -732,16 +738,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); return ret; } + ret = devm_add_action_or_reset(dev, k3_dsp_release_tsp, kproc->tsp); + if (ret) + return ret; ret = k3_dsp_rproc_of_get_memories(pdev, kproc); if (ret) - goto release_tsp; + return ret; ret = k3_dsp_reserved_mem_init(kproc); - if (ret) { - dev_err_probe(dev, ret, "reserved memory init failed\n"); - goto release_tsp; - } + if (ret) + return dev_err_probe(dev, ret, "reserved memory init failed\n"); ret = kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, NULL, &p_state); @@ -793,10 +800,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) release_mem: k3_dsp_reserved_mem_exit(kproc); -release_tsp: - ret1 = ti_sci_proc_release(kproc->tsp); - if (ret1) - dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret1)); return ret; } @@ -818,10 +821,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) rproc_del(kproc->rproc); - ret = ti_sci_proc_release(kproc->tsp); - if (ret) - dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret)); - k3_dsp_reserved_mem_exit(kproc); } From patchwork Mon Feb 5 18:27:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 196990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1064491dyb; Mon, 5 Feb 2024 10:33:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IECkfQ77VIpSSrtYSbwv5TCadnXc9qh7EAkTKef4meaEPBuVd/Oblwzy9K4FmW9BncLHiAJ X-Received: by 2002:a17:902:cec7:b0:1d9:4a24:5f4a with SMTP id d7-20020a170902cec700b001d94a245f4amr452567plg.13.1707158022119; Mon, 05 Feb 2024 10:33:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707158022; cv=pass; d=google.com; s=arc-20160816; b=qSr1LdNGeVrbVMVYyowHu5yP99DvlPzDTCFaRCL01uePqAr5pZwaXgv79hTDSNx/0r 2VxkagWtURWNCxgumuUufnglwPWYggpxN6kpSoMPYJsK8AU/Buw0WWHKrfH/mLBDSIUk TIXQz038XkGRbIATZJs7sT7SoXsy/vw+vm4JG+nmIQeXBjTeC7a5fQPrYkP+lQxKXIvM //UEjIQCEExjafNwgH63eL1K9imb3Ah4IDe21NJJy0GPDOzjgA3j3lx2Y+yyX0e1mCzy TlbeyOKWrS6zKi57eX3kkuOn213oDGhHR8z7Um3bsqlBtStrVcD6H33oAVFYvCsPPeHd j/eA== 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=PChh5xsLsnerdCoIJ9CmTZI/Hl/y3vuBaVRnyyN6aKc=; fh=nhoWq19OrP2YEi6OmU4ikcw92XqFofg9lBXZIlxfhzs=; b=0IPElFSiDahcnQEOek7b8lOR9o5tTxvZqH2rqZDIc5QwGteoI+zKIP/HR2J1GU0UCd kF+yG8ELbTV+o9FNsunPZtmGUyMCyID/ocMwu4it7Mohdw3u1XvYFNrV0fqUiI3bJI5c O5rGATAwyAkBZxUpL1rhp1DF1OjVSF1CAyuuxiPqh789gbaghQNW3lJCnEouDRu+7Mr2 KOG7uJW4A2VsnBQN/FVa+eECgLXnfUAm9+ifH7cA2n/0TdTD0+ZQ2aat2CNCMaDnGF9D Afw7QFkOHBZEN1kcPr6MqrzWnz0qcazOCUPBjP1wmpiTibQhbd34+JyWye7YxfMxajqJ gmkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=OZMvbcRj; 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-53218-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53218-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCV7cMnjiEecTy1lJuLjACMP9V01Wn0YcpPsKy+dt3xUWpOZc+9TCz+Pllp/lKOeiw9U/H9WDmGFReTjOUbpUNK6rfw2Vg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w1-20020a170902d10100b001d958b8d593si204143plw.399.2024.02.05.10.33.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:33:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53218-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=OZMvbcRj; 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-53218-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53218-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AD0ECB23504 for ; Mon, 5 Feb 2024 18:30:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4BAF4F218; Mon, 5 Feb 2024 18:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="OZMvbcRj" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 30FB248780; Mon, 5 Feb 2024 18:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157681; cv=none; b=aiB6W/DueJiaIE4Go2aPufYXr4bXP7h68HOULQ3AWJQf90vg/BZkxswCl7749tJRA12t6La4yG/Ju96J0+laqVCt/pNVFYkRInAh0eC/ZR8NyLfCQSGW06wbjFQysWRjg0ZbGWNQv4TGgoq81n7BrbqF3L7GJQvioe39Xh85aVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157681; c=relaxed/simple; bh=njlR0rO+G4g3TL1gkbOtBkBHGf3Jn2TMwjfojhYgCJE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YY7AsgZluACf5Vzi1DzfTnszn1vfbKPcE+aMdFOyj/IoCN1+hxM3OPXED2S/UHABgvInku0GRvsapVPpx3Aa/iu1wH9OEffrPHg/A23esxU57jha+ibBAAwh8xwMobJwsTZ2NngS7uyLW7uY0tddDAAzGPOkjMrkIfyAwAM9xcU= 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=OZMvbcRj; arc=none smtp.client-ip=198.47.19.141 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 fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415IRuL3120261; Mon, 5 Feb 2024 12:27:56 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707157676; bh=PChh5xsLsnerdCoIJ9CmTZI/Hl/y3vuBaVRnyyN6aKc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OZMvbcRjUTPLU6bYtZTrZVUWFyRjR+3PIUPVpjBOgHKRCt3FChySbfNkkOrsmkObg s2XuRuVlKU6c2+ts9sIyuZ8iS0DTAI3c9pH7y41EanZzQjtichfQSAQ/TWxjyc3ui+ esGCyoTXDEJyLuhNXEqU+vPiMQBqqqM+zym4GuLA= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415IRuaT010269 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 12:27:56 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 5 Feb 2024 12:27:55 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE105.ent.ti.com (157.170.170.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; Mon, 5 Feb 2024 12:27:55 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 415IRsX8058567; Mon, 5 Feb 2024 12:27:55 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 4/5] remoteproc: k3-dsp: Use devm_ioremap_wc() helper Date: Mon, 5 Feb 2024 12:27:52 -0600 Message-ID: <20240205182753.36978-5-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205182753.36978-1-afd@ti.com> References: <20240205182753.36978-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790084930118411291 X-GMAIL-MSGID: 1790084930118411291 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: Andrew Davis --- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 48 +++++------------------ 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 800c8c6767086..f799f74734b4a 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -598,16 +598,13 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_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); if (!rmem) { of_node_put(rmem_np); - ret = -EINVAL; - goto unmap_rmem; + return -EINVAL; } of_node_put(rmem_np); @@ -615,12 +612,11 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_rproc *kproc) /* 64-bit address regions currently not supported */ 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", @@ -631,19 +627,6 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_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_dsp_reserved_mem_exit(struct k3_dsp_rproc *kproc) -{ - int i; - - for (i = 0; i < kproc->num_rmems; i++) - iounmap(kproc->rmem[i].cpu_addr); } static void k3_dsp_release_tsp(void *data) @@ -752,10 +735,8 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ret = kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, NULL, &p_state); - if (ret) { - dev_err_probe(dev, ret, "failed to get initial state, mode cannot be determined\n"); - goto release_mem; - } + if (ret) + return dev_err_probe(dev, ret, "failed to get initial state, mode cannot be determined\n"); /* configure J721E devices for either remoteproc or IPC-only mode */ if (p_state) { @@ -779,8 +760,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) if (data->uses_lreset) { ret = reset_control_status(kproc->reset); if (ret < 0) { - dev_err_probe(dev, ret, "failed to get reset status\n"); - goto release_mem; + return dev_err_probe(dev, ret, "failed to get reset status\n"); } else if (ret == 0) { dev_warn(dev, "local reset is deasserted for device\n"); k3_dsp_rproc_reset(kproc); @@ -789,18 +769,12 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) } ret = rproc_add(rproc); - if (ret) { - dev_err_probe(dev, ret, "failed to add register device with remoteproc core\n"); - goto release_mem; - } + if (ret) + return dev_err_probe(dev, ret, "failed to add register device with remoteproc core\n"); platform_set_drvdata(pdev, kproc); return 0; - -release_mem: - k3_dsp_reserved_mem_exit(kproc); - return ret; } static void k3_dsp_rproc_remove(struct platform_device *pdev) @@ -820,8 +794,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) } rproc_del(kproc->rproc); - - k3_dsp_reserved_mem_exit(kproc); } static const struct k3_dsp_mem_data c66_mems[] = { From patchwork Mon Feb 5 18:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 196988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1062678dyb; Mon, 5 Feb 2024 10:30:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHsAK4VJj0asJY31HqQ6O7E71OW5iY0tIu4h9Y/TxgPxB/YBaVeEo8ZJhIL7CDz9pHVEFE X-Received: by 2002:a05:6402:b15:b0:55f:fe96:f0bb with SMTP id bm21-20020a0564020b1500b0055ffe96f0bbmr110803edb.1.1707157835494; Mon, 05 Feb 2024 10:30:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707157835; cv=pass; d=google.com; s=arc-20160816; b=nP9d4M2if5hekOdq4qR+UGI4rSBmNlHkyu8vGaXDQjkRcpHHTrtbHlIpd2OZmFLFRO fZUqIL8QFXtBrb2gHRih8M8AjKa8MCLAwARrp7+HQa6djQidcBa7V1V9dCiHr/GOqtkV /xgu0To9ru9zVO8PnFa5YWW6gkyfSxHxIgsgA49zjNQ34u+txkaTsPEmN3o51QyDkxhP Rf1gERmZYhJdo8ht3lLVng3gAtIR2woItoG0DBjPMU+zg8FrNIPrPRVWFe4vuTeIdUHb DCC4cNCcmdP+nRzuX4rvG/Zi6Yy5wBx8MXsEbhd3JlhsE22pUD32/l2h0nhEc+fsjQkX SL4w== 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=cCOdsqhr20y5QKXtiSnCUsddUxH/Yci+gnu7HPlrDyE=; fh=5uAeSpey2vfdo3rQcaKGuBWMrvdmza/JxrGTFM6OLYA=; b=U29fyvRgZ92HsOtArAtzCHYuzbOhZe4Sk7ElgkVO0ozby2WthyB0d+hCGw5cmawFrS 3JuHnToZjvrJFoKIGK8FGHKl4gpVshc18e6Fp543kLeikxnsU635pMsrRwGGp/10pr8q ki31T4MbL9m79VdS6GdJBvhG/JxokAaXAufMJ+exNJiKRsTiul05wATtfTLNDZbdU73C z9k9+bVcOnVoDOglZ+ms2u6ywInXlmxwpSfreqyPkGn4a3uPG+9t1re+OBlPaMNo5SUJ UXVB8NEbT7I62V5haogtldU/xCCnd8+CNGkgzoPRUp2irkqk0dcZIlb0kXqVqohOxYx0 YPng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H5yulMLP; 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-53217-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53217-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVObyhYiEt2wfoHavJ7Vt3LAmMg1wVdZWB/wlKytbxMYdcTyEJapI5IO973ZGolE6CFq/MaSEYWIMU7q19WORZOere/Fg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n5-20020aa7c445000000b0055fd61c9be9si143937edr.438.2024.02.05.10.30.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:30:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53217-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H5yulMLP; 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-53217-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53217-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 20A6E1F23F7C for ; Mon, 5 Feb 2024 18:30:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6454C4DA18; Mon, 5 Feb 2024 18:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="H5yulMLP" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 13682482FE; Mon, 5 Feb 2024 18:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157681; cv=none; b=CMLTFqTpSA7uAXFeFOFogZMcpwe3AZeGFO3/a0K5VWaCNe8ALaJc6ioNbSPOA3EQwN4OgT/KCWolIOZ17lwP++Dln14pH/WppEuxJUWKLiOCMn2q9C76SBnGr2OGADIi4qis2pw2AsKX+EfC/YRj0m1gYHj1v9A7Wiw4bRC+Vys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157681; c=relaxed/simple; bh=UTKjnl02zRrNFWyX0e1HTEuHJnpztcqmM5wI4qOg/PM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tFUndIcuFAkuNbQfnGbY5McoCbRvhUwLc8PYcsX1xsQUQHNaDzmKOQ5shWsE1P3befB3qGpiwNd/+pf+B4FS6Fmx7lJmMyW8s2epKxmWJ9SiEICOWz/wPcHmdivyTZU7IaruQIRRJ6/s48xajmEiX0LBbfn9aLB7Gl2QjCyadVk= 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=H5yulMLP; arc=none smtp.client-ip=198.47.19.141 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 lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415IRukq120265; Mon, 5 Feb 2024 12:27:56 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707157676; bh=cCOdsqhr20y5QKXtiSnCUsddUxH/Yci+gnu7HPlrDyE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=H5yulMLPBSMo1WqQqmzdeIODB5B+tM/DEG72QsvlnQ+3FHxzoHYJKwp3pNlHNljjt Hqu+0vCM+6BicpapV4dsQYmr+5Sd3/cRR98hdiMWfo6aD9ydfNHx+e1C4wImrWKPVb sh1nsOdLszLKhwFsN6aorpx9ERxOTxrEhCTYM0jQ= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415IRu8B123163 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 12:27:56 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) 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; Mon, 5 Feb 2024 12:27:56 -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; Mon, 5 Feb 2024 12:27:56 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 415IRsX9058567; Mon, 5 Feb 2024 12:27:55 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 5/5] remoteproc: k3-dsp: Use devm_rproc_add() helper Date: Mon, 5 Feb 2024 12:27:53 -0600 Message-ID: <20240205182753.36978-6-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205182753.36978-1-afd@ti.com> References: <20240205182753.36978-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790084734282744661 X-GMAIL-MSGID: 1790084734282744661 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: Andrew Davis --- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index f799f74734b4a..3555b535b1683 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -768,7 +768,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) } } - ret = rproc_add(rproc); + ret = devm_rproc_add(dev, rproc); if (ret) return dev_err_probe(dev, ret, "failed to add register device with remoteproc core\n"); @@ -786,14 +786,9 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) if (rproc->state == RPROC_ATTACHED) { ret = rproc_detach(rproc); - if (ret) { - /* Note this error path leaks resources */ + if (ret) dev_err(dev, "failed to detach proc (%pe)\n", ERR_PTR(ret)); - return; - } } - - rproc_del(kproc->rproc); } static const struct k3_dsp_mem_data c66_mems[] = {