Skip to contentSkip to conversation

drm/amdgpu: release exclusive mode after hw_init if no kfd

PATCH In review Pixel Ding 3 participants 9 messages Oct 30, 2017 – Nov 1, 2017 7 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Pixel Ding

author
#0 lore raw

PATCH 1/1 drm/amdgpu: release exclusive mode after hw_init if no kfd

From: pding <[email protected]>

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -2
index 3e9760d..e91907c 100644
@@ -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:
Signature · 6 lines
2.9.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1509350225-5712-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 58 lines · Pixel Ding

From: pding <[email protected]>

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index 3e9760d..e91907c 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAFCwf10VMsvGuQV5AtfeiOdi0jB2Je8=aGfZWLLGG00Z=N5t-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw

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

Quoted 59 lines · Oded Gabbay
Quoted 58 lines · Pixel Ding

From: pding <[email protected]>

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index 3e9760d..e91907c 100644
@@ -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

Quoted 9 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CC871653-9D31-4D2D-BBAA-3F828CC2B227-5C7GfCeVMHo@public.gmane.org

#6 lore raw

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

Quoted 15 lines · Pixel

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

Quoted 70 lines
Quoted 68 lines · Oded Gabbay
Quoted 58 lines · Pixel Ding

From: pding <[email protected]>

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index 3e9760d..e91907c 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAFCwf13p+-Yoh1xwKOQdbDZT+eKTK6ugf39WMXxjeRrPEgMkuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw

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

Quoted 8 lines · Oded Gabbay

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

Quoted 86 lines
Quoted 85 lines · Pixel

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

Quoted 68 lines · Oded Gabbay
Quoted 58 lines · Pixel Ding

From: pding <[email protected]>

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index 3e9760d..e91907c 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 72AC2064-6BD5-4FF5-B0BB-0AF06AA58295-5C7GfCeVMHo@public.gmane.org

#10 lore raw

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 ?

Quoted 16 lines · Pixel

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

Quoted 96 lines
Quoted 94 lines · Oded Gabbay

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

Quoted 85 lines · Pixel

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

Quoted 68 lines · Oded Gabbay
Quoted 58 lines · Pixel Ding

From: pding <[email protected]>

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
index 3e9760d..e91907c 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw
In reply to a message not in the archive
Quoted 5 lines · Pixel Ding

From: pding <[email protected]>

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

Quoted 43 lines
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
index 3e9760d..e91907c 100644
@@ -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)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 189

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): ddf9c014-565b-8cc5-42d7-69d896c57c46-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#13 lore raw

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

Quoted 59 lines · Tom Stellard
Quoted 5 lines · Pixel Ding

From: pding <[email protected]>

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

Quoted 45 lines
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
index 3e9760d..e91907c 100644
@@ -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);
 	}
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 189

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
-	if (amdgpu_sriov_vf(adev))
+	if (amdgpu_sriov_vf(adev) && adev->kfd)
 		amdgpu_virt_release_full_gpu(adev, true);
 
 out:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CCE67A7A-45E3-4B46-AD15-4B433B72939D-5C7GfCeVMHo@public.gmane.org

#15 lore raw

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

Quoted 81 lines · Pixel

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

Quoted 63 lines · Tom Stellard
Quoted 5 lines · Pixel Ding

From: pding <[email protected]>

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

Quoted 49 lines
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 400dfaa..e46ec51 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -2
index 3e9760d..e91907c 100644
@@ -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);
 
Quoted 7 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 189

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
 out:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx