From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Roger Quadros <rogerq@kernel.org>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <edumazet@google.com>,
<pabeni@redhat.com>, <vigneshr@ti.com>,
<linux-omap@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 net-next 5/6] net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume
Date: Mon, 28 Nov 2022 11:11:30 +0100 [thread overview]
Message-ID: <Y4SJUgm5KXA5BdAE@boxer> (raw)
In-Reply-To: <d20d3b73-38b4-fb06-2daa-125f446aeb44@kernel.org>
On Mon, Nov 28, 2022 at 11:21:40AM +0200, Roger Quadros wrote:
> On 25/11/2022 15:21, Maciej Fijalkowski wrote:
> > On Wed, Nov 23, 2022 at 02:48:34PM +0200, Roger Quadros wrote:
> >> During suspend resume the context of PORT_VLAN_REG is lost so
> >> save it during suspend and restore it during resume for
> >> host port and slave ports.
> >>
> >> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> >> Signed-off-by: David S. Miller <davem@davemloft.net>
> >> ---
> >> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 +++++++
> >> drivers/net/ethernet/ti/am65-cpsw-nuss.h | 4 ++++
> >> 2 files changed, 11 insertions(+)
> >>
> >> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> >> index 0b59088e3728..f5357afde527 100644
> >> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> >> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> >> @@ -2875,7 +2875,9 @@ static int am65_cpsw_nuss_suspend(struct device *dev)
> >> struct am65_cpsw_port *port;
> >> struct net_device *ndev;
> >> int i, ret;
> >> + struct am65_cpsw_host *host_p = am65_common_get_host(common);
> >
> > Nit: I see that retrieving host pointer depends on getting the common
> > pointer first from dev_get_drvdata(dev) so pure RCT is not possible to
> > maintain here but nonetheless I would move this line just below the common
> > pointer:
> >
> > struct am65_cpsw_common *common = dev_get_drvdata(dev);
> > struct am65_cpsw_host *host = am65_common_get_host(common);
> > struct am65_cpsw_port *port;
> > struct net_device *ndev;
> > int i, ret;
>
> OK.
>
> >
> > Also I think plain 'host' for variable name is just fine, no need for _p
> > suffix to indicate it is a pointer. in that case you should go with
> > common_p etc.
>
> host_p is the naming convention used throughout the driver.
> Do think it is a good idea to change it at this one place?
No, maybe think of a refactor throughout whole codebase, changing it in a
single place would be odd.
>
> >
> >>
> >> + host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET);
> >> for (i = 0; i < common->port_num; i++) {
> >> port = &common->ports[i];
> >> ndev = port->ndev;
> >> @@ -2883,6 +2885,7 @@ static int am65_cpsw_nuss_suspend(struct device *dev)
> >> if (!ndev)
> >> continue;
> >>
> >> + port->vid_context = readl(port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET);
> >> netif_device_detach(ndev);
> >> if (netif_running(ndev)) {
> >> rtnl_lock();
> >> @@ -2909,6 +2912,7 @@ static int am65_cpsw_nuss_resume(struct device *dev)
> >> struct am65_cpsw_port *port;
> >> struct net_device *ndev;
> >> int i, ret;
> >> + struct am65_cpsw_host *host_p = am65_common_get_host(common);
> >>
> >> ret = am65_cpsw_nuss_init_tx_chns(common);
> >> if (ret)
> >> @@ -2941,8 +2945,11 @@ static int am65_cpsw_nuss_resume(struct device *dev)
> >> }
> >>
> >> netif_device_attach(ndev);
> >> + writel(port->vid_context, port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET);
> >> }
> >>
> >> + writel(host_p->vid_context, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET);
> >> +
> >> return 0;
> >> }
> >> #endif /* CONFIG_PM_SLEEP */
> >> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h
> >> index 2c9850fdfcb6..e95cc37a7286 100644
> >> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h
> >> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h
> >> @@ -55,12 +55,16 @@ struct am65_cpsw_port {
> >> bool rx_ts_enabled;
> >> struct am65_cpsw_qos qos;
> >> struct devlink_port devlink_port;
> >> + /* Only for suspend resume context */
> >> + u32 vid_context;
> >> };
> >>
> >> struct am65_cpsw_host {
> >> struct am65_cpsw_common *common;
> >> void __iomem *port_base;
> >> void __iomem *stat_base;
> >> + /* Only for suspend resume context */
> >> + u32 vid_context;
> >> };
> >>
> >> struct am65_cpsw_tx_chn {
> >> --
> >> 2.17.1
> >>
>
> --
> cheers,
> -roger
next prev parent reply other threads:[~2022-11-28 10:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 12:48 [PATCH v3 net-next 0/6] net: ethernet: ti: am65-cpsw: Fix set channel operation Roger Quadros
2022-11-23 12:48 ` [PATCH v3 net-next 1/6] Revert "net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume" Roger Quadros
2022-11-23 12:48 ` [PATCH v3 net-next 2/6] Revert "net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume" Roger Quadros
2022-11-23 12:48 ` [PATCH v3 net-next 3/6] Revert "net: ethernet: ti: am65-cpsw: Add suspend/resume support" Roger Quadros
2022-11-23 12:48 ` [PATCH v3 net-next 4/6] net: ethernet: ti: am65-cpsw: Add suspend/resume support Roger Quadros
2022-11-23 17:42 ` Andrew Lunn
2022-11-25 8:41 ` Roger Quadros
2022-11-23 12:48 ` [PATCH v3 net-next 5/6] net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume Roger Quadros
2022-11-25 13:21 ` Maciej Fijalkowski
2022-11-28 9:21 ` Roger Quadros
2022-11-28 10:11 ` Maciej Fijalkowski [this message]
2022-11-23 12:48 ` [PATCH v3 net-next 6/6] net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume Roger Quadros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y4SJUgm5KXA5BdAE@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rogerq@kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).