Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1511486ybh; Sun, 19 Jul 2020 23:17:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0FqdJancDwsnZue90YtRUdi+qIMHXCZD9gmLAzgPQYrCRFXJ2yXOXt3GV6VP7tULZllOa X-Received: by 2002:a17:907:2105:: with SMTP id qn5mr19191636ejb.308.1595225868882; Sun, 19 Jul 2020 23:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595225868; cv=none; d=google.com; s=arc-20160816; b=Hz/WCxxxgZ72B4UkfhFx8lNqBnv+kyJ0WB7wzHV+ghkoj+q033ZhQSrO84ceE2JzA6 bzfL5h4p+SON/SNj0syRtPZSoKCWwytILBzZgBXhDPFXGk5sNoCggpPeeIZwnLvlw0gL HqtphR7gnCocBKlY86wEVJnEGmOl/3xErRcU1Jo6zvPcj+0Vbwd2CKAwF1ka8v0C8t6f iNitZkeK7b28JHFj1xiimUB0AQz9P/vZGj+g1Wn304JnhMn5c9aL/RF9jH6ziC7UX0mL s5s0P3l6yxrj2Nn0Q2Hc3Np9f2Zm2Yz9v2wiLGsR3I6EDAr/9SCHP0PwJu7C63ZNLCGQ JzxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=DYI01Ac+Qb+BX4rwaL473QeFGCLz0aQa8kOvE7DE2Mc=; b=EUTHwjLQgs/WyMcE6k7bauuj5wIvGK8w7cyYtjZPnEXcUhaxx8IsMFvoCQ/z6WCMLU X9fPVv1QV/oSIioaO8TQb7KhAOExM+hJVCc2Hb1O5Mu+AEw8bPwHm1bLPRdUzTj+CfVX TOFOE3mS2niepNciO1L5VoBsRzB3aMq/Q/Dp3f4/BQToGhxyg+Pf4UnDqq3mlpb/Eti2 O8JfC7qLvx7OkgzJi5yjuQTK3rG4u1tXlyvuq6aecllhKTOEXEBPIrKwgRoohUGX+lM1 ZySb20jDa23V28+CC3NbSFh82Y64K2BT9ZAD/kTqpAJBjTkVwwZHlFQOJxED3vhUkU+a /NlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lm17si9590213ejb.366.2020.07.19.23.17.26; Sun, 19 Jul 2020 23:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726017AbgGTGQ4 (ORCPT + 99 others); Mon, 20 Jul 2020 02:16:56 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:48380 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725805AbgGTGQ4 (ORCPT ); Mon, 20 Jul 2020 02:16:56 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F053821341B1D8D5B252; Mon, 20 Jul 2020 14:16:53 +0800 (CST) Received: from [127.0.0.1] (10.74.219.194) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Mon, 20 Jul 2020 14:16:45 +0800 Subject: Re: [PATCH v1 07/15] scsi: hisi_sas_v3_hw: use generic power management To: Vaibhav Gupta , Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Adam Radford , "James E.J. Bottomley" , "Martin K. Petersen" , Adaptec OEM Raid Solutions , Hannes Reinecke , Bradley Grove , John Garry , Don Brace , James Smart , "Dick Kennedy" , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang , Vaibhav Gupta References: <20200717063438.175022-1-vaibhavgupta40@gmail.com> <20200717063438.175022-8-vaibhavgupta40@gmail.com> CC: Shuah Khan , , , , , , From: "chenxiang (M)" Message-ID: <367bd5d3-f0a6-2bd7-2945-3095c827dbe6@hisilicon.com> Date: Mon, 20 Jul 2020 14:16:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20200717063438.175022-8-vaibhavgupta40@gmail.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.74.219.194] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vaibhav, ?? 2020/7/17 14:34, Vaibhav Gupta ะด??: > With legacy PM, drivers themselves were responsible for managing the > device's power states and takes care of register states. > > After upgrading to the generic structure, PCI core will take care of > required tasks and drivers should do only device-specific operations. > > The driver was calling pci_save/restore_state(), pci_choose_state(), > pci_enable/disable_device() and pci_set_power_state() which is no more > needed. > > Compile-tested only. > > Signed-off-by: Vaibhav Gupta Reviewed-by: Xiang Chen Just a small comment, below. > --- > drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 32 ++++++++------------------ > 1 file changed, 10 insertions(+), 22 deletions(-) > > diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c > index 55e2321a65bc..45605a520bc8 100644 > --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c > +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c > @@ -3374,13 +3374,13 @@ enum { > hip08, > }; > > -static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) > +static int __maybe_unused hisi_sas_v3_suspend(struct device *dev_d) > { > + struct pci_dev *pdev = to_pci_dev(dev_d); > struct sas_ha_struct *sha = pci_get_drvdata(pdev); > struct hisi_hba *hisi_hba = sha->lldd_ha; > struct device *dev = hisi_hba->dev; > struct Scsi_Host *shost = hisi_hba->shost; > - pci_power_t device_state; > int rc; > > if (!pdev->pm_cap) { > @@ -3406,21 +3406,15 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) > > hisi_sas_init_mem(hisi_hba); > > - device_state = pci_choose_state(pdev, state); > - dev_warn(dev, "entering operating state [D%d]\n", > - device_state); Please retain above print to keep consistence with the print in function hisi_sas_v3_resume(). > - pci_save_state(pdev); > - pci_disable_device(pdev); > - pci_set_power_state(pdev, device_state); > - > hisi_sas_release_tasks(hisi_hba); > > sas_suspend_ha(sha); > return 0; > } > > -static int hisi_sas_v3_resume(struct pci_dev *pdev) > +static int __maybe_unused hisi_sas_v3_resume(struct device *dev_d) > { > + struct pci_dev *pdev = to_pci_dev(dev_d); > struct sas_ha_struct *sha = pci_get_drvdata(pdev); > struct hisi_hba *hisi_hba = sha->lldd_ha; > struct Scsi_Host *shost = hisi_hba->shost; > @@ -3430,16 +3424,8 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) > > dev_warn(dev, "resuming from operating state [D%d]\n", > device_state); > - pci_set_power_state(pdev, PCI_D0); > - pci_enable_wake(pdev, PCI_D0, 0); > - pci_restore_state(pdev); > - rc = pci_enable_device(pdev); > - if (rc) { > - dev_err(dev, "enable device failed during resume (%d)\n", rc); > - return rc; > - } > + device_wakeup_disable(dev_d); > > - pci_set_master(pdev); > scsi_unblock_requests(shost); > clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); > > @@ -3447,7 +3433,6 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) > rc = hw_init_v3_hw(hisi_hba); > if (rc) { > scsi_remove_host(shost); > - pci_disable_device(pdev); > return rc; > } > hisi_hba->hw->phys_init(hisi_hba); > @@ -3468,13 +3453,16 @@ static const struct pci_error_handlers hisi_sas_err_handler = { > .reset_done = hisi_sas_reset_done_v3_hw, > }; > > +static SIMPLE_DEV_PM_OPS(hisi_sas_v3_pm_ops, > + hisi_sas_v3_suspend, > + hisi_sas_v3_resume); > + > static struct pci_driver sas_v3_pci_driver = { > .name = DRV_NAME, > .id_table = sas_v3_pci_table, > .probe = hisi_sas_v3_probe, > .remove = hisi_sas_v3_remove, > - .suspend = hisi_sas_v3_suspend, > - .resume = hisi_sas_v3_resume, > + .driver.pm = &hisi_sas_v3_pm_ops, > .err_handler = &hisi_sas_err_handler, > }; >