linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	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	[thread overview]
Message-ID: <20210909115900.149795-13-sashal@kernel.org> (raw)
In-Reply-To: <20210909115900.149795-1-sashal@kernel.org>

From: Geert Uytterhoeven <geert+renesas@glider.be>

[ 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: <none>/-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)
    [<c010c3c8>] (unwind_backtrace) from [<c010a49c>] (show_stack+0x10/0x14)
    [<c010a49c>] (show_stack) from [<c0159534>] (do_raw_spin_lock+0x20/0x94)
    [<c0159534>] (do_raw_spin_lock) from [<c040858c>] (dev_pm_get_subsys_data+0x8c/0x11c)
    [<c040858c>] (dev_pm_get_subsys_data) from [<c05fbcac>] (genpd_add_device+0x78/0x2b8)
    [<c05fbcac>] (genpd_add_device) from [<c0412db4>] (of_genpd_add_device+0x34/0x4c)
    [<c0412db4>] (of_genpd_add_device) from [<c0a1ea74>] (board_staging_register_device+0x11c/0x148)
    [<c0a1ea74>] (board_staging_register_device) from [<c0a1eac4>] (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 <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/57783ece7ddae55f2bda2f59f452180bff744ea0.1626257398.git.geert+renesas@glider.be
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


  parent reply	other threads:[~2021-09-09 13:20 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 11:58 [PATCH AUTOSEL 4.14 01/59] media: dib8000: rewrite the init prbs logic Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 02/59] crypto: mxs-dcp - Use sg_mapping_iter to copy data Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 03/59] PCI: Use pci_update_current_state() in pci_enable_device_flags() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 04/59] iio: dac: ad5624r: Fix incorrect handling of an optional regulator Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 05/59] ARM: dts: qcom: apq8064: correct clock names Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 06/59] video: fbdev: kyro: fix a DoS bug by restricting user input Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 07/59] netlink: Deal with ESRCH error in nlmsg_notify() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 08/59] Smack: Fix wrong semantics in smk_access_entry() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 09/59] usb: host: fotg210: fix the endpoint's transactional opportunities calculation Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 10/59] usb: host: fotg210: fix the actual_length of an iso packet Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 11/59] usb: gadget: u_ether: fix a potential null pointer dereference Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 12/59] usb: gadget: composite: Allow bMaxPower=0 if self-powered Sasha Levin
2021-09-09 11:58 ` Sasha Levin [this message]
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 14/59] tty: serial: jsm: hold port lock when reporting modem line changes Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 15/59] bpf/tests: Fix copy-and-paste error in double word test Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 16/59] bpf/tests: Do not PASS tests without actually testing the result Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 17/59] video: fbdev: asiliantfb: Error out if 'pixclock' equals zero Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 18/59] video: fbdev: kyro: " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 19/59] video: fbdev: riva: " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 20/59] ipv4: ip_output.c: Fix out-of-bounds warning in ip_copy_addrs() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 21/59] flow_dissector: Fix out-of-bounds warnings Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 22/59] s390/jump_label: print real address in a case of a jump label bug Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 23/59] serial: 8250: Define RX trigger levels for OxSemi 950 devices Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 24/59] xtensa: ISS: don't panic in rs_init Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 25/59] hvsi: don't panic on tty_register_driver failure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 26/59] serial: 8250_pci: make setup_port() parameters explicitly unsigned Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 27/59] staging: ks7010: Fix the initialization of the 'sleep_status' structure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 28/59] ata: sata_dwc_460ex: No need to call phy_exit() befre phy_init() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 29/59] Bluetooth: skip invalid hci_sync_conn_complete_evt Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 30/59] ASoC: Intel: bytcr_rt5640: Move "Platform Clock" routes to the maps for the matching in-/output Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 31/59] bpf: Fix off-by-one in tail call count limiting Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 32/59] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 33/59] arm64: dts: qcom: sdm660: use reg value for memory node Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 34/59] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 35/59] Bluetooth: avoid circular locks in sco_sock_connect Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 36/59] gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 37/59] ARM: tegra: tamonten: Fix UART pad setting Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 38/59] ACPICA: iASL: Fix for WPBT table with no command-line arguments Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 39/59] rpc: fix gss_svc_init cleanup on failure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 40/59] staging: rts5208: Fix get_ms_information() heap buffer size Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 41/59] gfs2: Don't call dlm after protocol is unmounted Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 42/59] btrfs: subpage: check if there are compressed extents inside one page Sasha Levin
2021-09-09 13:01   ` David Sterba
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 43/59] btrfs: subpage: fix race between prepare_pages() and btrfs_releasepage() Sasha Levin
2021-09-09 13:01   ` David Sterba
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 44/59] ASoC: intel: atom: Revert PCM buffer address setup workaround again Sasha Levin
2021-09-09 12:06   ` Takashi Iwai
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 45/59] mmc: sdhci-of-arasan: Check return value of non-void funtions Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 46/59] mmc: rtsx_pci: Fix long reads when clock is prescaled Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 47/59] selftests/bpf: Enlarge select() timeout for test_maps Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 48/59] cifs: fix wrong release in sess_alloc_buffer() failed path Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 49/59] Revert "USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set" Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 50/59] usb: musb: musb_dsps: request_irq() after initializing musb Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 51/59] usbip: give back URBs for unsent unlink requests during cleanup Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 52/59] usbip:vhci_hcd USB port can get stuck in the disabled state Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 53/59] ASoC: rockchip: i2s: Fix regmap_ops hang Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 54/59] ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 55/59] parport: remove non-zero check on count Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 56/59] ath9k: fix OOB read ar9300_eeprom_restore_internal Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 57/59] ath9k: fix sleeping in atomic context Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 58/59] net: fix NULL pointer reference in cipso_v4_doi_free Sasha Levin
2021-09-09 11:59 ` [PATCH AUTOSEL 4.14 59/59] net: w5100: check return value after calling platform_get_resource() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909115900.149795-13-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).