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

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


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

Modified Paths:
--------------
    trunk/sys/dev/adb/adb.h
    trunk/sys/dev/adb/adb_bus.c
    trunk/sys/dev/adb/adb_buttons.c
    trunk/sys/dev/adb/adb_hb_if.m
    trunk/sys/dev/adb/adb_if.m
    trunk/sys/dev/adb/adb_kbd.c
    trunk/sys/dev/adb/adb_mouse.c
    trunk/sys/dev/adb/adbvar.h
    trunk/sys/dev/adlink/adlink.c
    trunk/sys/dev/advansys/adv_eisa.c
    trunk/sys/dev/advansys/adv_isa.c
    trunk/sys/dev/advansys/adv_pci.c
    trunk/sys/dev/advansys/advansys.c
    trunk/sys/dev/advansys/advansys.h
    trunk/sys/dev/advansys/advlib.c
    trunk/sys/dev/advansys/advlib.h
    trunk/sys/dev/advansys/advmcode.c
    trunk/sys/dev/advansys/advmcode.h
    trunk/sys/dev/advansys/adw_pci.c
    trunk/sys/dev/advansys/adwcam.c
    trunk/sys/dev/advansys/adwlib.c
    trunk/sys/dev/advansys/adwlib.h
    trunk/sys/dev/advansys/adwmcode.c
    trunk/sys/dev/advansys/adwmcode.h
    trunk/sys/dev/advansys/adwvar.h
    trunk/sys/dev/ae/if_ae.c
    trunk/sys/dev/ae/if_aereg.h
    trunk/sys/dev/ae/if_aevar.h
    trunk/sys/dev/agp/agp.c
    trunk/sys/dev/agp/agp_ali.c
    trunk/sys/dev/agp/agp_amd.c
    trunk/sys/dev/agp/agp_amd64.c
    trunk/sys/dev/agp/agp_apple.c
    trunk/sys/dev/agp/agp_ati.c
    trunk/sys/dev/agp/agp_i810.c
    trunk/sys/dev/agp/agp_i810.h
    trunk/sys/dev/agp/agp_if.m
    trunk/sys/dev/agp/agp_intel.c
    trunk/sys/dev/agp/agp_nvidia.c
    trunk/sys/dev/agp/agp_sis.c
    trunk/sys/dev/agp/agp_via.c
    trunk/sys/dev/agp/agppriv.h
    trunk/sys/dev/agp/agpreg.h
    trunk/sys/dev/agp/agpvar.h

Property Changed:
----------------
    trunk/sys/dev/adb/adb_hb_if.m
    trunk/sys/dev/adb/adb_if.m
    trunk/sys/dev/agp/agp_if.m

Modified: trunk/sys/dev/adb/adb.h
===================================================================
--- trunk/sys/dev/adb/adb.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (C) 2008 Nathan Whitehorn
  * All rights reserved.
@@ -22,7 +23,7 @@
  * 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/adb/adb.h 199888 2009-11-28 17:48:25Z nwhitehorn $
  */
 
 #ifndef	_POWERPC_ADB_H_

Modified: trunk/sys/dev/adb/adb_bus.c
===================================================================
--- trunk/sys/dev/adb/adb_bus.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb_bus.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (C) 2008 Nathan Whitehorn
  * All rights reserved.
@@ -22,7 +23,7 @@
  * 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/adb/adb_bus.c 199888 2009-11-28 17:48:25Z nwhitehorn $
  */
 
 #include <sys/cdefs.h>

Modified: trunk/sys/dev/adb/adb_buttons.c
===================================================================
--- trunk/sys/dev/adb/adb_buttons.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb_buttons.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011, Justin Hibbits.
  * Copyright (c) 2002, Miodrag Vallat.
@@ -28,7 +29,7 @@
  * OpenBSD: abtn.c,v 1.12 2009/01/10 18:00:59 robert Exp
  * NetBSD: abtn.c,v 1.1 1999/07/12 17:48:26 tsubai Exp
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/adb/adb_buttons.c 226449 2011-10-16 21:01:42Z nwhitehorn $
  */
 
 #include <sys/param.h>

Modified: trunk/sys/dev/adb/adb_hb_if.m
===================================================================
--- trunk/sys/dev/adb/adb_hb_if.m	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb_hb_if.m	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # Copyright (c) 2008 Nathan Whitehorn
 # 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/adb/adb_hb_if.m 184299 2008-10-26 19:37:38Z nwhitehorn $
 #
 
 #include <sys/bus.h>


Property changes on: trunk/sys/dev/adb/adb_hb_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/adb/adb_if.m
===================================================================
--- trunk/sys/dev/adb/adb_if.m	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb_if.m	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # Copyright (c) 2008 Nathan Whitehorn
 # 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/adb/adb_if.m 184299 2008-10-26 19:37:38Z nwhitehorn $
 #
 
 #include <sys/bus.h>


Property changes on: trunk/sys/dev/adb/adb_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/adb/adb_kbd.c
===================================================================
--- trunk/sys/dev/adb/adb_kbd.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb_kbd.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (C) 2008 Nathan Whitehorn
  * All rights reserved.
@@ -22,7 +23,7 @@
  * 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/adb/adb_kbd.c 265998 2014-05-14 01:16:05Z ian $
  */
 
 #include <sys/cdefs.h>
@@ -304,7 +305,7 @@
 	/* Try stepping forward to the extended keyboard protocol */
 	adb_set_device_handler(dev,3);
 
-	mtx_init(&sc->sc_mutex,KBD_DRIVER_NAME,MTX_DEF,0);
+	mtx_init(&sc->sc_mutex, KBD_DRIVER_NAME, NULL, MTX_DEF);
 	cv_init(&sc->sc_cv,KBD_DRIVER_NAME);
 	callout_init(&sc->sc_repeater, 0);
 
@@ -621,7 +622,7 @@
 
 	if (!sc->buffers) {
 		mtx_unlock(&sc->sc_mutex);
-		return (0);
+		return (NOKEY);
 	}
 
 	adb_code = sc->buffer[0];

Modified: trunk/sys/dev/adb/adb_mouse.c
===================================================================
--- trunk/sys/dev/adb/adb_mouse.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adb_mouse.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (C) 2008 Nathan Whitehorn
  * All rights reserved.
@@ -22,7 +23,7 @@
  * 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/adb/adb_mouse.c 262668 2014-03-01 21:50:23Z jhibbits $
  */
 
 #include <sys/cdefs.h>
@@ -154,7 +155,7 @@
 	sc = device_get_softc(dev);
 	sc->sc_dev = dev;
 
-	mtx_init(&sc->sc_mtx,"ams",MTX_DEF,0);
+	mtx_init(&sc->sc_mtx, "ams", NULL, MTX_DEF);
 	cv_init(&sc->sc_cv,"ams");
 
 	sc->flags = 0;
@@ -471,7 +472,8 @@
 		mtx_lock(&sc->sc_mtx);
 		
 		if (sc->xdelta == 0 && sc->ydelta == 0 && 
-		   sc->buttons == sc->last_buttons) {
+		   sc->buttons == sc->last_buttons &&
+		   sc->packet_read_len == 0) {
 			selrecord(p, &sc->rsel);
 			events = 0;
 		} else {
@@ -569,9 +571,9 @@
 
 	mtx_unlock(&sc->sc_mtx);
 
-	uiomove(outpacket,len,uio);
+	error = uiomove(outpacket,len,uio);
 
-	return (0);
+	return (error);
 }
 
 

Modified: trunk/sys/dev/adb/adbvar.h
===================================================================
--- trunk/sys/dev/adb/adbvar.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adb/adbvar.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (C) 2008 Nathan Whitehorn
  * All rights reserved.
@@ -22,7 +23,7 @@
  * 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/adb/adbvar.h 185724 2008-12-06 23:26:02Z nwhitehorn $
  */
 
 #ifndef	_POWERPC_ADBVAR_H_

