Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1949678pxb; Thu, 16 Sep 2021 21:16:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpyja3Yzm71AXRz/ZEGZYKbKgZtDcBQqz0RtgGQBtC45Qo7O09lZJURpbAciqIB4yO/MOn X-Received: by 2002:a02:2452:: with SMTP id q18mr6973491jae.116.1631852186721; Thu, 16 Sep 2021 21:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631852186; cv=none; d=google.com; s=arc-20160816; b=YUvUT04J+XTGnC0pPpWgV0C+5jBzuPKb/rdka53ximnjI2TBq7rQBi8hMzv7wziEDX cM/r8pITMFO97qJA50FRnaRNb4NKvGKah77Iu+lIPFrLOAjr7TsozHt17wEfvxP/D4zB C9UeljmSnJkJy33twyqGg5y57JlFSonGj0z710ghQyIII4g7j8NS3O7QYBYt4+fwqU7T KeYRuvNMcQoVb0jmhKQmvYW883MlnsOCK28aLbEYHc1bGKH9+fR6ipQbsxqlXEwfEDlC jciXnck51sXJGOF2673tFTseFQc+WpWKNRF/63q+fhGrej74uYmgC+ATjNu5Y25vb6D4 sDag== 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=iV1obj98AbyJUO3uhoF+LEq6eAvX+rgiwhuYQ1ZtwebxxK1K+F7RwTHhS8gROxUg2Q Ph3/Mp9UUNHOViqEtZZYmt80s+MUPvZdFLJrQGKKUNOHTg5BzsF5sgMaIky3/5ZG7XdZ qpH5mhCqvd1rxzl32INRn9lTLEdJ8kRmDWq89zLQlE01NInSuevIvr8iUSrdX1/fVQZG zgwrC1J/LGqD8WrBhv8CL4SMY3XLZ/EPYEA+6HAHiwxq+WLwLMdgf3QjPCOQnquCUTkw eviIzFacEutAJYwKja3ohT8gYV61UOY5QF3zXqqH4BYoCFNZcVJH4KxfRA7xCw/QMsjx P9og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QnEuvhh1; 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 b125si4535359jab.33.2021.09.16.21.16.15; Thu, 16 Sep 2021 21:16:26 -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=QnEuvhh1; 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 S1353817AbhIPRfH (ORCPT + 99 others); Thu, 16 Sep 2021 13:35:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:46942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348337AbhIPRZz (ORCPT ); Thu, 16 Sep 2021 13:25:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5D4061C19; Thu, 16 Sep 2021 16:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810671; bh=JU4iJc6oY871eBLmLglTyk8lAnK2nHC5KV9FVXhDFpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QnEuvhh1hv5l1obM7VoGUQ8QnwlMw95EQCt2ekBQCqZh9YaV1RyKELoopDp9OZS1E QJHhILjiK0Q0oYDPc/LBIMxQn7udWLHSow883sGpCRMDLb9fj0TfM5i/fnGW0KJWcL m+v98LPQCdnY3CcvZrNyn6RX+Y7cw9WDFv/wYExo= 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.14 199/432] staging: board: Fix uninitialized spinlock when attaching genpd Date: Thu, 16 Sep 2021 17:59:08 +0200 Message-Id: <20210916155817.549060589@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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