Module Name:    src
Committed By:   martin
Date:           Sat Feb 21 18:28:13 UTC 2015

Modified Files:
        src/sys/arch/sparc64/dev [netbsd-7]: lom.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #539):
        sys/arch/sparc64/dev/lom.c: revision 1.14
Fix queue handling to make the watchdog timer actually works on
netbsd-7 if it is configured by wdogctl=YES in rc.conf, and also
avoid a hangup duaring shutdown.
- don't put an entry which is already in the queue.
- read a first entry properly to handle the queue.
- check the lom status if input buffer is empty before writing.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.4.1 src/sys/arch/sparc64/dev/lom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/dev/lom.c
diff -u src/sys/arch/sparc64/dev/lom.c:1.13 src/sys/arch/sparc64/dev/lom.c:1.13.4.1
--- src/sys/arch/sparc64/dev/lom.c:1.13	Tue Feb 25 18:30:08 2014
+++ src/sys/arch/sparc64/dev/lom.c	Sat Feb 21 18:28:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lom.c,v 1.13 2014/02/25 18:30:08 pooka Exp $	*/
+/*	$NetBSD: lom.c,v 1.13.4.1 2015/02/21 18:28:13 martin Exp $	*/
 /*	$OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $	*/
 /*
  * Copyright (c) 2009 Mark Kettenis
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.13 2014/02/25 18:30:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.13.4.1 2015/02/21 18:28:13 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -600,7 +600,15 @@ lom1_write_polled(struct lom_softc *sc, 
 static void
 lom1_queue_cmd(struct lom_softc *sc, struct lom_cmd *lc)
 {
+	struct lom_cmd *lcp;
+
 	mutex_enter(&sc->sc_queue_mtx);
+	TAILQ_FOREACH(lcp, &sc->sc_queue, lc_next) {
+		if (lcp == lc) {
+			mutex_exit(&sc->sc_queue_mtx);
+			return;
+		}
+	}
 	TAILQ_INSERT_TAIL(&sc->sc_queue, lc, lc_next);
 	if (sc->sc_state == LOM_STATE_IDLE) {
 		sc->sc_state = LOM_STATE_CMD;
@@ -818,13 +826,21 @@ lom2_write_polled(struct lom_softc *sc, 
 static void
 lom2_queue_cmd(struct lom_softc *sc, struct lom_cmd *lc)
 {
+	struct lom_cmd *lcp;
 	uint8_t str;
 
 	mutex_enter(&sc->sc_queue_mtx);
+	TAILQ_FOREACH(lcp, &sc->sc_queue, lc_next) {
+		if (lcp == lc) {
+			mutex_exit(&sc->sc_queue_mtx);
+			return;
+		}
+	}
 	TAILQ_INSERT_TAIL(&sc->sc_queue, lc, lc_next);
 	if (sc->sc_state == LOM_STATE_IDLE) {
 		str = bus_space_read_1(sc->sc_iot, sc->sc_ioh, LOM2_STATUS);
 		if ((str & LOM2_STATUS_IBF) == 0) {
+			lc = TAILQ_FIRST(&sc->sc_queue);
 			bus_space_write_1(sc->sc_iot, sc->sc_ioh,
 			    LOM2_CMD, lc->lc_cmd);
 			sc->sc_state = LOM_STATE_DATA;
@@ -852,9 +868,11 @@ lom2_intr(void *arg)
 	}
 
 	if (lc->lc_cmd & LOM_IDX_WRITE) {
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-		    LOM2_DATA, lc->lc_data);
-		lc->lc_cmd &= ~LOM_IDX_WRITE;
+		if ((str & LOM2_STATUS_IBF) == 0) {
+			bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+			    LOM2_DATA, lc->lc_data);
+			lc->lc_cmd &= ~LOM_IDX_WRITE;
+		}
 		mutex_exit(&sc->sc_queue_mtx);
 		return (1);
 	}
@@ -871,6 +889,7 @@ lom2_intr(void *arg)
 	if (!TAILQ_EMPTY(&sc->sc_queue)) {
 		str = bus_space_read_1(sc->sc_iot, sc->sc_ioh, LOM2_STATUS);
 		if ((str & LOM2_STATUS_IBF) == 0) {
+			lc = TAILQ_FIRST(&sc->sc_queue);
 			bus_space_write_1(sc->sc_iot, sc->sc_ioh,
 			    LOM2_CMD, lc->lc_cmd);
 			sc->sc_state = LOM_STATE_DATA;

Reply via email to