isp_sbus.c (302408) | isp_sbus.c (316084) |
---|---|
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/11/sys/dev/isp/isp_sbus.c 299849 2016-05-15 08:36:12Z trasz $"); | 32__FBSDID("$FreeBSD: stable/11/sys/dev/isp/isp_sbus.c 316084 2017-03-28 10:11:00Z 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> --- 9 unchanged lines hidden (view full) --- 50#include <sparc64/sbus/sbusvar.h> 51 52#include <dev/isp/isp_freebsd.h> 53 54static uint32_t isp_sbus_rd_reg(ispsoftc_t *, int); 55static void isp_sbus_wr_reg(ispsoftc_t *, int, uint32_t); 56static int isp_sbus_rd_isr(ispsoftc_t *, uint16_t *, uint16_t *, uint16_t *); 57static int isp_sbus_mbxdma(ispsoftc_t *); | 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> --- 9 unchanged lines hidden (view full) --- 50#include <sparc64/sbus/sbusvar.h> 51 52#include <dev/isp/isp_freebsd.h> 53 54static uint32_t isp_sbus_rd_reg(ispsoftc_t *, int); 55static void isp_sbus_wr_reg(ispsoftc_t *, int, uint32_t); 56static int isp_sbus_rd_isr(ispsoftc_t *, uint16_t *, uint16_t *, uint16_t *); 57static int isp_sbus_mbxdma(ispsoftc_t *); |
58static void isp_sbus_mbxdmafree(ispsoftc_t *); |
|
58static int isp_sbus_dmasetup(ispsoftc_t *, XS_T *, void *); | 59static int isp_sbus_dmasetup(ispsoftc_t *, XS_T *, void *); |
59 60 61static void isp_sbus_reset0(ispsoftc_t *); 62static void isp_sbus_reset1(ispsoftc_t *); | |
63static void isp_sbus_dumpregs(ispsoftc_t *, const char *); 64 65static struct ispmdvec mdvec = { 66 isp_sbus_rd_isr, 67 isp_sbus_rd_reg, 68 isp_sbus_wr_reg, 69 isp_sbus_mbxdma, 70 isp_sbus_dmasetup, 71 isp_common_dmateardown, | 60static void isp_sbus_dumpregs(ispsoftc_t *, const char *); 61 62static struct ispmdvec mdvec = { 63 isp_sbus_rd_isr, 64 isp_sbus_rd_reg, 65 isp_sbus_wr_reg, 66 isp_sbus_mbxdma, 67 isp_sbus_dmasetup, 68 isp_common_dmateardown, |
72 isp_sbus_reset0, 73 isp_sbus_reset1, | 69 NULL, |
74 isp_sbus_dumpregs, 75 NULL, 76 BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64 77}; 78 79static int isp_sbus_probe (device_t); 80static int isp_sbus_attach (device_t); 81static int isp_sbus_detach (device_t); --- 53 unchanged lines hidden (view full) --- 135 isp_announced++; 136 } 137 return (0); 138} 139 140static int 141isp_sbus_attach(device_t dev) 142{ | 70 isp_sbus_dumpregs, 71 NULL, 72 BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64 73}; 74 75static int isp_sbus_probe (device_t); 76static int isp_sbus_attach (device_t); 77static int isp_sbus_detach (device_t); --- 53 unchanged lines hidden (view full) --- 131 isp_announced++; 132 } 133 return (0); 134} 135 136static int 137isp_sbus_attach(device_t dev) 138{ |
139 struct isp_sbussoftc *sbs = device_get_softc(dev); 140 ispsoftc_t *isp = &sbs->sbus_isp; |
|
143 int tval, isp_debug, role, ispburst, default_id; | 141 int tval, isp_debug, role, ispburst, default_id; |
144 struct isp_sbussoftc *sbs; 145 ispsoftc_t *isp = NULL; 146 int locksetup = 0; | |
147 int ints_setup = 0; 148 | 142 int ints_setup = 0; 143 |
149 sbs = device_get_softc(dev); 150 if (sbs == NULL) { 151 device_printf(dev, "cannot get softc\n"); 152 return (ENOMEM); 153 } 154 | |
155 sbs->sbus_dev = dev; 156 sbs->sbus_mdvec = mdvec; | 144 sbs->sbus_dev = dev; 145 sbs->sbus_mdvec = mdvec; |
146 isp->isp_dev = dev; 147 mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); |
|
157 158 role = 0; 159 if (resource_int_value(device_get_name(dev), device_get_unit(dev), 160 "role", &role) == 0 && 161 ((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) { 162 device_printf(dev, "setting role to 0x%x\n", role); 163 } else { 164 role = ISP_DEFAULT_ROLES; --- 9 unchanged lines hidden (view full) --- 174 goto bad; 175 } 176 177 sbs->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; 178 sbs->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF; 179 sbs->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF; 180 sbs->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF; 181 sbs->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF; | 148 149 role = 0; 150 if (resource_int_value(device_get_name(dev), device_get_unit(dev), 151 "role", &role) == 0 && 152 ((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) { 153 device_printf(dev, "setting role to 0x%x\n", role); 154 } else { 155 role = ISP_DEFAULT_ROLES; --- 9 unchanged lines hidden (view full) --- 165 goto bad; 166 } 167 168 sbs->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; 169 sbs->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF; 170 sbs->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF; 171 sbs->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF; 172 sbs->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF; |
182 isp = &sbs->sbus_isp; | |
183 isp->isp_regs = sbs->regs; 184 isp->isp_mdvec = &sbs->sbus_mdvec; 185 isp->isp_bustype = ISP_BT_SBUS; 186 isp->isp_type = ISP_HA_SCSI_UNKNOWN; 187 isp->isp_param = &sbs->sbus_param; 188 isp->isp_osinfo.pc.ptr = &sbs->sbus_spi; 189 isp->isp_revision = 0; /* XXX */ | 173 isp->isp_regs = sbs->regs; 174 isp->isp_mdvec = &sbs->sbus_mdvec; 175 isp->isp_bustype = ISP_BT_SBUS; 176 isp->isp_type = ISP_HA_SCSI_UNKNOWN; 177 isp->isp_param = &sbs->sbus_param; 178 isp->isp_osinfo.pc.ptr = &sbs->sbus_spi; 179 isp->isp_revision = 0; /* XXX */ |
190 isp->isp_dev = dev; | |
191 isp->isp_nchan = 1; 192 if (IS_FC(isp)) 193 ISP_FC_PC(isp, 0)->def_role = role; 194 195 /* 196 * Get the clock frequency and convert it from HZ to MHz, 197 * rounding up. This defaults to 25MHz if there isn't a 198 * device specific one in the OFW device tree. --- 62 unchanged lines hidden (view full) --- 261 default_id = OF_getscsinitid(dev); 262 } 263 ISP_SPI_PC(isp, 0)->iid = default_id; 264 265 isp_debug = 0; 266 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), 267 "debug", &isp_debug); 268 | 180 isp->isp_nchan = 1; 181 if (IS_FC(isp)) 182 ISP_FC_PC(isp, 0)->def_role = role; 183 184 /* 185 * Get the clock frequency and convert it from HZ to MHz, 186 * rounding up. This defaults to 25MHz if there isn't a 187 * device specific one in the OFW device tree. --- 62 unchanged lines hidden (view full) --- 250 default_id = OF_getscsinitid(dev); 251 } 252 ISP_SPI_PC(isp, 0)->iid = default_id; 253 254 isp_debug = 0; 255 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), 256 "debug", &isp_debug); 257 |
269 /* Make sure the lock is set up. */ 270 mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); 271 locksetup++; 272 | |
273 sbs->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sbs->iqd, 274 RF_ACTIVE | RF_SHAREABLE); 275 if (sbs->irq == NULL) { 276 device_printf(dev, "could not allocate interrupt\n"); 277 goto bad; 278 } 279 280 if (isp_setup_intr(dev, sbs->irq, ISP_IFLAGS, NULL, isp_platform_intr, --- 15 unchanged lines hidden (view full) --- 296 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; 297 } 298 299 /* 300 * Make sure we're in reset state. 301 */ 302 ISP_LOCK(isp); 303 if (isp_reinit(isp, 1) != 0) { | 258 sbs->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sbs->iqd, 259 RF_ACTIVE | RF_SHAREABLE); 260 if (sbs->irq == NULL) { 261 device_printf(dev, "could not allocate interrupt\n"); 262 goto bad; 263 } 264 265 if (isp_setup_intr(dev, sbs->irq, ISP_IFLAGS, NULL, isp_platform_intr, --- 15 unchanged lines hidden (view full) --- 281 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; 282 } 283 284 /* 285 * Make sure we're in reset state. 286 */ 287 ISP_LOCK(isp); 288 if (isp_reinit(isp, 1) != 0) { |
304 isp_uninit(isp); | |
305 ISP_UNLOCK(isp); 306 goto bad; 307 } 308 ISP_UNLOCK(isp); 309 if (isp_attach(isp)) { 310 ISP_LOCK(isp); | 289 ISP_UNLOCK(isp); 290 goto bad; 291 } 292 ISP_UNLOCK(isp); 293 if (isp_attach(isp)) { 294 ISP_LOCK(isp); |
311 isp_uninit(isp); | 295 isp_shutdown(isp); |
312 ISP_UNLOCK(isp); 313 goto bad; 314 } 315 return (0); 316 317bad: 318 319 if (sbs && ints_setup) { 320 (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); 321 } 322 323 if (sbs && sbs->irq) { 324 bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq); 325 } 326 | 296 ISP_UNLOCK(isp); 297 goto bad; 298 } 299 return (0); 300 301bad: 302 303 if (sbs && ints_setup) { 304 (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); 305 } 306 307 if (sbs && sbs->irq) { 308 bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq); 309 } 310 |
327 if (locksetup && isp) { 328 mtx_destroy(&isp->isp_osinfo.lock); 329 } 330 | |
331 if (sbs->regs) { 332 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, 333 sbs->regs); 334 } | 311 if (sbs->regs) { 312 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, 313 sbs->regs); 314 } |
315 mtx_destroy(&isp->isp_osinfo.lock); |
|
335 return (ENXIO); 336} 337 338static int 339isp_sbus_detach(device_t dev) 340{ | 316 return (ENXIO); 317} 318 319static int 320isp_sbus_detach(device_t dev) 321{ |
341 struct isp_sbussoftc *sbs; 342 ispsoftc_t *isp; | 322 struct isp_sbussoftc *sbs = device_get_softc(dev); 323 ispsoftc_t *isp = &sbs->sbus_isp; |
343 int status; 344 | 324 int status; 325 |
345 sbs = device_get_softc(dev); 346 if (sbs == NULL) { 347 return (ENXIO); 348 } 349 isp = (ispsoftc_t *) sbs; | |
350 status = isp_detach(isp); 351 if (status) 352 return (status); 353 ISP_LOCK(isp); | 326 status = isp_detach(isp); 327 if (status) 328 return (status); 329 ISP_LOCK(isp); |
354 isp_uninit(isp); 355 if (sbs->ih) { 356 (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); 357 } | 330 isp_shutdown(isp); |
358 ISP_UNLOCK(isp); | 331 ISP_UNLOCK(isp); |
359 mtx_destroy(&isp->isp_osinfo.lock); | 332 if (sbs->ih) 333 (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); |
360 (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq); 361 (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); | 334 (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq); 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); |
|
362 return (0); 363} 364 365#define IspVirt2Off(a, x) \ 366 (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ 367 _BLK_REG_SHFT] + ((x) & 0xff)) 368 369#define BXR2(isp, off) bus_read_2((isp)->isp_regs, (off)) --- 61 unchanged lines hidden (view full) --- 431static int 432isp_sbus_mbxdma(ispsoftc_t *isp) 433{ 434 caddr_t base; 435 uint32_t len; 436 int i, error; 437 struct imush im; 438 | 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)) --- 61 unchanged lines hidden (view full) --- 407static int 408isp_sbus_mbxdma(ispsoftc_t *isp) 409{ 410 caddr_t base; 411 uint32_t len; 412 int i, error; 413 struct imush im; 414 |
439 /* 440 * Already been here? If so, leave... 441 */ 442 if (isp->isp_rquest) { | 415 /* Already been here? If so, leave... */ 416 if (isp->isp_xflist != NULL) |
443 return (0); | 417 return (0); |
444 } 445 | 418 if (isp->isp_rquest != NULL && isp->isp_maxcmds == 0) 419 return (0); |
446 ISP_UNLOCK(isp); | 420 ISP_UNLOCK(isp); |
421 if (isp->isp_rquest != NULL) 422 goto gotmaxcmds; |
|
447 | 423 |
448 len = sizeof (struct isp_pcmd) * isp->isp_maxcmds; 449 isp->isp_osinfo.pcmd_pool = (struct isp_pcmd *) 450 malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); 451 len = sizeof (isp_hdl_t *) * isp->isp_maxcmds; 452 isp->isp_xflist = (isp_hdl_t *) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); 453 for (len = 0; len < isp->isp_maxcmds - 1; len++) { 454 isp->isp_xflist[len].cmd = &isp->isp_xflist[len+1]; 455 } 456 isp->isp_xffree = isp->isp_xflist; 457 len = sizeof (bus_dmamap_t) * isp->isp_maxcmds; 458 | |
459 if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_SBD(isp)), 1, 460 BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, 461 BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 462 ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_osinfo.dmat)) { 463 isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); 464 goto bad; 465 } 466 --- 8 unchanged lines hidden (view full) --- 475 goto bad; 476 } 477 if (bus_dmamem_alloc(isp->isp_osinfo.reqdmat, (void **)&base, 478 BUS_DMA_COHERENT, &isp->isp_osinfo.reqmap) != 0) { 479 isp_prt(isp, ISP_LOGERR, "cannot allocate request DMA memory"); 480 bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); 481 goto bad; 482 } | 424 if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_SBD(isp)), 1, 425 BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, 426 BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 427 ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_osinfo.dmat)) { 428 isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); 429 goto bad; 430 } 431 --- 8 unchanged lines hidden (view full) --- 440 goto bad; 441 } 442 if (bus_dmamem_alloc(isp->isp_osinfo.reqdmat, (void **)&base, 443 BUS_DMA_COHERENT, &isp->isp_osinfo.reqmap) != 0) { 444 isp_prt(isp, ISP_LOGERR, "cannot allocate request DMA memory"); 445 bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); 446 goto bad; 447 } |
448 isp->isp_rquest = base; |
|
483 im.error = 0; 484 if (bus_dmamap_load(isp->isp_osinfo.reqdmat, isp->isp_osinfo.reqmap, 485 base, len, imc, &im, 0) || im.error) { 486 isp_prt(isp, ISP_LOGERR, "error loading request DMA map %d", im.error); 487 goto bad; 488 } 489 isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx", 490 (uintmax_t)im.maddr, (uintmax_t)len); | 449 im.error = 0; 450 if (bus_dmamap_load(isp->isp_osinfo.reqdmat, isp->isp_osinfo.reqmap, 451 base, len, imc, &im, 0) || im.error) { 452 isp_prt(isp, ISP_LOGERR, "error loading request DMA map %d", im.error); 453 goto bad; 454 } 455 isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx", 456 (uintmax_t)im.maddr, (uintmax_t)len); |
491 isp->isp_rquest = base; | |
492 isp->isp_rquest_dma = im.maddr; 493 494 /* 495 * Allocate and map the result queue. 496 */ 497 len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); 498 if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, 499 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, 500 len, 1, len, 0, &isp->isp_osinfo.respdmat)) { 501 isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); 502 goto bad; 503 } 504 if (bus_dmamem_alloc(isp->isp_osinfo.respdmat, (void **)&base, 505 BUS_DMA_COHERENT, &isp->isp_osinfo.respmap) != 0) { 506 isp_prt(isp, ISP_LOGERR, "cannot allocate response DMA memory"); 507 bus_dma_tag_destroy(isp->isp_osinfo.respdmat); 508 goto bad; 509 } | 457 isp->isp_rquest_dma = im.maddr; 458 459 /* 460 * Allocate and map the result queue. 461 */ 462 len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); 463 if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, 464 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, 465 len, 1, len, 0, &isp->isp_osinfo.respdmat)) { 466 isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); 467 goto bad; 468 } 469 if (bus_dmamem_alloc(isp->isp_osinfo.respdmat, (void **)&base, 470 BUS_DMA_COHERENT, &isp->isp_osinfo.respmap) != 0) { 471 isp_prt(isp, ISP_LOGERR, "cannot allocate response DMA memory"); 472 bus_dma_tag_destroy(isp->isp_osinfo.respdmat); 473 goto bad; 474 } |
475 isp->isp_result = base; |
|
510 im.error = 0; 511 if (bus_dmamap_load(isp->isp_osinfo.respdmat, isp->isp_osinfo.respmap, 512 base, len, imc, &im, 0) || im.error) { 513 isp_prt(isp, ISP_LOGERR, "error loading response DMA map %d", im.error); 514 goto bad; 515 } 516 isp_prt(isp, ISP_LOGDEBUG0, "response area @ 0x%jx/0x%jx", 517 (uintmax_t)im.maddr, (uintmax_t)len); | 476 im.error = 0; 477 if (bus_dmamap_load(isp->isp_osinfo.respdmat, isp->isp_osinfo.respmap, 478 base, len, imc, &im, 0) || im.error) { 479 isp_prt(isp, ISP_LOGERR, "error loading response DMA map %d", im.error); 480 goto bad; 481 } 482 isp_prt(isp, ISP_LOGDEBUG0, "response area @ 0x%jx/0x%jx", 483 (uintmax_t)im.maddr, (uintmax_t)len); |
518 isp->isp_result = base; | |
519 isp->isp_result_dma = im.maddr; 520 | 484 isp->isp_result_dma = im.maddr; 485 |
486 if (isp->isp_maxcmds == 0) { 487 ISP_LOCK(isp); 488 return (0); 489 } 490 491gotmaxcmds: 492 len = sizeof (struct isp_pcmd) * isp->isp_maxcmds; 493 isp->isp_osinfo.pcmd_pool = (struct isp_pcmd *) 494 malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); |
|
521 for (i = 0; i < isp->isp_maxcmds; i++) { 522 struct isp_pcmd *pcmd = &isp->isp_osinfo.pcmd_pool[i]; 523 error = bus_dmamap_create(isp->isp_osinfo.dmat, 0, &pcmd->dmap); 524 if (error) { 525 isp_prt(isp, ISP_LOGERR, 526 "error %d creating per-cmd DMA maps", error); 527 while (--i >= 0) { 528 bus_dmamap_destroy(isp->isp_osinfo.dmat, --- 4 unchanged lines hidden (view full) --- 533 callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); 534 if (i == isp->isp_maxcmds-1) { 535 pcmd->next = NULL; 536 } else { 537 pcmd->next = &isp->isp_osinfo.pcmd_pool[i+1]; 538 } 539 } 540 isp->isp_osinfo.pcmd_free = &isp->isp_osinfo.pcmd_pool[0]; | 495 for (i = 0; i < isp->isp_maxcmds; i++) { 496 struct isp_pcmd *pcmd = &isp->isp_osinfo.pcmd_pool[i]; 497 error = bus_dmamap_create(isp->isp_osinfo.dmat, 0, &pcmd->dmap); 498 if (error) { 499 isp_prt(isp, ISP_LOGERR, 500 "error %d creating per-cmd DMA maps", error); 501 while (--i >= 0) { 502 bus_dmamap_destroy(isp->isp_osinfo.dmat, --- 4 unchanged lines hidden (view full) --- 507 callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); 508 if (i == isp->isp_maxcmds-1) { 509 pcmd->next = NULL; 510 } else { 511 pcmd->next = &isp->isp_osinfo.pcmd_pool[i+1]; 512 } 513 } 514 isp->isp_osinfo.pcmd_free = &isp->isp_osinfo.pcmd_pool[0]; |
515 516 len = sizeof (isp_hdl_t *) * isp->isp_maxcmds; 517 isp->isp_xflist = (isp_hdl_t *) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); 518 for (len = 0; len < isp->isp_maxcmds - 1; len++) 519 isp->isp_xflist[len].cmd = &isp->isp_xflist[len+1]; 520 isp->isp_xffree = isp->isp_xflist; 521 |
|
541 ISP_LOCK(isp); 542 return (0); 543 544bad: | 522 ISP_LOCK(isp); 523 return (0); 524 525bad: |
545 if (isp->isp_rquest_dma != 0) { 546 bus_dmamap_unload(isp->isp_osinfo.reqdmat, 547 isp->isp_osinfo.reqmap); | 526 isp_sbus_mbxdmafree(isp); 527 ISP_LOCK(isp); 528 return (1); 529} 530 531static void 532isp_sbus_mbxdmafree(ispsoftc_t *isp) 533{ 534 int i; 535 536 if (isp->isp_xflist != NULL) { 537 free(isp->isp_xflist, M_DEVBUF); 538 isp->isp_xflist = NULL; |
548 } | 539 } |
549 if (isp->isp_rquest != NULL) { 550 bus_dmamem_free(isp->isp_osinfo.reqdmat, isp->isp_rquest, 551 isp->isp_osinfo.reqmap); 552 bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); | 540 if (isp->isp_osinfo.pcmd_pool != NULL) { 541 for (i = 0; i < isp->isp_maxcmds; i++) { 542 bus_dmamap_destroy(isp->isp_osinfo.dmat, 543 isp->isp_osinfo.pcmd_pool[i].dmap); 544 } 545 free(isp->isp_osinfo.pcmd_pool, M_DEVBUF); 546 isp->isp_osinfo.pcmd_pool = NULL; |
553 } 554 if (isp->isp_result_dma != 0) { 555 bus_dmamap_unload(isp->isp_osinfo.respdmat, 556 isp->isp_osinfo.respmap); | 547 } 548 if (isp->isp_result_dma != 0) { 549 bus_dmamap_unload(isp->isp_osinfo.respdmat, 550 isp->isp_osinfo.respmap); |
551 isp->isp_result_dma = 0; |
|
557 } 558 if (isp->isp_result != NULL) { 559 bus_dmamem_free(isp->isp_osinfo.respdmat, isp->isp_result, 560 isp->isp_osinfo.respmap); 561 bus_dma_tag_destroy(isp->isp_osinfo.respdmat); | 552 } 553 if (isp->isp_result != NULL) { 554 bus_dmamem_free(isp->isp_osinfo.respdmat, isp->isp_result, 555 isp->isp_osinfo.respmap); 556 bus_dma_tag_destroy(isp->isp_osinfo.respdmat); |
557 isp->isp_result = NULL; |
|
562 } | 558 } |
563 free(isp->isp_xflist, M_DEVBUF); 564 free(isp->isp_osinfo.pcmd_pool, M_DEVBUF); 565 isp->isp_rquest = NULL; 566 ISP_LOCK(isp); 567 return (1); | 559 if (isp->isp_rquest_dma != 0) { 560 bus_dmamap_unload(isp->isp_osinfo.reqdmat, 561 isp->isp_osinfo.reqmap); 562 isp->isp_rquest_dma = 0; 563 } 564 if (isp->isp_rquest != NULL) { 565 bus_dmamem_free(isp->isp_osinfo.reqdmat, isp->isp_rquest, 566 isp->isp_osinfo.reqmap); 567 bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); 568 isp->isp_rquest = NULL; 569 } |
568} 569 570typedef struct { 571 ispsoftc_t *isp; 572 void *cmd_token; 573 void *rq; /* original request */ 574 int error; 575 bus_size_t mapsize; --- 82 unchanged lines hidden (view full) --- 658 XS_SETERR(csio, CAM_UNREC_HBA_ERROR); 659 } 660 return (retval); 661 } 662 return (CMD_QUEUED); 663} 664 665static void | 570} 571 572typedef struct { 573 ispsoftc_t *isp; 574 void *cmd_token; 575 void *rq; /* original request */ 576 int error; 577 bus_size_t mapsize; --- 82 unchanged lines hidden (view full) --- 660 XS_SETERR(csio, CAM_UNREC_HBA_ERROR); 661 } 662 return (retval); 663 } 664 return (CMD_QUEUED); 665} 666 667static void |
666isp_sbus_reset0(ispsoftc_t *isp) 667{ 668 ISP_DISABLE_INTS(isp); 669} 670 671static void 672isp_sbus_reset1(ispsoftc_t *isp) 673{ 674 ISP_ENABLE_INTS(isp); 675} 676 677static void | |
678isp_sbus_dumpregs(ispsoftc_t *isp, const char *msg) 679{ 680 if (msg) 681 printf("%s: %s\n", device_get_nameunit(isp->isp_dev), msg); 682 else 683 printf("%s:\n", device_get_nameunit(isp->isp_dev)); 684 printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1)); 685 printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR), --- 21 unchanged lines hidden --- | 668isp_sbus_dumpregs(ispsoftc_t *isp, const char *msg) 669{ 670 if (msg) 671 printf("%s: %s\n", device_get_nameunit(isp->isp_dev), msg); 672 else 673 printf("%s:\n", device_get_nameunit(isp->isp_dev)); 674 printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1)); 675 printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR), --- 21 unchanged lines hidden --- |