Skip to contentSkip to conversation

amdgpu: add error return value for finding bo by cpu mapping

PATCH In review Junwei Zhang 3 participants 4 messages Aug 30, 2018 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu: add error return value for finding bo by cpu mapping

If nothing is found, error should be returned.

---
 amdgpu/amdgpu_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
amdgpu/amdgpu_bo.c +3 -1
index 2f4f90f..3812c5e 100644
@@ -550,6 +550,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
 				  uint64_t *offset_in_bo)
 {
 	uint32_t i;
+	int r = 0;
 	struct amdgpu_bo *bo;
 
 	if (cpu == NULL || size == 0)
@@ -577,10 +578,11 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
 	} else {
 		*buf_handle = NULL;
 		*offset_in_bo = 0;
+		r = -EINVAL;
 	}
 	pthread_mutex_unlock(&dev->bo_table_mutex);
 
-	return 0;
+	return r;
 }
 
 int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1535619003-18067-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

Am 30.08.2018 um 10:50 schrieb Junwei Zhang:

Quoted 3 lines

If nothing is found, error should be returned.

Quoted 9 lines
---
  amdgpu/amdgpu_bo.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
amdgpu/amdgpu_bo.c +0 -0
index 2f4f90f..3812c5e 100644

amdgpu/amdgpu_bo.c int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, · line 554

Quoted 5 lines
amdgpu/amdgpu_bo.c +1 -0
@@ -550,6 +550,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
  				  uint64_t *offset_in_bo)
  {
  	uint32_t i;
+	int r = 0;
  	struct amdgpu_bo *bo;

BTW: Kernel coding style usually uses reverse xmas tree for variables.

E.g. longest line first and variable like "i" or "r" last.

But not a big issue,
Christian.

Quoted 5 lines
amdgpu/amdgpu_bo.c +0 -0
  	if (cpu == NULL || size == 0)
@@ -577,10 +578,11 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
  	} else {
  		*buf_handle = NULL;

amdgpu/amdgpu_bo.c int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, · line 588

Quoted 10 lines
amdgpu/amdgpu_bo.c +2 -1
  		*offset_in_bo = 0;
+		r = -EINVAL;
  	}
  	pthread_mutex_unlock(&dev->bo_table_mutex);
 
-	return 0;
+	return r;
  }
 
  int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#3 lore raw
In reply to a message not in the archive

amdgpu/amdgpu_bo.c int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, · line 581

Quoted 11 lines · Junwei Zhang

If nothing is found, error should be returned.

[...]

amdgpu/amdgpu_bo.c +1 -0
@@ -577,10 +578,11 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
 	} else {
 		*buf_handle = NULL;
 		*offset_in_bo = 0;
+		r = -EINVAL;

I think -ENOENT would be better, to differentiate this error from passing invalid pointer / size parameters.

With that,

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 01272587-1647-4456-57fa-ad809a100c34-otUistvHUpPR7s880joybQ@public.gmane.org

#5 lore raw
Quoted 7 lines · Michel Dänzer
Quoted 6 lines · Junwei Zhang

If nothing is found, error should be returned.

[...]

Quoted 8 lines

amdgpu/amdgpu_bo.c int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, · line 581

Quoted 5 lines
amdgpu/amdgpu_bo.c +1 -0
@@ -577,10 +578,11 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
  	} else {
  		*buf_handle = NULL;
  		*offset_in_bo = 0;
+		r = -EINVAL;

I think -ENOENT would be better, to differentiate this error from passing invalid pointer / size parameters.

Mmm, good point, perhaps ENXIO is better,
which is used in amdgpu ttm for address out of existing range.

#define ENOENT           2      /* No such file or directory */
#define ENXIO            6      /* No such device or address */

Regards,
Jerry

Quoted 6 lines

With that,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx