Skip to contentSkip to conversation

drm/radeon/kms: forbid big bo allocation (fdo 31708) v2

PATCH In review [email protected] 5 participants 9 messages Nov 19, 2010 – Nov 29, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon/kms: forbid big bo allocation (fdo 31708) v2

From: Jerome Glisse <[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
- silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34 ++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +28 -6
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
 	u32 c = 0;
 
 	rbo->placement.fpfn = 0;
-	rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT;
+	rbo->placement.lpfn = 0;
 	rbo->placement.placement = rbo->placements;
 	rbo->placement.busy_placement = rbo->placements;
-	if (domain & RADEON_GEM_DOMAIN_VRAM)
+	if (domain & RADEON_GEM_DOMAIN_VRAM) {
+		rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.active_vram_size >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
 					TTM_PL_FLAG_VRAM;
-	if (domain & RADEON_GEM_DOMAIN_GTT)
+	}
+	if (domain & RADEON_GEM_DOMAIN_GTT) {
+		rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-	if (domain & RADEON_GEM_DOMAIN_CPU)
+	}
+	if (domain & RADEON_GEM_DOMAIN_CPU) {
+		/* 4G limit for CPU domain */
+		rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-	if (!c)
+	}
+	if (!c) {
+		/* 4G limit for CPU domain */
+		rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+	}
 	rbo->placement.num_placement = c;
 	rbo->placement.num_busy_placement = c;
 }
@@ -91,7 +101,8 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj,
 {
 	struct radeon_bo *bo;
 	enum ttm_bo_type type;
-	int page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT;
+	unsigned long page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT;
+	unsigned long max_size = 0;
 	int r;
 
 	if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) {
@@ -104,6 +115,17 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj,
 	}
 	*bo_ptr = NULL;
 
+	/* maximun bo size is the minimun btw visible vram and gtt size */
+	max_size = rdev->mc.visible_vram_size;
+	if (max_size > rdev->mc.gtt_size) {
+		max_size = rdev->mc.gtt_size;
+	}
+	if ((page_align << PAGE_SHIFT) >= max_size) {
+		printk(KERN_WARNING "%s:%d alloc size %ldM bigger than %ldMb limit\n",
+			__func__, __LINE__, page_align  >> (20 - PAGE_SHIFT), max_size >> 20);
+		return -ENOMEM;
+	}
+
 retry:
 	bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
 	if (bo == NULL)
Signature · 1 line
1.7.3.2
#1 lore raw
Quoted 38 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
- silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34 ++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +8 -4
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
 	u32 c = 0;
 
 	rbo->placement.fpfn = 0;
-	rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT;
+	rbo->placement.lpfn = 0;
 	rbo->placement.placement = rbo->placements;
 	rbo->placement.busy_placement = rbo->placements;
-	if (domain & RADEON_GEM_DOMAIN_VRAM)
+	if (domain & RADEON_GEM_DOMAIN_VRAM) {
+		rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.active_vram_size >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
 					TTM_PL_FLAG_VRAM;
-	if (domain & RADEON_GEM_DOMAIN_GTT)
+	}
+	if (domain & RADEON_GEM_DOMAIN_GTT) {
+		rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-	if (domain & RADEON_GEM_DOMAIN_CPU)
+	}
+	if (domain & RADEON_GEM_DOMAIN_CPU) {

drivers/gpu/drm/radeon/radeon_object.c void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) · line 93

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_object.c +7 -1
+		/* 4G limit for CPU domain */
+		rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-	if (!c)
+	}
+	if (!c) {
+		/* 4G limit for CPU domain */
+		rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT);
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+	}

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Out of curiosity, where does the 4G limit come from?

drivers/gpu/drm/radeon/radeon_object.c int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, · line 122

Quoted 9 lines
drivers/gpu/drm/radeon/radeon_object.c +5 -0
@@ -104,6 +115,17 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj,
 	}
 	*bo_ptr = NULL;
 
+	/* maximun bo size is the minimun btw visible vram and gtt size */
+	max_size = rdev->mc.visible_vram_size;
+	if (max_size > rdev->mc.gtt_size) {
+		max_size = rdev->mc.gtt_size;
+	}

max_size = min(rdev->mc.visible_vram_size, rdev->mc.gtt_size);

Except I think this should actually be max(...).

drivers/gpu/drm/radeon/radeon_object.c int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, · line 127

Quoted 5 lines
drivers/gpu/drm/radeon/radeon_object.c +5 -0
+	if ((page_align << PAGE_SHIFT) >= max_size) {
+		printk(KERN_WARNING "%s:%d alloc size %ldM bigger than %ldMb limit\n",
+			__func__, __LINE__, page_align  >> (20 - PAGE_SHIFT), max_size >> 20);
+		return -ENOMEM;
+	}

Maybe this should be rate-limited, or userspace can spam dmesg.

Signature · 6 lines
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

2010/11/22 Michel Dänzer <[email protected]>:

Quoted 54 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 40 lines

From: Jerome Glisse <[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
   - silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34 ++++++++++++++++++++++++++-----

 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -2
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain & RADEON_GEM_DOMAIN_VRAM)
+     if (domain & RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.active_vram_size >> PAGE_SHIFT);

              rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
                                      TTM_PL_FLAG_VRAM;