Modified: trunk/sys/dev/adlink/adlink.c
===================================================================
--- trunk/sys/dev/adlink/adlink.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/adlink/adlink.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/adlink/adlink.c,v 1.2 2008/12/02 02:24:29 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003-2004 Poul-Henning Kamp
  * All rights reserved.
@@ -44,7 +44,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/adlink/adlink.c 246128 2013-01-30 18:01:20Z sbz $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -408,7 +408,8 @@
 	DEVMETHOD(device_suspend,	bus_generic_suspend),
 	DEVMETHOD(device_resume,	bus_generic_resume),
 	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
-	{0, 0}
+
+	DEVMETHOD_END
 };
  
 static driver_t adlink_driver = {

Modified: trunk/sys/dev/advansys/adv_eisa.c
===================================================================
--- trunk/sys/dev/advansys/adv_eisa.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adv_eisa.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adv_eisa.c 241492 2012-10-12 21:31:44Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/advansys/adv_isa.c
===================================================================
--- trunk/sys/dev/advansys/adv_isa.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adv_isa.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adv_isa.c 241492 2012-10-12 21:31:44Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h> 

Modified: trunk/sys/dev/advansys/adv_pci.c
===================================================================
--- trunk/sys/dev/advansys/adv_pci.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adv_pci.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adv_pci.c 241492 2012-10-12 21:31:44Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/advansys/advansys.c
===================================================================
--- trunk/sys/dev/advansys/advansys.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/advansys.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/advansys.c 315813 2017-03-23 06:41:13Z mav $");
  
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -169,9 +169,9 @@
 			ccb_h = LIST_FIRST(&adv->pending_ccbs);
 			while (ccb_h != NULL) {
 				cinfo = ccb_h->ccb_cinfo_ptr;
-				callout_reset(&cinfo->timer,
-				    ccb_h->timeout * hz / 1000, adv_timeout,
-				    ccb_h);
+				callout_reset_sbt(&cinfo->timer,
+				    SBT_1MS * ccb_h->timeout, 0,
+				    adv_timeout, ccb_h, 0);
 				ccb_h = LIST_NEXT(ccb_h, sim_links.le);
 			}
 			adv->state &= ~ADV_IN_TIMEOUT;
@@ -208,6 +208,7 @@
 		struct	ccb_hdr *ccb_h;
 		struct	ccb_scsiio *csio;
 		struct	adv_ccb_info *cinfo;
+		int error;
 
 		ccb_h = &ccb->ccb_h;
 		csio = &ccb->csio;
@@ -218,58 +219,17 @@
 		ccb_h->ccb_cinfo_ptr = cinfo;
 		cinfo->ccb = ccb;
 
-		/* Only use S/G if there is a transfer */
-		if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
-			if ((ccb_h->flags & CAM_SCATTER_VALID) == 0) {
-				/*
-				 * We've been given a pointer
-				 * to a single buffer
-				 */
-				if ((ccb_h->flags & CAM_DATA_PHYS) == 0) {
-					int error;
-
-					error =
-					    bus_dmamap_load(adv->buffer_dmat,
-							    cinfo->dmamap,
-							    csio->data_ptr,
-							    csio->dxfer_len,
-							    adv_execute_ccb,
-							    csio, /*flags*/0);
-					if (error == EINPROGRESS) {
-						/*
-						 * So as to maintain ordering,
-						 * freeze the controller queue
-						 * until our mapping is
-						 * returned.
-						 */
-						adv_set_state(adv,
-							      ADV_BUSDMA_BLOCK);
-					}
-				} else {
-					struct bus_dma_segment seg;
-
-					/* Pointer to physical buffer */
-					seg.ds_addr =
-					     (bus_addr_t)csio->data_ptr;
-					seg.ds_len = csio->dxfer_len;
-					adv_execute_ccb(csio, &seg, 1, 0);
-				}
-			} else {
-				struct bus_dma_segment *segs;
-				if ((ccb_h->flags & CAM_DATA_PHYS) != 0)
-					panic("adv_setup_data - Physical "
-					      "segment pointers unsupported");
-
-				if ((ccb_h->flags & CAM_SG_LIST_PHYS) == 0)
-					panic("adv_setup_data - Virtual "
-					      "segment addresses unsupported");
-
-				/* Just use the segments provided */
-				segs = (struct bus_dma_segment *)csio->data_ptr;
-				adv_execute_ccb(ccb, segs, csio->sglist_cnt, 0);
-			}
-		} else {
-			adv_execute_ccb(ccb, NULL, 0, 0);
+		error = bus_dmamap_load_ccb(adv->buffer_dmat,
+					    cinfo->dmamap,
+					    ccb,
+					    adv_execute_ccb,
+					    csio, /*flags*/0);
+		if (error == EINPROGRESS) {
+			/*
+			 * So as to maintain ordering, freeze the controller
+			 * queue until our mapping is returned.
+			 */
+			adv_set_state(adv, ADV_BUSDMA_BLOCK);
 		}
 		break;
 	}
@@ -470,9 +430,9 @@
 		cpi->initiator_id = adv->scsi_id;
 		cpi->bus_id = cam_sim_bus(sim);
 		cpi->base_transfer_speed = 3300;
-		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-		strncpy(cpi->hba_vid, "Advansys", HBA_IDLEN);
-		strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+		strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+		strlcpy(cpi->hba_vid, "Advansys", HBA_IDLEN);
+		strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
 		cpi->unit_number = cam_sim_unit(sim);
 		cpi->ccb_h.status = CAM_REQ_CMP;
                 cpi->transport = XPORT_SPI;
@@ -610,8 +570,8 @@
 	ccb_h->status |= CAM_SIM_QUEUED;
 	LIST_INSERT_HEAD(&adv->pending_ccbs, ccb_h, sim_links.le);
 	/* Schedule our timeout */
-	callout_reset(&cinfo->timer, ccb_h->timeout * hz /1000, adv_timeout,
-	    csio);
+	callout_reset_sbt(&cinfo->timer, SBT_1MS * ccb_h->timeout, 0,
+	    adv_timeout, csio, 0);
 }
 
 static struct adv_ccb_info *

Modified: trunk/sys/dev/advansys/advansys.h
===================================================================
--- trunk/sys/dev/advansys/advansys.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/advansys.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  * All rights reserved.
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/advansys/advansys.h 241492 2012-10-12 21:31:44Z jhb $
  */
 
 #ifndef _ADVANSYS_H_

Modified: trunk/sys/dev/advansys/advlib.c
===================================================================
--- trunk/sys/dev/advansys/advlib.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/advlib.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/advlib.c 241492 2012-10-12 21:31:44Z jhb $");
 
 #include <sys/param.h>
 #include <sys/conf.h>

Modified: trunk/sys/dev/advansys/advlib.h
===================================================================
--- trunk/sys/dev/advansys/advlib.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/advlib.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/advansys/advlib.h 241492 2012-10-12 21:31:44Z jhb $
  */
 /*-
  * Ported from:

Modified: trunk/sys/dev/advansys/advmcode.c
===================================================================
--- trunk/sys/dev/advansys/advmcode.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/advmcode.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/advansys/advmcode.c,v 1.2 2008/12/02 02:24:29 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Downloadable microcode for Advanced Systems Inc. SCSI controllers
  *
@@ -16,7 +16,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/advmcode.c 139749 2005-01-06 01:43:34Z imp $");
 
 #include <sys/param.h>
 

Modified: trunk/sys/dev/advansys/advmcode.h
===================================================================
--- trunk/sys/dev/advansys/advmcode.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/advmcode.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,8 +1,8 @@
-/* $MidnightBSD: src/sys/dev/advansys/advmcode.h,v 1.2 2008/12/02 02:24:29 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Exported interface to downloadable microcode for AdvanSys SCSI Adapters
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/advansys/advmcode.h 139749 2005-01-06 01:43:34Z imp $
  *
  * Obtained from:
  *

Modified: trunk/sys/dev/advansys/adw_pci.c
===================================================================
--- trunk/sys/dev/advansys/adw_pci.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adw_pci.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adw_pci.c 254263 2013-08-12 23:30:01Z scottl $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -200,7 +200,7 @@
 {
 	struct		adw_softc *adw;
 	struct		adw_pci_identity *entry;
-	u_int32_t	command;
+	u_int16_t	command;
 	struct		resource *regs;
 	int		regs_type;
 	int		regs_id;
@@ -207,7 +207,6 @@
 	int		error;
 	int		zero;
  
-	command = pci_read_config(dev, PCIR_COMMAND, /*bytes*/1);
 	entry = adw_find_pci_device(dev);
 	if (entry == NULL)
 		return (ENXIO);
