From patchwork Mon Aug 19 16:12:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 171653 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3197909ily; Mon, 19 Aug 2019 09:12:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkrW0qHo3EweUQ0Hv2Ev3C5EjVInAZDkLmUmZ1VzFSlps5IS1+I8twNGj2c9fJHV6XrdbI X-Received: by 2002:a65:68c8:: with SMTP id k8mr20392199pgt.192.1566231142804; Mon, 19 Aug 2019 09:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566231142; cv=none; d=google.com; s=arc-20160816; b=gI4N6Jbrk12F6fpYIhq0zpXgx5/yMVTj8Nu3Z4wTKDWqvOjrJlRtmFtmGJwcOilKs1 mN+kCeiVWleM6xZZIhlhH0vYqXdPxnJ6M0bD3gECQz/w9rPcbpXGDQbw+ewOx+fAPGF+ LSXsYNQx6oZeHon0Z3CK+hu7/g84XT4XnoHt3QfooDA74/9L+XDmdcRgk/iWtUH8hTR0 nWOH+AJsqgN0oHhP5svuNxcesidi34emcMBkslKD36x1Qu2PcgPjECUJyghUTqwivwOi xM62nYYNjaZAMoDPbpNxuuq/33UZCtXL4yu7YEqaTjScJ6C20s+KFtRZG+0gX9sG9hAK xJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=Hehf3WGywgA9PHGL1xpGcS8tgW3ouqPmyGZAoFEYEEY=; b=WOxY00aOOEuYPu+emaoRFydmRF+2w6aPuIFGDvn0HsnCjzn1VGsUEBcAspudKiGNvd vPPX4HTh0usIiRDCSTEopKQ+DKxj2VQpeEKC/DRAg9M7rtzycL746qFGAp6gpwInK0Nq 6CFS+SXbOCvq4reItcJRAYV5eAWiA6vnMDKvMpuCXJf7cbTSjyDTKaVGNY7fT1CQo+zf QiT/J6DiBGih5Ctia2Op7RE3iZysuR2vKx8IfF7FRGvgUAGdRW8Yr6tHjOUWI8iaWTIh 1R0ke9Nbx/ASxBv4QVv3bh9fjF55JQcsKT/WyeECl2KCXypk9WnHz0oEkws+4tEdm1ZW IaHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id c10si9968845pgw.174.2019.08.19.09.12.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 09:12:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26B446E216; Mon, 19 Aug 2019 16:12:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 913276E1F4 for ; Mon, 19 Aug 2019 16:12:12 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id z3so5506617iog.0 for ; Mon, 19 Aug 2019 09:12:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FNgMoUuANjdtngNMgikfiFN/8UrV/9wNLIuF2chDYhI=; b=q9lXDIUP7RUhEAZWqyJolNk1SSOrD+BAJCUDdffTYI9nTzjFki8mVp58vZ5+RGR4iT 90Hqknvg2jWW7prj+4AufSI7RSKnccT1FcbLKHo93D57lGkMmIw8Yry18Qsjls7Jb9TQ 7nN+dCUh2yYCTVDPkA/+K1hwyI3rkSwtCjaOizIpY6HIgWV97za0k/A+YVOKZ7ZtbLpR bUUrn1TrNI/XosdcNg8Z6WFC2f3OsQrF1PrKi6PZikSYt27rQn5i9g6vKiSTPUHvPUFz 4qJSQ2z8k9bH4gzaJLM2g+sNPjLTtOkrGQDHqajrv1ePumxE5GBTxdOPsjaG7CERmQSe /tPQ== X-Gm-Message-State: APjAAAXDAhTYWurdHXWj2LXg3JO3f2QGU98tLy4WEJUKzF4cpyUKcmSX DsMEhEe7aaLdUWWfp6RQXxHCVvw= X-Received: by 2002:a5d:980d:: with SMTP id a13mr23539456iol.240.1566231131600; Mon, 19 Aug 2019 09:12:11 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id c19sm4770584ioi.22.2019.08.19.09.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 09:12:10 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/panfrost: Fix sleeping while atomic in panfrost_gem_open Date: Mon, 19 Aug 2019 11:12:04 -0500 Message-Id: <20190819161204.3106-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190819161204.3106-1-robh@kernel.org> References: <20190819161204.3106-1-robh@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Tomeu Vizoso , David Airlie , Sean Paul , Steven Price , Boris Brezillon , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We can't hold the mm_lock spinlock as panfrost_mmu_map() can sleep: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:909 in_atomic(): 1, irqs_disabled(): 0, pid: 974, name: glmark2-es2-drm 1 lock held by glmark2-es2-drm/974: CPU: 5 PID: 974 Comm: glmark2-es2-drm Tainted: G W L 5.3.0-rc1+ #94 Hardware name: 96boards Rock960 (DT) Call trace: dump_backtrace+0x0/0x130 show_stack+0x14/0x20 dump_stack+0xc4/0x10c ___might_sleep+0x158/0x228 __might_sleep+0x50/0x88 __mutex_lock+0x58/0x800 mutex_lock_interruptible_nested+0x1c/0x28 drm_gem_shmem_get_pages+0x24/0xa0 drm_gem_shmem_get_pages_sgt+0x48/0xd0 panfrost_mmu_map+0x38/0xf8 [panfrost] panfrost_gem_open+0xc0/0xd8 [panfrost] drm_gem_handle_create_tail+0xe8/0x198 drm_gem_handle_create+0x3c/0x50 panfrost_gem_create_with_handle+0x70/0xa0 [panfrost] panfrost_ioctl_create_bo+0x48/0x80 [panfrost] drm_ioctl_kernel+0xb8/0x110 drm_ioctl+0x244/0x3f0 do_vfs_ioctl+0xbc/0x910 ksys_ioctl+0x78/0xa8 __arm64_sys_ioctl+0x1c/0x28 el0_svc_common.constprop.0+0x90/0x168 el0_svc_handler+0x28/0x78 el0_svc+0x8/0xc Fixes: 68337d0b8644 ("drm/panfrost: Restructure the GEM object creation") Cc: Tomeu Vizoso Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_gem.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index e084bc4e9083..acb07fe06580 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -65,16 +65,18 @@ static int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_p spin_lock(&priv->mm_lock); ret = drm_mm_insert_node_generic(&priv->mm, &bo->node, size >> PAGE_SHIFT, align, color, 0); + spin_unlock(&priv->mm_lock); if (ret) - goto out; + return ret; if (!bo->is_heap) { ret = panfrost_mmu_map(bo); - if (ret) + if (ret) { + spin_lock(&priv->mm_lock); drm_mm_remove_node(&bo->node); + spin_unlock(&priv->mm_lock); + } } -out: - spin_unlock(&priv->mm_lock); return ret; }