[Midnightbsd-cvs] src [10103] trunk/sys/dev: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 19:44:08 EDT 2018


Revision: 10103
          http://svnweb.midnightbsd.org/src/?rev=10103
Author:   laffer1
Date:     2018-05-27 19:44:07 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/dev/ichwd/ichwd.c
    trunk/sys/dev/ichwd/ichwd.h
    trunk/sys/dev/ida/ida.c
    trunk/sys/dev/ida/ida_disk.c
    trunk/sys/dev/ida/ida_eisa.c
    trunk/sys/dev/ida/ida_pci.c
    trunk/sys/dev/ida/idaio.h
    trunk/sys/dev/ida/idareg.h
    trunk/sys/dev/ida/idavar.h
    trunk/sys/dev/ie/if_ie.c
    trunk/sys/dev/ie/if_ie507.h
    trunk/sys/dev/ie/if_ie_isa.c
    trunk/sys/dev/ie/if_iee16.h
    trunk/sys/dev/ie/if_iereg.h
    trunk/sys/dev/ie/if_ievar.h
    trunk/sys/dev/ieee488/ibfoo.c
    trunk/sys/dev/ieee488/ibfoo_int.h
    trunk/sys/dev/ieee488/pcii.c
    trunk/sys/dev/ieee488/tnt4882.c
    trunk/sys/dev/ieee488/tnt4882.h
    trunk/sys/dev/ieee488/ugpib.h
    trunk/sys/dev/ieee488/upd7210.c
    trunk/sys/dev/ieee488/upd7210.h
    trunk/sys/dev/iir/iir.c
    trunk/sys/dev/iir/iir.h
    trunk/sys/dev/iir/iir_ctrl.c
    trunk/sys/dev/iir/iir_pci.c
    trunk/sys/dev/io/iodev.c
    trunk/sys/dev/io/iodev.h
    trunk/sys/dev/ipmi/ipmi.c
    trunk/sys/dev/ipmi/ipmi_acpi.c
    trunk/sys/dev/ipmi/ipmi_isa.c
    trunk/sys/dev/ipmi/ipmi_kcs.c
    trunk/sys/dev/ipmi/ipmi_linux.c
    trunk/sys/dev/ipmi/ipmi_pci.c
    trunk/sys/dev/ipmi/ipmi_smbios.c
    trunk/sys/dev/ipmi/ipmi_smbus.c
    trunk/sys/dev/ipmi/ipmi_smic.c
    trunk/sys/dev/ipmi/ipmi_ssif.c
    trunk/sys/dev/ipmi/ipmivars.h
    trunk/sys/dev/ips/ips.c
    trunk/sys/dev/ips/ips.h
    trunk/sys/dev/ips/ips_commands.c
    trunk/sys/dev/ips/ips_disk.c
    trunk/sys/dev/ips/ips_disk.h
    trunk/sys/dev/ips/ips_ioctl.c
    trunk/sys/dev/ips/ips_ioctl.h
    trunk/sys/dev/ips/ips_pci.c
    trunk/sys/dev/ips/ipsreg.h
    trunk/sys/dev/ipw/if_ipw.c
    trunk/sys/dev/ipw/if_ipwreg.h
    trunk/sys/dev/ipw/if_ipwvar.h

Modified: trunk/sys/dev/ichwd/ichwd.c
===================================================================
--- trunk/sys/dev/ichwd/ichwd.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ichwd/ichwd.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Texas A&M University
  * All rights reserved.
@@ -53,10 +54,11 @@
  * (document no. 252516-001) sections 9.10 and 9.11.
  *
  * ICH6/7/8 support by Takeharu KATO <takeharu1219 at ybb.ne.jp>
