mpt_pci.c (156000) | mpt_pci.c (157117) |
---|---|
1/*- 2 * PCI specific probe and attach routines for LSI Fusion Adapters 3 * FreeBSD Version. 4 * 5 * Copyright (c) 2000, 2001 by Greg Ansley 6 * Partially derived from Matt Jacob's ISP driver. 7 * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 by Matthew Jacob 8 * Feral Software --- 82 unchanged lines hidden (view full) --- 91 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 92 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 93 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 94 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 95 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 96 */ 97 98#include <sys/cdefs.h> | 1/*- 2 * PCI specific probe and attach routines for LSI Fusion Adapters 3 * FreeBSD Version. 4 * 5 * Copyright (c) 2000, 2001 by Greg Ansley 6 * Partially derived from Matt Jacob's ISP driver. 7 * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 by Matthew Jacob 8 * Feral Software --- 82 unchanged lines hidden (view full) --- 91 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 92 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 93 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 94 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 95 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 96 */ 97 98#include <sys/cdefs.h> |
99__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_pci.c 156000 2006-02-25 07:45:54Z mjacob $"); | 99__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_pci.c 157117 2006-03-25 07:08:27Z mjacob $"); |
100 101#include <dev/mpt/mpt.h> 102#include <dev/mpt/mpt_cam.h> 103#include <dev/mpt/mpt_raid.h> 104 105 106#ifndef PCI_VENDOR_LSI 107#define PCI_VENDOR_LSI 0x1000 --- 129 unchanged lines hidden (view full) --- 237 default: 238 return (ENXIO); 239 } 240 241 device_set_desc(dev, desc); 242 return (0); 243} 244 | 100 101#include <dev/mpt/mpt.h> 102#include <dev/mpt/mpt_cam.h> 103#include <dev/mpt/mpt_raid.h> 104 105 106#ifndef PCI_VENDOR_LSI 107#define PCI_VENDOR_LSI 0x1000 --- 129 unchanged lines hidden (view full) --- 237 default: 238 return (ENXIO); 239 } 240 241 device_set_desc(dev, desc); 242 return (0); 243} 244 |
245#ifdef RELENG_4 | 245#if __FreeBSD_version < 500000 |
246static void 247mpt_set_options(struct mpt_softc *mpt) 248{ 249 int bitmap; 250 251 bitmap = 0; 252 if (getenv_int("mpt_disable", &bitmap)) { 253 if (bitmap & (1 << mpt->unit)) { 254 mpt->disabled = 1; 255 } 256 } 257 258 bitmap = 0; 259 if (getenv_int("mpt_debug", &bitmap)) { 260 if (bitmap & (1 << mpt->unit)) { 261 mpt->verbose = MPT_PRT_DEBUG; 262 } 263 } | 246static void 247mpt_set_options(struct mpt_softc *mpt) 248{ 249 int bitmap; 250 251 bitmap = 0; 252 if (getenv_int("mpt_disable", &bitmap)) { 253 if (bitmap & (1 << mpt->unit)) { 254 mpt->disabled = 1; 255 } 256 } 257 258 bitmap = 0; 259 if (getenv_int("mpt_debug", &bitmap)) { 260 if (bitmap & (1 << mpt->unit)) { 261 mpt->verbose = MPT_PRT_DEBUG; 262 } 263 } |
264 | 264 bitmap = 0; 265 if (getenv_int("mpt_target", &bitmap)) { 266 if (bitmap & (1 << mpt->unit)) { 267 mpt->role = MPT_ROLE_TARGET; 268 } 269 } 270 bitmap = 0; 271 if (getenv_int("mpt_none", &bitmap)) { 272 if (bitmap & (1 << mpt->unit)) { 273 mpt->role = MPT_ROLE_NONE; 274 } 275 } 276 bitmap = 0; 277 if (getenv_int("mpt_initiator", &bitmap)) { 278 if (bitmap & (1 << mpt->unit)) { 279 mpt->role = MPT_ROLE_INITIATOR; 280 } 281 } |
265} 266#else 267static void 268mpt_set_options(struct mpt_softc *mpt) 269{ 270 int tval; 271 272 tval = 0; 273 if (resource_int_value(device_get_name(mpt->dev), 274 device_get_unit(mpt->dev), "disable", &tval) == 0 && tval != 0) { 275 mpt->disabled = 1; 276 } 277 tval = 0; 278 if (resource_int_value(device_get_name(mpt->dev), 279 device_get_unit(mpt->dev), "debug", &tval) == 0 && tval != 0) { 280 mpt->verbose += tval; 281 } | 282} 283#else 284static void 285mpt_set_options(struct mpt_softc *mpt) 286{ 287 int tval; 288 289 tval = 0; 290 if (resource_int_value(device_get_name(mpt->dev), 291 device_get_unit(mpt->dev), "disable", &tval) == 0 && tval != 0) { 292 mpt->disabled = 1; 293 } 294 tval = 0; 295 if (resource_int_value(device_get_name(mpt->dev), 296 device_get_unit(mpt->dev), "debug", &tval) == 0 && tval != 0) { 297 mpt->verbose += tval; 298 } |
299 tval = 0; 300 if (resource_int_value(device_get_name(mpt->dev), 301 device_get_unit(mpt->dev), "role", &tval) == 0 && tval != 0 && 302 tval <= 3) { 303 mpt->role = tval; 304 } |
|
282} 283#endif 284 285 286static void 287mpt_link_peer(struct mpt_softc *mpt) 288{ 289 struct mpt_softc *mpt2; --- 59 unchanged lines hidden (view full) --- 349 break; 350 } 351 mpt->dev = dev; 352 mpt->unit = device_get_unit(dev); 353 mpt->raid_resync_rate = MPT_RAID_RESYNC_RATE_DEFAULT; 354 mpt->raid_mwce_setting = MPT_RAID_MWCE_DEFAULT; 355 mpt->raid_queue_depth = MPT_RAID_QUEUE_DEPTH_DEFAULT; 356 mpt->verbose = MPT_PRT_NONE; | 305} 306#endif 307 308 309static void 310mpt_link_peer(struct mpt_softc *mpt) 311{ 312 struct mpt_softc *mpt2; --- 59 unchanged lines hidden (view full) --- 372 break; 373 } 374 mpt->dev = dev; 375 mpt->unit = device_get_unit(dev); 376 mpt->raid_resync_rate = MPT_RAID_RESYNC_RATE_DEFAULT; 377 mpt->raid_mwce_setting = MPT_RAID_MWCE_DEFAULT; 378 mpt->raid_queue_depth = MPT_RAID_QUEUE_DEPTH_DEFAULT; 379 mpt->verbose = MPT_PRT_NONE; |
380 mpt->role = MPT_ROLE_DEFAULT; |
|
357 mpt_set_options(mpt); 358 if (mpt->verbose == MPT_PRT_NONE) { 359 mpt->verbose = MPT_PRT_WARN; 360 /* Print INFO level (if any) if bootverbose is set */ 361 mpt->verbose += (bootverbose != 0)? 1 : 0; 362 } 363 /* Make sure memory access decoders are enabled */ 364 cmd = pci_read_config(dev, PCIR_COMMAND, 2); --- 104 unchanged lines hidden (view full) --- 469 470 mpt_read_config_regs(mpt); 471 472 /* 473 * Disable PIO until we need it 474 */ 475 pci_disable_io(dev, SYS_RES_IOPORT); 476 | 381 mpt_set_options(mpt); 382 if (mpt->verbose == MPT_PRT_NONE) { 383 mpt->verbose = MPT_PRT_WARN; 384 /* Print INFO level (if any) if bootverbose is set */ 385 mpt->verbose += (bootverbose != 0)? 1 : 0; 386 } 387 /* Make sure memory access decoders are enabled */ 388 cmd = pci_read_config(dev, PCIR_COMMAND, 2); --- 104 unchanged lines hidden (view full) --- 493 494 mpt_read_config_regs(mpt); 495 496 /* 497 * Disable PIO until we need it 498 */ 499 pci_disable_io(dev, SYS_RES_IOPORT); 500 |
501 switch (mpt->role) { 502 case MPT_ROLE_TARGET: 503 break; 504 case MPT_ROLE_INITIATOR: 505 break; 506 case MPT_ROLE_TARGET|MPT_ROLE_INITIATOR: 507 mpt->disabled = 1; 508 mpt_prt(mpt, "dual roles unsupported\n"); 509 goto bad; 510 case MPT_ROLE_NONE: 511 device_printf(dev, "role of NONE same as disable\n"); 512 mpt->disabled = 1; 513 goto bad; 514 } 515 |
|
477 /* Initialize the hardware */ 478 if (mpt->disabled == 0) { | 516 /* Initialize the hardware */ 517 if (mpt->disabled == 0) { |
479 | |
480 MPT_LOCK(mpt); 481 if (mpt_attach(mpt) != 0) { 482 MPT_UNLOCK(mpt); 483 goto bad; 484 } | 518 MPT_LOCK(mpt); 519 if (mpt_attach(mpt) != 0) { 520 MPT_UNLOCK(mpt); 521 goto bad; 522 } |
523 MPT_UNLOCK(mpt); 524 } else { 525 mpt_prt(mpt, "device disabled at user request\n"); 526 goto bad; |
|
485 } 486 | 527 } 528 |
529 mpt->eh = EVENTHANDLER_REGISTER(shutdown_post_sync, mpt_pci_shutdown, 530 dev, SHUTDOWN_PRI_DEFAULT); 531 532 if (mpt->eh == NULL) { 533 mpt_prt(mpt, "shutdown event registration failed\n"); 534 MPT_LOCK(mpt); 535 (void) mpt_detach(mpt); 536 MPT_UNLOCK(mpt); 537 goto bad; 538 } |
|
487 return (0); 488 489bad: 490 mpt_dma_mem_free(mpt); 491 mpt_free_bus_resources(mpt); 492 493 /* 494 * but return zero to preserve unit numbering --- 35 unchanged lines hidden (view full) --- 530 * Disconnect ourselves from the system. 531 */ 532static int 533mpt_pci_detach(device_t dev) 534{ 535 struct mpt_softc *mpt; 536 537 mpt = (struct mpt_softc*)device_get_softc(dev); | 539 return (0); 540 541bad: 542 mpt_dma_mem_free(mpt); 543 mpt_free_bus_resources(mpt); 544 545 /* 546 * but return zero to preserve unit numbering --- 35 unchanged lines hidden (view full) --- 582 * Disconnect ourselves from the system. 583 */ 584static int 585mpt_pci_detach(device_t dev) 586{ 587 struct mpt_softc *mpt; 588 589 mpt = (struct mpt_softc*)device_get_softc(dev); |
538 mpt_prt(mpt, "mpt_detach\n"); | |
539 540 if (mpt) { | 590 591 if (mpt) { |
592 MPT_LOCK(mpt); |
|
541 mpt_disable_ints(mpt); 542 mpt_detach(mpt); 543 mpt_reset(mpt, /*reinit*/FALSE); 544 mpt_dma_mem_free(mpt); 545 mpt_free_bus_resources(mpt); | 593 mpt_disable_ints(mpt); 594 mpt_detach(mpt); 595 mpt_reset(mpt, /*reinit*/FALSE); 596 mpt_dma_mem_free(mpt); 597 mpt_free_bus_resources(mpt); |
546 if (mpt->raid_volumes != NULL 547 && mpt->ioc_page2 != NULL) { | 598 if (mpt->raid_volumes != NULL && mpt->ioc_page2 != NULL) { |
548 int i; | 599 int i; |
549 | |
550 for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { 551 struct mpt_raid_volume *mpt_vol; 552 553 mpt_vol = &mpt->raid_volumes[i]; | 600 for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { 601 struct mpt_raid_volume *mpt_vol; 602 603 mpt_vol = &mpt->raid_volumes[i]; |
554 if (mpt_vol->config_page) | 604 if (mpt_vol->config_page) { |
555 free(mpt_vol->config_page, M_DEVBUF); | 605 free(mpt_vol->config_page, M_DEVBUF); |
606 } |
|
556 } 557 } 558 if (mpt->ioc_page2 != NULL) 559 free(mpt->ioc_page2, M_DEVBUF); 560 if (mpt->ioc_page3 != NULL) 561 free(mpt->ioc_page3, M_DEVBUF); 562 if (mpt->raid_volumes != NULL) 563 free(mpt->raid_volumes, M_DEVBUF); 564 if (mpt->raid_disks != NULL) 565 free(mpt->raid_disks, M_DEVBUF); 566 if (mpt->eh != NULL) 567 EVENTHANDLER_DEREGISTER(shutdown_final, mpt->eh); | 607 } 608 } 609 if (mpt->ioc_page2 != NULL) 610 free(mpt->ioc_page2, M_DEVBUF); 611 if (mpt->ioc_page3 != NULL) 612 free(mpt->ioc_page3, M_DEVBUF); 613 if (mpt->raid_volumes != NULL) 614 free(mpt->raid_volumes, M_DEVBUF); 615 if (mpt->raid_disks != NULL) 616 free(mpt->raid_disks, M_DEVBUF); 617 if (mpt->eh != NULL) 618 EVENTHANDLER_DEREGISTER(shutdown_final, mpt->eh); |
619 MPT_UNLOCK(mpt); |
|
568 } 569 return(0); 570} 571 572 573/* 574 * Disable the hardware | 620 } 621 return(0); 622} 623 624 625/* 626 * Disable the hardware |
575 * XXX - Called too early by New Bus!!! ??? | |
576 */ 577static int 578mpt_pci_shutdown(device_t dev) 579{ 580 struct mpt_softc *mpt; 581 582 mpt = (struct mpt_softc *)device_get_softc(dev); | 627 */ 628static int 629mpt_pci_shutdown(device_t dev) 630{ 631 struct mpt_softc *mpt; 632 633 mpt = (struct mpt_softc *)device_get_softc(dev); |
583 if (mpt) 584 return (mpt_shutdown(mpt)); | 634 if (mpt) { 635 int r; 636 MPT_LOCK(mpt); 637 r = mpt_shutdown(mpt); 638 MPT_UNLOCK(mpt); 639 return (r); 640 } |
585 return(0); 586} 587 588static int 589mpt_dma_mem_alloc(struct mpt_softc *mpt) 590{ 591 int i, error, nsegs; 592 uint8_t *vptr; --- 256 unchanged lines hidden --- | 641 return(0); 642} 643 644static int 645mpt_dma_mem_alloc(struct mpt_softc *mpt) 646{ 647 int i, error, nsegs; 648 uint8_t *vptr; --- 256 unchanged lines hidden --- |