From patchwork Mon Nov 2 16:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874515 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AAC76A2 for ; Mon, 2 Nov 2020 16:50:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D74B722275 for ; Mon, 2 Nov 2020 16:50:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o1vVtcE0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbgKBQub (ORCPT ); Mon, 2 Nov 2020 11:50:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbgKBQua (ORCPT ); Mon, 2 Nov 2020 11:50:30 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B35C5C0617A6; Mon, 2 Nov 2020 08:50:30 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id t6so7084486plq.11; Mon, 02 Nov 2020 08:50:30 -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=eVI1RgdCTcgKOQYTeMJvf6pf7gm9DRT8JtIKidpJzFw=; b=o1vVtcE0URMlblenBRnxhQv+WgM1/34H7ENf+T6jvqYNL4Ji1VBlKPS1oMXYJ2aWyW NK/DV4SRSh+J8EOC3I9/1kRBQ7wyBgPQ9no4+U5sAsh42ryw8q3tsj7U8yvGUk1wOars qZt5hZUX15fvSrC6TLoj51YQu4QNGkj+OSo85oiqugyIKxty5w9yQm+q2f3eCusPsW1Z PBnu+O5hefQXc+E8y0mVQEjw45gBPEfvgCxuGmJEWOMe3N8nabHRI98VwK8wkURnJSxw eaAqYKq6AxzOfK3c6K9bSQ/NCf6gE11ArGXN3Izlko1WekyG2IkiVys9EO6Lo5DzzIBz P/Ag== 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=eVI1RgdCTcgKOQYTeMJvf6pf7gm9DRT8JtIKidpJzFw=; b=YOmLZxn0BQl5RPxxzI47h+zfkYBdxHnkDD9XPFHpj3H+YOZ0KH7bD16jBCpiF76giD bQlbxIWWl1/9MYHG9tGGdpcskkvG5PTDqsgEjOMOiLwq/mIlujcYy+LR93HXDQAchPcw wiPJvv5CDPBP+8s694b5Bs0wZoqPRMpAsw0UQfaK4qdKOXYSMspSdWHHRW7TJQviqKr+ Q1iZp/0mlJE9XogmhxeeImelMw1fSO7HRYa5YI66AkUnNLsIdzy7MyYBKdX2U6wW1ZKC gWmTTyDKRscCKO6ELOjMSPqr/Tvil1COj0kss3oGdYrh3B49Z96MUMs0rbyWqdzmLFJg GT9A== X-Gm-Message-State: AOAM532rRysNk9GhXpB9gCQnnjLDL/9R5x+pjQ4vaShJyiBko1k5WiUN j1LWayV539rqIJ2Ovpmp38Y= X-Google-Smtp-Source: ABdhPJw5fJDnITTvgjuL1NAJKSK4gc4d1RYAkQ7nw/AjwjVz99aLStx0ZElhrmau4lJ+iSxFQEjLvg== X-Received: by 2002:a17:902:6909:b029:d6:6ec4:e1f7 with SMTP id j9-20020a1709026909b02900d66ec4e1f7mr14716425plk.40.1604335830255; Mon, 02 Nov 2020 08:50:30 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:50:29 -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 01/29] scsi: megaraid_sas: Drop PCI wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:02 +0530 Message-Id: <20201102164730.324035-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in megasas_resume(), and there is no corresponding pci_enable_wake(...., true) in megasas_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from megasas_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/megaraid/megaraid_sas_base.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 41cd66fc7d81..47ffdada541d 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7668,7 +7668,6 @@ megasas_resume(struct pci_dev *pdev) host = instance->host; pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); dev_info(&pdev->dev, "%s is called\n", __func__); From patchwork Mon Nov 2 16:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874517 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1691392C for ; Mon, 2 Nov 2020 16:50:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E706722277 for ; Mon, 2 Nov 2020 16:50:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N3lZJK8y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbgKBQul (ORCPT ); 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-Google-Smtp-Source: ABdhPJwlKBw65eKuMzpHgWsQqGYAVR+8a482HYN1Sgsq7fhC5AYvVA4J3WoyPhUJQvYex+BL7iTQVw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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, }; From patchwork Mon Nov 2 16:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07DDC92C for ; Mon, 2 Nov 2020 16:50:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D606622268 for ; Mon, 2 Nov 2020 16:50:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FWH9UY/w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727307AbgKBQux (ORCPT ); Mon, 2 Nov 2020 11:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727300AbgKBQuv (ORCPT ); Mon, 2 Nov 2020 11:50:51 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CA25C0617A6; Mon, 2 Nov 2020 08:50:51 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id r10so7110864plx.3; Mon, 02 Nov 2020 08:50:51 -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=6vxmT3Q80RGrzEju3iFEpX/Dlj35TxSTYI0m/9BGYRs=; b=FWH9UY/wDTqHTqNDW/pn8h2yIfmsgHS21dYTh1aHdf8cUOHfnUFegf8yn4WRjjWGaH joAdmrRXOGEPJub/iSdpNMLi3lokD5WjHwC7k6ubgycdjzBFcw0+CbbaxCMVPRI6n8ML CY5AE4/7irrONltr1KZNZUnHRB3XLAjcDnAHaEtizk/QyoQZLPhexwozPopzFdSnocqR nlkTnvEIyEbP/sJTUBWxMiVnt1vA2HAc860zNARXrW0dlskPnVvCA/UJxJb0gd36o6pf YIJbquACBnknKIgAWfALmem9Up0DMD7OBWOCKDhEByXNdWHQ6L1SYiIhbwatDrEychsg SJ1w== 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=6vxmT3Q80RGrzEju3iFEpX/Dlj35TxSTYI0m/9BGYRs=; b=rRDxakJdEpKP4b/PSXa78G3xWMNOqBwqx78tNPKP56XNiBf/qE+81Dcz3aSqqRi3oM /h+YOz87c7UjviH4O2KHEhFlT3k4Gz/SobPEDRRncEn6jgLpP0qmr2Zf67cYQeSrdOU7 NgDXrYcU4t0GggJ8ewYvNI45k2ZeELJD4bJJVbFsaW9w1vdr9ktS5aXRCIWf6LphOkCJ TQoBsCBEmU3rTZ4J/aR+ffWNO+38wKS5BL18pCal31ejNyi9HcAGdd0ZrUr2I18db7JZ mAJ0/yXcjwKTtwV1P9wi3yUZuJ1VDsfA5SeNqrzy20cW7rmC9ei0QFN36r0+eiXROKt7 KYug== X-Gm-Message-State: AOAM531m7GNdm6dD0FZ3lezBzMKwCPracN8UJk1QH/6aJelGnQprJV2U 2C0oTZIuUIh6j+uJcLm0aiw= X-Google-Smtp-Source: ABdhPJz92w4o9HyAGBIzrllFPmwzHVzYzCAtkRWAXWpfppLSfftceomQcU1lQHfBjVjZXUoUlHfUJA== X-Received: by 2002:a17:902:8504:b029:d6:7552:19ab with SMTP id bj4-20020a1709028504b02900d6755219abmr22151785plb.83.1604335850971; Mon, 02 Nov 2020 08:50:50 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:50:50 -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 03/29] scsi: megaraid_sas: update function description Date: Mon, 2 Nov 2020 22:17:04 +0530 Message-Id: <20201102164730.324035-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Function parameter 'pdev 'is described as Generic Device Structure. It is a PCI device structure. Signed-off-by: Vaibhav Gupta --- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index bd330ea4063a..7384c8e9149d 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7958,7 +7958,7 @@ static void megasas_detach_one(struct pci_dev *pdev) /** * megasas_shutdown - Shutdown entry point - * @pdev: Generic device structure + * @pdev: PCI device structure */ static void megasas_shutdown(struct pci_dev *pdev) { From patchwork Mon Nov 2 16:47:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A2E06A2 for ; Mon, 2 Nov 2020 16:51:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78EB822268 for ; Mon, 2 Nov 2020 16:51:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nJYWDgNO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727323AbgKBQvC (ORCPT ); Mon, 2 Nov 2020 11:51:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727216AbgKBQvC (ORCPT ); Mon, 2 Nov 2020 11:51:02 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE44CC0617A6; Mon, 2 Nov 2020 08:51:01 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id t6so7085311plq.11; Mon, 02 Nov 2020 08:51:01 -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=cErhV76ENt4TSg24Fp7Ht7DEbiQDvH5TWJw2QAVKIhM=; b=nJYWDgNOZZtlxDlK5ueJ/5vxhAzGVJPLWbe9fkSlizduzmFLoZH0zqf9t3kk2HuA8U lE6tc3WYq/hvTZ0O/dieS6Q0bsdb+ZwDKBi/WGF+MNjDOGgMOOwl9I9+wvij52X2KOd+ A0IfARUHoB8llo6o4QJGAa3UBP3gx5Ug2qQLazIjl9u7OejBgmdVtGzum+CTl/qIPohd vzbAFqVqxo9zbrtVnZ6LWqiAOk0nN93L8q48Eg1TSmA+c6G2URYTrBZxj+k7FnkjHTkB VKsFmh+7Foh3Owu1wa0QQ9xbX8EmHldsQpndxjyfW4Ou2OWc3Uwh/ljhBDnfv/MiEC+i DGbg== 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=cErhV76ENt4TSg24Fp7Ht7DEbiQDvH5TWJw2QAVKIhM=; b=kpTTUbi7UjMnXl83hH/dgbBTL5cDeQUZXrZ+V7yLht+EE10nNp1iEuzA5ol3DUGSxc jkxNodkHunZkw7qr36u5w5rfiqVJujY4V7xaMfFXuyysfwkrLh8FljPkDy7PCQu+tmD0 hIpXzQ1Idz0YeqiUs3ixdg9/EuFDqAmrapzSLnk5vCPUubEdppNtn0x8pdI8qPxz1QtO nEcwbdc8geztmujcjpWr0tMuQJu2i3RsDk6669y2AejmtwMygNUSId65JtTowtipvdFA JPktSfc+kAG91ZbqVnwRuBYJjBuc9vEvmy4MNrIzsNiowuX3rHG9b52eHJOzsGodzL/C BubQ== X-Gm-Message-State: AOAM531uW3KBBSpiFNCYZDBnbiK6QoQr//K3HgdITY/RTOT+djnT/Jz4 wn+kRVL9L8ghj9PumeCVihA= X-Google-Smtp-Source: ABdhPJwp05t7yRIHJ8huQ7eLUfoMgxcmBsNLB9C02JBi8y2dAFVcKApcplQEaIPahN07b26OqEY6+Q== X-Received: by 2002:a17:902:bb81:b029:d5:b437:edb4 with SMTP id m1-20020a170902bb81b02900d5b437edb4mr21167595pls.6.1604335861454; Mon, 02 Nov 2020 08:51:01 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:51:00 -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 04/29] scsi: aacraid: Drop pci_enable_wake() from .resume Date: Mon, 2 Nov 2020 22:17:05 +0530 Message-Id: <20201102164730.324035-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in aac_resume(), and there is no corresponding pci_enable_wake(...., true) in aac_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this is a bug and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from aac_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/aacraid/linit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 8f3772480582..8c4dcb5ab329 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1938,7 +1938,6 @@ static int aac_resume(struct pci_dev *pdev) int r; pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); r = pci_enable_device(pdev); From patchwork Mon Nov 2 16:47:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874523 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 385C892C for ; Mon, 2 Nov 2020 16:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18DE822277 for ; Mon, 2 Nov 2020 16:51:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eP3P0NhL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727320AbgKBQvW (ORCPT ); Mon, 2 Nov 2020 11:51:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbgKBQvW (ORCPT ); Mon, 2 Nov 2020 11:51:22 -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 7AE6FC0617A6; Mon, 2 Nov 2020 08:51:22 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id x13so11592870pfa.9; Mon, 02 Nov 2020 08:51:22 -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=AdqDqmNu7Nx1PvYYi5OdlW5q1lUoCI4j4VahjSwyvEk=; b=eP3P0NhLcYeng6TK2EUujst4SvydxCeEyCUntT9SC6+LJvk6QHykhuueH6/pLI8gt1 JK7o+Kf5mqLx1NcJLWDCG81IPiUgEJzCPPLtLgwaHSyovtvH7t3P8pTlNcMnjcTjGJv9 Sl2bEk60Inn362/57NiowC+hgrvZCsYgGpWKA3TpQy5EG1WgSY/wjcIkGWi7KygKi+Go MdogMoJxegrgr530XGi0i+9ipmhRgpmpNaQtQ2zTd10tixdh97xB35Wtgssel8g+y1NP dxSTp4MoY8BZNBAcF8fwWGesVuDEB5NTgvzoAth0AhvFL1WdJIzmQ4Rpiv0vxnTiyiVo G8aA== 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=AdqDqmNu7Nx1PvYYi5OdlW5q1lUoCI4j4VahjSwyvEk=; b=INqBhtpPa/47P8iwMajcDBvxlsJt4bnBz61LcV/kOIBrKeDbdQEvWHiQlmtEhwdWj+ ZIcaskQ0/W/E9FrekbpMLwtfm5jrvJ0nsghObhZDRlqJD2lhpXC8cySCuEGmSuZsULvp fiSrnKiwb+cM4sf6V+S506ShHY81pWn0CReFvt6+9+94VVywhvIOQw4dn2u//OeJpKcO YP97kXvaoqY/6dEg2zn0FrxvHeVmkuWL0gYIXr6JZ9mjLmLMR55ZeKPJnO1Wy4ZcWPm0 6XKx72EjdL9HW9m6Y9dy3GkYwev9XfII1yZ1Jlti/WscHNYsCZNLKxmY2FG/IFzZRmRE 947g== X-Gm-Message-State: AOAM531DJoNZ4vKPzpKdKWkLZCMQJ5HdAaJ/Zz23LMG83iX5ASiGfT8D AG8XRlk2bPaEP6OlwAXLd5A= X-Google-Smtp-Source: ABdhPJw3oohovIVzEW6Lk1KewPzZqifa78hPzZ3VGJMa6114i8blFub1+pk+Izdv8VuHVrnlf8bR7w== X-Received: by 2002:a63:4556:: with SMTP id u22mr3179533pgk.261.1604335882067; Mon, 02 Nov 2020 08:51:22 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:51:21 -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 05/29] scsi: aacraid: use generic power management Date: Mon, 2 Nov 2020 22:17:06 +0530 Message-Id: <20201102164730.324035-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 Acked-by: Balsundar P --- drivers/scsi/aacraid/linit.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 8c4dcb5ab329..5177d387854a 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1910,11 +1910,9 @@ static int aac_acquire_resources(struct aac_dev *dev) } -#if (defined(CONFIG_PM)) -static int aac_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused aac_suspend(struct device *dev) { - - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev); struct aac_dev *aac = (struct aac_dev *)shost->hostdata; scsi_host_block(shost); @@ -1923,28 +1921,14 @@ static int aac_suspend(struct pci_dev *pdev, pm_message_t state) aac_release_resources(aac); - pci_set_drvdata(pdev, shost); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - return 0; } -static int aac_resume(struct pci_dev *pdev) +static int __maybe_unused aac_resume(struct device *dev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev); struct aac_dev *aac = (struct aac_dev *)shost->hostdata; - int r; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - r = pci_enable_device(pdev); - - if (r) - goto fail_device; - pci_set_master(pdev); if (aac_acquire_resources(aac)) goto fail_device; /* @@ -1959,10 +1943,8 @@ static int aac_resume(struct pci_dev *pdev) fail_device: printk(KERN_INFO "%s%d: resume failed.\n", aac->name, aac->id); scsi_host_put(shost); - pci_disable_device(pdev); return -ENODEV; } -#endif static void aac_shutdown(struct pci_dev *dev) { @@ -2107,15 +2089,14 @@ static struct pci_error_handlers aac_pci_err_handler = { .resume = aac_pci_resume, }; +static SIMPLE_DEV_PM_OPS(aac_pm_ops, aac_suspend, aac_resume); + static struct pci_driver aac_pci_driver = { .name = AAC_DRIVERNAME, .id_table = aac_pci_tbl, .probe = aac_probe_one, .remove = aac_remove_one, -#if (defined(CONFIG_PM)) - .suspend = aac_suspend, - .resume = aac_resume, -#endif + .driver.pm = &aac_pm_ops, .shutdown = aac_shutdown, .err_handler = &aac_pci_err_handler, }; From patchwork Mon Nov 2 16:47:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874525 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 341036A2 for ; Mon, 2 Nov 2020 16:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DA8722277 for ; Mon, 2 Nov 2020 16:51:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MVIGolkA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727156AbgKBQvj (ORCPT ); Mon, 2 Nov 2020 11:51:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgKBQvj (ORCPT ); Mon, 2 Nov 2020 11:51:39 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F932C0617A6; Mon, 2 Nov 2020 08:51:39 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id t6so7086185plq.11; Mon, 02 Nov 2020 08:51:39 -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=Rkeme0HWV2vGIGAMlkCl1UyOrxrPPWM02ZKhUnuADDY=; b=MVIGolkAxm9wL3HFLSzBrHr4RCbLS5hSYygOp5T65SYrlSe9dW1NgOWGohX//YkaGX pW+RhEBrR0hSAtGL7Ua+0fJ3X5OKNXfYzpqvEYCfxV/ugd3d7dzcgGALRgjb39aHN0t2 kW2ytvt05l1mFlE8DSJa/UCZetJRRY9EYJrwkXI2fpx+Nb2kGazlJ5yDLTSB9MjIlQnt FPto44U4wMEFqrmQQRtQgJ4ucMaXxvqnGSY1V89ji6PN0f3MNxXyAXPwJipJdn/v2rkH ApS/zKPsGPYZ8tga7K9gwTxocryAqiulZWQm0AAO4LcMD+RaG56+LBUvn3b9nTm9RCei eQkg== 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=Rkeme0HWV2vGIGAMlkCl1UyOrxrPPWM02ZKhUnuADDY=; b=dXNHOO2iMN1x7mCoFaA09w+t92fsxoUMD0Hm+9DWt94Yy72MxxyU3tHWwO2VvtaSGx 7KcfLDgQvSuO1PdMXBLlVgEfN8+CUKqvvWC6ngETM8fAOxI0ETsHiHNxaA5DZ2hz4KvP DMGil1N46UG7meAebFGC9sz6qJQO+Dv5VWjBsnAyAPD8+ZEC1avO8lg3USB7XKuQi9HX 8J5AT2Gxsx90UB+ABcSilHn9iwLmh/e5JXvFJHD7y5y092MXMEKe/vZFZQEQPUQ2DnHg XNd0OMsMalGq3ee9lpNCRmpuEs4TK29LxYu/pGpGxNdQ9yjL+bZyH9Fk0XYXkDZ7YUCs I7Eg== X-Gm-Message-State: AOAM533v4rEYe+lvYZtNIch2Ib/LTXPPwwCaaMN5Iv5pMHRBTrEhfB+v DO47UCp9ljqGL5g+ProwU8ij7XMXcb+5Xg== X-Google-Smtp-Source: ABdhPJwPTJkQo+eyulLgDesYWM3zj+Bn4umMf0gblMnQTVE2tWeRwAcD0M5KtQ7iNDdU2kCnXjCNMQ== X-Received: by 2002:a17:902:6909:b029:d6:6ec4:e1f7 with SMTP id j9-20020a1709026909b02900d66ec4e1f7mr14719882plk.40.1604335899053; Mon, 02 Nov 2020 08:51:39 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:51:38 -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 06/29] scsi: aic7xxx: use generic power management Date: Mon, 2 Nov 2020 22:17:07 +0530 Message-Id: <20201102164730.324035-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org use generic power management 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/aic7xxx/aic7xxx.h | 10 ++---- drivers/scsi/aic7xxx/aic7xxx_core.c | 6 ++-- drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 46 ++++++-------------------- drivers/scsi/aic7xxx/aic7xxx_pci.c | 4 +-- 4 files changed, 17 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h index 88b90f9806c9..11a09798e6b5 100644 --- a/drivers/scsi/aic7xxx/aic7xxx.h +++ b/drivers/scsi/aic7xxx/aic7xxx.h @@ -1134,9 +1134,7 @@ const struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t); int ahc_pci_config(struct ahc_softc *, const struct ahc_pci_identity *); int ahc_pci_test_register_access(struct ahc_softc *); -#ifdef CONFIG_PM -void ahc_pci_resume(struct ahc_softc *ahc); -#endif +void __maybe_unused ahc_pci_resume(struct ahc_softc *ahc); /*************************** EISA/VL Front End ********************************/ struct aic7770_identity *aic7770_find_device(uint32_t); @@ -1160,10 +1158,8 @@ int ahc_chip_init(struct ahc_softc *ahc); int ahc_init(struct ahc_softc *ahc); void ahc_intr_enable(struct ahc_softc *ahc, int enable); void ahc_pause_and_flushwork(struct ahc_softc *ahc); -#ifdef CONFIG_PM -int ahc_suspend(struct ahc_softc *ahc); -int ahc_resume(struct ahc_softc *ahc); -#endif +int __maybe_unused ahc_suspend(struct ahc_softc *ahc); +int __maybe_unused ahc_resume(struct ahc_softc *ahc); void ahc_set_unit(struct ahc_softc *, int); void ahc_set_name(struct ahc_softc *, char *); void ahc_free(struct ahc_softc *ahc); diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index 725bb7f58054..4ef7af8c0f55 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -5590,8 +5590,7 @@ ahc_pause_and_flushwork(struct ahc_softc *ahc) ahc->flags &= ~AHC_ALL_INTERRUPTS; } -#ifdef CONFIG_PM -int +int __maybe_unused ahc_suspend(struct ahc_softc *ahc) { @@ -5617,7 +5616,7 @@ ahc_suspend(struct ahc_softc *ahc) return (0); } -int +int __maybe_unused ahc_resume(struct ahc_softc *ahc) { @@ -5626,7 +5625,6 @@ ahc_resume(struct ahc_softc *ahc) ahc_restart(ahc); return (0); } -#endif /************************** Busy Target Table *********************************/ /* * Return the untagged transaction id for a given target/channel lun. diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index 9b293b1f0b71..a07e94fac673 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -121,47 +121,23 @@ static const struct pci_device_id ahc_linux_pci_id_table[] = { MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table); -#ifdef CONFIG_PM -static int -ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) +static int __maybe_unused +ahc_linux_pci_dev_suspend(struct device *dev) { - struct ahc_softc *ahc = pci_get_drvdata(pdev); - int rc; - - if ((rc = ahc_suspend(ahc))) - return rc; + struct ahc_softc *ahc = dev_get_drvdata(dev); - pci_save_state(pdev); - pci_disable_device(pdev); - - if (mesg.event & PM_EVENT_SLEEP) - pci_set_power_state(pdev, PCI_D3hot); - - return rc; + return ahc_suspend(ahc); } -static int -ahc_linux_pci_dev_resume(struct pci_dev *pdev) +static int __maybe_unused +ahc_linux_pci_dev_resume(struct device *dev) { - struct ahc_softc *ahc = pci_get_drvdata(pdev); - int rc; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - if ((rc = pci_enable_device(pdev))) { - dev_printk(KERN_ERR, &pdev->dev, - "failed to enable device after resume (%d)\n", rc); - return rc; - } - - pci_set_master(pdev); + struct ahc_softc *ahc = dev_get_drvdata(dev); ahc_pci_resume(ahc); return (ahc_resume(ahc)); } -#endif static void ahc_linux_pci_dev_remove(struct pci_dev *pdev) @@ -319,14 +295,14 @@ ahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width) } } +static SIMPLE_DEV_PM_OPS(ahc_linux_pci_dev_pm_ops, + ahc_linux_pci_dev_suspend, + ahc_linux_pci_dev_resume); static struct pci_driver aic7xxx_pci_driver = { .name = "aic7xxx", .probe = ahc_linux_pci_dev_probe, -#ifdef CONFIG_PM - .suspend = ahc_linux_pci_dev_suspend, - .resume = ahc_linux_pci_dev_resume, -#endif + .driver.pm = &ahc_linux_pci_dev_pm_ops, .remove = ahc_linux_pci_dev_remove, .id_table = ahc_linux_pci_id_table }; diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c index 656f680c7802..dab3a6d12c4d 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c @@ -2008,8 +2008,7 @@ ahc_pci_chip_init(struct ahc_softc *ahc) return (ahc_chip_init(ahc)); } -#ifdef CONFIG_PM -void +void __maybe_unused ahc_pci_resume(struct ahc_softc *ahc) { /* @@ -2040,7 +2039,6 @@ ahc_pci_resume(struct ahc_softc *ahc) ahc_release_seeprom(&sd); } } -#endif static int ahc_aic785X_setup(struct ahc_softc *ahc) From patchwork Mon Nov 2 16:47:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874527 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F15192C for ; Mon, 2 Nov 2020 16:51:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5FD922268 for ; Mon, 2 Nov 2020 16:51:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o0+RixOC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727359AbgKBQvv (ORCPT ); Mon, 2 Nov 2020 11:51:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgKBQvv (ORCPT ); Mon, 2 Nov 2020 11:51:51 -0500 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 00E2BC0617A6; Mon, 2 Nov 2020 08:51:51 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id t14so11302851pgg.1; Mon, 02 Nov 2020 08:51:50 -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=cJtPRbZ0BXTdxtMhOPuwVb993Cdrsr394jXmvtsCRXA=; b=o0+RixOC4+HHVj6IcZW2lxk7rwbti9/GvAsbGq27zORpiX5cG1FvjlbbRWCKcbJiGF Vs7IsnKkJmM+36NfFuYKo0L/FCmh5goFm0hzMpe0Za4SjFFM3gCI/B+6R/JTnHpXZd2b stDzegLSVxEFArvrp3VAWZe5KYgISU8AIzLnWGuIBsYBc7jtP3/YdXvAxDgQ/BD0xbNR VffUwUPEFHNLZIwOUeY2IULJ/p+Sx3J5mfIGQaU2LFOX+Ka1KZfyzy3cU8QWj65H0feQ 6b0X51LFE8QhjNwEqiWg0v0/CdO8DpJm429usdwVCb6f16jfJWt8B2cauQEKTumyCj7d SAEg== 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=cJtPRbZ0BXTdxtMhOPuwVb993Cdrsr394jXmvtsCRXA=; b=PyjT0+lGOR10AGZJonwyOrG/XtGhrY+r8eua4Zhr29B/ZwUoD82HJsXXFQecRVwrqj Gml0HJ/Po8qRT/cC0FUrZvPe7XiUWDx3D3jnsiVti0xYCFOyghJiZPJc3HYFwlinM1gU /fr5chgBXVVsu7YcGGCrlYHop/03TNj8cqvwV44g/HfavCxYCgzywdfo6SVn7NYCkuCX TzfKNflVKtYaJeUB2ieSBjvmhgtGFVJ/MBqQRKpexnV02mKsSTHe+YG8CdIx9rrYxP4C Vzfo1rBD2Yh4wmXZ0zrEq6s+NPd1tthX+RXwUvbbWGqn7iByuqrbYZagAL4XjM1EPQDi LXLA== X-Gm-Message-State: AOAM53083nEjdZ/lI5Rd8h9bzoXvnbUjXq6C9p7MULXb44bhAdeP8/XB drDu8JgSmlynxby5me3L0HY= X-Google-Smtp-Source: ABdhPJwMkLBsyBK8ShkMbKcFNpZL8/RhL7F9NjCxS+3MHLcgt2hVh7/aAb8+Yaa5TiGJGPB9d9fgfA== X-Received: by 2002:a63:d66:: with SMTP id 38mr13160055pgn.400.1604335910487; Mon, 02 Nov 2020 08:51:50 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:51:50 -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 07/29] scsi: aic79xx: use generic power management Date: Mon, 2 Nov 2020 22:17:08 +0530 Message-Id: <20201102164730.324035-8-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/aic7xxx/aic79xx.h | 12 +++---- drivers/scsi/aic7xxx/aic79xx_core.c | 8 ++--- drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 43 +++++++------------------- drivers/scsi/aic7xxx/aic79xx_pci.c | 6 ++-- 4 files changed, 20 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h index 9a515551641c..dd5dfd4f30a5 100644 --- a/drivers/scsi/aic7xxx/aic79xx.h +++ b/drivers/scsi/aic7xxx/aic79xx.h @@ -1330,10 +1330,8 @@ const struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); int ahd_pci_config(struct ahd_softc *, const struct ahd_pci_identity *); int ahd_pci_test_register_access(struct ahd_softc *); -#ifdef CONFIG_PM -void ahd_pci_suspend(struct ahd_softc *); -void ahd_pci_resume(struct ahd_softc *); -#endif +void __maybe_unused ahd_pci_suspend(struct ahd_softc *); +void __maybe_unused ahd_pci_resume(struct ahd_softc *); /************************** SCB and SCB queue management **********************/ void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, @@ -1344,10 +1342,8 @@ struct ahd_softc *ahd_alloc(void *platform_arg, char *name); int ahd_softc_init(struct ahd_softc *); void ahd_controller_info(struct ahd_softc *ahd, char *buf); int ahd_init(struct ahd_softc *ahd); -#ifdef CONFIG_PM -int ahd_suspend(struct ahd_softc *ahd); -void ahd_resume(struct ahd_softc *ahd); -#endif +int __maybe_unused ahd_suspend(struct ahd_softc *ahd); +void __maybe_unused ahd_resume(struct ahd_softc *ahd); int ahd_default_config(struct ahd_softc *ahd); int ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd); diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 98b02e7d38bb..78560a85b1e3 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -7866,11 +7866,9 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd) ahd->flags &= ~AHD_ALL_INTERRUPTS; } -#ifdef CONFIG_PM -int +int __maybe_unused ahd_suspend(struct ahd_softc *ahd) { - ahd_pause_and_flushwork(ahd); if (LIST_FIRST(&ahd->pending_scbs) != NULL) { @@ -7881,15 +7879,13 @@ ahd_suspend(struct ahd_softc *ahd) return (0); } -void +void __maybe_unused ahd_resume(struct ahd_softc *ahd) { - ahd_reset(ahd, /*reinit*/TRUE); ahd_intr_enable(ahd, TRUE); ahd_restart(ahd); } -#endif /************************** Busy Target Table *********************************/ /* diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index 8b891a05d9e7..07b670b80f1b 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c @@ -74,11 +74,10 @@ static const struct pci_device_id ahd_linux_pci_id_table[] = { MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table); -#ifdef CONFIG_PM -static int -ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) +static int __maybe_unused +ahd_linux_pci_dev_suspend(struct device *dev) { - struct ahd_softc *ahd = pci_get_drvdata(pdev); + struct ahd_softc *ahd = dev_get_drvdata(dev); int rc; if ((rc = ahd_suspend(ahd))) @@ -86,39 +85,20 @@ ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) ahd_pci_suspend(ahd); - pci_save_state(pdev); - pci_disable_device(pdev); - - if (mesg.event & PM_EVENT_SLEEP) - pci_set_power_state(pdev, PCI_D3hot); - return rc; } -static int -ahd_linux_pci_dev_resume(struct pci_dev *pdev) +static int __maybe_unused +ahd_linux_pci_dev_resume(struct device *dev) { - struct ahd_softc *ahd = pci_get_drvdata(pdev); - int rc; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - if ((rc = pci_enable_device(pdev))) { - dev_printk(KERN_ERR, &pdev->dev, - "failed to enable device after resume (%d)\n", rc); - return rc; - } - - pci_set_master(pdev); + struct ahd_softc *ahd = dev_get_drvdata(dev); ahd_pci_resume(ahd); ahd_resume(ahd); - return rc; + return 0; } -#endif static void ahd_linux_pci_dev_remove(struct pci_dev *pdev) @@ -224,13 +204,14 @@ ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return (0); } +static SIMPLE_DEV_PM_OPS(ahd_linux_pci_dev_pm_ops, + ahd_linux_pci_dev_suspend, + ahd_linux_pci_dev_resume); + static struct pci_driver aic79xx_pci_driver = { .name = "aic79xx", .probe = ahd_linux_pci_dev_probe, -#ifdef CONFIG_PM - .suspend = ahd_linux_pci_dev_suspend, - .resume = ahd_linux_pci_dev_resume, -#endif + .driver.pm = &ahd_linux_pci_dev_pm_ops, .remove = ahd_linux_pci_dev_remove, .id_table = ahd_linux_pci_id_table }; diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c index 8397ae93f7dd..2f0bdb9225a4 100644 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c @@ -377,8 +377,7 @@ ahd_pci_config(struct ahd_softc *ahd, const struct ahd_pci_identity *entry) return ahd_pci_map_int(ahd); } -#ifdef CONFIG_PM -void +void __maybe_unused ahd_pci_suspend(struct ahd_softc *ahd) { /* @@ -394,7 +393,7 @@ ahd_pci_suspend(struct ahd_softc *ahd) } -void +void __maybe_unused ahd_pci_resume(struct ahd_softc *ahd) { ahd_pci_write_config(ahd->dev_softc, DEVCONFIG, @@ -404,7 +403,6 @@ ahd_pci_resume(struct ahd_softc *ahd) ahd_pci_write_config(ahd->dev_softc, CSIZE_LATTIME, ahd->suspend_state.pci_state.csize_lattime, /*bytes*/1); } -#endif /* * Perform some simple tests that should catch situations where From patchwork Mon Nov 2 16:47:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874529 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4734E92C for ; Mon, 2 Nov 2020 16:52:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 292FF22275 for ; Mon, 2 Nov 2020 16:52:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IbZ0O0T8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbgKBQwF (ORCPT ); Mon, 2 Nov 2020 11:52:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgKBQwE (ORCPT ); Mon, 2 Nov 2020 11:52:04 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 471A8C0617A6; Mon, 2 Nov 2020 08:52:04 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id h6so11288247pgk.4; Mon, 02 Nov 2020 08:52:04 -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=2BX3eBQ2Nj+GCCBpMWn5GHt7XwDnkItryaVyf4Y9S0I=; b=IbZ0O0T8ZLpruZWx8PvK7pIXyCIC+2LArAr7gf2hEf6irIdajXFoOuZJTcnie4tIyf G1oLhRlByJxT057wMLQPeiSB92kNy/zw0tEC2IfA6CbIdp6SUrV4wqfX8P6+8Cpf+M8a GFrY3lYf01PJbkFZzZ+BzK7IJTAFCKFn2pLszTcpRuUxeUTgD8ZPZIPNZdiqT16U0CNs CRvJFySq8CxeR1BOep9PQjpP6lR3EDeAdABou7VZBITnUMR3mov86UKVWsuKRT+g7sB9 zXfDZNKgTsb6qXDtavgABdOmqU8ZEYoYP13Iq49TK5NIzr090H/NHAFkHUtljj6QeawQ yz4g== 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=2BX3eBQ2Nj+GCCBpMWn5GHt7XwDnkItryaVyf4Y9S0I=; b=augjeg4vwXr6owyf3qgiRQ6E/lQ/eRFrpXiG4ET1weSEuOB9Rs4MV7jDwpvbKxdPeH YApT6z4avuRh6XAUki6s58aZmp8KTHHMjdRuc07psyH+o5KuDt/Mv01jIm7/vTcNim0E YSyzEF52WiHWrfWYg1DiBW6gQrdrxjyhjnZQPIaZO+KqLR8Z5LWMwwkLQIZ9Veucojn9 Wz4N4yNZVIl/6jgZt0fWlMM3cbyS/qF+gMlKOQL6a5lAk5ehtUsP/qRDaw8B9N83J4yI F1Xs+CRCVEoLe2Owxc6gOO2FSP+nLchmX+i6T6/+KM6d+RDFQiSCaYUiuStrRILLhXw/ kWGQ== X-Gm-Message-State: AOAM532tRFi40NV2GSJkasyI2Yz1UW4weKreWWU/GLLcBo34DQx+TaOr zSxyEYXa2RbUFUZBXIbaR1U= X-Google-Smtp-Source: ABdhPJxxJSxyNACwkohZCylYPgk39LsF1tv3WZke7YS3us4tYJaRefkbEB8qZs0YOFgVDEY57hwVew== X-Received: by 2002:a17:90b:11cc:: with SMTP id gv12mr4371225pjb.132.1604335923821; Mon, 02 Nov 2020 08:52:03 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52:03 -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 08/29] scsi: arcmsr: Drop PCI wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:09 +0530 Message-Id: <20201102164730.324035-9-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in arcmsr_resume(), and there is no corresponding pci_enable_wake(...., true) in arcmsr_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from arcmsr_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/arcmsr/arcmsr_hba.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index e4fdb473b990..c7ba4cbd197b 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1154,7 +1154,6 @@ static int arcmsr_resume(struct pci_dev *pdev) (struct AdapterControlBlock *)host->hostdata; pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); if (pci_enable_device(pdev)) { pr_warn("%s: pci_enable_device error\n", __func__); From patchwork Mon Nov 2 16:47:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 506DE92C for ; Mon, 2 Nov 2020 16:52:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31B4422258 for ; Mon, 2 Nov 2020 16:52:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IdnDTo/Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727384AbgKBQwQ (ORCPT ); Mon, 2 Nov 2020 11:52:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727209AbgKBQwQ (ORCPT ); Mon, 2 Nov 2020 11:52:16 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47265C0617A6; Mon, 2 Nov 2020 08:52:16 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id 13so11607330pfy.4; Mon, 02 Nov 2020 08:52:16 -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=ZfFrvqo7DqkFljFYrfz490r27HiLjLHSzp/wVexiQxI=; b=IdnDTo/Z15gQQJenXHbz48rYyZ/viY+gIX4WeuWdw9YrvB5qHMPlW9Isvh8v/xjYQI 0kWZQNPsIkfFdOAjHYKP+c03Rh33P4ZJMStTRU1josXmDvOOc1vNyzmuUFxBPB3Qdrc5 ljpB3kLsnIHr0K044vjKgn0TpYJNwEvJt1tPcQgSCiUkMgdXAfiOH5cF9qXnOEKUWD0P hGkzzS9vDdqsfIS15adkZY7sb3CkU/GjCpwUppvlmyAxLmQk0jhk08kZzv2Qr9evE1jI TysSsLBvylG7r7fpMdwCYyLH6l4ofk8UcOAi2WaYRI4+4shSaRYRXhoZ0ONrcbsaK5OE I9sQ== 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=ZfFrvqo7DqkFljFYrfz490r27HiLjLHSzp/wVexiQxI=; b=EnpL0T4Wuv54VK67AsdQdr/VWyY/hdBvaLOgovv2hAr9TgAXJsQY5Z1hiMFmzOyCs0 5LsKd2qsqKtTKQf0UFgKwdI8bde8v4exAHaJ+Y3dVLBg/YJmCmM13omguTDeJJkRyxxe Ep3EJnDJxGuav5hWFQ3Esd4YxwSGOoaW5B3LmCFHTy1w/MX/Q2aMHDqoS51vJGc/+ycP oBU75ZqBxQfrb9VCmc0MUJK/kI8cACK3CI6A8O8C14cDvjLvVr3Gj85GDkBvAbTkc2dY P5zCsWpND9zqI4rP4wRoSXrzBWSsqfEgrD1xLOpn12gViA5OO/FtkCgJJ4t9wwLD8yxb fB5w== X-Gm-Message-State: AOAM530o4Rs5WE/8Tdfi97P2kDZXz3GDm2uDcz/bpufOoeUhXr7NjnCX rP7rGNPuxZ83tAZ892+NkzE= X-Google-Smtp-Source: ABdhPJzoB/aS3l59wiqAH8Fub2lfPofKLh5dv3O7rn/FPpOZWCaLVIp6hFC00Sx3oLNCUw1fY3Zkqw== X-Received: by 2002:a17:90a:8b93:: with SMTP id z19mr11878765pjn.123.1604335935795; Mon, 02 Nov 2020 08:52:15 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52:15 -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 09/29] scsi: arcmsr: use generic power management Date: Mon, 2 Nov 2020 22:17:10 +0530 Message-Id: <20201102164730.324035-10-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/arcmsr/arcmsr_hba.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index c7ba4cbd197b..907f5af3bbd4 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -113,8 +113,8 @@ static int arcmsr_bios_param(struct scsi_device *sdev, static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd); static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id); -static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state); -static int arcmsr_resume(struct pci_dev *pdev); +static int __maybe_unused arcmsr_suspend(struct device *dev); +static int __maybe_unused arcmsr_resume(struct device *dev); static void arcmsr_remove(struct pci_dev *pdev); static void arcmsr_shutdown(struct pci_dev *pdev); static void arcmsr_iop_init(struct AdapterControlBlock *acb); @@ -216,13 +216,14 @@ static struct pci_device_id arcmsr_device_id_table[] = { }; MODULE_DEVICE_TABLE(pci, arcmsr_device_id_table); +static SIMPLE_DEV_PM_OPS(arcmsr_pm_ops, arcmsr_suspend, arcmsr_resume); + static struct pci_driver arcmsr_pci_driver = { .name = "arcmsr", .id_table = arcmsr_device_id_table, .probe = arcmsr_probe, .remove = arcmsr_remove, - .suspend = arcmsr_suspend, - .resume = arcmsr_resume, + .driver.pm = &arcmsr_pm_ops, .shutdown = arcmsr_shutdown, }; /* @@ -1126,8 +1127,9 @@ static void arcmsr_free_irq(struct pci_dev *pdev, pci_free_irq_vectors(pdev); } -static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused arcmsr_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; @@ -1140,28 +1142,18 @@ static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state) flush_work(&acb->arcmsr_do_message_isr_bh); arcmsr_stop_adapter_bgrb(acb); arcmsr_flush_adapter_cache(acb); - pci_set_drvdata(pdev, host); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -static int arcmsr_resume(struct pci_dev *pdev) +static int __maybe_unused arcmsr_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - if (pci_enable_device(pdev)) { - pr_warn("%s: pci_enable_device error\n", __func__); - return -ENODEV; - } if (arcmsr_set_dma_mask(acb)) goto controller_unregister; - pci_set_master(pdev); if (arcmsr_request_irq(pdev, acb) == FAILED) goto controller_stop; switch (acb->adapter_type) { @@ -1206,9 +1198,7 @@ static int arcmsr_resume(struct pci_dev *pdev) if (acb->adapter_type == ACB_ADAPTER_TYPE_F) arcmsr_free_io_queue(acb); arcmsr_unmap_pciregion(acb); - pci_release_regions(pdev); scsi_host_put(host); - pci_disable_device(pdev); return -ENODEV; } From patchwork Mon Nov 2 16:47:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874533 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9161292C for ; Mon, 2 Nov 2020 16:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7587E22258 for ; Mon, 2 Nov 2020 16:52:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EInGRm6c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727392AbgKBQw0 (ORCPT ); Mon, 2 Nov 2020 11:52:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbgKBQw0 (ORCPT ); Mon, 2 Nov 2020 11:52:26 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54572C0617A6; Mon, 2 Nov 2020 08:52:26 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id j5so7098449plk.7; Mon, 02 Nov 2020 08:52:26 -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=80Yi1XLQzKPeoqRYuchuEzVl/P6+59b0kyvSplkNuqw=; b=EInGRm6cBk43ZkBUefE+Lxc1nMZ8wuWhwjNtsLaYAjJkkpXaroUIq/Ir/9rRIReZTa TX9Syn6BVfq83IPRQ7ykGpcDSU2omjDUI3aFWdcpcTOE4zk4dSfSsjJxRXA/HxRfwRnq ItPVjw8aiAUDrYudk7Kq3o9fsSpGJ085X8SNop1TA56COWuz2G5PaKpEdELT/3brT2Re Z3KSEtx+XzcTXvGNXhcZFGfzpg1EJVAyhG85b4saGFxQuf05Tf97gMtSJAW5Cf0q6pit ImNpcFHlfvOWYNqWyTpk9PqZ2elCuC7uo5nkhF6uYvOiCQO/H1luHZ5Su0VVC1HGsZPR VbTQ== 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=80Yi1XLQzKPeoqRYuchuEzVl/P6+59b0kyvSplkNuqw=; b=KFjTtzvKL3ixdicJKOip7CvYadhzT7PDfJ/f1hEkc6Eqxjk4/U7ka66QJvF1hsrJOS bPFyy2+0nAONKUAmAOrgGNzhCZXPEbtXTuiQcI6q7Kdc0wU1bTrUXL43yZo94pBJIfQ2 arcO1Y7/eN0TyAmL3DKbU7Twlvf8STLmTz3+zSjFEF04uV8qQLH/76yPOQPtWhFIgGXm 8enbjNvLfXwUBMYV9+0a/27G5xs6MSiIRx1OQOOpEIL/ViAd5lQ2vNDHhYLcgMrbYrA/ 698UbugsxuMWh3L+cmDZlfj0GtDQXyPnjCCmbrJzkyFiN8ARafoVBvE5F0qNaLHs0PSo koMg== X-Gm-Message-State: AOAM533UrePATMO4paMLeFP4dj1vrlrFCbP3Q3dm1Wq6bn6onF9hytjg T2mNkv19ZJ5Mk/PD93la8ow= X-Google-Smtp-Source: ABdhPJwWscqt8CM6V8MAKcDq8ZXDB9lxb+Wc/XDRC0YTbVpR2R6o45JcQIqTodOCmknuT+Pb9bX4UA== X-Received: by 2002:a17:902:bb81:b029:d5:b437:edb4 with SMTP id m1-20020a170902bb81b02900d5b437edb4mr21171215pls.6.1604335945887; Mon, 02 Nov 2020 08:52:25 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52:25 -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 10/29] scsi: esas2r: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:11 +0530 Message-Id: <20201102164730.324035-11-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in esas2r_resume(), and there is no corresponding pci_enable_wake(...., true) in esas2r_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from esas2r_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/esas2r/esas2r_init.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index 09c5c24bf391..905a6c874789 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c @@ -676,10 +676,6 @@ int esas2r_resume(struct pci_dev *pdev) "pci_set_power_state(PCI_D0) " "called"); pci_set_power_state(pdev, PCI_D0); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_enable_wake(PCI_D0, 0) " - "called"); - pci_enable_wake(pdev, PCI_D0, 0); esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "pci_restore_state() called"); pci_restore_state(pdev); From patchwork Mon Nov 2 16:47:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 805FB6A2 for ; Mon, 2 Nov 2020 16:52:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 592E322258 for ; Mon, 2 Nov 2020 16:52:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qeGq4sy0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbgKBQwg (ORCPT ); Mon, 2 Nov 2020 11:52:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbgKBQwg (ORCPT ); Mon, 2 Nov 2020 11:52:36 -0500 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 E5F74C0617A6; Mon, 2 Nov 2020 08:52:35 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id i26so11278254pgl.5; Mon, 02 Nov 2020 08:52: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=WUBvgbl6iGKCFFzOFeem+Ak5qZZi8vOAFv31Ry1s8Ag=; b=qeGq4sy0Twb2LAXIoCUbswcwn5ARIZjtbvsgY+oMv6tpsKJBflcN0heggKOvGtAqlF 5lWH8QI0yCIRswe3y9aFtE4ifNs/DVlApOrcyVqC+BWmQvc3TF2UsKcW2AvIOOf2Q5Xp eYffTtiEej9hzNYv+Ao6e5/9+dOMgx3vPfbwOh+YLptr1r/Zc88Yhm68bvLv4bNzolZ7 2pISvCLddMw9n0rFCiEzmY5pEMguW+KZ2mqsL0Poev7+GgE8Av4S/6rbZKZGxl4O5S0S CUlraZ6y34Q6SjK0QqTBWFJ18eEmU2626VUSvimPY1VA8lXybPhbRpHTHa7JCe8zQNHm 3Avw== 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=WUBvgbl6iGKCFFzOFeem+Ak5qZZi8vOAFv31Ry1s8Ag=; b=ianSS/mVTn5iZYF4mzv7P5UeURgWAyYQ22eQviFob9nxWSKvPUVVuZU3TNHe/Ymdm1 wL4rhgXIt9a6sJ3ir12I5sSG1Ovcdod4WgY8r0OSWbg9bMJNlzvuQCTvJzwgn1zdSLxa vbyBLLQ9ibyY3FF1p9wNMcvUWS1hCelLvxoHVABCfb1eFUTTaZku5N9Q2ythhoCfanuk Ct3hweVFQI8Cds4QOd4UUefKk0u35KpjZm9p3SwJIiEy3USzdpRt8yYqbDByqnxtWn6I KofVad6UZwyBoVRTATYswCe56daRFUivcnblyNwD0Njp2yVrY+EV+4lTyTJYN3Idv0g1 1lNA== X-Gm-Message-State: AOAM532yVmbLXmj/CWoGAXzprvzCrtFahXBTxgWOXPl4/mVKRWxXGV7t IbCLeK1SA+OPSpdKc2Abay0= X-Google-Smtp-Source: ABdhPJxVRX3en5oytRjcT9dRbMawLDnUSZPxIfG/YiS9M7Ityd8FlnM25FraJFjXR8i/6UM+kEw3Sw== X-Received: by 2002:a05:6a00:2cf:b029:160:c0c:a95c with SMTP id b15-20020a056a0002cfb02901600c0ca95cmr21990295pft.76.1604335955469; Mon, 02 Nov 2020 08:52:35 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52: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 11/29] scsi: esas2r: use generic power management Date: Mon, 2 Nov 2020 22:17:12 +0530 Message-Id: <20201102164730.324035-12-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/esas2r/esas2r.h | 5 ++-- drivers/scsi/esas2r/esas2r_init.c | 44 +++++++++---------------------- drivers/scsi/esas2r/esas2r_main.c | 3 +-- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index e30d2f1f5368..ed63f7a9ea54 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -996,8 +996,9 @@ void esas2r_adapter_tasklet(unsigned long context); irqreturn_t esas2r_interrupt(int irq, void *dev_id); irqreturn_t esas2r_msi_interrupt(int irq, void *dev_id); void esas2r_kickoff_timer(struct esas2r_adapter *a); -int esas2r_suspend(struct pci_dev *pcid, pm_message_t state); -int esas2r_resume(struct pci_dev *pcid); + +extern const struct dev_pm_ops esas2r_pm_ops; + void esas2r_fw_event_off(struct esas2r_adapter *a); void esas2r_fw_event_on(struct esas2r_adapter *a); bool esas2r_nvram_write(struct esas2r_adapter *a, struct esas2r_request *rq, diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index 905a6c874789..eb7763af7089 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c @@ -640,49 +640,27 @@ void esas2r_kill_adapter(int i) } } -int esas2r_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused esas2r_suspend(struct device *dev) { - struct Scsi_Host *host = pci_get_drvdata(pdev); - u32 device_state; + struct Scsi_Host *host = dev_get_drvdata(dev); struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "suspending adapter()"); + esas2r_log_dev(ESAS2R_LOG_INFO, dev, "suspending adapter()"); if (!a) return -ENODEV; esas2r_adapter_power_down(a, 1); - device_state = pci_choose_state(pdev, state); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_save_state() called"); - pci_save_state(pdev); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_disable_device() called"); - pci_disable_device(pdev); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_set_power_state() called"); - pci_set_power_state(pdev, device_state); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "esas2r_suspend(): 0"); + esas2r_log_dev(ESAS2R_LOG_INFO, dev, "esas2r_suspend(): 0"); return 0; } -int esas2r_resume(struct pci_dev *pdev) +static int __maybe_unused esas2r_resume(struct device *dev) { - struct Scsi_Host *host = pci_get_drvdata(pdev); + struct Scsi_Host *host = dev_get_drvdata(dev); struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; - int rez; - - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "resuming adapter()"); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_set_power_state(PCI_D0) " - "called"); - pci_set_power_state(pdev, PCI_D0); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_restore_state() called"); - pci_restore_state(pdev); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_enable_device() called"); - rez = pci_enable_device(pdev); - pci_set_master(pdev); + int rez = 0; + + esas2r_log_dev(ESAS2R_LOG_INFO, dev, "resuming adapter()"); if (!a) { rez = -ENODEV; @@ -726,11 +704,13 @@ int esas2r_resume(struct pci_dev *pdev) } error_exit: - esas2r_log_dev(ESAS2R_LOG_CRIT, &(pdev->dev), "esas2r_resume(): %d", + esas2r_log_dev(ESAS2R_LOG_CRIT, dev, "esas2r_resume(): %d", rez); return rez; } +SIMPLE_DEV_PM_OPS(esas2r_pm_ops, esas2r_suspend, esas2r_resume); + bool esas2r_set_degraded_mode(struct esas2r_adapter *a, char *error_str) { set_bit(AF_DEGRADED_MODE, &a->flags); diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 7b49e2e9fcde..aab3ea580e6b 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -346,8 +346,7 @@ static struct pci_driver .id_table = esas2r_pci_table, .probe = esas2r_probe, .remove = esas2r_remove, - .suspend = esas2r_suspend, - .resume = esas2r_resume, + .driver.pm = &esas2r_pm_ops, }; static int esas2r_probe(struct pci_dev *pcid, From patchwork Mon Nov 2 16:47:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874535 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5385B6A2 for ; Mon, 2 Nov 2020 16:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36F5E223FB for ; Mon, 2 Nov 2020 16:52:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BFOSE7/j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727486AbgKBQwu (ORCPT ); Mon, 2 Nov 2020 11:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727484AbgKBQwq (ORCPT ); Mon, 2 Nov 2020 11:52:46 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E1BC0617A6; Mon, 2 Nov 2020 08:52:46 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id k9so9590462pgt.9; Mon, 02 Nov 2020 08:52:46 -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=XPMjeP+Aj8Y7qYlQVBIVXdIdvsMXyUBB2qOriiIG5lA=; b=BFOSE7/jZj6D/hNGPW6Z+IYEY9S+IxabURlympaa+oRyRRbAXjsP9s3RqWZx4J9hsI BGEE9Eq70JfosYWPtLomF9SBSuA2HBDZ02GUj+CVWcFUEBT+XVI7n7zaCr7wbCwgw6ka 3+H7Z9qVtNwMndJMN2vWnlSyc5hAqGyIR5QQN8X+2yhvSRPnaI69RmUxBdbubFTuCUIX piy3chi0KamIbGXKBG2UJ2Es5dnVCmLTvftYmI0OmGoR0vMZdTO+zQFhPSeSyRYxhBDJ KlfHKfLgq+0S1P+m6dMT7tAXfXoDIUsQHSzhmIinIKqJS2Ln4WWV+wyx2ui1xnLN3d52 V74g== 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=XPMjeP+Aj8Y7qYlQVBIVXdIdvsMXyUBB2qOriiIG5lA=; b=aSrurqFQWiQ+kB2Dx66kipoTUG+G3EXQyW4/wxKVi9utlut22q/gg54gI9mKR1eN7J Y8J57qqNmrX8iU79FYrUJIKHE3Sk/X1X7mqcR37rt1ry+AgmKFym2fS2BF8sFbSex84o MzZ22R/HykFQgo7FQ1WY9NzpoL3eat1rW6Y0GJDKCfJj1mES/jeH0ufO8Zw85760SjBf dT5mGMfZ+KR08qWJWNP41fxHkdkwQZDhpcnknnzGg0YcgWTJX7Hip49jv2zq0nJ7XGtF iD+L86Acvn8KCv+VKSGxbAIIAP3oj5W0QSy+WUFN1Ld61mIHeEbbDX9Dza3NgpApcHUW 8yWA== X-Gm-Message-State: AOAM532FctXEUjsNslvOvuiSZlY/+v/mVxMYras0OXfEbY9r3WnUuDYP wDVCocXf+86wCMAlKIlPG5E= X-Google-Smtp-Source: ABdhPJyCrllqbyiFve3kKXuwDFU8Zp7rtUgBCNHNxZtJ2bhsDm1uCIq1J9Y4X4Ue1/8Cl51gz1/Uiw== X-Received: by 2002:a17:90a:468f:: with SMTP id z15mr17777167pjf.200.1604335966065; Mon, 02 Nov 2020 08:52:46 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52:45 -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 12/29] scsi: hisi_sas_v3_hw: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:13 +0530 Message-Id: <20201102164730.324035-13-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in hisi_sas_v3_resume(), and there is no corresponding pci_enable_wake(...., true) in hisi_sas_v3_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from hisi_sas_v3_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 7133ca859b5e..f19f3db1ac6d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3492,7 +3492,6 @@ static int _resume_v3_hw(struct device *device) dev_warn(dev, "resuming from operating state [D%d]\n", device_state); pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); rc = pci_enable_device(pdev); if (rc) { From patchwork Mon Nov 2 16:47:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEF176A2 for ; Mon, 2 Nov 2020 16:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2A15222B9 for ; Mon, 2 Nov 2020 16:53:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i4lK7B2j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727384AbgKBQxA (ORCPT ); Mon, 2 Nov 2020 11:53:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727196AbgKBQw7 (ORCPT ); Mon, 2 Nov 2020 11:52:59 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A0F0C0617A6; Mon, 2 Nov 2020 08:52:58 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id y14so11587475pfp.13; Mon, 02 Nov 2020 08:52:58 -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=MBzsuEUa6bYvsV+CNnIl+xHeK3YoENUVJTW96RlBScM=; b=i4lK7B2jCeWUWs/7k7aRJe2mVzCOREf/YaZphfdcnGM0u+NoaCHXT1UMtxiid1cPRk z+BPB3zIpcTUGy7gNJ+vQ+mf6T/j71u4xbBtkOpJFr0pkC7C9qKw3p0Q/5/01HSApBta Ou3O6JCnnfnkLTA7bAPGiA4KrhBxm/8fKADenbdF1J4iCL0+VyOS918WGeSy6jnLmizw gqP9jIo7nYYWjov+spMoRffy2As9Y9GUzTL5aQWpXYLgfZia0BjMUJBE8J1Or8gBFVVo F016wRV7uUCivQ4adKG5hAUXH+lhQwfZSg1Wfk102HFPrtIRVcxXRArRP+VFGN2ZB9nO alSg== 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=MBzsuEUa6bYvsV+CNnIl+xHeK3YoENUVJTW96RlBScM=; b=bipUM18rmPTrQX97TuRcxqTJVVlM3ldiB9OtaHS2o66vKrGS9Gm0qNr7LH0etVY5K5 SPjAhwU8y4YAEKTrGIc96hhlD4hA/+/zzhnJYQimMAJZc3vl8cY0+nnzgp2f1rAV8Amn QqfXMscTePQB0l7f23qk7HcFiwaj9sxiOwpXKnO0LAQEu1mLQcHLKrUq25kaXFGsh6R/ DnZU3z4GJz+9TxmUPmb7r4v2n31q411FWXaFzXTWCQevktnf9uetU1nKAzY6hs++aiIX y786XCihAkW7t97meEikuYhSoGoP2sFVJO7z2VTToyLphNzEUMXV3cmRgNR3uLgLUAyk bzHQ== X-Gm-Message-State: AOAM532uqq4HWH+zqVXLAPOQvw1n6kCiZDVgeUsiIjyLvSG3hJeo0AMj quQgZnHzDdUocDL4wgVexnk= X-Google-Smtp-Source: ABdhPJxiIXDXayIA4x2vypTJ5B2naXIVlq1IYCXlgXG2jWp3RJ2Zwiiq5D86qMZ/Pko1ZcPv4K6N1w== X-Received: by 2002:a17:90a:3e4a:: with SMTP id t10mr18207881pjm.151.1604335977846; Mon, 02 Nov 2020 08:52:57 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52:57 -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 13/29] scsi: hisi_sas_v3_hw: Don't use PCI helper functions Date: Mon, 2 Nov 2020 22:17:14 +0530 Message-Id: <20201102164730.324035-14-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Drivers using new-framework/generic-framework should not handle standard power management operations. These operations were performed by legacy framework through PCI helper functions like pci_save/restore_state(), pci_set_power_state(), etc. Drivers should not use them now. Signed-off-by: Vaibhav Gupta --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index f19f3db1ac6d..dfeb86c865d3 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3440,7 +3440,6 @@ static int _suspend_v3_hw(struct device *device) struct hisi_hba *hisi_hba = sha->lldd_ha; struct device *dev = hisi_hba->dev; struct Scsi_Host *shost = hisi_hba->shost; - pci_power_t device_state; int rc; if (!pdev->pm_cap) { @@ -3466,12 +3465,7 @@ static int _suspend_v3_hw(struct device *device) hisi_sas_init_mem(hisi_hba); - device_state = pci_choose_state(pdev, PMSG_SUSPEND); - dev_warn(dev, "entering operating state [D%d]\n", - device_state); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, device_state); + dev_warn(dev, "entering suspend state\n"); hisi_sas_release_tasks(hisi_hba); @@ -3491,15 +3485,7 @@ static int _resume_v3_hw(struct device *device) dev_warn(dev, "resuming from operating state [D%d]\n", device_state); - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - rc = pci_enable_device(pdev); - if (rc) { - dev_err(dev, "enable device failed during resume (%d)\n", rc); - return rc; - } - pci_set_master(pdev); scsi_unblock_requests(shost); clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); @@ -3507,7 +3493,6 @@ static int _resume_v3_hw(struct device *device) rc = hw_init_v3_hw(hisi_hba); if (rc) { scsi_remove_host(shost); - pci_disable_device(pdev); return rc; } hisi_hba->hw->phys_init(hisi_hba); From patchwork Mon Nov 2 16:47:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874541 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D6936A2 for ; Mon, 2 Nov 2020 16:53:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E562222EC for ; Mon, 2 Nov 2020 16:53:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="To8S2jHL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727218AbgKBQxJ (ORCPT ); Mon, 2 Nov 2020 11:53:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727201AbgKBQxI (ORCPT ); Mon, 2 Nov 2020 11:53:08 -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 61531C0617A6; Mon, 2 Nov 2020 08:53:08 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id c20so11601537pfr.8; Mon, 02 Nov 2020 08:53:08 -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=6EF8lQwOXO2Z8DiQbYXGCQ2159bXf7Ji78BoyHo/jeA=; b=To8S2jHLUsT+F/DtIpwDe+1nsQoZHhatxgqGT8Sxc9KuSJcRM3S8ryS3lDtBN5YMeC eShZMSTpM3aCVSG4nLzekO+XOUtDj7y1FgYmyOoflsoop1hjOytHUrxV2RaxdVt1uR2K MsYuRH9Cm4h6i8pQu10lgzPWUt+Es7x0imUyp5peUkZWoz88nNq3tKjWLVQXyeoy5Ul/ z5pEcBNh47ZPnd7Kj8KAiwpTLOhaDKBFsZhXe+elVgnjgD1CuacyLxDuhKvU82nUQZGn tVYMZUv2X+pju79d8atKoU76RgvzTZQ64FLTcnhEqHIhg+OcbKdWCbaUTKMj13OhJ0Ia oasA== 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=6EF8lQwOXO2Z8DiQbYXGCQ2159bXf7Ji78BoyHo/jeA=; b=d37kHKDzFpSjOQ915Qhlftyi96Q79AhiEdFGO0Pdss1OH3yeAJUjhwfnHrfQsOz7Qt vPWxNKQOt7fPi6a28yvMonDG51O9eIdVKmXq/lwmTHhdQdwb7+zJa3opTo0Jp9IxyfWj ysPrKMmDY47xt2Cjwbt7Spus3aQEXRBwNEl86BKLm0tgaZOZJ273oiatbXPuc4v7ooUH wfNOJxgq89YUdZxstLvGvIV7xamZnf7OhvcXe23KI8C7TyZiV5XZB03CZU4akR9t6hDn d09jfsDEU3PWmJRCW/EGzeJAYVeRpVnw7JxJ473YyNIfzSUxU4d85XTjaIbBwdvxGyzo 3u6g== X-Gm-Message-State: AOAM5301Ed8Xr0TZHYFimmSHh/2KmMqrWIMjfUUid6oKqV8+0fKA4c5l PrNCnhq9/jx4ni4nbUT+sck= X-Google-Smtp-Source: ABdhPJw+WZ503yKFquawRt0K3fv1VZ0392lfMRA03Pm+y/b3nAXy5mhWcTDXFlgVjXkApI1klFFsZw== X-Received: by 2002:a65:6819:: with SMTP id l25mr14077553pgt.111.1604335987979; Mon, 02 Nov 2020 08:53:07 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:53:07 -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 14/29] scsi: hisi_sas_v3_hw: Remove extra function calls for runtime pm Date: Mon, 2 Nov 2020 22:17:15 +0530 Message-Id: <20201102164730.324035-15-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Both runtime_suspend_v3_hw() and runtime_resume_v3_hw() do nothing else but invoke suspend_v3_hw() and resume_v3_hw() respectively. This is the case of unnecessary function calls. To use those functions for runtime pm as well, simply use UNIVERSAL_DEV_PM_OPS. make -j$(nproc) W=1, with CONFIG_PM disabled, throws '-Wunused-function' warning for runtime_suspend_v3_hw() and runtime_resume_v3_hw(). After dropping those function definitions, the warning was thrown for suspend_v3_hw() and resume_v3_hw(). Hence, mark them as '__maybe_unused'. Signed-off-by: Vaibhav Gupta --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index dfeb86c865d3..9f0b4fe564cc 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3502,7 +3502,7 @@ static int _resume_v3_hw(struct device *device) return 0; } -static int suspend_v3_hw(struct device *device) +static int __maybe_unused suspend_v3_hw(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); struct sas_ha_struct *sha = pci_get_drvdata(pdev); @@ -3518,7 +3518,7 @@ static int suspend_v3_hw(struct device *device) return rc; } -static int resume_v3_hw(struct device *device) +static int __maybe_unused resume_v3_hw(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); struct sas_ha_struct *sha = pci_get_drvdata(pdev); @@ -3541,21 +3541,10 @@ static const struct pci_error_handlers hisi_sas_err_handler = { .reset_done = hisi_sas_reset_done_v3_hw, }; -static int runtime_suspend_v3_hw(struct device *dev) -{ - return suspend_v3_hw(dev); -} - -static int runtime_resume_v3_hw(struct device *dev) -{ - return resume_v3_hw(dev); -} - -static const struct dev_pm_ops hisi_sas_v3_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(suspend_v3_hw, resume_v3_hw) - SET_RUNTIME_PM_OPS(runtime_suspend_v3_hw, - runtime_resume_v3_hw, NULL) -}; +static UNIVERSAL_DEV_PM_OPS(hisi_sas_v3_pm_ops, + suspend_v3_hw, + resume_v3_hw, + NULL); static struct pci_driver sas_v3_pci_driver = { .name = DRV_NAME, From patchwork Mon Nov 2 16:47:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C06FF6A2 for ; Mon, 2 Nov 2020 16:53:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A488A222BA for ; Mon, 2 Nov 2020 16:53:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kl55ZSfn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727277AbgKBQxU (ORCPT ); Mon, 2 Nov 2020 11:53:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbgKBQxU (ORCPT ); Mon, 2 Nov 2020 11:53:20 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDB30C0617A6; Mon, 2 Nov 2020 08:53:19 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id x13so11597992pfa.9; Mon, 02 Nov 2020 08:53:19 -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=SOLD0sLwTuY4TfChHkgrK5w3Qn4ds7uACuE/j2qv8aY=; b=Kl55ZSfnA/Mn6mRPbWGTEkVUeJVome2iCB4Xfr9T7sFbx+NyK9JIXu+IgS5Nd9JzVu VIIWniztcf0DJVP/1CQMsGvr4EqGMnwwNEGK/M2b7Gl0TfcJcryeDVWLN/iYumoIrO43 ADHSpvqZXrzcigImQPZNzVq6jtJj/CAOky00a8lUaOYngj4zbATM9922FCGv563HpKp2 420zs+mB01xfIaGLNNvJXAoLvO000Crd4uVftw97qkXpTpnQTlw6XJH+L3qEp1Vzeduy e1Y0xnM94DQx2YHOQ0SugTcrZcuPHU0jJ/3B6iTbhTxv0Q4cGUnh5ZUD77kF7eTV6KKt V0yw== 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=SOLD0sLwTuY4TfChHkgrK5w3Qn4ds7uACuE/j2qv8aY=; b=b09xyGseVAenFqiXgspXQ+KB0SO/IvfN6CR2QVBjrGyeoJhUS3HD1pPeHXf5mT7vbY 4tKyUzj0+tg5yMfkDFg9JFk3x/GKf2lwKcaMY3k+cacHq1oHgyqj+l84UvzdAJaeHiuT 3MKRuud0w1sZkcDbdFSuiddq/AsVq9Ci2qrAKe80kwq9HgeNokopQvsgTg9hhpiSJ3+n Iftidd6DMTD5Pc/kImElE1W/gF68vwjriCKinciecRZnMbdgpzexPe9BEeKaKbdboquF YAOlSK/S0PLTeY7J573orZPsCz3ZCItcaGgUeknOrxsRsPqzR+7AXy7a2nWKg/UQaQ/+ 9PRA== X-Gm-Message-State: AOAM5333f5sUQ3gWj37TvgZZdMxZSZhOei+nNaA+osuXXaDMkeXAYrD/ IqTXvUAcRw/sEzYf6gkt3zg= X-Google-Smtp-Source: ABdhPJy9xYff9LIPIsDObGt8ERWBvTi6YfmYoCnJqKilM2cZDKSwDGQcnLftGSiW4932taWJnp+wKQ== X-Received: by 2002:a65:5c4c:: with SMTP id v12mr14283773pgr.119.1604335999411; Mon, 02 Nov 2020 08:53:19 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:53:18 -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 15/29] scsi: mpt3sas_scsih: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:16 +0530 Message-Id: <20201102164730.324035-16-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in scsih_resume(), and there is no corresponding pci_enable_wake(...., true) in scsih_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from scsih_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 5f845d7094fc..2d201558b8fb 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -11140,7 +11140,6 @@ scsih_resume(struct pci_dev *pdev) pdev, pci_name(pdev), device_state); pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); ioc->pdev = pdev; r = mpt3sas_base_map_resources(ioc); From patchwork Mon Nov 2 16:47:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D6E392C for ; Mon, 2 Nov 2020 16:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7032C222B9 for ; Mon, 2 Nov 2020 16:53:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pqGb/ojs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727172AbgKBQxb (ORCPT ); Mon, 2 Nov 2020 11:53:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgKBQxa (ORCPT ); Mon, 2 Nov 2020 11:53:30 -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 8C1F3C0617A6; Mon, 2 Nov 2020 08:53:30 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id 133so11600998pfx.11; Mon, 02 Nov 2020 08:53:30 -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=+FYzDpJVo6o7vUtMY5MEW3bJWYDQoUDOxT/IdoR7Mtw=; b=pqGb/ojsmTzbDiumh4WtNsiJGH606Ide/pZHjT/+BjoFB9KSMAxpV5CQ/t8AKbvQGk XCAnGwApPmGusMpujWANyP8+gZo1ZRlaGApYaRePfDufmZHYy99ou3SXZuLmJXd0dWUt OKvifn+K0l7/WMND09NwcnDQuNoic84nBqnSOGIpaivKWdYB4YOrccXAwTuZUTvHTyWZ GzJ+y2jstwpxTLlbyW/PVd00XF4no1zmuNRnaB7cO9hRqxD1ZkZGWXtQUr1vebklVT5X e1GSX3d+E1PCXauLySvGSrl/ZR5kPQCC6NjKFQ2nJqe2TDljCRvMhydQZKWhjnAodB/s QVKg== 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=+FYzDpJVo6o7vUtMY5MEW3bJWYDQoUDOxT/IdoR7Mtw=; b=QEXUREHD7nfDbfL8EGJCI4x7xdcmwzX7jiCm5PVEkJmWXRUD9UwPjvdJ2uRrrV/jq6 /P6ccw7vTVv7P1HHbbQWSj5AsrU1cnlA8hJ7TWPe3Ipw2aWgr10mqe25JhZHfeWs4Chw jp0NEinw/1EQ7BdhIe5AIQTRDcdT6kaBiBygq7OH6OCnPSvKKElu9exVYRhek/K/JFqc krRTaKJpUqm8N0xeVhDpYGSwXgqD7EVTVBd3+f50nWVg3lmd7bpgbyTFPtPmiQ2v2Qz+ 9bzcRgPGiUqfFjVk7D0Q1MOMOmqXQnZ3UNLh+h/up8w8BRDB8115UxyySiRNs/KxyZ+R EIUw== X-Gm-Message-State: AOAM533Vd2s77Jgz3s51bO3TjTOswKWUZWLWB+emcoWV0YHvAdOOGz2n 6/6S3kRXOAOONhsykUQlW3E= X-Google-Smtp-Source: ABdhPJzZ7HDMBFqkm0MG4EFU8WiBbdUVuQB59efLgHWUNo012dsn+LurOxiWFE0CxiU/fLJiJMq5UA== X-Received: by 2002:aa7:9341:0:b029:18b:b43:6c7 with SMTP id 1-20020aa793410000b029018b0b4306c7mr3186804pfn.7.1604336010095; Mon, 02 Nov 2020 08:53:30 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:53:29 -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 16/29] scsi: mpt3sas_scsih: use generic power management Date: Mon, 2 Nov 2020 22:17:17 +0530 Message-Id: <20201102164730.324035-17-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/mpt3sas/mpt3sas_scsih.c | 34 +++++++++++----------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 2d201558b8fb..bc68544856b9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -11084,20 +11084,18 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) return rv; } -#ifdef CONFIG_PM /** * scsih_suspend - power management suspend main entry point - * @pdev: PCI device struct - * @state: PM state change to (usually PCI_D3) + * @dev: Device struct * * Return: 0 success, anything else error. */ -static int -scsih_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused +scsih_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *shost; struct MPT3SAS_ADAPTER *ioc; - pci_power_t device_state; int rc; rc = _scsih_get_shost_and_ioc(pdev, &shost, &ioc); @@ -11108,25 +11106,23 @@ scsih_suspend(struct pci_dev *pdev, pm_message_t state) flush_scheduled_work(); scsi_block_requests(shost); _scsih_nvme_shutdown(ioc); - device_state = pci_choose_state(pdev, state); - ioc_info(ioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n", - pdev, pci_name(pdev), device_state); + ioc_info(ioc, "pdev=0x%p, slot=%s, entering operating state\n", + pdev, pci_name(pdev)); - pci_save_state(pdev); mpt3sas_base_free_resources(ioc); - pci_set_power_state(pdev, device_state); return 0; } /** * scsih_resume - power management resume main entry point - * @pdev: PCI device struct + * @dev: Device struct * * Return: 0 success, anything else error. */ -static int -scsih_resume(struct pci_dev *pdev) +static int __maybe_unused +scsih_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *shost; struct MPT3SAS_ADAPTER *ioc; pci_power_t device_state = pdev->current_state; @@ -11139,8 +11135,6 @@ scsih_resume(struct pci_dev *pdev) ioc_info(ioc, "pdev=0x%p, slot=%s, previous operating state [D%d]\n", pdev, pci_name(pdev), device_state); - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); ioc->pdev = pdev; r = mpt3sas_base_map_resources(ioc); if (r) @@ -11151,7 +11145,6 @@ scsih_resume(struct pci_dev *pdev) mpt3sas_base_start_watchdog(ioc); return 0; } -#endif /* CONFIG_PM */ /** * scsih_pci_error_detected - Called when a PCI error is detected. @@ -11453,6 +11446,8 @@ static struct pci_error_handlers _mpt3sas_err_handler = { .resume = scsih_pci_resume, }; +static SIMPLE_DEV_PM_OPS(scsih_pm_ops, scsih_suspend, scsih_resume); + static struct pci_driver mpt3sas_driver = { .name = MPT3SAS_DRIVER_NAME, .id_table = mpt3sas_pci_table, @@ -11460,10 +11455,7 @@ static struct pci_driver mpt3sas_driver = { .remove = scsih_remove, .shutdown = scsih_shutdown, .err_handler = &_mpt3sas_err_handler, -#ifdef CONFIG_PM - .suspend = scsih_suspend, - .resume = scsih_resume, -#endif + .driver.pm = &scsih_pm_ops, }; /** From patchwork Mon Nov 2 16:47:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E50AD139F for ; Mon, 2 Nov 2020 16:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C48E4206F9 for ; Mon, 2 Nov 2020 16:53:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k39IdQvP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727279AbgKBQxn (ORCPT ); Mon, 2 Nov 2020 11:53:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgKBQxm (ORCPT ); Mon, 2 Nov 2020 11:53:42 -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 C57D8C0617A6; Mon, 2 Nov 2020 08:53:41 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id z24so11300702pgk.3; Mon, 02 Nov 2020 08:53: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=Cb4ySFnlLhJ+JhmjzTriCdxevKzKPzQ3J+4RmScEJzI=; b=k39IdQvP1VxpzbrTjqwHF03rdVaMGcVa2DaAthYQylkXsudCrqFgaVQbrIkBPu/FNd QgQXKMyda64eqPigNDlcm9mGheOisop4qdbgVCJzw/ubGzQlkcqdWK3Ar8yut9n/KnyQ SAnY1Kh1+u+17/F6wFRuhDjO/O6qf3hPw0T/D/zKjUT0WpkTMqVkzB11aE+sX2AfqC17 YTgY8W09DxEpecirzY99zQk2JIxo+vtDeGk7LqtBvr9sFweFACof13OVigrSUDEJcDz6 7GOJBI8ll20grnDg10A5kSpOhmxPsTrbhoicpFhGMjh3GPD5QiPt5+o6hQln2PxKRop2 5DnA== 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=Cb4ySFnlLhJ+JhmjzTriCdxevKzKPzQ3J+4RmScEJzI=; b=cryl0I5XaQozGAaJoSCP8wKWARe6gyb2x+qGcBJbDle0azaHG7R2YQNyh1cytUxxKj tGbY9gDG36l3qfnCqdt0n89XJl22/wXQTV96SXgxRtLnB3Iovu2/rvt8Zgh0TBmIblN0 6ev0mv6zAFXYD2OQsY/UX8lwOq8AM99/omjcZKbvTNIuq5v+Bzs3n7f7JMOlpJYJTWXi UmNG32sNphUwjxULVhaDzc07h5g5xlKUfqDmGLChqDlvrXBpuZeDbmxCvsn7TBNcuV9p PQN2we6sW87r7M8zVxJIJ727X81yct7Tm6mHpTqUdZWsRi/Erk83VNSWEOv+C92d/3sk H9Ng== X-Gm-Message-State: AOAM533eidQBhR7f7HROlErO7BVgu9fLY9z6/WrzcG0ZNBki9wUCl1Zs N0GLn35WlQrI3JwOP24tbOk= X-Google-Smtp-Source: ABdhPJyDgyx30V3H6BJoMMsQFczZcCAejBuc6H/HGyKQkmU7mR9yTb65KORXvUYyjWd/Sjka5RxOJA== X-Received: by 2002:a63:7c46:: with SMTP id l6mr8264187pgn.301.1604336021260; Mon, 02 Nov 2020 08:53:41 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:53: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 17/29] scsi: lpfc: use generic power management Date: Mon, 2 Nov 2020 22:17:18 +0530 Message-Id: <20201102164730.324035-18-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/lpfc/lpfc_init.c | 100 +++++++++++----------------------- 1 file changed, 33 insertions(+), 67 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index ca25e54bb782..bf12328a5e45 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -12581,8 +12581,7 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev) /** * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt - * @pdev: pointer to PCI device - * @msg: power management message + * @dev_d: pointer to device * * This routine is to be called from the kernel's PCI subsystem to support * system Power Management (PM) to device with SLI-3 interface spec. When @@ -12600,10 +12599,10 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev) * 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg) +static int __maybe_unused +lpfc_pci_suspend_one_s3(struct device *dev_d) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev_d); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; lpfc_printf_log(phba, KERN_INFO, LOG_INIT, @@ -12617,16 +12616,12 @@ lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg) /* Disable interrupt from device */ lpfc_sli_disable_intr(phba); - /* Save device state to PCI config space */ - pci_save_state(pdev); - pci_set_power_state(pdev, PCI_D3hot); - return 0; } /** * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt - * @pdev: pointer to PCI device + * @dev_d: pointer to device * * This routine is to be called from the kernel's PCI subsystem to support * system Power Management (PM) to device with SLI-3 interface spec. When PM @@ -12643,10 +12638,10 @@ lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg) * 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_resume_one_s3(struct pci_dev *pdev) +static int __maybe_unused +lpfc_pci_resume_one_s3(struct device *dev_d) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev_d); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; uint32_t intr_mode; int error; @@ -12654,19 +12649,6 @@ lpfc_pci_resume_one_s3(struct pci_dev *pdev) lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "0452 PCI device Power Management resume.\n"); - /* Restore device state from PCI config space */ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - /* - * As the new kernel behavior of pci_restore_state() API call clears - * device saved_state flag, need to save the restored state again. - */ - pci_save_state(pdev); - - if (pdev->is_busmaster) - pci_set_master(pdev); - /* Startup the kernel thread for this host adapter. */ phba->worker_thread = kthread_run(lpfc_do_work, phba, "lpfc_worker_%d", phba->brd_no); @@ -13423,8 +13405,7 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev) /** * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt - * @pdev: pointer to PCI device - * @msg: power management message + * @dev_d: pointer to device * * This routine is called from the kernel's PCI subsystem to support system * Power Management (PM) to device with SLI-4 interface spec. When PM invokes @@ -13442,10 +13423,10 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev) * 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg) +static int __maybe_unused +lpfc_pci_suspend_one_s4(struct device *dev_d) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev_d); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; lpfc_printf_log(phba, KERN_INFO, LOG_INIT, @@ -13460,16 +13441,12 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg) lpfc_sli4_disable_intr(phba); lpfc_sli4_queue_destroy(phba); - /* Save device state to PCI config space */ - pci_save_state(pdev); - pci_set_power_state(pdev, PCI_D3hot); - return 0; } /** * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt - * @pdev: pointer to PCI device + * @dev_d: pointer to device * * This routine is called from the kernel's PCI subsystem to support system * Power Management (PM) to device with SLI-4 interface spac. When PM invokes @@ -13486,10 +13463,10 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg) * 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_resume_one_s4(struct pci_dev *pdev) +static int __maybe_unused +lpfc_pci_resume_one_s4(struct device *dev_d) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev_d); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; uint32_t intr_mode; int error; @@ -13497,19 +13474,6 @@ lpfc_pci_resume_one_s4(struct pci_dev *pdev) lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "0292 PCI device Power Management resume.\n"); - /* Restore device state from PCI config space */ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - /* - * As the new kernel behavior of pci_restore_state() API call clears - * device saved_state flag, need to save the restored state again. - */ - pci_save_state(pdev); - - if (pdev->is_busmaster) - pci_set_master(pdev); - /* Startup the kernel thread for this host adapter. */ phba->worker_thread = kthread_run(lpfc_do_work, phba, "lpfc_worker_%d", phba->brd_no); @@ -13825,8 +13789,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev) /** * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management - * @pdev: pointer to PCI device - * @msg: power management message + * @dev: pointer to device * * This routine is to be registered to the kernel's PCI subsystem to support * system Power Management (PM). When PM invokes this method, it dispatches @@ -13837,19 +13800,19 @@ lpfc_pci_remove_one(struct pci_dev *pdev) * 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_suspend_one(struct pci_dev *pdev, pm_message_t msg) +static int __maybe_unused +lpfc_pci_suspend_one(struct device *dev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; int rc = -ENODEV; switch (phba->pci_dev_grp) { case LPFC_PCI_DEV_LP: - rc = lpfc_pci_suspend_one_s3(pdev, msg); + rc = lpfc_pci_suspend_one_s3(dev); break; case LPFC_PCI_DEV_OC: - rc = lpfc_pci_suspend_one_s4(pdev, msg); + rc = lpfc_pci_suspend_one_s4(dev); break; default: lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, @@ -13862,7 +13825,7 @@ lpfc_pci_suspend_one(struct pci_dev *pdev, pm_message_t msg) /** * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management - * @pdev: pointer to PCI device + * @dev: pointer to device * * This routine is to be registered to the kernel's PCI subsystem to support * system Power Management (PM). When PM invokes this method, it dispatches @@ -13873,19 +13836,19 @@ lpfc_pci_suspend_one(struct pci_dev *pdev, pm_message_t msg) * 0 - driver suspended the device * Error otherwise **/ -static int -lpfc_pci_resume_one(struct pci_dev *pdev) +static int __maybe_unused +lpfc_pci_resume_one(struct device *dev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct Scsi_Host *shost = dev_get_drvdata(dev); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; int rc = -ENODEV; switch (phba->pci_dev_grp) { case LPFC_PCI_DEV_LP: - rc = lpfc_pci_resume_one_s3(pdev); + rc = lpfc_pci_resume_one_s3(dev); break; case LPFC_PCI_DEV_OC: - rc = lpfc_pci_resume_one_s4(pdev); + rc = lpfc_pci_resume_one_s4(dev); break; default: lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, @@ -14065,14 +14028,17 @@ static const struct pci_error_handlers lpfc_err_handler = { .resume = lpfc_io_resume, }; +static SIMPLE_DEV_PM_OPS(lpfc_pci_pm_ops_one, + lpfc_pci_suspend_one, + lpfc_pci_resume_one); + static struct pci_driver lpfc_driver = { .name = LPFC_DRIVER_NAME, .id_table = lpfc_id_table, .probe = lpfc_pci_probe_one, .remove = lpfc_pci_remove_one, .shutdown = lpfc_pci_remove_one, - .suspend = lpfc_pci_suspend_one, - .resume = lpfc_pci_resume_one, + .driver.pm = &lpfc_pci_pm_ops_one, .err_handler = &lpfc_err_handler, }; From patchwork Mon Nov 2 16:47:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 363A692C for ; Mon, 2 Nov 2020 16:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1573822268 for ; Mon, 2 Nov 2020 16:53:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b7V5ebDK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbgKBQxx (ORCPT ); Mon, 2 Nov 2020 11:53:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727314AbgKBQxw (ORCPT ); Mon, 2 Nov 2020 11:53:52 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7FEC0617A6; Mon, 2 Nov 2020 08:53:52 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id x13so11599551pfa.9; Mon, 02 Nov 2020 08:53:52 -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=6rD2BjZVXaWq6x/ciVXhavn4M1TtA7njBLCCq/6xvNk=; b=b7V5ebDKKXGuZHoL4SHs/xhU9TSjdnCtAK37F+LCrKoSIqMXn5CcNy6Q7UT6JXy5DQ FUwcS5u4UIEyEmtTB+fdZZ/Bn7qPuDQDD3GZPwCrJ3x0nb5OlkVEustCFKdd5zAEktLk OAwlU8y8Agp+4CSx30btenvFNwz50WL63UtlPVo29WPutJSRSMPbz9fm0pwBSkvADWzq xgvDFX9h8N5QCdSVpJt9yc82mMVjp6GWSoiIjAcHYK8WFXoAC8gsBvslTruCDf7LfBas 5PCT5R2awaZbMHlmbLEQLiqBn1Q/1k9+Sdkkdy1pobcJzsFulLI+TpB9iQbIlL76eD5f AYdw== 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=6rD2BjZVXaWq6x/ciVXhavn4M1TtA7njBLCCq/6xvNk=; b=aBdXmiOPDUjdxttjgwsBrsEe99+abUBNyF82r+iiA0jFgshzDfa3UAhCwt9bcRwB49 lZ0tPgJlon9p+tTkDyjk2vCQCIbJyrgw1ONQ34YHYcmajjJV1/AbkNR/VI04h8oQshE6 GGs0B2T8IhusxY3jRWxhkLxxrCQ3Sm3MtllWHb+MURubGxUpzrAyM17gxT2OpRrUbAVJ wZZvG/z2B/A0JYAi1CrWYji3Vok4AC44rbtprDBVtGJ0+5Gr6GiGECp4ZXpQ9+w68EVt E7I9HDBLk0nIGAgrA6Id5HhOh2Y7q52APoCUOj7mbV+3rFBb/+99S+Yif5XX69YqZIo6 RybQ== X-Gm-Message-State: AOAM533VAUE9KzAskzDYutVNr0PeBlvCoOMwWqSTP5rWRpHAaX7tk1LB l+MPuY4kVpJgoSZaqPeTRxk= X-Google-Smtp-Source: ABdhPJwsP+UyDRDmxoRtGAw+s8a66u11cnaGSNVCpQZuTJmTiL6Ebr0tI4XDNJ+fnuEGBgA7g0EPwQ== X-Received: by 2002:a17:90a:a4c6:: with SMTP id l6mr7360518pjw.91.1604336032479; Mon, 02 Nov 2020 08:53:52 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:53:52 -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 18/29] scsi: pm_8001: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:19 +0530 Message-Id: <20201102164730.324035-19-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in pm8001_pci_resume(), and there is no corresponding pci_enable_wake(...., true) in pm8001_pci_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from pm8001_pci__resume(). Signed-off-by: Vaibhav Gupta Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 3cf3e58b6979..d47ed9a33173 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1327,7 +1327,6 @@ static int pm8001_pci_resume(struct pci_dev *pdev) "operating state [D%d]\n", pdev, pm8001_ha->name, device_state); pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); rc = pci_enable_device(pdev); if (rc) { From patchwork Mon Nov 2 16:47:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7153D6A2 for ; Mon, 2 Nov 2020 16:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BE8B22268 for ; Mon, 2 Nov 2020 16:54:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FNiyl1hX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727305AbgKBQyD (ORCPT ); Mon, 2 Nov 2020 11:54:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgKBQyD (ORCPT ); Mon, 2 Nov 2020 11:54:03 -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 73560C0617A6; Mon, 2 Nov 2020 08:54:03 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id w4so1059280pgg.13; Mon, 02 Nov 2020 08:54:03 -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=VhabbmrVlKfIcloXKiUycGjVLZHaLqGck6HUDFpjzd4=; b=FNiyl1hXUBQIr2AqRDMiQQrHQtakYZefo7BHUUaFEaNe3AON3Ra5wz0jv1lYLopD/J 9q8+190FFV4gQaefv/2wGEECM1DanKSBBp6LpCc5bFyiS/gJ+vAWZ2XhBgvBprgyn077 FtvPNPx+RM9xASBAwpDud3V4EfOVN+Dh/9fc+LvsrT2IGgKnHDRKA1uwwlTf8TFb4Mo7 Xe3hTU/lEOs5umAd2rcm6QQ20EQOL36vlpNKBpAt/kwzfLP8K3TFO6RzPr+MypS1qIDV vuob7yY27jvqqNGxWe15ZTzBVzQdcCPRfXzff+iC9VGLk3vk1aq6qMg6V2WoZ2bF7s5E YD/A== 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=VhabbmrVlKfIcloXKiUycGjVLZHaLqGck6HUDFpjzd4=; b=etcvYIQRsfAcgWccS/1ttbZOzfAQKrx0/PFAhM+H1BBhHlIND6ShCVwAHZcAOrR/kX P/6Ewa8JGI3B0iCf4HttrHI8CmixXcXtv9MpoSRkY/jsRYqt1JkAvKagIvciXKIzVnmq DpbrykCdNbJhOVStoB9CGB6AAzbq8LEpfIqS6DslCgzVyOdvpisT7nmQuoVlPGTTnWJ3 UA7fyM5il8BjLYmB+Gtk3ywobeKo18FkTA/kM6l3NxXVn/xeJFDtI7/rV6DWYzySpNcN 3ZkaNaC8dnzbeeUrYdT2zu6jGzObTIyqOXyRMMCDJJFH3GFauiVuTdjcDNyKBzCT69FZ FkKg== X-Gm-Message-State: AOAM5309TZOT0f/P8k13KvBt4kSmN9Juci8JmxT0uysqYy2FwmgOsrAg cGAYL4dhn0roGfDuG1L3cOU= X-Google-Smtp-Source: ABdhPJxw8lCwnUiNaQAX76vwhA4YIcPI6dIqpyLBz643suOBf7Pk6OZM1tXuc9wBPSC5zsTj+b76jA== X-Received: by 2002:a17:90a:4a15:: with SMTP id e21mr4038914pjh.130.1604336042989; Mon, 02 Nov 2020 08:54:02 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:54:02 -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 19/29] scsi: pm_8001: use generic power management Date: Mon, 2 Nov 2020 22:17:20 +0530 Message-Id: <20201102164730.324035-20-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/pm8001/pm8001_init.c | 45 +++++++++++-------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index d47ed9a33173..7a732fd09b38 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1257,23 +1257,21 @@ static void pm8001_pci_remove(struct pci_dev *pdev) /** * pm8001_pci_suspend - power management suspend main entry point - * @pdev: PCI device struct - * @state: PM state change to (usually PCI_D3) + * @dev: Device struct * * Returns 0 success, anything else error. */ -static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused pm8001_pci_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct sas_ha_struct *sha = pci_get_drvdata(pdev); - struct pm8001_hba_info *pm8001_ha; + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; int i, j; - u32 device_state; - pm8001_ha = sha->lldd_ha; sas_suspend_ha(sha); flush_workqueue(pm8001_wq); scsi_block_requests(pm8001_ha->shost); if (!pdev->pm_cap) { - dev_err(&pdev->dev, " PCI PM not supported\n"); + dev_err(dev, " PCI PM not supported\n"); return -ENODEV; } PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); @@ -1296,24 +1294,21 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) tasklet_kill(&pm8001_ha->tasklet[j]); #endif - device_state = pci_choose_state(pdev, state); pm8001_printk("pdev=0x%p, slot=%s, entering " - "operating state [D%d]\n", pdev, - pm8001_ha->name, device_state); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, device_state); + "suspended state\n", pdev, + pm8001_ha->name); return 0; } /** * pm8001_pci_resume - power management resume main entry point - * @pdev: PCI device struct + * @dev: Device struct * * Returns 0 success, anything else error. */ -static int pm8001_pci_resume(struct pci_dev *pdev) +static int __maybe_unused pm8001_pci_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct pm8001_hba_info *pm8001_ha; int rc; @@ -1326,16 +1321,6 @@ static int pm8001_pci_resume(struct pci_dev *pdev) pm8001_printk("pdev=0x%p, slot=%s, resuming from previous " "operating state [D%d]\n", pdev, pm8001_ha->name, device_state); - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - rc = pci_enable_device(pdev); - if (rc) { - pm8001_printk("slot=%s Enable device failed during resume\n", - pm8001_ha->name); - goto err_out_enable; - } - - pci_set_master(pdev); rc = pci_go_44(pdev); if (rc) goto err_out_disable; @@ -1396,8 +1381,7 @@ static int pm8001_pci_resume(struct pci_dev *pdev) err_out_disable: scsi_remove_host(pm8001_ha->shost); - pci_disable_device(pdev); -err_out_enable: + return rc; } @@ -1480,13 +1464,16 @@ static struct pci_device_id pm8001_pci_table[] = { {} /* terminate list */ }; +static SIMPLE_DEV_PM_OPS(pm8001_pci_pm_ops, + pm8001_pci_suspend, + pm8001_pci_resume); + static struct pci_driver pm8001_pci_driver = { .name = DRV_NAME, .id_table = pm8001_pci_table, .probe = pm8001_pci_probe, .remove = pm8001_pci_remove, - .suspend = pm8001_pci_suspend, - .resume = pm8001_pci_resume, + .driver.pm = &pm8001_pci_pm_ops, }; /** From patchwork Mon Nov 2 16:47:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 677846A2 for ; Mon, 2 Nov 2020 16:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B170206F9 for ; Mon, 2 Nov 2020 16:54:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CGndiWGb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbgKBQyO (ORCPT ); Mon, 2 Nov 2020 11:54:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727157AbgKBQyN (ORCPT ); Mon, 2 Nov 2020 11:54:13 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB36C0617A6; Mon, 2 Nov 2020 08:54:13 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id x13so11275252pgp.7; Mon, 02 Nov 2020 08:54:13 -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=y9mWg+/4v2UCFJAlCKvgYuV+7m/IMMSCBwMkcMZiS84=; b=CGndiWGbeSa0mZUzNP66q0m9jiwhXlWICOiDvD/aXAaAJaV11Abd15VLtUvUSiB8Oj 7HbbO6v9eHhFuHCvGlbf7bKUBw8vMz1pct/80te2IDeQGdEEsZQKEdjRiCPqGa3A/jhb kxZStACpdV/f42s2hwn5yaSZ+B5YqtZQvCHktHJOzl5DI/8opJgVkeGZWlpXVBQmjuCj HwP1zLtTDbxrTyxo40PGgdgjtU0mylXAqS9dDbhPmynAscuBSdw4yZynqaoLNJEVH72m I6zx+2RpSG9MuYE1HAWlMp6lGsKIzWx4MkEriuyMomTbCi61P6XXeZdoyUZjoZ8KpxOr sWgg== 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=y9mWg+/4v2UCFJAlCKvgYuV+7m/IMMSCBwMkcMZiS84=; b=LM/9AY5CWfS5iCxVRFc2rK65O/xtU+BDyTsJK8Kg8NtwIy2ZF6zcFNOw/kYQA+HrbS vGbpYQlMxu1QXIh0NZeAIo+yGu/2+IUAHsyslA90RgC5P72J4qK4HD7G7450Yn4HCnLd nsUcKSz/yRIcgZGq6XqTnT+m0zJhfHg1hYOAJj6yavQ3chrleXpUfClhmAGZBYg5M/vP co7qLfelNaEFlWY9GlWSJ9qdi0naXh2/2/ZMb3QeaCtPIh6njpxg1VLRT02KXWky6Ala wtOfh/+pPt8gH6d6sywI+BaDqFIPmPsS/jJ0tIVQSfHTRyH+7TO9Op4Sjo4O2Lfz6h8R gDKA== X-Gm-Message-State: AOAM531royx4XnsWRY51q9Mdu9s6vlBoYkbDj/xV1fqOnork4vbovvDP RuqgNXWjJ/aioVFqWumXhv8= X-Google-Smtp-Source: ABdhPJzpwB1ncwX9rI1DG4O7sobiR6+6b36+pLha0Afpn+jdJ0C7J2kMqfr4zgoRAaArG6s8YBucwQ== X-Received: by 2002:a17:90b:994:: with SMTP id bl20mr18624263pjb.34.1604336053051; Mon, 02 Nov 2020 08:54:13 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:54:12 -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 20/29] scsi: hpsa: use generic power management Date: Mon, 2 Nov 2020 22:17:21 +0530 Message-Id: <20201102164730.324035-21-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 Signed-off-by: Vaibhav Gupta Acked-by: Don Brace --- drivers/scsi/hpsa.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 83ce4f11a589..e53364141fa3 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -9090,25 +9090,27 @@ static void hpsa_remove_one(struct pci_dev *pdev) hpda_free_ctlr_info(h); /* init_one 1 */ } -static int hpsa_suspend(__attribute__((unused)) struct pci_dev *pdev, - __attribute__((unused)) pm_message_t state) +static int __maybe_unused hpsa_suspend( + __attribute__((unused)) struct device *dev) { return -ENOSYS; } -static int hpsa_resume(__attribute__((unused)) struct pci_dev *pdev) +static int __maybe_unused hpsa_resume + (__attribute__((unused)) struct device *dev) { return -ENOSYS; } +static SIMPLE_DEV_PM_OPS(hpsa_pm_ops, hpsa_suspend, hpsa_resume); + static struct pci_driver hpsa_pci_driver = { .name = HPSA, .probe = hpsa_init_one, .remove = hpsa_remove_one, .id_table = hpsa_pci_device_id, /* id_table */ .shutdown = hpsa_shutdown, - .suspend = hpsa_suspend, - .resume = hpsa_resume, + .driver.pm = &hpsa_pm_ops, }; /* Fill in bucket_map[], given nsgs (the max number of From patchwork Mon Nov 2 16:47:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874577 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 171AD6A2 for ; Mon, 2 Nov 2020 16:54:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF90D22268 for ; Mon, 2 Nov 2020 16:54:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CggIJjuL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbgKBQyY (ORCPT ); Mon, 2 Nov 2020 11:54:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgKBQyY (ORCPT ); Mon, 2 Nov 2020 11:54:24 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EB18C0617A6; Mon, 2 Nov 2020 08:54:24 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id 72so4910754pfv.7; Mon, 02 Nov 2020 08:54:24 -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=tsLH0jLFmVf53d+PF9Z2Na19r4rjuIS/8Zz7+PtjCXU=; b=CggIJjuLgbNz5h9DMzIwuEZcDOyBeLnQvT5WCGynKw9pz1RuWMdXCJOWYp3NZzApN1 5TBUiKdxFqSDRUHRCO2qU3kio/t0jZwx4abi/KMvW5/UTq0nqPOsP1O4ISj+P/XIDkuH rpNVoompz/nXdUmotTvmXnXwyZasLldh77ZFlBopuN2bA8ODByuIso2frephWNPNMtVW WneU29PmIXRrtBlNSHAqfCqNigB9Itbwqg/wTL6QT7uIFrHWrp6630UHXsjJIOYgn3sq vvXQZggrNhY8c0S3Wt//xQ+geunh8dWFZlZ0BymMoJhsD/DrtE6kuxIlfI/Kc69YAQtB JAJQ== 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=tsLH0jLFmVf53d+PF9Z2Na19r4rjuIS/8Zz7+PtjCXU=; b=dbqatvVHzdQKPm5dTPWdqfRmOelvsSDRRWuL/jEqE3fPxCZRWTXVMQ2MOKnqly3EBy zVknUHl4LpL7inYKWN35A+wFPjMUXxpAX6w/sgTmB6A70/2GwpgjsZOv1DfTCCinVYTE h/J4m+7jv+SOKemWB5WWu696lSQArN+V4gfDou++xnEF8/sVCKbQgTm5PvtBACZHV1ji 66aU82GoaRQFuWBz2SfXlbGUoIAuuCE278RqSlmzBa8ppuQGZPYnujs139STHvqvS7qp p/K4cbXmC7JcTEYMAeU14V0uP2I8t7gWJcwHl9wOxgDTxRo8GBm19yfg21XNWvsRb3Lu N1hg== X-Gm-Message-State: AOAM5318hLUdYDLIOvBw3/8ca55L4LRcyUzaIq0wLd2valKwKrVp0JgM LnN4A7WO/zKKNGMMZy/cJ20= X-Google-Smtp-Source: ABdhPJxfN31gUnc7+QlY1HyEuUCBrTa6c8PhSwyeZjh6Dft+Dt5ux4oRfpn1AS4dPI5FbYSinWGC5w== X-Received: by 2002:a63:70d:: with SMTP id 13mr14407549pgh.263.1604336063665; Mon, 02 Nov 2020 08:54:23 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:54:23 -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, Don Brace Subject: [PATCH v4 21/29] scsi: 3w-9xxx: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:22 +0530 Message-Id: <20201102164730.324035-22-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in twa_resume(), and there is no corresponding pci_enable_wake(...., true) in twa_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from twa_resume(). Signed-off-by: Vaibhav Gupta Acked-by: Don Brace --- drivers/scsi/3w-9xxx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 3337b1e80412..e458e99ff161 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -2230,7 +2230,6 @@ static int twa_resume(struct pci_dev *pdev) 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); From patchwork Mon Nov 2 16:47:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F331F6A2 for ; Mon, 2 Nov 2020 16:54:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD8AC22277 for ; Mon, 2 Nov 2020 16:54:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jhuPycR6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727369AbgKBQyf (ORCPT ); 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-Google-Smtp-Source: ABdhPJy6QlJL7rYPIqq+l9/hn/Ik10ZaEmiHPX/5F8UA/Oua+uxbilOEwf4GgfFLo04ls0CNL2F2nA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 }; From patchwork Mon Nov 2 16:47:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27A9192C for ; Mon, 2 Nov 2020 16:54:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 048BC22277 for ; Mon, 2 Nov 2020 16:54:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NpW31TLe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbgKBQyp (ORCPT ); Mon, 2 Nov 2020 11:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbgKBQyo (ORCPT ); Mon, 2 Nov 2020 11:54:44 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5047C0617A6; Mon, 2 Nov 2020 08:54:44 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id o3so11269885pgr.11; Mon, 02 Nov 2020 08:54:44 -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=6ccyY/JHq4D3PLCl7N5Le5xwodBVxQCbk5cLiaDjEFw=; b=NpW31TLetItFsb140xAKZVbCVOKP2GAN9IMwURcruykGX00RcSle7+2EuM5I36CM8o fe4KsRaDfKtHUaTt5xVXCH2kez+BLnx9rJKFhORdMLQa+sk8W1vYH6YiTDcef8q2V1nl TUb30IC4T2Nfc+uLV0DYvKeXIHBywuPzlJoPTU+U8+zHYiyGEDA04TIpppSOGFkxexbh pGh73vWQpUaRpZ0IY9BxvFO5oZ4uB7CxqpYtva2SHbT1HQ+v+o8j8g0UTb+rkEAPvUH+ uaO2mHw4WvhZwEH8bDpx50oDS1g4G4FzH6lSucG9qGv8O1Aqk+f4J93leDCgYGD3nIcm IuCQ== 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=6ccyY/JHq4D3PLCl7N5Le5xwodBVxQCbk5cLiaDjEFw=; b=qM0ug096weLn6w5GT3rTvFwJ3HGTIKjq/2t7ltyS3m1RNVdcme0O96uuz5XPCKyysZ zp9kVQwtXbkhEZ7ApyYN1A4W16ADy3nZFMaTDKHNqppl4V2T+b6apzCOj5GIpaUWOTTe Qs5wbLEES0ccaZTk295LmlWufN/yaNJ8gXx7nRKz3hhIUNhBaAvIZSA96PWKe0JX5NI/ sxmoe04PP7YfAWp30M/sAGK/mhYMR4CV9/HpmqTOtpjUF4Lr/2MZlq2BOpFh/MVJwmAZ xAhMmrWj1mpNoB4U+bQeGF3e26z8vS7qJclQXte/koXilrOOWWij4bug77f8cdjGyddX whzg== X-Gm-Message-State: AOAM531HyrtWxvHIH231+q6dIjpvY54kUHvhaK3SUKz4JcOaZs1C4ClR D21DoAIhczSTmZKVBugKLuc= X-Google-Smtp-Source: ABdhPJx/1LewIo20VjBh1CMTVa+zuJIuzuWLg4W/csDX8oOWuCb+rFAFC6LAzjvhej07R0r8NoDkqA== X-Received: by 2002:a17:90a:1188:: with SMTP id e8mr18750804pja.61.1604336084398; Mon, 02 Nov 2020 08:54:44 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:54:43 -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 23/29] scsi: 3w-sas: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:24 +0530 Message-Id: <20201102164730.324035-24-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in twl_resume(), and there is no corresponding pci_enable_wake(...., true) in twl_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from twl_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/3w-sas.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index dda6fa857709..0b4888199699 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1795,7 +1795,6 @@ static int twl_resume(struct pci_dev *pdev) printk(KERN_WARNING "3w-sas: 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); From patchwork Mon Nov 2 16:47:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 999BC6A2 for ; Mon, 2 Nov 2020 16:54:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 774BB222B9 for ; Mon, 2 Nov 2020 16:54:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vEvEad+H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727279AbgKBQy4 (ORCPT ); Mon, 2 Nov 2020 11:54:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbgKBQyz (ORCPT ); Mon, 2 Nov 2020 11:54:55 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 354B5C0617A6; Mon, 2 Nov 2020 08:54:54 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id b3so11637876pfo.2; Mon, 02 Nov 2020 08:54:54 -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=yCf+5pBHtGakI8vGh3iG+XqVcPWuJKKA8L3HBDKw1hc=; b=vEvEad+H+eWgs40nHp0nELDOrVYmOjvKeE8TdSmqxH7ZmAMRXi1eSZ7qutoPGgA4u5 WPdcoQo385A3T7OpTMB3cbQGMlWXACIioV9OSZuSn1tb9mjhz+tj2cS8C8O9M7V96FFF CymO2EIqjBX5jAxCBOdANWVLSoEo23UDAbpv3+JYCr6jWz83uCmS12oETvsUt9MAcatU xwat4DGT9+NnfQV771nNYlSURM1Mz3blHVjX/ho9fOd4dJtCSWgja3vUa/N0CGM073BC lv4+c8nj+FtUU1dwarFxLyqWq66qErjq6j7camqsETu6KfU+dtlzGEK0Zb9YOnx/HI4L SSmQ== 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=yCf+5pBHtGakI8vGh3iG+XqVcPWuJKKA8L3HBDKw1hc=; b=G5RtMx2aD1A22TZb1YtBFGSrmA7YfKsV/ToA9ekDN2Qx688WgHS7dQFz36J2F+1cbx VSTaKgz5hWHQ0qf/RFIEp8vw/8vGVF4uVqUdY2n4C73LocQESJejfiG/ZRhgPbizNcRD lkn8lu99hOQLPyB69LRFpZ3/gwj2O8mskyyrPd0uxOX8jdRKoNw3R7aP8kstbkuy4Fa4 OfIFVQPL5kJcbu12TVaIBBB1PGKKV0BNpxaAPl9o0hsYfuSkA94lPmOMXnFefMGWwh6G 8tggIRTmvhwY7OJvHPNE1vDE34C7xBMPlSwRNpSvvZeHBdu3kWcAga6qxMM+TlNxnL4p 7UHg== X-Gm-Message-State: AOAM53383huwKn01AX9E9O9VkGOGZ+xf3jBFI0wUlwEwnDbe+SC/QsWY wBJbbwk5wY2OpXT2Vg04up4= X-Google-Smtp-Source: ABdhPJzNTDOXtAD5WGfTQNsPSzEj202Ojni4ZSsnXTsIRIn/f/5a2YTj/Xz6GogQ3JzQYLUvqUiQUQ== X-Received: by 2002:a17:90a:4a15:: with SMTP id e21mr4041783pjh.130.1604336093729; Mon, 02 Nov 2020 08:54:53 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:54:53 -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 24/29] scsi: 3w-sas: use generic power management Date: Mon, 2 Nov 2020 22:17:25 +0530 Message-Id: <20201102164730.324035-25-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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-sas.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index 0b4888199699..b8f1848ecef2 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1756,11 +1756,10 @@ static void twl_remove(struct pci_dev *pdev) twl_device_extension_count--; } /* End twl_remove() */ -#ifdef CONFIG_PM /* This function is called on PCI suspend */ -static int twl_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused twl_suspend(struct device *dev) { - struct Scsi_Host *host = pci_get_drvdata(pdev); + struct Scsi_Host *host = dev_get_drvdata(dev); TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; printk(KERN_WARNING "3w-sas: Suspending host %d.\n", tw_dev->host->host_no); @@ -1779,31 +1778,18 @@ static int twl_suspend(struct pci_dev *pdev, pm_message_t state) /* Clear doorbell interrupt */ TWL_CLEAR_DB_INTERRUPT(tw_dev); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - return 0; } /* End twl_suspend() */ /* This function is called on PCI resume */ -static int twl_resume(struct pci_dev *pdev) +static int __maybe_unused twl_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-sas: 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, 0x24, "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)); @@ -1841,11 +1827,9 @@ static int twl_resume(struct pci_dev *pdev) out_disable_device: scsi_remove_host(host); - pci_disable_device(pdev); return retval; } /* End twl_resume() */ -#endif /* PCI Devices supported by this driver */ static struct pci_device_id twl_pci_tbl[] = { @@ -1854,16 +1838,15 @@ static struct pci_device_id twl_pci_tbl[] = { }; MODULE_DEVICE_TABLE(pci, twl_pci_tbl); +static SIMPLE_DEV_PM_OPS(twl_pm_ops, twl_suspend, twl_resume); + /* pci_driver initializer */ static struct pci_driver twl_driver = { .name = "3w-sas", .id_table = twl_pci_tbl, .probe = twl_probe, .remove = twl_remove, -#ifdef CONFIG_PM - .suspend = twl_suspend, - .resume = twl_resume, -#endif + .driver.pm = &twl_pm_ops, .shutdown = twl_shutdown }; From patchwork Mon Nov 2 16:47:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874585 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8C426A2 for ; Mon, 2 Nov 2020 16:55:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98A5922258 for ; Mon, 2 Nov 2020 16:55:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gEvgla2U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727418AbgKBQzE (ORCPT ); Mon, 2 Nov 2020 11:55:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbgKBQzD (ORCPT ); Mon, 2 Nov 2020 11:55:03 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5102C0617A6; Mon, 2 Nov 2020 08:55:03 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id 62so4005693pgg.12; Mon, 02 Nov 2020 08:55:03 -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=2ui/Tg6A0BnaN3BBtG1fWoCuT6IRPSKhNvvy+KUOGlY=; b=gEvgla2U5+zkdxzjNq4Y+OqR7bhdhQ0U0ekzs2BUF7LP6e6f6brIFD04ZOYiDVPHxd B9oVKKMNwBQWGe66H/1aQESSOVXsP63gLokNheNZit56xFJNuEMiCdzQnrKBqRmPJJWT lDquROHkFpB84dZuD0RVTYUpGgLlebkH52pLhkaJJ2Sldm9cSK/RwmtiR05ZhyIlBEeb uuUV0QHyV2oMWiQgqSWjPhbJkWsPRJ7dqtZSAzYTrv6st0o9gasryxNlww5hQkhTMyqo zocJxNcaS/PPboDIGkm18Ko5e4bHENEqABMuZj6W15JKx131fJFy2FB8t+KrLXK0mQ64 YaYA== 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=2ui/Tg6A0BnaN3BBtG1fWoCuT6IRPSKhNvvy+KUOGlY=; b=IwECKlz9QYjqSXjlJ+xcI6DI2hl4fCmlfXqO7V5+ujSNfuSK65X39pn9qLfLr/7mT7 SdANwnvZ0fGooastfyMo+FMRaAJ1l7+Ert3n+wk/shCBaCDFEewLj32JqvWHWQ5dOtfI v1noCisM6WBONKGfSJ697zrQO1oKw+nvJnXMmi/ypcPFfEO6gwfMiATK9Z0WBa5bpdnW Ux32VKIiG2+Tgbt+lr1dEyHPsk/ZtvBta2oMulXdDf7NRxeOHTdIGjsZLU3FG0k9u6Kd EyMzbHv+mC232alI4XI0EFH24R3ytsbEA1+pJ9DBzKBDyw53vpCsNJCjLdWwHuisPYY5 XZlg== X-Gm-Message-State: AOAM5324iOEnFLVTvoVWp+PqQ5ZJFuZo2Qn2M4IRhbNptdBjNe8NN/og n1S/yYhN3NCKr35G3Tob04Q= X-Google-Smtp-Source: ABdhPJyj629fp48GcZrJ+3yMSSNljQLe94icEhcMlzF6ecfvj/MGCVMilJk+PvxHmE3Q2s0IobZPjA== X-Received: by 2002:a17:90b:994:: with SMTP id bl20mr18627123pjb.34.1604336103472; Mon, 02 Nov 2020 08:55:03 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:55:03 -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 25/29] scsi: mvumi: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:26 +0530 Message-Id: <20201102164730.324035-26-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in mvumi_resume(), and there is no corresponding pci_enable_wake(...., true) in mvumi_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from mvumi_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/mvumi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 0354898d7cac..7cd9c70e32dd 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2595,7 +2595,6 @@ static int __maybe_unused mvumi_resume(struct pci_dev *pdev) mhba = pci_get_drvdata(pdev); pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); ret = pci_enable_device(pdev); From patchwork Mon Nov 2 16:47:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874587 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BD2C92C for ; Mon, 2 Nov 2020 16:55:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33E67222BA for ; Mon, 2 Nov 2020 16:55:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EqBfrFxF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727676AbgKBQzO (ORCPT ); Mon, 2 Nov 2020 11:55:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbgKBQzN (ORCPT ); Mon, 2 Nov 2020 11:55:13 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAD3C0617A6; Mon, 2 Nov 2020 08:55:13 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id z24so11304338pgk.3; Mon, 02 Nov 2020 08:55:13 -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=6TT5IHBGfMGaGX7Gmtu8Tm24mP0xvbXIdvxm/B+0he0=; b=EqBfrFxF3+hGpsiNVPo8B7GgJAUlGeMlNhH4lysYEpmhzxoV8GNoyu/v9Zgu3a4eD+ /l1IOopOJ9pacDJCFInIx35HkiAgm40qHSIp/3I6CQf3pZzipCXNyg/vurrrRZOivvqO CrmOgAFw6h1Kg5IBW4wOJ+8UwWIel6QPoukYqeIVOdJgEiySCg+RxGKzSKishp1brJI3 g+rw57xfHlZWaa4hiv+58wFpMOtLvcqp9Ht86Iz2795uzAYQtUpdptGiFEaLnS7kzKIG /u1u/vQTEjEXMDnqc3LfIyIQDBiQLVYY5FdWrkFqx/aGb9x51pauemc/gZCjOLQa2pHS LZrA== 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=6TT5IHBGfMGaGX7Gmtu8Tm24mP0xvbXIdvxm/B+0he0=; b=E2EIEioekDMKHNW62ooDgpT63G5yWuBGAOaXpWaJTEauTWAyAjJBMz0Yqe7XUtXnOO x5YorXaDsYLADzF8/PlEqjjeYvmYisz0bFjre6vBmEh5NeZ9OZLk3P1MJ0sXll7a4mOi rHybdqm7EbalsuCFoOLt4/mdu3HO+svUSYXQzdzNNps/XS6KBI/7J9AknpwteC2F7Ea9 5fqai6OqkCoCHZQRpa7rkBOCB+CVx1+Oe3H/yogEyU6ZmtN8WWKQL673XO2psmVq3btb 7NxAcNFVSAmvCMh2iwX5UHeBqV6NgUuQrfaL4pXRFbnuzR8KAARRMf0TX4f5I2a4S18c 8tfg== X-Gm-Message-State: AOAM530INj99C2eWd+ARLNT8CokZXxwI7VUsgBRNEijxBe6QOtxMQHLO rFCaQyjT6tU0AmQENgPQCBI= X-Google-Smtp-Source: ABdhPJxSqIjszVQ7UUpwB2fQQhrisUvUQEw43M/qAx4xbj3NgP0iA3aMYeRnvG7fJ414uX2K3G8LgA== X-Received: by 2002:a63:e80b:: with SMTP id s11mr14105089pgh.380.1604336113148; Mon, 02 Nov 2020 08:55:13 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:55:12 -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 26/29] scsi: mvumi: use generic power management Date: Mon, 2 Nov 2020 22:17:27 +0530 Message-Id: <20201102164730.324035-27-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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/mvumi.c | 46 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 7cd9c70e32dd..bbf0faac1f05 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2568,46 +2568,26 @@ 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); + struct mvumi_hba *mhba = pci_get_drvdata(pdev); - 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_restore_state(pdev); - - ret = pci_enable_device(pdev); - if (ret) { - dev_err(&pdev->dev, "enable device failed\n"); - return ret; - } + struct pci_dev *pdev = to_pci_dev(dev); + struct mvumi_hba *mhba = pci_get_drvdata(pdev); - 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 +2607,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 +2616,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 +2629,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); From patchwork Mon Nov 2 16:47:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874589 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08E736A2 for ; Mon, 2 Nov 2020 16:55:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD6F3222B9 for ; Mon, 2 Nov 2020 16:55:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X+zOGPT/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727692AbgKBQzX (ORCPT ); Mon, 2 Nov 2020 11:55:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbgKBQzX (ORCPT ); Mon, 2 Nov 2020 11:55:23 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AEDDC0617A6; Mon, 2 Nov 2020 08:55:23 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id 72so4913122pfv.7; Mon, 02 Nov 2020 08:55:23 -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=EXCGiZLEfZtvWjQ4e/G4dbiDVH55KoRFUUF32V42VvE=; b=X+zOGPT/TSOjE20bmMX712PNBloY0JW3OvLlxo329Ib1Nf2+FbziCV/QGDeTkMtx3D Ab6QfTFENhrYD1E/hwYQlE6GPQRAaqwsm3H1gCYd65BpugqByfoG3PnQ4AG4MMPNdBhm 1FtG6g90mxk2rKio+tEnH6/jKTlWAcNL5g+wjjNzYlzM8idwGsSZ+iCykVZSPWTTqivi WZ352otPwDz30BsdcSrChlsHrFNfm1b/w3AHyNdbVSDJoXEa6FU9mnfJNrr295p8orMa yKxsCSYOkyY4oE/6MbL82LydkpnzJTbqmN8AwhAm1RYe8+lwWUhiSIV4r4rQUh7gT3TO pCVA== 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=EXCGiZLEfZtvWjQ4e/G4dbiDVH55KoRFUUF32V42VvE=; b=fpaKd6KpQTVQwPhyV/g68Zvfvb9M7k39T1G6xhknP3by+qdijbmPWUBm5GW3z3tdtj VIAh27MMTha3d4/VLRQ0Vw0KQDVLRe3OaA8phltfyGp1e95LqfnCOUlyGj6poPee6m/e 3nre9h6NJ8ZWBFcdzG80KZebNLrERkZC683gb4+P3mjKbOkDy/So1CnegvZGpfJnq3n6 yQdWeYNoqRUj/l7zyF2OiPngyu0CIJtAqsFo+E+z1cPr2P6wjaG/9K5cHs0RXsDcB4jb rdQJIV5Lnh7YuhKGolCS55gcLA5ysXVLNTzPOIFCm/F4VAB+ML3bdoYls/kKhqBMSQS0 y0ZA== X-Gm-Message-State: AOAM530acSaAF2TNXLQlsZ9UWFXc1QVSlwn3zCCwFm+F8bqIwa5PQSW9 0AOwcF9XscrAHl4OVSziCJ0= X-Google-Smtp-Source: ABdhPJwzfPgvdSwIBa5QtR9xO4o0HjNoNHKyv4uGH33LCWmGslB9FXZpefstEtLmcHt2vG3qPnXRHw== X-Received: by 2002:a17:90a:fb8d:: with SMTP id cp13mr7412843pjb.168.1604336122852; Mon, 02 Nov 2020 08:55:22 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:55:22 -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 27/29] scsi: mvumi: update function description Date: Mon, 2 Nov 2020 22:17:28 +0530 Message-Id: <20201102164730.324035-28-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no "device" parameter in mvumi_shutdown(). Instead there is "pdev" which is not described. Signed-off-by: Vaibhav Gupta --- drivers/scsi/mvumi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index bbf0faac1f05..6c82b0bc391a 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2559,7 +2559,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) { From patchwork Mon Nov 2 16:47:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874591 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B8956A2 for ; Mon, 2 Nov 2020 16:55:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA827222B9 for ; Mon, 2 Nov 2020 16:55:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="byawQ/SZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbgKBQzd (ORCPT ); Mon, 2 Nov 2020 11:55:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbgKBQzd (ORCPT ); Mon, 2 Nov 2020 11:55:33 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C9B0C0617A6; Mon, 2 Nov 2020 08:55:33 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id 10so11618333pfp.5; Mon, 02 Nov 2020 08:55:33 -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=fW/BfkSigqeA/7sHlInXZcmolxISxSAGZHTmLq9vq7w=; b=byawQ/SZbG7wwZwJ/BWULutg85ygIZfRKdeXa6SDhyrH+Rigyw6EMt2sR1MiBbdTHo M1mHBCdM3y2DRE3nwIa0HJ5k9WC0RrQrjWynbAxYIaDORDdrqukMS2WUewpCne1LJXYW BP9li66eIdwTbKooMZc37vvk78qDwS6ARQJQ40bwL8JbiOZpr3L3H9JFwnhEbKs8bYYr e1Jkp1hoefRoRYxYTlxlvW5g3nfMnlKn0RQzuPdS5E04KMkj2nsjb7E6s3+hmDMw/rBF ale7UeErtqRDabJT2q8yjGBLjBtYgxYA1bRnU+8UJus5+SNjPOrGz8Yh9NnvSOXLkPm8 vhDQ== 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=fW/BfkSigqeA/7sHlInXZcmolxISxSAGZHTmLq9vq7w=; b=MzkzJ2/gIxgofl9dMAo0go0xUkHT4i5hS/xf7LdHsY5kB1dUlkc+M0QwbCE0bqj95m UTWdDAiZxlgqFGKyArvZeVFAKzsiaA4h1vrl1t150z4vlOBcTX6EsK5E6wR4qGI+tdn+ zDaDQEvUv/3gxVbJHfBgwB6T/USe3hIi3FOdTq5pQEX6ZQFYFiwh3mcEwXlBbet/PnaV fGqo7QMolnwylwKRAAwWDyYOHzPSnAdvjEBH1q2r5FWa12H2XK1rmJqhjYDHT8b8XspG OnztcWQ3Cmi0bMZ0uJD+1ELB2Xxe/wud3W2cTMDiBK2aiEwU2Kv5eiA8BHf/jXUfTjbe GBQw== X-Gm-Message-State: AOAM531Q7aQaKH8/ZpLUxNWjO9O9HADp4alq461FnzGVeV0p56W/GMJO 5u/79dUw6kT5cVh06S2zLwY= X-Google-Smtp-Source: ABdhPJyhJXUnKsKoEx0UezB9HVKpp590ogdrqyESHRkls/XQE7Dx1XdbSnVjSMeH5dlNWJM1qUpfVw== X-Received: by 2002:a63:221d:: with SMTP id i29mr5230679pgi.69.1604336132873; Mon, 02 Nov 2020 08:55:32 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:55:32 -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 28/29] scsi: pmcraid: Drop PCI Wakeup calls from .resume Date: Mon, 2 Nov 2020 22:17:29 +0530 Message-Id: <20201102164730.324035-29-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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver calls pci_enable_wake(...., false) in pmcraid_resume(), and there is no corresponding pci_enable_wake(...., true) in pmcraid_suspend(). Either it should do enable-wake the device in .suspend() or should not invoke pci_enable_wake() at all. Concluding that this driver doesn't support enable-wake and PCI core calls pci_enable_wake(pci_dev, PCI_D0, false) during resume, drop it from pmcraid_resume(). Signed-off-by: Vaibhav Gupta --- drivers/scsi/pmcraid.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index cbe5fab793eb..5c767cd8ffc3 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -5271,7 +5271,6 @@ static int pmcraid_resume(struct pci_dev *pdev) int rc; pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); rc = pci_enable_device(pdev); From patchwork Mon Nov 2 16:47:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11874593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65E5D92C for ; Mon, 2 Nov 2020 16:55:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40AF7222B9 for ; Mon, 2 Nov 2020 16:55:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DSlnE7WO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727387AbgKBQzo (ORCPT ); Mon, 2 Nov 2020 11:55:44 -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-Google-Smtp-Source: ABdhPJyKCCtMCVaSvU3Is+RZvy6q7HpSGUGMl4yzO6ssLEtChPuyUb5A8lINnWDTzVhEeOe929D7+Q== 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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 };