From mboxrd@z Thu Jan 1 00:00:00 1970 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 CE1D2C4332F for ; Thu, 8 Dec 2022 15:46:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D5B7847ED; Thu, 8 Dec 2022 16:46:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="E+epLipl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 98EC280393; Thu, 8 Dec 2022 16:46:13 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4300D847ED for ; Thu, 8 Dec 2022 16:45:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-wr1-x436.google.com with SMTP id h7so2090020wrs.6 for ; Thu, 08 Dec 2022 07:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NXE8WIysmhJ1V+xrvYronkFoLUouRvZ7++zJgoAVEW8=; b=E+epLiplrFEgdMQX7aXuR6ue5Zdj2CEYtVFgatJk5n9iBUP0rMRV0H9fEQ2vXveyh4 0B4+WbYS4Oo1ZhwwA/a2+V7JJq1/LP94uYTXcpuNjCA3bTn9A0tmZlK8N/Y1RRUX4n57 BKpqf2EXpCVlgscIYEkNfnYqU6TsNmptymMPI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NXE8WIysmhJ1V+xrvYronkFoLUouRvZ7++zJgoAVEW8=; b=mVFPaq9gkovGDD6cktgP+9l5pY1jDsSrr9sEqUzomI7LSDUHc5f/IawJvlThYlHm2V TxlNQH/KSu5wU7r0lbQoGlm/V5EYlR/xUURFSUK20y2xLROsAS21s9RY3ktn3BHZTaE0 aQC38/VRjjPXdVYXAAHKjG7KqQfa3nERIFz7R8RUCbKgXw/fYOrpLpOWfNEz5ajgBkBH dK0kD1yDShzkGTG9OPrs8PcUD9JVEsLfrR63hiZK8/3QoxCSjkmsnNQUSKhb7nY9Xd9P 60u0clWuX0Vg9ttXKHMtezbHL8/Jk9AJuiXMbZTqPMP9P4j41C/KOtOtdEwRx0Q59ZdK kcoA== X-Gm-Message-State: ANoB5plZnpPWMe77QKD71egtA5Y5tZBBwbLxKcG2aqzzLjy07Ks1knJX blm5f/BhF54zXhCYMpI1meB2pA== X-Google-Smtp-Source: AA0mqf4hVUzv0HjHdxFnZx/ckAv0hYWR0JNeCc3wTa7EsAJa6b2U8ZC7kMrs4RYM/Ey+YI/213sKXA== X-Received: by 2002:a5d:680b:0:b0:242:51ae:e9ca with SMTP id w11-20020a5d680b000000b0024251aee9camr1753383wru.35.1670514353768; Thu, 08 Dec 2022 07:45:53 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-0511-db36-5a97-af74.res6.spectrum.com. [2603:6081:7b00:6400:511:db36:5a97:af74]) by smtp.gmail.com with ESMTPSA id k1-20020adfe3c1000000b002426d0a4048sm10245023wrm.49.2022.12.08.07.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 07:45:53 -0800 (PST) Date: Thu, 8 Dec 2022 10:45:49 -0500 From: Tom Rini To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Stefan Roese , u-boot@lists.denx.de, Simon Glass Subject: Re: [PATCH] serial: Use -EAGAIN in getc and putc Message-ID: <20221208154549.GA551143@bill-the-cat> References: <20221204123655.29939-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: <20221204123655.29939-1-pali@kernel.org> X-Clacks-Overhead: GNU Terry Pratchett 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 --huq684BweRXVnRxX Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 04, 2022 at 01:36:55PM +0100, Pali Roh=E1r wrote: > U-Boot serial code already handles -EAGAIN value from getc and putc > callbacks. So change drivers code to return -EAGAIN when HW is busy inste= ad > of doing its own busy loop and waiting until HW is ready. >=20 > Signed-off-by: Pali Roh=E1r > Reviewed-by: Simon Glass > Reviewed-by: Stefan Roese [snip] > diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuar= t.c > index ff576da516d4..d7259d531b55 100644 > --- a/drivers/serial/serial_lpuart.c > +++ b/drivers/serial/serial_lpuart.c > @@ -168,8 +168,8 @@ static void _lpuart_serial_setbrg(struct udevice *dev, > static int _lpuart_serial_getc(struct lpuart_serial_plat *plat) > { > struct lpuart_fsl *base =3D plat->reg; > - while (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR))) > - schedule(); > + if (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR))) > + return -EAGAIN; > =20 > barrier(); > =20 > @@ -181,8 +181,8 @@ static void _lpuart_serial_putc(struct lpuart_serial_= plat *plat, > { > struct lpuart_fsl *base =3D plat->reg; > =20 > - while (!(__raw_readb(&base->us1) & US1_TDRE)) > - schedule(); > + if (!(__raw_readb(&base->us1) & US1_TDRE)) > + return -EAGAIN; > =20 > __raw_writeb(c, &base->ud); > } This is non-trivially not right for this driver. ->putc here is set to lpuart_serial_putc which calls _lpuart_serial_putc OR _lpuart32_serial_putc, so there's the lpuart32 cases to address, and then lpuart_serial_putc needs to just return whatever one it called rather than always returning 0. --=20 Tom --huq684BweRXVnRxX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmOSBqoACgkQFHw5/5Y0 tywsTgv/c+6/zSi4PbHN7r0EzQHx5SlLaLb7qpGYodUIjLKfeMqDGvH8CdhkdPKS As/44T08WK4BeFSBg4WWI94zjZ7AiMWG4GOfH0AlWg4gdEvr8NJVTJZtQBxDi3Xk v0F7qqgYKEvZGT4OFm18qDqVD485W5aMOk6P88cNrtzRhzJnV6Je/tbxUHKoGJU/ gHC8XwyL4FHg5dads1yrH8I4AMiXn/PKBUOoYG9hlQCKswnYHn6WrY6xSnRpSccV BqhcW6udLml3XVpCHYMOIUbxgwkzeSqibf34zSdzL5s4o/Zrn7QNpzfoVBCUb3hL hH+sr0cuOhfU6wW5QpWbacoK7gC7Ri5HdTLH6byKTwinSHpUtOl68uPJ2Hbrdb7W L0HjMYNMGRe/bjR7GOMEjW06byAkCuG1NW2uduQYJ3Q2SnZqCECSb/oDqvSxblMN BK4vgkV1lEyzg/gyPgZfFIcLgeKW1D9D6ZNJWH9ok53wedbtkOrJBBtNrpmEbGK1 NydKT5CZ =l1Gy -----END PGP SIGNATURE----- --huq684BweRXVnRxX--