The attached diff fixes amdgpu(4) and might very well fix radeondrm(4) as well. The problems with the hardware cursor are gone, various screen corruptions no longer seem to happen and the laptop I have here suspends and resumes now. I still occasionally see some glitches playing youtube videos, but overall this seems to be huge improvement.

Apologies for sending the diff as an attachment, but I'm stuck with having to use webmail at this moment.

ok?
Index: dev/pci/drm/ttm/ttm_bo.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/drm/ttm/ttm_bo.c,v
retrieving revision 1.25
diff -u -p -r1.25 ttm_bo.c
--- dev/pci/drm/ttm/ttm_bo.c	20 Apr 2019 08:44:08 -0000	1.25
+++ dev/pci/drm/ttm/ttm_bo.c	22 Jan 2020 02:01:12 -0000
@@ -1609,7 +1609,34 @@ void ttm_bo_unmap_virtual_locked(struct 
 {
 	struct ttm_bo_device *bdev = bo->bdev;
 
+#ifdef __linux__
 	drm_vma_node_unmap(&bo->vma_node, bdev->dev_mapping);
+#else
+	if (drm_vma_node_has_offset(&bo->vma_node) &&
+	    bo->mem.bus.io_reserved_vm) {
+		struct vm_page *pg;
+		bus_addr_t addr;
+		paddr_t paddr;
+		unsigned i;
+
+		if (bo->mem.bus.is_iomem) {
+			addr = bo->mem.bus.base + bo->mem.bus.offset;
+			paddr = bus_space_mmap(bdev->memt, addr, 0, 0, 0);
+			for (i = 0; i < bo->mem.num_pages; i++) {
+				pg = PHYS_TO_VM_PAGE(paddr);
+				if (pg)
+					pmap_page_protect(pg, PROT_NONE);
+				paddr += PAGE_SIZE;
+			}
+		} else if (bo->ttm) {
+			for (i = 0; i < bo->ttm->num_pages; i++) {
+				pg = bo->ttm->pages[i];
+				if (pg)
+					pmap_page_protect(pg, PROT_NONE);
+			}
+		}
+	}
+#endif
 	ttm_mem_io_free_vm(bo);
 }
 

Reply via email to