All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
@ 2017-10-30  7:57 Pixel Ding
       [not found] ` <1509350225-5712-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Pixel Ding @ 2017-10-30  7:57 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: pding

From: pding <Pixel.Ding@amd.com>

Move kfd probe prior to device init. Release exclusive mode
after hw_init if kfd is not enabled.

Signed-off-by: pding <Pixel.Ding@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 400dfaa..e46ec51 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
 		adev->ip_blocks[i].status.hw = true;
 	}
 
+	if (amdgpu_sriov_vf(adev) && !adev->kfd)
+		amdgpu_virt_release_full_gpu(adev, true);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 3e9760d..e91907c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 	    !pci_is_thunderbolt_attached(dev->pdev))
 		flags |= AMD_IS_PX;
 
+	amdgpu_amdkfd_device_probe(adev);
+
 	/* amdgpu_device_init should report only fatal error
 	 * like memory allocation failure or iomapping failure,
 	 * or memory manager initialization failure, it must
@@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 				"Error during ACPI methods call\n");
 	}
 
-	amdgpu_amdkfd_device_probe(adev);
 	amdgpu_amdkfd_device_init(adev);
 
 	if (amdgpu_device_is_px(dev)) {
@@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 		pm_runtime_put_autosuspend(dev->dev);
 	}
 
-	if (amdgpu_sriov_vf(adev))
+	if (amdgpu_sriov_vf(adev) && adev->kfd)
 		amdgpu_virt_release_full_gpu(adev, true);
 
 out:
-- 
2.9.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found] ` <1509350225-5712-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
@ 2017-10-30  8:20   ` Oded Gabbay
       [not found]     ` <CAFCwf10VMsvGuQV5AtfeiOdi0jB2Je8=aGfZWLLGG00Z=N5t-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2017-10-31 15:06   ` Tom Stellard
  1 sibling, 1 reply; 9+ messages in thread
From: Oded Gabbay @ 2017-10-30  8:20 UTC (permalink / raw)
  To: Pixel Ding; +Cc: amd-gfx list

On Mon, Oct 30, 2017 at 9:57 AM, Pixel Ding <Pixel.Ding@amd.com> wrote:
> From: pding <Pixel.Ding@amd.com>
>
> Move kfd probe prior to device init. Release exclusive mode
> after hw_init if kfd is not enabled.
>
> Signed-off-by: pding <Pixel.Ding@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 400dfaa..e46ec51 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>                 adev->ip_blocks[i].status.hw = true;
>         }
>
> +       if (amdgpu_sriov_vf(adev) && !adev->kfd)
> +               amdgpu_virt_release_full_gpu(adev, true);
> +
>         return 0;
>  }
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 3e9760d..e91907c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>             !pci_is_thunderbolt_attached(dev->pdev))
>                 flags |= AMD_IS_PX;
>
> +       amdgpu_amdkfd_device_probe(adev);
> +
>         /* amdgpu_device_init should report only fatal error
>          * like memory allocation failure or iomapping failure,
>          * or memory manager initialization failure, it must
> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>                                 "Error during ACPI methods call\n");
>         }
>
> -       amdgpu_amdkfd_device_probe(adev);
>         amdgpu_amdkfd_device_init(adev);
>
>         if (amdgpu_device_is_px(dev)) {
> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>                 pm_runtime_put_autosuspend(dev->dev);
>         }
>
> -       if (amdgpu_sriov_vf(adev))
> +       if (amdgpu_sriov_vf(adev) && adev->kfd)
>                 amdgpu_virt_release_full_gpu(adev, true);
>
>  out:
> --
> 2.9.5
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

The amdkfd probe function uses the pdev field inside adev. That field
is initialized in device init, so you can't call amdkfd probe before
that function.
Oded
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found]     ` <CAFCwf10VMsvGuQV5AtfeiOdi0jB2Je8=aGfZWLLGG00Z=N5t-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-10-30  8:30       ` Ding, Pixel
       [not found]         ` <CC871653-9D31-4D2D-BBAA-3F828CC2B227-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Ding, Pixel @ 2017-10-30  8:30 UTC (permalink / raw)
  To: Oded Gabbay; +Cc: amd-gfx list

Get your point. I don’t know why the test is passed however will revise later.

I definitely want the know if KFD is enabled before device init. Any suggestion? Or do you mind if the pdev is passed to probe in other way?

— 
Sincerely Yours,
Pixel








On 30/10/2017, 4:20 PM, "Oded Gabbay" <oded.gabbay@gmail.com> wrote:

>On Mon, Oct 30, 2017 at 9:57 AM, Pixel Ding <Pixel.Ding@amd.com> wrote:
>> From: pding <Pixel.Ding@amd.com>
>>
>> Move kfd probe prior to device init. Release exclusive mode
>> after hw_init if kfd is not enabled.
>>
>> Signed-off-by: pding <Pixel.Ding@amd.com>
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index 400dfaa..e46ec51 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>>                 adev->ip_blocks[i].status.hw = true;
>>         }
>>
>> +       if (amdgpu_sriov_vf(adev) && !adev->kfd)
>> +               amdgpu_virt_release_full_gpu(adev, true);
>> +
>>         return 0;
>>  }
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> index 3e9760d..e91907c 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>             !pci_is_thunderbolt_attached(dev->pdev))
>>                 flags |= AMD_IS_PX;
>>
>> +       amdgpu_amdkfd_device_probe(adev);
>> +
>>         /* amdgpu_device_init should report only fatal error
>>          * like memory allocation failure or iomapping failure,
>>          * or memory manager initialization failure, it must
>> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>                                 "Error during ACPI methods call\n");
>>         }
>>
>> -       amdgpu_amdkfd_device_probe(adev);
>>         amdgpu_amdkfd_device_init(adev);
>>
>>         if (amdgpu_device_is_px(dev)) {
>> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>                 pm_runtime_put_autosuspend(dev->dev);
>>         }
>>
>> -       if (amdgpu_sriov_vf(adev))
>> +       if (amdgpu_sriov_vf(adev) && adev->kfd)
>>                 amdgpu_virt_release_full_gpu(adev, true);
>>
>>  out:
>> --
>> 2.9.5
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>
>The amdkfd probe function uses the pdev field inside adev. That field
>is initialized in device init, so you can't call amdkfd probe before
>that function.
>Oded
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found]         ` <CC871653-9D31-4D2D-BBAA-3F828CC2B227-5C7GfCeVMHo@public.gmane.org>
@ 2017-10-30  8:52           ` Oded Gabbay
       [not found]             ` <CAFCwf13p+-Yoh1xwKOQdbDZT+eKTK6ugf39WMXxjeRrPEgMkuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Oded Gabbay @ 2017-10-30  8:52 UTC (permalink / raw)
  To: Ding, Pixel; +Cc: amd-gfx list

Except from pdev, kfd doesn't access any other fields in adev, so
passing pdev as a different parameter seems fine.
The problem with that approach is we need to remember for the future
not to access other adev fields, and that seems risky and not correct




On Mon, Oct 30, 2017 at 10:30 AM, Ding, Pixel <Pixel.Ding@amd.com> wrote:
> Get your point. I don’t know why the test is passed however will revise later.
>
> I definitely want the know if KFD is enabled before device init. Any suggestion? Or do you mind if the pdev is passed to probe in other way?
>
> —
> Sincerely Yours,
> Pixel
>
>
>
>
>
>
>
>
> On 30/10/2017, 4:20 PM, "Oded Gabbay" <oded.gabbay@gmail.com> wrote:
>
>>On Mon, Oct 30, 2017 at 9:57 AM, Pixel Ding <Pixel.Ding@amd.com> wrote:
>>> From: pding <Pixel.Ding@amd.com>
>>>
>>> Move kfd probe prior to device init. Release exclusive mode
>>> after hw_init if kfd is not enabled.
>>>
>>> Signed-off-by: pding <Pixel.Ding@amd.com>
>>> ---
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> index 400dfaa..e46ec51 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>>>                 adev->ip_blocks[i].status.hw = true;
>>>         }
>>>
>>> +       if (amdgpu_sriov_vf(adev) && !adev->kfd)
>>> +               amdgpu_virt_release_full_gpu(adev, true);
>>> +
>>>         return 0;
>>>  }
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>> index 3e9760d..e91907c 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>             !pci_is_thunderbolt_attached(dev->pdev))
>>>                 flags |= AMD_IS_PX;
>>>
>>> +       amdgpu_amdkfd_device_probe(adev);
>>> +
>>>         /* amdgpu_device_init should report only fatal error
>>>          * like memory allocation failure or iomapping failure,
>>>          * or memory manager initialization failure, it must
>>> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>                                 "Error during ACPI methods call\n");
>>>         }
>>>
>>> -       amdgpu_amdkfd_device_probe(adev);
>>>         amdgpu_amdkfd_device_init(adev);
>>>
>>>         if (amdgpu_device_is_px(dev)) {
>>> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>                 pm_runtime_put_autosuspend(dev->dev);
>>>         }
>>>
>>> -       if (amdgpu_sriov_vf(adev))
>>> +       if (amdgpu_sriov_vf(adev) && adev->kfd)
>>>                 amdgpu_virt_release_full_gpu(adev, true);
>>>
>>>  out:
>>> --
>>> 2.9.5
>>>
>>> _______________________________________________
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>>
>>The amdkfd probe function uses the pdev field inside adev. That field
>>is initialized in device init, so you can't call amdkfd probe before
>>that function.
>>Oded
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found]             ` <CAFCwf13p+-Yoh1xwKOQdbDZT+eKTK6ugf39WMXxjeRrPEgMkuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-10-30  9:13               ` Ding, Pixel
       [not found]                 ` <72AC2064-6BD5-4FF5-B0BB-0AF06AA58295-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Ding, Pixel @ 2017-10-30  9:13 UTC (permalink / raw)
  To: Oded Gabbay; +Cc: amd-gfx list

Another option is adding a function with the same logics as top half probe to determine if KFD is enabled or not, like amdgpu_amdkfd_enabled().

I think it’s okay to pass pdev separately. The KFD probe implementation also has pdev parameter, it doesn’t retrieve that from adev, while the middle layer does this.

Which one do you prefer?

— 
Sincerely Yours,
Pixel







On 30/10/2017, 4:52 PM, "Oded Gabbay" <oded.gabbay@gmail.com> wrote:

>Except from pdev, kfd doesn't access any other fields in adev, so
>passing pdev as a different parameter seems fine.
>The problem with that approach is we need to remember for the future
>not to access other adev fields, and that seems risky and not correct
>
>
>
>
>On Mon, Oct 30, 2017 at 10:30 AM, Ding, Pixel <Pixel.Ding@amd.com> wrote:
>> Get your point. I don’t know why the test is passed however will revise later.
>>
>> I definitely want the know if KFD is enabled before device init. Any suggestion? Or do you mind if the pdev is passed to probe in other way?
>>
>> —
>> Sincerely Yours,
>> Pixel
>>
>>
>>
>>
>>
>>
>>
>>
>> On 30/10/2017, 4:20 PM, "Oded Gabbay" <oded.gabbay@gmail.com> wrote:
>>
>>>On Mon, Oct 30, 2017 at 9:57 AM, Pixel Ding <Pixel.Ding@amd.com> wrote:
>>>> From: pding <Pixel.Ding@amd.com>
>>>>
>>>> Move kfd probe prior to device init. Release exclusive mode
>>>> after hw_init if kfd is not enabled.
>>>>
>>>> Signed-off-by: pding <Pixel.Ding@amd.com>
>>>> ---
>>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>>>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>> index 400dfaa..e46ec51 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>>>>                 adev->ip_blocks[i].status.hw = true;
>>>>         }
>>>>
>>>> +       if (amdgpu_sriov_vf(adev) && !adev->kfd)
>>>> +               amdgpu_virt_release_full_gpu(adev, true);
>>>> +
>>>>         return 0;
>>>>  }
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>>> index 3e9760d..e91907c 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>>> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>>             !pci_is_thunderbolt_attached(dev->pdev))
>>>>                 flags |= AMD_IS_PX;
>>>>
>>>> +       amdgpu_amdkfd_device_probe(adev);
>>>> +
>>>>         /* amdgpu_device_init should report only fatal error
>>>>          * like memory allocation failure or iomapping failure,
>>>>          * or memory manager initialization failure, it must
>>>> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>>                                 "Error during ACPI methods call\n");
>>>>         }
>>>>
>>>> -       amdgpu_amdkfd_device_probe(adev);
>>>>         amdgpu_amdkfd_device_init(adev);
>>>>
>>>>         if (amdgpu_device_is_px(dev)) {
>>>> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>>                 pm_runtime_put_autosuspend(dev->dev);
>>>>         }
>>>>
>>>> -       if (amdgpu_sriov_vf(adev))
>>>> +       if (amdgpu_sriov_vf(adev) && adev->kfd)
>>>>                 amdgpu_virt_release_full_gpu(adev, true);
>>>>
>>>>  out:
>>>> --
>>>> 2.9.5
>>>>
>>>> _______________________________________________
>>>> amd-gfx mailing list
>>>> amd-gfx@lists.freedesktop.org
>>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>>>
>>>The amdkfd probe function uses the pdev field inside adev. That field
>>>is initialized in device init, so you can't call amdkfd probe before
>>>that function.
>>>Oded
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found]                 ` <72AC2064-6BD5-4FF5-B0BB-0AF06AA58295-5C7GfCeVMHo@public.gmane.org>
@ 2017-10-31 10:25                   ` Oded Gabbay
  0 siblings, 0 replies; 9+ messages in thread
From: Oded Gabbay @ 2017-10-31 10:25 UTC (permalink / raw)
  To: Ding, Pixel; +Cc: amd-gfx list

I would pass only pdev to kgd2kfd_probe, instead of adev.
Then, I would initialize adev inside kgd2kfd_device_init
That way, you can call kgd2kfd_probe before device_init of amdgpu and
you can know if amdkfd is supposed to handle this device.
Does that make sense ?

On Mon, Oct 30, 2017 at 11:13 AM, Ding, Pixel <Pixel.Ding@amd.com> wrote:
> Another option is adding a function with the same logics as top half probe to determine if KFD is enabled or not, like amdgpu_amdkfd_enabled().
>
> I think it’s okay to pass pdev separately. The KFD probe implementation also has pdev parameter, it doesn’t retrieve that from adev, while the middle layer does this.
>
> Which one do you prefer?
>
> —
> Sincerely Yours,
> Pixel
>
>
>
>
>
>
>
> On 30/10/2017, 4:52 PM, "Oded Gabbay" <oded.gabbay@gmail.com> wrote:
>
>>Except from pdev, kfd doesn't access any other fields in adev, so
>>passing pdev as a different parameter seems fine.
>>The problem with that approach is we need to remember for the future
>>not to access other adev fields, and that seems risky and not correct
>>
>>
>>
>>
>>On Mon, Oct 30, 2017 at 10:30 AM, Ding, Pixel <Pixel.Ding@amd.com> wrote:
>>> Get your point. I don’t know why the test is passed however will revise later.
>>>
>>> I definitely want the know if KFD is enabled before device init. Any suggestion? Or do you mind if the pdev is passed to probe in other way?
>>>
>>> —
>>> Sincerely Yours,
>>> Pixel
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 30/10/2017, 4:20 PM, "Oded Gabbay" <oded.gabbay@gmail.com> wrote:
>>>
>>>>On Mon, Oct 30, 2017 at 9:57 AM, Pixel Ding <Pixel.Ding@amd.com> wrote:
>>>>> From: pding <Pixel.Ding@amd.com>
>>>>>
>>>>> Move kfd probe prior to device init. Release exclusive mode
>>>>> after hw_init if kfd is not enabled.
>>>>>
>>>>> Signed-off-by: pding <Pixel.Ding@amd.com>
>>>>> ---
>>>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>>>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>>>>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>>> index 400dfaa..e46ec51 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>>> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>>>>>                 adev->ip_blocks[i].status.hw = true;
>>>>>         }
>>>>>
>>>>> +       if (amdgpu_sriov_vf(adev) && !adev->kfd)
>>>>> +               amdgpu_virt_release_full_gpu(adev, true);
>>>>> +
>>>>>         return 0;
>>>>>  }
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>>>> index 3e9760d..e91907c 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>>>>> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>>>             !pci_is_thunderbolt_attached(dev->pdev))
>>>>>                 flags |= AMD_IS_PX;
>>>>>
>>>>> +       amdgpu_amdkfd_device_probe(adev);
>>>>> +
>>>>>         /* amdgpu_device_init should report only fatal error
>>>>>          * like memory allocation failure or iomapping failure,
>>>>>          * or memory manager initialization failure, it must
>>>>> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>>>                                 "Error during ACPI methods call\n");
>>>>>         }
>>>>>
>>>>> -       amdgpu_amdkfd_device_probe(adev);
>>>>>         amdgpu_amdkfd_device_init(adev);
>>>>>
>>>>>         if (amdgpu_device_is_px(dev)) {
>>>>> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>>>>                 pm_runtime_put_autosuspend(dev->dev);
>>>>>         }
>>>>>
>>>>> -       if (amdgpu_sriov_vf(adev))
>>>>> +       if (amdgpu_sriov_vf(adev) && adev->kfd)
>>>>>                 amdgpu_virt_release_full_gpu(adev, true);
>>>>>
>>>>>  out:
>>>>> --
>>>>> 2.9.5
>>>>>
>>>>> _______________________________________________
>>>>> amd-gfx mailing list
>>>>> amd-gfx@lists.freedesktop.org
>>>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>>>>
>>>>The amdkfd probe function uses the pdev field inside adev. That field
>>>>is initialized in device init, so you can't call amdkfd probe before
>>>>that function.
>>>>Oded
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found] ` <1509350225-5712-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
  2017-10-30  8:20   ` Oded Gabbay
@ 2017-10-31 15:06   ` Tom Stellard
       [not found]     ` <ddf9c014-565b-8cc5-42d7-69d896c57c46-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  1 sibling, 1 reply; 9+ messages in thread
From: Tom Stellard @ 2017-10-31 15:06 UTC (permalink / raw)
  To: Pixel Ding, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 10/30/2017 12:57 AM, Pixel Ding wrote:
> From: pding <Pixel.Ding@amd.com>
> 
> Move kfd probe prior to device init. Release exclusive mode
> after hw_init if kfd is not enabled.
> 

What happens if only the amdgpu module is loaded at startup, and then the
user manually loads the amdkfd module at some point later on.  Will the driver
still behave correctly in this case with this patch?

-Tom


> Signed-off-by: pding <Pixel.Ding@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 400dfaa..e46ec51 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>  		adev->ip_blocks[i].status.hw = true;
>  	}
>  
> +	if (amdgpu_sriov_vf(adev) && !adev->kfd)
> +		amdgpu_virt_release_full_gpu(adev, true);
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 3e9760d..e91907c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>  	    !pci_is_thunderbolt_attached(dev->pdev))
>  		flags |= AMD_IS_PX;
>  
> +	amdgpu_amdkfd_device_probe(adev);
> +
>  	/* amdgpu_device_init should report only fatal error
>  	 * like memory allocation failure or iomapping failure,
>  	 * or memory manager initialization failure, it must
> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>  				"Error during ACPI methods call\n");
>  	}
>  
> -	amdgpu_amdkfd_device_probe(adev);
>  	amdgpu_amdkfd_device_init(adev);
>  
>  	if (amdgpu_device_is_px(dev)) {
> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>  		pm_runtime_put_autosuspend(dev->dev);
>  	}
>  
> -	if (amdgpu_sriov_vf(adev))
> +	if (amdgpu_sriov_vf(adev) && adev->kfd)
>  		amdgpu_virt_release_full_gpu(adev, true);
>  
>  out:
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found]     ` <ddf9c014-565b-8cc5-42d7-69d896c57c46-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2017-11-01  1:25       ` Ding, Pixel
       [not found]         ` <CCE67A7A-45E3-4B46-AD15-4B433B72939D-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Ding, Pixel @ 2017-11-01  1:25 UTC (permalink / raw)
  To: tstellar-H+wXaHxf7aLQT0dZR+AlfA,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

I’m not for sure about this case you talked about. Assume that it could happen and the KFD probe and init are invoked when loading it manually.

For baremetal device, it’s always correct.
For SRIOV virtual function, it doesn’t behave correctly with or without this patch. KFD initialization also needs to access VF in exclusive mode, while the exclusive mode request/release messages are sent in amdgpu_device_init.

—
Sincerely Yours,
Pixel







On 31/10/2017, 11:06 PM, "Tom Stellard" <tstellar@redhat.com> wrote:

>On 10/30/2017 12:57 AM, Pixel Ding wrote:
>> From: pding <Pixel.Ding@amd.com>
>> 
>> Move kfd probe prior to device init. Release exclusive mode
>> after hw_init if kfd is not enabled.
>> 
>
>What happens if only the amdgpu module is loaded at startup, and then the
>user manually loads the amdkfd module at some point later on.  Will the driver
>still behave correctly in this case with this patch?
>
>-Tom
>
>
>> Signed-off-by: pding <Pixel.Ding@amd.com>
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
>>  2 files changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index 400dfaa..e46ec51 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
>>  		adev->ip_blocks[i].status.hw = true;
>>  	}
>>  
>> +	if (amdgpu_sriov_vf(adev) && !adev->kfd)
>> +		amdgpu_virt_release_full_gpu(adev, true);
>> +
>>  	return 0;
>>  }
>>  
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> index 3e9760d..e91907c 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
>> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>  	    !pci_is_thunderbolt_attached(dev->pdev))
>>  		flags |= AMD_IS_PX;
>>  
>> +	amdgpu_amdkfd_device_probe(adev);
>> +
>>  	/* amdgpu_device_init should report only fatal error
>>  	 * like memory allocation failure or iomapping failure,
>>  	 * or memory manager initialization failure, it must
>> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>  				"Error during ACPI methods call\n");
>>  	}
>>  
>> -	amdgpu_amdkfd_device_probe(adev);
>>  	amdgpu_amdkfd_device_init(adev);
>>  
>>  	if (amdgpu_device_is_px(dev)) {
>> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
>>  		pm_runtime_put_autosuspend(dev->dev);
>>  	}
>>  
>> -	if (amdgpu_sriov_vf(adev))
>> +	if (amdgpu_sriov_vf(adev) && adev->kfd)
>>  		amdgpu_virt_release_full_gpu(adev, true);
>>  
>>  out:
>> 
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd
       [not found]         ` <CCE67A7A-45E3-4B46-AD15-4B433B72939D-5C7GfCeVMHo@public.gmane.org>
@ 2017-11-01  8:37           ` Oded Gabbay
  0 siblings, 0 replies; 9+ messages in thread
From: Oded Gabbay @ 2017-11-01  8:37 UTC (permalink / raw)
  To: Ding, Pixel
  Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	tstellar-H+wXaHxf7aLQT0dZR+AlfA

Tom,
AFAIK, you can't manually load the amdkfd driver. i.e. it simply won't
work, with or without this change.
It must be loaded in a certain order (in relation to amdgpu and
amd_iommu_v2) during Linux boot.
That issue is one that has been with us from the start and has
received justified criticism over the years.
Unfortunately, no one bothered to fix it yet.

Oded

On Wed, Nov 1, 2017 at 3:25 AM, Ding, Pixel <Pixel.Ding@amd.com> wrote:
>
> I’m not for sure about this case you talked about. Assume that it could happen and the KFD probe and init are invoked when loading it manually.
>
> For baremetal device, it’s always correct.
> For SRIOV virtual function, it doesn’t behave correctly with or without this patch. KFD initialization also needs to access VF in exclusive mode, while the exclusive mode request/release messages are sent in amdgpu_device_init.
>
> —
> Sincerely Yours,
> Pixel
>
>
>
>
>
>
>
> On 31/10/2017, 11:06 PM, "Tom Stellard" <tstellar@redhat.com> wrote:
>
> >On 10/30/2017 12:57 AM, Pixel Ding wrote:
> >> From: pding <Pixel.Ding@amd.com>
> >>
> >> Move kfd probe prior to device init. Release exclusive mode
> >> after hw_init if kfd is not enabled.
> >>
> >
> >What happens if only the amdgpu module is loaded at startup, and then the
> >user manually loads the amdkfd module at some point later on.  Will the driver
> >still behave correctly in this case with this patch?
> >
> >-Tom
> >
> >
> >> Signed-off-by: pding <Pixel.Ding@amd.com>
> >> ---
> >>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
> >>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
> >>  2 files changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> index 400dfaa..e46ec51 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> >> @@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
> >>              adev->ip_blocks[i].status.hw = true;
> >>      }
> >>
> >> +    if (amdgpu_sriov_vf(adev) && !adev->kfd)
> >> +            amdgpu_virt_release_full_gpu(adev, true);
> >> +
> >>      return 0;
> >>  }
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> >> index 3e9760d..e91907c 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> >> @@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
> >>          !pci_is_thunderbolt_attached(dev->pdev))
> >>              flags |= AMD_IS_PX;
> >>
> >> +    amdgpu_amdkfd_device_probe(adev);
> >> +
> >>      /* amdgpu_device_init should report only fatal error
> >>       * like memory allocation failure or iomapping failure,
> >>       * or memory manager initialization failure, it must
> >> @@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
> >>                              "Error during ACPI methods call\n");
> >>      }
> >>
> >> -    amdgpu_amdkfd_device_probe(adev);
> >>      amdgpu_amdkfd_device_init(adev);
> >>
> >>      if (amdgpu_device_is_px(dev)) {
> >> @@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
> >>              pm_runtime_put_autosuspend(dev->dev);
> >>      }
> >>
> >> -    if (amdgpu_sriov_vf(adev))
> >> +    if (amdgpu_sriov_vf(adev) && adev->kfd)
> >>              amdgpu_virt_release_full_gpu(adev, true);
> >>
> >>  out:
> >>
> >
> _______________________________________________
> 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] 9+ messages in thread

end of thread, other threads:[~2017-11-01  8:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30  7:57 [PATCH] drm/amdgpu: release exclusive mode after hw_init if no kfd Pixel Ding
     [not found] ` <1509350225-5712-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
2017-10-30  8:20   ` Oded Gabbay
     [not found]     ` <CAFCwf10VMsvGuQV5AtfeiOdi0jB2Je8=aGfZWLLGG00Z=N5t-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-30  8:30       ` Ding, Pixel
     [not found]         ` <CC871653-9D31-4D2D-BBAA-3F828CC2B227-5C7GfCeVMHo@public.gmane.org>
2017-10-30  8:52           ` Oded Gabbay
     [not found]             ` <CAFCwf13p+-Yoh1xwKOQdbDZT+eKTK6ugf39WMXxjeRrPEgMkuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-30  9:13               ` Ding, Pixel
     [not found]                 ` <72AC2064-6BD5-4FF5-B0BB-0AF06AA58295-5C7GfCeVMHo@public.gmane.org>
2017-10-31 10:25                   ` Oded Gabbay
2017-10-31 15:06   ` Tom Stellard
     [not found]     ` <ddf9c014-565b-8cc5-42d7-69d896c57c46-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-01  1:25       ` Ding, Pixel
     [not found]         ` <CCE67A7A-45E3-4B46-AD15-4B433B72939D-5C7GfCeVMHo@public.gmane.org>
2017-11-01  8:37           ` Oded Gabbay

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.