Module Name: src Committed By: maya Date: Thu Mar 9 08:27:18 UTC 2017
Modified Files: src/sys/external/bsd/drm2/dist/drm/ttm: ttm_tt.c src/sys/external/bsd/drm2/ttm: ttm_agp_backend.c ttm_bus_dma.c Log Message: Clarify ttm state transitions tt_unpopulated<->tt_unbound<->tt_bound. Assert it, too, and don't handle other cases. We can add the assertion to ttm_agp_tt_unpopulate because it is called by {nouveau,radeon}_ttm_tt_unpopulate, which is generically called ttm_tt_unpopulate. And the sole caller to ttm_tt_unpopulate (ttm_tt_destroy) only does so if the state is unbound. the other caller is in a !NetBSD block. We can add the assertion to ttm_agp_tt_populate and avoid handling the !unpopulated case because the sole callers are {nouveau,radeon}_ttm_tt_populate both of which return early in the !unpopulated case. We can change the assertion on ttm_tt_wire because it is solely called by ttm_bus_dma_populate, which already asserts that it is the unpopulated case. from riastradh To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/ttm/ttm_agp_backend.c cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c diff -u src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c:1.8 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c:1.9 --- src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c:1.8 Sat Dec 24 15:46:50 2016 +++ src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c Thu Mar 9 08:27:18 2017 @@ -360,9 +360,9 @@ EXPORT_SYMBOL(ttm_tt_bind); * ttm_tt_wire(ttm) * * Wire the uvm pages of ttm and fill the ttm page array. ttm - * must be unpopulated or unbound, and must be marked swapped. - * This does not change either state -- the caller is expected to - * include it among other operations for such a state transition. + * must be unpopulated, and must be marked swapped. This does not + * change either state -- the caller is expected to include it + * among other operations for such a state transition. */ int ttm_tt_wire(struct ttm_tt *ttm) @@ -372,9 +372,8 @@ ttm_tt_wire(struct ttm_tt *ttm) unsigned i; int error; - KASSERTMSG((ttm->state == tt_unpopulated || ttm->state == tt_unbound), - "ttm_tt %p must be unpopulated or unbound for wiring," - " but state=%d", + KASSERTMSG((ttm->state == tt_unpopulated), + "ttm_tt %p must be unpopulated for wiring, but state=%d", ttm, (int)ttm->state); KASSERT(ISSET(ttm->page_flags, TTM_PAGE_FLAG_SWAPPED)); KASSERT(uobj != NULL); Index: src/sys/external/bsd/drm2/ttm/ttm_agp_backend.c diff -u src/sys/external/bsd/drm2/ttm/ttm_agp_backend.c:1.5 src/sys/external/bsd/drm2/ttm/ttm_agp_backend.c:1.6 --- src/sys/external/bsd/drm2/ttm/ttm_agp_backend.c:1.5 Sat Oct 17 21:05:57 2015 +++ src/sys/external/bsd/drm2/ttm/ttm_agp_backend.c Thu Mar 9 08:27:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ttm_agp_backend.c,v 1.5 2015/10/17 21:05:57 jmcneill Exp $ */ +/* $NetBSD: ttm_agp_backend.c,v 1.6 2017/03/09 08:27:18 maya Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ttm_agp_backend.c,v 1.5 2015/10/17 21:05:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ttm_agp_backend.c,v 1.6 2017/03/09 08:27:18 maya Exp $"); #include <sys/types.h> #include <sys/kmem.h> @@ -78,9 +78,9 @@ int ttm_agp_tt_populate(struct ttm_tt *ttm) { - if (ttm->state != tt_unpopulated) - return 0; - + KASSERTMSG((ttm->state == tt_unpopulated), + "ttm_agp_tt_populate: ttm %p state is not tt_unpopulated: %d", + ttm, (int)ttm->state); return ttm_bus_dma_populate(container_of(ttm, struct ttm_dma_tt, ttm)); } @@ -88,6 +88,9 @@ void ttm_agp_tt_unpopulate(struct ttm_tt *ttm) { + KASSERTMSG((ttm->state == tt_unbound), + "ttm_agp_tt_unpopulate: ttm %p state is not tt_unbound: %d", + ttm, (int)ttm->state); ttm_bus_dma_unpopulate(container_of(ttm, struct ttm_dma_tt, ttm)); } Index: src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c diff -u src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c:1.6 src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c:1.7 --- src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c:1.6 Thu Mar 9 08:05:21 2017 +++ src/sys/external/bsd/drm2/ttm/ttm_bus_dma.c Thu Mar 9 08:27:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ttm_bus_dma.c,v 1.6 2017/03/09 08:05:21 maya Exp $ */ +/* $NetBSD: ttm_bus_dma.c,v 1.7 2017/03/09 08:27:18 maya Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ttm_bus_dma.c,v 1.6 2017/03/09 08:05:21 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ttm_bus_dma.c,v 1.7 2017/03/09 08:27:18 maya Exp $"); #include <sys/bus.h> @@ -47,8 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: ttm_bus_dma. * its DMA map. The wiring and loading are stable as long as the * associated bo is reserved. * - * Transitions from tt_unpopulated or tt_unbound to tt_unbound. - * Marks as wired, a.k.a. !swapped. + * Transitions from tt_unpopulated to tt_unbound. Marks as wired, + * a.k.a. !swapped. */ int ttm_bus_dma_populate(struct ttm_dma_tt *ttm_dma)