Deleted Added
full compact
ida.c (138853) ida.c (144991)
1/*-
2 * Copyright (c) 1999,2000 Jonathan Lemon
3 * All rights reserved.
4 *
5 # Derived from the original IDA Compaq RAID driver, which is
6 * Copyright (c) 1996, 1997, 1998, 1999
7 * Mark Dawson and David James. All rights reserved.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999,2000 Jonathan Lemon
3 * All rights reserved.
4 *
5 # Derived from the original IDA Compaq RAID driver, which is
6 * Copyright (c) 1996, 1997, 1998, 1999
7 * Mark Dawson and David James. All rights reserved.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/ida/ida.c 138853 2004-12-14 17:45:30Z mdodd $");
32__FBSDID("$FreeBSD: head/sys/dev/ida/ida.c 144991 2005-04-13 05:06:57Z mdodd $");
33
34/*
35 * Generic driver for Compaq SMART RAID adapters.
36 */
37
38#include <sys/param.h>
39#include <sys/kernel.h>
40#include <sys/systm.h>

--- 54 unchanged lines hidden (view full) ---

95
96 if (ida->hwqcb_dmat)
97 bus_dma_tag_destroy(ida->hwqcb_dmat);
98
99 if (ida->qcbs != NULL)
100 free(ida->qcbs, M_DEVBUF);
101
102 if (ida->ih != NULL)
33
34/*
35 * Generic driver for Compaq SMART RAID adapters.
36 */
37
38#include <sys/param.h>
39#include <sys/kernel.h>
40#include <sys/systm.h>

--- 54 unchanged lines hidden (view full) ---

