Skip to contentSkip to conversation

drm/amdgpu: call pci_[un]register_driver() directly

PATCH In review Alex Deucher 2 participants 3 messages Jun 7, 2017 – Jun 8, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: call pci_[un]register_driver() directly

Rather than calling the deprecated drm_pci_init() and drm_pci_exit() which just wrapped the pci functions anyway.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
index 8c0c1c1..05c8343 100644
@@ -833,7 +833,7 @@ static int __init amdgpu_init(void)
 	driver->num_ioctls = amdgpu_max_kms_ioctl;
 	amdgpu_register_atpx_handler();
 	/* let modprobe override vga console setting */
-	return drm_pci_init(driver, pdriver);
+	return pci_register_driver(pdriver);
 
 error_sched:
 	amdgpu_fence_slab_fini();
@@ -848,7 +848,7 @@ static int __init amdgpu_init(void)
 static void __exit amdgpu_exit(void)
 {
 	amdgpu_amdkfd_fini();
-	drm_pci_exit(driver, pdriver);
+	pci_unregister_driver(pdriver);
 	amdgpu_unregister_atpx_handler();
 	amdgpu_sync_fini();
 	amd_sched_fence_slab_fini();
Signature · 6 lines
2.5.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): 1496871736-22329-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/amdgpu: drop deprecated drm_get_pci_dev and drm_put_dev

Open code them so we can adjust the order in the
driver more easily.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +26 -2
index 05c8343..855b0c2 100644
@@ -507,6 +507,7 @@ static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
 static int amdgpu_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *ent)
 {
+	struct drm_device *dev;
 	unsigned long flags = ent->driver_data;
 	int ret;
 
@@ -529,7 +530,29 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
-	return drm_get_pci_dev(pdev, ent, &kms_driver);
+	dev = drm_dev_alloc(&kms_driver, &pdev->dev);
+	if (IS_ERR(dev))
+		return PTR_ERR(dev);
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		goto err_free;
+
+	dev->pdev = pdev;
+
+	pci_set_drvdata(pdev, dev);
+
+	ret = drm_dev_register(dev, ent->driver_data);
+	if (ret)
+		goto err_pci;
+
+	return 0;
+
+err_pci:
+	pci_disable_device(pdev);
+err_free:
+	drm_dev_unref(dev);
+	return ret;
 }
 
 static void
@@ -537,7 +560,8 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
 
-	drm_put_dev(dev);
+	drm_dev_unregister(dev);
+	drm_dev_unref(dev);
 }
 
 static void
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#3 lore raw
In reply to a message not in the archive

Am 07.06.2017 um 23:42 schrieb Alex Deucher:

Quoted 5 lines

Rather than calling the deprecated drm_pci_init() and drm_pci_exit() which just wrapped the pci functions anyway.

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 8c0c1c1..05c8343 100644
@@ -833,7 +833,7 @@ static int __init amdgpu_init(void)
  	driver->num_ioctls = amdgpu_max_kms_ioctl;
  	amdgpu_register_atpx_handler();
  	/* let modprobe override vga console setting */
-	return drm_pci_init(driver, pdriver);
+	return pci_register_driver(pdriver);
 
  error_sched:
  	amdgpu_fence_slab_fini();

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int __init amdgpu_init(void) · line 854

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -848,7 +848,7 @@ static int __init amdgpu_init(void)
  static void __exit amdgpu_exit(void)
  {
  	amdgpu_amdkfd_fini();
-	drm_pci_exit(driver, pdriver);
+	pci_unregister_driver(pdriver);
  	amdgpu_unregister_atpx_handler();
  	amdgpu_sync_fini();
  	amd_sched_fence_slab_fini();

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