From patchwork Wed May 31 07:58:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 101264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2715661vqr; Wed, 31 May 2023 01:19:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+JfYOBTcBj/1V8Uw1geIpmudkt2fi5ITqmPlt0OLyKi40twJsbHZmUE5E+3kjRUmOxBZv X-Received: by 2002:a17:902:b18a:b0:1af:bae0:6be7 with SMTP id s10-20020a170902b18a00b001afbae06be7mr11562488plr.10.1685521182331; Wed, 31 May 2023 01:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685521182; cv=none; d=google.com; s=arc-20160816; b=ZR/a1J9mp7L5Y1NS99Svzb+ihToIdUNSubS3Kijx9Ly5zFZqm3haRZ3OyXg+MWT7UJ BXhYIwzr1na4RJpmsxtq4yW7A14M06TmySgYWPDWU8TalQBqkCdSjxrVB5uscZ4wLRiX g6iuCDfLDCfH798funogXCKAO2iPkAhQ9eqzJPkP7QK0i3kKE33DjxAifXiPXOiv+ebG RR6VpLofLBl1/jQkEmHtFjXvtQjEr5XWUJIeJDXWobGhvNqlKNxR2crIflLxcM22KG+C GaBVrS6hfJQ/niTLIYzCYoxRI/V0szsgUD6O/xUJ807JvmiD12KsdL1xbNP8ImXxAqBo bmlA== 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=7HJ2HfEOnW+XCRqJH0fmCG9N4JKQnJkKXTs3jnp0tEo=; b=wgMlJNCIFIaP9XeYVhILNnGqGhCrjG7rBkX7s9+vBGI3u+mSIw44/FGppVPgXlZLyM CVWGYKVCgQezUU731L0oBc9p18Ql27amxTUt7vvMrY5bceSP26ytZKcZ8HJqL/QJHx0Z 2sl+V8x7vJyqiuhGDxuskKYurrFH0P74eqUTDTfBtrUsVXx0lAHqzSMZ/RrdOSc0vBPn RTYlWK96qNgdYxEz2k4XFtzMOZmUS/Ee/dNclgC12JfAw1KYsGCgvD4XURRUSOFLDU3p bTzQ2K0q9OQxM3mq83mTtNFcNfQwMnkCteXW8y43Vqi7tHHObMWn44G3hWpA3/ZW0Bml LuUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FiW9J8LH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k196-20020a636fcd000000b0051b15b58764si593847pgc.343.2023.05.31.01.19.29; Wed, 31 May 2023 01:19:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FiW9J8LH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235005AbjEaIBO (ORCPT + 99 others); Wed, 31 May 2023 04:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235453AbjEaIAo (ORCPT ); Wed, 31 May 2023 04:00:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6810EE77; Wed, 31 May 2023 01:00:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F00E1637C4; Wed, 31 May 2023 08:00:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5705CC433EF; Wed, 31 May 2023 08:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685520017; bh=c6Duq3c+yZHkdCZ4H7pQzdV4qKMi9g8iw8iuvGIfvk0=; h=From:To:Cc:Subject:Date:From; b=FiW9J8LHcud0gneuOakQNXig/Xsx+xPjtCWFvOaZcHDQTWYbvnnteZgvxwbvqw+Xz QrZc3kTX9J4JiSvhiEvjNF9D077T38NMgxOPLQsZ14OKsHmirvs4CWUu+k6fn67jMp /sk8SEhiIIYhLEh7FGhTlulJoJHmdHd3Uznxo7Tvt+cDEQvS3vo/FAiqmjP7GyTCRT 4dUeUppARvJQl6F67wOoCSnkjZgYYt6M3iVgoGrS3EMdyx9YfF95Q7O3B4mUA55zua +DzTZ3EA3mC7GuREpicd28R07bgEuKZUTDF7HmSxntqitc+OygLOsKeA6zfZUaDuYU VXpCNH0Pa6aKQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1q4Gkm-0000CD-LB; Wed, 31 May 2023 10:00:20 +0200 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Douglas Anderson Subject: [PATCH] drm/msm/a6xx: fix uninitialised lock in init error path Date: Wed, 31 May 2023 09:58:54 +0200 Message-Id: <20230531075854.703-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767397059536652343?= X-GMAIL-MSGID: =?utf-8?q?1767397059536652343?= A recent commit started taking the GMU lock in the GPU destroy path, which on GPU initialisation failure is called before the GMU and its lock have been initialised. Make sure that the GMU has been initialised before taking the lock in a6xx_destroy() and drop the now redundant check from a6xx_gmu_remove(). Fixes: 4cd15a3e8b36 ("drm/msm/a6xx: Make GPU destroy a bit safer") Cc: stable@vger.kernel.org # 6.3 Cc: Douglas Anderson Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 3 --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 9 ++++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index e16b4b3f8535..105ccf17041f 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1472,9 +1472,6 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) struct a6xx_gmu *gmu = &a6xx_gpu->gmu; struct platform_device *pdev = to_platform_device(gmu->dev); - if (!gmu->initialized) - return; - pm_runtime_force_suspend(gmu->dev); /* diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 9fb214f150dd..ee47b95a0205 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -1684,6 +1684,7 @@ static void a6xx_destroy(struct msm_gpu *gpu) { struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu); + struct a6xx_gmu *gmu = &a6xx_gpu->gmu; if (a6xx_gpu->sqe_bo) { msm_gem_unpin_iova(a6xx_gpu->sqe_bo, gpu->aspace); @@ -1697,9 +1698,11 @@ static void a6xx_destroy(struct msm_gpu *gpu) a6xx_llc_slices_destroy(a6xx_gpu); - mutex_lock(&a6xx_gpu->gmu.lock); - a6xx_gmu_remove(a6xx_gpu); - mutex_unlock(&a6xx_gpu->gmu.lock); + if (gmu->initialized) { + mutex_lock(&gmu->lock); + a6xx_gmu_remove(a6xx_gpu); + mutex_unlock(&gmu->lock); + } adreno_gpu_cleanup(adreno_gpu);