@@ -215,14 +214,11 @@
 	regs_type = 0;
 	regs_id = 0;
 #ifdef ADW_ALLOW_MEMIO
-	if ((command & PCIM_CMD_MEMEN) != 0) {
-		regs_type = SYS_RES_MEMORY;
-		regs_id = ADW_PCI_MEMBASE;
-		regs = bus_alloc_resource_any(dev, regs_type,
-					      &regs_id, RF_ACTIVE);
-	}
+	regs_type = SYS_RES_MEMORY;
+	regs_id = ADW_PCI_MEMBASE;
+	regs = bus_alloc_resource_any(dev, regs_type, &regs_id, RF_ACTIVE);
 #endif
-	if (regs == NULL && (command & PCIM_CMD_PORTEN) != 0) {
+	if (regs == NULL) {
 		regs_type = SYS_RES_IOPORT;
 		regs_id = ADW_PCI_IOBASE;
 		regs = bus_alloc_resource_any(dev, regs_type,
@@ -297,6 +293,7 @@
 	 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
 	 * to ignore DMA parity errors.
 	 */
+	command = pci_read_config(dev, PCIR_COMMAND, /*bytes*/2);
 	if ((command & PCIM_CMD_PERRESPEN) == 0)
 		adw_lram_write_16(adw, ADW_MC_CONTROL_FLAG,
 				  adw_lram_read_16(adw, ADW_MC_CONTROL_FLAG)

Modified: trunk/sys/dev/advansys/adwcam.c
===================================================================
--- trunk/sys/dev/advansys/adwcam.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adwcam.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adwcam.c 315813 2017-03-23 06:41:13Z mav $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -76,7 +76,6 @@
 #define ccb_acb_ptr spriv_ptr0
 #define ccb_adw_ptr spriv_ptr1
 
-static __inline cam_status	adwccbstatus(union ccb*);
 static __inline struct acb*	adwgetacb(struct adw_softc *adw);
 static __inline void		adwfreeacb(struct adw_softc *adw,
 					   struct acb *acb);
@@ -101,12 +100,6 @@
 static void		adw_handle_bus_reset(struct adw_softc *adw,
 					     int initiated);
 
-static __inline cam_status
-adwccbstatus(union ccb* ccb)
-{
-	return (ccb->ccb_h.status & CAM_STATUS_MASK);
-}
-
 static __inline struct acb*
 adwgetacb(struct adw_softc *adw)
 {
@@ -330,8 +323,8 @@
 	acb->state |= ACB_ACTIVE;
 	ccb->ccb_h.status |= CAM_SIM_QUEUED;
 	LIST_INSERT_HEAD(&adw->pending_ccbs, &ccb->ccb_h, sim_links.le);
-	callout_reset(&acb->timer, (ccb->ccb_h.timeout * hz) / 1000,
-	    adwtimeout, acb);
+	callout_reset_sbt(&acb->timer, SBT_1MS * ccb->ccb_h.timeout, 0,
+	    adwtimeout, acb, 0);
 
 	adw_send_acb(adw, acb, acbvtob(adw, acb));
 }
@@ -354,6 +347,7 @@
 		struct	ccb_scsiio *csio;
 		struct	ccb_hdr *ccbh;
 		struct	acb *acb;
+		int error;
 
 		csio = &ccb->csio;
 		ccbh = &ccb->ccb_h;
@@ -428,66 +422,18 @@
 			      acb->queue.cdb, csio->cdb_len);
 		}
 
-		/*
-		 * If we have any data to send with this command,
-		 * map it into bus space.
-		 */
-		if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
-			if ((ccbh->flags & CAM_SCATTER_VALID) == 0) {
-				/*
-				 * We've been given a pointer
-				 * to a single buffer.
-				 */
-				if ((ccbh->flags & CAM_DATA_PHYS) == 0) {
-					int error;
-
-					error =
-					    bus_dmamap_load(adw->buffer_dmat,
-							    acb->dmamap,
-							    csio->data_ptr,
-							    csio->dxfer_len,
-							    adwexecuteacb,
-							    acb, /*flags*/0);
-					if (error == EINPROGRESS) {
-						/*
-						 * So as to maintain ordering,
-						 * freeze the controller queue
-						 * until our mapping is
-						 * returned.
-						 */
-						xpt_freeze_simq(sim, 1);
-						acb->state |= CAM_RELEASE_SIMQ;
-					}
-				} else {
-					struct bus_dma_segment seg; 
-
-					/* Pointer to physical buffer */
-					seg.ds_addr =
-					    (bus_addr_t)csio->data_ptr;
-					seg.ds_len = csio->dxfer_len;
-					adwexecuteacb(acb, &seg, 1, 0);
-				}
-			} else {
-				struct bus_dma_segment *segs;
-
-				if ((ccbh->flags & CAM_DATA_PHYS) != 0)
-					panic("adw_action - Physical "
-					      "segment pointers "
-					      "unsupported");
-
-				if ((ccbh->flags&CAM_SG_LIST_PHYS)==0)
-					panic("adw_action - Virtual "
-					      "segment addresses "
-					      "unsupported");
-
-				/* Just use the segments provided */
-				segs = (struct bus_dma_segment *)csio->data_ptr;
-				adwexecuteacb(acb, segs, csio->sglist_cnt,
-					      (csio->sglist_cnt < ADW_SGSIZE)
-					      ? 0 : EFBIG);
-			}
-		} else {
-			adwexecuteacb(acb, NULL, 0, 0);
+		error = bus_dmamap_load_ccb(adw->buffer_dmat,
+					    acb->dmamap,
+					    ccb,
+					    adwexecuteacb,
+					    acb, /*flags*/0);
+		if (error == EINPROGRESS) {
+			/*
+			 * So as to maintain ordering, freeze the controller
+			 * queue until our mapping is returned.
+			 */
+			xpt_freeze_simq(sim, 1);
+			acb->state |= CAM_RELEASE_SIMQ;
 		}
 		break;
 	}
@@ -765,9 +711,9 @@
 		cpi->initiator_id = adw->initiator_id;
 		cpi->bus_id = cam_sim_bus(sim);
 		cpi->base_transfer_speed = 3300;
-		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-		strncpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN);
-		strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+		strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+		strlcpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN);
+		strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
 		cpi->unit_number = cam_sim_unit(sim);
                 cpi->transport = XPORT_SPI;
                 cpi->transport_version = 2;
@@ -1020,7 +966,7 @@
 			/* highaddr	*/ BUS_SPACE_MAXADDR,
 			/* filter	*/ NULL,
 			/* filterarg	*/ NULL,
-			/* maxsize	*/ MAXBSIZE,
+			/* maxsize	*/ DFLTPHYS,
 			/* nsegments	*/ ADW_SGSIZE,
 			/* maxsegsz	*/ BUS_SPACE_MAXSIZE_32BIT,
 			/* flags	*/ BUS_DMA_ALLOCNOW,