+ * SoC PMC support by Denir Li <denir.li at cas-well.com>
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ichwd/ichwd.c 322116 2017-08-06 08:15:21Z mav $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -74,161 +76,216 @@
 #include <dev/ichwd/ichwd.h>
 
 static struct ichwd_device ichwd_devices[] = {
-	{ DEVICEID_82801AA,  "Intel 82801AA watchdog timer",	1 },
-	{ DEVICEID_82801AB,  "Intel 82801AB watchdog timer",	1 },
-	{ DEVICEID_82801BA,  "Intel 82801BA watchdog timer",	2 },
-	{ DEVICEID_82801BAM, "Intel 82801BAM watchdog timer",	2 },
-	{ DEVICEID_82801CA,  "Intel 82801CA watchdog timer",	3 },
-	{ DEVICEID_82801CAM, "Intel 82801CAM watchdog timer",	3 },
-	{ DEVICEID_82801DB,  "Intel 82801DB watchdog timer",	4 },
-	{ DEVICEID_82801DBM, "Intel 82801DBM watchdog timer",	4 },
-	{ DEVICEID_82801E,   "Intel 82801E watchdog timer",	5 },
-	{ DEVICEID_82801EB,  "Intel 82801EB watchdog timer",	5 },
-	{ DEVICEID_82801EBR, "Intel 82801EB/ER watchdog timer",	5 },
-	{ DEVICEID_6300ESB,  "Intel 6300ESB watchdog timer",	5 },
-	{ DEVICEID_82801FBR, "Intel 82801FB/FR watchdog timer",	6 },
-	{ DEVICEID_ICH6M,    "Intel ICH6M watchdog timer",	6 },
-	{ DEVICEID_ICH6W,    "Intel ICH6W watchdog timer",	6 },
-	{ DEVICEID_ICH7,     "Intel ICH7 watchdog timer",	7 },
-	{ DEVICEID_ICH7DH,   "Intel ICH7DH watchdog timer",	7 },
-	{ DEVICEID_ICH7M,    "Intel ICH7M watchdog timer",	7 },
-	{ DEVICEID_ICH7MDH,  "Intel ICH7MDH watchdog timer",	7 },
-	{ DEVICEID_NM10,     "Intel NM10 watchdog timer",	7 },
-	{ DEVICEID_ICH8,     "Intel ICH8 watchdog timer",	8 },
-	{ DEVICEID_ICH8DH,   "Intel ICH8DH watchdog timer",	8 },
-	{ DEVICEID_ICH8DO,   "Intel ICH8DO watchdog timer",	8 },
-	{ DEVICEID_ICH8M,    "Intel ICH8M watchdog timer",	8 },
-	{ DEVICEID_ICH8ME,   "Intel ICH8M-E watchdog timer",	8 },
-	{ DEVICEID_63XXESB,  "Intel 63XXESB watchdog timer",	8 },
-	{ DEVICEID_ICH9,     "Intel ICH9 watchdog timer",	9 },
-	{ DEVICEID_ICH9DH,   "Intel ICH9DH watchdog timer",	9 },
-	{ DEVICEID_ICH9DO,   "Intel ICH9DO watchdog timer",	9 },
-	{ DEVICEID_ICH9M,    "Intel ICH9M watchdog timer",	9 },
-	{ DEVICEID_ICH9ME,   "Intel ICH9M-E watchdog timer",	9 },
-	{ DEVICEID_ICH9R,    "Intel ICH9R watchdog timer",	9 },
-	{ DEVICEID_ICH10,    "Intel ICH10 watchdog timer",	10 },
-	{ DEVICEID_ICH10D,   "Intel ICH10D watchdog timer",	10 },
-	{ DEVICEID_ICH10DO,  "Intel ICH10DO watchdog timer",	10 },
-	{ DEVICEID_ICH10R,   "Intel ICH10R watchdog timer",	10 },
-	{ DEVICEID_PCH,      "Intel PCH watchdog timer",	10 },
-	{ DEVICEID_PCHM,     "Intel PCH watchdog timer",	10 },
-	{ DEVICEID_P55,      "Intel P55 watchdog timer",	10 },
-	{ DEVICEID_PM55,     "Intel PM55 watchdog timer",	10 },
-	{ DEVICEID_H55,      "Intel H55 watchdog timer",	10 },
-	{ DEVICEID_QM57,     "Intel QM57 watchdog timer",       10 },
-	{ DEVICEID_H57,      "Intel H57 watchdog timer",        10 },
-	{ DEVICEID_HM55,     "Intel HM55 watchdog timer",       10 },
-	{ DEVICEID_Q57,      "Intel Q57 watchdog timer",        10 },
-	{ DEVICEID_HM57,     "Intel HM57 watchdog timer",       10 },
-	{ DEVICEID_PCHMSFF,  "Intel PCHMSFF watchdog timer",    10 },
-	{ DEVICEID_QS57,     "Intel QS57 watchdog timer",       10 },
-	{ DEVICEID_3400,     "Intel 3400 watchdog timer",       10 },
-	{ DEVICEID_3420,     "Intel 3420 watchdog timer",       10 },
-	{ DEVICEID_3450,     "Intel 3450 watchdog timer",       10 },
-	{ DEVICEID_CPT0,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT1,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT2,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT3,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT4,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT5,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT6,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT7,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT8,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT9,     "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT10,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT11,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT12,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT13,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT14,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT15,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT16,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT17,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT18,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT19,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT20,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT21,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT22,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT23,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT23,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT25,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT26,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT27,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT28,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT29,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT30,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_CPT31,    "Intel Cougar Point watchdog timer",	10 },
-	{ DEVICEID_PATSBURG_LPC1, "Intel Patsburg watchdog timer",	10 },
-	{ DEVICEID_PATSBURG_LPC2, "Intel Patsburg watchdog timer",	10 },
-	{ DEVICEID_PPT0,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT1,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT2,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT3,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT4,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT5,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT6,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT7,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT8,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT9,     "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT10,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT11,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT12,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT13,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT14,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT15,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT16,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT17,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT18,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT19,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT20,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT21,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT22,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT23,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT24,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT25,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT26,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT27,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT28,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT29,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT30,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_PPT31,    "Intel Panther Point watchdog timer",	10 },
-	{ DEVICEID_LPT0,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT1,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT2,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT3,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT4,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT5,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT6,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT7,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT8,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT9,     "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT10,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT11,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT12,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT13,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT14,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT15,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT16,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT17,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT18,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT19,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT20,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT21,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT22,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT23,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT24,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT25,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT26,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT27,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT28,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT29,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT30,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_LPT31,    "Intel Lynx Point watchdog timer",		10 },
-	{ DEVICEID_WCPT2,    "Intel Wildcat Point watchdog timer",	10 },
-	{ DEVICEID_WCPT4,    "Intel Wildcat Point watchdog timer",	10 },
-	{ DEVICEID_WCPT6,    "Intel Wildcat Point watchdog timer",	10 },
-	{ DEVICEID_DH89XXCC_LPC,  "Intel DH89xxCC watchdog timer",	10 },
-	{ DEVICEID_COLETOCRK_LPC, "Intel Coleto Creek watchdog timer",  10 },
-	{ 0, NULL, 0 },
+	{ DEVICEID_82801AA,  "Intel 82801AA watchdog timer",	1, 1 },
+	{ DEVICEID_82801AB,  "Intel 82801AB watchdog timer",	1, 1 },
+	{ DEVICEID_82801BA,  "Intel 82801BA watchdog timer",	2, 1 },
+	{ DEVICEID_82801BAM, "Intel 82801BAM watchdog timer",	2, 1 },
+	{ DEVICEID_82801CA,  "Intel 82801CA watchdog timer",	3, 1 },
+	{ DEVICEID_82801CAM, "Intel 82801CAM watchdog timer",	3, 1 },
+	{ DEVICEID_82801DB,  "Intel 82801DB watchdog timer",	4, 1 },
+	{ DEVICEID_82801DBM, "Intel 82801DBM watchdog timer",	4, 1 },
+	{ DEVICEID_82801E,   "Intel 82801E watchdog timer",	5, 1 },
+	{ DEVICEID_82801EB,  "Intel 82801EB watchdog timer",	5, 1 },
+	{ DEVICEID_82801EBR, "Intel 82801EB/ER watchdog timer",	5, 1 },
+	{ DEVICEID_6300ESB,  "Intel 6300ESB watchdog timer",	5, 1 },
+	{ DEVICEID_82801FBR, "Intel 82801FB/FR watchdog timer",	6, 2 },
+	{ DEVICEID_ICH6M,    "Intel ICH6M watchdog timer",	6, 2 },
+	{ DEVICEID_ICH6W,    "Intel ICH6W watchdog timer",	6, 2 },
+	{ DEVICEID_ICH7,     "Intel ICH7 watchdog timer",	7, 2 },
+	{ DEVICEID_ICH7DH,   "Intel ICH7DH watchdog timer",	7, 2 },
+	{ DEVICEID_ICH7M,    "Intel ICH7M watchdog timer",	7, 2 },
+	{ DEVICEID_ICH7MDH,  "Intel ICH7MDH watchdog timer",	7, 2 },
+	{ DEVICEID_NM10,     "Intel NM10 watchdog timer",	7, 2 },
+	{ DEVICEID_ICH8,     "Intel ICH8 watchdog timer",	8, 2 },
+	{ DEVICEID_ICH8DH,   "Intel ICH8DH watchdog timer",	8, 2 },
+	{ DEVICEID_ICH8DO,   "Intel ICH8DO watchdog timer",	8, 2 },
+	{ DEVICEID_ICH8M,    "Intel ICH8M watchdog timer",	8, 2 },
+	{ DEVICEID_ICH8ME,   "Intel ICH8M-E watchdog timer",	8, 2 },
+	{ DEVICEID_63XXESB,  "Intel 63XXESB watchdog timer",	8, 2 },
+	{ DEVICEID_ICH9,     "Intel ICH9 watchdog timer",	9, 2 },
+	{ DEVICEID_ICH9DH,   "Intel ICH9DH watchdog timer",	9, 2 },
+	{ DEVICEID_ICH9DO,   "Intel ICH9DO watchdog timer",	9, 2 },
+	{ DEVICEID_ICH9M,    "Intel ICH9M watchdog timer",	9, 2 },
+	{ DEVICEID_ICH9ME,   "Intel ICH9M-E watchdog timer",	9, 2 },
+	{ DEVICEID_ICH9R,    "Intel ICH9R watchdog timer",	9, 2 },
+	{ DEVICEID_ICH10,    "Intel ICH10 watchdog timer",	10, 2 },
+	{ DEVICEID_ICH10D,   "Intel ICH10D watchdog timer",	10, 2 },
+	{ DEVICEID_ICH10DO,  "Intel ICH10DO watchdog timer",	10, 2 },
+	{ DEVICEID_ICH10R,   "Intel ICH10R watchdog timer",	10, 2 },
+	{ DEVICEID_PCH,      "Intel PCH watchdog timer",	10, 2 },
+	{ DEVICEID_PCHM,     "Intel PCH watchdog timer",	10, 2 },
+	{ DEVICEID_P55,      "Intel P55 watchdog timer",	10, 2 },
+	{ DEVICEID_PM55,     "Intel PM55 watchdog timer",	10, 2 },
+	{ DEVICEID_H55,      "Intel H55 watchdog timer",	10, 2 },
+	{ DEVICEID_QM57,     "Intel QM57 watchdog timer",       10, 2 },
+	{ DEVICEID_H57,      "Intel H57 watchdog timer",        10, 2 },
+	{ DEVICEID_HM55,     "Intel HM55 watchdog timer",       10, 2 },
+	{ DEVICEID_Q57,      "Intel Q57 watchdog timer",        10, 2 },
+	{ DEVICEID_HM57,     "Intel HM57 watchdog timer",       10, 2 },
+	{ DEVICEID_PCHMSFF,  "Intel PCHMSFF watchdog timer",    10, 2 },
+	{ DEVICEID_QS57,     "Intel QS57 watchdog timer",       10, 2 },
+	{ DEVICEID_3400,     "Intel 3400 watchdog timer",       10, 2 },
+	{ DEVICEID_3420,     "Intel 3420 watchdog timer",       10, 2 },
+	{ DEVICEID_3450,     "Intel 3450 watchdog timer",       10, 2 },
+	{ DEVICEID_CPT0,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT1,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT2,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT3,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT4,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT5,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT6,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT7,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT8,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT9,     "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT10,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT11,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT12,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT13,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT14,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT15,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT16,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT17,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT18,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT19,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT20,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT21,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT22,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT23,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT24,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT25,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT26,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT27,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT28,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT29,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT30,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_CPT31,    "Intel Cougar Point watchdog timer",	10, 2 },
+	{ DEVICEID_PATSBURG_LPC1, "Intel Patsburg watchdog timer",	10, 2 },
+	{ DEVICEID_PATSBURG_LPC2, "Intel Patsburg watchdog timer",	10, 2 },
+	{ DEVICEID_PPT0,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT1,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT2,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT3,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT4,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT5,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT6,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT7,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT8,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT9,     "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT10,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT11,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT12,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT13,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT14,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT15,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT16,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT17,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT18,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT19,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT20,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT21,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT22,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT23,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT24,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT25,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT26,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT27,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT28,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT29,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT30,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_PPT31,    "Intel Panther Point watchdog timer",	10, 2 },
+	{ DEVICEID_LPT0,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT1,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT2,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT3,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT4,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT5,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT6,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT7,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT8,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT9,     "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT10,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT11,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT12,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT13,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT14,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT15,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT16,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT17,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT18,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT19,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT20,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT21,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT22,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT23,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT24,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT25,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT26,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT27,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT28,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT29,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT30,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_LPT31,    "Intel Lynx Point watchdog timer",		10, 2 },
+	{ DEVICEID_WCPT1,    "Intel Wildcat Point watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT2,    "Intel Wildcat Point watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT3,    "Intel Wildcat Point watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT4,    "Intel Wildcat Point watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT6,    "Intel Wildcat Point watchdog timer",	10, 2 },
+	{ DEVICEID_WBG0,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG1,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG2,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG3,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG4,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG5,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG6,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG7,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG8,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG9,     "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG10,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG11,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG12,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG13,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG14,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG15,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG16,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG17,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG18,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG19,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG20,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG21,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG22,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG23,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG24,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG25,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG26,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG27,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG28,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG29,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG30,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_WBG31,    "Intel Wellsburg watchdog timer",		10, 2 },
+	{ DEVICEID_LPT_LP0,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP1,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP2,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP3,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP4,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP5,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP6,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_LPT_LP7,  "Intel Lynx Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP1, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP2, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP3, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP5, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP6, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP7, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_WCPT_LP9, "Intel Wildcat Point-LP watchdog timer",	10, 2 },
+	{ DEVICEID_DH89XXCC_LPC,  "Intel DH89xxCC watchdog timer",	10, 2 },
+	{ DEVICEID_COLETOCRK_LPC, "Intel Coleto Creek watchdog timer",  10, 2 },
+	{ DEVICEID_AVN0,     "Intel Avoton/Rangeley SoC watchdog timer",10, 3 },
+	{ DEVICEID_AVN1,     "Intel Avoton/Rangeley SoC watchdog timer",10, 3 },
+	{ DEVICEID_AVN2,     "Intel Avoton/Rangeley SoC watchdog timer",10, 3 },
+	{ DEVICEID_AVN3,     "Intel Avoton/Rangeley SoC watchdog timer",10, 3 },
+	{ DEVICEID_BAYTRAIL, "Intel Bay Trail SoC watchdog timer",	10, 3 },
+	{ DEVICEID_BRASWELL, "Intel Braswell SoC watchdog timer",	10, 3 },
+	{ 0, NULL, 0, 0 },
 };
 
 static devclass_t ichwd_devclass;
@@ -243,6 +300,9 @@
 	bus_read_4((sc)->smi_res, (off))
 #define ichwd_read_gcs_4(sc, off) \
 	bus_read_4((sc)->gcs_res, (off))
+/* NB: TCO version 3 devices use the gcs_res resource for the PMC register. */
+#define ichwd_read_pmc_4(sc, off) \
+	bus_read_4((sc)->gcs_res, (off))
 
 #define ichwd_write_tco_1(sc, off, val) \
 	bus_write_1((sc)->tco_res, (off), (val))
@@ -254,6 +314,9 @@
 	bus_write_4((sc)->smi_res, (off), (val))
 #define ichwd_write_gcs_4(sc, off, val) \
 	bus_write_4((sc)->gcs_res, (off), (val))
+/* NB: TCO version 3 devices use the gcs_res resource for the PMC register. */
+#define ichwd_write_pmc_4(sc, off, val) \
+	bus_write_4((sc)->gcs_res, (off), (val))
 
 #define ichwd_verbose_printf(dev, ...) \
 	do {						\
@@ -352,7 +415,7 @@
 static __inline void
 ichwd_tmr_reload(struct ichwd_softc *sc)
 {
-	if (sc->ich_version <= 5)
+	if (sc->tco_version == 1)
 		ichwd_write_tco_1(sc, TCO_RLD, 1);
 	else
 		ichwd_write_tco_2(sc, TCO_RLD, 1);
@@ -369,7 +432,7 @@
 	if (timeout < TCO_RLD_TMR_MIN)
 		timeout = TCO_RLD_TMR_MIN;
 
-	if (sc->ich_version <= 5) {
+	if (sc->tco_version == 1) {
 		uint8_t tmr_val8 = ichwd_read_tco_1(sc, TCO_TMR1);
 
 		tmr_val8 &= (~TCO_RLD1_TMR_MAX & 0xff);
@@ -399,7 +462,8 @@
 	int rc = 0;
 
 	/* try to clear the NO_REBOOT bit */
-	if (sc->ich_version <= 5) {
+	switch (sc->tco_version) {
+	case 1:
 		status = pci_read_config(sc->ich, ICH_GEN_STA, 1);
 		status &= ~ICH_GEN_STA_NO_REBOOT;
 		pci_write_config(sc->ich, ICH_GEN_STA, status, 1);
@@ -406,7 +470,8 @@
 		status = pci_read_config(sc->ich, ICH_GEN_STA, 1);
 		if (status & ICH_GEN_STA_NO_REBOOT)
 			rc = EIO;
-	} else {
+		break;
+	case 2:
 		status = ichwd_read_gcs_4(sc, 0);
 		status &= ~ICH_GCS_NO_REBOOT;
 		ichwd_write_gcs_4(sc, 0, status);
@@ -413,6 +478,20 @@
 		status = ichwd_read_gcs_4(sc, 0);
 		if (status & ICH_GCS_NO_REBOOT)
 			rc = EIO;
+		break;
+	case 3:
+		status = ichwd_read_pmc_4(sc, 0);
+		status &= ~ICH_PMC_NO_REBOOT;
+		ichwd_write_pmc_4(sc, 0, status);
+		status = ichwd_read_pmc_4(sc, 0);
+		if (status & ICH_PMC_NO_REBOOT)
+			rc = EIO;
+		break;
+	default:
+		ichwd_verbose_printf(sc->device,
+		    "Unknown TCO Version: %d, can't set NO_REBOOT.\n",
+		    sc->tco_version);
+		break;
 	}
 
 	if (rc)
@@ -449,26 +528,29 @@
 }
 
 static device_t
-ichwd_find_ich_lpc_bridge(struct ichwd_device **id_p)
+ichwd_find_ich_lpc_bridge(device_t isa, struct ichwd_device **id_p)
 {
 	struct ichwd_device *id;
-	device_t ich = NULL;
+	device_t isab, pci;
+	uint16_t devid;
 
-	/* look for an ICH LPC interface bridge */
-	for (id = ichwd_devices; id->desc != NULL; ++id)
-		if ((ich = pci_find_device(VENDORID_INTEL, id->device)) != NULL)
-			break;
-
-	if (ich == NULL)
+	/* Check whether parent ISA bridge looks familiar. */
+	isab = device_get_parent(isa);
+	pci = device_get_parent(isab);
+	if (pci == NULL || device_get_devclass(pci) != devclass_find("pci"))
 		return (NULL);
+	if (pci_get_vendor(isab) != VENDORID_INTEL)
+		return (NULL);
+	devid = pci_get_device(isab);
+	for (id = ichwd_devices; id->desc != NULL; ++id) {
+		if (devid == id->device) {
+			if (id_p != NULL)
+				*id_p = id;
+			return (isab);
+		}
+	}
 
-	ichwd_verbose_printf(ich, "found ICH%d or equivalent chipset: %s\n",
-	    id->version, id->desc);
-
-	if (id_p)
-		*id_p = id;
-
-	return (ich);
+	return (NULL);
 }
 
 /*
@@ -481,10 +563,10 @@
 	struct ichwd_device *id_p;
 	device_t ich = NULL;
 	device_t dev;
-	uint32_t rcba;
+	uint32_t base_address;
 	int rc;
 
-	ich = ichwd_find_ich_lpc_bridge(&id_p);
+	ich = ichwd_find_ich_lpc_bridge(parent, &id_p);
 	if (ich == NULL)
 		return;
 
@@ -495,16 +577,36 @@
 	if (dev == NULL)
 		return;
 
-	device_set_desc_copy(dev, id_p->desc);
-
-	if (id_p->version >= 6) {
+	switch (id_p->tco_version) {
+	case 1:
+		break;
+	case 2:
 		/* get RCBA (root complex base address) */
-		rcba = pci_read_config(ich, ICH_RCBA, 4);
+		base_address = pci_read_config(ich, ICH_RCBA, 4);
 		rc = bus_set_resource(ich, SYS_RES_MEMORY, 0,
-		    (rcba & 0xffffc000) + ICH_GCS_OFFSET, ICH_GCS_SIZE);
+		    (base_address & 0xffffc000) + ICH_GCS_OFFSET,
+		    ICH_GCS_SIZE);
 		if (rc)
 			ichwd_verbose_printf(dev,
-			    "Can not set memory resource for RCBA\n");
+			    "Can not set TCO v%d memory resource for RCBA\n",
+			    id_p->tco_version);
+		break;
+	case 3:
+		/* get PBASE (Power Management Controller base address) */
+		base_address = pci_read_config(ich, ICH_PBASE, 4);
+		rc = bus_set_resource(ich, SYS_RES_MEMORY, 0,
+		    (base_address & 0xfffffe00) + ICH_PMC_OFFSET,
+		    ICH_PMC_SIZE);
+		if (rc)
+			ichwd_verbose_printf(dev,
+			    "Can not set TCO v%d memory resource for PBASE\n",
+			    id_p->tco_version);
+		break;
+	default:
+		ichwd_verbose_printf(dev,
+		    "Can not set unknown TCO v%d memory resource for unknown base address\n",
+		    id_p->tco_version);
+		break;
 	}
 }
 
@@ -511,10 +613,16 @@
 static int
 ichwd_probe(device_t dev)
 {
+	struct ichwd_device *id_p;
 
 	/* Do not claim some ISA PnP device by accident. */
 	if (isa_get_logicalid(dev) != 0)
 		return (ENXIO);
+
+	if (ichwd_find_ich_lpc_bridge(device_get_parent(dev), &id_p) == NULL)
+		return (ENXIO);
+
+	device_set_desc_copy(dev, id_p->desc);
 	return (0);
 }
 
@@ -529,13 +637,14 @@
 	sc = device_get_softc(dev);
 	sc->device = dev;
 
-	ich = ichwd_find_ich_lpc_bridge(&id_p);
+	ich = ichwd_find_ich_lpc_bridge(device_get_parent(dev), &id_p);
 	if (ich == NULL) {
 		device_printf(sc->device, "Can not find ICH device.\n");
 		goto fail;
 	}
 	sc->ich = ich;
-	sc->ich_version = id_p->version;
+	sc->ich_version = id_p->ich_version;
+	sc->tco_version = id_p->tco_version;
 
 	/* get ACPI base address */
 	pmbase = pci_read_config(ich, ICH_PMBASE, 2) & ICH_PMBASE_MASK;
@@ -564,7 +673,7 @@
 	}
 
 	sc->gcs_rid = 0;
-	if (sc->ich_version >= 6) {
+	if (sc->tco_version >= 2) {
 		sc->gcs_res = bus_alloc_resource_any(ich, SYS_RES_MEMORY,
 		    &sc->gcs_rid, RF_ACTIVE|RF_SHAREABLE);
 		if (sc->gcs_res == NULL) {
@@ -576,9 +685,6 @@
 	if (ichwd_clear_noreboot(sc) != 0)
 		goto fail;
 
-	ichwd_verbose_printf(dev, "%s (ICH%d or equivalent)\n",
-	    device_get_desc(dev), sc->ich_version);
-
 	/*
 	 * Determine if we are coming up after a watchdog-induced reset.  Some
 	 * BIOSes may clear this bit at bootup, preventing us from reporting
@@ -621,7 +727,6 @@
 ichwd_detach(device_t dev)
 {
 	struct ichwd_softc *sc;
-	device_t ich = NULL;
 
 	sc = device_get_softc(dev);
 
@@ -646,9 +751,9 @@
 	bus_release_resource(dev, SYS_RES_IOPORT, sc->smi_rid, sc->smi_res);
 
 	/* deallocate memory resource */
-	ich = ichwd_find_ich_lpc_bridge(NULL);
-	if (sc->gcs_res && ich)
-		bus_release_resource(ich, SYS_RES_MEMORY, sc->gcs_rid, sc->gcs_res);
+	if (sc->gcs_res)
+		bus_release_resource(sc->ich, SYS_RES_MEMORY, sc->gcs_rid,
+		    sc->gcs_res);
 
 	return (0);
 }

Modified: trunk/sys/dev/ichwd/ichwd.h
===================================================================
--- trunk/sys/dev/ichwd/ichwd.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ichwd/ichwd.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Texas A&M University
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: stable/10/sys/dev/ichwd/ichwd.h 275439 2014-12-03 06:53:49Z mav $
+ * $FreeBSD: stable/10/sys/dev/ichwd/ichwd.h 297660 2016-04-07 08:31:52Z mav $
  */
 
 #ifndef _ICHWD_H_
@@ -34,7 +35,8 @@
 struct ichwd_device {
 	uint16_t		 device;
 	char			*desc;
-	unsigned int		 version;
+	unsigned int		 ich_version;
+	unsigned int		 tco_version;
 };
 
 struct ichwd_softc {
@@ -41,6 +43,7 @@
 	device_t		 device;
 	device_t		 ich;
 	int			 ich_version;
+	int			 tco_version;
 
 	int			 active;
 	unsigned int		 timeout;
@@ -59,6 +62,7 @@
 };
 
 #define VENDORID_INTEL		0x8086
+#define DEVICEID_BAYTRAIL	0x0f1c
 #define DEVICEID_CPT0		0x1c40
 #define DEVICEID_CPT1		0x1c41
 #define DEVICEID_CPT2		0x1c42
@@ -125,6 +129,11 @@
 #define DEVICEID_PPT29		0x1e5d
 #define DEVICEID_PPT30		0x1e5e
 #define DEVICEID_PPT31		0x1e5f
+#define DEVICEID_AVN0		0x1f38
+#define DEVICEID_AVN1		0x1f39
+#define DEVICEID_AVN2		0x1f3a
+#define DEVICEID_AVN3		0x1f3b
+#define DEVICEID_BRASWELL	0x229c
 #define DEVICEID_DH89XXCC_LPC	0x2310
 #define DEVICEID_COLETOCRK_LPC	0x2390
 #define DEVICEID_82801AA	0x2410
@@ -210,9 +219,58 @@
 #define DEVICEID_LPT29		0x8c5d
 #define DEVICEID_LPT30		0x8c5e
 #define DEVICEID_LPT31		0x8c5f
+#define DEVICEID_WCPT1		0x8cc1
 #define DEVICEID_WCPT2		0x8cc2
+#define DEVICEID_WCPT3		0x8cc3
 #define DEVICEID_WCPT4		0x8cc4
 #define DEVICEID_WCPT6		0x8cc6
+#define DEVICEID_WBG0		0x8d40
+#define DEVICEID_WBG1		0x8d41
+#define DEVICEID_WBG2		0x8d42
+#define DEVICEID_WBG3		0x8d43
+#define DEVICEID_WBG4		0x8d44
+#define DEVICEID_WBG5		0x8d45
+#define DEVICEID_WBG6		0x8d46
+#define DEVICEID_WBG7		0x8d47
+#define DEVICEID_WBG8		0x8d48
+#define DEVICEID_WBG9		0x8d49
+#define DEVICEID_WBG10		0x8d4a
+#define DEVICEID_WBG11		0x8d4b
+#define DEVICEID_WBG12		0x8d4c
+#define DEVICEID_WBG13		0x8d4d
+#define DEVICEID_WBG14		0x8d4e
+#define DEVICEID_WBG15		0x8d4f
+#define DEVICEID_WBG16		0x8d50
+#define DEVICEID_WBG17		0x8d51
+#define DEVICEID_WBG18		0x8d52
+#define DEVICEID_WBG19		0x8d53
+#define DEVICEID_WBG20		0x8d54
+#define DEVICEID_WBG21		0x8d55
+#define DEVICEID_WBG22		0x8d56
+#define DEVICEID_WBG23		0x8d57
+#define DEVICEID_WBG24		0x8d58
+#define DEVICEID_WBG25		0x8d59
+#define DEVICEID_WBG26		0x8d5a
+#define DEVICEID_WBG27		0x8d5b
+#define DEVICEID_WBG28		0x8d5c
+#define DEVICEID_WBG29		0x8d5d
+#define DEVICEID_WBG30		0x8d5e
+#define DEVICEID_WBG31		0x8d5f
+#define DEVICEID_LPT_LP0	0x9c40
+#define DEVICEID_LPT_LP1	0x9c41
+#define DEVICEID_LPT_LP2	0x9c42
+#define DEVICEID_LPT_LP3	0x9c43
+#define DEVICEID_LPT_LP4	0x9c44
+#define DEVICEID_LPT_LP5	0x9c45
+#define DEVICEID_LPT_LP6	0x9c46
+#define DEVICEID_LPT_LP7	0x9c47
+#define DEVICEID_WCPT_LP1	0x9cc1
+#define DEVICEID_WCPT_LP2	0x9cc2
+#define DEVICEID_WCPT_LP3	0x9cc3
+#define DEVICEID_WCPT_LP5	0x9cc5
+#define DEVICEID_WCPT_LP6	0x9cc6
+#define DEVICEID_WCPT_LP7	0x9cc7
+#define DEVICEID_WCPT_LP9	0x9cc9
 
 /* ICH LPC Interface Bridge Registers (ICH5 and older) */
 #define ICH_GEN_STA		0xd4
@@ -226,6 +284,12 @@
 #define ICH_GCS_SIZE		0x4
 #define ICH_GCS_NO_REBOOT	0x20
 
+/* SoC Power Management Configuration Registers */
+#define ICH_PBASE		0x44
+#define ICH_PMC_OFFSET		0x08
+#define ICH_PMC_SIZE		0x4
+#define ICH_PMC_NO_REBOOT	0x10
+
 /* register names and locations (relative to PMBASE) */
 #define SMI_BASE		0x30 /* base address for SMI registers */
 #define SMI_LEN			0x08

Modified: trunk/sys/dev/ida/ida.c
===================================================================
--- trunk/sys/dev/ida/ida.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/ida.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999,2000 Jonathan Lemon
  * All rights reserved.
@@ -29,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ida/ida.c 281826 2015-04-21 11:27:50Z mav $");
 
 /*
  * Generic driver for Compaq SMART RAID adapters.
@@ -38,7 +39,9 @@
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
+#include <sys/lock.h>
 #include <sys/malloc.h>
+#include <sys/mutex.h>
 #include <sys/stat.h>
 
 #include <sys/bio.h>
@@ -56,17 +59,17 @@
 #include <dev/ida/idaio.h>
 
 /* prototypes */
-static void ida_alloc_qcb(struct ida_softc *ida);
-static void ida_construct_qcb(struct ida_softc *ida);
+static int ida_alloc_qcbs(struct ida_softc *ida);
+static void ida_done(struct ida_softc *ida, struct ida_qcb *qcb);
 static void ida_start(struct ida_softc *ida);
-static void ida_done(struct ida_softc *ida, struct ida_qcb *qcb);
+static void ida_startio(struct ida_softc *ida);
+static void ida_startup(void *arg);
+static void ida_timeout(void *arg);
 static int ida_wait(struct ida_softc *ida, struct ida_qcb *qcb);
-static void ida_timeout (void *arg);
 
 static d_ioctl_t ida_ioctl;
 static struct cdevsw ida_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
 	.d_ioctl =	ida_ioctl,
 	.d_name =	"ida",
 };
@@ -76,10 +79,16 @@
 {
 	int i;
 
+	if (ida->ih != NULL)
+		bus_teardown_intr(ida->dev, ida->irq, ida->ih);
+
+	mtx_lock(&ida->lock);
 	callout_stop(&ida->ch);
+	mtx_unlock(&ida->lock);
+	callout_drain(&ida->ch);
 
 	if (ida->buffer_dmat) {
-		for (i = 0; i < ida->num_qcbs; i++)
+		for (i = 0; i < IDA_QCB_MAX; i++)
 			bus_dmamap_destroy(ida->buffer_dmat, ida->qcbs[i].dmamap);
 		bus_dma_tag_destroy(ida->buffer_dmat);
 	}
@@ -96,9 +105,6 @@
 	if (ida->qcbs != NULL)
 		free(ida->qcbs, M_DEVBUF);
 
-	if (ida->ih != NULL)
-		bus_teardown_intr(ida->dev, ida->irq, ida->ih);
-
 	if (ida->irq != NULL)
 		bus_release_resource(ida->dev, ida->irq_res_type,
 		    0, ida->irq);
@@ -109,6 +115,8 @@
 	if (ida->regs != NULL)
 		bus_release_resource(ida->dev, ida->regs_res_type,
 		    ida->regs_res_id, ida->regs);
+
+	mtx_destroy(&ida->lock);
 }
 
 /*
@@ -130,14 +138,21 @@
 
 	if ((qcb = SLIST_FIRST(&ida->free_qcbs)) != NULL) {
 		SLIST_REMOVE_HEAD(&ida->free_qcbs, link.sle);
-	} else {
-		ida_alloc_qcb(ida);
-		if ((qcb = SLIST_FIRST(&ida->free_qcbs)) != NULL)
-			SLIST_REMOVE_HEAD(&ida->free_qcbs, link.sle);
+		bzero(qcb->hwqcb, sizeof(struct ida_hdr) + sizeof(struct ida_req));
 	}
 	return (qcb);
 }
 
+static __inline void
+ida_free_qcb(struct ida_softc *ida, struct ida_qcb *qcb)
+{
+
+	qcb->state = QCB_FREE;
+	qcb->buf = NULL;
+	qcb->error = 0;
+	SLIST_INSERT_HEAD(&ida->free_qcbs, qcb, link.sle);
+}
+
 static __inline bus_addr_t
 idahwqcbvtop(struct ida_softc *ida, struct ida_hardware_qcb *hwqcb)
 {
@@ -155,43 +170,36 @@
 	return (hwqcb->qcb);
 }
 
-/*
- * XXX
- * since we allocate all QCB space up front during initialization, then
- * why bother with this routine?
- */
-static void
-ida_alloc_qcb(struct ida_softc *ida)
+static int
+ida_alloc_qcbs(struct ida_softc *ida)
 {
 	struct ida_qcb *qcb;
-	int error;
+	int error, i;
 
-	if (ida->num_qcbs >= IDA_QCB_MAX)
-		return;
+	for (i = 0; i < IDA_QCB_MAX; i++) {
+		qcb = &ida->qcbs[i];
 
-	qcb = &ida->qcbs[ida->num_qcbs];
+		error = bus_dmamap_create(ida->buffer_dmat, /*flags*/0, &qcb->dmamap);
+		if (error != 0)
+			return (error);
 
-	error = bus_dmamap_create(ida->buffer_dmat, /*flags*/0, &qcb->dmamap);
-	if (error != 0)
-		return;
-
-	qcb->flags = QCB_FREE;
-	qcb->hwqcb = &ida->hwqcbs[ida->num_qcbs];
-	qcb->hwqcb->qcb = qcb;
-	qcb->hwqcb_busaddr = idahwqcbvtop(ida, qcb->hwqcb);
-	SLIST_INSERT_HEAD(&ida->free_qcbs, qcb, link.sle);
-	ida->num_qcbs++;
+		qcb->ida = ida;
+		qcb->flags = QCB_FREE;
+		qcb->hwqcb = &ida->hwqcbs[i];
+		qcb->hwqcb->qcb = qcb;
+		qcb->hwqcb_busaddr = idahwqcbvtop(ida, qcb->hwqcb);
+		SLIST_INSERT_HEAD(&ida->free_qcbs, qcb, link.sle);
+	}
+	return (0);
 }
 
 int
 ida_init(struct ida_softc *ida)
 {
-	int error;
+	struct ida_controller_info cinfo;
+	device_t child;
+	int error, i, unit;
 
-	ida->unit = device_get_unit(ida->dev);
-	ida->tag = rman_get_bustag(ida->regs);
-	ida->bsh = rman_get_bushandle(ida->regs);
-
 	SLIST_INIT(&ida->free_qcbs);
 	STAILQ_INIT(&ida->qcb_queue);
 	bioq_init(&ida->bio_queue);
@@ -219,8 +227,8 @@
 		/* nsegments	*/ 1,
 		/* maxsegsz	*/ BUS_SPACE_MAXSIZE_32BIT,
 		/* flags	*/ 0,
-		/* lockfunc	*/ busdma_lock_mutex,
-		/* lockarg	*/ &Giant,
+		/* lockfunc	*/ NULL,
+		/* lockarg	*/ NULL,
 		&ida->hwqcb_dmat);
 	if (error)
 		return (ENOMEM);
@@ -234,7 +242,7 @@
 		/* highaddr	*/ BUS_SPACE_MAXADDR,
 		/* filter	*/ NULL,
 		/* filterarg	*/ NULL,
-		/* maxsize	*/ MAXBSIZE,
+		/* maxsize	*/ DFLTPHYS,
 		/* nsegments	*/ IDA_NSEG,
 		/* maxsegsz	*/ BUS_SPACE_MAXSIZE_32BIT,
 		/* flags	*/ 0,
@@ -258,26 +266,19 @@
 
 	bzero(ida->hwqcbs, IDA_QCB_MAX * sizeof(struct ida_hardware_qcb));
 
-	ida_alloc_qcb(ida);		/* allocate an initial qcb */
+	error = ida_alloc_qcbs(ida);
+	if (error)
+		return (error);
 
-	callout_init(&ida->ch, CALLOUT_MPSAFE);
-
-	return (0);
-}
-
-void
-ida_attach(struct ida_softc *ida)
-{
-	struct ida_controller_info cinfo;
-	int error, i;
-
+	mtx_lock(&ida->lock);
 	ida->cmd.int_enable(ida, 0);
 
 	error = ida_command(ida, CMD_GET_CTRL_INFO, &cinfo, sizeof(cinfo),
 	    IDA_CONTROLLER, 0, DMA_DATA_IN);
 	if (error) {
+		mtx_unlock(&ida->lock);
 		device_printf(ida->dev, "CMD_GET_CTRL_INFO failed.\n");
-		return;
+		return (error);
 	}
 
 	device_printf(ida->dev, "drives=%d firm_rev=%c%c%c%c\n",
@@ -290,23 +291,51 @@
 		error = ida_command(ida, CMD_START_FIRMWARE,
 		    &data, sizeof(data), IDA_CONTROLLER, 0, DMA_DATA_IN);
 		if (error) {
+			mtx_unlock(&ida->lock);
 			device_printf(ida->dev, "CMD_START_FIRMWARE failed.\n");
-			return;
+			return (error);
 		}
 	}
+	
+	ida->cmd.int_enable(ida, 1);
+	ida->flags |= IDA_ATTACHED;
+	mtx_unlock(&ida->lock);
 
-	ida->ida_dev_t = make_dev(&ida_cdevsw, ida->unit,
+	for (i = 0; i < cinfo.num_drvs; i++) {
+		child = device_add_child(ida->dev, /*"idad"*/NULL, -1);
+		if (child != NULL)
+			device_set_ivars(child, (void *)(intptr_t)i);
+	}
+
+	ida->ich.ich_func = ida_startup;
+	ida->ich.ich_arg = ida;
+	if (config_intrhook_establish(&ida->ich) != 0) {
+		device_delete_children(ida->dev);
+		device_printf(ida->dev, "Cannot establish configuration hook\n");
+		return (error);
+	}
+
+	unit = device_get_unit(ida->dev);
+	ida->ida_dev_t = make_dev(&ida_cdevsw, unit,
 				 UID_ROOT, GID_OPERATOR, S_IRUSR | S_IWUSR,
-				 "ida%d", ida->unit);
+				 "ida%d", unit);
 	ida->ida_dev_t->si_drv1 = ida;
 
-	ida->num_drives = 0;
-	for (i = 0; i < cinfo.num_drvs; i++)
-		device_add_child(ida->dev, /*"idad"*/NULL, -1);
+	return (0);
+}
 
+static void
+ida_startup(void *arg)
+{
+	struct ida_softc *ida;
+
+	ida = arg;
+
+	config_intrhook_disestablish(&ida->ich);
+
+	mtx_lock(&Giant);
 	bus_generic_attach(ida->dev);
-
-	ida->cmd.int_enable(ida, 1);
+	mtx_unlock(&Giant);
 }
 
 int
@@ -313,10 +342,17 @@
 ida_detach(device_t dev)
 {
 	struct ida_softc *ida;
-	int error = 0;
+	int error;
 
 	ida = (struct ida_softc *)device_get_softc(dev);
 
+	error = bus_generic_detach(dev);
+	if (error)
+		return (error);
+	error = device_delete_children(dev);
+	if (error)
+		return (error);
+
 	/*
 	 * XXX
 	 * before detaching, we must make sure that the system is
@@ -335,11 +371,25 @@
 }
 
 static void
-ida_setup_dmamap(void *arg, bus_dma_segment_t *segs, int nsegments, int error)
+ida_data_cb(void *arg, bus_dma_segment_t *segs, int nsegments, int error)
 {
-	struct ida_hardware_qcb *hwqcb = (struct ida_hardware_qcb *)arg;
+	struct ida_hardware_qcb *hwqcb;
+	struct ida_softc *ida;
+	struct ida_qcb *qcb;
+	bus_dmasync_op_t op;
 	int i;
 
+	qcb = arg;
+	ida = qcb->ida;
+	if (!dumping)
+		mtx_assert(&ida->lock, MA_OWNED);
+	if (error) {
+		qcb->error = error;
+		ida_done(ida, qcb);
+		return;
+	}
+
+	hwqcb = qcb->hwqcb;
 	hwqcb->hdr.size = htole16((sizeof(struct ida_req) +
 	    sizeof(struct ida_sgb) * IDA_NSEG) >> 2);
 
@@ -348,8 +398,49 @@
 		hwqcb->seg[i].length = htole32(segs[i].ds_len);
 	}
 	hwqcb->req.sgcount = nsegments;
+	if (qcb->flags & DMA_DATA_TRANSFER) {
+		switch (qcb->flags & DMA_DATA_TRANSFER) {
+		case DMA_DATA_TRANSFER:
+			op = BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE;
+			break;
+		case DMA_DATA_IN:
+			op = BUS_DMASYNC_PREREAD;
+			break;
+		default:
+			KASSERT((qcb->flags & DMA_DATA_TRANSFER) ==
+			    DMA_DATA_OUT, ("bad DMA data flags"));
+			op = BUS_DMASYNC_PREWRITE;
+			break;
+		}
+		bus_dmamap_sync(ida->buffer_dmat, qcb->dmamap, op);
+	}
+	bus_dmamap_sync(ida->hwqcb_dmat, ida->hwqcb_dmamap,
+	    BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
+
+	STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe);
+	ida_start(ida);
+	ida->flags &= ~IDA_QFROZEN;
 }
 
+static int
+ida_map_qcb(struct ida_softc *ida, struct ida_qcb *qcb, void *data,
+    bus_size_t datasize)
+{
+	int error, flags;
+
+	if (ida->flags & IDA_INTERRUPTS)
+		flags = BUS_DMA_WAITOK;
+	else
+		flags = BUS_DMA_NOWAIT;
+	error = bus_dmamap_load(ida->buffer_dmat, qcb->dmamap, data, datasize,
+	    ida_data_cb, qcb, flags);
+	if (error == EINPROGRESS) {
+		ida->flags |= IDA_QFROZEN;
+		error = 0;
+	}
+	return (error);
+}
+
 int
 ida_command(struct ida_softc *ida, int command, void *data, int datasize,
 	int drive, u_int32_t pblkno, int flags)
@@ -356,43 +447,37 @@
 {
 	struct ida_hardware_qcb *hwqcb;
 	struct ida_qcb *qcb;
-	bus_dmasync_op_t op;
-	int s, error;
+	int error;
 
-	s = splbio();
+	if (!dumping)
+		mtx_assert(&ida->lock, MA_OWNED);
 	qcb = ida_get_qcb(ida);
-	splx(s);
 
 	if (qcb == NULL) {
-		printf("ida_command: out of QCBs");
+		device_printf(ida->dev, "out of QCBs\n");
 		return (EAGAIN);
 	}
 
+	qcb->flags = flags | IDA_COMMAND;
 	hwqcb = qcb->hwqcb;
-	bzero(hwqcb, sizeof(struct ida_hdr) + sizeof(struct ida_req));
-
-	bus_dmamap_load(ida->buffer_dmat, qcb->dmamap,
-	    (void *)data, datasize, ida_setup_dmamap, hwqcb, 0);
-	op = qcb->flags & DMA_DATA_IN ?
-	    BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE;
-	bus_dmamap_sync(ida->buffer_dmat, qcb->dmamap, op);
-
 	hwqcb->hdr.drive = drive;
 	hwqcb->req.blkno = htole32(pblkno);
 	hwqcb->req.bcount = htole16(howmany(datasize, DEV_BSIZE));
 	hwqcb->req.command = command;
 
-	qcb->flags = flags | IDA_COMMAND;
+	error = ida_map_qcb(ida, qcb, data, datasize);
+	if (error == 0) {
+		error = ida_wait(ida, qcb);
+		/* Don't free QCB on a timeout in case it later completes. */
+		if (error)
+			return (error);
+		error = qcb->error;
+	}
 
-	s = splbio();
-	STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe);
-	ida_start(ida);
-	error = ida_wait(ida, qcb);
-	splx(s);
-
 	/* XXX should have status returned here? */
 	/* XXX have "status pointer" area in QCB? */
 
+	ida_free_qcb(ida, qcb);
 	return (error);
 }
 
@@ -399,62 +484,59 @@
 void
 ida_submit_buf(struct ida_softc *ida, struct bio *bp)
 {
+	mtx_lock(&ida->lock);
 	bioq_insert_tail(&ida->bio_queue, bp);
-	ida_construct_qcb(ida);
-	ida_start(ida);
+	ida_startio(ida);
+	mtx_unlock(&ida->lock);
 }
 
 static void
-ida_construct_qcb(struct ida_softc *ida)
+ida_startio(struct ida_softc *ida)
 {
 	struct ida_hardware_qcb *hwqcb;
 	struct ida_qcb *qcb;
-	bus_dmasync_op_t op;
+	struct idad_softc *drv;
 	struct bio *bp;
+	int error;
 
-	bp = bioq_first(&ida->bio_queue);
-	if (bp == NULL)
-		return;				/* no more buffers */
+	mtx_assert(&ida->lock, MA_OWNED);
+	for (;;) {
+		if (ida->flags & IDA_QFROZEN)
+			return;
+		bp = bioq_first(&ida->bio_queue);
+		if (bp == NULL)
+			return;				/* no more buffers */
 
-	qcb = ida_get_qcb(ida);
-	if (qcb == NULL)
-		return;				/* out of resources */
+		qcb = ida_get_qcb(ida);
+		if (qcb == NULL)
+			return;				/* out of resources */
 
-	bioq_remove(&ida->bio_queue, bp);
-	qcb->buf = bp;
-	qcb->flags = bp->bio_cmd == BIO_READ ? DMA_DATA_IN : DMA_DATA_OUT;
+		bioq_remove(&ida->bio_queue, bp);
+		qcb->buf = bp;
+		qcb->flags = bp->bio_cmd == BIO_READ ? DMA_DATA_IN : DMA_DATA_OUT;
 
-	hwqcb = qcb->hwqcb;
-	bzero(hwqcb, sizeof(struct ida_hdr) + sizeof(struct ida_req));
+		hwqcb = qcb->hwqcb;
+		drv = bp->bio_driver1;
+		hwqcb->hdr.drive = drv->drive;
+		hwqcb->req.blkno = bp->bio_pblkno;
+		hwqcb->req.bcount = howmany(bp->bio_bcount, DEV_BSIZE);
+		hwqcb->req.command = bp->bio_cmd == BIO_READ ? CMD_READ : CMD_WRITE;
 
-	bus_dmamap_load(ida->buffer_dmat, qcb->dmamap,
-	    (void *)bp->bio_data, bp->bio_bcount, ida_setup_dmamap, hwqcb, 0);
-	op = qcb->flags & DMA_DATA_IN ?
-	    BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE;
-	bus_dmamap_sync(ida->buffer_dmat, qcb->dmamap, op);
-
-	{
-		struct idad_softc *drv = (struct idad_softc *)bp->bio_driver1;
-		hwqcb->hdr.drive = drv->drive;
+		error = ida_map_qcb(ida, qcb, bp->bio_data, bp->bio_bcount);
+		if (error) {
+			qcb->error = error;
+			ida_done(ida, qcb);
+		}
 	}
-
-	hwqcb->req.blkno = bp->bio_pblkno;
-	hwqcb->req.bcount = howmany(bp->bio_bcount, DEV_BSIZE);
-	hwqcb->req.command = bp->bio_cmd == BIO_READ ? CMD_READ : CMD_WRITE;
-
-	STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe);
 }
 
-/*
- * This routine will be called from ida_intr in order to queue up more
- * I/O, meaning that we may be in an interrupt context.  Hence, we should
- * not muck around with spl() in this routine.
- */
 static void
 ida_start(struct ida_softc *ida)
 {
 	struct ida_qcb *qcb;
 
+	if (!dumping)
+		mtx_assert(&ida->lock, MA_OWNED);
 	while ((qcb = STAILQ_FIRST(&ida->qcb_queue)) != NULL) {
 		if (ida->cmd.fifo_full(ida))
 			break;
@@ -465,7 +547,7 @@
 		 */
 
 		/* Set a timeout. */
-		if (!ida->qactive)
+		if (!ida->qactive && !dumping)
 			callout_reset(&ida->ch, hz * 5, ida_timeout, ida);
 		ida->qactive++;
 
@@ -481,9 +563,13 @@
 	bus_addr_t completed;
 	int delay;
 
+	if (!dumping)
+		mtx_assert(&ida->lock, MA_OWNED);
 	if (ida->flags & IDA_INTERRUPTS) {
-		if (tsleep(qcb, PRIBIO, "idacmd", 5 * hz))
+		if (mtx_sleep(qcb, &ida->lock, PRIBIO, "idacmd", 5 * hz)) {
+			qcb->state = QCB_TIMEDOUT;
 			return (ETIMEDOUT);
+		}
 		return (0);
 	}
 
@@ -490,8 +576,10 @@
 again:
 	delay = 5 * 1000 * 100;			/* 5 sec delay */
 	while ((completed = ida->cmd.done(ida)) == 0) {
-		if (delay-- == 0)
+		if (delay-- == 0) {
+			qcb->state = QCB_TIMEDOUT;
 			return (ETIMEDOUT);
+		}
 		DELAY(10);
 	}
 
@@ -511,8 +599,11 @@
 
 	ida = (struct ida_softc *)data;
 
-	if (ida->cmd.int_pending(ida) == 0)
+	mtx_lock(&ida->lock);
+	if (ida->cmd.int_pending(ida) == 0) {
+		mtx_unlock(&ida->lock);
 		return;				/* not our interrupt */
+	}
 
 	while ((completed = ida->cmd.done(ida)) != 0) {
 		qcb = idahwqcbptov(ida, completed & ~3);
@@ -527,7 +618,8 @@
 			qcb->hwqcb->req.error = CMD_REJECTED;
 		ida_done(ida, qcb);
 	}
-	ida_start(ida);
+	ida_startio(ida);
+	mtx_unlock(&ida->lock);
 }
 
 /*
@@ -536,19 +628,35 @@
 static void
 ida_done(struct ida_softc *ida, struct ida_qcb *qcb)
 {
-	int error = 0;
+	bus_dmasync_op_t op;
+	int active, error = 0;
 
 	/*
 	 * finish up command
 	 */
-	if (qcb->flags & DMA_DATA_TRANSFER) {
-		bus_dmasync_op_t op;
-
-		op = qcb->flags & DMA_DATA_IN ?
-		    BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE;
+	if (!dumping)
+		mtx_assert(&ida->lock, MA_OWNED);
+	active = (qcb->state != QCB_FREE);
+	if (qcb->flags & DMA_DATA_TRANSFER && active) {
+		switch (qcb->flags & DMA_DATA_TRANSFER) {
+		case DMA_DATA_TRANSFER:
+			op = BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE;
+			break;
+		case DMA_DATA_IN:
+			op = BUS_DMASYNC_POSTREAD;
+			break;
+		default:
+			KASSERT((qcb->flags & DMA_DATA_TRANSFER) ==
+			    DMA_DATA_OUT, ("bad DMA data flags"));
+			op = BUS_DMASYNC_POSTWRITE;
+			break;
+		}
 		bus_dmamap_sync(ida->buffer_dmat, qcb->dmamap, op);
 		bus_dmamap_unload(ida->buffer_dmat, qcb->dmamap);
 	}
+	if (active)
+		bus_dmamap_sync(ida->hwqcb_dmat, ida->hwqcb_dmamap,
+		    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
 	if (qcb->hwqcb->req.error & SOFT_ERROR) {
 		if (qcb->buf)
@@ -571,17 +679,27 @@
 		error = 1;
 		device_printf(ida->dev, "invalid request\n");
 	}
+	if (qcb->error) {
+		error = 1;
+		device_printf(ida->dev, "request failed to map: %d\n", qcb->error);
+	}
 
 	if (qcb->flags & IDA_COMMAND) {
 		if (ida->flags & IDA_INTERRUPTS)
 			wakeup(qcb);
+		if (qcb->state == QCB_TIMEDOUT)
+			ida_free_qcb(ida, qcb);
 	} else {
 		KASSERT(qcb->buf != NULL, ("ida_done(): qcb->buf is NULL!"));
 		if (error)
 			qcb->buf->bio_flags |= BIO_ERROR;
 		idad_intr(qcb->buf);
+		ida_free_qcb(ida, qcb);
 	}
 
+	if (!active)
+		return;
+
 	ida->qactive--;
 	/* Reschedule or cancel timeout */
 	if (ida->qactive)
@@ -588,15 +706,10 @@
 		callout_reset(&ida->ch, hz * 5, ida_timeout, ida);
 	else
 		callout_stop(&ida->ch);
-
-	qcb->state = QCB_FREE;
-	qcb->buf = NULL;
-	SLIST_INSERT_HEAD(&ida->free_qcbs, qcb, link.sle);
-	ida_construct_qcb(ida);
 }
 
 static void
-ida_timeout (void *arg)
+ida_timeout(void *arg)
 {
 	struct ida_softc *ida;
 
@@ -661,8 +774,10 @@
 			daddr = &data;
 			len = sizeof(data);
 		}
+		mtx_lock(&sc->lock);
 		error = ida_command(sc, uc->command, daddr, len,
 				    uc->drive, uc->blkno, flags);
+		mtx_unlock(&sc->lock);
 		break;
 	default:
 		error = ENOIOCTL;

Modified: trunk/sys/dev/ida/ida_disk.c
===================================================================
--- trunk/sys/dev/ida/ida_disk.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/ida_disk.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999,2000 Jonathan Lemon
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ida/ida_disk.c 239740 2012-08-27 17:24:07Z jhb $
  */
 
 /*
@@ -87,7 +88,6 @@
 idad_strategy(struct bio *bp)
 {
 	struct idad_softc *drv;
-	int s;
 
 	drv = bp->bio_disk->d_drv1;
 	if (drv == NULL) {
@@ -104,9 +104,7 @@
 	}
 
 	bp->bio_driver1 = drv;
-	s = splbio();
 	ida_submit_buf(drv->controller, bp);
-	splx(s);
 	return;
 
 bad:
@@ -179,11 +177,12 @@
 	drv->dev = dev;
 	drv->controller = (struct ida_softc *)device_get_softc(parent);
 	drv->unit = device_get_unit(dev);
-	drv->drive = drv->controller->num_drives;
-	drv->controller->num_drives++;
+	drv->drive = (intptr_t)device_get_ivars(dev);
 
+	mtx_lock(&drv->controller->lock);
 	error = ida_command(drv->controller, CMD_GET_LOG_DRV_INFO,
 	    &dinfo, sizeof(dinfo), drv->drive, 0, DMA_DATA_IN);
+	mtx_unlock(&drv->controller->lock);
 	if (error) {
 		device_printf(dev, "CMD_GET_LOG_DRV_INFO failed\n");
 		return (ENXIO);
@@ -213,7 +212,6 @@
 	drv->disk->d_drv1 = drv;
 	drv->disk->d_maxsize = DFLTPHYS;		/* XXX guess? */
 	drv->disk->d_unit = drv->unit;
-	drv->disk->d_flags = DISKFLAG_NEEDSGIANT;
 	disk_create(drv->disk, DISK_VERSION);
 
 	return (0);

Modified: trunk/sys/dev/ida/ida_eisa.c
===================================================================
--- trunk/sys/dev/ida/ida_eisa.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/ida_eisa.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Jonathan Lemon
  * Copyright (c) 1999 by Matthew N. Dodd <winter at jurai.net>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ida/ida_eisa.c 281826 2015-04-21 11:27:50Z mav $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -282,6 +283,8 @@
 	board = ida_eisa_match(eisa_get_id(dev));
 	ida->cmd = *board->accessor;
 	ida->flags = board->flags;
+	mtx_init(&ida->lock, "ida", NULL, MTX_DEF);
+	callout_init_mtx(&ida->ch, &ida->lock, 0);
 
 	ida->regs_res_type = SYS_RES_IOPORT;
 	ida->regs_res_id = 0;
@@ -293,15 +296,15 @@
 	}
 
 	error = bus_dma_tag_create(
-		/* parent	*/	NULL,
-		/* alignment	*/	0,
+		/* parent	*/	bus_get_dma_tag(dev),
+		/* alignment	*/	1,
 		/* boundary	*/	0,
 		/* lowaddr	*/	BUS_SPACE_MAXADDR_32BIT,
 		/* highaddr	*/	BUS_SPACE_MAXADDR,
 		/* filter	*/	NULL,
 		/* filterarg	*/	NULL,
-		/* maxsize	*/	MAXBSIZE,
-		/* nsegments	*/	IDA_NSEG,
+		/* maxsize	*/	BUS_SPACE_MAXSIZE_32BIT,
+		/* nsegments	*/	BUS_SPACE_UNRESTRICTED,
 		/* maxsegsize	*/	BUS_SPACE_MAXSIZE_32BIT,
 		/* flags	*/	BUS_DMA_ALLOCNOW,
 		/* lockfunc	*/	NULL,
@@ -323,7 +326,7 @@
 		return (ENOMEM);
 	}
 
-	error = bus_setup_intr(dev, ida->irq, INTR_TYPE_BIO | INTR_ENTROPY,
+	error = bus_setup_intr(dev, ida->irq, INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE,
 	    NULL, ida_intr, ida, &ida->ih);
 	if (error) {
 		device_printf(dev, "can't setup interrupt\n");
@@ -337,9 +340,6 @@
 		return (error);
 	}
 
-	ida_attach(ida);
-	ida->flags |= IDA_ATTACHED;
-
 	return (0);
 }
 

Modified: trunk/sys/dev/ida/ida_pci.c
===================================================================
--- trunk/sys/dev/ida/ida_pci.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/ida_pci.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999,2000 Jonathan Lemon
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ida/ida_pci.c 281826 2015-04-21 11:27:50Z mav $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -236,23 +237,14 @@
 	struct ida_board *board = ida_pci_match(dev);
 	u_int32_t id = pci_get_devid(dev);
 	struct ida_softc *ida;
-	u_int command;
 	int error, rid;
 
-	command = pci_read_config(dev, PCIR_COMMAND, 1);
-
-	/*
-	 * it appears that this board only does MEMIO access.
-	 */
-	if ((command & PCIM_CMD_MEMEN) == 0) {
-	        device_printf(dev, "Only memory mapped I/O is supported\n");
-		return (ENXIO);
-	}
-
 	ida = (struct ida_softc *)device_get_softc(dev);
 	ida->dev = dev;
 	ida->cmd = *board->accessor;
 	ida->flags = board->flags;
+	mtx_init(&ida->lock, "ida", NULL, MTX_DEF);
+	callout_init_mtx(&ida->ch, &ida->lock, 0);
 
 	ida->regs_res_type = SYS_RES_MEMORY;
 	ida->regs_res_id = IDA_PCI_MEMADDR;
@@ -274,8 +266,8 @@
 		/* highaddr	*/ BUS_SPACE_MAXADDR,
 		/* filter	*/ NULL,
 		/* filterarg	*/ NULL,
-		/* maxsize	*/ MAXBSIZE,
-		/* nsegments	*/ IDA_NSEG,
+		/* maxsize	*/ BUS_SPACE_MAXSIZE_32BIT,
+		/* nsegments	*/ BUS_SPACE_UNRESTRICTED,
 		/* maxsegsize	*/ BUS_SPACE_MAXSIZE_32BIT,
 		/* flags	*/ BUS_DMA_ALLOCNOW,
 		/* lockfunc	*/ NULL,
@@ -295,7 +287,7 @@
 	        ida_free(ida);
 	        return (ENOMEM);
 	}
-	error = bus_setup_intr(dev, ida->irq, INTR_TYPE_BIO | INTR_ENTROPY,
+	error = bus_setup_intr(dev, ida->irq, INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE,
 	    NULL, ida_intr, ida, &ida->ih);
 	if (error) {
 		device_printf(dev, "can't setup interrupt\n");
@@ -308,8 +300,6 @@
 	        ida_free(ida);
 	        return (error);
 	}
-	ida_attach(ida);
-	ida->flags |= IDA_ATTACHED;
 
 	return (0);
 }

Modified: trunk/sys/dev/ida/idaio.h
===================================================================
--- trunk/sys/dev/ida/idaio.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/idaio.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ida/idaio.h 124540 2004-01-15 06:37:52Z mdodd $
  */
 
 #include <sys/ioccom.h>

Modified: trunk/sys/dev/ida/idareg.h
===================================================================
--- trunk/sys/dev/ida/idareg.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/idareg.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999,2000 Jonathan Lemon
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ida/idareg.h 144992 2005-04-13 05:09:49Z mdodd $
  */
 
 /*

Modified: trunk/sys/dev/ida/idavar.h
===================================================================
--- trunk/sys/dev/ida/idavar.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ida/idavar.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999,2000 Jonathan Lemon
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ida/idavar.h 239740 2012-08-27 17:24:07Z jhb $
  */
 
 /*
@@ -34,18 +35,18 @@
 #define	_IDAVAR_H
 
 #define	ida_inb(ida, port) \
-	bus_space_read_1((ida)->tag, (ida)->bsh, port)
+	bus_read_1((ida)->regs, port)
 #define	ida_inw(ida, port) \
-	bus_space_read_2((ida)->tag, (ida)->bsh, port)
+	bus_read_2((ida)->regs, port)
 #define	ida_inl(ida, port) \
-	bus_space_read_4((ida)->tag, (ida)->bsh, port)
+	bus_read_4((ida)->regs, port)
 
 #define	ida_outb(ida, port, val) \
-	bus_space_write_1((ida)->tag, (ida)->bsh, port, val)
+	bus_write_1((ida)->regs, port, val)
 #define	ida_outw(ida, port, val) \
-	bus_space_write_2((ida)->tag, (ida)->bsh, port, val)
+	bus_write_2((ida)->regs, port, val)
 #define	ida_outl(ida, port, val) \
-	bus_space_write_4((ida)->tag, (ida)->bsh, port, val)
+	bus_write_4((ida)->regs, port, val)
 
 struct ida_hdr {
 	u_int8_t	drive;		/* logical drive */
@@ -83,6 +84,7 @@
 typedef enum {
 	QCB_FREE		= 0x0000,
 	QCB_ACTIVE		= 0x0001,	/* waiting for completion */
+	QCB_TIMEDOUT		= 0x0002,
 } qcb_state;
 
 #define	DMA_DATA_IN	0x0001
@@ -93,8 +95,11 @@
 #define	IDA_QCB_MAX	256
 #define	IDA_CONTROLLER	0		/* drive "number" for controller */
 
+struct ida_softc;
+
 struct ida_qcb {
 	struct		ida_hardware_qcb *hwqcb;
+	struct		ida_softc *ida;
 	qcb_state	state;
 	short		flags;
 	union {
@@ -104,10 +109,9 @@
 	bus_dmamap_t	dmamap;
 	bus_addr_t	hwqcb_busaddr;
 	struct		bio *buf;		/* bio associated with qcb */
+	int		error;
 };
 
-struct ida_softc;
-
 struct ida_access {
 	int		(*fifo_full)(struct ida_softc *);
 	void		(*submit)(struct ida_softc *, struct ida_qcb *);
@@ -122,10 +126,10 @@
 #define	IDA_ATTACHED	0x01		/* attached */
 #define	IDA_FIRMWARE	0x02		/* firmware must be started */
 #define	IDA_INTERRUPTS	0x04		/* interrupts enabled */
+#define	IDA_QFROZEN	0x08		/* request queue frozen */
 
 struct ida_softc {
 	device_t	dev;
-	int		unit;
 
 	struct callout	ch;
 	struct cdev *ida_dev_t;
@@ -138,8 +142,8 @@
 	struct		resource *irq;
 	void		*ih;
 
-	bus_space_tag_t		tag;
-	bus_space_handle_t	bsh;
+	struct mtx	lock;
+	struct intr_config_hook ich;
 
 	/* various DMA tags */
 	bus_dma_tag_t	parent_dmat;
@@ -151,8 +155,6 @@
 
 	bus_dma_tag_t	sg_dmat;
 
-	int		num_drives;
-	int		num_qcbs;
 	int		flags;
 
 	int		qactive;
@@ -197,7 +199,6 @@
 	int regs_type, int regs_id, bus_dma_tag_t parent_dmat);
 extern void ida_free(struct ida_softc *ida);
 extern int ida_init(struct ida_softc *ida);
-extern void ida_attach(struct ida_softc *ida);
 extern int ida_command(struct ida_softc *ida, int command, void *data,
 	int datasize, int drive, u_int32_t pblkno, int flags);
 extern void ida_submit_buf(struct ida_softc *ida, struct bio *bp);

Modified: trunk/sys/dev/ie/if_ie.c
===================================================================
--- trunk/sys/dev/ie/if_ie.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ie/if_ie.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1992, 1993, University of Vermont and State
  *  Agricultural College.
@@ -51,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ie/if_ie.c 320923 2017-07-12 22:16:54Z jhb $");
 
 /*
  * Intel 82586 Ethernet chip
@@ -157,6 +158,9 @@
 
 #define IE_BUF_LEN	ETHER_MAX_LEN	/* length of transmit buffer */
 
+/* XXX this driver uses `volatile' and `caddr_t' to a fault. */
+typedef	volatile char *v_caddr_t;	/* core address, pointer to volatile */
+
 /* Forward declaration */
 struct ie_softc;
 
@@ -169,10 +173,6 @@
 
 static __inline void
 		ee16_interrupt_enable	(struct ie_softc *);
-static void	ee16_eeprom_outbits	(struct ie_softc *, int, int);
-static void	ee16_eeprom_clock	(struct ie_softc *, int);
-static u_short	ee16_read_eeprom	(struct ie_softc *, int);
-static int	ee16_eeprom_inbits	(struct ie_softc *);
 
 static __inline void
 		ie_ack			(struct ie_softc *, u_int);
@@ -179,7 +179,6 @@
 static void	iereset			(struct ie_softc *);
 static void	ie_readframe		(struct ie_softc *, int);
 static void	ie_drop_packet_buffer	(struct ie_softc *);
-static void	find_ie_mem_size	(struct ie_softc *);
 static int	command_and_wait	(struct ie_softc *,
 					 int, void volatile *, int);
 static void	run_tdr			(struct ie_softc *,
@@ -313,7 +312,6 @@
 
 	ifp->if_softc = sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_mtu = ETHERMTU;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_start = iestart;
 	ifp->if_ioctl = ieioctl;
@@ -329,6 +327,8 @@
 		mtx_destroy(&sc->lock);
 		return (error);
 	}
+	device_printf(dev,
+	    "WARNING: This driver is deprecated and will be removed.\n");
 
 	return (0);
 }
@@ -1088,26 +1088,6 @@
 	return (1);
 }
 
-/*
- * Divine the memory size of ie board UNIT.
- * Better hope there's nothing important hiding just below the ie card...
- */
-static void
-find_ie_mem_size(struct ie_softc *sc)
-{
-	unsigned size;
-
-	sc->iosize = 0;
-
-	for (size = 65536; size >= 8192; size -= 8192) {
-		if (check_ie_present(sc)) {
-			return;
-		}
-	}
-
-	return;
-}
-
 void
 el_reset_586(struct ie_softc *sc)
 {
@@ -1150,82 +1130,6 @@
 	outb(PORT(sc) + IEE16_ATTN, 0);
 }
 
-u_short
-ee16_read_eeprom(struct ie_softc *sc, int location)
-{
-	int	ectrl, edata;
-
-	ectrl = inb(sc->port + IEE16_ECTRL);
-	ectrl &= IEE16_ECTRL_MASK;
-	ectrl |= IEE16_ECTRL_EECS;
-	outb(sc->port + IEE16_ECTRL, ectrl);
-
-	ee16_eeprom_outbits(sc, IEE16_EEPROM_READ, IEE16_EEPROM_OPSIZE1);
-	ee16_eeprom_outbits(sc, location, IEE16_EEPROM_ADDR_SIZE);
-	edata = ee16_eeprom_inbits(sc);
-	ectrl = inb(sc->port + IEE16_ECTRL);
-	ectrl &= ~(IEE16_RESET_ASIC | IEE16_ECTRL_EEDI | IEE16_ECTRL_EECS);
-	outb(sc->port + IEE16_ECTRL, ectrl);
-	ee16_eeprom_clock(sc, 1);
-	ee16_eeprom_clock(sc, 0);
-	return edata;
-}
-
-static void
-ee16_eeprom_outbits(struct ie_softc *sc, int edata, int count)
-{
-	int	ectrl, i;
-
-	ectrl = inb(sc->port + IEE16_ECTRL);
-	ectrl &= ~IEE16_RESET_ASIC;
-	for (i = count - 1; i >= 0; i--) {
-		ectrl &= ~IEE16_ECTRL_EEDI;
-		if (edata & (1 << i)) {
-			ectrl |= IEE16_ECTRL_EEDI;
-		}
-		outb(sc->port + IEE16_ECTRL, ectrl);
-		DELAY(1);	/* eeprom data must be setup for 0.4 uSec */
-		ee16_eeprom_clock(sc, 1);
-		ee16_eeprom_clock(sc, 0);
-	}
-	ectrl &= ~IEE16_ECTRL_EEDI;
-	outb(sc->port + IEE16_ECTRL, ectrl);
-	DELAY(1);		/* eeprom data must be held for 0.4 uSec */
-}
-
-static int
-ee16_eeprom_inbits(struct ie_softc *sc)
-{
-	int	ectrl, edata, i;
-
-	ectrl = inb(sc->port + IEE16_ECTRL);
-	ectrl &= ~IEE16_RESET_ASIC;
-	for (edata = 0, i = 0; i < 16; i++) {
-		edata = edata << 1;
-		ee16_eeprom_clock(sc, 1);
-		ectrl = inb(sc->port + IEE16_ECTRL);
-		if (ectrl & IEE16_ECTRL_EEDO) {
-			edata |= 1;
-		}
-		ee16_eeprom_clock(sc, 0);
-	}
-	return (edata);
-}
-
-static void
-ee16_eeprom_clock(struct ie_softc *sc, int state)
-{
-	int	ectrl;
-
-	ectrl = inb(sc->port + IEE16_ECTRL);
-	ectrl &= ~(IEE16_RESET_ASIC | IEE16_ECTRL_EESK);
-	if (state) {
-		ectrl |= IEE16_ECTRL_EESK;
-	}
-	outb(sc->port + IEE16_ECTRL, ectrl);
-	DELAY(9);		/* EESK must be stable for 8.38 uSec */
-}
-
 static __inline void
 ee16_interrupt_enable(struct ie_softc *sc)
 {

Modified: trunk/sys/dev/ie/if_ie507.h
===================================================================
--- trunk/sys/dev/ie/if_ie507.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ie/if_ie507.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ie/if_ie507.h 112734 2003-03-28 06:27:08Z mdodd $
  * Definitions for 3C507
  */
 

Modified: trunk/sys/dev/ie/if_ie_isa.c
===================================================================
--- trunk/sys/dev/ie/if_ie_isa.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ie/if_ie_isa.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Matthew N. Dodd
  * All rights reserved.
@@ -37,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ie/if_ie_isa.c 241066 2012-09-30 09:21:10Z kevlo $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -875,6 +876,7 @@
 		devclass_get_devices(ie_devclass, &devs, &count);
 		for (i = 0; i < count; i++)
 			device_delete_child(device_get_parent(devs[i]), devs[i]);
+		free(devs, M_TEMP);
 		break;
 	default:
 		break;

Modified: trunk/sys/dev/ie/if_iee16.h
===================================================================
--- trunk/sys/dev/ie/if_iee16.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ie/if_iee16.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1993, 1994, 1995
  *	Rodney W. Grimes, Milwaukie, Oregon  97222.  All rights reserved.
@@ -28,7 +29,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ie/if_iee16.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 /*

Modified: trunk/sys/dev/ie/if_iereg.h
===================================================================
--- trunk/sys/dev/ie/if_iereg.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ie/if_iereg.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ie/if_iereg.h 112790 2003-03-29 13:36:41Z mdodd $
  * definitions for AT&T StarLAN 10 etc...
  */
 

Modified: trunk/sys/dev/ie/if_ievar.h
===================================================================
--- trunk/sys/dev/ie/if_ievar.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ie/if_ievar.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*-
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ie/if_ievar.h 181134 2008-08-01 21:33:07Z jhb $
  */
 
 enum ie_hardware {

Modified: trunk/sys/dev/ieee488/ibfoo.c
===================================================================
--- trunk/sys/dev/ieee488/ibfoo.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/ibfoo.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp <phk at FreeBSD.org>
  * Copyright (c) 2010 Joerg Wunsch <joerg at FreeBSD.org>
@@ -24,12 +25,12 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * High-level driver for \xB5PD7210 based GPIB cards.
+ * High-level driver for µPD7210 based GPIB cards.
  *
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ieee488/ibfoo.c 230134 2012-01-15 13:23:43Z uqs $");
 
 #  define	IBDEBUG
 #  undef	IBDEBUG

Modified: trunk/sys/dev/ieee488/ibfoo_int.h
===================================================================
--- trunk/sys/dev/ieee488/ibfoo_int.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/ibfoo_int.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp
  * All rights reserved.
@@ -26,7 +27,7 @@
  * This file defines the ABI between the userland gpib library and the
  * kernel.  This file should not be used anywhere else.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ieee488/ibfoo_int.h 141768 2005-02-12 21:07:09Z phk $
  */
 
 #include <sys/ioccom.h>

Modified: trunk/sys/dev/ieee488/pcii.c
===================================================================
--- trunk/sys/dev/ieee488/pcii.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/pcii.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp <phk at FreeBSD.org>
  * Copyright (c) 2010 Joerg Wunsch <joerg at FreeBSD.org>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Driver for GPIB cards based on NEC \xB5PD7210 and compatibles.
+ * Driver for GPIB cards based on NEC µPD7210 and compatibles.
  *
  * This driver just hooks up to the hardware and leaves all the interesting
  * stuff to upd7210.c.
@@ -40,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ieee488/pcii.c 230134 2012-01-15 13:23:43Z uqs $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -116,7 +117,7 @@
 	/*
 	 * The PCIIA decodes a fixed pattern of 0x2e1 for the lower 10
 	 * address bits A0 ... A9.  Bits A10 through A12 are used by
-	 * the \xB5PD7210 register select lines.  This makes the
+	 * the µPD7210 register select lines.  This makes the
 	 * individual 7210 register being 0x400 bytes apart in the ISA
 	 * bus address space.  Address bits A13 and A14 are compared
 	 * to a DIP switch setting on the card, allowing for up to 4
@@ -123,7 +124,7 @@
 	 * different cards being installed (at base addresses 0x2e1,
 	 * 0x22e1, 0x42e1, and 0x62e1, respectively).  A15 has been
 	 * used to select an optional on-board time-of-day clock chip
-	 * (MM58167A) on the original PCIIA rather than the \xB5PD7210
+	 * (MM58167A) on the original PCIIA rather than the µPD7210
 	 * (which is not implemented on later boards).  The
 	 * documentation states the respective addresses for that chip
 	 * should be handled as reserved addresses, which we don't do
@@ -174,7 +175,7 @@
 	}
 	error = ENXIO;
 	/*
-	 * Perform some basic tests on the \xB5PD7210 registers.  At
+	 * Perform some basic tests on the µPD7210 registers.  At
 	 * least *some* register must read different from 0x00 or
 	 * 0xff.
 	 */

Modified: trunk/sys/dev/ieee488/tnt4882.c
===================================================================
--- trunk/sys/dev/ieee488/tnt4882.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/tnt4882.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp
  * Copyright (c) 2010 Joerg Wunsch
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ieee488/tnt4882.c 203360 2010-02-01 21:21:10Z joerg $
  */
 
 #include <sys/param.h>

Modified: trunk/sys/dev/ieee488/tnt4882.h
===================================================================
--- trunk/sys/dev/ieee488/tnt4882.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/tnt4882.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Joerg Wunsch
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ieee488/tnt4882.h 203360 2010-02-01 21:21:10Z joerg $
  */
 
 enum tnt4882reg {

Modified: trunk/sys/dev/ieee488/ugpib.h
===================================================================
--- trunk/sys/dev/ieee488/ugpib.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/ugpib.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp <phk at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ieee488/ugpib.h 141777 2005-02-12 23:52:44Z phk $
  *
  */
 

Modified: trunk/sys/dev/ieee488/upd7210.c
===================================================================
--- trunk/sys/dev/ieee488/upd7210.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/upd7210.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp <phk at FreeBSD.org>
  * Copyright (c) 2010 Joerg Wunsch <joerg at FreeBSD.org>
@@ -24,12 +25,12 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * High-level driver for \xB5PD7210 based GPIB cards.
+ * High-level driver for µPD7210 based GPIB cards.
  *
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ieee488/upd7210.c 230134 2012-01-15 13:23:43Z uqs $");
 
 #  define	GPIB_DEBUG
 #  undef	GPIB_DEBUG
@@ -252,7 +253,7 @@
 		bus_write_1(u->reg_res[0], cmdr, 0x04); /* GO */
 		bus_write_1(u->reg_res[0], imr3, 0x04); /* NEF IE */
 	} else {
-		/* \xB5PD7210/NAT7210, or TNT4882 in non-FIFO mode */
+		/* µPD7210/NAT7210, or TNT4882 in non-FIFO mode */
 		upd7210_wr(u, IMR1, 0x01); /* data in interrupt enable */
 	}
 	return (0);

Modified: trunk/sys/dev/ieee488/upd7210.h
===================================================================
--- trunk/sys/dev/ieee488/upd7210.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ieee488/upd7210.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Poul-Henning Kamp <phk at FreeBSD.org>
  * Copyright (c) 2010 Joerg Wunsch <joerg at FreeBSD.org>
@@ -24,15 +25,15 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ieee488/upd7210.h 230134 2012-01-15 13:23:43Z uqs $
  *
- * Locating an actual \xB5PD7210 data book has proven quite impossible for me.
- * There are a fair number of newer chips which are supersets of the \xB5PD7210
+ * Locating an actual µPD7210 data book has proven quite impossible for me.
+ * There are a fair number of newer chips which are supersets of the µPD7210
  * but they are particular eager to comprehensively mark what the extensions
  * are and what is in the base set.  Some even give the registers and their
  * bits new names.
  *
- * The following information is based on a description of the \xB5PD7210 found
+ * The following information is based on a description of the µPD7210 found
  * in an old manual for a VME board which used the chip.
  */
 

Modified: trunk/sys/dev/iir/iir.c
===================================================================
--- trunk/sys/dev/iir/iir.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/iir/iir.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  *       Copyright (c) 2000-04 ICP vortex GmbH
  *       Copyright (c) 2002-04 Intel Corporation
@@ -39,11 +40,11 @@
  *              Mike Smith;             Some driver source code.
  *              FreeBSD.ORG;            Great O/S to work on and for.
  *
- * $Id: iir.c,v 1.5 2013-01-08 03:53:20 laffer1 Exp $"
+ * $Id: iir.c 1.5 2004/03/30 10:17:53 achim Exp $"
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/iir/iir.c 315813 2017-03-23 06:41:13Z mav $");
 
 #define _IIR_C_
 
@@ -71,9 +72,6 @@
 
 static MALLOC_DEFINE(M_GDTBUF, "iirbuf", "iir driver buffer");
 
-struct gdt_softc *gdt_wait_gdt;
-int     gdt_wait_index;
-
 #ifdef GDT_DEBUG
 int     gdt_debug = GDT_DEBUG;
 #ifdef __SERIAL__
@@ -135,13 +133,13 @@
 #endif
 #endif
 
-/* The linked list of softc structures */
-struct gdt_softc_list gdt_softcs = TAILQ_HEAD_INITIALIZER(gdt_softcs);
 /* controller cnt. */
 int gdt_cnt = 0;
 /* event buffer */
 static gdt_evt_str ebuffer[GDT_MAX_EVENTS];
 static int elastidx, eoldidx;
+static struct mtx elock;
+MTX_SYSINIT(iir_elock, &elock, "iir events", MTX_DEF);
 /* statistics */
 gdt_statist_t gdt_stat;
 
@@ -150,6 +148,7 @@
 #define ccb_priority    spriv_field1
 
 static void     iir_action(struct cam_sim *sim, union ccb *ccb);
+static int	iir_intr_locked(struct gdt_softc *gdt);
 static void     iir_poll(struct cam_sim *sim);
 static void     iir_shutdown(void *arg, int howto);
 static void     iir_timeout(void *arg);
@@ -168,12 +167,12 @@
                                u_int8_t index, struct gdt_ccb *gccb);
 static int      gdt_async_event(struct gdt_softc *gdt, int service);
 static struct gdt_ccb *gdt_raw_cmd(struct gdt_softc *gdt, 
-                                   union ccb *ccb, int *lock);
+                                   union ccb *ccb);
 static struct gdt_ccb *gdt_cache_cmd(struct gdt_softc *gdt, 
-                                     union ccb *ccb, int *lock);
+                                     union ccb *ccb);
 static struct gdt_ccb *gdt_ioctl_cmd(struct gdt_softc *gdt, 
-                                     gdt_ucmd_t *ucmd, int *lock);
-static void     gdt_internal_cache_cmd(struct gdt_softc *gdt,union ccb *ccb);
+                                     gdt_ucmd_t *ucmd);
+static void     gdt_internal_cache_cmd(struct gdt_softc *gdt, union ccb *ccb);
 
 static void     gdtmapmem(void *arg, bus_dma_segment_t *dm_segs,
                           int nseg, int error);
@@ -197,7 +196,6 @@
     SLIST_INIT(&gdt->sc_pending_gccb);
     TAILQ_INIT(&gdt->sc_ccb_queue);
     TAILQ_INIT(&gdt->sc_ucmd_queue);
-    TAILQ_INSERT_TAIL(&gdt_softcs, gdt, links);
 
     /* DMA tag for mapping buffers into device visible space. */
     if (bus_dma_tag_create(gdt->sc_parent_dmat, /*alignment*/1, /*boundary*/0,
@@ -204,13 +202,15 @@
                            /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
                            /*highaddr*/BUS_SPACE_MAXADDR,
                            /*filter*/NULL, /*filterarg*/NULL,
-                           /*maxsize*/MAXBSIZE, /*nsegments*/GDT_MAXSG,
+			   /*maxsize*/DFLTPHYS,
+			   /*nsegments*/GDT_MAXSG,
                            /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
                            /*flags*/BUS_DMA_ALLOCNOW,
-			   /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant,
+			   /*lockfunc*/busdma_lock_mutex,
+			   /*lockarg*/&gdt->sc_lock,
                            &gdt->sc_buffer_dmat) != 0) {
-        printf("iir%d: bus_dma_tag_create(...,gdt->sc_buffer_dmat) failed\n",
-               gdt->sc_hanum);
+	device_printf(gdt->sc_devnode,
+	    "bus_dma_tag_create(..., gdt->sc_buffer_dmat) failed\n");
         return (1);
     }
     gdt->sc_init_level++;
@@ -227,9 +227,10 @@
                            /*nsegments*/1,
                            /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
 			   /*flags*/0, /*lockfunc*/busdma_lock_mutex,
-			   /*lockarg*/&Giant, &gdt->sc_gcscratch_dmat) != 0) {
-        printf("iir%d: bus_dma_tag_create(...,gdt->sc_gcscratch_dmat) failed\n",
-               gdt->sc_hanum);
+			   /*lockarg*/&gdt->sc_lock,
+			   &gdt->sc_gcscratch_dmat) != 0) {
+        device_printf(gdt->sc_devnode,
+	    "bus_dma_tag_create(...,gdt->sc_gcscratch_dmat) failed\n");
         return (1);
     }
     gdt->sc_init_level++;
