dev_priv = nouveau_bdev(ttm->bdev);
        dev = dev_priv->dev;
 
+#if __OS_HAS_AGP
+       if (dev_priv->gart_info.type == NOUVEAU_GART_AGP) {
+               return ttm_agp_tt_populate(ttm);
+       }
+#endif
+
 #ifdef CONFIG_SWIOTLB
        if (swiotlb_nr_tbl()) {
                return ttm_dma_populate((void *)ttm, dev->dev);
        dev_priv = nouveau_bdev(ttm->bdev);
        dev = dev_priv->dev;
 
+#if __OS_HAS_AGP
+       if (dev_priv->gart_info.type == NOUVEAU_GART_AGP) {
+               ttm_agp_tt_unpopulate(ttm);
+               return;
+       }
+#endif
+
 #ifdef CONFIG_SWIOTLB
        if (swiotlb_nr_tbl()) {
                ttm_dma_unpopulate((void *)ttm, dev->dev);
 
                return 0;
 
        rdev = radeon_get_rdev(ttm->bdev);
+#if __OS_HAS_AGP
+       if (rdev->flags & RADEON_IS_AGP) {
+               return ttm_agp_tt_populate(ttm);
+       }
+#endif
 
 #ifdef CONFIG_SWIOTLB
        if (swiotlb_nr_tbl()) {
        unsigned i;
 
        rdev = radeon_get_rdev(ttm->bdev);
+#if __OS_HAS_AGP
+       if (rdev->flags & RADEON_IS_AGP) {
+               ttm_agp_tt_unpopulate(ttm);
+               return;
+       }
+#endif
 
 #ifdef CONFIG_SWIOTLB
        if (swiotlb_nr_tbl()) {
 
 
 #include "ttm/ttm_module.h"
 #include "ttm/ttm_bo_driver.h"
+#include "ttm/ttm_page_alloc.h"
 #ifdef TTM_HAS_AGP
 #include "ttm/ttm_placement.h"
 #include <linux/agp_backend.h>
 
        if (agp_be->mem)
                ttm_agp_unbind(ttm);
+       ttm_tt_fini(ttm);
        kfree(agp_be);
 }
 
 }
 EXPORT_SYMBOL(ttm_agp_tt_create);
 
+int ttm_agp_tt_populate(struct ttm_tt *ttm)
+{
+       if (ttm->state != tt_unpopulated)
+               return 0;
+
+       return ttm_pool_populate(ttm);
+}
+EXPORT_SYMBOL(ttm_agp_tt_populate);
+
+void ttm_agp_tt_unpopulate(struct ttm_tt *ttm)
+{
+       ttm_pool_unpopulate(ttm);
+}
+EXPORT_SYMBOL(ttm_agp_tt_unpopulate);
+
 #endif
 
        ttm->page_flags = page_flags;
        ttm->dummy_read_page = dummy_read_page;
        ttm->state = tt_unpopulated;
+       ttm->swap_storage = NULL;
 
        ttm_tt_alloc_page_directory(ttm);
        if (!ttm->pages) {
        ttm->page_flags = page_flags;
        ttm->dummy_read_page = dummy_read_page;
        ttm->state = tt_unpopulated;
+       ttm->swap_storage = NULL;
 
        INIT_LIST_HEAD(&ttm_dma->pages_list);
        ttm_dma_tt_alloc_page_directory(ttm_dma);
 
                                        struct agp_bridge_data *bridge,
                                        unsigned long size, uint32_t page_flags,
                                        struct page *dummy_read_page);
+int ttm_agp_tt_populate(struct ttm_tt *ttm);
+void ttm_agp_tt_unpopulate(struct ttm_tt *ttm);
 #endif
 
 #endif