Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp342008ybh; Mon, 20 Jul 2020 18:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+HQT2+vexScFOW+Gh1wbRG2SgDfcY5Bvg2f+CB54vtR2exew14u73YwgY9bjudBrfrQl/ X-Received: by 2002:a17:907:728a:: with SMTP id dt10mr22538684ejc.150.1595295550343; Mon, 20 Jul 2020 18:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595295550; cv=none; d=google.com; s=arc-20160816; b=Uv4O66n7BbToquUdo7zNZDFZMmmiLL62ZI2KnSp+Hso5ZXinWE1OIFbfiP0yoCObbB o0kCTAgeKZohfDvfKwYWTeXZt1yHSjjJ5aFBAE60tjxDW+lNAtz7KDHyy59W5DQIblxb 0pDybyQmuuxEn705MesDnOq7/9uw3PPxM9pAnr/kb9Fl4f7AfJtN6eju3MGgeiOj/dSv hGfVI/Nxie6wqoSsOwtdUZyqCuWpPlOq1d2hlU8fstukBnKIg5Nv1scF5KXNWYww1l0c 4uZPWMlXEnURLt3w4PrSNvIBq2eOkiAp8tVR7aVKomgnI4LFXmR+Ejiv8RqlQ4W1XIRH 0SIQ== 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=MOX0v7EK2GmeYwdEhIC49Nx5GHbZYJg4JPkxi8CtD/I=; b=p2UaR0C+szb7P5oyhDdWUdG7y9deX1iMc0+wK1UW+m80j5sY/eBEywzk0xr0fr4WcS rzj+ToIbVxdeql7qWNpB8yMF1qF+8DKQtwNxpFig1OjlqmmfQFa+3pbODRSBji8tQOwF Bh0I7gtrT90uFnVqMKywAgTeislpQyPKhyUpXMTEhFgiq+4zR4m7QmuhvOWBG+AFuOoJ CBBTnWPJ8TVMc8xhVQv1IFiZuJ/monl4DcseXC48GEpccHfHId/4f0rFXQcTlq/3AJt1 8R/QwZh2l9AkaAlY5TI11tUcz0dxDDe/jivqF7qMmgYs4ftsHl6PWAKz8HbU24vp0s/X GYNw== 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 qp24si12725904ejb.270.2020.07.20.18.38.43; Mon, 20 Jul 2020 18:39:10 -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 S1726653AbgGUBga (ORCPT + 99 others); Mon, 20 Jul 2020 21:36:30 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7800 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725857AbgGUBga (ORCPT ); Mon, 20 Jul 2020 21:36:30 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 26509A670D8F65776AE7; Tue, 21 Jul 2020 09:36:27 +0800 (CST) Received: from [127.0.0.1] (10.74.219.194) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 21 Jul 2020 09:36:18 +0800 Subject: Re: [PATCH v2 07/15] scsi: hisi_sas_v3_hw: use generic power management To: Vaibhav Gupta , Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , 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 References: <20200720133427.454400-1-vaibhavgupta40@gmail.com> <20200720133427.454400-8-vaibhavgupta40@gmail.com> CC: Shuah Khan , , , , , , From: "chenxiang (M)" Message-ID: Date: Tue, 21 Jul 2020 09:36:18 +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: <20200720133427.454400-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 ?? 2020/7/20 21: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 > --- > drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 32 +++++++++----------------- > 1 file changed, 11 insertions(+), 21 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..824bfbe1abbb 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,12 +3406,7 @@ 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); > - pci_save_state(pdev); > - pci_disable_device(pdev); > - pci_set_power_state(pdev, device_state); > + dev_warn(dev, "entering suspend state\n"); > > hisi_sas_release_tasks(hisi_hba); > > @@ -3419,8 +3414,9 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) > 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 +3426,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 +3435,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 +3455,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, > }; >