2003-08-24 17:55:58 +00:00
|
|
|
/*-
|
2006-01-23 06:23:37 +00:00
|
|
|
* Copyright (c) 1997-2006 by Matthew Jacob
|
|
|
|
* All rights reserved.
|
2002-07-11 03:25:04 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2006-07-16 20:11:50 +00:00
|
|
|
/*
|
|
|
|
* SBus specific probe and attach routines for Qlogic ISP SCSI adapters.
|
|
|
|
* FreeBSD Version.
|
|
|
|
*/
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
Convert isp(4) and ispfw(4) to use firmware(9) to manage firmware
loading for the QLogic cards.
Because isp(4) exists before the root is mounted, it's not really
possible for us to use the kernel's linker to load modules directly
from disk- that's really too bad.
However, the this is still a net win in in that the firmware has
been split up on a per chip (and in some cases, functionality)
basis, so the amount of stuff loaded *can* be substantially less
than the 1.5MB of firmware images that ispfw now manages. That is,
each specific f/w set is now also built as a module. For example,
QLogic 2322 f/w is built as isp_2322.ko and Initiator/Target 1080
firmware is built as isp_1080_it.ko.
For compatibility purposes (i.e., to perturb folks the least), we
also still build all of the firmware as one ispfw.ko module.
This allows us to let 'ispfw_LOAD' keep on working in existing
loader.conf files. If you now want to strip this down to just
the firmware for your h/w, you can then change loader.conf to
load the f/w you specifically want.
We also still allow for ispfw to be statically built (e.g., for
PAE and sparc64).
Future changes will look at f/w unloading and also role switching
that then uses the kernel linker to load different ips f/w sets.
MFC after: 2 months
2006-07-09 17:50:20 +00:00
|
|
|
#include <sys/linker.h>
|
|
|
|
#include <sys/firmware.h>
|
2002-07-11 03:25:04 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-06-03 06:10:02 +00:00
|
|
|
#include <sys/module.h>
|
2002-07-11 03:25:04 +00:00
|
|
|
#include <sys/resource.h>
|
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.
Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
|
|
|
|
|
|
|
#include <dev/ofw/ofw_bus.h>
|
2010-05-03 18:39:40 +00:00
|
|
|
#include <dev/ofw/openfirm.h>
|
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.
Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
|
|
|
|
2002-07-11 03:25:04 +00:00
|
|
|
#include <machine/bus.h>
|
2010-05-03 18:39:40 +00:00
|
|
|
#include <machine/ofw_machdep.h>
|
2002-07-11 03:25:04 +00:00
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <sparc64/sbus/sbusvar.h>
|
|
|
|
|
|
|
|
#include <dev/isp/isp_freebsd.h>
|
|
|
|
|
2009-08-01 01:04:26 +00:00
|
|
|
static uint32_t isp_sbus_rd_reg(ispsoftc_t *, int);
|
|
|
|
static void isp_sbus_wr_reg(ispsoftc_t *, int, uint32_t);
|
2015-10-23 21:01:46 +00:00
|
|
|
static int isp_sbus_rd_isr(ispsoftc_t *, uint16_t *, uint16_t *, uint16_t *);
|
2006-04-21 18:30:01 +00:00
|
|
|
static int isp_sbus_mbxdma(ispsoftc_t *);
|
2017-03-14 08:03:56 +00:00
|
|
|
static void isp_sbus_mbxdmafree(ispsoftc_t *);
|
2009-08-01 01:04:26 +00:00
|
|
|
static int isp_sbus_dmasetup(ispsoftc_t *, XS_T *, void *);
|
2006-04-21 18:30:01 +00:00
|
|
|
static void isp_sbus_dumpregs(ispsoftc_t *, const char *);
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
static struct ispmdvec mdvec = {
|
|
|
|
isp_sbus_rd_isr,
|
|
|
|
isp_sbus_rd_reg,
|
|
|
|
isp_sbus_wr_reg,
|
|
|
|
isp_sbus_mbxdma,
|
|
|
|
isp_sbus_dmasetup,
|
2007-05-05 20:17:23 +00:00
|
|
|
isp_common_dmateardown,
|
2017-03-14 08:03:56 +00:00
|
|
|
NULL,
|
2002-07-11 03:25:04 +00:00
|
|
|
isp_sbus_dumpregs,
|
|
|
|
NULL,
|
|
|
|
BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
|
|
|
|
};
|
|
|
|
|
|
|
|
static int isp_sbus_probe (device_t);
|
|
|
|
static int isp_sbus_attach (device_t);
|
2012-08-04 00:00:30 +00:00
|
|
|
static int isp_sbus_detach (device_t);
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
|
2007-05-11 06:28:26 +00:00
|
|
|
#define ISP_SBD(isp) ((struct isp_sbussoftc *)isp)->sbus_dev
|
2002-07-11 03:25:04 +00:00
|
|
|
struct isp_sbussoftc {
|
2006-04-21 18:30:01 +00:00
|
|
|
ispsoftc_t sbus_isp;
|
2002-07-11 03:25:04 +00:00
|
|
|
device_t sbus_dev;
|
2012-08-04 00:00:30 +00:00
|
|
|
struct resource * regs;
|
|
|
|
void * irq;
|
|
|
|
int iqd;
|
|
|
|
int rgd;
|
2002-07-11 03:25:04 +00:00
|
|
|
void * ih;
|
|
|
|
int16_t sbus_poff[_NREG_BLKS];
|
|
|
|
sdparam sbus_param;
|
2009-08-01 01:04:26 +00:00
|
|
|
struct isp_spi sbus_spi;
|
2002-07-11 03:25:04 +00:00
|
|
|
struct ispmdvec sbus_mdvec;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static device_method_t isp_sbus_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, isp_sbus_probe),
|
|
|
|
DEVMETHOD(device_attach, isp_sbus_attach),
|
2012-08-04 00:00:30 +00:00
|
|
|
DEVMETHOD(device_detach, isp_sbus_detach),
|
2002-07-11 03:25:04 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t isp_sbus_driver = {
|
|
|
|
"isp", isp_sbus_methods, sizeof (struct isp_sbussoftc)
|
|
|
|
};
|
|
|
|
static devclass_t isp_devclass;
|
|
|
|
DRIVER_MODULE(isp, sbus, isp_sbus_driver, isp_devclass, 0, 0);
|
2012-06-01 04:34:49 +00:00
|
|
|
MODULE_DEPEND(isp, cam, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(isp, firmware, 1, 1, 1);
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
isp_sbus_probe(device_t dev)
|
|
|
|
{
|
|
|
|
int found = 0;
|
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.
Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
|
|
|
const char *name = ofw_bus_get_name(dev);
|
2002-07-11 03:25:04 +00:00
|
|
|
if (strcmp(name, "SUNW,isp") == 0 ||
|
|
|
|
strcmp(name, "QLGC,isp") == 0 ||
|
|
|
|
strcmp(name, "ptisp") == 0 ||
|
|
|
|
strcmp(name, "PTI,ptisp") == 0) {
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if (isp_announced == 0 && bootverbose) {
|
|
|
|
printf("Qlogic ISP Driver, FreeBSD Version %d.%d, "
|
|
|
|
"Core Version %d.%d\n",
|
|
|
|
ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR,
|
|
|
|
ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR);
|
|
|
|
isp_announced++;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
isp_sbus_attach(device_t dev)
|
|
|
|
{
|
2017-03-14 08:03:56 +00:00
|
|
|
struct isp_sbussoftc *sbs = device_get_softc(dev);
|
|
|
|
ispsoftc_t *isp = &sbs->sbus_isp;
|
2012-08-04 00:00:30 +00:00
|
|
|
int tval, isp_debug, role, ispburst, default_id;
|
2006-11-02 03:21:32 +00:00
|
|
|
int ints_setup = 0;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
sbs->sbus_dev = dev;
|
|
|
|
sbs->sbus_mdvec = mdvec;
|
2017-03-14 08:03:56 +00:00
|
|
|
isp->isp_dev = dev;
|
|
|
|
mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF);
|
2012-08-04 00:00:30 +00:00
|
|
|
|
2002-07-11 03:25:04 +00:00
|
|
|
role = 0;
|
|
|
|
if (resource_int_value(device_get_name(dev), device_get_unit(dev),
|
|
|
|
"role", &role) == 0 &&
|
|
|
|
((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) {
|
|
|
|
device_printf(dev, "setting role to 0x%x\n", role);
|
|
|
|
} else {
|
|
|
|
role = ISP_DEFAULT_ROLES;
|
|
|
|
}
|
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
sbs->irq = sbs->regs = NULL;
|
|
|
|
sbs->rgd = sbs->iqd = 0;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
sbs->regs = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sbs->rgd,
|
|
|
|
RF_ACTIVE);
|
|
|
|
if (sbs->regs == NULL) {
|
2002-07-11 03:25:04 +00:00
|
|
|
device_printf(dev, "unable to map registers\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
sbs->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF;
|
|
|
|
sbs->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF;
|
|
|
|
sbs->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF;
|
|
|
|
sbs->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF;
|
|
|
|
sbs->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF;
|
2015-12-04 19:46:49 +00:00
|
|
|
isp->isp_regs = sbs->regs;
|
2002-07-11 03:25:04 +00:00
|
|
|
isp->isp_mdvec = &sbs->sbus_mdvec;
|
|
|
|
isp->isp_bustype = ISP_BT_SBUS;
|
|
|
|
isp->isp_type = ISP_HA_SCSI_UNKNOWN;
|
|
|
|
isp->isp_param = &sbs->sbus_param;
|
2009-08-01 01:04:26 +00:00
|
|
|
isp->isp_osinfo.pc.ptr = &sbs->sbus_spi;
|
2002-07-11 03:25:04 +00:00
|
|
|
isp->isp_revision = 0; /* XXX */
|
2009-11-02 21:22:30 +00:00
|
|
|
isp->isp_nchan = 1;
|
2015-11-23 10:06:19 +00:00
|
|
|
if (IS_FC(isp))
|
|
|
|
ISP_FC_PC(isp, 0)->def_role = role;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2006-02-03 12:35:42 +00:00
|
|
|
/*
|
|
|
|
* Get the clock frequency and convert it from HZ to MHz,
|
|
|
|
* rounding up. This defaults to 25MHz if there isn't a
|
|
|
|
* device specific one in the OFW device tree.
|
|
|
|
*/
|
|
|
|
sbs->sbus_mdvec.dv_clock = (sbus_get_clockfreq(dev) + 500000)/1000000;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now figure out what the proper burst sizes, etc., to use.
|
|
|
|
* Unfortunately, there is no ddi_dma_burstsizes here which
|
|
|
|
* walks up the tree finding the limiting burst size node (if
|
|
|
|
* any). We just use what's here for isp.
|
|
|
|
*/
|
|
|
|
ispburst = sbus_get_burstsz(dev);
|
|
|
|
if (ispburst == 0) {
|
|
|
|
ispburst = SBUS_BURST_32 - 1;
|
|
|
|
}
|
|
|
|
sbs->sbus_mdvec.dv_conf1 = 0;
|
|
|
|
if (ispburst & (1 << 5)) {
|
|
|
|
sbs->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_32;
|
|
|
|
} else if (ispburst & (1 << 4)) {
|
|
|
|
sbs->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_16;
|
|
|
|
} else if (ispburst & (1 << 3)) {
|
|
|
|
sbs->sbus_mdvec.dv_conf1 =
|
|
|
|
BIU_SBUS_CONF1_BURST8 | BIU_SBUS_CONF1_FIFO_8;
|
|
|
|
}
|
|
|
|
if (sbs->sbus_mdvec.dv_conf1) {
|
|
|
|
sbs->sbus_mdvec.dv_conf1 |= BIU_BURST_ENABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-11-02 03:21:32 +00:00
|
|
|
* We don't trust NVRAM on SBus cards
|
2002-07-11 03:25:04 +00:00
|
|
|
*/
|
2006-11-02 03:21:32 +00:00
|
|
|
isp->isp_confopts |= ISP_CFG_NONVRAM;
|
2002-07-25 20:49:30 +00:00
|
|
|
|
|
|
|
/*
|
2006-11-02 03:21:32 +00:00
|
|
|
* Mark things if we're a PTI SBus adapter.
|
2002-07-25 20:49:30 +00:00
|
|
|
*/
|
2006-11-02 03:21:32 +00:00
|
|
|
if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 ||
|
|
|
|
strcmp("ptisp", ofw_bus_get_name(dev)) == 0) {
|
2009-08-01 01:04:26 +00:00
|
|
|
SDPARAM(isp, 0)->isp_ptisp = 1;
|
2006-11-02 03:21:32 +00:00
|
|
|
}
|
2002-07-25 20:49:30 +00:00
|
|
|
|
Convert isp(4) and ispfw(4) to use firmware(9) to manage firmware
loading for the QLogic cards.
Because isp(4) exists before the root is mounted, it's not really
possible for us to use the kernel's linker to load modules directly
from disk- that's really too bad.
However, the this is still a net win in in that the firmware has
been split up on a per chip (and in some cases, functionality)
basis, so the amount of stuff loaded *can* be substantially less
than the 1.5MB of firmware images that ispfw now manages. That is,
each specific f/w set is now also built as a module. For example,
QLogic 2322 f/w is built as isp_2322.ko and Initiator/Target 1080
firmware is built as isp_1080_it.ko.
For compatibility purposes (i.e., to perturb folks the least), we
also still build all of the firmware as one ispfw.ko module.
This allows us to let 'ispfw_LOAD' keep on working in existing
loader.conf files. If you now want to strip this down to just
the firmware for your h/w, you can then change loader.conf to
load the f/w you specifically want.
We also still allow for ispfw to be statically built (e.g., for
PAE and sparc64).
Future changes will look at f/w unloading and also role switching
that then uses the kernel linker to load different ips f/w sets.
MFC after: 2 months
2006-07-09 17:50:20 +00:00
|
|
|
isp->isp_osinfo.fw = firmware_get("isp_1000");
|
|
|
|
if (isp->isp_osinfo.fw) {
|
|
|
|
union {
|
|
|
|
const void *cp;
|
|
|
|
uint16_t *sp;
|
|
|
|
} stupid;
|
|
|
|
stupid.cp = isp->isp_osinfo.fw->data;
|
|
|
|
isp->isp_mdvec->dv_ispfw = stupid.sp;
|
|
|
|
}
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
tval = 0;
|
|
|
|
if (resource_int_value(device_get_name(dev), device_get_unit(dev),
|
|
|
|
"fwload_disable", &tval) == 0 && tval != 0) {
|
|
|
|
isp->isp_confopts |= ISP_CFG_NORELOAD;
|
|
|
|
}
|
2002-07-25 20:49:30 +00:00
|
|
|
|
2009-08-01 01:04:26 +00:00
|
|
|
default_id = -1;
|
2002-07-25 20:49:30 +00:00
|
|
|
if (resource_int_value(device_get_name(dev), device_get_unit(dev),
|
|
|
|
"iid", &tval) == 0) {
|
2009-08-01 01:04:26 +00:00
|
|
|
default_id = tval;
|
2002-07-25 20:49:30 +00:00
|
|
|
isp->isp_confopts |= ISP_CFG_OWNLOOPID;
|
|
|
|
}
|
2009-08-01 01:04:26 +00:00
|
|
|
if (default_id == -1) {
|
2010-05-03 18:39:40 +00:00
|
|
|
default_id = OF_getscsinitid(dev);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
2009-08-01 01:04:26 +00:00
|
|
|
ISP_SPI_PC(isp, 0)->iid = default_id;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
isp_debug = 0;
|
|
|
|
(void) resource_int_value(device_get_name(dev), device_get_unit(dev),
|
|
|
|
"debug", &isp_debug);
|
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
sbs->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sbs->iqd,
|
2006-11-02 03:21:32 +00:00
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
2012-08-04 00:00:30 +00:00
|
|
|
if (sbs->irq == NULL) {
|
2006-11-02 03:21:32 +00:00
|
|
|
device_printf(dev, "could not allocate interrupt\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
if (isp_setup_intr(dev, sbs->irq, ISP_IFLAGS, NULL, isp_platform_intr,
|
|
|
|
isp, &sbs->ih)) {
|
2002-07-11 03:25:04 +00:00
|
|
|
device_printf(dev, "could not setup interrupt\n");
|
|
|
|
goto bad;
|
|
|
|
}
|
2006-11-02 03:21:32 +00:00
|
|
|
ints_setup++;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up logging levels.
|
|
|
|
*/
|
|
|
|
if (isp_debug) {
|
|
|
|
isp->isp_dblev = isp_debug;
|
|
|
|
} else {
|
|
|
|
isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR;
|
|
|
|
}
|
2006-11-02 03:21:32 +00:00
|
|
|
if (bootverbose) {
|
2002-07-11 03:25:04 +00:00
|
|
|
isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO;
|
2006-11-02 03:21:32 +00:00
|
|
|
}
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we're in reset state.
|
|
|
|
*/
|
2007-11-05 11:22:18 +00:00
|
|
|
ISP_LOCK(isp);
|
2015-10-25 10:49:05 +00:00
|
|
|
if (isp_reinit(isp, 1) != 0) {
|
2007-11-05 11:22:18 +00:00
|
|
|
ISP_UNLOCK(isp);
|
2002-07-11 03:25:04 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
2009-11-02 21:22:30 +00:00
|
|
|
ISP_UNLOCK(isp);
|
|
|
|
if (isp_attach(isp)) {
|
|
|
|
ISP_LOCK(isp);
|
2017-03-14 08:03:56 +00:00
|
|
|
isp_shutdown(isp);
|
2007-11-05 11:22:18 +00:00
|
|
|
ISP_UNLOCK(isp);
|
2002-07-11 03:25:04 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
bad:
|
|
|
|
|
2006-11-02 03:21:32 +00:00
|
|
|
if (sbs && ints_setup) {
|
2012-08-04 00:00:30 +00:00
|
|
|
(void) bus_teardown_intr(dev, sbs->irq, sbs->ih);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
if (sbs && sbs->irq) {
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
if (sbs->regs) {
|
|
|
|
(void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd,
|
|
|
|
sbs->regs);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
2017-03-14 08:03:56 +00:00
|
|
|
mtx_destroy(&isp->isp_osinfo.lock);
|
2012-08-04 00:00:30 +00:00
|
|
|
return (ENXIO);
|
|
|
|
}
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2012-08-04 00:00:30 +00:00
|
|
|
static int
|
|
|
|
isp_sbus_detach(device_t dev)
|
|
|
|
{
|
2017-03-14 08:03:56 +00:00
|
|
|
struct isp_sbussoftc *sbs = device_get_softc(dev);
|
|
|
|
ispsoftc_t *isp = &sbs->sbus_isp;
|
2012-08-04 00:00:30 +00:00
|
|
|
int status;
|
|
|
|
|
|
|
|
status = isp_detach(isp);
|
|
|
|
if (status)
|
|
|
|
return (status);
|
|
|
|
ISP_LOCK(isp);
|
2017-03-14 08:03:56 +00:00
|
|
|
isp_shutdown(isp);
|
2012-08-04 00:00:30 +00:00
|
|
|
ISP_UNLOCK(isp);
|
2017-03-14 08:03:56 +00:00
|
|
|
if (sbs->ih)
|
|
|
|
(void) bus_teardown_intr(dev, sbs->irq, sbs->ih);
|
2012-08-04 00:00:30 +00:00
|
|
|
(void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq);
|
|
|
|
(void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs);
|
2017-03-14 08:03:56 +00:00
|
|
|
isp_sbus_mbxdmafree(isp);
|
|
|
|
mtx_destroy(&isp->isp_osinfo.lock);
|
2012-08-04 00:00:30 +00:00
|
|
|
return (0);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define IspVirt2Off(a, x) \
|
|
|
|
(((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \
|
|
|
|
_BLK_REG_SHFT] + ((x) & 0xff))
|
|
|
|
|
2015-12-04 19:46:49 +00:00
|
|
|
#define BXR2(isp, off) bus_read_2((isp)->isp_regs, (off))
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
static int
|
2015-10-23 08:26:45 +00:00
|
|
|
isp_sbus_rd_isr(ispsoftc_t *isp, uint16_t *isrp, uint16_t *semap, uint16_t *info)
|
2002-07-11 03:25:04 +00:00
|
|
|
{
|
2006-02-15 00:31:48 +00:00
|
|
|
uint16_t isr, sema;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2015-12-04 19:46:49 +00:00
|
|
|
isr = BXR2(isp, IspVirt2Off(isp, BIU_ISR));
|
|
|
|
sema = BXR2(isp, IspVirt2Off(isp, BIU_SEMA));
|
2002-07-11 03:25:04 +00:00
|
|
|
isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema);
|
|
|
|
isr &= INT_PENDING_MASK(isp);
|
|
|
|
sema &= BIU_SEMA_LOCK;
|
|
|
|
if (isr == 0 && sema == 0) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
*isrp = isr;
|
2015-10-23 08:26:45 +00:00
|
|
|
if ((*semap = sema) != 0)
|
2015-12-04 19:46:49 +00:00
|
|
|
*info = BXR2(isp, IspVirt2Off(isp, OUTMAILBOX0));
|
2002-07-11 03:25:04 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2006-11-02 03:21:32 +00:00
|
|
|
static uint32_t
|
2006-04-21 18:30:01 +00:00
|
|
|
isp_sbus_rd_reg(ispsoftc_t *isp, int regoff)
|
2002-07-11 03:25:04 +00:00
|
|
|
{
|
2006-02-15 00:31:48 +00:00
|
|
|
uint16_t rval;
|
2002-07-11 03:25:04 +00:00
|
|
|
struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp;
|
|
|
|
int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
|
|
|
|
offset += (regoff & 0xff);
|
2015-12-04 19:46:49 +00:00
|
|
|
rval = BXR2(isp, offset);
|
2002-07-11 03:25:04 +00:00
|
|
|
isp_prt(isp, ISP_LOGDEBUG3,
|
|
|
|
"isp_sbus_rd_reg(off %x) = %x", regoff, rval);
|
|
|
|
return (rval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-11-02 03:21:32 +00:00
|
|
|
isp_sbus_wr_reg(ispsoftc_t *isp, int regoff, uint32_t val)
|
2002-07-11 03:25:04 +00:00
|
|
|
{
|
|
|
|
struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp;
|
|
|
|
int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
|
|
|
|
offset += (regoff & 0xff);
|
|
|
|
isp_prt(isp, ISP_LOGDEBUG3,
|
|
|
|
"isp_sbus_wr_reg(off %x) = %x", regoff, val);
|
2015-12-04 19:46:49 +00:00
|
|
|
bus_write_2(isp->isp_regs, offset, val);
|
2011-02-14 21:50:51 +00:00
|
|
|
MEMORYBARRIER(isp, SYNC_REG, offset, 2, -1);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct imush {
|
2015-12-27 06:16:02 +00:00
|
|
|
bus_addr_t maddr;
|
2002-07-11 03:25:04 +00:00
|
|
|
int error;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void imc(void *, bus_dma_segment_t *, int, int);
|
|
|
|
|
|
|
|
static void
|
|
|
|
imc(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
|
|
|
{
|
|
|
|
struct imush *imushp = (struct imush *) arg;
|
|
|
|
|
2015-12-27 06:16:02 +00:00
|
|
|
if (!(imushp->error = error))
|
|
|
|
imushp->maddr = segs[0].ds_addr;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-04-21 18:30:01 +00:00
|
|
|
isp_sbus_mbxdma(ispsoftc_t *isp)
|
2002-07-11 03:25:04 +00:00
|
|
|
{
|
|
|
|
caddr_t base;
|
2006-02-15 00:31:48 +00:00
|
|
|
uint32_t len;
|
2012-11-02 14:38:57 +00:00
|
|
|
int i, error;
|
2002-07-11 03:25:04 +00:00
|
|
|
struct imush im;
|
|
|
|
|
2017-03-14 08:03:56 +00:00
|
|
|
/* Already been here? If so, leave... */
|
|
|
|
if (isp->isp_xflist != NULL)
|
|
|
|
return (0);
|
|
|
|
if (isp->isp_rquest != NULL && isp->isp_maxcmds == 0)
|
2002-07-11 03:25:04 +00:00
|
|
|
return (0);
|
2002-07-25 16:02:09 +00:00
|
|
|
ISP_UNLOCK(isp);
|
2017-03-14 08:03:56 +00:00
|
|
|
if (isp->isp_rquest != NULL)
|
|
|
|
goto gotmaxcmds;
|
2007-05-05 20:17:23 +00:00
|
|
|
|
2007-05-11 13:47:28 +00:00
|
|
|
if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_SBD(isp)), 1,
|
2007-05-05 20:17:23 +00:00
|
|
|
BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT,
|
2012-08-21 16:18:11 +00:00
|
|
|
ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_osinfo.dmat)) {
|
2007-05-05 20:17:23 +00:00
|
|
|
isp_prt(isp, ISP_LOGERR, "could not create master dma tag");
|
2015-12-27 06:16:02 +00:00
|
|
|
goto bad;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-12-27 06:16:02 +00:00
|
|
|
* Allocate and map the request queue.
|
2002-07-11 03:25:04 +00:00
|
|
|
*/
|
|
|
|
len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
|
2015-12-27 06:16:02 +00:00
|
|
|
if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
len, 1, len, 0, &isp->isp_osinfo.reqdmat)) {
|
|
|
|
isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
if (bus_dmamem_alloc(isp->isp_osinfo.reqdmat, (void **)&base,
|
|
|
|
BUS_DMA_COHERENT, &isp->isp_osinfo.reqmap) != 0) {
|
|
|
|
isp_prt(isp, ISP_LOGERR, "cannot allocate request DMA memory");
|
|
|
|
bus_dma_tag_destroy(isp->isp_osinfo.reqdmat);
|
|
|
|
goto bad;
|
|
|
|
}
|
2017-03-14 08:03:56 +00:00
|
|
|
isp->isp_rquest = base;
|
2015-12-27 06:16:02 +00:00
|
|
|
im.error = 0;
|
|
|
|
if (bus_dmamap_load(isp->isp_osinfo.reqdmat, isp->isp_osinfo.reqmap,
|
|
|
|
base, len, imc, &im, 0) || im.error) {
|
|
|
|
isp_prt(isp, ISP_LOGERR, "error loading request DMA map %d", im.error);
|
|
|
|
goto bad;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
2015-12-27 06:16:02 +00:00
|
|
|
isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx",
|
|
|
|
(uintmax_t)im.maddr, (uintmax_t)len);
|
|
|
|
isp->isp_rquest_dma = im.maddr;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2015-12-27 06:16:02 +00:00
|
|
|
/*
|
|
|
|
* Allocate and map the result queue.
|
|
|
|
*/
|
|
|
|
len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp));
|
|
|
|
if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
len, 1, len, 0, &isp->isp_osinfo.respdmat)) {
|
|
|
|
isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
if (bus_dmamem_alloc(isp->isp_osinfo.respdmat, (void **)&base,
|
|
|
|
BUS_DMA_COHERENT, &isp->isp_osinfo.respmap) != 0) {
|
|
|
|
isp_prt(isp, ISP_LOGERR, "cannot allocate response DMA memory");
|
|
|
|
bus_dma_tag_destroy(isp->isp_osinfo.respdmat);
|
|
|
|
goto bad;
|
|
|
|
}
|
2017-03-14 08:03:56 +00:00
|
|
|
isp->isp_result = base;
|
2015-12-27 06:16:02 +00:00
|
|
|
im.error = 0;
|
|
|
|
if (bus_dmamap_load(isp->isp_osinfo.respdmat, isp->isp_osinfo.respmap,
|
|
|
|
base, len, imc, &im, 0) || im.error) {
|
|
|
|
isp_prt(isp, ISP_LOGERR, "error loading response DMA map %d", im.error);
|
|
|
|
goto bad;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
2015-12-27 06:16:02 +00:00
|
|
|
isp_prt(isp, ISP_LOGDEBUG0, "response area @ 0x%jx/0x%jx",
|
|
|
|
(uintmax_t)im.maddr, (uintmax_t)len);
|
|
|
|
isp->isp_result_dma = im.maddr;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2017-03-14 08:03:56 +00:00
|
|
|
if (isp->isp_maxcmds == 0) {
|
|
|
|
ISP_LOCK(isp);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gotmaxcmds:
|
|
|
|
len = sizeof (struct isp_pcmd) * isp->isp_maxcmds;
|
|
|
|
isp->isp_osinfo.pcmd_pool = (struct isp_pcmd *)
|
|
|
|
malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
|
2002-07-11 03:25:04 +00:00
|
|
|
for (i = 0; i < isp->isp_maxcmds; i++) {
|
2007-05-05 20:17:23 +00:00
|
|
|
struct isp_pcmd *pcmd = &isp->isp_osinfo.pcmd_pool[i];
|
|
|
|
error = bus_dmamap_create(isp->isp_osinfo.dmat, 0, &pcmd->dmap);
|
2002-07-11 03:25:04 +00:00
|
|
|
if (error) {
|
|
|
|
isp_prt(isp, ISP_LOGERR,
|
|
|
|
"error %d creating per-cmd DMA maps", error);
|
|
|
|
while (--i >= 0) {
|
2007-05-05 20:17:23 +00:00
|
|
|
bus_dmamap_destroy(isp->isp_osinfo.dmat,
|
|
|
|
isp->isp_osinfo.pcmd_pool[i].dmap);
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
goto bad;
|
|
|
|
}
|
2009-08-01 01:04:26 +00:00
|
|
|
callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0);
|
2007-05-05 20:17:23 +00:00
|
|
|
if (i == isp->isp_maxcmds-1) {
|
|
|
|
pcmd->next = NULL;
|
|
|
|
} else {
|
|
|
|
pcmd->next = &isp->isp_osinfo.pcmd_pool[i+1];
|
|
|
|
}
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
2007-05-05 20:17:23 +00:00
|
|
|
isp->isp_osinfo.pcmd_free = &isp->isp_osinfo.pcmd_pool[0];
|
2017-03-14 08:03:56 +00:00
|
|
|
|
|
|
|
len = sizeof (isp_hdl_t *) * isp->isp_maxcmds;
|
|
|
|
isp->isp_xflist = (isp_hdl_t *) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
|
|
|
|
for (len = 0; len < isp->isp_maxcmds - 1; len++)
|
|
|
|
isp->isp_xflist[len].cmd = &isp->isp_xflist[len+1];
|
|
|
|
isp->isp_xffree = isp->isp_xflist;
|
|
|
|
|
2007-05-05 20:17:23 +00:00
|
|
|
ISP_LOCK(isp);
|
2002-07-11 03:25:04 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
bad:
|
2017-03-14 08:03:56 +00:00
|
|
|
isp_sbus_mbxdmafree(isp);
|
|
|
|
ISP_LOCK(isp);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
isp_sbus_mbxdmafree(ispsoftc_t *isp)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (isp->isp_xflist != NULL) {
|
|
|
|
free(isp->isp_xflist, M_DEVBUF);
|
|
|
|
isp->isp_xflist = NULL;
|
2015-12-27 06:16:02 +00:00
|
|
|
}
|
2017-03-14 08:03:56 +00:00
|
|
|
if (isp->isp_osinfo.pcmd_pool != NULL) {
|
|
|
|
for (i = 0; i < isp->isp_maxcmds; i++) {
|
|
|
|
bus_dmamap_destroy(isp->isp_osinfo.dmat,
|
|
|
|
isp->isp_osinfo.pcmd_pool[i].dmap);
|
|
|
|
}
|
|
|
|
free(isp->isp_osinfo.pcmd_pool, M_DEVBUF);
|
|
|
|
isp->isp_osinfo.pcmd_pool = NULL;
|
2015-12-27 06:16:02 +00:00
|
|
|
}
|
|
|
|
if (isp->isp_result_dma != 0) {
|
|
|
|
bus_dmamap_unload(isp->isp_osinfo.respdmat,
|
|
|
|
isp->isp_osinfo.respmap);
|
2017-03-14 08:03:56 +00:00
|
|
|
isp->isp_result_dma = 0;
|
2015-12-27 06:16:02 +00:00
|
|
|
}
|
|
|
|
if (isp->isp_result != NULL) {
|
|
|
|
bus_dmamem_free(isp->isp_osinfo.respdmat, isp->isp_result,
|
|
|
|
isp->isp_osinfo.respmap);
|
|
|
|
bus_dma_tag_destroy(isp->isp_osinfo.respdmat);
|
2017-03-14 08:03:56 +00:00
|
|
|
isp->isp_result = NULL;
|
|
|
|
}
|
|
|
|
if (isp->isp_rquest_dma != 0) {
|
|
|
|
bus_dmamap_unload(isp->isp_osinfo.reqdmat,
|
|
|
|
isp->isp_osinfo.reqmap);
|
|
|
|
isp->isp_rquest_dma = 0;
|
|
|
|
}
|
|
|
|
if (isp->isp_rquest != NULL) {
|
|
|
|
bus_dmamem_free(isp->isp_osinfo.reqdmat, isp->isp_rquest,
|
|
|
|
isp->isp_osinfo.reqmap);
|
|
|
|
bus_dma_tag_destroy(isp->isp_osinfo.reqdmat);
|
|
|
|
isp->isp_rquest = NULL;
|
2015-12-27 06:16:02 +00:00
|
|
|
}
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
2006-04-21 18:30:01 +00:00
|
|
|
ispsoftc_t *isp;
|
2002-07-11 03:25:04 +00:00
|
|
|
void *cmd_token;
|
2009-08-01 01:04:26 +00:00
|
|
|
void *rq; /* original request */
|
2006-02-15 00:31:48 +00:00
|
|
|
int error;
|
2009-08-01 01:04:26 +00:00
|
|
|
bus_size_t mapsize;
|
2002-07-11 03:25:04 +00:00
|
|
|
} mush_t;
|
|
|
|
|
|
|
|
#define MUSHERR_NOQENTRIES -2
|
|
|
|
|
|
|
|
static void dma2(void *, bus_dma_segment_t *, int, int);
|
|
|
|
|
|
|
|
static void
|
|
|
|
dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
|
|
|
|
{
|
|
|
|
mush_t *mp;
|
2006-04-21 18:30:01 +00:00
|
|
|
ispsoftc_t *isp;
|
2002-07-11 03:25:04 +00:00
|
|
|
struct ccb_scsiio *csio;
|
2009-08-01 01:04:26 +00:00
|
|
|
isp_ddir_t ddir;
|
2002-07-11 03:25:04 +00:00
|
|
|
ispreq_t *rq;
|
|
|
|
|
|
|
|
mp = (mush_t *) arg;
|
|
|
|
if (error) {
|
|
|
|
mp->error = error;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
csio = mp->cmd_token;
|
|
|
|
isp = mp->isp;
|
|
|
|
rq = mp->rq;
|
2009-08-01 01:04:26 +00:00
|
|
|
if (nseg) {
|
|
|
|
if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
|
|
|
|
bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_PREREAD);
|
|
|
|
ddir = ISP_FROM_DEVICE;
|
|
|
|
} else if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) {
|
|
|
|
bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_PREWRITE);
|
|
|
|
ddir = ISP_TO_DEVICE;
|
|
|
|
} else {
|
|
|
|
ddir = ISP_NOXFR;
|
|
|
|
}
|
2002-07-11 03:25:04 +00:00
|
|
|
} else {
|
2009-08-01 01:04:26 +00:00
|
|
|
dm_segs = NULL;
|
|
|
|
nseg = 0;
|
|
|
|
ddir = ISP_NOXFR;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
|
2012-07-29 14:21:42 +00:00
|
|
|
if (isp_send_cmd(isp, rq, dm_segs, nseg, XS_XFRLEN(csio), ddir, NULL) != CMD_QUEUED) {
|
2009-08-01 01:04:26 +00:00
|
|
|
mp->error = MUSHERR_NOQENTRIES;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-01 01:04:26 +00:00
|
|
|
isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff)
|
2002-07-11 03:25:04 +00:00
|
|
|
{
|
|
|
|
mush_t mush, *mp;
|
|
|
|
void (*eptr)(void *, bus_dma_segment_t *, int, int);
|
2013-02-12 16:57:20 +00:00
|
|
|
int error;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
|
|
|
mp = &mush;
|
|
|
|
mp->isp = isp;
|
|
|
|
mp->cmd_token = csio;
|
2009-08-01 01:04:26 +00:00
|
|
|
mp->rq = ff;
|
2002-07-11 03:25:04 +00:00
|
|
|
mp->error = 0;
|
2009-08-01 01:04:26 +00:00
|
|
|
mp->mapsize = 0;
|
|
|
|
|
|
|
|
eptr = dma2;
|
2002-07-11 03:25:04 +00:00
|
|
|
|
2013-02-12 16:57:20 +00:00
|
|
|
error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat,
|
|
|
|
PISP_PCMD(csio)->dmap, (union ccb *)csio, eptr, mp, 0);
|
|
|
|
if (error == EINPROGRESS) {
|
|
|
|
bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
|
|
|
|
mp->error = EINVAL;
|
|
|
|
isp_prt(isp, ISP_LOGERR,
|
|
|
|
"deferred dma allocation not supported");
|
|
|
|
} else if (error && mp->error == 0) {
|
2002-07-11 03:25:04 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
2013-02-12 16:57:20 +00:00
|
|
|
isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
|
2002-07-11 03:25:04 +00:00
|
|
|
#endif
|
2013-02-12 16:57:20 +00:00
|
|
|
mp->error = error;
|
2002-07-11 03:25:04 +00:00
|
|
|
}
|
|
|
|
if (mp->error) {
|
|
|
|
int retval = CMD_COMPLETE;
|
|
|
|
if (mp->error == MUSHERR_NOQENTRIES) {
|
|
|
|
retval = CMD_EAGAIN;
|
|
|
|
} else if (mp->error == EFBIG) {
|
|
|
|
XS_SETERR(csio, CAM_REQ_TOO_BIG);
|
|
|
|
} else if (mp->error == EINVAL) {
|
|
|
|
XS_SETERR(csio, CAM_REQ_INVALID);
|
|
|
|
} else {
|
|
|
|
XS_SETERR(csio, CAM_UNREC_HBA_ERROR);
|
|
|
|
}
|
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
return (CMD_QUEUED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-21 18:30:01 +00:00
|
|
|
isp_sbus_dumpregs(ispsoftc_t *isp, const char *msg)
|
2002-07-11 03:25:04 +00:00
|
|
|
{
|
|
|
|
if (msg)
|
|
|
|
printf("%s: %s\n", device_get_nameunit(isp->isp_dev), msg);
|
|
|
|
else
|
|
|
|
printf("%s:\n", device_get_nameunit(isp->isp_dev));
|
|
|
|
printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1));
|
|
|
|
printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR),
|
|
|
|
ISP_READ(isp, BIU_ISR), ISP_READ(isp, BIU_SEMA));
|
|
|
|
printf("risc_hccr=%x\n", ISP_READ(isp, HCCR));
|
|
|
|
|
|
|
|
|
|
|
|
ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
|
|
|
|
printf(" cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n",
|
|
|
|
ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS),
|
|
|
|
ISP_READ(isp, CDMA_FIFO_STS));
|
|
|
|
printf(" ddma_conf=%x ddma_sts=%x ddma_fifostat=%x\n",
|
|
|
|
ISP_READ(isp, DDMA_CONF), ISP_READ(isp, DDMA_STATUS),
|
|
|
|
ISP_READ(isp, DDMA_FIFO_STS));
|
|
|
|
printf(" sxp_int=%x sxp_gross=%x sxp(scsi_ctrl)=%x\n",
|
|
|
|
ISP_READ(isp, SXP_INTERRUPT),
|
|
|
|
ISP_READ(isp, SXP_GROSS_ERR),
|
|
|
|
ISP_READ(isp, SXP_PINS_CTRL));
|
|
|
|
ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
|
|
|
|
printf(" mbox regs: %x %x %x %x %x\n",
|
|
|
|
ISP_READ(isp, OUTMAILBOX0), ISP_READ(isp, OUTMAILBOX1),
|
|
|
|
ISP_READ(isp, OUTMAILBOX2), ISP_READ(isp, OUTMAILBOX3),
|
|
|
|
ISP_READ(isp, OUTMAILBOX4));
|
|
|
|
}
|