From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7744CC4332F for ; Sun, 8 Sep 2019 12:55:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51B482190F for ; Sun, 8 Sep 2019 12:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947309; bh=j6EGaUgINAbUeHJRDMaId7xXvK70U2UclSJg0QPS1sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZFKkM6MbrSIHK9hF4DEtkU8gWwuofHc8hmkt5jeg2s79d7EfQuqi1tRjdrxqlCZuw 2fxHk63+YFd12+W2CL5RhghBWMgX/ypQQKnU2Ac2lFmiZqBEO8N3IN5DxFIx+hAjbF IrOd+uM+EAzuwuyqrYgV0nuI8rtzuWb0/BwmTQ10= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732693AbfIHMzF (ORCPT ); Sun, 8 Sep 2019 08:55:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:42978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732631AbfIHMva (ORCPT ); Sun, 8 Sep 2019 08:51:30 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E8E620693; Sun, 8 Sep 2019 12:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947089; bh=j6EGaUgINAbUeHJRDMaId7xXvK70U2UclSJg0QPS1sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIl4AAv9JaImaNsNsE9BtGTa61TSKrWmULHt/e3tad5mfuc0yLVlBTcdKzDzq4vyO ve4gmQPwS310DkAOwN5jhwtH611fmr9vmrhm7l8MzSMKA5Rbsl0dLUye8R4DTcPlcO rfeKZfIRmQNZzsfLEgR1LOgqhiDAdm2QHYYi0kIc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Hartmann , Andrew Lunn , "David S. Miller" Subject: [PATCH 5.2 15/94] Add genphy_c45_config_aneg() function to phy-c45.c Date: Sun, 8 Sep 2019 13:41:11 +0100 Message-Id: <20190908121150.869039333@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121150.420989666@linuxfoundation.org> References: <20190908121150.420989666@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marco Hartmann [ Upstream commit 2ebb991641d3f64b70fec0156e2b6933810177e9 ] Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling genphy_config_aneg") introduced a check that aborts phy_config_aneg() if the phy is a C45 phy. This causes phy_state_machine() to call phy_error() so that the phy ends up in PHY_HALTED state. Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg() (analogous to the C22 case) so that the state machine can run correctly. genphy_c45_config_aneg() closely resembles mv3310_config_aneg() in drivers/net/phy/marvell10g.c, excluding vendor specific configurations for 1000BaseT. Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver") Signed-off-by: Marco Hartmann Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/phy-c45.c | 26 ++++++++++++++++++++++++++ drivers/net/phy/phy.c | 2 +- include/linux/phy.h | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -523,6 +523,32 @@ int genphy_c45_read_status(struct phy_de } EXPORT_SYMBOL_GPL(genphy_c45_read_status); +/** + * genphy_c45_config_aneg - restart auto-negotiation or forced setup + * @phydev: target phy_device struct + * + * Description: If auto-negotiation is enabled, we configure the + * advertising, and then restart auto-negotiation. If it is not + * enabled, then we force a configuration. + */ +int genphy_c45_config_aneg(struct phy_device *phydev) +{ + bool changed = false; + int ret; + + if (phydev->autoneg == AUTONEG_DISABLE) + return genphy_c45_pma_setup_forced(phydev); + + ret = genphy_c45_an_config_aneg(phydev); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + return genphy_c45_check_and_restart_aneg(phydev, changed); +} +EXPORT_SYMBOL_GPL(genphy_c45_config_aneg); + /* The gen10g_* functions are the old Clause 45 stub */ int gen10g_config_aneg(struct phy_device *phydev) --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -499,7 +499,7 @@ static int phy_config_aneg(struct phy_de * allowed to call genphy_config_aneg() */ if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0))) - return -EOPNOTSUPP; + return genphy_c45_config_aneg(phydev); return genphy_config_aneg(phydev); } --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1108,6 +1108,7 @@ int genphy_c45_an_disable_aneg(struct ph int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_pma_read_abilities(struct phy_device *phydev); int genphy_c45_read_status(struct phy_device *phydev); +int genphy_c45_config_aneg(struct phy_device *phydev); /* The gen10g_* functions are the old Clause 45 stub */ int gen10g_config_aneg(struct phy_device *phydev);