Modified: trunk/sys/dev/advansys/adwlib.c
===================================================================
--- trunk/sys/dev/advansys/adwlib.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adwlib.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adwlib.c 241588 2012-10-15 15:26:00Z jhb $");
 
 #include <sys/param.h>
 #include <sys/conf.h>

Modified: trunk/sys/dev/advansys/adwlib.h
===================================================================
--- trunk/sys/dev/advansys/adwlib.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adwlib.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/advansys/adwlib.h 241588 2012-10-15 15:26:00Z jhb $
  */
 /*-
  * Ported from:

Modified: trunk/sys/dev/advansys/adwmcode.c
===================================================================
--- trunk/sys/dev/advansys/adwmcode.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adwmcode.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/advansys/adwmcode.c,v 1.2 2008/12/02 02:24:30 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Downloadable microcode for Second Generation
  * Advanced Systems Inc. SCSI controllers
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/advansys/adwmcode.c 139749 2005-01-06 01:43:34Z imp $");
 
 #include <sys/param.h>
 

Modified: trunk/sys/dev/advansys/adwmcode.h
===================================================================
--- trunk/sys/dev/advansys/adwmcode.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adwmcode.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,8 +1,8 @@
-/* $MidnightBSD: src/sys/dev/advansys/adwmcode.h,v 1.2 2008/12/02 02:24:30 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Exported interface to downloadable microcode for AdvanSys SCSI Adapters
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/advansys/adwmcode.h 139749 2005-01-06 01:43:34Z imp $
  *
  * Obtained from:
  *

Modified: trunk/sys/dev/advansys/adwvar.h
===================================================================
--- trunk/sys/dev/advansys/adwvar.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/advansys/adwvar.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  * All rights reserved.
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/advansys/adwvar.h 241588 2012-10-15 15:26:00Z jhb $
  */
 
 #ifndef _ADWVAR_H_

Modified: trunk/sys/dev/ae/if_ae.c
===================================================================
--- trunk/sys/dev/ae/if_ae.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/ae/if_ae.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008 Stanislav Sedov <stas at FreeBSD.org>.
  * All rights reserved.
@@ -28,8 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-/* $FreeBSD: stable/9/sys/dev/ae/if_ae.c 264445 2014-04-14 04:59:46Z yongari $ */
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ae/if_ae.c 264444 2014-04-14 04:58:50Z yongari $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/ae/if_aereg.h
===================================================================
--- trunk/sys/dev/ae/if_aereg.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/ae/if_aereg.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008 Stanislav Sedov <stas at FreeBSD.org>.
  * All rights reserved.
@@ -22,8 +23,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/9/sys/dev/ae/if_aereg.h 258960 2013-12-05 07:16:24Z yongari $
+ * $FreeBSD: stable/10/sys/dev/ae/if_aereg.h 253406 2013-07-17 01:34:25Z yongari $
  */
 
 /*

Modified: trunk/sys/dev/ae/if_aevar.h
===================================================================
--- trunk/sys/dev/ae/if_aevar.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/ae/if_aevar.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008 Stanislav Sedov <stas at FreeBSD.org>.
  * All rights reserved.
@@ -22,7 +23,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/ae/if_aevar.h 216925 2011-01-03 18:28:30Z jhb $
  */
 
 #ifndef IF_AEVAR_H

Modified: trunk/sys/dev/agp/agp.c
===================================================================
--- trunk/sys/dev/agp/agp.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -25,10 +26,9 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp.c 275406 2014-12-02 13:46:13Z tijl $");
 
 #include "opt_agp.h"
-#include "opt_bus.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,6 +42,7 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
+#include <sys/rwlock.h>
 
 #include <dev/agp/agppriv.h>
 #include <dev/agp/agpvar.h>
@@ -50,6 +51,8 @@
 #include <dev/pci/pcireg.h>
 
 #include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
@@ -56,7 +59,6 @@
 #include <vm/vm_pageout.h>
 #include <vm/pmap.h>
 
-#include <machine/md_var.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
 #include <sys/rman.h>
@@ -85,14 +87,6 @@
 
 /* Helper functions for implementing chipset mini drivers. */
 
-void
-agp_flush_cache()
-{
-#if defined(__i386__) || defined(__amd64__)
-	wbinvd();
-#endif
-}
-
 u_int8_t
 agp_find_caps(device_t dev)
 {
@@ -159,8 +153,9 @@
 		return 0;
 
 	gatt->ag_entries = entries;
-	gatt->ag_virtual = contigmalloc(entries * sizeof(u_int32_t), M_AGP, 0,
-					0, ~0, PAGE_SIZE, 0);
+	gatt->ag_virtual = (void *)kmem_alloc_contig(kernel_arena,
+	    entries * sizeof(u_int32_t), M_NOWAIT | M_ZERO, 0, ~0, PAGE_SIZE,
+	    0, VM_MEMATTR_WRITE_COMBINING);
 	if (!gatt->ag_virtual) {
 		if (bootverbose)
 			device_printf(dev, "contiguous allocation failed\n");
@@ -167,9 +162,7 @@
 		free(gatt, M_AGP);
 		return 0;
 	}
-	bzero(gatt->ag_virtual, entries * sizeof(u_int32_t));
 	gatt->ag_physical = vtophys((vm_offset_t) gatt->ag_virtual);
-	agp_flush_cache();
 
 	return gatt;
 }
@@ -177,8 +170,8 @@
 void
 agp_free_gatt(struct agp_gatt *gatt)
 {
-	contigfree(gatt->ag_virtual,
-		   gatt->ag_entries * sizeof(u_int32_t), M_AGP);
+	kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
+	    gatt->ag_entries * sizeof(u_int32_t));
 	free(gatt, M_AGP);
 }
 
@@ -235,7 +228,7 @@
 	 * Work out an upper bound for agp memory allocation. This
 	 * uses a heurisitc table from the Linux driver.
 	 */
-	memsize = ptoa(Maxmem) >> 20;
+	memsize = ptoa(realmem) >> 20;
 	for (i = 0; i < agp_max_size; i++) {
 		if (memsize <= agp_max[i][0])
 			break;
@@ -281,7 +274,6 @@
 		bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid,
 		    sc->as_aperture);
 	mtx_destroy(&sc->as_lock);
-	agp_flush_cache();
 }
 
 int
@@ -486,7 +478,7 @@
 	if ((size & (AGP_PAGE_SIZE - 1)) != 0)
 		return 0;
 
-	if (sc->as_allocated + size > sc->as_maxmem)
+	if (size > sc->as_maxmem - sc->as_allocated)
 		return 0;
 
 	if (type != 0) {
@@ -546,7 +538,7 @@
 	 * because vm_page_grab() may sleep and we can't hold a mutex
 	 * while sleeping.
 	 */
-	VM_OBJECT_LOCK(mem->am_obj);
+	VM_OBJECT_WLOCK(mem->am_obj);
 	for (i = 0; i < mem->am_size; i += PAGE_SIZE) {
 		/*
 		 * Find a page from the object and wire it
@@ -556,10 +548,10 @@
 		 * the pages will be allocated and zeroed.
 		 */
 		m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i),
-		    VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY);
+		    VM_ALLOC_WIRED | VM_ALLOC_ZERO);
 		AGP_DPF("found page pa=%#jx\n", (uintmax_t)VM_PAGE_TO_PHYS(m));
 	}
-	VM_OBJECT_UNLOCK(mem->am_obj);
+	VM_OBJECT_WUNLOCK(mem->am_obj);
 
 	mtx_lock(&sc->as_lock);
 
@@ -566,7 +558,7 @@
 	if (mem->am_is_bound) {
 		device_printf(dev, "memory already bound\n");
 		error = EINVAL;
-		VM_OBJECT_LOCK(mem->am_obj);
+		VM_OBJECT_WLOCK(mem->am_obj);
 		i = 0;
 		goto bad;
 	}
