SUMMARY: Sun cdrom drive not responding

From: Todd Pfaff (todd@flex.eng.mcmaster.ca)
Date: Thu Dec 02 1993 - 21:25:36 CST


Yesterday I asked...

----- Begin Included Message -----

We have a an internal Sun cdrom drive in a 4/670 which is recognized
at boot time, but which stops responding some time later. I have not
determined what exactly causes it to go to sleep. Everything else on
the SCSI bus seems fine.

Nov 26 18:09:22 flex1 vmunix: sr0 at esp0 target 6 lun 0

root(275)cdplay
Failed to open device /dev/rsr0 No such device or address

root(276)ll /dev/rsr0
cr-xr-xr-x 1 root operator 58, 0 May 7 1992 /dev/rsr0

Any idea how to get this things attention again? SCSI bus reset maybe?
How? Will this adversely affect the other disks/tapes on the bus?

----- End Included Message -----

Some people suggested that I didn't have sr0 in my kernel config, but yes
it is there. My question probably didn't make it clear that the cdrom
works fine for a while (mount, dismount data CDs, play audio CDs) and
then at some point it says 'No such device...'.

Someone else suggested I add write permission to the /dev/rsr0. I don't
plan on writing to the (READ ONLY) cd so I don't think this will help.

And the winner is...

----- Begin Included Message -----

From: rott@cclink.logicon.com (Ott, Randy)

Attached is sun patch 100519-01 which should answer you questions.

+----------------------------+---------------------------------+
| Randy J. Ott | ROtt@Logicon.COM (Internet) |
| Logicon, Inc. | Randy Ott at LSIS-BEL (cc:Mail) |
| 1408 Fort Crook Road South | (402) 291-7750 (Voice) |
| Bellevue, NE 68005 | (402) 291-2503 (Fax) |
+----------------------------+---------------------------------+
Patch-ID# 100519-01
Keywords: CD, CDRROM, SCSI, bus, reset, address, busy, device
Synopsis: SunOS 4.1.1: cdrom becomes inaccessible after normal use
Date: 6/Apr/92

SunOS release: 4.1.1

Topic: Need method to reset SCSI bus.

BugId's fixed with this patch: 1072950, 1052372

Architectures for which this patch is available: All

Patches which may conflict with this patch:

Note: Using this patch will terminate any active tape or cdrom I/O
      on the scsi bus. Other SCSI I/O (disk, etc.) should recover
      correctly from the reset.

Obsoleted by:

Problem Description:
   After using the CDROM for a while, doing multiple mounts, umounts,
   and ejects, operations begin to fail with the message "device busy"
   or "no such device or address".

   This patch is a script that creates a Makefile and a C source file.
   It then uses make to build a loadable device driver module from
   the source file, modload's the driver which does a scsi reset,
   then modunload's the driver.

INSTALL:

1) Login as root.

2) Determine SCSI controller type (ctrlr_type) esp, sc, se, si, or sm.

3) Determine SCSI controller number (ctrlr_num).

4) enter: sh ./SCSI_Reset <ctrlr_type> <ctrlr_num>

   The default ctrlr_type is 'esp' and ctrlr_num is '0'.

   WARNING: failure to specify the correct ctrlr_type or ctrlr_num
            _will_ result in a system panic.

Note: Using this patch will terminate any active tape or cdrom I/O
      on the scsi bus. Other scsi I/O (disk, etc.) should recover
      correctly from the reset.
#! /bin/sh
Usage='makeit [esp|sc|se|si|sm] [ctlr_num]'
#
# The following files will be written:
# Makefile
# sload.c
# Then make will be called to make and modload the driver fragment
# for the appropriate controller.
#

export PATH; PATH=/bin:/usr/bin:$PATH

CTLR_TYPE=${1:-esp}
CTLR_NUM=${2:-0}

echo
echo "Resetting $CTLR_TYPE controller #$CTLR_NUM."
echo "If this is incorrect your system _WILL_ panic!!!"
echo -n "Is this correct? "
read ans
case $ans in
        y|Y*) ;;
        *) echo
                echo "Usage: $Usage"
                exit 1 ;;
esac

if test -f 'Makefile'
then
        echo "Will not over-write existing file 'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'

default:
        exit 1

# ESP
esp: sload_esp.o modload_esp

sload_esp.o: sload.c
        cc -o sload_esp.o -c -O2 -DNCTLR=$(CTLR_NUM) -Dsun4c -DESP sload.c

modload_esp: sload_esp.o
        modunload -id `modload sload_esp.o -entry _dummy_init | sed -n 's/.* id
        =\(.*\)/\1/p'`
        rm sload_esp sload_esp.o

# SC
sc: sload_sc.o modload_sc

sload_sc.o: sload.c
        cc -o sload_sc.o -c -O2 -DNCTLR=$(CTLR_NUM) -Dsun4 -DSC sload.c