95
96 if (ida->hwqcb_dmat)
97 bus_dma_tag_destroy(ida->hwqcb_dmat);
98
99 if (ida->qcbs != NULL)
100 free(ida->qcbs, M_DEVBUF);
101
102 if (ida->ih != NULL)
103 bus_teardown_intr(ida->dev, ida->irq, ida->ih);
103 bus_teardown_intr(ida->dev, ida->irq, ida->ih);
104
105 if (ida->irq != NULL)
106 bus_release_resource(ida->dev, ida->irq_res_type,
107 0, ida->irq);
108
109 if (ida->parent_dmat != NULL)
110 bus_dma_tag_destroy(ida->parent_dmat);
111
112 if (ida->regs != NULL)
113 bus_release_resource(ida->dev, ida->regs_res_type,
114 ida->regs_res_id, ida->regs);
115}
116
117/*
118 * record bus address from bus_dmamap_load
119 */
120static void
104
105 if (ida->irq != NULL)
106 bus_release_resource(ida->dev, ida->irq_res_type,
107 0, ida->irq);
108
109 if (ida->parent_dmat != NULL)
110 bus_dma_tag_destroy(ida->parent_dmat);
111
112 if (ida->regs != NULL)
113 bus_release_resource(ida->dev, ida->regs_res_type,
114 ida->regs_res_id, ida->regs);
115}
116
117/*
118 * record bus address from bus_dmamap_load
119 */
120static void
121ida_dma_map_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
121ida_dma_map_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
122{
122{
123 bus_addr_t *baddr;
123 bus_addr_t *baddr;
124
124
125 baddr = (bus_addr_t *)arg;
126 *baddr = segs->ds_addr;
125 baddr = (bus_addr_t *)arg;
126 *baddr = segs->ds_addr;
127}
128
129static __inline struct ida_qcb *
130ida_get_qcb(struct ida_softc *ida)
131{
132 struct ida_qcb *qcb;
133
134 if ((qcb = SLIST_FIRST(&ida->free_qcbs)) != NULL) {

--- 57 unchanged lines hidden (view full) ---

192 int error;
193
194 ida->unit = device_get_unit(ida->dev);
195 ida->tag = rman_get_bustag(ida->regs);
196 ida->bsh = rman_get_bushandle(ida->regs);
197
198 SLIST_INIT(&ida->free_qcbs);
199 STAILQ_INIT(&ida->qcb_queue);
127}
128
129static __inline struct ida_qcb *
130ida_get_qcb(struct ida_softc *ida)
131{
132 struct ida_qcb *qcb;
133
134 if ((qcb = SLIST_FIRST(&ida->free_qcbs)) != NULL) {

--- 57 unchanged lines hidden (view full) ---

192 int error;
193
194 ida->unit = device_get_unit(ida->dev);
195 ida->tag = rman_get_bustag(ida->regs);
196 ida->bsh = rman_get_bushandle(ida->regs);
197
198 SLIST_INIT(&ida->free_qcbs);
199 STAILQ_INIT(&ida->qcb_queue);
200 bioq_init(&ida->bio_queue);
200 bioq_init(&ida->bio_queue);
201
202 ida->qcbs = (struct ida_qcb *)
203 malloc(IDA_QCB_MAX * sizeof(struct ida_qcb), M_DEVBUF,
204 M_NOWAIT | M_ZERO);
205 if (ida->qcbs == NULL)
206 return (ENOMEM);
207
208 /*

--- 12 unchanged lines hidden (view full) ---

221 /* maxsize */ IDA_QCB_MAX * sizeof(struct ida_hardware_qcb),
222 /* nsegments */ 1,
223 /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
224 /* flags */ 0,
225 /* lockfunc */ busdma_lock_mutex,
226 /* lockarg */ &Giant,
227 &ida->hwqcb_dmat);
228 if (error)
201
202 ida->qcbs = (struct ida_qcb *)
203 malloc(IDA_QCB_MAX * sizeof(struct ida_qcb), M_DEVBUF,
204 M_NOWAIT | M_ZERO);
205 if (ida->qcbs == NULL)
206 return (ENOMEM);
207
208 /*

--- 12 unchanged lines hidden (view full) ---

221 /* maxsize */ IDA_QCB_MAX * sizeof(struct ida_hardware_qcb),
222 /* nsegments */ 1,
223 /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
224 /* flags */ 0,
225 /* lockfunc */ busdma_lock_mutex,
226 /* lockarg */ &Giant,
227 &ida->hwqcb_dmat);
228 if (error)
229 return (ENOMEM);
229 return (ENOMEM);
230
231 /* DMA tag for mapping buffers into device space */
232 error = bus_dma_tag_create(
233 /* parent */ ida->parent_dmat,
234 /* alignment */ 1,
235 /* boundary */ 0,
236 /* lowaddr */ BUS_SPACE_MAXADDR,
237 /* highaddr */ BUS_SPACE_MAXADDR,
238 /* filter */ NULL,
239 /* filterarg */ NULL,
240 /* maxsize */ MAXBSIZE,
241 /* nsegments */ IDA_NSEG,
242 /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
243 /* flags */ 0,
244 /* lockfunc */ busdma_lock_mutex,
245 /* lockarg */ &Giant,
246 &ida->buffer_dmat);
247 if (error)
230
231 /* DMA tag for mapping buffers into device space */
232 error = bus_dma_tag_create(
233 /* parent */ ida->parent_dmat,
234 /* alignment */ 1,
235 /* boundary */ 0,
236 /* lowaddr */ BUS_SPACE_MAXADDR,
237 /* highaddr */ BUS_SPACE_MAXADDR,
238 /* filter */ NULL,
239 /* filterarg */ NULL,
240 /* maxsize */ MAXBSIZE,
241 /* nsegments */ IDA_NSEG,
242 /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
243 /* flags */ 0,
244 /* lockfunc */ busdma_lock_mutex,
245 /* lockarg */ &Giant,
246 &ida->buffer_dmat);
247 if (error)
248 return (ENOMEM);
248 return (ENOMEM);
249
249
250 /* Allocation of hardware QCBs */
250 /* Allocation of hardware QCBs */
251 /* XXX allocation is rounded to hardware page size */
252 error = bus_dmamem_alloc(ida->hwqcb_dmat,
253 (void **)&ida->hwqcbs, BUS_DMA_NOWAIT, &ida->hwqcb_dmamap);
254 if (error)
251 /* XXX allocation is rounded to hardware page size */
252 error = bus_dmamem_alloc(ida->hwqcb_dmat,
253 (void **)&ida->hwqcbs, BUS_DMA_NOWAIT, &ida->hwqcb_dmamap);
254 if (error)
255 return (ENOMEM);
255 return (ENOMEM);
256
256
257 /* And permanently map them in */
258 bus_dmamap_load(ida->hwqcb_dmat, ida->hwqcb_dmamap,
257 /* And permanently map them in */
258 bus_dmamap_load(ida->hwqcb_dmat, ida->hwqcb_dmamap,
259 ida->hwqcbs, IDA_QCB_MAX * sizeof(struct ida_hardware_qcb),
260 ida_dma_map_cb, &ida->hwqcb_busaddr, /*flags*/0);
261
262 bzero(ida->hwqcbs, IDA_QCB_MAX * sizeof(struct ida_hardware_qcb));
263
264 ida_alloc_qcb(ida); /* allocate an initial qcb */
265
266 callout_init(&ida->ch, CALLOUT_MPSAFE);

--- 46 unchanged lines hidden (view full) ---

313}
314
315int
316ida_detach(device_t dev)
317{
318 struct ida_softc *ida;
319 int error = 0;
320
259 ida->hwqcbs, IDA_QCB_MAX * sizeof(struct ida_hardware_qcb),
260 ida_dma_map_cb, &ida->hwqcb_busaddr, /*flags*/0);
261
262 bzero(ida->hwqcbs, IDA_QCB_MAX * sizeof(struct ida_hardware_qcb));
263
264 ida_alloc_qcb(ida); /* allocate an initial qcb */
265
266 callout_init(&ida->ch, CALLOUT_MPSAFE);

--- 46 unchanged lines hidden (view full) ---

313}
314
315int
316ida_detach(device_t dev)
317{
318 struct ida_softc *ida;
319 int error = 0;
320
321 ida = (struct ida_softc *)device_get_softc(dev);
321 ida = (struct ida_softc *)device_get_softc(dev);
322
323 /*
324 * XXX
322
323 /*
324 * XXX
325 * before detaching, we must make sure that the system is
325 * before detaching, we must make sure that the system is
326 * quiescent; nothing mounted, no pending activity.
327 */
328
329 /*
330 * XXX
331 * now, how are we supposed to maintain a list of our drives?
332 * iterate over our "child devices"?
333 */

--- 4 unchanged lines hidden (view full) ---

338}
339
340static void
341ida_setup_dmamap(void *arg, bus_dma_segment_t *segs, int nsegments, int error)
342{
343 struct ida_hardware_qcb *hwqcb = (struct ida_hardware_qcb *)arg;
344 int i;
345
326 * quiescent; nothing mounted, no pending activity.
327 */
328
329 /*
330 * XXX
331 * now, how are we supposed to maintain a list of our drives?
332 * iterate over our "child devices"?
333 */

--- 4 unchanged lines hidden (view full) ---

338}
339
340static void
341ida_setup_dmamap(void *arg, bus_dma_segment_t *segs, int nsegments, int error)
342{
343 struct ida_hardware_qcb *hwqcb = (struct ida_hardware_qcb *)arg;
344 int i;
345
346 hwqcb->hdr.size = htole16((sizeof(struct ida_req) +
346 hwqcb->hdr.size = htole16((sizeof(struct ida_req) +
347 sizeof(struct ida_sgb) * IDA_NSEG) >> 2);
348
349 for (i = 0; i < nsegments; i++) {
350 hwqcb->seg[i].addr = htole32(segs[i].ds_addr);
351 hwqcb->seg[i].length = htole32(segs[i].ds_len);
352 }
353 hwqcb->req.sgcount = nsegments;
354}

--- 42 unchanged lines hidden (view full) ---

397 /* XXX have "status pointer" area in QCB? */
398
399 return (error);
400}
401
402void
403ida_submit_buf(struct ida_softc *ida, struct bio *bp)
404{
347 sizeof(struct ida_sgb) * IDA_NSEG) >> 2);
348
349 for (i = 0; i < nsegments; i++) {
350 hwqcb->seg[i].addr = htole32(segs[i].ds_addr);
351 hwqcb->seg[i].length = htole32(segs[i].ds_len);
352 }
353 hwqcb->req.sgcount = nsegments;
354}

--- 42 unchanged lines hidden (view full) ---

397 /* XXX have "status pointer" area in QCB? */
398
399 return (error);
400}
401
402void
403ida_submit_buf(struct ida_softc *ida, struct bio *bp)
404{
405 bioq_insert_tail(&ida->bio_queue, bp);
406 ida_construct_qcb(ida);
405 bioq_insert_tail(&ida->bio_queue, bp);
406 ida_construct_qcb(ida);
407 ida_start(ida);
408}
409
410static void
411ida_construct_qcb(struct ida_softc *ida)
412{
413 struct ida_hardware_qcb *hwqcb;
414 struct ida_qcb *qcb;

--- 313 unchanged lines hidden ---
407 ida_start(ida);
408}
409
410static void
411ida_construct_qcb(struct ida_softc *ida)
412{
413 struct ida_hardware_qcb *hwqcb;
414 struct ida_qcb *qcb;

--- 313 unchanged lines hidden ---