All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: dmukhin@ford.com, xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech,
	jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com,
	roger@xenproject.org, sstabellini@kernel.org,
	xakep.amatop@gmail.com, dmukhin@xen.org
Subject: Re: [PATCH v8 12/26] emul/ns16x50: implement FCR register (write-only)
Date: Thu, 19 Nov 2026 12:14:46 +0100	[thread overview]
Message-ID: <90615fba-8f94-4daa-b8d3-5a81f35fbf41@gmail.com> (raw)
In-Reply-To: <20261111194800.1070016-13-dmukhin@ford.com>



On 11/11/26 8:47 PM, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com>
> 
> Add emulation logic for FCR register.
> 
> Note, that does not hook FIFO interrupt moderation to the FIFO
> management code for simplicity.
> 
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
>   xen/common/emul/vuart/ns16x50.c | 33 +++++++++++++++++++++++++++++++++
>   1 file changed, 33 insertions(+)
> 
> diff --git a/xen/common/emul/vuart/ns16x50.c b/xen/common/emul/vuart/ns16x50.c
> index 8d3845a8a4cd..404e12311090 100644
> --- a/xen/common/emul/vuart/ns16x50.c
> +++ b/xen/common/emul/vuart/ns16x50.c
> @@ -436,6 +436,39 @@ static int ns16x50_io_write8(
>           }
>           break;
>   
> +    case UART_FCR: /* WO */
> +        if ( val & UART_FCR_RSRVD0 )
> +            ns16x50_warn(vdev, "FCR: attempt to set reserved bit: %x\n",
> +                         UART_FCR_RSRVD0);

