Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp669546rdb; Tue, 23 Jan 2024 10:57:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn49Um3Bj4/Bi+ziJl4wKhngItswlHpbtmnFL/7S00GF47HNicQ4SFEOf1kyqYyjeJwgzd X-Received: by 2002:a9d:4809:0:b0:6dd:ebeb:ad0d with SMTP id c9-20020a9d4809000000b006ddebebad0dmr376086otf.66.1706036249672; Tue, 23 Jan 2024 10:57:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706036249; cv=pass; d=google.com; s=arc-20160816; b=nYSPYdHlbmFc61BSgAjtTmtyxiJTtUhnpYmxJ+ZKFSW3mbNItScwJvBd3hQk89rDk+ v2RHB2Ui+YMKA2h2E9gkv0UCPXySKst9sZrgoB8C8MkGXPO8MesvtZvlnn8E7s+U0XV0 fE7vUXmodl6om4K8KUDH58Xv6k+vaqAJhEGHMIfeiJd7FcM8B3pkNJ35pmxq+5Y2HcZu 6yS+Ofm9Ya6vV2MwAkdLsqFNJPXlyyfHU8TsuEH8qIP6uw5WV1m2tWJf1d4B1K2eEC96 Chpb5TfqH4S0I/bZWirRsk1ncAtmnsFifBq84sqs9Qg4BA6d1TqBz1Y8kaNFfzxSh5L+ xN7w== 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=XCXZxruqA8lrGMCNwWZAu5EPSG9vI2uddVwOuAHoO/I=; fh=26fOig74KkB7hULuYNgHMDbW8F00rUC5uFYx3bIWP/A=; b=I8ll3uWThKewu1S1CovjFAntcKGAykoFbG6DwnTgDEDJql3fTKKE2AfKA3Es+i0j0V 89eOlJwHvLQDLNQ8YC9n2ogJfkW464pFTa3nLaG8guN6363GjMqcwU/PPsL20OLaoSDJ euHEu/QXXTDnIEWjE2tWpKj340UlnZQDpkhtTu9deqIqkKqEXK07q6lpe+p840wSm1TG zuLfUJOmH/+pK4piOyyyMzO1O2FxfRbqtl6vBu1u/TE3F/KtFMmB/5VWJi1SpMqdw8NZ sZWOdzXiUkvH1ZIm0SlWQXjv+uA0mv6m8PPBXbD7bjWwtXEX4K18sL0BB5qCGugAQMay rUgg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Q6Bw1OMm; 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-35924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35924-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g16-20020ac85810000000b0042a56a134a4si671313qtg.573.2024.01.23.10.57.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:57:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Q6Bw1OMm; 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-35924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35924-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B3B01C20A2E for ; Tue, 23 Jan 2024 18:57:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31B5D12FF9D; Tue, 23 Jan 2024 18:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Q6Bw1OMm" 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 D16741272A2; Tue, 23 Jan 2024 18:49:20 +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=1706035762; cv=none; b=h0xVcdzA0j3h3ZcDNMfrIgrS3HCNSREfif2gS7XMFyNmYYTd0Ga6wE7NDhVW2lRtRryHQ4QMP1Aaz3vsop/ou0Gryx+TSKdahtiH9GyrAolfcZPTeb9DdFiQc8iey1sPiuyW65kxzMDFU0+8jga7lWlj65921QU9Nx2vh4zOTIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706035762; c=relaxed/simple; bh=ayZ2nhNGWlLRyCN/ixD3RqwmKoxDFKmlndW7u/MzhS8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rWZjgXY5F/4ov46hNrF1FXh/bcDUQfk43J5Vz5WC4xBnwY5FAh6ZfuGKuEpUy06QBoIdGz4LMzSy5iZOjioetkgmiAcAYV3Kw/dOPYuofwUPgvCdoINqeK02GOmvdiCz0aUfoiTyW8yP/1ieSG3b4eqXz5W87wluW/6CwMoGca8= 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=Q6Bw1OMm; 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NInGAX112956; Tue, 23 Jan 2024 12:49:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706035756; bh=XCXZxruqA8lrGMCNwWZAu5EPSG9vI2uddVwOuAHoO/I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Q6Bw1OMmsN4x3dOuCLMTArJM2Wt8WnJO0cNHEpxwtjJbGR1ecwriDxO93QIH5qIff dI1ODyos9ED+8vKnKBnwbJUH/sthq1usNtq3ZqDskY+fTvuqhsp44hXGriezxA+dhv 7qd2YZ4T1B/F9IpJ5EM5wbMqBYuGBTSFmZBf+ioE= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NInG4A013678 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 12:49:16 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) 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; Tue, 23 Jan 2024 12:49:16 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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 via Frontend Transport; Tue, 23 Jan 2024 12:49:16 -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 40NInEnN066395; Tue, 23 Jan 2024 12:49:15 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 6/8] remoteproc: k3-dsp: Add devm action to release tsp Date: Tue, 23 Jan 2024 12:49:11 -0600 Message-ID: <20240123184913.725435-6-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123184913.725435-1-afd@ti.com> References: <20240123184913.725435-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 2aac25d013985..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) @@ -731,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); @@ -792,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; } @@ -817,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); } -- 2.39.2