From f582582c11f73cef1733317743aa98045853bc3f Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 20 Mar 2014 10:17:14 +0100 Subject: [PATCH] mpt(4): Sync with FreeBSD. Nothing big, as far as I can tell. Some fixes and removal of old compatibility code. While here, use callout_init_mp() and callout_stop_sync(). --- share/man/man4/mpt.4 | 9 ++-- sys/dev/disk/mpt/mpilib/mpi.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_cnfg.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_fc.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_init.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_ioc.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_lan.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_raid.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_sas.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_targ.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_tool.h | 2 +- sys/dev/disk/mpt/mpilib/mpi_type.h | 2 +- sys/dev/disk/mpt/mpt.c | 4 +- sys/dev/disk/mpt/mpt.h | 25 ++++------- sys/dev/disk/mpt/mpt_cam.c | 19 ++++----- sys/dev/disk/mpt/mpt_cam.h | 2 +- sys/dev/disk/mpt/mpt_debug.c | 2 +- sys/dev/disk/mpt/mpt_pci.c | 67 +++++++++++++++--------------- sys/dev/disk/mpt/mpt_raid.c | 13 +++--- sys/dev/disk/mpt/mpt_raid.h | 2 +- sys/dev/disk/mpt/mpt_reg.h | 2 +- sys/dev/disk/mpt/mpt_user.c | 2 +- 22 files changed, 79 insertions(+), 90 deletions(-) diff --git a/share/man/man4/mpt.4 b/share/man/man4/mpt.4 index db3d32c876..fb6a449c3a 100644 --- a/share/man/man4/mpt.4 +++ b/share/man/man4/mpt.4 @@ -33,7 +33,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.\" $FreeBSD: src/share/man/man4/mpt.4,v 1.22 2011/07/23 22:55:32 gjb Exp $ +.\" $FreeBSD: head/share/man/man4/mpt.4 236623 2012-06-05 17:49:11Z obrien $ .\" .Dd July 21, 2012 .Dt MPT 4 @@ -131,8 +131,8 @@ Dell PowerEdge 1750 thru 2850 IBM eServer xSeries 335 .El .Pp -These systems also contain Integrated Raid Mirroring and Integrated -Raid Mirroring Enhanced which this driver also supports. +These systems also contain Integrated RAID Mirroring and Integrated +RAID Mirroring Enhanced which this driver also supports. .Pp The 53c1030 is also available in .Tn VMware @@ -144,7 +144,7 @@ controller chips are also present on many new AMD/Opteron based systems, like the Sun 4100. Note that this controller can drive both SAS and SATA drives or a mix of them at the same time. -The Integrated Raid Mirroring +The Integrated RAID Mirroring available for these controllers is poorly supported at best. .Pp The @@ -168,6 +168,7 @@ can take on - no separate compilation is required. .Xr pci 4 , .Xr sa 4 , .Xr scsi 4 , +.Xr targ 4 , .Xr mptutil 8 .Rs .%T "LSI Logic Website" diff --git a/sys/dev/disk/mpt/mpilib/mpi.h b/sys/dev/disk/mpt/mpilib/mpi.h index 12a1ce577b..b29b95ca7d 100644 --- a/sys/dev/disk/mpt/mpilib/mpi.h +++ b/sys/dev/disk/mpt/mpilib/mpi.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi.h,v 1.10 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_cnfg.h b/sys/dev/disk/mpt/mpilib/mpi_cnfg.h index 95da666df1..4669835ed7 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_cnfg.h +++ b/sys/dev/disk/mpt/mpilib/mpi_cnfg.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_cnfg.h,v 1.10 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_cnfg.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_fc.h b/sys/dev/disk/mpt/mpilib/mpi_fc.h index 7583d452e7..6c725fdf93 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_fc.h +++ b/sys/dev/disk/mpt/mpilib/mpi_fc.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_fc.h,v 1.7 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_fc.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_init.h b/sys/dev/disk/mpt/mpilib/mpi_init.h index a6edcbf0e3..ee1adfbcb5 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_init.h +++ b/sys/dev/disk/mpt/mpilib/mpi_init.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_init.h,v 1.9 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_init.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_ioc.h b/sys/dev/disk/mpt/mpilib/mpi_ioc.h index a1202178c6..fd693db6d2 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_ioc.h +++ b/sys/dev/disk/mpt/mpilib/mpi_ioc.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_ioc.h,v 1.11 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_ioc.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_lan.h b/sys/dev/disk/mpt/mpilib/mpi_lan.h index 5ae91185d1..063af553d0 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_lan.h +++ b/sys/dev/disk/mpt/mpilib/mpi_lan.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_lan.h,v 1.7 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_lan.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_raid.h b/sys/dev/disk/mpt/mpilib/mpi_raid.h index 83cdb06d4c..7d65405f07 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_raid.h +++ b/sys/dev/disk/mpt/mpilib/mpi_raid.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_raid.h,v 1.9 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_raid.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2005, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_sas.h b/sys/dev/disk/mpt/mpilib/mpi_sas.h index 8011ccc3f8..93c1a05b1c 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_sas.h +++ b/sys/dev/disk/mpt/mpilib/mpi_sas.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_sas.h,v 1.4 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_sas.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_targ.h b/sys/dev/disk/mpt/mpilib/mpi_targ.h index 2032ae5da5..9ee99efff5 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_targ.h +++ b/sys/dev/disk/mpt/mpilib/mpi_targ.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_targ.h,v 1.8 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_targ.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_tool.h b/sys/dev/disk/mpt/mpilib/mpi_tool.h index 93f043ab86..ea036c256d 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_tool.h +++ b/sys/dev/disk/mpt/mpilib/mpi_tool.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_tool.h,v 1.2 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_tool.h 233425 2012-03-24 16:23:21Z marius $ */ /*- * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpilib/mpi_type.h b/sys/dev/disk/mpt/mpilib/mpi_type.h index bf1a7a00da..8506d48596 100644 --- a/sys/dev/disk/mpt/mpilib/mpi_type.h +++ b/sys/dev/disk/mpt/mpilib/mpi_type.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpilib/mpi_type.h,v 1.12 2012/03/24 16:23:21 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpilib/mpi_type.h 233425 2012-03-24 16:23:21Z marius $ */ /* * Copyright (c) 2000-2010, LSI Logic Corporation and its contributors. * All rights reserved. diff --git a/sys/dev/disk/mpt/mpt.c b/sys/dev/disk/mpt/mpt.c index 497a2c90b4..3baee2de25 100644 --- a/sys/dev/disk/mpt/mpt.c +++ b/sys/dev/disk/mpt/mpt.c @@ -94,7 +94,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/mpt/mpt.c,v 1.61 2012/02/11 12:03:44 marius Exp $ + * $FreeBSD: head/sys/dev/mpt/mpt.c 241874 2012-10-22 10:42:59Z marius $ */ #include @@ -2369,7 +2369,7 @@ mpt_core_detach(struct mpt_softc *mpt) /* Make sure no request has pending timeouts. */ for (val = 0; val < MPT_MAX_REQUESTS(mpt); val++) { request_t *req = &mpt->request_pool[val]; - callout_stop(&req->callout); + mpt_callout_drain(mpt, &req->callout); } mpt_dma_buf_free(mpt); diff --git a/sys/dev/disk/mpt/mpt.h b/sys/dev/disk/mpt/mpt.h index c3c2720766..45f0670308 100644 --- a/sys/dev/disk/mpt/mpt.h +++ b/sys/dev/disk/mpt/mpt.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpt.h,v 1.60 2012/03/24 00:30:17 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpt.h 260058 2013-12-29 20:41:32Z marius $ */ /*- * Generic defines for LSI '909 FC adapters. * FreeBSD Version. @@ -100,7 +100,6 @@ #define _MPT_H_ /********************************* OS Includes ********************************/ -#include #include #include #include @@ -226,19 +225,6 @@ struct mpt_map_info { }; void mpt_map_rquest(void *, bus_dma_segment_t *, int, int); -/* **************************** NewBUS interrupt Crock ************************/ -#define mpt_setup_intr(d, i, f, U, if, ifa, hp) \ - bus_setup_intr(d, i, f, if, ifa, hp, NULL) - -/* **************************** NewBUS CAM Support ****************************/ -#define mpt_xpt_bus_register(sim, parent, bus) \ - xpt_bus_register(sim, bus) - -/**************************** Kernel Thread Support ***************************/ -#define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \ - kthread_create(func, farg, proc_ptr, fmtstr, arg) -#define mpt_kthread_exit(status) \ - kthread_exit() /********************************** Endianess *********************************/ #define MPT_2_HOST64(ptr, tag) ptr->tag = le64toh(ptr->tag) @@ -643,7 +629,7 @@ struct mpt_softc { /* * PCI Hardware info */ -#ifdef OLD_MSI +#if 0 /* XXX MSI-X support */ int pci_msi_count; #endif int irq_type; /* Interrupt type */ @@ -729,9 +715,10 @@ struct mpt_softc { uint16_t sequence; /* Sequence Number */ uint16_t pad3; - +#if 0 /* Paired port in some dual adapters configurations */ struct mpt_softc * mpt2; +#endif /* FW Image management */ uint32_t fw_image_size; @@ -787,7 +774,9 @@ mpt_assign_serno(struct mpt_softc *mpt, request_t *req) #define mpt_req_untimeout(req, func, arg) \ callout_stop(&(req)->callout) #define mpt_callout_init(mpt, c) \ - callout_init(c) + callout_init_mp(c) +#define mpt_callout_drain(mpt, c) \ + callout_stop_sync(c) /******************************* Register Access ******************************/ static __inline void mpt_write(struct mpt_softc *, size_t, uint32_t); diff --git a/sys/dev/disk/mpt/mpt_cam.c b/sys/dev/disk/mpt/mpt_cam.c index 8dfdff2dd9..c5d6e81533 100644 --- a/sys/dev/disk/mpt/mpt_cam.c +++ b/sys/dev/disk/mpt/mpt_cam.c @@ -105,9 +105,9 @@ #include "dev/disk/mpt/mpilib/mpi_targ.h" #include "dev/disk/mpt/mpilib/mpi_fc.h" #include "dev/disk/mpt/mpilib/mpi_sas.h" -#include #include #include +#include static void mpt_poll(struct cam_sim *); static timeout_t mpt_timeout; @@ -337,7 +337,7 @@ mpt_cam_attach(struct mpt_softc *mpt) * Register exactly this bus. */ MPT_LOCK(mpt); - if (mpt_xpt_bus_register(mpt->sim, mpt->dev, 0) != CAM_SUCCESS) { + if (xpt_bus_register(mpt->sim, 0) != CAM_SUCCESS) { mpt_prt(mpt, "Bus registration Failed!\n"); error = ENOMEM; MPT_UNLOCK(mpt); @@ -376,7 +376,7 @@ mpt_cam_attach(struct mpt_softc *mpt) * Register this bus. */ MPT_LOCK(mpt); - if (mpt_xpt_bus_register(mpt->phydisk_sim, mpt->dev, 1) != + if (xpt_bus_register(mpt->phydisk_sim, 1) != CAM_SUCCESS) { mpt_prt(mpt, "Physical Disk Bus registration Failed!\n"); error = ENOMEM; @@ -1425,7 +1425,7 @@ bad: /* SAS1078 36GB limitation WAR */ if (mpt->is_1078 && (((uint64_t)dm_segs->ds_addr + MPI_SGE_LENGTH(se->FlagsLength)) >> 32) == 9) { - addr |= (1 << 31); + addr |= (1U << 31); tf |= MPI_SGE_FLAGS_LOCAL_ADDRESS; } se->Address.High = htole32(addr); @@ -1548,7 +1548,7 @@ bad: (((uint64_t)dm_segs->ds_addr + MPI_SGE_LENGTH(se->FlagsLength)) >> 32) == 9) { - addr |= (1 << 31); + addr |= (1U << 31); tf |= MPI_SGE_FLAGS_LOCAL_ADDRESS; } se->Address.High = htole32(addr); @@ -3804,7 +3804,7 @@ mpt_get_spi_settings(struct mpt_softc *mpt, struct ccb_trans_settings *cts) } mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "mpt_get_spi_settings[%d]: %s flags 0x%x per 0x%x off=%d\n", tgt, - IS_CURRENT_SETTINGS(cts)? "ACTIVE" : "NVRAM ", dval, pval, oval); + IS_CURRENT_SETTINGS(cts) ? "ACTIVE" : "NVRAM ", dval, pval, oval); return (0); } @@ -3874,9 +3874,8 @@ mpt_spawn_recovery_thread(struct mpt_softc *mpt) { int error; - error = mpt_kthread_create(mpt_recovery_thread, mpt, - &mpt->recovery_thread, /*flags*/0, - /*altstack*/0, "mpt_recovery%d", mpt->unit); + error = kthread_create(mpt_recovery_thread, mpt, + &mpt->recovery_thread, "mpt_recovery%d", mpt->unit); return (error); } @@ -3917,7 +3916,7 @@ mpt_recovery_thread(void *arg) mpt->recovery_thread = NULL; wakeup(&mpt->recovery_thread); MPT_UNLOCK(mpt); - mpt_kthread_exit(0); + kthread_exit(); } static int diff --git a/sys/dev/disk/mpt/mpt_cam.h b/sys/dev/disk/mpt/mpt_cam.h index 318fa62703..e2e19500e7 100644 --- a/sys/dev/disk/mpt/mpt_cam.h +++ b/sys/dev/disk/mpt/mpt_cam.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpt_cam.h,v 1.7 2010/01/28 08:41:30 mav Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpt_cam.h 203108 2010-01-28 08:41:30Z mav $ */ /*- * LSI MPT Host Adapter FreeBSD Wrapper Definitions (CAM version) * diff --git a/sys/dev/disk/mpt/mpt_debug.c b/sys/dev/disk/mpt/mpt_debug.c index 81c42d9f20..e3bcaae798 100644 --- a/sys/dev/disk/mpt/mpt_debug.c +++ b/sys/dev/disk/mpt/mpt_debug.c @@ -62,7 +62,7 @@ * Support from LSI-Logic has also gone a great deal toward making this a * workable subsystem and is gratefully acknowledged. * - * $FreeBSD: src/sys/dev/mpt/mpt_debug.c,v 1.20 2011/07/29 18:35:10 marius Exp $ + * $FreeBSD: head/sys/dev/mpt/mpt_debug.c 241874 2012-10-22 10:42:59Z marius $ */ #include diff --git a/sys/dev/disk/mpt/mpt_pci.c b/sys/dev/disk/mpt/mpt_pci.c index 24fe9d9509..f9a4013cad 100644 --- a/sys/dev/disk/mpt/mpt_pci.c +++ b/sys/dev/disk/mpt/mpt_pci.c @@ -140,10 +140,6 @@ #define MPI_MANUFACTPAGE_DEVID_SAS1078DE_FB 0x007C #endif -#ifndef PCIM_CMD_SERRESPEN -#define PCIM_CMD_SERRESPEN 0x0100 -#endif - static int mpt_pci_probe(device_t); static int mpt_pci_attach(device_t); static void mpt_free_bus_resources(struct mpt_softc *mpt); @@ -169,6 +165,7 @@ static device_method_t mpt_methods[] = { static driver_t mpt_driver = { "mpt", mpt_methods, sizeof(struct mpt_softc) }; + static devclass_t mpt_devclass; DRIVER_MODULE(mpt, pci, mpt_driver, mpt_devclass, NULL, NULL); MODULE_DEPEND(mpt, pci, 1, 1, 1); @@ -319,6 +316,7 @@ mpt_set_options(struct mpt_softc *mpt) mpt->msi_enable = tval; } +#if 0 static void mpt_link_peer(struct mpt_softc *mpt) { @@ -357,13 +355,14 @@ mpt_unlink_peer(struct mpt_softc *mpt) mpt->mpt2->mpt2 = NULL; } } +#endif static int mpt_pci_attach(device_t dev) { struct mpt_softc *mpt; int iqd; - uint32_t data, cmd; + uint32_t val; int mpt_io_bar, mpt_mem_bar; u_int irq_flags; @@ -417,28 +416,23 @@ mpt_pci_attach(device_t dev) /* Print INFO level (if any) if bootverbose is set */ mpt->verbose += (bootverbose != 0)? 1 : 0; } - /* Make sure memory access decoders are enabled */ - cmd = pci_read_config(dev, PCIR_COMMAND, 2); - if ((cmd & PCIM_CMD_MEMEN) == 0) { - device_printf(dev, "Memory accesses disabled"); - return (ENXIO); - } /* * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER are set. */ - cmd |= - PCIM_CMD_SERRESPEN | PCIM_CMD_PERRESPEN | + val = pci_read_config(dev, PCIR_COMMAND, 2); + val |= PCIM_CMD_SERRESPEN | PCIM_CMD_PERRESPEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN; - pci_write_config(dev, PCIR_COMMAND, cmd, 2); + pci_write_config(dev, PCIR_COMMAND, val, 2); /* * Make sure we've disabled the ROM. */ - data = pci_read_config(dev, PCIR_BIOS, 4); - data &= ~PCIM_BIOS_ENABLE; - pci_write_config(dev, PCIR_BIOS, data, 4); + val = pci_read_config(dev, PCIR_BIOS, 4); + val &= ~PCIM_BIOS_ENABLE; + pci_write_config(dev, PCIR_BIOS, val, 4); +#if 0 /* * Is this part a dual? * If so, link with our partner (around yet) @@ -455,12 +449,13 @@ mpt_pci_attach(device_t dev) default: break; } +#endif /* * Figure out which are the I/O and MEM Bars */ - data = pci_read_config(dev, PCIR_BAR(0), 4); - if (PCI_BAR_IO(data)) { + val = pci_read_config(dev, PCIR_BAR(0), 4); + if (PCI_BAR_IO(val)) { /* BAR0 is IO, BAR1 is memory */ mpt_io_bar = 0; mpt_mem_bar = 1; @@ -512,7 +507,7 @@ mpt_pci_attach(device_t dev) /* Get a handle to the interrupt */ iqd = 0; -#ifdef OLD_MSI +#if 0 /* XXX MSI-X support */ if (mpt->msi_enable) { /* * First try to alloc an MSI-X message. If that @@ -543,8 +538,8 @@ mpt_pci_attach(device_t dev) mpt_disable_ints(mpt); /* Register the interrupt handler */ - if (mpt_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, NULL, mpt_pci_intr, - mpt, &mpt->ih)) { + if (bus_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, mpt_pci_intr, + mpt, &mpt->ih, NULL)) { device_printf(dev, "could not setup interrupt\n"); goto bad; } @@ -587,11 +582,14 @@ mpt_pci_attach(device_t dev) } mpt->eh = EVENTHANDLER_REGISTER(shutdown_post_sync, mpt_pci_shutdown, - dev, SHUTDOWN_PRI_DEFAULT); + dev, SHUTDOWN_PRI_LAST); if (mpt->eh == NULL) { mpt_prt(mpt, "shutdown event registration failed\n"); + mpt_disable_ints(mpt); (void) mpt_detach(mpt); + mpt_reset(mpt, /*reinit*/FALSE); + mpt_raid_free_mem(mpt); goto bad; } return (0); @@ -599,7 +597,9 @@ mpt_pci_attach(device_t dev) bad: mpt_dma_mem_free(mpt); mpt_free_bus_resources(mpt); +#if 0 mpt_unlink_peer(mpt); +#endif MPT_LOCK_DESTROY(mpt); @@ -624,23 +624,23 @@ mpt_free_bus_resources(struct mpt_softc *mpt) if (mpt->pci_irq) { bus_release_resource(mpt->dev, SYS_RES_IRQ, rman_get_rid(mpt->pci_irq), mpt->pci_irq); + if (mpt->irq_type == PCI_INTR_TYPE_MSI) + pci_release_msi(mpt->dev); + mpt->pci_irq = NULL; } - if (mpt->irq_type == PCI_INTR_TYPE_MSI) - pci_release_msi(mpt->dev); - if (mpt->pci_pio_reg) { bus_release_resource(mpt->dev, SYS_RES_IOPORT, rman_get_rid(mpt->pci_pio_reg), mpt->pci_pio_reg); mpt->pci_pio_reg = NULL; } + if (mpt->pci_reg) { bus_release_resource(mpt->dev, SYS_RES_MEMORY, rman_get_rid(mpt->pci_reg), mpt->pci_reg); mpt->pci_reg = NULL; } - MPT_LOCK_DESTROY(mpt); } /* @@ -657,12 +657,16 @@ mpt_pci_detach(device_t dev) mpt_disable_ints(mpt); mpt_detach(mpt); mpt_reset(mpt, /*reinit*/FALSE); + mpt_raid_free_mem(mpt); mpt_dma_mem_free(mpt); mpt_free_bus_resources(mpt); - mpt_raid_free_mem(mpt); +#if 0 + mpt_unlink_peer(mpt); +#endif if (mpt->eh != NULL) { EVENTHANDLER_DEREGISTER(shutdown_post_sync, mpt->eh); } + MPT_LOCK_DESTROY(mpt); } return(0); } @@ -676,11 +680,8 @@ mpt_pci_shutdown(device_t dev) struct mpt_softc *mpt; mpt = (struct mpt_softc *)device_get_softc(dev); - if (mpt) { - int r; - r = mpt_shutdown(mpt); - return (r); - } + if (mpt) + return (mpt_shutdown(mpt)); return(0); } diff --git a/sys/dev/disk/mpt/mpt_raid.c b/sys/dev/disk/mpt/mpt_raid.c index d57237cbdc..b00738ee35 100644 --- a/sys/dev/disk/mpt/mpt_raid.c +++ b/sys/dev/disk/mpt/mpt_raid.c @@ -39,7 +39,7 @@ * Support from LSI-Logic has also gone a great deal toward making this a * workable subsystem and is gratefully acknowledged. * - * $FreeBSD: src/sys/dev/mpt/mpt_raid.c,v 1.30 2011/07/29 18:38:31 marius Exp $ + * $FreeBSD: head/sys/dev/mpt/mpt_raid.c 260058 2013-12-29 20:41:32Z marius $ */ #include @@ -50,9 +50,9 @@ #include #include +#include #include #include -#include #include #include @@ -326,7 +326,7 @@ mpt_raid_detach(struct mpt_softc *mpt) struct ccb_setasync csa; mpt_handler_t handler; - callout_stop(&mpt->raid_timer); + mpt_callout_drain(mpt, &mpt->raid_timer); MPT_LOCK(mpt); mpt_terminate_raid_thread(mpt); @@ -635,9 +635,8 @@ mpt_spawn_raid_thread(struct mpt_softc *mpt) MPT_LOCK(mpt); xpt_freeze_simq(mpt->phydisk_sim, 1); MPT_UNLOCK(mpt); - error = mpt_kthread_create(mpt_raid_thread, mpt, - &mpt->raid_thread, /*flags*/0, /*altstack*/0, - "mpt_raid%d", mpt->unit); + error = kthread_create(mpt_raid_thread, mpt, + &mpt->raid_thread, "mpt_raid%d", mpt->unit); if (error != 0) { MPT_LOCK(mpt); xpt_release_simq(mpt->phydisk_sim, /*run_queue*/FALSE); @@ -733,7 +732,7 @@ mpt_raid_thread(void *arg) mpt->raid_thread = NULL; wakeup(&mpt->raid_thread); MPT_UNLOCK(mpt); - mpt_kthread_exit(0); + kthread_exit(); } #if 0 diff --git a/sys/dev/disk/mpt/mpt_raid.h b/sys/dev/disk/mpt/mpt_raid.h index 14485a25a2..0a9763a511 100644 --- a/sys/dev/disk/mpt/mpt_raid.h +++ b/sys/dev/disk/mpt/mpt_raid.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpt_raid.h,v 1.9 2011/07/29 18:38:31 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpt_raid.h 224494 2011-07-29 18:38:31Z marius $ */ /*- * Definitions for the integrated RAID features LSI MPT Fusion adapters. * diff --git a/sys/dev/disk/mpt/mpt_reg.h b/sys/dev/disk/mpt/mpt_reg.h index 3537d13d86..1d0a74877c 100644 --- a/sys/dev/disk/mpt/mpt_reg.h +++ b/sys/dev/disk/mpt/mpt_reg.h @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mpt/mpt_reg.h,v 1.5 2012/02/11 12:03:44 marius Exp $ */ +/* $FreeBSD: head/sys/dev/mpt/mpt_reg.h 231518 2012-02-11 12:03:44Z marius $ */ /*- * Generic defines for LSI '909 FC adapters. * FreeBSD Version. diff --git a/sys/dev/disk/mpt/mpt_user.c b/sys/dev/disk/mpt/mpt_user.c index b54e9c4999..617a15b7b5 100644 --- a/sys/dev/disk/mpt/mpt_user.c +++ b/sys/dev/disk/mpt/mpt_user.c @@ -29,7 +29,7 @@ * * LSI MPT-Fusion Host Adapter FreeBSD userland interface * - * $FreeBSD: src/sys/dev/mpt/mpt_user.c,v 1.6 2011/07/29 18:35:10 marius Exp $ + * $FreeBSD: head/sys/dev/mpt/mpt_user.c 251187 2013-05-31 17:27:44Z delphij $ */ #include -- 2.41.0