Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3440290pxx; Mon, 2 Nov 2020 08:58:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDWCaEBuR0WOsrUYBcvnari4ZyAgWufWLd10icNUBDltA1gUkLzaY8DUbOkhM1q2w4vB2q X-Received: by 2002:aa7:ce04:: with SMTP id d4mr17141628edv.130.1604336290205; Mon, 02 Nov 2020 08:58:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604336290; cv=none; d=google.com; s=arc-20160816; b=MW6n133+48ury+CJelWcfK7K0pcHxJMHyJm6MYYrWFBzVbuks2mATXDmLNLm+dZkhn jKKwtt0OvZVEAxoDnAChMYiSXwRbVyi7B/m68V1RRNeoYL9huB7ueQIfDZ17eOZwfmRt s+6x94nZGZ0zT7w53wlyBZy+fQC8W9RRhsyB92p3Rjg2fJmL2x8BFiVoCTCYk18NUtb3 xVl6cYCQGFDqA+2lMRrMQ0dG7miTiYXTdyX3fp43IW4CtquzB7Gtv0JoIUlO+DUr2cn5 g7zQ2dyDmCNarQUi7OHlv+EqjsHHgETm7jB8k3a7dMxV1zpYL/l3n58vwgCxQ7wuBELS QrtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9uM1XyBCr19CDVWn9sf0w7KO65sKBGQo8/F3BUibYX0=; b=dBWZ2wKiOcIEoZPxfK9PTIPTLPMo2pDWvE3SVo4QoFlOno1Uuk27uDMT5betfu+hMc Lt5Q7HwdOGkeQSGjY8WMmc41NN95JH0XUKMt0HHrTKQ4bKiTJ85z3Byplp0ZGvQuMfVK EcdBTpCatXqZ39sZCqravO8dw1ccAv2fl1JSQ+SkRNCHE75TcmQoBHVMYt5VrfUpe3LB KzZ83BpEJFPcTXTl/jkntsvhvk0qwoyTMX+0og4L3/NKJdls5IK9UH8amruK+PIbCOtP LqGqIE2TRbuwRYZYQUB8a0NIBVL5/0S2iMhjRJI62ToxNqWABAUKIO3iLoqFqc4llJrQ nKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jhuPycR6; 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 w22si7025941edl.537.2020.11.02.08.57.47; Mon, 02 Nov 2020 08:58:10 -0800 (PST) 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=jhuPycR6; 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 S1727646AbgKBQyf (ORCPT + 99 others); Mon, 2 Nov 2020 11:54:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbgKBQyf (ORCPT ); Mon, 2 Nov 2020 11:54:35 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B20C0617A6; Mon, 2 Nov 2020 08:54:35 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id b12so7115351plr.4; Mon, 02 Nov 2020 08:54:35 -0800 (PST) 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=9uM1XyBCr19CDVWn9sf0w7KO65sKBGQo8/F3BUibYX0=; b=jhuPycR6Z/wfvaaHNzXfc6OMqTM4Mq+Ig3Ee77rGMzNXYvQWVO633PGQk5JKhaF3b6 3/iDxbTuFjPIBsUcSennmmHy02QR0xJUXKu9e8ClWUpoEUOEwI0NWhEjW810xOAKmzuy /fSnVWnf5zZphYFflkfjQfj6sC4ywREOnDbN5ck3and1bq5EmfSJaDj1Og5DkJ+ReaMN XbEcC6KXbk7Q9qP4VEON/GLc4LBchBug/PQf+FRuPfxkpcy30ZO66ng832u4aZ2U5sRB DnAgJGb7VLmXnm04ensXzXggKuWR2GJPsBUn9sBClxGDEFjHwXL7IKkzgAD+oi7AQtKT 4haw== 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=9uM1XyBCr19CDVWn9sf0w7KO65sKBGQo8/F3BUibYX0=; b=UGSuNGW8e02oOfdeHikjgmZbbvGUosptE6hlN02E7Y96zT1wFnvqerK5agSpGVTX5U p/AClG4sJVQmnf2MHKVmRPCcrmvEAw7Rtsk7AwdTKIqtN8iHT6esUtrajW4Iq0KAoc2c H1GpXV5mtevAEsOGAXtCTm0iykFM/jOLQQJ+VxUkbrp1tyQ+cEFCFk0OjuPiIHa+LvEU 4cAJorVbjCL3pV+ILhVK0UM/xX4jZYd/ZPtIq+YKERo98CuDf/fz29tqNsilkOo4cxEe nhl7+GoEB3YKYSTRWPHIgJb4YbC0E/bgCkAAkbIHhjwu2MHjlEgvtSDJIRXNnMoUY6Ck gPEQ== X-Gm-Message-State: AOAM5306scDJudcy3hJXrc7BFNOgwprraqOgz18CporZ9684Wkr7S+Gy BLEld4X2Nc40ViFluLxfMCc= X-Received: by 2002:a17:902:9b95:b029:d6:991d:118c with SMTP id y21-20020a1709029b95b02900d6991d118cmr18181316plp.4.1604336074711; Mon, 02 Nov 2020 08:54:34 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:54:34 -0800 (PST) From: Vaibhav Gupta To: 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 , Xiang Chen , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang , Balsundar P 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 v4 22/29] scsi: 3w-9xxx: use generic power management Date: Mon, 2 Nov 2020 22:17:23 +0530 Message-Id: <20201102164730.324035-23-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102164730.324035-1-vaibhavgupta40@gmail.com> References: <20201102164730.324035-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them. Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings. Signed-off-by: Vaibhav Gupta --- drivers/scsi/3w-9xxx.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index e458e99ff161..b4718a1b2bd6 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,31 +2214,19 @@ 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_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; - } - - pci_set_master(pdev); pci_try_set_mwi(pdev); retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); @@ -2276,11 +2264,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[] = { @@ -2296,16 +2282,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.28.0