drm/i915: prefer resource_size_t for everything stolen
authorMatthew Auld <matthew.auld@intel.com>
Mon, 11 Dec 2017 15:18:22 +0000 (15:18 +0000)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Tue, 12 Dec 2017 10:30:22 +0000 (12:30 +0200)
Keeps things consistent now that we make use of struct resource. This
should keep us covered in case we ever get huge amounts of stolen
memory.

v2: bunch of missing conversions (Chris)

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171211151822.20953-10-matthew.auld@intel.com
drivers/char/agp/intel-gtt.c
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/intel_pm.c
include/drm/intel-gtt.h

index 0c86b4dfd59c25f99f0beed79f01fc84d98cdb30..c6271ce250b32150ffa6516526d79f80516398dc 100644 (file)
@@ -80,7 +80,7 @@ static struct _intel_private {
        unsigned int needs_dmar : 1;
        phys_addr_t gma_bus_addr;
        /*  Size of memory reserved for graphics by the BIOS */
-       unsigned int stolen_size;
+       resource_size_t stolen_size;
        /* Total number of gtt entries. */
        unsigned int gtt_total_entries;
        /* Part of the gtt that is mappable by the cpu, for those chips where
@@ -333,13 +333,13 @@ static void i810_write_entry(dma_addr_t addr, unsigned int entry,
        writel_relaxed(addr | pte_flags, intel_private.gtt + entry);
 }
 
-static unsigned int intel_gtt_stolen_size(void)
+static resource_size_t intel_gtt_stolen_size(void)
 {
        u16 gmch_ctrl;
        u8 rdct;
        int local = 0;
        static const int ddt[4] = { 0, 16, 32, 64 };
-       unsigned int stolen_size = 0;
+       resource_size_t stolen_size = 0;
 
        if (INTEL_GTT_GEN == 1)
                return 0; /* no stolen mem on i81x */
@@ -417,8 +417,8 @@ static unsigned int intel_gtt_stolen_size(void)
        }
 
        if (stolen_size > 0) {
-               dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n",
-                      stolen_size / KB(1), local ? "local" : "stolen");
+               dev_info(&intel_private.bridge_dev->dev, "detected %lluK %s memory\n",
+                      (u64)stolen_size / KB(1), local ? "local" : "stolen");
        } else {
                dev_info(&intel_private.bridge_dev->dev,
                       "no pre-allocated video memory detected\n");
@@ -1425,7 +1425,7 @@ EXPORT_SYMBOL(intel_gmch_probe);
 
 void intel_gtt_get(u64 *gtt_total,
                   phys_addr_t *mappable_base,
-                  u64 *mappable_end)
+                  resource_size_t *mappable_end)
 {
        *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
        *mappable_base = intel_private.gma_bus_addr;
index f91dd68c53a171a861a87206ca5c057cdc8a9603..d8c6ec3cca718685b55719efb7700d71876916af 100644 (file)
@@ -522,8 +522,8 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
        seq_printf(m, "%u display objects (globally pinned), %llu bytes\n",
                   dpy_count, dpy_size);
 
-       seq_printf(m, "%llu [%llu] gtt total\n",
-                  ggtt->base.total, ggtt->mappable_end);
+       seq_printf(m, "%llu [%pa] gtt total\n",
+                  ggtt->base.total, &ggtt->mappable_end);
        seq_printf(m, "Supported page sizes: %s\n",
                   stringify_page_sizes(INTEL_INFO(dev_priv)->page_sizes,
                                        buf, sizeof(buf)));
index d71e59e44d50f98be15f193f8f72d90794a08f47..61196ff939011c4789bb4c86ff4fed8c566a7a4f 100644 (file)
@@ -2273,7 +2273,7 @@ struct drm_i915_private {
         * avoid the first page! The upper end of stolen memory is reserved for
         * hardware functions and similarly removed from the accessible range.
         */
-       u32 stolen_usable_size; /* Total size minus reserved ranges */
+       resource_size_t stolen_usable_size;     /* Total size minus reserved ranges */
 
        void __iomem *regs;
 
@@ -3932,12 +3932,13 @@ void i915_gem_stolen_remove_node(struct drm_i915_private *dev_priv,
 int i915_gem_init_stolen(struct drm_i915_private *dev_priv);
 void i915_gem_cleanup_stolen(struct drm_device *dev);
 struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_i915_private *dev_priv, u32 size);
+i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
+                             resource_size_t size);
 struct drm_i915_gem_object *
 i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv,
-                                              u32 stolen_offset,
-                                              u32 gtt_offset,
-                                              u32 size);
+                                              resource_size_t stolen_offset,
+                                              resource_size_t gtt_offset,
+                                              resource_size_t size);
 
 /* i915_gem_internal.c */
 struct drm_i915_gem_object *
