From: linyunsheng Sent: Wednesday, January 6, 2021 2:34 AM To: zhangjiaran zhangjiaran@huawei.com; shenjian (K) shenjian15@huawei.com; lipeng (Y) lipeng321@huawei.com; tanhuazhong tanhuazhong@huawei.com; Salil Mehta salil.mehta@huawei.com; huangguangbin (A) huangguangbin2@huawei.com; moyufeng moyufeng@huawei.com; chenhao (DY) chenhao288@hisilicon.com Cc: Linuxarm linuxarm@huawei.com Subject: Re: [PATCH net-next 1/2] {topost} net: hns3: add suspend/resume function for hns3 driver
On 2020/12/30 12:44, Jiaran Zhang wrote:
To implement the system hibernation and wakeup functions, the NIC driver needs to support the PCI suspend and resume functions. The following functions need to be supported:
- When the system enters the hibernation mode, the driver needs to
implement the suspend callback function of the NIC device. The driver needs to mute the device, stop all RX/TX activities of the device, and unmap the interrupt. 2. When the system enters the wakeup mode (self-wakeup/wakeup source-triggered wakeup), the driver needs to implement the resume callback function of the NIC device and restore the device to the state before suspension.
[...]
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 405e490..d1bc430 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2323,6 +2323,28 @@ static void hns3_shutdown(struct pci_dev *pdev) pci_set_power_state(pdev, PCI_D3hot); }
+static int hns3_suspend(struct device *dev)
It seems the i40e has the "__maybe_unused" keyword as below:
static int __maybe_unused i40e_resume(struct device *dev)
This is a good point and I saw most of the drivers which are initializing PM ops using SIMPLE_DEV_PM_OPS() are using this to avoid warning perhaps.
The also checked the history of it in the GCC, interestingly it looks The __attribute((unused)) is missing from GCC documentation from GCC 6.2.0 onwards. I am not sure why.
https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Function-Attributes.html
But below GCC 5.4.0 does have the mention of the unused attribute. https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Function-Attributes.html
Maybe worth checking why this is so.
Salil.