drm (ast, cirrus, mgag200, nouveau, savage, vmwgfx): Remove drm_mtrr_{add, del}
authorAndy Lutomirski <luto@amacapital.net>
Mon, 13 May 2013 23:58:41 +0000 (23:58 +0000)
committerDave Airlie <airlied@redhat.com>
Fri, 31 May 2013 03:02:54 +0000 (13:02 +1000)
This replaces drm_mtrr_{add,del} with arch_phys_wc_{add,del}.  The
interface is simplified (because the base and size parameters to
drm_mtrr_del never did anything), and it no longer adds MTRRs on
systems that don't need them.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/ast/ast_ttm.c
drivers/gpu/drm/cirrus/cirrus_ttm.c
drivers/gpu/drm/mgag200/mgag200_ttm.c
drivers/gpu/drm/nouveau/nouveau_ttm.c
drivers/gpu/drm/savage/savage_bci.c
drivers/gpu/drm/savage/savage_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
include/drm/drmP.h

index 09da3393c527188f85a5e5f42316c502788e1a93..a5a1a034033dcb5d4cb1a074ef8227dcaf78d5e5 100644 (file)
@@ -271,26 +271,19 @@ int ast_mm_init(struct ast_private *ast)
                return ret;
        }
 
                return ret;
        }
 
-       ast->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
-                                   pci_resource_len(dev->pdev, 0),
-                                   DRM_MTRR_WC);
+       ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
+                                       pci_resource_len(dev->pdev, 0));
 
        return 0;
 }
 
 void ast_mm_fini(struct ast_private *ast)
 {
 
        return 0;
 }
 
 void ast_mm_fini(struct ast_private *ast)
 {
-       struct drm_device *dev = ast->dev;
        ttm_bo_device_release(&ast->ttm.bdev);
 
        ast_ttm_global_release(ast);
 
        ttm_bo_device_release(&ast->ttm.bdev);
 
        ast_ttm_global_release(ast);
 
-       if (ast->fb_mtrr >= 0) {
-               drm_mtrr_del(ast->fb_mtrr,
-                            pci_resource_start(dev->pdev, 0),
-                            pci_resource_len(dev->pdev, 0), DRM_MTRR_WC);
-               ast->fb_mtrr = -1;
-       }
+       arch_phys_wc_del(ast->fb_mtrr);
 }
 
 void ast_ttm_placement(struct ast_bo *bo, int domain)
 }
 
 void ast_ttm_placement(struct ast_bo *bo, int domain)
index 2ed8cfc740c9fa1845d86edcd876644b69302f82..36b9b0bab1daf9f19e1f229f819f9249af077491 100644 (file)
@@ -271,9 +271,8 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
                return ret;
        }
 
                return ret;
        }
 
-       cirrus->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
-                                   pci_resource_len(dev->pdev, 0),
-                                   DRM_MTRR_WC);
+       cirrus->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
+                                          pci_resource_len(dev->pdev, 0));
 
        cirrus->mm_inited = true;
        return 0;
 
        cirrus->mm_inited = true;
        return 0;
@@ -281,8 +280,6 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
 
 void cirrus_mm_fini(struct cirrus_device *cirrus)
 {
 
 void cirrus_mm_fini(struct cirrus_device *cirrus)
 {
-       struct drm_device *dev = cirrus->dev;
-
        if (!cirrus->mm_inited)
                return;
 
        if (!cirrus->mm_inited)
                return;
 
@@ -290,12 +287,8 @@ void cirrus_mm_fini(struct cirrus_device *cirrus)
 
        cirrus_ttm_global_release(cirrus);
 
 
        cirrus_ttm_global_release(cirrus);
 
-       if (cirrus->fb_mtrr >= 0) {
-               drm_mtrr_del(cirrus->fb_mtrr,
-                            pci_resource_start(dev->pdev, 0),
-                            pci_resource_len(dev->pdev, 0), DRM_MTRR_WC);
-               cirrus->fb_mtrr = -1;
-       }
+       arch_phys_wc_del(cirrus->fb_mtrr);
+       cirrus->fb_mtrr = 0;
 }
 
 void cirrus_ttm_placement(struct cirrus_bo *bo, int domain)
 }
 
 void cirrus_ttm_placement(struct cirrus_bo *bo, int domain)
