From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796296169; b=YbYSdjjHJGxTVYCAbEgnuUDD/t2tp6Z5aK1JJ4jlpe9xFUyKZh3+4Qf9tiiwQebrV5aB xK2fKRmpEbsWPEErJzGdLYVgKv1GTEE5cfVzPz/codr+Au7uhf9eSz/zwPM789D+H20M0 7AXOz9doVUkUHP4f/B+JnQeeKMHU2HzSEpgWvSmsGXYGwxm7dS8pcGJtJXs21M4GSQv9S dIhSx1g9WUoL9AESFDIaxaorAx09iw1b9mz4Af/5hdbKSpBf0/X6umZa3rh31RVNQTFjN gcUgctHjq4ra8YQLEz3h4sFnqmpd62fRMTOpPFWiRV26fQ/uaF5D0PmVL2OiFsSBT1Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296169; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=LXxxFdgxFlPzej4uZM6eHb4v7ktCdRAwLICcPH6ikOg=; b=JaSVeXj5HidUn/gcqUAaAOZeYDy39YqKSMo4u2GZqWjK7fTjD/r3R0MmWknT7UDX7+UK SrNA1jdKG+OQew/nyUb9ZpGkknbLhBYZXl9CI6EPd15VR9oNI8U7hLjyxYwrayK+kuQ0p QqZj5sSezkInd8efa2qJQ0/cpQ/ijtiPI/1HVVAVaOp5/JZOTRipRivwFI8gRbGXkFekb S7+eMuRDvigMS2ZzaKM0/Omr7vQ4KyPM2oIUBe9Pgk2pUKJBUzndddDU/M8DcxZ15SZUw DSP4UBtjJYBe9JYFJXxkprq7So87zI69tn4m+wZi77esKpssZ3eFnYZxiOat91LLLSg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Pti1tAQx; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B637F606A322; Thu, 3 Dec 2026 11:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Pti1tAQx Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796296169; b=3n15l1rwqwWSseIOYYHWlhKKgvxrFgtLIi8humaJFW1UVpIZhivuj9/LT8yKf3ujyJDE 1l9yvSWLUJbb43GspDAyq8NKK9LnfqnpYZH1+L9hOja1ifZaVu+jCoYwV6bSUIWnHtahU qvvBLSd6q0Ca5x0NZrmEqmVDG7fb2xIZAAH/SKm3riKjTIpDIlTM9ZOwBLhN5hDqSLvqg M1IXinsBhEy/iHNEHYGBSQS4dr+nS6ZhnEz6fqQp4nrHQ0LbIvzbP9l+vSZWRNOAycyty CXE8sBeiDSHfXHV+V9Poc8sZHtYrHP8AuTrfej+VFoPM1xXaqrtxXkol1ybEZd2N4Qg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796296169; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=LXxxFdgxFlPzej4uZM6eHb4v7ktCdRAwLICcPH6ikOg=; b=wo4HjwwvEF/WLKRsfzQx3dsp9O7qoNM7S04tJwhmhGIYBe5a6YXwng5GEpBbThWSbQDJ C77+L0GyWs6NX+y1rNe9VBFdsddqX9K2W35SY3yhTxrMv0pPOkygjahEK+OgLzTCSeyx4 lY1c//eEsRs01dXRTkFw3dMg1sCN4fOgTDuLNJ2z23Aj6k4llvcZ1d41zO87wHRZD/V3U QZfyC3LIr7NobujDbPkfPZpPMzQlMT/TKnfGLJjbKkmKMW1bpHnc1YlguQkxKGsmBMgWr TV88o4ZmmS088Ql/pli6SBh0/VT3gymL2sPLkGUsB7stPH0uMvo/vLS43CY6vNT1vBw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 214271F000C1; Thu, 3 Dec 2026 11:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796296169; bh=LXxxFdgxFlPzej4uZM6eHb4v7ktCdRAwLICcPH6ikOg=; h=From:Date:Subject:To:Cc:Reply-To; b=Pti1tAQx6vLWD0BDxz2yuUCP9mkYHk+SQxFVNsZXZTr8dX6WfJIO7ShvRfn0IcYWt j3bW1l8D2aGttPx2OKkqg/6WI3uE3yaTcwHVqmC7B0vflCslO0xlSJRdAKDtzcgMWr qChbmjL/XHMr0L9DLrqdrKMFANH89lTbgK9r/5jm3V/AjnOUispo1S+5tIu5izxW4R TFVHZNVznBkFLAipc/zsL3CsokxsqDhEg+SDIHGtvZpOUvVeW6+JkY7gPkDaEELqqy 2KOFQuuJACkW99D1jATvIpmBwg6ibZhub1znmA3hkY+BRfgaBmBrbCyiBnnJ4yjuJj 4gBr4t+eYD8Ag== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 767164F916; Thu, 3 Dec 2026 11:09:28 +0000 (UTC) From: Arina Kharlamova via B4 Relay Date: Thu, 03 Dec 2026 15:09:20 +0400 Subject: [PATCH v2] serial: uartlite: Disable the clock after the port is removed X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261203-uartlite-remove-clk-v2-1-920d6ba90074@mbzuai.ac.ae> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/32Nyw6CMBBFf4XM2iG00Rpc+R+GRSlTGeWVtjQq4 d8tuHd5knvPWcCTY/JwyRZwFNnzOCSQhwxMq4c7ITeJQRZSCVkInLULHQdCR/0YCU33xLKxRoq zssqUkJ6TI8uv3Xqrfuzn+kEmbKpt0bIPo3vv2Si23f9CFCiwbqw1x/KkUuja159Zc65Nrgmqd V2/RsJY9csAAAA= X-Change-ID: 20261201-uartlite-remove-clk-9dfc2176f6c9 To: Peter Korsgaard , Greg Kroah-Hartman , Jiri Slaby , Shubhrajyoti Datta Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Arina Kharlamova X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796296167; l=2923; i=arina.kharlamova@mbzuai.ac.ae; s=20261123; h=from:subject:message-id; bh=SNEVlkxenegLIPt1Qh8VIg86t5ZywSWe6yp5wA5gyFQ=; b=R7NUxDxOqINYKQSLRs6GMMAI5Rjf4DlN7YbqQz9uXcaFHXpolriE/72QZdFwjIYceqWJ4QkO2 jY05K0DC87PBWE2Dhcp/JBduDMMnCg+qp1SEz1HWkXMxKdiZ0EeNxAb X-Developer-Key: i=arina.kharlamova@mbzuai.ac.ae; a=ed25519; pk=DzQWwMpUtJvSDuzprqvRdbrC72n4Sq8dW6cq3NRt2Mk= X-Endpoint-Received: by B4 Relay for arina.kharlamova@mbzuai.ac.ae/20261123 with auth_id=1625 X-Original-From: Arina Kharlamova Reply-To: arina.kharlamova@mbzuai.ac.ae Content-Transfer-Encoding: 7bit From: Arina Kharlamova ulite_remove() calls clk_disable_unprepare() before ulite_release(). When the port is open, ulite_startup() holds a second clk_enable(), so the clock is unprepared while still enabled, and then uart_remove_one_port() runs ulite_shutdown(), which writes ULITE_CONTROL and calls clk_disable() on the unprepared clock. For a console port the clock is gated before the console is unregistered. The device can also runtime suspend during the remove. The pm_runtime_put_sync() that the driver core calls before ->remove() arms the autosuspend timer, or suspends at once when autosuspend_delay_ms is 0. ulite_runtime_suspend() then disables the clock a second time, and after ulite_release() it dereferences the cleared drvdata. Hold a runtime PM reference across ulite_release(), so the device is resumed and cannot suspend while the port is torn down. Disable the clock after runtime PM is disabled, and only if the device is not runtime suspended, then unprepare it. Fixes: 14288befeb57 ("tty: serial: uartlite: Add clock adaptation") Fixes: 5bbe10a6942d ("tty: serial: uartlite: Add runtime pm support") Signed-off-by: Arina Kharlamova --- I noticed this while reviewing a related fix in the same driver. With the help of an AI coding assistant (Claude); I reviewed the analysis and the fix. Compile-tested only, not tested on hardware. --- Changes in v2: - Disable and unprepare the clock after ulite_release(), so ulite_shutdown() and the console unregister run with the clock on (Sashiko review). - Skip clk_disable() if the device stayed suspended because pm_runtime_get_sync() failed. - Fixes: add 14288befeb57, which added the clock calls in this order, instead of 6a7ce07d6cb7. - New subject. - Link to v1: https://patch.msgid.link/20261201-uartlite-remove-clk-v1-1-bdffc49566f6@mbzuai.ac.ae --- drivers/tty/serial/uartlite.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index b9a14dc2f2fd..b6d5cd462886 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -893,9 +893,13 @@ static void ulite_remove(struct platform_device *pdev) struct uart_port *port = dev_get_drvdata(&pdev->dev); struct uartlite_data *pdata = port->private_data; - clk_disable_unprepare(pdata->clk); + pm_runtime_get_sync(&pdev->dev); ulite_release(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (!pm_runtime_status_suspended(&pdev->dev)) + clk_disable(pdata->clk); + clk_unprepare(pdata->clk); + pm_runtime_put_noidle(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); } --- base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 change-id: 20261201-uartlite-remove-clk-9dfc2176f6c9 Best regards, -- Arina Kharlamova