isp_sbus.c (316399) | isp_sbus.c (316403) |
---|---|
1/*- 2 * Copyright (c) 1997-2006 by Matthew Jacob 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 --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26/* 27 * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. 28 * FreeBSD Version. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2006 by Matthew Jacob 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 --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26/* 27 * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. 28 * FreeBSD Version. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp_sbus.c 316399 2017-04-02 10:52:00Z mav $"); | 32__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp_sbus.c 316403 2017-04-02 10:54:58Z mav $"); |
33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/linker.h> 37#include <sys/firmware.h> 38#include <sys/bus.h> 39#include <sys/kernel.h> 40#include <sys/module.h> --- 97 unchanged lines hidden (view full) --- 138{ 139 struct isp_sbussoftc *sbs = device_get_softc(dev); 140 ispsoftc_t *isp = &sbs->sbus_isp; 141 int tval, isp_debug, role, ispburst, default_id; 142 143 sbs->sbus_dev = dev; 144 sbs->sbus_mdvec = mdvec; 145 isp->isp_dev = dev; | 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/linker.h> 37#include <sys/firmware.h> 38#include <sys/bus.h> 39#include <sys/kernel.h> 40#include <sys/module.h> --- 97 unchanged lines hidden (view full) --- 138{ 139 struct isp_sbussoftc *sbs = device_get_softc(dev); 140 ispsoftc_t *isp = &sbs->sbus_isp; 141 int tval, isp_debug, role, ispburst, default_id; 142 143 sbs->sbus_dev = dev; 144 sbs->sbus_mdvec = mdvec; 145 isp->isp_dev = dev; |
146 mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); | 146 mtx_init(&isp->isp_lock, "isp", NULL, MTX_DEF); |
147 148 role = 0; 149 if (resource_int_value(device_get_name(dev), device_get_unit(dev), 150 "role", &role) == 0 && 151 ((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) { 152 device_printf(dev, "setting role to 0x%x\n", role); 153 } else { 154 role = ISP_DEFAULT_ROLES; --- 150 unchanged lines hidden (view full) --- 305 (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, 306 sbs->irq); 307 } 308 309 if (sbs->regs) { 310 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, 311 sbs->regs); 312 } | 147 148 role = 0; 149 if (resource_int_value(device_get_name(dev), device_get_unit(dev), 150 "role", &role) == 0 && 151 ((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) { 152 device_printf(dev, "setting role to 0x%x\n", role); 153 } else { 154 role = ISP_DEFAULT_ROLES; --- 150 unchanged lines hidden (view full) --- 305 (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, 306 sbs->irq); 307 } 308 309 if (sbs->regs) { 310 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, 311 sbs->regs); 312 } |
313 mtx_destroy(&isp->isp_osinfo.lock); | 313 mtx_destroy(&isp->isp_lock); |
314 return (ENXIO); 315} 316 317static int 318isp_sbus_detach(device_t dev) 319{ 320 struct isp_sbussoftc *sbs = device_get_softc(dev); 321 ispsoftc_t *isp = &sbs->sbus_isp; --- 7 unchanged lines hidden (view full) --- 329 ISP_UNLOCK(isp); 330 if (isp->isp_nirq > 0) { 331 (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); 332 (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, 333 sbs->irq); 334 } 335 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); 336 isp_sbus_mbxdmafree(isp); | 314 return (ENXIO); 315} 316 317static int 318isp_sbus_detach(device_t dev) 319{ 320 struct isp_sbussoftc *sbs = device_get_softc(dev); 321 ispsoftc_t *isp = &sbs->sbus_isp; --- 7 unchanged lines hidden (view full) --- 329 ISP_UNLOCK(isp); 330 if (isp->isp_nirq > 0) { 331 (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); 332 (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, 333 sbs->irq); 334 } 335 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); 336 isp_sbus_mbxdmafree(isp); |
337 mtx_destroy(&isp->isp_osinfo.lock); | 337 mtx_destroy(&isp->isp_lock); |
338 return (0); 339} 340 341#define IspVirt2Off(a, x) \ 342 (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ 343 _BLK_REG_SHFT] + ((x) & 0xff)) 344 345#define BXR2(isp, off) bus_read_2((isp)->isp_regs, (off)) --- 78 unchanged lines hidden (view full) --- 424 if (isp->isp_xflist != NULL) 425 return (0); 426 if (isp->isp_rquest != NULL && isp->isp_maxcmds == 0) 427 return (0); 428 ISP_UNLOCK(isp); 429 if (isp->isp_rquest != NULL) 430 goto gotmaxcmds; 431 | 338 return (0); 339} 340 341#define IspVirt2Off(a, x) \ 342 (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ 343 _BLK_REG_SHFT] + ((x) & 0xff)) 344 345#define BXR2(isp, off) bus_read_2((isp)->isp_regs, (off)) --- 78 unchanged lines hidden (view full) --- 424 if (isp->isp_xflist != NULL) 425 return (0); 426 if (isp->isp_rquest != NULL && isp->isp_maxcmds == 0) 427 return (0); 428 ISP_UNLOCK(isp); 429 if (isp->isp_rquest != NULL) 430 goto gotmaxcmds; 431 |
432 if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_SBD(isp)), 1, | 432 if (bus_dma_tag_create(bus_get_dma_tag(ISP_SBD(isp)), 1, |
433 BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, 434 BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, | 433 BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, 434 BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, |
435 ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_osinfo.dmat)) { | 435 ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, 436 busdma_lock_mutex, &isp->isp_lock, &isp->isp_osinfo.dmat)) { |
436 isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); 437 goto bad; 438 } 439 440 /* 441 * Allocate and map the request queue. 442 */ 443 len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); | 437 isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); 438 goto bad; 439 } 440 441 /* 442 * Allocate and map the request queue. 443 */ 444 len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); |
444 if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, | 445 if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, |
445 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, | 446 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, |
446 len, 1, len, 0, &isp->isp_osinfo.reqdmat)) { | 447 len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, 448 &isp->isp_osinfo.reqdmat)) { |
447 isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); 448 goto bad; 449 } 450 if (bus_dmamem_alloc(isp->isp_osinfo.reqdmat, (void **)&base, 451 BUS_DMA_COHERENT, &isp->isp_osinfo.reqmap) != 0) { 452 isp_prt(isp, ISP_LOGERR, "cannot allocate request DMA memory"); 453 bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); 454 goto bad; --- 8 unchanged lines hidden (view full) --- 463 isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx", 464 (uintmax_t)im.maddr, (uintmax_t)len); 465 isp->isp_rquest_dma = im.maddr; 466 467 /* 468 * Allocate and map the result queue. 469 */ 470 len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); | 449 isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); 450 goto bad; 451 } 452 if (bus_dmamem_alloc(isp->isp_osinfo.reqdmat, (void **)&base, 453 BUS_DMA_COHERENT, &isp->isp_osinfo.reqmap) != 0) { 454 isp_prt(isp, ISP_LOGERR, "cannot allocate request DMA memory"); 455 bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); 456 goto bad; --- 8 unchanged lines hidden (view full) --- 465 isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx", 466 (uintmax_t)im.maddr, (uintmax_t)len); 467 isp->isp_rquest_dma = im.maddr; 468 469 /* 470 * Allocate and map the result queue. 471 */ 472 len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); |
471 if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, | 473 if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, |
472 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, | 474 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, |
473 len, 1, len, 0, &isp->isp_osinfo.respdmat)) { | 475 len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, 476 &isp->isp_osinfo.respdmat)) { |
474 isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); 475 goto bad; 476 } 477 if (bus_dmamem_alloc(isp->isp_osinfo.respdmat, (void **)&base, 478 BUS_DMA_COHERENT, &isp->isp_osinfo.respmap) != 0) { 479 isp_prt(isp, ISP_LOGERR, "cannot allocate response DMA memory"); 480 bus_dma_tag_destroy(isp->isp_osinfo.respdmat); 481 goto bad; --- 25 unchanged lines hidden (view full) --- 507 isp_prt(isp, ISP_LOGERR, 508 "error %d creating per-cmd DMA maps", error); 509 while (--i >= 0) { 510 bus_dmamap_destroy(isp->isp_osinfo.dmat, 511 isp->isp_osinfo.pcmd_pool[i].dmap); 512 } 513 goto bad; 514 } | 477 isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); 478 goto bad; 479 } 480 if (bus_dmamem_alloc(isp->isp_osinfo.respdmat, (void **)&base, 481 BUS_DMA_COHERENT, &isp->isp_osinfo.respmap) != 0) { 482 isp_prt(isp, ISP_LOGERR, "cannot allocate response DMA memory"); 483 bus_dma_tag_destroy(isp->isp_osinfo.respdmat); 484 goto bad; --- 25 unchanged lines hidden (view full) --- 510 isp_prt(isp, ISP_LOGERR, 511 "error %d creating per-cmd DMA maps", error); 512 while (--i >= 0) { 513 bus_dmamap_destroy(isp->isp_osinfo.dmat, 514 isp->isp_osinfo.pcmd_pool[i].dmap); 515 } 516 goto bad; 517 } |
515 callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); | 518 callout_init_mtx(&pcmd->wdog, &isp->isp_lock, 0); |
516 if (i == isp->isp_maxcmds-1) { 517 pcmd->next = NULL; 518 } else { 519 pcmd->next = &isp->isp_osinfo.pcmd_pool[i+1]; 520 } 521 } 522 isp->isp_osinfo.pcmd_free = &isp->isp_osinfo.pcmd_pool[0]; 523 --- 181 unchanged lines hidden --- | 519 if (i == isp->isp_maxcmds-1) { 520 pcmd->next = NULL; 521 } else { 522 pcmd->next = &isp->isp_osinfo.pcmd_pool[i+1]; 523 } 524 } 525 isp->isp_osinfo.pcmd_free = &isp->isp_osinfo.pcmd_pool[0]; 526 --- 181 unchanged lines hidden --- |