Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1888462ybd; Sun, 23 Jun 2019 19:17:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhwpraqSvGaFJHiJQkbXFkIZewN9oHryXSVxEmfty+Wxzv1IotCzf8QAfZZO1cR47VYnwP X-Received: by 2002:a17:902:341:: with SMTP id 59mr91488162pld.20.1561342621237; Sun, 23 Jun 2019 19:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561342621; cv=none; d=google.com; s=arc-20160816; b=ruSLtJ2oWTXOA4CfqhTZ1Wt8llSqec8tczUTy5Ytvr3UjktBBkqWelBEKrQVWNORtZ OLRCVoBEm6KrF708v+eo4GeT7pRFl2uaSJF/qhrtWyEMAwor+cxgh+qhJP/UXqxsouvF TdzzhCZq3kg47+V9kF8cA4+yT4ClsDCs3XehGICe67+plz+lCdTADxyqiiLo4ooefat8 jKa6VlDpD8SjgnK20RSTfEAXXfMT/rvnsZngMzXsNj+wmYK4S7akGc1kai2003Ne/Zfx oTCNMIPnDe3nX/ShuZP348MTXFDI69kt21feFXaFXYdxb27Ej3FZtLK1aeW+1V1tEbKn L3kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=Q7wz2t7u/9aK1bNPZ479OzccMgC+SVvO9ZTRTaDQNLE=; b=Affsh/tzpYHA8SwIwW0pk4YezTTN1BEdoC5rbsnEvxAEFCJW4PMGpurTuPjr2dMQB5 SZSLcXcrPcVsYaj8vj+DagiljoYgxePDxRvPSASAgpAojHovxuyckyvLGS3BwuQqG1Rx XDM859IkXzr0F7JViK1+OOR/MLnoqvjsGr0nxnUpU/id4IVBB6Mg1qyZDIAMxrTYcZl2 tS0BpP9a+5WFKUOwwOBmCfjF3pwi6RART9b4vdH+AOIrY/fOzmx7U6q7Rwm38s+GtaaS tHEsqbrfN7HdHXScinVm1gvkJAX81lnygoKteKx4BjxZID64suXY1NflvLc8jnZKrLf1 wl0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wYbpjEsl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si8872651pgk.52.2019.06.23.19.16.45; Sun, 23 Jun 2019 19:17:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wYbpjEsl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbfFXCOu (ORCPT + 99 others); Sun, 23 Jun 2019 22:14:50 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:44107 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbfFXCOu (ORCPT ); Sun, 23 Jun 2019 22:14:50 -0400 Received: by mail-lj1-f193.google.com with SMTP id k18so10938464ljc.11 for ; Sun, 23 Jun 2019 19:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Q7wz2t7u/9aK1bNPZ479OzccMgC+SVvO9ZTRTaDQNLE=; b=wYbpjEslFKzGNA9UaWsVFJoVeLBrAL2HmRatz8rnXjHTni7OJoRzaBqf+1rBIdEwZw Cx9pdmsZUDC/a+Q7OsWMnQCi4PH5CB8Hre6I0gStJ4XwjEoTZWjf+E2fZ0aa75ILq1/o 5wQyQz/YYBAYTpy4i6neEfHrjZqOG4vYDJ9qpJkyij231cxbv15bxsfnyKiSoUmIandO iyzVrAmOx/iZrCrvom9Y7aLJOvkdw6HJLoe1pee4JERvMzXQ4SMrE/9CBfFDcd5XSRr0 ohuRCeg1XcOtmzKkZuVvV0xc9FQ6fNxv9yFvl9g5WAEjwm7x/GUrIV2kDIWoxEcWo2ZL ICHw== 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 :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Q7wz2t7u/9aK1bNPZ479OzccMgC+SVvO9ZTRTaDQNLE=; b=eY4PEdWk1U93ipCMmjCXIvsJYLh4r3wtnPg3UMWrhkhxRoKK+FxA2PlqabjtYmaCr1 KF0E3rvLKYGqM7YIEvvpv/V0yLjpoAFwfclESXpzzwrMJzpCX7r4Ot9ytgriMvu5zEZS 4GCpUfEOg9b62n0CCUaXyU6A96PosJxVLx9SukvOydl9HRaI3F90Hh4ExVu40Y2stkmL Daa9Y6UaVUZjKjHQI9A2irw+fZDln6zs+FCQvdzM1qhNfZ1/5dDo0TStt0TzTg6g1jDy 3Nwvee2ZHySABkoyjwtVDOhz/G8kYRSfeiy/yt3HhazW9N1rQZSfj14HN7SWQC7I2VkX VbYQ== X-Gm-Message-State: APjAAAVMnPj3niz5ikVbzZ4tBEj4Rp3bKNdU75xJln72sMkK6W4CoXpd P+aFJe9D3jVOCKwIbRTdV3PrqQ== X-Received: by 2002:a2e:9950:: with SMTP id r16mr45976579ljj.173.1561332668839; Sun, 23 Jun 2019 16:31:08 -0700 (PDT) Received: from khorivan (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 80sm1325307lfz.56.2019.06.23.16.31.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 16:31:08 -0700 (PDT) Date: Mon, 24 Jun 2019 02:31:06 +0300 From: Ivan Khoronzhuk To: Keerthy Cc: davem@davemloft.net, andrew@lunn.ch, ilias.apalodimas@linaro.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-omap@vger.kernel.org, t-kristo@ti.com, grygorii.strashko@ti.com, nsekhar@ti.com Subject: Re: [PATCH] net: ethernet: ti: cpsw: Fix suspend/resume break Message-ID: <20190623233105.GA5472@khorivan> Mail-Followup-To: Keerthy , davem@davemloft.net, andrew@lunn.ch, ilias.apalodimas@linaro.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-omap@vger.kernel.org, t-kristo@ti.com, grygorii.strashko@ti.com, nsekhar@ti.com References: <20190622103140.22902-1-j-keerthy@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190622103140.22902-1-j-keerthy@ti.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 22, 2019 at 04:01:40PM +0530, Keerthy wrote: Hi Keerty, >Commit bfe59032bd6127ee190edb30be9381a01765b958 ("net: ethernet: >ti: cpsw: use cpsw as drv data")changes >the driver data to struct cpsw_common *cpsw. This is done >only in probe/remove but the suspend/resume functions are >still left with struct net_device *ndev. Hence fix both >suspend & resume also to fetch the updated driver data. > >Fixes: bfe59032bd6127ee1 ("net: ethernet: ti: cpsw: use cpsw as drv data") >Signed-off-by: Keerthy >--- > drivers/net/ethernet/ti/cpsw.c | 36 +++++++++++----------------------- > 1 file changed, 11 insertions(+), 25 deletions(-) > >diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c >index 7bdd287074fc..2aeaad15e20e 100644 >--- a/drivers/net/ethernet/ti/cpsw.c >+++ b/drivers/net/ethernet/ti/cpsw.c >@@ -2590,20 +2590,12 @@ static int cpsw_remove(struct platform_device *pdev) > #ifdef CONFIG_PM_SLEEP > static int cpsw_suspend(struct device *dev) > { >- struct net_device *ndev = dev_get_drvdata(dev); >- struct cpsw_common *cpsw = ndev_to_cpsw(ndev); >- >- if (cpsw->data.dual_emac) { >- int i; >+ struct cpsw_common *cpsw = dev_get_drvdata(dev); >+ int i; > >- for (i = 0; i < cpsw->data.slaves; i++) { >- if (netif_running(cpsw->slaves[i].ndev)) >- cpsw_ndo_stop(cpsw->slaves[i].ndev); >- } >- } else { >- if (netif_running(ndev)) >- cpsw_ndo_stop(ndev); >- } >+ for (i = 0; i < cpsw->data.slaves; i++) >+ if (netif_running(cpsw->slaves[i].ndev)) Seems I've missed to add this, but in your fix potential issue in switch mode. ndev is not necessarily present for slave, you need to check on ndev != null before using it, if you still remove cpsw->data.dual_emac ofc. Thanks. >+ cpsw_ndo_stop(cpsw->slaves[i].ndev); > > /* Select sleep pin state */ > pinctrl_pm_select_sleep_state(dev); >@@ -2613,25 +2605,19 @@ static int cpsw_suspend(struct device *dev) > > static int cpsw_resume(struct device *dev) > { >- struct net_device *ndev = dev_get_drvdata(dev); >- struct cpsw_common *cpsw = ndev_to_cpsw(ndev); >+ 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(); >- if (cpsw->data.dual_emac) { >- int i; > >- for (i = 0; i < cpsw->data.slaves; i++) { >- if (netif_running(cpsw->slaves[i].ndev)) >- cpsw_ndo_open(cpsw->slaves[i].ndev); >- } >- } else { >- if (netif_running(ndev)) >- cpsw_ndo_open(ndev); >- } >+ for (i = 0; i < cpsw->data.slaves; i++) >+ if (netif_running(cpsw->slaves[i].ndev)) >+ cpsw_ndo_open(cpsw->slaves[i].ndev); >+ same here > rtnl_unlock(); > > return 0; >-- >2.17.1 > -- Regards, Ivan Khoronzhuk