Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1011799lqm; Thu, 2 May 2024 02:33:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlS2NGSnP/LCNRURfuTIOpXsmx3YCjmRTXSOJQN1r+hW7uCqgNlOikGswnCNdybIO+f2QE5FHj4xWAM/+VbFUgp3+n65++OaOqsT0NFA== X-Google-Smtp-Source: AGHT+IGsn+51jbX8xhvzkyMCCTEt1OWUg6bXRiyKvudR9Wz09/JsouX61k66xvbqkygnfiPNamml X-Received: by 2002:a17:906:3ac1:b0:a58:7283:f587 with SMTP id z1-20020a1709063ac100b00a587283f587mr3214197ejd.33.1714642419182; Thu, 02 May 2024 02:33:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714642419; cv=pass; d=google.com; s=arc-20160816; b=isXud/Wzy+Imt/wvMk4EjBNHNcaSXJ6xGnyJVg0hqZij5q/hkfPgJiKK9LbLPSFwKs 0JYhUt3J0HgNvpcvaBmkR6KN2Veo/Nn/cEyo6mYIurkHAp3DTMGPCQ4Lh98CCJOI+0sa wDmT/5o1cXCD82Uy84aW9qCbymx7JHkkdLGIchZ2ubC7bv3sZzQX3sIsw0DdLb4XWyR1 /8eATJ9wi7qno3REBTj1mLOe78E6DHTnRTfuz3lngnFEzsHW9ukUFxaMD7KfwK4Qr762 po1R1av4NYs+V5bH5Em82cnXjNinXTKZj/q/cgp9ik/SepyA70niALEBbLNvxiYcCGOK axZg== 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=V8exqiog62oJz5/MYIpC49kvof08XXJ4t0un9gQscHU=; fh=7fGmPDBGig1mWQld28CGpF1raS0K9tsA2ebmmPmAFKc=; b=rUKtGfrY2XjanE4yp1gXsJODi4JwGvWQZAdeT3mTmAg/7SiV9qoVZ77oWVeIXk3+Tp ZAbieiFmWgYtzs6gb98yXUPP4gzT2RUw5Mx8VwkKTKfZpuEv+e9fUGx1KdpZ/uTiQzZl Q7o4ymk2RGZmxaAKDev55V4l/vC24sFvcTL3hmsXhIwFwqlDj0GcDKH+Jt0f45uAtfUE rH6eOXj/CKU3I8w3HLMvGHOmq/apS6syeoFGt4V36s+gb1gm8E/i2VFsWYaeWYyM5wrE lF8L59/V5mLFGR/KUSnF+Ua0MvcJonmV8vkVoVOiCjF+sWzTqafXxlHbZlNE2Xb2MA8A jCfQ==; 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-166209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166209-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h13-20020a170906398d00b00a58bce3665asi324337eje.342.2024.05.02.02.33.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 02:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-kernel+bounces-166209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166209-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5526B1F257A1 for ; Thu, 2 May 2024 09:24:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B5CC54903; Thu, 2 May 2024 09:22:31 +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 560F6548E7; Thu, 2 May 2024 09:22:28 +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=1714641751; cv=none; b=mJ/PHNYHuD/oqZLFp97s7VBe8M/4NuDofponpol6kJfcm6I7MvOsqQyhVkDloUoteR9lny5mIu6pFupNHuAAsG5LUnRHnAP7mLvdnItpRMks3WFlrCeeomQN43WLlcOcZDr4IG0kcJuLxalL1U4M3UO7eK4sKA2F/JxBWxBAUm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714641751; c=relaxed/simple; bh=y1jwBf7Bi9E4iSsBmwVrFXCieuN307HWzrKedCrJ/eI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ghWiXPajxlHQQCdv/RXUnQLx8iANbiKIvqs5hFNqPt823/pgKlLAu1kqm4y9hR2cC3Pg2Lp9tbHteGhszTwft2qMCuEv+fG76uSY3RQ5TAa+c9c2V1tdmV3C96phXQMz8V0ryHCRiFc0zQs3QGgFvwo8V30tW2dFdxvPEcCkvpQ= 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 4429MB9002332798, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 4429MB9002332798 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 May 2024 17:22:11 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 2 May 2024 17:22:12 +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; Thu, 2 May 2024 17:22:11 +0800 From: Justin Lai To: CC: , , , , , , , , , "Justin Lai" Subject: [PATCH net-next v17 09/13] rtase: Implement pci_driver suspend and resume function Date: Thu, 2 May 2024 17:18:43 +0800 Message-ID: <20240502091847.65181-10-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502091847.65181-1-justinlai0215@realtek.com> References: <20240502091847.65181-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: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback 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 a9b3848e8e8a..b8af5edc13a2 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -2160,12 +2160,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