Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3437037pxx; Mon, 2 Nov 2020 08:52:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhp7KEUGe0Ow7nALI/phebpFLTf14BSik1z0Sb39QevapubCI3zMC4KJVVzS8nIVictBIH X-Received: by 2002:a17:906:c149:: with SMTP id dp9mr17067134ejc.88.1604335953360; Mon, 02 Nov 2020 08:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604335953; cv=none; d=google.com; s=arc-20160816; b=jWe8W0chhYWyPVt1JhBKxOMDmk4VkpB3RpzKMn/A5AxD9rRAjmZ+OUilLtmHFt8s/+ AakVtaulN4gYQBEC6MJTkvj/Zwy0nbgZeCM6MdSiq74fr/KOsD194H842GsBmZxqO5Rj oDj8bF3N0VlF+PHFn4ST5OsBHuD0xkx4Gob9kW1Yc92k1ijxwQJFBhDyH6cGwH3OJ5RI URJ7mfJBhbCvxqXNNNds72kubt57Jn5XYLn9Pyr/zb5WDQ2q1b3mEETB71Kun9F1h/hi bW7SytT7iekSaBzj/fJxuTArHXuwCuh/fNUMYGNFuPiy3kfPeTyaYCv9P35LoC1A2Mop N+fQ== 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=xMl2q2iLm2/Cdtv5ee/rXDY13o0Y92WxN2/36ftQDFE=; b=GFQy5puuzB17XOJhUuJyAbfRRAqkSQUfkdowh3id30jAv1tPhYfWUdwykhr0U5GLzW nk2e74LT1RBZ2R0UMQ/dkRI3IzLqjg1tOyuxpmbM51QKDslGK7Jl5lCXhJULH+sb419M FmJxX04UJim7lwpNGp0vWa2V4V9HZ4YiSWGBgbaFu7PwIas27Fq9CQRRyhCf15vwptQm hsod9ee0zhKc1akSjyIDkHM2BMKDRby1HZlL1D84rFUV6+kvxQ2o+ebUBA9rlmq5c0Nu 7/iIqTLQw9CHAr23NL5ECPXO4lq9Mk//AdpNAFBXItIlyMx4RRbPGBizIv5Azl/ty0bq ITMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N3lZJK8y; 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 b7si710159edz.277.2020.11.02.08.52.10; Mon, 02 Nov 2020 08:52:33 -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=N3lZJK8y; 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 S1727221AbgKBQul (ORCPT + 99 others); Mon, 2 Nov 2020 11:50:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbgKBQul (ORCPT ); Mon, 2 Nov 2020 11:50:41 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53BEDC0617A6; Mon, 2 Nov 2020 08:50:41 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id o3so11259172pgr.11; Mon, 02 Nov 2020 08:50:41 -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=xMl2q2iLm2/Cdtv5ee/rXDY13o0Y92WxN2/36ftQDFE=; b=N3lZJK8yVGUBj08y7lZt7IKKaayO2BadDdgyAZ9gRmKGK7XyajcLkU5LhsDuEvMnxa PRuDKB3XzVTnwB/DYV2HNDtLpYtOjIRuPUaHDRfvDb6bOuc1p6wPfuxsWo+S8cc8L4vf iHzqhFfXxn7Jj3P2U9C4ymYwQ496zq4jFZB2HSTunKz1T2JAecHGkxV17uSihi8LqTBr GkJDeZSx8hOUUss2rEYm+nnd1bTxHsgNkMD3EWkt4HGM0IDilHelovgDeLlKUuVfiVdY +qyO0VTSi064IAD8fGEaVcA/WBgBaMYDSNI6OZYgzNbW97ChhjPKTkUJd84nwyvcHP/m 0alg== 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=xMl2q2iLm2/Cdtv5ee/rXDY13o0Y92WxN2/36ftQDFE=; b=OhT7/caLgqAyBbIAxEiNGbXpOrtjnYXP7MiAYDSKJGsO3UFgZNPAuen0VvGce6eaMt X5Vwmztt09Ov4fj7oGY/5UaclpJNgH7KXw+7Ahsb5u5pP2Q4YhL+Mvusex1OCliGzl00 /XaGe9WI/AfMwFj/nL8bKXUB/kY/EHdcvn4/58a39+V+kNPaNoTMaZ1+tF51fJYVtdSF ycoAUXhLqWN7ufjLrCmo0eEX+HJSeHd8TPOQiblTafo8zVltwIjlhUSjKZCiQdH7q4q7 SFiFHbalVyXAwecltZtT8X8oxcq56q5N3a7evJckhctx2sGulJa3Dms3PQSLsclV1Khg sJpA== X-Gm-Message-State: AOAM5334m6JTeVkeLOzpaSpnYIJAotjw2/Haezzkie0q/WQmuq5E+Gar DLIhuYEUAw6rxJ30e0tpLCM= X-Received: by 2002:a63:f80f:: with SMTP id n15mr13940744pgh.267.1604335840856; Mon, 02 Nov 2020 08:50:40 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:50:40 -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 02/29] scsi: megaraid_sas: use generic power management Date: Mon, 2 Nov 2020 22:17:03 +0530 Message-Id: <20201102164730.324035-3-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/megaraid/megaraid_sas_base.c | 51 ++++++----------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 47ffdada541d..bd330ea4063a 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7593,25 +7593,23 @@ static void megasas_shutdown_controller(struct megasas_instance *instance, megasas_return_cmd(instance, cmd); } -#ifdef CONFIG_PM /** * megasas_suspend - driver suspend entry point - * @pdev: PCI device structure - * @state: PCI power state to suspend routine + * @dev: Device structure */ -static int -megasas_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused +megasas_suspend(struct device *dev) { struct megasas_instance *instance; - instance = pci_get_drvdata(pdev); + instance = dev_get_drvdata(dev); if (!instance) return 0; instance->unload = 1; - dev_info(&pdev->dev, "%s is called\n", __func__); + dev_info(dev, "%s is called\n", __func__); /* Shutdown SR-IOV heartbeat timer */ if (instance->requestorId && !instance->skip_heartbeat_timer_del) @@ -7641,47 +7639,29 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) if (instance->msix_vectors) pci_free_irq_vectors(instance->pdev); - pci_save_state(pdev); - pci_disable_device(pdev); - - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - return 0; } /** * megasas_resume- driver resume entry point - * @pdev: PCI device structure + * @dev: Device structure */ -static int -megasas_resume(struct pci_dev *pdev) +static int __maybe_unused +megasas_resume(struct device *dev) { int rval; struct Scsi_Host *host; struct megasas_instance *instance; u32 status_reg; - instance = pci_get_drvdata(pdev); + instance = dev_get_drvdata(dev); if (!instance) return 0; host = instance->host; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - dev_info(&pdev->dev, "%s is called\n", __func__); - /* - * PCI prepping: enable device set bus mastering and dma mask - */ - rval = pci_enable_device_mem(pdev); - if (rval) { - dev_err(&pdev->dev, "Enable device failed\n"); - return rval; - } - - pci_set_master(pdev); + dev_info(dev, "%s is called\n", __func__); /* * We expect the FW state to be READY @@ -7807,14 +7787,8 @@ megasas_resume(struct pci_dev *pdev) fail_set_dma_mask: fail_ready_state: - pci_disable_device(pdev); - return -ENODEV; } -#else -#define megasas_suspend NULL -#define megasas_resume NULL -#endif static inline int megasas_wait_for_adapter_operational(struct megasas_instance *instance) @@ -8572,6 +8546,8 @@ static const struct file_operations megasas_mgmt_fops = { .llseek = noop_llseek, }; +static SIMPLE_DEV_PM_OPS(megasas_pm_ops, megasas_suspend, megasas_resume); + /* * PCI hotplug support registration structure */ @@ -8581,8 +8557,7 @@ static struct pci_driver megasas_pci_driver = { .id_table = megasas_pci_table, .probe = megasas_probe_one, .remove = megasas_detach_one, - .suspend = megasas_suspend, - .resume = megasas_resume, + .driver.pm = &megasas_pm_ops, .shutdown = megasas_shutdown, }; -- 2.28.0