All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Dave Airlie <airlied@redhat.com>,
	dri-devel@lists.freedesktop.org,
	Gustavo Padovan <gustavo.padovan@collabora.com>
Subject: Re: [PATCH v2 1/2] drm: qxl: Open code probing sequence for qxl
Date: Wed, 18 Jan 2017 17:01:12 -0200	[thread overview]
Message-ID: <20170118190112.GP16017@joana> (raw)
In-Reply-To: <20170117132603.4064-1-krisman@collabora.co.uk>

Hi Gabriel,

2017-01-17 Gabriel Krisman Bertazi <krisman@collabora.co.uk>:

> This avoids using the deprecated drm_get_pci_dev() and load() hook
> interfaces in the qxl driver.
> 
> The only tricky part is to ensure TTM debugfs initialization happens
> after the debugfs root node is created, which is done by moving that
> code into the debufs_init() hook.
> 
> Tested on qemu with igt and running a WM on top of X.
> 
> Changes since v1:
>  - Drop verification for primary minor in qxl_debugsfs_init
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Gustavo Padovan <gustavo.padovan@collabora.com>
> ---
>  drivers/gpu/drm/qxl/qxl_debugfs.c | 10 +++++++
>  drivers/gpu/drm/qxl/qxl_drv.c     | 58 +++++++++++++++++++++++++++++++++++++--
>  drivers/gpu/drm/qxl/qxl_drv.h     |  7 ++++-
>  drivers/gpu/drm/qxl/qxl_kms.c     | 40 ++-------------------------
>  drivers/gpu/drm/qxl/qxl_ttm.c     |  8 +-----
>  5 files changed, 75 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
> index 241af9131dc8..057b2b547cac 100644
> --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
> +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
> @@ -84,8 +84,18 @@ int
>  qxl_debugfs_init(struct drm_minor *minor)
>  {
>  #if defined(CONFIG_DEBUG_FS)
> +	int r;
> +	struct qxl_device *dev =
> +		(struct qxl_device *) minor->dev->dev_private;
> +
>  	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
>  				 minor->debugfs_root, minor);
> +
> +	r = qxl_ttm_debugfs_init(dev);
> +	if (r) {
> +		DRM_ERROR("Failed to init TTM debugfs\n");
> +		return r;
> +	}
>  #endif
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 460bbceae297..7cc29027a612 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -62,12 +62,67 @@ static struct pci_driver qxl_pci_driver;
>  static int
>  qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  {
> +	struct drm_device *drm;
> +	struct qxl_device *qdev;
> +	int ret;
> +
>  	if (pdev->revision < 4) {
>  		DRM_ERROR("qxl too old, doesn't support client_monitors_config,"
>  			  " use xf86-video-qxl in user mode");
>  		return -EINVAL; /* TODO: ENODEV ? */
>  	}
> -	return drm_get_pci_dev(pdev, ent, &qxl_driver);
> +
> +	drm = drm_dev_alloc(&qxl_driver, &pdev->dev);
> +	if (IS_ERR(drm))
> +		return -ENOMEM;
> +
> +	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> +	if (!qdev) {
> +		ret = -ENOMEM;
> +		goto free_drm_device;
> +	}
> +
> +	ret = pci_enable_device(pdev);
> +	if (ret)
> +		goto free_drm_device;
> +
> +	drm->pdev = pdev;
> +	pci_set_drvdata(pdev, drm);
> +	drm->dev_private = qdev;
> +
> +	ret = qxl_device_init(qdev, drm, pdev, ent->driver_data);
> +	if (ret)
> +		goto disable_pci;
> +
> +	ret = drm_vblank_init(drm, 1);
> +	if (ret)
> +		goto unload;
> +
> +	ret = qxl_modeset_init(qdev);
> +	if (ret)
> +		goto vblank_cleanup;
> +
> +	drm_kms_helper_poll_init(qdev->ddev);
> +
> +	/* Complete initialization. */
> +	ret = drm_dev_register(drm, ent->driver_data);
> +	if (ret)
> +		goto modeset_cleanup;
> +
> +	return 0;
> +
> +modeset_cleanup:
> +	qxl_modeset_fini(qdev);
> +vblank_cleanup:
> +	drm_vblank_cleanup(drm);
> +unload:
> +	qxl_device_fini(qdev);
> +disable_pci:
> +	pci_disable_device(pdev);
> +free_drm_device:
> +	kfree(qdev);
> +	kfree(drm);
> +	return ret;
>  }
>  
>  static void
> @@ -230,7 +285,6 @@ static struct pci_driver qxl_pci_driver = {
>  static struct drm_driver qxl_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
>  			   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
> -	.load = qxl_driver_load,
>  	.unload = qxl_driver_unload,
>  	.get_vblank_counter = qxl_noop_get_vblank_counter,
>  	.enable_vblank = qxl_noop_enable_vblank,
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 883d8639c04e..d0aed9ed12d2 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -336,7 +336,10 @@ __printf(2,3) void qxl_io_log(struct qxl_device *qdev, const char *fmt, ...);
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> -int qxl_driver_load(struct drm_device *dev, unsigned long flags);
> +int qxl_device_init(struct qxl_device *qdev, struct drm_device *ddev,
> +		    struct pci_dev *pdev,  unsigned long flags);
> +void qxl_device_fini(struct qxl_device *qdev);
> +
>  void qxl_driver_unload(struct drm_device *dev);
>  
>  int qxl_modeset_init(struct qxl_device *qdev);
> @@ -345,6 +348,8 @@ void qxl_modeset_fini(struct qxl_device *qdev);
>  int qxl_bo_init(struct qxl_device *qdev);
>  void qxl_bo_fini(struct qxl_device *qdev);
>  
> +int qxl_ttm_debugfs_init(struct qxl_device *qdev);
> +

Please group this declaration together with the other qxl debugfs
declarations.

Gustavo

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-01-18 19:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 13:26 [PATCH v2 1/2] drm: qxl: Open code probing sequence for qxl Gabriel Krisman Bertazi
2017-01-17 13:26 ` [PATCH v2 2/2] drm: qxl: Open code teardown function " Gabriel Krisman Bertazi
2017-01-18 19:01 ` Gustavo Padovan [this message]
2017-01-19 13:49   ` [PATCH v2 1/2] drm: qxl: Open code probing sequence " Gabriel Krisman Bertazi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170118190112.GP16017@joana \
    --to=gustavo@padovan.org \
    --cc=airlied@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo.padovan@collabora.com \
    --cc=krisman@collabora.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.