]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/gpu/drm/i915/i915_gem_gtt.c
drm/i915: make mappable struct resource centric
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / i915 / i915_gem_gtt.c
index 2af65ecf2df84e8a26fe694f8e115d9e8e7d3671..5dc06c6e532666d2852baef0816d906c6c46c8a6 100644 (file)
@@ -2877,7 +2877,7 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv)
        mutex_unlock(&dev_priv->drm.struct_mutex);
 
        arch_phys_wc_del(ggtt->mtrr);
-       io_mapping_fini(&ggtt->mappable);
+       io_mapping_fini(&ggtt->iomap);
 }
 
 static unsigned int gen6_get_total_gtt_size(u16 snb_gmch_ctl)
@@ -3303,8 +3303,10 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
        int err;
 
        /* TODO: We're not aware of mappable constraints on gen8 yet */
-       ggtt->mappable_base = pci_resource_start(pdev, 2);
-       ggtt->mappable_end = pci_resource_len(pdev, 2);
+       ggtt->gmadr =
+               (struct resource) DEFINE_RES_MEM(pci_resource_start(pdev, 2),
+                                                pci_resource_len(pdev, 2));
+       ggtt->mappable_end = resource_size(&ggtt->gmadr);
 
        err = pci_set_dma_mask(pdev, DMA_BIT_MASK(39));
        if (!err)
@@ -3361,8 +3363,10 @@ static int gen6_gmch_probe(struct i915_ggtt *ggtt)
        u16 snb_gmch_ctl;
        int err;
 
-       ggtt->mappable_base = pci_resource_start(pdev, 2);
-       ggtt->mappable_end = pci_resource_len(pdev, 2);
+       ggtt->gmadr =
+               (struct resource) DEFINE_RES_MEM(pci_resource_start(pdev, 2),
+                                                pci_resource_len(pdev, 2));
+       ggtt->mappable_end = resource_size(&ggtt->gmadr);
 
        /* 64/512MB is the current min/max we actually know of, but this is just
         * a coarse sanity check.
@@ -3417,6 +3421,7 @@ static void i915_gmch_remove(struct i915_address_space *vm)
 static int i915_gmch_probe(struct i915_ggtt *ggtt)
 {
        struct drm_i915_private *dev_priv = ggtt->base.i915;
+       phys_addr_t gmadr_base;
        int ret;
 
        ret = intel_gmch_probe(dev_priv->bridge_dev, dev_priv->drm.pdev, NULL);
@@ -3427,9 +3432,13 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt)
 
        intel_gtt_get(&ggtt->base.total,
                      &ggtt->stolen_size,
-                     &ggtt->mappable_base,
+                     &gmadr_base,
                      &ggtt->mappable_end);
 
+       ggtt->gmadr =
+               (struct resource) DEFINE_RES_MEM(gmadr_base,
+                                                ggtt->mappable_end);
+
        ggtt->do_idle_maps = needs_idle_maps(dev_priv);
        ggtt->base.insert_page = i915_ggtt_insert_page;
        ggtt->base.insert_entries = i915_ggtt_insert_entries;
@@ -3497,7 +3506,7 @@ int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv)
        /* GMADR is the PCI mmio aperture into the global GTT. */
        DRM_INFO("Memory usable by graphics device = %lluM\n",
                 ggtt->base.total >> 20);
-       DRM_DEBUG_DRIVER("GMADR size = %lldM\n", ggtt->mappable_end >> 20);
+       DRM_DEBUG_DRIVER("GMADR size = %lluM\n", (u64)ggtt->mappable_end >> 20);
        DRM_DEBUG_DRIVER("GTT stolen size = %uM\n", ggtt->stolen_size >> 20);
        if (intel_vtd_active())
                DRM_INFO("VT-d active for gfx access\n");
@@ -3527,14 +3536,14 @@ int i915_ggtt_init_hw(struct drm_i915_private *dev_priv)
                ggtt->base.mm.color_adjust = i915_gtt_color_adjust;
        mutex_unlock(&dev_priv->drm.struct_mutex);
 
-       if (!io_mapping_init_wc(&dev_priv->ggtt.mappable,
-                               dev_priv->ggtt.mappable_base,
+       if (!io_mapping_init_wc(&dev_priv->ggtt.iomap,
+                               dev_priv->ggtt.gmadr.start,
                                dev_priv->ggtt.mappable_end)) {
                ret = -EIO;
                goto out_gtt_cleanup;
        }
 
-       ggtt->mtrr = arch_phys_wc_add(ggtt->mappable_base, ggtt->mappable_end);
+       ggtt->mtrr = arch_phys_wc_add(ggtt->gmadr.start, ggtt->mappable_end);
 
        /*
         * Initialise stolen early so that we may reserve preallocated