Thu Aug 25 19:08:35 2011 UTC ()
When this debug printf is enabled, please also tell WHAT address one is using
for read/write.


(reinoud)
diff -r1.5 -r1.6 src/sys/arch/usermode/dev/ld_thunkbus.c

cvs diff -r1.5 -r1.6 src/sys/arch/usermode/dev/ld_thunkbus.c (expand / switch to unified diff)

--- src/sys/arch/usermode/dev/ld_thunkbus.c 2011/08/23 17:12:32 1.5
+++ src/sys/arch/usermode/dev/ld_thunkbus.c 2011/08/25 19:08:35 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ld_thunkbus.c,v 1.5 2011/08/23 17:12:32 jmcneill Exp $ */ 1/* $NetBSD: ld_thunkbus.c,v 1.6 2011/08/25 19:08:35 reinoud Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.5 2011/08/23 17:12:32 jmcneill Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.6 2011/08/25 19:08:35 reinoud Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/proc.h> 33#include <sys/proc.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35#include <sys/device.h> 35#include <sys/device.h>
36#include <sys/buf.h> 36#include <sys/buf.h>
37#include <sys/disk.h> 37#include <sys/disk.h>
38#include <sys/kmem.h> 38#include <sys/kmem.h>
39 39
40#include <dev/ldvar.h> 40#include <dev/ldvar.h>
41 41
42#include <machine/mainbus.h> 42#include <machine/mainbus.h>
43#include <machine/thunk.h> 43#include <machine/thunk.h>
@@ -154,53 +154,54 @@ ld_thunkbus_complete(void *arg) @@ -154,53 +154,54 @@ ld_thunkbus_complete(void *arg)
154 struct ld_thunkbus_softc *sc = arg; 154 struct ld_thunkbus_softc *sc = arg;
155 struct ld_thunkbus_transfer *tt = &sc->sc_tt; 155 struct ld_thunkbus_transfer *tt = &sc->sc_tt;
156 struct buf *bp = tt->tt_bp; 156 struct buf *bp = tt->tt_bp;
157 157
158 if (thunk_aio_error(&tt->tt_aio) == 0 && 158 if (thunk_aio_error(&tt->tt_aio) == 0 &&
159 thunk_aio_return(&tt->tt_aio) != -1) { 159 thunk_aio_return(&tt->tt_aio) != -1) {
160 bp->b_resid = 0; 160 bp->b_resid = 0;
161 } else { 161 } else {
162 bp->b_error = errno; 162 bp->b_error = errno;
163 bp->b_resid = bp->b_bcount; 163 bp->b_resid = bp->b_bcount;
164 } 164 }
165 165
166 if (bp->b_error) 166 if (bp->b_error)
167 printf("errpr!\n"); 167 printf("error!\n");
168 168
169 lddone(&sc->sc_ld, bp); 169 lddone(&sc->sc_ld, bp);
170} 170}
171 171
172static int 172static int
173ld_thunkbus_ldstart(struct ld_softc *ld, struct buf *bp) 173ld_thunkbus_ldstart(struct ld_softc *ld, struct buf *bp)
174{ 174{
175 struct ld_thunkbus_softc *sc = (struct ld_thunkbus_softc *)ld; 175 struct ld_thunkbus_softc *sc = (struct ld_thunkbus_softc *)ld;
176 struct ld_thunkbus_transfer *tt = &sc->sc_tt; 176 struct ld_thunkbus_transfer *tt = &sc->sc_tt;
177 int error; 177 int error;
178 178
179 tt->tt_sc = sc; 179 tt->tt_sc = sc;
180 tt->tt_bp = bp; 180 tt->tt_bp = bp;
181 memset(&tt->tt_aio, 0, sizeof(tt->tt_aio)); 181 memset(&tt->tt_aio, 0, sizeof(tt->tt_aio));
182 tt->tt_aio.aio_fildes = sc->sc_fd; 182 tt->tt_aio.aio_fildes = sc->sc_fd;
183 tt->tt_aio.aio_buf = bp->b_data; 183 tt->tt_aio.aio_buf = bp->b_data;
184 tt->tt_aio.aio_nbytes = bp->b_bcount; 184 tt->tt_aio.aio_nbytes = bp->b_bcount;
185 tt->tt_aio.aio_offset = bp->b_rawblkno * ld->sc_secsize; 185 tt->tt_aio.aio_offset = bp->b_rawblkno * ld->sc_secsize;
186 186
187 tt->tt_aio.aio_sigevent.sigev_notify = SIGEV_SIGNAL; 187 tt->tt_aio.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
188 tt->tt_aio.aio_sigevent.sigev_signo = SIGIO; 188 tt->tt_aio.aio_sigevent.sigev_signo = SIGIO;
189 tt->tt_aio.aio_sigevent.sigev_value.sival_ptr = tt; 189 tt->tt_aio.aio_sigevent.sigev_value.sival_ptr = tt;
190 190
191#if 0 191#if 0
192 device_printf(sc->sc_ld.sc_dv, "%s off=%lld count=%lld\n", 192 device_printf(sc->sc_ld.sc_dv, "%s addr %p, off=%lld, count=%lld\n",
193 (bp->b_flags & B_READ) ? "rd" : "wr", 193 (bp->b_flags & B_READ) ? "rd" : "wr",
 194 bp->b_data,
194 (long long)bp->b_rawblkno, 195 (long long)bp->b_rawblkno,
195 (long long)bp->b_bcount); 196 (long long)bp->b_bcount);
196#endif 197#endif
197 198
198 if (bp->b_flags & B_READ) 199 if (bp->b_flags & B_READ)
199 error = thunk_aio_read(&tt->tt_aio); 200 error = thunk_aio_read(&tt->tt_aio);
200 else 201 else
201 error = thunk_aio_write(&tt->tt_aio); 202 error = thunk_aio_write(&tt->tt_aio);
202 203
203 return error == -1 ? errno : 0; 204 return error == -1 ? errno : 0;
204} 205}
205 206
206static int 207static int