| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: nand_io.c,v 1.3 2011/04/26 13:38:13 ahoka Exp $ */ | | 1 | /* $NetBSD: nand_io.c,v 1.4 2011/04/26 17:27:52 ahoka Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 Department of Software Engineering, | | 4 | * Copyright (c) 2011 Department of Software Engineering, |
5 | * University of Szeged, Hungary | | 5 | * University of Szeged, Hungary |
6 | * Copyright (c) 2011 Adam Hoka <ahoka@NetBSD.org> | | 6 | * Copyright (c) 2011 Adam Hoka <ahoka@NetBSD.org> |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * This code is derived from software contributed to The NetBSD Foundation | | 9 | * This code is derived from software contributed to The NetBSD Foundation |
10 | * by the Department of Software Engineering, University of Szeged, Hungary | | 10 | * by the Department of Software Engineering, University of Szeged, Hungary |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -131,48 +131,48 @@ err_bufq: | | | @@ -131,48 +131,48 @@ err_bufq: |
131 | mutex_destroy(&wc->nwc_lock); | | 131 | mutex_destroy(&wc->nwc_lock); |
132 | | | 132 | |
133 | kmem_free(sc->sc_cache.nwc_data, chip->nc_block_size); | | 133 | kmem_free(sc->sc_cache.nwc_data, chip->nc_block_size); |
134 | | | 134 | |
135 | return error; | | 135 | return error; |
136 | } | | 136 | } |
137 | | | 137 | |
138 | void | | 138 | void |
139 | nand_sync_thread_stop(device_t self) | | 139 | nand_sync_thread_stop(device_t self) |
140 | { | | 140 | { |
141 | struct nand_softc *sc = device_private(self); | | 141 | struct nand_softc *sc = device_private(self); |
142 | struct nand_chip *chip = &sc->sc_chip; | | 142 | struct nand_chip *chip = &sc->sc_chip; |
143 | struct nand_write_cache *wc = &sc->sc_cache; | | 143 | struct nand_write_cache *wc = &sc->sc_cache; |
144 | | | 144 | |
145 | DPRINTF(("stopping nand io thread\n")); | | 145 | DPRINTF(("stopping nand io thread\n")); |
146 | | | 146 | |
147 | kmem_free(wc->nwc_data, chip->nc_block_size); | | 147 | kmem_free(wc->nwc_data, chip->nc_block_size); |
148 | | | 148 | |
149 | sc->sc_io_running = false; | | 149 | sc->sc_io_running = false; |
150 | | | 150 | |
151 | mutex_enter(&sc->sc_io_lock); | | 151 | mutex_enter(&sc->sc_io_lock); |
152 | cv_broadcast(&sc->sc_io_cv); | | 152 | cv_broadcast(&sc->sc_io_cv); |
153 | mutex_exit(&sc->sc_io_lock); | | 153 | mutex_exit(&sc->sc_io_lock); |
154 | | | 154 | |
155 | kthread_join(sc->sc_sync_thread); | | 155 | kthread_join(sc->sc_sync_thread); |
156 | | | 156 | |
157 | bufq_free(wc->nwc_bufq); | | 157 | bufq_free(wc->nwc_bufq); |
158 | mutex_destroy(&wc->nwc_lock); | | 158 | mutex_destroy(&wc->nwc_lock); |
159 | | | 159 | |
160 | #ifdef DIAGNOSTIC | | 160 | #ifdef DIAGNOSTIC |
161 | mutex_enter(&sc->sc_io_lock); | | 161 | mutex_enter(&sc->sc_io_lock); |
162 | KASSERT(!cv_has_waiters(&sc->sc_io_cv)); | | 162 | KASSERT(!cv_has_waiters(&sc->sc_io_cv)); |
163 | mutex_exit(&sc->sc_io_lock); | | 163 | mutex_exit(&sc->sc_io_lock); |
164 | #endif | | 164 | #endif |
165 | | | 165 | |
166 | cv_destroy(&sc->sc_io_cv); | | 166 | cv_destroy(&sc->sc_io_cv); |
167 | mutex_destroy(&sc->sc_io_lock); | | 167 | mutex_destroy(&sc->sc_io_lock); |
168 | } | | 168 | } |
169 | | | 169 | |
170 | int | | 170 | int |
171 | nand_io_submit(device_t self, struct buf *bp) | | 171 | nand_io_submit(device_t self, struct buf *bp) |
172 | { | | 172 | { |
173 | struct nand_softc *sc = device_private(self); | | 173 | struct nand_softc *sc = device_private(self); |
174 | struct nand_write_cache *wc = &sc->sc_cache; | | 174 | struct nand_write_cache *wc = &sc->sc_cache; |
175 | | | 175 | |
176 | DPRINTF(("submitting job to nand io thread: %p\n", bp)); | | 176 | DPRINTF(("submitting job to nand io thread: %p\n", bp)); |
177 | | | 177 | |
178 | if (__predict_false(!sc->sc_io_running)) { | | 178 | if (__predict_false(!sc->sc_io_running)) { |