tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: tracking P->V for unmanaged device pages



Hi Taylor,

On Thu, Mar 26, 2015 at 12:13:56PM +0000, Taylor R Campbell wrote:
> Various DRM graphics drivers, including Intel, Radeon, and Nouveau,
> sometimes need to unmap all virtual mappings of certain physical
> pages for which there is no struct vm_page.  The issue is explained in
> detail here:
...

> Index: sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c
> ===================================================================
> RCS file: /cvsroot/src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c,v
> retrieving revision 1.6
> diff -p -u -r1.6 ttm_bo.c
> --- sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c	18 Aug 2014 02:43:27 -0000	1.6
> +++ sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c	23 Mar 2015 13:13:57 -0000
> @@ -1611,11 +1611,16 @@ void ttm_bo_unmap_virtual_locked(struct 
>  
>  #ifdef __NetBSD__
>  	if (bo->mem.bus.is_iomem) {
> -		/*
> -		 * XXX OOPS!  NetBSD doesn't have a way to enumerate
> -		 * and remove the virtual mappings for device addresses
> -		 * or of a uvm object.
> -		 */
> +		paddr_t start, end, pa;
> +
> +		KASSERT((bo->mem.bus.base & (PAGE_SIZE - 1)) == 0);
> +		KASSERT((bo->mem.bus.offset & (PAGE_SIZE - 1)) == 0);
> +		start = bo->mem.bus.base + bo->mem.bus.offset;
> +		KASSERT((bo->mem.bus.size & (PAGE_SIZE - 1)) == 0);
> +		end = start + bo->mem.bus.size;
> +
> +		for (pa = start; pa < end; pa += PAGE_SIZE)
> +			pmap_pv_protect(pa, VM_PROT_NONE);
>  	} else if (bo->ttm != NULL) {
>  		unsigned i;
>  

I got a panic here:
Apr 14 21:18:10 diablo savecore: reboot after panic: panic: kernel diagnostic
assertion "(bo->mem.bus.base & (PAGE_SIZE - 1)) == 0" failed: file
"../../../../external/bsd/drm2/dist/drm/ttm/ttm_bo.c", line 1618 bo bus base
addr not page-aligned: fffffe833a3989b0

The trace i get:
#0  0xffffffff80684ae5 in cpu_reboot ()
#1  0xffffffff808c5cf4 in vpanic ()
#2  0xffffffff80a78443 in kern_assert ()
#3  0xffffffff8091ca9a in ttm_bo_unmap_virtual_locked ()
#4  0xffffffff8091d10d in ttm_bo_unmap_virtual ()
#5  0xffffffff807cc4aa in radeon_pm_set_clocks ()
#6  0xffffffff807cd65f in radeon_pm_compute_clocks ()
#7  0xffffffff802c8548 in drm_crtc_helper_set_mode ()
#8  0xffffffff807b44d7 in radeon_connector_set_property ()
#9  0xffffffff802c64dc in drm_mode_obj_set_property_ioctl ()
#10 0xffffffff802c66fa in drm_mode_connector_property_set_ioctl ()
#11 0xffffffff802ca9da in drm_ioctl ()
#12 0xffffffff808d8799 in sys_ioctl ()
#13 0xffffffff808e37f7 in syscall ()
#14 0xffffffff80100691 in Xsyscall ()

version 1.6 of ttm_bo.c (checkout kernel source date 20150402) works fine.

I hope this will shed some light on it, no clue yet as to why yet though.

(note to myself, crash 113)

With regards,
Reinoud



Home | Main Index | Thread Index | Old Index