Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24A23C38A2D for ; Tue, 25 Oct 2022 21:41:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9C2C84E9C; Tue, 25 Oct 2022 23:41:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="HDV2+6kU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23A2884F41; Tue, 25 Oct 2022 23:41:29 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 26BD8806EB for ; Tue, 25 Oct 2022 23:41:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AA22161B89; Tue, 25 Oct 2022 21:41:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8B10C433C1; Tue, 25 Oct 2022 21:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666734084; bh=LmwiJ9AnZCZ6I38MfWbiJsxAZqpaHeLoi/NxuyDawGQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HDV2+6kUi9pHhz2ZzvjjeCUAxsgCA1NEAzz0D06w03uOt+6smAYmt8d1SE4rO7nLU MzamvkpvmYx71FpdYDUMWvDnKWAzRSfc4Yg/4y94ESLxzMayLNJ8jZaGFKOANrnRDo EcWQcK6tynBhqH01QM03K3+/Z+9R2hHZqmUs3YtBtFXR2v6rUC2Q13lvdujCPuchIW MLrPKtgs3aosfGU2Nbwv2BsERsGUEB55M5wwW4SmzAnvEbPUKS0zQQeJEB5VCVYD7F 60mNsqD0KqCImNFUrDBoCN0B7YHaT5CALkP6Q/1t5bvJvlzMlS+CbS+MUlAnGX4giY JZuueiQ4I5stA== Received: by pali.im (Postfix) id F33A2898; Tue, 25 Oct 2022 23:41:20 +0200 (CEST) Date: Tue, 25 Oct 2022 23:41:20 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Fabio Estevam Cc: Tim Harvey , Johannes Schneider , u-boot@lists.denx.de, peng.fan@oss.nxp.com, sbabic@denx.de, trini@konsulko.com, bsp-development.geo@leica-geosystems.com, Peng Fan Subject: Re: [PATCH v5 2/2] serial: mxc: have putc use the TXFIFO Message-ID: <20221025214120.ukfzvontprhmzxog@pali> References: <20220906121504.2200171-1-johannes.schneider@leica-geosystems.com> <20220906121504.2200171-3-johannes.schneider@leica-geosystems.com> <20221025202335.k5isd54j6ubhdglu@pali> <4e715158a0c58e2ae42b7748676851ff@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4e715158a0c58e2ae42b7748676851ff@denx.de> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Tuesday 25 October 2022 17:37:01 Fabio Estevam wrote: > Hi Pali, > > On 25/10/2022 17:23, Pali Rohár wrote: > > > Hello! I do not have any MXC hardware but I see there one issue. > > mxc_serial_putc() function probably should not return -EAGAIN when > > device is busy. But instead it should wait until it is ready. > > > > Could you try to change code to following? > > > > while (readl(&uart->ts) & UTS_TXFULL) > > ; > > > > writel(ch, &uart->txd); > > Your analysis looks correct. > > The kernel does like this: > > static void imx_uart_console_putchar(struct uart_port *port, unsigned char > ch) > { > struct imx_port *sport = (struct imx_port *)port; > > while (imx_uart_readl(sport, imx_uart_uts_reg(sport)) & UTS_TXFULL) > barrier(); > > imx_uart_writel(sport, ch, URTX0); > } > > Thanks Well, "waiting for HW to be ready" vs. "returning -EAGAIN" is serial API detail. Kernel (or other implementation) may have different API and driver always have to implement what API expects. So aligning return value with kernel is not the argument for fixing issue. Anyway, I think that my change is not correct. serial-uclass.c is already calling: do { err = ops->putc(dev, ch); } while (err == -EAGAIN); Which means that function is called again.