#include "amdgpu_atomfirmware.h"
 #include "atom.h"
 
+#define AMDGPU_MAX_SG_SEGMENT_SIZE     (2UL << 30)
+
 struct amdgpu_vram_reservation {
        u64 start;
        u64 size;
                else
                        min_block_size = mgr->default_page_size;
 
-               /* Limit maximum size to 2GiB due to SG table limitations */
-               size = min(remaining_size, 2ULL << 30);
-
+               size = remaining_size;
                if ((size >= (u64)pages_per_block << PAGE_SHIFT) &&
                    !(size & (((u64)pages_per_block << PAGE_SHIFT) - 1)))
                        min_block_size = (u64)pages_per_block << PAGE_SHIFT;
        amdgpu_res_first(res, offset, length, &cursor);
        while (cursor.remaining) {
                num_entries++;
-               amdgpu_res_next(&cursor, cursor.size);
+               amdgpu_res_next(&cursor, min(cursor.size, AMDGPU_MAX_SG_SEGMENT_SIZE));
        }
 
        r = sg_alloc_table(*sgt, num_entries, GFP_KERNEL);
        amdgpu_res_first(res, offset, length, &cursor);
        for_each_sgtable_sg((*sgt), sg, i) {
                phys_addr_t phys = cursor.start + adev->gmc.aper_base;
-               size_t size = cursor.size;
+               unsigned long size = min(cursor.size, AMDGPU_MAX_SG_SEGMENT_SIZE);
                dma_addr_t addr;
 
                addr = dma_map_resource(dev, phys, size, dir,
                sg_dma_address(sg) = addr;
                sg_dma_len(sg) = size;
 
-               amdgpu_res_next(&cursor, cursor.size);
+               amdgpu_res_next(&cursor, size);
        }
 
        return 0;