* [PATCH 1/1] drm/amdgpu: implement and use amdgpu_bo_create_with_shadow()
@ 2021-04-21 13:20 Nirmoy Das
2021-04-21 13:28 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Nirmoy Das @ 2021-04-21 13:20 UTC (permalink / raw)
To: Christian.Koenig; +Cc: Nirmoy Das, amd-gfx
Shadow bo is only needed for some amdgpu_vm allcations.
amdgpu_bo_create_with_shadow() should make it clear that
a bo is for amdgpu_vm and will also remove unnecessary checks
from amdgpu_bo_create().
Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 26 ++++++++++++++++++----
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++-
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 1345f7eba011..608f07377d20 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -661,10 +661,7 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
* @bp: parameters to be used for the buffer object
* @bo_ptr: pointer to the buffer object pointer
*
- * Creates an &amdgpu_bo buffer object; and if requested, also creates a
- * shadow object.
- * Shadow object is used to backup the original buffer object, and is always
- * in GTT.
+ * Creates an &amdgpu_bo buffer object.
*
* Returns:
* 0 for success or a negative error code on failure.
@@ -673,6 +670,27 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
struct amdgpu_bo_param *bp,
struct amdgpu_bo **bo_ptr)
{
+
+ return amdgpu_bo_do_create(adev, bp, bo_ptr);
+}
+
+/**
+ * amdgpu_bo_create_with_shadow - create an &amdgpu_bo buffer object
+ * @adev: amdgpu device object
+ * @bp: parameters to be used for the buffer object
+ * @bo_ptr: pointer to the buffer object pointer
+ *
+ * Creates an &amdgpu_bo buffer object with a shadow object.
+ * Shadow object is used to backup the original buffer object, and is always
+ * in GTT.
+ *
+ * Returns:
+ * 0 for success or a negative error code on failure.
+ */
+int amdgpu_bo_create_with_shadow(struct amdgpu_device *adev,
+ struct amdgpu_bo_param *bp,
+ struct amdgpu_bo **bo_ptr)
+{
u64 flags = bp->flags;
int r;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 973c88bdf37b..6a9187ca0496 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -255,6 +255,11 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain);
int amdgpu_bo_create(struct amdgpu_device *adev,
struct amdgpu_bo_param *bp,
struct amdgpu_bo **bo_ptr);
+
+int amdgpu_bo_create_with_shadow(struct amdgpu_device *adev,
+ struct amdgpu_bo_param *bp,
+ struct amdgpu_bo **bo_ptr);
+
int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
unsigned long size, int align,
u32 domain, struct amdgpu_bo **bo_ptr,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f95bcda8463f..2770d3b8dbde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -920,8 +920,11 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
return 0;
amdgpu_vm_bo_param(adev, vm, cursor->level, immediate, &bp);
+ if (bp.flags & AMDGPU_GEM_CREATE_SHADOW)
+ r = amdgpu_bo_create_with_shadow(adev, &bp, &pt);
+ else
+ r = amdgpu_bo_create(adev, &bp, &pt);
- r = amdgpu_bo_create(adev, &bp, &pt);
if (r)
return r;
--
2.31.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] drm/amdgpu: implement and use amdgpu_bo_create_with_shadow()
2021-04-21 13:20 [PATCH 1/1] drm/amdgpu: implement and use amdgpu_bo_create_with_shadow() Nirmoy Das
@ 2021-04-21 13:28 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2021-04-21 13:28 UTC (permalink / raw)
To: Nirmoy Das; +Cc: amd-gfx
Am 21.04.21 um 15:20 schrieb Nirmoy Das:
> Shadow bo is only needed for some amdgpu_vm allcations.
> amdgpu_bo_create_with_shadow() should make it clear that
> a bo is for amdgpu_vm and will also remove unnecessary checks
> from amdgpu_bo_create().
I was the one suggesting to make the shadow thing general handling.
But since that never took of I think we could just move it back into the
VM handling and maybe even drop the flag.
Christian.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 26 ++++++++++++++++++----
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++-
> 3 files changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 1345f7eba011..608f07377d20 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -661,10 +661,7 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
> * @bp: parameters to be used for the buffer object
> * @bo_ptr: pointer to the buffer object pointer
> *
> - * Creates an &amdgpu_bo buffer object; and if requested, also creates a
> - * shadow object.
> - * Shadow object is used to backup the original buffer object, and is always
> - * in GTT.
> + * Creates an &amdgpu_bo buffer object.
> *
> * Returns:
> * 0 for success or a negative error code on failure.
> @@ -673,6 +670,27 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
> struct amdgpu_bo_param *bp,
> struct amdgpu_bo **bo_ptr)
> {
> +
> + return amdgpu_bo_do_create(adev, bp, bo_ptr);
> +}
> +
> +/**
> + * amdgpu_bo_create_with_shadow - create an &amdgpu_bo buffer object
> + * @adev: amdgpu device object
> + * @bp: parameters to be used for the buffer object
> + * @bo_ptr: pointer to the buffer object pointer
> + *
> + * Creates an &amdgpu_bo buffer object with a shadow object.
> + * Shadow object is used to backup the original buffer object, and is always
> + * in GTT.
> + *
> + * Returns:
> + * 0 for success or a negative error code on failure.
> + */
> +int amdgpu_bo_create_with_shadow(struct amdgpu_device *adev,
> + struct amdgpu_bo_param *bp,
> + struct amdgpu_bo **bo_ptr)
> +{
> u64 flags = bp->flags;
> int r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index 973c88bdf37b..6a9187ca0496 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -255,6 +255,11 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain);
> int amdgpu_bo_create(struct amdgpu_device *adev,
> struct amdgpu_bo_param *bp,
> struct amdgpu_bo **bo_ptr);
> +
> +int amdgpu_bo_create_with_shadow(struct amdgpu_device *adev,
> + struct amdgpu_bo_param *bp,
> + struct amdgpu_bo **bo_ptr);
> +
> int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
> unsigned long size, int align,
> u32 domain, struct amdgpu_bo **bo_ptr,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index f95bcda8463f..2770d3b8dbde 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -920,8 +920,11 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
> return 0;
>
> amdgpu_vm_bo_param(adev, vm, cursor->level, immediate, &bp);
> + if (bp.flags & AMDGPU_GEM_CREATE_SHADOW)
> + r = amdgpu_bo_create_with_shadow(adev, &bp, &pt);
> + else
> + r = amdgpu_bo_create(adev, &bp, &pt);
>
> - r = amdgpu_bo_create(adev, &bp, &pt);
> if (r)
> return r;
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-21 13:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 13:20 [PATCH 1/1] drm/amdgpu: implement and use amdgpu_bo_create_with_shadow() Nirmoy Das
2021-04-21 13:28 ` Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).