Bits 4 and 5 are indeed reserved on the TL16C550C ("reserved for future
use"), so warning is fine; with a local mask (02/26) the two checks
collapse into one. Nit: %#x, as in the MCR warnings.

> +
> +        if ( val & UART_FCR_RSRVD1 )
> +            ns16x50_warn(vdev, "FCR: attempt to set reserved bit: %x\n",
> +                         UART_FCR_RSRVD1);
> +
> +        if ( val & UART_FCR_CLRX )
> +        {
> +            ns16x50_fifo_rx_reset(vdev);
> +            regs[UART_LSR] &= ~UART_LSR_DR;
> +        }

One of the places that keeps LSR.DR in sync by hand, see 10/26.

> +
> +        if ( val & UART_FCR_CLTX )
> +        {
> +            ns16x50_fifo_tx_reset(vdev);

The TX "FIFO" here is the line buffer of 11/26: everything in it has
already been reported to the guest as transmitted (THRE and TEMT are
set again right after each THR write), it just hasn't been printed yet
because no newline arrived. Resetting it discards output the guest
considers sent, e.g. a prompt without a trailing newline, whenever the
guest clears the TX FIFO. Linux does that in serial8250_do_startup()
and serial8250_do_shutdown(), via serial8250_clear_fifos(). Since TEMT
says the transmitter is empty, there is nothing left to clear from the
guest's point of view; I'd flush the buffer here instead of dropping
it (or leave it alone).
	
> +
> +            regs[UART_LSR] |= UART_LSR_THRE | UART_LSR_TEMT;
> +            vdev->thr_pending = true;
> +        }
> +
> +        if ( val & UART_FCR_ENABLE )
> +            val &= UART_FCR_ENABLE | UART_FCR_DMA |
> +                   UART_FCR_RTB0 | UART_FCR_RTB1;
> +        else
> +            val = 0;

The datasheet (SLLS177I, 7.7.2) also says for bit 0: "Changing this bit
clears the FIFOs", which isn't emulated: toggling FCR.ENABLE without
CLRX/CLTX leaves stale RX data in place. QEMU handles it by forcing
both clear bits when the enable bit changes:

     if ((val ^ s->fcr) & UART_FCR_FE) {
         val |= UART_FCR_XFR | UART_FCR_RFR;
     }

(and with the above, the TX part would then be a flush rather than a
drop.)

As for the mask, UART_FCR_RTB0 | UART_FCR_RTB1 is UART_FCR_TRG14, see
my reply to 02/26.

> +
> +        regs[UART_FCR] = val;
> +
> +        break;
> +
>       case UART_LCR:
>           regs[UART_LCR] = val;
>           break;

~ Oleksii


  reply	other threads:[~2026-11-19 11:15 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 19:47 [PATCH v8 00/26] x86: introduce NS16550-compatible UART emulator dmukhin
2026-11-11 19:47 ` [PATCH v8 01/26] emul/vuart: introduce framework for UART emulators dmukhin
2026-11-12 15:35   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 02/26] xen/8250-uart: update definitions dmukhin
2026-11-12 14:49   ` Jan Beulich
2026-11-12 16:34   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 03/26] x86: fixup dependencies for asm/x86_emulate.h dmukhin
2026-11-12 20:25   ` Oleksii Kurochko
2026-11-13  7:20     ` Jan Beulich
2026-11-11 19:47 ` [PATCH v8 04/26] emul/ns16x50: implement emulator stub dmukhin
2026-11-13 11:48   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 05/26] emul/ns16x50: implement DLL/DLM registers dmukhin
2026-11-11 19:47 ` [PATCH v8 06/26] emul/ns16x50: implement SCR register dmukhin
2026-11-16 10:42   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 07/26] emul/ns16x50: implement IER/IIR registers dmukhin
2026-11-16 16:59   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 08/26] emul/ns16x50: implement LCR/LSR registers dmukhin
2026-11-17 16:33   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 09/26] emul/ns16x50: implement MCR/MSR registers dmukhin
2026-11-17 18:32   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 10/26] emul/ns16x50: implement RBR register dmukhin
2026-11-18 16:28   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 11/26] emul/ns16x50: implement THR register dmukhin
2026-11-19 10:22   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 12/26] emul/ns16x50: implement FCR register (write-only) dmukhin
2026-11-19 11:14   ` Oleksii Kurochko [this message]
2026-11-11 19:47 ` [PATCH v8 13/26] emul/ns16550: implement dump_state() hook dmukhin
2026-11-19 19:43   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 14/26] emul/vuart: add global UART emulator configuration knob dmukhin
2026-11-20  9:37   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 15/26] emul/ns16x50: enable emulator dmukhin
2026-11-20  9:45   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 16/26] emul/ns16x50: add Kconfig options dmukhin
2026-11-20  9:53   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 17/26] x86/domain: enable per-domain I/O port bitmaps dmukhin
2026-11-11 19:47 ` [PATCH v8 18/26] emul/ns16x50: resolve physical I/O port sharing dmukhin
2026-11-20 10:17   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 19/26] xen/domain: allocate d->irq_caps before arch-specific initialization dmukhin
2026-11-11 19:47 ` [PATCH v8 20/26] emul/ns16x50: resolve physical IRQ sharing dmukhin
2026-11-11 19:47 ` [PATCH v8 21/26] emul/ns16x50: implement IRQ emulation via vIOAPIC dmukhin
2026-11-11 19:47 ` [PATCH v8 22/26] MAINTAINERS: add myself as vUART framework maintainer dmukhin
2026-11-20 10:23   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 23/26] docs/fusa: add NS16x50 UART requirements for x86 dmukhin
2026-11-19 17:10   ` Halder, Ayan Kumar
2026-11-19 22:22     ` Stefano Stabellini
2026-11-20 11:17       ` Halder, Ayan Kumar
2026-11-20 10:26   ` Oleksii Kurochko
2026-11-20 11:16     ` Halder, Ayan Kumar
2026-11-11 19:47 ` [PATCH v8 24/26] ci: add initial NS16550-compatible XTF test dmukhin
2026-11-20 10:34   ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 25/26] ci: add smoke NS16550-compatible PVH Linux test dmukhin
2026-11-11 19:48 ` [PATCH v8 26/26] ci: do not merge: test dmukhin
2026-11-12 14:53 ` [PATCH v8 00/26] x86: introduce NS16550-compatible UART emulator Oleksii Kurochko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90615fba-8f94-4daa-b8d3-5a81f35fbf41@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=dmukhin@ford.com \
    --cc=dmukhin@xen.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger@xenproject.org \
    --cc=sstabellini@kernel.org \
    --cc=xakep.amatop@gmail.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.