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 CF9E6C433EF for ; Mon, 28 Mar 2022 16:04:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C37D83C0F; Mon, 28 Mar 2022 18:03:58 +0200 (CEST) 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="AiE0zilE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E78183B12; Mon, 28 Mar 2022 18:03:56 +0200 (CEST) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) (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 22A4B83C0F for ; Mon, 28 Mar 2022 18:03:53 +0200 (CEST) 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-qv1-xf2d.google.com with SMTP id kk12so12145776qvb.13 for ; Mon, 28 Mar 2022 09:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JeTEeX2upUgLFalPXWy6EYk5ooB6zDuReiUk9a5VuI0=; b=AiE0zilEYTA4iuesp2zXTkDUxuTQkGLrllB+lpbuqTFxs8XivuIRm56ttDhq2bWO18 uWOCnyJwnQkIgduVYkGZXj9pu/dZPCROQ9CBCfDr/cDo81ib6rVL/fkmi6dlKewCjylk x23ENyvax5BIVN1zRDLDeQ2yvmb6yfC/zcsqQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JeTEeX2upUgLFalPXWy6EYk5ooB6zDuReiUk9a5VuI0=; b=nQB0WiXEzAguC2m4S7h3qTnuAOYp0sGa+pRxYfKU5uZMkYCMYte70hf3f9qFwj79Tb ZNiRuTpjPYSGdTFXYsrczgeNlQCVIN/lfPP71/WRSbrmk2eVLhDwdFXuvoUfI0b0Aw+1 +R83l8wLACXPzr+DiB0oNa3+SlUU3tqQfPeMHfKkjrgR/hh6+QhA2TO57BmogXz0TdjY XiOMaTpjtmL1Bo43kjKwCYv7BraHmDEQO68EAWfu1oRJfACgiT+pKFknBM3QFDA9t0DB S0bm3nBrtIeet22Dcf5KPqoZjc6Pu8b5ZRKvJFd+M3Aqxcug+iivb3w1Xh3O9v/x7vLN dL7g== X-Gm-Message-State: AOAM532UUhYJKs3qEae4aCJA1hKMyUOtL/eHdagC8IZkMoGg9vU7gwcy Ki2oh7ze3rcqPuDl/TzX4r1bAg== X-Google-Smtp-Source: ABdhPJyoYToRDdWYUrXwbTL7RPhn46Pbi7Cl1LLcnrJOcbgmlIdkrwdZJEIVJd+ONaHGl3dKLhbZSQ== X-Received: by 2002:a0c:fc46:0:b0:440:f78f:f4c4 with SMTP id w6-20020a0cfc46000000b00440f78ff4c4mr21122439qvp.108.1648483427434; Mon, 28 Mar 2022 09:03:47 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-2ef0-5dff-fedb-a8ba.res6.spectrum.com. [2603:6081:7b01:cbda:2ef0:5dff:fedb:a8ba]) by smtp.gmail.com with ESMTPSA id 21-20020ac85715000000b002e1ce9605ffsm13173276qtw.65.2022.03.28.09.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 09:03:46 -0700 (PDT) Date: Mon, 28 Mar 2022 12:03:44 -0400 From: Tom Rini To: Sean Anderson Cc: Simon Glass , Linus Walleij , Liviu Dudau , Andre Przywara , U-Boot Mailing List Subject: Re: [PATCH v3 16/29] serial: Add semihosting driver Message-ID: <20220328160344.GA14476@bill-the-cat> References: <20220322205938.1721846-1-sean.anderson@seco.com> <20220322205938.1721846-17-sean.anderson@seco.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ikeVEW9yuYc//A+q" Content-Disposition: inline In-Reply-To: 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.5 at phobos.denx.de X-Virus-Status: Clean --ikeVEW9yuYc//A+q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 28, 2022 at 11:36:46AM -0400, Sean Anderson wrote: >=20 >=20 > On 3/28/22 2:35 AM, Simon Glass wrote: > > Hi Sean, > >=20 > > On Tue, 22 Mar 2022 at 15:00, Sean Anderson wr= ote: > >> > >> This adds a serial driver which uses semihosting calls to read and wri= te > >> to the host's console. For convenience, if CONFIG_DM_SERIAL is enabled, > >> we will instantiate a serial driver. This allows users to enable this > >> driver (which has no physical device) without modifying their device > >> trees or board files. We also implement a non-DM driver for SPL, or for > >> much faster output in U-Boot proper. > >> > >> There are three ways to print to the console: > >> > >> Method Baud > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D > >> smh_putc in a loop 170 > >> smh_puts 1600 > >> smh_write with :tt 20000 > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D > >> > >> These speeds were measured using a 175 character message with a J-Link > >> adapter. For reference, U-Boot typically prints around 2700 characters > >> during boot on this board. There are two major factors affecting the > >> speed of these functions. First, each breakpoint incurs a delay. Secon= d, > >> each debugger memory transaction incurs a delay. smh_putc has a > >> breakpoint and memory transaction for every character. smh_puts has one > >> breakpoint, but still has to use a transaction for every character. Th= is > >> is because we don't know the length up front, so OpenOCD has to check = if > >> each character is nul. smh_write has only one breakpoint and one memory > >> transfer. > >> > >> DM serial drivers can only implement a putc interface, so we are stuck > >> with the slowest API. Non-DM drivers can implement puts, which is vast= ly > >> more efficient. When the driver starts up, we try to open :tt. Since > >> this is an extension, this may fail. If it does, we fall back to > >> smh_puts. We don't check :semihosting-features, since there are > >> nonconforming implementations (OpenOCD) which don't implement it (but > >> *do* implement :tt). > >> > >> Some semihosting implementations (QEMU) don't handle READC properly. To > >> work around this, we try to use open/read (much like for stdin) if > >> possible. > >> > >> There is no non-blocking I/O available, so we don't implement pending. > >> This will cause __serial_tstc to always return true. If > >> CONFIG_SERIAL_RX_BUFFER is enabled, _serial_tstc will try and read > >> characters forever. To avoid this, we depend on this config being > >> disabled. > >> > >> Signed-off-by: Sean Anderson > >> --- > >> > >> (no changes since v2) > >> > >> Changes in v2: > >> - Fix baud numbers being off by 10 > >> - Fix typos in commit message > >> - Rename non-DM driver struct to match format of other drivers > >> > >> drivers/serial/Kconfig | 22 +++++ > >> drivers/serial/Makefile | 1 + > >> drivers/serial/serial.c | 2 + > >> drivers/serial/serial_semihosting.c | 147 ++++++++++++++++++++++++++++ > >> include/serial.h | 1 + > >> 5 files changed, 173 insertions(+) > >> create mode 100644 drivers/serial/serial_semihosting.c > >> > >=20 > > Reviewed-by: Simon Glass > >=20 > > But please can we drop the non-DM support? >=20 > Unfortunately, Layerscape does not support DM serial. I tried converting > it, but I ran into some unusual aborts. At the moment, I don't have time > to debug things further. And I thought that non-DM serial was ok for > SPL? It is OK for SPL, and it needs migration for non-SPL. Can you make another thread with your conversion-that-fails for layerscape please? --=20 Tom --ikeVEW9yuYc//A+q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmJB3F0ACgkQFHw5/5Y0 tyx8YAv+NdCARdg4IvHSc/8Hud3eHOBAqyDiSKnKBJVJvDCDATUNu1YCHY6Ov8LP FNmMBIXdBC1r9vTMKbLgE9B6K+HigLeGEk59TLKOpwqSCTaV/loU8/D/JBAm4c/9 mtFbF1J3scflWrNXyrzZ4Q5CIogOFhPCh8/4AGB8zQvbPXdi0T+WeS2UQ0t98TTz OVccKf5L4sNPhEP32Ps9pbnMizFDLOrgUQUBc5uISLt5/sGBJpVWKc+rItM5tr1b km1nS7lYBEqDH5QUW2vRAf5MwhnOtqHeYm1Q1aGloc+1NJSFQ0u8zQc/oPiHTcvN +68bXcMe+wniZzHp/oJEWTxQRTdpzhtSESjJE4hcvKlmgRRaJ6/BsKGfaoZd5Owl WtsDImnF/gwKPZ2vCuuXJlQRpVEqwk7UIsJhokWGY9n5mOzIXimnTlYhJ/1VdyL7 DmWMh/fds6+kbDZ8n4FtahCSDik6XLQehxEpruQvwN7y5wOkv10DdTwnYCJ0yDz0 QC5P/MPE =QonA -----END PGP SIGNATURE----- --ikeVEW9yuYc//A+q--