From patchwork Tue Nov 1 01:11:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Chiu X-Patchwork-Id: 13026576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4631FFA3740 for ; Tue, 1 Nov 2022 01:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=iucumZ/JjwyuBICRE+8eT2LRcddwXNWRYnN//IEYx6U=; b=HpWjVhQV+NmhEj ed4Wvn7uOkHhF2hNWg+wmYQv13cnYHGR3vdPdWR5qlP86diGSiSsJ32ohy6sAHRu8jhmHcjHONzCk WPBBnCDL8sM2+Sr1VNQ03b3Sn+V3vgD5z3c1tiTk478KtNi2HBBkJPBhecEO26fEL7NNhhPx68PKq LJ2dEvnlzOP9Zwl5wQUT71hk+KMpNS5J1xbQEeEM0Mxy+PBlExvSkM3IIM5KXvLgt4gSJFc+dllhc z9k7P5M98TtLQ/ATNaTan4tjm9iZjoNLlMz7JJSXw6VzicmS/WrhiYFDHkDM7rrGMmJ/R23RY+xKJ bh9QbulqwS7+MXwRhYIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opfok-00H6zt-GY; Tue, 01 Nov 2022 01:11:50 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opfoh-00H6xI-Sb for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2022 01:11:49 +0000 Received: by mail-pl1-x62b.google.com with SMTP id 4so12273947pli.0 for ; Mon, 31 Oct 2022 18:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zeBMYdMZ1p+Lm3eAVj+hDEsLF6ZsPuh0Td05pqMw4LA=; b=T9kXSSEJxsE21WH61OdQ94VYWF4t4yhNq+JNB4JInAbU+UacVYZxmMjZZMlI7DnBOO ccf30kthD6BT7dwFyQKdZjpm2/0ZKvuQeEqzvi0mD78XN44pVNOHtBn4lw2ONh1hiDed eBy5ILKEF7jd244fvYM/UF6LRMhRyBpRarbK9lkwPZPSAuYhcm0KJ3ZB1Tx2mu5NArFy BbfUrboNAjd0py/1bhJgtaVcnsp5O7GYFuiLob61wH324nOLBdEKe7342LOSYAIey/iy dKXufj8PweP65FvykoLbX5IMH5jPsChfrwU5OEkroqwkowFHVfKedsHP2r1DmQBfvbWN P+Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zeBMYdMZ1p+Lm3eAVj+hDEsLF6ZsPuh0Td05pqMw4LA=; b=QjhB+LcjOtS7h48tJSGAd3w0f4GFxaj9Pg5ZTOHbtIEUPZSbbXq+Se3p0vNt+uc9aI sIjb0c0xF3XjajkDSC7Vo6+WL+OW/HD8d8ax8SIJJbwcIsXR++hjraaRAOzQjsP/hzck NeDph7JTixFuq8wimRRI3KsXXabHjCnP7P94tWILUE6DcP/pXeqZJ4jF/t/MfTUZFUzk idAKj3Lf63HqL5e23zII3RinP9oTIIjEEVEZCh01xjkbCnL5CKe8vTw3FHfDA8xluKRu SS3e30/5NJ+L23e3yDDR2JVM/ADct35eeVSQ4/Jd3YZIV5Ogfkf95r2OxuTZmDggS3Ae 5vHQ== X-Gm-Message-State: ACrzQf1rt5peqje6Jc9CVG5sKdmY86Qd6PDwpiXzvTSwzNOdYUdl/D71 gybzWRcFxltUbOhrDuL7YlL/eg== X-Google-Smtp-Source: AMsMyM4B0jgEDjy497l6SopIpu1wkozw10ZHKcpyKvpI1a5y333hD2+JbNSwhHScPQj2OGXxhsP3JA== X-Received: by 2002:a17:902:c1c6:b0:186:994f:6e57 with SMTP id c6-20020a170902c1c600b00186994f6e57mr16841442plc.17.1667265104900; Mon, 31 Oct 2022 18:11:44 -0700 (PDT) Received: from archlinux.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id e64-20020a621e43000000b0056be7ac5261sm5230900pfe.163.2022.10.31.18.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 18:11:44 -0700 (PDT) From: Andy Chiu To: davem@davemloft.net, kuba@kernel.org, michal.simek@xilinx.com, radhey.shyam.pandey@xilinx.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, pabeni@redhat.com, edumazet@google.com, andy.chiu@sifive.com, greentime.hu@sifive.com Subject: [PATCH net-next] net: axiemac: add PM callbacks to support suspend/resume Date: Tue, 1 Nov 2022 09:11:39 +0800 Message-Id: <20221101011139.900930-1-andy.chiu@sifive.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221031_181147_944526_0FCBFB24 X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Support basic system-wide suspend and resume functions Signed-off-by: Andy Chiu --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 441e1058104f..d082f2b10f4d 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -2217,12 +2217,48 @@ static void axienet_shutdown(struct platform_device *pdev) rtnl_unlock(); } +static int axienet_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + + if (!netif_running(ndev)) + return 0; + + netif_device_detach(ndev); + + rtnl_lock(); + axienet_stop(ndev); + rtnl_unlock(); + + return 0; +} + +static int axienet_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + + if (!netif_running(ndev)) + return 0; + + rtnl_lock(); + axienet_open(ndev); + rtnl_unlock(); + + netif_device_attach(ndev); + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(axienet_pm_ops, + axienet_suspend, axienet_resume); + static struct platform_driver axienet_driver = { .probe = axienet_probe, .remove = axienet_remove, .shutdown = axienet_shutdown, .driver = { .name = "xilinx_axienet", + .pm = &axienet_pm_ops, .of_match_table = axienet_of_match, }, };