@@ -237,8 +238,8 @@
     /* Allocation for our ccb scratch area */
     if (bus_dmamem_alloc(gdt->sc_gcscratch_dmat, (void **)&gdt->sc_gcscratch,
                          BUS_DMA_NOWAIT, &gdt->sc_gcscratch_dmamap) != 0) {
-        printf("iir%d: bus_dmamem_alloc(...,&gdt->sc_gccbs,...) failed\n",
-               gdt->sc_hanum);
+        device_printf(gdt->sc_devnode,
+	    "bus_dmamem_alloc(...,&gdt->sc_gccbs,...) failed\n");
         return (1);
     }
     gdt->sc_init_level++;
@@ -256,7 +257,7 @@
     gdt->sc_gccbs = malloc(sizeof(struct gdt_ccb) * GDT_MAXCMDS, M_GDTBUF,
         M_NOWAIT | M_ZERO);
     if (gdt->sc_gccbs == NULL) {
-        printf("iir%d: no memory for gccbs.\n", gdt->sc_hanum);
+        device_printf(gdt->sc_devnode, "no memory for gccbs.\n");
         return (1);
     }
     for (i = GDT_MAXCMDS-1; i >= 0; i--) {
@@ -268,20 +269,22 @@
                               &gccb->gc_dmamap) != 0)
             return(1);
         gccb->gc_map_flag = TRUE;
