lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 26 Jun 2024 16:43:13 +0200
From: Thomas Zimmermann <tzimmermann@...e.de>
To: Wu Hoi Pok <wuhoipok@...il.com>
Cc: Alex Deucher <alexander.deucher@....com>,
 Christian König <christian.koenig@....com>,
 "Pan, Xinhui" <Xinhui.Pan@....com>, David Airlie <airlied@...il.com>,
 Daniel Vetter <daniel@...ll.ch>, amd-gfx@...ts.freedesktop.org,
 dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/7] drm/radeon: remove load callback

Hi

Am 24.06.24 um 17:10 schrieb Wu Hoi Pok:
> Remove ".load" callback form "kms_driver", and move "struct drm_device"
> into radeon_device. Patch 2 to 7 follows up with changing the way of
> accessing drm_device, from "rdev->ddev" to "rdev_to_drm(rdev)" which is
> "&rdev->ddev".

This is not going to build, so it cannot go in.

This should be the final patch. First add rdev_to_drm() and convert the 
driver to use it (that's one patch). Then change radeon_device.dev from 
a pointer to a value in a second patch.

Best regards
Thomas


>
> Signed-off-by: Wu Hoi Pok <wuhoipok@...il.com>
> ---
>   drivers/gpu/drm/radeon/radeon.h     | 11 ++++++++---
>   drivers/gpu/drm/radeon/radeon_drv.c | 27 ++++++++++++++++++---------
>   drivers/gpu/drm/radeon/radeon_drv.h |  1 -
>   drivers/gpu/drm/radeon/radeon_kms.c | 18 ++++++------------
>   4 files changed, 32 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 0999c8eaae94..69bb30ced189 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -2297,7 +2297,7 @@ typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
>   
>   struct radeon_device {
>   	struct device			*dev;
> -	struct drm_device		*ddev;
> +	struct drm_device		ddev;
>   	struct pci_dev			*pdev;
>   #ifdef __alpha__
>   	struct pci_controller		*hose;
> @@ -2440,10 +2440,13 @@ struct radeon_device {
>   	u64 gart_pin_size;
>   };
>   
> +static inline struct drm_device *rdev_to_drm(struct radeon_device *rdev)
> +{
> +	return &rdev->ddev;
> +}
> +
>   bool radeon_is_px(struct drm_device *dev);
>   int radeon_device_init(struct radeon_device *rdev,
> -		       struct drm_device *ddev,
> -		       struct pci_dev *pdev,
>   		       uint32_t flags);
>   void radeon_device_fini(struct radeon_device *rdev);
>   int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
> @@ -2818,6 +2821,8 @@ struct radeon_device *radeon_get_rdev(struct ttm_device *bdev);
>   
>   /* KMS */
>   
> +int radeon_driver_load_kms(struct radeon_device *dev, unsigned long flags);
> +
>   u32 radeon_get_vblank_counter_kms(struct drm_crtc *crtc);
>   int radeon_enable_vblank_kms(struct drm_crtc *crtc);
>   void radeon_disable_vblank_kms(struct drm_crtc *crtc);
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index 7bf08164140e..ae9cadceba83 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -259,7 +259,8 @@ static int radeon_pci_probe(struct pci_dev *pdev,
>   			    const struct pci_device_id *ent)
>   {
>   	unsigned long flags = 0;
> -	struct drm_device *dev;
> +	struct drm_device *ddev;
> +	struct radeon_device *rdev;
>   	int ret;
>   
>   	if (!ent)
> @@ -300,28 +301,37 @@ static int radeon_pci_probe(struct pci_dev *pdev,
>   	if (ret)
>   		return ret;
>   
> -	dev = drm_dev_alloc(&kms_driver, &pdev->dev);
> -	if (IS_ERR(dev))
> -		return PTR_ERR(dev);
> +	rdev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*rdev), ddev);
> +	if (IS_ERR(rdev))
> +		return PTR_ERR(rdev);
> +
> +	rdev->dev  = &pdev->dev;
> +	rdev->pdev = pdev;
> +	ddev = rdev_to_drm(rdev);
> +	ddev->dev_private = rdev;
>   
>   	ret = pci_enable_device(pdev);
>   	if (ret)
>   		goto err_free;
>   
> -	pci_set_drvdata(pdev, dev);
> +	pci_set_drvdata(pdev, ddev);
> +
> +	ret = radeon_driver_load_kms(rdev, flags);
> +	if (ret)
> +		goto err_agp;
>   
> -	ret = drm_dev_register(dev, ent->driver_data);
> +	ret = drm_dev_register(ddev, flags);
>   	if (ret)
>   		goto err_agp;
>   
> -	radeon_fbdev_setup(dev->dev_private);
> +	radeon_fbdev_setup(ddev->dev_private);
>   
>   	return 0;
>   
>   err_agp:
>   	pci_disable_device(pdev);
>   err_free:
> -	drm_dev_put(dev);
> +	drm_dev_put(ddev);
>   	return ret;
>   }
>   
> @@ -569,7 +579,6 @@ static const struct drm_ioctl_desc radeon_ioctls_kms[] = {
>   static const struct drm_driver kms_driver = {
>   	.driver_features =
>   	    DRIVER_GEM | DRIVER_RENDER | DRIVER_MODESET,
> -	.load = radeon_driver_load_kms,
>   	.open = radeon_driver_open_kms,
>   	.postclose = radeon_driver_postclose_kms,
>   	.unload = radeon_driver_unload_kms,
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
> index 02a65971d140..6c1eb75a951b 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.h
> +++ b/drivers/gpu/drm/radeon/radeon_drv.h
> @@ -117,7 +117,6 @@
>   long radeon_drm_ioctl(struct file *filp,
>   		      unsigned int cmd, unsigned long arg);
>   
> -int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
>   void radeon_driver_unload_kms(struct drm_device *dev);
>   int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
>   void radeon_driver_postclose_kms(struct drm_device *dev,
> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> index a16590c6247f..d2df194393af 100644
> --- a/drivers/gpu/drm/radeon/radeon_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> @@ -91,7 +91,7 @@ void radeon_driver_unload_kms(struct drm_device *dev)
>   /**
>    * radeon_driver_load_kms - Main load function for KMS.
>    *
> - * @dev: drm dev pointer
> + * @rdev: radeon dev pointer
>    * @flags: device flags
>    *
>    * This is the main load function for KMS (all asics).
> @@ -101,24 +101,18 @@ void radeon_driver_unload_kms(struct drm_device *dev)
>    * (crtcs, encoders, hotplug detect, etc.).
>    * Returns 0 on success, error on failure.
>    */
> -int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
> +int radeon_driver_load_kms(struct radeon_device *rdev, unsigned long flags)
>   {
> -	struct pci_dev *pdev = to_pci_dev(dev->dev);
> -	struct radeon_device *rdev;
> +	struct pci_dev *pdev = rdev->pdev;
> +	struct drm_device *dev = rdev_to_drm(rdev);
>   	int r, acpi_status;
>   
> -	rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
> -	if (rdev == NULL) {
> -		return -ENOMEM;
> -	}
> -	dev->dev_private = (void *)rdev;
> -
>   #ifdef __alpha__
>   	rdev->hose = pdev->sysdata;
>   #endif
>   
>   	if (pci_find_capability(pdev, PCI_CAP_ID_AGP))
> -		rdev->agp = radeon_agp_head_init(dev);
> +		rdev->agp = radeon_agp_head_init(rdev_to_drm(rdev));
>   	if (rdev->agp) {
>   		rdev->agp->agp_mtrr = arch_phys_wc_add(
>   			rdev->agp->agp_info.aper_base,
> @@ -147,7 +141,7 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
>   	 * properly initialize the GPU MC controller and permit
>   	 * VRAM allocation
>   	 */
> -	r = radeon_device_init(rdev, dev, pdev, flags);
> +	r = radeon_device_init(rdev, flags);
>   	if (r) {
>   		dev_err(dev->dev, "Fatal error during GPU init\n");
>   		goto out;

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