From: Greg Kroah-Hartman Date: Wed, 7 Nov 2012 08:42:10 +0000 (+0100) Subject: 3.6-stable patches X-Git-Tag: v3.0.52~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f660c16b42dcfe5cbdba2ad9e3198bfc0340a645;p=thirdparty%2Fkernel%2Fstable-queue.git 3.6-stable patches added patches: drm-restore-open_count-if-drm_setup-fails.patch drm-set-dev_mapping-before-calling-drm_open_helper.patch --- diff --git a/queue-3.6/drm-restore-open_count-if-drm_setup-fails.patch b/queue-3.6/drm-restore-open_count-if-drm_setup-fails.patch new file mode 100644 index 00000000000..6abf32cda6e --- /dev/null +++ b/queue-3.6/drm-restore-open_count-if-drm_setup-fails.patch @@ -0,0 +1,37 @@ +From 0f1cb1bd94a9c967cd4ad3de51cfdabe61eb5dcc Mon Sep 17 00:00:00 2001 +From: Ilija Hadzic +Date: Mon, 29 Oct 2012 17:35:00 +0000 +Subject: drm: restore open_count if drm_setup fails + +From: Ilija Hadzic + +commit 0f1cb1bd94a9c967cd4ad3de51cfdabe61eb5dcc upstream. + +If drm_setup (called at first open) fails, the whole +open call has failed, so we should not keep the +open_count incremented. + +Signed-off-by: Ilija Hadzic +Reviewed-by: Thomas Hellstrom +Signed-off-by: Dave Airlie +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/drm_fops.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/drm_fops.c ++++ b/drivers/gpu/drm/drm_fops.c +@@ -135,8 +135,11 @@ int drm_open(struct inode *inode, struct + retcode = drm_open_helper(inode, filp, dev); + if (!retcode) { + atomic_inc(&dev->counts[_DRM_STAT_OPENS]); +- if (!dev->open_count++) ++ if (!dev->open_count++) { + retcode = drm_setup(dev); ++ if (retcode) ++ dev->open_count--; ++ } + } + if (!retcode) { + mutex_lock(&dev->struct_mutex); diff --git a/queue-3.6/drm-set-dev_mapping-before-calling-drm_open_helper.patch b/queue-3.6/drm-set-dev_mapping-before-calling-drm_open_helper.patch new file mode 100644 index 00000000000..7f4888302c6 --- /dev/null +++ b/queue-3.6/drm-set-dev_mapping-before-calling-drm_open_helper.patch @@ -0,0 +1,92 @@ +From fdb40a08ef7bc970899c3a1f471165f9c22763a1 Mon Sep 17 00:00:00 2001 +From: Ilija Hadzic +Date: Mon, 29 Oct 2012 17:35:01 +0000 +Subject: drm: set dev_mapping before calling drm_open_helper + +From: Ilija Hadzic + +commit fdb40a08ef7bc970899c3a1f471165f9c22763a1 upstream. + +Some drivers (specifically vmwgfx) look at dev_mapping +in their open hook, so we have to set dev->dev_mapping +earlier in the process. + +Reference: +http://lists.freedesktop.org/archives/dri-devel/2012-October/029420.html + +Signed-off-by: Ilija Hadzic +Reported-by: Thomas Hellstrom +Reviewed-by: Thomas Hellstrom +Signed-off-by: Dave Airlie +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/drm_fops.c | 47 ++++++++++++++++++++++++++++----------------- + 1 file changed, 30 insertions(+), 17 deletions(-) + +--- a/drivers/gpu/drm/drm_fops.c ++++ b/drivers/gpu/drm/drm_fops.c +@@ -121,6 +121,8 @@ int drm_open(struct inode *inode, struct + int minor_id = iminor(inode); + struct drm_minor *minor; + int retcode = 0; ++ int need_setup = 0; ++ struct address_space *old_mapping; + + minor = idr_find(&drm_minors_idr, minor_id); + if (!minor) +@@ -132,26 +134,37 @@ int drm_open(struct inode *inode, struct + if (drm_device_is_unplugged(dev)) + return -ENODEV; + ++ if (!dev->open_count++) ++ need_setup = 1; ++ mutex_lock(&dev->struct_mutex); ++ old_mapping = dev->dev_mapping; ++ if (old_mapping == NULL) ++ dev->dev_mapping = &inode->i_data; ++ /* ihold ensures nobody can remove inode with our i_data */ ++ ihold(container_of(dev->dev_mapping, struct inode, i_data)); ++ inode->i_mapping = dev->dev_mapping; ++ filp->f_mapping = dev->dev_mapping; ++ mutex_unlock(&dev->struct_mutex); ++ + retcode = drm_open_helper(inode, filp, dev); +- if (!retcode) { +- atomic_inc(&dev->counts[_DRM_STAT_OPENS]); +- if (!dev->open_count++) { +- retcode = drm_setup(dev); +- if (retcode) +- dev->open_count--; +- } +- } +- if (!retcode) { +- mutex_lock(&dev->struct_mutex); +- if (dev->dev_mapping == NULL) +- dev->dev_mapping = &inode->i_data; +- /* ihold ensures nobody can remove inode with our i_data */ +- ihold(container_of(dev->dev_mapping, struct inode, i_data)); +- inode->i_mapping = dev->dev_mapping; +- filp->f_mapping = dev->dev_mapping; +- mutex_unlock(&dev->struct_mutex); ++ if (retcode) ++ goto err_undo; ++ atomic_inc(&dev->counts[_DRM_STAT_OPENS]); ++ if (need_setup) { ++ retcode = drm_setup(dev); ++ if (retcode) ++ goto err_undo; + } ++ return 0; + ++err_undo: ++ mutex_lock(&dev->struct_mutex); ++ filp->f_mapping = old_mapping; ++ inode->i_mapping = old_mapping; ++ iput(container_of(dev->dev_mapping, struct inode, i_data)); ++ dev->dev_mapping = old_mapping; ++ mutex_unlock(&dev->struct_mutex); ++ dev->open_count--; + return retcode; + } + EXPORT_SYMBOL(drm_open); diff --git a/queue-3.6/series b/queue-3.6/series index b94c40a7aad..ae73b16a161 100644 --- a/queue-3.6/series +++ b/queue-3.6/series @@ -31,3 +31,5 @@ nfsv4.1-we-must-release-the-sequence-id-when-we-fail-to-get-a-session-slot.patch nfs-wait-for-session-recovery-to-finish-before-returning.patch nfs-fix-bug-in-legacy-dns-resolver.patch batman-adv-fix-broadcast-packet-crc-calculation.patch +drm-restore-open_count-if-drm_setup-fails.patch +drm-set-dev_mapping-before-calling-drm_open_helper.patch