svn commit: r302570 - projects/powernv/powerpc/powernv

Nathan Whitehorn nwhitehorn at FreeBSD.org
Mon Jul 11 15:33:50 UTC 2016


Author: nwhitehorn
Date: Mon Jul 11 15:33:49 2016
New Revision: 302570
URL: https://svnweb.freebsd.org/changeset/base/302570

Log:
  Miscellaneous robustness improvements.

Modified:
  projects/powernv/powerpc/powernv/opal_console.c
  projects/powernv/powerpc/powernv/platform_powernv.c

Modified: projects/powernv/powerpc/powernv/opal_console.c
==============================================================================
--- projects/powernv/powerpc/powernv/opal_console.c	Mon Jul 11 15:32:37 2016	(r302569)
+++ projects/powernv/powerpc/powernv/opal_console.c	Mon Jul 11 15:33:49 2016	(r302570)
@@ -131,43 +131,39 @@ static struct {
 	char tmpbuf[16];
 	uint64_t size;
 	struct mtx mtx;
-} escapehatch;
+} opalcons_buffer;
 
 static void
 uart_opal_real_map_outbuffer(uint64_t *bufferp, uint64_t *lenp)
 {
 
-	if (!mtx_initialized(&escapehatch.mtx))
-		mtx_init(&escapehatch.mtx, "uart_opal", NULL,
+	if (!mtx_initialized(&opalcons_buffer.mtx))
+		mtx_init(&opalcons_buffer.mtx, "uart_opal", NULL,
 		    MTX_SPIN | MTX_QUIET | MTX_NOWITNESS);
 
 	if (!pmap_bootstrapped)
 		return;
 
-	if (TD_IS_IDLETHREAD(curthread)) {
-		escapehatch.size = *(uint64_t *)(*lenp) =
-		    min(sizeof(escapehatch.tmpbuf), *(uint64_t *)(*lenp));
-		mtx_lock_spin(&escapehatch.mtx);
-		memcpy(escapehatch.tmpbuf, (void *)(*bufferp),
-		    *(uint64_t *)(*lenp));
-		*bufferp = (uint64_t)escapehatch.tmpbuf;
-		*lenp = (uint64_t)&escapehatch.size;
-	}
+	mtx_lock_spin(&opalcons_buffer.mtx);
 
-	*bufferp = vtophys(*bufferp);
-	*lenp = vtophys(*lenp);
+	opalcons_buffer.size = *(uint64_t *)(*lenp) =
+	    min(sizeof(opalcons_buffer.tmpbuf), *(uint64_t *)(*lenp));
+	memcpy(opalcons_buffer.tmpbuf, (void *)(*bufferp),
+	    *(uint64_t *)(*lenp));
+	*bufferp = (uint64_t)opalcons_buffer.tmpbuf;
+	*lenp = (uint64_t)&opalcons_buffer.size;
 }
 	
 static void
-uart_opal_real_unmap_outbuffer(uint64_t lenp, uint64_t *origlen)
+uart_opal_real_unmap_outbuffer(uint64_t *len)
 {
 
-	if (!pmap_bootstrapped || !TD_IS_IDLETHREAD(curthread))
+	if (!pmap_bootstrapped)
 		return;
 
-	mtx_assert(&escapehatch.mtx, MA_OWNED);
-	*origlen = escapehatch.size;
-	mtx_unlock_spin(&escapehatch.mtx);
+	mtx_assert(&opalcons_buffer.mtx, MA_OWNED);
+	*len = opalcons_buffer.size;
+	mtx_unlock_spin(&opalcons_buffer.mtx);
 }
 
 static int
@@ -388,7 +384,7 @@ uart_opal_put(struct uart_opal_softc *sc
 
 		uart_opal_real_map_outbuffer(&obuf, &olen);
 		err = opal_call(OPAL_CONSOLE_WRITE, sc->vtermid, olen, obuf);
-		uart_opal_real_unmap_outbuffer(olen, &len);
+		uart_opal_real_unmap_outbuffer(&len);
 	} else {
 		uart_lock(&sc->sc_mtx);
 		if (bufsize > 12)
@@ -403,7 +399,7 @@ uart_opal_put(struct uart_opal_softc *sc
 
 		uart_opal_real_map_outbuffer(&obuf, &olen);
 		err = opal_call(OPAL_CONSOLE_WRITE, sc->vtermid, olen, obuf);
-		uart_opal_real_unmap_outbuffer(olen, &len);
+		uart_opal_real_unmap_outbuffer(&len);
 
 		uart_unlock(&sc->sc_mtx);
 
@@ -437,7 +433,11 @@ uart_opal_cngetc(struct consdev *cp)
 static void
 uart_opal_cnputc(struct consdev *cp, int c)
 {
+	static uint64_t events;
 	unsigned char ch = c;
+
+	if (cold)
+		opal_call(OPAL_POLL_EVENTS, &events); /* Clear FIFO if needed */
 	uart_opal_put(console_sc, &ch, 1);
 }
 

Modified: projects/powernv/powerpc/powernv/platform_powernv.c
==============================================================================
--- projects/powernv/powerpc/powernv/platform_powernv.c	Mon Jul 11 15:32:37 2016	(r302569)
+++ projects/powernv/powerpc/powernv/platform_powernv.c	Mon Jul 11 15:33:49 2016	(r302570)
@@ -129,8 +129,8 @@ powernv_attach(platform_t plat)
 	cpu_idle_hook = powernv_cpu_idle;
 	powernv_boot_pir = mfspr(SPR_PIR);
 
-	/* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */
-	mtspr(SPR_LPCR, LPCR_LPES);
+	/* Init CPU bits */
+	powernv_smp_ap_init(plat);
 
 	/* Set SLB count from device tree */
 	cpu = OF_peer(0);
@@ -425,6 +425,9 @@ powernv_reset(platform_t platform)
 static void
 powernv_smp_ap_init(platform_t platform)
 {
+
+	/* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */
+	mtspr(SPR_LPCR, LPCR_LPES);
 }
 
 static void


More information about the svn-src-projects mailing list