index fbc1f467273ae2f7aa2300ae16e392ec77e3eb6d..a7fe05666f72cf8695c2edfdd94b0f7dd6f04333 100644 (file)
@@ -3354,7 +3354,7 @@ static int gen6_gmch_probe(struct i915_ggtt *ggtt)
         * a coarse sanity check.
         */
        if (ggtt->mappable_end < (64<<20) || ggtt->mappable_end > (512<<20)) {
-               DRM_ERROR("Unknown GMADR size (%llx)\n", ggtt->mappable_end);
+               DRM_ERROR("Unknown GMADR size (%pa)\n", &ggtt->mappable_end);
                return -ENXIO;
        }
 
@@ -3464,7 +3464,7 @@ int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv)
         */
        if (USES_GUC(dev_priv)) {
                ggtt->base.total = min_t(u64, ggtt->base.total, GUC_GGTT_TOP);
-               ggtt->mappable_end = min(ggtt->mappable_end, ggtt->base.total);
+               ggtt->mappable_end = min_t(u64, ggtt->mappable_end, ggtt->base.total);
        }
 
        if ((ggtt->base.total - 1) >> 32) {
@@ -3472,13 +3472,13 @@ int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv)
                          " of address space! Found %lldM!\n",
                          ggtt->base.total >> 20);
                ggtt->base.total = 1ULL << 32;
-               ggtt->mappable_end = min(ggtt->mappable_end, ggtt->base.total);
+               ggtt->mappable_end = min_t(u64, ggtt->mappable_end, ggtt->base.total);
        }
 
        if (ggtt->mappable_end > ggtt->base.total) {
                DRM_ERROR("mappable aperture extends past end of GGTT,"
-                         " aperture=%llx, total=%llx\n",
-                         ggtt->mappable_end, ggtt->base.total);
+                         " aperture=%pa, total=%llx\n",
+                         &ggtt->mappable_end, ggtt->base.total);
                ggtt->mappable_end = ggtt->base.total;
        }
 
index e5aa07ceb627192d9d86a3bf2ffeb5b581f96d32..a42890d9af380162e8014d7cdf2191ff0b56b478 100644 (file)
@@ -371,7 +371,7 @@ struct i915_ggtt {
 
        struct io_mapping iomap;        /* Mapping to our CPU mappable region */
        struct resource gmadr;          /* GMADR resource */
-       u64 mappable_end;               /* End offset that we can CPU map */
+       resource_size_t mappable_end;   /* End offset that we can CPU map */
 
        /** "Graphics Stolen Memory" holds the global PTEs */
        void __iomem *gsm;
index 63d568512db5f48ce6d76db958f7c2a438ead43d..d3f222fa6356d53d70c0bb37ea46e0a56c0c03b3 100644 (file)
@@ -95,7 +95,7 @@ static int i915_adjust_stolen(struct drm_i915_private *dev_priv,
            !IS_G33(dev_priv) && !IS_PINEVIEW(dev_priv) && !IS_G4X(dev_priv)) {
                struct resource stolen[2] = {*dsm, *dsm};
                struct resource ggtt_res;
-               u64 ggtt_start;
+               resource_size_t ggtt_start;
 
                ggtt_start = I915_READ(PGTBL_CTL);
                if (IS_GEN4(dev_priv))
@@ -174,12 +174,12 @@ void i915_gem_cleanup_stolen(struct drm_device *dev)
 }
 
 static void g4x_get_stolen_reserved(struct drm_i915_private *dev_priv,
-                                   dma_addr_t *base, u32 *size)
+                                   resource_size_t *base, resource_size_t *size)
 {
        uint32_t reg_val = I915_READ(IS_GM45(dev_priv) ?
                                     CTG_STOLEN_RESERVED :
                                     ELK_STOLEN_RESERVED);
-       dma_addr_t stolen_top = dev_priv->dsm.end + 1;
+       resource_size_t stolen_top = dev_priv->dsm.end + 1;
 
        if ((reg_val & G4X_STOLEN_RESERVED_ENABLE) == 0) {
                *base = 0;
@@ -208,7 +208,7 @@ static void g4x_get_stolen_reserved(struct drm_i915_private *dev_priv,
 }
 
 static void gen6_get_stolen_reserved(struct drm_i915_private *dev_priv,
-                                    dma_addr_t *base, u32 *size)
+                                    resource_size_t *base, resource_size_t *size)
 {
        uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED);
 
@@ -240,7 +240,7 @@ static void gen6_get_stolen_reserved(struct drm_i915_private *dev_priv,
 }
 
 static void gen7_get_stolen_reserved(struct drm_i915_private *dev_priv,
-                                    dma_addr_t *base, u32 *size)
+                                    resource_size_t *base, resource_size_t *size)
 {
        uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED);
 
@@ -266,7 +266,7 @@ static void gen7_get_stolen_reserved(struct drm_i915_private *dev_priv,
 }
 
 static void chv_get_stolen_reserved(struct drm_i915_private *dev_priv,
-                                   dma_addr_t *base, u32 *size)
+                                   resource_size_t *base, resource_size_t *size)
 {
        uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED);
 
