Convert to using devm_drm_dev_alloc() (v2)
Subsystems (2)
cover Convert to using devm_drm_dev_alloc() (v2)
This is based on top of Daniel's documentation patch and it applies cleanly onto amd-staging-drm-next. I'm also running this live.
This version removes explicit drm_dev_put(), as it seems that devres acts as a garbage collector.
Luben Tuikov (1):
drm/amdgpu: Convert to using devm_drm_dev_alloc() (v2)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
Signature · 6 lines
2.28.0.394.ge197136389 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/1 drm/amdgpu: Convert to using devm_drm_dev_alloc() (v2)
Convert to using devm_drm_dev_alloc(),
as drm_dev_init() is going away.
v2: Remove drm_dev_put() since
a) devres doesn't do refcounting, see Documentation/driver-api/driver-model/devres.rst, Section 4, paragraph 1; and since
b) devres acts as garbage collector when
the DRM device's parent's devres "action" callback is called to free the container device (amdgpu_device), which embeds the DRM dev.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -12
@@ -1159,25 +1159,20 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret; - adev =kzalloc (sizeof (*adev),GFP_KERNEL ); -if (!adev) -return -ENOMEM ; + adev =devm_drm_dev_alloc (&pdev->dev, &kms_driver,typeof (*adev), ddev); +if (IS_ERR (adev)) +return PTR_ERR (adev); adev->dev = &pdev->dev; adev->pdev = pdev; ddev =adev_to_drm (adev); - ret =drm_dev_init (ddev, &kms_driver, &pdev->dev); -if (ret) - goto err_free; - -drmm_add_final_kfree (ddev, adev);if (!supports_atomic) ddev->driver_features &= ~DRIVER_ATOMIC ; ret =pci_enable_device (pdev);if (ret) - goto err_free; +return ret; ddev->pdev = pdev;pci_set_drvdata (pdev, ddev);
@@ -1205,8 +1200,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, err_pci:pci_disable_device (pdev); -err_free: -drm_dev_put (ddev);return ret; }
@@ -1223,7 +1216,6 @@ amdgpu_pci_remove(struct pci_dev *pdev)amdgpu_driver_unload_kms (dev);pci_disable_device (pdev);pci_set_drvdata (pdev,NULL ); -drm_dev_put (dev); } static void
Signature · 6 lines
2.28.0.394.ge197136389 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 1/1] drm/amdgpu: Convert to using devm_drm_dev_alloc() (v2)
Quoted 13 lines · Luben Tuikov
Convert to using
devm_drm_dev_alloc(),
asdrm_dev_init()is going away.v2: Remove
drm_dev_put()since
a) devres doesn't do refcounting, seeDocumentation/driver-api/driver-model/devres.rst, Section 4, paragraph 1; and since
b) devres acts as garbage collector when
the DRM device's parent's devres "action" callback is called to free the container device (amdgpu_device), which embeds the DRM dev.
Quoted 1 line
Signed-off-by Luben Tuikov <[email protected]>
Quoted 58 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-13@@ -1159,25 +1159,20 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret; - adev =kzalloc (sizeof (*adev),GFP_KERNEL ); -if (!adev) -return -ENOMEM ; + adev =devm_drm_dev_alloc (&pdev->dev, &kms_driver,typeof (*adev), ddev); +if (IS_ERR (adev)) +return PTR_ERR (adev); adev->dev = &pdev->dev; adev->pdev = pdev; ddev =adev_to_drm (adev); - ret =drm_dev_init (ddev, &kms_driver, &pdev->dev); -if (ret) - goto err_free; - -drmm_add_final_kfree (ddev, adev);if (!supports_atomic) ddev->driver_features &= ~DRIVER_ATOMIC ; ret =pci_enable_device (pdev);if (ret) - goto err_free; +return ret; ddev->pdev = pdev;pci_set_drvdata (pdev, ddev);@@ -1205,8 +1200,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, err_pci:pci_disable_device (pdev); -err_free: -drm_dev_put (ddev);return ret; }@@ -1223,7 +1216,6 @@ amdgpu_pci_remove(struct pci_dev *pdev)amdgpu_driver_unload_kms (dev);pci_disable_device (pdev);pci_set_drvdata (pdev,NULL ); -drm_dev_put (dev); } static void --2.28.0.394.ge197136389
Quoted 4 lines
_______________________________________________
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