From patchwork Mon Mar 5 16:48:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 7092 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 9C3EA23DC3 for ; Mon, 5 Mar 2012 16:49:10 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 63791A18182 for ; Mon, 5 Mar 2012 16:49:10 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so7746420iag.11 for ; Mon, 05 Mar 2012 08:49:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.147.199 with SMTP id o7mr11441523icv.50.1330966150164; Mon, 05 Mar 2012 08:49:10 -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.231.53.18 with SMTP id k18csp30877ibg; Mon, 5 Mar 2012 08:49:09 -0800 (PST) Received: by 10.236.195.38 with SMTP id o26mr6005795yhn.100.1330966149204; Mon, 05 Mar 2012 08:49:09 -0800 (PST) Received: from mail-gy0-f178.google.com (mail-gy0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id d9si16881028yhn.135.2012.03.05.08.49.09 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Mar 2012 08:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-gy0-f178.google.com with SMTP id f1so2032935ghb.37 for ; Mon, 05 Mar 2012 08:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 10.101.138.33 as permitted sender) client-ip=10.101.138.33; Received: from mr.google.com ([10.101.138.33]) by 10.101.138.33 with SMTP id q33mr8595214ann.76.1330966149030 (num_hops = 1); Mon, 05 Mar 2012 08:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=7HjNC9pALaFdBkbESLjZO8lV3GH57cEPeAFUUkR4+sM=; b=qYCeiVF3owkx+v3/EFJ+Iec3P4JzZmS/GMOoYX4pjwRKHlQ1hyTNjzG4eum/uTjW8d hWuZBJaM/W/9WQgtBoEbK6gV1kgcFk6AVL25RMUU1EvD21tht3cMCeNNTCNPRLoyMmgK 3GESwQXMpl8vxwM4Wgq7xlWHCCqphsY0AtALVg+/AnHomQt3In0yzQEOScp+b12P2Q2s HyAwRkQFHUXzitwVNMd/Lac37ezgyc5l8CROZWyzpg3aFf2AVo4a2Zj09vYhFYxszqV1 Bp2JoPiuy7XfyOFBiwHIaklJiuZdkP4UKnwTaKJYClU0f/P1ZDIiulDqBUDym+jYdY6L lZIg== Received: by 10.101.138.33 with SMTP id q33mr6792892ann.76.1330966148873; Mon, 05 Mar 2012 08:49:08 -0800 (PST) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id k16sm25339382anm.18.2012.03.05.08.49.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Mar 2012 08:49:07 -0800 (PST) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Cc: patches@linaro.org, Greg KH , Tomi Valkeinen , Andy Gross , Rob Clark Subject: [PATCH 03/10] staging: drm/omap: call omap_gem_roll() in non-atomic ctx Date: Mon, 5 Mar 2012 10:48:33 -0600 Message-Id: <1330966120-28582-4-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1330966120-28582-1-git-send-email-rob.clark@linaro.org> References: <1330966120-28582-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQnlzh7n8913QPx9PwW9MwSvxX3ycsIeAvtRz+r5NPd0ODLQUZ6vbZtC/B1YNMAmConBSHZm From: Rob Clark If fbcon calls us from atomic context, push the work off to the workqueue to avoid calling into the gem/dmm code in an atomic context. Signed-off-by: Rob Clark --- drivers/staging/omapdrm/omap_fbdev.c | 26 ++++++++++++++++++++++---- drivers/staging/omapdrm/omap_gem.c | 14 ++------------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/omapdrm/omap_fbdev.c b/drivers/staging/omapdrm/omap_fbdev.c index 96940bb..11acd4c 100644 --- a/drivers/staging/omapdrm/omap_fbdev.c +++ b/drivers/staging/omapdrm/omap_fbdev.c @@ -37,6 +37,9 @@ struct omap_fbdev { struct drm_framebuffer *fb; struct drm_gem_object *bo; bool ywrap_enabled; + + /* for deferred dmm roll when getting called in atomic ctx */ + struct work_struct work; }; static void omap_fbdev_flush(struct fb_info *fbi, int x, int y, int w, int h); @@ -75,12 +78,22 @@ static void omap_fbdev_imageblit(struct fb_info *fbi, image->width, image->height); } +static void pan_worker(struct work_struct *work) +{ + struct omap_fbdev *fbdev = container_of(work, struct omap_fbdev, work); + struct fb_info *fbi = fbdev->base.fbdev; + int npages; + + /* DMM roll shifts in 4K pages: */ + npages = fbi->fix.line_length >> PAGE_SHIFT; + omap_gem_roll(fbdev->bo, fbi->var.yoffset * npages); +} + static int omap_fbdev_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi) { struct drm_fb_helper *helper = get_fb(fbi); struct omap_fbdev *fbdev = to_omap_fbdev(helper); - int npages; if (!helper) goto fallback; @@ -88,9 +101,12 @@ static int omap_fbdev_pan_display(struct fb_var_screeninfo *var, if (!fbdev->ywrap_enabled) goto fallback; - /* DMM roll shifts in 4K pages: */ - npages = fbi->fix.line_length >> PAGE_SHIFT; - omap_gem_roll(fbdev->bo, var->yoffset * npages); + if (drm_can_sleep()) { + pan_worker(&fbdev->work); + } else { + struct omap_drm_private *priv = helper->dev->dev_private; + queue_work(priv->wq, &fbdev->work); + } return 0; @@ -336,6 +352,8 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) goto fail; } + INIT_WORK(&fbdev->work, pan_worker); + helper = &fbdev->base; helper->funcs = &omap_fb_helper_funcs; diff --git a/drivers/staging/omapdrm/omap_gem.c b/drivers/staging/omapdrm/omap_gem.c index b7d6f88..bd35520 100644 --- a/drivers/staging/omapdrm/omap_gem.c +++ b/drivers/staging/omapdrm/omap_gem.c @@ -566,6 +566,8 @@ fail: /* Set scrolling position. This allows us to implement fast scrolling * for console. + * + * Call only from non-atomic contexts. */ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll) { @@ -580,18 +582,6 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll) 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 */