-	gccb->gc_scratch = &gdt->sc_gcscratch[GDT_SCRATCH_SZ * i];
+        gccb->gc_scratch = &gdt->sc_gcscratch[GDT_SCRATCH_SZ * i];
         gccb->gc_scratch_busbase = gdt->sc_gcscratch_busbase + GDT_SCRATCH_SZ * i;
+	callout_init_mtx(&gccb->gc_timeout, &gdt->sc_lock, 0);
         SLIST_INSERT_HEAD(&gdt->sc_free_gccb, gccb, sle);
     }
     gdt->sc_init_level++;
 
     /* create the control device */
-    gdt->sc_dev = gdt_make_dev(gdt->sc_hanum);
+    gdt->sc_dev = gdt_make_dev(gdt);
 
     /* allocate ccb for gdt_internal_cmd() */
+    mtx_lock(&gdt->sc_lock);
     gccb = gdt_get_ccb(gdt);
     if (gccb == NULL) {
-        printf("iir%d: No free command index found\n",
-               gdt->sc_hanum);
+	mtx_unlock(&gdt->sc_lock);
+        device_printf(gdt->sc_devnode, "No free command index found\n");
         return (1);
     }
     bzero(gccb->gc_cmd, GDT_CMD_SZ);
@@ -288,9 +291,10 @@
 
     if (!gdt_internal_cmd(gdt, gccb, GDT_SCREENSERVICE, GDT_INIT, 
                           0, 0, 0)) {
-        printf("iir%d: Screen service initialization error %d\n",
-               gdt->sc_hanum, gdt->sc_status);
+        device_printf(gdt->sc_devnode,
+	    "Screen service initialization error %d\n", gdt->sc_status);
         gdt_free_ccb(gdt, gccb);
+	mtx_unlock(&gdt->sc_lock);
         return (1);
     }
 
@@ -299,9 +303,10 @@
 
     if (!gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_INIT, 
                           GDT_LINUX_OS, 0, 0)) {
-        printf("iir%d: Cache service initialization error %d\n",
-               gdt->sc_hanum, gdt->sc_status);
+        device_printf(gdt->sc_devnode, "Cache service initialization error %d\n",
+               gdt->sc_status);
         gdt_free_ccb(gdt, gccb);
+	mtx_unlock(&gdt->sc_lock);
         return (1);
     }
     cdev_cnt = (u_int16_t)gdt->sc_info;
@@ -331,9 +336,10 @@
                                   GDT_IO_CHANNEL | GDT_INVALID_CHANNEL,
                                   GDT_GETCH_SZ)) {
                 if (i == 0) {
-                    printf("iir%d: Cannot get channel count, "
-                           "error %d\n", gdt->sc_hanum, gdt->sc_status);
+                    device_printf(gdt->sc_devnode, "Cannot get channel count, "
+                           "error %d\n", gdt->sc_status);
                     gdt_free_ccb(gdt, gccb);
+		    mtx_unlock(&gdt->sc_lock);
                     return (1);
                 }
                 break;
@@ -350,9 +356,10 @@
 
     if (!gdt_internal_cmd(gdt, gccb, GDT_SCSIRAWSERVICE, GDT_INIT, 
                           0, 0, 0)) {
-            printf("iir%d: Raw service initialization error %d\n",
-                   gdt->sc_hanum, gdt->sc_status);
+            device_printf(gdt->sc_devnode,
+		"Raw service initialization error %d\n", gdt->sc_status);
             gdt_free_ccb(gdt, gccb);
+	    mtx_unlock(&gdt->sc_lock);
             return (1);
     }
 
@@ -364,9 +371,11 @@
                              0, 0, 0)) {
             gdt->sc_raw_feat = gdt->sc_info;
             if (!(gdt->sc_info & GDT_SCATTER_GATHER)) {
-                panic("iir%d: Scatter/Gather Raw Service "
-                      "required but not supported!\n", gdt->sc_hanum);
+                panic("%s: Scatter/Gather Raw Service "
+		    "required but not supported!\n",
+		    device_get_nameunit(gdt->sc_devnode));
                 gdt_free_ccb(gdt, gccb);
+		mtx_unlock(&gdt->sc_lock);
                 return (1);
             }
         }
@@ -380,9 +389,11 @@
                              0, 0, 0)) {
             gdt->sc_cache_feat = gdt->sc_info;
             if (!(gdt->sc_info & GDT_SCATTER_GATHER)) {
-                panic("iir%d: Scatter/Gather Cache Service "
-                  "required but not supported!\n", gdt->sc_hanum);
+                panic("%s: Scatter/Gather Cache Service "
+		    "required but not supported!\n",
+		    device_get_nameunit(gdt->sc_devnode));
                 gdt_free_ccb(gdt, gccb);
+		mtx_unlock(&gdt->sc_lock);
                 return (1);
             }
         }
@@ -399,7 +410,7 @@
 		gdt->oem_name[7]='\0';
 	} else {
 		/* Old method, based on PCI ID */
-		if (gdt->sc_vendor == INTEL_VENDOR_ID)
+		if (gdt->sc_vendor == INTEL_VENDOR_ID_IIR)
             strcpy(gdt->oem_name,"Intel  ");
         else 
        	    strcpy(gdt->oem_name,"ICP    ");
@@ -441,8 +452,9 @@
                              gdt->sc_bus_cnt, cdev_cnt, 
                              cdev_cnt == 1 ? "" : "s"));
     gdt_free_ccb(gdt, gccb);
+    mtx_unlock(&gdt->sc_lock);
 
-    gdt_cnt++;
+    atomic_add_int(&gdt_cnt, 1);
     return (0);
 }
 
@@ -458,9 +470,11 @@
         gdt_destroy_dev(gdt->sc_dev);
       case 5:
         for (i = GDT_MAXCMDS-1; i >= 0; i--) 
-            if (gdt->sc_gccbs[i].gc_map_flag)
+            if (gdt->sc_gccbs[i].gc_map_flag) {
+		callout_drain(&gdt->sc_gccbs[i].gc_timeout);
                 bus_dmamap_destroy(gdt->sc_buffer_dmat,
                                    gdt->sc_gccbs[i].gc_dmamap);
+	    }
         bus_dmamap_unload(gdt->sc_gcscratch_dmat, gdt->sc_gcscratch_dmamap);
         free(gdt->sc_gccbs, M_GDTBUF);
       case 4:
