Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp897908lqt; Fri, 7 Jun 2024 01:51:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKET47UGxAaYlsWRkhIZy/famUWIXKKA2muHLzCT+WequPmGs9wa1K6qKf6BbWkq2l8OHGOhXpXB0x5cO1mMbMSVkwyiGOmSygTsrcRA== X-Google-Smtp-Source: AGHT+IGNxe61YoCjXktIcup7a3wyKB5ML5HBYcPI7ywuH6jTgWMztw42gzTpabqFWzAdHOpqSsmm X-Received: by 2002:a05:6a00:c88:b0:702:7116:ca33 with SMTP id d2e1a72fcca58-7040c741a7emr1983173b3a.28.1717750308989; Fri, 07 Jun 2024 01:51:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717750308; cv=pass; d=google.com; s=arc-20160816; b=W1Qbmd8LYygT+Hz31i3XcuzPF1oIadI2lduu2ZgUnVe1s5xhpjUCVhuOPg6EKd6+MR 0GroAjXW50EPr4bwkp0QSqxjJ0NmjmiBBEB2dVlexwLMt5gbh2tuL9E+e+z6xuUygDKY V/ilCibx7xYmXvWjTkeJE9LIVrbTIoBzxgsKwR7q//b0v2RPzbbaggfzVCCxKHO1/fo2 pa4OxEk4klzQ7j2Uzlbt3BTL3O+3cPyjJWcY9cT1E5MVlDKb17MPPfdzVtrRTieFCLS+ 9PzLmWQ7xOOWxJbHrnqyPB6ELn9CT7ccjz2OYh8CcL2Hk87CvKoqgiTlG/z/KzYopUhD IHZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6+awExwp4ESftMiFoetNTcH9M5qxz87VVk6rsF79TKA=; fh=HTx+hWhxW7A9pmX86MXapJNyGhFtaRFzfw4H4nFStD4=; b=GLsjxRI3kkMuGV/xjYNh0BJLKKushBE7D/SyTr4vZJjLR6Tmy/1OTBmHPhG8Y6ws4O T4jemiMauG37XBruw7L0nhEidSyQUgdcJ7Z5YrH2v1lBaNtqX+9hU/29BgGlkHEgEaxb BA/iVdE62OJM8r6UW2bRRb55+y7tc512yn28rjfjlsgrsB2IS7RvdoLjh4EGJNN4C+EY 65RQu9Rub6R88wovpTDQqX/los+NO/8DEtEbvbhoGZ+rp4Zw6giKVXl4imCgSwiCd3rZ JlxaUx7QJkWkWcclDQwqIILQoa2zSs1t2nQcqoCNyelyYU8S9k0TpLwY31lNpB968npz 5S5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-kernel+bounces-205641-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205641-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-703fd395765si2611582b3a.5.2024.06.07.01.51.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 01:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205641-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-kernel+bounces-205641-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205641-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F18CBB23F6F for ; Fri, 7 Jun 2024 08:50:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1226615B552; Fri, 7 Jun 2024 08:50:13 +0000 (UTC) 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 0BCBE15B134; Fri, 7 Jun 2024 08:50:10 +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=1717750212; cv=none; b=K3xVPDLxB5d43/qNNzGoW9STEUACxyG91qbN9fwmu4ArmzoukhuWBk+NIJr4MQJFj1lV0oF+Vl0IqZ2/u2doZAVRWp00b7zhgxUpU7OP4skKbfP1LpSQsR92wgtQgAACeufL1Vh7hy6U8naH7tTB6S1aN+hfNHkCoYjRtJn21D0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717750212; c=relaxed/simple; bh=bhv9T7017HVwAhOtMD71Qok04WzxOMUK6L1+ok3bHoQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D2OQi/2ZK7IutUHZ6XdPtsrE4yvwjbkPlngbVVbIxntDI8zrT7JiafEVXT9MdHD6Ih1MXsXKrxUWr5l3ZntHdv0kpY8yslNiFA9UeSiR2Pqo1h07U8zgM7zn5zWySluvMFtaaqzBseO3LfHC+r94mtZG8Z7MDEzCKe056WmsnsM= 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 4578nnXW33819216, 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 4578nnXW33819216 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Jun 2024 16:49:49 +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.39; Fri, 7 Jun 2024 16:49:49 +0800 Received: from RTDOMAIN (172.21.210.98) 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; Fri, 7 Jun 2024 16:49:48 +0800 From: Justin Lai To: CC: , , , , , , , , , , , Justin Lai Subject: [PATCH net-next v20 09/13] rtase: Implement pci_driver suspend and resume function Date: Fri, 7 Jun 2024 16:43:17 +0800 Message-ID: <20240607084321.7254-10-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607084321.7254-1-justinlai0215@realtek.com> References: <20240607084321.7254-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: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXH36506.realtek.com.tw (172.21.6.27) To RTEXMBS04.realtek.com.tw (172.21.6.97) 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 38faff333a93..e9bbafc212c5 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -2201,12 +2201,63 @@ static void rtase_shutdown(struct pci_dev *pdev) rtase_reset_interrupt(pdev, tp); } +static int rtase_suspend(struct device *device) +{ + struct net_device *dev = 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 = dev_get_drvdata(device); + struct rtase_private *tp = 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 = 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 = { + SYSTEM_SLEEP_PM_OPS(rtase_suspend, rtase_resume) +}; + static struct pci_driver rtase_pci_driver = { .name = KBUILD_MODNAME, .id_table = rtase_pci_tbl, .probe = rtase_init_one, .remove = rtase_remove_one, .shutdown = rtase_shutdown, + .driver.pm = pm_ptr(&rtase_pm_ops), }; module_pci_driver(rtase_pci_driver); -- 2.34.1