Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1519301ybh; Sun, 19 Jul 2020 23:35:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcy+aFEH+/SqEimZM5uFerDel4M7tN16ghqBL9o328sQzxNd+PHJ33Fn67oiUs5wXom0TK X-Received: by 2002:a05:6402:202a:: with SMTP id ay10mr20945052edb.0.1595226905477; Sun, 19 Jul 2020 23:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595226905; cv=none; d=google.com; s=arc-20160816; b=ISzHaK8J8QHNph8aysK69QXemRl6n0QFF7Vlph2jwCJs3W7Zta0Q34hAjBPs0S/6Rk VL0OkHmbQexEq5ErRli2tAcqyUtZO24hlBoC3TFLWjCFr1LKqcorJBb8VBjwAf2yjEov d+3+PYZcTPcWb3Rc8bzwBC2dyUjs6HXgyFvMrWRi3eyhjkIlfxOYHFmeNEcPPto8GB4U OrsoinBwZDmT9Pl6qpWxMeetmsA9Ah2oG9rK/X6fUNfGNr9PfaQyADEgvcm70HztzT0L XmmTyxKqrABVz6KPNOnIRpUFIB24C4q4b4WXKnBsqh1AaxVOA27qvpaRKaFgItPI4fdf 86hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7GFd7Yku8i+FF1S4CUo1hrbA5Zh0OraFGwFf9HMOIw4=; b=PwTXlMyDl1l6evobEl3M1Q+szFEotC18XlqwmwP1tBUv6gNknSErH0/+geITCQvIgy 7izii4GhQ4Ii6NLL5RYIILCd8QcMUFFoA8B2zGh6pA0/Qn8GOaPj6SAUnXBy8UOLy09q aJbG+T2Zb7JHck5FShlPLy9Fz+qeEDjSbXInuN0TdE/VvnbheTnVq1rTFitV1GJN7WIr M/02AzVfmQiO0CpgNSC9uSCQGGcmkGNjeTmQs0ej2cCLRxhnMaDenzIWqaxkvYSfHRq6 agrNrLNGeTHJ1xiVVSEWTia9x5DyVGDgSbDXPf+IL/hQzzM0QkGEV/h7ijTwyMd1nkNS /L/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mVP/VDVo"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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.34.42; Sun, 19 Jul 2020 23:35:05 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mVP/VDVo"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726893AbgGTGeS (ORCPT + 99 others); Mon, 20 Jul 2020 02:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgGTGeS (ORCPT ); Mon, 20 Jul 2020 02:34:18 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9B05C0619D2; Sun, 19 Jul 2020 23:34:17 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id s26so8549613pfm.4; Sun, 19 Jul 2020 23:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=7GFd7Yku8i+FF1S4CUo1hrbA5Zh0OraFGwFf9HMOIw4=; b=mVP/VDVoII2NYltj2o/cI4fLTlW/fCOt78CYJjBWGV3FlC1cg7w1KI0zfcsoirtrHe JvbZzVZHR2sXINXqeeAhp+A2yvDPsaqmcWaYJK9TVh1vtyXed+oyhPkBs9lU21w7n0aP dwUT3+UKIgLVzg9F7+fC6tFRIys/i902EF85yBj7exUlO6atH0OgZxtlC4nK2ke7/5Bf BKDFGs/x2NojAd3JV1QyMpLSgzC6wh/oTwKzRGYGpJqie//kXCGszMeOOJ868KE7zm12 oRHjiy1/BDf9BqgLxoi1KB9zL7qD3zIBWDnX527KiIslcSBIuVd0Yo25ZcxgP5Tv3iEf v3cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=7GFd7Yku8i+FF1S4CUo1hrbA5Zh0OraFGwFf9HMOIw4=; b=ZI+5psT4Tw3zHBg6wlTSYcCDe6yIi5/k7w6vywBFTxy7EPQ9x3vQN+fQvwGUXsQMm0 7E7dHuSfbx/EP+i5HGNkpzDiglKtTbq4RYr6FV0n5z/0liY8tyygRHOFnCG9dN0y1NQr 6rEeQfLmwJt2z+xSDAXdeCJvi/2pCiEyNXbGqxHfpA2zBBKiLj1RuVIGoBhS3e+TEWNx cZTPfGwrMHIP7zPV7/jpPPbGIyYtNin1AeC88gxYyhMXoqPV87K/Oa1+9zvgEpVloKY3 O2FMGfURRiWXEV1ugiSCGFxt9Uwok5SzVKmPePgG+ZBWY62mMG4b5EKUaJ89vVG68AD4 DbcQ== X-Gm-Message-State: AOAM5311ACZ+4q/dLPlwfTIwYsKp/ftPyYAo6PhXONUs5Gp3EXFJQ/Bb iuS59FgTYepfIG7Teeljvlg= X-Received: by 2002:aa7:9a03:: with SMTP id w3mr17729156pfj.228.1595226857292; Sun, 19 Jul 2020 23:34:17 -0700 (PDT) Received: from gmail.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id 195sm7901326pfb.206.2020.07.19.23.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2020 23:34:16 -0700 (PDT) Date: Mon, 20 Jul 2020 12:02:53 +0530 From: Vaibhav Gupta To: "chenxiang (M)" Cc: 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 , Shuah Khan , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-scsi@vger.kernel.org, esc.storagedev@microsemi.com, megaraidlinux.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com Subject: Re: [PATCH v1 07/15] scsi: hisi_sas_v3_hw: use generic power management Message-ID: <20200720063253.GA4237@gmail.com> References: <20200717063438.175022-1-vaibhavgupta40@gmail.com> <20200717063438.175022-8-vaibhavgupta40@gmail.com> <367bd5d3-f0a6-2bd7-2945-3095c827dbe6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <367bd5d3-f0a6-2bd7-2945-3095c827dbe6@hisilicon.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2020 at 02:16:45PM +0800, chenxiang (M) wrote: > 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(). > Okay, Thanks for the review :) This is will be fixed in v2 patch-series along with other changes. -- Vaibhav Gupta > > - 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, > > }; > >