From patchwork Thu Jun 18 13:45:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 217600 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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham 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 928CEC433E0 for ; Thu, 18 Jun 2020 13:45:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F4AD20888 for ; Thu, 18 Jun 2020 13:45:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="gVVVBCDn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730469AbgFRNpj (ORCPT ); Thu, 18 Jun 2020 09:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730116AbgFRNpf (ORCPT ); Thu, 18 Jun 2020 09:45:35 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 632E8C06174E for ; Thu, 18 Jun 2020 06:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WTru7edNn8MCB5Scv+/luMphYcFkpQo0NPRSa81kWu0=; b=gVVVBCDnWtT/dMtmaFZg4gbUBX 0AxF1h5dQT+sxXzSgmntLcX/97dTBKISoGP2EBiL0AvT7mYKOdFBhpea934rS0pPQBMRTXnvhDHRT 0dwrq9JXJ/MA1mK1K6zLsadUxr4Ud7wFC+NnGsU8jM/KzLaX8ik4oNOqslL2qtDrjgSBvGSmtfSQW QBSomf0QlwTk+BgyAFcqczqpZQ9MyoweIMgseXtguXhkU6oN0n6Nw0l5zN/i0uO/Q7F4LbRIQh43a dCR2roiioeawrALR1lIA1qQM6YbWuu6QA+6NAJXxzq7LProlEBmIEQDHj7U0k4D3/uvq5pMDIO/S4 0/vi80CA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37642 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlurE-0005AA-UW; Thu, 18 Jun 2020 14:45:33 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jlurE-0004jN-N6; Thu, 18 Jun 2020 14:45:32 +0100 In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk> References: <20200618134500.GB1551@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: Jeremy Linton , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next 1/9] net: phy: clean up cortina workaround MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 18 Jun 2020 14:45:32 +0100 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the Cortina PHY workaround out of the "devices in package" loop; it doesn't need to be in there as the control flow will terminate the loop once we enter the workaround irrespective of the workaround's outcome. The workaround is triggered by the ID being mostly 1's, which will in any case terminate the loop. Signed-off-by: Russell King --- drivers/net/phy/phy_device.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 04946de74fa0..c71dc2624c4b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -720,23 +720,21 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs); if (phy_reg < 0) return -EIO; + } + + if ((*devs & 0x1fffffff) == 0x1fffffff) { + /* If mostly Fs, there is no device there, then let's probe + * MMD 0, as some 10G PHYs have zero Devices In package, + * e.g. Cortina CS4315/CS4340 PHY. + */ + phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs); + if (phy_reg < 0) + return -EIO; + /* no device there, let's get out of here */ if ((*devs & 0x1fffffff) == 0x1fffffff) { - /* If mostly Fs, there is no device there, - * then let's continue to probe more, as some - * 10G PHYs have zero Devices In package, - * e.g. Cortina CS4315/CS4340 PHY. - */ - phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs); - if (phy_reg < 0) - return -EIO; - /* no device there, let's get out of here */ - if ((*devs & 0x1fffffff) == 0x1fffffff) { - *phy_id = 0xffffffff; - return 0; - } else { - break; - } + *phy_id = 0xffffffff; + return 0; } } From patchwork Thu Jun 18 13:45:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 217599 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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham 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 62ABFC433E0 for ; Thu, 18 Jun 2020 13:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CF3420897 for ; Thu, 18 Jun 2020 13:45:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="BCw2nW0B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730483AbgFRNpu (ORCPT ); Thu, 18 Jun 2020 09:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbgFRNpq (ORCPT ); Thu, 18 Jun 2020 09:45:46 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6786C06174E for ; Thu, 18 Jun 2020 06:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tFOv+YVPwjLJyVpWeYC1IcmmAnR5VK5kd8WjdRrUblE=; b=BCw2nW0B1SOdoEG9tq2vfaFpB5 p/x4zn47n1dLhm//Waf1EbttJMIuoYColb47l1MmQ4VuDuF9QNYstqs7P75C5So2wQDfb35sqr6lj rYtD0aQQB9MBYmr3N5kMYMx+F8Al9FEtivz2n6JldeAdmQebbojXrWWX77JAXpp5uISsEHT8r38r9 Hr7rdcVtaLJBADtYg50nOwjVtpVj2aR37cIg2Hdy7qrnSZRfdINsDxRsUjrhsmfk4CxzzrY2V1puw EemLRN2fmXsrahHDm9ItNla+ifXHHvsHNYnQdAWoiDRPSehEHSfKnlOfc3sa+YJt/Bf/rldbN0bNx XOVjgFZA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37646 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlurP-0005AW-7R; Thu, 18 Jun 2020 14:45:43 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jlurP-0004jn-08; Thu, 18 Jun 2020 14:45:43 +0100 In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk> References: <20200618134500.GB1551@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: Jeremy Linton , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next 3/9] net: phy: clean up get_phy_c45_ids() failure handling MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 18 Jun 2020 14:45:43 +0100 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When we decide that a PHY is not present, we do not need to go through the hoops of setting *phy_id to 0xffffffff, and then return zero to make get_phy_device() fail - we can return -ENODEV which will have the same effect. Doing so means we no longer have to pass a pointer to phy_id in, and we can then clean up the clause 22 path in a similar way. Reviewed-by: Florian Fainelli Signed-off-by: Russell King --- drivers/net/phy/phy_device.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a351eabe772f..e8dc9fcf188e 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -697,16 +697,16 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, * get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs. * @bus: the target MII bus * @addr: PHY address on the MII bus - * @phy_id: where to store the ID retrieved. * @c45_ids: where to store the c45 ID information. * - * If the PHY devices-in-package appears to be valid, it and the - * corresponding identifiers are stored in @c45_ids, zero is stored - * in @phy_id. Otherwise 0xffffffff is stored in @phy_id. Returns - * zero on success. + * Read the PHY "devices in package". If this appears to be valid, read + * the PHY identifiers for each device. Return the "devices in package" + * and identifiers in @c45_ids. * + * Returns zero on success, %-EIO on bus access error, or %-ENODEV if + * the "devices in package" is invalid. */ -static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, +static int get_phy_c45_ids(struct mii_bus *bus, int addr, struct phy_c45_device_ids *c45_ids) { const int num_ids = ARRAY_SIZE(c45_ids->device_ids); @@ -732,10 +732,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, return -EIO; /* no device there, let's get out of here */ - if ((*devs & 0x1fffffff) == 0x1fffffff) { - *phy_id = 0xffffffff; - return 0; - } + if ((*devs & 0x1fffffff) == 0x1fffffff) + return -ENODEV; } /* Now probe Device Identifiers for each device present. */ @@ -753,7 +751,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, return -EIO; c45_ids->device_ids[i] |= phy_reg; } - *phy_id = 0; + return 0; } @@ -809,7 +807,7 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids)); if (is_c45) - r = get_phy_c45_ids(bus, addr, &phy_id, &c45_ids); + r = get_phy_c45_ids(bus, addr, &c45_ids); else r = get_phy_c22_id(bus, addr, &phy_id); From patchwork Thu Jun 18 13:45:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 217598 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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham 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 C559FC433DF for ; Thu, 18 Jun 2020 13:45:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F95C2082F for ; Thu, 18 Jun 2020 13:45:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="v3WkQZjr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730494AbgFRNp4 (ORCPT ); Thu, 18 Jun 2020 09:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbgFRNp4 (ORCPT ); Thu, 18 Jun 2020 09:45:56 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0AE0C06174E for ; Thu, 18 Jun 2020 06:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oryfz0YuhzbuZg/1pIX6cfRuGPEDdepmwEcWH2Rmj8c=; b=v3WkQZjrwuT0vMsFY9E/AtkNQo BmlbD4LyYCa4N+Ef0Nu6UTz0oUqZ7IJTTgcf1j15ENbRFmxHpcmFK6JlpaNzJATXQJVIHgfQ7qJ5m kDYQY/BIzasbxP72qZ/4XGV5+Txqst7Q4g2e5WklpQiK7p8tlqyODyIgUCiL217FvxSDUvIQfQCr3 XJTwDZBP6HpQE0pB+gjlSFX84NdpRGZqHvY+K2M5fbgq6I2ADoE65jGKtel04qxwwyqPDa0lAHN2z HXSEzzEJyOmj71xtx/uVfIuyb9HfA/2vV+ABMcxDsO/MWSONEMSMwAmor2ahCo9dI3C8ZFviAr30w mIIExG+g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37652 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlurZ-0005As-Fw; Thu, 18 Jun 2020 14:45:53 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jlurZ-0004kE-8l; Thu, 18 Jun 2020 14:45:53 +0100 In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk> References: <20200618134500.GB1551@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: Jeremy Linton , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next 5/9] net: phy: reword get_phy_device() kerneldoc MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 18 Jun 2020 14:45:53 +0100 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Reword the get_phy_device() kerneldoc to be more explicit about how we probe for the PHY, and what the various return conditions signify. Reviewed-by: Florian Fainelli Signed-off-by: Russell King --- drivers/net/phy/phy_device.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 0e802c6add09..09096c3ceb86 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -800,8 +800,17 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) * @addr: PHY address on the MII bus * @is_c45: If true the PHY uses the 802.3 clause 45 protocol * - * Description: Reads the ID registers of the PHY at @addr on the - * @bus, then allocates and returns the phy_device to represent it. + * Probe for a PHY at @addr on @bus. + * + * When probing for a clause 22 PHY, then read the ID registers. If we find + * a valid ID, allocate and return a &struct phy_device. + * + * When probing for a clause 45 PHY, read the "devices in package" registers. + * If the "devices in package" appears valid, read the ID registers for each + * MMD, allocate and return a &struct phy_device. + * + * Returns an allocated &struct phy_device on success, %-ENODEV if there is + * no PHY present, or %-EIO on bus access error. */ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) { From patchwork Thu Jun 18 13:46:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 217597 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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham 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 1B9BDC433DF for ; Thu, 18 Jun 2020 13:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB1292082F for ; Thu, 18 Jun 2020 13:46:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="qvgIF6FL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730509AbgFRNqG (ORCPT ); Thu, 18 Jun 2020 09:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbgFRNqG (ORCPT ); Thu, 18 Jun 2020 09:46:06 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE67DC06174E for ; Thu, 18 Jun 2020 06:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QzRQrOdnhxiJG1ol77C1+vh3e2NLJm2naHErfJ0MsVc=; b=qvgIF6FL/YnSOGexRIXtpc6anl YxSqu788C000MWbvT/UDk9jvYHNvKz4N3CbJKHGIfTwk1yBK62AI3EpsczW+edLhl/Lu67FQ84cGc p27SIEtrM3+zqcwcHP9lpD7TfTesZdRVVjQaROpzbZNzOe00WbdwCQIQThC51Z4KolNi1O99Ab4sJ 5ATZhP3wjA+VquPaQLwJEhRW3q2r/DLKlS0hYNoU/Y6o+gyND6kgjADvfP4Crf2Nq4f/miBjMZcAC /n4zAdETomI+cMh+3JXkS+I6c0BmufUJeGuDGTObvWgx+Z+35ISZeq8yURm0AS1hOvFj6KiXmmsR5 s5Xaqc6Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37656 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlurj-0005BF-Nw; Thu, 18 Jun 2020 14:46:03 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jlurj-0004kd-Gl; Thu, 18 Jun 2020 14:46:03 +0100 In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk> References: <20200618134500.GB1551@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: Jeremy Linton , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next 7/9] net: phy: set devices_in_package only after validation MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 18 Jun 2020 14:46:03 +0100 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Only set the devices_in_package to a non-zero value if we find a valid value for this field, so we avoid leaving it set to e.g. 0x1fffffff. Reviewed-by: Florian Fainelli Signed-off-by: Russell King --- drivers/net/phy/phy_device.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8d9af2772853..8e11e3d3a801 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -732,13 +732,13 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, struct phy_c45_device_ids *c45_ids) { const int num_ids = ARRAY_SIZE(c45_ids->device_ids); - u32 *devs = &c45_ids->devices_in_package; + u32 devs_in_pkg = 0; int i, ret, phy_reg; /* Find first non-zero Devices In package. Device zero is reserved * for 802.3 c45 complied PHYs, so don't probe it at first. */ - for (i = 1; i < MDIO_MMD_NUM && *devs == 0; i++) { + for (i = 1; i < MDIO_MMD_NUM && devs_in_pkg == 0; i++) { if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) { /* Check that there is a device present at this * address before reading the devices-in-package @@ -753,28 +753,28 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, if (!ret) continue; } - phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs); + phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, &devs_in_pkg); if (phy_reg < 0) return -EIO; } - if ((*devs & 0x1fffffff) == 0x1fffffff) { + if ((devs_in_pkg & 0x1fffffff) == 0x1fffffff) { /* If mostly Fs, there is no device there, then let's probe * MMD 0, as some 10G PHYs have zero Devices In package, * e.g. Cortina CS4315/CS4340 PHY. */ - phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs); + phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, &devs_in_pkg); if (phy_reg < 0) return -EIO; /* no device there, let's get out of here */ - if ((*devs & 0x1fffffff) == 0x1fffffff) + if ((devs_in_pkg & 0x1fffffff) == 0x1fffffff) return -ENODEV; } /* Now probe Device Identifiers for each device present. */ for (i = 1; i < num_ids; i++) { - if (!(c45_ids->devices_in_package & (1 << i))) + if (!(devs_in_pkg & (1 << i))) continue; phy_reg = mdiobus_c45_read(bus, addr, i, MII_PHYSID1); @@ -788,6 +788,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, c45_ids->device_ids[i] |= phy_reg; } + c45_ids->devices_in_package = devs_in_pkg; + return 0; } From patchwork Thu Jun 18 13:46:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 217596 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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham 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 B38DBC433DF for ; Thu, 18 Jun 2020 13:46:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FE402082F for ; Thu, 18 Jun 2020 13:46:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="Ya8xyPdc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730359AbgFRNqR (ORCPT ); Thu, 18 Jun 2020 09:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbgFRNqQ (ORCPT ); Thu, 18 Jun 2020 09:46:16 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6DD5C06174E for ; Thu, 18 Jun 2020 06:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GiFQJ9YH36TkCMUWPJFGLeZZczOGx1FEnxudIbi89Yo=; b=Ya8xyPdc7heG7HgJafivIXApIF SDD3r7e/g3inUrAcTRCi4nuIUQ1r3Gq5c7Eo5NIRixFWXQvSNsInUSdZZ1f776tbEPAvtPaBHFWMZ 6QvgN9dCg0vY223MYyqqzoomybB7DDEboFsn72i9zYM2OBncOsUnNssv78WJ001ii3bOVmE9gM4i7 XLJPLgpzVr0t/PWHCVGI1suSKDJJCrvMnPW6keIQjD3xADR+n3k09PV7N1pRdH0AK3ateHBnKfFlh JJ7EqknIjkchSnWcEalAXX2KEFrF4zGt6UFufAZBUBn8nOiqU3R0M+SKVsihqLH49vseRQCXliBSK RhilfWaQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37660 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jluru-0005Bb-0e; Thu, 18 Jun 2020 14:46:14 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jlurt-0004l4-PS; Thu, 18 Jun 2020 14:46:13 +0100 In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk> References: <20200618134500.GB1551@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: Jeremy Linton , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next 9/9] net: phy: read MMD ID from all present MMDs MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 18 Jun 2020 14:46:13 +0100 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Expand the device_ids[] array to allow all MMD IDs to be read rather than just the first 8 MMDs, but only read the ID if the MDIO_STAT2 register reports that a device really is present here for these new devices to maintain compatibility with our current behaviour. Note that only a limited number of devices have MDIO_STAT2. 88X3310 PHY vendor MMDs do are marked as present in the devices_in_package, but do not contain IEE 802.3 compatible register sets in their lower space. This avoids reading incorrect values as MMD identifiers. Reviewed-by: Florian Fainelli Signed-off-by: Russell King --- drivers/net/phy/phy_device.c | 13 +++++++++++++ include/linux/phy.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index c1f81c4d0bb3..29ef4456ac25 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -774,6 +774,19 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, if (!(devs_in_pkg & (1 << i))) continue; + if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) { + /* Probe the "Device Present" bits for the vendor MMDs + * to ignore these if they do not contain IEEE 802.3 + * registers. + */ + ret = phy_c45_probe_present(bus, addr, i); + if (ret < 0) + return ret; + + if (!ret) + continue; + } + phy_reg = mdiobus_c45_read(bus, addr, i, MII_PHYSID1); if (phy_reg < 0) return -EIO; diff --git a/include/linux/phy.h b/include/linux/phy.h index 19d9e040ad84..9248dd2ce4ca 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -399,7 +399,7 @@ enum phy_state { struct phy_c45_device_ids { u32 devices_in_package; u32 mmds_present; - u32 device_ids[8]; + u32 device_ids[MDIO_MMD_NUM]; }; struct macsec_context;