From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49771C624D3 for ; Sat, 5 Sep 2026 00:43:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D97B10E485; Sat, 5 Sep 2026 00:43:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="D4N/ws20"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 95C7510E246 for ; Sat, 5 Sep 2026 00:43:44 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 718264479F; Sat, 5 Sep 2026 00:43:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 000C51F00A3D; Sat, 5 Sep 2026 00:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788569024; bh=mqjpar+f+Cbdq0pcg7A44i7twxcYoQfNarTSIk1nh1I=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=D4N/ws2031xrS0VVK2n/p92pVVAXHWTnmNjUpCldYgvY5M6YP4tIOwHoxDiJdIHiM qwYJvkTZgS96Sb9IxXsc2BrHkoqHNAdtQNLo5K7Iu1llqaJz7pcXA+7ivVuWxhQAAU t/y+C47gui4QrntSq/QUzF7dZhuhLg2NA8uwG5rACRDqcLfoNibHZVtXZLhNERQZL8 ByOoXkSTjYB7U9GLX3OO4bJPvrWQQM5GW6PFmM6jWPHCug+oYuXF494x9gq5ZSN6ET ybJSumPbIkqqW526GjSc7R63xKSPL2TdOtDZUi0CzNnyjB1cYPMzH5rRLpIssd5VXc 4OLEzd7+wVT6g== From: "Rob Herring (Arm)" Date: Fri, 04 Sep 2026 19:43:21 -0500 Subject: [PATCH v2 02/19] accel: ethosu: Fix probe error cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260904-ethosu-fixes-v2-2-3767738756a4@kernel.org> References: <20260904-ethosu-fixes-v2-0-3767738756a4@kernel.org> In-Reply-To: <20260904-ethosu-fixes-v2-0-3767738756a4@kernel.org> To: Tomeu Vizoso , Oded Gabbay , Frank Li , Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16-dev X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Once the job scheduler has been initialized, failures from ethosu_init() or drm_dev_register() return from probe without tearing it down. The registration failure also leaves the SRAM-pool allocation in use, because the platform remove callback is not called after a failed probe. Unwind the initialized resources on both paths. Also do not call drm_sched_fini() after a failed drm_sched_init(): the scheduler initializer already unwinds its partial setup, while drm_sched_fini() requires a successfully initialized scheduler. Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Rob Herring (Arm) --- v2: - Adjust for previous patch reworking runtime-PM suspend --- drivers/accel/ethosu/ethosu_drv.c | 13 ++++++++++++- drivers/accel/ethosu/ethosu_job.c | 6 +----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/accel/ethosu/ethosu_drv.c b/drivers/accel/ethosu/ethosu_drv.c index df76253d01a6..c684e28ac787 100644 --- a/drivers/accel/ethosu/ethosu_drv.c +++ b/drivers/accel/ethosu/ethosu_drv.c @@ -375,9 +375,20 @@ static int ethosu_probe(struct platform_device *pdev) ret = ethosu_init(ethosudev); if (ret) - return ret; + goto err_job_fini; ret = drm_dev_register(ðosudev->base, 0); + if (ret) + goto err_sram_free; + + return 0; + +err_sram_free: + if (ethosudev->sram) + gen_pool_free(ethosudev->srampool, (unsigned long)ethosudev->sram, + ethosudev->npu_info.sram_size); +err_job_fini: + ethosu_job_fini(ethosudev); return ret; } diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c index 8dce74db0cb4..ec65305e0cd7 100644 --- a/drivers/accel/ethosu/ethosu_job.c +++ b/drivers/accel/ethosu/ethosu_job.c @@ -355,14 +355,10 @@ int ethosu_job_init(struct ethosu_device *edev) ret = drm_sched_init(&edev->sched, &args); if (ret) { dev_err(dev, "Failed to create scheduler: %d\n", ret); - goto err_sched; + return ret; } return 0; - -err_sched: - drm_sched_fini(&edev->sched); - return ret; } void ethosu_job_fini(struct ethosu_device *dev) -- 2.53.0