@@ -474,7 +488,6 @@
       case 0:
         break;
     }
-    TAILQ_REMOVE(&gdt_softcs, gdt, links);
 }
 
 void
@@ -498,11 +511,12 @@
          * Construct our SIM entry
          */
         gdt->sims[i] = cam_sim_alloc(iir_action, iir_poll, "iir",
-                                     gdt, gdt->sc_hanum, &Giant,
-				     /*untagged*/1,
-                                     /*tagged*/GDT_MAXCMDS, devq);
+	    gdt, device_get_unit(gdt->sc_devnode), &gdt->sc_lock,
+	    /*untagged*/1, /*tagged*/GDT_MAXCMDS, devq);
+	mtx_lock(&gdt->sc_lock);
         if (xpt_bus_register(gdt->sims[i], gdt->sc_devnode, i) != CAM_SUCCESS) {
             cam_sim_free(gdt->sims[i], /*free_devq*/i == 0);
+	    mtx_unlock(&gdt->sc_lock);
             break;
         }
 
@@ -512,8 +526,10 @@
                             CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
             xpt_bus_deregister(cam_sim_path(gdt->sims[i]));
             cam_sim_free(gdt->sims[i], /*free_devq*/i == 0);
+	    mtx_unlock(&gdt->sc_lock);
             break;
         }
+	mtx_unlock(&gdt->sc_lock);
     }
     if (i > 0)
         EVENTHANDLER_REGISTER(shutdown_final, iir_shutdown,
@@ -555,9 +571,7 @@
 
     gdt->sc_state |= GDT_POLL_WAIT;
     do {
-        iir_intr(gdt);
-        if (gdt == gdt_wait_gdt &&
-            gccb->gc_cmd_index == gdt_wait_index) {
+        if (iir_intr_locked(gdt) == gccb->gc_cmd_index) {
             rv = 1;
             break;
         }
@@ -641,11 +655,10 @@
 gdt_get_ccb(struct gdt_softc *gdt)
 {
     struct gdt_ccb *gccb;
-    int lock;
     
     GDT_DPRINTF(GDT_D_QUEUE, ("gdt_get_ccb(%p)\n", gdt));
 
-    lock = splcam();
+    mtx_assert(&gdt->sc_lock, MA_OWNED);
     gccb = SLIST_FIRST(&gdt->sc_free_gccb);
     if (gccb != NULL) {
         SLIST_REMOVE_HEAD(&gdt->sc_free_gccb, sle);
@@ -654,7 +667,6 @@
         if (gdt_stat.cmd_index_act > gdt_stat.cmd_index_max)
             gdt_stat.cmd_index_max = gdt_stat.cmd_index_act;
     }
-    splx(lock);
     return (gccb);
 }
 
@@ -661,16 +673,14 @@
 void
 gdt_free_ccb(struct gdt_softc *gdt, struct gdt_ccb *gccb)
 {
-    int lock;
 
     GDT_DPRINTF(GDT_D_QUEUE, ("gdt_free_ccb(%p, %p)\n", gdt, gccb));
-    
-    lock = splcam();
+
+    mtx_assert(&gdt->sc_lock, MA_OWNED);
     gccb->gc_flags = GDT_GCF_UNUSED;
     SLIST_REMOVE(&gdt->sc_pending_gccb, gccb, gdt_ccb, sle);
     SLIST_INSERT_HEAD(&gdt->sc_free_gccb, gccb, sle);
     --gdt_stat.cmd_index_act;
-    splx(lock);
     if (gdt->sc_state & GDT_SHUTDOWN)
         wakeup(gccb);
 }
@@ -678,7 +688,6 @@
 void    
 gdt_next(struct gdt_softc *gdt)
 {
-    int lock;
     union ccb *ccb;
     gdt_ucmd_t *ucmd;
     struct cam_sim *sim;
@@ -692,10 +701,9 @@
 
     GDT_DPRINTF(GDT_D_QUEUE, ("gdt_next(%p)\n", gdt));
 
-    lock = splcam();
+    mtx_assert(&gdt->sc_lock, MA_OWNED);
     if (gdt->sc_test_busy(gdt)) {
         if (!(gdt->sc_state & GDT_POLLING)) {
-            splx(lock);
             return;
         }
         while (gdt->sc_test_busy(gdt))
@@ -714,7 +722,7 @@
         ucmd = TAILQ_FIRST(&gdt->sc_ucmd_queue);
         if (ucmd != NULL) {
             TAILQ_REMOVE(&gdt->sc_ucmd_queue, ucmd, links);
-            if ((gccb = gdt_ioctl_cmd(gdt, ucmd, &lock)) == NULL) {
+            if ((gccb = gdt_ioctl_cmd(gdt, ucmd)) == NULL) {
                 TAILQ_INSERT_HEAD(&gdt->sc_ucmd_queue, ucmd, links);
                 break;
             }
@@ -737,15 +745,15 @@
                                   ccb->ccb_h.flags));
         csio = &ccb->csio;
         ccbh = &ccb->ccb_h;
-        cmd  = csio->cdb_io.cdb_bytes[0];
-        /* Max CDB length is 12 bytes */
-        if (csio->cdb_len > 12) { 
+        cmd  = scsiio_cdb_ptr(csio)[0];
+        /* Max CDB length is 12 bytes, can't be phys addr */
+        if (csio->cdb_len > 12 || (ccbh->flags & CAM_CDB_PHYS)) { 
             ccbh->status = CAM_REQ_INVALID;
             --gdt_stat.io_count_act;
             xpt_done(ccb);
         } else if (bus != gdt->sc_virt_bus) {
             /* raw service command */
-            if ((gccb = gdt_raw_cmd(gdt, ccb, &lock)) == NULL) {
+            if ((gccb = gdt_raw_cmd(gdt, ccb)) == NULL) {
                 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, 
                                   sim_links.tqe);
                 ++gdt_stat.req_queue_act;
@@ -762,7 +770,7 @@
             /* cache service command */
             if (cmd == READ_6  || cmd == WRITE_6 ||
                 cmd == READ_10 || cmd == WRITE_10) {
-                if ((gccb = gdt_cache_cmd(gdt, ccb, &lock)) == NULL) {
+                if ((gccb = gdt_cache_cmd(gdt, ccb)) == NULL) {
                     TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, 
                                       sim_links.tqe);
                     ++gdt_stat.req_queue_act;
@@ -771,9 +779,7 @@
                     next_cmd = FALSE;
                 }
             } else {
-                splx(lock);
                 gdt_internal_cache_cmd(gdt, ccb);
-                lock = splcam();
             }
         }           
         if ((gdt->sc_state & GDT_POLLING) || !next_cmd)
@@ -782,8 +788,6 @@
     if (gdt->sc_cmd_cnt > 0)
         gdt->sc_release_event(gdt);
 
-    splx(lock);
-
     if ((gdt->sc_state & GDT_POLLING) && gdt->sc_cmd_cnt > 0) {
         gdt_wait(gdt, gccb, GDT_POLL_TIMEOUT);
     }
@@ -790,10 +794,11 @@
 }
 
 static struct gdt_ccb *
-gdt_raw_cmd(struct gdt_softc *gdt, union ccb *ccb, int *lock)
+gdt_raw_cmd(struct gdt_softc *gdt, union ccb *ccb)
 {
     struct gdt_ccb *gccb;
     struct cam_sim *sim;
+    int error;
 
     GDT_DPRINTF(GDT_D_CMD, ("gdt_raw_cmd(%p, %p)\n", gdt, ccb));
 
@@ -800,15 +805,15 @@
     if (roundup(GDT_CMD_UNION + GDT_RAW_SZ, sizeof(u_int32_t)) +
         gdt->sc_cmd_off + GDT_DPMEM_COMMAND_OFFSET >
         gdt->sc_ic_all_size) {
-        GDT_DPRINTF(GDT_D_INVALID, ("iir%d: gdt_raw_cmd(): DPMEM overflow\n", 
-                                    gdt->sc_hanum));
+        GDT_DPRINTF(GDT_D_INVALID, ("%s: gdt_raw_cmd(): DPMEM overflow\n", 
+		device_get_nameunit(gdt->sc_devnode)));
         return (NULL);
     }
 
     gccb = gdt_get_ccb(gdt);
     if (gccb == NULL) {
-        GDT_DPRINTF(GDT_D_INVALID, ("iir%d: No free command index found\n",
-                                    gdt->sc_hanum));
+        GDT_DPRINTF(GDT_D_INVALID, ("%s: No free command index found\n",
+		device_get_nameunit(gdt->sc_devnode)));
         return (gccb);
     }
     bzero(gccb->gc_cmd, GDT_CMD_SZ);
@@ -819,7 +824,6 @@
         
     if (gdt->sc_cmd_cnt == 0)
         gdt->sc_set_sema0(gdt);
-    splx(*lock);
     gdt_enc32(gccb->gc_cmd + GDT_CMD_COMMANDINDEX,
               gccb->gc_cmd_index);
     gdt_enc16(gccb->gc_cmd + GDT_CMD_OPCODE, GDT_WRITE);
@@ -844,59 +848,21 @@
     gdt_enc32(gccb->gc_cmd + GDT_CMD_UNION + GDT_RAW_SENSE_DATA,
               gccb->gc_scratch_busbase);
  
-    /*
-     * If we have any data to send with this command,
-     * map it into bus space.
-     */
-    /* Only use S/G if there is a transfer */
-    if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
-        if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) { 
-            if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
-                int s;
-                int error;
-            
-                /* vorher unlock von splcam() ??? */
-                s = splsoftvm();
-                error =
-                    bus_dmamap_load(gdt->sc_buffer_dmat,
-                                    gccb->gc_dmamap,
-                                    ccb->csio.data_ptr,
-                                    ccb->csio.dxfer_len,
-                                    gdtexecuteccb,
-                                    gccb, /*flags*/0);
-                if (error == EINPROGRESS) {
-                    xpt_freeze_simq(sim, 1);
-                    gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
-                }
-                splx(s);
-            } else {
-		panic("iir: CAM_DATA_PHYS not supported");
-            }
-        } else {
-            struct bus_dma_segment *segs;
-
-            if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0)
-                panic("iir%d: iir_action - Physical "
-                      "segment pointers unsupported", gdt->sc_hanum);
-
-            if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS)==0)
-                panic("iir%d: iir_action - Virtual "
-                      "segment addresses unsupported", gdt->sc_hanum);
-
-            /* Just use the segments provided */
-            segs = (struct bus_dma_segment *)ccb->csio.data_ptr;
-            gdtexecuteccb(gccb, segs, ccb->csio.sglist_cnt, 0);
-        }
-    } else {
-        gdtexecuteccb(gccb, NULL, 0, 0);
+    error = bus_dmamap_load_ccb(gdt->sc_buffer_dmat,
+			        gccb->gc_dmamap,
+			        ccb,
+			        gdtexecuteccb,
+			        gccb, /*flags*/0);
+    if (error == EINPROGRESS) {
+        xpt_freeze_simq(sim, 1);
+        gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
     }
 
-    *lock = splcam();
     return (gccb);
 }
 
 static struct gdt_ccb *
-gdt_cache_cmd(struct gdt_softc *gdt, union ccb *ccb, int *lock)
+gdt_cache_cmd(struct gdt_softc *gdt, union ccb *ccb)
 {
     struct gdt_ccb *gccb;
     struct cam_sim *sim;
@@ -903,6 +869,7 @@
     u_int8_t *cmdp;
     u_int16_t opcode;
     u_int32_t blockno, blockcnt;
+    int error;
 
     GDT_DPRINTF(GDT_D_CMD, ("gdt_cache_cmd(%p, %p)\n", gdt, ccb));
 
@@ -909,15 +876,15 @@
     if (roundup(GDT_CMD_UNION + GDT_CACHE_SZ, sizeof(u_int32_t)) +
         gdt->sc_cmd_off + GDT_DPMEM_COMMAND_OFFSET >
         gdt->sc_ic_all_size) {
-        GDT_DPRINTF(GDT_D_INVALID, ("iir%d: gdt_cache_cmd(): DPMEM overflow\n", 
-                                    gdt->sc_hanum));
+        GDT_DPRINTF(GDT_D_INVALID, ("%s: gdt_cache_cmd(): DPMEM overflow\n", 
+		device_get_nameunit(gdt->sc_devnode)));
         return (NULL);
     }
 
     gccb = gdt_get_ccb(gdt);
     if (gccb == NULL) {
-        GDT_DPRINTF(GDT_D_DEBUG, ("iir%d: No free command index found\n",
-                                  gdt->sc_hanum));
+        GDT_DPRINTF(GDT_D_DEBUG, ("%s: No free command index found\n",
+		device_get_nameunit(gdt->sc_devnode)));
         return (gccb);
     }
     bzero(gccb->gc_cmd, GDT_CMD_SZ);
@@ -928,7 +895,6 @@
         
     if (gdt->sc_cmd_cnt == 0)
         gdt->sc_set_sema0(gdt);
-    splx(*lock);
     gdt_enc32(gccb->gc_cmd + GDT_CMD_COMMANDINDEX,
               gccb->gc_cmd_index);
     cmdp = ccb->csio.cdb_io.cdb_bytes;
@@ -953,55 +919,20 @@
     gdt_enc32(gccb->gc_cmd + GDT_CMD_UNION + GDT_CACHE_BLOCKCNT,
               blockcnt);
 
-    /*
-     * If we have any data to send with this command,
-     * map it into bus space.
-     */
-    /* Only use S/G if there is a transfer */
-    if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) { 
-        if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
-            int s;
-            int error;
-            
-            /* vorher unlock von splcam() ??? */
-            s = splsoftvm();
-            error =
-                bus_dmamap_load(gdt->sc_buffer_dmat,
+    error = bus_dmamap_load_ccb(gdt->sc_buffer_dmat,
                                 gccb->gc_dmamap,
-                                ccb->csio.data_ptr,
-                                ccb->csio.dxfer_len,
+                                ccb,
                                 gdtexecuteccb,
                                 gccb, /*flags*/0);
-            if (error == EINPROGRESS) {
-                xpt_freeze_simq(sim, 1);
-                gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
-            }
-            splx(s);
-        } else {
-	    panic("iir: CAM_DATA_PHYS not supported");
-        }
-    } else {
-        struct bus_dma_segment *segs;
-
-        if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0)
-            panic("iir%d: iir_action - Physical "
-                  "segment pointers unsupported", gdt->sc_hanum);
-
-        if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS)==0)
-            panic("iir%d: iir_action - Virtual "
-                  "segment addresses unsupported", gdt->sc_hanum);
-
-        /* Just use the segments provided */
-        segs = (struct bus_dma_segment *)ccb->csio.data_ptr;
-        gdtexecuteccb(gccb, segs, ccb->csio.sglist_cnt, 0);
+    if (error == EINPROGRESS) {
+        xpt_freeze_simq(sim, 1);
+        gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
     }
-
-    *lock = splcam();
     return (gccb);
 }
 
 static struct gdt_ccb *
-gdt_ioctl_cmd(struct gdt_softc *gdt, gdt_ucmd_t *ucmd, int *lock)
+gdt_ioctl_cmd(struct gdt_softc *gdt, gdt_ucmd_t *ucmd)
 {
     struct gdt_ccb *gccb;
     u_int32_t cnt;
@@ -1010,8 +941,8 @@
 
     gccb = gdt_get_ccb(gdt);
     if (gccb == NULL) {
-        GDT_DPRINTF(GDT_D_DEBUG, ("iir%d: No free command index found\n",
-                                  gdt->sc_hanum));
+        GDT_DPRINTF(GDT_D_DEBUG, ("%s: No free command index found\n",
+		device_get_nameunit(gdt->sc_devnode)));
         return (gccb);
     }
     bzero(gccb->gc_cmd, GDT_CMD_SZ);
@@ -1026,8 +957,8 @@
                                       sizeof(u_int32_t));
             cnt = ucmd->u.ioctl.param_size;
             if (cnt > GDT_SCRATCH_SZ) {
-                printf("iir%d: Scratch buffer too small (%d/%d)\n", 
-                       gdt->sc_hanum, GDT_SCRATCH_SZ, cnt);
+                device_printf(gdt->sc_devnode,
+		    "Scratch buffer too small (%d/%d)\n", GDT_SCRATCH_SZ, cnt);
                 gdt_free_ccb(gdt, gccb);
                 return (NULL);
             }
@@ -1036,8 +967,8 @@
                                       GDT_SG_SZ, sizeof(u_int32_t));
             cnt = ucmd->u.cache.BlockCnt * GDT_SECTOR_SIZE;
             if (cnt > GDT_SCRATCH_SZ) {
-                printf("iir%d: Scratch buffer too small (%d/%d)\n", 
-                       gdt->sc_hanum, GDT_SCRATCH_SZ, cnt);
+                device_printf(gdt->sc_devnode,
+		    "Scratch buffer too small (%d/%d)\n", GDT_SCRATCH_SZ, cnt);
                 gdt_free_ccb(gdt, gccb);
                 return (NULL);
             }
@@ -1047,8 +978,8 @@
                                   GDT_SG_SZ, sizeof(u_int32_t));
         cnt = ucmd->u.raw.sdlen;
         if (cnt + ucmd->u.raw.sense_len > GDT_SCRATCH_SZ) {
-            printf("iir%d: Scratch buffer too small (%d/%d)\n", 
-                   gdt->sc_hanum, GDT_SCRATCH_SZ, cnt + ucmd->u.raw.sense_len);
+            device_printf(gdt->sc_devnode, "Scratch buffer too small (%d/%d)\n", 
+		GDT_SCRATCH_SZ, cnt + ucmd->u.raw.sense_len);
             gdt_free_ccb(gdt, gccb);
             return (NULL);
         }
@@ -1058,8 +989,8 @@
 
     if (gdt->sc_cmd_off + gccb->gc_cmd_len + GDT_DPMEM_COMMAND_OFFSET >
         gdt->sc_ic_all_size) {
-        GDT_DPRINTF(GDT_D_INVALID, ("iir%d: gdt_ioctl_cmd(): DPMEM overflow\n", 
-                                    gdt->sc_hanum));
+        GDT_DPRINTF(GDT_D_INVALID, ("%s: gdt_ioctl_cmd(): DPMEM overflow\n", 
+		device_get_nameunit(gdt->sc_devnode)));
         gdt_free_ccb(gdt, gccb);
         return (NULL);
     }
@@ -1066,7 +997,6 @@
 
     if (gdt->sc_cmd_cnt == 0)
         gdt->sc_set_sema0(gdt);
-    splx(*lock);
 
     /* fill cmd structure */
     gdt_enc32(gccb->gc_cmd + GDT_CMD_COMMANDINDEX,
@@ -1132,7 +1062,6 @@
                   GDT_SG_LEN, ucmd->u.raw.sdlen);
     }
 
-    *lock = splcam();
     gdt_stat.sg_count_act = 1;
     gdt->sc_copy_cmd(gdt, gccb);
     return (gccb);
@@ -1249,13 +1178,12 @@
     struct gdt_ccb *gccb;
     union ccb *ccb;
     struct gdt_softc *gdt;
-    int i, lock;
+    int i;
 
-    lock = splcam();
-
     gccb = (struct gdt_ccb *)arg;
     ccb = gccb->gc_ccb;
     gdt = cam_sim_softc((struct cam_sim *)ccb->ccb_h.ccb_sim_ptr);
+    mtx_assert(&gdt->sc_lock, MA_OWNED);
 
     GDT_DPRINTF(GDT_D_CMD, ("gdtexecuteccb(%p, %p, %p, %d, %d)\n", 
                             gdt, gccb, dm_segs, nseg, error));
@@ -1308,12 +1236,10 @@
     
     ccb->ccb_h.status |= CAM_SIM_QUEUED;
     /* timeout handling */
-    ccb->ccb_h.timeout_ch =
-        timeout(iir_timeout, (caddr_t)gccb,
-                (ccb->ccb_h.timeout * hz) / 1000);
+    callout_reset_sbt(&gccb->gc_timeout, SBT_1MS * ccb->ccb_h.timeout, 0,
+      iir_timeout, (caddr_t)gccb, 0);
 
     gdt->sc_copy_cmd(gdt, gccb);
-    splx(lock);
 }
 
 
@@ -1321,9 +1247,10 @@
 iir_action( struct cam_sim *sim, union ccb *ccb )
 {
     struct gdt_softc *gdt;
-    int lock, bus, target, lun;
+    int bus, target, lun;
 
     gdt = (struct gdt_softc *)cam_sim_softc( sim );
+    mtx_assert(&gdt->sc_lock, MA_OWNED);
     ccb->ccb_h.ccb_sim_ptr = sim;
     bus = cam_sim_bus(sim);
     target = ccb->ccb_h.target_id;
@@ -1338,12 +1265,10 @@
 
     switch (ccb->ccb_h.func_code) {
       case XPT_SCSI_IO:
-        lock = splcam();
         TAILQ_INSERT_TAIL(&gdt->sc_ccb_queue, &ccb->ccb_h, sim_links.tqe);
         ++gdt_stat.req_queue_act;
         if (gdt_stat.req_queue_act > gdt_stat.req_queue_max)
             gdt_stat.req_queue_max = gdt_stat.req_queue_act;
-        splx(lock);
         gdt_next(gdt);
         break;
       case XPT_RESET_DEV:   /* Bus Device Reset the specified SCSI device */
@@ -1442,12 +1367,12 @@
               cpi->initiator_id = 
                   (bus == gdt->sc_virt_bus ? 127 : gdt->sc_bus_id[bus]);
               cpi->base_transfer_speed = 3300;
-              strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-              if (gdt->sc_vendor == INTEL_VENDOR_ID)
-                  strncpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN);
+              strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+              if (gdt->sc_vendor == INTEL_VENDOR_ID_IIR)
+                  strlcpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN);
               else
-                  strncpy(cpi->hba_vid, "ICP vortex ", HBA_IDLEN);
-              strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+                  strlcpy(cpi->hba_vid, "ICP vortex ", HBA_IDLEN);
+              strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
               cpi->transport = XPORT_SPI;
               cpi->transport_version = 2;
               cpi->protocol = PROTO_SCSI;
@@ -1474,7 +1399,7 @@
 
     gdt = (struct gdt_softc *)cam_sim_softc( sim );
     GDT_DPRINTF(GDT_D_CMD, ("iir_poll sim %p gdt %p\n", sim, gdt));
-    iir_intr(gdt);
+    iir_intr_locked(gdt);
 }
 
 static void     
@@ -1489,29 +1414,29 @@
     struct gdt_softc *gdt;
     struct gdt_ccb *gccb;
     gdt_ucmd_t *ucmd;
-    int lock, i;
+    int i;
 
     gdt = (struct gdt_softc *)arg;
     GDT_DPRINTF(GDT_D_CMD, ("iir_shutdown(%p, %d)\n", gdt, howto));
 
-    printf("iir%d: Flushing all Host Drives. Please wait ...  ",
-           gdt->sc_hanum);
+    device_printf(gdt->sc_devnode,
+	"Flushing all Host Drives. Please wait ...  ");
 
     /* allocate ucmd buffer */
     ucmd = malloc(sizeof(gdt_ucmd_t), M_GDTBUF, M_NOWAIT);
     if (ucmd == NULL) {
-        printf("iir%d: iir_shutdown(): Cannot allocate resource\n",
-               gdt->sc_hanum);
+	printf("\n");
+        device_printf(gdt->sc_devnode,
+	    "iir_shutdown(): Cannot allocate resource\n");
         return;
     }
     bzero(ucmd, sizeof(gdt_ucmd_t));
 
     /* wait for pending IOs */
-    lock = splcam();
+    mtx_lock(&gdt->sc_lock);
     gdt->sc_state = GDT_SHUTDOWN;
-    splx(lock);
     if ((gccb = SLIST_FIRST(&gdt->sc_pending_gccb)) != NULL)
