From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 3C08C606A32E for ; Thu, 12 Nov 2026 16:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EsjB1/I2 Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jQQP74KXjz2xVY; Fri, 13 Nov 2026 03:11:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1794499883; cv=none; b=WRgp5cqZzyvH0qZau+V/mF7GwBRfGutb92a+RxRkCzMvnkW4gxqcDpdVn+30ua7B2EB0fLzhhnEZ4TXGaTAAIKVwL4sIqwHLoNOfZS2tkhLDRGhoChX0Iu4Y9TFTt3m+ODNqLy1Xu2jjKliHaQ0FJ/fyf4nzaAZgvmX2RlstHXg+YtyQlYeJHwNKAmQyRyweg6g76Z3dS8oxLj5IZiN+lFZ7AkqslZtF/MM2ksjGt6xv7FGaP6q79jeepRHAEyHUmkvjX0hvzg23CDtWcrx+X686Qz+UgwHCILMeeFPkTZ+o0DgxMPv96XUZ/2YVSz8GpxH2/s/UbSUHl939RYPf0g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1794499883; c=relaxed/relaxed; bh=wYw3PsXp2ITZe1gp5kAYVuoE8XjZzVKbPqIuhL3V96o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FThhp932Gg+eAmxH3gkIEhhvEI1hHjjFR2Zyu06pn7Yx6xTZZTdllPthnYqSu7E11vSciKHUcNW50BrdBW6pEM8lztckNeZ6I3Qzx58PmJlflxvG/2LMASgV+SxAY9dxH+AEVqxhuMjkY9YD8yVFBvB56e2z8oYdMPmsf4w3O5Vj4Uh3lwM8hg1oL3tEeI01dl8FKz0aFs9fiLm0bCQ6Uhnuy/11klM1AhUQ87kdd5RbyEADEntS4SkH4Oot1Y8RvUQtf0V20qSpi2jIZwTa+k3axfskcGroorA4JALSLGJ3EErf9vJV95c7WmEhAK6Kd7AZ+535uC97OFt6ncJTMQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EsjB1/I2; dkim-atps=neutral; spf=pass (client-ip=192.198.163.19; helo=mgamail.intel.com; envelope-from=andriy.shevchenko@linux.intel.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.intel.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EsjB1/I2; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.intel.com (client-ip=192.198.163.19; helo=mgamail.intel.com; envelope-from=andriy.shevchenko@linux.intel.com; receiver=lists.ozlabs.org) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jQQP44bH1z2xS2 for ; Fri, 13 Nov 2026 03:11:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794499880; x=1826035880; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=KBEV1+wJUVkGmgDR8fswFDchKVGVUIlgzz8KWBVWUnM=; b=EsjB1/I2a31HuVgitedhhfxgBb85KETAs8ljUME1DJFAAIO0mUnSjzQD yhjr49g0E1v+oBR1KW6/uDhegzoKjS8ehWmlTsqZBEQ6qoUgzHI67Z8mz NNQ9h1O0XZWlB1s56Yw+axYrqYPqy/iCh9VZDUGTg4/w0KxKlmZ/1M8oR bpzx3aaP27gk3LkhdoYf1D2pD+PrjN5HEVJYY8BAuZmr/GvFBQDwybmxD Y7EstZC76uWeGRcHx+igPB99rWSJbTE/BYklece3g8tDW87NG/pjG4fHx UCnOrErpOyh5IgJ85hI4lFl/nz3BzFofgo9Z2vG/Qqmbw29NDkZJ/KUOw Q==; X-CSE-ConnectionGUID: JIh2+RT5TJ2cUJ4+pykPxg== X-CSE-MsgGUID: qSj+TN/uSpiAg1/XdgIYSQ== X-IronPort-AV: E=McAfee;i="6800,10657,11964"; a="3389982" X-IronPort-AV: E=Sophos;i="6.27,210,1787036400"; d="scan'208";a="3389982" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2026 08:11:10 -0800 X-CSE-ConnectionGUID: Ar7wg5q8RPSLm90mcDK6lQ== X-CSE-MsgGUID: BqOUjxi1T12vvGwXG4HdSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,210,1787036400"; d="scan'208";a="8860902" Received: from ettammin-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.244.6]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2026 08:11:04 -0800 Date: Thu, 12 Nov 2026 18:11:02 +0200 From: Andy Shevchenko To: James Hilliard Cc: Greg Kroah-Hartman , Jiri Slaby , Raul E Rangel , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Heikki Krogerus , Tony Lindgren , Sebastian Andrzej Siewior , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Jacky Huang , Shan-Chun Hung , Pali =?iso-8859-1?Q?Roh=E1r?= , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , "Maciej W. Rozycki" , Timur Tabi , Peter Ujfalusi , Vignesh Raghavendra , Patrice Chotard , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v12 2/8] serial: serialize asynchronous write wakeups with the port lock Message-ID: References: <20261111-submit-serial-8250-dma-cancel-v1-v12-0-9e3456bc2555@gmail.com> <20261111-submit-serial-8250-dma-cancel-v1-v12-2-9e3456bc2555@gmail.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261111-submit-serial-8250-dma-cancel-v1-v12-2-9e3456bc2555@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Nov 11, 2026 at 03:16:27PM -0700, James Hilliard wrote: > uart_write_wakeup() expects the UART port lock to be held. Several worker, > DMA completion and interrupt paths call it without that lock, including > indirect calls from uart_handle_cts_change() and the transmit helpers. > > Take the port lock around these notifications or their transmit helper. > Keep sleeping SPI and regmap accesses outside the locked region, and keep > the FSL LPUART completion lock held through its wakeup. Acquire the port > lock after releasing private channel locks to preserve the ordering used > by UART callbacks. In the MUX timer, publish available FIFO space under > the port lock and keep the hardware FIFO-drain wait outside it. > > Use plain port locking in hard-IRQ handlers and in helpers whose callers > already mask interrupts. Atmel status handling is also called during > resume, where lock_suspended is acquired with interrupts disabled; JSM > interrupt processing holds its IRQ-saving board lock. Keep IRQ-saving > locking in workers, tasklets and other mixed-context paths. > > Take the port lock after requesting the ST ASC interrupt and hold it > through startup's transmit servicing and RX interrupt enable. The transmit > helper can notify writers even when the FIFO is empty, and serial core > calls startup without holding the port spinlock. > > Use IRQ-safe locking in the Atmel RX and TX tasklets and SB1250 termios > path, since their interrupt handlers now acquire the same port lock. > Preserve the caller's interrupt state when releasing those locks. > > On SB1250, lock modem-state updates after reading and filtering the change > status, and wake modem-status waiters after unlocking. Take the TX lock > inside its service routine so RX-only interrupts need no acquisition. > Keep that lock across x_char handling, FIFO consumption and the decision > to mask TX interrupts: a writer must not enqueue data and enable TX between > the empty-FIFO check and the interrupt-mask write. Each TX invocation sends > at most one character. > > Serialize CLPS711x TX servicing and its interrupt-enable state with the > port lock. Disable TX interrupts without waiting in stop_tx(), since a > threaded handler may need that same lock. Have an already queued handler > leave stopped output untouched, and drain it outside the lock during > shutdown before the transmit FIFO can be released. > > SCCNXP handles interrupts under a controller lock which its UART callbacks > acquire with the port lock already held. Collect the ports needing wakeups > in an unsigned long bitmap while servicing the controller, then release > that lock before visiting the set bits, taking each port lock and > rechecking the wakeup threshold. Removal drains the IRQ or timer before > unregistering the ports. > > This serializes write notifications with port-locked serial-core state > changes, allowing readiness and transmit-storage reservations to gate the > notification without a check-versus-shutdown race. > > Cover DZ TX servicing and JSM Classic modem notifications as well. On > DECstation ZS, acquire the port lock before the SCC lock and notify writers > after releasing the SCC lock. Defer normal TX restart after console output > to a worker, since console output can already run under the port lock. > Check transmitter readiness before consuming another character and drain > the restart worker during shutdown and removal. Release Lantiq's hardware > lock through the transmit helper's completion hook before notifying the > line discipline. ... > static inline void dz_transmit_chars(struct dz_mux *mux) > status = dz_in(dport, DZ_CSR); > dport = &mux->dport[LINE(status)]; + blank line to make guard()() visible at a glance. (no need to resend just for this, though) > + guard(uart_port_lock)(&dport->port); > + > tport = &dport->port.state->port; > > if (dport->port.x_char) { /* XON/XOFF chars */ -- With Best Regards, Andy Shevchenko