From patchwork Thu Apr 21 18:19:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David Rivshin (Allworx)" X-Patchwork-Id: 8903381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4745ABF29F for ; Thu, 21 Apr 2016 18:22:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5750C202EC for ; Thu, 21 Apr 2016 18:22:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61A30202E9 for ; Thu, 21 Apr 2016 18:22:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1atJDp-000816-El; Thu, 21 Apr 2016 18:21:01 +0000 Received: from mail-qg0-x241.google.com ([2607:f8b0:400d:c04::241]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atJDm-0007vX-Pl for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2016 18:20:59 +0000 Received: by mail-qg0-x241.google.com with SMTP id f74so7035350qge.3 for ; Thu, 21 Apr 2016 11:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ty7agvjckPonPfWLQwHqM8vhHKHOYXoo30dRqbyeeHM=; b=Sso+ay3BYiWTTBw1mc6z6aV2XbpQEPnyv9ITLY8f3GTHBQBb5ypwdJ2Vtx9vohQGl4 m+OLB6Vg7Tgcd4m8iwFerpwCp65HNGuZUILLlSRGmKNl0QdK2tq27aqFll2nc29+eJ7w XFlGEXJnE9E3iCK2KyBt3YhfHMfWk4oJMPQ193q8jMN215sBP90F734wVxSg4geqKrAS Mt6CrbUwiDPJ+Qc672HWcqHUPP3bMfuiQrCtFuoo5JA2NseQ6ezpNR4/DG5yxceIo07F eaRt12ZDdmlGHfolkcQLt0bcvsTdGho28mXqKnsitD46wgwZXx6s7okl2tQVtTHtpf3W m59w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ty7agvjckPonPfWLQwHqM8vhHKHOYXoo30dRqbyeeHM=; b=cAGGtUCIAHmhaGV/L+gM2kjlwudyFP2oshe9qOBu2XPswpnWxZy5fCus4EPyibziKs rrGY6nXXvfTuoCjNFGqsacFiOoQ8v3VlIhhIBdhFexGlZRMCsGz1CprpsMR0w3abXpEF Ce9dAr4dWodE8TAr+tbDgLWiviLlAFLP8fNfT/XR4nmAqErLyOXyWuMZTmk9JiELTVM3 ZvkPdMUI2BtJ/cg+TOlgRetBKUDd2OxiyQhHKBzrZUoBlElHvA5G7sIY7BqssoK1Tjms E6M8ivVUsvkyELwNHQjrgSvVJd5v6hz2KOFf/YxTqsB8vjBkp1ozcbWbIzp/k9CLY7vi gPCQ== X-Gm-Message-State: AOPr4FUldUZP62UaOqFkQnu9+gTOeV9BryQ/MjYta8vX89WhR5x+jUPJPCM+Xf1izUv+gA== X-Received: by 10.140.100.225 with SMTP id s88mr17907093qge.76.1461262837758; Thu, 21 Apr 2016 11:20:37 -0700 (PDT) Received: from drivshin-linux.crosskeys.inscitek.com ([24.213.148.66]) by smtp.gmail.com with ESMTPSA id y89sm926548qgd.5.2016.04.21.11.20.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2016 11:20:37 -0700 (PDT) From: "David Rivshin (Allworx)" To: netdev@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH net v2 1/3] drivers: net: cpsw: fix parsing of phy-handle DT property in dual_emac config Date: Thu, 21 Apr 2016 14:19:54 -0400 Message-Id: <1461262794-9562-1-git-send-email-drivshin.allworx@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461261035-5578-1-git-send-email-drivshin.allworx@gmail.com> References: <1461261035-5578-1-git-send-email-drivshin.allworx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160421_112058_920029_319DA760 X-CRM114-Status: GOOD ( 16.79 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Brunner , devicetree@vger.kernel.org, Grygorii Strashko , Mugunthan V N , Nicolas Chauvet , linux-kernel@vger.kernel.org, Andrew Goodbody , David Miller , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Rivshin Commit 9e42f715264ff158478fa30eaed847f6e131366b ("drivers: net: cpsw: add phy-handle parsing") saved the "phy-handle" phandle into a new cpsw_priv field. However, phy connections are per-slave, so the phy_node field should be in cpsw_slave_data rather than cpsw_priv. This would go unnoticed in a single emac configuration. But in dual_emac mode, the last "phy-handle" property parsed for either slave would be used by both of them, causing them both to refer to the same phy_device. Fixes: 9e42f715264f ("drivers: net: cpsw: add phy-handle parsing") Signed-off-by: David Rivshin Tested-by: Nicolas Chauvet Reviewed-by: Grygorii Strashko --- I would suggest this for -stable. It should apply cleanly as far back as 4.4. Changes since v1 [1]: - Rebased (no conflicts) - Added Tested-by from Nicolas Chauvet [1] https://patchwork.ozlabs.org/patch/560326/ drivers/net/ethernet/ti/cpsw.c | 13 ++++++------- drivers/net/ethernet/ti/cpsw.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 42fdfd4..d69cb3f 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -363,15 +363,14 @@ static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset) __raw_writel(val, slave->regs + offset); } struct cpsw_priv { spinlock_t lock; struct platform_device *pdev; struct net_device *ndev; - struct device_node *phy_node; struct napi_struct napi_rx; struct napi_struct napi_tx; struct device *dev; struct cpsw_platform_data data; struct cpsw_ss_regs __iomem *regs; struct cpsw_wr_regs __iomem *wr_regs; u8 __iomem *hw_stats; @@ -1144,16 +1143,16 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) if (priv->data.dual_emac) cpsw_add_dual_emac_def_ale_entries(priv, slave, slave_port); else cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); - if (priv->phy_node) - slave->phy = of_phy_connect(priv->ndev, priv->phy_node, + if (slave->data->phy_node) + slave->phy = of_phy_connect(priv->ndev, slave->data->phy_node, &cpsw_adjust_link, 0, slave->data->phy_if); else slave->phy = phy_connect(priv->ndev, slave->data->phy_id, &cpsw_adjust_link, slave->data->phy_if); if (IS_ERR(slave->phy)) { dev_err(priv->dev, "phy %s not found on slave %d\n", slave->data->phy_id, slave->slave_num); @@ -1936,20 +1935,19 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv, slave->data = data; slave->regs = regs + slave_reg_ofs; slave->sliver = regs + sliver_reg_ofs; slave->port_vlan = data->dual_emac_res_vlan; } -static int cpsw_probe_dt(struct cpsw_priv *priv, +static int cpsw_probe_dt(struct cpsw_platform_data *data, struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct device_node *slave_node; - struct cpsw_platform_data *data = &priv->data; int i = 0, ret; u32 prop; if (!node) return -EINVAL; if (of_property_read_u32(node, "slaves", &prop)) { @@ -2029,15 +2027,16 @@ static int cpsw_probe_dt(struct cpsw_priv *priv, int lenp; const __be32 *parp; /* This is no slave child node, continue */ if (strcmp(slave_node->name, "slave")) continue; - priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); + slave_data->phy_node = of_parse_phandle(slave_node, + "phy-handle", 0); parp = of_get_property(slave_node, "phy_id", &lenp); if (of_phy_is_fixed_link(slave_node)) { struct device_node *phy_node; struct phy_device *phy_dev; /* In the case of a fixed PHY, the DT node associated * to the PHY is the Ethernet MAC DT node. @@ -2271,15 +2270,15 @@ static int cpsw_probe(struct platform_device *pdev) * This may be required here for child devices. */ pm_runtime_enable(&pdev->dev); /* Select default pin state */ pinctrl_pm_select_default_state(&pdev->dev); - if (cpsw_probe_dt(priv, pdev)) { + if (cpsw_probe_dt(&priv->data, pdev)) { dev_err(&pdev->dev, "cpsw: platform data missing\n"); ret = -ENODEV; goto clean_runtime_disable_ret; } data = &priv->data; if (is_valid_ether_addr(data->slave_data[0].mac_addr)) { diff --git a/drivers/net/ethernet/ti/cpsw.h b/drivers/net/ethernet/ti/cpsw.h index 442a703..e50afd1 100644 --- a/drivers/net/ethernet/ti/cpsw.h +++ b/drivers/net/ethernet/ti/cpsw.h @@ -14,14 +14,15 @@ #ifndef __CPSW_H__ #define __CPSW_H__ #include #include struct cpsw_slave_data { + struct device_node *phy_node; char phy_id[MII_BUS_ID_SIZE]; int phy_if; u8 mac_addr[ETH_ALEN]; u16 dual_emac_res_vlan; /* Reserved VLAN for DualEMAC */ }; struct cpsw_platform_data {