Re: [PATCH 3/3] drm/amdgpu: Embed drm_device into amdgpu_device (v2)
On 2020-09-01 9:49 a.m., Alex Deucher wrote: > On Tue, Sep 1, 2020 at 3:44 AM Daniel Vetter wrote: >> >> On Wed, Aug 19, 2020 at 01:00:42AM -0400, Luben Tuikov wrote: >>> a) Embed struct drm_device into struct amdgpu_device. >>> b) Modify the inline-f drm_to_adev() accordingly. >>> c) Modify the inline-f adev_to_drm() accordingly. >>> d) Eliminate the use of drm_device.dev_private, >>>in amdgpu. >>> e) Switch from using drm_dev_alloc() to >>>drm_dev_init(). >>> f) Add a DRM driver release function, which frees >>>the container amdgpu_device after all krefs on >>>the contained drm_device have been released. >>> >>> v2: Split out adding adev_to_drm() into its own >>> patch (previous commit), making this patch >>> more succinct and clear. More detailed commit >>> description. >>> >>> Signed-off-by: Luben Tuikov >>> --- >>> drivers/gpu/drm/amd/amdgpu/amdgpu.h| 10 ++--- >>> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++- >>> drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 43 ++ >>> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 20 +++--- >>> 4 files changed, 43 insertions(+), 45 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>> index 735480cc7dcf..107a6ec920f7 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>> @@ -724,8 +724,8 @@ struct amd_powerplay { >>> #define AMDGPU_MAX_DF_PERFMONS 4 >>> struct amdgpu_device { >>> struct device *dev; >>> - struct drm_device *ddev; >>> struct pci_dev *pdev; >>> + struct drm_device ddev; >>> >>> #ifdef CONFIG_DRM_AMD_ACP >>> struct amdgpu_acp acp; >>> @@ -990,12 +990,12 @@ struct amdgpu_device { >>> >>> static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) >>> { >>> - return ddev->dev_private; >>> + return container_of(ddev, struct amdgpu_device, ddev); >>> } >>> >>> static inline struct drm_device *adev_to_drm(struct amdgpu_device *adev) >>> { >>> - return adev->ddev; >>> + return >ddev; >>> } >>> >>> static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device >>> *bdev) >>> @@ -1004,8 +1004,6 @@ static inline struct amdgpu_device >>> *amdgpu_ttm_adev(struct ttm_bo_device *bdev) >>> } >>> >>> int amdgpu_device_init(struct amdgpu_device *adev, >>> -struct drm_device *ddev, >>> -struct pci_dev *pdev, >>> uint32_t flags); >>> void amdgpu_device_fini(struct amdgpu_device *adev); >>> int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); >>> @@ -1195,7 +1193,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; >>> >>> -int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); >>> +int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long >>> flags); >>> 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); >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>> index 07012d71eeea..6e529548e708 100644 >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>> @@ -1216,7 +1216,8 @@ static int amdgpu_device_check_arguments(struct >>> amdgpu_device *adev) >>> * Callback for the switcheroo driver. Suspends or resumes the >>> * the asics before or after it is powered up using ACPI methods. >>> */ >>> -static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum >>> vga_switcheroo_state state) >>> +static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, >>> + enum vga_switcheroo_state state) >>> { >>> struct drm_device *dev = pci_get_drvdata(pdev); >>> int r; >>> @@ -2977,8 +2978,6 @@ static const struct attribute >>> *amdgpu_dev_attributes[] = { >>> * amdgpu_device_init - initialize the driver >>> * >>> * @adev: amdgpu_device pointer >>> - * @ddev: drm dev pointer >>> - * @pdev: pci dev pointer >>> * @flags: driver flags >>> * >>> * Initializes the driver info and hw (all asics). >>> @@ -2986,18 +2985,15 @@ static const struct attribute >>> *amdgpu_dev_attributes[] = { >>> * Called at driver startup. >>> */ >>> int amdgpu_device_init(struct amdgpu_device *adev, >>> -struct drm_device *ddev, >>> -struct pci_dev *pdev, >>> uint32_t flags) >>> { >>> + struct drm_device *ddev = adev_to_drm(adev); >>> + struct pci_dev *pdev = adev->pdev; >>> int r, i; >>> bool boco = false; >>> u32
Re: [PATCH 3/3] drm/amdgpu: Embed drm_device into amdgpu_device (v2)
On Tue, Sep 1, 2020 at 3:44 AM Daniel Vetter wrote: > > On Wed, Aug 19, 2020 at 01:00:42AM -0400, Luben Tuikov wrote: > > a) Embed struct drm_device into struct amdgpu_device. > > b) Modify the inline-f drm_to_adev() accordingly. > > c) Modify the inline-f adev_to_drm() accordingly. > > d) Eliminate the use of drm_device.dev_private, > >in amdgpu. > > e) Switch from using drm_dev_alloc() to > >drm_dev_init(). > > f) Add a DRM driver release function, which frees > >the container amdgpu_device after all krefs on > >the contained drm_device have been released. > > > > v2: Split out adding adev_to_drm() into its own > > patch (previous commit), making this patch > > more succinct and clear. More detailed commit > > description. > > > > Signed-off-by: Luben Tuikov > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu.h| 10 ++--- > > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++- > > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 43 ++ > > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 20 +++--- > > 4 files changed, 43 insertions(+), 45 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > > index 735480cc7dcf..107a6ec920f7 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > > @@ -724,8 +724,8 @@ struct amd_powerplay { > > #define AMDGPU_MAX_DF_PERFMONS 4 > > struct amdgpu_device { > > struct device *dev; > > - struct drm_device *ddev; > > struct pci_dev *pdev; > > + struct drm_device ddev; > > > > #ifdef CONFIG_DRM_AMD_ACP > > struct amdgpu_acp acp; > > @@ -990,12 +990,12 @@ struct amdgpu_device { > > > > static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) > > { > > - return ddev->dev_private; > > + return container_of(ddev, struct amdgpu_device, ddev); > > } > > > > static inline struct drm_device *adev_to_drm(struct amdgpu_device *adev) > > { > > - return adev->ddev; > > + return >ddev; > > } > > > > static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device > > *bdev) > > @@ -1004,8 +1004,6 @@ static inline struct amdgpu_device > > *amdgpu_ttm_adev(struct ttm_bo_device *bdev) > > } > > > > int amdgpu_device_init(struct amdgpu_device *adev, > > -struct drm_device *ddev, > > -struct pci_dev *pdev, > > uint32_t flags); > > void amdgpu_device_fini(struct amdgpu_device *adev); > > int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); > > @@ -1195,7 +1193,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; > > > > -int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); > > +int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long > > flags); > > 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); > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > index 07012d71eeea..6e529548e708 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > > @@ -1216,7 +1216,8 @@ static int amdgpu_device_check_arguments(struct > > amdgpu_device *adev) > > * Callback for the switcheroo driver. Suspends or resumes the > > * the asics before or after it is powered up using ACPI methods. > > */ > > -static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum > > vga_switcheroo_state state) > > +static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, > > + enum vga_switcheroo_state state) > > { > > struct drm_device *dev = pci_get_drvdata(pdev); > > int r; > > @@ -2977,8 +2978,6 @@ static const struct attribute > > *amdgpu_dev_attributes[] = { > > * amdgpu_device_init - initialize the driver > > * > > * @adev: amdgpu_device pointer > > - * @ddev: drm dev pointer > > - * @pdev: pci dev pointer > > * @flags: driver flags > > * > > * Initializes the driver info and hw (all asics). > > @@ -2986,18 +2985,15 @@ static const struct attribute > > *amdgpu_dev_attributes[] = { > > * Called at driver startup. > > */ > > int amdgpu_device_init(struct amdgpu_device *adev, > > -struct drm_device *ddev, > > -struct pci_dev *pdev, > > uint32_t flags) > > { > > + struct drm_device *ddev = adev_to_drm(adev); > > + struct pci_dev *pdev = adev->pdev; > > int r, i; > > bool boco = false; > > u32 max_MBps; > > > > adev->shutdown = false; > > -
Re: [PATCH 3/3] drm/amdgpu: Embed drm_device into amdgpu_device (v2)
On Wed, Aug 19, 2020 at 01:00:42AM -0400, Luben Tuikov wrote: > a) Embed struct drm_device into struct amdgpu_device. > b) Modify the inline-f drm_to_adev() accordingly. > c) Modify the inline-f adev_to_drm() accordingly. > d) Eliminate the use of drm_device.dev_private, >in amdgpu. > e) Switch from using drm_dev_alloc() to >drm_dev_init(). > f) Add a DRM driver release function, which frees >the container amdgpu_device after all krefs on >the contained drm_device have been released. > > v2: Split out adding adev_to_drm() into its own > patch (previous commit), making this patch > more succinct and clear. More detailed commit > description. > > Signed-off-by: Luben Tuikov > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h| 10 ++--- > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++- > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 43 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 20 +++--- > 4 files changed, 43 insertions(+), 45 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 735480cc7dcf..107a6ec920f7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -724,8 +724,8 @@ struct amd_powerplay { > #define AMDGPU_MAX_DF_PERFMONS 4 > struct amdgpu_device { > struct device *dev; > - struct drm_device *ddev; > struct pci_dev *pdev; > + struct drm_device ddev; > > #ifdef CONFIG_DRM_AMD_ACP > struct amdgpu_acp acp; > @@ -990,12 +990,12 @@ struct amdgpu_device { > > static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) > { > - return ddev->dev_private; > + return container_of(ddev, struct amdgpu_device, ddev); > } > > static inline struct drm_device *adev_to_drm(struct amdgpu_device *adev) > { > - return adev->ddev; > + return >ddev; > } > > static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device > *bdev) > @@ -1004,8 +1004,6 @@ static inline struct amdgpu_device > *amdgpu_ttm_adev(struct ttm_bo_device *bdev) > } > > int amdgpu_device_init(struct amdgpu_device *adev, > -struct drm_device *ddev, > -struct pci_dev *pdev, > uint32_t flags); > void amdgpu_device_fini(struct amdgpu_device *adev); > int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); > @@ -1195,7 +1193,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; > > -int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); > +int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags); > 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); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 07012d71eeea..6e529548e708 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -1216,7 +1216,8 @@ static int amdgpu_device_check_arguments(struct > amdgpu_device *adev) > * Callback for the switcheroo driver. Suspends or resumes the > * the asics before or after it is powered up using ACPI methods. > */ > -static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum > vga_switcheroo_state state) > +static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, > + enum vga_switcheroo_state state) > { > struct drm_device *dev = pci_get_drvdata(pdev); > int r; > @@ -2977,8 +2978,6 @@ static const struct attribute *amdgpu_dev_attributes[] > = { > * amdgpu_device_init - initialize the driver > * > * @adev: amdgpu_device pointer > - * @ddev: drm dev pointer > - * @pdev: pci dev pointer > * @flags: driver flags > * > * Initializes the driver info and hw (all asics). > @@ -2986,18 +2985,15 @@ static const struct attribute > *amdgpu_dev_attributes[] = { > * Called at driver startup. > */ > int amdgpu_device_init(struct amdgpu_device *adev, > -struct drm_device *ddev, > -struct pci_dev *pdev, > uint32_t flags) > { > + struct drm_device *ddev = adev_to_drm(adev); > + struct pci_dev *pdev = adev->pdev; > int r, i; > bool boco = false; > u32 max_MBps; > > adev->shutdown = false; > - adev->dev = >dev; > - adev->ddev = ddev; > - adev->pdev = pdev; > adev->flags = flags; > > if (amdgpu_force_asic_type >= 0 && amdgpu_force_asic_type < CHIP_LAST) > @@ -3451,9 +3447,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool > fbcon) >
Re: [PATCH 3/3] drm/amdgpu: Embed drm_device into amdgpu_device (v2)
On Wed, Aug 19, 2020 at 1:01 AM Luben Tuikov wrote: > > a) Embed struct drm_device into struct amdgpu_device. > b) Modify the inline-f drm_to_adev() accordingly. > c) Modify the inline-f adev_to_drm() accordingly. > d) Eliminate the use of drm_device.dev_private, >in amdgpu. > e) Switch from using drm_dev_alloc() to >drm_dev_init(). > f) Add a DRM driver release function, which frees >the container amdgpu_device after all krefs on >the contained drm_device have been released. > > v2: Split out adding adev_to_drm() into its own > patch (previous commit), making this patch > more succinct and clear. More detailed commit > description. > > Signed-off-by: Luben Tuikov Series is: Reviewed-by: Alex Deucher > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h| 10 ++--- > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++- > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 43 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 20 +++--- > 4 files changed, 43 insertions(+), 45 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 735480cc7dcf..107a6ec920f7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -724,8 +724,8 @@ struct amd_powerplay { > #define AMDGPU_MAX_DF_PERFMONS 4 > struct amdgpu_device { > struct device *dev; > - struct drm_device *ddev; > struct pci_dev *pdev; > + struct drm_device ddev; > > #ifdef CONFIG_DRM_AMD_ACP > struct amdgpu_acp acp; > @@ -990,12 +990,12 @@ struct amdgpu_device { > > static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) > { > - return ddev->dev_private; > + return container_of(ddev, struct amdgpu_device, ddev); > } > > static inline struct drm_device *adev_to_drm(struct amdgpu_device *adev) > { > - return adev->ddev; > + return >ddev; > } > > static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device > *bdev) > @@ -1004,8 +1004,6 @@ static inline struct amdgpu_device > *amdgpu_ttm_adev(struct ttm_bo_device *bdev) > } > > int amdgpu_device_init(struct amdgpu_device *adev, > - struct drm_device *ddev, > - struct pci_dev *pdev, >uint32_t flags); > void amdgpu_device_fini(struct amdgpu_device *adev); > int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); > @@ -1195,7 +1193,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; > > -int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); > +int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags); > 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); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 07012d71eeea..6e529548e708 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -1216,7 +1216,8 @@ static int amdgpu_device_check_arguments(struct > amdgpu_device *adev) > * Callback for the switcheroo driver. Suspends or resumes the > * the asics before or after it is powered up using ACPI methods. > */ > -static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum > vga_switcheroo_state state) > +static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, > + enum vga_switcheroo_state state) > { > struct drm_device *dev = pci_get_drvdata(pdev); > int r; > @@ -2977,8 +2978,6 @@ static const struct attribute *amdgpu_dev_attributes[] > = { > * amdgpu_device_init - initialize the driver > * > * @adev: amdgpu_device pointer > - * @ddev: drm dev pointer > - * @pdev: pci dev pointer > * @flags: driver flags > * > * Initializes the driver info and hw (all asics). > @@ -2986,18 +2985,15 @@ static const struct attribute > *amdgpu_dev_attributes[] = { > * Called at driver startup. > */ > int amdgpu_device_init(struct amdgpu_device *adev, > - struct drm_device *ddev, > - struct pci_dev *pdev, >uint32_t flags) > { > + struct drm_device *ddev = adev_to_drm(adev); > + struct pci_dev *pdev = adev->pdev; > int r, i; > bool boco = false; > u32 max_MBps; > > adev->shutdown = false; > - adev->dev = >dev; > - adev->ddev = ddev; > - adev->pdev = pdev; > adev->flags = flags; > > if (amdgpu_force_asic_type >= 0 && amdgpu_force_asic_type < CHIP_LAST) > @@ -3451,9 +3447,8 @@ int
[PATCH 3/3] drm/amdgpu: Embed drm_device into amdgpu_device (v2)
a) Embed struct drm_device into struct amdgpu_device. b) Modify the inline-f drm_to_adev() accordingly. c) Modify the inline-f adev_to_drm() accordingly. d) Eliminate the use of drm_device.dev_private, in amdgpu. e) Switch from using drm_dev_alloc() to drm_dev_init(). f) Add a DRM driver release function, which frees the container amdgpu_device after all krefs on the contained drm_device have been released. v2: Split out adding adev_to_drm() into its own patch (previous commit), making this patch more succinct and clear. More detailed commit description. Signed-off-by: Luben Tuikov --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 10 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 43 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 20 +++--- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 735480cc7dcf..107a6ec920f7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -724,8 +724,8 @@ struct amd_powerplay { #define AMDGPU_MAX_DF_PERFMONS 4 struct amdgpu_device { struct device *dev; - struct drm_device *ddev; struct pci_dev *pdev; + struct drm_device ddev; #ifdef CONFIG_DRM_AMD_ACP struct amdgpu_acp acp; @@ -990,12 +990,12 @@ struct amdgpu_device { static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) { - return ddev->dev_private; + return container_of(ddev, struct amdgpu_device, ddev); } static inline struct drm_device *adev_to_drm(struct amdgpu_device *adev) { - return adev->ddev; + return >ddev; } static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) @@ -1004,8 +1004,6 @@ static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) } int amdgpu_device_init(struct amdgpu_device *adev, - struct drm_device *ddev, - struct pci_dev *pdev, uint32_t flags); void amdgpu_device_fini(struct amdgpu_device *adev); int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); @@ -1195,7 +1193,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; -int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); +int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags); 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); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 07012d71eeea..6e529548e708 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1216,7 +1216,8 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev) * Callback for the switcheroo driver. Suspends or resumes the * the asics before or after it is powered up using ACPI methods. */ -static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state) +static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, + enum vga_switcheroo_state state) { struct drm_device *dev = pci_get_drvdata(pdev); int r; @@ -2977,8 +2978,6 @@ static const struct attribute *amdgpu_dev_attributes[] = { * amdgpu_device_init - initialize the driver * * @adev: amdgpu_device pointer - * @ddev: drm dev pointer - * @pdev: pci dev pointer * @flags: driver flags * * Initializes the driver info and hw (all asics). @@ -2986,18 +2985,15 @@ static const struct attribute *amdgpu_dev_attributes[] = { * Called at driver startup. */ int amdgpu_device_init(struct amdgpu_device *adev, - struct drm_device *ddev, - struct pci_dev *pdev, uint32_t flags) { + struct drm_device *ddev = adev_to_drm(adev); + struct pci_dev *pdev = adev->pdev; int r, i; bool boco = false; u32 max_MBps; adev->shutdown = false; - adev->dev = >dev; - adev->ddev = ddev; - adev->pdev = pdev; adev->flags = flags; if (amdgpu_force_asic_type >= 0 && amdgpu_force_asic_type < CHIP_LAST) @@ -3451,9 +3447,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon) struct drm_connector_list_iter iter; int r; - if (dev == NULL || dev->dev_private == NULL) { + if (!dev) return -ENODEV; - } adev = drm_to_adev(dev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c