Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1760757ybh; Thu, 16 Jul 2020 23:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/o5GClnBzuTeRGWeNwa+RNo/Aibk/ExGhrRo+RbeOE17O7TbVZW6e7p+1SyZMldG0JAsA X-Received: by 2002:a17:906:fca4:: with SMTP id qw4mr6774021ejb.362.1594968142496; Thu, 16 Jul 2020 23:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594968142; cv=none; d=google.com; s=arc-20160816; b=VXHaFvl/okPCUxSQQfqgh4lU2svUQA0zwU3locPp1Ya/25mZYnxmHbtej0lg0HzX84 NrAwQyWqhtkaxkJOw+dHF+7SdFBiq8y0Z9ztTN/RG/7mco22hb7ljrUSy5LNPkTHq6w6 +4bOkWwOV0ygv8MHgFRuvutWy89K4xjd4eGUwHFrKm+q/3rHpRQFjATfl3ZW7EIZmLMP FKlFhMEpTLP+dZZ/3A5s5NChQym1ZLd+WMF1OlDm46ehLGj+QLh+a+8+3eMWUSpLkBvA ZpT1CnkK3TfUK7C+PZMEBzpgzZysJeZp7L/FujKRd1I8ymIEozlXkGLCOwn0dO6rL4RQ 6bCA== 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=WwDPleRnNmF5nIya5pCRA/s+OZ7smPPXMDZ4egsrQq8=; b=FsAZ1iYEin4NmObOD9YPSnHCFgqJ2s7CvLMccL7yaRSjNLqzuv1Q3ZGwx52yc9DsDL zvTT9v7eLZltris+K23NUxvBnaHZJzHne1lySgEGw5QWyzSKMwwcQbmBpLUSWVgLoI0t 5pO9fpbZsc9X5oS10PvqxzqN6T+HJLEtgJO9W6aUAKcZXhKt0Ip4eJFKE0d25Sr35X4u aGxmUPex4groRGSCoZ3V/zCIUPEljTaiI7mL0/1BuAK67KClYCqIOCEoGmv+1cnF6DFR eqUyJIIfuFoUZMBQSHGm6hkhXy6M3JqYauygZvy8GnRMFt53pXeXI8GAvG134mriUU9L aE4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Sxs5vUMY; 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 bd1si2864899edb.290.2020.07.16.23.41.59; Thu, 16 Jul 2020 23:42:22 -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=Sxs5vUMY; 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 S1728114AbgGQGiy (ORCPT + 99 others); Fri, 17 Jul 2020 02:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgGQGix (ORCPT ); Fri, 17 Jul 2020 02:38:53 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 951F3C061755; Thu, 16 Jul 2020 23:38:53 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ls15so6059535pjb.1; Thu, 16 Jul 2020 23:38:53 -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=WwDPleRnNmF5nIya5pCRA/s+OZ7smPPXMDZ4egsrQq8=; b=Sxs5vUMY0V6BCKr7DKEOTGDZCUt/8u3jqwBpxtsn7i9+oINAXq1UxmNprGzSwGRgae B33pGfemI+QD5yx7KKdb5J8rkcGrOLBJPMe/rUMwkVYmUTCT8i/OA3Li0NsFc+3+VSHu cY39QV5mrxomlxn0m1gBI3bmE6QxqIZEHENHFRq9cnbcbQJEv4oYgWmCHj74OZj3FBln d3Q438HeyqrzkNxFVqzMgDFLZaAR70pBctstQdSawn6ms9esp3q3gE12oPOoEEyq8VwW hqq9teyF1zi3e5a1OOTzAbH1YQTXxiKbpJocrkO7ogpm74d/6ff5bNFYQKFF1Cl09hCn kxfA== 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=WwDPleRnNmF5nIya5pCRA/s+OZ7smPPXMDZ4egsrQq8=; b=AY2O7YBkOi34ggoYiWIvAAVsvpJApdULQ1YNuo+I00ApCxZVqtaLonboI9gszuqzRm iISfm2h7rv6QCD94CTjAT1LHDf8vtmvlVcuG6uc7YpNonH2DYh8uqf2VPQqrtHW3xZt7 g6BaAnI4wTozi+XPjwppxLQ36a8glp1a2cROTTvdew4DYIF6W2FUfBXK0cm5ZR742Eth SRh0KRFig4i86wSi/3OcIQu0HcxgMTz/5m4CrIKKLDR/9/+KlOOm+Qgs+6+z6dHjRWQn /7f3Yom1rfXsxRBp6AKGgWUVOXwcsZ2piBWW9jduoaRLq4BMuc0Uo1S4rnMc0BC+ljPv C8Dw== X-Gm-Message-State: AOAM532o3BzURicoRF5DM3GsacBBY7fmRSm/k/8/dnrBTOBoaki0Xflg EnFa1rSqFb+gbJKkkq+LceI= X-Received: by 2002:a17:902:8697:: with SMTP id g23mr6410059plo.94.1594967933074; Thu, 16 Jul 2020 23:38:53 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 23:38:52 -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 14/15] scsi: mvumi: use generic power management Date: Fri, 17 Jul 2020 12:04:37 +0530 Message-Id: <20200717063438.175022-15-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 dev_get_drvdata() to get drv data. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/scsi/mvumi.c | 49 ++++++++++---------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 8906aceda4c4..7a6ef8264e47 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2558,7 +2558,7 @@ static void mvumi_detach_one(struct pci_dev *pdev) /** * mvumi_shutdown - Shutdown entry point - * @device: Generic device structure + * @pdev: PCI device structure */ static void mvumi_shutdown(struct pci_dev *pdev) { @@ -2567,47 +2567,28 @@ static void mvumi_shutdown(struct pci_dev *pdev) mvumi_flush_cache(mhba); } -static int __maybe_unused mvumi_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused mvumi_suspend(struct device *dev) { - struct mvumi_hba *mhba = NULL; + struct pci_dev *pdev = to_pci_dev(dev); - mhba = pci_get_drvdata(pdev); + struct mvumi_hba *mhba = pci_get_drvdata(pdev); mvumi_flush_cache(mhba); - pci_set_drvdata(pdev, mhba); mhba->instancet->disable_intr(mhba); - free_irq(mhba->pdev->irq, mhba); mvumi_unmap_pci_addr(pdev, mhba->base_addr); - pci_release_regions(pdev); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -static int __maybe_unused mvumi_resume(struct pci_dev *pdev) +static int __maybe_unused mvumi_resume(struct device *dev) { int ret; - struct mvumi_hba *mhba = NULL; - - mhba = pci_get_drvdata(pdev); - - pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); - pci_restore_state(pdev); + struct pci_dev *pdev = to_pci_dev(dev); + struct mvumi_hba *mhba = pci_get_drvdata(pdev); - ret = pci_enable_device(pdev); - if (ret) { - dev_err(&pdev->dev, "enable device failed\n"); - return ret; - } + device_wakeup_disable(dev); - ret = mvumi_pci_set_master(pdev); ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (ret) - goto fail; - ret = pci_request_regions(mhba->pdev, MV_DRIVER_NAME); if (ret) goto fail; ret = mvumi_map_pci_addr(mhba->pdev, mhba->base_addr); @@ -2627,12 +2608,6 @@ static int __maybe_unused mvumi_resume(struct pci_dev *pdev) goto unmap_pci_addr; } - ret = request_irq(mhba->pdev->irq, mvumi_isr_handler, IRQF_SHARED, - "mvumi", mhba); - if (ret) { - dev_err(&pdev->dev, "failed to register IRQ\n"); - goto unmap_pci_addr; - } mhba->instancet->enable_intr(mhba); return 0; @@ -2642,11 +2617,12 @@ static int __maybe_unused mvumi_resume(struct pci_dev *pdev) release_regions: pci_release_regions(pdev); fail: - pci_disable_device(pdev); return ret; } +static SIMPLE_DEV_PM_OPS(mvumi_pm_ops, mvumi_suspend, mvumi_resume); + static struct pci_driver mvumi_pci_driver = { .name = MV_DRIVER_NAME, @@ -2654,10 +2630,7 @@ static struct pci_driver mvumi_pci_driver = { .probe = mvumi_probe_one, .remove = mvumi_detach_one, .shutdown = mvumi_shutdown, -#ifdef CONFIG_PM - .suspend = mvumi_suspend, - .resume = mvumi_resume, -#endif + .driver.pm = &mvumi_pm_ops, }; module_pci_driver(mvumi_pci_driver); -- 2.27.0