From 82bb1c2ff86f7aeab4373d451b9a9994d5652342 Mon Sep 17 00:00:00 2001 From: simonb Date: Mon, 11 Aug 2008 06:43:37 +0000 Subject: [PATCH] Add a flags argument to the ld(4) flush handlers, and call these with a "poll" flag when called from ld_shutdown(). This is the infrastructure part of kern/38655 - in itself it doesn't fix the panic referenced in that PR. XXX: At least ld_twa.c and perhaps ld_iop.c and ld_icp.c need to check for this new poll flag and do something useful. --- sys/dev/i2o/ld_iop.c | 8 ++++---- sys/dev/ic/ld_icp.c | 8 ++++---- sys/dev/ld.c | 12 ++++++------ sys/dev/ldvar.h | 8 ++++++-- sys/dev/pci/ld_twa.c | 8 ++++---- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/sys/dev/i2o/ld_iop.c b/sys/dev/i2o/ld_iop.c index 1e74d77b4968..63bfe5846e9b 100644 --- a/sys/dev/i2o/ld_iop.c +++ b/sys/dev/i2o/ld_iop.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld_iop.c,v 1.29 2008/05/10 14:52:55 simonb Exp $ */ +/* $NetBSD: ld_iop.c,v 1.30 2008/08/11 06:43:37 simonb Exp $ */ /*- * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_iop.c,v 1.29 2008/05/10 14:52:55 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_iop.c,v 1.30 2008/08/11 06:43:37 simonb Exp $"); #include "rnd.h" @@ -78,7 +78,7 @@ static void ld_iop_adjqparam(struct device *, int); static void ld_iop_attach(struct device *, struct device *, void *); static int ld_iop_detach(struct device *, int); static int ld_iop_dump(struct ld_softc *, void *, int, int); -static int ld_iop_flush(struct ld_softc *); +static int ld_iop_flush(struct ld_softc *, int); static void ld_iop_intr(struct device *, struct iop_msg *, void *); static void ld_iop_intr_event(struct device *, struct iop_msg *, void *); static int ld_iop_match(struct device *, struct cfdata *, void *); @@ -446,7 +446,7 @@ ld_iop_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) } static int -ld_iop_flush(struct ld_softc *ld) +ld_iop_flush(struct ld_softc *ld, int flags) { struct iop_msg *im; struct iop_softc *iop; diff --git a/sys/dev/ic/ld_icp.c b/sys/dev/ic/ld_icp.c index 1928cbc8fad3..a20863f06270 100644 --- a/sys/dev/ic/ld_icp.c +++ b/sys/dev/ic/ld_icp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld_icp.c,v 1.20 2008/04/28 20:23:50 martin Exp $ */ +/* $NetBSD: ld_icp.c,v 1.21 2008/08/11 06:43:38 simonb Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_icp.c,v 1.20 2008/04/28 20:23:50 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_icp.c,v 1.21 2008/08/11 06:43:38 simonb Exp $"); #include "rnd.h" @@ -70,7 +70,7 @@ int ld_icp_detach(struct device *, int); int ld_icp_dobio(struct ld_icp_softc *, void *, int, int, int, struct buf *); int ld_icp_dump(struct ld_softc *, void *, int, int); -int ld_icp_flush(struct ld_softc *); +int ld_icp_flush(struct ld_softc *, int); void ld_icp_intr(struct icp_ccb *); int ld_icp_match(struct device *, struct cfdata *, void *); int ld_icp_start(struct ld_softc *, struct buf *); @@ -265,7 +265,7 @@ ld_icp_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) } int -ld_icp_flush(struct ld_softc *ld) +ld_icp_flush(struct ld_softc *ld, int flags) { struct ld_icp_softc *sc; struct icp_softc *icp; diff --git a/sys/dev/ld.c b/sys/dev/ld.c index 8aa3fe99170f..0dc73ec21e37 100644 --- a/sys/dev/ld.c +++ b/sys/dev/ld.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld.c,v 1.61 2008/08/01 16:09:45 ws Exp $ */ +/* $NetBSD: ld.c,v 1.62 2008/08/11 06:43:37 simonb Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.61 2008/08/01 16:09:45 ws Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.62 2008/08/11 06:43:37 simonb Exp $"); #include "rnd.h" @@ -253,7 +253,7 @@ ldenddetach(struct ld_softc *sc) #if 0 /* Flush the device's cache. */ if (sc->sc_flush != NULL) - if ((*sc->sc_flush)(sc) != 0) + if ((*sc->sc_flush)(sc, 0) != 0) aprint_error_dev(&sc->sc_dv, "unable to flush cache\n"); #endif mutex_destroy(&sc->sc_mutex); @@ -265,7 +265,7 @@ ld_shutdown(device_t dev, int flags) { struct ld_softc *sc = device_private(dev); - if (sc->sc_flush != NULL && (*sc->sc_flush)(sc) != 0) { + if (sc->sc_flush != NULL && (*sc->sc_flush)(sc, LDFL_POLL) != 0) { printf("%s: unable to flush cache\n", device_xname(dev)); return false; } @@ -345,7 +345,7 @@ ldclose(dev_t dev, int flags, int fmt, struct lwp *l) sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; if (sc->sc_dk.dk_openmask == 0) { - if (sc->sc_flush != NULL && (*sc->sc_flush)(sc) != 0) + if (sc->sc_flush != NULL && (*sc->sc_flush)(sc, 0) != 0) aprint_error_dev(&sc->sc_dv, "unable to flush cache\n"); if ((sc->sc_flags & LDF_KLABEL) == 0) sc->sc_flags &= ~LDF_VLABEL; @@ -487,7 +487,7 @@ ldioctl(dev_t dev, u_long cmd, void *addr, int32_t flag, struct lwp *l) if ((flag & FWRITE) == 0) error = EBADF; else if (sc->sc_flush) - error = (*sc->sc_flush)(sc); + error = (*sc->sc_flush)(sc, 0); else error = 0; /* XXX Error out instead? */ break; diff --git a/sys/dev/ldvar.h b/sys/dev/ldvar.h index 9d161b9af818..f04bec7953b6 100644 --- a/sys/dev/ldvar.h +++ b/sys/dev/ldvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ldvar.h,v 1.13 2008/04/28 20:23:46 martin Exp $ */ +/* $NetBSD: ldvar.h,v 1.14 2008/08/11 06:43:37 simonb Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -57,10 +57,11 @@ struct ld_softc { int sc_maxqueuecnt; /* maximum h/w queue depth */ int (*sc_dump)(struct ld_softc *, void *, int, int); - int (*sc_flush)(struct ld_softc *); + int (*sc_flush)(struct ld_softc *, int); int (*sc_start)(struct ld_softc *, struct buf *); }; +/* sc_flags */ #define LDF_ENABLED 0x001 /* device enabled */ #define LDF_WLABEL 0x008 /* label is writable */ #define LDF_LABELLING 0x010 /* writing label */ @@ -69,6 +70,9 @@ struct ld_softc { #define LDF_KLABEL 0x080 /* keep label on close */ #define LDF_VLABEL 0x100 /* label is valid */ +/* sc_flush() flags */ +#define LDFL_POLL 0x001 /* poll for completion */ + int ldadjqparam(struct ld_softc *, int); void ldattach(struct ld_softc *); int ldbegindetach(struct ld_softc *, int); diff --git a/sys/dev/pci/ld_twa.c b/sys/dev/pci/ld_twa.c index afae7b8f6943..29d9d2b0ef38 100644 --- a/sys/dev/pci/ld_twa.c +++ b/sys/dev/pci/ld_twa.c @@ -1,5 +1,5 @@ /* $wasabi: ld_twa.c,v 1.9 2006/02/14 18:44:37 jordanr Exp $ */ -/* $NetBSD: ld_twa.c,v 1.11 2008/05/07 17:47:20 joerg Exp $ */ +/* $NetBSD: ld_twa.c,v 1.12 2008/08/11 06:43:38 simonb Exp $ */ /*- * Copyright (c) 2000, 2001, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_twa.c,v 1.11 2008/05/07 17:47:20 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_twa.c,v 1.12 2008/08/11 06:43:38 simonb Exp $"); #include "rnd.h" @@ -81,7 +81,7 @@ static int ld_twa_detach(struct device *, int); static int ld_twa_dobio(struct ld_twa_softc *, void *, size_t, daddr_t, struct buf *); static int ld_twa_dump(struct ld_softc *, void *, int, int); -static int ld_twa_flush(struct ld_softc *); +static int ld_twa_flush(struct ld_softc *, int); static void ld_twa_handler(struct twa_request *); static int ld_twa_match(struct device *, struct cfdata *, void *); static int ld_twa_start(struct ld_softc *, struct buf *); @@ -243,7 +243,7 @@ ld_twa_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) static int -ld_twa_flush(struct ld_softc *ld) +ld_twa_flush(struct ld_softc *ld, int flags) { int s, rv = 0; struct twa_request *tr;