index 401c9891d3a8b7cfdf37ed4f40e1a5c5e79b050f..0004f7740b8e0a5c0cde9fc79fa169a5c5f2b413 100644 (file)
@@ -270,26 +270,20 @@ int mgag200_mm_init(struct mga_device *mdev)
                return ret;
        }
 
                return ret;
        }
 
-       mdev->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
-                                   pci_resource_len(dev->pdev, 0),
-                                   DRM_MTRR_WC);
+       mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
+                                        pci_resource_len(dev->pdev, 0));
 
        return 0;
 }
 
 void mgag200_mm_fini(struct mga_device *mdev)
 {
 
        return 0;
 }
 
 void mgag200_mm_fini(struct mga_device *mdev)
 {
-       struct drm_device *dev = mdev->dev;
        ttm_bo_device_release(&mdev->ttm.bdev);
 
        mgag200_ttm_global_release(mdev);
 
        ttm_bo_device_release(&mdev->ttm.bdev);
 
        mgag200_ttm_global_release(mdev);
 
-       if (mdev->fb_mtrr >= 0) {
-               drm_mtrr_del(mdev->fb_mtrr,
-                            pci_resource_start(dev->pdev, 0),
-                            pci_resource_len(dev->pdev, 0), DRM_MTRR_WC);
-               mdev->fb_mtrr = -1;
-       }
+       arch_phys_wc_del(mdev->fb_mtrr);
+       mdev->fb_mtrr = 0;
 }
 
 void mgag200_ttm_placement(struct mgag200_bo *bo, int domain)
 }
 
 void mgag200_ttm_placement(struct mgag200_bo *bo, int domain)
index f19a15a3bc030cadc0be656ff444264864785b77..3da985eb38ccbc18eb0d5f4e97e2e592cf773c6b 100644 (file)
@@ -396,9 +396,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)
                return ret;
        }
 
                return ret;
        }
 
-       drm->ttm.mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
-                                    pci_resource_len(dev->pdev, 1),
-                                    DRM_MTRR_WC);
+       drm->ttm.mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 1),
+                                        pci_resource_len(dev->pdev, 1));
 
        /* GART init */
        if (drm->agp.stat != ENABLED) {
 
        /* GART init */
        if (drm->agp.stat != ENABLED) {
@@ -433,10 +432,6 @@ nouveau_ttm_fini(struct nouveau_drm *drm)
 
        nouveau_ttm_global_release(drm);
 
 
        nouveau_ttm_global_release(drm);
 
-       if (drm->ttm.mtrr >= 0) {
-               drm_mtrr_del(drm->ttm.mtrr,
-                            pci_resource_start(drm->dev->pdev, 1),
-                            pci_resource_len(drm->dev->pdev, 1), DRM_MTRR_WC);
-               drm->ttm.mtrr = -1;
-       }
+       arch_phys_wc_del(drm->ttm.mtrr);
+       drm->ttm.mtrr = 0;
 }
 }
index b55c1d66114745e1db6c56f027be1b953269d2e1..bd6b2cf508d56e952160f12b93332c8be17386ed 100644 (file)
@@ -570,9 +570,6 @@ int savage_driver_firstopen(struct drm_device *dev)
        unsigned int fb_rsrc, aper_rsrc;
        int ret = 0;
 
        unsigned int fb_rsrc, aper_rsrc;
        int ret = 0;
 
-       dev_priv->mtrr[0].handle = -1;
-       dev_priv->mtrr[1].handle = -1;
-       dev_priv->mtrr[2].handle = -1;
        if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
                fb_rsrc = 0;
                fb_base = pci_resource_start(dev->pdev, 0);
        if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
                fb_rsrc = 0;
                fb_base = pci_resource_start(dev->pdev, 0);
