mlx.c (130585) | mlx.c (144161) |
---|---|
1/*- 2 * Copyright (c) 1999 Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999 Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/mlx/mlx.c 130585 2004-06-16 09:47:26Z phk $ | 26 * $FreeBSD: head/sys/dev/mlx/mlx.c 144161 2005-03-26 21:58:09Z phk $ |
27 */ 28 29/* 30 * Driver for the Mylex DAC960 family of RAID controllers. 31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> --- 285 unchanged lines hidden (view full) --- 320 break; 321 case MLX_IFTYPE_5: 322 sc->mlx_tryqueue = mlx_v5_tryqueue; 323 sc->mlx_findcomplete = mlx_v5_findcomplete; 324 sc->mlx_intaction = mlx_v5_intaction; 325 sc->mlx_fw_handshake = mlx_v5_fw_handshake; 326 break; 327 default: | 27 */ 28 29/* 30 * Driver for the Mylex DAC960 family of RAID controllers. 31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> --- 285 unchanged lines hidden (view full) --- 320 break; 321 case MLX_IFTYPE_5: 322 sc->mlx_tryqueue = mlx_v5_tryqueue; 323 sc->mlx_findcomplete = mlx_v5_findcomplete; 324 sc->mlx_intaction = mlx_v5_intaction; 325 sc->mlx_fw_handshake = mlx_v5_fw_handshake; 326 break; 327 default: |
328 mlx_free(sc); | |
329 return(ENXIO); /* should never happen */ 330 } 331 332 /* disable interrupts before we start talking to the controller */ 333 sc->mlx_intaction(sc, MLX_INTACTION_DISABLE); 334 335 /* 336 * Wait for the controller to come ready, handshake with the firmware if required. --- 8 unchanged lines hidden (view full) --- 345 device_printf(sc->mlx_dev, "controller initialisation in progress...\n"); 346 hsmsg = 1; 347 } 348 /* did we get a real message? */ 349 if (hscode == 2) { 350 hscode = mlx_fw_message(sc, hserror, hsparam1, hsparam2); 351 /* fatal initialisation error? */ 352 if (hscode != 0) { | 328 return(ENXIO); /* should never happen */ 329 } 330 331 /* disable interrupts before we start talking to the controller */ 332 sc->mlx_intaction(sc, MLX_INTACTION_DISABLE); 333 334 /* 335 * Wait for the controller to come ready, handshake with the firmware if required. --- 8 unchanged lines hidden (view full) --- 344 device_printf(sc->mlx_dev, "controller initialisation in progress...\n"); 345 hsmsg = 1; 346 } 347 /* did we get a real message? */ 348 if (hscode == 2) { 349 hscode = mlx_fw_message(sc, hserror, hsparam1, hsparam2); 350 /* fatal initialisation error? */ 351 if (hscode != 0) { |
353 mlx_free(sc); | |
354 return(ENXIO); 355 } 356 } 357 } 358 if (hsmsg == 1) 359 device_printf(sc->mlx_dev, "initialisation complete.\n"); 360 361 /* 362 * Allocate and connect our interrupt. 363 */ 364 rid = 0; 365 sc->mlx_irq = bus_alloc_resource_any(sc->mlx_dev, SYS_RES_IRQ, &rid, 366 RF_SHAREABLE | RF_ACTIVE); 367 if (sc->mlx_irq == NULL) { 368 device_printf(sc->mlx_dev, "can't allocate interrupt\n"); | 352 return(ENXIO); 353 } 354 } 355 } 356 if (hsmsg == 1) 357 device_printf(sc->mlx_dev, "initialisation complete.\n"); 358 359 /* 360 * Allocate and connect our interrupt. 361 */ 362 rid = 0; 363 sc->mlx_irq = bus_alloc_resource_any(sc->mlx_dev, SYS_RES_IRQ, &rid, 364 RF_SHAREABLE | RF_ACTIVE); 365 if (sc->mlx_irq == NULL) { 366 device_printf(sc->mlx_dev, "can't allocate interrupt\n"); |
369 mlx_free(sc); | |
370 return(ENXIO); 371 } 372 error = bus_setup_intr(sc->mlx_dev, sc->mlx_irq, INTR_TYPE_BIO | INTR_ENTROPY, mlx_intr, sc, &sc->mlx_intr); 373 if (error) { 374 device_printf(sc->mlx_dev, "can't set up interrupt\n"); | 367 return(ENXIO); 368 } 369 error = bus_setup_intr(sc->mlx_dev, sc->mlx_irq, INTR_TYPE_BIO | INTR_ENTROPY, mlx_intr, sc, &sc->mlx_intr); 370 if (error) { 371 device_printf(sc->mlx_dev, "can't set up interrupt\n"); |
375 mlx_free(sc); | |
376 return(ENXIO); 377 } 378 379 /* 380 * Create DMA tag for mapping buffers into controller-addressable space. 381 */ 382 error = bus_dma_tag_create(sc->mlx_parent_dmat, /* parent */ 383 1, 0, /* align, boundary */ 384 BUS_SPACE_MAXADDR, /* lowaddr */ 385 BUS_SPACE_MAXADDR, /* highaddr */ 386 NULL, NULL, /* filter, filterarg */ 387 MAXBSIZE, MLX_NSEG, /* maxsize, nsegments */ 388 BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 389 0, /* flags */ 390 busdma_lock_mutex, /* lockfunc */ 391 &Giant, /* lockarg */ 392 &sc->mlx_buffer_dmat); 393 if (error != 0) { 394 device_printf(sc->mlx_dev, "can't allocate buffer DMA tag\n"); | 372 return(ENXIO); 373 } 374 375 /* 376 * Create DMA tag for mapping buffers into controller-addressable space. 377 */ 378 error = bus_dma_tag_create(sc->mlx_parent_dmat, /* parent */ 379 1, 0, /* align, boundary */ 380 BUS_SPACE_MAXADDR, /* lowaddr */ 381 BUS_SPACE_MAXADDR, /* highaddr */ 382 NULL, NULL, /* filter, filterarg */ 383 MAXBSIZE, MLX_NSEG, /* maxsize, nsegments */ 384 BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 385 0, /* flags */ 386 busdma_lock_mutex, /* lockfunc */ 387 &Giant, /* lockarg */ 388 &sc->mlx_buffer_dmat); 389 if (error != 0) { 390 device_printf(sc->mlx_dev, "can't allocate buffer DMA tag\n"); |
395 mlx_free(sc); | |
396 return(ENOMEM); 397 } 398 399 /* 400 * Create some initial scatter/gather mappings so we can run the probe 401 * commands. 402 */ 403 error = mlx_sglist_map(sc); 404 if (error != 0) { 405 device_printf(sc->mlx_dev, "can't make initial s/g list mapping\n"); | 391 return(ENOMEM); 392 } 393 394 /* 395 * Create some initial scatter/gather mappings so we can run the probe 396 * commands. 397 */ 398 error = mlx_sglist_map(sc); 399 if (error != 0) { 400 device_printf(sc->mlx_dev, "can't make initial s/g list mapping\n"); |
406 mlx_free(sc); | |
407 return(error); 408 } 409 410 /* 411 * We don't (yet) know where the event log is up to. 412 */ 413 sc->mlx_currevent = -1; 414 415 /* 416 * Obtain controller feature information 417 */ 418 if ((sc->mlx_enq2 = mlx_enquire(sc, MLX_CMD_ENQUIRY2, sizeof(struct mlx_enquiry2), NULL)) == NULL) { 419 device_printf(sc->mlx_dev, "ENQUIRY2 failed\n"); | 401 return(error); 402 } 403 404 /* 405 * We don't (yet) know where the event log is up to. 406 */ 407 sc->mlx_currevent = -1; 408 409 /* 410 * Obtain controller feature information 411 */ 412 if ((sc->mlx_enq2 = mlx_enquire(sc, MLX_CMD_ENQUIRY2, sizeof(struct mlx_enquiry2), NULL)) == NULL) { 413 device_printf(sc->mlx_dev, "ENQUIRY2 failed\n"); |
420 mlx_free(sc); | |
421 return(ENXIO); 422 } 423 424 /* 425 * Do quirk/feature related things. 426 */ 427 fwminor = (sc->mlx_enq2->me_firmware_id >> 8) & 0xff; 428 switch(sc->mlx_iftype) { 429 case MLX_IFTYPE_2: 430 /* These controllers don't report the firmware version in the ENQUIRY2 response */ 431 if ((meo = mlx_enquire(sc, MLX_CMD_ENQUIRY_OLD, sizeof(struct mlx_enquiry_old), NULL)) == NULL) { 432 device_printf(sc->mlx_dev, "ENQUIRY_OLD failed\n"); | 414 return(ENXIO); 415 } 416 417 /* 418 * Do quirk/feature related things. 419 */ 420 fwminor = (sc->mlx_enq2->me_firmware_id >> 8) & 0xff; 421 switch(sc->mlx_iftype) { 422 case MLX_IFTYPE_2: 423 /* These controllers don't report the firmware version in the ENQUIRY2 response */ 424 if ((meo = mlx_enquire(sc, MLX_CMD_ENQUIRY_OLD, sizeof(struct mlx_enquiry_old), NULL)) == NULL) { 425 device_printf(sc->mlx_dev, "ENQUIRY_OLD failed\n"); |
433 mlx_free(sc); | |
434 return(ENXIO); 435 } 436 sc->mlx_enq2->me_firmware_id = ('0' << 24) | (0 << 16) | (meo->me_fwminor << 8) | meo->me_fwmajor; 437 438 /* XXX require 2.42 or better (PCI) or 2.14 or better (EISA) */ 439 if (meo->me_fwminor < 42) { 440 device_printf(sc->mlx_dev, " *** WARNING *** This firmware revision is not recommended\n"); 441 device_printf(sc->mlx_dev, " *** WARNING *** Use revision 2.42 or later\n"); --- 16 unchanged lines hidden (view full) --- 458 break; 459 case MLX_IFTYPE_5: 460 if (fwminor < 7) { 461 device_printf(sc->mlx_dev, " *** WARNING *** This firmware revision is not recommended\n"); 462 device_printf(sc->mlx_dev, " *** WARNING *** Use revision 5.07 or later\n"); 463 } 464 break; 465 default: | 426 return(ENXIO); 427 } 428 sc->mlx_enq2->me_firmware_id = ('0' << 24) | (0 << 16) | (meo->me_fwminor << 8) | meo->me_fwmajor; 429 430 /* XXX require 2.42 or better (PCI) or 2.14 or better (EISA) */ 431 if (meo->me_fwminor < 42) { 432 device_printf(sc->mlx_dev, " *** WARNING *** This firmware revision is not recommended\n"); 433 device_printf(sc->mlx_dev, " *** WARNING *** Use revision 2.42 or later\n"); --- 16 unchanged lines hidden (view full) --- 450 break; 451 case MLX_IFTYPE_5: 452 if (fwminor < 7) { 453 device_printf(sc->mlx_dev, " *** WARNING *** This firmware revision is not recommended\n"); 454 device_printf(sc->mlx_dev, " *** WARNING *** Use revision 5.07 or later\n"); 455 } 456 break; 457 default: |
466 mlx_free(sc); | |
467 return(ENXIO); /* should never happen */ 468 } 469 470 /* 471 * Create the final scatter/gather mappings now that we have characterised the controller. 472 */ 473 error = mlx_sglist_map(sc); 474 if (error != 0) { 475 device_printf(sc->mlx_dev, "can't make final s/g list mapping\n"); | 458 return(ENXIO); /* should never happen */ 459 } 460 461 /* 462 * Create the final scatter/gather mappings now that we have characterised the controller. 463 */ 464 error = mlx_sglist_map(sc); 465 if (error != 0) { 466 device_printf(sc->mlx_dev, "can't make final s/g list mapping\n"); |
476 mlx_free(sc); | |
477 return(error); 478 } 479 480 /* 481 * No user-requested background operation is in progress. 482 */ 483 sc->mlx_background = 0; 484 sc->mlx_rebuildstat.rs_code = MLX_REBUILDSTAT_IDLE; --- 2533 unchanged lines hidden --- | 467 return(error); 468 } 469 470 /* 471 * No user-requested background operation is in progress. 472 */ 473 sc->mlx_background = 0; 474 sc->mlx_rebuildstat.rs_code = MLX_REBUILDSTAT_IDLE; --- 2533 unchanged lines hidden --- |