From patchwork Thu Sep 10 20:52:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 249681 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp1084677ilk; Thu, 10 Sep 2020 13:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK1YGx4dRtMc2nhWzxHMn5VBGJsHW30dMg4BtSP4BYxHor9SbUAlyWbX2ZBh6H8M4cPahF X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr11435737ejf.368.1599771202844; Thu, 10 Sep 2020 13:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599771202; cv=none; d=google.com; s=arc-20160816; b=V4PAL6PociItFA9laNgeKKErKMDFKsgq5sEIBsr7Vvhpvybt27y71iGjRqbeg1D4dU SRZ39k1l6inJUGhTAkD/CvdQHriOvWNx7NJcXKBd32q7I/rKoRNr0aXH1coZDbjU3QwD o8e099F0j/tmbmf3nmcV/gzBGz9MpT44Ml1+Mo01WljbTPYrN1Pum6cIXn55Hf9K9oIG klDTksDodBJ8o+xiRUqo2TP015UXQl2NVr0x7baMkbY56fG19gybGBO+M7OyoS4JuNOI OVOfKYqmW73MUfdwlRVvX+sWeSuBcwexIgkMpUDYzavM2U7pfU6BKPqlz8kc55p8vpwB UZiA== 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=0qOcUtnUEJPotHKBVYQSW8SY5i1Wk3N1sIK9TTfyrPECKX1nZ7VHFJEqvUO48kkW5G lI14djctiEY973ka8dBCNC8G4riJnLBBml9JG9iX/VkR/nyjvM3Bsn0rPVFwORP9lCJP G7T9U5cPkNcg8viqdBzXRHmR0LZ51mavwGq7F9mP7uma9ooagiEO+mHyfxIwtRDI6V9A 5BtI6cIomVrQzv+3rw3YVQs/c8vLqijFvCHJL/uIm81nC0FkW0L5z9t/i2vFRDzM/hpk rp8/YabE2I92mO6mqPkuczgx90GzleH+4KFm2Vd7yJOsjH9SmB7kAtx6Qr8jRfFSuGrU qVAg== 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 netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 n21si4426471edr.327.2020.09.10.13.53.22; Thu, 10 Sep 2020 13:53:22 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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 netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S1726301AbgIJUxR (ORCPT + 8 others); Thu, 10 Sep 2020 16:53:17 -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 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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(+) -- 2.17.1 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,