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[] = {