From nobody Sat Jul 25 03:46:07 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C08B380FF5 for ; Fri, 24 Jul 2026 21:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784929039; cv=none; b=SZtcklDssecXPquvqJg9705OhrCtXDbsmD+EIBNe+DyPjV56Egcy7Y/3mAms8xX8Xp8cm+mLaAJX/TG+K76+ZqAacXGD71CH5NmlLW9WwgSNKIUugdNZKfQA0QJ4SI56bscfrsCjLeNHS8BfIcBI7VUcFpxQENA8mfTJy61wgqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784929039; c=relaxed/simple; bh=rXmESC+ogzRUoBCqexa0HRaaPKIP/aORjommBvUq5SU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hHxyVif8ExfFvXvTQMPc6AmD2/9tWiREZVERE+rA11jav2w2IzPktFVm9Db2WPvzWMzeNqxjhNvuklkN8sPPsG85ftrN+bsUqcNbTbaQyvBxoa5pr/E8xf0tra2MqLPFsYEfSKnM6bUlLeBLvXkwMG0kncEVjP0qpdcIf7V6mL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=s06Dc2w/; arc=none smtp.client-ip=209.85.221.43 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.b="s06Dc2w/" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-47f93b2fe4cso724267f8f.0 for ; Fri, 24 Jul 2026 14:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784929036; x=1785533836; 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=nuZr0SzwEmaEHP8VYIwWfef2g2YTiEiEHZ6M99Shj8M=; b=s06Dc2w//fPcdmZ+fn7qrtNqyxtbyAXyNAvEKGAm0569RiDGIw7MlrD4dNfLft5h7M /sC9oPNAQe3WaCTzM+9xBXv2VWMLlpxIpjzWuAd8KRIg7/GUSdwvV7VCWvhpCytuS7J2 j2P9VaKntNl20Z8yn5daA2aY/+7P2ij81LJKIQx63LXipXaJLKCaZHXFx5vI8zjKAY80 FD3t+WwaRX38VKi46/V4B9B8B7WyXOoDjiKrZaJl+rW7z3OMsNZZnPaOKxNIyngtfm6i MDLleICM00CrrVKWdkXcnw30bp9gjA0D6PaJsjkJdWgh5kcWjD5wYlCqpY5KeivSUDpX Bdzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784929036; x=1785533836; 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=nuZr0SzwEmaEHP8VYIwWfef2g2YTiEiEHZ6M99Shj8M=; b=HwQ7XHRZpjX3JzeM7pOU6mJfh7zgdPh1QueCmT5POrco8QUG1UCvxVmAPrFZAysJ5J +2gDCzp3cb851vfgyvHivVgPtK6TPcIGaHgvMhehtrGg6U+2h8/rOCxVeiPhbexae9MC 56Hfaex5ZcqYDg+fPwoJvEHMB9SuFOiIAI+cmz/P5xAP7DUusZsyK4BexnQpwvxZ7vGo hArsWbkW1nMjYxlegPAc1rf2fAlfbBcBzF1wf2iEs0GhXVvoHnuhesEee72uQGT83umU 5fTRTo1uIc1CyCy6z1XO3Gf2dLPHV/LjFHPL/NN+H3CvODvWNh1dDZhu5SuwPlOwnLP+ jUUA== X-Forwarded-Encrypted: i=1; AHgh+Rp7znC0KjIS1pWGO2gkN4mmbg5rvYEDWhyTFSB3VKI0B9jsLALklhyq+AHYCTDlUzXc9teAAW8MPP2H7bY=@vger.kernel.org X-Gm-Message-State: AOJu0YwFIcFw9yJb/g1/rWs+62RfB5F4ae8NVtB1SKTjcqKnpbWCR9ko loabZKdiUzH2caYFTTEgj819nliF819hnBfexLE/bg3vS2NsKEVtJHW+ X-Gm-Gg: AR+sD115UHTfTsqwtBQD4fL6r9TbzfJ0wRpzUE8F8fV6X6yNuIIo3M+hjwOlEDqLYMG Xn4hVGDpJBjMnd55A25taU5cLcxVCqhoDELnqu4terw5csvC/CF7WmC0QCnLb1z1IIkQ45ULedJ fKTK/Wftw24PKtdYEGRhJgim6UP5dDpfe5MJ0Ayr7qqi8IyUBTPc0honu1Y1WfAA8mdvQbyc3TI WrXmbF4HBVheEpOCcDdtjp4Cvh4cuLvRxPE081cEcQO/MONWamQbmLGwzbmcNM4lcWgdv4gL3vs xCQ1sz98EhWvBtReiPMFW6TAjQtUe5VMbHTilSYvpzFQJcwhJoW+j1WeNiVQwtat2Zkxm832mwc Gv9aTj+N7l5LDd2AgPC31ABMGkPo8H+KNoLS5Ro1BFl4b/N/O7uXEhyNnhh5f2zolLCzthmT3Eb o9t5p1Zva+l17p2OE8f5uItDpvJT5iUODp9G9L6jPYTO3go+H6NVJt1hFehY1rK+sKtEUTyyU7G gGaQnJpYLE4UpoTv7+jwPVogq2FFictnqClfeqWjUIWQzL+QVBjeFWEgvnrMyAb1FADMnBH/aF8 2c7YIcsV8SRixbLac6VMMRXr X-Received: by 2002:a05:600c:46cc:b0:495:5e86:4e11 with SMTP id 5b1f17b1804b1-496b57177d7mr363715e9.12.1784929036022; Fri, 24 Jul 2026 14:37:16 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a02-3100-ae93-f301-cdd9-d5ea-080d-9131.310.pool.telefonica.de. [2a02:3100:ae93:f301:cdd9:d5ea:80d:9131]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496b499cc49sm20754015e9.9.2026.07.24.14.37.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 24 Jul 2026 14:37:15 -0700 (PDT) From: Karl Mehltretter To: Russell King , Greg Kroah-Hartman , Jiri Slaby Cc: Karl Mehltretter , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Sebastian Andrzej Siewior , John Ogness , Petr Mladek , Steven Rostedt , Clark Williams , Toshiyuki Sato Subject: [PATCH v2 1/2] serial: amba-pl011: unprepare console clock on unregister Date: Fri, 24 Jul 2026 23:33:47 +0200 Message-Id: <20260724213348.77418-2-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260724213348.77418-1-kmehltretter@gmail.com> References: <20260724213348.77418-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pl011_console_setup() calls clk_prepare() on the UART clock, but the console provides no matching teardown, so the clock is never unprepared when the console is unregistered -- via the sysfs "console" attribute or a driver unbind. Each re-registration prepares the clock again, leaking one prepare reference per cycle. Even where preparing the clock has no hardware effect, the stale reference leaves the clock framework's prepare count unbalanced. For providers with prepare/unprepare operations or runtime-PM integration, it may also retain resources after the console is unregistered. Add a console .exit() callback that clk_unprepare()s the clock, balancing the clk_prepare() in pl011_console_setup(). Fixes: 4b4851c65d92 ("clk: amba-pl011: convert to clk_prepare()/clk_unprepa= re()") Assisted-by: Claude:claude-fable-5 Signed-off-by: Karl Mehltretter --- drivers/tty/serial/amba-pl011.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl01= 1.c index 8ed91e1da22b..1aa43994a3cd 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2552,6 +2552,15 @@ static int pl011_console_setup(struct console *co, c= har *options) return uart_set_options(&uap->port, co, baud, parity, bits, flow); } =20 +static int pl011_console_exit(struct console *co) +{ + struct uart_amba_port *uap =3D amba_ports[co->index]; + + clk_unprepare(uap->clk); + + return 0; +} + /** * pl011_console_match - non-standard console matching * @co: registering console @@ -2705,6 +2714,7 @@ static struct console amba_console =3D { .name =3D "ttyAMA", .device =3D uart_console_device, .setup =3D pl011_console_setup, + .exit =3D pl011_console_exit, .match =3D pl011_console_match, .write_atomic =3D pl011_console_write_atomic, .write_thread =3D pl011_console_write_thread, --=20 2.53.0 From nobody Sat Jul 25 03:46:07 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C86933ADB97 for ; Fri, 24 Jul 2026 21:37:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784929045; cv=none; b=VlYJAGX4i17NfV0Wi5ww4gYyAqNVSgR5fdG5lzxlzkJlRJV16xDIRJ4xCfxi1QcrJCKvca5Aqf5TnQ0/DIn2QaiVE/C62hyyQyBPYt7O0m7uvVtu3zl31XVQab+lpTD5Dlnvws5xeqflPotciu++nfD21g/mJgPD23OSw3xzOPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784929045; c=relaxed/simple; bh=k0eIj9G6Isnpa32QRNbc3ZJdWbsPOLvyESbeGdG2D8A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f0PY+qChwEq3M2u+2bq3wWNrYzIcTZTiXb6/W8Xu+o9cReUJsl1+jkG+nE3AYL+i9vM2TEgy1qNmlfaSIOAjkwu7x6FkvguDtJnP0NmmtYvP6SD3Pm/z4bdhszr7vC9IFTjpEfrzg+9WaouhcfBNZOPPLhXRU04aP785Qbzyp24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T20gc38f; arc=none smtp.client-ip=209.85.128.45 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.b="T20gc38f" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4953e04ef16so9384165e9.2 for ; Fri, 24 Jul 2026 14:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784929041; x=1785533841; 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=zw+In47VNqyZ6M3jtrWopK6tPDTD0rxTpVkixtQCLIg=; b=T20gc38f83JIJOSoPdH/rUsRKTxHFMK9j6stpBIAvThek//jgOe8/8KE1Qd4SQnkFl HNqaeIKnau4gugLRciE6+Y5cG6hMPyoyw8DAYf8B7OzXbs/DtO4gxyE4lqCb0bpLntcH B1lLc3xuy4rKQ3DlnQjymjbsqusYhiw4ZkaiA0T/67XDf3UYHdRHwYWdQvRa1alu3QWt h36yNB2pJ1DLEa2hB5dyIY14UoCvRaGSpllmUNuZ3iY7MkPLdp+DW5GV8HbdR91qO5Mw Nz1qPd/b+WR13C0nXvdlpfsJtl9T/xcVABDVbgQSCAFlOWu4uZHDYQ/2uC7BEijN32Kj 53gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784929041; x=1785533841; 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=zw+In47VNqyZ6M3jtrWopK6tPDTD0rxTpVkixtQCLIg=; b=EBzDDLIUUEl1LEHI0H4PY4yIB+ofHO1wws5nWqs/i/64HS15QD+E8vYbHFwFknWMKh uhpJwCvb+n2zQ2+QfSco7FQIZtmFrTYV3l08oGwYlTN8CrsuhelH0zVVxSueRcBBvUXn wLJCyyw82NwO8qQHcbD/wCclqIjNItGWNz7EMS9j14ffWgJ26p3dmUfx7jS5TUvg3NRj t2pHbr+fJQ0kKifqAXsXm5FrkXUqEkV6+zUgLcl3HjWrh/JCTbQETNYKZ6FaBAEHdDB4 9rYIqDg58CWSioiravgAwjrL8LL6Gm8Yp9j8vcfI9uajgulDlXNOfOd0q+irpHHIhUuY wX4w== X-Forwarded-Encrypted: i=1; AHgh+RrSHYpt2nVz73LlMIwR5bPnsJZFHUHcYbmLP+UMzrrfYC5yzp0ozeGU7ymRP5/YVyE3EFdFV3gg2uRiwt4=@vger.kernel.org X-Gm-Message-State: AOJu0YwfT8qgU1TMxOljpmGMtgErpheVb8VMnhFzw6tu1+uo4HZ1IlcV fYLC3n0ic7CRGqhArpYAwi2Vn2v/HmoU/r3JF321AqGGvXMOX6Z5Fov3 X-Gm-Gg: AR+sD133rlOJrM8tMgpAtsml+XDrGES9GsO3gJpmxgEAYVhtXUUsqC4iT6AI02E7lV4 yQdKKnUz3PFO5dQNHbQ/qSBjiOdkR5xbBWoM84rBHCEWU7AUX/NkcYOI15y+53rLwHUUtJaxsLZ 2qA2bTVQLRLAWrtlBUigUk2icpvgr1trQOYTy+BaSJ18xT7zAImqDxcjbQI1iQww5EhaRY0GNO0 tY86cBOZwDdXv5pS+2e85WP6CtOfQF7zOKAJ7buVSDxEp27p9yWA8+0FnXLi971F3OBlB3IfvF1 UfLh7yajORFb2qNT1CmCTpIailYckj4cjYXl3q4rU7YcEuJzydhqWRyHvSMDtKh2iakpQFIIALB w9lSse7ACthVFxbgs2CdPWLJn24g6/tBHaAfLRufy3lAQ59RLlrBDW6lzoYM59Gf5xC1/dCfw+3 wofCKl/TTpX/LLpKwOSU8LmJXcbi9iNKV+ONECJ5kyGdnFAFxxPS78H1bJN7vgJ3RgymoC4h1Gf gMLbXt70lOnsWypnv932s2rXkh6u8F6qqeDwDqxQ28nVqSmONLkYDBVmlFd+WVW02tsAcq93fI4 DBZQ0eehxKgjOA== X-Received: by 2002:a05:600c:4f94:b0:493:eb71:5cc6 with SMTP id 5b1f17b1804b1-496b5720ac4mr429335e9.27.1784929040710; Fri, 24 Jul 2026 14:37:20 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a02-3100-ae93-f301-cdd9-d5ea-080d-9131.310.pool.telefonica.de. [2a02:3100:ae93:f301:cdd9:d5ea:80d:9131]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496b499cc49sm20754015e9.9.2026.07.24.14.37.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 24 Jul 2026 14:37:20 -0700 (PDT) From: Karl Mehltretter To: Russell King , Greg Kroah-Hartman , Jiri Slaby Cc: Karl Mehltretter , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Sebastian Andrzej Siewior , John Ogness , Petr Mladek , Steven Rostedt , Clark Williams , Toshiyuki Sato Subject: [PATCH v2 2/2] serial: amba-pl011: keep console clock enabled for atomic writes Date: Fri, 24 Jul 2026 23:33:48 +0200 Message-Id: <20260724213348.77418-3-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260724213348.77418-1-kmehltretter@gmail.com> References: <20260724213348.77418-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pl011_console_write_atomic() runs from nbcon atomic context, where sleeping is not allowed. It calls clk_enable(), which takes the common-clk enable_lock. Under PREEMPT_RT that is a sleeping lock: clk_enable_lock() first tries spin_trylock_irqsave(), but on contention falls back to spin_lock_irqsave(). Therefore, an atomic-context printk on an RT kernel with a clk-backed pl011 can trip: BUG: sleeping function called from invalid context at spinlock_rt.c:48 __might_resched from rt_spin_lock rt_spin_lock from clk_enable_lock clk_enable_lock from clk_enable clk_enable from pl011_console_write_atomic ... from vprintk_emit This was found and reproduced on PREEMPT_RT. Arm32 and arm64 DT SoCs are affected; arm64 SBSA/ACPI has no clk, so clk_enable(NULL) short-circuits before the lock. In addition, write_atomic() may be invoked from NMI context and is documented to avoid locking. Removing clk_enable() from the callback also avoids a potentially unsafe NMI acquisition of the common-clock enable_lock. An nbcon atomic-capable console must be printable from any context, so the clock cannot be gated between writes. Enable the clock while the console is available for output: use clk_prepare_enable() in pl011_console_setup(), release it via clk_disable_unprepare() in the console .exit() callback, and drop the per-write clk_enable()/clk_disable() pairs from write_atomic() and write_thread(). When printk suspends consoles, drop the reference after uart_suspend_port() stops console access and restore it before uart_resume_port() -- but only if suspend actually marked the port suspended (a wake-capable tty stays running and must keep its clock), and keep it when console_suspend_enabled is false so no_console_suspend works. The active power cost of keeping the clock enabled is platform-dependent: none where the UART clock is a fixed always-on oscillator, real where it is a gateable clock branch, which then cannot be gated (nor possibly can its parent clocks) while the console is available for output. When serial core actually suspends the port, the reference is released so the clock provider can gate the clock tree. Fixes: 2eb2608618ce ("serial: amba-pl011: Implement nbcon console") Suggested-by: John Ogness Link: https://lore.kernel.org/all/8733xeaxix.fsf@jogness.linutronix.de/ Assisted-by: Claude:claude-fable-5 Signed-off-by: Karl Mehltretter --- drivers/tty/serial/amba-pl011.c | 40 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl01= 1.c index 1aa43994a3cd..611d1f6a0590 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2523,7 +2523,7 @@ static int pl011_console_setup(struct console *co, ch= ar *options) /* Allow pins to be muxed in and configured */ pinctrl_pm_select_default_state(uap->port.dev); =20 - ret =3D clk_prepare(uap->clk); + ret =3D clk_prepare_enable(uap->clk); if (ret) return ret; =20 @@ -2556,7 +2556,7 @@ static int pl011_console_exit(struct console *co) { struct uart_amba_port *uap =3D amba_ports[co->index]; =20 - clk_unprepare(uap->clk); + clk_disable_unprepare(uap->clk); =20 return 0; } @@ -2630,8 +2630,6 @@ pl011_console_write_atomic(struct console *co, struct= nbcon_write_context *wctxt if (!nbcon_enter_unsafe(wctxt)) return; =20 - clk_enable(uap->clk); - if (!uap->vendor->always_enabled) { old_cr =3D pl011_read(uap, REG_CR); pl011_write((old_cr & ~UART011_CR_CTSEN) | (UART01x_CR_UARTEN | UART011_= CR_TXE), @@ -2648,8 +2646,6 @@ pl011_console_write_atomic(struct console *co, struct= nbcon_write_context *wctxt if (!uap->vendor->always_enabled) pl011_write(old_cr, uap, REG_CR); =20 - clk_disable(uap->clk); - nbcon_exit_unsafe(wctxt); } =20 @@ -2662,8 +2658,6 @@ pl011_console_write_thread(struct console *co, struct= nbcon_write_context *wctxt if (!nbcon_enter_unsafe(wctxt)) return; =20 - clk_enable(uap->clk); - if (!uap->vendor->always_enabled) { old_cr =3D pl011_read(uap, REG_CR); pl011_write((old_cr & ~UART011_CR_CTSEN) | (UART01x_CR_UARTEN | UART011_= CR_TXE), @@ -2692,8 +2686,6 @@ pl011_console_write_thread(struct console *co, struct= nbcon_write_context *wctxt if (!uap->vendor->always_enabled) pl011_write(old_cr, uap, REG_CR); =20 - clk_disable(uap->clk); - nbcon_exit_unsafe(wctxt); } =20 @@ -3080,21 +3072,45 @@ static void pl011_remove(struct amba_device *dev) static int pl011_suspend(struct device *dev) { struct uart_amba_port *uap =3D dev_get_drvdata(dev); + int ret; =20 if (!uap) return -EINVAL; =20 - return uart_suspend_port(&amba_reg, &uap->port); + ret =3D uart_suspend_port(&amba_reg, &uap->port); + if (ret) + return ret; + + if (console_suspend_enabled && uap->port.suspended && + uart_console_registered(&uap->port)) + clk_disable_unprepare(uap->clk); + + return 0; } =20 static int pl011_resume(struct device *dev) { struct uart_amba_port *uap =3D dev_get_drvdata(dev); + bool resume_console; + int ret; =20 if (!uap) return -EINVAL; =20 - return uart_resume_port(&amba_reg, &uap->port); + resume_console =3D console_suspend_enabled && + uap->port.suspended && + uart_console_registered(&uap->port); + if (resume_console) { + ret =3D clk_prepare_enable(uap->clk); + if (ret) + return ret; + } + + ret =3D uart_resume_port(&amba_reg, &uap->port); + if (ret && resume_console) + clk_disable_unprepare(uap->clk); + + return ret; } #endif =20 --=20 2.39.5 (Apple Git-154)