From: "Thomas Hellström" <thomas@tungstengraphics.com>
To: Johannes Engel <jcnengel@googlemail.com>
Cc: dri-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1 repost #1] DRM: don't enable irqs in locking
Date: Wed, 13 Aug 2008 10:16:14 +0200 [thread overview]
Message-ID: <48A2984E.5050202@tungstengraphics.com> (raw)
In-Reply-To: <48A18EAB.40808@googlemail.com>
[-- Attachment #1: Type: text/plain, Size: 438 bytes --]
Johannes Engel wrote:
> Thomas Hellström wrote:
>> Yes, this bug could occur, but the remedy is not to use
>> spin_lock_irqsave() for lock_data::spinlock but to avoid calling
>> drm_lock_take with the drm_device::tasklet_lock held with irqs disabled.
>> I'll see if I can come up with a patch.
> Hi Thomas,
>
> any news on that so far?
>
> Cheers, Johannes
Hi!
Been on vacation.
Pls try the attached patch.
/Thomas
[-- Attachment #2: 0001-Don-t-call-the-vblank-tasklet-with-irqs-disabled.patch --]
[-- Type: text/plain, Size: 2775 bytes --]
>From af12ef4f6b4ca111d9a2ef45263ad89610498724 Mon Sep 17 00:00:00 2001
From: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date: Wed, 13 Aug 2008 10:04:21 +0200
Subject: [PATCH] Don't call the vblank tasklet with irqs disabled.
If a specific tasklet shares data with irq context,
it needs to take a private irq-blocking spinlock within
the tasklet itself.
Signed-off-by: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
---
linux-core/drm_irq.c | 20 ++++++++++++--------
linux-core/drm_lock.c | 12 +++++-------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c
index 5b9f474..57419ca 100644
--- a/linux-core/drm_irq.c
+++ b/linux-core/drm_irq.c
@@ -705,27 +705,31 @@ static void drm_locked_tasklet_func(unsigned long data)
{
struct drm_device *dev = (struct drm_device *)data;
unsigned long irqflags;
-
+ void (*tasklet_func)(struct drm_device *);
+
spin_lock_irqsave(&dev->tasklet_lock, irqflags);
+ tasklet_func = dev->locked_tasklet_func;
+ spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
- if (!dev->locked_tasklet_func ||
+ if (!tasklet_func ||
!drm_lock_take(&dev->lock,
DRM_KERNEL_CONTEXT)) {
- spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
return;
}
dev->lock.lock_time = jiffies;
atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
- dev->locked_tasklet_func(dev);
+ spin_lock_irqsave(&dev->tasklet_lock, irqflags);
+ tasklet_func = dev->locked_tasklet_func;
+ dev->locked_tasklet_func = NULL;
+ spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
+
+ if (tasklet_func != NULL)
+ tasklet_func(dev);
drm_lock_free(&dev->lock,
DRM_KERNEL_CONTEXT);
-
- dev->locked_tasklet_func = NULL;
-
- spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
}
/**
diff --git a/linux-core/drm_lock.c b/linux-core/drm_lock.c
index a2966ef..cad2e44 100644
--- a/linux-core/drm_lock.c
+++ b/linux-core/drm_lock.c
@@ -155,6 +155,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
struct drm_lock *lock = data;
unsigned long irqflags;
+ void (*tasklet_func)(struct drm_device *);
if (lock->context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
@@ -163,14 +164,11 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
}
spin_lock_irqsave(&dev->tasklet_lock, irqflags);
-
- if (dev->locked_tasklet_func) {
- dev->locked_tasklet_func(dev);
-
- dev->locked_tasklet_func = NULL;
- }
-
+ tasklet_func = dev->locked_tasklet_func;
+ dev->locked_tasklet_func = NULL;
spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
+ if (tasklet_func != NULL)
+ tasklet_func(dev);
atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
--
1.5.4.3
next prev parent reply other threads:[~2008-08-13 8:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-25 8:42 [PATCH 1/1 repost #1] DRM: don't enable irqs in locking Jiri Slaby
2008-07-25 8:54 ` Dave Airlie
2008-07-28 20:32 ` Thomas Hellström
2008-07-29 7:31 ` Andrew Morton
2008-07-29 8:16 ` Dave Airlie
2008-08-12 13:22 ` Johannes Engel
2008-08-13 8:16 ` Thomas Hellström [this message]
2008-08-13 11:08 ` Johannes Engel
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=48A2984E.5050202@tungstengraphics.com \
--to=thomas@tungstengraphics.com \
--cc=dri-devel@lists.sourceforge.net \
--cc=jcnengel@googlemail.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox