shithub: riscv

Download patch

ref: 5cecf46e8716d5f2424f162a8caca52677c17ee1
parent: 34821e8b4c4b9ca6fba20f0366fc17894a0c330e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 12 15:47:23 EST 2023

devuart: handle software flow control (XON/XOFF) in devuart alone

No need for Physuart.kick() to check Uart.blocked state,
already handled by devuart().

--- a/sys/src/9/arm64/uartqemu.c
+++ b/sys/src/9/arm64/uartqemu.c
@@ -173,8 +173,6 @@
 {
 	u32int *reg = (u32int*)uart->regs;
 
-	if(uart->blocked)
-		return;
 	coherence();
 	while((reg[FR] & TXFF) == 0){
 		if(uart->op >= uart->oe && uartstageoutput(uart) == 0)
--- a/sys/src/9/bcm/uartmini.c
+++ b/sys/src/9/bcm/uartmini.c
@@ -121,10 +121,8 @@
 {
 	u32int *ap;
 
-	ap = (u32int*)uart->regs;
-	if(uart->blocked)
-		return;
 	coherence();
+	ap = (u32int*)uart->regs;
 	while(ap[MuLsr] & TxRdy){
 		if(uart->op >= uart->oe && uartstageoutput(uart) == 0)
 			break;
--- a/sys/src/9/bcm/uartpl011.c
+++ b/sys/src/9/bcm/uartpl011.c
@@ -173,8 +173,6 @@
 {
 	u32int *reg = (u32int*)uart->regs;
 
-	if(uart->blocked)
-		return;
 	coherence();
 	while((reg[FR] & TXFF) == 0){
 		if(uart->op >= uart->oe && uartstageoutput(uart) == 0)
--- a/sys/src/9/cycv/uartcycv.c
+++ b/sys/src/9/cycv/uartcycv.c
@@ -70,8 +70,6 @@
 	Ctlr *ct;
 	int i;
 
-	if(uart->blocked)
-		return;
 	ct = uart->regs;
 	if((ct->r[LSR] & LSR_THRE) == 0)
 		return;
@@ -102,7 +100,7 @@
 			}
 			break;
 		case 2:
-			vuartkick(uart);
+			uartkick(uart);
 			break;
 		default:
 			return;
--- a/sys/src/9/imx8/uartimx.c
+++ b/sys/src/9/imx8/uartimx.c
@@ -167,8 +167,6 @@
 	u32int *regs = (u32int*)u->regs;
 
 	while(u->op < u->oe || uartstageoutput(u)){
-		if(u->blocked)
-			break;
 		if((regs[USR1] & SR1_TRDY) == 0){
 			regs[UCR1] |= CR1_TRDYEN;
 			return;
--- a/sys/src/9/kw/uartkw.c
+++ b/sys/src/9/kw/uartkw.c
@@ -195,9 +195,6 @@
 	UartReg *regs = ctlr->regs;
 	int i;
 
-	if(uart->cts == 0 || uart->blocked)
-		return;
-
 	for(i = 0; i < 16; i++) {
 		if((regs->lsr & LSRthre) == 0 ||
 		    uart->op >= uart->oe && uartstageoutput(uart) == 0)
--- a/sys/src/9/mt7688/uarti8250.c
+++ b/sys/src/9/mt7688/uarti8250.c
@@ -9,11 +9,6 @@
 #include "fns.h"
 #include "io.h"
 
-enum {
-	Pollstuckoutput = 1,
-};
-
-
 enum {					/* registers */
 	Rbr		= 0,		/* Receiver Buffer (RO) */
 	Thr		= 0,		/* Transmitter Holding (WO) */
@@ -443,9 +438,6 @@
 {
 	int i;
 	Ctlr *ctlr;
-
-	if(/* uart->cts == 0 || */ uart->blocked)
-		return;
 
 	/* nothing more to send? then disable xmit intr */
 	ctlr = uart->regs;
--- a/sys/src/9/mtx/uarti8250.c
+++ b/sys/src/9/mtx/uarti8250.c
@@ -419,7 +419,7 @@
 	int i;
 	Ctlr *ctlr;
 
-	if(uart->cts == 0 || uart->blocked)
+	if(uart->cts == 0)
 		return;
 
 	/*
--- a/sys/src/9/omap/uarti8250.c
+++ b/sys/src/9/omap/uarti8250.c
@@ -467,9 +467,6 @@
 	int i;
 	Ctlr *ctlr;
 
-	if(/* uart->cts == 0 || */ uart->blocked)
-		return;
-
 	/* nothing more to send? then disable xmit intr */
 	ctlr = uart->regs;
 	if (uart->op >= uart->oe && qlen(uart->oq) == 0 &&
--- a/sys/src/9/pc/uartaxp.c
+++ b/sys/src/9/pc/uartaxp.c
@@ -545,7 +545,7 @@
 	Ccb *ccb;
 	uchar *ep, *mem, *rp, *wp, *bp;
 
-	if(uart->cts == 0 || uart->blocked)
+	if(uart->cts == 0)
 		return;
 
 	cc = uart->regs;
--- a/sys/src/9/pc/uarti8250.c
+++ b/sys/src/9/pc/uarti8250.c
@@ -438,7 +438,7 @@
 	int i;
 	Ctlr *ctlr;
 
-	if(uart->cts == 0 || uart->blocked)
+	if(uart->cts == 0)
 		return;
 
 	/*
--- a/sys/src/9/port/devuart.c
+++ b/sys/src/9/port/devuart.c
@@ -70,6 +70,7 @@
 
 	/* assume we can send */
 	p->cts = 1;
+	p->blocked = 0;
 	p->ctsbackoff = 0;
 
 	if(p->bits == 0)
@@ -655,6 +656,9 @@
 {
 	int n;
 
+	if(!p->enabled || p->blocked)
+		return 0;
+
 	n = qconsume(p->oq, p->ostage, Stagesize);
 	if(n <= 0)
 		return 0;
@@ -779,7 +783,7 @@
 		if(p->ctsbackoff){
 			ilock(&p->tlock);
 			if(p->ctsbackoff){
-				if(--(p->ctsbackoff) == 0)
+				if(--(p->ctsbackoff) == 0 && !p->blocked)
 					(*p->phys->kick)(p);
 			}
 			iunlock(&p->tlock);
--- a/sys/src/9/ppc/uartsaturn.c
+++ b/sys/src/9/ppc/uartsaturn.c
@@ -278,9 +278,6 @@
 	Saturnuart *su;
 	int i;
 
-	if(uart->blocked)
-		return;
-
 	su = ((UartData*)uart->regs)->su;
 	if((su->iir & Iir_txempty) == 0)
 		return;
--- a/sys/src/9/ppc/uartsmc.c
+++ b/sys/src/9/ppc/uartsmc.c
@@ -393,9 +393,6 @@
 	UartData *ud;
 	int i;
 
-	if(uart->blocked)
-		return;
-
 	ud = uart->regs;
 	txb = ud->txb;
 
--- a/sys/src/9/teg2/uarti8250.c
+++ b/sys/src/9/teg2/uarti8250.c
@@ -438,9 +438,6 @@
 	int i;
 	Ctlr *ctlr;
 
-	if(/* uart->cts == 0 || */ uart->blocked)
-		return;
-
 	/* nothing more to send? then disable xmit intr */
 	ctlr = uart->regs;
 	if (uart->op >= uart->oe && qlen(uart->oq) == 0 &&
--- a/sys/src/9/zynq/uartzynq.c
+++ b/sys/src/9/zynq/uartzynq.c
@@ -69,8 +69,6 @@
 	Ctlr *ct;
 	int i;
 
-	if(uart->blocked)
-		return;
 	ct = uart->regs;
 	for(i = 0; i < 128; i++){
 		if((ct->r[CHANSTAT] & TXFULL) != 0)
@@ -99,7 +97,7 @@
 			uartrecv(uart, c);
 		}
 	if((fl & TXEMPTY) != 0)
-		zuartkick(uart);
+		uartkick(uart);
 }
 
 static void