Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1378281pxk; Thu, 10 Sep 2020 13:54:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHQlSW5xHLrV69+3mxN3sipikspw2F6PFxg/IGZkRoofz0oQYlddZTwkBfl6rzYw8oZEhl X-Received: by 2002:a50:e3c4:: with SMTP id c4mr11746263edm.90.1599771249116; Thu, 10 Sep 2020 13:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599771249; cv=none; d=google.com; s=arc-20160816; b=ZfxXEF7aM+qhSb98ncNmwHNS7Nic1cKApNG+R+YEl3jYLfvBgR/vIWoSy2PCb5tbkp 6q/EoaVYMjSoYWljF8jn1tr+H8UJfyY7yGvOkQAQY7qyfxYfx4gJSzsM/V+RVEx6z3/3 C/typedRmCenvEAX1acN8knR9YW46AJ1DY0mz752P2hLoQkgzvuO1Cj3M1Yvu0kRdgrQ iK4kleXhSQ3ECLKnddSP0B9hk+6x+sLko3YdIdtExsWo7PQipXT0sVty0ZcMhxDJkv4U SbKQXldoTQxmRcYiT785zT3B/J8crjsod1BrVvCeKJnu+9dKCys0ECsnRdTf/c/Czz+i 1sFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=t7k46oT9pdpc2te28RZVzUBs6yLYoN9qqxmc9rN0uSU=; b=T9yI1EyN3DPbDP0XL6k70Y//EqfvSSFduKYr+mZSeVsciiyLgUg9BSI0fvHxcyEj6T vEGBLcmxpNYb+4JWk/fNetucodtTpeFIiEk2oNrxGQDFoFhU2K3Cc007vTbo98LEk86A W3UjF2IjjsQ3jHq7mvrIIeqSm7/cs9qAh+yuvQik9NS1oXYtuADdceFmQK19NJaPdn3e 3MMoFGKA7f8AiqSNhbL2+g43vVNICULTedUw/rQelRvHetPOgFd+RJZptRUlbJPN/7MU hMKuuQqWEq7bTrgwJNbX1q2noiE7pUylfM57NlDxCw+POmY/Y5L/K/E/WvWqqXZKaifE VjJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=undEP0rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si4201165edm.239.2020.09.10.13.53.46; Thu, 10 Sep 2020 13:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=undEP0rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgIJUxK (ORCPT + 99 others); Thu, 10 Sep 2020 16:53:10 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:59268 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgIJUwn (ORCPT ); Thu, 10 Sep 2020 16:52:43 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 08AKqcEd034925; Thu, 10 Sep 2020 15:52:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1599771158; bh=t7k46oT9pdpc2te28RZVzUBs6yLYoN9qqxmc9rN0uSU=; h=From:To:CC:Subject:Date; b=undEP0rsph6DlL2R+xPaLD+9BEhykMfEuAMAd6MROCbwOSHDWlrrnxbB2P5w7PM7S NYHBw2TKvjWRWN7pRFQzEzdgP4qtgc5lGZeobOXAJ3oND4Gwv90iwbMjpGviciHhTO NfwwqW5fkZ9i0gdky4FFT9Fu/kM0rtmzQm1Evst4= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 08AKqc5J089725; Thu, 10 Sep 2020 15:52:38 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 10 Sep 2020 15:52:38 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 10 Sep 2020 15:52:38 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 08AKqbEN070224; Thu, 10 Sep 2020 15:52:37 -0500 From: Grygorii Strashko To: "David S. Miller" , , Jakub Kicinski CC: , , Grygorii Strashko Subject: [PATCH] net: ethernet: ti: cpsw_new: fix suspend/resume Date: Thu, 10 Sep 2020 23:52:29 +0300 Message-ID: <20200910205229.21288-1-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add missed suspend/resume callbacks to properly restore networking after suspend/resume cycle. Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac") Signed-off-by: Grygorii Strashko --- drivers/net/ethernet/ti/cpsw_new.c | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 8ed78577cded..15672d0a4de6 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -2070,9 +2071,61 @@ static int cpsw_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused cpsw_suspend(struct device *dev) +{ + struct cpsw_common *cpsw = dev_get_drvdata(dev); + int i; + + rtnl_lock(); + + for (i = 0; i < cpsw->data.slaves; i++) { + struct net_device *ndev = cpsw->slaves[i].ndev; + + if (!(ndev && netif_running(ndev))) + continue; + + cpsw_ndo_stop(ndev); + } + + rtnl_unlock(); + + /* Select sleep pin state */ + pinctrl_pm_select_sleep_state(dev); + + return 0; +} + +static int __maybe_unused cpsw_resume(struct device *dev) +{ + struct cpsw_common *cpsw = dev_get_drvdata(dev); + int i; + + /* Select default pin state */ + pinctrl_pm_select_default_state(dev); + + /* shut up ASSERT_RTNL() warning in netif_set_real_num_tx/rx_queues */ + rtnl_lock(); + + for (i = 0; i < cpsw->data.slaves; i++) { + struct net_device *ndev = cpsw->slaves[i].ndev; + + if (!(ndev && netif_running(ndev))) + continue; + + cpsw_ndo_open(ndev); + } + + rtnl_unlock(); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(cpsw_pm_ops, cpsw_suspend, cpsw_resume); + static struct platform_driver cpsw_driver = { .driver = { .name = "cpsw-switch", + .pm = &cpsw_pm_ops, .of_match_table = cpsw_of_mtable, }, .probe = cpsw_probe, -- 2.17.1