CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: martin Date: Thu Feb 11 12:54:56 UTC 2021 Modified Files: src/sys/dev/scsipi [netbsd-8]: cd.c sd.c Log Message: Pull up following revision(s) (requested by ryoon in ticket #1652): sys/dev/scsipi/cd.c: revision 1.350 sys/dev/scsipi/sd.c: revision 1.331 PR 55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c consistent by also using __BIT() To generate a diff of this commit: cvs rdiff -u -r1.340.6.2 -r1.340.6.3 src/sys/dev/scsipi/cd.c cvs rdiff -u -r1.324.6.1 -r1.324.6.2 src/sys/dev/scsipi/sd.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.340.6.2 src/sys/dev/scsipi/cd.c:1.340.6.3 --- src/sys/dev/scsipi/cd.c:1.340.6.2 Sun Mar 29 12:10:37 2020 +++ src/sys/dev/scsipi/cd.c Thu Feb 11 12:54:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $ */ +/* $NetBSD: cd.c,v 1.340.6.3 2021/02/11 12:54:56 martin Exp $ */ /*- * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation, @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.3 2021/02/11 12:54:56 martin Exp $"); #include #include @@ -1378,7 +1378,7 @@ cdioctl(dev_t dev, u_long cmd, void *add XS_CTL_IGNORE_NOT_READY | XS_CTL_IGNORE_MEDIA_CHANGE)); case DIOCEJECT: if (*(int *)addr == 0) { - int pmask = 1 << part; + int pmask = __BIT(part); /* * Don't force eject: check that we are the only * partition open. If so, unlock it. Index: src/sys/dev/scsipi/sd.c diff -u src/sys/dev/scsipi/sd.c:1.324.6.1 src/sys/dev/scsipi/sd.c:1.324.6.2 --- src/sys/dev/scsipi/sd.c:1.324.6.1 Wed Jun 21 18:18:55 2017 +++ src/sys/dev/scsipi/sd.c Thu Feb 11 12:54:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.324.6.1 2017/06/21 18:18:55 snj Exp $ */ +/* $NetBSD: sd.c,v 1.324.6.2 2021/02/11 12:54:56 martin Exp $ */ /*- * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.324.6.1 2017/06/21 18:18:55 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.324.6.2 2021/02/11 12:54:56 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_scsi.h" @@ -950,11 +950,12 @@ sdioctl(dev_t dev, u_long cmd, void *add if ((periph->periph_flags & PERIPH_REMOVABLE) == 0) return (ENOTTY); if (*(int *)addr == 0) { + int pmask = __BIT(part); /* * Don't force eject: check that we are the only * partition open. If so, unlock it. */ - if (DK_BUSY(dksc, part) == 0) { + if (DK_BUSY(dksc, pmask) == 0) { error = scsipi_prevent(periph, SPAMR_ALLOW, XS_CTL_IGNORE_NOT_READY); if (error)
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: martin Date: Sat Dec 19 19:04:49 UTC 2020 Modified Files: src/sys/dev/scsipi [netbsd-8]: scsiconf.c Log Message: Pull up following revision(s) (requested by tsutsui in ticket #1640): sys/dev/scsipi/scsiconf.c: revision 1.283 Add NOLUNS quirk for more SEAGATE SCA/WIDE drives. Tested on NetBSD/luna68k and LUNA with SCA 80pin -> NARROW 50pin and WIDE 68pin -> NARROW 50pin connectors. To generate a diff of this commit: cvs rdiff -u -r1.279.6.2 -r1.279.6.3 src/sys/dev/scsipi/scsiconf.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/scsiconf.c diff -u src/sys/dev/scsipi/scsiconf.c:1.279.6.2 src/sys/dev/scsipi/scsiconf.c:1.279.6.3 --- src/sys/dev/scsipi/scsiconf.c:1.279.6.2 Mon Jul 13 14:10:25 2020 +++ src/sys/dev/scsipi/scsiconf.c Sat Dec 19 19:04:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $ */ +/* $NetBSD: scsiconf.c,v 1.279.6.3 2020/12/19 19:04:49 martin Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.3 2020/12/19 19:04:49 martin Exp $"); #include #include @@ -674,6 +674,12 @@ static const struct scsi_quirk_inquiry_p {{T_DIRECT, T_FIXED, "SEAGATE ", "ST318404LC ", ""}, PQUIRK_NOLUNS}, {{T_DIRECT, T_FIXED, + "SEAGATE ", "ST336753LC ", ""}, PQUIRK_NOLUNS}, + {{T_DIRECT, T_FIXED, + "SEAGATE ", "ST336753LW ", ""}, PQUIRK_NOLUNS}, + {{T_DIRECT, T_FIXED, + "SEAGATE ", "ST336754LC ", ""}, PQUIRK_NOLUNS}, + {{T_DIRECT, T_FIXED, "SEAGATE ", "ST39236LC ", ""}, PQUIRK_NOLUNS}, {{T_DIRECT, T_FIXED, "SEAGATE ", "ST15150N", ""}, PQUIRK_NOTAG},
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: martin Date: Mon Jul 13 14:10:25 UTC 2020 Modified Files: src/sys/dev/scsipi [netbsd-8]: scsiconf.c Log Message: Pull up following revision(s) (requested by kim in ticket #1571): sys/dev/scsipi/scsiconf.c: revision 1.288 Continue scanning a SCSI bus when a LUN is reported not present This fixes disk attachment under Qemu when there is no disk on LUN 0 on a SCSI bus but there is a disk on LUN 1. The inquiry for LUN 0 returns SID_QUAL_LU_NOTPRESENT & T_NODEVICE. Quirks are only checked if neither one of those are set, so cannot use a quirk entry. Use case 1: Proxmox 6 configures each disk on its own bus when using the "Virtio SCSI single" SCSI controller. However, while the "scsi0" disk is on LUN 0, the "scsi1" disk is on LUN 1. Use case 2: A Linode boot profile with multiple disks results in the first disk ("sda") on LUN 1, while the second disk ("sdb") is on LUN 0, each on their own bus. To generate a diff of this commit: cvs rdiff -u -r1.279.6.1 -r1.279.6.2 src/sys/dev/scsipi/scsiconf.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/scsiconf.c diff -u src/sys/dev/scsipi/scsiconf.c:1.279.6.1 src/sys/dev/scsipi/scsiconf.c:1.279.6.2 --- src/sys/dev/scsipi/scsiconf.c:1.279.6.1 Wed Jun 21 18:18:55 2017 +++ src/sys/dev/scsipi/scsiconf.c Mon Jul 13 14:10:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.c,v 1.279.6.1 2017/06/21 18:18:55 snj Exp $ */ +/* $NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.1 2017/06/21 18:18:55 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $"); #include #include @@ -869,6 +869,8 @@ scsi_probe_device(struct scsibus_softc * break; case SID_QUAL_LU_NOTPRESENT: + docontinue = 1; + /* FALLTHROUGH */ case SID_QUAL_reserved: case SID_QUAL_LU_NOT_SUPP: goto bad;
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: martin Date: Fri Mar 1 17:29:32 UTC 2019 Modified Files: src/sys/dev/scsipi [netbsd-8]: files.scsipi st.c Log Message: Pull up following revision(s) (requested by kardel in ticket #1197): sys/dev/scsipi/st.c: revision 1.236 sys/dev/scsipi/st.c: revision 1.237 sys/dev/scsipi/files.scsipi: revision 1.42 Fix PR kern/53949: Fix inconsistent/incomplete file mark handling to conform again to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW bracket was reduced from a whole mount session to cover only the open(2)/close(2) time on ~2002-03-22. The rationale was to allow robots and humans to change the media during a mount session. Unfortunately this lead to file marks being written to potentially other media at the beginning on drives that used the two file marks as EOM pattern. In order for that to happen the media had to be removed after data and at most one file mark had been written before removal. The mount error message has been clarified and a warning about potential data/file mark lossage on UNIT ATTENTION during an active mount session with unfinished file marks has been added. While there, fix, but disable the commented SUN compatibility to write final file marks by opening and immediately closing the device in O_WRONLY mode. That code has not been working since around 1998. It can now be enabled with options ST_SUNCOMPAT. Additionally debug output coverage has been extended. - Correct printing type of b_blkno (int64_t) in st.c Fixes build with kUBSan on NetBSD/i386. Fix, but disable the commented SUN compatibility in st.c to write final file marks by opening and immediately closing the device in O_WRONLY mode. That code has not been working since around 1998. It can now be enabled with options ST_SUNCOMPAT. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.41.156.1 src/sys/dev/scsipi/files.scsipi cvs rdiff -u -r1.230.8.2 -r1.230.8.3 src/sys/dev/scsipi/st.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/files.scsipi diff -u src/sys/dev/scsipi/files.scsipi:1.41 src/sys/dev/scsipi/files.scsipi:1.41.156.1 --- src/sys/dev/scsipi/files.scsipi:1.41 Sun Dec 11 12:23:50 2005 +++ src/sys/dev/scsipi/files.scsipi Fri Mar 1 17:29:32 2019 @@ -1,11 +1,12 @@ -# $NetBSD: files.scsipi,v 1.41 2005/12/11 12:23:50 christos Exp $ +# $NetBSD: files.scsipi,v 1.41.156.1 2019/03/01 17:29:32 martin Exp $ # # Config file and device description for machine-independent SCSI code. # Included by ports that need it. Ports that use it must provide # their own "major" declarations for the appropriate devices. defflag opt_scsi.h SCSIVERBOSE ST_ENABLE_EARLYWARN -SES_ENABLE_PASSTHROUGH SCSI_OLD_NOINQUIRY +ST_SUNCOMPAT SES_ENABLE_PASSTHROUGH +SCSI_OLD_NOINQUIRY defparam opt_scsi.h ST_MOUNT_DELAY SDRETRIES SD_IO_TIMEOUT defflag opt_scsipi_debug.h SCSIPI_DEBUG Index: src/sys/dev/scsipi/st.c diff -u src/sys/dev/scsipi/st.c:1.230.8.2 src/sys/dev/scsipi/st.c:1.230.8.3 --- src/sys/dev/scsipi/st.c:1.230.8.2 Sun Apr 8 06:11:41 2018 +++ src/sys/dev/scsipi/st.c Fri Mar 1 17:29:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.230.8.2 2018/04/08 06:11:41 snj Exp $ */ +/* $NetBSD: st.c,v 1.230.8.3 2019/03/01 17:29:32 martin Exp $ */ /*- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.230.8.2 2018/04/08 06:11:41 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.230.8.3 2019/03/01 17:29:32 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_scsi.h" @@ -615,8 +615,30 @@ stopen(dev_t dev, int flags, int mode, s */ if ((st->flags & ST_MOUNTED) || ST_MOUNT_DELAY == 0 || (st->mt_key != SKEY_NOT_READY)) { - device_printf(st->sc_dev, "mount error (key=%d)\n", -st->mt_key); + device_printf(st->sc_dev, + "mount error (sense key=%d) - " + "terminating mount session\n", + st->mt_key); + /* + * the following should not trigger unless + * something serious happened while the device + * was open (PREVENT MEDIUM REMOVAL in effect) + */ + if (st->flags & ST_WRITTEN && + st->mt_key == SKEY_UNIT_ATTENTION) { +/* + * device / media state may have changed + * refrain from writing missing file marks + * onto potentially newly inserted/formatted + * media (e. g. emergency EJECT/RESET/etc.) + */ +st->flags &= ~(ST_WRITTEN|ST_FM_WRITTEN); + +device_printf(st->sc_dev, +"CAUTION: file marks/data may be missing" +" - ASC = 0x%02x, ASCQ = 0x%02x\n", + st->asc, st->ascq); + } goto bad; } @@ -727,15 +749,30 @@ stclose(dev_t dev, int flags, int mode, */ stxx = st->flags & (ST_WRITTEN | ST_FM_WRITTEN); - if (((flags & FWRITE) && stxx ==
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: martin Date: Sun Sep 23 17:24:59 UTC 2018 Modified Files: src/sys/dev/scsipi [netbsd-8]: scsipi_verbose.c Log Message: Pull up following revision(s) (requested by mrg in ticket #1023): sys/dev/scsipi/scsipi_verbose.c: revision 1.34 don't print a blank line that ends up in logs and console output. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.33.8.1 src/sys/dev/scsipi/scsipi_verbose.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/scsipi_verbose.c diff -u src/sys/dev/scsipi/scsipi_verbose.c:1.33 src/sys/dev/scsipi/scsipi_verbose.c:1.33.8.1 --- src/sys/dev/scsipi/scsipi_verbose.c:1.33 Sat Sep 17 18:53:13 2016 +++ src/sys/dev/scsipi/scsipi_verbose.c Sun Sep 23 17:24:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: scsipi_verbose.c,v 1.33 2016/09/17 18:53:13 kardel Exp $ */ +/* $NetBSD: scsipi_verbose.c,v 1.33.8.1 2018/09/23 17:24:59 martin Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.33 2016/09/17 18:53:13 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.33.8.1 2018/09/23 17:24:59 martin Exp $"); #include #include @@ -954,10 +954,8 @@ scsipi_print_sense_data_real(struct scsi if (sbs) printf("\n SKSV: %s", sbs); printf("\n"); - if (verbosity == 0) { - printf("\n"); + if (verbosity == 0) return; - } /* * Now figure whether we should print any additional informtion.
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: martin Date: Fri Sep 7 12:21:13 UTC 2018 Modified Files: src/sys/dev/scsipi [netbsd-8]: scsipi_base.c Log Message: Pull up following revision(s) (requested by mrg in ticket #1010): sys/dev/scsipi/scsipi_base.c: revision 1.178 Async event can be called before the adapter is running (pmax tc asc) To generate a diff of this commit: cvs rdiff -u -r1.175.8.1 -r1.175.8.2 src/sys/dev/scsipi/scsipi_base.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/scsipi_base.c diff -u src/sys/dev/scsipi/scsipi_base.c:1.175.8.1 src/sys/dev/scsipi/scsipi_base.c:1.175.8.2 --- src/sys/dev/scsipi/scsipi_base.c:1.175.8.1 Wed Jun 21 18:18:55 2017 +++ src/sys/dev/scsipi/scsipi_base.c Fri Sep 7 12:21:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: scsipi_base.c,v 1.175.8.1 2017/06/21 18:18:55 snj Exp $ */ +/* $NetBSD: scsipi_base.c,v 1.175.8.2 2018/09/07 12:21:13 martin Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.175.8.1 2017/06/21 18:18:55 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.175.8.2 2018/09/07 12:21:13 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_scsi.h" @@ -2238,8 +2238,10 @@ void scsipi_async_event(struct scsipi_channel *chan, scsipi_async_event_t event, void *arg) { + bool lock = chan_running(chan) > 0; - mutex_enter(chan_mtx(chan)); + if (lock) + mutex_enter(chan_mtx(chan)); switch (event) { case ASYNC_EVENT_MAX_OPENINGS: scsipi_async_event_max_openings(chan, @@ -2256,7 +2258,8 @@ scsipi_async_event(struct scsipi_channel scsipi_async_event_channel_reset(chan); break; } - mutex_exit(chan_mtx(chan)); + if (lock) + mutex_exit(chan_mtx(chan)); } /*
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: snj Date: Sun Apr 8 06:11:41 UTC 2018 Modified Files: src/sys/dev/scsipi [netbsd-8]: st.c stvar.h Log Message: Pull up following revision(s) (requested by mlelstv in ticket #703): sys/dev/scsipi/st.c: 1.234 sys/dev/scsipi/stvar.h: 1.26 Use separate lock to protect internal state and release locks when calling biodone. To generate a diff of this commit: cvs rdiff -u -r1.230.8.1 -r1.230.8.2 src/sys/dev/scsipi/st.c cvs rdiff -u -r1.25 -r1.25.10.1 src/sys/dev/scsipi/stvar.h 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/st.c diff -u src/sys/dev/scsipi/st.c:1.230.8.1 src/sys/dev/scsipi/st.c:1.230.8.2 --- src/sys/dev/scsipi/st.c:1.230.8.1 Wed Jun 21 18:18:55 2017 +++ src/sys/dev/scsipi/st.c Sun Apr 8 06:11:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.230.8.1 2017/06/21 18:18:55 snj Exp $ */ +/* $NetBSD: st.c,v 1.230.8.2 2018/04/08 06:11:41 snj Exp $ */ /*- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.230.8.1 2017/06/21 18:18:55 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.230.8.2 2018/04/08 06:11:41 snj Exp $"); #ifdef _KERNEL_OPT #include "opt_scsi.h" @@ -343,6 +343,7 @@ static int st_mount_tape(dev_t, int); static void st_unmount(struct st_softc *, boolean); static int st_decide_mode(struct st_softc *, boolean); static void ststart(struct scsipi_periph *); +static int ststart1(struct scsipi_periph *, struct buf *); static void strestart(void *); static void stdone(struct scsipi_xfer *, int); static int st_read(struct st_softc *, char *, int, int); @@ -392,9 +393,11 @@ stattach(device_t parent, device_t self, /* Set initial flags */ st->flags = ST_INIT_FLAGS; - /* Set up the buf queue for this device */ + /* Set up the buf queues for this device */ bufq_alloc(>buf_queue, "fcfs", 0); + bufq_alloc(>buf_defer, "fcfs", 0); callout_init(>sc_callout, 0); + mutex_init(>sc_iolock, MUTEX_DEFAULT, IPL_VM); /* * Check if the drive is a known criminal and take @@ -445,6 +448,7 @@ stdetach(device_t self, int flags) mutex_enter(chan_mtx(chan)); /* Kill off any queued buffers. */ + bufq_drain(st->buf_defer); bufq_drain(st->buf_queue); /* Kill off any pending commands. */ @@ -452,7 +456,9 @@ stdetach(device_t self, int flags) mutex_exit(chan_mtx(chan)); + bufq_free(st->buf_defer); bufq_free(st->buf_queue); + mutex_destroy(>sc_iolock); /* Nuke the vnodes for any open instances */ mn = STUNIT(device_unit(self)); @@ -609,6 +615,8 @@ stopen(dev_t dev, int flags, int mode, s */ if ((st->flags & ST_MOUNTED) || ST_MOUNT_DELAY == 0 || (st->mt_key != SKEY_NOT_READY)) { + device_printf(st->sc_dev, "mount error (key=%d)\n", +st->mt_key); goto bad; } @@ -629,11 +637,11 @@ stopen(dev_t dev, int flags, int mode, s periph->periph_flags = oflags; /* restore flags */ if (slpintr != 0 && slpintr != EWOULDBLOCK) { + device_printf(st->sc_dev, "load interrupted\n"); goto bad; } } - /* * If the mode is 3 (e.g. minor = 3,7,11,15) then the device has * been opened to set defaults and perform other, usually non-I/O @@ -642,7 +650,9 @@ stopen(dev_t dev, int flags, int mode, s * as to whether or not we got a NOT READY for the above * unit attention). If a tape is there, go do a mount sequence. */ - if (stmode == CTRL_MODE && st->mt_key == SKEY_NOT_READY) { + if (stmode == CTRL_MODE && + st->mt_key != SKEY_NO_SENSE && + st->mt_key != SKEY_UNIT_ATTENTION) { periph->periph_flags |= PERIPH_OPEN; return 0; } @@ -1107,160 +1117,187 @@ abort: /* * ststart looks to see if there is a buf waiting for the device - * and that the device is not already busy. If both are true, - * It dequeues the buf and creates a scsi command to perform the - * transfer required. The transfer request will call scsipi_done - * on completion, which will in turn call this routine again - * so that the next queued transfer is performed. - * The bufs are queued by the strategy routine (ststrategy) + * and that the device is not already busy. If the device is busy, + * the request is deferred and retried on the next attempt. + * If both are true, ststart creates a scsi command to perform + * the transfer required. + * + * The transfer request will call scsipi_done on completion, + * which will in turn call this routine again so that the next + * queued transfer is performed. The bufs are queued by the + * strategy routine (ststrategy) * * This routine is also called after other non-queued requests * have been made of the scsi driver, to ensure that the queue * continues to be drained. * ststart() is called with channel lock held */ -static void -ststart(struct scsipi_periph *periph) +static int +ststart1(struct scsipi_periph *periph, struct buf *bp) { struct
CVS commit: [netbsd-8] src/sys/dev/scsipi
Module Name:src Committed By: snj Date: Wed Jun 21 18:18:55 UTC 2017 Modified Files: src/sys/dev/scsipi [netbsd-8]: atapiconf.c cd.c scsi_base.c scsiconf.c scsipi_base.c sd.c ss.c st.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #53): sys/dev/scsipi/atapiconf.c: revision 1.91 sys/dev/scsipi/cd.c: revision 1.341 sys/dev/scsipi/scsi_base.c: revision 1.92 sys/dev/scsipi/scsiconf.c: revision 1.280 sys/dev/scsipi/scsipi_base.c: revisions 1.176, 1.177 sys/dev/scsipi/sd.c: revision 1.325 sys/dev/scsipi/ss.c: revision 1.89 sys/dev/scsipi/st.c: revision 1.231 The atapibus detach path did hold the channel mutex while calling into autoconf, which would trigger a panic when unplugging a USB ATAPI CDROM. Align detach code for scsibus and atapibus to fix this. Also avoid races when detaching devices by replacing callout_stop with callout_halt. -- pass config_detach error to caller. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.90.8.1 src/sys/dev/scsipi/atapiconf.c cvs rdiff -u -r1.340 -r1.340.6.1 src/sys/dev/scsipi/cd.c cvs rdiff -u -r1.91 -r1.91.8.1 src/sys/dev/scsipi/scsi_base.c cvs rdiff -u -r1.279 -r1.279.6.1 src/sys/dev/scsipi/scsiconf.c cvs rdiff -u -r1.175 -r1.175.8.1 src/sys/dev/scsipi/scsipi_base.c cvs rdiff -u -r1.324 -r1.324.6.1 src/sys/dev/scsipi/sd.c cvs rdiff -u -r1.88 -r1.88.8.1 src/sys/dev/scsipi/ss.c cvs rdiff -u -r1.230 -r1.230.8.1 src/sys/dev/scsipi/st.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/atapiconf.c diff -u src/sys/dev/scsipi/atapiconf.c:1.90 src/sys/dev/scsipi/atapiconf.c:1.90.8.1 --- src/sys/dev/scsipi/atapiconf.c:1.90 Tue Nov 29 03:23:00 2016 +++ src/sys/dev/scsipi/atapiconf.c Wed Jun 21 18:18:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: atapiconf.c,v 1.90 2016/11/29 03:23:00 mlelstv Exp $ */ +/* $NetBSD: atapiconf.c,v 1.90.8.1 2017/06/21 18:18:55 snj Exp $ */ /* * Copyright (c) 1996, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.90 2016/11/29 03:23:00 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.90.8.1 2017/06/21 18:18:55 snj Exp $"); #include #include @@ -147,6 +147,7 @@ atapibusattach(device_t parent, device_t sc->sc_dev = self; chan->chan_name = device_xname(sc->sc_dev); + chan->chan_id = -1; /* ATAPI has no LUNs. */ chan->chan_nluns = 1; @@ -192,38 +193,27 @@ atapibuschilddet(device_t self, device_t mutex_exit(chan_mtx(chan)); } +/* same as scsibusdetach */ static int atapibusdetach(device_t self, int flags) { struct atapibus_softc *sc = device_private(self); struct scsipi_channel *chan = sc->sc_channel; - struct scsipi_periph *periph; - int target, error = 0; + int error = 0; /* - * Shut down the channel. + * Detach all of the periphs. */ - scsipi_channel_shutdown(chan); + error = scsipi_target_detach(chan, -1, -1, flags); + if (error) + return error; - /* for config_detach() */ - KERNEL_LOCK(1, curlwp); + pmf_device_deregister(self); /* - * Now detach all of the periphs. + * Shut down the channel. */ - mutex_enter(chan_mtx(chan)); - for (target = 0; target < chan->chan_ntargets; target++) { - periph = scsipi_lookup_periph_locked(chan, target, 0); - if (periph == NULL) - continue; - error = config_detach(periph->periph_dev, flags); - if (error) { - mutex_exit(chan_mtx(chan)); - goto out; - } - KASSERT(scsipi_lookup_periph(chan, target, 0) == NULL); - } - mutex_exit(chan_mtx(chan)); + scsipi_channel_shutdown(chan); cv_destroy(>chan_cv_xs); cv_destroy(>chan_cv_comp); @@ -232,10 +222,7 @@ atapibusdetach(device_t self, int flags) if (atomic_dec_uint_nv(_running(chan)) == 0) mutex_destroy(chan_mtx(chan)); -out: - /* XXXSMP scsipi */ - KERNEL_UNLOCK_ONE(curlwp); - return error; + return 0; } static int Index: src/sys/dev/scsipi/cd.c diff -u src/sys/dev/scsipi/cd.c:1.340 src/sys/dev/scsipi/cd.c:1.340.6.1 --- src/sys/dev/scsipi/cd.c:1.340 Sat Apr 8 13:50:23 2017 +++ src/sys/dev/scsipi/cd.c Wed Jun 21 18:18:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.340 2017/04/08 13:50:23 mlelstv Exp $ */ +/* $NetBSD: cd.c,v 1.340.6.1 2017/06/21 18:18:55 snj Exp $ */ /*- * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation, @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340 2017/04/08 13:50:23 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.1 2017/06/21 18:18:55 snj Exp $"); #include #include @@ -354,7 +354,7 @@ cddetach(device_t self, int flags) } /* kill any pending restart */ - callout_stop(>sc_callout); + callout_halt(>sc_callout, NULL); dk_drain(dksc); Index: src/sys/dev/scsipi/scsi_base.c diff -u src/sys/dev/scsipi/scsi_base.c:1.91 src/sys/dev/scsipi/scsi_base.c:1.91.8.1 ---