Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1532933pxb; Thu, 16 Sep 2021 09:22:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyidX4nZL2mh6cSIU1YtTtCpKJJO4DyuxHm8Hs6Tl2hWow8KbR6aKtBqHKKiRvXqmnYmGQ2 X-Received: by 2002:a17:906:7256:: with SMTP id n22mr7265112ejk.173.1631809344929; Thu, 16 Sep 2021 09:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809344; cv=none; d=google.com; s=arc-20160816; b=0yRUEPCGY0ilms6EE2RM1IJ9NSuSIXlm1fsHDE6k03fZu79tNM5jQrl6IY6kqLGjGK 3SumQIZ5xgf58I4jHc4+LDIYeH2qXZzLHBpJc5TYdWlF5I/Zz0DolCcUlIZWdH5LsHJ/ isiBiTDcNyByuqoUohO51iifKmf9edV5drNV8wDVST1zjo0l4sBJRrjdvMf6R4Bb3JX5 8y6QZtivI5q+sYgFcxgGEz2DDO+KdBV+IHLEFQRY0p43JOTnkSvS6d5uVNXxTFWdc7XW 5NsUD0yIxtk0Vqew/UHxNUTFfWrOvQ6bxaArTEywcmcw5H+hzMaMzGUUholuWr+2lGxy +IHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0TWBszD5WU1ZGk+vmA2FpdSIBsuZZPokgVNfRymfSxw=; b=IbCNQEHMPhV6Z9ye0EGwlqwGyy9Gy1QDrZzk07PYUl1Km3Lkhed644UWMH4UfWY0wS 22f4akDktBn5FSN7ZUdZCmdfvSZHrGRc1lz89f1gH5oVJZZkkKyZb087beki2XGeg+l2 IyAYlD/V9VhPI3Wyw6f7YHefzO5JzeZFkrysp7y0ZMAG/k62xYY6b4W0OvraNJuPeg2J T3zQjJVLQgq6K4RN39CdV9CJ26idBm7Za05+dwk9Sk/x9/YYTUO7b38ZLxf91d44knPI auQ8IHCi3e0oaj0RraYyEGOUnl36nPuw4vNcRDYe6GPVt9Nuu+gVwbMjGE3dAvfsAuTC kuMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AhL8iW1d; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si4035237ejy.256.2021.09.16.09.21.59; Thu, 16 Sep 2021 09:22:24 -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=@linuxfoundation.org header.s=korg header.b=AhL8iW1d; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241139AbhIPQVT (ORCPT + 99 others); Thu, 16 Sep 2021 12:21:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:47552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236100AbhIPQM3 (ORCPT ); Thu, 16 Sep 2021 12:12:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B0B76137E; Thu, 16 Sep 2021 16:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808564; bh=JU4iJc6oY871eBLmLglTyk8lAnK2nHC5KV9FVXhDFpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhL8iW1dC+AELtGKBvq3swutudkaUMBx177MUy1kBxA2gEo1c8I2JXxbNAsfTiQG6 XPK+WQYjHPgcASCqTHI7D/nGb+ZEUx8ChTGhwpWs05WjyQWRlRP3lbWzkXd3bEUJ7K cRUS8aQ11+3g+Zv7H+eerUj7AT6htvXN5Y3+KOq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Sasha Levin Subject: [PATCH 5.10 137/306] staging: board: Fix uninitialized spinlock when attaching genpd Date: Thu, 16 Sep 2021 17:58:02 +0200 Message-Id: <20210916155758.715060304@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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