-        (void) tsleep((void *)gccb, PCATCH | PRIBIO, "iirshw", 100 * hz);
+        mtx_sleep(gccb, &gdt->sc_lock, PCATCH | PRIBIO, "iirshw", 100 * hz);
 
     /* flush */
     for (i = 0; i < GDT_MAX_HDRIVES; ++i) {
@@ -1519,15 +1444,15 @@
             ucmd->service = GDT_CACHESERVICE;
             ucmd->OpCode = GDT_FLUSH;
             ucmd->u.cache.DeviceNo = i;
-            lock = splcam();
             TAILQ_INSERT_TAIL(&gdt->sc_ucmd_queue, ucmd, links);
             ucmd->complete_flag = FALSE;
-            splx(lock);
             gdt_next(gdt);
             if (!ucmd->complete_flag)
-                (void) tsleep((void *)ucmd, PCATCH|PRIBIO, "iirshw", 10*hz);
+                mtx_sleep(ucmd, &gdt->sc_lock, PCATCH | PRIBIO, "iirshw",
+		    10 * hz);
         }
     }
+    mtx_unlock(&gdt->sc_lock);
 
     free(ucmd, M_DEVBUF);
     printf("Done.\n");
@@ -1537,8 +1462,16 @@
 iir_intr(void *arg)
 {
     struct gdt_softc *gdt = arg;
+
+    mtx_lock(&gdt->sc_lock);
+    iir_intr_locked(gdt);
+    mtx_unlock(&gdt->sc_lock);
+}
+
+int
+iir_intr_locked(struct gdt_softc *gdt)
+{
     struct gdt_intr_ctx ctx;
-    int lock = 0;
     struct gdt_ccb *gccb;
     gdt_ucmd_t *ucmd;
     u_int32_t cnt;
@@ -1545,21 +1478,17 @@
 
     GDT_DPRINTF(GDT_D_INTR, ("gdt_intr(%p)\n", gdt));
 
+    mtx_assert(&gdt->sc_lock, MA_OWNED);
+
     /* If polling and we were not called from gdt_wait, just return */
     if ((gdt->sc_state & GDT_POLLING) &&
         !(gdt->sc_state & GDT_POLL_WAIT))
-        return;
+        return (0);
 
-    if (!(gdt->sc_state & GDT_POLLING)) 
-        lock = splcam();
-    gdt_wait_index = 0;
-
     ctx.istatus = gdt->sc_get_status(gdt);
     if (ctx.istatus == 0x00) {
-        if (!(gdt->sc_state & GDT_POLLING)) 
-            splx(lock);
         gdt->sc_status = GDT_S_NO_STATUS;
-        return;
+        return (ctx.istatus);
     }
 
     gdt->sc_intr(gdt, &ctx);
@@ -1569,27 +1498,18 @@
     gdt->sc_info = ctx.info;
     gdt->sc_info2 = ctx.info2;
 
-    if (gdt->sc_state & GDT_POLL_WAIT) { 
-        gdt_wait_gdt = gdt;
-        gdt_wait_index = ctx.istatus;
-    }
-
     if (ctx.istatus == GDT_ASYNCINDEX) {
         gdt_async_event(gdt, ctx.service);
-        if (!(gdt->sc_state & GDT_POLLING)) 
-            splx(lock);
-        return;
+        return (ctx.istatus);
     }
     if (ctx.istatus == GDT_SPEZINDEX) {
         GDT_DPRINTF(GDT_D_INVALID, 
-                    ("iir%d: Service unknown or not initialized!\n", 
-                     gdt->sc_hanum));   
+                    ("%s: Service unknown or not initialized!\n", 
+		     device_get_nameunit(gdt->sc_devnode)));   
         gdt->sc_dvr.size = sizeof(gdt->sc_dvr.eu.driver);
         gdt->sc_dvr.eu.driver.ionode = gdt->sc_hanum;
         gdt_store_event(GDT_ES_DRIVER, 4, &gdt->sc_dvr);
-        if (!(gdt->sc_state & GDT_POLLING)) 
-            splx(lock);
-        return;
+        return (ctx.istatus);
     }
 
     gccb = &gdt->sc_gccbs[ctx.istatus - 2];
@@ -1597,18 +1517,16 @@
 
     switch (gccb->gc_flags) {
       case GDT_GCF_UNUSED:
-        GDT_DPRINTF(GDT_D_INVALID, ("iir%d: Index (%d) to unused command!\n",
-                    gdt->sc_hanum, ctx.istatus));
+        GDT_DPRINTF(GDT_D_INVALID, ("%s: Index (%d) to unused command!\n",
+		    device_get_nameunit(gdt->sc_devnode), ctx.istatus));
         gdt->sc_dvr.size = sizeof(gdt->sc_dvr.eu.driver);
         gdt->sc_dvr.eu.driver.ionode = gdt->sc_hanum;
         gdt->sc_dvr.eu.driver.index = ctx.istatus;
         gdt_store_event(GDT_ES_DRIVER, 1, &gdt->sc_dvr);
         gdt_free_ccb(gdt, gccb);
-        /* fallthrough */
+	break;
 
       case GDT_GCF_INTERNAL:
-        if (!(gdt->sc_state & GDT_POLLING)) 
-            splx(lock);
         break;
 
       case GDT_GCF_IOCTL:
@@ -1617,8 +1535,6 @@
             GDT_DPRINTF(GDT_D_DEBUG, ("iir_intr(%p) ioctl: gccb %p busy\n", 
                                       gdt, gccb));
             TAILQ_INSERT_HEAD(&gdt->sc_ucmd_queue, ucmd, links);
-            if (!(gdt->sc_state & GDT_POLLING)) 
-                splx(lock);
         } else {
             ucmd->status = gdt->sc_status;
             ucmd->info = gdt->sc_info;
@@ -1641,8 +1557,6 @@
                     bcopy(gccb->gc_scratch, ucmd->data, cnt);
             }
             gdt_free_ccb(gdt, gccb);
-            if (!(gdt->sc_state & GDT_POLLING)) 
-                splx(lock);
             /* wakeup */
             wakeup(ucmd);
         }
@@ -1652,11 +1566,11 @@
       default:
         gdt_free_ccb(gdt, gccb);
         gdt_sync_event(gdt, ctx.service, ctx.istatus, gccb);
-        if (!(gdt->sc_state & GDT_POLLING)) 
-            splx(lock);
         gdt_next(gdt); 
         break;
     }
+
+    return (ctx.istatus);
 }
 
 int
@@ -1672,8 +1586,7 @@
                 DELAY(1);
             gccb = gdt_get_ccb(gdt);
             if (gccb == NULL) {
-                printf("iir%d: No free command index found\n",
-                       gdt->sc_hanum);
+                device_printf(gdt->sc_devnode, "No free command index found\n");
                 return (1);
             }
             bzero(gccb->gc_cmd, GDT_CMD_SZ);
@@ -1692,8 +1605,8 @@
                                       sizeof(u_int32_t));
             gdt->sc_cmd_cnt = 0;
             gdt->sc_copy_cmd(gdt, gccb);
-            printf("iir%d: [PCI %d/%d] ",
-                gdt->sc_hanum,gdt->sc_bus,gdt->sc_slot);
+            device_printf(gdt->sc_devnode, "[PCI %d/%d] ", gdt->sc_bus,
+		gdt->sc_slot);
             gdt->sc_release_event(gdt);
         }
 
@@ -1712,7 +1625,7 @@
             *(u_int32_t *)gdt->sc_dvr.eu.async.scsi_coord  = gdt->sc_info2;
         }
         gdt_store_event(GDT_ES_ASYNC, service, &gdt->sc_dvr);
-        printf("iir%d: %s\n", gdt->sc_hanum, gdt->sc_dvr.event_string);
+        device_printf(gdt->sc_devnode, "%s\n", gdt->sc_dvr.event_string);
     }
     
     return (0);
@@ -1747,8 +1660,7 @@
             bzero(gccb->gc_cmd, GDT_CMD_SZ);
             gccb = gdt_get_ccb(gdt);
             if (gccb == NULL) {
-                printf("iir%d: No free command index found\n",
-                       gdt->sc_hanum);
+                device_printf(gdt->sc_devnode, "No free command index found\n");
                 return (1);
             }
             gccb->gc_service = service;
@@ -1791,8 +1703,7 @@
             bzero(gccb->gc_cmd, GDT_CMD_SZ);
             gccb = gdt_get_ccb(gdt);
             if (gccb == NULL) {
-                printf("iir%d: No free command index found\n",
-                       gdt->sc_hanum);
+                device_printf(gdt->sc_devnode, "No free command index found\n");
                 return (1);
             }
             gccb->gc_service = service;
@@ -1816,7 +1727,7 @@
         printf("\n");
         return (0);
     } else {
-        untimeout(iir_timeout, gccb, ccb->ccb_h.timeout_ch);
+	callout_stop(&gccb->gc_timeout);
         if (gdt->sc_status == GDT_S_BSY) {
             GDT_DPRINTF(GDT_D_DEBUG, ("gdt_sync_event(%p) gccb %p busy\n", 
                                       gdt, gccb));
@@ -1884,7 +1795,7 @@
 }
 
 /* Controller event handling functions */
-gdt_evt_str *gdt_store_event(u_int16_t source, u_int16_t idx,
+void gdt_store_event(u_int16_t source, u_int16_t idx,
                              gdt_evt_data *evt)
 {
     gdt_evt_str *e;
@@ -1892,8 +1803,9 @@
 
     GDT_DPRINTF(GDT_D_MISC, ("gdt_store_event(%d, %d)\n", source, idx));
     if (source == 0)                        /* no source -> no event */
-        return 0;
+        return;
 
+    mtx_lock(&elock);
     if (ebuffer[elastidx].event_source == source &&
         ebuffer[elastidx].event_idx == idx &&
         ((evt->size != 0 && ebuffer[elastidx].event_data.size != 0 &&
@@ -1926,16 +1838,16 @@
         e->event_data = *evt;
         e->application = 0;
     }
-    return e;
+    mtx_unlock(&elock);
 }
 
 int gdt_read_event(int handle, gdt_evt_str *estr)
 {
     gdt_evt_str *e;
-    int eindex, lock;
+    int eindex;
     
     GDT_DPRINTF(GDT_D_MISC, ("gdt_read_event(%d)\n", handle));
-    lock = splcam();
+    mtx_lock(&elock);
     if (handle == -1)
         eindex = eoldidx;
     else
@@ -1943,7 +1855,7 @@
     estr->event_source = 0;
 
     if (eindex >= GDT_MAX_EVENTS) {
-        splx(lock);
+	mtx_unlock(&elock);
         return eindex;
     }
     e = &ebuffer[eindex];
@@ -1956,7 +1868,7 @@
         }
         memcpy(estr, e, sizeof(gdt_evt_str));
     }
-    splx(lock);
+    mtx_unlock(&elock);
     return eindex;
 }
 
@@ -1964,10 +1876,10 @@
 {
     gdt_evt_str *e;
     int found = FALSE;
-    int eindex, lock;
+    int eindex;
     
     GDT_DPRINTF(GDT_D_MISC, ("gdt_readapp_event(%d)\n", application));
-    lock = splcam();
+    mtx_lock(&elock);
     eindex = eoldidx;
     for (;;) {
         e = &ebuffer[eindex];
@@ -1987,7 +1899,7 @@
         memcpy(estr, e, sizeof(gdt_evt_str));
     else
         estr->event_source = 0;
-    splx(lock);
+    mtx_unlock(&elock);
 }
 
 void gdt_clear_events()
@@ -1994,6 +1906,8 @@
 {
     GDT_DPRINTF(GDT_D_MISC, ("gdt_clear_events\n"));
 
+    mtx_lock(&elock);
     eoldidx = elastidx = 0;
     ebuffer[0].event_source = 0;
+    mtx_unlock(&elock);
 }

Modified: trunk/sys/dev/iir/iir.h
===================================================================
--- trunk/sys/dev/iir/iir.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/iir/iir.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/iir/iir.h 275975 2014-12-21 01:39:21Z smh $ */
 /*-
  *       Copyright (c) 2000-04 ICP vortex GmbH
  *       Copyright (c) 2002-04 Intel Corporation
@@ -41,7 +42,7 @@
  * credits:     Niklas Hallqvist;       OpenBSD driver for the ICP Controllers.
  *              FreeBSD.ORG;            Great O/S to work on and for.
  *
- * $Id: iir.h,v 1.5 2013-01-08 03:53:20 laffer1 Exp $"
+ * $Id: iir.h 1.6 2004/03/30 10:19:44 achim Exp $"
  */
 
 #ifndef _IIR_H
@@ -63,7 +64,7 @@
 #define GDT_DEVICE_ID_MAX       0x2ff
 #define GDT_DEVICE_ID_NEWRX     0x300
 
-#define INTEL_VENDOR_ID         0x8086
+#define INTEL_VENDOR_ID_IIR     0x8086
 #define INTEL_DEVICE_ID_IIR     0x600
 
 #define GDT_MAXBUS              6       /* XXX Why not 5? */
@@ -591,6 +592,7 @@
 /* softc structure */
 struct gdt_softc {
     device_t sc_devnode;
+    struct mtx sc_lock;
     int sc_hanum;
     int sc_class;               /* Controller class */
 #define GDT_MPR         0x05
@@ -608,9 +610,7 @@
 #define GDT_SHUTDOWN    0x02
 #define GDT_POLL_WAIT   0x80
     struct cdev *sc_dev;
-    bus_space_tag_t sc_dpmemt;
-    bus_space_handle_t sc_dpmemh;
-    bus_addr_t sc_dpmembase;
+    struct resource *sc_dpmem;
     bus_dma_tag_t sc_parent_dmat;
     bus_dma_tag_t sc_buffer_dmat;
     bus_dma_tag_t sc_gcscratch_dmat;
@@ -684,8 +684,8 @@
     union ccb   *gc_ccb;
     gdt_ucmd_t  *gc_ucmd;
     bus_dmamap_t gc_dmamap;
+    struct callout gc_timeout;
     int         gc_map_flag;
-    int         gc_timeout;
     u_int8_t    gc_service;
     u_int8_t    gc_cmd_index;
     u_int8_t    gc_flags;
@@ -737,15 +737,14 @@
 }
 #endif
 
-extern TAILQ_HEAD(gdt_softc_list, gdt_softc) gdt_softcs;
 extern u_int8_t gdt_polling;
 
-struct cdev *gdt_make_dev(int unit);
+struct cdev *gdt_make_dev(struct gdt_softc *gdt);
 void    gdt_destroy_dev(struct cdev *dev);
 void    gdt_next(struct gdt_softc *gdt);
 void gdt_free_ccb(struct gdt_softc *gdt, struct gdt_ccb *gccb);
 
-gdt_evt_str *gdt_store_event(u_int16_t source, u_int16_t idx,
+void gdt_store_event(u_int16_t source, u_int16_t idx,
                              gdt_evt_data *evt);
 int gdt_read_event(int handle, gdt_evt_str *estr);
 void gdt_readapp_event(u_int8_t app, gdt_evt_str *estr);

Modified: trunk/sys/dev/iir/iir_ctrl.c
===================================================================
--- trunk/sys/dev/iir/iir_ctrl.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/iir/iir_ctrl.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  *       Copyright (c) 2000-03 ICP vortex GmbH
  *       Copyright (c) 2002-03 Intel Corporation
@@ -35,14 +36,15 @@
  * Written by: Achim Leubner <achim_leubner at adaptec.com>
  * Fixes/Additions: Boji Tony Kannanthanam <boji.t.kannanthanam at intel.com>
  *
- * $Id: iir_ctrl.c,v 1.2 2013-01-08 03:53:20 laffer1 Exp $"
+ * $Id: iir_ctrl.c 1.3 2003/08/26 12:31:15 achim Exp $"
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/iir/iir_ctrl.c 275975 2014-12-21 01:39:21Z smh $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/bus.h>
 #include <sys/endian.h>
 #include <sys/malloc.h>
 #include <sys/kernel.h>
@@ -52,12 +54,13 @@
 #include <sys/stat.h>
 #include <sys/disklabel.h>
 #include <sys/sysctl.h>
+#include <sys/sx.h>
 #include <machine/bus.h>
 
 #include <dev/iir/iir.h>
 
 /* Entry points and other prototypes */
-static struct gdt_softc *gdt_minor2softc(int minor_no);
+static struct gdt_softc *gdt_minor2softc(struct cdev *dev, int minor_no);
 
 static d_open_t		iir_open;
 static d_close_t	iir_close;
@@ -68,7 +71,6 @@
 /* Normally, this is a static structure.  But we need it in pci/iir_pci.c */
 static struct cdevsw iir_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
 	.d_open =	iir_open,
 	.d_close =	iir_close,
 	.d_read =	iir_read,
@@ -77,11 +79,10 @@
 	.d_name =	"iir",
 };
 
-/*
-static int iir_devsw_installed = 0;
-*/
 #ifndef SDEV_PER_HBA
 static int sdev_made = 0;
+static struct sx sdev_lock;
+SX_SYSINIT(iir_sdev_lock, &sdev_lock, "iir sdev");
 #endif
 extern int gdt_cnt;
 extern gdt_statist_t gdt_stat;
@@ -91,19 +92,22 @@
  * make a special device and return the dev_t
  */
 struct cdev *
-gdt_make_dev(int unit)
+gdt_make_dev(struct gdt_softc *gdt)
 {
     struct cdev *dev;
 
 #ifdef SDEV_PER_HBA
-    dev = make_dev(&iir_cdevsw, hba2minor(unit), UID_ROOT, GID_OPERATOR,
+    dev = make_dev(&iir_cdevsw, 0, UID_ROOT, GID_OPERATOR,
                    S_IRUSR | S_IWUSR, "iir%d", unit);
+    dev->si_drv1 = gdt;
 #else
+    sx_xlock(&sdev_lock);
     if (sdev_made)
-        return (0);
+        return (NULL);
     dev = make_dev(&iir_cdevsw, 0, UID_ROOT, GID_OPERATOR,
                    S_IRUSR | S_IWUSR, "iir");
     sdev_made = 1;
+    sx_xunlock(&sdev_lock);
 #endif
     return (dev);
 }
@@ -120,22 +124,23 @@
  * return the pointer to its softc structure
  */
 static struct gdt_softc *
-gdt_minor2softc(int minor_no)
+gdt_minor2softc(struct cdev *dev, int minor_no)
 {
-    struct gdt_softc *gdt;
-    int hanum;
+#ifdef SDEV_PER_HBA
 
-#ifdef SDEV_PER_HBA
-    hanum = minor2hba(minor_no);
+    return (dev->si_drv1);
 #else
-    hanum = minor_no;
+    devclass_t dc;
+    device_t child;
+
+    dc = devclass_find("iir");
+    if (dc == NULL)
+	return (NULL);
+    child = devclass_get_device(dc, minor_no);
+    if (child == NULL)
+	return (NULL);
+    return (device_get_softc(child));
 #endif
-
-    for (gdt = TAILQ_FIRST(&gdt_softcs);
-         gdt != NULL && gdt->sc_hanum != hanum;
-         gdt = TAILQ_NEXT(gdt, links));
-
-    return (gdt);
 }
 
 static int
@@ -143,16 +148,6 @@
 {
     GDT_DPRINTF(GDT_D_DEBUG, ("iir_open()\n"));
 
-#ifdef SDEV_PER_HBA
-    int minor_no;
-    struct gdt_softc *gdt;
-
-    minor_no = dev2unit(dev);
-    gdt = gdt_minor2softc(minor_no);
-    if (gdt == NULL)
-        return (ENXIO);
-#endif
-                
     return (0);
 }
 
@@ -161,16 +156,6 @@
 {
     GDT_DPRINTF(GDT_D_DEBUG, ("iir_close()\n"));
                 
-#ifdef SDEV_PER_HBA
-    int minor_no;
-    struct gdt_softc *gdt;
-
-    minor_no = dev2unit(dev);
-    gdt = gdt_minor2softc(minor_no);
-    if (gdt == NULL)
-        return (ENXIO);
-#endif
-
     return (0);
 }
 
@@ -179,16 +164,6 @@
 {
     GDT_DPRINTF(GDT_D_DEBUG, ("iir_write()\n"));
                 
-#ifdef SDEV_PER_HBA
-    int minor_no;
-    struct gdt_softc *gdt;
-
-    minor_no = dev2unit(dev);
-    gdt = gdt_minor2softc(minor_no);
-    if (gdt == NULL)
-        return (ENXIO);
-#endif
-
     return (0);
 }
 
@@ -197,16 +172,6 @@
 {
     GDT_DPRINTF(GDT_D_DEBUG, ("iir_read()\n"));
                 
-#ifdef SDEV_PER_HBA
-    int minor_no;
-    struct gdt_softc *gdt;
-
-    minor_no = dev2unit(dev);
-    gdt = gdt_minor2softc(minor_no);
-    if (gdt == NULL)
-        return (ENXIO);
-#endif
-
     return (0);
 }
 
@@ -221,15 +186,6 @@
 {
     GDT_DPRINTF(GDT_D_DEBUG, ("iir_ioctl() cmd 0x%lx\n",cmd));
 
-#ifdef SDEV_PER_HBA
-    int minor_no;
-    struct gdt_softc *gdt;
-
-    minor_no = dev2unit(dev);
-    gdt = gdt_minor2softc(minor_no);
-    if (gdt == NULL)
-        return (ENXIO);
-#endif
     ++gdt_stat.io_count_act;
     if (gdt_stat.io_count_act > gdt_stat.io_count_max)
         gdt_stat.io_count_max = gdt_stat.io_count_act;
@@ -239,19 +195,19 @@
         {
             gdt_ucmd_t *ucmd;
             struct gdt_softc *gdt;
-            int lock;
 
             ucmd = (gdt_ucmd_t *)cmdarg;
-            gdt = gdt_minor2softc(ucmd->io_node);
+            gdt = gdt_minor2softc(dev, ucmd->io_node);
             if (gdt == NULL)
                 return (ENXIO);
-            lock = splcam();
+	    mtx_lock(&gdt->sc_lock);
             TAILQ_INSERT_TAIL(&gdt->sc_ucmd_queue, ucmd, links);
             ucmd->complete_flag = FALSE;
-            splx(lock);
             gdt_next(gdt);
             if (!ucmd->complete_flag)
-                (void) tsleep((void *)ucmd, PCATCH | PRIBIO, "iirucw", 0);
+                (void) mtx_sleep(ucmd, &gdt->sc_lock, PCATCH | PRIBIO, "iirucw",
+		    0);
+	    mtx_unlock(&gdt->sc_lock);
             break;
         }
 
@@ -268,12 +224,12 @@
             struct gdt_softc *gdt; 
             
             p = (gdt_ctrt_t *)cmdarg;
-            gdt = gdt_minor2softc(p->io_node);
+            gdt = gdt_minor2softc(dev, p->io_node);
             if (gdt == NULL)
                 return (ENXIO);
             /* only RP controllers */
             p->ext_type = 0x6000 | gdt->sc_device;
-            if (gdt->sc_vendor == INTEL_VENDOR_ID) {
+            if (gdt->sc_vendor == INTEL_VENDOR_ID_IIR) {
                 p->oem_id = OEM_ID_INTEL;
                 p->type = 0xfd;
                 /* new -> subdevice into ext_type */
@@ -298,15 +254,9 @@
 
             p = (gdt_osv_t *)cmdarg;
             p->oscode = 10;
-            p->version = osrelease[0] - '0';
-            if (osrelease[1] == '.')
-                p->subversion = osrelease[2] - '0';
-            else
-                p->subversion = 0;
-            if (osrelease[3] == '.')
-                p->revision = osrelease[4] - '0';
-            else
-                p->revision = 0;
+	    p->version = osreldate / 100000;
+	    p->subversion = osreldate / 1000 % 100;
+	    p->revision = 0;
             strcpy(p->name, ostype);
             break;
         }
@@ -318,7 +268,6 @@
       case GDT_IOCTL_EVENT:
         {
             gdt_event_t *p;
-            int lock;
 
             p = (gdt_event_t *)cmdarg;
             if (p->erase == 0xff) {
@@ -330,14 +279,10 @@
                     p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.sync);
                 else
                     p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.async);
-                lock = splcam();
                 gdt_store_event(p->dvr.event_source, p->dvr.event_idx,
                                 &p->dvr.event_data);
-                splx(lock);
             } else if (p->erase == 0xfe) {
-                lock = splcam();
                 gdt_clear_events();
-                splx(lock);
             } else if (p->erase == 0) {
                 p->handle = gdt_read_event(p->handle, &p->dvr);
             } else {
@@ -362,18 +307,3 @@
     --gdt_stat.io_count_act;
     return (0);
 }
-
-/*
-static void
-iir_drvinit(void *unused)
-{
-    GDT_DPRINTF(GDT_D_DEBUG, ("iir_drvinit()\n"));
-                
-    if (!iir_devsw_installed) {
-        cdevsw_add(&iir_cdevsw);
-        iir_devsw_installed = 1;
-    }
-}
-
-SYSINIT(iir_dev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, iir_drvinit, NULL)
-*/

Modified: trunk/sys/dev/iir/iir_pci.c
===================================================================
--- trunk/sys/dev/iir/iir_pci.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/iir/iir_pci.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  *       Copyright (c) 2000-03 ICP vortex GmbH
  *       Copyright (c) 2002-03 Intel Corporation
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/iir/iir_pci.c 281826 2015-04-21 11:27:50Z mav $");
 
 /*
  *  iir_pci.c:  PCI Bus Attachment for Intel Integrated RAID Controller driver
@@ -163,7 +164,7 @@
 static int
 iir_pci_probe(device_t dev)
 {
-    if (pci_get_vendor(dev) == INTEL_VENDOR_ID &&
+    if (pci_get_vendor(dev) == INTEL_VENDOR_ID_IIR &&
         pci_get_device(dev) == INTEL_DEVICE_ID_IIR) {
         device_set_desc(dev, "Intel Integrated RAID Controller");
         return (BUS_PROBE_DEFAULT);
@@ -183,15 +184,18 @@
 iir_pci_attach(device_t dev)
 {
     struct gdt_softc    *gdt;
-    struct resource     *io = NULL, *irq = NULL;
+    struct resource     *irq = NULL;
     int                 retries, rid, error = 0;
     void                *ih;
     u_int8_t            protocol;  
- 
+
+    gdt = device_get_softc(dev);
+    mtx_init(&gdt->sc_lock, "iir", NULL, MTX_DEF);
+
     /* map DPMEM */
     rid = PCI_DPMEM;
-    io = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
-    if (io == NULL) {
+    gdt->sc_dpmem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+    if (gdt->sc_dpmem == NULL) {
         device_printf(dev, "can't allocate register resources\n");
         error = ENOMEM;
         goto err;
@@ -207,12 +211,8 @@
         goto err;
     }
 
-    gdt = device_get_softc(dev);
     gdt->sc_devnode = dev;
     gdt->sc_init_level = 0;
-    gdt->sc_dpmemt = rman_get_bustag(io);
-    gdt->sc_dpmemh = rman_get_bushandle(io);
-    gdt->sc_dpmembase = rman_get_start(io);
     gdt->sc_hanum = device_get_unit(dev);
     gdt->sc_bus = pci_get_bus(dev);
     gdt->sc_slot = pci_get_slot(dev);
@@ -227,40 +227,32 @@
 
     /* initialize RP controller */
     /* check and reset interface area */
-    bus_space_write_4(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC,
-                      htole32(GDT_MPR_MAGIC));
-    if (bus_space_read_4(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC) !=
-        htole32(GDT_MPR_MAGIC)) {
-        printf("cannot access DPMEM at 0x%jx (shadowed?)\n",
-               (uintmax_t)gdt->sc_dpmembase);
+    bus_write_4(gdt->sc_dpmem, GDT_MPR_IC, htole32(GDT_MPR_MAGIC));
+    if (bus_read_4(gdt->sc_dpmem, GDT_MPR_IC) != htole32(GDT_MPR_MAGIC)) {
+	device_printf(dev, "cannot access DPMEM at 0x%lx (shadowed?)\n",
+	    rman_get_start(gdt->sc_dpmem));
         error = ENXIO;
         goto err;
     }
-    bus_space_set_region_4(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_I960_SZ, htole32(0),
-                           GDT_MPR_SZ >> 2);
+    bus_set_region_4(gdt->sc_dpmem, GDT_I960_SZ, htole32(0), GDT_MPR_SZ >> 2);
 
     /* Disable everything */
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_EDOOR_EN,
-                      bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh, 
-                                       GDT_EDOOR_EN) | 4);
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_EDOOR, 0xff);
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_STATUS,
-                      0);
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_CMD_INDEX,
-                      0);
+    bus_write_1(gdt->sc_dpmem, GDT_EDOOR_EN,
+	bus_read_1(gdt->sc_dpmem, GDT_EDOOR_EN) | 4);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_EDOOR, 0xff);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_STATUS, 0);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_CMD_INDEX, 0);
 
