mpt_pci.c (146734) | mpt_pci.c (147883) |
---|---|
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 --- 15 unchanged lines hidden (view full) --- 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ | 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 --- 15 unchanged lines hidden (view full) --- 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ |
32/* 33 * Copyright (c) 2004, Avid Technology, Inc. and its contributors. 34 * Copyright (c) 2005, WHEEL Sp. z o.o. 35 * Copyright (c) 2004, 2005 Justin T. Gibbs 36 * All rights reserved. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions are 40 * met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 44 * substantially similar to the "NO WARRANTY" disclaimer below 45 * ("Disclaimer") and any redistribution must be conditioned upon including 46 * a substantially similar Disclaimer requirement for further binary 47 * redistribution. 48 * 3. Neither the name of the LSI Logic Corporation nor the names of its 49 * contributors may be used to endorse or promote products derived from 50 * this software without specific prior written permission. 51 * 52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 53 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 56 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 57 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 58 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 59 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 60 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 62 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 */ |
|
32 33#include <sys/cdefs.h> | 64 65#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_pci.c 146734 2005-05-29 04:42:30Z nyan $"); | 66__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_pci.c 147883 2005-07-10 15:05:39Z scottl $"); |
35 | 67 |
36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/kernel.h> 39#include <sys/module.h> 40#include <sys/bus.h> | 68#include <dev/mpt/mpt.h> 69#include <dev/mpt/mpt_cam.h> 70#include <dev/mpt/mpt_raid.h> |
41 | 71 |
72#if __FreeBSD_version < 500000 73#include <pci/pcireg.h> 74#include <pci/pcivar.h> 75#else |
|
42#include <dev/pci/pcireg.h> 43#include <dev/pci/pcivar.h> | 76#include <dev/pci/pcireg.h> 77#include <dev/pci/pcivar.h> |
78#endif |
|
44 | 79 |
45#include <machine/bus.h> 46#include <machine/resource.h> 47#include <sys/rman.h> 48#include <sys/malloc.h> 49 50#include <dev/mpt/mpt_freebsd.h> 51 | |
52#ifndef PCI_VENDOR_LSI 53#define PCI_VENDOR_LSI 0x1000 54#endif 55 56#ifndef PCI_PRODUCT_LSI_FC909 57#define PCI_PRODUCT_LSI_FC909 0x0620 58#endif 59 --- 4 unchanged lines hidden (view full) --- 64#ifndef PCI_PRODUCT_LSI_FC919 65#define PCI_PRODUCT_LSI_FC919 0x0624 66#endif 67 68#ifndef PCI_PRODUCT_LSI_FC929 69#define PCI_PRODUCT_LSI_FC929 0x0622 70#endif 71 | 80#ifndef PCI_VENDOR_LSI 81#define PCI_VENDOR_LSI 0x1000 82#endif 83 84#ifndef PCI_PRODUCT_LSI_FC909 85#define PCI_PRODUCT_LSI_FC909 0x0620 86#endif 87 --- 4 unchanged lines hidden (view full) --- 92#ifndef PCI_PRODUCT_LSI_FC919 93#define PCI_PRODUCT_LSI_FC919 0x0624 94#endif 95 96#ifndef PCI_PRODUCT_LSI_FC929 97#define PCI_PRODUCT_LSI_FC929 0x0622 98#endif 99 |
72#ifndef PCI_PRODUCT_LSI_FC929X 73#define PCI_PRODUCT_LSI_FC929X 0x0626 74#endif 75 | |
76#ifndef PCI_PRODUCT_LSI_1030 77#define PCI_PRODUCT_LSI_1030 0x0030 78#endif 79 80#ifndef PCIM_CMD_SERRESPEN 81#define PCIM_CMD_SERRESPEN 0x0100 82#endif 83 84 85 | 100#ifndef PCI_PRODUCT_LSI_1030 101#define PCI_PRODUCT_LSI_1030 0x0030 102#endif 103 104#ifndef PCIM_CMD_SERRESPEN 105#define PCIM_CMD_SERRESPEN 0x0100 106#endif 107 108 109 |
86#define MEM_MAP_REG 0x14 87#define MEM_MAP_SRAM 0x1C | 110#define MPT_IO_BAR 0 111#define MPT_MEM_BAR 1 |
88 | 112 |
89static int mpt_probe(device_t); 90static int mpt_attach(device_t); 91static void mpt_free_bus_resources(mpt_softc_t *mpt); 92static int mpt_detach(device_t); 93static int mpt_shutdown(device_t); 94static int mpt_dma_mem_alloc(mpt_softc_t *mpt); 95static void mpt_dma_mem_free(mpt_softc_t *mpt); 96static void mpt_read_config_regs(mpt_softc_t *mpt); | 113static int mpt_pci_probe(device_t); 114static int mpt_pci_attach(device_t); 115static void mpt_free_bus_resources(struct mpt_softc *mpt); 116static int mpt_pci_detach(device_t); 117static int mpt_pci_shutdown(device_t); 118static int mpt_dma_mem_alloc(struct mpt_softc *mpt); 119static void mpt_dma_mem_free(struct mpt_softc *mpt); 120static void mpt_read_config_regs(struct mpt_softc *mpt); |
97static void mpt_pci_intr(void *); 98 99static device_method_t mpt_methods[] = { 100 /* Device interface */ | 121static void mpt_pci_intr(void *); 122 123static device_method_t mpt_methods[] = { 124 /* Device interface */ |
101 DEVMETHOD(device_probe, mpt_probe), 102 DEVMETHOD(device_attach, mpt_attach), 103 DEVMETHOD(device_detach, mpt_detach), 104 DEVMETHOD(device_shutdown, mpt_shutdown), | 125 DEVMETHOD(device_probe, mpt_pci_probe), 126 DEVMETHOD(device_attach, mpt_pci_attach), 127 DEVMETHOD(device_detach, mpt_pci_detach), 128 DEVMETHOD(device_shutdown, mpt_pci_shutdown), |
105 { 0, 0 } 106}; 107 108static driver_t mpt_driver = { | 129 { 0, 0 } 130}; 131 132static driver_t mpt_driver = { |
109 "mpt", mpt_methods, sizeof (mpt_softc_t) | 133 "mpt", mpt_methods, sizeof(struct mpt_softc) |
110}; 111static devclass_t mpt_devclass; 112DRIVER_MODULE(mpt, pci, mpt_driver, mpt_devclass, 0, 0); 113MODULE_VERSION(mpt, 1); 114 | 134}; 135static devclass_t mpt_devclass; 136DRIVER_MODULE(mpt, pci, mpt_driver, mpt_devclass, 0, 0); 137MODULE_VERSION(mpt, 1); 138 |
115int 116mpt_intr(void *dummy) 117{ 118 int nrepl = 0; 119 u_int32_t reply; 120 mpt_softc_t *mpt = (mpt_softc_t *)dummy; 121 122 if ((mpt_read(mpt, MPT_OFFSET_INTR_STATUS) & MPT_INTR_REPLY_READY) == 0) 123 return (0); 124 reply = mpt_pop_reply_queue(mpt); 125 while (reply != MPT_REPLY_EMPTY) { 126 nrepl++; 127 if (mpt->verbose > 1) { 128 if ((reply & MPT_CONTEXT_REPLY) != 0) { 129 /* Address reply; IOC has something to say */ 130 mpt_print_reply(MPT_REPLY_PTOV(mpt, reply)); 131 } else { 132 /* Context reply ; all went well */ 133 mpt_prt(mpt, "context %u reply OK", reply); 134 } 135 } 136 mpt_done(mpt, reply); 137 reply = mpt_pop_reply_queue(mpt); 138 } 139 return (nrepl != 0); 140} 141 | |
142static int | 139static int |
143mpt_probe(device_t dev) | 140mpt_pci_probe(device_t dev) |
144{ 145 char *desc; 146 147 if (pci_get_vendor(dev) != PCI_VENDOR_LSI) 148 return (ENXIO); 149 150 switch ((pci_get_device(dev) & ~1)) { 151 case PCI_PRODUCT_LSI_FC909: 152 desc = "LSILogic FC909 FC Adapter"; 153 break; 154 case PCI_PRODUCT_LSI_FC909A: 155 desc = "LSILogic FC909A FC Adapter"; 156 break; 157 case PCI_PRODUCT_LSI_FC919: 158 desc = "LSILogic FC919 FC Adapter"; 159 break; 160 case PCI_PRODUCT_LSI_FC929: 161 desc = "LSILogic FC929 FC Adapter"; 162 break; | 141{ 142 char *desc; 143 144 if (pci_get_vendor(dev) != PCI_VENDOR_LSI) 145 return (ENXIO); 146 147 switch ((pci_get_device(dev) & ~1)) { 148 case PCI_PRODUCT_LSI_FC909: 149 desc = "LSILogic FC909 FC Adapter"; 150 break; 151 case PCI_PRODUCT_LSI_FC909A: 152 desc = "LSILogic FC909A FC Adapter"; 153 break; 154 case PCI_PRODUCT_LSI_FC919: 155 desc = "LSILogic FC919 FC Adapter"; 156 break; 157 case PCI_PRODUCT_LSI_FC929: 158 desc = "LSILogic FC929 FC Adapter"; 159 break; |
163 case PCI_PRODUCT_LSI_FC929X: 164 desc = "LSILogic FC929X FC Adapter"; 165 break; | |
166 case PCI_PRODUCT_LSI_1030: 167 desc = "LSILogic 1030 Ultra4 Adapter"; 168 break; 169 default: 170 return (ENXIO); 171 } 172 173 device_set_desc(dev, desc); | 160 case PCI_PRODUCT_LSI_1030: 161 desc = "LSILogic 1030 Ultra4 Adapter"; 162 break; 163 default: 164 return (ENXIO); 165 } 166 167 device_set_desc(dev, desc); |
174 return (BUS_PROBE_DEFAULT); | 168 return (0); |
175} 176 177#ifdef RELENG_4 178static void | 169} 170 171#ifdef RELENG_4 172static void |
179mpt_set_options(mpt_softc_t *mpt) | 173mpt_set_options(struct mpt_softc *mpt) |
180{ 181 int bitmap; 182 183 bitmap = 0; 184 if (getenv_int("mpt_disable", &bitmap)) { 185 if (bitmap & (1 << mpt->unit)) { 186 mpt->disabled = 1; 187 } 188 } 189 190 bitmap = 0; 191 if (getenv_int("mpt_debug", &bitmap)) { 192 if (bitmap & (1 << mpt->unit)) { | 174{ 175 int bitmap; 176 177 bitmap = 0; 178 if (getenv_int("mpt_disable", &bitmap)) { 179 if (bitmap & (1 << mpt->unit)) { 180 mpt->disabled = 1; 181 } 182 } 183 184 bitmap = 0; 185 if (getenv_int("mpt_debug", &bitmap)) { 186 if (bitmap & (1 << mpt->unit)) { |
193 mpt->verbose = 2; | 187 mpt->verbose = MPT_PRT_DEBUG; |
194 } 195 } 196 197} 198#else 199static void | 188 } 189 } 190 191} 192#else 193static void |
200mpt_set_options(mpt_softc_t *mpt) | 194mpt_set_options(struct mpt_softc *mpt) |
201{ 202 int tval; 203 204 tval = 0; 205 if (resource_int_value(device_get_name(mpt->dev), 206 device_get_unit(mpt->dev), "disable", &tval) == 0 && tval != 0) { 207 mpt->disabled = 1; 208 } 209 tval = 0; 210 if (resource_int_value(device_get_name(mpt->dev), 211 device_get_unit(mpt->dev), "debug", &tval) == 0 && tval != 0) { 212 mpt->verbose += tval; 213 } 214} 215#endif 216 217 218static void | 195{ 196 int tval; 197 198 tval = 0; 199 if (resource_int_value(device_get_name(mpt->dev), 200 device_get_unit(mpt->dev), "disable", &tval) == 0 && tval != 0) { 201 mpt->disabled = 1; 202 } 203 tval = 0; 204 if (resource_int_value(device_get_name(mpt->dev), 205 device_get_unit(mpt->dev), "debug", &tval) == 0 && tval != 0) { 206 mpt->verbose += tval; 207 } 208} 209#endif 210 211 212static void |
219mpt_link_peer(mpt_softc_t *mpt) | 213mpt_link_peer(struct mpt_softc *mpt) |
220{ | 214{ |
221 mpt_softc_t *mpt2; | 215 struct mpt_softc *mpt2; |
222 | 216 |
223 if (mpt->unit == 0) { | 217 if (mpt->unit == 0) |
224 return; | 218 return; |
225 } | |
226 227 /* 228 * XXX: depends on probe order 229 */ | 219 220 /* 221 * XXX: depends on probe order 222 */ |
230 mpt2 = (mpt_softc_t *) devclass_get_softc(mpt_devclass, mpt->unit-1); | 223 mpt2 = (struct mpt_softc *)devclass_get_softc(mpt_devclass,mpt->unit-1); |
231 232 if (mpt2 == NULL) { 233 return; 234 } 235 if (pci_get_vendor(mpt2->dev) != pci_get_vendor(mpt->dev)) { 236 return; 237 } 238 if (pci_get_device(mpt2->dev) != pci_get_device(mpt->dev)) { 239 return; 240 } 241 mpt->mpt2 = mpt2; 242 mpt2->mpt2 = mpt; | 224 225 if (mpt2 == NULL) { 226 return; 227 } 228 if (pci_get_vendor(mpt2->dev) != pci_get_vendor(mpt->dev)) { 229 return; 230 } 231 if (pci_get_device(mpt2->dev) != pci_get_device(mpt->dev)) { 232 return; 233 } 234 mpt->mpt2 = mpt2; 235 mpt2->mpt2 = mpt; |
243 if (mpt->verbose) { 244 mpt_prt(mpt, "linking with peer (mpt%d)", | 236 if (mpt->verbose >= MPT_PRT_DEBUG) { 237 mpt_prt(mpt, "linking with peer (mpt%d)\n", |
245 device_get_unit(mpt2->dev)); 246 } 247} 248 249 250static int | 238 device_get_unit(mpt2->dev)); 239 } 240} 241 242 243static int |
251mpt_attach(device_t dev) | 244mpt_pci_attach(device_t dev) |
252{ | 245{ |
253 int iqd; 254 u_int32_t data, cmd; 255 mpt_softc_t *mpt; | 246 struct mpt_softc *mpt; 247 int iqd; 248 uint32_t data, cmd; |
256 257 /* Allocate the softc structure */ | 249 250 /* Allocate the softc structure */ |
258 mpt = (mpt_softc_t*) device_get_softc(dev); | 251 mpt = (struct mpt_softc*)device_get_softc(dev); |
259 if (mpt == NULL) { 260 device_printf(dev, "cannot allocate softc\n"); 261 return (ENOMEM); 262 } | 252 if (mpt == NULL) { 253 device_printf(dev, "cannot allocate softc\n"); 254 return (ENOMEM); 255 } |
263 bzero(mpt, sizeof (mpt_softc_t)); | 256 bzero(mpt, sizeof(struct mpt_softc)); |
264 switch ((pci_get_device(dev) & ~1)) { 265 case PCI_PRODUCT_LSI_FC909: 266 case PCI_PRODUCT_LSI_FC909A: 267 case PCI_PRODUCT_LSI_FC919: 268 case PCI_PRODUCT_LSI_FC929: 269 mpt->is_fc = 1; 270 break; 271 default: 272 break; 273 } 274 mpt->dev = dev; 275 mpt->unit = device_get_unit(dev); | 257 switch ((pci_get_device(dev) & ~1)) { 258 case PCI_PRODUCT_LSI_FC909: 259 case PCI_PRODUCT_LSI_FC909A: 260 case PCI_PRODUCT_LSI_FC919: 261 case PCI_PRODUCT_LSI_FC929: 262 mpt->is_fc = 1; 263 break; 264 default: 265 break; 266 } 267 mpt->dev = dev; 268 mpt->unit = device_get_unit(dev); |
269 mpt->raid_resync_rate = MPT_RAID_RESYNC_RATE_DEFAULT; 270 mpt->raid_mwce_setting = MPT_RAID_MWCE_DEFAULT; 271 mpt->raid_queue_depth = MPT_RAID_QUEUE_DEPTH_DEFAULT; |
|
276 mpt_set_options(mpt); | 272 mpt_set_options(mpt); |
273 mpt->verbose = MPT_PRT_INFO; |
|
277 mpt->verbose += (bootverbose != 0)? 1 : 0; 278 279 /* Make sure memory access decoders are enabled */ 280 cmd = pci_read_config(dev, PCIR_COMMAND, 2); 281 if ((cmd & PCIM_CMD_MEMEN) == 0) { 282 device_printf(dev, "Memory accesses disabled"); 283 goto bad; 284 } --- 8 unchanged lines hidden (view full) --- 293 294 /* 295 * Make sure we've disabled the ROM. 296 */ 297 data = pci_read_config(dev, PCIR_BIOS, 4); 298 data &= ~1; 299 pci_write_config(dev, PCIR_BIOS, data, 4); 300 | 274 mpt->verbose += (bootverbose != 0)? 1 : 0; 275 276 /* Make sure memory access decoders are enabled */ 277 cmd = pci_read_config(dev, PCIR_COMMAND, 2); 278 if ((cmd & PCIM_CMD_MEMEN) == 0) { 279 device_printf(dev, "Memory accesses disabled"); 280 goto bad; 281 } --- 8 unchanged lines hidden (view full) --- 290 291 /* 292 * Make sure we've disabled the ROM. 293 */ 294 data = pci_read_config(dev, PCIR_BIOS, 4); 295 data &= ~1; 296 pci_write_config(dev, PCIR_BIOS, data, 4); 297 |
301 | |
302 /* 303 * Is this part a dual? 304 * If so, link with our partner (around yet) 305 */ 306 if ((pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_FC929 || 307 (pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_1030) { 308 mpt_link_peer(mpt); 309 } 310 | 298 /* 299 * Is this part a dual? 300 * If so, link with our partner (around yet) 301 */ 302 if ((pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_FC929 || 303 (pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_1030) { 304 mpt_link_peer(mpt); 305 } 306 |
311 /* Set up the memory regions */ | 307 /* 308 * Set up register access. PIO mode is required for 309 * certain reset operations. 310 */ 311 mpt->pci_pio_rid = PCIR_BAR(MPT_IO_BAR); 312 mpt->pci_pio_reg = bus_alloc_resource(dev, SYS_RES_IOPORT, 313 &mpt->pci_pio_rid, 0, ~0, 0, RF_ACTIVE); 314 if (mpt->pci_pio_reg == NULL) { 315 device_printf(dev, "unable to map registers in PIO mode\n"); 316 goto bad; 317 } 318 mpt->pci_pio_st = rman_get_bustag(mpt->pci_pio_reg); 319 mpt->pci_pio_sh = rman_get_bushandle(mpt->pci_pio_reg); 320 |
312 /* Allocate kernel virtual memory for the 9x9's Mem0 region */ | 321 /* Allocate kernel virtual memory for the 9x9's Mem0 region */ |
313 mpt->pci_reg_id = MEM_MAP_REG; | 322 mpt->pci_mem_rid = PCIR_BAR(MPT_MEM_BAR); |
314 mpt->pci_reg = bus_alloc_resource(dev, SYS_RES_MEMORY, | 323 mpt->pci_reg = bus_alloc_resource(dev, SYS_RES_MEMORY, |
315 &mpt->pci_reg_id, 0, ~0, 0, RF_ACTIVE); | 324 &mpt->pci_mem_rid, 0, ~0, 0, RF_ACTIVE); |
316 if (mpt->pci_reg == NULL) { | 325 if (mpt->pci_reg == NULL) { |
317 device_printf(dev, "unable to map any ports\n"); 318 goto bad; | 326 device_printf(dev, "Unable to memory map registers.\n"); 327 device_printf(dev, "Falling back to PIO mode.\n"); 328 mpt->pci_st = mpt->pci_pio_st; 329 mpt->pci_sh = mpt->pci_pio_sh; 330 } else { 331 mpt->pci_st = rman_get_bustag(mpt->pci_reg); 332 mpt->pci_sh = rman_get_bushandle(mpt->pci_reg); |
319 } | 333 } |
320 mpt->pci_st = rman_get_bustag(mpt->pci_reg); 321 mpt->pci_sh = rman_get_bushandle(mpt->pci_reg); 322 /* Get the Physical Address */ 323 mpt->pci_pa = rman_get_start(mpt->pci_reg); | |
324 325 /* Get a handle to the interrupt */ 326 iqd = 0; | 334 335 /* Get a handle to the interrupt */ 336 iqd = 0; |
337#if __FreeBSD_version < 500000 338 mpt->pci_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &iqd, 0, ~0, 1, 339 RF_ACTIVE | RF_SHAREABLE); 340#else |
|
327 mpt->pci_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd, 328 RF_ACTIVE | RF_SHAREABLE); | 341 mpt->pci_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd, 342 RF_ACTIVE | RF_SHAREABLE); |
343#endif |
|
329 if (mpt->pci_irq == NULL) { 330 device_printf(dev, "could not allocate interrupt\n"); 331 goto bad; 332 } 333 | 344 if (mpt->pci_irq == NULL) { 345 device_printf(dev, "could not allocate interrupt\n"); 346 goto bad; 347 } 348 |
349 MPT_LOCK_SETUP(mpt); 350 351 /* Disable interrupts at the part */ 352 mpt_disable_ints(mpt); 353 |
|
334 /* Register the interrupt handler */ 335 if (bus_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, mpt_pci_intr, 336 mpt, &mpt->ih)) { 337 device_printf(dev, "could not setup interrupt\n"); 338 goto bad; 339 } 340 | 354 /* Register the interrupt handler */ 355 if (bus_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, mpt_pci_intr, 356 mpt, &mpt->ih)) { 357 device_printf(dev, "could not setup interrupt\n"); 358 goto bad; 359 } 360 |
341 MPT_LOCK_SETUP(mpt); 342 343 /* Disable interrupts at the part */ 344 mpt_disable_ints(mpt); 345 | |
346 /* Allocate dma memory */ | 361 /* Allocate dma memory */ |
362/* XXX JGibbs -Should really be done based on IOCFacts. */ |
|
347 if (mpt_dma_mem_alloc(mpt)) { 348 device_printf(dev, "Could not allocate DMA memory\n"); 349 goto bad; 350 } 351 352 /* 353 * Save the PCI config register values 354 * --- 4 unchanged lines hidden (view full) --- 359 * configuration space transfers, so we need to save it now 360 */ 361 362 mpt_read_config_regs(mpt); 363 364 /* Initialize the hardware */ 365 if (mpt->disabled == 0) { 366 MPT_LOCK(mpt); | 363 if (mpt_dma_mem_alloc(mpt)) { 364 device_printf(dev, "Could not allocate DMA memory\n"); 365 goto bad; 366 } 367 368 /* 369 * Save the PCI config register values 370 * --- 4 unchanged lines hidden (view full) --- 375 * configuration space transfers, so we need to save it now 376 */ 377 378 mpt_read_config_regs(mpt); 379 380 /* Initialize the hardware */ 381 if (mpt->disabled == 0) { 382 MPT_LOCK(mpt); |
367 if (mpt_init(mpt, MPT_DB_INIT_HOST) != 0) { | 383 if (mpt_attach(mpt) != 0) { |
368 MPT_UNLOCK(mpt); 369 goto bad; 370 } | 384 MPT_UNLOCK(mpt); 385 goto bad; 386 } |
371 372 /* 373 * Attach to CAM 374 */ 375 MPTLOCK_2_CAMLOCK(mpt); 376 mpt_cam_attach(mpt); 377 CAMLOCK_2_MPTLOCK(mpt); 378 MPT_UNLOCK(mpt); | |
379 } 380 381 return (0); 382 383bad: 384 mpt_dma_mem_free(mpt); 385 mpt_free_bus_resources(mpt); 386 387 /* 388 * but return zero to preserve unit numbering 389 */ 390 return (0); 391} 392 393/* 394 * Free bus resources 395 */ 396static void | 387 } 388 389 return (0); 390 391bad: 392 mpt_dma_mem_free(mpt); 393 mpt_free_bus_resources(mpt); 394 395 /* 396 * but return zero to preserve unit numbering 397 */ 398 return (0); 399} 400 401/* 402 * Free bus resources 403 */ 404static void |
397mpt_free_bus_resources(mpt_softc_t *mpt) | 405mpt_free_bus_resources(struct mpt_softc *mpt) |
398{ 399 if (mpt->ih) { 400 bus_teardown_intr(mpt->dev, mpt->pci_irq, mpt->ih); 401 mpt->ih = 0; 402 } 403 404 if (mpt->pci_irq) { 405 bus_release_resource(mpt->dev, SYS_RES_IRQ, 0, mpt->pci_irq); 406 mpt->pci_irq = 0; 407 } 408 | 406{ 407 if (mpt->ih) { 408 bus_teardown_intr(mpt->dev, mpt->pci_irq, mpt->ih); 409 mpt->ih = 0; 410 } 411 412 if (mpt->pci_irq) { 413 bus_release_resource(mpt->dev, SYS_RES_IRQ, 0, mpt->pci_irq); 414 mpt->pci_irq = 0; 415 } 416 |
417 if (mpt->pci_pio_reg) { 418 bus_release_resource(mpt->dev, SYS_RES_IOPORT, mpt->pci_pio_rid, 419 mpt->pci_pio_reg); 420 mpt->pci_pio_reg = 0; 421 } |
|
409 if (mpt->pci_reg) { | 422 if (mpt->pci_reg) { |
410 bus_release_resource(mpt->dev, SYS_RES_MEMORY, mpt->pci_reg_id, | 423 bus_release_resource(mpt->dev, SYS_RES_MEMORY, mpt->pci_mem_rid, |
411 mpt->pci_reg); 412 mpt->pci_reg = 0; 413 } 414 MPT_LOCK_DESTROY(mpt); 415} 416 417 418/* 419 * Disconnect ourselves from the system. 420 */ 421static int | 424 mpt->pci_reg); 425 mpt->pci_reg = 0; 426 } 427 MPT_LOCK_DESTROY(mpt); 428} 429 430 431/* 432 * Disconnect ourselves from the system. 433 */ 434static int |
422mpt_detach(device_t dev) | 435mpt_pci_detach(device_t dev) |
423{ | 436{ |
424 mpt_softc_t *mpt; 425 mpt = (mpt_softc_t*) device_get_softc(dev); | 437 struct mpt_softc *mpt; |
426 | 438 |
427 mpt_prt(mpt, "mpt_detach"); | 439 mpt = (struct mpt_softc*)device_get_softc(dev); 440 mpt_prt(mpt, "mpt_detach\n"); |
428 429 if (mpt) { 430 mpt_disable_ints(mpt); | 441 442 if (mpt) { 443 mpt_disable_ints(mpt); |
431 mpt_cam_detach(mpt); 432 mpt_reset(mpt); | 444 mpt_detach(mpt); 445 mpt_reset(mpt, /*reinit*/FALSE); |
433 mpt_dma_mem_free(mpt); 434 mpt_free_bus_resources(mpt); | 446 mpt_dma_mem_free(mpt); 447 mpt_free_bus_resources(mpt); |
448 if (mpt->raid_volumes != NULL 449 && mpt->ioc_page2 != NULL) { 450 int i; 451 452 for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { 453 struct mpt_raid_volume *mpt_vol; 454 455 mpt_vol = &mpt->raid_volumes[i]; 456 if (mpt_vol->config_page) 457 free(mpt_vol->config_page, M_DEVBUF); 458 } 459 } 460 if (mpt->ioc_page2 != NULL) 461 free(mpt->ioc_page2, M_DEVBUF); 462 if (mpt->ioc_page3 != NULL) 463 free(mpt->ioc_page3, M_DEVBUF); 464 if (mpt->raid_volumes != NULL) 465 free(mpt->raid_volumes, M_DEVBUF); 466 if (mpt->raid_disks != NULL) 467 free(mpt->raid_disks, M_DEVBUF); 468 if (mpt->eh != NULL) 469 EVENTHANDLER_DEREGISTER(shutdown_final, mpt->eh); |
|
435 } 436 return(0); 437} 438 439 440/* 441 * Disable the hardware | 470 } 471 return(0); 472} 473 474 475/* 476 * Disable the hardware |
477 * XXX - Called too early by New Bus!!! ??? |
|
442 */ 443static int | 478 */ 479static int |
444mpt_shutdown(device_t dev) | 480mpt_pci_shutdown(device_t dev) |
445{ | 481{ |
446 mpt_softc_t *mpt; 447 mpt = (mpt_softc_t*) device_get_softc(dev); | 482 struct mpt_softc *mpt; |
448 | 483 |
449 if (mpt) { 450 mpt_reset(mpt); 451 } | 484 mpt = (struct mpt_softc *)device_get_softc(dev); 485 if (mpt) 486 return (mpt_shutdown(mpt)); |
452 return(0); 453} 454 | 487 return(0); 488} 489 |
455 456struct imush { 457 mpt_softc_t *mpt; 458 int error; 459 u_int32_t phys; 460}; 461 462static void 463mpt_map_rquest(void *arg, bus_dma_segment_t *segs, int nseg, int error) 464{ 465 struct imush *imushp = (struct imush *) arg; 466 imushp->error = error; 467 imushp->phys = segs->ds_addr; 468} 469 470 | |
471static int | 490static int |
472mpt_dma_mem_alloc(mpt_softc_t *mpt) | 491mpt_dma_mem_alloc(struct mpt_softc *mpt) |
473{ 474 int i, error; | 492{ 493 int i, error; |
475 u_char *vptr; 476 u_int32_t pptr, end; | 494 uint8_t *vptr; 495 uint32_t pptr, end; |
477 size_t len; | 496 size_t len; |
478 struct imush im; | 497 struct mpt_map_info mi; |
479 device_t dev = mpt->dev; 480 481 /* Check if we alreay have allocated the reply memory */ 482 if (mpt->reply_phys != 0) { 483 return 0; 484 } 485 | 498 device_t dev = mpt->dev; 499 500 /* Check if we alreay have allocated the reply memory */ 501 if (mpt->reply_phys != 0) { 502 return 0; 503 } 504 |
486 len = sizeof (request_t *) * MPT_REQ_MEM_SIZE(mpt); | 505 len = sizeof (request_t) * MPT_MAX_REQUESTS(mpt); |
487#ifdef RELENG_4 | 506#ifdef RELENG_4 |
488 mpt->request_pool = (request_t *) malloc(len, M_DEVBUF, M_WAITOK); | 507 mpt->request_pool = (request_t *)malloc(len, M_DEVBUF, M_WAITOK); |
489 if (mpt->request_pool == NULL) { 490 device_printf(dev, "cannot allocate request pool\n"); 491 return (1); 492 } 493 bzero(mpt->request_pool, len); 494#else | 508 if (mpt->request_pool == NULL) { 509 device_printf(dev, "cannot allocate request pool\n"); 510 return (1); 511 } 512 bzero(mpt->request_pool, len); 513#else |
495 mpt->request_pool = (request_t *) 496 malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); | 514 mpt->request_pool = (request_t *)malloc(len, M_DEVBUF, M_WAITOK|M_ZERO); |
497 if (mpt->request_pool == NULL) { 498 device_printf(dev, "cannot allocate request pool\n"); 499 return (1); 500 } 501#endif 502 503 /* | 515 if (mpt->request_pool == NULL) { 516 device_printf(dev, "cannot allocate request pool\n"); 517 return (1); 518 } 519#endif 520 521 /* |
504 * Create a dma tag for this device | 522 * Create a parent dma tag for this device |
505 * | 523 * |
506 * Align at page boundaries, limit to 32-bit addressing | 524 * Align at byte boundaries, limit to 32-bit addressing |
507 * (The chip supports 64-bit addressing, but this driver doesn't) 508 */ | 525 * (The chip supports 64-bit addressing, but this driver doesn't) 526 */ |
509 if (bus_dma_tag_create(NULL, PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT, 510 BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 511 BUS_SPACE_MAXSIZE_32BIT, BUS_SPACE_UNRESTRICTED, 0, 512 busdma_lock_mutex, &Giant, &mpt->parent_dmat) != 0) { | 527 if (mpt_dma_tag_create(mpt, /*parent*/NULL, /*alignment*/1, 528 /*boundary*/0, /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, 529 /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, 530 /*maxsize*/BUS_SPACE_MAXSIZE_32BIT, 531 /*nsegments*/BUS_SPACE_MAXSIZE_32BIT, 532 /*maxsegsz*/BUS_SPACE_UNRESTRICTED, /*flags*/0, 533 &mpt->parent_dmat) != 0) { |
513 device_printf(dev, "cannot create parent dma tag\n"); 514 return (1); 515 } 516 517 /* Create a child tag for reply buffers */ | 534 device_printf(dev, "cannot create parent dma tag\n"); 535 return (1); 536 } 537 538 /* Create a child tag for reply buffers */ |
518 if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, | 539 if (mpt_dma_tag_create(mpt, mpt->parent_dmat, PAGE_SIZE, |
519 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 520 NULL, NULL, PAGE_SIZE, 1, BUS_SPACE_MAXSIZE_32BIT, 0, | 540 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 541 NULL, NULL, PAGE_SIZE, 1, BUS_SPACE_MAXSIZE_32BIT, 0, |
521 busdma_lock_mutex, &Giant, &mpt->reply_dmat) != 0) { | 542 &mpt->reply_dmat) != 0) { |
522 device_printf(dev, "cannot create a dma tag for replies\n"); 523 return (1); 524 } 525 526 /* Allocate some DMA accessable memory for replies */ 527 if (bus_dmamem_alloc(mpt->reply_dmat, (void **)&mpt->reply, 528 BUS_DMA_NOWAIT, &mpt->reply_dmap) != 0) { 529 device_printf(dev, "cannot allocate %lu bytes of reply memory\n", 530 (u_long)PAGE_SIZE); 531 return (1); 532 } 533 | 543 device_printf(dev, "cannot create a dma tag for replies\n"); 544 return (1); 545 } 546 547 /* Allocate some DMA accessable memory for replies */ 548 if (bus_dmamem_alloc(mpt->reply_dmat, (void **)&mpt->reply, 549 BUS_DMA_NOWAIT, &mpt->reply_dmap) != 0) { 550 device_printf(dev, "cannot allocate %lu bytes of reply memory\n", 551 (u_long)PAGE_SIZE); 552 return (1); 553 } 554 |
534 im.mpt = mpt; 535 im.error = 0; | 555 mi.mpt = mpt; 556 mi.error = 0; |
536 537 /* Load and lock it into "bus space" */ 538 bus_dmamap_load(mpt->reply_dmat, mpt->reply_dmap, mpt->reply, | 557 558 /* Load and lock it into "bus space" */ 559 bus_dmamap_load(mpt->reply_dmat, mpt->reply_dmap, mpt->reply, |
539 PAGE_SIZE, mpt_map_rquest, &im, 0); | 560 PAGE_SIZE, mpt_map_rquest, &mi, 0); |
540 | 561 |
541 if (im.error) { | 562 if (mi.error) { |
542 device_printf(dev, | 563 device_printf(dev, |
543 "error %d loading dma map for DMA reply queue\n", im.error); | 564 "error %d loading dma map for DMA reply queue\n", mi.error); |
544 return (1); 545 } | 565 return (1); 566 } |
546 mpt->reply_phys = im.phys; | 567 mpt->reply_phys = mi.phys; |
547 548 /* Create a child tag for data buffers */ | 568 569 /* Create a child tag for data buffers */ |
549 if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, | 570 if (mpt_dma_tag_create(mpt, mpt->parent_dmat, 1, |
550 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 551 NULL, NULL, MAXBSIZE, MPT_SGL_MAX, BUS_SPACE_MAXSIZE_32BIT, 0, | 571 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 572 NULL, NULL, MAXBSIZE, MPT_SGL_MAX, BUS_SPACE_MAXSIZE_32BIT, 0, |
552 busdma_lock_mutex, &Giant, &mpt->buffer_dmat) != 0) { | 573 &mpt->buffer_dmat) != 0) { |
553 device_printf(dev, 554 "cannot create a dma tag for data buffers\n"); 555 return (1); 556 } 557 558 /* Create a child tag for request buffers */ | 574 device_printf(dev, 575 "cannot create a dma tag for data buffers\n"); 576 return (1); 577 } 578 579 /* Create a child tag for request buffers */ |
559 if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, | 580 if (mpt_dma_tag_create(mpt, mpt->parent_dmat, PAGE_SIZE, |
560 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 561 NULL, NULL, MPT_REQ_MEM_SIZE(mpt), 1, BUS_SPACE_MAXSIZE_32BIT, 0, | 581 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 582 NULL, NULL, MPT_REQ_MEM_SIZE(mpt), 1, BUS_SPACE_MAXSIZE_32BIT, 0, |
562 busdma_lock_mutex, &Giant, &mpt->request_dmat) != 0) { | 583 &mpt->request_dmat) != 0) { |
563 device_printf(dev, "cannot create a dma tag for requests\n"); 564 return (1); 565 } 566 567 /* Allocate some DMA accessable memory for requests */ 568 if (bus_dmamem_alloc(mpt->request_dmat, (void **)&mpt->request, 569 BUS_DMA_NOWAIT, &mpt->request_dmap) != 0) { 570 device_printf(dev, 571 "cannot allocate %d bytes of request memory\n", 572 MPT_REQ_MEM_SIZE(mpt)); 573 return (1); 574 } 575 | 584 device_printf(dev, "cannot create a dma tag for requests\n"); 585 return (1); 586 } 587 588 /* Allocate some DMA accessable memory for requests */ 589 if (bus_dmamem_alloc(mpt->request_dmat, (void **)&mpt->request, 590 BUS_DMA_NOWAIT, &mpt->request_dmap) != 0) { 591 device_printf(dev, 592 "cannot allocate %d bytes of request memory\n", 593 MPT_REQ_MEM_SIZE(mpt)); 594 return (1); 595 } 596 |
576 im.mpt = mpt; 577 im.error = 0; | 597 mi.mpt = mpt; 598 mi.error = 0; |
578 579 /* Load and lock it into "bus space" */ 580 bus_dmamap_load(mpt->request_dmat, mpt->request_dmap, mpt->request, | 599 600 /* Load and lock it into "bus space" */ 601 bus_dmamap_load(mpt->request_dmat, mpt->request_dmap, mpt->request, |
581 MPT_REQ_MEM_SIZE(mpt), mpt_map_rquest, &im, 0); | 602 MPT_REQ_MEM_SIZE(mpt), mpt_map_rquest, &mi, 0); |
582 | 603 |
583 if (im.error) { | 604 if (mi.error) { |
584 device_printf(dev, 585 "error %d loading dma map for DMA request queue\n", | 605 device_printf(dev, 606 "error %d loading dma map for DMA request queue\n", |
586 im.error); | 607 mi.error); |
587 return (1); 588 } | 608 return (1); 609 } |
589 mpt->request_phys = im.phys; | 610 mpt->request_phys = mi.phys; |
590 591 i = 0; 592 pptr = mpt->request_phys; 593 vptr = mpt->request; 594 end = pptr + MPT_REQ_MEM_SIZE(mpt); 595 while(pptr < end) { 596 request_t *req = &mpt->request_pool[i]; 597 req->index = i++; --- 18 unchanged lines hidden (view full) --- 616 return (0); 617} 618 619 620 621/* Deallocate memory that was allocated by mpt_dma_mem_alloc 622 */ 623static void | 611 612 i = 0; 613 pptr = mpt->request_phys; 614 vptr = mpt->request; 615 end = pptr + MPT_REQ_MEM_SIZE(mpt); 616 while(pptr < end) { 617 request_t *req = &mpt->request_pool[i]; 618 req->index = i++; --- 18 unchanged lines hidden (view full) --- 637 return (0); 638} 639 640 641 642/* Deallocate memory that was allocated by mpt_dma_mem_alloc 643 */ 644static void |
624mpt_dma_mem_free(mpt_softc_t *mpt) | 645mpt_dma_mem_free(struct mpt_softc *mpt) |
625{ 626 int i; 627 628 /* Make sure we aren't double destroying */ 629 if (mpt->reply_dmat == 0) { | 646{ 647 int i; 648 649 /* Make sure we aren't double destroying */ 650 if (mpt->reply_dmat == 0) { |
630 if (mpt->verbose) | 651 if (mpt->verbose >= MPT_PRT_DEBUG) |
631 device_printf(mpt->dev,"Already released dma memory\n"); 632 return; 633 } 634 635 for (i = 0; i < MPT_MAX_REQUESTS(mpt); i++) { 636 bus_dmamap_destroy(mpt->buffer_dmat, mpt->request_pool[i].dmap); 637 } 638 bus_dmamap_unload(mpt->request_dmat, mpt->request_dmap); --- 9 unchanged lines hidden (view full) --- 648 mpt->request_pool = 0; 649 650} 651 652 653 654/* Reads modifiable (via PCI transactions) config registers */ 655static void | 652 device_printf(mpt->dev,"Already released dma memory\n"); 653 return; 654 } 655 656 for (i = 0; i < MPT_MAX_REQUESTS(mpt); i++) { 657 bus_dmamap_destroy(mpt->buffer_dmat, mpt->request_pool[i].dmap); 658 } 659 bus_dmamap_unload(mpt->request_dmat, mpt->request_dmap); --- 9 unchanged lines hidden (view full) --- 669 mpt->request_pool = 0; 670 671} 672 673 674 675/* Reads modifiable (via PCI transactions) config registers */ 676static void |
656mpt_read_config_regs(mpt_softc_t *mpt) | 677mpt_read_config_regs(struct mpt_softc *mpt) |
657{ 658 mpt->pci_cfg.Command = pci_read_config(mpt->dev, PCIR_COMMAND, 2); 659 mpt->pci_cfg.LatencyTimer_LineSize = 660 pci_read_config(mpt->dev, PCIR_CACHELNSZ, 2); 661 mpt->pci_cfg.IO_BAR = pci_read_config(mpt->dev, PCIR_BAR(0), 4); 662 mpt->pci_cfg.Mem0_BAR[0] = pci_read_config(mpt->dev, PCIR_BAR(1), 4); 663 mpt->pci_cfg.Mem0_BAR[1] = pci_read_config(mpt->dev, PCIR_BAR(2), 4); 664 mpt->pci_cfg.Mem1_BAR[0] = pci_read_config(mpt->dev, PCIR_BAR(3), 4); 665 mpt->pci_cfg.Mem1_BAR[1] = pci_read_config(mpt->dev, PCIR_BAR(4), 4); 666 mpt->pci_cfg.ROM_BAR = pci_read_config(mpt->dev, PCIR_BIOS, 4); 667 mpt->pci_cfg.IntLine = pci_read_config(mpt->dev, PCIR_INTLINE, 1); 668 mpt->pci_cfg.PMCSR = pci_read_config(mpt->dev, 0x44, 4); 669} 670 671/* Sets modifiable config registers */ 672void | 678{ 679 mpt->pci_cfg.Command = pci_read_config(mpt->dev, PCIR_COMMAND, 2); 680 mpt->pci_cfg.LatencyTimer_LineSize = 681 pci_read_config(mpt->dev, PCIR_CACHELNSZ, 2); 682 mpt->pci_cfg.IO_BAR = pci_read_config(mpt->dev, PCIR_BAR(0), 4); 683 mpt->pci_cfg.Mem0_BAR[0] = pci_read_config(mpt->dev, PCIR_BAR(1), 4); 684 mpt->pci_cfg.Mem0_BAR[1] = pci_read_config(mpt->dev, PCIR_BAR(2), 4); 685 mpt->pci_cfg.Mem1_BAR[0] = pci_read_config(mpt->dev, PCIR_BAR(3), 4); 686 mpt->pci_cfg.Mem1_BAR[1] = pci_read_config(mpt->dev, PCIR_BAR(4), 4); 687 mpt->pci_cfg.ROM_BAR = pci_read_config(mpt->dev, PCIR_BIOS, 4); 688 mpt->pci_cfg.IntLine = pci_read_config(mpt->dev, PCIR_INTLINE, 1); 689 mpt->pci_cfg.PMCSR = pci_read_config(mpt->dev, 0x44, 4); 690} 691 692/* Sets modifiable config registers */ 693void |
673mpt_set_config_regs(mpt_softc_t *mpt) | 694mpt_set_config_regs(struct mpt_softc *mpt) |
674{ | 695{ |
675 u_int32_t val; | 696 uint32_t val; |
676 677#define MPT_CHECK(reg, offset, size) \ 678 val = pci_read_config(mpt->dev, offset, size); \ 679 if (mpt->pci_cfg.reg != val) { \ 680 mpt_prt(mpt, \ 681 "Restoring " #reg " to 0x%X from 0x%X\n", \ 682 mpt->pci_cfg.reg, val); \ 683 } 684 | 697 698#define MPT_CHECK(reg, offset, size) \ 699 val = pci_read_config(mpt->dev, offset, size); \ 700 if (mpt->pci_cfg.reg != val) { \ 701 mpt_prt(mpt, \ 702 "Restoring " #reg " to 0x%X from 0x%X\n", \ 703 mpt->pci_cfg.reg, val); \ 704 } 705 |
685 if (mpt->verbose) { | 706 if (mpt->verbose >= MPT_PRT_DEBUG) { |
686 MPT_CHECK(Command, PCIR_COMMAND, 2); 687 MPT_CHECK(LatencyTimer_LineSize, PCIR_CACHELNSZ, 2); 688 MPT_CHECK(IO_BAR, PCIR_BAR(0), 4); 689 MPT_CHECK(Mem0_BAR[0], PCIR_BAR(1), 4); 690 MPT_CHECK(Mem0_BAR[1], PCIR_BAR(2), 4); 691 MPT_CHECK(Mem1_BAR[0], PCIR_BAR(3), 4); 692 MPT_CHECK(Mem1_BAR[1], PCIR_BAR(4), 4); 693 MPT_CHECK(ROM_BAR, PCIR_BIOS, 4); --- 13 unchanged lines hidden (view full) --- 707 pci_write_config(mpt->dev, PCIR_BIOS, mpt->pci_cfg.ROM_BAR, 4); 708 pci_write_config(mpt->dev, PCIR_INTLINE, mpt->pci_cfg.IntLine, 1); 709 pci_write_config(mpt->dev, 0x44, mpt->pci_cfg.PMCSR, 4); 710} 711 712static void 713mpt_pci_intr(void *arg) 714{ | 707 MPT_CHECK(Command, PCIR_COMMAND, 2); 708 MPT_CHECK(LatencyTimer_LineSize, PCIR_CACHELNSZ, 2); 709 MPT_CHECK(IO_BAR, PCIR_BAR(0), 4); 710 MPT_CHECK(Mem0_BAR[0], PCIR_BAR(1), 4); 711 MPT_CHECK(Mem0_BAR[1], PCIR_BAR(2), 4); 712 MPT_CHECK(Mem1_BAR[0], PCIR_BAR(3), 4); 713 MPT_CHECK(Mem1_BAR[1], PCIR_BAR(4), 4); 714 MPT_CHECK(ROM_BAR, PCIR_BIOS, 4); --- 13 unchanged lines hidden (view full) --- 728 pci_write_config(mpt->dev, PCIR_BIOS, mpt->pci_cfg.ROM_BAR, 4); 729 pci_write_config(mpt->dev, PCIR_INTLINE, mpt->pci_cfg.IntLine, 1); 730 pci_write_config(mpt->dev, 0x44, mpt->pci_cfg.PMCSR, 4); 731} 732 733static void 734mpt_pci_intr(void *arg) 735{ |
715 mpt_softc_t *mpt = arg; | 736 struct mpt_softc *mpt; 737 738 mpt = (struct mpt_softc *)arg; |
716 MPT_LOCK(mpt); | 739 MPT_LOCK(mpt); |
717 (void) mpt_intr(mpt); | 740 mpt_intr(mpt); |
718 MPT_UNLOCK(mpt); 719} | 741 MPT_UNLOCK(mpt); 742} |