@@ -584,21 +581,14 @@ int savage_driver_firstopen(struct drm_device *dev)
                if (pci_resource_len(dev->pdev, 0) == 0x08000000) {
                        /* Don't make MMIO write-cobining! We need 3
                         * MTRRs. */
                if (pci_resource_len(dev->pdev, 0) == 0x08000000) {
                        /* Don't make MMIO write-cobining! We need 3
                         * MTRRs. */
-                       dev_priv->mtrr[0].base = fb_base;
-                       dev_priv->mtrr[0].size = 0x01000000;
-                       dev_priv->mtrr[0].handle =
-                           drm_mtrr_add(dev_priv->mtrr[0].base,
-                                        dev_priv->mtrr[0].size, DRM_MTRR_WC);
-                       dev_priv->mtrr[1].base = fb_base + 0x02000000;
-                       dev_priv->mtrr[1].size = 0x02000000;
-                       dev_priv->mtrr[1].handle =
-                           drm_mtrr_add(dev_priv->mtrr[1].base,
-                                        dev_priv->mtrr[1].size, DRM_MTRR_WC);
-                       dev_priv->mtrr[2].base = fb_base + 0x04000000;
-                       dev_priv->mtrr[2].size = 0x04000000;
-                       dev_priv->mtrr[2].handle =
-                           drm_mtrr_add(dev_priv->mtrr[2].base,
-                                        dev_priv->mtrr[2].size, DRM_MTRR_WC);
+                       dev_priv->mtrr_handles[0] =
+                               arch_phys_wc_add(fb_base, 0x01000000);
+                       dev_priv->mtrr_handles[1] =
+                               arch_phys_wc_add(fb_base + 0x02000000,
+                                                0x02000000);
+                       dev_priv->mtrr_handles[2] =
+                               arch_phys_wc_add(fb_base + 0x04000000,
+                                               0x04000000);
                } else {
                        DRM_ERROR("strange pci_resource_len %08llx\n",
                                  (unsigned long long)
                } else {
                        DRM_ERROR("strange pci_resource_len %08llx\n",
                                  (unsigned long long)
@@ -616,11 +606,9 @@ int savage_driver_firstopen(struct drm_device *dev)
                if (pci_resource_len(dev->pdev, 1) == 0x08000000) {
                        /* Can use one MTRR to cover both fb and
                         * aperture. */
                if (pci_resource_len(dev->pdev, 1) == 0x08000000) {
                        /* Can use one MTRR to cover both fb and
                         * aperture. */
-                       dev_priv->mtrr[0].base = fb_base;
-                       dev_priv->mtrr[0].size = 0x08000000;
-                       dev_priv->mtrr[0].handle =
-                           drm_mtrr_add(dev_priv->mtrr[0].base,
-                                        dev_priv->mtrr[0].size, DRM_MTRR_WC);
+                       dev_priv->mtrr_handles[0] =
+                               arch_phys_wc_add(fb_base,
+                                                0x08000000);
                } else {
                        DRM_ERROR("strange pci_resource_len %08llx\n",
                                  (unsigned long long)
                } else {
                        DRM_ERROR("strange pci_resource_len %08llx\n",
                                  (unsigned long long)
@@ -660,11 +648,10 @@ void savage_driver_lastclose(struct drm_device *dev)
        drm_savage_private_t *dev_priv = dev->dev_private;
        int i;
 
        drm_savage_private_t *dev_priv = dev->dev_private;
        int i;
 
-       for (i = 0; i < 3; ++i)
-               if (dev_priv->mtrr[i].handle >= 0)
-                       drm_mtrr_del(dev_priv->mtrr[i].handle,
-                                dev_priv->mtrr[i].base,
-                                dev_priv->mtrr[i].size, DRM_MTRR_WC);
+       for (i = 0; i < 3; ++i) {
+               arch_phys_wc_del(dev_priv->mtrr_handles[i]);
+               dev_priv->mtrr_handles[i] = 0;
+       }
 }
 
 int savage_driver_unload(struct drm_device *dev)
 }
 
 int savage_driver_unload(struct drm_device *dev)
index df2aac6636f72fe956b77b14e14c2d9f91746754..c05082a59f6f1e40119558111184cbc9f5ef69f9 100644 (file)
@@ -160,10 +160,7 @@ typedef struct drm_savage_private {
        drm_local_map_t *cmd_dma;
        drm_local_map_t fake_dma;
 
        drm_local_map_t *cmd_dma;
        drm_local_map_t fake_dma;
 
-       struct {
-               int handle;
-               unsigned long base, size;
-       } mtrr[3];
+       int mtrr_handles[3];
 
        /* BCI and status-related stuff */
        volatile uint32_t *status_ptr, *bci_ptr;
 
        /* BCI and status-related stuff */
        volatile uint32_t *status_ptr, *bci_ptr;
index 07dfd823cc304987bc41056d705bbd6253216013..78e21649d48adf52ee4a849da033eddd9c47a2a2 100644 (file)
@@ -565,8 +565,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
                dev_priv->has_gmr = false;
        }
 
                dev_priv->has_gmr = false;
        }
 
-       dev_priv->mmio_mtrr = drm_mtrr_add(dev_priv->mmio_start,
-                                          dev_priv->mmio_size, DRM_MTRR_WC);
+       dev_priv->mmio_mtrr = arch_phys_wc_add(dev_priv->mmio_start,
+                                              dev_priv->mmio_size);
 
        dev_priv->mmio_virt = ioremap_wc(dev_priv->mmio_start,
                                         dev_priv->mmio_size);
 
        dev_priv->mmio_virt = ioremap_wc(dev_priv->mmio_start,
                                         dev_priv->mmio_size);
@@ -664,8 +664,7 @@ out_no_device:
 out_err4:
        iounmap(dev_priv->mmio_virt);
 out_err3:
 out_err4:
        iounmap(dev_priv->mmio_virt);
 out_err3:
-       drm_mtrr_del(dev_priv->mmio_mtrr, dev_priv->mmio_start,
-                    dev_priv->mmio_size, DRM_MTRR_WC);
+       arch_phys_wc_del(dev_priv->mmio_mtrr);
        if (dev_priv->has_gmr)
                (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
        (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
        if (dev_priv->has_gmr)
                (void) ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
        (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
@@ -709,8 +708,7 @@ static int vmw_driver_unload(struct drm_device *dev)
 
        ttm_object_device_release(&dev_priv->tdev);
        iounmap(dev_priv->mmio_virt);
 
        ttm_object_device_release(&dev_priv->tdev);
        iounmap(dev_priv->mmio_virt);
-       drm_mtrr_del(dev_priv->mmio_mtrr, dev_priv->mmio_start,
-                    dev_priv->mmio_size, DRM_MTRR_WC);
+       arch_phys_wc_del(dev_priv->mmio_mtrr);
        if (dev_priv->has_gmr)
                (void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
        (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
        if (dev_priv->has_gmr)
                (void)ttm_bo_clean_mm(&dev_priv->bdev, VMW_PL_GMR);
        (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
index 63d17ee9eb488c336ad55521f346dc1c2703c4c4..5a87655508fc55f73012cbae6e1d1b1f24661a86 100644 (file)
@@ -1250,37 +1250,8 @@ static inline int drm_core_has_MTRR(struct drm_device *dev)
 {
        return drm_core_check_feature(dev, DRIVER_USE_MTRR);
 }
 {
        return drm_core_check_feature(dev, DRIVER_USE_MTRR);
 }
-
-#define DRM_MTRR_WC            MTRR_TYPE_WRCOMB
-
-static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
-                              unsigned int flags)
-{
-       return mtrr_add(offset, size, flags, 1);
-}
-
-static inline int drm_mtrr_del(int handle, unsigned long offset,
-                              unsigned long size, unsigned int flags)
-{
-       return mtrr_del(handle, offset, size);
-}
-
 #else
 #define drm_core_has_MTRR(dev) (0)
 #else
 #define drm_core_has_MTRR(dev) (0)
-
-#define DRM_MTRR_WC            0
-
-static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
-                              unsigned int flags)
-{
-       return 0;
-}
-
-static inline int drm_mtrr_del(int handle, unsigned long offset,
-                              unsigned long size, unsigned int flags)
-{
-       return 0;
-}
 #endif
 
 static inline void drm_device_set_unplugged(struct drm_device *dev)
 #endif
 
 static inline void drm_device_set_unplugged(struct drm_device *dev)