From patchwork Fri Dec 16 17:34:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 5831 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E23E623E10 for ; Fri, 16 Dec 2011 17:34:39 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id CB7BDA184E6 for ; Fri, 16 Dec 2011 17:34:39 +0000 (UTC) Received: by eaak10 with SMTP id k10so3906648eaa.11 for ; Fri, 16 Dec 2011 09:34:39 -0800 (PST) Received: by 10.205.120.135 with SMTP id fy7mr3290368bkc.54.1324056879463; Fri, 16 Dec 2011 09:34:39 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.173.131 with SMTP id p3cs463bkz; Fri, 16 Dec 2011 09:34:38 -0800 (PST) Received: by 10.220.155.3 with SMTP id q3mr4760913vcw.36.1324056876897; Fri, 16 Dec 2011 09:34:36 -0800 (PST) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by mx.google.com with ESMTPS id l30si9354724yhm.6.2011.12.16.09.34.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Dec 2011 09:34:36 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) client-ip=209.85.213.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by yenm5 with SMTP id m5so2562949yen.37 for ; Fri, 16 Dec 2011 09:34:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=SEhcyRIp3cP2fe3XYg0aOPecXvkqMB3CiiP5Tk4KUw0=; b=NpvdOMFzx+0k0SMXdNniqJQERARDosrMUSM2JZioeY6LPI1k/kelwO3I7w/33vBTde 5pGYBvA0yCXwT7lbpgQOX6cxrYUe6NzcNKnB5HucYzptV9nQpU1AZ1wVuc+VMBBtt78m 7gVV+W+uy3j+2N2ipgW0G6elHcXRy5SVHp41k= Received: by 10.101.213.31 with SMTP id p31mr4087764anq.57.1324056876414; Fri, 16 Dec 2011 09:34:36 -0800 (PST) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id u47sm15233220yhl.0.2011.12.16.09.34.35 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Dec 2011 09:34:35 -0800 (PST) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, Greg KH , Tomi Valkeinen , Rob Clark Subject: [PATCH] drm/omap: avoid aquiring mutex in atomic context (v2) Date: Fri, 16 Dec 2011 11:34:34 -0600 Message-Id: <1324056874-10635-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: From: Rob Clark omap_gem_roll() could be called by fbcon in atomic context or when struct_mutext is held. Avoid aquiring mutex (deadlock), or calling tiler_pin() (which itself is not safe for atomic context) in these cases. Signed-off-by: Rob Clark --- drivers/staging/omapdrm/omap_gem.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/staging/omapdrm/omap_gem.c b/drivers/staging/omapdrm/omap_gem.c index 9684891..63490f7 100644 --- a/drivers/staging/omapdrm/omap_gem.c +++ b/drivers/staging/omapdrm/omap_gem.c @@ -538,10 +538,22 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll) return -EINVAL; } - mutex_lock(&obj->dev->struct_mutex); - omap_obj->roll = roll; + if (in_atomic() || mutex_is_locked(&obj->dev->struct_mutex)) { + /* this can get called from fbcon in atomic context.. so + * just ignore it and wait for next time called from + * interruptible context to update the PAT.. the result + * may be that user sees wrap-around instead of scrolling + * momentarily on the screen. If we wanted to be fancier + * we could perhaps schedule some workqueue work at this + * point. + */ + return 0; + } + + mutex_lock(&obj->dev->struct_mutex); + /* if we aren't mapped yet, we don't need to do anything */ if (omap_obj->block) { struct page **pages;