* [PATCH 1/2] drm/amdgpu: set preferred_domain independent of fallback handling
@ 2018-04-17 10:38 Chunming Zhou
[not found] ` <20180417103834.27656-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Chunming Zhou @ 2018-04-17 10:38 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Chunming Zhou
When GEM needs to fallback to GTT for VRAM BOs we still want the
preferred domain to be untouched so that the BO has a cance to move back
to VRAM in the future.
Change-Id: I8cfdf3f30532f7e5d80b8e4266b7800211de2f0b
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 15 +++++++++------
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 +
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 1200c5ba37da..ff606ce88837 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -62,6 +62,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
bp.byte_align = alignment;
bp.type = type;
bp.resv = resv;
+ bp.preferred_domain = initial_domain;
retry:
bp.flags = flags;
bp.domain = initial_domain;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index cac65e32a0b9..9258f0694922 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
};
struct amdgpu_bo *bo;
unsigned long page_align, size = bp->size;
+ u32 preferred_domains;
size_t acc_size;
int r;
@@ -380,12 +381,14 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
drm_gem_private_object_init(adev->ddev, &bo->gem_base, size);
INIT_LIST_HEAD(&bo->shadow_list);
INIT_LIST_HEAD(&bo->va);
- bo->preferred_domains = bp->domain & (AMDGPU_GEM_DOMAIN_VRAM |
- AMDGPU_GEM_DOMAIN_GTT |
- AMDGPU_GEM_DOMAIN_CPU |
- AMDGPU_GEM_DOMAIN_GDS |
- AMDGPU_GEM_DOMAIN_GWS |
- AMDGPU_GEM_DOMAIN_OA);
+ preferred_domains = bp->preferred_domain ? bp->preferred_domain :
+ bp->domain;
+ bo->preferred_domains = preferred_domains & (AMDGPU_GEM_DOMAIN_VRAM |
+ AMDGPU_GEM_DOMAIN_GTT |
+ AMDGPU_GEM_DOMAIN_CPU |
+ AMDGPU_GEM_DOMAIN_GDS |
+ AMDGPU_GEM_DOMAIN_GWS |
+ AMDGPU_GEM_DOMAIN_OA);
bo->allowed_domains = bo->preferred_domains;
if (bp->type != ttm_bo_type_kernel &&
bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index e9a21d991e77..540e03fa159f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -37,6 +37,7 @@ struct amdgpu_bo_param {
unsigned long size;
int byte_align;
u32 domain;
+ u32 preferred_domain;
u64 flags;
enum ttm_bo_type type;
struct reservation_object *resv;
--
2.14.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] drm/amdgpu: handle domain mask checking
[not found] ` <20180417103834.27656-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
@ 2018-04-17 10:38 ` Chunming Zhou
[not found] ` <20180417103834.27656-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Chunming Zhou @ 2018-04-17 10:38 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Chunming Zhou
if domain is illegal, we should return error.
Change-Id: I65a738f5ac4fc34be76de867afb0db1d4bd27c24
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 15 +++++++--------
include/uapi/drm/amdgpu_drm.h | 6 ++++++
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 9258f0694922..ddf1b3580d37 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -378,17 +378,16 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
if (bo == NULL)
return -ENOMEM;
+ preferred_domains = bp->preferred_domain ? bp->preferred_domain :
+ bp->domain;
+ if (preferred_domains & ~AMDGPU_GEM_DOMAIN_MASK) {
+ kfree(bo);
+ return -EINVAL;
+ }
drm_gem_private_object_init(adev->ddev, &bo->gem_base, size);
INIT_LIST_HEAD(&bo->shadow_list);
INIT_LIST_HEAD(&bo->va);
- preferred_domains = bp->preferred_domain ? bp->preferred_domain :
- bp->domain;
- bo->preferred_domains = preferred_domains & (AMDGPU_GEM_DOMAIN_VRAM |
- AMDGPU_GEM_DOMAIN_GTT |
- AMDGPU_GEM_DOMAIN_CPU |
- AMDGPU_GEM_DOMAIN_GDS |
- AMDGPU_GEM_DOMAIN_GWS |
- AMDGPU_GEM_DOMAIN_OA);
+ bo->preferred_domains = preferred_domains;
bo->allowed_domains = bo->preferred_domains;
if (bp->type != ttm_bo_type_kernel &&
bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 0087799962cf..d023d3c4ee51 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -81,6 +81,12 @@ extern "C" {
#define AMDGPU_GEM_DOMAIN_GDS 0x8
#define AMDGPU_GEM_DOMAIN_GWS 0x10
#define AMDGPU_GEM_DOMAIN_OA 0x20
+#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \
+ AMDGPU_GEM_DOMAIN_GTT | \
+ AMDGPU_GEM_DOMAIN_VRAM | \
+ AMDGPU_GEM_DOMAIN_GDS | \
+ AMDGPU_GEM_DOMAIN_GWS | \
+ AMDGPU_GEM_DOMAIN_OA)
/* Flag that CPU access will be required for the case of VRAM domain */
#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
--
2.14.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] drm/amdgpu: handle domain mask checking
[not found] ` <20180417103834.27656-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
@ 2018-04-17 12:07 ` Christian König
0 siblings, 0 replies; 3+ messages in thread
From: Christian König @ 2018-04-17 12:07 UTC (permalink / raw)
To: Chunming Zhou, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Am 17.04.2018 um 12:38 schrieb Chunming Zhou:
> if domain is illegal, we should return error.
This check is already in amdgpu_gem_create_ioctl():
> if (args->in.domains & ~(AMDGPU_GEM_DOMAIN_CPU |
> AMDGPU_GEM_DOMAIN_GTT |
> AMDGPU_GEM_DOMAIN_VRAM |
> AMDGPU_GEM_DOMAIN_GDS |
> AMDGPU_GEM_DOMAIN_GWS |
> AMDGPU_GEM_DOMAIN_OA))
> return -EINVAL;
We should just check it at one place I think.
Either remove it in amdgpu_bo_do_create() or in amdgpu_gem_create_ioctl().
Regards,
Christian.
>
> Change-Id: I65a738f5ac4fc34be76de867afb0db1d4bd27c24
> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 15 +++++++--------
> include/uapi/drm/amdgpu_drm.h | 6 ++++++
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 9258f0694922..ddf1b3580d37 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -378,17 +378,16 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
> bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
> if (bo == NULL)
> return -ENOMEM;
> + preferred_domains = bp->preferred_domain ? bp->preferred_domain :
> + bp->domain;
> + if (preferred_domains & ~AMDGPU_GEM_DOMAIN_MASK) {
> + kfree(bo);
> + return -EINVAL;
> + }
> drm_gem_private_object_init(adev->ddev, &bo->gem_base, size);
> INIT_LIST_HEAD(&bo->shadow_list);
> INIT_LIST_HEAD(&bo->va);
> - preferred_domains = bp->preferred_domain ? bp->preferred_domain :
> - bp->domain;
> - bo->preferred_domains = preferred_domains & (AMDGPU_GEM_DOMAIN_VRAM |
> - AMDGPU_GEM_DOMAIN_GTT |
> - AMDGPU_GEM_DOMAIN_CPU |
> - AMDGPU_GEM_DOMAIN_GDS |
> - AMDGPU_GEM_DOMAIN_GWS |
> - AMDGPU_GEM_DOMAIN_OA);
> + bo->preferred_domains = preferred_domains;
> bo->allowed_domains = bo->preferred_domains;
> if (bp->type != ttm_bo_type_kernel &&
> bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
> index 0087799962cf..d023d3c4ee51 100644
> --- a/include/uapi/drm/amdgpu_drm.h
> +++ b/include/uapi/drm/amdgpu_drm.h
> @@ -81,6 +81,12 @@ extern "C" {
> #define AMDGPU_GEM_DOMAIN_GDS 0x8
> #define AMDGPU_GEM_DOMAIN_GWS 0x10
> #define AMDGPU_GEM_DOMAIN_OA 0x20
> +#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \
> + AMDGPU_GEM_DOMAIN_GTT | \
> + AMDGPU_GEM_DOMAIN_VRAM | \
> + AMDGPU_GEM_DOMAIN_GDS | \
> + AMDGPU_GEM_DOMAIN_GWS | \
> + AMDGPU_GEM_DOMAIN_OA)
>
> /* Flag that CPU access will be required for the case of VRAM domain */
> #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-17 12:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17 10:38 [PATCH 1/2] drm/amdgpu: set preferred_domain independent of fallback handling Chunming Zhou
[not found] ` <20180417103834.27656-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-04-17 10:38 ` [PATCH 2/2] drm/amdgpu: handle domain mask checking Chunming Zhou
[not found] ` <20180417103834.27656-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-04-17 12:07 ` 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.