Mon Aug 27 00:51:37 2018 UTC ()
Restore gtt page table control register on resume.

Additional subroutine agp_i810_reset is used by i915drmkms to make
sure it happens early enough, since i915drmkms resumes before agp.

XXX pullup-7
XXX pullup-8


(riastradh)
diff -r1.122 -r1.123 src/sys/dev/pci/agp_i810.c
diff -r1.6 -r1.7 src/sys/dev/pci/agp_i810var.h
diff -r1.6 -r1.7 src/sys/external/bsd/drm2/i915drm/intel_gtt.c

cvs diff -r1.122 -r1.123 src/sys/dev/pci/agp_i810.c (expand / switch to unified diff)

--- src/sys/dev/pci/agp_i810.c 2016/05/01 04:22:50 1.122
+++ src/sys/dev/pci/agp_i810.c 2018/08/27 00:51:37 1.123
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: agp_i810.c,v 1.122 2016/05/01 04:22:50 nonaka Exp $ */ 1/* $NetBSD: agp_i810.c,v 1.123 2018/08/27 00:51:37 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 Doug Rabson 4 * Copyright (c) 2000 Doug Rabson
5 * Copyright (c) 2000 Ruslan Ermilov 5 * Copyright (c) 2000 Ruslan Ermilov
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 * 28 *
29 * $FreeBSD$ 29 * $FreeBSD$
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.122 2016/05/01 04:22:50 nonaka Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.123 2018/08/27 00:51:37 riastradh Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/atomic.h> 37#include <sys/atomic.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/proc.h> 40#include <sys/proc.h>
41#include <sys/device.h> 41#include <sys/device.h>
42#include <sys/conf.h> 42#include <sys/conf.h>
43#include <sys/xcall.h> 43#include <sys/xcall.h>
44 44
45#include <dev/pci/pcivar.h> 45#include <dev/pci/pcivar.h>
46#include <dev/pci/pcireg.h> 46#include <dev/pci/pcireg.h>
@@ -1480,27 +1480,34 @@ agp_i810_unbind_memory(struct agp_softc  @@ -1480,27 +1480,34 @@ agp_i810_unbind_memory(struct agp_softc
1480 case AGP_I810_MEMTYPE_HWCURSOR: 1480 case AGP_I810_MEMTYPE_HWCURSOR:
1481 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) 1481 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
1482 (void)agp_i810_unbind_page(sc, mem->am_offset + i); 1482 (void)agp_i810_unbind_page(sc, mem->am_offset + i);
1483 mem->am_offset = 0; 1483 mem->am_offset = 0;
1484 break; 1484 break;
1485 default: 1485 default:
1486 panic("invalid agp i810 memory type: %d", mem->am_type); 1486 panic("invalid agp i810 memory type: %d", mem->am_type);
1487 } 1487 }
1488 1488
1489 mem->am_is_bound = 0; 1489 mem->am_is_bound = 0;
1490 return 0; 1490 return 0;
1491} 1491}
1492 1492
 1493void
 1494agp_i810_reset(struct agp_i810_softc *isc)
 1495{
 1496
 1497 /* Restore the page table control register. */
 1498 bus_space_write_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL,
 1499 isc->pgtblctl);
 1500
 1501 agp_flush_cache();
 1502}
 1503
1493static bool 1504static bool
1494agp_i810_resume(device_t dv, const pmf_qual_t *qual) 1505agp_i810_resume(device_t dv, const pmf_qual_t *qual)
1495{ 1506{
1496 struct agp_softc *sc = device_private(dv); 1507 struct agp_softc *sc = device_private(dv);
1497 struct agp_i810_softc *isc = sc->as_chipc; 1508 struct agp_i810_softc *isc = sc->as_chipc;
1498 1509
1499 /* 1510 agp_i810_reset(isc);
1500 * XXX Nothing uses this! Save on suspend, restore on resume? 
1501 */ 
1502 isc->pgtblctl_resume_hack = READ4(AGP_I810_PGTBL_CTL); 
1503 agp_flush_cache(); 
1504 1511
1505 return true; 1512 return true;
1506} 1513}

cvs diff -r1.6 -r1.7 src/sys/dev/pci/agp_i810var.h (expand / switch to unified diff)

--- src/sys/dev/pci/agp_i810var.h 2015/03/06 22:03:06 1.6
+++ src/sys/dev/pci/agp_i810var.h 2018/08/27 00:51:37 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: agp_i810var.h,v 1.6 2015/03/06 22:03:06 riastradh Exp $ */ 1/* $NetBSD: agp_i810var.h,v 1.7 2018/08/27 00:51:37 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 Doug Rabson 4 * Copyright (c) 2000 Doug Rabson
5 * Copyright (c) 2000 Ruslan Ermilov 5 * Copyright (c) 2000 Ruslan Ermilov
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -48,30 +48,28 @@ struct agp_i810_softc { @@ -48,30 +48,28 @@ struct agp_i810_softc {
48 bus_space_tag_t gtt_bst; 48 bus_space_tag_t gtt_bst;
49 bus_space_handle_t gtt_bsh; 49 bus_space_handle_t gtt_bsh;
50 bus_size_t gtt_size; 50 bus_size_t gtt_size;
51 51
52 /* Chipset flush page. */ 52 /* Chipset flush page. */
53 bus_space_tag_t flush_bst; 53 bus_space_tag_t flush_bst;
54 bus_space_handle_t flush_bsh; 54 bus_space_handle_t flush_bsh;
55 bus_addr_t flush_addr; 55 bus_addr_t flush_addr;
56 56
57 /* i810-only fields. */ 57 /* i810-only fields. */
58 struct agp_gatt *gatt; /* i810-only OS-allocated GTT */ 58 struct agp_gatt *gatt; /* i810-only OS-allocated GTT */
59 uint32_t dcache_size; /* i810-only on-chip memory size */ 59 uint32_t dcache_size; /* i810-only on-chip memory size */
60 60
61 /* XXX Kludge to work around broken X servers. */ 61 /* Cached pgtblctl register for resume. */
62 pcireg_t pgtblctl; 62 pcireg_t pgtblctl;
63 
64 /* XXX Vestige of unfinished powerhook? */ 
65 uint32_t pgtblctl_resume_hack; 
66}; 63};
67 64
68extern struct agp_softc *agp_i810_sc; 65extern struct agp_softc *agp_i810_sc;
69 66
70#define AGP_I810_GTT_VALID 0x01 67#define AGP_I810_GTT_VALID 0x01
71#define AGP_I810_GTT_I810_DCACHE 0x02 /* i810-only */ 68#define AGP_I810_GTT_I810_DCACHE 0x02 /* i810-only */
72#define AGP_I810_GTT_CACHED 0x06 /* >=i830 */ 69#define AGP_I810_GTT_CACHED 0x06 /* >=i830 */
73 70
74int agp_i810_write_gtt_entry(struct agp_i810_softc *, off_t, bus_addr_t, 71int agp_i810_write_gtt_entry(struct agp_i810_softc *, off_t, bus_addr_t,
75 int); 72 int);
76void agp_i810_post_gtt_entry(struct agp_i810_softc *, off_t); 73void agp_i810_post_gtt_entry(struct agp_i810_softc *, off_t);
77void agp_i810_chipset_flush(struct agp_i810_softc *); 74void agp_i810_chipset_flush(struct agp_i810_softc *);
 75void agp_i810_reset(struct agp_i810_softc *);

cvs diff -r1.6 -r1.7 src/sys/external/bsd/drm2/i915drm/Attic/intel_gtt.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/i915drm/Attic/intel_gtt.c 2018/08/06 00:30:15 1.6
+++ src/sys/external/bsd/drm2/i915drm/Attic/intel_gtt.c 2018/08/27 00:51:37 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: intel_gtt.c,v 1.6 2018/08/06 00:30:15 riastradh Exp $ */ 1/* $NetBSD: intel_gtt.c,v 1.7 2018/08/27 00:51:37 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc. 4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* Intel GTT stubs */ 32/* Intel GTT stubs */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.6 2018/08/06 00:30:15 riastradh Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.7 2018/08/27 00:51:37 riastradh Exp $");
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/bus.h> 38#include <sys/bus.h>
39#include <sys/errno.h> 39#include <sys/errno.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41 41
42#include <machine/vmparam.h> 42#include <machine/vmparam.h>
43 43
44#include <dev/pci/pcivar.h> /* XXX agpvar.h needs... */ 44#include <dev/pci/pcivar.h> /* XXX agpvar.h needs... */
45#include <dev/pci/agpvar.h> 45#include <dev/pci/agpvar.h>
46#include <dev/pci/agp_i810var.h> 46#include <dev/pci/agp_i810var.h>
47 47
48#include "drm/intel-gtt.h" 48#include "drm/intel-gtt.h"
@@ -115,28 +115,34 @@ fail0: KASSERT(error); @@ -115,28 +115,34 @@ fail0: KASSERT(error);
115void 115void
116intel_gmch_remove(void) 116intel_gmch_remove(void)
117{ 117{
118 struct agp_softc *const sc = agp_i810_sc; 118 struct agp_softc *const sc = agp_i810_sc;
119 119
120 bus_dmamap_unload(sc->as_dmat, intel_gtt.scratch_map); 120 bus_dmamap_unload(sc->as_dmat, intel_gtt.scratch_map);
121 bus_dmamap_destroy(sc->as_dmat, intel_gtt.scratch_map); 121 bus_dmamap_destroy(sc->as_dmat, intel_gtt.scratch_map);
122 bus_dmamem_free(sc->as_dmat, &intel_gtt.scratch_seg, 1); 122 bus_dmamem_free(sc->as_dmat, &intel_gtt.scratch_seg, 1);
123} 123}
124 124
125bool 125bool
126intel_enable_gtt(void) 126intel_enable_gtt(void)
127{ 127{
 128 struct agp_softc *sc = agp_i810_sc;
 129 struct agp_i810_softc *isc;
128 130
129 return (agp_i810_sc != NULL); 131 if (sc == NULL)
 132 return false;
 133 isc = sc->as_chipc;
 134 agp_i810_reset(isc);
 135 return true;
130} 136}
131 137
132void 138void
133intel_gtt_chipset_flush(void) 139intel_gtt_chipset_flush(void)
134{ 140{
135 141
136 KASSERT(agp_i810_sc != NULL); 142 KASSERT(agp_i810_sc != NULL);
137 agp_i810_chipset_flush(agp_i810_sc->as_chipc); 143 agp_i810_chipset_flush(agp_i810_sc->as_chipc);
138} 144}
139 145
140void 146void
141intel_gtt_insert_entries(bus_dmamap_t dmamap, unsigned va_page, unsigned flags) 147intel_gtt_insert_entries(bus_dmamap_t dmamap, unsigned va_page, unsigned flags)
142{ 148{