-    bus_space_write_4(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_INFO,
-                      htole32(gdt->sc_dpmembase));
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_CMD_INDX,
-                      0xff);
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_LDOOR, 1);
+    bus_write_4(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_INFO,
+	htole32(rman_get_start(gdt->sc_dpmem)));
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_CMD_INDX, 0xff);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_LDOOR, 1);
 
     DELAY(20);
     retries = GDT_RETRIES;
-    while (bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                            GDT_MPR_IC + GDT_S_STATUS) != 0xff) {
+    while (bus_read_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_STATUS) != 0xff) {
         if (--retries == 0) {
-            printf("DEINIT failed\n");
+            device_printf(dev, "DEINIT failed\n");
             error = ENXIO;
             goto err;
         }
@@ -267,37 +259,31 @@
         DELAY(1);
     }
 
-    protocol = (uint8_t)le32toh(bus_space_read_4(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                                                  GDT_MPR_IC + GDT_S_INFO));
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_STATUS,
-                      0);
+    protocol = (uint8_t)le32toh(bus_read_4(gdt->sc_dpmem,
+	    GDT_MPR_IC + GDT_S_INFO));
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_STATUS, 0);
     if (protocol != GDT_PROTOCOL_VERSION) {
-        printf("unsupported protocol %d\n", protocol);
+        device_printf(dev, "unsupported protocol %d\n", protocol);
         error = ENXIO;
         goto err;
     }
     
-    /* special commnd to controller BIOS */
-    bus_space_write_4(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_INFO,
-                      htole32(0));
-    bus_space_write_4(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                      GDT_MPR_IC + GDT_S_INFO + sizeof (u_int32_t), htole32(0));
-    bus_space_write_4(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                      GDT_MPR_IC + GDT_S_INFO + 2 * sizeof (u_int32_t),
-                      htole32(1));
-    bus_space_write_4(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                      GDT_MPR_IC + GDT_S_INFO + 3 * sizeof (u_int32_t),
-                      htole32(0));
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_CMD_INDX,
-                      0xfe);
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_LDOOR, 1);
+    /* special command to controller BIOS */
+    bus_write_4(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_INFO, htole32(0));
+    bus_write_4(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_INFO + sizeof (u_int32_t),
+	htole32(0));
+    bus_write_4(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_INFO + 2 * sizeof (u_int32_t),
+	htole32(1));
+    bus_write_4(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_INFO + 3 * sizeof (u_int32_t),
+	htole32(0));
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_CMD_INDX, 0xfe);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_LDOOR, 1);
 
     DELAY(20);
     retries = GDT_RETRIES;
-    while (bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                            GDT_MPR_IC + GDT_S_STATUS) != 0xfe) {
+    while (bus_read_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_STATUS) != 0xfe) {
         if (--retries == 0) {
-            printf("initialization error\n");
+            device_printf(dev, "initialization error\n");
             error = ENXIO;
             goto err;
         }
@@ -304,8 +290,7 @@
         DELAY(1);
     }
 
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_IC + GDT_S_STATUS,
-                      0);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_IC + GDT_S_STATUS, 0);
 
     gdt->sc_ic_all_size = GDT_MPR_SZ;
     
@@ -323,10 +308,10 @@
                            /*highaddr*/BUS_SPACE_MAXADDR,
                            /*filter*/NULL, /*filterarg*/NULL,
                            /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
-                           /*nsegments*/GDT_MAXSG,
+			   /*nsegments*/BUS_SPACE_UNRESTRICTED,
                            /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
 			   /*flags*/0, /*lockfunc*/busdma_lock_mutex,
-			   /*lockarg*/&Giant, &gdt->sc_parent_dmat) != 0) {
+			   /*lockarg*/&gdt->sc_lock, &gdt->sc_parent_dmat) != 0) {
         error = ENXIO;
         goto err;
     }
@@ -342,7 +327,7 @@
     iir_attach(gdt);
 
     /* associate interrupt handler */
-    if (bus_setup_intr( dev, irq, INTR_TYPE_CAM, 
+    if (bus_setup_intr(dev, irq, INTR_TYPE_CAM | INTR_MPSAFE, 
                         NULL, iir_intr, gdt, &ih )) {
         device_printf(dev, "Unable to register interrupt handler\n");
         error = ENXIO;
@@ -355,10 +340,11 @@
 err:
     if (irq)
         bus_release_resource( dev, SYS_RES_IRQ, 0, irq );
-/*
-    if (io)
-        bus_release_resource( dev, SYS_RES_MEMORY, rid, io );
-*/
+
+    if (gdt->sc_dpmem)
+        bus_release_resource( dev, SYS_RES_MEMORY, rid, gdt->sc_dpmem );
+    mtx_destroy(&gdt->sc_lock);
+
     return (error);
 }
 
@@ -371,11 +357,9 @@
 
     switch(GDT_CLASS(gdt)) {
       case GDT_MPR:
-        bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                          GDT_MPR_EDOOR, 0xff);
-        bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_EDOOR_EN,
-                          bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                                           GDT_EDOOR_EN) & ~4);
+        bus_write_1(gdt->sc_dpmem, GDT_MPR_EDOOR, 0xff);
+        bus_write_1(gdt->sc_dpmem, GDT_EDOOR_EN,
+	    bus_read_1(gdt->sc_dpmem, GDT_EDOOR_EN) & ~4);
         break;
     }
 }
@@ -396,15 +380,14 @@
 
     gdt->sc_cmd_off += cp_count;
 
-    bus_space_write_region_4(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                             GDT_MPR_IC + GDT_DPR_CMD + dp_offset, 
-                             (u_int32_t *)gccb->gc_cmd, cp_count >> 2);
-    bus_space_write_2(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                      GDT_MPR_IC + GDT_COMM_QUEUE + cmd_no * GDT_COMM_Q_SZ + GDT_OFFSET,
-                      htole16(GDT_DPMEM_COMMAND_OFFSET + dp_offset));
-    bus_space_write_2(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                      GDT_MPR_IC + GDT_COMM_QUEUE + cmd_no * GDT_COMM_Q_SZ + GDT_SERV_ID,
-                      htole16(gccb->gc_service));
+    bus_write_region_4(gdt->sc_dpmem, GDT_MPR_IC + GDT_DPR_CMD + dp_offset, 
+	(u_int32_t *)gccb->gc_cmd, cp_count >> 2);
+    bus_write_2(gdt->sc_dpmem,
+	GDT_MPR_IC + GDT_COMM_QUEUE + cmd_no * GDT_COMM_Q_SZ + GDT_OFFSET,
+	htole16(GDT_DPMEM_COMMAND_OFFSET + dp_offset));
+    bus_write_2(gdt->sc_dpmem,
+	GDT_MPR_IC + GDT_COMM_QUEUE + cmd_no * GDT_COMM_Q_SZ + GDT_SERV_ID,
+	htole16(gccb->gc_service));
 }
 
 u_int8_t
@@ -412,7 +395,7 @@
 {
     GDT_DPRINTF(GDT_D_MISC, ("gdt_mpr_get_status(%p) ", gdt));
         
-    return bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_EDOOR);
+    return bus_read_1(gdt->sc_dpmem, GDT_MPR_EDOOR);
 }
 
 void
@@ -422,39 +405,32 @@
 
     GDT_DPRINTF(GDT_D_INTR, ("gdt_mpr_intr(%p) ", gdt));
 
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_EDOOR, 0xff);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_EDOOR, 0xff);
 
     if (ctx->istatus & 0x80) {          /* error flag */
         ctx->istatus &= ~0x80;
-        ctx->cmd_status = bus_space_read_2(gdt->sc_dpmemt,
-                                           gdt->sc_dpmemh, GDT_MPR_STATUS);
+        ctx->cmd_status = bus_read_2(gdt->sc_dpmem, GDT_MPR_STATUS);
     } else                                      /* no error */
         ctx->cmd_status = GDT_S_OK;
 
-    ctx->info =
-        bus_space_read_4(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_INFO);
-    ctx->service = 
-        bus_space_read_2(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_SERVICE);
-    ctx->info2 = 
-        bus_space_read_4(gdt->sc_dpmemt, gdt->sc_dpmemh, 
-                         GDT_MPR_INFO + sizeof (u_int32_t));
+    ctx->info = bus_read_4(gdt->sc_dpmem, GDT_MPR_INFO);
+    ctx->service = bus_read_2(gdt->sc_dpmem, GDT_MPR_SERVICE);
+    ctx->info2 = bus_read_4(gdt->sc_dpmem, GDT_MPR_INFO + sizeof (u_int32_t));
 
     /* event string */
     if (ctx->istatus == GDT_ASYNCINDEX) {
         if (ctx->service != GDT_SCREENSERVICE && 
             (gdt->sc_fw_vers & 0xff) >= 0x1a) {
-            gdt->sc_dvr.severity = 
-                bus_space_read_1(gdt->sc_dpmemt,gdt->sc_dpmemh, GDT_SEVERITY);
+            gdt->sc_dvr.severity = bus_read_1(gdt->sc_dpmem, GDT_SEVERITY);
             for (i = 0; i < 256; ++i) {
-                gdt->sc_dvr.event_string[i] = 
-                    bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                                     GDT_EVT_BUF + i);
+                gdt->sc_dvr.event_string[i] = bus_read_1(gdt->sc_dpmem,
+		    GDT_EVT_BUF + i);
                 if (gdt->sc_dvr.event_string[i] == 0)
                     break;
             }
         }
     }
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_SEMA1, 0);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_SEMA1, 0);
 }
 
 void
@@ -462,7 +438,7 @@
 {
     GDT_DPRINTF(GDT_D_MISC, ("gdt_mpr_release_event(%p) ", gdt));
     
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_LDOOR, 1);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_LDOOR, 1);
 }
 
 void
@@ -470,7 +446,7 @@
 {
     GDT_DPRINTF(GDT_D_MISC, ("gdt_mpr_set_sema0(%p) ", gdt));
 
-    bus_space_write_1(gdt->sc_dpmemt, gdt->sc_dpmemh, GDT_MPR_SEMA0, 1);
+    bus_write_1(gdt->sc_dpmem, GDT_MPR_SEMA0, 1);
 }
 
 int
@@ -478,6 +454,5 @@
 {
     GDT_DPRINTF(GDT_D_MISC, ("gdt_mpr_test_busy(%p) ", gdt));
 
-    return (bus_space_read_1(gdt->sc_dpmemt, gdt->sc_dpmemh,
-                             GDT_MPR_SEMA0) & 1);
+    return (bus_read_1(gdt->sc_dpmem, GDT_MPR_SEMA0) & 1);
 }

Modified: trunk/sys/dev/io/iodev.c
===================================================================
--- trunk/sys/dev/io/iodev.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/io/iodev.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Mark R V Murray
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/io/iodev.c 207329 2010-04-28 15:38:01Z attilio $");
 
 #include <sys/param.h>
 #include <sys/conf.h>

Modified: trunk/sys/dev/io/iodev.h
===================================================================
--- trunk/sys/dev/io/iodev.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/io/iodev.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Marcel Moolenaar
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/io/iodev.h 207329 2010-04-28 15:38:01Z attilio $
  */
 
 #ifndef _DEV_IODEV_H_

Modified: trunk/sys/dev/ipmi/ipmi.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi.c 297574 2016-04-05 06:37:58Z mav $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -49,6 +50,23 @@
 #include <dev/ipmi/ipmivars.h>
 #endif
 
+/*
+ * Driver request structures are allocated on the stack via alloca() to
+ * avoid calling malloc(), especially for the watchdog handler.
+ * To avoid too much stack growth, a previously allocated structure can
+ * be reused via IPMI_INIT_DRIVER_REQUEST(), but the caller should ensure
+ * that there is adequate reply/request space in the original allocation.
+ */
+#define	IPMI_INIT_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen)	\
+	bzero((req), sizeof(struct ipmi_request));			\
+	ipmi_init_request((req), NULL, 0, (addr), (cmd), (reqlen), (replylen))
+
+#define	IPMI_ALLOC_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen)	\
+	(req) = __builtin_alloca(sizeof(struct ipmi_request) +		\
+	    (reqlen) + (replylen));					\
+	IPMI_INIT_DRIVER_REQUEST((req), (addr), (cmd), (reqlen),	\
+	    (replylen))
+
 #ifdef IPMB
 static int ipmi_ipmb_checksum(u_char, int);
 static int ipmi_ipmb_send_message(device_t, u_char, u_char, u_char,
@@ -181,8 +199,8 @@
 		 */
 		dev->ipmi_closing = 1;
 		while (dev->ipmi_requests > 0) {
-			msleep(&dev->ipmi_requests, &sc->ipmi_lock, PWAIT,
-			    "ipmidrain", 0);
+			msleep(&dev->ipmi_requests, &sc->ipmi_requests_lock,
+			    PWAIT, "ipmidrain", 0);
 			ipmi_purge_completed_requests(dev);
 		}
 	}
@@ -215,7 +233,7 @@
 	u_char slave_addr = 0x52;
 	int error;
 
-	req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+	IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 	    IPMI_SEND_MSG, data_len + 8, 0);
 	req->ir_request[0] = channel;
 	req->ir_request[1] = slave_addr;
@@ -231,7 +249,6 @@
 
 	ipmi_submit_driver_request(sc, req);
 	error = req->ir_error;
-	ipmi_free_request(req);
 
 	return (error);
 }
@@ -243,7 +260,7 @@
 	int error;
 
 	device_printf(sc->ipmi_dev, "BMC has a message\n");
-	req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+	IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 	    IPMI_GET_MSG_FLAGS, 0, 1);
 
 	ipmi_submit_driver_request(sc, req);
@@ -257,9 +274,7 @@
 			    "watchdog about to go off");
 		}
 		if (req->ir_reply[0] & IPMI_MSG_AVAILABLE) {
-			ipmi_free_request(req);
-
-			req = ipmi_alloc_driver_request(
+			IPMI_ALLOC_DRIVER_REQUEST(req,
 			    IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_MSG, 0,
 			    16);
 
@@ -268,7 +283,6 @@
 		}
 	}
 	error = req->ir_error;
-	ipmi_free_request(req);
 
 	return (error);
 }
@@ -478,15 +492,11 @@
  * Request management.
  */
 
-/* Allocate a new request with request and reply buffers. */
-struct ipmi_request *
-ipmi_alloc_request(struct ipmi_device *dev, long msgid, uint8_t addr,
-    uint8_t command, size_t requestlen, size_t replylen)
+static __inline void
+ipmi_init_request(struct ipmi_request *req, struct ipmi_device *dev, long msgid,
+    uint8_t addr, uint8_t command, size_t requestlen, size_t replylen)
 {
-	struct ipmi_request *req;
 
-	req = malloc(sizeof(struct ipmi_request) + requestlen + replylen,
-	    M_IPMI, M_WAITOK | M_ZERO);
 	req->ir_owner = dev;
 	req->ir_msgid = msgid;
 	req->ir_addr = addr;
@@ -499,6 +509,18 @@
 		req->ir_reply = (char *)&req[1] + requestlen;
 		req->ir_replybuflen = replylen;
 	}
+}
+
+/* Allocate a new request with request and reply buffers. */
+struct ipmi_request *
+ipmi_alloc_request(struct ipmi_device *dev, long msgid, uint8_t addr,
+    uint8_t command, size_t requestlen, size_t replylen)
+{
+	struct ipmi_request *req;
+
+	req = malloc(sizeof(struct ipmi_request) + requestlen + replylen,
+	    M_IPMI, M_WAITOK | M_ZERO);
+	ipmi_init_request(req, dev, msgid, addr, command, requestlen, replylen);
 	return (req);
 }
 
@@ -533,21 +555,13 @@
 	}
 }
 
-/* Enqueue an internal driver request and wait until it is completed. */
+/* Perform an internal driver request. */
 int
 ipmi_submit_driver_request(struct ipmi_softc *sc, struct ipmi_request *req,
     int timo)
 {
-	int error;
 
-	IPMI_LOCK(sc);
-	error = sc->ipmi_enqueue_request(sc, req);
-	if (error == 0)
-		error = msleep(req, &sc->ipmi_lock, 0, "ipmireq", timo);
-	if (error == 0)
-		error = req->ir_error;
-	IPMI_UNLOCK(sc);
-	return (error);
+	return (sc->ipmi_driver_request(sc, req, timo));
 }
 
 /*
@@ -564,7 +578,7 @@
 	IPMI_LOCK_ASSERT(sc);
 
 	while (!sc->ipmi_detaching && TAILQ_EMPTY(&sc->ipmi_pending_requests))
-		cv_wait(&sc->ipmi_request_added, &sc->ipmi_lock);
+		cv_wait(&sc->ipmi_request_added, &sc->ipmi_requests_lock);
 	if (sc->ipmi_detaching)
 		return (NULL);
 
@@ -590,6 +604,20 @@
  */
 
 static int
+ipmi_reset_watchdog(struct ipmi_softc *sc)
+{
+	struct ipmi_request *req;
+	int error;
+
+	IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
+	    IPMI_RESET_WDOG, 0, 0);
+	error = ipmi_submit_driver_request(sc, req, 0);
+	if (error)
+		device_printf(sc->ipmi_dev, "Failed to reset watchdog\n");
+	return (error);
+}
+
+static int
 ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec)
 {
 	struct ipmi_request *req;
@@ -598,9 +626,8 @@
 	if (sec > 0xffff / 10)
 		return (EINVAL);
 
-	req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+	IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 	    IPMI_SET_WDOG, 6, 0);
-
 	if (sec) {
 		req->ir_request[0] = IPMI_SET_WD_TIMER_DONT_STOP
 		    | IPMI_SET_WD_TIMER_SMS_OS;
@@ -617,27 +644,10 @@
 		req->ir_request[4] = 0;
 		req->ir_request[5] = 0;
 	}
-
 	error = ipmi_submit_driver_request(sc, req, 0);
 	if (error)
 		device_printf(sc->ipmi_dev, "Failed to set watchdog\n");
-	else if (sec) {
-		ipmi_free_request(req);
-
-		req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
-		    IPMI_RESET_WDOG, 0, 0);
-
-		error = ipmi_submit_driver_request(sc, req, 0);
-		if (error)
-			device_printf(sc->ipmi_dev,
-			    "Failed to reset watchdog\n");
-	}
-
-	ipmi_free_request(req);
 	return (error);
-	/*
-	dump_watchdog(sc);
-	*/
 }
 
 static void
@@ -647,17 +657,32 @@
 	unsigned int timeout;
 	int e;
 
+	if (dumping)
+		return;
+
 	cmd &= WD_INTERVAL;
 	if (cmd > 0 && cmd <= 63) {
 		timeout = ((uint64_t)1 << cmd) / 1000000000;
 		if (timeout == 0)
 			timeout = 1;
-		e = ipmi_set_watchdog(sc, timeout);
-		if (e == 0) {
-			*error = 0;
-			sc->ipmi_watchdog_active = 1;
-		} else
-			(void)ipmi_set_watchdog(sc, 0);
+		if (timeout != sc->ipmi_watchdog_active) {
+			e = ipmi_set_watchdog(sc, timeout);
+			if (e == 0) {
+				sc->ipmi_watchdog_active = timeout;
+			} else {
+				(void)ipmi_set_watchdog(sc, 0);
+				sc->ipmi_watchdog_active = 0;
+			}
+		}
+		if (sc->ipmi_watchdog_active != 0) {
+			e = ipmi_reset_watchdog(sc);
+			if (e == 0) {
+				*error = 0;
+			} else {
+				(void)ipmi_set_watchdog(sc, 0);
+				sc->ipmi_watchdog_active = 0;
+			}
+		}
 	} else if (atomic_readandclear_int(&sc->ipmi_watchdog_active) != 0) {
 		e = ipmi_set_watchdog(sc, 0);
 		if (e != 0 && cmd == 0)
@@ -677,7 +702,8 @@
 	dev = sc->ipmi_dev;
 
 	/* Initialize interface-independent state. */
-	mtx_init(&sc->ipmi_lock, device_get_nameunit(dev), "ipmi", MTX_DEF);
+	mtx_init(&sc->ipmi_requests_lock, "ipmi requests", NULL, MTX_DEF);
+	mtx_init(&sc->ipmi_io_lock, "ipmi io", NULL, MTX_DEF);
 	cv_init(&sc->ipmi_request_added, "ipmireq");
 	TAILQ_INIT(&sc->ipmi_pending_requests);
 
@@ -690,28 +716,24 @@
 	}
 
 	/* Send a GET_DEVICE_ID request. */
