From owner-freebsd-bugs Sun Nov 30 15:40:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id PAA14382 for bugs-outgoing; Sun, 30 Nov 1997 15:40:05 -0800 (PST) (envelope-from owner-freebsd-bugs) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id PAA14373; Sun, 30 Nov 1997 15:40:02 -0800 (PST) (envelope-from gnats) Resent-Date: Sun, 30 Nov 1997 15:40:02 -0800 (PST) Resent-Message-Id: <199711302340.PAA14373@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, wilko@yedi.iaf.nl Received: from iafnl.es.iaf.nl (uucp@iafnl.es.iaf.nl [195.108.17.20]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id PAA14200 for ; Sun, 30 Nov 1997 15:35:25 -0800 (PST) (envelope-from wilko@yedi.iaf.nl) Received: by iafnl.es.iaf.nl with UUCP id AA19170 (5.67b/IDA-1.5 for FreeBSD-gnats-submit@freebsd.org); Mon, 1 Dec 1997 00:35:29 +0100 Received: (from wilko@localhost) by yedi.iaf.nl (8.8.5/8.6.12) id AAA28132; Mon, 1 Dec 1997 00:25:23 +0100 (MET) Message-Id: <199711302325.AAA28132@yedi.iaf.nl> Date: Mon, 1 Dec 1997 00:25:23 +0100 (MET) From: wilko@yedi.iaf.nl Reply-To: wilko@yedi.iaf.nl To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/5181: patch to allow slow scsi cdroms more time to startup Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 5181 >Category: kern >Synopsis: patch to allow slow scsi cdroms more time to startup >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Nov 30 15:40:01 PST 1997 >Last-Modified: >Originator: Wilko Bulte >Organization: Private FreeBSD site - Arnhem, The Netherlands >Release: FreeBSD 2.2.1-RELEASE i386 >Environment: FreeBSD 2.2.1-R but also applicable to FreeBSD-2.2.5R Toshiba XM5701 12x SCSI cdrom connected to a NCR810 >Description: Some SCSI cdroms are slow to react to a start_unit command after the media has been changed. While getting up to speed, they report 'not ready'. This makes the cd_open() fail immediately with ENXIO, resulting in misleading 'device not configured' errors when 'mount' is run. >How-To-Repeat: Change media and immediately perform mount of the cdrom. >Fix: Below is a diff -c based on the 2.2.1R sources for /sys/scsi/cd.c that fixes the issue: *** cd.c.orig Wed Nov 26 20:18:54 1997 --- cd.c Mon Dec 1 00:12:05 1997 *************** *** 246,251 **** --- 246,252 ---- errval errcode = 0; u_int32_t unit, part; struct scsi_data *cd; + int n = 0; unit = CDUNIT(dev); part = PARTITION(dev); *************** *** 285,295 **** --- 286,312 ---- scsi_start_unit(sc_link, CD_START); SC_DEBUG(sc_link, SDEV_DB3, ("'start' attempted ")); sc_link->flags |= SDEV_OPEN; /* unit attn errors are now errors */ + + /* Some drives e.g. Toshiba's tend to take a long time to become ready + * after a disc swap and report 'Not Ready' while doing so. + * They should have reported 'Unit In The Process Of Getting Ready' + * but alas they don't. Attempts to e.g. mount during this period + * will result in device not configured due to ENXIO. The code below + * gives them some time to come up. + */ + while ((scsi_test_unit_ready(sc_link, SCSI_SILENT) != 0) && + (n != 12)) { + tsleep(cd, PRIBIO | PCATCH, "cdrdy", hz); + n++; + } + + /* It really should be ready by now. If not, it's time to give up */ if (scsi_test_unit_ready(sc_link, SCSI_SILENT) != 0) { SC_DEBUG(sc_link, SDEV_DB3, ("not ready\n")); errcode = ENXIO; goto bad; } + SC_DEBUG(sc_link, SDEV_DB3, ("Device present\n")); scsi_prevent(sc_link, PR_PREVENT, SCSI_SILENT); /* >Audit-Trail: >Unformatted: