Skip to content

Commit

Permalink
drm/amdkcl: always init drm_device.dev_private
Browse files Browse the repository at this point in the history
Although v5.5-rc2-1531-ge62bf83aa1bb has removed checking on dev->dev_private,
some distro with kernel v5.6+ (such as ubuntu20.04-oem) may still access dev->dev_private
In case of accessing dev->dev_private in drm code, init dev->dev_private to amdgpu_device.
Wrap this initialization with kcl inline function for easy tracking.

This patch is caused by the following patches:
f9896ea drm/amdkcl: test whether drm checking on dev->dev_private
82fc7ac 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>
Acked-by: Guchun Chen <guchun.chen@amd.com>
Change-Id: Ida1c4c10753865c036f21c577a3b552f4e14c2d5
  • Loading branch information
Yang Xiong authored and Rui Teng committed Sep 9, 2020
1 parent 6fae19c commit 772dce4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
12 changes: 3 additions & 9 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,9 +1198,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
return PTR_ERR(ddev);
adev->ddev = ddev;
#endif
#ifdef AMDKCL_CHECK_DRM_DEVICE_DEV_PRIVATE
ddev->dev_private = (void *)adev;
#endif
kcl_drm_dev_init_private(ddev, (void *)adev);
kcl_drm_vma_offset_manager_init(ddev->vma_offset_manager);

#ifdef HAVE_DRM_DRV_DRIVER_ATOMIC
Expand Down Expand Up @@ -1251,10 +1249,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
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);
kcl_drm_dev_fini_private(ddev);
#endif
drm_dev_put(ddev);
return ret;
Expand All @@ -1280,10 +1276,8 @@ amdgpu_pci_remove(struct pci_dev *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));
kcl_drm_dev_fini_private(dev);
}
#endif
drm_dev_put(dev);
Expand Down
8 changes: 0 additions & 8 deletions include/kcl/backport/kcl_drm_backport.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ int _kcl_drm_syncobj_find_fence(struct drm_file *file_private,
#define AMDKCL_AMDGPU_DEBUGFS_CLEANUP
#endif

/*
* commit v5.5-rc2-1531-ge62bf83aa1bb
* drm/irq: remove check on dev->dev_private
*/
#if DRM_VERSION_CODE < DRM_VERSION(5, 6, 0)
#define AMDKCL_CHECK_DRM_DEVICE_DEV_PRIVATE
#endif

#ifndef HAVE_DRM_GEM_OBJECT_LOOKUP_2ARGS
static inline struct drm_gem_object *
_kcl_drm_gem_object_lookup(struct drm_file *filp, u32 handle)
Expand Down
17 changes: 17 additions & 0 deletions include/kcl/kcl_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@

#include <kcl/header/kcl_drmP_h.h>
#include <drm/drm_gem.h>
#include <kcl/header/kcl_drm_device_h.h>
#include <kcl/header/kcl_drm_print_h.h>
#include <kcl/header/kcl_drm_file_h.h>
#if defined(HAVE_DRM_COLOR_LUT_SIZE)
#include <drm/drm_color_mgmt.h>
#endif

/*
* commit v5.5-rc2-1531-ge62bf83aa1bb
* drm/irq: remove check on dev->dev_private
*/
static inline
void kcl_drm_dev_init_private(struct drm_device *dev, void *priv)
{
dev->dev_private = priv;
}

static inline
void kcl_drm_dev_fini_private(struct drm_device *dev)
{
dev->dev_private = NULL;
}

#if !defined(HAVE_DRM_DRM_PRINT_H)
struct drm_printer {
void (*printfn)(struct drm_printer *p, struct va_format *vaf);
Expand Down

0 comments on commit 772dce4

Please sign in to comment.