Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796373102; b=JOu2ObWD04DGx8ypc04v+AnHxqrutZBuYsgrj1FSrKdhXE02XYeCYtbWXQCrxoqDuaw7 mZZqyptef7LKojbJifwFUfSi+FreeuGzKIjtRGxcKSzmkfLKb6tf4J6jcCYuWbworz/Ww mjTTTovOuiioSvqvIQQt9/jxZyzOTIV1+XEpYMxLM2BaYxJUN8OTlh2vdPyYuGL1nQs6X SIKPUHU+qgWnvpYVkmnhVs9yV+YFJjZoEIcX/JtMqQt+xztGLbKJExr1vyolek7AWLIvP X7Bjh699Ai2kNS3HwDO2cbch7f83VeOEu9D6s3kEBvQJlYxRPkuEoLwYybRaoR4GOEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796373102; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=dGnsUdPlXCovpvvRAbUSKoMzaQrcy7ro8TwKTeumKD4=; b=nkHpmmHhONrqem9O5IijC9ZpYcRjekW/NXHyPw3gg4hNdSy8igJMSM+VcTxfhmM0NtUD D4tsh0ay6oV0tmpkAOJIv6jNOHwMd7P9bfBKxPJBTu/OK4qIiK/1OjyrliFlEqjZNZjo2 0i4tTas4zuwrcC3EPZgcwxWkBu/MTieOS4AVVTJ6W+3dQs4O5N0Cdgg/ODuHVPh29pBIM U8atvYErgLENqG5cNJbZ7gtZ13/eIERGWniFTxWWtLUzwcCsVyqtwRbAraPCGvnblGTKA X2fSYfxT/TBwYUXe4VQNjg5HxHTA7rIsYE7vMqux3DpeO8DsfBXMT/z6YrmulZFw9FQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tlbHHxjo; arc=none smtp.remote-ip=209.85.128.41 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ED21606A338 for ; Fri, 4 Dec 2026 08:31:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7ED21606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tlbHHxjo Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4bba60271d7so5477975e9.2 for ; Fri, 04 Dec 2026 00:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796373101; x=1796977901; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=dGnsUdPlXCovpvvRAbUSKoMzaQrcy7ro8TwKTeumKD4=; b=tlbHHxjoeiFXT1D8F0FrpTJ8weXzHn0Qb6vrCKE3uFumm8wqvozki8JP9Mxkxue/+6 iOYQhONV7hKqwOTnf1P9ALmf75FdpU2GqN+a4Y2USD7YRuluEu6itmU8llwlVFsRa1bK zzu8hnBjzBv9XTYxr5vf6l5rgL10uxVnMePtXVYegJj5C2URnfvmybAOhYpc7iXynwW+ it9r7I+F4jgarakS59globFe5TB/lsquiqQKw4xs5XXZH6Z2iC3IRCDQGIdgsKde8mJp tNiAfJpN4Swfs3u3VqGEmBotFkIf5FGaFVvIROiYk87YHo+0Ky9HYfFDQjs5eN6fkBjA Wmzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796373101; x=1796977901; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=dGnsUdPlXCovpvvRAbUSKoMzaQrcy7ro8TwKTeumKD4=; b=AeMrwMKV2TUqwndNreZmi9Y1SjPuARo6ibS8oVHcN8U1YS5L92oU1XBoosDmI05Pdg 0BJYY2JCMrEVMxfQdJhNjRnAE2QZXHM/+8Bb3X87caZcuDVcfBh15JU4jPY6HVOKZEq5 siUbnJgPF5WUl6Rn9dBKs2iA14+NwCsQSzGQzW5mGAajbcYkCLpMcfp4dPQuhtY41n01 uaiTPQO+UoZ31FOcdVE4kWvox59Tz0VKjlUcbUGrsnj4RBxLWLtGvzsHKnTQh0shK24h Ic9i0SUV/fdgvjXvI+NFahO0mddY1/RMCTmolnqPmuPhQHq7xw4WJnEy6SfI0JRBHDMj r3fA== X-Forwarded-Encrypted: i=1; AL+hErFIo0n1p7Rr7tEZnwAG1VBrcqBYFks3a3nEjxYzc/GSZ6f3ziQPWrJW/gu+FPoLOZj07927ZOrWcYj1cg==@vger.kernel.org X-Gm-Message-State: APuU4Z9tPOoZr8sjzfGmtNaYg86O9MQIbykq8KPGpuNUYOfmnJ6kL/WB RgNPn4Eqb11aFoIqhdBFu2j6sBqQ7SzSFxiGbVmIBnqZzWIJr/hKaTA= X-Gm-Gg: AZFdTZe9D2VfnsMOZSZTKiblr7QoYxEQlg9kGOCZM6ddqwrs9oqCDRH5YnhlY4a14tA mbQAjt0Lb3bnL9grG3YqwjyO5tTKR0OwtrpQoXzQEGpslgdjT1Hq7RZuxFAmuIEZ6ZrkBWhUl6z VIZbQQBvhkbxOPvOs62wBBAoImCeCZWAbhx8SmQLBzjBX89R2T3DaFwK21e3+Ja8qK7T0eTWrx+ kOXhrJjFv3axvbJcrog9+1XRa6SsPvRBnEmd5rN4lz6jL3RgvezZyR/VdpYTHJL9VXTjUmYLWWW Cu5hlwH6iLFMBfxvp5HCifdUJlVwYGlHJfEz7gvRWbPL/hJ5hixIZdNt9TQeT8K9d1MXvFRVPXI enhpwUOleCxfSiKe4Ol3/9JBmMQ6UhciL0dOoCOSO1e52+1ueqtxNg5jkLUl8ahhyxTTXr0NAnp romU7hNKWy9+3SXp3OeIxZuJ266t5LYjEMWu4sP8v8ro1yVXV8S+7AeaS0iWgCUhEGMK9SzLxWG 6U3kbYPZu02z5IJwMHgL+Zmgt2l7O5ezLFJCCNzJP7obCfVVrMk8qKnGC6qCoVo2mushyrJpDih ZNarMV9IQpG5kAUkor9/26TRcXV+CBev6D73yuTdLVD0INYGagKDuGF+Pp4nlVar5kAlVHEICzj 6cqdBUzmsD3WGnhPs X-Received: by 2002:a05:600c:1d15:b0:49f:e772:6ddf with SMTP id 5b1f17b1804b1-4bbeb8cfb96mr22392825e9.32.1796373100770; Fri, 04 Dec 2026 00:31:40 -0800 (PST) Received: from localhost.localdomain ([151.57.87.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00792c9sm144669115e9.3.2026.12.04.00.31.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Dec 2026 00:31:40 -0800 (PST) From: Francesco Saverio Pavone To: Jonas Karlman , Detlev Casanova , Nicolas Dufresne , Hans Verkuil , Mauro Carvalho Chehab Cc: Ezequiel Garcia , Heiko Stuebner , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/3] media: rkvdec: fix clk reference leak on unbind Date: Fri, 4 Dec 2026 09:31:21 +0100 Message-ID: <20261204083123.30740-3-pavone.lawyer@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204083123.30740-1-pavone.lawyer@gmail.com> References: <20261204083123.30740-1-pavone.lawyer@gmail.com> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jonas Karlman remove() calls pm_runtime_disable() before pm_runtime_dont_use_autosuspend(), so the second call can never suspend the device: it reaches rpm_idle(), which returns -EACCES once PM runtime is disabled. The probe error path has had the two the other way round since the driver was merged. This shows up when the device is unbound while the 100ms autosuspend window is still open, which is what an rmmod right after a decode does. device_release_driver() calls pm_runtime_put_sync() before .remove(), and rpm_idle() adds RPM_AUTO on its own, so that put only arms the autosuspend timer. pm_runtime_disable() then cancels the timer, and pm_runtime_reinit() relabels the device suspended without calling the driver back. The clk_bulk reference taken by rkvdec_runtime_resume() is never dropped, and a later probe does not reclaim it, so every such unbind leaks one enable count. Drop autosuspend first, so the callback still runs and drops the reference rkvdec_runtime_resume() took. The callback needs the driver data, which v4l2_device_unregister() clears. The previous patch moved that call to the end of remove(), so the callback can run here. Swapping the two PM calls without it oopses whenever the device is still active at unbind. Fixes: cd33c830448b ("media: rkvdec: Add the rkvdec driver") Signed-off-by: Jonas Karlman [fsp: moved pm_runtime_disable() below iommu_domain_free() to fit the teardown split, wrote the commit message] Signed-off-by: Francesco Saverio Pavone --- drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c index 262ff6a407986..8a0967f6f6895 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c @@ -1903,12 +1903,12 @@ static void rkvdec_remove(struct platform_device *pdev) rkvdec_v4l2_unregister(rkvdec); - pm_runtime_disable(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); if (rkvdec->empty_domain) iommu_domain_free(rkvdec->empty_domain); + pm_runtime_disable(&pdev->dev); rkvdec_v4l2_release(rkvdec); } -- 2.54.0