-     if (domain & RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain & RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size >> PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-     if (domain & RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain & RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT);

Quoted 8 lines

              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-     if (!c)
+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+     }

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

Quoted 8 lines

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Out of curiosity, where does the 4G limit come from?

From my hat, but iirc ttm limit things to 1G anyway (vm size for

mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

Doing a v3.

Cheers,
Jerome

#3 lore raw

2010/11/22 Jerome Glisse <[email protected]>:

Quoted 59 lines

2010/11/22 Michel Dänzer <[email protected]>:

Quoted 58 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 40 lines

From: Jerome Glisse <[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
   - silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34 ++++++++++++++++++++++++++-----

 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -2
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain & RADEON_GEM_DOMAIN_VRAM)
+     if (domain & RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.active_vram_size >> PAGE_SHIFT);

              rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
                                      TTM_PL_FLAG_VRAM;
-     if (domain & RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain & RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size >> PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-     if (domain & RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain & RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT);

Quoted 8 lines

              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-     if (!c)
+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF >> PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+     }

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Quoted 8 lines
Quoted 3 lines

Out of curiosity, where does the 4G limit come from?

From my hat, but iirc ttm limit things to 1G anyway (vm size for mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

FWIW, r1xx-r5xx have a 32 bit MC address space while r6xx+ have a 40 bit address space (with certain limitations on 6xx/7xx).

Alex

Quoted 9 lines

Doing a v3.

Cheers,
Jerome
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to Jerome Glisse
Quoted 61 lines · Jerome Glisse

2010/11/22 Michel Dänzer<[email protected]>:

Quoted 59 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 40 lines

From: Jerome Glisse<[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
- silence warning

---
  drivers/gpu/drm/radeon/radeon_object.c |   34 ++++++++++++++++++++++++++-----
  1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +9 -4
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size>>  PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain&  RADEON_GEM_DOMAIN_VRAM)
+     if (domain&  RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.active_vram_size>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
                                       TTM_PL_FLAG_VRAM;
-     if (domain&  RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-     if (domain&  RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */

drivers/gpu/drm/radeon/radeon_object.c void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) · line 94

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_object.c +6 -1
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-     if (!c)
+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+     }
 

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Quoted 9 lines
Quoted 5 lines

Out of curiosity, where does the 4G limit come from?

From my hat, but iirc ttm limit things to 1G anyway (vm size for

mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

That limit is taken from *my* hat. Nothing prevents us to increase that limit to whatever.

/Thomas

Quoted 9 lines

Doing a v3.

Cheers,
Jerome
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 89 lines · Thomas Hellstrom
Quoted 82 lines · Jerome Glisse

2010/11/22 Michel Dänzer<[email protected]>:

Quoted 78 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 54 lines

From: Jerome Glisse<[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
   - silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34
++++++++++++++++++++++++++-----

 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -2
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct
 radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size>>
  PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain&  RADEON_GEM_DOMAIN_VRAM)
+     if (domain&  RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn,
 (unsigned)rbo->rdev->mc.active_vram_size>>  PAGE_SHIFT);

              rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
                                      TTM_PL_FLAG_VRAM;
-     if (domain&  RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size>>  PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-     if (domain&  RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-     if (!c)

Quoted 9 lines

+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+     }

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Out of curiosity, where does the 4G limit come from?

Quoted 5 lines
Quoted 1 line

From my hat, but iirc ttm limit things to 1G anyway (vm size for

mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

Quoted 5 lines

That limit is taken from *my* hat. Nothing prevents us to increase that limit to whatever.

/Thomas

I think we can at most have 3G as the lower space is use by old drm stuff iirc.

Cheers,
Jerome

#6 lore raw
Quoted 90 lines · Jerome Glisse
Quoted 89 lines · Thomas Hellstrom
Quoted 87 lines · Jerome Glisse

2010/11/22 Michel Dänzer<[email protected]>:

Quoted 74 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 54 lines

From: Jerome Glisse<[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
   - silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34
++++++++++++++++++++++++++-----

 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -2
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct
 radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size>>
  PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain&  RADEON_GEM_DOMAIN_VRAM)
+     if (domain&  RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn,
 (unsigned)rbo->rdev->mc.active_vram_size>>  PAGE_SHIFT);

              rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
                                      TTM_PL_FLAG_VRAM;
-     if (domain&  RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size>>  PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-     if (domain&  RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-     if (!c)

Quoted 9 lines

+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+     }

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Quoted 6 lines

Out of curiosity, where does the 4G limit come from?

From my hat, but iirc ttm limit things to 1G anyway (vm size for

mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

Quoted 7 lines
Quoted 5 lines

That limit is taken from *my* hat. Nothing prevents us to increase that limit to whatever.

/Thomas

I think we can at most have 3G as the lower space is use by old drm stuff iirc.

We already sell cards with 4 GB of vram.

Alex

Quoted 8 lines

Cheers,
Jerome
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
In reply to Thomas Hellstrom
Quoted 73 lines · Thomas Hellstrom
Quoted 72 lines · Jerome Glisse

2010/11/22 Michel Dänzer<[email protected]>:

Quoted 71 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 57 lines

From: Jerome Glisse<[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
- silence warning

---
  drivers/gpu/drm/radeon/radeon_object.c |   34 
++++++++++++++++++++++++++-----
  1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -2
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct 
 radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size>>  
 PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain&  RADEON_GEM_DOMAIN_VRAM)
+     if (domain&  RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = 
 max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.active_vram_size>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_FLAG_WC | 

TTM_PL_FLAG_UNCACHED |

                                       TTM_PL_FLAG_VRAM;
drivers/gpu/drm/radeon/radeon_object.c +3 -1
-     if (domain&  RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = 
max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_MASK_CACHING | 

TTM_PL_FLAG_TT;

drivers/gpu/drm/radeon/radeon_object.c +4 -1
-     if (domain&  RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 
0xFFFFFFFF>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_MASK_CACHING | 

TTM_PL_FLAG_SYSTEM;

drivers/gpu/drm/radeon/radeon_object.c +4 -1
-     if (!c)
+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 
0xFFFFFFFF>>  PAGE_SHIFT);
               rbo->placements[c++] = TTM_PL_MASK_CACHING | 
Quoted 2 lines

TTM_PL_FLAG_SYSTEM;
+ }

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Out of curiosity, where does the 4G limit come from?

Quoted 10 lines
Quoted 4 lines
Quoted 1 line

From my hat, but iirc ttm limit things to 1G anyway (vm size for

mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

That limit is taken from *my* hat. Nothing prevents us to increase that limit to whatever.

/Thomas

Hmm.
Did you guys ever run into trouble with this? Looking at the code, it seems the current limit is not 1GB but 1TB? (0x10000000 << PAGE_SHIFT)

/Thomas

Quoted 14 lines
Quoted 9 lines

Doing a v3.

Cheers,
Jerome
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
Quoted 92 lines · Thomas Hellstrom
Quoted 80 lines · Thomas Hellstrom
Quoted 78 lines · Jerome Glisse

2010/11/22 Michel Dänzer<[email protected]>:

Quoted 76 lines · On Fre, 2010-11-19 at 16:34 -0500, [email protected] wrote:
Quoted 53 lines

From: Jerome Glisse<[email protected]>

Forbid allocating buffer bigger than visible VRAM or GTT, also properly set lpfn field.

v2 - use max macro
   - silence warning

---
 drivers/gpu/drm/radeon/radeon_object.c |   34
++++++++++++++++++++++++++-----

 1 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -2
index 1d06774..c2fa64c 100644
@@ -69,18 +69,28 @@ void radeon_ttm_placement_from_domain(struct
 radeon_bo *rbo, u32 domain)
       u32 c = 0;
 
       rbo->placement.fpfn = 0;
-     rbo->placement.lpfn = rbo->rdev->mc.active_vram_size>>
  PAGE_SHIFT;
+     rbo->placement.lpfn = 0;
       rbo->placement.placement = rbo->placements;
       rbo->placement.busy_placement = rbo->placements;
-     if (domain&  RADEON_GEM_DOMAIN_VRAM)
+     if (domain&  RADEON_GEM_DOMAIN_VRAM) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn,
 (unsigned)rbo->rdev->mc.active_vram_size>>  PAGE_SHIFT);

              rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
                                      TTM_PL_FLAG_VRAM;
-     if (domain&  RADEON_GEM_DOMAIN_GTT)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_GTT) {
+             rbo->placement.lpfn = max((unsigned)rbo->placement.lpfn, (unsigned)rbo->rdev->mc.gtt_size>>  PAGE_SHIFT); rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-     if (domain&  RADEON_GEM_DOMAIN_CPU)
+     }
+     if (domain&  RADEON_GEM_DOMAIN_CPU) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-     if (!c)

Quoted 8 lines

+     }
+     if (!c) {
+             /* 4G limit for CPU domain */
+             rbo->placement.lpfn = max(rbo->placement.lpfn, 0xFFFFFFFF>>  PAGE_SHIFT);
              rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+     }

I don't think taxing the maximum is the right thing to do: If domain is (RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT) and VRAM doesn't happen to be the same size as GTT, lpfn will end up larger than one of them.

AFAICT radeon_ttm_placement_from_domain() should just set lpfn to 0 (i.e. unrestricted), the callers that need it to be non-0 already set it afterwards.

Out of curiosity, where does the 4G limit come from?

From my hat, but iirc ttm limit things to 1G anyway (vm size for

Quoted 10 lines
Quoted 3 lines

mapping object in drm file and iirc we will report error if we can't find a mapping for userspace object). I guess at one point we should start thinking about what we want to do on that front.

That limit is taken from *my* hat. Nothing prevents us to increase that limit to whatever.

/Thomas

Quoted 6 lines

Hmm.
Did you guys ever run into trouble with this? Looking at the code, it seems the current limit is not 1GB but 1TB? (0x10000000 << PAGE_SHIFT)

/Thomas

No never run into it, i also wrongly parsed the limit or my memory of it wasn't good.

Cheers,
Jerome