Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp781158lqo; Fri, 17 May 2024 00:59:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6etG/jYNqpHJWCIIfXqpICt1FMkSN6sOmpsLreVhINPt0K3gC3+bvX3oYlUXt+NKElkYGFY/DKIGbpuXzCRYzRs289oGVZ8yd3iKOhQ== X-Google-Smtp-Source: AGHT+IFydUd5qrruha+xHjb3ZPvbiYaxuKKL5dR3sieO2tkCaFV8uivhyEHqTupew2ci8OWajZHy X-Received: by 2002:a05:620a:cee:b0:792:8dc3:d714 with SMTP id af79cd13be357-792c7610931mr1929117785a.76.1715932794972; Fri, 17 May 2024 00:59:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715932794; cv=pass; d=google.com; s=arc-20160816; b=TvrsngW4Zitb1g4/RR+djSRjlIT1rgbapYZsReGXRf/5D+Lu1eaY4HEZTd6qVSFu13 /cqEO+p7LPBOpWZeMH4HDgad5+DSnyj7OHE5JMZdJVFNfLuz4RWQDrUeyYrlI56Vj5q0 hekNojUp6BETErFRTSuz+497tye/1xSi+0ZUgITf93I/jdjBVpmCIDhYERQHrqjzvx8A sirgUAnGOtPhAC9qTFOUt3vWYGtdKz9XLEjsxGdQVi9bu88COC86s3j43gTwBhdlkbEu WB+6LJI63HSmvmCWX0rirEYStjonfzf2vO86TmqxsiH8ppgnizopw2A02PuxXXskSrI1 cnWQ== 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=ghc958vlj8bYce8abhdPV2hi1+iPHycjre4vU2IxmSo=; fh=HTx+hWhxW7A9pmX86MXapJNyGhFtaRFzfw4H4nFStD4=; b=l+u0DqTJq1cAPjkl7jloQ56zP7ia8dQNEqsFeAI6m0JIzbcqopUZU6+eNhHHZelU++ 6RZ73KW2oew0xoIjxH/TqF/VN1Es9gMoBc/vqhdISbdLZ2c36UvxrSpBhE+gWjIveHAF 3jnvU4OkrFRqnAXb2U/unmCG3+iJar5MXUiz1RUUqLUE0uTTCAsP8NAekx1ORBaVnNs8 A0HcBm9vZ11EWUIn+QPiwbuGF6uXAufdXYlr2QdMhDAsOyQvgZecg6Rv8oAXrE20Ty5p au/tiDkSrOOlM9Sp4BZE8Mkzc9JIhEZCVYMaKzX3kRStNy4zjI3i7C8hD4bqJ84tP9oO /kug==; 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-181833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181833-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf30a79asi1952897485a.239.2024.05.17.00.59.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 00:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-kernel+bounces-181833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181833-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B02191C21431 for ; Fri, 17 May 2024 07:59:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF6792941F; Fri, 17 May 2024 07:58:14 +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 A8BCA28DCA; Fri, 17 May 2024 07:58:11 +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=1715932694; cv=none; b=la7OSTuf1QHc/Eo4roQtwwsPJpJsHMizZVJ4K/HXKuTGGCcZ789+CQVVS9VhtoWfWWTopaclbzzU3eQcMOiQeS4mTKkd6jxx8nTS8Vvv4SiLvEATbkvWNbKcfhTQKHgWlTw6hmtDhW8VVCneVZ2C3V1q5bKDP7PelUn9uVF2lnU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715932694; c=relaxed/simple; bh=cjeFXBQn53hX5Dr4JDVUnrR1PFzZM+Zup6sh4cDKVkg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=okIc+wksupbCvbwgGVDPVqVe9b6ldTe728PiuapMCtJ60QTCTwe3CosROQllxlgrX7yzOGgp1ZCBAWpCWYZils35kabVZFLc9kPxlZ7k1zRaCvebsoMg+AiJ7XVWjvV2zgIuHtl3c6LhNJOlKVEdI9pTNsuTbdwmB8edfkj3pIg= 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 44H7vnsM72161379, 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 44H7vnsM72161379 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 May 2024 15:57: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, 17 May 2024 15:57:49 +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; Fri, 17 May 2024 15:57:48 +0800 From: Justin Lai To: CC: , , , , , , , , , , , Justin Lai Subject: [PATCH net-next v19 09/13] rtase: Implement pci_driver suspend and resume function Date: Fri, 17 May 2024 15:52:58 +0800 Message-ID: <20240517075302.7653-10-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517075302.7653-1-justinlai0215@realtek.com> References: <20240517075302.7653-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 2ef02cdbe322..b94041b1d4fd 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -2200,12 +2200,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