-	req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+	IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 	    IPMI_GET_DEVICE_ID, 0, 15);
 
 	error = ipmi_submit_driver_request(sc, req, MAX_TIMEOUT);
 	if (error == EWOULDBLOCK) {
 		device_printf(dev, "Timed out waiting for GET_DEVICE_ID\n");
-		ipmi_free_request(req);
 		return;
 	} else if (error) {
 		device_printf(dev, "Failed GET_DEVICE_ID: %d\n", error);
-		ipmi_free_request(req);
 		return;
 	} else if (req->ir_compcode != 0) {
 		device_printf(dev,
 		    "Bad completion code for GET_DEVICE_ID: %d\n",
 		    req->ir_compcode);
-		ipmi_free_request(req);
 		return;
 	} else if (req->ir_replylen < 5) {
 		device_printf(dev, "Short reply for GET_DEVICE_ID: %d\n",
 		    req->ir_replylen);
-		ipmi_free_request(req);
 		return;
 	}
 
@@ -721,9 +743,7 @@
 	     req->ir_reply[2] & 0x7f, req->ir_reply[3] >> 4, req->ir_reply[3] & 0x0f,
 	     req->ir_reply[4] & 0x0f, req->ir_reply[4] >> 4);
 
-	ipmi_free_request(req);
-
-	req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+	IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 	    IPMI_CLEAR_FLAGS, 1, 0);
 
 	ipmi_submit_driver_request(sc, req, 0);
@@ -735,36 +755,36 @@
 	if (req->ir_compcode == 0xc1) {
 		device_printf(dev, "Clear flags illegal\n");
 	}
-	ipmi_free_request(req);
 
 	for (i = 0; i < 8; i++) {
-		req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+		IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
 		    IPMI_GET_CHANNEL_INFO, 1, 0);
 		req->ir_request[0] = i;
 
 		ipmi_submit_driver_request(sc, req, 0);
 
-		if (req->ir_compcode != 0) {
-			ipmi_free_request(req);
+		if (req->ir_compcode != 0)
 			break;
-		}
-		ipmi_free_request(req);
 	}
 	device_printf(dev, "Number of channels %d\n", i);
 
-	/* probe for watchdog */
-	req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
-	    IPMI_GET_WDOG, 0, 0);
+	/*
+	 * Probe for watchdog, but only for backends which support
+	 * polled driver requests.
+	 */
+	if (sc->ipmi_driver_requests_polled) {
+		IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
+		    IPMI_GET_WDOG, 0, 0);
 
-	ipmi_submit_driver_request(sc, req, 0);
+		ipmi_submit_driver_request(sc, req, 0);
 
-	if (req->ir_compcode == 0x00) {
-		device_printf(dev, "Attached watchdog\n");
-		/* register the watchdog event handler */
-		sc->ipmi_watchdog_tag = EVENTHANDLER_REGISTER(watchdog_list,
-		    ipmi_wd_event, sc, 0);
+		if (req->ir_compcode == 0x00) {
+			device_printf(dev, "Attached watchdog\n");
+			/* register the watchdog event handler */
+			sc->ipmi_watchdog_tag = EVENTHANDLER_REGISTER(
+			    watchdog_list, ipmi_wd_event, sc, 0);
+		}
 	}
-	ipmi_free_request(req);
 
 	sc->ipmi_cdev = make_dev(&ipmi_cdevsw, device_get_unit(dev),
 	    UID_ROOT, GID_OPERATOR, 0660, "ipmi%d", device_get_unit(dev));
@@ -831,7 +851,8 @@
 	sc->ipmi_detaching = 1;
 	if (sc->ipmi_kthread) {
 		cv_broadcast(&sc->ipmi_request_added);
-		msleep(sc->ipmi_kthread, &sc->ipmi_lock, 0, "ipmi_wait", 0);
+		msleep(sc->ipmi_kthread, &sc->ipmi_requests_lock, 0,
+		    "ipmi_wait", 0);
 	}
 	IPMI_UNLOCK(sc);
 	if (sc->ipmi_irq)
@@ -838,7 +859,8 @@
 		bus_teardown_intr(dev, sc->ipmi_irq_res, sc->ipmi_irq);
 
 	ipmi_release_resources(dev);
-	mtx_destroy(&sc->ipmi_lock);
+	mtx_destroy(&sc->ipmi_io_lock);
+	mtx_destroy(&sc->ipmi_requests_lock);
 	return (0);
 }
 

Modified: trunk/sys/dev/ipmi/ipmi_acpi.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_acpi.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_acpi.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_acpi.c 193530 2009-06-05 18:44:36Z jkim $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/ipmi/ipmi_isa.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_isa.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_isa.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_isa.c 253813 2013-07-30 18:54:24Z sbruno $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -78,6 +79,14 @@
 ipmi_isa_probe(device_t dev)
 {
 
+	/*
+	 * Give other drivers precedence.  Unfortunately, this doesn't
+	 * work if we have an SMBIOS table that duplicates a PCI device
+	 * that's later on the bus than the PCI-ISA bridge.
+	 */
+	if (ipmi_attached)
+		return (ENXIO);
+
 	/* Skip any PNP devices. */
 	if (isa_get_logicalid(dev) != 0)
 		return (ENXIO);
@@ -175,14 +184,6 @@
 	    !ipmi_hint_identify(dev, &info))
 		return (ENXIO);
 
-	/*
-	 * Give other drivers precedence.  Unfortunately, this doesn't
-	 * work if we have an SMBIOS table that duplicates a PCI device
-	 * that's later on the bus than the PCI-ISA bridge.
-	 */
-	if (ipmi_attached)
-		return (EBUSY);
-
 	switch (info.iface_type) {
 	case KCS_MODE:
 		count = 2;

Modified: trunk/sys/dev/ipmi/ipmi_kcs.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_kcs.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_kcs.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_kcs.c 287435 2015-09-03 16:43:35Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -184,6 +185,8 @@
 	for (retry = 0; retry < 10; retry++) {
 		/* Wait for IBF = 0 */
 		status = kcs_wait_for_ibf(sc, 0);
+		if (status & KCS_STATUS_IBF)
+			return (0);
 
 		/* Clear OBF */
 		kcs_clear_obf(sc, status);
@@ -193,6 +196,9 @@
 
 		/* Wait for IBF = 0 */
 		status = kcs_wait_for_ibf(sc, 0);
+		if (status & KCS_STATUS_IBF)
+			return (0);
+
 		if (KCS_STATUS_STATE(status) == KCS_STATUS_STATE_WRITE)
 			break;
 		DELAY(1000000);
@@ -222,6 +228,8 @@
 
 	/* Wait for IBF = 0 */
 	status = kcs_wait_for_ibf(sc, 0);
+	if (status & KCS_STATUS_IBF)
+		return (0);
 
 	if (KCS_STATUS_STATE(status) != KCS_STATUS_STATE_WRITE)
 		return (0);
@@ -244,6 +252,8 @@
 
 	/* Wait for IBF = 0 */
 	status = kcs_wait_for_ibf(sc, 0);
+	if (status & KCS_STATUS_IBF)
+		return (0);
 
 	if (KCS_STATUS_STATE(status) != KCS_STATUS_STATE_WRITE)
 		/* error state */
@@ -274,6 +284,8 @@
 
 		/* Wait for OBF = 1 */
 		status = kcs_wait_for_obf(sc, 1);
+		if ((status & KCS_STATUS_OBF) == 0)
+			return (0);
 
 		/* Read Data_out */
 		*data = INB(sc, KCS_DATA);
@@ -288,6 +300,8 @@
 
 		/* Wait for OBF = 1*/
 		status = kcs_wait_for_obf(sc, 1);
+		if ((status & KCS_STATUS_OBF) == 0)
+			return (0);
 
 		/* Read Dummy */
 		dummy = INB(sc, KCS_DATA);
@@ -308,6 +322,8 @@
 	u_char *cp, data;
 	int i, state;
 
+	IPMI_IO_LOCK(sc);
+
 	/* Send the request. */
 	if (!kcs_start_write(sc)) {
 		device_printf(sc->ipmi_dev, "KCS: Failed to start write\n");
@@ -431,6 +447,7 @@
 		}
 		i++;
 	}
+	IPMI_IO_UNLOCK(sc);
 	req->ir_replylen = i;
 #ifdef KCS_DEBUG
 	device_printf(sc->ipmi_dev, "KCS: READ finished (%d bytes)\n", i);
@@ -444,6 +461,7 @@
 	return (1);
 fail:
 	kcs_error(sc);
+	IPMI_IO_UNLOCK(sc);
 	return (0);
 }
 
@@ -456,6 +474,7 @@
 
 	IPMI_LOCK(sc);
 	while ((req = ipmi_dequeue_request(sc)) != NULL) {
+		IPMI_UNLOCK(sc);
 		ok = 0;
 		for (i = 0; i < 3 && !ok; i++)
 			ok = kcs_polled_request(sc, req);
@@ -463,6 +482,7 @@
 			req->ir_error = 0;
 		else
 			req->ir_error = EIO;
+		IPMI_LOCK(sc);
 		ipmi_complete_request(sc, req);
 	}
 	IPMI_UNLOCK(sc);
@@ -477,6 +497,21 @@
 	    device_get_nameunit(sc->ipmi_dev)));
 }
 
+static int
+kcs_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo)
+{
+	int i, ok;
+
+	ok = 0;
+	for (i = 0; i < 3 && !ok; i++)
+		ok = kcs_polled_request(sc, req);
+	if (ok)
+		req->ir_error = 0;
+	else
+		req->ir_error = EIO;
+	return (req->ir_error);
+}
+
 int
 ipmi_kcs_attach(struct ipmi_softc *sc)
 {
@@ -485,6 +520,8 @@
 	/* Setup function pointers. */
 	sc->ipmi_startup = kcs_startup;
 	sc->ipmi_enqueue_request = ipmi_polled_enqueue_request;
+	sc->ipmi_driver_request = kcs_driver_request;
+	sc->ipmi_driver_requests_polled = 1;
 
 	/* See if we can talk to the controller. */
 	status = INB(sc, KCS_CTL_STS);

Modified: trunk/sys/dev/ipmi/ipmi_linux.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_linux.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_linux.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_linux.c 280258 2015-03-19 13:37:36Z rwatson $");
 
 /*
  * Linux ioctl handler for the ipmi device driver
@@ -33,7 +34,7 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/capability.h>
+#include <sys/capsicum.h>
 #include <sys/conf.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
@@ -89,11 +90,13 @@
 static int
 ipmi_linux_ioctl(struct thread *td, struct linux_ioctl_args *args)
 {
+	cap_rights_t rights;
 	struct file *fp;
 	u_long cmd;
 	int error;
 
-	if ((error = fget(td, args->fd, CAP_IOCTL, &fp)) != 0)
+	error = fget(td, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp);
+	if (error != 0)
 		return (error);
 	cmd = args->cmd;
 

Modified: trunk/sys/dev/ipmi/ipmi_pci.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_pci.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_pci.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_pci.c 168162 2007-03-31 21:39:02Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/ipmi/ipmi_smbios.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_smbios.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_smbios.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_smbios.c 241027 2012-09-28 11:59:32Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/ipmi/ipmi_smbus.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_smbus.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_smbus.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_smbus.c 162562 2006-09-22 22:11:29Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/ipmi/ipmi_smic.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_smic.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_smic.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_smic.c 287435 2015-09-03 16:43:35Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -362,13 +363,18 @@
 
 	IPMI_LOCK(sc);
 	while ((req = ipmi_dequeue_request(sc)) != NULL) {
+		IPMI_UNLOCK(sc);
 		ok = 0;
-		for (i = 0; i < 3 && !ok; i++)
+		for (i = 0; i < 3 && !ok; i++) {
+			IPMI_IO_LOCK(sc);
 			ok = smic_polled_request(sc, req);
+			IPMI_IO_UNLOCK(sc);
+		}
 		if (ok)
 			req->ir_error = 0;
 		else
 			req->ir_error = EIO;
+		IPMI_LOCK(sc);
 		ipmi_complete_request(sc, req);
 	}
 	IPMI_UNLOCK(sc);
@@ -383,6 +389,24 @@
 	    "%s: smic", device_get_nameunit(sc->ipmi_dev)));
 }
 
+static int
+smic_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo)
+{
+	int i, ok;
+
+	ok = 0;
+	for (i = 0; i < 3 && !ok; i++) {
+		IPMI_IO_LOCK(sc);
+		ok = smic_polled_request(sc, req);
+		IPMI_IO_UNLOCK(sc);
+	}
+	if (ok)
+		req->ir_error = 0;
+	else
+		req->ir_error = EIO;
+	return (req->ir_error);
+}
+
 int
 ipmi_smic_attach(struct ipmi_softc *sc)
 {
@@ -391,6 +415,8 @@
 	/* Setup function pointers. */
 	sc->ipmi_startup = smic_startup;
 	sc->ipmi_enqueue_request = ipmi_polled_enqueue_request;
+	sc->ipmi_driver_request = smic_driver_request;
+	sc->ipmi_driver_requests_polled = 1;
 
 	/* See if we can talk to the controller. */
 	flags = INB(sc, SMIC_FLAGS);

Modified: trunk/sys/dev/ipmi/ipmi_ssif.c
===================================================================
--- trunk/sys/dev/ipmi/ipmi_ssif.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmi_ssif.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipmi/ipmi_ssif.c 278872 2015-02-16 22:33:44Z scottl $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -359,6 +360,22 @@
 	    "%s: ssif", device_get_nameunit(sc->ipmi_dev)));
 }
 
+static int
+ssif_driver_request(struct ipmi_softc *sc, struct ipmi_request *req, int timo)
+{
+	int error;
+
+	IPMI_LOCK(sc);
+	error = ipmi_polled_enqueue_request(sc, req);
+	if (error == 0)
+		error = msleep(req, &sc->ipmi_requests_lock, 0, "ipmireq",
+		    timo);
+	if (error == 0)
+		error = req->ir_error;
+	IPMI_UNLOCK(sc);
+	return (error);
+}
+
 int
 ipmi_ssif_attach(struct ipmi_softc *sc, device_t smbus, int smbus_address)
 {
@@ -370,6 +387,7 @@
 	/* Setup function pointers. */
 	sc->ipmi_startup = ssif_startup;
 	sc->ipmi_enqueue_request = ipmi_polled_enqueue_request;
+	sc->ipmi_driver_request = ssif_driver_request;
 
 	return (0);
 }

Modified: trunk/sys/dev/ipmi/ipmivars.h
===================================================================
--- trunk/sys/dev/ipmi/ipmivars.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipmi/ipmivars.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ipmi/ipmivars.h 287435 2015-09-03 16:43:35Z jhb $
  */
 
 #ifndef __IPMIVARS_H__
@@ -95,6 +96,7 @@
 	} _iface;
 	int			ipmi_io_rid;
 	int			ipmi_io_type;
+	struct mtx		ipmi_io_lock;
 	struct resource		*ipmi_io_res[MAX_RES];
 	int			ipmi_io_spacing;
 	int			ipmi_irq_rid;
@@ -104,15 +106,17 @@
 	int			ipmi_opened;
 	struct cdev		*ipmi_cdev;
 	TAILQ_HEAD(,ipmi_request) ipmi_pending_requests;
+	int			ipmi_driver_requests_polled;
 	eventhandler_tag	ipmi_watchdog_tag;
 	int			ipmi_watchdog_active;
 	struct intr_config_hook	ipmi_ich;
-	struct mtx		ipmi_lock;
+	struct mtx		ipmi_requests_lock;
 	struct cv		ipmi_request_added;
 	struct proc		*ipmi_kthread;
 	driver_intr_t		*ipmi_intr;
 	int			(*ipmi_startup)(struct ipmi_softc *);
 	int			(*ipmi_enqueue_request)(struct ipmi_softc *, struct ipmi_request *);
+	int			(*ipmi_driver_request)(struct ipmi_softc *, struct ipmi_request *, int);
 };
 
 #define	ipmi_ssif_smbus_address		_iface.ssif.smbus_address
@@ -183,12 +187,13 @@
 #define	IPMI_ADDR(netfn, lun)		((netfn) << 2 | (lun))
 #define	IPMI_REPLY_ADDR(addr)		((addr) + 0x4)
 
-#define	IPMI_LOCK(sc)			mtx_lock(&(sc)->ipmi_lock)
-#define	IPMI_UNLOCK(sc)			mtx_unlock(&(sc)->ipmi_lock)
-#define	IPMI_LOCK_ASSERT(sc)		mtx_assert(&(sc)->ipmi_lock, MA_OWNED)
+#define	IPMI_LOCK(sc)		mtx_lock(&(sc)->ipmi_requests_lock)
+#define	IPMI_UNLOCK(sc)		mtx_unlock(&(sc)->ipmi_requests_lock)
+#define	IPMI_LOCK_ASSERT(sc)	mtx_assert(&(sc)->ipmi_requests_lock, MA_OWNED)
 
-#define	ipmi_alloc_driver_request(addr, cmd, reqlen, replylen)		\
-	ipmi_alloc_request(NULL, 0, (addr), (cmd), (reqlen), (replylen))
+#define	IPMI_IO_LOCK(sc)	mtx_lock(&(sc)->ipmi_io_lock)
+#define	IPMI_IO_UNLOCK(sc)	mtx_unlock(&(sc)->ipmi_io_lock)
+#define	IPMI_IO_LOCK_ASSERT(sc)	mtx_assert(&(sc)->ipmi_io_lock, MA_OWNED)
 
 #if __FreeBSD_version < 601105
 #define bus_read_1(r, o) \
@@ -219,7 +224,7 @@
 	((sc)->ipmi_io_res[1] != NULL ? OUTB_MULTIPLE(sc, x, value) :	\
 	    OUTB_SINGLE(sc, x, value))
 
-#define MAX_TIMEOUT 3 * hz
+#define MAX_TIMEOUT 6 * hz
 
 int	ipmi_attach(device_t);
 int	ipmi_detach(device_t);

Modified: trunk/sys/dev/ips/ips.c
===================================================================
--- trunk/sys/dev/ips/ips.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Written by: David Jeffery
  * Copyright (c) 2002 Adaptec Inc.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ips/ips.c 249595 2013-04-17 21:21:27Z hiren $");
 
 #include <dev/ips/ipsreg.h>
 #include <dev/ips/ips.h>
@@ -578,7 +579,7 @@
 {
 	int error;
 	bus_dma_tag_t dmatag;
-	bus_dmamap_t dmamap = NULL;
+	bus_dmamap_t dmamap;
        	if (bus_dma_tag_create(	/* parent    */	sc->adapter_dmatag,
 				/* alignemnt */	1,
 				/* boundary  */	0,
@@ -595,7 +596,7 @@
 				&dmatag) != 0) {
                 device_printf(sc->dev, "can't alloc dma tag for statue queue\n");
 		error = ENOMEM;
-		goto exit;
+		return error;
         }
 	if(bus_dmamem_alloc(dmatag, (void *)&(sc->copper_queue), 
 	   		    BUS_DMA_NOWAIT, &dmamap)){
@@ -623,7 +624,8 @@
 	
 	return 0;
 exit:
-	bus_dmamem_free(dmatag, sc->copper_queue, dmamap);
+	if (sc->copper_queue != NULL)
+		bus_dmamem_free(dmatag, sc->copper_queue, dmamap);
 	bus_dma_tag_destroy(dmatag);
 	return error;
 }

Modified: trunk/sys/dev/ips/ips.h
===================================================================
--- trunk/sys/dev/ips/ips.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ips/ips.h 161425 2006-08-17 22:50:33Z imp $
  */
 #ifndef _IPS_H
 #define _IPS_H

Modified: trunk/sys/dev/ips/ips_commands.c
===================================================================
--- trunk/sys/dev/ips/ips_commands.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips_commands.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Written by: David Jeffery
  * Copyright (c) 2002 Adaptec Inc.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ips/ips_commands.c 152919 2005-11-29 09:39:41Z scottl $");
 
 #include <dev/ips/ipsreg.h>
 #include <dev/ips/ips.h>

Modified: trunk/sys/dev/ips/ips_disk.c
===================================================================
--- trunk/sys/dev/ips/ips_disk.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips_disk.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Written by: David Jeffery
  * Copyright (c) 2002 Adaptec Inc.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ips/ips_disk.c 198329 2009-10-21 15:04:50Z brueffer $");
 
 #include <dev/ips/ipsreg.h>
 #include <dev/ips/ips.h>

Modified: trunk/sys/dev/ips/ips_disk.h
===================================================================
--- trunk/sys/dev/ips/ips_disk.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips_disk.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ips/ips_disk.h 146734 2005-05-29 04:42:30Z nyan $
  */
 
 

Modified: trunk/sys/dev/ips/ips_ioctl.c
===================================================================
--- trunk/sys/dev/ips/ips_ioctl.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips_ioctl.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Written by: David Jeffery
  * Copyright (c) 2002 Adaptec Inc.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ips/ips_ioctl.c 152919 2005-11-29 09:39:41Z scottl $");
 
 #include <dev/ips/ipsreg.h>
 #include <dev/ips/ips.h>

Modified: trunk/sys/dev/ips/ips_ioctl.h
===================================================================
--- trunk/sys/dev/ips/ips_ioctl.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips_ioctl.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ips/ips_ioctl.h 154006 2006-01-03 23:03:39Z scottl $
  */
 
 #ifndef _IPS_IOCTL_H

Modified: trunk/sys/dev/ips/ips_pci.c
===================================================================
--- trunk/sys/dev/ips/ips_pci.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ips_pci.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
@@ -27,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ips/ips_pci.c 254263 2013-08-12 23:30:01Z scottl $");
 
 #include <dev/ips/ipsreg.h>
 #include <dev/ips/ips.h>

Modified: trunk/sys/dev/ips/ipsreg.h
===================================================================
--- trunk/sys/dev/ips/ipsreg.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ips/ipsreg.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Adaptec Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/ips/ipsreg.h 163024 2006-10-05 07:28:43Z maxim $
  */
 
 #include <sys/param.h>

Modified: trunk/sys/dev/ipw/if_ipw.c
===================================================================
--- trunk/sys/dev/ipw/if_ipw.c	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipw/if_ipw.c	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/ipw/if_ipw.c 262007 2014-02-17 01:36:53Z kevlo $	*/
 
 /*-
  * Copyright (c) 2004-2006
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ipw/if_ipw.c 262007 2014-02-17 01:36:53Z kevlo $");
 
 /*-
  * Intel(R) PRO/Wireless 2100 MiniPCI driver
@@ -1604,7 +1605,7 @@
 
 	wh = mtod(m0, struct ieee80211_frame *);
 
-	if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
+	if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
 		k = ieee80211_crypto_encap(ni, m0);
 		if (k == NULL) {
 			m_freem(m0);
@@ -1628,7 +1629,7 @@
 
 	shdr->hdr.type = htole32(IPW_HDR_TYPE_SEND);
 	shdr->hdr.subtype = 0;
-	shdr->hdr.encrypted = (wh->i_fc[1] & IEEE80211_FC1_WEP) ? 1 : 0;
+	shdr->hdr.encrypted = (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) ? 1 : 0;
 	shdr->hdr.encrypt = 0;
 	shdr->hdr.keyidx = 0;
 	shdr->hdr.keysz = 0;

Modified: trunk/sys/dev/ipw/if_ipwreg.h
===================================================================
--- trunk/sys/dev/ipw/if_ipwreg.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipw/if_ipwreg.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,4 +1,5 @@
-/*      $MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*      $FreeBSD: stable/10/sys/dev/ipw/if_ipwreg.h 172567 2007-10-12 05:23:00Z thompsa $	*/
 
 /*-
  * Copyright (c) 2004-2006

Modified: trunk/sys/dev/ipw/if_ipwvar.h
===================================================================
--- trunk/sys/dev/ipw/if_ipwvar.h	2018-05-27 23:40:39 UTC (rev 10102)
+++ trunk/sys/dev/ipw/if_ipwvar.h	2018-05-27 23:44:07 UTC (rev 10103)
@@ -1,4 +1,5 @@
-/*      $MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*      $FreeBSD: stable/10/sys/dev/ipw/if_ipwvar.h 232874 2012-03-12 18:15:08Z scottl $	*/
 
 /*-
  * Copyright (c) 2004-2006



More information about the Midnightbsd-cvs mailing list