All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/ttm: allow zero sized kernel allocations
@ 2014-08-07 14:30 Christian König
  2014-08-07 14:30 ` [PATCH 2/2] drm/radeon: allow zero sized BOs for fences Christian König
  0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2014-08-07 14:30 UTC (permalink / raw)
  To: dri-devel

From: Christian König <christian.koenig@amd.com>

This patch allows to create zero sized TTM buffer
objects for driver internal use.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c      | 4 ++--
 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3da89d5..0b96a3b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -309,7 +309,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 		if (ret)
 			goto out_err;
 
-		if (mem->mem_type != TTM_PL_SYSTEM) {
+		if (bo->ttm->num_pages && mem->mem_type != TTM_PL_SYSTEM) {
 			ret = ttm_tt_bind(bo->ttm, mem);
 			if (ret)
 				goto out_err;
@@ -1107,7 +1107,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
 	}
 
 	num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-	if (num_pages == 0) {
+	if (type != ttm_bo_type_kernel && num_pages == 0) {
 		pr_err("Illegal buffer object size\n");
 		if (destroy)
 			(*destroy)(bo);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 30e5d90..8354195 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -63,7 +63,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 	if (unlikely(ret != 0))
 		return ret;
 
-	if (new_mem->mem_type != TTM_PL_SYSTEM) {
+	if (ttm->num_pages && new_mem->mem_type != TTM_PL_SYSTEM) {
 		ret = ttm_tt_bind(ttm, new_mem);
 		if (unlikely(ret != 0))
 			return ret;
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drm/radeon: allow zero sized BOs for fences
  2014-08-07 14:30 [PATCH 1/2] drm/ttm: allow zero sized kernel allocations Christian König
@ 2014-08-07 14:30 ` Christian König
  2014-08-07 15:01   ` Jerome Glisse
  0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2014-08-07 14:30 UTC (permalink / raw)
  To: dri-devel

From: Christian König <christian.koenig@amd.com>

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
 drivers/gpu/drm/radeon/radeon_object.c | 2 +-
 drivers/gpu/drm/radeon/radeon_vm.c     | 3 +++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index a773830..f788170 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -84,9 +84,10 @@
  *   2.39.0 - Add INFO query for number of active CUs
  *   2.40.0 - Add RADEON_GEM_GTT_WC/UC, flush HDP cache before submitting
  *            CS to GPU
+ *   2.41.0 - Allow zero sized BOs
  */
 #define KMS_DRIVER_MAJOR	2
-#define KMS_DRIVER_MINOR	40
+#define KMS_DRIVER_MINOR	41
 #define KMS_DRIVER_PATCHLEVEL	0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 480c87d..9dd670e 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -154,7 +154,7 @@ int radeon_bo_create(struct radeon_device *rdev,
 
 	size = ALIGN(size, PAGE_SIZE);
 
-	if (kernel) {
+	if (kernel || size == 0) {
 		type = ttm_bo_type_kernel;
 	} else if (sg) {
 		type = ttm_bo_type_sg;
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index ccae4d9..a80f856 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -877,6 +877,9 @@ int radeon_vm_bo_update(struct radeon_device *rdev,
 	uint32_t flags;
 	int r;
 
+	if (bo_va->bo && radeon_bo_size(bo_va->bo) == 0)
+		return 0;
+
 	if (!bo_va->it.start) {
 		dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n",
 			bo_va->bo, vm);
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drm/radeon: allow zero sized BOs for fences
  2014-08-07 14:30 ` [PATCH 2/2] drm/radeon: allow zero sized BOs for fences Christian König
@ 2014-08-07 15:01   ` Jerome Glisse
  2014-08-07 15:52     ` Christian König
  0 siblings, 1 reply; 4+ messages in thread
From: Jerome Glisse @ 2014-08-07 15:01 UTC (permalink / raw)
  To: Christian König; +Cc: dri-devel

On Thu, Aug 07, 2014 at 04:30:33PM +0200, Christian König wrote:
> From: Christian König <christian.koenig@amd.com>


Can we get proper change log with motivation for doing that, use case,
why it can not be done any other ways ...

Change log is invaluable information and empty change log is the worst
thing ever.

> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
>  drivers/gpu/drm/radeon/radeon_object.c | 2 +-
>  drivers/gpu/drm/radeon/radeon_vm.c     | 3 +++
>  3 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index a773830..f788170 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -84,9 +84,10 @@
>   *   2.39.0 - Add INFO query for number of active CUs
>   *   2.40.0 - Add RADEON_GEM_GTT_WC/UC, flush HDP cache before submitting
>   *            CS to GPU
> + *   2.41.0 - Allow zero sized BOs
>   */
>  #define KMS_DRIVER_MAJOR	2
> -#define KMS_DRIVER_MINOR	40
> +#define KMS_DRIVER_MINOR	41
>  #define KMS_DRIVER_PATCHLEVEL	0
>  int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
>  int radeon_driver_unload_kms(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index 480c87d..9dd670e 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -154,7 +154,7 @@ int radeon_bo_create(struct radeon_device *rdev,
>  
>  	size = ALIGN(size, PAGE_SIZE);
>  
> -	if (kernel) {
> +	if (kernel || size == 0) {
>  		type = ttm_bo_type_kernel;
>  	} else if (sg) {
>  		type = ttm_bo_type_sg;
> diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
> index ccae4d9..a80f856 100644
> --- a/drivers/gpu/drm/radeon/radeon_vm.c
> +++ b/drivers/gpu/drm/radeon/radeon_vm.c
> @@ -877,6 +877,9 @@ int radeon_vm_bo_update(struct radeon_device *rdev,
>  	uint32_t flags;
>  	int r;
>  
> +	if (bo_va->bo && radeon_bo_size(bo_va->bo) == 0)
> +		return 0;
> +
>  	if (!bo_va->it.start) {
>  		dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n",
>  			bo_va->bo, vm);
> -- 
> 1.9.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drm/radeon: allow zero sized BOs for fences
  2014-08-07 15:01   ` Jerome Glisse
@ 2014-08-07 15:52     ` Christian König
  0 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2014-08-07 15:52 UTC (permalink / raw)
  To: Jerome Glisse; +Cc: dri-devel

Am 07.08.2014 um 17:01 schrieb Jerome Glisse:
> On Thu, Aug 07, 2014 at 04:30:33PM +0200, Christian König wrote:
>> From: Christian König <christian.koenig@amd.com>
>
> Can we get proper change log with motivation for doing that, use case,
> why it can not be done any other ways ...
>
> Change log is invaluable information and empty change log is the worst
> thing ever.

Yeah, sorry. Actually wanted to send out only the first one to get an 
opinion on that before proceeding.

Going to add a proper commit message,
Christian.

>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
>>   drivers/gpu/drm/radeon/radeon_object.c | 2 +-
>>   drivers/gpu/drm/radeon/radeon_vm.c     | 3 +++
>>   3 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
>> index a773830..f788170 100644
>> --- a/drivers/gpu/drm/radeon/radeon_drv.c
>> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
>> @@ -84,9 +84,10 @@
>>    *   2.39.0 - Add INFO query for number of active CUs
>>    *   2.40.0 - Add RADEON_GEM_GTT_WC/UC, flush HDP cache before submitting
>>    *            CS to GPU
>> + *   2.41.0 - Allow zero sized BOs
>>    */
>>   #define KMS_DRIVER_MAJOR	2
>> -#define KMS_DRIVER_MINOR	40
>> +#define KMS_DRIVER_MINOR	41
>>   #define KMS_DRIVER_PATCHLEVEL	0
>>   int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
>>   int radeon_driver_unload_kms(struct drm_device *dev);
>> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
>> index 480c87d..9dd670e 100644
>> --- a/drivers/gpu/drm/radeon/radeon_object.c
>> +++ b/drivers/gpu/drm/radeon/radeon_object.c
>> @@ -154,7 +154,7 @@ int radeon_bo_create(struct radeon_device *rdev,
>>   
>>   	size = ALIGN(size, PAGE_SIZE);
>>   
>> -	if (kernel) {
>> +	if (kernel || size == 0) {
>>   		type = ttm_bo_type_kernel;
>>   	} else if (sg) {
>>   		type = ttm_bo_type_sg;
>> diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
>> index ccae4d9..a80f856 100644
>> --- a/drivers/gpu/drm/radeon/radeon_vm.c
>> +++ b/drivers/gpu/drm/radeon/radeon_vm.c
>> @@ -877,6 +877,9 @@ int radeon_vm_bo_update(struct radeon_device *rdev,
>>   	uint32_t flags;
>>   	int r;
>>   
>> +	if (bo_va->bo && radeon_bo_size(bo_va->bo) == 0)
>> +		return 0;
>> +
>>   	if (!bo_va->it.start) {
>>   		dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n",
>>   			bo_va->bo, vm);
>> -- 
>> 1.9.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-07 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-07 14:30 [PATCH 1/2] drm/ttm: allow zero sized kernel allocations Christian König
2014-08-07 14:30 ` [PATCH 2/2] drm/radeon: allow zero sized BOs for fences Christian König
2014-08-07 15:01   ` Jerome Glisse
2014-08-07 15:52     ` Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.