@@ -575,7 +567,7 @@
 	 * Bind the individual pages and flush the chipset's
 	 * TLB.
 	 */
-	VM_OBJECT_LOCK(mem->am_obj);
+	VM_OBJECT_WLOCK(mem->am_obj);
 	for (i = 0; i < mem->am_size; i += PAGE_SIZE) {
 		m = vm_page_lookup(mem->am_obj, OFF_TO_IDX(i));
 
@@ -601,17 +593,11 @@
 				goto bad;
 			}
 		}
-		vm_page_wakeup(m);
+		vm_page_xunbusy(m);
 	}
-	VM_OBJECT_UNLOCK(mem->am_obj);
+	VM_OBJECT_WUNLOCK(mem->am_obj);
 
 	/*
-	 * Flush the cpu cache since we are providing a new mapping
-	 * for these pages.
-	 */
-	agp_flush_cache();
-
-	/*
 	 * Make sure the chipset gets the new mappings.
 	 */
 	AGP_FLUSH_TLB(dev);
@@ -624,16 +610,16 @@
 	return 0;
 bad:
 	mtx_unlock(&sc->as_lock);
-	VM_OBJECT_LOCK_ASSERT(mem->am_obj, MA_OWNED);
+	VM_OBJECT_ASSERT_WLOCKED(mem->am_obj);
 	for (k = 0; k < mem->am_size; k += PAGE_SIZE) {
 		m = vm_page_lookup(mem->am_obj, OFF_TO_IDX(k));
 		if (k >= i)
-			vm_page_wakeup(m);
+			vm_page_xunbusy(m);
 		vm_page_lock(m);
 		vm_page_unwire(m, 0);
 		vm_page_unlock(m);
 	}
-	VM_OBJECT_UNLOCK(mem->am_obj);
+	VM_OBJECT_WUNLOCK(mem->am_obj);
 
 	return error;
 }
@@ -660,7 +646,10 @@
 	 */
 	for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
 		AGP_UNBIND_PAGE(dev, mem->am_offset + i);
-	VM_OBJECT_LOCK(mem->am_obj);
+
+	AGP_FLUSH_TLB(dev);
+
+	VM_OBJECT_WLOCK(mem->am_obj);
 	for (i = 0; i < mem->am_size; i += PAGE_SIZE) {
 		m = vm_page_lookup(mem->am_obj, atop(i));
 		vm_page_lock(m);
@@ -667,10 +656,7 @@
 		vm_page_unwire(m, 0);
 		vm_page_unlock(m);
 	}
-	VM_OBJECT_UNLOCK(mem->am_obj);
-		
-	agp_flush_cache();
-	AGP_FLUSH_TLB(dev);
+	VM_OBJECT_WUNLOCK(mem->am_obj);
 
 	mem->am_offset = 0;
 	mem->am_is_bound = 0;
@@ -997,3 +983,76 @@
 	mi->ami_offset = mem->am_offset;
 	mi->ami_is_bound = mem->am_is_bound;
 }
+
+int
+agp_bind_pages(device_t dev, vm_page_t *pages, vm_size_t size,
+    vm_offset_t offset)
+{
+	struct agp_softc *sc;
+	vm_offset_t i, j, k, pa;
+	vm_page_t m;
+	int error;
+
+	if ((size & (AGP_PAGE_SIZE - 1)) != 0 ||
+	    (offset & (AGP_PAGE_SIZE - 1)) != 0)
+		return (EINVAL);
+
+	sc = device_get_softc(dev);
+
+	mtx_lock(&sc->as_lock);
+	for (i = 0; i < size; i += PAGE_SIZE) {
+		m = pages[OFF_TO_IDX(i)];
+		KASSERT(m->wire_count > 0,
+		    ("agp_bind_pages: page %p hasn't been wired", m));
+
+		/*
+		 * Install entries in the GATT, making sure that if
+		 * AGP_PAGE_SIZE < PAGE_SIZE and size is not
+		 * aligned to PAGE_SIZE, we don't modify too many GATT 
+		 * entries.
+		 */
+		for (j = 0; j < PAGE_SIZE && i + j < size; j += AGP_PAGE_SIZE) {
+			pa = VM_PAGE_TO_PHYS(m) + j;
+			AGP_DPF("binding offset %#jx to pa %#jx\n",
+				(uintmax_t)offset + i + j, (uintmax_t)pa);
+			error = AGP_BIND_PAGE(dev, offset + i + j, pa);
+			if (error) {
+				/*
+				 * Bail out. Reverse all the mappings.
+				 */
+				for (k = 0; k < i + j; k += AGP_PAGE_SIZE)
+					AGP_UNBIND_PAGE(dev, offset + k);
+
+				mtx_unlock(&sc->as_lock);
+				return (error);
+			}
+		}
+	}
+
+	AGP_FLUSH_TLB(dev);
+
+	mtx_unlock(&sc->as_lock);
+	return (0);
+}
+
+int
+agp_unbind_pages(device_t dev, vm_size_t size, vm_offset_t offset)
+{
+	struct agp_softc *sc;
+	vm_offset_t i;
+
+	if ((size & (AGP_PAGE_SIZE - 1)) != 0 ||
+	    (offset & (AGP_PAGE_SIZE - 1)) != 0)
+		return (EINVAL);
+
+	sc = device_get_softc(dev);
+
+	mtx_lock(&sc->as_lock);
+	for (i = 0; i < size; i += AGP_PAGE_SIZE)
+		AGP_UNBIND_PAGE(dev, offset + i);
+
+	AGP_FLUSH_TLB(dev);
+
+	mtx_unlock(&sc->as_lock);
+	return (0);
+}

Modified: trunk/sys/dev/agp/agp_ali.c
===================================================================
--- trunk/sys/dev/agp/agp_ali.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_ali.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_ali.c 244926 2013-01-01 18:16:49Z antoine $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -71,7 +70,7 @@
 		return ("Ali M1541 host to AGP bridge");
 	case 0x162110b9:
 		return ("Ali M1621 host to AGP bridge");
-	};
+	}
 
 	return NULL;
 }

Modified: trunk/sys/dev/agp/agp_amd.c
===================================================================
--- trunk/sys/dev/agp/agp_amd.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_amd.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_amd.c 275406 2014-12-02 13:46:13Z tijl $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -45,6 +44,8 @@
 #include <dev/pci/pcireg.h>
 
 #include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_object.h>
 #include <vm/pmap.h>
 #include <machine/bus.h>
@@ -94,13 +95,14 @@
 
 	/*
 	 * The AMD751 uses a page directory to map a non-contiguous
-	 * gatt so we don't need to use contigmalloc.
-	 * Malloc individual gatt pages and map them into the page
+	 * gatt so we don't need to use kmem_alloc_contig.
+	 * Allocate individual GATT pages and map them into the page
 	 * directory.
 	 */
 	gatt->ag_entries = entries;
-	gatt->ag_virtual = malloc(entries * sizeof(u_int32_t),
-				  M_AGP, M_NOWAIT);
+	gatt->ag_virtual = (void *)kmem_alloc_attr(kernel_arena,
+	    entries * sizeof(u_int32_t), M_NOWAIT | M_ZERO, 0, ~0,
+	    VM_MEMATTR_WRITE_COMBINING);
 	if (!gatt->ag_virtual) {
 		if (bootverbose)
 			device_printf(dev, "allocation failed\n");
@@ -107,21 +109,21 @@
 		free(gatt, M_AGP);
 		return 0;
 	}
-	bzero(gatt->ag_virtual, entries * sizeof(u_int32_t));
 
 	/*
 	 * Allocate the page directory.
 	 */
-	gatt->ag_vdir = malloc(AGP_PAGE_SIZE, M_AGP, M_NOWAIT);
+	gatt->ag_vdir = (void *)kmem_alloc_attr(kernel_arena, AGP_PAGE_SIZE,
+	    M_NOWAIT | M_ZERO, 0, ~0, VM_MEMATTR_WRITE_COMBINING);
 	if (!gatt->ag_vdir) {
 		if (bootverbose)
 			device_printf(dev,
 				      "failed to allocate page directory\n");
-		free(gatt->ag_virtual, M_AGP);
+		kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
+		    entries * sizeof(u_int32_t));
 		free(gatt, M_AGP);
 		return 0;
 	}
-	bzero(gatt->ag_vdir, AGP_PAGE_SIZE);
 
 	gatt->ag_pdir = vtophys((vm_offset_t) gatt->ag_vdir);
 	if(bootverbose)
@@ -160,11 +162,6 @@
 		gatt->ag_vdir[i + pdir_offset] = pa | 1;
 	}
 
-	/*
-	 * Make sure the chipset can see everything.
-	 */
-	agp_flush_cache();
-
 	return gatt;
 }
 
@@ -171,8 +168,9 @@
 static void
 agp_amd_free_gatt(struct agp_amd_gatt *gatt)
 {
-	free(gatt->ag_virtual, M_AGP);
-	free(gatt->ag_vdir, M_AGP);
+	kmem_free(kernel_arena, (vm_offset_t)gatt->ag_vdir, AGP_PAGE_SIZE);
+	kmem_free(kernel_arena, (vm_offset_t)gatt->ag_virtual,
+	    gatt->ag_entries * sizeof(u_int32_t));
 	free(gatt, M_AGP);
 }
 
@@ -193,7 +191,7 @@
 		return ("AMD 761 host to AGP bridge");
 	case 0x700c1022:
 		return ("AMD 762 host to AGP bridge");
-	};
+	}
 
 	return NULL;
 }
@@ -350,9 +348,6 @@
 		return EINVAL;
 
 	sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 1;
-
-	/* invalidate the cache */
-	AGP_FLUSH_TLB(dev);
 	return 0;
 }
 

Modified: trunk/sys/dev/agp/agp_amd64.c
===================================================================
--- trunk/sys/dev/agp/agp_amd64.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_amd64.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004, 2005 Jung-uk Kim <jkim at FreeBSD.org>
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_amd64.c 275406 2014-12-02 13:46:13Z tijl $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -115,7 +114,7 @@
 		return ("VIA K8T800Pro host to PCI bridge");
 	case 0x31881106:
 		return ("VIA 8385 host to PCI bridge");
-	};
+	}
 
 	return (NULL);
 }
@@ -243,8 +242,6 @@
 		    4);
 	}
 
-	agp_flush_cache();
-
 	return (0);
 }
 

Modified: trunk/sys/dev/agp/agp_apple.c
===================================================================
--- trunk/sys/dev/agp/agp_apple.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_apple.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Nathan Whitehorn
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_apple.c 275406 2014-12-02 13:46:13Z tijl $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -226,8 +225,6 @@
 		return EINVAL;
 
 	sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical;
-	__asm __volatile("dcbst 0,%0; sync" ::
-	    "r"(&sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT]) : "memory");
 	return (0);
 }
 
@@ -240,8 +237,6 @@
 		return EINVAL;
 
 	sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0;
-	__asm __volatile("dcbst 0,%0; sync" ::
-	    "r"(&sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT]) : "memory");
 	return (0);
 }
 

Modified: trunk/sys/dev/agp/agp_ati.c
===================================================================
--- trunk/sys/dev/agp/agp_ati.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_ati.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Eric Anholt
  * All rights reserved.
@@ -27,10 +28,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_ati.c 275406 2014-12-02 13:46:13Z tijl $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -47,6 +46,8 @@
 #include <dev/pci/pcireg.h>
 
 #include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_object.h>
 #include <vm/pmap.h>
 #include <machine/bus.h>
@@ -101,7 +102,7 @@
 		return ("ATI RS300_166 AGP bridge");
 	case 0x58331002:
 		return ("ATI RS300_200 AGP bridge");
-	};
+	}
 
 	return NULL;
 }
@@ -131,20 +132,23 @@
 
 	/* Alloc the GATT -- pointers to pages of AGP memory */
 	sc->ag_entries = entries;
-	sc->ag_virtual = malloc(entries * sizeof(u_int32_t), M_AGP,
-	    M_NOWAIT | M_ZERO);
+	sc->ag_virtual = (void *)kmem_alloc_attr(kernel_arena,
+	    entries * sizeof(u_int32_t), M_NOWAIT | M_ZERO, 0, ~0,
+	    VM_MEMATTR_WRITE_COMBINING);
 	if (sc->ag_virtual == NULL) {
 		if (bootverbose)
-			device_printf(dev, "aperture allocation failed\n");
+			device_printf(dev, "GATT allocation failed\n");
 		return ENOMEM;
 	}
 
 	/* Alloc the page directory -- pointers to each page of the GATT */
-	sc->ag_vdir = malloc(AGP_PAGE_SIZE, M_AGP, M_NOWAIT | M_ZERO);
+	sc->ag_vdir = (void *)kmem_alloc_attr(kernel_arena, AGP_PAGE_SIZE,
+	    M_NOWAIT | M_ZERO, 0, ~0, VM_MEMATTR_WRITE_COMBINING);
 	if (sc->ag_vdir == NULL) {
 		if (bootverbose)
 			device_printf(dev, "pagedir allocation failed\n");
-		free(sc->ag_virtual, M_AGP);
+		kmem_free(kernel_arena, (vm_offset_t)sc->ag_virtual,
+		    entries * sizeof(u_int32_t));
 		return ENOMEM;
 	}
 	sc->ag_pdir = vtophys((vm_offset_t)sc->ag_vdir);
@@ -160,11 +164,6 @@
 		sc->ag_vdir[apbase_offset + i] = pa | 1;
 	}
 
-	/*
-	 * Make sure the chipset can see everything.
-	 */
-	agp_flush_cache();
-
 	return 0;
 }
 
@@ -201,7 +200,7 @@
 	default:
 		/* Unknown chipset */
 		return EINVAL;
-	};
+	}
 
 	rid = ATI_GART_MMADDR;
 	sc->regs = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
@@ -266,8 +265,9 @@
 	temp = pci_read_config(dev, apsize_reg, 4);
 	pci_write_config(dev, apsize_reg, temp & ~1, 4);
 
-	free(sc->ag_vdir, M_AGP);
-	free(sc->ag_virtual, M_AGP);
+	kmem_free(kernel_arena, (vm_offset_t)sc->ag_vdir, AGP_PAGE_SIZE);
+	kmem_free(kernel_arena, (vm_offset_t)sc->ag_virtual,
+	    sc->ag_entries * sizeof(u_int32_t));
 
 	bus_release_resource(dev, SYS_RES_MEMORY, ATI_GART_MMADDR, sc->regs);
 	agp_free_res(dev);

Modified: trunk/sys/dev/agp/agp_i810.c
===================================================================
--- trunk/sys/dev/agp/agp_i810.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_i810.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * Copyright (c) 2000 Ruslan Ermilov
@@ -38,10 +39,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_i810.c 275406 2014-12-02 13:46:13Z tijl $");
 
-#include "opt_bus.h"
-
 #if 0
 #define	KTR_AGP_I810	KTR_DEV
 #else
@@ -58,6 +57,7 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
+#include <sys/rwlock.h>
 
 #include <dev/agp/agppriv.h>
 #include <dev/agp/agpreg.h>
@@ -67,6 +67,8 @@
 #include <dev/pci/pci_private.h>
 
 #include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
@@ -114,6 +116,8 @@
 
 static int agp_i810_install_gatt(device_t dev);
 static int agp_i830_install_gatt(device_t dev);
+static int agp_i965_install_gatt(device_t dev);
+static int agp_g4x_install_gatt(device_t dev);
 
 static void agp_i810_deinstall_gatt(device_t dev);
 static void agp_i830_deinstall_gatt(device_t dev);