@@ -298,10 +298,10 @@ static void chv_get_stolen_reserved(struct drm_i915_private *dev_priv,
 }
 
 static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
-                                   dma_addr_t *base, u32 *size)
+                                   resource_size_t *base, resource_size_t *size)
 {
        uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED);
-       dma_addr_t stolen_top;
+       resource_size_t stolen_top;
 
        if ((reg_val & GEN6_STOLEN_RESERVED_ENABLE) == 0) {
                *base = 0;
@@ -325,9 +325,9 @@ static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
 
 int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 {
-       dma_addr_t reserved_base, stolen_top;
-       u32 reserved_total, reserved_size;
-       u32 stolen_usable_start;
+       resource_size_t reserved_base, stolen_top;
+       resource_size_t reserved_total, reserved_size;
+       resource_size_t stolen_usable_start;
 
        mutex_init(&dev_priv->mm.stolen_lock);
 
@@ -427,14 +427,13 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 
 static struct sg_table *
 i915_pages_create_for_stolen(struct drm_device *dev,
-                            u32 offset, u32 size)
+                            resource_size_t offset, resource_size_t size)
 {
        struct drm_i915_private *dev_priv = to_i915(dev);
        struct sg_table *st;
        struct scatterlist *sg;
 
-       GEM_BUG_ON(range_overflows_t(resource_size_t, offset, size,
-                                    resource_size(&dev_priv->dsm)));
+       GEM_BUG_ON(range_overflows(offset, size, resource_size(&dev_priv->dsm)));
 
        /* We hide that we have no struct page backing our stolen object
         * by wrapping the contiguous physical allocation with a fake
@@ -532,7 +531,8 @@ cleanup:
 }
 
 struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_i915_private *dev_priv, u32 size)
+i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
+                             resource_size_t size)
 {
        struct drm_i915_gem_object *obj;
        struct drm_mm_node *stolen;
@@ -565,9 +565,9 @@ i915_gem_object_create_stolen(struct drm_i915_private *dev_priv, u32 size)
 
 struct drm_i915_gem_object *
 i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv,
-                                              u32 stolen_offset,
-                                              u32 gtt_offset,
-                                              u32 size)
+                                              resource_size_t stolen_offset,
+                                              resource_size_t gtt_offset,
+                                              resource_size_t size)
 {
        struct i915_ggtt *ggtt = &dev_priv->ggtt;
        struct drm_i915_gem_object *obj;
@@ -580,8 +580,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 
        lockdep_assert_held(&dev_priv->drm.struct_mutex);
 
-       DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n",
-                       stolen_offset, gtt_offset, size);
+       DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%pa, gtt_offset=%pa, size=%pa\n",
+                       &stolen_offset, &gtt_offset, &size);
 
        /* KISS and expect everything to be page-aligned */
        if (WARN_ON(size == 0) ||
index 57dcf8e1ff30e281dd8c7b02fd788f4275bf1395..18779c6eb4bf9d9086f29b76777dedcd6ed9977d 100644 (file)
@@ -7033,9 +7033,9 @@ static void cherryview_check_pctx(struct drm_i915_private *dev_priv)
 
 static void cherryview_setup_pctx(struct drm_i915_private *dev_priv)
 {
-       unsigned long pctx_paddr, paddr;
+       resource_size_t pctx_paddr, paddr;
+       resource_size_t pctx_size = 32*1024;
        u32 pcbr;
-       int pctx_size = 32*1024;
 
        pcbr = I915_READ(VLV_PCBR);
        if ((pcbr >> VLV_PCBR_ADDR_SHIFT) == 0) {
@@ -7053,14 +7053,14 @@ static void cherryview_setup_pctx(struct drm_i915_private *dev_priv)
 static void valleyview_setup_pctx(struct drm_i915_private *dev_priv)
 {
        struct drm_i915_gem_object *pctx;
-       unsigned long pctx_paddr;
+       resource_size_t pctx_paddr;
+       resource_size_t pctx_size = 24*1024;
        u32 pcbr;
-       int pctx_size = 24*1024;
 
        pcbr = I915_READ(VLV_PCBR);
        if (pcbr) {
                /* BIOS set it up already, grab the pre-alloc'd space */
-               int pcbr_offset;
+               resource_size_t pcbr_offset;
 
                pcbr_offset = (pcbr & (~4095)) - dev_priv->dsm.start;
                pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv,
index 8c577ca38e2ee976bd5d4c073691de2887849d91..2324c84a25c02eca5d26e0f639fe32beb9979cfc 100644 (file)
@@ -6,7 +6,7 @@
 
 void intel_gtt_get(u64 *gtt_total,
                   phys_addr_t *mappable_base,
-                  u64 *mappable_end);
+                  resource_size_t *mappable_end);
 
 int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
                     struct agp_bridge_data *bridge);