From nobody Wed Dec 17 07:29:22 2025 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F238054BFD; Wed, 8 May 2024 12:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715172311; cv=none; b=LNOE9KY/6zAjvGeLc99fbw0yJljCnMqoywLR3YOlL0PLFrpUzyRGOdQrh8C7IG4ix55nGoHOU0AUaZRG63MJXsfpps1i4iWvsrFPuJouW6iE3TBIsxq1khDIIlsbUHBXglRWP0iKeskc/IY5w8u8m+YOuZGcy23VY6bkUsg/yqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715172311; c=relaxed/simple; bh=7R8U9Pn+fSgmx2Bzggll2m9VpDK62jiFfTEWCcLiq80=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lo0hb7H1/c7HTzpLFDKkDlJM83gG4xuE1a1BUOTRJNo6DmPx5Vwy9XCD/7wHur3g4worVJc8m/yOGyQtWn+ImXxqkjlX0c4weCzma0rqHDlfVBvXjEuxO4k6jS6YzUVvuNRcTocErNUESlwSmmkTAL3qYOEWOwIxqzgxdem2ZSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 448CipkrF467652, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 448CipkrF467652 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 May 2024 20:44:52 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 8 May 2024 20:44:52 +0800 Received: from RTDOMAIN (172.21.210.160) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 8 May 2024 20:44:49 +0800 From: Justin Lai To: CC: , , , , , , , , , , Justin Lai Subject: [PATCH net-next v18 09/13] rtase: Implement pci_driver suspend and resume function Date: Wed, 8 May 2024 20:39:41 +0800 Message-ID: <20240508123945.201524-10-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508123945.201524-1-justinlai0215@realtek.com> References: <20240508123945.201524-1-justinlai0215@realtek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) Content-Type: text/plain; charset="utf-8" Implement the pci_driver suspend function to enable the device to sleep, and implement the resume function to enable the device to resume operation. Signed-off-by: Justin Lai --- .../net/ethernet/realtek/rtase/rtase_main.c | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/= ethernet/realtek/rtase/rtase_main.c index 61f12a3b79eb..4928397d88a5 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -2197,12 +2197,63 @@ static void rtase_shutdown(struct pci_dev *pdev) rtase_reset_interrupt(pdev, tp); } =20 +static int rtase_suspend(struct device *device) +{ + struct net_device *dev =3D dev_get_drvdata(device); + + if (netif_running(dev)) { + netif_device_detach(dev); + rtase_hw_reset(dev); + } + + return 0; +} + +static int rtase_resume(struct device *device) +{ + struct net_device *dev =3D dev_get_drvdata(device); + struct rtase_private *tp =3D netdev_priv(dev); + int ret; + + /* restore last modified mac address */ + rtase_rar_set(tp, dev->dev_addr); + + if (!netif_running(dev)) + goto out; + + rtase_wait_for_quiescence(dev); + + rtase_tx_clear(tp); + rtase_rx_clear(tp); + + ret =3D rtase_init_ring(dev); + if (ret) { + netdev_err(dev, "unable to init ring\n"); + rtase_free_desc(tp); + return -ENOMEM; + } + + rtase_hw_config(dev); + /* always link, so start to transmit & receive */ + rtase_hw_start(dev); + + netif_device_attach(dev); +out: + + return 0; +} + +static const struct dev_pm_ops rtase_pm_ops =3D { + SYSTEM_SLEEP_PM_OPS(rtase_suspend, rtase_resume) +}; + static struct pci_driver rtase_pci_driver =3D { .name =3D KBUILD_MODNAME, .id_table =3D rtase_pci_tbl, .probe =3D rtase_init_one, .remove =3D rtase_remove_one, .shutdown =3D rtase_shutdown, + .driver.pm =3D pm_ptr(&rtase_pm_ops), }; =20 module_pci_driver(rtase_pci_driver); --=20 2.34.1