Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1759633ybh; Thu, 16 Jul 2020 23:40:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1w6/NWYb/dwlXqsRygdFfCgas4qjYiXUdwHb3QEznFK2I9llPND6Djm0LWsdLSBahJdAr X-Received: by 2002:a17:906:c209:: with SMTP id d9mr7544054ejz.449.1594968000041; Thu, 16 Jul 2020 23:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594968000; cv=none; d=google.com; s=arc-20160816; b=kxLUGpZ0ZJpz8aoS3XWPyZtkfudbDiEVX50FlUMwzI3gBPwfDFtQ9PzyhvAPGZ6OoX G2XVX1y9O+xQnFc/GGm19V0HMMFBPwIdnFhRzDQn96STCziitkpBGMQ9zs+xx5k+SG0e HHh8M2KB34lRj2SlrhFz7av/EkA2bCn+GX0VrgQZADZv2w87x3lFv31eK83svZvNlnry 8jSfEpavnEstZU57eZTb0zaQHc6pyMB2bIZF6WBdC0z0XuiIJ8EfW3VgSYjEwXzf8FeZ IN0V7NKsBP+MmXaPN6uADe/EyH1nYIRwmrj+O66dQkRIE5mMsosL+Ake83jXn2aTcTKl SKwA== 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=BmYWixz0aTv3tC/NVtl+PgP5U+VPOImgYj6l6MODrn0=; b=dblgHGFxj6t9CN3CVeEc8qs107isG5MIsURBQkEmflG1CLbW+/Jm2nlE9RjBHvCs2V MdRAx1NvqmVs/zwCrZ34VUENw7nWvIyrg9vDO0toRWQmUZb/2ThE+LbaDTgh/ZX8zOzs u/rC6LPbUMrrMieLWOyy4Avwzv0siyBaDYrh0LlQYuYdjb/ooOPoBllzCIbTQjV5h5Aa A7YcV54QpCeQlWUuVCjx+DFNEnv+lj/KMfT1V+R/layzjBn5OYnPvPA3byYU/tZCi3mn 8dFjodD8UQ1IzFDdjA0bBPrCGIBZDdnIxqD4PUUaOIfuJ7/PuYfm+gMNQ+32wFv1AsZ0 IXjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B15O9is8; 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 rk8si4581064ejb.578.2020.07.16.23.39.23; Thu, 16 Jul 2020 23:40:00 -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=B15O9is8; 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 S1727094AbgGQGia (ORCPT + 99 others); Fri, 17 Jul 2020 02:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgGQGi3 (ORCPT ); Fri, 17 Jul 2020 02:38:29 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF88C061755; Thu, 16 Jul 2020 23:38:29 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id j19so6189902pgm.11; Thu, 16 Jul 2020 23:38:29 -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=BmYWixz0aTv3tC/NVtl+PgP5U+VPOImgYj6l6MODrn0=; b=B15O9is89PmX5an+uhM//ru71UM53jvDp3CejX0ogqr/+64eYgHITIjTbjOASxPvSf LEfLfM7E0XeG5y70TdtaSH/5/fV7SYxE9oKrUJZk10ICoCodnxEMIICJZ1CkSKY8JDJT /udWMKXmEtF2qhVgaHW4uLfZHODaY/vYfBw/qFLpBksJBw3hNJouno5XHevbHBoEMRI/ 3H5LSqqrCeXYjhGV3G1pNNsCoA+YMgmX8Eg2n56oGTf5AdKDk60CgfumYPATFqdqMtBt SHnnX7VQ7lq8V8EC0GjS1S/Wn9VBZ1iyDInvk5SGMEpAd/Vkxt2FugTMntAmGFeZS1iy XaeQ== 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=BmYWixz0aTv3tC/NVtl+PgP5U+VPOImgYj6l6MODrn0=; b=S1J+IGxwgcn5esfCJgs44gfPxt9hY2J5qB9JPHcfG4EpvBa7Ch0iuERDD7EoOXPc9o VKY//rZjXQjBjDKh+x9ZVXtmBWcqywY1kdAvFtk1MDojp9iwPd37KZqiFJSKPHADjmXZ WoZCwmSjjSTifqTVDd9J5wgp+IjdZmyD3iwho0gWsMJc1wzVMGJUS9JRkXS/L85cbhok uca4SOunM+80WIkmDm6U0ll1t1xqDhVfaE6BOuCPDojlTbhNGH15gL+I6oOGQJkTlm7k TUxVKaH0nAGXc/wESVKRs3bhixigfd+5KD8j//ZGyzySOm9Mz8q6wsKgWqx7eto9wOfs 5F5g== X-Gm-Message-State: AOAM532uozeo+hvy3uh6PPBjwtarWlTFjECDOnncmABRdtU2VsWKRspa MGOzew6aenYwGajOIbBukrs= X-Received: by 2002:a63:4f4d:: with SMTP id p13mr6909259pgl.400.1594967909160; Thu, 16 Jul 2020 23:38:29 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id y22sm1683392pjp.41.2020.07.16.23.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 23:38:28 -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 12/15] scsi: 3w-9xxx: use generic power management Date: Fri, 17 Jul 2020 12:04:35 +0530 Message-Id: <20200717063438.175022-13-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 Drivers using legacy PM have to manage PCI states and device's PM states themselves. They also need to take care of configuration registers. With improved and powerful support of generic PM, PCI Core takes care of above mentioned, device-independent, jobs. This driver makes use of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), pci_set_power_state() and pci_set_master() to do required operations. In generic mode, they are no longer needed. Change function parameter in both .suspend() and .resume() to "struct device*" type. Use to_pci_dev() and dev_get_drvdata() to get "struct pci_dev*" variable and drv data. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/scsi/3w-9xxx.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 3337b1e80412..c15dcfda3957 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -2191,10 +2191,10 @@ static void twa_remove(struct pci_dev *pdev) twa_device_extension_count--; } /* End twa_remove() */ -#ifdef CONFIG_PM /* This function is called on PCI suspend */ -static int twa_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused twa_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; @@ -2214,32 +2214,21 @@ static int twa_suspend(struct pci_dev *pdev, pm_message_t state) } TW_CLEAR_ALL_INTERRUPTS(tw_dev); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - return 0; } /* End twa_suspend() */ /* This function is called on PCI resume */ -static int twa_resume(struct pci_dev *pdev) +static int __maybe_unused twa_resume(struct device *dev) { int retval = 0; + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; printk(KERN_WARNING "3w-9xxx: Resuming host %d.\n", tw_dev->host->host_no); - pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); - pci_restore_state(pdev); - retval = pci_enable_device(pdev); - if (retval) { - TW_PRINTK(tw_dev->host, TW_DRIVER, 0x39, "Enable device failed during resume"); - return retval; - } + device_wakeup_disable(dev); - pci_set_master(pdev); pci_try_set_mwi(pdev); retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); @@ -2277,11 +2266,9 @@ static int twa_resume(struct pci_dev *pdev) out_disable_device: scsi_remove_host(host); - pci_disable_device(pdev); return retval; } /* End twa_resume() */ -#endif /* PCI Devices supported by this driver */ static struct pci_device_id twa_pci_tbl[] = { @@ -2297,16 +2284,15 @@ static struct pci_device_id twa_pci_tbl[] = { }; MODULE_DEVICE_TABLE(pci, twa_pci_tbl); +static SIMPLE_DEV_PM_OPS(twa_pm_ops, twa_suspend, twa_resume); + /* pci_driver initializer */ static struct pci_driver twa_driver = { .name = "3w-9xxx", .id_table = twa_pci_tbl, .probe = twa_probe, .remove = twa_remove, -#ifdef CONFIG_PM - .suspend = twa_suspend, - .resume = twa_resume, -#endif + .driver.pm = &twa_pm_ops, .shutdown = twa_shutdown }; -- 2.27.0