* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-14 8:19 [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too Lang Yu
@ 2022-04-14 13:44 ` Eric Huang
2022-04-15 2:38 ` Lang Yu
2022-04-14 15:15 ` Felix Kuehling
2022-04-14 17:46 ` Paul Menzel
2 siblings, 1 reply; 10+ messages in thread
From: Eric Huang @ 2022-04-14 13:44 UTC (permalink / raw)
To: Lang Yu, amd-gfx; +Cc: Alex Deucher, Felix Kuehling, Huang Rui
On 2022-04-14 04:19, Lang Yu wrote:
> The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> on some ASICs when running SVM applications.
>
> Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> 3 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 91f82a9ccdaf..459f59e3d0ed 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> return ret;
> }
>
> -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> -{
> - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> - dev->adev->sdma.instance[0].fw_version >= 18) ||
> - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> -}
> -
> static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> struct kfd_process *p, void *data)
> {
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 8a43def1f638..aff6f598ff2c 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
>
> void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
>
> +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> +{
> + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> + dev->adev->sdma.instance[0].fw_version >= 18) ||
> + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> +}
> +
It is a cosmetic change for function kfd_flush_tlb_after_unmap, and not
related to the topic. You can separate that into another patch.
Regards,
Eric
> bool kfd_is_locked(void);
>
> /* Compute profile */
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 459fa07a3bcc..5afe216cf099 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> if (r)
> break;
> }
> - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> +
> + if (kfd_flush_tlb_after_unmap(pdd->dev))
> + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> }
>
> return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-14 13:44 ` Eric Huang
@ 2022-04-15 2:38 ` Lang Yu
0 siblings, 0 replies; 10+ messages in thread
From: Lang Yu @ 2022-04-15 2:38 UTC (permalink / raw)
To: Eric Huang; +Cc: Alex Deucher, Felix Kuehling, Huang Rui, amd-gfx
On 04/14/ , Eric Huang wrote:
>
>
> On 2022-04-14 04:19, Lang Yu wrote:
> > The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> > TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> > heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> > on some ASICs when running SVM applications.
> >
> > Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> > drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> > drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> > 3 files changed, 11 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > index 91f82a9ccdaf..459f59e3d0ed 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> > return ret;
> > }
> > -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > -{
> > - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > - dev->adev->sdma.instance[0].fw_version >= 18) ||
> > - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > -}
> > -
> > static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> > struct kfd_process *p, void *data)
> > {
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > index 8a43def1f638..aff6f598ff2c 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
> > void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
> > +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > +{
> > + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > + dev->adev->sdma.instance[0].fw_version >= 18) ||
> > + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > +}
> > +
> It is a cosmetic change for function kfd_flush_tlb_after_unmap, and not
> related to the topic. You can separate that into another patch.
Okay. Thanks.
Regards,
Lang
> Regards,
> Eric
> > bool kfd_is_locked(void);
> > /* Compute profile */
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > index 459fa07a3bcc..5afe216cf099 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> > if (r)
> > break;
> > }
> > - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > +
> > + if (kfd_flush_tlb_after_unmap(pdd->dev))
> > + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > }
> > return r;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-14 8:19 [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too Lang Yu
2022-04-14 13:44 ` Eric Huang
@ 2022-04-14 15:15 ` Felix Kuehling
2022-04-15 2:47 ` Lang Yu
2022-04-14 17:46 ` Paul Menzel
2 siblings, 1 reply; 10+ messages in thread
From: Felix Kuehling @ 2022-04-14 15:15 UTC (permalink / raw)
To: Lang Yu, amd-gfx; +Cc: Eric Huang, Alex Deucher, Huang Rui
Am 2022-04-14 um 04:19 schrieb Lang Yu:
> The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> on some ASICs when running SVM applications.
>
> Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> 3 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 91f82a9ccdaf..459f59e3d0ed 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> return ret;
> }
>
> -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> -{
> - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> - dev->adev->sdma.instance[0].fw_version >= 18) ||
> - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> -}
> -
> static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> struct kfd_process *p, void *data)
> {
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 8a43def1f638..aff6f598ff2c 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
>
> void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
>
> +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> +{
> + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> + dev->adev->sdma.instance[0].fw_version >= 18) ||
> + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> +}
> +
> bool kfd_is_locked(void);
>
> /* Compute profile */
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 459fa07a3bcc..5afe216cf099 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> if (r)
> break;
> }
> - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> +
> + if (kfd_flush_tlb_after_unmap(pdd->dev))
> + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
Then you probably need to add another flush_tlb call in
svm_range_map_to_gpus.
Regards,
Felix
> }
>
> return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-14 15:15 ` Felix Kuehling
@ 2022-04-15 2:47 ` Lang Yu
2022-04-15 5:07 ` Felix Kuehling
0 siblings, 1 reply; 10+ messages in thread
From: Lang Yu @ 2022-04-15 2:47 UTC (permalink / raw)
To: Felix Kuehling; +Cc: Eric Huang, Alex Deucher, Huang Rui, amd-gfx
On 04/14/ , Felix Kuehling wrote:
>
> Am 2022-04-14 um 04:19 schrieb Lang Yu:
> > The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> > TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> > heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> > on some ASICs when running SVM applications.
> >
> > Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> > drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> > drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> > 3 files changed, 11 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > index 91f82a9ccdaf..459f59e3d0ed 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> > return ret;
> > }
> > -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > -{
> > - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > - dev->adev->sdma.instance[0].fw_version >= 18) ||
> > - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > -}
> > -
> > static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> > struct kfd_process *p, void *data)
> > {
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > index 8a43def1f638..aff6f598ff2c 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
> > void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
> > +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > +{
> > + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > + dev->adev->sdma.instance[0].fw_version >= 18) ||
> > + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > +}
> > +
> > bool kfd_is_locked(void);
> > /* Compute profile */
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > index 459fa07a3bcc..5afe216cf099 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> > if (r)
> > break;
> > }
> > - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > +
> > + if (kfd_flush_tlb_after_unmap(pdd->dev))
> > + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
>
> Then you probably need to add another flush_tlb call in
> svm_range_map_to_gpus.
There is a TLB_FLUSH_LEGACY call in svm_range_map_to_gpus same with
kfd_ioctl_map_memory_to_gpu. Do we still need to add another one?
Regards,
Lang
> Regards,
> Felix
>
>
> > }
> > return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-15 2:47 ` Lang Yu
@ 2022-04-15 5:07 ` Felix Kuehling
0 siblings, 0 replies; 10+ messages in thread
From: Felix Kuehling @ 2022-04-15 5:07 UTC (permalink / raw)
To: Lang Yu; +Cc: Eric Huang, Alex Deucher, Huang Rui, amd-gfx
Am 2022-04-14 um 22:47 schrieb Lang Yu:
> On 04/14/ , Felix Kuehling wrote:
>> Am 2022-04-14 um 04:19 schrieb Lang Yu:
>>> The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
>>> TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
>>> heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
>>> on some ASICs when running SVM applications.
>>>
>>> Signed-off-by: Lang Yu <Lang.Yu@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
>>> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
>>> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
>>> 3 files changed, 11 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> index 91f82a9ccdaf..459f59e3d0ed 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
>>> return ret;
>>> }
>>> -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
>>> -{
>>> - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
>>> - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
>>> - dev->adev->sdma.instance[0].fw_version >= 18) ||
>>> - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
>>> -}
>>> -
>>> static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
>>> struct kfd_process *p, void *data)
>>> {
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> index 8a43def1f638..aff6f598ff2c 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
>>> void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
>>> +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
>>> +{
>>> + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
>>> + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
>>> + dev->adev->sdma.instance[0].fw_version >= 18) ||
>>> + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
>>> +}
>>> +
>>> bool kfd_is_locked(void);
>>> /* Compute profile */
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> index 459fa07a3bcc..5afe216cf099 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
>>> if (r)
>>> break;
>>> }
>>> - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
>>> +
>>> + if (kfd_flush_tlb_after_unmap(pdd->dev))
>>> + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
>> Then you probably need to add another flush_tlb call in
>> svm_range_map_to_gpus.
> There is a TLB_FLUSH_LEGACY call in svm_range_map_to_gpus same with
> kfd_ioctl_map_memory_to_gpu. Do we still need to add another one?
Right, I missed that one. I think that should cover it and the patch
looks good to me.
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
>
> Regards,
> Lang
>
>> Regards,
>> Felix
>>
>>
>>> }
>>> return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-14 8:19 [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too Lang Yu
2022-04-14 13:44 ` Eric Huang
2022-04-14 15:15 ` Felix Kuehling
@ 2022-04-14 17:46 ` Paul Menzel
2022-04-15 3:20 ` Lang Yu
2 siblings, 1 reply; 10+ messages in thread
From: Paul Menzel @ 2022-04-14 17:46 UTC (permalink / raw)
To: Lang Yu; +Cc: Eric Huang, Alex Deucher, Felix Kühling, Huang Rui, amd-gfx
Dear Lang,
Thank you for the patch.
Am 14.04.22 um 10:19 schrieb Lang Yu:
> The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> on some ASICs when running SVM applications.
Please list the ASICs, you know of having problems, and even add how to
reproduce this.
Kind regards,
Paul
> Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> 3 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 91f82a9ccdaf..459f59e3d0ed 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> return ret;
> }
>
> -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> -{
> - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> - dev->adev->sdma.instance[0].fw_version >= 18) ||
> - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> -}
> -
> static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> struct kfd_process *p, void *data)
> {
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 8a43def1f638..aff6f598ff2c 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
>
> void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
>
> +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> +{
> + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> + dev->adev->sdma.instance[0].fw_version >= 18) ||
> + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> +}
> +
> bool kfd_is_locked(void);
>
> /* Compute profile */
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 459fa07a3bcc..5afe216cf099 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> if (r)
> break;
> }
> - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> +
> + if (kfd_flush_tlb_after_unmap(pdd->dev))
> + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> }
>
> return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-14 17:46 ` Paul Menzel
@ 2022-04-15 3:20 ` Lang Yu
2022-04-15 5:14 ` Paul Menzel
0 siblings, 1 reply; 10+ messages in thread
From: Lang Yu @ 2022-04-15 3:20 UTC (permalink / raw)
To: Paul Menzel
Cc: Eric Huang, Alex Deucher, Felix Kühling, Huang Rui, amd-gfx
On 04/14/ , Paul Menzel wrote:
> Dear Lang,
>
>
> Thank you for the patch.
>
> Am 14.04.22 um 10:19 schrieb Lang Yu:
> > The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> > TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> > heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> > on some ASICs when running SVM applications.
>
> Please list the ASICs, you know of having problems, and even add how to
> reproduce this.
Actually, this is ported from previous commits. You can find more details
from the commits I mentioned. At the moment the ASICs except Aldebaran
and Arcturus probably have the problem. And running a SVM application
could reproduce the issue.
Thanks,
Lang
>
> Kind regards,
>
> Paul
>
>
> > Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> > drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> > drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> > 3 files changed, 11 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > index 91f82a9ccdaf..459f59e3d0ed 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> > return ret;
> > }
> > -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > -{
> > - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > - dev->adev->sdma.instance[0].fw_version >= 18) ||
> > - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > -}
> > -
> > static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> > struct kfd_process *p, void *data)
> > {
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > index 8a43def1f638..aff6f598ff2c 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
> > void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
> > +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > +{
> > + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > + dev->adev->sdma.instance[0].fw_version >= 18) ||
> > + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > +}
> > +
> > bool kfd_is_locked(void);
> > /* Compute profile */
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > index 459fa07a3bcc..5afe216cf099 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> > if (r)
> > break;
> > }
> > - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > +
> > + if (kfd_flush_tlb_after_unmap(pdd->dev))
> > + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > }
> > return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-15 3:20 ` Lang Yu
@ 2022-04-15 5:14 ` Paul Menzel
2022-04-15 6:37 ` Lang Yu
0 siblings, 1 reply; 10+ messages in thread
From: Paul Menzel @ 2022-04-15 5:14 UTC (permalink / raw)
To: Lang Yu; +Cc: Eric Huang, Alex Deucher, Felix Kühling, Huang Rui, amd-gfx
Dear Lang,
Am 15.04.22 um 05:20 schrieb Lang Yu:
> On 04/14/ , Paul Menzel wrote:
>> Am 14.04.22 um 10:19 schrieb Lang Yu:
>>> The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
>>> TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
>>> heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
>>> on some ASICs when running SVM applications.
>>
>> Please list the ASICs, you know of having problems, and even add how to
>> reproduce this.
>
> Actually, this is ported from previous commits. You can find more details
> from the commits I mentioned. At the moment the ASICs except Aldebaran
> and Arcturus probably have the problem.
I think, it’s always good to make it as easy as possible for reviewers
and, later, people reading a commit, and include the necessary
information directly in the commit message. It’d be great if you amended
the commit message.
> And running a SVM application could reproduce the issue.
Thanks. How will it fail though?
(Also, a small implementation note would be nice to have. Maybe: Move
the helper function into the header `kfd_priv.h`, and use in
`svm_range_unmap_from_gpus()`.)
Kind regards,
Paul
>>> Signed-off-by: Lang Yu <Lang.Yu@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
>>> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
>>> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
>>> 3 files changed, 11 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> index 91f82a9ccdaf..459f59e3d0ed 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>>> @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
>>> return ret;
>>> }
>>> -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
>>> -{
>>> - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
>>> - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
>>> - dev->adev->sdma.instance[0].fw_version >= 18) ||
>>> - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
>>> -}
>>> -
>>> static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
>>> struct kfd_process *p, void *data)
>>> {
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> index 8a43def1f638..aff6f598ff2c 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
>>> @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
>>> void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
>>> +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
>>> +{
>>> + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
>>> + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
>>> + dev->adev->sdma.instance[0].fw_version >= 18) ||
>>> + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
>>> +}
>>> +
>>> bool kfd_is_locked(void);
>>> /* Compute profile */
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> index 459fa07a3bcc..5afe216cf099 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>>> @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
>>> if (r)
>>> break;
>>> }
>>> - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
>>> +
>>> + if (kfd_flush_tlb_after_unmap(pdd->dev))
>>> + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
>>> }
>>> return r;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: only allow heavy-weight TLB flush on some ASICs for SVM too
2022-04-15 5:14 ` Paul Menzel
@ 2022-04-15 6:37 ` Lang Yu
0 siblings, 0 replies; 10+ messages in thread
From: Lang Yu @ 2022-04-15 6:37 UTC (permalink / raw)
To: Paul Menzel
Cc: Eric Huang, Alex Deucher, Felix Kühling, Huang Rui, amd-gfx
On 04/15/ , Paul Menzel wrote:
> Dear Lang,
>
>
> Am 15.04.22 um 05:20 schrieb Lang Yu:
> > On 04/14/ , Paul Menzel wrote:
>
> > > Am 14.04.22 um 10:19 schrieb Lang Yu:
> > > > The idea is from commit a50fe7078035 ("drm/amdkfd: Only apply heavy-weight
> > > > TLB flush on Aldebaran") and commit f61c40c0757a ("drm/amdkfd: enable
> > > > heavy-weight TLB flush on Arcturus"). Otherwise, we will run into problems
> > > > on some ASICs when running SVM applications.
> > >
> > > Please list the ASICs, you know of having problems, and even add how to
> > > reproduce this.
> >
> > Actually, this is ported from previous commits. You can find more details
> > from the commits I mentioned. At the moment the ASICs except Aldebaran
> > and Arcturus probably have the problem.
>
> I think, it’s always good to make it as easy as possible for reviewers and,
> later, people reading a commit, and include the necessary information
> directly in the commit message. It’d be great if you amended the commit
> message.
Yes, I agree with you. Will amended the commit message.
> > And running a SVM application could reproduce the issue.
>
> Thanks. How will it fail though?
Will describe more details in commit message.
> (Also, a small implementation note would be nice to have. Maybe: Move the
> helper function into the header `kfd_priv.h`, and use in
> `svm_range_unmap_from_gpus()`.)
Will separate this change into another patch suggested by Eric.
Thanks,
Lang
> Kind regards,
>
> Paul
>
>
> > > > Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> > > > ---
> > > > drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 --------
> > > > drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 ++++++++
> > > > drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
> > > > 3 files changed, 11 insertions(+), 9 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > > > index 91f82a9ccdaf..459f59e3d0ed 100644
> > > > --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > > > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> > > > @@ -1128,14 +1128,6 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
> > > > return ret;
> > > > }
> > > > -static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > > > -{
> > > > - return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > > > - (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > > > - dev->adev->sdma.instance[0].fw_version >= 18) ||
> > > > - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > > > -}
> > > > -
> > > > static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
> > > > struct kfd_process *p, void *data)
> > > > {
> > > > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > > > index 8a43def1f638..aff6f598ff2c 100644
> > > > --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > > > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> > > > @@ -1328,6 +1328,14 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);
> > > > void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);
> > > > +static inline bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev)
> > > > +{
> > > > + return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
> > > > + (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> > > > + dev->adev->sdma.instance[0].fw_version >= 18) ||
> > > > + KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0);
> > > > +}
> > > > +
> > > > bool kfd_is_locked(void);
> > > > /* Compute profile */
> > > > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > > > index 459fa07a3bcc..5afe216cf099 100644
> > > > --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > > > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> > > > @@ -1229,7 +1229,9 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
> > > > if (r)
> > > > break;
> > > > }
> > > > - kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > > > +
> > > > + if (kfd_flush_tlb_after_unmap(pdd->dev))
> > > > + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT);
> > > > }
> > > > return r;
^ permalink raw reply [flat|nested] 10+ messages in thread