Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2349265pxb; Mon, 20 Sep 2021 19:42:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2VsQlw3675DIyl4miIRW1SkH670M8TY/ti9ocPLfB09d6h/EIW1qT2ykMXhF5rAxu2mrR X-Received: by 2002:aa7:d99a:: with SMTP id u26mr32586712eds.320.1632192164150; Mon, 20 Sep 2021 19:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192164; cv=none; d=google.com; s=arc-20160816; b=w2851KnMwsK6cmursS9BRveYpCBTEWQDawMoeG6t9z9jAHWCn4GHDvmAbrgbLe/1EY DBzDGnKQ8S6bBjEByUgFlvPelwcoTpsZ5WoW86SpB5VnTpHG11pMTohrAqLdzialDSHG mC2UT0JHpnhCXAnX8MfV8YmOjD1Zcbpgc0toW8S/1yZaH+ZKMKo/iXBysR9Q8Jz5/hdm IRdCweatj0oCYoLQ+juCN/2MZ1EoEAs8XRn0vP6TRQKWcUDJZKbQCGwwxkWok+JeF01P UohrZHhioIvbvtwhQIUxLJyKSCv2vc206RJJoHKVMDuVLlEd/v4+5Aou4N0pCMZWjGrL 4zTQ== 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=ipFr51vboLAXFSaSPocaLacFdpUO9UhH3ZGOxrun+hiLwzjigAFN3/Q2ROtiZrkjrz cmuXKr+zrbOTgkrG4647jcP3HD9BYVALxeNxztOgI4RAmQ7VboDzLYsCdmkv2FAbGc/3 ybWZa3hmMwINA8CaqR22zxrBIV74gTclOBnFlYA2iTCWLi6o7PONJeHL2yqIehRHIcA6 uNpPYG+JwTIIhQdL7ceOzaZwqDgtkYh7NEMQA+LDBnj/OXPCV+u0cHsBqFqu7Y0MqYvJ Xqk3tfC8lhcsgOg8yNaa2/IHrb61X5jioJsM3ZThixMIm+CfXN/iYPtqGL/DXQInm3G7 QqcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x6fhbzdS; 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 c23si17573297edv.45.2021.09.20.19.42.21; Mon, 20 Sep 2021 19:42:44 -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=x6fhbzdS; 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 S1377822AbhITSVG (ORCPT + 99 others); Mon, 20 Sep 2021 14:21:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:32930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358662AbhITSHT (ORCPT ); Mon, 20 Sep 2021 14:07:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F26F663254; Mon, 20 Sep 2021 17:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158297; bh=JU4iJc6oY871eBLmLglTyk8lAnK2nHC5KV9FVXhDFpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x6fhbzdSOcBL5QkPL7AyGnooRPLwgw8lQa/Nqf8CjAXLbDDQ5PdExXaTcDlkJTCQf id6TsPln5Xle9aonmYoA8vyaXFTo8V1uOoNenyxGJ8uX51kPWMN72UaRzE1MBswutA o9CRXkD35b2wUUHzUUfSZghCkzRyu1BH548bvj0w= 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.4 092/260] staging: board: Fix uninitialized spinlock when attaching genpd Date: Mon, 20 Sep 2021 18:41:50 +0200 Message-Id: <20210920163934.264583785@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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