Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3440206pxx; Mon, 2 Nov 2020 08:58:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4C7YE7qpIh++iDWkSvN212Jz0BYgMzJcOxmlMBrUe8EcCdlfLYM8RxAc0c3r1Ny8Q1dx5 X-Received: by 2002:a17:906:1a57:: with SMTP id j23mr16687595ejf.291.1604336283013; Mon, 02 Nov 2020 08:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604336283; cv=none; d=google.com; s=arc-20160816; b=e8aYD0A+mt037XTf8P98IEy06n4vSOxQvOAs0iSmUvSStMRbSm2zH2WEmil9j7ByRb ALFYIw3WwL1PUAcNFfns6+d4GBFJBLUdBNQNaJpC/9F6bWHQyTJeNUbxP6sagTmqs5oJ V9oSEVakJDpMGAK0WAQmKemndQGMrGxzuGIQ5Tq4sLQ/Tq7HaT1mtEkk9Eob2CaWAZzN EZYK6O9vRDM8XATbPQmm0mb+piGmEEhXMs5vqrg/seEt8Ua3RlqL6ojU3/5RAFNhrfKA P4SWXTtvBTzQXfZ+mK3R+9p9TnCVfjK6Mh5r3XvdGrlF07VzdjExdVAbfz2BIeT7d4Sz ueRg== 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=1YdlygNrEXUlcZfght3UiooWvJCdKrIM8fi0Iud6y9Y=; b=YdTFX6BdcmXGZeFebwWu6FckNPqEgDviAaQhj3kHSkiuaqiIS7n5G+xHz0ZlgoNpS5 ns7qp2GfxygieWZHYDq+DidCFSXoHc6WuG0M+2a50sx7JVCHWIhUbw4/SrCOYtGjaq2Y OkYT4Im/Md9Cai1CewotRXipNBVSRaTWogIaF7hEnx4BZPchU1aRlT1viUZBfD3btMAz OMD1xiSqfiQTYXhfCpKazZ95FEmGe/4q8ycKQjd/3OTDi3SlrkdKmqmU1eRWEVvXLKjM 09oYOEafX0Rt7cySivxlUcmquy8nE7SMrCnkReYTUvCdD8j1R2rxJjVel6H7Il1idVyJ icAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DSlnE7WO; 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 e4si11692773eds.412.2020.11.02.08.57.40; Mon, 02 Nov 2020 08:58:02 -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=DSlnE7WO; 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 S1727483AbgKBQzp (ORCPT + 99 others); Mon, 2 Nov 2020 11:55:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727151AbgKBQzo (ORCPT ); Mon, 2 Nov 2020 11:55:44 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDF14C0617A6; Mon, 2 Nov 2020 08:55:43 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id 133so11606802pfx.11; Mon, 02 Nov 2020 08:55:43 -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=1YdlygNrEXUlcZfght3UiooWvJCdKrIM8fi0Iud6y9Y=; b=DSlnE7WOf8he6FwOZCHT0o0XLzJMz58pzJ8F8DkrkD5UT5XNdt4xRz8jQ+ehq9l8Np wIw+a9CV1/PHPbvYYAtenesSaPDQ6MbHpwtdOv89La0LK+/mL0g0NLcCo7HmahFBnp6G 9hLADmmoaDc4d40gKXJbNmthS2Cnl1TrjysQVV+TfK9fy12cnhMJd+g/DcAiCwphLpRD OwODZPwdwRvHZHTqVc+0SZt50nyKFXzDL/uy5vCNJtZFDLUjTTn2sTiGNqOLK6woOdNx 4uEj0KnUBhRMVdwRQR04iYpkHu3sBiuVuRLAnDTvrY6MoGdNG8/88lEG3MSVbfkDufGg eNug== 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=1YdlygNrEXUlcZfght3UiooWvJCdKrIM8fi0Iud6y9Y=; b=G68NmBk9R184yf4xrkyvNgZhwCgckYNexns3uhKVdxQmMeDGwi0RP4CI4dlifXvaKB PPu3jJasUfwkpEoiKp/FD/Fpv449vZLW+wRtRpXKPAjWu74mOW4GKOjjirMMAYukNeg4 3KpADnr6b6DYsjFJNlBim2X9KhkblEcBSFVkHcSkjXfsVEU1KJOAVlAb9yt/YeBNlr6q Q2XK1fmjnqIJHRYaVcaEgguxDfw4QjQrlYyPup2oyCsOiPAUtrReWMfJZl5u1lcjTh+q WErCZPSXB4R9t0CDeaW9B/CEuyhUxRXbSvg6AvZPYTSz6Kx4BPGjOtuxoAmy8OAGe83G jH2g== X-Gm-Message-State: AOAM532DlfPNvBwJHUPgqaYvXMBPzJVixPywfSOXYY3pLFsKKVH15Q18 Sr5vQNphTzp6cAASngK5Rk0= X-Received: by 2002:a63:1c45:: with SMTP id c5mr10089758pgm.357.1604336143430; Mon, 02 Nov 2020 08:55:43 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:55:42 -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 29/29] scsi: pmcraid: use generic power management Date: Mon, 2 Nov 2020 22:17:30 +0530 Message-Id: <20201102164730.324035-30-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/pmcraid.c | 43 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 5c767cd8ffc3..834556ea21d2 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -5234,53 +5234,37 @@ static void pmcraid_remove(struct pci_dev *pdev) return; } -#ifdef CONFIG_PM /** * pmcraid_suspend - driver suspend entry point for power management - * @pdev: PCI device structure - * @state: PCI power state to suspend routine + * @dev: Device structure * * Return Value - 0 always */ -static int pmcraid_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused pmcraid_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct pmcraid_instance *pinstance = pci_get_drvdata(pdev); pmcraid_shutdown(pdev); pmcraid_disable_interrupts(pinstance, ~0); pmcraid_kill_tasklets(pinstance); - pci_set_drvdata(pinstance->pdev, pinstance); pmcraid_unregister_interrupt_handler(pinstance); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } /** * pmcraid_resume - driver resume entry point PCI power management - * @pdev: PCI device structure + * @dev: Device structure * * Return Value - 0 in case of success. Error code in case of any failure */ -static int pmcraid_resume(struct pci_dev *pdev) +static int __maybe_unused pmcraid_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct pmcraid_instance *pinstance = pci_get_drvdata(pdev); struct Scsi_Host *host = pinstance->host; - int rc; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - rc = pci_enable_device(pdev); - - if (rc) { - dev_err(&pdev->dev, "resume: Enable device failed\n"); - return rc; - } - - pci_set_master(pdev); + int rc = 0; if (sizeof(dma_addr_t) == 4 || dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) @@ -5333,18 +5317,10 @@ static int pmcraid_resume(struct pci_dev *pdev) scsi_host_put(host); disable_device: - pci_disable_device(pdev); return rc; } -#else - -#define pmcraid_suspend NULL -#define pmcraid_resume NULL - -#endif /* CONFIG_PM */ - /** * pmcraid_complete_ioa_reset - Called by either timer or tasklet during * completion of the ioa reset @@ -5832,6 +5808,8 @@ static int pmcraid_probe(struct pci_dev *pdev, return -ENODEV; } +static SIMPLE_DEV_PM_OPS(pmcraid_pm_ops, pmcraid_suspend, pmcraid_resume); + /* * PCI driver structure of pmcraid driver */ @@ -5840,8 +5818,7 @@ static struct pci_driver pmcraid_driver = { .id_table = pmcraid_pci_table, .probe = pmcraid_probe, .remove = pmcraid_remove, - .suspend = pmcraid_suspend, - .resume = pmcraid_resume, + .driver.pm = &pmcraid_pm_ops, .shutdown = pmcraid_shutdown }; -- 2.28.0