Re: [PATCH v3 13/14] serial: liteuart: add IRQ support for the TX path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 15 Nov 2022, Gabriel L. Somlo wrote:

> On Tue, Nov 15, 2022 at 06:14:50PM +0200, Ilpo Järvinen wrote:
> > On Sat, 12 Nov 2022, Gabriel Somlo wrote:
> > 
> > > Modify the TX path to operate in an IRQ-compatible way, while
> > > maintaining support for polling mode via the poll timer.
> > > 
> > > Signed-off-by: Gabriel Somlo <gsomlo@xxxxxxxxx>
> > > ---
> > >  drivers/tty/serial/liteuart.c | 67 ++++++++++++++++++++++++-----------
> > >  1 file changed, 47 insertions(+), 20 deletions(-)
> > > 
> > > diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> > > index e30adb30277f..307c27398e30 100644
> > > --- a/drivers/tty/serial/liteuart.c
> > > +++ b/drivers/tty/serial/liteuart.c

> > > +	if (port->irq) {
> > > +		u8 irq_mask = litex_read8(port->membase + OFF_EV_ENABLE);
> > > +		litex_write8(port->membase + OFF_EV_ENABLE, irq_mask & ~EV_TX);
> > 
> > If you put irq_mask into liteuart_port you wouldn't need to read it 
> > back here?
> 
> So, instead of `bool poll_tx_started` I should just keep a copy of the
> irq_mask there, and take `&port->lock` whenever I need to *both* update
> the mask *and* write it out to the actual device register?

I was mostly thinking of storing EV_RX there but then it could be derived 
from port->irq that is checked by all paths already.

> > > +	if (unlikely(port->x_char)) {
> > > +		litex_write8(port->membase + OFF_RXTX, port->x_char);
> > > +		port->x_char = 0;
> > > +		port->icount.tx++;
> > > +		return;
> > > +	}
> > > +
> > > +	while (!litex_read8(port->membase + OFF_TXFULL)) {
> > > +		if (xmit->head == xmit->tail)
> > 
> > There exists a helper for this condition.
> 
> Is that in the released linus tree, or still only in tty-next?

uart_circ_empty() has been around for ages.

> > > +	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
> > > +		uart_write_wakeup(port);
> > > +
> > > +	if (uart_circ_empty(xmit))
> > > +		liteuart_stop_tx(port);
> > > +}
> > 
> > You might want to check if you can generate this whole function with 
> > Jiri's tx helpers (IIRC, they're only in tty-next tree currently).
> 
> Looks like I should switch to tty-next for this whole series, which
> makes sense, since it's a tty I'm working on :)
> 
> I'll rebase on top of that before I send out v4, hopefully later this
> afternoon.

Ok.

As I now looked it up, Jiri's tx helpers is 
8275b48b278096edc1e3ea5aa9cf946a10022f79 and you'll find some example 
conversions in the changes following it.


-- 
 i.

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux