Skip to content

Commit

Permalink
drm/amdkcl: test whether drm_dev_fini() is available (v2)
Browse files Browse the repository at this point in the history
This patch is caused by the following patches:
drm/amdkcl: test whether drm_dev_fini() is available
drm/amdgpu: Embed drm_device into amdgpu_device (v2)

Signed-off-by: Yang Xiong <Yang.Xiong@amd.com>
Reviewed-by: Flora Cui <flora.cui@amd.com>
  • Loading branch information
Yang Xiong authored and Yang Xiong committed Sep 7, 2020
1 parent f117461 commit 22de9a4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 39 deletions.
4 changes: 0 additions & 4 deletions drivers/gpu/drm/amd/amdgpu/amdgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1267,11 +1267,7 @@ static inline void *amdgpu_atpx_get_dhandle(void) { return NULL; }
extern const struct drm_ioctl_desc amdgpu_ioctls_kms[];
extern const int amdgpu_max_kms_ioctl;

#ifdef HAVE_DRM_DRIVER_RELEASE
int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags);
#else
int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags);
#endif
void amdgpu_driver_unload_kms(struct drm_device *dev);
void amdgpu_driver_lastclose_kms(struct drm_device *dev);
int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
Expand Down
27 changes: 19 additions & 8 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,13 +1181,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
if (ret)
return ret;

#ifdef HAVE_DRM_DRIVER_RELEASE
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
if (!adev)
return -ENOMEM;

adev->dev = &pdev->dev;
adev->pdev = pdev;
#ifdef HAVE_DRM_DRIVER_RELEASE
ddev = adev_to_drm(adev);
ret = drm_dev_init(ddev, &kms_driver, &pdev->dev);
if (ret)
Expand All @@ -1196,6 +1196,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
ddev = drm_dev_alloc(&kms_driver, &pdev->dev);
if (IS_ERR(ddev))
return PTR_ERR(ddev);
adev->ddev = ddev;
#endif
#ifdef AMDKCL_CHECK_DRM_DEVICE_DEV_PRIVATE
ddev->dev_private = (void *)adev;
#endif
kcl_drm_vma_offset_manager_init(ddev->vma_offset_manager);

Expand All @@ -1222,11 +1226,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
ddev->pdev = pdev;
pci_set_drvdata(pdev, ddev);

#ifdef HAVE_DRM_DRIVER_RELEASE
ret = amdgpu_driver_load_kms(adev, ent->driver_data);
#else
ret = amdgpu_driver_load_kms(ddev, ent->driver_data);
#endif
if (ret)
goto err_pci;

Expand All @@ -1241,9 +1241,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
goto err_pci;
}

#ifndef HAVE_DRM_DRIVER_RELEASE
adev = drm_to_adev(ddev);
#endif
ret = amdgpu_debugfs_init(adev);
if (ret)
DRM_ERROR("Creating debugfs files failed (%d).\n", ret);
Expand All @@ -1253,6 +1250,12 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
err_pci:
pci_disable_device(pdev);
err_free:
#ifndef HAVE_DRM_DRIVER_RELEASE
#ifdef AMDKCL_CHECK_DRM_DEVICE_DEV_PRIVATE
ddev->dev_private = NULL;
#endif
kfree(adev);
#endif
drm_dev_put(ddev);
return ret;
}
Expand All @@ -1275,6 +1278,14 @@ amdgpu_pci_remove(struct pci_dev *pdev)
kcl_pci_remove_measure_file(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
#ifndef HAVE_DRM_DRIVER_RELEASE
if (dev) {
#ifdef AMDKCL_CHECK_DRM_DEVICE_DEV_PRIVATE
dev->dev_private = NULL;
#endif
kfree(drm_to_adev(dev));
}
#endif
drm_dev_put(dev);
}

Expand Down
27 changes: 0 additions & 27 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)
amdgpu_unregister_gpu_instance(adev);

if (adev->rmmio == NULL)
#ifdef HAVE_DRM_DRIVER_RELEASE
return;
#else
goto done_free;
#endif

if (adev->runpm) {
pm_runtime_get_sync(dev->dev);
Expand All @@ -99,11 +95,6 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)

amdgpu_acpi_fini(adev);
amdgpu_device_fini(adev);
#ifndef HAVE_DRM_DRIVER_RELEASE
done_free:
kfree(adev);
dev->dev_private = NULL;
#endif
}

void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
Expand Down Expand Up @@ -140,30 +131,12 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
* This is the main load function for KMS (all asics).
* Returns 0 on success, error on failure.
*/
#ifdef HAVE_DRM_DRIVER_RELEASE
int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
#else
int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
#endif
{
#ifdef HAVE_DRM_DRIVER_RELEASE
struct drm_device *dev;
#else
struct amdgpu_device *adev;
#endif
int r, acpi_status;

#ifdef HAVE_DRM_DRIVER_RELEASE
dev = adev_to_drm(adev);
#else
adev = kzalloc(sizeof(struct amdgpu_device), GFP_KERNEL);
if (adev == NULL) {
return -ENOMEM;
}
#endif
#ifdef AMDKCL_CHECK_DRM_DEVICE_DEV_PRIVATE
dev->dev_private = (void *)adev;
#endif

if (amdgpu_has_atpx() &&
(amdgpu_is_atpx_hybrid() ||
Expand Down

0 comments on commit 22de9a4

Please sign in to comment.