Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1759128ybh; Thu, 16 Jul 2020 23:38:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmTnemMPfYkW++chMb2px7gd20ZThrpEwkYE7dLUPZA4G20qKZrxgBETQu6gyh73iQeZzM X-Received: by 2002:a05:6402:1c07:: with SMTP id ck7mr7913554edb.297.1594967931187; Thu, 16 Jul 2020 23:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594967931; cv=none; d=google.com; s=arc-20160816; b=MMLvsRRH+nht2YGYUBymyeYjQbDc7JW9w3f4tkmUxAMz9XDZSavjkuBmA1HUIGlPiH 27cJ6HIKyCOVb4wg5jzfKHET4EQHLC1gLHM+icUclnjEtpSuEp1Bkihsj6KH2DP5gECH flCKVIDb8j9n0CCk9CH6TA7FtU7vuSAo9CXEUOIaSbPminbhmU5v2RPm+1ywdkT55Dk5 p6dssPJmSRC/Ns9aucLuIrZ7/K6wUwly5WJDYJGQsQy+UOGSF2wqrWr5fDjAwKB741wP er5Bp+xVTfUmFlgyLzHhkzmm+DNlLBN+oz03tm2GsUuPKm9WfdPY1jlqIxNiwZzKrMZM RHeA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l8tgAiiB6kZiNGO4J6Nzv+v3TQbrsbT5yAPUnfw5Pug=; b=IO2bhjVqxnCi9rx/wpi2Guvn4JhfXEOlqjjmUM3ig1E37hUzshe5bsVsL6Flropci/ 9aVV6oE87P21d9oUpaa/6cddJRdS/bthLzd3Z1wyurUbIy9mZFsta/QVNucUk6TEOTAz +eCC0r8srgaMt7beiRH9Nm4Xrc1K5DRUaFX5iIZ3JgF10s29pA7hpH7NPPxtH12GQH4K NkIfGpsCKleLfdRB1PYPTcH5rXFC8Y5skHT5dfYTZHHutzXE64YB2DPlnFZzG/0b3CxJ /k3+5yTqSprCQrWRq3pME8ocxLKEkl9seYK1c2YfckEN14MT33d17aTKptVtjEvK+9Zm An/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XaarUoCO; 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 cy15si4367454edb.22.2020.07.16.23.38.28; Thu, 16 Jul 2020 23:38:51 -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=XaarUoCO; 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 S1727961AbgGQGh1 (ORCPT + 99 others); Fri, 17 Jul 2020 02:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgGQGh1 (ORCPT ); Fri, 17 Jul 2020 02:37:27 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F588C061755; Thu, 16 Jul 2020 23:37:27 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a9so412379pjd.3; Thu, 16 Jul 2020 23:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l8tgAiiB6kZiNGO4J6Nzv+v3TQbrsbT5yAPUnfw5Pug=; b=XaarUoCO66nhPhPELtHqNVFXorQ6eK3GrkcYG/idLL6uzFQD6scgYMlGFHF8+ArnEe 5ugaK5J4tCVIk3w/Pec3KSsMF8hCaKhgRGWFAdpYTOHHTG1la4zboiVxAKXPTTODqi4F QpZZhaz0XHqxLGKFEcpgbQ90d8aR3tE17RH3o+9C0us8oFUv/4iZ759Z2heiF4iZ5yJt PBkjdZr0hP29Y8b6p0Yk5ofAGJjX71UIcqRTaAj/GYCuNdPMUANsO16TjZOskASRUiVc 1RbB0a6hdXFfZI9j/21dKGhQpMUSKhDSrORW76vl0LlDrQcjA2vPP0Ni4NeX2pFCJHpU 8PAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l8tgAiiB6kZiNGO4J6Nzv+v3TQbrsbT5yAPUnfw5Pug=; b=esQRuUFIfV1xapmY9ITF6mIr/YjLiVHkZUSlalf1bhtotK12rOa66zFvDgYdvXICm4 gyD7ae4FJjf53QgqAVjk1zvCXMk/T7JgirnkJUxIjOtO6otgZX+IwShkyhQYjKHNrLW8 8F60aEc8yLZTsx1vz4sgL6nfoWGvmDFjpoiWxPL/aJWrpuc9ABlR50VGdOutK5Rmo3kI UjFKvy2Wweh6WLY7RGhD18j2Bd/lvANwIg0vmU7143NqQRS8jHwjbqsDEf59+86hn1pP 5dJd8FBVNXxFgf6zjvVkZq5gcQzqXEqbN5xjxhVjr18iHe6yoSOcmr97OzO+QYGuKTH9 FY3Q== X-Gm-Message-State: AOAM530Vt0ynse6fiEyOQLfN10+BtL0CK+3ud1E9uCprOEPjBJooIJ5Y 3B6A8tn42nwkTbDKbfOSQVg= X-Received: by 2002:a17:90a:7648:: with SMTP id s8mr3550818pjl.122.1594967846799; Thu, 16 Jul 2020 23:37:26 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id y22sm1683392pjp.41.2020.07.16.23.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 23:37:26 -0700 (PDT) From: Vaibhav Gupta To: 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 Cc: Vaibhav Gupta , 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: [PATCH v1 07/15] scsi: hisi_sas_v3_hw: use generic power management Date: Fri, 17 Jul 2020 12:04:30 +0530 Message-Id: <20200717063438.175022-8-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717063438.175022-1-vaibhavgupta40@gmail.com> References: <20200717063438.175022-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); - 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, }; -- 2.27.0