Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp909211pxb; Fri, 22 Apr 2022 14:03:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjXuI0oQoHrnCpNNyNp8XJku3pb6CQeNNrcEfgDghfJesZ8oKMsvr+wUMT6QCn2Bl3aujw X-Received: by 2002:a4a:dcd7:0:b0:33a:4531:aa35 with SMTP id h23-20020a4adcd7000000b0033a4531aa35mr2329284oou.49.1650661413038; Fri, 22 Apr 2022 14:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650661413; cv=none; d=google.com; s=arc-20160816; b=Aj2mD8dk/cpYFOtl/rSJ7kWgNosADl9INhi1N7h9pO5JStWJM4rmc8YHB1mcqqnpBJ 7nH/wvruY5iKZ+8oy0Y9XchRe90aBeK8rznyvDvPgNAIOayC1JS5NwDYWYhnzvhemoR7 Kk41Nzwgs3ODKDUzopjMSUc26l1jDLezxZ5XuLrYYr2pofbtG0o7wB3rtcPV+/hQomoz 9Rminug/Z9eVhNCzUmBdAEdCSxHwS9zpbJxGJ1Wp3P4abMaMWSkWG/Iz8L1jAO+1Ydl+ j9F/nwLZxUa8XSF7QBX0Niks6G9/x7pOmqZyp+AmE8PR5pxgova2UWAMTl8cnfa9aoxo Ouww== 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=H8Qb6hfrY/68U2JtBtRavvgDqHYimQnhLuA1KylBiuE=; b=V/AjshrfEV8f0WTrZ8xOpEf8oiaJDvykX4Q0u0LDDGmQzMq8NWrInQ3eNoJO3MhI9L 24IHP49JEUghyZqQ4VkJh+jb8bjRiYLnoeTqA1s9GFsLJQfd88TDQzr42ZqyeZSFFsHI gwbd1R7z620Dpcrf8kIUa4oWtxirSeWkRD4U+ui2V+zhI8Y17dNEtv6v/Z1k3LkT/mgV 3MW56mhN4X8t0YTqKawOji5n6VPryu8VvWK7/czRCMieMHwXXWQx81qmajyQP3q/7lof KE1eIJLsNm2cPp+IzKCNGpwstMUFQFRwsrkAhrIbYLLV3rCUGoV9v2+40f2LPlVoGoW7 TfEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rqzy/wWJ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o19-20020a056870969300b000e67a0c3148si3587211oaq.89.2022.04.22.14.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:03:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rqzy/wWJ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 33D2522C05D; Fri, 22 Apr 2022 12:59:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238456AbiDRMYz (ORCPT + 99 others); Mon, 18 Apr 2022 08:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238988AbiDRMXQ (ORCPT ); Mon, 18 Apr 2022 08:23:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2A5B1F639; Mon, 18 Apr 2022 05:18:42 -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 4F93C60F01; Mon, 18 Apr 2022 12:18:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 464D3C385A1; Mon, 18 Apr 2022 12:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284321; bh=tZywWRlz/GYtnjHuFQ/H2v22JKSJT+kAwSDdH8vOghk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqzy/wWJoVS/j6JbGvLPi+tU+cvqRaSLngkMuw++Ch1wR0D+zjtKOeyW0snvhbZ7S UL3S0c+DqwaXo4hAjjfwH7/wH0uLM6LqzO3YFCeU1mA4JiwiNnYlOYdqAQqgCOkgs9 gq2jrsAoDktIci0AS17MGlskMNeDMZQMq+UORsmI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Vladimir Oltean , Florian Fainelli , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 074/219] net: mdio: dont defer probe forever if PHY IRQ provider is missing Date: Mon, 18 Apr 2022 14:10:43 +0200 Message-Id: <20220418121208.043153639@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@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=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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: Vladimir Oltean [ Upstream commit 74befa447e6839cdd90ed541159ec783726946f9 ] When a driver for an interrupt controller is missing, of_irq_get() returns -EPROBE_DEFER ad infinitum, causing fwnode_mdiobus_phy_device_register(), and ultimately, the entire of_mdiobus_register() call, to fail. In turn, any phy_connect() call towards a PHY on this MDIO bus will also fail. This is not what is expected to happen, because the PHY library falls back to poll mode when of_irq_get() returns a hard error code, and the MDIO bus, PHY and attached Ethernet controller work fine, albeit suboptimally, when the PHY library polls for link status. However, -EPROBE_DEFER has special handling given the assumption that at some point probe deferral will stop, and the driver for the supplier will kick in and create the IRQ domain. Reasons for which the interrupt controller may be missing: - It is not yet written. This may happen if a more recent DT blob (with an interrupt-parent for the PHY) is used to boot an old kernel where the driver didn't exist, and that kernel worked with the vintage-correct DT blob using poll mode. - It is compiled out. Behavior is the same as above. - It is compiled as a module. The kernel will wait for a number of seconds specified in the "deferred_probe_timeout" boot parameter for user space to load the required module. The current default is 0, which times out at the end of initcalls. It is possible that this might cause regressions unless users adjust this boot parameter. The proposed solution is to use the driver_deferred_probe_check_state() helper function provided by the driver core, which gives up after some -EPROBE_DEFER attempts, taking "deferred_probe_timeout" into consideration. The return code is changed from -EPROBE_DEFER into -ENODEV or -ETIMEDOUT, depending on whether the kernel is compiled with support for modules or not. Fixes: 66bdede495c7 ("of_mdio: Fix broken PHY IRQ in case of probe deferral") Suggested-by: Robin Murphy Signed-off-by: Vladimir Oltean Acked-by: Greg Kroah-Hartman Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20220407165538.4084809-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/base/dd.c | 1 + drivers/net/mdio/fwnode_mdio.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 752a11d16e26..7e079fa3795b 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -296,6 +296,7 @@ int driver_deferred_probe_check_state(struct device *dev) return -EPROBE_DEFER; } +EXPORT_SYMBOL_GPL(driver_deferred_probe_check_state); static void deferred_probe_timeout_work_func(struct work_struct *work) { diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 1becb1a731f6..1c1584fca632 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -43,6 +43,11 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, int rc; rc = fwnode_irq_get(child, 0); + /* Don't wait forever if the IRQ provider doesn't become available, + * just fall back to poll mode + */ + if (rc == -EPROBE_DEFER) + rc = driver_deferred_probe_check_state(&phy->mdio.dev); if (rc == -EPROBE_DEFER) return rc; -- 2.35.1