modload_sc: sload_sc.o
        modunload -id `modload sload_sc.o -entry _dummy_init | sed -n 's/.* id
        =\(.*\)/\1/p'`
        rm sload_sc sload_sc.o

# SE
se: sload_se.o modload_se

sload_se.o: sload.c
        cc -o sload_se.o -c -O2 -DNCTLR=$(CTLR_NUM) -Dsun4 -DSE sload.c

modload_se: sload_se.o
        modunload -id `modload sload_se.o -entry _dummy_init | sed -n 's/.* id
        =\(.*\)/\1/p'`
        rm sload_se sload_se.o

# SI
si:
        cc -o sload_si.o -c -O2 -DNCTLR=$(CTLR_NUM) -Dsun4 -DSI sload.c
        modunload -id `modload sload_si.o -entry _dummy_init | sed -n 's/.* id
        =\(.*\)/\1/p'`
        rm sload_si sload_si.o

# SM
sm: sload_sm.o modload_sm

sload_sm.o: sload.c
        cc -o sload_sm.o -c -O2 -DNCTLR=$(CTLR_NUM) -Dsun4 -DSM sload.c

modload_sm: sload_sm.o
        modunload -id `modload sload_sm.o -entry _dummy_init | sed -n 's/.* id
        =\(.*\)/\1/p'`
        rm sload_sm sload_sm.o

SHAR_EOF
fi

if test -f 'sload.c'
then
        echo "Will not over-write existing file 'sload.c'"
else
cat << \SHAR_EOF > 'sload.c'
/*
 * Copyright (c) 1992 by Sun Microsystems, Inc.
 *
 * simple hack to reset scsi bus
 * (for 4.1 or 4.1.1 releases).
 *
 * This is a sample piece of code, not warranted
 * be accurate other than for reference and
 * informational purposes. The interfaces described
 * herein are subject to change without notice.
 * No warranty, express or implied, can be made
 * as to the correctness of this sample code.
 *
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sun/vddrv.h>
#include <sun/openprom.h>

#ifdef ESP

#include <scsi/scsi.h>
#include <scsi/impl/transport.h>

extern struct scsi_transport *scsibuscookies[];

#else

#include <sun/dklabel.h>
#include <sun/dkio.h>
#include <sundev/scsi.h>
#include <sys/errno.h>

extern struct scsi_ctlr scctlrs[], se_ctlrs[], sictlrs[], smctlrs[];
extern int nsc, nse, nsi, nsm;

#endif

struct vdldrv dummydrv = {
        VD_TYPELESS, /* Drv_magic */
        "dummy driver", /* Drv_name */
};

dummy_init(fcn, vdp, vdi, vds)
int fcn;
struct vddrv *vdp;
caddr_t vdi;
struct vdstat *vds;
{
        switch (fcn) {
        case VDLOAD:
                vdp->vdd_vdtab = (struct vdlinkage *)&dummydrv;
#ifdef ESP
                do_esp_reset();
#endif
#ifdef SE
                do_sun4_reset(se_ctlrs, nse);
#endif
#ifdef SC
                do_sun4_reset(scctlrs, nsc);
#endif
#ifdef SI
                do_sun4_reset(sictlrs, nsi);
#endif
#ifdef SM
                do_sun4_reset(smctlrs, nsm);
#endif
        case VDUNLOAD:
        case VDSTAT:
                break;
        default:
                return(EINVAL); /* causes modload to abort the load */
        }
        return(0);
}

#ifdef ESP
do_esp_reset()
{
        struct scsi_address sa;

        sa.a_cookie = (int) scsibuscookies[NCTLR];
        sa.a_target = 6; /* probably doesn't matter */
        sa.a_lun = 0;
        sa.a_sublun = 0;
        scsi_reset(&sa, RESET_ALL);
        printf("SCSI Bus Reset - Controller #%d\n", NCTLR);
}
#endif

#ifdef sun4
do_sun4_reset(ctlrs, nctlr)
struct scsi_ctlr ctlrs[];
int nctlr;
{
        struct scsi_ctlr *ctlr;

        /*
         * Reset the Bus and print a message
         */
        ctlr = &ctlrs[NCTLR];
        (*ctlr->c_ss->scs_reset)(ctlr, 0);
        printf("SCSI Bus Reset - Controller #%d\n", NCTLR);
}
#endif
SHAR_EOF
fi

# Now make the binary and load it
export CTLR_NUM
make $CTLR_TYPE
rm Makefile sload.c

exit 0

----- End Included Message -----

--
Todd Pfaff                       \  Internet: todd@flex.eng.mcmaster.ca
Dept. of Mechanical Engineering   \    Voice: (905) 525-9140 x22902
McMaster University                \     FAX: (905) 572-7944
Hamilton, Ontario, CANADA  L8S 4L7  \



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:31 CDT