Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3165733imw; Mon, 11 Jul 2022 03:20:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sDZ70wZUgLCJ5Pc+g6CiLR5Skq60bAuNIg2uB40nwhSLfUHE8lw1xOnPz1vH8IJYHxq+Bx X-Received: by 2002:a17:90b:2341:b0:1ef:819f:dfc4 with SMTP id ms1-20020a17090b234100b001ef819fdfc4mr16354954pjb.206.1657534802828; Mon, 11 Jul 2022 03:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657534802; cv=none; d=google.com; s=arc-20160816; b=vWDPk125jQRX1s28CNXo8Sqr32P+avJIbvulolnBP30h4Km5gZpSpNlqlIV9dipjIf 962IfFha34uahUv6jaWdg1lNXYbsb8nYMN4cQXNocW3fHcUEYV3KmwX+YFTtG8k6Npf+ dh5uq82kcMtLCsvhH9hSe8KOFpP14u14sfxaPWK1s5P5VVAND5maalpqFJmG77Zm21MX XDCMVs6zDqkRRNEoYZpki3GXr3Lnlug1346JQ6MuJNQZBtuneZXROQEJOvJ33+j4wq0h ZC/IJEsoyPL1gwRlDx3OgJex9LwwCHr7I6ClPBbZaDjKcJSJAVuEwacHit1kzWl0VyX/ 3dvw== 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=eo6YdyvbXrlXvxPVEoYI1/13ghUhfBJDvIlz37Zl0Mw=; b=JrzXi+kUUvSeUFeoaCH6KSjX3egitn8qmhJLNCJZi45qrnPOWPVmhK/Nf7WlWkoAoZ xp2mYFl/sXrPbNCDEU5cH8pdYwZ/m+n3gX6eOUE8Gu7iLKBwt2MLP9QKNpEAJitRds75 1YijfB9cTZRzSxqFf1X4PGzwskjTXT8FuRNzEGHOSUvgLBMtbjhMNVAE5MrvKJz4gav4 EDaHxu2xHonniSF23AAllvDEaz1AUVgt0JObOStYbNlHRwS7rVWPltMiPObsp/SahuhM 9D0IBS2TWAtbFSZeOwVo1ti4CZVvKtz3pQJcKc4HlbYTCbjYQ6S9xLR5aSuktf5fkuCT +AEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t9aQNkX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij6-20020a170902ab4600b0016b9cf35991si8072395plb.250.2022.07.11.03.19.50; Mon, 11 Jul 2022 03:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t9aQNkX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232086AbiGKJZO (ORCPT + 99 others); Mon, 11 Jul 2022 05:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbiGKJYI (ORCPT ); Mon, 11 Jul 2022 05:24:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76926313A8; Mon, 11 Jul 2022 02:14:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0C5B9B80DBA; Mon, 11 Jul 2022 09:14:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D4AFC34115; Mon, 11 Jul 2022 09:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530842; bh=K6jNGp2dUuNiWhAggovJ4j01QWBZArB13C35cE1qd8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9aQNkX3VwwU4zwvU/6IIkChnafhwf0uY1540hgeWW7JD3Hn/b49Mjy/O6VFtppMB slUBNb3QISnRYPgme9LpV6uXVoQW5AULGxpKFbTbzEFe3Ob2ofjF2zZwif656lwUCV U3K/zQFccdXlX/bAeMFC6LQ1GinB0dkZN/j1o+T8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sachin Sant , "Jason A. Donenfeld" , Michael Ellerman Subject: [PATCH 5.10 20/55] powerpc/powernv: delay rng platform device creation until later in boot Date: Mon, 11 Jul 2022 11:07:08 +0200 Message-Id: <20220711090542.362424663@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090541.764895984@linuxfoundation.org> References: <20220711090541.764895984@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason A. Donenfeld commit 887502826549caa7e4215fd9e628f48f14c0825a upstream. The platform device for the rng must be created much later in boot. Otherwise it tries to connect to a parent that doesn't yet exist, resulting in this splat: [ 0.000478] kobject: '(null)' ((____ptrval____)): is not initialized, yet kobject_get() is being called. [ 0.002925] [c000000002a0fb30] [c00000000073b0bc] kobject_get+0x8c/0x100 (unreliable) [ 0.003071] [c000000002a0fba0] [c00000000087e464] device_add+0xf4/0xb00 [ 0.003194] [c000000002a0fc80] [c000000000a7f6e4] of_device_add+0x64/0x80 [ 0.003321] [c000000002a0fcb0] [c000000000a800d0] of_platform_device_create_pdata+0xd0/0x1b0 [ 0.003476] [c000000002a0fd00] [c00000000201fa44] pnv_get_random_long_early+0x240/0x2e4 [ 0.003623] [c000000002a0fe20] [c000000002060c38] random_init+0xc0/0x214 This patch fixes the issue by doing the platform device creation inside of machine_subsys_initcall. Fixes: f3eac426657d ("powerpc/powernv: wire up rng during setup_arch") Cc: stable@vger.kernel.org Reported-by: Sachin Sant Signed-off-by: Jason A. Donenfeld Tested-by: Sachin Sant [mpe: Change "of node" to "platform device" in change log] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220630121654.1939181-1-Jason@zx2c4.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/powernv/rng.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/arch/powerpc/platforms/powernv/rng.c +++ b/arch/powerpc/platforms/powernv/rng.c @@ -176,12 +176,8 @@ static int __init pnv_get_random_long_ea NULL) != pnv_get_random_long_early) return 0; - for_each_compatible_node(dn, NULL, "ibm,power-rng") { - if (rng_create(dn)) - continue; - /* Create devices for hwrng driver */ - of_platform_device_create(dn, NULL, NULL); - } + for_each_compatible_node(dn, NULL, "ibm,power-rng") + rng_create(dn); if (!ppc_md.get_random_seed) return 0; @@ -205,10 +201,18 @@ void __init pnv_rng_init(void) static int __init pnv_rng_late_init(void) { + struct device_node *dn; unsigned long v; + /* In case it wasn't called during init for some other reason. */ if (ppc_md.get_random_seed == pnv_get_random_long_early) pnv_get_random_long_early(&v); + + if (ppc_md.get_random_seed == powernv_get_random_long) { + for_each_compatible_node(dn, NULL, "ibm,power-rng") + of_platform_device_create(dn, NULL, NULL); + } + return 0; } machine_subsys_initcall(powernv, pnv_rng_late_init);