* [PATCH 1/2] drm/amdgpu: Add kfd2kgd.set_compute_idle interface
@ 2018-07-16 23:10 Felix Kuehling
[not found] ` <1531782637-7458-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Felix Kuehling @ 2018-07-16 23:10 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
oded.gabbay-Re5JQEeQqe8AvxtiuMwx3w
Cc: Felix Kuehling
This allows automatic switching to the compute power profile depending
on compute activity.
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Eric Huang <JinHuiEric.Huang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 8 ++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 3 ++-
drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 5 +++++
6 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 6ec9f31..91864ada 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -484,6 +484,14 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
return ret;
}
+void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle)
+{
+ struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
+
+ amdgpu_dpm_switch_power_profile(adev,
+ PP_SMC_POWER_PROFILE_COMPUTE, !idle);
+}
+
bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid)
{
if (adev->kfd) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index 60207ea..2f379c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -119,6 +119,7 @@ int amdgpu_amdkfd_evict_userptr(struct kgd_mem *mem, struct mm_struct *mm);
int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
uint32_t vmid, uint64_t gpu_addr,
uint32_t *ib_cmd, uint32_t ib_len);
+void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void);
struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
index 98eac00..ea3f698 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
@@ -219,7 +219,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
.submit_ib = amdgpu_amdkfd_submit_ib,
.get_vm_fault_info = amdgpu_amdkfd_gpuvm_get_vm_fault_info,
.read_vmid_from_vmfault_reg = read_vmid_from_vmfault_reg,
- .gpu_recover = amdgpu_amdkfd_gpu_reset
+ .gpu_recover = amdgpu_amdkfd_gpu_reset,
+ .set_compute_idle = amdgpu_amdkfd_set_compute_idle
};
struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
index ad563b1..f6e53e9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
@@ -177,7 +177,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
.invalidate_tlbs_vmid = invalidate_tlbs_vmid,
.submit_ib = amdgpu_amdkfd_submit_ib,
.get_vm_fault_info = amdgpu_amdkfd_gpuvm_get_vm_fault_info,
- .gpu_recover = amdgpu_amdkfd_gpu_reset
+ .gpu_recover = amdgpu_amdkfd_gpu_reset,
+ .set_compute_idle = amdgpu_amdkfd_set_compute_idle
};
struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
index 3b07d37..8efedfc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
@@ -213,7 +213,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
.invalidate_tlbs = invalidate_tlbs,
.invalidate_tlbs_vmid = invalidate_tlbs_vmid,
.submit_ib = amdgpu_amdkfd_submit_ib,
- .gpu_recover = amdgpu_amdkfd_gpu_reset
+ .gpu_recover = amdgpu_amdkfd_gpu_reset,
+ .set_compute_idle = amdgpu_amdkfd_set_compute_idle
};
struct kfd2kgd_calls *amdgpu_amdkfd_gfx_9_0_get_functions(void)
diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h
index 7df5e4a..14391b0 100644
--- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h
@@ -282,6 +282,9 @@ struct tile_config {
*
* @gpu_recover: let kgd reset gpu after kfd detect CPC hang
*
+ * @set_compute_idle: Indicates that compute is idle on a device. This
+ * can be used to change power profiles depending on compute activity.
+ *
* This structure contains function pointers to services that the kgd driver
* provides to amdkfd driver.
*
@@ -403,6 +406,8 @@ struct kfd2kgd_calls {
uint32_t (*read_vmid_from_vmfault_reg)(struct kgd_dev *kgd);
void (*gpu_recover)(struct kgd_dev *kgd);
+
+ void (*set_compute_idle)(struct kgd_dev *kgd, bool idle);
};
/**
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] drm/amdkfd: Call kfd2kgd.set_compute_idle
[not found] ` <1531782637-7458-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
@ 2018-07-16 23:10 ` Felix Kuehling
[not found] ` <1531782637-7458-2-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Felix Kuehling @ 2018-07-16 23:10 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
oded.gabbay-Re5JQEeQqe8AvxtiuMwx3w
Cc: Felix Kuehling
User mode queue submissions don't go through KFD. Therefore we don't
know exactly when compute is idle or not idle. We use the existence
of user mode queues on a device as an approximation.
register_process is called when the first queue of a process is
created. Conversely unregister_process is called when the last queue
is destroyed. The first process that is registered takes compute
out of idle. The last process that is unregisters sets compute back
to idle.
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Eric Huang <JinHuiEric.Huang@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index ace94d6..ec0d62a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -782,7 +782,8 @@ static int register_process(struct device_queue_manager *dqm,
retval = dqm->asic_ops.update_qpd(dqm, qpd);
- dqm->processes_count++;
+ if (dqm->processes_count++ == 0)
+ dqm->dev->kfd2kgd->set_compute_idle(dqm->dev->kgd, false);
dqm_unlock(dqm);
@@ -805,7 +806,9 @@ static int unregister_process(struct device_queue_manager *dqm,
if (qpd == cur->qpd) {
list_del(&cur->list);
kfree(cur);
- dqm->processes_count--;
+ if (--dqm->processes_count == 0)
+ dqm->dev->kfd2kgd->set_compute_idle(
+ dqm->dev->kgd, true);
goto out;
}
}
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] drm/amdkfd: Call kfd2kgd.set_compute_idle
[not found] ` <1531782637-7458-2-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
@ 2018-07-17 16:14 ` Alex Deucher
[not found] ` <CADnq5_OPpyw06o-3qqOGmVVgY54wgxwqEhMWrSNHcVk8=c5znw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2018-07-17 16:14 UTC (permalink / raw)
To: Felix Kuehling; +Cc: Oded Gabbay, amd-gfx list
On Mon, Jul 16, 2018 at 7:10 PM, Felix Kuehling <Felix.Kuehling@amd.com> wrote:
> User mode queue submissions don't go through KFD. Therefore we don't
> know exactly when compute is idle or not idle. We use the existence
> of user mode queues on a device as an approximation.
>
> register_process is called when the first queue of a process is
> created. Conversely unregister_process is called when the last queue
> is destroyed. The first process that is registered takes compute
> out of idle. The last process that is unregisters sets compute back
> to idle.
>
> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
> Reviewed-by: Eric Huang <JinHuiEric.Huang@amd.com>
Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index ace94d6..ec0d62a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -782,7 +782,8 @@ static int register_process(struct device_queue_manager *dqm,
>
> retval = dqm->asic_ops.update_qpd(dqm, qpd);
>
> - dqm->processes_count++;
> + if (dqm->processes_count++ == 0)
> + dqm->dev->kfd2kgd->set_compute_idle(dqm->dev->kgd, false);
>
> dqm_unlock(dqm);
>
> @@ -805,7 +806,9 @@ static int unregister_process(struct device_queue_manager *dqm,
> if (qpd == cur->qpd) {
> list_del(&cur->list);
> kfree(cur);
> - dqm->processes_count--;
> + if (--dqm->processes_count == 0)
> + dqm->dev->kfd2kgd->set_compute_idle(
> + dqm->dev->kgd, true);
> goto out;
> }
> }
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] drm/amdkfd: Call kfd2kgd.set_compute_idle
[not found] ` <CADnq5_OPpyw06o-3qqOGmVVgY54wgxwqEhMWrSNHcVk8=c5znw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2018-07-28 9:23 ` Oded Gabbay
0 siblings, 0 replies; 4+ messages in thread
From: Oded Gabbay @ 2018-07-28 9:23 UTC (permalink / raw)
To: Alex Deucher; +Cc: Kuehling, Felix, amd-gfx list
Hi Felix,
Both patches applied to -next.
Oded
On Tue, Jul 17, 2018 at 7:14 PM Alex Deucher <alexdeucher@gmail.com> wrote:
>
> On Mon, Jul 16, 2018 at 7:10 PM, Felix Kuehling <Felix.Kuehling@amd.com> wrote:
> > User mode queue submissions don't go through KFD. Therefore we don't
> > know exactly when compute is idle or not idle. We use the existence
> > of user mode queues on a device as an approximation.
> >
> > register_process is called when the first queue of a process is
> > created. Conversely unregister_process is called when the last queue
> > is destroyed. The first process that is registered takes compute
> > out of idle. The last process that is unregisters sets compute back
> > to idle.
> >
> > Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
> > Reviewed-by: Eric Huang <JinHuiEric.Huang@amd.com>
>
> Series is:
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>
> > ---
> > drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> > index ace94d6..ec0d62a 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> > @@ -782,7 +782,8 @@ static int register_process(struct device_queue_manager *dqm,
> >
> > retval = dqm->asic_ops.update_qpd(dqm, qpd);
> >
> > - dqm->processes_count++;
> > + if (dqm->processes_count++ == 0)
> > + dqm->dev->kfd2kgd->set_compute_idle(dqm->dev->kgd, false);
> >
> > dqm_unlock(dqm);
> >
> > @@ -805,7 +806,9 @@ static int unregister_process(struct device_queue_manager *dqm,
> > if (qpd == cur->qpd) {
> > list_del(&cur->list);
> > kfree(cur);
> > - dqm->processes_count--;
> > + if (--dqm->processes_count == 0)
> > + dqm->dev->kfd2kgd->set_compute_idle(
> > + dqm->dev->kgd, true);
> > goto out;
> > }
> > }
> > --
> > 2.7.4
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-28 9:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-16 23:10 [PATCH 1/2] drm/amdgpu: Add kfd2kgd.set_compute_idle interface Felix Kuehling
[not found] ` <1531782637-7458-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2018-07-16 23:10 ` [PATCH 2/2] drm/amdkfd: Call kfd2kgd.set_compute_idle Felix Kuehling
[not found] ` <1531782637-7458-2-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2018-07-17 16:14 ` Alex Deucher
[not found] ` <CADnq5_OPpyw06o-3qqOGmVVgY54wgxwqEhMWrSNHcVk8=c5znw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-07-28 9:23 ` Oded Gabbay
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).