Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1636642pxy; Mon, 2 Aug 2021 06:47:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsngAZZ4qK/RDwJ0zkkLrPIv5R1FEv2xIf86ixjmEcWGSLV4ARBidQB9QKJiXEPBmj35uR X-Received: by 2002:a05:6602:25da:: with SMTP id d26mr391803iop.106.1627912047733; Mon, 02 Aug 2021 06:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912047; cv=none; d=google.com; s=arc-20160816; b=GW7L1aCAaLv3LLQJ2kalB1ccBvywmxOtWZOOYkX5b4dTuacuyZ+2wjR1HVPaKUZGWi VNVQudMcF+tZdnYaeKTjO9OYCqbzOhxdVHVyvBI4TNICMeXiLgV04ZPVdFuGJsRirDb3 GVdlGF1N0nSuWJrTgxFzVBQ/XySGmUpNoK6ddPkQOV0TkYs9HTAEQk9WfX5rVTlxVO/w QQufcVcqlhPfoec37tNzsasfW5NwfcH0e042Dw252/PEhKg5ML/VJMscfn8+uqR02KBn bX5kVCUCciEcprrRuTAX2b8Kx4Ikl5gE4YicJSvb+h7eZxD+OjrLURk8HYYbjSNmHTAK QFvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RB17MU1pJAfRQkn/6jvNyWpVmGH7Icd/hgOnLlEzxuk=; b=veipnHJzwKEI7LD+XQ7eRMmH9lamDN7sWxi88yQJN/wMPeOZVNrq9wK6eH+6r+v8nP Dkq5uNNpsxVDa279emnHm10tLc7bDg1pgt/6ghVzb4YQYRCL43o7Rj19nwiiktBnPoke Rgv/C3panN2fSOdzydVSgyJ3Q3mxN4drjzR7hMpLNnr+k6ZUPe7/z3dbUf+N/e+jhWTW tPcMW8mT5e9N+evL7FiLjYoF55MpNgBOtybCJF9anlAykPjqBwoIAaTrr2jFFv6tFf9v l60U+IiqZij5UrXZ9jBOyCMV83WUfZVE9OKfSXnRf1Q0dUkbKddXtvCFE92pv8LUgeSk 9UEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F5ASIru8; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si11645021ila.59.2021.08.02.06.47.16; Mon, 02 Aug 2021 06:47:27 -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=@linaro.org header.s=google header.b=F5ASIru8; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234143AbhHBNq0 (ORCPT + 99 others); Mon, 2 Aug 2021 09:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234014AbhHBNqN (ORCPT ); Mon, 2 Aug 2021 09:46:13 -0400 Received: from mail-vk1-xa33.google.com (mail-vk1-xa33.google.com [IPv6:2607:f8b0:4864:20::a33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B41C061760 for ; Mon, 2 Aug 2021 06:46:04 -0700 (PDT) Received: by mail-vk1-xa33.google.com with SMTP id d15so3629047vka.13 for ; Mon, 02 Aug 2021 06:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RB17MU1pJAfRQkn/6jvNyWpVmGH7Icd/hgOnLlEzxuk=; b=F5ASIru8EOb8b8ijHzOub5FKpL7CkNGrP/d38JvlhjC4EZQb4iHRHWmoHA99e522SR DudGw4ze9SBj/QThHZHNn3eBE4gaiiwfiWkoA84+VmIQOahuMLfOCst9BsGiGPYhyhcg 1/SP/TOZczxWNXOzV6gLXF6xl7FwEnXCaGwOBSIqLnLLlbK3BgElbOQEHltY5Lzk0etI p19bOUg4+/T1NhUQFD/CsIivwMBF1Gacc4DEcLrtL0X94Wgc5kGAfH9FtdnNSx6DtcPz KbiHk+DDKEUVtXJEl2WzSWw92KUqI+0SSS6Td1/DoPK7ndr5VU/zMpev/hZOde2R+vO8 FgdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RB17MU1pJAfRQkn/6jvNyWpVmGH7Icd/hgOnLlEzxuk=; b=gMLey7ZQPHmenIyqJzDVZbWgF3Ts8C9lA6ULMosEhKV7pW0NpLy5ttSVDkHhBKvQGz aiaETl0bYHdBoGq0G8WwQ/TdPXq4XpdMum1LzR/tttFLZL1Z8nZOrXCZ6x8SxNbjCoXQ cBqj7Bmvldkz3W1/oNtlldy1Zq5uoDHaZVzYowUoJHjk3XZ5EVSeRLKNmMyqKOxxeSqu g8/uV8+Hwz5hxgcaiFCHrrM3Mh3P49GPGYguRm+kfrvuCKcb7ENlk1zsp8Prq/bgKIxu hg91nLUuKOak717U6b2x/N7EVnQWSm5Xvb1tB/KUEDm4+NHNtEvt732wHTaM+JFL2cW6 8jaw== X-Gm-Message-State: AOAM5304tYhPlh89O66e0zGWpyHQO6OGsndjKrxEdYmwjrlyZkN4Rn1R z62vnS6vcO3+Rjz82kqI3LTbsK+tS2iz7HZhAtbTkA== X-Received: by 2002:a1f:cf47:: with SMTP id f68mr8719981vkg.7.1627911963456; Mon, 02 Aug 2021 06:46:03 -0700 (PDT) MIME-Version: 1.0 References: <57783ece7ddae55f2bda2f59f452180bff744ea0.1626257398.git.geert+renesas@glider.be> In-Reply-To: <57783ece7ddae55f2bda2f59f452180bff744ea0.1626257398.git.geert+renesas@glider.be> From: Ulf Hansson Date: Mon, 2 Aug 2021 15:45:27 +0200 Message-ID: Subject: Re: [PATCH v2] staging: board: Fix uninitialized spinlock when attaching genpd To: Geert Uytterhoeven Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , Kevin Hilman , Saravana Kannan , Bartosz Golaszewski , Magnus Damm , Linux-Renesas , Linux PM , linux-staging@lists.linux.dev, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Jul 2021 at 12:13, Geert Uytterhoeven wrote: > > 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 > --- > Exposed by fw_devlinks changing probe order. > Masked before due to an unrelated wait context check failure, which > disabled any further spinlock checks. > https://lore.kernel.org/linux-acpi/CAMuHMdVL-1RKJ5u-HDVA4F4w_+8yGvQQuJQBcZMsdV4yXzzfcw@mail.gmail.com > > v2: > - Improve code comment. > --- > 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 cb6feb34dd401ae3..f980af0373452cab 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); It looks like the only device that is being managed here, is a platform device that corresponds to the sh_mobile_lcdc_driver (drivers/video/fbdev/sh_mobile_lcdcfb.c). Wouldn't it be better to move the domain information into the platform data of the above platform device and then deal with the attach to the genpd from the sh_mobile_lcdc_driver? In this way, the behaviour would be more consistent with others probe/attach to genpd - and $subject patch would not be needed. > } > #else > static inline int board_staging_add_dev_domain(struct platform_device *pdev, > -- > 2.25.1 > Kind regards Uffe