Skip to contentSkip to conversation

amdgpu: add amdgpu_bo_inc_ref() function.

PATCH In review Qiang Yu 4 participants 7 messages Sep 3, 2018 5 messages not in the archive

lore
Share & tools
lore

Qiang Yu

author
#0 lore raw

PATCH 1/1 amdgpu: add amdgpu_bo_inc_ref() function.

For Pro OGL be able to work with upstream libdrm.

---
 amdgpu/amdgpu-symbol-check |  1 +
 amdgpu/amdgpu.h            | 15 ++++++++++++++-
 amdgpu/amdgpu_bo.c         |  6 ++++++
 3 files changed, 21 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +1 -0
index b5e4fe6..487610e 100755
@@ -15,6 +15,7 @@ amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
+amdgpu_bo_inc_ref
 amdgpu_bo_import
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
amdgpu/amdgpu.h +14 -1
index a8c353c..e1f93f8 100644
@@ -721,7 +721,20 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
 int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
 
 /**
- * Request CPU access to GPU accessible memory
+ * Increase the reference count of a buffer object
+ *
+ * \param   bo - \c [in]  Buffer object handle to increase the reference count
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
+ *
+*/
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo);
+
+/**
+ * Request CPU access to GPU accessable memory
  *
  * \param   buf_handle - \c [in] Buffer handle
  * \param   cpu        - \c [out] CPU address to be used for access
amdgpu/amdgpu_bo.c +6 -0
index a2fc525..dceab01 100644
@@ -438,6 +438,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
 	return 0;
 }
 
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+	atomic_inc(&bo->refcount);
+	return 0;
+}
+
 int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)
 {
 	union drm_amdgpu_gem_mmap args;
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): 1535957709-26008-1-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org

Reviewed-by Junwei Zhang
#2 lore raw
Quoted 4 lines · Qiang Yu

For Pro OGL be able to work with upstream libdrm.

I'm fine with that, not sure if mesa is going to use that as well.

Regards,
Jerry

Quoted 52 lines
---
  amdgpu/amdgpu-symbol-check |  1 +
  amdgpu/amdgpu.h            | 15 ++++++++++++++-
  amdgpu/amdgpu_bo.c         |  6 ++++++
  3 files changed, 21 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +1 -0
index b5e4fe6..487610e 100755
@@ -15,6 +15,7 @@ amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
+amdgpu_bo_inc_ref
  amdgpu_bo_import
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
amdgpu/amdgpu.h +14 -1
index a8c353c..e1f93f8 100644
@@ -721,7 +721,20 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
  int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
 
  /**
- * Request CPU access to GPU accessible memory
+ * Increase the reference count of a buffer object
+ *
+ * \param   bo - \c [in]  Buffer object handle to increase the reference count
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
+ *
+*/
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo);
+
+/**
+ * Request CPU access to GPU accessable memory
   *
   * \param   buf_handle - \c [in] Buffer handle
   * \param   cpu        - \c [out] CPU address to be used for access
amdgpu/amdgpu_bo.c +0 -0
index a2fc525..dceab01 100644
@@ -438,6 +438,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
  	return 0;
  }

amdgpu/amdgpu_bo.c int amdgpu_bo_free(amdgpu_bo_handle buf_handle) · line 449

Quoted 10 lines
amdgpu/amdgpu_bo.c +6 -0
 
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+	atomic_inc(&bo->refcount);
+	return 0;
+}
+
  int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)
  {
  	union drm_amdgpu_gem_mmap args;

_______________________________________________
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): [email protected]

author Reviewed-by Junwei Zhang
#4 lore raw

Thanks Jerry.

Hi Christian,

This is an old patch back to 2016 reviewed in hybrid list. If you are OK with it, would you please submit it to upstream?

Thanks,
Qiang

________________________________________
From: amd-gfx <[email protected]> on behalf of Zhang, Jerry (Junwei) <[email protected]>
Sent: Monday, September 3, 2018 3:18:14 PM
To: Yu, Qiang; [email protected]
Cc: Koenig, Christian; Deng, Hui
Subject: Re: [PATCH libdrm] amdgpu: add amdgpu_bo_inc_ref() function.

Quoted 4 lines · Qiang Yu

For Pro OGL be able to work with upstream libdrm.

I'm fine with that, not sure if mesa is going to use that as well.

Regards,
Jerry

Quoted 52 lines
---
  amdgpu/amdgpu-symbol-check |  1 +
  amdgpu/amdgpu.h            | 15 ++++++++++++++-
  amdgpu/amdgpu_bo.c         |  6 ++++++
  3 files changed, 21 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +1 -0
index b5e4fe6..487610e 100755
@@ -15,6 +15,7 @@ amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
+amdgpu_bo_inc_ref
  amdgpu_bo_import
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
amdgpu/amdgpu.h +14 -1
index a8c353c..e1f93f8 100644
@@ -721,7 +721,20 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
  int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
 
  /**
- * Request CPU access to GPU accessible memory
+ * Increase the reference count of a buffer object
+ *
+ * \param   bo - \c [in]  Buffer object handle to increase the reference count
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
+ *
+*/
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo);
+
+/**
+ * Request CPU access to GPU accessable memory
   *
   * \param   buf_handle - \c [in] Buffer handle
   * \param   cpu        - \c [out] CPU address to be used for access
amdgpu/amdgpu_bo.c +0 -0
index a2fc525..dceab01 100644
@@ -438,6 +438,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
      return 0;
  }

amdgpu/amdgpu_bo.c int amdgpu_bo_free(amdgpu_bo_handle buf_handle) · line 449

Quoted 10 lines
amdgpu/amdgpu_bo.c +6 -0
 
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+     atomic_inc(&bo->refcount);
+     return 0;
+}
+
  int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)
  {
      union drm_amdgpu_gem_mmap args;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): BY2PR12MB0243586F3EAAD25B3A2308AC8F0C0-K//h7OWB4q7MW+x49lsN/[email protected]

#6 lore raw

Done.

Christian.

Am 03.09.2018 um 10:03 schrieb Yu, Qiang:

Quoted 91 lines

Thanks Jerry.

Hi Christian,

This is an old patch back to 2016 reviewed in hybrid list. If you are OK with it, would you please submit it to upstream?

Thanks,
Qiang

________________________________________
From: amd-gfx <[email protected]> on behalf of Zhang, Jerry (Junwei) <[email protected]>
Sent: Monday, September 3, 2018 3:18:14 PM
To: Yu, Qiang; [email protected]
Cc: Koenig, Christian; Deng, Hui
Subject: Re: [PATCH libdrm] amdgpu: add amdgpu_bo_inc_ref() function.

Quoted 4 lines · Qiang Yu

For Pro OGL be able to work with upstream libdrm.

I'm fine with that, not sure if mesa is going to use that as well.

Regards,
Jerry

Quoted 52 lines
---
   amdgpu/amdgpu-symbol-check |  1 +
   amdgpu/amdgpu.h            | 15 ++++++++++++++-
   amdgpu/amdgpu_bo.c         |  6 ++++++
   3 files changed, 21 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +1 -0
index b5e4fe6..487610e 100755
@@ -15,6 +15,7 @@ amdgpu_bo_cpu_map
   amdgpu_bo_cpu_unmap
   amdgpu_bo_export
   amdgpu_bo_free
+amdgpu_bo_inc_ref
   amdgpu_bo_import
   amdgpu_bo_list_create
   amdgpu_bo_list_destroy
amdgpu/amdgpu.h +14 -1
index a8c353c..e1f93f8 100644
@@ -721,7 +721,20 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
   int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
 
   /**
- * Request CPU access to GPU accessible memory
+ * Increase the reference count of a buffer object
+ *
+ * \param   bo - \c [in]  Buffer object handle to increase the reference count
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
+ *
+*/
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo);
+
+/**
+ * Request CPU access to GPU accessable memory
    *
    * \param   buf_handle - \c [in] Buffer handle
    * \param   cpu        - \c [out] CPU address to be used for access
amdgpu/amdgpu_bo.c +0 -0
index a2fc525..dceab01 100644
@@ -438,6 +438,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
       return 0;
   }

amdgpu/amdgpu_bo.c int amdgpu_bo_free(amdgpu_bo_handle buf_handle) · line 449

Quoted 10 lines
amdgpu/amdgpu_bo.c +6 -0
 
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+     atomic_inc(&bo->refcount);
+     return 0;
+}
+
   int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)
   {
       union drm_amdgpu_gem_mmap args;
Quoted 8 lines

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

_______________________________________________
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): a62cdc40-80b4-6d51-b504-794fcc4a68c0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#8 lore raw

Thanks.

Regards,
Qiang

________________________________________
From: Christian König <[email protected]>
Sent: Monday, September 3, 2018 4:57:39 PM
To: Yu, Qiang; Zhang, Jerry; [email protected]
Cc: Koenig, Christian; Deng, Hui
Subject: Re: [PATCH libdrm] amdgpu: add amdgpu_bo_inc_ref() function.

Done.

Christian.

Am 03.09.2018 um 10:03 schrieb Yu, Qiang:

Quoted 91 lines

Thanks Jerry.

Hi Christian,

This is an old patch back to 2016 reviewed in hybrid list. If you are OK with it, would you please submit it to upstream?

Thanks,
Qiang

________________________________________
From: amd-gfx <[email protected]> on behalf of Zhang, Jerry (Junwei) <[email protected]>
Sent: Monday, September 3, 2018 3:18:14 PM
To: Yu, Qiang; [email protected]
Cc: Koenig, Christian; Deng, Hui
Subject: Re: [PATCH libdrm] amdgpu: add amdgpu_bo_inc_ref() function.

Quoted 4 lines · Qiang Yu

For Pro OGL be able to work with upstream libdrm.

I'm fine with that, not sure if mesa is going to use that as well.

Regards,
Jerry

Quoted 52 lines
---
   amdgpu/amdgpu-symbol-check |  1 +
   amdgpu/amdgpu.h            | 15 ++++++++++++++-
   amdgpu/amdgpu_bo.c         |  6 ++++++
   3 files changed, 21 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +1 -0
index b5e4fe6..487610e 100755
@@ -15,6 +15,7 @@ amdgpu_bo_cpu_map
   amdgpu_bo_cpu_unmap
   amdgpu_bo_export
   amdgpu_bo_free
+amdgpu_bo_inc_ref
   amdgpu_bo_import
   amdgpu_bo_list_create
   amdgpu_bo_list_destroy
amdgpu/amdgpu.h +14 -1
index a8c353c..e1f93f8 100644
@@ -721,7 +721,20 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
   int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
 
   /**
- * Request CPU access to GPU accessible memory
+ * Increase the reference count of a buffer object
+ *
+ * \param   bo - \c [in]  Buffer object handle to increase the reference count
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
+ *
+*/
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo);
+
+/**
+ * Request CPU access to GPU accessable memory
    *
    * \param   buf_handle - \c [in] Buffer handle
    * \param   cpu        - \c [out] CPU address to be used for access
amdgpu/amdgpu_bo.c +0 -0
index a2fc525..dceab01 100644
@@ -438,6 +438,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
       return 0;
   }

amdgpu/amdgpu_bo.c int amdgpu_bo_free(amdgpu_bo_handle buf_handle) · line 449

Quoted 10 lines
amdgpu/amdgpu_bo.c +6 -0
 
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+     atomic_inc(&bo->refcount);
+     return 0;
+}
+
   int amdgpu_bo_cpu_map(amdgpu_bo_handle bo, void **cpu)
   {
       union drm_amdgpu_gem_mmap args;
Quoted 8 lines

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

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

#9 lore raw
In reply to a message not in the archive
Quoted 15 lines · Qiang Yu

For Pro OGL be able to work with upstream libdrm.

---
 amdgpu/amdgpu-symbol-check |  1 +
 amdgpu/amdgpu.h            | 15 ++++++++++++++-
 amdgpu/amdgpu_bo.c         |  6 ++++++
 3 files changed, 21 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +0 -0
index b5e4fe6..487610e 100755

amdgpu/amdgpu-symbol-check amdgpu_bo_cpu_map · line 21

Quoted 7 lines
amdgpu/amdgpu-symbol-check +1 -0
@@ -15,6 +15,7 @@ amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
+amdgpu_bo_inc_ref
 amdgpu_bo_import
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy

Thanks for remembering to add the symbol here, but amdgpu_bo_inc_ref goes after amdgpu_bo_import in lexical order. :)

amdgpu/amdgpu_bo.c int amdgpu_bo_free(amdgpu_bo_handle buf_handle) · line 445

Quoted 13 lines
amdgpu/amdgpu_bo.c +5 -0
index a2fc525..dceab01 100644
@@ -438,6 +438,12 @@ int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
 	return 0;
 }
 
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+	atomic_inc(&bo->refcount);
+	return 0;
+}

What's the point of having a non-void return value that's always 0?

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): ff7f2575-7c8b-3083-d10a-7445bbaa6f14-otUistvHUpPR7s880joybQ@public.gmane.org

author
#11 lore raw
Quoted 9 lines
Quoted 6 lines

amdgpu_bo_free
+amdgpu_bo_inc_ref
amdgpu_bo_import
amdgpu_bo_list_create
amdgpu_bo_list_destroy

Thanks for remembering to add the symbol here, but amdgpu_bo_inc_ref goes after amdgpu_bo_import in lexical order. :)

Oh, haven't notice this is in alphabetic order.

Quoted 8 lines

amdgpu/amdgpu_bo.c int amdgpu_bo_free(amdgpu_bo_handle buf_handle) · line 445

Quoted 6 lines
amdgpu/amdgpu_bo.c +5 -0
+int amdgpu_bo_inc_ref(amdgpu_bo_handle bo)
+{
+     atomic_inc(&bo->refcount);
+     return 0;
+}

What's the point of having a non-void return value that's always 0?

Indeed no actual functionality, will prepare a patch for removing it.

Thanks,
Qiang

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