Module Name: src Committed By: martin Date: Fri Aug 31 17:43:03 UTC 2018
Modified Files: src/sys/external/bsd/common/include/linux [netbsd-8]: kernel.h src/sys/external/bsd/drm2/i915drm [netbsd-8]: intel_gtt.c src/sys/external/bsd/drm2/include/linux [netbsd-8]: bitops.h delay.h vmalloc.h Log Message: Pull up following revision(s) (requested by riastradh in ticket #997): sys/external/bsd/drm2/i915drm/intel_gtt.c: revision 1.6 sys/external/bsd/drm2/include/linux/delay.h: revision 1.5 sys/external/bsd/common/include/linux/kernel.h: revision 1.9 sys/external/bsd/drm2/include/linux/vmalloc.h: revision 1.5 sys/external/bsd/drm2/include/linux/bitops.h: revision 1.12 sys/external/bsd/drm2/include/linux/bitops.h: revision 1.13 hweight32 should take uint32_t, not uint16_t. OOPS. XXX pullup Fix find_first_zero_bit to find the high bits of 64-bit words...oops. XXX pullup Use uvm_km_alloc(kernel_map) and pmap_kenter, not uvm_pagermapin. XXX pullup Flush chipset writes after GGTT update. Echoes Linux commit: commit 8516673a996870ea0ceb337ee4f83c33c5ec3111 Author: Chris Wilson <chris%chris-wilson.co.uk@localhost> Date: Fri Dec 8 21:46:16 2017 +0000 agp/intel: Flush all chipset writes after updating the GGTT Before accessing the GGTT we must flush the PTE writes and make them visible to the chipset, or else the indirect access may end up in the wrong page. In commit 3497971a71d8 ("agp/intel: Flush chipset writes after updating a single PTE"), we noticed corruption of the uploads for pwrite and for capturing GPU error states, but it was presumed that the explicit calls to intel_gtt_chipset_flush() were sufficient for the execbuffer path. However, we have not been flushing the chipset between the PTE writes and access via the GTT itself. For simplicity, do the flush after any PTE update rather than try and batch the flushes on a just-in-time basis. References: 3497971a71d8 ("agp/intel: Flush chipset writes after updating a single PTE") Signed-off-by: Chris Wilson <chris%chris-wilson.co.uk@localhost> Cc: Tvrtko Ursulin <tvrtko.ursulin%intel.com@localhost> Cc: Mika Kuoppala <mika.kuoppala%intel.com@localhost> Cc: drm-intel-fixes%lists.freedesktop.org@localhost Reviewed-by: Joonas Lahtinen <joonas.lahtinen%linux.intel.com@localhost> Link: https://patchwork.freedesktop.org/patch/msgid/20171208214616.30147-1-chris%chris-wilson.co.uk@localhost XXX pullup Round nsec up for usec delay. XXX pullup libkern min/max is 32-bit. Linux min/max is generic. @!*#@!$& XXX pullup To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.8.10.1 \ src/sys/external/bsd/common/include/linux/kernel.h cvs rdiff -u -r1.5 -r1.5.10.1 src/sys/external/bsd/drm2/i915drm/intel_gtt.c cvs rdiff -u -r1.11 -r1.11.10.1 \ src/sys/external/bsd/drm2/include/linux/bitops.h cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/external/bsd/drm2/include/linux/delay.h cvs rdiff -u -r1.4 -r1.4.12.1 \ src/sys/external/bsd/drm2/include/linux/vmalloc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/common/include/linux/kernel.h diff -u src/sys/external/bsd/common/include/linux/kernel.h:1.8 src/sys/external/bsd/common/include/linux/kernel.h:1.8.10.1 --- src/sys/external/bsd/common/include/linux/kernel.h:1.8 Thu Aug 20 21:41:12 2015 +++ src/sys/external/bsd/common/include/linux/kernel.h Fri Aug 31 17:43:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kernel.h,v 1.8 2015/08/20 21:41:12 skrll Exp $ */ +/* $NetBSD: kernel.h,v 1.8.10.1 2018/08/31 17:43:03 martin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -59,6 +59,9 @@ #define uninitialized_var(x) x = 0 /* XXX These will multiply evaluate their arguments. */ +#define min(X, Y) MIN(X, Y) +#define max(X, Y) MAX(X, Y) + #define max_t(T, X, Y) MAX(X, Y) #define min_t(T, X, Y) MIN(X, Y) Index: src/sys/external/bsd/drm2/i915drm/intel_gtt.c diff -u src/sys/external/bsd/drm2/i915drm/intel_gtt.c:1.5 src/sys/external/bsd/drm2/i915drm/intel_gtt.c:1.5.10.1 --- src/sys/external/bsd/drm2/i915drm/intel_gtt.c:1.5 Fri Mar 6 22:03:06 2015 +++ src/sys/external/bsd/drm2/i915drm/intel_gtt.c Fri Aug 31 17:43:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intel_gtt.c,v 1.5 2015/03/06 22:03:06 riastradh Exp $ */ +/* $NetBSD: intel_gtt.c,v 1.5.10.1 2018/08/31 17:43:03 martin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ /* Intel GTT stubs */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.5 2015/03/06 22:03:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.5.10.1 2018/08/31 17:43:03 martin Exp $"); #include <sys/types.h> #include <sys/bus.h> @@ -176,6 +176,7 @@ intel_gtt_insert_entries(bus_dmamap_t dm va += PAGE_SIZE; } agp_i810_post_gtt_entry(isc, (va - PAGE_SIZE)); + intel_gtt_chipset_flush(); } void Index: src/sys/external/bsd/drm2/include/linux/bitops.h diff -u src/sys/external/bsd/drm2/include/linux/bitops.h:1.11 src/sys/external/bsd/drm2/include/linux/bitops.h:1.11.10.1 --- src/sys/external/bsd/drm2/include/linux/bitops.h:1.11 Tue Oct 13 00:42:59 2015 +++ src/sys/external/bsd/drm2/include/linux/bitops.h Fri Aug 31 17:43:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bitops.h,v 1.11 2015/10/13 00:42:59 riastradh Exp $ */ +/* $NetBSD: bitops.h,v 1.11.10.1 2018/08/31 17:43:03 martin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ hweight16(uint16_t n) } static inline unsigned int -hweight32(uint16_t n) +hweight32(uint32_t n) { return popcount32(n); } @@ -171,7 +171,8 @@ find_first_zero_bit(const unsigned long break; } - result += ffs(~*p | (~0UL << MIN(nbits, bpl))); + CTASSERT(sizeof(unsigned long) <= sizeof(uint64_t)); + result += ffs64(~(uint64_t)*p | (~0UL << MIN(nbits, bpl))); return result; } Index: src/sys/external/bsd/drm2/include/linux/delay.h diff -u src/sys/external/bsd/drm2/include/linux/delay.h:1.4 src/sys/external/bsd/drm2/include/linux/delay.h:1.4.10.1 --- src/sys/external/bsd/drm2/include/linux/delay.h:1.4 Fri Feb 19 21:08:19 2016 +++ src/sys/external/bsd/drm2/include/linux/delay.h Fri Aug 31 17:43:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: delay.h,v 1.4 2016/02/19 21:08:19 skrll Exp $ */ +/* $NetBSD: delay.h,v 1.4.10.1 2018/08/31 17:43:03 martin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ static inline void ndelay(unsigned int nsec) { - DELAY(nsec / 1000); + DELAY((nsec + 999) / 1000); } #endif /* _LINUX_DELAY_H_ */ Index: src/sys/external/bsd/drm2/include/linux/vmalloc.h diff -u src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.4 src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.4.12.1 --- src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.4 Sat Aug 23 08:03:33 2014 +++ src/sys/external/bsd/drm2/include/linux/vmalloc.h Fri Aug 31 17:43:03 2018 @@ -1,7 +1,7 @@ -/* $NetBSD: vmalloc.h,v 1.4 2014/08/23 08:03:33 riastradh Exp $ */ +/* $NetBSD: vmalloc.h,v 1.4.12.1 2018/08/31 17:43:03 martin Exp $ */ /*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. + * Copyright (c) 2013, 2018 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -38,6 +38,8 @@ #include <linux/mm_types.h> +#include <asm/page.h> + static inline bool is_vmalloc_addr(void *addr) { @@ -69,28 +71,67 @@ vfree(void *ptr) return free(ptr, M_TEMP); } -#define PAGE_KERNEL 0 /* XXX pgprot */ +#define PAGE_KERNEL UVM_PROT_RW +/* + * vmap(pages, npages, flags, prot) + * + * Map pages[0], pages[1], ..., pages[npages-1] into contiguous + * kernel virtual address space with the specified protection, and + * return a KVA pointer to the start. + * + * prot may be a bitwise ior of UVM_PROT_READ/WRITE/EXEC and + * PMAP_* cache flags accepted by pmap_enter(). + */ static inline void * -vmap(struct page **pages, unsigned npages, unsigned long flags __unused, - pgprot_t prot __unused) +vmap(struct page **pages, unsigned npages, unsigned long flags, + pgprot_t protflags) { + vm_prot_t justprot = protflags & UVM_PROT_ALL; vaddr_t va; + unsigned i; - /* XXX Sleazy cast should be OK here. */ - __CTASSERT(sizeof(*pages[0]) == sizeof(struct vm_page)); - va = uvm_pagermapin((struct vm_page **)pages, npages, 0); + /* Allocate some KVA, or return NULL if we can't. */ + va = uvm_km_alloc(kernel_map, (vsize_t)npages << PAGE_SHIFT, PAGE_SIZE, + UVM_KMF_VAONLY|UVM_KMF_NOWAIT); if (va == 0) return NULL; + /* Ask pmap to map the KVA to the specified page addresses. */ + for (i = 0; i < npages; i++) { + pmap_kenter_pa(va + i*PAGE_SIZE, page_to_phys(pages[i]), + justprot, protflags); + } + + /* Commit the pmap updates. */ + pmap_update(pmap_kernel()); + return (void *)va; } +/* + * vunmap(ptr, npages) + * + * Unmap the KVA pages starting at ptr that were mapped by a call + * to vmap with the same npages parameter. + */ static inline void vunmap(void *ptr, unsigned npages) { + vaddr_t va = (vaddr_t)ptr; + + /* Ask pmap to unmap the KVA. */ + pmap_kremove(va, (vsize_t)npages << PAGE_SHIFT); + + /* Commit the pmap updates. */ + pmap_update(pmap_kernel()); - uvm_pagermapout((vaddr_t)ptr, npages); + /* + * Now that the pmap is no longer mapping the KVA we allocated + * on any CPU, it is safe to free the KVA. + */ + uvm_km_free(kernel_map, va, (vsize_t)npages << PAGE_SHIFT, + UVM_KMF_VAONLY); } #endif /* _LINUX_VMALLOC_H_ */