From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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.subspace.kernel.org (Postfix) with ESMTPS id EB067606A905 for ; Thu, 29 Oct 2026 14:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=p6KL3Amt; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=P2ugtpaC DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=0t7g2WC+b9FztvwqiERlUGDT4mF51ROculYuxl9U52o=; b=p6KL3Amt4FsCl75iPQXGW46/2N H31NP5ArqvofJzXrlk3lKKhhNkDnRZCZ1PO2o5XUIha1StrKKQzBJKV5y5DiwkKtaLtO4cyeYBBRw iiTxfZcohLShYKKs1HAKpIqkewIdEkRJCMpt51qifBl4h7KV6biVuEaHnJFcpq/nuXl2z5th4VIHM Ec3ESPZ49jrTZFC3ARg0X27y3jWTSYe0VGJqWRmBe0LWHyWTYJ36YfyZq7dwICB6YgFMQ3oEWGK58 8/3GkM4DzIHHutvjFhRA31ojjXiKhGZGbNAGIlsoSRyZkqPjItuJShkKrYHrg+JJmyeLE/dnzveTY fWw9pV2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xMQyl-00000009VRe-3OFp; Thu, 29 Oct 2026 14:19:43 +0000 Received: from mgamail.intel.com ([192.198.163.10]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xMQyj-00000009VR7-3OM2 for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2026 14:19:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793283582; x=1824819582; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ks0QnF665NpX8S1B9/P4xaJFMSaRvnc+QpU5Vun1o38=; b=P2ugtpaC5ZywUSLFtAdmujFqrPVyyBNCcVWNKcwB5fCSYUEToFGQLv1u 4bMkB5fojJ2zVy3LX6MrYnLePZXpDBb3YIlnk1Q2w/UGel+DZH/r1s3aD pz1iIyD9G/PmblNHU2GZVQE4uy/YZr81gBktY8VpB91sWh9BrVq1Y1w8h zEKHOSY8HNXSFb3ueVzyte315/YTZVAIU2hdLQJN7w+Gnyz2pBxS4uXs8 lTezWr3DY9xaJYAoCEoY47zs4yvUGAbNnCXJnG2og3IlIwzeAk0fKCc9E hZU/Rdz1a9Rkl+wLGSCs8BK+LNXgtFcv7i+8gf8+DwEeOv7ksTxTTuutF g==; X-CSE-ConnectionGUID: BN8lns9MQhOqXZKCKKXq6Q== X-CSE-MsgGUID: wbxlJr87SxKFxFVn4osdkQ== X-IronPort-AV: E=McAfee;i="6800,10657,11949"; a="1934271" X-IronPort-AV: E=Sophos;i="6.27,184,1787036400"; d="scan'208";a="1934271" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2026 07:19:34 -0700 X-CSE-ConnectionGUID: QyJOQ8qDTY+boqh3NJr+/A== X-CSE-MsgGUID: 7B3JJIPERS6eyiaI7RVCSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,184,1787036400"; d="scan'208";a="5119312" Received: from ncintean-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.245.129]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2026 07:19:28 -0700 Date: Thu, 29 Oct 2026 16:19:25 +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 , 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 v8 4/6] serial: 8250: drain canceled TX DMA before reusing its buffer Message-ID: References: <20261029-submit-serial-8250-dma-cancel-v1-v8-0-3fd56ba352ed@gmail.com> <20261029-submit-serial-8250-dma-cancel-v1-v8-4-3fd56ba352ed@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261029-submit-serial-8250-dma-cancel-v1-v8-4-3fd56ba352ed@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261029_071941_917499_BAD055E9 X-CRM114-Status: GOOD ( 15.36 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,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 Thu, Oct 29, 2026 at 01:37:00AM -0600, James Hilliard wrote: > uart_flush_buffer() resets the transmit kfifo before calling the driver. > serial8250_tx_dma_flush() terminates DMA asynchronously and clears > tx_running, allowing a new write to replace tx_size while a detached > callback has not yet run. That callback can then consume bytes > from the new transmission. Reusing the reset kfifo can also overwrite the > source of a transfer that has not stopped yet. > > Reserve the flushed FIFO storage through serial core before returning > from the flush callback. Keep tx_running set until a worker synchronizes > the terminated channel, suppressing old callbacks and new submissions > during that interval. Return the mapping to CPU ownership before releasing > the reservation and waking writers. Normal transfers continue to use the > FIFO directly. > > Reuse the locked completion processing after retirement, including OMAP > delayed register restoration and transmitter-empty handling. Take a runtime > PM reference around worker UART accesses and drain the worker before > releasing the channels. Shutdown releases the FIFO reservation after > stopping DMA and unmapping its source. Serial core keeps writes and wakeups > gated until startup or resume makes the port ready again. > > Track a flushed FIFO separately from the transfer length. If termination > fails, retain the reservation until normal completion and account the > completed bytes without advancing the reset FIFO. After successful > cancellation, process a zero-length completion once callbacks have drained. > > The race was found by inspecting cancellation and restart while preparing > H616 UART DMA support. > > Retain the tx_running check in both completion callbacks. Releasing the > reservation relies on the DMA provider draining detached callbacks when > dmaengine_synchronize() returns; provider callback-lifetime fixes supply > that guarantee for controllers which previously lacked it. ... > - bool shutting_down; > + bool shutting_down:1; > + bool tx_terminating:1; > + bool tx_flushed:1; What is the meaning of bool XXX:1? Have you checked with `pahole` the result? -- With Best Regards, Andy Shevchenko