@@ -396,7 +400,7 @@
 	.get_stolen_size = agp_i915_get_stolen_size,
 	.get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries,
 	.get_gtt_total_entries = agp_i965_get_gtt_total_entries,
-	.install_gatt = agp_i830_install_gatt,
+	.install_gatt = agp_i965_install_gatt,
 	.deinstall_gatt = agp_i830_deinstall_gatt,
 	.write_gtt = agp_i965_write_gtt,
 	.install_gtt_pte = agp_i965_install_gtt_pte,
@@ -465,7 +469,7 @@
 	.get_stolen_size = agp_i915_get_stolen_size,
 	.get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries,
 	.get_gtt_total_entries = agp_gen5_get_gtt_total_entries,
-	.install_gatt = agp_i830_install_gatt,
+	.install_gatt = agp_g4x_install_gatt,
 	.deinstall_gatt = agp_i830_deinstall_gatt,
 	.write_gtt = agp_g4x_write_gtt,
 	.install_gtt_pte = agp_g4x_install_gtt_pte,
@@ -488,7 +492,7 @@
 	.get_stolen_size = agp_sb_get_stolen_size,
 	.get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries,
 	.get_gtt_total_entries = agp_sb_get_gtt_total_entries,
-	.install_gatt = agp_i830_install_gatt,
+	.install_gatt = agp_g4x_install_gatt,
 	.deinstall_gatt = agp_i830_deinstall_gatt,
 	.write_gtt = agp_sb_write_gtt,
 	.install_gtt_pte = agp_sb_install_gtt_pte,
@@ -500,6 +504,29 @@
 	.chipset_flush = agp_i810_chipset_flush,
 };
 
+static const struct agp_i810_driver agp_i810_hsw_driver = {
+	.chiptype = CHIP_SB,
+	.gen = 7,
+	.busdma_addr_mask_sz = 40,
+	.res_spec = agp_g4x_res_spec,
+	.check_active = agp_sb_check_active,
+	.set_desc = agp_i810_set_desc,
+	.dump_regs = agp_sb_dump_regs,
+	.get_stolen_size = agp_sb_get_stolen_size,
+	.get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries,
+	.get_gtt_total_entries = agp_sb_get_gtt_total_entries,
+	.install_gatt = agp_g4x_install_gatt,
+	.deinstall_gatt = agp_i830_deinstall_gatt,
+	.write_gtt = agp_sb_write_gtt,
+	.install_gtt_pte = agp_sb_install_gtt_pte,
+	.read_gtt_pte = agp_g4x_read_gtt_pte,
+	.read_gtt_pte_paddr = agp_sb_read_gtt_pte_paddr,
+	.set_aperture = agp_i915_set_aperture,
+	.chipset_flush_setup = agp_i810_chipset_flush_setup,
+	.chipset_flush_teardown = agp_i810_chipset_flush_teardown,
+	.chipset_flush = agp_i810_chipset_flush,
+};
+
 /* For adding new devices, devid is the id of the graphics controller
  * (pci:0:2:0, for example).  The placeholder (usually at pci:0:2:1) for the
  * second head should never be added.  The bridge_offset is the offset to
@@ -736,6 +763,41 @@
 		.driver = &agp_i810_sb_driver
 	},
 	{
+		.devid = 0x04028086,
+		.name = "Haswell desktop GT1",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
+		.devid = 0x04128086,
+		.name = "Haswell desktop GT2",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
+		.devid = 0x040a8086,
+		.name = "Haswell server GT1",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
+		.devid = 0x041a8086,
+		.name = "Haswell server GT2",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
+		.devid = 0x04068086,
+		.name = "Haswell mobile GT1",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
+		.devid = 0x04168086,
+		.name = "Haswell mobile GT2",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
+		.devid = 0x0c168086,
+		.name = "Haswell SDV",
+		.driver = &agp_i810_hsw_driver
+	},
+	{
 		.devid = 0,
 	}
 };
@@ -746,7 +808,8 @@
 	int i, devid;
 
 	if (pci_get_class(dev) != PCIC_DISPLAY
-	    || pci_get_subclass(dev) != PCIS_DISPLAY_VGA)
+	    || (pci_get_subclass(dev) != PCIS_DISPLAY_VGA &&
+	    pci_get_subclass(dev) != PCIS_DISPLAY_OTHER))
 		return (NULL);
 
 	devid = pci_get_devid(dev);
@@ -1389,8 +1452,9 @@
 		sc->dcache_size = 0;
 
 	/* According to the specs the gatt on the i810 must be 64k. */
-	sc->gatt->ag_virtual = contigmalloc(64 * 1024, M_AGP, 0, 0, ~0,
-	    PAGE_SIZE, 0);
+	sc->gatt->ag_virtual = (void *)kmem_alloc_contig(kernel_arena,
+	    64 * 1024, M_NOWAIT | M_ZERO, 0, ~0, PAGE_SIZE,
+	    0, VM_MEMATTR_WRITE_COMBINING);
 	if (sc->gatt->ag_virtual == NULL) {
 		if (bootverbose)
 			device_printf(dev, "contiguous allocation failed\n");
@@ -1397,9 +1461,7 @@
 		return (ENOMEM);
 	}
 
-	bzero(sc->gatt->ag_virtual, sc->gatt->ag_entries * sizeof(u_int32_t));
 	sc->gatt->ag_physical = vtophys((vm_offset_t)sc->gatt->ag_virtual);
-	agp_flush_cache();
 	/* Install the GATT. */
 	bus_write_4(sc->sc_res[0], AGP_I810_PGTBL_CTL,
 	    sc->gatt->ag_physical | 1);
@@ -1406,14 +1468,11 @@
 	return (0);
 }
 
-static int
-agp_i830_install_gatt(device_t dev)
+static void
+agp_i830_install_gatt_init(struct agp_i810_softc *sc)
 {
-	struct agp_i810_softc *sc;
 	uint32_t pgtblctl;
 
-	sc = device_get_softc(dev);
-
 	/*
 	 * The i830 automatically initializes the 128k gatt on boot.
 	 * GATT address is already in there, make sure it's enabled.
@@ -1423,10 +1482,46 @@
 	bus_write_4(sc->sc_res[0], AGP_I810_PGTBL_CTL, pgtblctl);
 	
 	sc->gatt->ag_physical = pgtblctl & ~1;
+}
+
+static int
+agp_i830_install_gatt(device_t dev)
+{
+	struct agp_i810_softc *sc;
+
+	sc = device_get_softc(dev);
+	agp_i830_install_gatt_init(sc);
 	return (0);
 }
 
 static int
+agp_gen4_install_gatt(device_t dev, const vm_size_t gtt_offset)
+{
+	struct agp_i810_softc *sc;
+
+	sc = device_get_softc(dev);
+	pmap_change_attr((vm_offset_t)rman_get_virtual(sc->sc_res[0]) +
+	    gtt_offset, rman_get_size(sc->sc_res[0]) - gtt_offset,
+	    VM_MEMATTR_WRITE_COMBINING);
+	agp_i830_install_gatt_init(sc);
+	return (0);
+}
+
+static int
+agp_i965_install_gatt(device_t dev)
+{
+
+	return (agp_gen4_install_gatt(dev, 512 * 1024));
+}
+
+static int
+agp_g4x_install_gatt(device_t dev)
+{
+
+	return (agp_gen4_install_gatt(dev, 2 * 1024 * 1024));
+}
+
+static int
 agp_i810_attach(device_t dev)
 {
 	struct agp_i810_softc *sc;
@@ -1498,7 +1593,7 @@
 
 	sc = device_get_softc(dev);
 	bus_write_4(sc->sc_res[0], AGP_I810_PGTBL_CTL, 0);
-	contigfree(sc->gatt->ag_virtual, 64 * 1024, M_AGP);
+	kmem_free(kernel_arena, (vm_offset_t)sc->gatt->ag_virtual, 64 * 1024);
 }
 
 static void
@@ -1969,10 +2064,10 @@
 			 * Allocate and wire down the page now so that we can
 			 * get its physical address.
 			 */
-			VM_OBJECT_LOCK(mem->am_obj);
+			VM_OBJECT_WLOCK(mem->am_obj);
 			m = vm_page_grab(mem->am_obj, 0, VM_ALLOC_NOBUSY |
-			    VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY);
-			VM_OBJECT_UNLOCK(mem->am_obj);
+			    VM_ALLOC_WIRED | VM_ALLOC_ZERO);
+			VM_OBJECT_WUNLOCK(mem->am_obj);
 			mem->am_physical = VM_PAGE_TO_PHYS(m);
 		} else {
 			/* Our allocation is already nicely wired down for us.
@@ -2007,12 +2102,12 @@
 			/*
 			 * Unwire the page which we wired in alloc_memory.
 			 */
-			VM_OBJECT_LOCK(mem->am_obj);
+			VM_OBJECT_WLOCK(mem->am_obj);
 			m = vm_page_lookup(mem->am_obj, 0);
 			vm_page_lock(m);
 			vm_page_unwire(m, 0);
 			vm_page_unlock(m);
-			VM_OBJECT_UNLOCK(mem->am_obj);
+			VM_OBJECT_WUNLOCK(mem->am_obj);
 		} else {
 			contigfree(sc->argb_cursor, mem->am_size, M_AGP);
 			sc->argb_cursor = NULL;
@@ -2053,7 +2148,6 @@
 			sc->match->driver->install_gtt_pte(dev, (offset + i) >>
 			    AGP_PAGE_SHIFT, mem->am_physical + i, 0);
 		}
