Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp521335pxb; Thu, 9 Sep 2021 06:21:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO1eGCURlOTiqvUN9IpMW7py0Sdb7bQAvq4IDpq0a7oDKBejQsbe0UvEsowPkxJxXtK2s+ X-Received: by 2002:a5e:dc02:: with SMTP id b2mr2663402iok.197.1631193682966; Thu, 09 Sep 2021 06:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193682; cv=none; d=google.com; s=arc-20160816; b=UgPiUv4PMDpyhZEaTrqd3Zn+D7WJrXtT/M9/RVLuPHbZ6lbHva8/bv1+4ujhjXLLgH JG6FMWMDN9aAiiKHUpX5HBnzsJE9/LZ4kkY1sthaTC3QcNVY80x99/+8UeWcIPG8CYRo IPpc/rmFG43Z5vkDKtPzJ1ywM3UsVkOpncdRYvgcDekdDjcYymk2hKzVTfDqv/MNEctb O/ttx8k/t7C3wuuZnw3TJte0x77TqtavV7F8crVd8KoG3G9mj2M3BuE05KU4jaLcTxfr SJU2c9uyyho8thY7b7u+puvuaZBBXD8UDqgKcFp1Dlg35zDN7Zno9Vl1KCh3/YvRaxMl 38UQ== 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=UcpWgd6aK+9UrsYIIL+B6572yQ/gl0XfZgka6WQ5TOE=; b=w+5+A7ZFJSLKwRbCKQCCmHt2uw/QO7RIJjXLkWvmnJnkhQlrukNHyLkOUM3zmu1dAL TQ+6CtKcNQ16DPYga7yfymD6EWcOV7SbNkzYGiC1N/tbjCo9vn+6mX2dVwIgozrAEFGJ DXmIo6y/GgehgbufmyHDEJacd2qDEUw/qCuM5QkP2D9M2xUJ5UQoQJo91LGczT8UN75R /M0A+P+jsckDJidOX8Lb1hODiDNAUFKessu+iyBF7JMguApqWvHyYR1M/TaPGrizdbCW IzNvvyBrdmul/oEdIa/gYXmXPgusORXJzLpq2kGqymKvRce1f+aUCMnSqomPLJLcqmgn gZ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TstgKyBn; 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 t7si1939124ilf.11.2021.09.09.06.21.10; Thu, 09 Sep 2021 06:21:22 -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=TstgKyBn; 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 S1343878AbhIINV3 (ORCPT + 99 others); Thu, 9 Sep 2021 09:21:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:42450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357488AbhIINBD (ORCPT ); Thu, 9 Sep 2021 09:01:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 635286140D; Thu, 9 Sep 2021 11:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188758; bh=j7fEjZeqNGG1BVw4z7+o9ebWYMqAA1V0g2vnqTRhNPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TstgKyBnJDRO41897CqYx+jcTjBbsm4xamMxOgF0aKZGfOn8ygM046iyjWeOi3Pqh BXsRBOsAyCP4sXsyWSQF2f4A2d2yPW9i6xD5b9KcP4uilglW50bPzurjDqVgU5DZkF dnqu8Zbr//lMTOLCKa5G63CxZ4aWmtduDcVtNipzpotmgAPSuRcthVeK7aaOtOj/BW IWB/oClIyp5uSiMKkBx8TgYXV/nFy7YOaVIY9tRz0nOAFZK9xYTMn1vlDyEbYzLC4X hVucA1lhLt3JYKk53KVcQ9RvBtJzVCXvrALjWWwlwJ1Y4NvwA0TLIlZMNKt3kWiOzd nDR6rKrxYwm5g== 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 4.14 13/59] staging: board: Fix uninitialized spinlock when attaching genpd Date: Thu, 9 Sep 2021 07:58:14 -0400 Message-Id: <20210909115900.149795-13-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 86dc41101610..1e2b33912a8a 100644 --- a/drivers/staging/board/board.c +++ b/drivers/staging/board/board.c @@ -139,6 +139,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; @@ -151,7 +152,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