? 1 ? i915_gem.c.works ? o ? warn-domain.patch Index: i915_gem.c =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c,v retrieving revision 1.27 diff -u -u -r1.27 i915_gem.c --- i915_gem.c 5 Mar 2015 01:04:51 -0000 1.27 +++ i915_gem.c 6 Mar 2015 22:11:32 -0000 @@ -1050,6 +1050,9 @@ int needs_clflush_before = 0; #ifndef __NetBSD__ struct sg_page_iter sg_iter; + int flush_mask = boot_cpu_data.x86_clflush_size - 1; +#else + int flush_mask = cpu_info_primary.ci_cflush_lsize - 1; #endif user_data = to_user_ptr(args->data_ptr); @@ -1083,48 +1086,18 @@ obj->dirty = 1; #ifdef __NetBSD__ - while (0 < remain) { - /* Get the next page. */ - shmem_page_offset = offset_in_page(offset); - KASSERT(shmem_page_offset < PAGE_SIZE); - page_length = MIN(remain, (PAGE_SIZE - shmem_page_offset)); + while (0 < remain) +#else + for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, + offset >> PAGE_SHIFT) +#endif + { +#ifdef __NetBSD__ struct page *const page = i915_gem_object_get_page(obj, atop(offset)); - - /* Decide whether to flush the cache or swizzle bit 17. */ - const bool partial_cacheline_write = needs_clflush_before && - ((shmem_page_offset | page_length) - & (cpu_info_primary.ci_cflush_lsize - 1)); - page_do_bit17_swizzling = obj_do_bit17_swizzling && - (page_to_phys(page) & (1 << 17)) != 0; - - /* Try the fast path. */ - ret = shmem_pwrite_fast(page, shmem_page_offset, page_length, - user_data, page_do_bit17_swizzling, - partial_cacheline_write, needs_clflush_after); - if (ret == 0) - goto next_page; - - /* Fast path failed. Try the slow path. */ - hit_slowpath = 1; - mutex_unlock(&dev->struct_mutex); - ret = shmem_pwrite_slow(page, shmem_page_offset, page_length, - user_data, page_do_bit17_swizzling, - partial_cacheline_write, needs_clflush_after); - mutex_lock(&dev->struct_mutex); - if (ret) - goto out; - -next_page: KASSERT(page_length <= remain); - remain -= page_length; - user_data += page_length; - offset += page_length; - } #else - for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, - offset >> PAGE_SHIFT) { struct page *page = sg_page_iter_page(&sg_iter); - int partial_cacheline_write; +#endif if (remain <= 0) break; @@ -1143,9 +1116,8 @@ /* If we don't overwrite a cacheline completely we need to be * careful to have up-to-date data by first clflushing. Don't * overcomplicate things and flush the entire patch. */ - partial_cacheline_write = needs_clflush_before && - ((shmem_page_offset | page_length) - & (boot_cpu_data.x86_clflush_size - 1)); + const int partial_cacheline_write = needs_clflush_before && + ((shmem_page_offset | page_length) & flush_mask); page_do_bit17_swizzling = obj_do_bit17_swizzling && (page_to_phys(page) & (1 << 17)) != 0; @@ -1174,7 +1146,6 @@ user_data += page_length; offset += page_length; } -#endif out: i915_gem_object_unpin_pages(obj);