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=-5.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 9F77EC4338F for ; Mon, 9 Aug 2021 11:08:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 668ED60F8F for ; Mon, 9 Aug 2021 11:08:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 668ED60F8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Fn9FARNMUv5tXub4qbjs7eRWu9Icm3x3MjP83j/MlAE=; b=BqGA0F/NOr+x5Z C0QA/33aAq4pcL6ngO59wfgzD3ex/hm1TY0UDsJrK4K3CLe+DTCF0bjL9BGuE9zY7p71HkJcUgaLZ nEe30/Ah3WsLNhAaqx7bdR5h9t6a29G6A9Azg/3MRMkeWNuceLNoqRUpwYugP7uUTiArMm3ZTwfVi 1/6PPJTWEYKVr+7Fc0pbiABv47xPhF/bHmlby1XF6Bk7iWvCkhw0iTn/cH0fygMCKowhIbpnTkvdY 8Hjlom0X4CdsYYorPjNZ85UgGBtuVWHlYjnfkZYItvcKcbM4OueDjwXWVyP0Ts5F3fULFfhRt/VnR r3fBLkJ2qq0n6mNKIiNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD374-000I81-8P; Mon, 09 Aug 2021 11:06:34 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD36z-000I6i-Tr for linux-arm-kernel@lists.infradead.org; Mon, 09 Aug 2021 11:06:31 +0000 Received: by mail-ed1-x52b.google.com with SMTP id y12so23940867edo.6 for ; Mon, 09 Aug 2021 04:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rqeeHdFchIP+lwGA3HCPDFYMIAiS+hDBXIwLFpK/6FQ=; b=LysAVhcZN4VamA6w0Bt5EA0pSwuLmjl6mFBc/WjwCp/VqGiUwNjWfZf+MhmKZtOETw NXGKJAz5m9eVz6OiSPVACZT+rT+XxT9zEdF0EriCtD5gm4a7GEetlFWQzj6UN3PMeWhh l1IyPQJ3D/iQnXzP1kKr0QKGoRrvNXSD5HbPlxM7xaLiVVRvzguIV7MJbEJihqnXezPW o1FIsieBqIKuaJR/QkjKApmwu3qm69u5ETCRQEs5TTE9ynCckJn9tr2guVVeNzIj43sy uBlbv947wJyiIOT6HeEehYqivl79V7Fj1IkWNV5LeGz6N9ZG91KxXwIfspe8YayhpTht giUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rqeeHdFchIP+lwGA3HCPDFYMIAiS+hDBXIwLFpK/6FQ=; b=AR0j4ekWUFl1hEAzU/YKF7y2myCX8n5jFg+cgWTdetawu7yrxmfGuz0V40lZKxk8hN HZ9k5VdjdTFxsKiNG5ZureBfaLj3lVaXDs+dbQIW9+II+v7UDb4/XpaLUEYpAlNtZKBI i/LZmC2ricNskHxygc3tkDkgLdglF67ypAb6UcfaxxAZSbHlln1VHMbfiXQMgnQGtidE ei/eX94z0pg7vWLVYmrLa50ySl/TRTWH9BSuUaFiHIHVAcUvjIK4oOL+k0KOPjXSvw+m 9DtWcNkuYWcwknFG04gyO0bPq6G2JcG2v8qCbobyLJ99duvuw3ithuYD7iNHZqSgRD4q x1ng== X-Gm-Message-State: AOAM532+vbfgYl9Sls/Wflk2PzZKMPEuuseObchNWIiiPLVHvnIWK6zZ YOcThA4cw/gF0OMmnkjz6NA= X-Google-Smtp-Source: ABdhPJyH0j2dqKqb+c+DaZqSChnn1pBcE8AI4Vi7lk9pC1/kUS7xkWpuQsFpG0Z1NuGIataB+B6pYg== X-Received: by 2002:a50:fc96:: with SMTP id f22mr6964806edq.367.1628507188420; Mon, 09 Aug 2021 04:06:28 -0700 (PDT) Received: from skbuf ([188.25.144.60]) by smtp.gmail.com with ESMTPSA id y23sm5794648ejp.115.2021.08.09.04.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 04:06:28 -0700 (PDT) Date: Mon, 9 Aug 2021 14:06:26 +0300 From: Vladimir Oltean To: Wong Vee Khee Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S . Miller" , Jakub Kicinski , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King , Voon Weifeng , Michael Sit Wei Hong , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset Message-ID: <20210809110626.4kfkegwixiualq2x@skbuf> References: <20210809102229.933748-1-vee.khee.wong@linux.intel.com> <20210809102229.933748-2-vee.khee.wong@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210809102229.933748-2-vee.khee.wong@linux.intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210809_040630_019138_1A133E15 X-CRM114-Status: GOOD ( 26.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi VK, On Mon, Aug 09, 2021 at 06:22:28PM +0800, Wong Vee Khee wrote: > diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c > index 63fda3fc40aa..c7a3aa862079 100644 > --- a/drivers/net/pcs/pcs-xpcs.c > +++ b/drivers/net/pcs/pcs-xpcs.c > @@ -1081,7 +1081,8 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { > }; > > struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > - phy_interface_t interface) > + phy_interface_t interface, > + bool skip_reset) > { > struct dw_xpcs *xpcs; > u32 xpcs_id; > @@ -1113,9 +1114,16 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > xpcs->pcs.ops = &xpcs_phylink_ops; > xpcs->pcs.poll = true; > > - ret = xpcs_soft_reset(xpcs, compat); > - if (ret) > - goto out; > + if (!skip_reset) { > + dev_info(&xpcs->mdiodev->dev, "%s: xPCS soft reset\n", > + __func__); > + ret = xpcs_soft_reset(xpcs, compat); > + if (ret) > + goto out; > + } else { > + dev_info(&xpcs->mdiodev->dev, > + "%s: skip xpcs soft reset\n", __func__); > + } I don't feel like the prints are really necessary. > > return xpcs; > } > diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h > index add077a81b21..0c05a63f3446 100644 > --- a/include/linux/pcs/pcs-xpcs.h > +++ b/include/linux/pcs/pcs-xpcs.h > @@ -36,7 +36,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, > int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, > int enable); > struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > - phy_interface_t interface); > + phy_interface_t interface, > + bool xpcs_reset); > void xpcs_destroy(struct dw_xpcs *xpcs); > How about exporting the reset functionality as a separate function, and the Intel Alder Lake stmmac shim just won't call it? Like this: -----------------------------[ cut here ]----------------------------- diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c index 19aea8fb76f6..5acf6742da4d 100644 --- a/drivers/net/dsa/sja1105/sja1105_mdio.c +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c @@ -437,13 +437,17 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) goto out_pcs_free; } - xpcs = xpcs_create(mdiodev, priv->phy_mode[port]); + xpcs = xpcs_create(mdiodev); if (IS_ERR(xpcs)) { rc = PTR_ERR(xpcs); goto out_pcs_free; } priv->xpcs[port] = xpcs; + + rc = xpcs_reset(xpcs, priv->phy_mode[port]); + if (rc) + goto out_pcs_free; } priv->mdio_pcs = bus; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index a5d150c5f3d8..81a145009488 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -401,12 +401,15 @@ int stmmac_xpcs_setup(struct mii_bus *bus) { struct net_device *ndev = bus->priv; struct mdio_device *mdiodev; + bool skip_xpcs_soft_reset; struct stmmac_priv *priv; struct dw_xpcs *xpcs; int mode, addr; + int err; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; + skip_xpcs_soft_reset = priv->plat->skip_xpcs_soft_reset; /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { @@ -414,12 +417,21 @@ int stmmac_xpcs_setup(struct mii_bus *bus) if (IS_ERR(mdiodev)) continue; - xpcs = xpcs_create(mdiodev, mode); + xpcs = xpcs_create(mdiodev); if (IS_ERR_OR_NULL(xpcs)) { mdio_device_free(mdiodev); continue; } + if (!skip_xpcs_soft_reset) { + err = xpcs_reset(xpcs, mode); + if (err) { + xpcs_destroy(xpcs); + mdio_device_free(mdiodev); + continue; + } + } + priv->hw->xpcs = xpcs; break; } diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 63fda3fc40aa..2e721e57bee4 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -248,6 +248,18 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs, return xpcs_poll_reset(xpcs, dev); } +int xpcs_reset(struct dw_xpcs *xpcs, phy_interface_t interface) +{ + const struct xpcs_compat *compat; + + compat = xpcs_find_compat(xpcs->id, interface); + if (!compat) + return -ENODEV; + + return xpcs_soft_reset(xpcs, compat); +} +EXPORT_SYMBOL_GPL(xpcs_reset); + #define xpcs_warn(__xpcs, __state, __args...) \ ({ \ if ((__state)->link) \ @@ -1080,12 +1092,11 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; -struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, - phy_interface_t interface) +struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev) { struct dw_xpcs *xpcs; u32 xpcs_id; - int i, ret; + int i; xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); if (!xpcs) @@ -1097,35 +1108,18 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { const struct xpcs_id *entry = &xpcs_id_list[i]; - const struct xpcs_compat *compat; if ((xpcs_id & entry->mask) != entry->id) continue; xpcs->id = entry; - - compat = xpcs_find_compat(entry, interface); - if (!compat) { - ret = -ENODEV; - goto out; - } - xpcs->pcs.ops = &xpcs_phylink_ops; xpcs->pcs.poll = true; - ret = xpcs_soft_reset(xpcs, compat); - if (ret) - goto out; - return xpcs; } - ret = -ENODEV; - -out: - kfree(xpcs); - - return ERR_PTR(ret); + return ERR_PTR(-ENODEV); } EXPORT_SYMBOL_GPL(xpcs_create); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index add077a81b21..d841f55f12cc 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -35,8 +35,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, struct phylink_link_state *state); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); -struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, - phy_interface_t interface); +int xpcs_reset(struct dw_xpcs *xpcs, phy_interface_t interface); +struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev); void xpcs_destroy(struct dw_xpcs *xpcs); #endif /* __LINUX_PCS_XPCS_H */ diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index a6f03b36fc4f..0f901773c5e4 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -268,5 +268,6 @@ struct plat_stmmacenet_data { int msi_rx_base_vec; int msi_tx_base_vec; bool use_phy_wol; + bool skip_xpcs_soft_reset; }; #endif -----------------------------[ cut here ]----------------------------- I also gave this patch a run on sja1105 and it still works. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel