Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3162360imw; Mon, 11 Jul 2022 03:15:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRVuQZxO3RFKbJFVurJ3kljHR+KXNqI5w7WSiQOItbUBg/cgKSxh5HVRpWt6jK94BIIy4q X-Received: by 2002:a63:90c9:0:b0:413:9922:1eb1 with SMTP id a192-20020a6390c9000000b0041399221eb1mr14982351pge.360.1657534533768; Mon, 11 Jul 2022 03:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657534533; cv=none; d=google.com; s=arc-20160816; b=DGz6juu4GLpmnTVRR5d5+ZsIyKVLp4I1w+IY5rebc2Py6R1UzzDA3bmgc8UHBEyw9g UFjjjlWXZDzovX1wu4IZmwUuoxpY5nrs0maX6zHHaz2RcKeoeyPHdXaG+KHIfIp2H91l Cjkjk3xgzybHfqe+HevKhntqnsJtPXulqtHHu5IkMy8o5Y9j586b3yc3SRkY0h2/tiBE OlOCEtvmGVrrfhA3p0fqaiwyjEUFO89EIPMAIbtLyzax0AafnKAk/uB4cDWvD8+Rid+s OJJ9ISE1VGYkzUkhybbsOChkopvD07IP+TVdXAxAHiSrh0hS1ufe1SPI+HaZVbkbrmv+ tnxg== 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=dQTj3YB6zXelOnDw2kva+MZ1BTAIibKllbkU2dTnDYM=; b=Uf2fKZBYzDcv9drtnn5kNjAo9uz2figYFeaNoFiSKwlGS9xW07kZEKJhyTiYefYB1b tkEuv7dsn8JFWXi2LJsGOU4CL6CH5CiYOTbkHw3ZOFAl1ZCqGieHoG3Y+yZ/qY4JAGJZ /g1s2Ey8sp3AouviYlVvICr3f3EwmrdGo0xKgdQ6McDhwAcgajwRCz7NnvB3mSpkhHNO LHrYVI7A1NuWIuS2MDTFvpR1FLqfVdC1OOtSmyvpzOtLCv4+ZJqCuN753enupeum1oak EVVYAtFfpMpOXJGvwv7DYpmTu9/EpxI5zw8ZBqB6dSdahKAztkzI3qwBUVcilctNcGAE qFMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aW4fvyOC; 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 rj9-20020a17090b3e8900b001f03f928cc0si3287618pjb.162.2022.07.11.03.15.21; Mon, 11 Jul 2022 03:15:33 -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=aW4fvyOC; 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 S231290AbiGKJK6 (ORCPT + 99 others); Mon, 11 Jul 2022 05:10:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiGKJKW (ORCPT ); Mon, 11 Jul 2022 05:10:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B125B6558; Mon, 11 Jul 2022 02:08:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 0FAB66115B; Mon, 11 Jul 2022 09:08:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A787C341C0; Mon, 11 Jul 2022 09:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530511; bh=kD1iJdxSkOm5UfN81VY5A8MLK+M5zbq4zTJX5JFQUmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aW4fvyOCAaWIbs+Hg+EtKpyBOybrKd6JZHKDlii2uL4aUVs6CGlDKcKcyHSrjj6VG UvGyiv3pku7oaXoy0b3+UDMUl6b8+fcjmCwv+KxZn87Pp6BtkGPp5UmrrovxnkMtS8 4rsgb8LMj5qEP4SHxYx4/vFFUuXVyb62HfX4vwnU= 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 4.19 11/31] powerpc/powernv: delay rng platform device creation until later in boot Date: Mon, 11 Jul 2022 11:06:50 +0200 Message-Id: <20220711090538.180373926@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090537.841305347@linuxfoundation.org> References: <20220711090537.841305347@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 @@ -180,12 +180,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; @@ -209,10 +205,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);