diff options
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/i915/i915_drv.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem.c | 40 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem_execbuffer.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem_gtt.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem_tiling.c | 51 |
5 files changed, 34 insertions, 85 deletions
diff --git a/sys/dev/pci/drm/i915/i915_drv.h b/sys/dev/pci/drm/i915/i915_drv.h index 7fbc299fa55..c345f3a21ff 100644 --- a/sys/dev/pci/drm/i915/i915_drv.h +++ b/sys/dev/pci/drm/i915/i915_drv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_drv.h,v 1.44 2013/12/05 13:29:56 kettenis Exp $ */ +/* $OpenBSD: i915_drv.h,v 1.45 2013/12/11 20:31:43 kettenis Exp $ */ /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*- */ /* @@ -997,7 +997,7 @@ struct drm_i915_gem_object { unsigned int has_global_gtt_mapping:1; unsigned int has_dma_mapping:1; - bus_dma_segment_t *pages; + struct vm_page **pages; int pages_pin_count; /** diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c index d989bb65fc5..74a31677e98 100644 --- a/sys/dev/pci/drm/i915/i915_gem.c +++ b/sys/dev/pci/drm/i915/i915_gem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem.c,v 1.58 2013/12/09 20:09:55 kettenis Exp $ */ +/* $OpenBSD: i915_gem.c,v 1.59 2013/12/11 20:31:43 kettenis Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -1768,10 +1768,10 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj) } #else for (i = 0; i < page_count; i++) { - struct vm_page *pg = PHYS_TO_VM_PAGE(obj->pages[i].ds_addr); + struct vm_page *page = obj->pages[i]; if (obj->dirty) - atomic_clearbits_int(&pg->pg_flags, PG_CLEAN); + atomic_clearbits_int(&page->pg_flags, PG_CLEAN); } uvm_objunwire(obj->base.uao, 0, obj->base.size); #endif @@ -1877,9 +1877,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) gfp_t gfp; #else int page_count, i; - bus_dma_segment_t *segs; + struct vm_page **st; struct pglist plist; - struct vm_page *pg; + struct vm_page *page; #endif /* Assert that the object is not currently in any GPU domain. As it @@ -1939,9 +1939,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) obj->pages = st; #else page_count = obj->base.size / PAGE_SIZE; - segs = malloc(page_count * sizeof(*segs), M_DRM, - M_WAITOK | M_CANFAIL | M_ZERO); - if (segs == NULL) + st = malloc(page_count * sizeof(struct vm_page *), M_DRM, + M_WAITOK | M_CANFAIL); + if (st == NULL) return -ENOMEM; TAILQ_INIT(&plist); @@ -1949,12 +1949,11 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) goto err_pages; i = 0; - TAILQ_FOREACH(pg, &plist, pageq) { - segs[i].ds_addr = VM_PAGE_TO_PHYS(pg); - segs[i].ds_len = PAGE_SIZE; + TAILQ_FOREACH(page, &plist, pageq) { + st[i] = page; i++; } - obj->pages = segs; + obj->pages = st; #endif if (i915_gem_object_needs_bit17_swizzle(obj)) @@ -1971,7 +1970,7 @@ err_pages: return PTR_ERR(page); #else err_pages: - drm_free(segs); + drm_free(st); return -ENOMEM; #endif } @@ -3143,20 +3142,11 @@ i915_gem_clflush_object(struct drm_i915_gem_object *obj) drm_clflush_sg(obj->pages); #else { - bus_dma_segment_t *segp; int page_count = obj->base.size >> PAGE_SHIFT; - int i, n; + int i; - segp = &obj->pages[0]; - n = 0; - for (i = 0; i < page_count; i++) { - pmap_flush_page(segp->ds_addr + n); - n += PAGE_SIZE; - if (n >= segp->ds_len) { - n = 0; - segp++; - } - } + for (i = 0; i < page_count; i++) + pmap_flush_page(VM_PAGE_TO_PHYS(obj->pages[i])); } #endif } diff --git a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c index daba146d72c..79e7dc9ed75 100644 --- a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c +++ b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem_execbuffer.c,v 1.24 2013/12/07 10:48:35 kettenis Exp $ */ +/* $OpenBSD: i915_gem_execbuffer.c,v 1.25 2013/12/11 20:31:43 kettenis Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -1322,11 +1322,5 @@ kunmap_atomic(void *addr) static inline struct vm_page * i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n) { - bus_dma_segment_t *segp; - struct vm_page *pg; - - segp = &obj->pages[n]; - pg = PHYS_TO_VM_PAGE(segp->ds_addr); - - return (pg); + return (obj->pages[n]); } diff --git a/sys/dev/pci/drm/i915/i915_gem_gtt.c b/sys/dev/pci/drm/i915/i915_gem_gtt.c index 8b48227d5f9..4b634e782b7 100644 --- a/sys/dev/pci/drm/i915/i915_gem_gtt.c +++ b/sys/dev/pci/drm/i915/i915_gem_gtt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem_gtt.c,v 1.7 2013/12/07 10:53:29 kettenis Exp $ */ +/* $OpenBSD: i915_gem_gtt.c,v 1.8 2013/12/11 20:31:43 kettenis Exp $ */ /* * Copyright © 2010 Daniel Vetter * @@ -523,10 +523,9 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj, unsigned int flags = (cache_level == I915_CACHE_NONE) ? 0 : BUS_DMA_COHERENT; struct agp_softc *sc = dev->agp->agpdev; - bus_dma_segment_t *segp; bus_addr_t addr = sc->sc_apaddr + obj->gtt_space->start; int page_count = obj->base.size >> PAGE_SHIFT; - int i, n; + int i; switch (cache_level) { case I915_CACHE_NONE: @@ -542,16 +541,9 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj, BUG(); } - segp = &obj->pages[0]; - n = 0; for (i = 0; i < page_count; i++) { sc->sc_methods->bind_page(sc->sc_chipc, addr, - segp->ds_addr + n, flags); - n += PAGE_SIZE; - if (n >= segp->ds_len) { - n = 0; - segp++; - } + VM_PAGE_TO_PHYS(obj->pages[i]), flags); addr += PAGE_SIZE; } diff --git a/sys/dev/pci/drm/i915/i915_gem_tiling.c b/sys/dev/pci/drm/i915/i915_gem_tiling.c index 37d3139bab4..3681bbdf246 100644 --- a/sys/dev/pci/drm/i915/i915_gem_tiling.c +++ b/sys/dev/pci/drm/i915/i915_gem_tiling.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem_tiling.c,v 1.10 2013/11/20 21:55:23 kettenis Exp $ */ +/* $OpenBSD: i915_gem_tiling.c,v 1.11 2013/12/11 20:31:43 kettenis Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -474,7 +474,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data, * bit 17 of its physical address and therefore being interpreted differently * by the GPU. */ -static int +static void i915_gem_swizzle_page(struct vm_page *pg) { char temp[64]; @@ -485,10 +485,8 @@ i915_gem_swizzle_page(struct vm_page *pg) #if defined (__HAVE_PMAP_DIRECT) va = pmap_map_direct(pg); #else - va = uvm_km_valloc(kernel_map, PAGE_SIZE); - if (va == 0) - return (ENOMEM); - pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg), UVM_PROT_RW); + va = uvm_km_valloc_wait(kernel_map, PAGE_SIZE); + pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg), VM_PROT_READ|VM_PROT_WRITE); pmap_update(pmap_kernel()); #endif vaddr = (char *)va; @@ -506,41 +504,24 @@ i915_gem_swizzle_page(struct vm_page *pg) pmap_update(pmap_kernel()); uvm_km_free(kernel_map, va, PAGE_SIZE); #endif - return (0); } void i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj) { - struct vm_page *pg; - bus_dma_segment_t *segp; int page_count = obj->base.size >> PAGE_SHIFT; - int i, n, ret; + int i; if (obj->bit_17 == NULL) return; - segp = &obj->pages[0]; - n = 0; for (i = 0; i < page_count; i++) { - char new_bit_17 = (segp->ds_addr + n) >> 17; + struct vm_page *page = obj->pages[i]; + char new_bit_17 = VM_PAGE_TO_PHYS(page) >> 17; if ((new_bit_17 & 0x1) != (test_bit(i, obj->bit_17) != 0)) { - /* XXX move this to somewhere where we already have pg */ - pg = PHYS_TO_VM_PAGE(segp->ds_addr + n); - KASSERT(pg != NULL); - ret = i915_gem_swizzle_page(pg); - if (ret) { - printf("%s: page swizzle failed\n", __func__); - return; - } - atomic_clearbits_int(&pg->pg_flags, PG_CLEAN); - } - - n += PAGE_SIZE; - if (n >= segp->ds_len) { - n = 0; - segp++; + i915_gem_swizzle_page(page); + atomic_clearbits_int(&page->pg_flags, PG_CLEAN); } } } @@ -548,9 +529,8 @@ i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj) void i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj) { - bus_dma_segment_t *segp; int page_count = obj->base.size >> PAGE_SHIFT; - int i, n; + int i; if (obj->bit_17 == NULL) { /* round up number of pages to a multiple of 32 so we know what @@ -566,18 +546,11 @@ i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj) } } - segp = &obj->pages[0]; - n = 0; for (i = 0; i < page_count; i++) { - if ((segp->ds_addr + n) & (1 << 17)) + struct vm_page *page = obj->pages[i]; + if (VM_PAGE_TO_PHYS(page) & (1 << 17)) set_bit(i, obj->bit_17); else clear_bit(i, obj->bit_17); - - n += PAGE_SIZE; - if (n >= segp->ds_len) { - n = 0; - segp++; - } } } |