All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilija Hadzic <ihadzic@research.bell-labs.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 08/16] drm: do not remove a render node in use
Date: Thu, 29 Mar 2012 12:41:30 -0400	[thread overview]
Message-ID: <1333039298-2520-9-git-send-email-ihadzic@research.bell-labs.com> (raw)
In-Reply-To: <1333039298-2520-1-git-send-email-ihadzic@research.bell-labs.com>

Keep track of per-node open count and do not allow removal
of a render node in use.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
---
 drivers/gpu/drm/drm_fops.c |    2 ++
 drivers/gpu/drm/drm_stub.c |    2 ++
 include/drm/drmP.h         |    1 +
 3 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 4498d76..686236f 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -136,6 +136,7 @@ int drm_open(struct inode *inode, struct file *filp)
 	retcode = drm_open_helper(filp, minor);
 	if (!retcode) {
 		atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
+		minor->open_count++;
 		if (!dev->open_count++)
 			retcode = drm_setup(dev);
 	}
@@ -573,6 +574,7 @@ int drm_release(struct inode *inode, struct file *filp)
 	 */
 
 	atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
+	file_priv->minor->open_count--;
 	if (!--dev->open_count) {
 		if (atomic_read(&dev->ioctl_count)) {
 			DRM_ERROR("Device busy: %d\n",
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index fb241e6..aa4b34f 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -426,6 +426,8 @@ int drm_destroy_render_node(struct drm_device *dev, int index)
 
 	list_for_each_entry_safe(node, tmp, &dev->render_node_list, list) {
 		if (node->minor->index == index) {
+			if (node->minor->open_count)
+				return -EBUSY;
 			list_del(&node->list);
 			drm_put_minor(&node->minor);
 			kfree(node);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1131fd4..981f005 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -983,6 +983,7 @@ struct drm_info_node {
 struct drm_minor {
 	int index;			/**< Minor device number */
 	int type;                       /**< Control or render */
+	int open_count;
 	dev_t device;			/**< Device number for mknod */
 	struct device kdev;		/**< Linux device */
 	struct drm_device *dev;
-- 
1.7.8.5

  parent reply	other threads:[~2012-03-29 16:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 16:41 [RFC] Revive the work on render-nodes branch Ilija Hadzic
2012-03-29 16:41 ` [PATCH 01/16] drm: do not push inode down into drm_open_helper Ilija Hadzic
2012-03-29 16:41 ` [PATCH 02/16] drm: move dev_mapping to the minor node Ilija Hadzic
2012-03-29 16:41 ` [PATCH 03/16] drm: add support for render nodes Ilija Hadzic
2012-03-29 16:41 ` [PATCH 04/16] drm: initial multiple nodes ioctl work Ilija Hadzic
2012-03-29 17:15   ` Ville Syrjälä
2012-03-29 17:22     ` Ilija Hadzic
2012-03-29 18:01       ` Ville Syrjälä
2012-03-29 16:41 ` [PATCH 05/16] drm: separate render node descriptor from minor Ilija Hadzic
2012-03-29 16:41 ` [PATCH 06/16] drm: cleanup render node ioctls Ilija Hadzic
2012-03-29 16:41 ` [PATCH 07/16] drm: only allow render node ioctls through control node Ilija Hadzic
2012-03-29 16:41 ` Ilija Hadzic [this message]
2012-03-29 16:41 ` [PATCH 09/16] drm: allocate correct id_list size for a render node Ilija Hadzic
2012-03-29 16:41 ` [PATCH 10/16] drm: add drm_mode_group_fini function Ilija Hadzic
2012-03-29 16:41 ` [PATCH 11/16] drm: properly free id_list when a render node is removed Ilija Hadzic
2012-03-29 16:41 ` [PATCH 12/16] drm: call drm_mode_group_fini on primary node Ilija Hadzic
2012-03-29 16:41 ` [PATCH 13/16] drm: more elaborate check for num_crtc/encoder/connector Ilija Hadzic
2012-03-29 16:41 ` [PATCH 14/16] drm: validate id list when creating a render node Ilija Hadzic
2012-03-29 16:41 ` [PATCH 15/16] drm: keep track of which node holds which resource Ilija Hadzic
2012-03-29 16:41 ` [PATCH 16/16] drm: hold mutex in critical sections of render-node code Ilija Hadzic
2012-03-29 17:16 ` [RFC] Revive the work on render-nodes branch Ville Syrjälä

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=1333039298-2520-9-git-send-email-ihadzic@research.bell-labs.com \
    --to=ihadzic@research.bell-labs.com \
    --cc=dri-devel@lists.freedesktop.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.