-		agp_flush_cache();
 		mem->am_offset = offset;
 		mem->am_is_bound = 1;
 		mtx_unlock(&sc->agp.as_lock);
@@ -2094,7 +2188,6 @@
 			sc->match->driver->install_gtt_pte(dev,
 			    (mem->am_offset + i) >> AGP_PAGE_SHIFT, 0, 0);
 		}
-		agp_flush_cache();
 		mem->am_is_bound = 0;
 		mtx_unlock(&sc->agp.as_lock);
 		return (0);
@@ -2227,10 +2320,10 @@
 	sc = device_get_softc(dev);
 	pmap_invalidate_cache();
 	hic = bus_read_4(sc->sc_res[0], AGP_I830_HIC);
-	bus_write_4(sc->sc_res[0], AGP_I830_HIC, hic | (1 << 31));
+	bus_write_4(sc->sc_res[0], AGP_I830_HIC, hic | (1U << 31));
 	for (i = 0; i < 20000 /* 1 sec */; i++) {
 		hic = bus_read_4(sc->sc_res[0], AGP_I830_HIC);
-		if ((hic & (1 << 31)) == 0)
+		if ((hic & (1U << 31)) == 0)
 			break;
 		DELAY(50);
 	}

Modified: trunk/sys/dev/agp/agp_i810.h
===================================================================
--- trunk/sys/dev/agp/agp_i810.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_i810.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 The FreeBSD Foundation
  * All rights reserved.
@@ -26,7 +27,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/agp/agp_i810.h 235782 2012-05-22 10:59:26Z kib $
  */
 
 #ifndef AGP_AGP_I810_H

Modified: trunk/sys/dev/agp/agp_if.m
===================================================================
--- trunk/sys/dev/agp/agp_if.m	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_if.m	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # Copyright (c) 2000 Doug Rabson
 # 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/agp/agp_if.m 235782 2012-05-22 10:59:26Z kib $
 #
 
 #include <sys/bus.h>


Property changes on: trunk/sys/dev/agp/agp_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/agp/agp_intel.c
===================================================================
--- trunk/sys/dev/agp/agp_intel.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_intel.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_intel.c 244926 2013-01-01 18:16:49Z antoine $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -107,7 +106,7 @@
 		return ("Intel 82845G host to AGP bridge");
 	case 0x35808086:
 		return ("Intel 82855GM host to AGP bridge");
-	};
+	}
 
 	return (NULL);
 }

Modified: trunk/sys/dev/agp/agp_nvidia.c
===================================================================
--- trunk/sys/dev/agp/agp_nvidia.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_nvidia.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Matthew N. Dodd <winter at jurai.net>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_nvidia.c 243095 2012-11-15 18:49:17Z eadler $");
 
 /*
  * Written using information gleaned from the
@@ -32,8 +33,6 @@
  * NVIDIA nForce/nForce2 AGPGART Linux Kernel Patch.
  */
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>

Modified: trunk/sys/dev/agp/agp_sis.c
===================================================================
--- trunk/sys/dev/agp/agp_sis.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_sis.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_sis.c 244926 2013-01-01 18:16:49Z antoine $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -103,7 +102,7 @@
 		return ("SiS 745 host to AGP bridge");
 	case 0x07461039:
 		return ("SiS 746 host to AGP bridge");
-	};
+	}
 
 	return NULL;
 }

Modified: trunk/sys/dev/agp/agp_via.c
===================================================================
--- trunk/sys/dev/agp/agp_via.c	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agp_via.c	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -25,10 +26,8 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/agp/agp_via.c 244926 2013-01-01 18:16:49Z antoine $");
 
-#include "opt_bus.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
@@ -137,7 +136,7 @@
 		return ("VIA PT880 host to PCI bridge");
 	case 0xb1981106:
 		return ("VIA VT83xx/VT87xx/KTxxx/Px8xx host to PCI bridge");
-	};
+	}
 
 	return NULL;
 }

Modified: trunk/sys/dev/agp/agppriv.h
===================================================================
--- trunk/sys/dev/agp/agppriv.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agppriv.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * 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/agp/agppriv.h 275406 2014-12-02 13:46:13Z tijl $
  */
 
 #ifndef _PCI_AGPPRIV_H_
@@ -83,7 +84,6 @@
 	vm_offset_t	ag_physical;
 };
 
-void			agp_flush_cache(void);
 u_int8_t		agp_find_caps(device_t dev);
 struct agp_gatt	       *agp_alloc_gatt(device_t dev);
 void			agp_set_aperture_resource(device_t dev, int rid);

Modified: trunk/sys/dev/agp/agpreg.h
===================================================================
--- trunk/sys/dev/agp/agpreg.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agpreg.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * 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/agp/agpreg.h 235782 2012-05-22 10:59:26Z kib $
  */
 
 #ifndef _PCI_AGPREG_H_

Modified: trunk/sys/dev/agp/agpvar.h
===================================================================
--- trunk/sys/dev/agp/agpvar.h	2018-05-27 23:55:56 UTC (rev 10113)
+++ trunk/sys/dev/agp/agpvar.h	2018-05-27 23:56:26 UTC (rev 10114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * 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/agp/agpvar.h 275406 2014-12-02 13:46:13Z tijl $
  */
 
 #ifndef _PCI_AGPVAR_H_
@@ -122,6 +123,19 @@
  */
 void agp_memory_info(device_t dev, void *handle, struct agp_memory_info *mi);
 
+/*
+ * Bind a set of pages at a given offset within the AGP aperture.
+ * Returns EINVAL if the given size or offset is not at an AGP page boundary.
+ */
+int agp_bind_pages(device_t dev, vm_page_t *pages, vm_size_t size,
+		   vm_offset_t offset);
+
+/*
+ * Unbind a set of pages from the AGP aperture.
+ * Returns EINVAL if the given size or offset is not at an AGP page boundary.
+ */
+int agp_unbind_pages(device_t dev, vm_size_t size, vm_offset_t offset);
+
 #define AGP_NORMAL_MEMORY 0
 
 #define AGP_USER_TYPES (1 << 16)



More information about the Midnightbsd-cvs mailing list