From nobody Sat Feb 7 18:15:24 2026 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 1E43020969A for ; Fri, 10 Jan 2025 21:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736545128; cv=none; b=Eb4VF1OvH+XypP32xT9lbju3GltWlGea4VXEzWYWL1Doqd8xl5YFF6RSICMvKB8bP3QlasJRNsXBLGQRgpKrKI2wpli4bzW53XfLHH/K5lEpmudQtFGFBTW5lBKv2Vz6Z3U8OgG/xY6sM27F26U7TrvC9/LsxDoxOt8n2CIDPQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736545128; c=relaxed/simple; bh=uN8OvW217jnJrGT746idFk71yViCEnErL4OQOhqSQZE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=guwuXoh38H2Y2LhOOxopa2gYEqBevcb5XPLzudsCwhH+gAuBsaFs0y+aklm/oYQrvD+N8auj4LgfEs+QTXtWXNB9MYbJ6X81IZdL6b9hfxh6kkve0M7xXRLQ6s4nRslLXC6SQK+YS84ki2u2IMUuKsdOYqRu7RNVbsg0k9dA86Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Wva81Aww; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Wva81Aww" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1736545109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=iC3k1SZlNlarqOZELintr0r8/tkyMFglXXS2+edHzKk=; b=Wva81Awwv8ENbIE/bgyPENEqbHTNL7iwNmGOtP50PP3xoef58qXCG690ciwFORmKWOkdrA FNQQVJ3dEzFR5l/R2SluGnP4Br//1R/g2BpGUpQFhiM0+NiikXAjGI5g6lNrvm9Vedt/b/ wGU6ue67daWJX2W5IWpOviA0bntRhrY= From: Sean Anderson To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Cc: Manikanta Guntupalli , linux-arm-kernel@lists.infradead.org, John Ogness , linux-kernel@vger.kernel.org, Michal Simek , Thomas Gleixner , Sean Anderson , stable@vger.kernel.org Subject: [PATCH] tty: xilinx_uartps: split sysrq handling Date: Fri, 10 Jan 2025 16:38:22 -0500 Message-Id: <20250110213822.2107462-1-sean.anderson@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" lockdep detects the following circular locking dependency: CPU 0 CPU 1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D cdns_uart_isr() printk() uart_port_lock(port) console_lock() cdns_uart_console_write() if (!port->sysrq) uart_port_lock(port) uart_handle_break() port->sysrq =3D ... uart_handle_sysrq_char() printk() console_lock() The fixed commit attempts to avoid this situation by only taking the port lock in cdns_uart_console_write if port->sysrq unset. However, if (as shown above) cdns_uart_console_write runs before port->sysrq is set, then it will try to take the port lock anyway. This may result in a deadlock. Fix this by splitting sysrq handling into two parts. We use the prepare helper under the port lock and defer handling until we release the lock. Fixes: 74ea66d4ca06 ("tty: xuartps: Improve sysrq handling") Signed-off-by: Sean Anderson Cc: # c980248179d: serial: xilinx_uartps: Use port= lock wrappers Acked-by: John Ogness --- drivers/tty/serial/xilinx_uartps.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx= _uartps.c index beb151be4d32..92ec51870d1d 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -287,7 +287,7 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned = int isrstatus) continue; } =20 - if (uart_handle_sysrq_char(port, data)) + if (uart_prepare_sysrq_char(port, data)) continue; =20 if (is_rxbs_support) { @@ -495,7 +495,7 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id) !(readl(port->membase + CDNS_UART_CR) & CDNS_UART_CR_RX_DIS)) cdns_uart_handle_rx(dev_id, isrstatus); =20 - uart_port_unlock(port); + uart_unlock_and_check_sysrq(port); return IRQ_HANDLED; } =20 @@ -1380,9 +1380,7 @@ static void cdns_uart_console_write(struct console *c= o, const char *s, unsigned int imr, ctrl; int locked =3D 1; =20 - if (port->sysrq) - locked =3D 0; - else if (oops_in_progress) + if (oops_in_progress) locked =3D uart_port_trylock_irqsave(port, &flags); else uart_port_lock_irqsave(port, &flags); --=20 2.35.1.1320.gc452695387.dirty