Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp18861rdb; Fri, 5 Jan 2024 00:56:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPtcpQ4uBGah1XDQI68oO0ZVLs5fmt1QH+AUfuEnSj5e69t652vgh/jy65IypSR0CtE9Co X-Received: by 2002:a19:9141:0:b0:50e:6a9d:b3c4 with SMTP id y1-20020a199141000000b0050e6a9db3c4mr808808lfj.128.1704445005656; Fri, 05 Jan 2024 00:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704445005; cv=none; d=google.com; s=arc-20160816; b=O1jAL0vlWcAafuDc+fXU3WXQEld5y5IZNquWmJ1uJndt33/OpsCAdmv6ajIa8XaJEV rbIffPEWk5+KFmwADnnTGTuuG5rjRn1Ya1JxRIEnzmalHcSxXCNiC/3Yz4h/C3nZ8BE6 vegx90hmbAiAe/xyRMaA7VokPeiCXAEkPwFodp9vQX5d/wWXehoCkMVuS7+ABTmh2HV2 d89j7cBdGAqy2G2RL5X97ZILDLU58Dr4KySeDVeTiHRa05s16PuEn1DuvRbUco6tRks4 tFA7lJkDS6vBjy6CXR6x73hAjLs5rKc/qlXtWsSoMJojcKnxLufYP13c9Yk609wJOMGk KWug== ARC-Message-Signature: i=1; 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=6jaKCgRgGGzCxN/P9G3gjdV4D0QDk0pe5GM1QCZjB1o=; fh=J4St9tMjBInT3r1VVHSF1O7f2qS3KxSaZBHCVggmRHk=; b=q/zy3bdnPnp45AsIDthQWwdu2K+yxcEBxXRHlDZSNLjuDvN1ChjOIn4pHfnktW/d7q lhLUjOyKN+XBQ7gBdFGGxyV6C2K56ED00fsM6uzVFXO/dePVMRXECGxcHps0x5frZyYt Awvu8JZc7wtb9Axb/fjXhkPrAshOzbZvgZA7Xl03/2wLI6GmJCTebYJwjsJQ3Nim87X3 UD3e6x2p9ioFTTV8zV3dNRRbzFDMZ7KYuHFOYGzVzzSuX77mAPkkUVU5HitWZ+oD2nnW 51MYQO6G2ENu5V3r7B/GBoKoyT3lVgW/4UgZTpbVZ8QrU0gspQJ4Oeyv2ReHZLhDpfCy SX7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17624-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17624-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gk1-20020a17090790c100b00a297d7e0bc1si62231ejb.103.2024.01.05.00.56.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:56:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17624-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17624-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17624-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 63E0A1F218BB for ; Fri, 5 Jan 2024 08:56:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 815A425116; Fri, 5 Jan 2024 08:55:31 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 6E00A2510D; Fri, 5 Jan 2024 08:55:28 +0000 (UTC) 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 4058tAIU12287216, 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 4058tAIU12287216 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jan 2024 16:55:10 +0800 Received: from RTEXDAG02.realtek.com.tw (172.21.6.101) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 5 Jan 2024 16:55:10 +0800 Received: from RTDOMAIN (172.21.210.160) by RTEXDAG02.realtek.com.tw (172.21.6.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 5 Jan 2024 16:55:07 +0800 From: Justin Lai To: CC: , , , , , , , , Justin Lai Subject: [PATCH net-next v15 09/13] rtase: Implement pci_driver suspend and resume function Date: Fri, 5 Jan 2024 16:54:35 +0800 Message-ID: <20240105085439.376802-5-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240105085439.376802-1-justinlai0215@realtek.com> References: <20240105085439.376802-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 RTEXDAG02.realtek.com.tw (172.21.6.101) X-KSE-ServerInfo: RTEXDAG02.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 16fe3d8e3987..b8e5ef489b0c 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -2148,12 +2148,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