Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp445247pxb; Thu, 9 Sep 2021 04:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi2q+r/eH4lpWNxrhDxBpstbbwLD5vJCFVcFkvtTt0xAXfgboSAtBRm7sxMPA6xq2iwwsl X-Received: by 2002:aa7:d610:: with SMTP id c16mr1464766edr.286.1631187968100; Thu, 09 Sep 2021 04:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631187968; cv=none; d=google.com; s=arc-20160816; b=iTmUEfOf/9ugT7Y4AsCRnXPZ8ZRveXkvt4uFE78FJ8jTB2muJ1w6fQaFe3TapbQT4y pYhvAzWgZktesEBOCua0oxAwBCrp7pz1cX+pyQv/8cStgCF3QVlL2NpDa6uKL4jVpQTo svtE4B9qMK2kVBTYalCC9oKuAoFESGkY8ObQccUWOGkZeMzSDcANyCY0eMT7BeZir9t8 9vYR3bjLC9/WaznJPTmhYAsov8V8a5iEwrNzMfoyKZ5rRWE4wfqEaT8UD1CkTXqwSF4Y ZvacnpRM639nS1T0dTZwa8JZqrsMwKRvY/sElKbSxdln3iZJ+7fSLz5//HP6zkYNewb4 W6kA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0TWBszD5WU1ZGk+vmA2FpdSIBsuZZPokgVNfRymfSxw=; b=sH8aHFwcqtlACTTImkjumhHMwHat47+3vVWGW5toP5OmhR7ugq663Tn3Fm1D7AAJHX X4ZqDVRR0H7VA8Pbso00pE5O6NssEtsEcHY6IjeWUsEWar3jNAt7BLaox06o5Jnc5CXO 0BZcdlH8yGSbuIZqefIM55Y7RxSBe3SqwLo8m9DDBmw78EFw6cfrvIStzQq8kiyXynXO Y0VfADbUnreFnfcVB1uSMsSbQYwf6IlIGlWDihyWk+Ha38OOgLJiEySLA+9QwQHDNTAI 1g8WTOFvDWLcHqFWbYAX3zrQwN9PP1ME+xs6dQPbm7icAYSFp4alY5V/y/7MIfoSWDrc T/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bTzzWY85; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si1409397ejn.102.2021.09.09.04.45.42; Thu, 09 Sep 2021 04:46:08 -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=@kernel.org header.s=k20201202 header.b=bTzzWY85; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236308AbhIILpV (ORCPT + 99 others); Thu, 9 Sep 2021 07:45:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238199AbhIILn3 (ORCPT ); Thu, 9 Sep 2021 07:43:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0EA3C611EF; Thu, 9 Sep 2021 11:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187724; bh=JU4iJc6oY871eBLmLglTyk8lAnK2nHC5KV9FVXhDFpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bTzzWY853UDUuBGirw9UAK+WL2djwmfur80CTjlaiqop9zK9yJdCQ2IKvSUWbKbIq RnzZ4m7AedRNNkLlWW8YMJjxrCW4xosSLbja3wayQBs8MfhOzDiQ7vsJCcGM4TK9Ay /KmZ47VHE3ArojEBa9GWUP5siA+8R/LwCkfDVdcypKwB7FMOMKJbCWOzviRzvhoGZS vyhkKRosuU9Ls5iNNWAdsXx/As75uCBfR/dSgyhjWwsTqQ8wWmS9v6v1nnv+KrrJuk zJ5Zz7L6OjhyfXmp08NYulZVUXB3PN5NOzy9wrl5C6ogT3UW8bbdzw9nH5p1hCG8oV ywjMNEmqMp87w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Geert Uytterhoeven , Greg Kroah-Hartman , Sasha Levin , linux-staging@lists.linux.dev Subject: [PATCH AUTOSEL 5.14 045/252] staging: board: Fix uninitialized spinlock when attaching genpd Date: Thu, 9 Sep 2021 07:37:39 -0400 Message-Id: <20210909114106.141462-45-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven [ Upstream commit df00609821bf17f50a75a446266d19adb8339d84 ] On Armadillo-800-EVA with CONFIG_DEBUG_SPINLOCK=y: BUG: spinlock bad magic on CPU#0, swapper/1 lock: lcdc0_device+0x10c/0x308, .magic: 00000000, .owner: /-1, .owner_cpu: 0 CPU: 0 PID: 1 Comm: swapper Not tainted 5.11.0-rc5-armadillo-00036-gbbca04be7a80-dirty #287 Hardware name: Generic R8A7740 (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (do_raw_spin_lock+0x20/0x94) [] (do_raw_spin_lock) from [] (dev_pm_get_subsys_data+0x8c/0x11c) [] (dev_pm_get_subsys_data) from [] (genpd_add_device+0x78/0x2b8) [] (genpd_add_device) from [] (of_genpd_add_device+0x34/0x4c) [] (of_genpd_add_device) from [] (board_staging_register_device+0x11c/0x148) [] (board_staging_register_device) from [] (board_staging_register_devices+0x24/0x28) of_genpd_add_device() is called before platform_device_register(), as it needs to attach the genpd before the device is probed. But the spinlock is only initialized when the device is registered. Fix this by open-coding the spinlock initialization, cfr. device_pm_init_common() in the internal drivers/base code, and in the SuperH early platform code. Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/57783ece7ddae55f2bda2f59f452180bff744ea0.1626257398.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/board/board.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c index cb6feb34dd40..f980af037345 100644 --- a/drivers/staging/board/board.c +++ b/drivers/staging/board/board.c @@ -136,6 +136,7 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc) static int board_staging_add_dev_domain(struct platform_device *pdev, const char *domain) { + struct device *dev = &pdev->dev; struct of_phandle_args pd_args; struct device_node *np; @@ -148,7 +149,11 @@ static int board_staging_add_dev_domain(struct platform_device *pdev, pd_args.np = np; pd_args.args_count = 0; - return of_genpd_add_device(&pd_args, &pdev->dev); + /* Initialization similar to device_pm_init_common() */ + spin_lock_init(&dev->power.lock); + dev->power.early_init = true; + + return of_genpd_add_device(&pd_args, dev); } #else static inline int board_staging_add_dev_domain(struct platform_device *pdev, -- 2.30.2