Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Nov 2019 21:03:08 +0000 (UTC)
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354310 - head/sys/dev/ichiic
Message-ID:  <201911032103.xA3L38F2071748@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wulf
Date: Sun Nov  3 21:03:07 2019
New Revision: 354310
URL: https://svnweb.freebsd.org/changeset/base/354310

Log:
  [ig4] Rewrite ig4iic_write routine to use TX_EMPTY status flag
  
  rather than TX_NOTFULL. It makes possible interrupt utilization while
  waiting for empty space in TX FIFO.

Modified:
  head/sys/dev/ichiic/ig4_iic.c

Modified: head/sys/dev/ichiic/ig4_iic.c
==============================================================================
--- head/sys/dev/ichiic/ig4_iic.c	Sun Nov  3 21:01:53 2019	(r354309)
+++ head/sys/dev/ichiic/ig4_iic.c	Sun Nov  3 21:03:07 2019	(r354310)
@@ -384,21 +384,31 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_
     bool repeated_start, bool stop)
 {
 	uint32_t cmd;
-	uint16_t i;
+	int sent = 0;
+	int burst, target;
 	int error;
 
 	if (len == 0)
 		return (0);
 
-	cmd = repeated_start ? IG4_DATA_RESTART : 0;
-	for (i = 0; i < len; i++) {
-		error = wait_status(sc, IG4_STATUS_TX_NOTFULL);
-		if (error)
-			break;
-		cmd |= buf[i];
-		cmd |= stop && i == len - 1 ? IG4_DATA_STOP : 0;
-		reg_write(sc, IG4_REG_DATA_CMD, cmd);
-		cmd = 0;
+	while (sent < len) {
+		burst = sc->cfg.txfifo_depth -
+		    (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK);
+		target = MIN(sent + burst, (int)len);
+		while(sent < target) {
+			cmd = buf[sent];
+			if (repeated_start && sent == 0)
+				cmd |= IG4_DATA_RESTART;
+			if (stop && sent == len - 1)
+				cmd |= IG4_DATA_STOP;
+			reg_write(sc, IG4_REG_DATA_CMD, cmd);
+			sent++;
+		}
+		if (sent < len) {
+			error = wait_status(sc, IG4_STATUS_TX_EMPTY);
+			if (error)
+				break;
+		}
 	}
 
 	(void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911032103.xA3L38F2071748>