Module Name: src
Committed By: snj
Date: Tue Mar 24 20:16:58 UTC 2009
Modified Files:
src/sys/dev/scsipi [netbsd-5]: cd.c
Log Message:
Pull up following revision(s) (requested by reinoud in ticket #586):
sys/dev/scsipi/cd.c: revision 1.289
Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.
To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.
This fixes PR 40528
To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.283.4.1 src/sys/dev/scsipi/cd.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/dev/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.283 src/sys/dev/scsipi/cd.c:1.283.4.1
--- src/sys/dev/scsipi/cd.c:1.283 Fri Sep 5 22:25:39 2008
+++ src/sys/dev/scsipi/cd.c Tue Mar 24 20:16:58 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.283 2008/09/05 22:25:39 gmcgarry Exp $ */
+/* $NetBSD: cd.c,v 1.283.4.1 2009/03/24 20:16:58 snj Exp $ */
/*-
* Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.283 2008/09/05 22:25:39 gmcgarry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.283.4.1 2009/03/24 20:16:58 snj Exp $");
#include "rnd.h"
@@ -148,6 +148,7 @@
static int cd_get_parms(struct cd_softc *, int);
static int cd_load_toc(struct cd_softc *, int, struct cd_formatted_toc *, int);
static int cdreadmsaddr(struct cd_softc *, struct cd_formatted_toc *,int *);
+static int cdcachesync(struct scsipi_periph *periph, int flags);
static int dvd_auth(struct cd_softc *, dvd_authinfo *);
static int dvd_read_physical(struct cd_softc *, dvd_struct *);
@@ -549,6 +550,10 @@
cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
if (cd->sc_dk.dk_openmask == 0) {
+ /* synchronise caches on last close */
+ cdcachesync(periph, 0);
+
+ /* drain outstanding calls */
scsipi_wait_drain(periph);
scsipi_prevent(periph, SPAMR_ALLOW,