| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: wd.c,v 1.386 2011/02/10 05:07:46 enami Exp $ */ | | 1 | /* $NetBSD: wd.c,v 1.387 2011/07/30 04:42:03 jakllsch Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. | | 4 | * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -44,27 +44,27 @@ | | | @@ -44,27 +44,27 @@ |
44 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 44 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
45 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 45 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
46 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 46 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
47 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 47 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
48 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 48 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
49 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 49 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
50 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 50 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
51 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 51 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
52 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 52 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
53 | * POSSIBILITY OF SUCH DAMAGE. | | 53 | * POSSIBILITY OF SUCH DAMAGE. |
54 | */ | | 54 | */ |
55 | | | 55 | |
56 | #include <sys/cdefs.h> | | 56 | #include <sys/cdefs.h> |
57 | __KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.386 2011/02/10 05:07:46 enami Exp $"); | | 57 | __KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.387 2011/07/30 04:42:03 jakllsch Exp $"); |
58 | | | 58 | |
59 | #include "opt_ata.h" | | 59 | #include "opt_ata.h" |
60 | | | 60 | |
61 | #include "rnd.h" | | 61 | #include "rnd.h" |
62 | | | 62 | |
63 | #include <sys/param.h> | | 63 | #include <sys/param.h> |
64 | #include <sys/systm.h> | | 64 | #include <sys/systm.h> |
65 | #include <sys/kernel.h> | | 65 | #include <sys/kernel.h> |
66 | #include <sys/conf.h> | | 66 | #include <sys/conf.h> |
67 | #include <sys/file.h> | | 67 | #include <sys/file.h> |
68 | #include <sys/stat.h> | | 68 | #include <sys/stat.h> |
69 | #include <sys/ioctl.h> | | 69 | #include <sys/ioctl.h> |
70 | #include <sys/buf.h> | | 70 | #include <sys/buf.h> |
| @@ -693,26 +693,27 @@ wdstart1(struct wd_softc *wd, struct buf | | | @@ -693,26 +693,27 @@ wdstart1(struct wd_softc *wd, struct buf |
693 | | | 693 | |
694 | /* Put ptr to orig buf in b_private and use new buf */ | | 694 | /* Put ptr to orig buf in b_private and use new buf */ |
695 | nbp->b_private = bp; | | 695 | nbp->b_private = bp; |
696 | | | 696 | |
697 | BIO_COPYPRIO(nbp, bp); | | 697 | BIO_COPYPRIO(nbp, bp); |
698 | | | 698 | |
699 | bp = nbp; | | 699 | bp = nbp; |
700 | } | | 700 | } |
701 | | | 701 | |
702 | wd->sc_wdc_bio.blkno = bp->b_rawblkno; | | 702 | wd->sc_wdc_bio.blkno = bp->b_rawblkno; |
703 | wd->sc_wdc_bio.bcount = bp->b_bcount; | | 703 | wd->sc_wdc_bio.bcount = bp->b_bcount; |
704 | wd->sc_wdc_bio.databuf = bp->b_data; | | 704 | wd->sc_wdc_bio.databuf = bp->b_data; |
705 | wd->sc_wdc_bio.blkdone =0; | | 705 | wd->sc_wdc_bio.blkdone =0; |
| | | 706 | KASSERT(bp == wd->sc_bp || wd->sc_bp == NULL); |
706 | wd->sc_bp = bp; | | 707 | wd->sc_bp = bp; |
707 | /* | | 708 | /* |
708 | * If we're retrying, retry in single-sector mode. This will give us | | 709 | * If we're retrying, retry in single-sector mode. This will give us |
709 | * the sector number of the problem, and will eventually allow the | | 710 | * the sector number of the problem, and will eventually allow the |
710 | * transfer to succeed. | | 711 | * transfer to succeed. |
711 | */ | | 712 | */ |
712 | if (wd->retries >= WDIORETRIES_SINGLE) | | 713 | if (wd->retries >= WDIORETRIES_SINGLE) |
713 | wd->sc_wdc_bio.flags = ATA_SINGLE; | | 714 | wd->sc_wdc_bio.flags = ATA_SINGLE; |
714 | else | | 715 | else |
715 | wd->sc_wdc_bio.flags = 0; | | 716 | wd->sc_wdc_bio.flags = 0; |
716 | if (wd->sc_flags & WDF_LBA48 && | | 717 | if (wd->sc_flags & WDF_LBA48 && |
717 | (wd->sc_wdc_bio.blkno + | | 718 | (wd->sc_wdc_bio.blkno + |
718 | wd->sc_wdc_bio.bcount / wd->sc_dk.dk_label->d_secsize) > | | 719 | wd->sc_wdc_bio.bcount / wd->sc_dk.dk_label->d_secsize) > |
| @@ -819,26 +820,28 @@ noerror: if ((wd->sc_wdc_bio.flags & ATA | | | @@ -819,26 +820,28 @@ noerror: if ((wd->sc_wdc_bio.flags & ATA |
819 | } | | 820 | } |
820 | disk_unbusy(&wd->sc_dk, (bp->b_bcount - bp->b_resid), | | 821 | disk_unbusy(&wd->sc_dk, (bp->b_bcount - bp->b_resid), |
821 | (bp->b_flags & B_READ)); | | 822 | (bp->b_flags & B_READ)); |
822 | #if NRND > 0 | | 823 | #if NRND > 0 |
823 | rnd_add_uint32(&wd->rnd_source, bp->b_blkno); | | 824 | rnd_add_uint32(&wd->rnd_source, bp->b_blkno); |
824 | #endif | | 825 | #endif |
825 | /* XXX Yuck, but we don't want to increment openings in this case */ | | 826 | /* XXX Yuck, but we don't want to increment openings in this case */ |
826 | if (__predict_false(bp->b_iodone == wd_split_mod15_write)) | | 827 | if (__predict_false(bp->b_iodone == wd_split_mod15_write)) |
827 | biodone(bp); | | 828 | biodone(bp); |
828 | else { | | 829 | else { |
829 | biodone(bp); | | 830 | biodone(bp); |
830 | wd->openings++; | | 831 | wd->openings++; |
831 | } | | 832 | } |
| | | 833 | KASSERT(wd->sc_bp != NULL); |
| | | 834 | wd->sc_bp = NULL; |
832 | wdstart(wd); | | 835 | wdstart(wd); |
833 | } | | 836 | } |
834 | | | 837 | |
835 | void | | 838 | void |
836 | wdrestart(void *v) | | 839 | wdrestart(void *v) |
837 | { | | 840 | { |
838 | struct wd_softc *wd = v; | | 841 | struct wd_softc *wd = v; |
839 | struct buf *bp = wd->sc_bp; | | 842 | struct buf *bp = wd->sc_bp; |
840 | int s; | | 843 | int s; |
841 | | | 844 | |
842 | ATADEBUG_PRINT(("wdrestart %s\n", device_xname(wd->sc_dev)), | | 845 | ATADEBUG_PRINT(("wdrestart %s\n", device_xname(wd->sc_dev)), |
843 | DEBUG_XFERS); | | 846 | DEBUG_XFERS); |
844 | s = splbio(); | | 847 | s = splbio(); |