All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Maxim Levitsky <maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 09/10] nouveau: EVO debug iface
Date: Sun, 9 Oct 2011 23:23:02 +0200	[thread overview]
Message-ID: <20111009212302.GD3323@joi.lan> (raw)
In-Reply-To: <1318193920-27461-10-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Sun, Oct 09, 2011 at 10:58:39PM +0200, Maxim Levitsky wrote:
> This code adds new debugfs file that allows to send evo commands from userspace.
> Its usefull for RE.
> 
> Signed-off-by: Maxim Levitsky <maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Just a minor nit below.

> ---
>  drivers/gpu/drm/nouveau/nouveau_debugfs.c |  101 +++++++++++++++++++++++++++++
>  drivers/gpu/drm/nouveau/nv50_crtc.c       |    2 +-
>  drivers/gpu/drm/nouveau/nv50_display.h    |    1 +
>  3 files changed, 103 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> index 8e15923..c79bf56 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> @@ -30,11 +30,16 @@
>  
>  #include <linux/debugfs.h>
>  
> +#define NOUVEAU_DMA_DEBUG 1
>  #include "drmP.h"
>  #include "nouveau_drv.h"
> +#include "nouveau_dma.h"
> +#include "nv50_display.h"
> +#include "nouveau_crtc.h"
>  
>  #include <ttm/ttm_page_alloc.h>
>  
> +
>  static int
>  nouveau_debugfs_channel_info(struct seq_file *m, void *data)
>  {
> @@ -181,11 +186,107 @@ static struct drm_info_list nouveau_debugfs_list[] = {
>  };
>  #define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
>  
> +static int nouveau_evo_debugfs_open(struct inode *inode, struct file *file)
> +{
> +	file->private_data = inode->i_private;
> +	return 0;
> +}
> +
> +static int nouveau_evo_debugfs_release (struct inode *inode, struct file *file)
> +{
> +	return 0;
> +}
> +
> +int
> +nv50_crtc_wait_complete(struct drm_crtc *crtc);
> +
> +
> +static ssize_t nouveau_evo_debugfs_write(struct file *file, const char __user * user_buf,
> +			size_t count, loff_t *ppos)
> +{
> +	struct drm_minor *minor = (struct drm_minor *)file->private_data;
> +	struct drm_device* dev = minor->dev;
> +	struct nouveau_channel *evo;
> +	struct drm_crtc *crtc;
> +	struct nv50_display *display;
> +	u32 method, value;
> +	unsigned char *cmd;
> +	int ret;
> +
> +	if (count > 100 || *ppos)
> +		return -EINVAL;
> +
> +	cmd = kmalloc(count + 1, GFP_KERNEL);
> +	if (!cmd)
> +		return -ENOMEM;
> +
> +	if (copy_from_user(cmd, user_buf, count)) {
> +		kfree(cmd);
> +		return -EINVAL;
> +	}

The convention is to return -EFAULT when copy_from_user fails.

> +
> +	cmd[count] = '\0';
> +
> +	mutex_lock(&dev->mode_config.mutex);
> +
> +	display = nv50_display(dev);
> +	evo = display->master;
> +
> +	if (sscanf(cmd, "%x %x", &method, &value) == 2) {
> +
> +		ret = RING_SPACE(evo, 2);
> +		if (ret)
> +			goto out;
> +
> +		BEGIN_RING(evo, 0, method, 1);
> +		OUT_RING(evo, value);
> +		FIRE_RING(evo);
> +
> +	} else if (!strncmp(cmd, "flush", 5)) {
> +
> +		ret = RING_SPACE(evo, 6);
> +		if (ret)
> +			goto out;
> +
> +		BEGIN_RING(evo, 0, 0x84, 1);
> +		OUT_RING(evo, 0x80000004);
> +		BEGIN_RING(evo, 0, 0x84, 1);
> +		OUT_RING(evo, 0x80000008);
> +		BEGIN_RING(evo, 0, 0x80, 1);
> +		OUT_RING(evo, 0x00000000);
> +		FIRE_RING(evo);
> +
> +		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> +			if (crtc->fb) {
> +				nv50_display_flip_stop(crtc);
> +				nv50_crtc_wait_complete(crtc);
> +				nv50_display_flip_next(crtc, crtc->fb, NULL);
> +			}
> +		}
> +	} else
> +		NV_ERROR(dev, "evodbg: malformated input %s\n", cmd);
> +
> +	ret =  count;
> +out:
> +	kfree(cmd);
> +	mutex_unlock(&dev->mode_config.mutex);
> +	return ret;
> +}
> +
> +static const struct file_operations evo_debugfs_ops = {
> +	.open = nouveau_evo_debugfs_open,
> +	.release = nouveau_evo_debugfs_release,
> +	.write = nouveau_evo_debugfs_write,
> +	.llseek = default_llseek,
> +};
> +
>  int
>  nouveau_debugfs_init(struct drm_minor *minor)
>  {
>  	drm_debugfs_create_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
>  				 minor->debugfs_root, minor);
> +	debugfs_create_file("evo",
> +		S_IWUSR, minor->debugfs_root, minor, &evo_debugfs_ops);
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/nouveau/nv50_crtc.c b/drivers/gpu/drm/nouveau/nv50_crtc.c
> index cb8943f..4b2d9ec 100644
> --- a/drivers/gpu/drm/nouveau/nv50_crtc.c
> +++ b/drivers/gpu/drm/nouveau/nv50_crtc.c
> @@ -443,7 +443,7 @@ nv50_crtc_dpms(struct drm_crtc *crtc, int mode)
>  {
>  }
>  
> -static int
> +int
>  nv50_crtc_wait_complete(struct drm_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->dev;
> diff --git a/drivers/gpu/drm/nouveau/nv50_display.h b/drivers/gpu/drm/nouveau/nv50_display.h
> index c2da503..44c0157 100644
> --- a/drivers/gpu/drm/nouveau/nv50_display.h
> +++ b/drivers/gpu/drm/nouveau/nv50_display.h
> @@ -72,6 +72,7 @@ int nv50_display_init(struct drm_device *dev);
>  void nv50_display_destroy(struct drm_device *dev);
>  int nv50_crtc_blank(struct nouveau_crtc *, bool blank);
>  int nv50_crtc_set_clock(struct drm_device *, int head, int pclk);
> +int nv50_crtc_wait_complete(struct drm_crtc *crtc);
>  
>  int  nv50_display_flip_next(struct drm_crtc *, struct drm_framebuffer *,
>  			    struct nouveau_channel *chan);
> -- 

  parent reply	other threads:[~2011-10-09 21:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09 20:58 [PATCH 01/10]: nouveau: assorted fixes Maxim Levitsky
     [not found] ` <1318193920-27461-1-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-10-09 20:58   ` [PATCH 01/10] nv50: fix stability issue on NV86 Maxim Levitsky
2011-10-09 20:58   ` [PATCH 02/10] nv50: also report errors in MP1/MP2 when they happen Maxim Levitsky
2011-10-09 20:58   ` [PATCH 03/10] nouveau: disable output polling through suspend Maxim Levitsky
2011-10-09 20:58   ` [PATCH 04/10] nouveau: hide cursor before suspending Maxim Levitsky
     [not found]     ` <1318193920-27461-5-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-10-09 21:03       ` Maxim Levitsky
2011-10-09 20:58   ` [PATCH 05/10] nouveau: restore performance mode a bit later Maxim Levitsky
     [not found]     ` <1318193920-27461-6-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-10-09 21:05       ` Maxim Levitsky
2011-10-09 20:58   ` [PATCH 06/10] nv50: fix doublescan modes Maxim Levitsky
2011-10-09 20:58   ` [PATCH 07/10] nv50: cosmetic cleanup in modesetting code Maxim Levitsky
2011-10-09 20:58   ` [PATCH 08/10] drm: debugfs: remove debug directores using recursion Maxim Levitsky
2011-10-09 20:58   ` [PATCH 09/10] nouveau: EVO debug iface Maxim Levitsky
     [not found]     ` <1318193920-27461-10-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-10-09 21:23       ` Marcin Slusarz [this message]
2011-10-09 20:58   ` [PATCH 10/10] nv50: WIP: initial import of power save magic Maxim Levitsky
2011-10-10  0:53   ` [PATCH 01/10]: nouveau: assorted fixes Ben Skeggs

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=20111009212302.GD3323@joi.lan \
    --to=marcin.slusarz-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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.