From: jsg Date: Wed, 20 Mar 2024 02:47:24 +0000 (+0000) Subject: add replacements for io_mapping_init_wc() paths X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=56f0ffbe28176ef7906dc89bebb3974c944e3d1d;p=openbsd add replacements for io_mapping_init_wc() paths --- diff --git a/sys/dev/pci/drm/i915/gem/i915_gem_stolen.c b/sys/dev/pci/drm/i915/gem/i915_gem_stolen.c index a07b1a10498..0c9dc66cef1 100644 --- a/sys/dev/pci/drm/i915/gem/i915_gem_stolen.c +++ b/sys/dev/pci/drm/i915/gem/i915_gem_stolen.c @@ -821,19 +821,41 @@ static int init_stolen_lmem(struct intel_memory_region *mem) return 0; } - STUB(); - return -ENOSYS; -#ifdef notyet +#ifdef __linux__ if (mem->io_size && !io_mapping_init_wc(&mem->iomap, mem->io_start, mem->io_size)) goto err_cleanup; +#else + if (mem->io_size) { + paddr_t start, end; + struct vm_page *pgs; + int i; + bus_space_handle_t bsh; + + start = atop(mem->io_start); + end = start + atop(mem->io_size); + uvm_page_physload(start, end, start, end, PHYSLOAD_DEVICE); + + pgs = PHYS_TO_VM_PAGE(mem->io_start); + for (i = 0; i < atop(mem->io_size); i++) + atomic_setbits_int(&(pgs[i].pg_flags), PG_PMAP_WC); + + if (bus_space_map(i915->bst, mem->io_start, mem->io_size, + BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &bsh)) + panic("can't map stolen lmem"); + + mem->iomap.base = mem->io_start; + mem->iomap.size = mem->io_size; + mem->iomap.iomem = bus_space_vaddr(i915->bst, bsh); + } +#endif drm_dbg(&i915->drm, "Stolen Local memory IO start: %pa\n", &mem->io_start); drm_dbg(&i915->drm, "Stolen Local DSM base: %pa\n", &mem->region.start); return 0; - +#ifdef __linux__ err_cleanup: i915_gem_cleanup_stolen(mem->i915); return err; diff --git a/sys/dev/pci/drm/i915/gt/intel_region_lmem.c b/sys/dev/pci/drm/i915/gt/intel_region_lmem.c index 511b3b3766e..6b6143eeb5a 100644 --- a/sys/dev/pci/drm/i915/gt/intel_region_lmem.c +++ b/sys/dev/pci/drm/i915/gt/intel_region_lmem.c @@ -153,15 +153,36 @@ region_lmem_release(struct intel_memory_region *mem) static int region_lmem_init(struct intel_memory_region *mem) { - STUB(); - return -ENOSYS; -#ifdef notyet int ret; +#ifdef __linux__ if (!io_mapping_init_wc(&mem->iomap, mem->io_start, mem->io_size)) return -EIO; +#else + struct drm_i915_private *i915 = mem->i915; + paddr_t start, end; + struct vm_page *pgs; + int i; + bus_space_handle_t bsh; + + start = atop(mem->io_start); + end = start + atop(mem->io_size); + uvm_page_physload(start, end, start, end, PHYSLOAD_DEVICE); + + pgs = PHYS_TO_VM_PAGE(mem->io_start); + for (i = 0; i < atop(mem->io_size); i++) + atomic_setbits_int(&(pgs[i].pg_flags), PG_PMAP_WC); + + if (bus_space_map(i915->bst, mem->io_start, mem->io_size, + BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &bsh)) + panic("can't map lmem"); + + mem->iomap.base = mem->io_start; + mem->iomap.size = mem->io_size; + mem->iomap.iomem = bus_space_vaddr(i915->bst, bsh); +#endif ret = intel_region_ttm_init(mem); if (ret) @@ -170,10 +191,11 @@ region_lmem_init(struct intel_memory_region *mem) return 0; out_no_buddy: +#ifdef __linux__ io_mapping_fini(&mem->iomap); +#endif return ret; -#endif } static const struct intel_memory_region_ops intel_region_lmem_ops = { diff --git a/sys/dev/pci/drm/i915/intel_memory_region.h b/sys/dev/pci/drm/i915/intel_memory_region.h index 961c62b07f5..935f299db32 100644 --- a/sys/dev/pci/drm/i915/intel_memory_region.h +++ b/sys/dev/pci/drm/i915/intel_memory_region.h @@ -70,9 +70,7 @@ struct intel_memory_region { const struct intel_memory_region_ops *ops; -#ifdef notyet struct io_mapping iomap; -#endif struct resource region; resource_size_t io_start;