Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5014784pxb; Mon, 15 Feb 2021 07:22:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdE2BPiwtLHHr2/hpQ5k56yI/7nvYHXL3JLgZlybyXpVwZUTilfmnPGX8pBIQfzlRPdYrg X-Received: by 2002:a17:906:4d12:: with SMTP id r18mr5003374eju.406.1613402559207; Mon, 15 Feb 2021 07:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613402559; cv=none; d=google.com; s=arc-20160816; b=dRrweMG0FsXIb4qbcdGSwv9CWpuEe5DPylSKOClInpdWqqZEnOFP0T6r0W1qko5Cbf 1HWmEyA0uevYjMFKwFqUyaPOwGXy0fobNLSJYApPdcjtF9/HzV24jp2WE5AaB3nR5ITF Xe36seUEB+zO67/Kg7ZrxBVN7DigAsOBYvfhMMW041GJZFVxBSJu67JFhWSG/Zjr1KZ3 0chRi1Z2tN1myqSnQXCp60bBHZe6FaCNynrQ895hTfFo+SBITR+Zc5M/ZbkYIpl+8F/O pJd9L7VkBXOnzN7H/XtXlCNYurAEB5bGv3Wbpn5wUgWpWKAUPRtc2SfzgDzYVBdK+FTH tzdw== 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; bh=R9/zQOsvQANjrCnsxwn/5rThDj/56Q6Gsu2p1SN46CA=; b=beI5q6Bam4jBQgLm7+DXqx8WOd8vWJ2I7Kbrcn5ca5R24jKFbiQiXLqObYCg1+Uyxt 7v+Zl5ANwGCNp8C5agYrwZ+lwXuI3adL3IrSUA/ApyyTMDe6uNEWYuMsUEtJBXGVRYSV zLpXBxPTa3Sw1EAVwxh9eY43KH1yk1vHTvEIRM86AlXy8xt9paMEE9rlxFVRj+kKPmR8 3Q0HkEQzVCsup2r/zZDo7ztFbxPawhn+vlu+trq9StyW8h49HOY+FBsheTlRtUa/S91p pF/SibvFECSyA1Ep/wICjMCrz0OECs7fpqfIt7qRpi+bZj/NCZrZ9dA/aBc4cP2antEw c1Ww== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si12446148eja.248.2021.02.15.07.22.15; Mon, 15 Feb 2021 07:22:39 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbhBOPTT (ORCPT + 99 others); Mon, 15 Feb 2021 10:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbhBOPO4 (ORCPT ); Mon, 15 Feb 2021 10:14:56 -0500 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D97D4C061786 for ; Mon, 15 Feb 2021 07:14:10 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed60:c5d6:9422:c618:ee58]) by albert.telenet-ops.be with bizsmtp id VTE8240042PLE0706TE84E; Mon, 15 Feb 2021 16:14:09 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lBfZf-0079Q4-IO; Mon, 15 Feb 2021 16:14:07 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lBfZe-00AhgE-RK; Mon, 15 Feb 2021 16:14:06 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman Cc: Saravana Kannan , Bartosz Golaszewski , "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Magnus Damm , linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] staging: board: Fix uninitialized spinlock when attaching genpd Date: Mon, 15 Feb 2021 16:14:05 +0100 Message-Id: <20210215151405.2551143-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Exposed by fw_devlinks changing probe order. Masked before due to an unrelated wait context check failure, which disabled any further spinlock checks. https://lore.kernel.org/linux-acpi/CAMuHMdVL-1RKJ5u-HDVA4F4w_+8yGvQQuJQBcZMsdV4yXzzfcw@mail.gmail.com --- 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 cb6feb34dd401ae3..604612937f038e92 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); + /* Cfr. 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.25.1