All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: serialize access to debugs_nodes.list
@ 2011-10-30 22:04 Marcin Slusarz
  2011-10-31  8:06 ` Daniel Vetter
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Slusarz @ 2011-10-30 22:04 UTC (permalink / raw)
  To: dri-devel; +Cc: nouveau

Nouveau, when configured with debugfs, creates debugfs files for every
channel, so structure holding list of files needs to be protected from
simultaneous changes by multiple threads.

Without this patch it's possible to hit kernel oops in
drm_debugfs_remove_files just by running a couple of xterms with
looped glxinfo.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
---
 drivers/gpu/drm/drm_debugfs.c |    5 +++++
 include/drm/drmP.h            |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 9d2668a..1144fbe 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -120,7 +120,9 @@ int drm_debugfs_create_files(struct drm_info_list *files, int count,
 		tmp->minor = minor;
 		tmp->dent = ent;
 		tmp->info_ent = &files[i];
+		mutex_lock(&minor->debugfs_nodes.mutex);
 		list_add(&(tmp->list), &(minor->debugfs_nodes.list));
+		mutex_unlock(&minor->debugfs_nodes.mutex);
 	}
 	return 0;
 
@@ -149,6 +151,7 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 	int ret;
 
 	INIT_LIST_HEAD(&minor->debugfs_nodes.list);
+	mutex_init(&minor->debugfs_nodes.mutex);
 	sprintf(name, "%d", minor_id);
 	minor->debugfs_root = debugfs_create_dir(name, root);
 	if (!minor->debugfs_root) {
@@ -194,6 +197,7 @@ int drm_debugfs_remove_files(struct drm_info_list *files, int count,
 	struct drm_info_node *tmp;
 	int i;
 
+	mutex_lock(&minor->debugfs_nodes.mutex);
 	for (i = 0; i < count; i++) {
 		list_for_each_safe(pos, q, &minor->debugfs_nodes.list) {
 			tmp = list_entry(pos, struct drm_info_node, list);
@@ -204,6 +208,7 @@ int drm_debugfs_remove_files(struct drm_info_list *files, int count,
 			}
 		}
 	}
+	mutex_unlock(&minor->debugfs_nodes.mutex);
 	return 0;
 }
 EXPORT_SYMBOL(drm_debugfs_remove_files);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 9b7c2bb..c70c943 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -970,6 +970,7 @@ struct drm_info_list {
  * debugfs node structure. This structure represents a debugfs file.
  */
 struct drm_info_node {
+	struct mutex mutex;
 	struct list_head list;
 	struct drm_minor *minor;
 	struct drm_info_list *info_ent;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-09 21:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-30 22:04 [PATCH] drm: serialize access to debugs_nodes.list Marcin Slusarz
2011-10-31  8:06 ` Daniel Vetter
2011-10-31 17:00   ` Marcin Slusarz
2011-10-31 17:33     ` [PATCH] drm: serialize access to list of debugfs files Marcin Slusarz
2011-10-31 21:00       ` Daniel Vetter
2011-11-09 21:20         ` Marcin Slusarz

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.