Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3339664pxb; Sun, 26 Sep 2021 12:04:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ9LFKmn3slsb/fY0485IxpfsWMSfa1tDG2pNCzhBAXSIBags6aYTnF5XI/J411CuMFkcH X-Received: by 2002:a17:906:1b15:: with SMTP id o21mr23668831ejg.473.1632683047885; Sun, 26 Sep 2021 12:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632683047; cv=none; d=google.com; s=arc-20160816; b=OClB3RR36XQKLkjZ09dH1aQGHY/d8k4lpbDhKftqKw/2RHt/7IqT74eCDKRxFiNcQ1 Yto1fMJF6wpegf8ECB6aLHAm01g41N0Qv+FOXwuPXrCz4epo/4cPEroP3OX2Uon1ib/G DXi3MX7wEPw1oNfrQL6YJHoB9E+A+zKv56jvc1panfG48nXR1MYR7Y9mFFgRvyTKrKQ6 GRvqfiEkqoW+wPvHut/KmPAAvmSejhbzaiSI/Fnq1xL1aPmU+WvTUyjYbtkNcUGFnGSQ eHPqNFLK1IsWTyL1yQ5kZ05igwwax4LM2yjloVX60a2nenzMgNhSrkpgHcODO6T8QVpe aFRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=YpW3MI6iw3Oxd5NOrsE2ej3i7oWt4Lvf7C0mm1vXsEQ=; b=eRpmEIrkTYS8+E3lNy6iwaNL19eYcqK5vAFMjEKvvoI1OreaE9dHAYCLJGXPw+QNem au6jb7jm/vzWoemCiBq+Nk1ch2Fdp0VDdlcBaQUGpHfssZVhgxGVX7Rztn85UEJ4np4K Tk+ggXTOf2WRwqstveUg4Z2ZeZqQWzv3F/7qifkkir7rXAh6oBxcFJw49eX5WHV4EBEE oaBmdrjb9ozlMcMb3Vr0EBr95i5+EKDdEeHCtsNBs7QJEUnp6t0CZyQ2zKhif/n6xUY4 mTsfXtfNVSr/mogl176w8pUYPo5QVKG5QX3QOOZQKwO/062osvIrOcaX7fMQGnt3+cT0 O3sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X0rbqYOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si7083846eda.546.2021.09.26.12.03.43; Sun, 26 Sep 2021 12:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X0rbqYOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhIZTCw (ORCPT + 99 others); Sun, 26 Sep 2021 15:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbhIZTCu (ORCPT ); Sun, 26 Sep 2021 15:02:50 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F62DC061570; Sun, 26 Sep 2021 12:01:14 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id g2so9665778pfc.6; Sun, 26 Sep 2021 12:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YpW3MI6iw3Oxd5NOrsE2ej3i7oWt4Lvf7C0mm1vXsEQ=; b=X0rbqYOiPa8TR+xNbKQ11zADEYeGWxHP8OrJ6G2orV+nrn4Y5kg47k6ijU9zijsWf0 qEPDgpYVkCkU1T/snvGOIFcLFQcDb7Zep2AxLIOX5obxq6Dv4QLHg/SfdzlY4fqVNex7 klkvLSVc8ApN6L9RY2fTs11WLvhHwp3rIT2amnqsnQIEtsgF6Jez/gAi7ebTegxyOEtf QCVk8VFA4UD6ua1YKS8riL4/kAHEc+X2ZWo+sHXDhwKgMsgWjmh8XHT1vROTrvR+zpgF 5j7MtQvIbP1VhY/9nuPeI2v5QbpQkZ9wk/hTnkxLcn+++qJQzcgotbUB/6q/ggBo+1Na oE/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YpW3MI6iw3Oxd5NOrsE2ej3i7oWt4Lvf7C0mm1vXsEQ=; b=unnFgaXsepgdjwt3+Z8PKvrXKyi9IMUKVLFj4+MjPIeZU4KA5jH7dw9qI/mggLJHWy cqinPgDy9vBSDNMUvrB/WSLZGehydC1uODmsUCrfoZU42/4vfbzxSW6YB8HFx3QYBvgJ s+rzex1dyTWJm5PVnSJkQrRPXb7XOXK+bXwo0ech8lw6544K5nCQIgCFehCBmGo7Jx0Y AwR/Q8tbI3FtIvWvoMphdOIHwRGZfPl7PEgZdGbtkS/Y5G+QI3m0SClBVyn6PABqa/LE xE+w6RTivqKcv/n+dloOCfO8cvDjHDYTWREP6e2/n9FV03IcynKnPxQlT2Laz+BsvRZn Yzgg== X-Gm-Message-State: AOAM530CcVawLJO0ZfBDXM0tzMu7Qy3Y2clxGLn+fABbAsVaGtyclxsv 2Sr8+/5EUsGe/H8wg93urqI= X-Received: by 2002:a63:7784:: with SMTP id s126mr13408029pgc.264.1632682873670; Sun, 26 Sep 2021 12:01:13 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id q4sm9781104pfl.50.2021.09.26.12.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:01:12 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Rob Clark , Steev Klimaszewski , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , =?UTF-8?q?Christian=20K=C3=B6nig?= , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/msm: Fix crash on dev file close Date: Sun, 26 Sep 2021 12:05:54 -0700 Message-Id: <20210926190554.761482-1-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Clark If the device file was opened prior to fw being available (such as from initrd before rootfs is mounted, when the initrd does not contain GPU fw), that would cause a later crash when the dev file is closed due to unitialized submitqueues list: CPU: 4 PID: 263 Comm: plymouthd Tainted: G W 5.15.0-rc2-next-20210924 #2 Hardware name: LENOVO 81JL/LNVNB161216, BIOS 9UCN33WW(V2.06) 06/ 4/2019 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : msm_submitqueue_close+0x30/0x190 [msm] lr : msm_postclose+0x54/0xf0 [msm] sp : ffff80001074bb80 x29: ffff80001074bb80 x28: ffff03ad80c4db80 x27: ffff03ad80dc5ab0 x26: 0000000000000000 x25: ffff03ad80dc5af8 x24: ffff03ad81e90800 x23: 0000000000000000 x22: ffff03ad81e90800 x21: ffff03ad8b35e788 x20: ffff03ad81e90878 x19: 0000000000000000 x18: 0000000000000000 x17: 0000000000000000 x16: ffffda15f14f7940 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000001 x12: 0000000000000040 x11: 0000000000000000 x10: 0000000000000000 x9 : ffffda15cd18ff88 x8 : ffff03ad80c4db80 x7 : 0000000000000228 x6 : 0000000000000000 x5 : 1793a4e807e636bd x4 : ffff03ad80c4db80 x3 : ffff03ad81e90878 x2 : 0000000000000000 x1 : ffff03ad80c4db80 x0 : 0000000000000000 Call trace: msm_submitqueue_close+0x30/0x190 [msm] msm_postclose+0x54/0xf0 [msm] drm_file_free.part.0+0x1cc/0x2e0 [drm] drm_close_helper.isra.0+0x74/0x84 [drm] drm_release+0x78/0x120 [drm] __fput+0x78/0x23c ____fput+0x1c/0x30 task_work_run+0xcc/0x22c do_exit+0x304/0x9f4 do_group_exit+0x44/0xb0 __wake_up_parent+0x0/0x3c invoke_syscall+0x50/0x120 el0_svc_common.constprop.0+0x4c/0xf4 do_el0_svc+0x30/0x9c el0_svc+0x20/0x60 el0t_64_sync_handler+0xe8/0xf0 el0t_64_sync+0x1a0/0x1a4 Code: aa0003f5 a90153f3 f8408eb3 aa1303e0 (f85e8674) ---[ end trace 39b2fa37509a2be2 ]--- Fixing recursive fault but reboot is needed! Fixes: 86c2a0f000c1 drm/msm: ("Small submitqueue creation cleanup") Reported-by: Steev Klimaszewski Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 3 +++ drivers/gpu/drm/msm/msm_submitqueue.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index f350de754f84..938765ad7109 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -689,6 +689,9 @@ static int context_init(struct drm_device *dev, struct drm_file *file) if (!ctx) return -ENOMEM; + INIT_LIST_HEAD(&ctx->submitqueues); + rwlock_init(&ctx->queuelock); + kref_init(&ctx->ref); msm_submitqueue_init(dev, ctx); diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c index 32a55d81b58b..7ce0771b5582 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -140,10 +140,6 @@ int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx) */ default_prio = DIV_ROUND_UP(max_priority, 2); - INIT_LIST_HEAD(&ctx->submitqueues); - - rwlock_init(&ctx->queuelock); - return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL); } -- 2.31.1