Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic add debug code to check for completion queue corr...
details: https://anonhg.NetBSD.org/src/rev/50d44f152c43
branches: trunk
changeset: 818610:50d44f152c43
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Oct 19 19:34:31 2016 +0000
description:
add debug code to check for completion queue corruption
diffstat:
sys/dev/ic/nvme.c | 25 ++++++++++++++++++++++---
sys/dev/ic/nvmevar.h | 3 ++-
2 files changed, 24 insertions(+), 4 deletions(-)
diffs (78 lines):
diff -r 784593ed2213 -r 50d44f152c43 sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Wed Oct 19 19:31:23 2016 +0000
+++ b/sys/dev/ic/nvme.c Wed Oct 19 19:34:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme.c,v 1.17 2016/10/19 19:31:23 jdolecek Exp $ */
+/* $NetBSD: nvme.c,v 1.18 2016/10/19 19:34:31 jdolecek Exp $ */
/* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.17 2016/10/19 19:31:23 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.18 2016/10/19 19:34:31 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1069,6 +1069,18 @@
q->q_cq_phase ^= NVME_CQE_PHASE;
}
+#ifdef DEBUG
+ /*
+ * If we get spurious completion notification, something
+ * is seriously hosed up. Very likely DMA to some random
+ * memory place happened, so just bail out.
+ */
+ if ((intptr_t)ccb->ccb_cookie == NVME_CCB_FREE) {
+ panic("%s: invalid ccb detected",
+ device_xname(sc->sc_dev));
+ /* NOTREACHED */
+ }
+#endif
rv = 1;
/*
@@ -1314,8 +1326,12 @@
mutex_enter(&q->q_ccb_mtx);
ccb = SIMPLEQ_FIRST(&q->q_ccb_list);
- if (ccb != NULL)
+ if (ccb != NULL) {
SIMPLEQ_REMOVE_HEAD(&q->q_ccb_list, ccb_entry);
+#ifdef DEBUG
+ ccb->ccb_cookie = NULL;
+#endif
+ }
mutex_exit(&q->q_ccb_mtx);
return ccb;
@@ -1326,6 +1342,9 @@
{
mutex_enter(&q->q_ccb_mtx);
+#ifdef DEBUG
+ ccb->ccb_cookie = (void *)NVME_CCB_FREE;
+#endif
SIMPLEQ_INSERT_HEAD(&q->q_ccb_list, ccb, ccb_entry);
mutex_exit(&q->q_ccb_mtx);
}
diff -r 784593ed2213 -r 50d44f152c43 sys/dev/ic/nvmevar.h
--- a/sys/dev/ic/nvmevar.h Wed Oct 19 19:31:23 2016 +0000
+++ b/sys/dev/ic/nvmevar.h Wed Oct 19 19:34:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmevar.h,v 1.7 2016/10/19 19:31:23 jdolecek Exp $ */
+/* $NetBSD: nvmevar.h,v 1.8 2016/10/19 19:34:31 jdolecek Exp $ */
/* $OpenBSD: nvmevar.h,v 1.8 2016/04/14 11:18:32 dlg Exp $ */
/*
@@ -53,6 +53,7 @@
/* command context */
uint16_t ccb_id;
void *ccb_cookie;
+#define NVME_CCB_FREE 0xbeefdeed
void (*ccb_done)(struct nvme_queue *,
struct nvme_ccb *, struct nvme_cqe *);
Home |
Main Index |
Thread Index |
Old Index