From patchwork Thu Oct 1 12:24:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B54ACC4741F for ; Thu, 1 Oct 2020 12:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81C0E20B1F for ; Thu, 1 Oct 2020 12:27:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z87+Fi6I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732104AbgJAM1x (ORCPT ); Thu, 1 Oct 2020 08:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731926AbgJAM1w (ORCPT ); Thu, 1 Oct 2020 08:27:52 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A225CC0613D0; Thu, 1 Oct 2020 05:27:52 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id s14so1466853pju.1; Thu, 01 Oct 2020 05:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ouf2Btjyrfu8hsFcX+gtYlfigwnxT6LfTNtyIop3GBc=; b=Z87+Fi6IIGwkNUbmObg3E0/O10eaRcuM5Kd3G82MlAh09V9X7354YHpxaBYFyuNw1G WZmDVHcXg/w5luVGvpjX43K8Zwgyn+A4750tWtcDrYVTESOfZajw4J2U/353zYymU52w X3G/k102+ysSejaWCLDW4VWmsXgfhvIFJ7euzzDP1YbWASctdo07HJPSvYp8JBZWdKwl VLVAY2vy1xzDtS6dMqClEXoEoiMgJpOEbI/kf3MPw3ASAOBu/3gwhylq6WvVbQSenOT/ d5Cve0jXoU9L9+EuVPjBjoMvmMTgpgorWPG7eAQur7PIIMfWSGrSHzGcDhBOo1JpS+XR zxvg== 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=Ouf2Btjyrfu8hsFcX+gtYlfigwnxT6LfTNtyIop3GBc=; b=WcviQ5SsYXywhDRHKUu9QVgRVDeZpSIscZBxawBN2l85JD2bR6SyhmDJHf01NAugSt tvcOMkJjA6i3Yc6E9H+UUXQZ/DfORwIhNJ1d0dJhQo+P1Nl7tzKtaM5DLyXmIphZUzaF Rwq9b6lPktf24r2QKhitB1H9Ir/Sur5UpPs2pjKhGhiR9APoTpKwsNPOBwrbrUHrLDwW dX3bBGArEkNvwlMgObXpRG2uzqaWeDZ7T4dtZiYvEUl20XIN4Z0T0mx4Pz4174afBk+T jdeI/UA911oERKjc+BVLETiH6tH+Ku2hBB4FMCxzsFCTbawqCFOvvAe3in12LyZHkIm5 a4sQ== X-Gm-Message-State: AOAM530kqUg1l0NjL568Ui4+cu6BcAN/uYFSnhbRySwQoPbI6PICxDcs jmLsL/8trY+usgdcEYhqL0Y= X-Google-Smtp-Source: ABdhPJxe+iLicMnfTPWlWjlRFAFHdqc2Xz6AwEGS5yjnoYV11M4Hi9lSXBxqapocUcsLDxuimEqxWw== X-Received: by 2002:a17:90b:e01:: with SMTP id ge1mr6582136pjb.187.1601555272157; Thu, 01 Oct 2020 05:27:52 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:27:51 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 01/28] scsi: megaraid_sas: Drop PCI wakeup calls from .resume Date: Thu, 1 Oct 2020 17:54:44 +0530 Message-Id: <20201001122511.1075420-2-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 00668335c2af..93ade9915ec0 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7614,7 +7614,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 Thu Oct 1 12:24:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BD5BC4727C for ; Thu, 1 Oct 2020 12:28:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D946620B1F for ; Thu, 1 Oct 2020 12:28:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k7GKoiAT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732145AbgJAM2E (ORCPT ); Thu, 1 Oct 2020 08:28:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732048AbgJAM2D (ORCPT ); Thu, 1 Oct 2020 08:28:03 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CEEC0613D0; Thu, 1 Oct 2020 05:28:03 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id l18so1894269pjz.1; Thu, 01 Oct 2020 05:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4T8XvHSCCKBEvcExwNjwW62MsEy/1YjMUFgvIQB5ws8=; b=k7GKoiATiSxjT+F9rfYPUKEXdcXcEVFwTV8Ldohq5M5ctIOadQKeOXqZ7COD+LFNkW xJFWjfC43YY7ntIrA8MADedQcYARCXs3KlhMdKrP+tNVn5941RzEGzKfs4KFnctsc6sQ vD3bb+KDPIsfTS4qwlX+VJbWibkh4O5XOf8ceoTpBEwBMj6rxB3CIf6uYGpycNJ/rgtv h81Mj2nvmk5piuRy7umzrv3CFMP6H5ahDMBpulwMvWF2l6hmJFAv86Y3CCRuLNQh7E68 r7Ah63vSHCjcP4h2pqv9//GVLUfGTOqRuJ3HzOUVRUcNOSYEIto46mkr05ULO5ntnPkA 74Uw== 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=4T8XvHSCCKBEvcExwNjwW62MsEy/1YjMUFgvIQB5ws8=; b=D+cnDpMehafDTZ7bCKEAc9fiXMmD07MJHcoM54bk48g1vhfCgAPOS5m/23IrldpNOx csl5xt5rIXPG9Cm2IiPrtsNht+q2g9LNJzptesNi28f2g1o0HEWObxpltCRPI8R//aig MhoDjzEV8NLBbMqW0dFVOI0SvN1hxlB2czkpNUUtKciV3FTdIDQhVHxbAqVB5StgIpxy 53+I0Bs3gsV7uKU0RcXggcFyBJ3/D26SY1RIDk3Ip9Rs5/5yBCvIDYCDS48YoiXJ5CeP J/qnZG57dJTXs2m0do83eoUVlYLNBi/fhpA41x+Rd5dXnWLMCqoQ0UFNN7YAtp69Xq+B It8w== X-Gm-Message-State: AOAM532tLdvdN31icHUKmRFvS2/Qeb0oTA8wVwsPhVelGFizp7WYnGEA 34Fgt4v+bPSQBpe7Z+1Zv3g= X-Google-Smtp-Source: ABdhPJxuLh9trbu2zHl2tlaTucRQjVNAPfjayrHOdJidMlZ1JGhKEcFq5fQgu4N2gmE6GpuQMiaSkQ== X-Received: by 2002:a17:90b:34e:: with SMTP id fh14mr6980697pjb.186.1601555283391; Thu, 01 Oct 2020 05:28:03 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:28:02 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 02/28] scsi: megaraid_sas: use generic power management Date: Thu, 1 Oct 2020 17:54:45 +0530 Message-Id: <20201001122511.1075420-3-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 93ade9915ec0..72aa7fabe051 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7539,25 +7539,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) @@ -7587,47 +7585,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 @@ -7753,14 +7733,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) @@ -8507,6 +8481,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 */ @@ -8516,8 +8492,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 Thu Oct 1 12:24:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04CDAC4727C for ; Thu, 1 Oct 2020 12:28:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD75721707 for ; Thu, 1 Oct 2020 12:28:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vfQtCC3m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732195AbgJAM2O (ORCPT ); Thu, 1 Oct 2020 08:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732048AbgJAM2O (ORCPT ); Thu, 1 Oct 2020 08:28:14 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E9DC0613D0; Thu, 1 Oct 2020 05:28:14 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id p21so1588532pju.0; Thu, 01 Oct 2020 05:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fjwnmscz0yil9BJar/ERhlr5lRA/SIC3GZV8Duqsy+A=; b=vfQtCC3mxJnOwF7Ww2VeP/fhKLsh2irLqd/ZQ8ITsCJgrYxOgLin0hbbo8cZSq0TT8 jzRUJjpfOM4ZrpyF4/liO267vI/XYDmKmlASwzlEOCG6Y+GBLpjxZaeXY0yBeMTdVLoK Q1MK7hjslVZZOCoOUiqIGkqzGaPM0CVxwLhJpkciwYC8uL5k8IvNfEhNFw+/740xrJLR PIoD9CN1ZP8LaqnR2eVLIPTlDgqV1422WtNZ6DFpJWAIa0rwluNMfFfpkZ2rvzpzffp/ uL/JYr8aVeQM/I4doQid5rdOnASibwhknhfOI/AJL+5bupHavdROcP0eV1K6ZSTijO1N UKSg== 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=fjwnmscz0yil9BJar/ERhlr5lRA/SIC3GZV8Duqsy+A=; b=DRS4K/dhbYrrqfo1yo9I4NOsASqUyWH4PjtRzAejz+PQ6zjK+TOlEIPvnrbS8nbVPK uytUIQuC8z+WsWpYzX4/Ki5yPhCLpHayrHKvjOjxoxJPGM7YaviX00GvwARytRoPRAg9 K5akgTGnLbY1IZusTQzhZBceBZNNcnUGZqWuq944m9M1YJRviAouzU7gN2/XQKZc52yf LTUuZFtFzqp5xEX7xtaK5szpbcVRt5hXtwOAGxw1W0irqxfIutmgNrzES/MuFoWe3wrl dHI8RuvVN56ZB32Ek7qONaNDOyIEzFnaYTTQIxs1WVMwf/m9Wbe685WuE7Rv3GaNTvMB VRbw== X-Gm-Message-State: AOAM530b4p1+f27k8R7tVIAZJL4t9H1+p76PYTZT7LYsRgTU0R3NC7hQ xDlgaYOG6MdcQ/CRMsTD28c= X-Google-Smtp-Source: ABdhPJytG0TtooA/ti7rplUndguiIZY51ru5WUO6GpxeViniX6/MzTPHWmXOYNKYwrUMrQtll7f/cg== X-Received: by 2002:a17:90b:1b03:: with SMTP id nu3mr6898644pjb.148.1601555293584; Thu, 01 Oct 2020 05:28:13 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:28:13 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 03/28] scsi: megaraid_sas: update function description Date: Thu, 1 Oct 2020 17:54:46 +0530 Message-Id: <20201001122511.1075420-4-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 megasas_shutdown(). Instead there is "pdev" which is not described. 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 72aa7fabe051..63ff8b87fd18 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7904,7 +7904,7 @@ static void megasas_detach_one(struct pci_dev *pdev) /** * megasas_shutdown - Shutdown entry point - * @device: Generic device structure + * @pdev: PCI device structure */ static void megasas_shutdown(struct pci_dev *pdev) { From patchwork Thu Oct 1 12:24:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6631AC47420 for ; Thu, 1 Oct 2020 12:28:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3096A2087D for ; Thu, 1 Oct 2020 12:28:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uD8CXQZd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732195AbgJAM2Z (ORCPT ); Thu, 1 Oct 2020 08:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731946AbgJAM2Y (ORCPT ); Thu, 1 Oct 2020 08:28:24 -0400 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 B6105C0613D0; Thu, 1 Oct 2020 05:28:24 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id k13so4365489pfg.1; Thu, 01 Oct 2020 05:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ypqOHrjRHTrRjWj0JrpKHgXr697RC6F/PNYuZQnGfKg=; b=uD8CXQZdzmDCEwzR8gXof/EZqnW9HM5+NDbk8JtZCj8WkwAaxxnZK7jCKvHoox3Cgv o4blxFzlUCoFhAaWUgRoWnymVNWSLY4de9HnYhOHIGjeX+IXEuGtM7ikCJ2I/H1jvVb4 gDzdLwMMsF293gOLxQqug/womCmgxYrbjbHo3HLsB0+apfAa59b0b2oZynJXL3sNuFsf LqKIJjoE+Nwj1brTGFCrzTQIjXRhJcpn4MEbfWH+4Tb7Sjd5PN5dt4mg6I0E4d0SyjSd GdtP50OsY342DXUasAaWEVCbHT4dHCuDDfduYrTCSYqf8j89m3vaO1+u4E2YkSms1l9q 82Ew== 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=ypqOHrjRHTrRjWj0JrpKHgXr697RC6F/PNYuZQnGfKg=; b=OQA6tv2cTvWN1+8bBpdyzfce6ZGH1bDOdEU0/rTtM1hEVcVMVK92IiGoMuN7snqJq6 V/zY3riJp9yZgZZgZdwQU0mA3RXkJpf6t4XZZLuhFqQhUY9sNl1BlwwohXdseCENEZBy QnZS8DVXyKEyS65xvFgLVyjXYecS34eLdbL0ZI7hnsLOD4AQMDCannDq+em/FxK+v5mH MAGx3s097QQCUbMbZGLy+lrYY+VpFlIq3j8n8PwdjWNAomK57zKsqGdrAEfULL/6F5dz VoU30JpOku8VcqZwgIzxcGBhktnmQW6hqOkvIEWRFhck/3KM/oCCVHDhe3+6NTtlYOy4 FK2A== X-Gm-Message-State: AOAM530oBgUmWRstr7bu83EEN25IZZOKMkEZ2QYT2pIvSYl5OJNqWw8y owkZE4s3Mds+LKkcDOyAyiY= X-Google-Smtp-Source: ABdhPJwBz5U6AswbiGknT4A+/BI8h3JQ1UevL5inKwYxlFZqbQj2tSMJL/mXdP6Bi7sF+EQXX6cAXw== X-Received: by 2002:a62:1542:0:b029:150:e3f5:d8fc with SMTP id 63-20020a6215420000b0290150e3f5d8fcmr6787347pfv.66.1601555304239; Thu, 01 Oct 2020 05:28:24 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:28:23 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 04/28] scsi: aacraid: Drop pci_enable_wake() from .resume Date: Thu, 1 Oct 2020 17:54:47 +0530 Message-Id: <20201001122511.1075420-5-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 a308e86a97f1..289887d5cc79 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 Thu Oct 1 12:24:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B9C5C4727F for ; Thu, 1 Oct 2020 12:28:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A7D121481 for ; Thu, 1 Oct 2020 12:28:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G+ygD2UH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732213AbgJAM2g (ORCPT ); Thu, 1 Oct 2020 08:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731946AbgJAM2g (ORCPT ); Thu, 1 Oct 2020 08:28:36 -0400 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 791C9C0613D0; Thu, 1 Oct 2020 05:28:36 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u24so3942428pgi.1; Thu, 01 Oct 2020 05:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8kLo0gZF2UOxlz4SENenPZS/3x2aIQArUFdn3IjxG9Y=; b=G+ygD2UHHwE9QZJ1oE1FgDI12pyXUUyL1CzamuZ70w/mrL1bysB4o1u9EpLtah7hyJ jXwC0S4A+Zeqty7/8Hnn2Ani0rKdSzkhWXcasGcfwvckdnqhoOPbSbxVr0kvv5osCH2Z NjT2eJy3RVOO5Tm6hVQqEQR5rxEcPGL4lWNsqQ280jE4qLXmaPPbU2EYJFMps1IClVqT FF+zazMB6unFU5pkwVm2rrs+ioNrXysIjVBqToVAJmjlMMW3p5fsmE68PSd2PD69HmE/ 7gEtPgNw1x/vrOW42dSIaeQ8cTb1BeiKZeuXeFKbVsDxSAWJY3VhMwtKAOFwESGws/Tq ZaUA== 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=8kLo0gZF2UOxlz4SENenPZS/3x2aIQArUFdn3IjxG9Y=; b=gj9qgrL+Aequ8jFRysVVnyHX2+eOXcqxSB1dacFYYKIUVPgq8MXv1oeO4rfRz46Tbt OAOIwT/6aNvFLPMnbRictiyL9MxId01Nto1NPwseqkM4fXTCplgM07JdDTdKKg4SoAGc 7DceYAwbOb4Q7mT9hK1INrDnjTlxiac+fNO7HVLJVGt9T18xWjKDpB6RkiVBOu2X/Mq9 1wqb1j+C+quqnutRPGe4JPI/ouFm9oXGsiBuzaX7SaCEKsw0BwtIls3yk2Gk5dhHzFeF yB/oGzEZ8wlAjN0Ecu3j+S1JnnUaCbtz6ELVm3xn4joKZGckM4W9haVkQO0+hLlP7Y3t Ue9Q== X-Gm-Message-State: AOAM530odC/aNfqVpD9tJ6YydkQvNhJSLUQIUaeNLcOe1PFohovOYlIO b7/Ef6tfPec5+AVHv35zF4c= X-Google-Smtp-Source: ABdhPJygIiBhJ8/JdESriF9fL7Ps2GK9iJhtR+3q//LmPe7qK5BFguWcEgPqIJXgifk1kqiHXDCTbg== X-Received: by 2002:a63:2e42:: with SMTP id u63mr5960797pgu.292.1601555315957; Thu, 01 Oct 2020 05:28:35 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:28:35 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 05/28] scsi: aacraid: use generic power management Date: Thu, 1 Oct 2020 17:54:48 +0530 Message-Id: <20201001122511.1075420-6-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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/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 289887d5cc79..4740b7afa612 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 Thu Oct 1 12:24:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BC1BC4727C for ; Thu, 1 Oct 2020 12:28:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0B9121707 for ; Thu, 1 Oct 2020 12:28:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PBjWADf9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732273AbgJAM2w (ORCPT ); Thu, 1 Oct 2020 08:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732213AbgJAM2r (ORCPT ); Thu, 1 Oct 2020 08:28:47 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8949DC0613D0; Thu, 1 Oct 2020 05:28:47 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id b17so1797371pji.1; Thu, 01 Oct 2020 05:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yhtxGQNhK3T+ylubBdKrbNFuuXsZgQN7Noq0oMcBTh0=; b=PBjWADf9OOdDW8zANSU9jYd8H1IdJK6NxqrDX3pIRw8DWbjl1Y7iEaYxwkOSlurf8a pb9OfF/HDlXFfEkvWxWqImA8qLd1QgyRY2J/H/9Nrg6NokbvD3e+S7I5cluK7/fsKtzn JkrhAq7QjaIzxrCnEVTT8iWpoyaPrOMGf7JhfaJVJPTVD3BeDLcAq3SrVHzxRSN27OjW Ib7rcJVur1BULj15lkN3Zqkva3JksCuUB2X/F9YMbEy77TuNGwKeGK47i2xvPTw37QO/ b6d7P0UiZVz5DR8mnvLYa29JY0aZ35dR+7vOozDn0yXRGlbVu3BtOS96xnjZsTR0sH0W Q4+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=yhtxGQNhK3T+ylubBdKrbNFuuXsZgQN7Noq0oMcBTh0=; b=mDRdgaPLZlPEo2aOkBCE8GL0jiXJjPw2TzQOZ1cPYpkIY8fFRfy3p+2s90am1qT9UU S+3NqKcWLRRtznQUZ8lfC+9URtR2LYUlA5w1nkYn3HmCiuGGGqr3Hj+fJ/2bmxsOiqFY ibgCcWisCsUC8xm2vdXRxSvkw6eUHMg5Dfi1olzBf4yHTzZ73uy+yRUPw2fjsB8eEQPP ymTxlFJt/kewyl7xxZ/Ofy2o99NdF/ADZvHtgBQar1QXM/kWWaDvmpp79SJ1xZuiILQ7 aHUW1bnQZdLcLU2oEoDY126r8SviwdwQatYMFin6quuAC6ffbrSC6iXe1nk+C0uY4wr9 Y4Kg== X-Gm-Message-State: AOAM532zIvRSqwmzpXL6Cdc8L03qUVQL/clnXlR5ttEFFWit/V2q5MLC zsBt3Aq8XqF4gc2UR24sI/s= X-Google-Smtp-Source: ABdhPJy4WZOnKwQ2uluKVwl6UQf4C6g3RJjYnCvHofT0UdvgSQwuV+Vz3bw7RmpfA6IO15g1cmWOhg== X-Received: by 2002:a17:90a:62c3:: with SMTP id k3mr5218829pjs.157.1601555327058; Thu, 01 Oct 2020 05:28:47 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:28:46 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 06/28] scsi: aic7xxx: use generic power management Date: Thu, 1 Oct 2020 17:54:49 +0530 Message-Id: <20201001122511.1075420-7-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 3d4df906fa4f..c7eb238a9599 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 Thu Oct 1 12:24:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1096C47420 for ; Thu, 1 Oct 2020 12:29:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61D5321707 for ; Thu, 1 Oct 2020 12:29:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GR8utQ6K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732242AbgJAM27 (ORCPT ); Thu, 1 Oct 2020 08:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731952AbgJAM27 (ORCPT ); Thu, 1 Oct 2020 08:28:59 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E7AC0613D0; Thu, 1 Oct 2020 05:28:58 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id v14so1787367pjd.4; Thu, 01 Oct 2020 05:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mVOjXEKkfZyVO1Nq7xgMnj9Ub/DFSexPEpxry6WmpFc=; b=GR8utQ6Kl0t0pzV+SidY8CU1m87lKEvg+HQ6OMuHmDLX0hfhHYLNWdTbltLemaEGO7 stOH4lQNsrpTMsvnpTIEle0bbqA/hGO0MG6BxSe4GyT19dmG4JT79CPT3Z7A28Qsjfk3 UVSMrDiPwYi7n48VyY66YDybpu0Zx25AA0bOVDFVPeCv1SfpDng4xYPxtbZVCg1RTEDk PTsapRjJ37CQZSEIwpO40Y7l5/pkjN5+ZVChWeAEzeqJs/YjuyKFgIuaBXgGEqh84KFQ PJf+eR/qnCJ3kG1Uaxq2R2VvwDMmX1ueWR9ZLG0fkGwaqS8qfle/zt0CX+1fiIrUt8FB lwCg== 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=mVOjXEKkfZyVO1Nq7xgMnj9Ub/DFSexPEpxry6WmpFc=; b=QVqGGW0ZrT4YMTwUgDSccMtXaBk2AfCYzQH7Y5PfYy7xuxa+pE9Cy52FkkeyqZp9Zm TFGhXnPo0IpgO6NmyaoyMDNC0HSZ9rMgexhvM+tN42ZkAG95vnzsr6zavij0gBQEY5Pn FB8db3PBDy02D2Cu4/ZSgBo9a1tLj0AYZySvCEZ3qHOPwuP9QwplQzYnf/Jt/Pvcg9H1 4Gn058pva4THZyv4ZjNIYprVzf89GbrP0fUcNEZmBHUGG/uervi+pX2rUXzPBzfJCuWA cqNjlzcSXXlOci/rusx9EPa2i+EzTjEFheiqOldwtTGEhkgpfY29lycWVyvfT2Zz4GVt 5JjQ== X-Gm-Message-State: AOAM5300mhf0KEUaBu5aJC/EPej8ZJwgJObfyNrfdjh9N+Yy2J+zzwWp USnfT8VBr2xrC5fKrJo9FCo= X-Google-Smtp-Source: ABdhPJwjjEy6svQpFdYpn9f4L4Tzu+FutlqW8hTSvgj9ExQD35LeiMkVBZJFqbliBzWc1yUOi3OjdQ== X-Received: by 2002:a17:90b:ecc:: with SMTP id gz12mr6649534pjb.219.1601555338113; Thu, 01 Oct 2020 05:28:58 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:28:57 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 07/28] scsi: aic79xx: use generic power management Date: Thu, 1 Oct 2020 17:54:50 +0530 Message-Id: <20201001122511.1075420-8-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 e4a09b93d00c..06ee7abd0f8f 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -7880,11 +7880,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) { @@ -7895,15 +7893,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 Thu Oct 1 12:24:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A0AC4741F for ; Thu, 1 Oct 2020 12:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EDC220B1F for ; Thu, 1 Oct 2020 12:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MRsd2Wno" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732273AbgJAM3I (ORCPT ); Thu, 1 Oct 2020 08:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731888AbgJAM3H (ORCPT ); Thu, 1 Oct 2020 08:29:07 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E098BC0613E2; Thu, 1 Oct 2020 05:29:07 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id j19so1886625pjl.4; Thu, 01 Oct 2020 05:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nFScM+arNxRtQeZvbbAHYBWlDLtA4fLReR+nPVgLlBM=; b=MRsd2WnoH84TSpfdS0xsAvvPKUvk+hWZ2jQyWrlHyJno4rRc/WvqtEJNAREGXx8lpc /aCIT/eymCmbHgVRPLsgUxGj6G8VePygO3I9hpnIBR++cdiovm6tHtXu+JXXLlKCL0xX mdPMbym0b+f4+UI7k89TE1GdFB57FAS9jxNNZ6KjQNV/tGEIItv9SeVBRVP13Jqwkunq kaEVvQVpvesS6iUFLdoLZzp+PWvlHcKTl8HXXadHCnqSUZFd2BgdSS0lpha9Er/EIFkk KGhmBW6jFGZ+srVHjpVRZBT3KuUsqIZ3x5TmeSFQrxPePp5t7lYj2SFjXJPncs34uTlD +Y5g== 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=nFScM+arNxRtQeZvbbAHYBWlDLtA4fLReR+nPVgLlBM=; b=BXDBgChYU+IijkwS60m2SfxToYQ52E6/UQPZccE8PelWNOkih5q/ahSwYMAKDe93dw 7CPxP+YUn6o2uAwquDamzap7yKwQdGYQegzEnWQANMM0pc1HqYFAXxiBogSbYg73UQ86 Lf2m/IQx5DBiGa31LcS+NXd9e+rPdfOLW5HBzNzUa8QatAnh/7c3P4GjN7l3E9O4/MKv DAobW9MPOQVFGu6EXGrFKq4CGV4CRWd5ZlIjHQ/KplkPbA/DaG4n7HF+B1J5zCQqjH9G 9DXdWe6mk/WJ0gKsvIhWqRCKeAwYivz2t5nq6rPEWoTFL4+HjMN0oWMd6T7LPujGA9Qs SGYw== X-Gm-Message-State: AOAM533v5fdZnZzmoq6jbPMCXPH8pLrDNkkcDGh7XTDnuCUGtgG15k3s adwNebqHR+ii2JuxDToLCj8= X-Google-Smtp-Source: ABdhPJwQJMPHi93RFnwt6p0B1nWePCTdTn//Wk9AHwIXspt4V69jOm3D2hO/uhuP3PPE6FF1Js5Dgw== X-Received: by 2002:a17:90a:bd0e:: with SMTP id y14mr6924794pjr.58.1601555347469; Thu, 01 Oct 2020 05:29:07 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:29:07 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 08/28] scsi: arcmsr: Drop PCI wakeup calls from .resume Date: Thu, 1 Oct 2020 17:54:51 +0530 Message-Id: <20201001122511.1075420-9-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 30914c8f29cc..6ed2ad10bede 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1094,7 +1094,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 Thu Oct 1 12:24:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A464C4727F for ; Thu, 1 Oct 2020 12:29:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C0020B1F for ; Thu, 1 Oct 2020 12:29:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eEW+Bq2O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732313AbgJAM3T (ORCPT ); Thu, 1 Oct 2020 08:29:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731888AbgJAM3T (ORCPT ); Thu, 1 Oct 2020 08:29:19 -0400 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 46CA6C0613D0; Thu, 1 Oct 2020 05:29:19 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 5so3925007pgf.5; Thu, 01 Oct 2020 05:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gmS7YS0DYtnClD0w40MsdNzZxacHM1ziMOHmrUQ2hbc=; b=eEW+Bq2OFiAcFjiQ/Kh6k50Y+/jrfCr5zJgWHOXUF9hUA59/xEPLAC5NIH6AcsJBMX BDM5+3mWvmHQZpeEMRBTROgyKQ7Jida8YlMzGvfIr2M1+O7Qcy6+udFsjda+DF+B0FlJ a7k9ZIDbJgn2wWQSo/gHKzibWDxWlBAUTg9N5F9uNfEGJURBwfz8FL/ogjHqkOT40L3p t5OhMhSR3Vv2A3Inm8JLsOF6VmgbVWwHMl7/ozsy8H3cccXX5fZA4E7wO+/3r/JABzjE N3EBLbeNHJVkX5vl2hmg/XpJJN8f5akAJ5CEneJr/necgvUzjo01UgBRkG70MAjprecp weuQ== 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=gmS7YS0DYtnClD0w40MsdNzZxacHM1ziMOHmrUQ2hbc=; b=mYqFq9KVqhcjj2zP/Bf4IumAT8Q87YIFS9yARKdZ7yp+5VC87hKOzIv0ZA+45xoIrH Q2mMyq9Q6tG6ibPZCUZvaHBEfRzz+rxt5cilYyZLOwRmXZp0w6zu9kRavnS95CM3Tzn0 Uw0+PN5Bv56FESiwy+i2BMV3mleJnj/S6HpI3YEB298dLNfjDoEJYM60z/WrXkpXXvbm etd6xK44QRiezNR/lhPB1izlHAGA9HvfxJXxdjNMpiJkYJgAvFOoRsApquTKCejHdHt0 lOANqmR3fp6/IYpPnRLVwANOIQLVMyRXl7OZoCSziTaa+t2HE7FfwReDMNfxMtrt32o1 DlTQ== X-Gm-Message-State: AOAM530AVr5FZrWfiAqEKxIzxElBk3HlEUOwd2iQ+nC1Ags2ZscbI21K GnZn4IUQXrXE+T7dydAM3Mw= X-Google-Smtp-Source: ABdhPJwLO4BrCq7cf6OgUMx23vEZaXY9wyYutL8lxvt8uRhaE9u6WKIypSkdMK4htyWuRqaw/lpc+Q== X-Received: by 2002:a63:544a:: with SMTP id e10mr5895346pgm.284.1601555358804; Thu, 01 Oct 2020 05:29:18 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:29:18 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 09/28] scsi: arcmsr: use generic power management Date: Thu, 1 Oct 2020 17:54:52 +0530 Message-Id: <20201001122511.1075420-10-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 6ed2ad10bede..43848b467d8c 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); @@ -213,13 +213,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, }; /* @@ -1065,14 +1066,14 @@ 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) { - uint32_t intmask_org; + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; - intmask_org = arcmsr_disable_outbound_ints(acb); + arcmsr_disable_outbound_ints(acb); arcmsr_free_irq(pdev, acb); del_timer_sync(&acb->eternal_timer); if (set_date_time) @@ -1080,28 +1081,19 @@ 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) { @@ -1136,9 +1128,7 @@ static int arcmsr_resume(struct pci_dev *pdev) scsi_remove_host(host); arcmsr_free_ccb_pool(acb); arcmsr_unmap_pciregion(acb); - pci_release_regions(pdev); scsi_host_put(host); - pci_disable_device(pdev); return -ENODEV; } From patchwork Thu Oct 1 12:24:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2A11C4727F for ; Thu, 1 Oct 2020 12:29:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C22FD21707 for ; Thu, 1 Oct 2020 12:29:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ofxvab+g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732052AbgJAM3d (ORCPT ); Thu, 1 Oct 2020 08:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731888AbgJAM3d (ORCPT ); Thu, 1 Oct 2020 08:29:33 -0400 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 EA3CCC0613D0; Thu, 1 Oct 2020 05:29:32 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x123so4334898pfc.7; Thu, 01 Oct 2020 05:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DZ7mt7sETAYntydhqj7zSY8Hb/mTTvO0FCNgup4L184=; b=ofxvab+gDa9g6e3GCmRNtAWmZgzvGNWvNibyvC7rraADmGTq1B3cETmqA1yEwb4Sjj d+BAlu0Zu26l9w05vCkME9kjZLJkbJ+2T55OZtnVF2Eol7At2NE7DKjUKkvBw9Ua140d Qqlb7u9ZSdyD71hLDUzTkMatHSjZmUdkcCrvHrEmwziPJ778n5dPexVUisZWxDERkpZ0 dp5H610n+2VZ7CKg/dLkPTI5M8cY0cySZNtgI34kn65nWzAtT3GBxRjGfL0DAhYABm3M lOyvgh3DPdJnkl+AMxiXbe+pbrjMX4jIfDZ+r2nbgetiAhAGOVJ53H/7JREN8iJ6KYwu Id7g== 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=DZ7mt7sETAYntydhqj7zSY8Hb/mTTvO0FCNgup4L184=; b=UUFXfbgfsXzAdsHM7f1QJhi6OVs4Ov5YTA0v3XP7WIT3OumFnjmDB8qA1paZ2vKybv HteuyAkpyXvB5YZIpVk8eDf+8qErB6sHO3LwBpIBez8Cll7OgisWqEu8pBU7EDCGeXC2 ApOW0+bD6sSR1i3VheaU6fGLUNXnr7Hg3w0KuDnylsa4g0MCrqx52L7hgHIIOHOtZIpt sWOI4bQNk6DE3wo4cLzz9ladQF+MEpcQ6lMzMNeb7mJceKCNnvv2Y8M2Hhblit2HOCOr CayiB4A8kKKym2bL40/P9/zhngp/x0b+c+TQPd/otjb5UUz3jXsH7ltno5fwK0avpTjB TsNA== X-Gm-Message-State: AOAM5323XdOead9yoHOimVpFAwgsOsVF8PIHtGlQHYp8laPTDIx7M2WM g/ZV7KUjfpIrZn+dwilE2KI= X-Google-Smtp-Source: ABdhPJwYFX9JzHaMbhHVTN3co8ODVcF0d4NZ4tbbKgJM0ztwTs8zXOSTqSzUZ9YqbBR0AQLE2XU7ag== X-Received: by 2002:a17:902:a3c8:b029:d3:781a:15d1 with SMTP id q8-20020a170902a3c8b02900d3781a15d1mr2470367plb.0.1601555372488; Thu, 01 Oct 2020 05:29:32 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:29:32 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 10/28] scsi: esas2r: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:54:53 +0530 Message-Id: <20201001122511.1075420-11-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 eb7d139ffc00..90bc3489964b 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 Thu Oct 1 12:24:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B758CC4727F for ; Thu, 1 Oct 2020 12:29:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C65D20B1F for ; Thu, 1 Oct 2020 12:29:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ynw4vNSw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732312AbgJAM3n (ORCPT ); Thu, 1 Oct 2020 08:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731888AbgJAM3n (ORCPT ); Thu, 1 Oct 2020 08:29:43 -0400 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 8BEACC0613D0; Thu, 1 Oct 2020 05:29:43 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id s31so3925911pga.7; Thu, 01 Oct 2020 05:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=myfhugrrkv0aDEdYCgYP11ATu35KzXWAY+Dl3giNZCY=; b=Ynw4vNSwrPMXOQXuozN5l7J/dx8FjDMUhnYrzZMwYofxkySKCqe2dCaGsMwiyKUxqr VR4PG9EJRl6i0R87X/GGQ7kxmqvGy4bJFi0Kmk3iY4vFe77rn30pF9fWFgcs09rDJT2v yXOQ7evG/5Ua0FpdirrRgXWBJQpdwugrQ/BebxA0PU2qjBJrfzgvX+0algpuiQRQBxyC GopickCUn9S5Jak3UzhJYVZliwAoUV+aH5CE70JUdqiWBMXz+WGC+pHniq/N0vanyO08 PhkQ/JqrD26topnez2NRweMFLh8VaY99mjP4QcYa+6g6OfUmNl6djOuYYoteFiVolcNK QJAg== 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=myfhugrrkv0aDEdYCgYP11ATu35KzXWAY+Dl3giNZCY=; b=FRodU0UJKVZUnaVUAwppk6MsY8vmrNWG4mb6tuVUqYvRHm0vUbXVe+8l7wfzqjJR6p 4tVl+63Trx/UPkVcdLJBoQk7eLdFJsIX83qIiuFLta6xc30yFbLSJldCqXb+a9F/cggt f67cCUQOpLUCHW23RzLzyG7G20b3oxDZWK6gOGXLLsr+GxdymKGT0iIR9nUEkV1mw8tq 882/esBiF6RD+guo/oXJ6ESBwxfEAuNXEqhchE2JpcKMI40aafkOvlj3q04fK0szj7VK k9D4HYtbQOvbn436QEs1PIa5n1esJj2oFey5w95UD5y55MNyyk/cnmFxUrATZjIQQgPQ G98Q== X-Gm-Message-State: AOAM533nwnwtBRjA4QGiiMP6ZNFXUomwgFWgwHt4F3MWgL1szK+eNXh2 vDWPvmCwnrgH7ybztklJpC8= X-Google-Smtp-Source: ABdhPJy2flIto3LrD2kgbvoK+WEbGAqit9JPlOlT1LIXRYdWXUoQMItkP3OhFTO4T4MvcHacMCU8aQ== X-Received: by 2002:a17:902:dc82:b029:d2:8cba:90d6 with SMTP id n2-20020a170902dc82b02900d28cba90d6mr2500939pld.19.1601555383075; Thu, 01 Oct 2020 05:29:43 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:29:42 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 11/28] scsi: esas2r: use generic power management Date: Thu, 1 Oct 2020 17:54:54 +0530 Message-Id: <20201001122511.1075420-12-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 7f43b95f4e94..6ad3e0871ef0 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 90bc3489964b..f6bf76f49d15 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 Thu Oct 1 12:24:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBDDEC4727C for ; Thu, 1 Oct 2020 12:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B479021481 for ; Thu, 1 Oct 2020 12:29:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gjmVpbBd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732075AbgJAM34 (ORCPT ); Thu, 1 Oct 2020 08:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731888AbgJAM34 (ORCPT ); Thu, 1 Oct 2020 08:29:56 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EEDEC0613D0; Thu, 1 Oct 2020 05:29:56 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id l18so1896619pjz.1; Thu, 01 Oct 2020 05:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RBZwp5x8UpGlk91TPxM4Ak8snRIr/reeIn72JiuDlp8=; b=gjmVpbBdrYV7W4vnPwxhllWyqLusqcAZ95Zx+Zd2FmqGRG0dCvxKZgF2FMcGXMJSH7 vJoYsygMlkhCkudEegEdKdzXOEsUAPlfx0TqtBJCvCbcmLxzZ7cN63eHbzHmxd22janf mDL50Y9AgI7urwsCvgjfaeyddJ/12zOPntDQj3eSgwmFYm4XVrXQUujluccrOtX6fPOK BxTXuM4up0uq2P0keKubWPHsHHWvH0Jw3tfOeYtwa7QC2Go619cdQnRIfMDJjmSy+IOG G2xuxyDnWt3cXVJVOrRA1NkRlvF4s1rs4skM9h9i5LWySTvIcwn4AH95EhxX+WKQZnph Zs7Q== 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=RBZwp5x8UpGlk91TPxM4Ak8snRIr/reeIn72JiuDlp8=; b=NBiOnTmCsMAbj4FDT41vgIulrfHPA/SvJ1I299Qr9AsyZbxFZ4y1Tk6XzWnNK3LFNT Nd029oPut7LswqsSfsaIgrZ/xJFE9VoBpYYabsoqo6AF7DaVVWjA514EHOliKi1V4zPW YOJNC2jXr061QB0J5Me2NDedOi9mPbq+l5zd6msM7l7eIVT+Rlt+6O9H1doLTL2442XK g62xu5hgEQHJR2MsYTbAKXj9DDwpJUkO7uWsIynjHcOJGh1MWXzXA4M+713lU2+jIQwi b/+Eqi/r/0Eh8SJv1oUbDIJKIyyw8EVOEvHz+ZGOEmUXon02e1iBM8+xORf53jATCoBq tStA== X-Gm-Message-State: AOAM5335wJjIVjiXkiQExKfE2X/umMtpsHBSBkjuDBcMDJbaWv2b8HiV b46qVKbX+RBCDbsAsZHlJmM= X-Google-Smtp-Source: ABdhPJzlzAVFo+0pMkVbQhAIpkRbYBfJ7ypPdOHOuQMuDNfriSdjUytOJ3wyeXymJmbNtz8f8xsmww== X-Received: by 2002:a17:90b:950:: with SMTP id dw16mr5141541pjb.200.1601555395535; Thu, 01 Oct 2020 05:29:55 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:29:55 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 12/28] scsi: hisi_sas_v3_hw: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:54:55 +0530 Message-Id: <20201001122511.1075420-13-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 55e2321a65bc..8f0f4084a054 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3431,7 +3431,6 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) 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 Thu Oct 1 12:24:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6D26C47420 for ; Thu, 1 Oct 2020 12:30:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B92F20B1F for ; Thu, 1 Oct 2020 12:30:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ajS/f1/Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732334AbgJAMaJ (ORCPT ); Thu, 1 Oct 2020 08:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731888AbgJAMaI (ORCPT ); Thu, 1 Oct 2020 08:30:08 -0400 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 96FF3C0613D0; Thu, 1 Oct 2020 05:30:08 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id k8so4359015pfk.2; Thu, 01 Oct 2020 05:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F8ILo9F3hOuAiWCSF9VP8lcH33lMFOWB0JB4FepGoHw=; b=ajS/f1/QOGhJu7Hm7zXDe4wRl0ElgGA5K3TaNcrUSzXQNopdfqtSgRJArv9LL+cWFT u/gHMiPQqyBmVdVk4Ex3axgmIAnCvlFMvD9NNGhd3w76DkYPmiyNz5igixD214sh3Pyq LE8EQO+cKU7qoCPicvO+n+CmdZvNP/KDLGEL836TuvkyUYtH78CViZf0mvXbG1BE4Y6x ZGWAE7G8Ibv/zQiE/ZhWJGBanNiTYb8e8l2sDuC37QH1mjzlalljv1BWR5lwYaA3Jujs FoIgPC2cvC7y/Bsuxjk38uODZSCbdpz1Qx+Ge5jH1/LEtfytYj+Zg7mfysPMKuWLaOHV Tm6Q== 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=F8ILo9F3hOuAiWCSF9VP8lcH33lMFOWB0JB4FepGoHw=; b=bMPxBdmrATx8Pwsa4gmZ6t1MfR27AWSytdV0jRvU0PQ5qKK7gsSuVMAFY2WRjaqtEV XlEEx5cUjAilKL5Bihz5rKXCSc3mGDZDZZ/MSJLgJ4nPzCn57BKvt14lUmSme2YTyfXl DbEIbTzktUb3ewPPkp0PcbRkypbvs2RKtxqacs066OL90bWx42NRsok93M4zea7S2lYu R/qaySpOsNylq2IX4Sqm+FnF363FUb3D6+MzbFSL+8ckflhfOLViD21R43cxFi7AGmop 2H8RuQrq6J3ceYy9UKcmc6iBq4DrH4p+za8kFHd4M4Iguxeuu13hsnj7sYJK9NniElqo 8kqw== X-Gm-Message-State: AOAM532kk2jTYRpwfxf9/2GfNa6Ze8bZyuwVKet8HRYTF3QyZBACd8hk 8hEAKkoJjvmuA6h5H0FSIuo= X-Google-Smtp-Source: ABdhPJwWTj+c4zhPxJxBu5RLvuvcwrNnzC7eEEHwrr31ec/sCEh3mqzLFvRvjyV506wuR8QklVu2ZQ== X-Received: by 2002:a65:5902:: with SMTP id f2mr5718129pgu.379.1601555408153; Thu, 01 Oct 2020 05:30:08 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:30:05 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 13/28] scsi: hisi_sas_v3_hw: use generic power management Date: Thu, 1 Oct 2020 17:54:56 +0530 Message-Id: <20201001122511.1075420-14-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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/hisi_sas/hisi_sas_v3_hw.c | 30 +++++++++----------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 8f0f4084a054..98b1848aabe7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3374,13 +3374,13 @@ enum { hip08, }; -static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused hisi_sas_v3_suspend(struct device *dev_d) { + struct pci_dev *pdev = to_pci_dev(dev_d); struct sas_ha_struct *sha = pci_get_drvdata(pdev); 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) { @@ -3406,12 +3406,7 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) hisi_sas_init_mem(hisi_hba); - device_state = pci_choose_state(pdev, state); - 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); @@ -3419,8 +3414,9 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } -static int hisi_sas_v3_resume(struct pci_dev *pdev) +static int __maybe_unused hisi_sas_v3_resume(struct device *dev_d) { + struct pci_dev *pdev = to_pci_dev(dev_d); struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct hisi_hba *hisi_hba = sha->lldd_ha; struct Scsi_Host *shost = hisi_hba->shost; @@ -3430,15 +3426,7 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) 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); @@ -3446,7 +3434,6 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) 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); @@ -3456,6 +3443,10 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) return 0; } +static SIMPLE_DEV_PM_OPS(hisi_sas_v3_pm_ops, + hisi_sas_v3_suspend, + hisi_sas_v3_resume); + static const struct pci_device_id sas_v3_pci_table[] = { { PCI_VDEVICE(HUAWEI, 0xa230), hip08 }, {} @@ -3472,8 +3463,7 @@ static struct pci_driver sas_v3_pci_driver = { .id_table = sas_v3_pci_table, .probe = hisi_sas_v3_probe, .remove = hisi_sas_v3_remove, - .suspend = hisi_sas_v3_suspend, - .resume = hisi_sas_v3_resume, + .driver.pm = &hisi_sas_v3_pm_ops, .err_handler = &hisi_sas_err_handler, }; From patchwork Thu Oct 1 12:24:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9580EC4727F for ; Thu, 1 Oct 2020 12:30:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C36221481 for ; Thu, 1 Oct 2020 12:30:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LLG7rUs4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732114AbgJAMaU (ORCPT ); Thu, 1 Oct 2020 08:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732075AbgJAMaT (ORCPT ); Thu, 1 Oct 2020 08:30:19 -0400 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 24ED7C0613D0; Thu, 1 Oct 2020 05:30:18 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id f18so4325369pfa.10; Thu, 01 Oct 2020 05:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BG4V+85MuR6ufcPlMQYJVSkjLvahD//hnAYu8ukq0+g=; b=LLG7rUs4ONQDZHwO3toTKM1EzjbEMOaBcW6uAevZ94Y4Gr+jAUC85f08QFUy9cA+Gc NheZRLCYCyoX21wZ1deAbsThK70Ze6j33cllDlN/m5pHVcpfH0icwbVsQOFSKrm2tTrO sh/gb0JCSXdwN8kcIaSO4cSIRg/9IrdrUWYNmq7czfoRs4UAfxa4MZB1ht46IA1Q6yBN vyIKETbYfjkk8RN6b2pS8/JiFSGGzg5KJM9M7J7WBR3AnMX35mLAS8yh94jeGyG1rwWQ vjjYDXf1PDodKLGh1JeVGjS8eKrBpBzIWKGPQO0/KAduiet6kMKbvHl15z13Te/GWaCB HU6w== 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=BG4V+85MuR6ufcPlMQYJVSkjLvahD//hnAYu8ukq0+g=; b=WONQ4tpj76dGWEtswAjZdcunZ+qagpcZTXk6letaq9lM60B9aIvfI4+Rcfp0DUF457 Yx4m8TI4NZMHt/A25iElh7OOiEZWbpvwWoNqEUVqLpcq2Hq7Jh+3MIL43xVwVh7dby+w VR0twchisyHqMIYBAQOQWBS4Z4/WFriuN7+TlCHr3zGEdHRI3ORvHYf6r+NW65WiDK31 TvbnyiPA5nDmo9+ic8U3SnlSboJTezqsA+zK2LNL/vXcFnmckEgpG64XiIJQzJ4EPbY7 3Oy74uQ+Xu1m33yIt1zdnxQ2biVGpJ/MjPSrIbljVbmEips5EaIe3QVKW0M0EQJOolyt yv9Q== X-Gm-Message-State: AOAM531fHUK2b30kNHtEyxinUFzqhsfHVp+oqBZLSrtLHmJVAqENQciY zHXeRU9jfe3BoaHznoDylLc= X-Google-Smtp-Source: ABdhPJxpcLkoQM3qv+xaqbCqBU3lTkKKGRDya6S4p4gMIwqTyelhPUWUE2zNe5Z5D9JMzciOMlHnog== X-Received: by 2002:a17:902:ec02:b029:d1:fc2b:fe95 with SMTP id l2-20020a170902ec02b02900d1fc2bfe95mr7521409pld.79.1601555417670; Thu, 01 Oct 2020 05:30:17 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:30:17 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 14/28] scsi: mpt3sas_scsih: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:54:57 +0530 Message-Id: <20201001122511.1075420-15-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 08fc4b381056..ce3dfe26691f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10876,7 +10876,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 Thu Oct 1 12:24:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE29DC4727F for ; Thu, 1 Oct 2020 12:30:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7566F206CA for ; Thu, 1 Oct 2020 12:30:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IQQEPTYs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732178AbgJAMa1 (ORCPT ); Thu, 1 Oct 2020 08:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMa1 (ORCPT ); Thu, 1 Oct 2020 08:30:27 -0400 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 7E5CDC0613D0; Thu, 1 Oct 2020 05:30:27 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id k13so4370654pfg.1; Thu, 01 Oct 2020 05:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7rgufBpw93V8mG4rKsbALHUTh6KZISs0E2Oa73Zj8nQ=; b=IQQEPTYsZAyFdCQMzgShYX9XD3kMKT7z9vH7pMuIDi6Ei0TkMv+wM9MJedgCBQbbaB AbqCwrP7+a/XnWVlL/bj88wlr2pl/WQ2kmUOhQrPDFuNLVyGhlpxd/7/7fzjfNx2phEv ysK+Cu4vORuD71ieEnpxFyTzLncFMamyvDCiFiLTzz64AW72X8BbzJrkd7hY+rds91nC x5U5aj2F4s2F3wpyvYQT/v0ghNWIiyVNFkCKqXTY9pDxZ39B3bu9R3+zAWNr5/QBSiDK vG+KTSWYYxn2mUGxlQpxrCOyuVFxlczOjVM/GustJurog32TRjcnlxPUJG30C3/IDEES 9UFQ== 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=7rgufBpw93V8mG4rKsbALHUTh6KZISs0E2Oa73Zj8nQ=; b=G8sE065Lz24U9737imTu5gSUOMMF0uQ1psg1+YIkvH9mp5NtiEa6tx4h/xFdCJOBQc KXAvAZRLCFzflyXE/DC9m+vWTaWsI+rDixfZiDuwyy+F3zyXUMocfl4xvjQ7uEuqlpFV x4/8GDr+12p6YXxOMCvzQBJZCG5tCVpXR/fntvSX0w+jfYEY3T6grc1lrKY9r+WyElql C4gGKtGKdrjEbhRNa5Nr8apqyQLYsC91z9shvW6zDAr2ciEgDGRsBILOa76yAYiomEj3 mV0VJ8G07iUab6nRRXo8jtAFu/o7K5PGWb59JRTRM8tDHOetZIfHFYiDGXtrjZ/rS1sz 2cOg== X-Gm-Message-State: AOAM531hPV2QjULYnnLTfc7QmFdCkX5myrKIh1um3+J/sLU1OhgrsFLL QfdYW7ZA/sXrGU4Z+htTIDg= X-Google-Smtp-Source: ABdhPJxBsH7cHoNMekIO6E7c1Lz4xgNz6S5K0NhR5o6UOdEqCbv12kSwZbqhxobu5u1HFxuJpNwXPg== X-Received: by 2002:a63:457:: with SMTP id 84mr5936764pge.191.1601555426990; Thu, 01 Oct 2020 05:30:26 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:30:26 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 15/28] scsi: mpt3sas_scsih: use generic power management Date: Thu, 1 Oct 2020 17:54:58 +0530 Message-Id: <20201001122511.1075420-16-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 ce3dfe26691f..6691b7cddfff 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10829,44 +10829,40 @@ _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 = pci_get_drvdata(pdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - pci_power_t device_state; mpt3sas_base_stop_watchdog(ioc); 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 suspended 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 = pci_get_drvdata(pdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); pci_power_t device_state = pdev->current_state; @@ -10875,8 +10871,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) @@ -10887,7 +10881,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. @@ -11161,6 +11154,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, @@ -11168,10 +11163,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 Thu Oct 1 12:24:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98DF0C47420 for ; Thu, 1 Oct 2020 12:30:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 441DB20B1F for ; Thu, 1 Oct 2020 12:30:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n1UU20g9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732361AbgJAMal (ORCPT ); Thu, 1 Oct 2020 08:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMai (ORCPT ); Thu, 1 Oct 2020 08:30:38 -0400 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 313E5C0613D0; Thu, 1 Oct 2020 05:30:38 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id z19so4327455pfn.8; Thu, 01 Oct 2020 05:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IGW8IlJhbl6Nts1XfHuu7tbzn41lhQHUi5h+OssWiq8=; b=n1UU20g9aZqtKPVyZnbm/6f3LyIwyxC6ssLGhtz4yIabo0vn9HiaNEsTgAjht1HN8/ Ys8UHsJuCSUTlgl5dBxLRCk9rbGbX2lK12PuXfWsH6SzdAF2dunLnC7z1sAfHaLCLTx1 bChter5FcslJDKouBNb2gBJByg1mhKezv3x7htDGJa/KlrEgFWs1h1DBA9dcUHyVXlX7 cYq0a7s5VI5xr32SQzNWs24Qgmco0QAIQtAbTvVsa5v8Hft7HLSiV51G7U19mQEHBVcD NxbUHigWNn4bNaqoYOyAHficg38rgE0yxxt9Ut7W6efrOtZMDrAFrCll+7W3cKDTbL+K 0lvg== 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=IGW8IlJhbl6Nts1XfHuu7tbzn41lhQHUi5h+OssWiq8=; b=bGsHGj69K4HuB2q/w11C9bbdWd97Wtiw27gef17vsVpWTqBSi9GQt1Lf0pFTdJcUgj PmWY9/h8P7xnPbOjLX/9vbj++fdqokBfh5Wgi6GiH0Ndszsr3L4zok9Q9GB86OGcqE4S 6BgWh1eES00MqDymJpHJmZ3dbraIZepYr1TaQUp3pi9q6YtuT06CAtiME6Q9RUPtZHcY evHXqq6qNVILWlSRLwdsS6/ecp5+lXRf5J6nHkYRMnbbPQ0HUizGkf8Lj/Cc9r91ooT3 ENKORutMuLMQKwz9KBMhq4Wo491/KpCfdMO6YN0RKZnH0aJIrvuiz480E+CRGLao4ALZ U/Qw== X-Gm-Message-State: AOAM532SoakpYsshyVuSHOZSBCfcSckwZqhGXIWqBA9iJsV4Ro11i7sr ZiGc93HNJMRyNpPiOYYukKs= X-Google-Smtp-Source: ABdhPJwl/cN0ttyqrKyPoGXMsArUklgf5vXX+wqLEJX0rf0IAGcvBppfNXmaHtWSx16cGl+O6ySsZQ== X-Received: by 2002:a17:902:a407:b029:d2:2113:7f8f with SMTP id p7-20020a170902a407b02900d221137f8fmr2617062plq.70.1601555437595; Thu, 01 Oct 2020 05:30:37 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:30:36 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 16/28] scsi: lpfc: use generic power management Date: Thu, 1 Oct 2020 17:54:59 +0530 Message-Id: <20201001122511.1075420-17-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 6637f84a3d1b..a36309b48144 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -12452,8 +12452,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 @@ -12471,10 +12470,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, @@ -12488,16 +12487,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 @@ -12514,10 +12509,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; @@ -12525,19 +12520,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); @@ -13294,8 +13276,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 @@ -13313,10 +13294,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, @@ -13331,16 +13312,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 @@ -13357,10 +13334,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; @@ -13368,19 +13345,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); @@ -13696,8 +13660,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 @@ -13708,19 +13671,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_INIT, @@ -13733,7 +13696,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 @@ -13744,19 +13707,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_INIT, @@ -13936,14 +13899,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 Thu Oct 1 12:25:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 287278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E981FC4727C for ; Thu, 1 Oct 2020 12:30:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A59B020B1F for ; Thu, 1 Oct 2020 12:30:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UClizyI0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732162AbgJAMau (ORCPT ); Thu, 1 Oct 2020 08:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMat (ORCPT ); Thu, 1 Oct 2020 08:30:49 -0400 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 42D7FC0613D0; Thu, 1 Oct 2020 05:30:48 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id e18so3934128pgd.4; Thu, 01 Oct 2020 05:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=08PYeurcX5Vq/35NZf/krIMx9TNkE2AMAtJDR5OrRSQ=; b=UClizyI08VIm/vQ8nJqeIAbyEYMxRxqGpcI9FusZBz7DvsVF7ubCMQvbUve487fviP WVkSGVTBZgEnW2uqwsS2/nUzU4MJCNzuNvGBqzbLtgUNDl+gRAoigTtp1ujGLy5LVPik /NyG17ybIW2fvkdWYQWWgfdH/nBL7XXtU4FxHU1G9G344V6VFYGlMRFQW1zkBlP7C3Fs dxIzMfom1Kd8OoeolMSkORkB+cxShrLeYaNny2m2r1/6oK52SDi69U9JCLsAreMlGicF YZOvIPjoCMRNh9JudNtQkLtJp7Mv3Rw32vPomHMAnlFTowUAP+nYPRc43Tl/fsKYTCwH CF0g== 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=08PYeurcX5Vq/35NZf/krIMx9TNkE2AMAtJDR5OrRSQ=; b=HP9wOq78wc4BmyhrwhC3ybzRo9v8Rh2k0+3qX/kyxiH0qwWQAjU9gxLe8yIhz1wtfi UbCe7Vlw+b4UjzzfwuztvDvu9K5y9KFWqpHgswEQwPB83hAS5XrBSeAOa+IrDQVWfP8M uf53a01d7zGcdCnMFJo/I/wD1e2FhusYAISfpEnT+EUkxOctHo9bfP/9ttNwc+0d7oVS paiJVUtGyVV9jjIONbHeJVUlI6Yw7Bk+WdUlAxol5DQu3CoRYchVnHgsy+MN+VudGtqn Ej1VRfsRFk7/6TJmpD2C6zUnzUvzrxhpe/I2EPHBt9w0FzqZI4/xJJFEI/CHNe+Ppiwy TF5w== X-Gm-Message-State: AOAM5304mrAIZ4W0f2/YW/TIGCyVNnft/sKzUVuVIDj8mRGTNHcjpJ/W BOiQfMfnKw86Jv0WxrIHrek= X-Google-Smtp-Source: ABdhPJxR7bQaE+TCO8waq1FrQFlsa8qiJ19vieCYYeJwvWOnmGAIFrqiOfw1z33AhlDcElu7bocMWA== X-Received: by 2002:a62:19c1:0:b029:13c:1611:6529 with SMTP id 184-20020a6219c10000b029013c16116529mr6783201pfz.9.1601555447756; Thu, 01 Oct 2020 05:30:47 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:30:47 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 17/28] scsi: pm_8001: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:55:00 +0530 Message-Id: <20201001122511.1075420-18-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 9e99262a2b9d..ee27ecb17560 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1248,7 +1248,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 Thu Oct 1 12:25:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 257480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82069C4741F for ; Thu, 1 Oct 2020 12:31:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3EDD020B1F for ; Thu, 1 Oct 2020 12:31:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S4vxVY6v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732368AbgJAMa7 (ORCPT ); Thu, 1 Oct 2020 08:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732180AbgJAMa7 (ORCPT ); Thu, 1 Oct 2020 08:30:59 -0400 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 96EF5C0613D0; Thu, 1 Oct 2020 05:30:59 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id d6so4334959pfn.9; Thu, 01 Oct 2020 05:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a2Jimmslu4qP6milaPXPNgv6BhHWWJb4M6uEgyL5FY0=; b=S4vxVY6vZO+1XCsgvAOsJJpRSO9TihhxfLtpAR1s0R/IBlYYTF7ybcC658ZnEe12F2 Tk81IBH5+gLSAqhiv0o7rgCS/lklNlonTjzJsdLm6V/4E/t7mUUzyMrGCYzcg/GbYFqJ E7lIXhCoCnvwl1oLYJQqgDnDPXewWk8nC6rVAjQlhqLDC4jJiZIAyK5UbiJKqySIC2vn ZsK+mLFYwNoeaYcm9zTen7U93+MLn6+WUYoNc0NUZhGdJ/yHyX/uJensNAedmyV/LPDH Bkfwt9Vx/f5BIURumhSN6NSGKgmCz2tGvnnOgXhU8UWQKvAypwTQnF64NQEbJSrJubqJ et/w== 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=a2Jimmslu4qP6milaPXPNgv6BhHWWJb4M6uEgyL5FY0=; b=WpwG3VRmV6jsZB369eWaTwtZLnSnROfbAvnLNcVMoeBRhFEUV6Juu9cS2BByRA29ot lLgg+A6zMcVXiKBsG1VBCsCHDIx8OYAXiRY6rL2Wnvgvd4lMTF8xbPVJrm4ArNX1V7Ci XSgQA8vlkmJPatnHkNyYtGONZ0tobOJFYDB/hWUCOAimAm5WsS7wwB+DqPiB5jofhQFj xXAaIQ8KDZuA7Y4LlPybCbIl6dTzyZD/fApERr7qvLIA+f+/DhXUQQs5dwt31pVSIDhR mXvfZqM3Q2MeCdY1TBQGD9+hnTceb1TiGcyp4SaaKb1SsDJVPxJVL3Ou6i4qt7ZDGlqn rfYw== X-Gm-Message-State: AOAM53109iqzlfl3/J1PXVrb1LkJnXxIcy1goNMbuGNjPIvzmWVsLJSV ax/0U5UP9DO2ULo/2BVZmsmX2tnQFgQdCA7f X-Google-Smtp-Source: ABdhPJzFT+8I0OSlV2t152hgKtHTxC98pvTJk2S0gTh62JrgFAbw9Wf4H3LkAr5KLgeavlTYpnSv7w== X-Received: by 2002:a17:902:8f8f:b029:d2:4276:1b2d with SMTP id z15-20020a1709028f8fb02900d242761b2dmr7247496plo.17.1601555459098; Thu, 01 Oct 2020 05:30:59 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:30:58 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 18/28] scsi: pm_8001: use generic power management Date: Thu, 1 Oct 2020 17:55:01 +0530 Message-Id: <20201001122511.1075420-19-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 ee27ecb17560..62dc30a45ac4 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1178,23 +1178,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); @@ -1217,24 +1215,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; @@ -1247,16 +1242,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; @@ -1317,8 +1302,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; } @@ -1401,13 +1385,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 Thu Oct 1 12:25: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: 287277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1A73C4727F for ; Thu, 1 Oct 2020 12:31:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD6EA21D46 for ; Thu, 1 Oct 2020 12:31:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eKbTvNn2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732162AbgJAMbM (ORCPT ); Thu, 1 Oct 2020 08:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMbL (ORCPT ); Thu, 1 Oct 2020 08:31:11 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B0A4C0613D0; Thu, 1 Oct 2020 05:31:10 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b17so1800590pji.1; Thu, 01 Oct 2020 05:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X9+5w7ntCnYJb2A+Fo6HNLMhcm7EurVWX4dh2Zlyo8c=; b=eKbTvNn2EBH7D8mRmzUMR5hFm0LyThX2Lv4WvawuKjmGiAJlFLGfpH+F59V0TqZ0i+ vLgEsgmDnPcYM/xpDRF+jiDKOg74ffpT39BkHUNeR3IjcprQZVQtoIhFABpYClJM/uX6 ADA4iVqzV9NwYTYNy0hxnGwDOysdzuKHkOOducpacFu8POHMKXVCzUqkOAsqPQN3yl/k tYxc9UXc6T0ymUDrwFvo7bTNgntDI5l6BZByVSTOcIEO3lLdVTb8SVdT8VlJqtDtqtby QOwYRD9+zzsbmTOIrjlnYyRsWdpDUb0BqqNM2BU3FCvIZ0AO6pMxNtefm/5nLt8BzZf3 NYXg== 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=X9+5w7ntCnYJb2A+Fo6HNLMhcm7EurVWX4dh2Zlyo8c=; b=XTb8K+P7yM5Y8FJhdOpYv0OjtyQ77zO0OUEA3aIKO2ncJ8BkRcaENmKgZjoT2PdNkS MLW2weiHT9sPpsfhkpRQqyiAs+Lh5li61g6a2D+lCahkFkLMiDdRTOxN7rFrkbIeiEe2 MBwXauq/DQoHzGuRM3P7pvAN2zAgkNEq6r7wrcPxb1q8U3BTv6gxVJvbdio7LJk0UnWK 6vEeN3JEp4YWCJ0s3Kl9SQBcJjxQJsPScDJ8PCDWW+NOjjxtIJULKhIQ6d3Ax5IfZcUv CGg3zlRKCQq9s8li/muE+zXuzm455KJMZ04tTQ/LOIZgQleHWa+pIkun8U20iocvDYuX VaBw== X-Gm-Message-State: AOAM530DjqVpRkqlSLauuujeV8lJ4GQ5FyW7vVGxFMThCYdD34ob93G+ AD0qEtwLHZop2rFVAZo/b3s= X-Google-Smtp-Source: ABdhPJyXECPCwBVqenedBV4SZWlPcKO0pUxmQEMyMGfbvbsvAEvzmje4h2iHqQQ96D1U3iCuvNPp2A== X-Received: by 2002:a17:90b:1b03:: with SMTP id nu3mr6910088pjb.148.1601555469972; Thu, 01 Oct 2020 05:31:09 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:31:09 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 19/28] scsi: hpsa: use generic power management Date: Thu, 1 Oct 2020 17:55:02 +0530 Message-Id: <20201001122511.1075420-20-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 81d0414e2117..70bdd6fe91ee 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -9070,25 +9070,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 Thu Oct 1 12:25: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: 257479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 582F2C47420 for ; Thu, 1 Oct 2020 12:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12DE721707 for ; Thu, 1 Oct 2020 12:31:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jpu/Vb5N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732386AbgJAMbV (ORCPT ); Thu, 1 Oct 2020 08:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMbU (ORCPT ); Thu, 1 Oct 2020 08:31:20 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6269C0613D0; Thu, 1 Oct 2020 05:31:20 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id t7so1892320pjd.3; Thu, 01 Oct 2020 05:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W5RQgrjqJr5D2/1pMUi9WfhBDO4kIlgckrIrr7JrWwo=; b=Jpu/Vb5Nw77VU7c9YF9sge1HNLGbWsv3FaRzRsopC6QZ9H7s6CzbkM/xMjlVpKUsjL 3Lx8PRl0fNXjJbkQqUXYO0hQZIG/KXny9k5CkhZocA8R2t36b+SSk21ceqqjz3UMkHP1 4YDHMfNIBv50XuKnBJ4Gob4rd0A0o+a7cYgONiZrlPBIENFaXIoKjWT154+U30tkmIMc Izc7OZZqbOplD7ySa0U7xr6J3wde4slj3xBVSfDSy8iOFm9F1mXVZ/688/aM98M9rt5u /ZS3lJUWndubLlv4U541MzoTIOPWt6f/3ESeTH+QF16ioLJg/YaqcZB64vy3jlZzosKr LkBQ== 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=W5RQgrjqJr5D2/1pMUi9WfhBDO4kIlgckrIrr7JrWwo=; b=CEA1qcv165RZD1MZGxORAy/m8jrLikN3lgAce3Z4NeGAYCfPgoV6Je4xkhGNL1LYqu 1q+Re1FENEdWUDdfFwqmJESFKPd90q2QsHHdr9sEIs1lstePodKlbfOUOAtGAOysE9cz iPQWE3vfno2WF+7FrDjW9doBZJFg+bL95Q+BVtHsAOj8fjIvgmEssKxsENWkqu4R3Qg0 SqLrJKRd0mHO+G3H66KYC93iQ4QPkp6JrQwvEieC8hyHu/PHPW8vDPgGz4CfzG/S2El9 lXM6GNxnksd0wX3AiJAMBcblO9Ut2dWnIrzr2IX9UE6yuXv4hGrRqRh0teRO1kT0nwPn 6VDg== X-Gm-Message-State: AOAM533IDR/Wm0jaOUXcXOOjvkRC72xsmgYGuJJwj9E2r/U5wazTTWYv nPLkS6caXDWSJIrj0OKak1U= X-Google-Smtp-Source: ABdhPJz+KCJHSAQgaeGoflykrGaOKtfCro4i2b1LFeI0SBNUzX0loLJxcb9Ye3ccBlGN8YblucDNCw== X-Received: by 2002:a17:90a:b944:: with SMTP id f4mr7006528pjw.127.1601555480240; Thu, 01 Oct 2020 05:31:20 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:31:19 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 20/28] scsi: 3w-9xxx: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:55:03 +0530 Message-Id: <20201001122511.1075420-21-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 --- 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 Thu Oct 1 12:25: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: 287276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7297C47420 for ; Thu, 1 Oct 2020 12:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6548821707 for ; Thu, 1 Oct 2020 12:31:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nZzb3EcU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732232AbgJAMbb (ORCPT ); Thu, 1 Oct 2020 08:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMba (ORCPT ); Thu, 1 Oct 2020 08:31:30 -0400 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 D65E0C0613D0; Thu, 1 Oct 2020 05:31:30 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id x16so3941995pgj.3; Thu, 01 Oct 2020 05:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9uM1XyBCr19CDVWn9sf0w7KO65sKBGQo8/F3BUibYX0=; b=nZzb3EcUjTYpCRdQAX3xmBANibn8WqIzGcBrd3W6p89cEtprf6OSZWiMpMuzQCqz7l DLTk6SbEUdDfOoQ29zSTEol5F2yPN2p7Dc6zE5rVYK2nuQe1rldK/QMwFbghEBPY7tYz +7NMIKvBS2hy8a+5tKkIUPRdrNWx5q5pUWSpxeRMYexZ8IOtdSrZpaTF2DkBXs+/eYia XGRYIvY96aIJ2r+nofhnxdNpBDCs0zd8b2MgxeGJO6ctuXpylq1xBukWrPjplHayi0zV bKIQJh3VbZUGi39zmjAgktNDPf8uk9EPqD3JjGPawFYB4E/R901uAyWIh0kZQHNdyNvQ XIQw== 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=n//7tg+mzVRiPfa11FDAk6j2M87QZmjwHLQiLjZAKcwAXOvevbUhcK8EbUErA+HRlk okYK3ZCcvwpUFdTYsd/yhlzpGjAgjal87lj1pwehz5CIZgAzxsYACgQPxryuul2MkIo+ qOQ8JCMERb6pXpa09ctGknrypPJ73JdnI8pbC3VRhkyuycSbjKi8PdcIMjTLRUFKMSt0 39lf6LoZ6sqT1RgIYM0x/cwbvdTWFIBIChLF60/yjPpJMxRKICft+15NDHlMLIlZ2dIK 3WaQtXKc8hqaSkHqIbfeswiyI8dBM0ha/I4+gRo+xtm2Cj9PPPTGspNQOfg8cxlC74Qi bpuw== X-Gm-Message-State: AOAM533ysUtsKjtvLlbZuCFYX2PEjviAiOuLCUBOS+5QBOGWmMOG0MRk ytoHIAcTCxiY0x6whZsvOLQ= X-Google-Smtp-Source: ABdhPJxGhxM79NkvfOxZ0wQbj6bjRlnLTRjAkhtufgv4O5/RVevsS/GoXarVQFu027om5zbBF/ehhQ== X-Received: by 2002:a17:902:aa04:b029:d3:8b4e:e5ef with SMTP id be4-20020a170902aa04b02900d38b4ee5efmr2953510plb.65.1601555490385; Thu, 01 Oct 2020 05:31:30 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:31:29 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 21/28] scsi: 3w-9xxx: use generic power management Date: Thu, 1 Oct 2020 17:55:04 +0530 Message-Id: <20201001122511.1075420-22-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 Thu Oct 1 12:25: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: 257478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3609C4727C for ; Thu, 1 Oct 2020 12:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9901020B1F for ; Thu, 1 Oct 2020 12:31:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ADnt676A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732258AbgJAMbm (ORCPT ); Thu, 1 Oct 2020 08:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731987AbgJAMbl (ORCPT ); Thu, 1 Oct 2020 08:31:41 -0400 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 CD9C2C0613D0; Thu, 1 Oct 2020 05:31:40 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id m34so3914455pgl.9; Thu, 01 Oct 2020 05:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6ccyY/JHq4D3PLCl7N5Le5xwodBVxQCbk5cLiaDjEFw=; b=ADnt676AAP5flINm0S2qqqHIISzdszBdV/K0pjxZBtIPrRD/ewjglITrUMhytntX8O smIsN3OgyJl0MQ1/tPj9e05fRv0HczWSF/ZXnEY15KL7AWwXO02zvKX0ahPsmVA8TZ4P yYki4jkZuGLsBZhuvTI5FwB52ypNCzv+tZNOQsryxDs57yX75HsWby3yGfSo7rjEwarR t01z0TOTWpT4tFRwIMcFjXga5dQlwtnOWgeLS/EeTLGM+IO91206jAyyB76fq2wjhBC4 4Qs2Tqosp+F/tw63f1DC/YLufjTScHtwuoAQJxfdFXxY83Iv4G5jOWVyl+agP5ZkshU3 tZwQ== 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=Yo9SAA0R/nFgUw+KpV2FUP/ykTLSS8yGYY7MLFCVDnDuqv4R27qg+A8dn3qOqx6kDs 1kW0BUJ2HXKa8zW3r7n653h7WqiO7+iZ6drgRMoEXBqZIf6pZ6icL8dks13cS80ig6vO dJSaGmeeAkM7/NrMH57IcYMhpbEezENr9QI6AMgZLwShckQm+L5o+yR7vWPOrxUjuoev M43k/ThFwhlfZngqvmWcunL1mZkE/lEhG6InO6CcabxG0JynuDCgSc7aXocSRwca4rnV zv+hjDNLaKONHdNTOH1nKu98qfM7KPrDoQYVPjY1kFXqQ09LG65dhkZKWx22VvICTsZo x8wQ== X-Gm-Message-State: AOAM531ZOUFMlnw9OVVN3k5v4uiLH+xCWiwU5br+Xbe2ZxycDhiRfLVA exrIt7+3+i6Pd9doAxD66Lo= X-Google-Smtp-Source: ABdhPJx2jLFxmDE9qTYw6Qz+MBqtFoeNRTBU/qZxwnXqlpVbCbPeeKH1h7TjhV5KgZWFB2gS5ae13A== X-Received: by 2002:a17:902:758f:b029:d2:ac2f:3a79 with SMTP id j15-20020a170902758fb02900d2ac2f3a79mr6879952pll.59.1601555500390; Thu, 01 Oct 2020 05:31:40 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:31:39 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 22/28] scsi: 3w-sas: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:55:05 +0530 Message-Id: <20201001122511.1075420-23-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 Thu Oct 1 12:25: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: 287275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E512C4727C for ; Thu, 1 Oct 2020 12:31:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB1BB2087D for ; Thu, 1 Oct 2020 12:31:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SMCaefO+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732401AbgJAMbv (ORCPT ); Thu, 1 Oct 2020 08:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbgJAMbv (ORCPT ); Thu, 1 Oct 2020 08:31:51 -0400 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 34FB9C0613D0; Thu, 1 Oct 2020 05:31:51 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id x16so3942699pgj.3; Thu, 01 Oct 2020 05:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yCf+5pBHtGakI8vGh3iG+XqVcPWuJKKA8L3HBDKw1hc=; b=SMCaefO+GDy2LTqmcPRkWQzQePduXz/8CGCTNsh/8EIR8JfCXCVnh2Cs1IaTM5UDKc gz0Nl37bLENTFOZGFkklP8NUuiW+iwPxpXjr3R7XCT0hX56VqUVK3c1uDfigpK+8CdOz QNGOhCEDX0kytXW6hnYuRWbTPi342VGN+FtmWBxcSm1ikbfJ2IDIaUrayFC90L7r2R+l WQ13Kr+71cPKp/EqDKJDbhnfYB7tPkQ88LCmVyGRGQy8KDNF2JB5KSLSaeE9/dMBzb8E sxzSVZJhZlEk1Cml4/GrkMV4DXn8SpuiMWvYuFXHlhNGzP1gIgeEhWYddpHm2d3E1/pF 24Fg== 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=jmoqNMDr7htAB4XMRZDtwC/VuBZdVc4XMG/rRgW2hE7+PGPThN5oVakiIk+LRpS2jD 8CtFa3IDwgrxCW0ru10dOnLLZWYlOh0x3OMaxPKAqXZOSyE/LIzcCVMDA5cslK9IOc2Y mn2z1RnZAsII9i/Za1yrKP7f0f86vx0CN65qMgtqNn6x3QzIDAr7gUD8nM/tpjrtZnXU NANKhILZxQDYmJDgSzU+WlZrjjMUaYSIEoGZGg1inBmNffV3PJMHLKkBBuOUK27ktX1t Ybv8+cgsSb51fKQhHmi+xuc+klO8KKaaFznnIOtbHqnGRfGbRFNEPolPWeLGzKr1NrP2 wt9Q== X-Gm-Message-State: AOAM533e5xipjFDkvwz5nCuVqWebuMaYYYVf6RMO7XMQuniSgFxFfXUg jNi0pc8lz618HRaBTOkGsC8= X-Google-Smtp-Source: ABdhPJyaWJwo00IH02FqAlYVk3iDFt3m09OedfhK544ZN2l6gEpfDhkFeia4cyHlU5Y/1x6rQ0Zh9A== X-Received: by 2002:a63:d648:: with SMTP id d8mr5912533pgj.4.1601555510725; Thu, 01 Oct 2020 05:31:50 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:31:50 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 23/28] scsi: 3w-sas: use generic power management Date: Thu, 1 Oct 2020 17:55:06 +0530 Message-Id: <20201001122511.1075420-24-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 Thu Oct 1 12:25: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: 257477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D69C47420 for ; Thu, 1 Oct 2020 12:32:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C023020B1F for ; Thu, 1 Oct 2020 12:32:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sgY1fPrx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732258AbgJAMcB (ORCPT ); Thu, 1 Oct 2020 08:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbgJAMcB (ORCPT ); Thu, 1 Oct 2020 08:32:01 -0400 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 260A2C0613D0; Thu, 1 Oct 2020 05:32:01 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id y14so3914105pgf.12; Thu, 01 Oct 2020 05:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/MM5wiFpgdT4mwRJ2jTZ+VkorPqMhISLnhdlnmMc63Y=; b=sgY1fPrx0IIEz/mOq8kxGdUETanyglSMjkCnSF4mTv/pLvw8tyO5Cwpb2sLVYF1Oz1 9m2TR79x+fC9Q9GSgfU15LGIGsiOikZGA7o//JJgcQwToPC4Z12sE1zKJal7nFk3k8UZ AEOYH5VoltYZa6p0fSG+GVeja3IiLnbCo9be2TA1gkiF1wbKQ/8PJAGDtYIuDEdoPoo5 KebSd/18DSUIzKJDl7xqS4rggtobe+tSXTD8zwB+iRhPrpAhbHVRMiUXSepvRlEoieNA la7rbpdYHXAZNSiDEvu6yBb+9lMdZD4LPofEZqCyseas6wHIb0EetnR3VWLfO5p4kT5S 0SWw== 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=/MM5wiFpgdT4mwRJ2jTZ+VkorPqMhISLnhdlnmMc63Y=; b=ONzTfKvNZaQs4QpI66uxeZm4RmReYHsWnGamu0GvNHYYsaa8R0ByqpGUDFyTTuWekl tpXVrW/CaemTUGVrFUnoAt+Q9F0z7gUL02Zf41r/gzLQE1VygZEIcHX1voX0MP0PX90w pCMg5TMPBtmHh9S1hEHrPiaBFUkqz3mLQB/+Q913ft8fMBXeLJZJCPUrJ9lwMh9gi66r qYxBLikXS178sVaV12fNUX33Qt1f1ldkmx2CdNjrXNaIUcMZTgV9jFwRhQPRfCTeIk4v WG84gY5Iy6DaQWwzHhW0ZFaXH0dUvcNx8hKMZ01Rz3dVmG0YvEJwbr4pHH91D9mug8Q/ q6Ww== X-Gm-Message-State: AOAM531W7g3wi+Mu4fwfnYc1Hj4zf0v46tAk1aubEcGWsY66Jjfe6iSK PCiPyeJ1LFF7xa+OIj9KLFk= X-Google-Smtp-Source: ABdhPJzfLjOv1Um6n+JXmHxhDleig+gqaBsH2YdlboNeT6atbMUqJdrMFxbom5GiSdgteIOYOIsH3A== X-Received: by 2002:a62:be0a:0:b029:142:2501:35de with SMTP id l10-20020a62be0a0000b0290142250135demr7404486pff.62.1601555520655; Thu, 01 Oct 2020 05:32:00 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:32:00 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 24/28] scsi: mvumi: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:55:07 +0530 Message-Id: <20201001122511.1075420-25-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 8906aceda4c4..6a25e6918e26 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2594,7 +2594,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 Thu Oct 1 12:25: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: 287274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F8E0C47420 for ; Thu, 1 Oct 2020 12:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8F5620B1F for ; Thu, 1 Oct 2020 12:32:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GeHv+bOB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732401AbgJAMcL (ORCPT ); Thu, 1 Oct 2020 08:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbgJAMcL (ORCPT ); Thu, 1 Oct 2020 08:32:11 -0400 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 F3FB8C0613D0; Thu, 1 Oct 2020 05:32:10 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id t14so3914705pgl.10; Thu, 01 Oct 2020 05:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hrv7wRA+5E+4KqJ7bQMOzG1YJwF6Az+zVhIMy7DopLU=; b=GeHv+bOByYv/7nmo32iMHC75G0isZBzRUMMMArTGgzfs7JvMHmpNFXqYjkpdRwGcSX bhtqUAN53rSGBzAAnZmZcPat6VFeFAerXN9EaAXMWDs+NTfKG+rBXqeAmEv25g8l1raE 2ZHoHLIqC2XJ38K0hXyFtf8vtb7O/7VC/+oyuRVK3Lrh/3BInkkLRXL+BhyPYU+Lf2Bx JGCVRIQS84xFLCF8CGYiSNvD7MnZuyoTOadztIIem4SQlARGl11jCRTh/WiSMZbe7T6I 7FpPT+/sjvY2PngX2h4oMdb4Bbjnvs9yjL8llG/eaCnEOgsAGM7omVhMbsH36fkL/eem lFxg== 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=hrv7wRA+5E+4KqJ7bQMOzG1YJwF6Az+zVhIMy7DopLU=; b=Yvhmy+jhowqMcfB/KMeClnYmiDtVuTTBrWL7bWPjbkoxS4EyMro55+DQkRBVjpAzjs XcJiybzW07eRIb6z3CTuhFnMFg7efhAoEFyZEtQ8y19pcsb92GnWIjHitiWmDq6WlKHz cMrtdJQMMHDEV+L2kdDAgNwzjmMH0KtWxOlKyiF8Su51YTME8wvdHuAK01jEaVs1nqKI nsYIo9qlADrrfrHLG7lLblyYKhMmAh50P5xTuiUHzhUd4Cg9l2kn/tfl9AU83W+VmiJU t6LZjaVnMwtU+Ha7trO3KXD5LlZ+Q1UaajluAlFBgi2BoAlmMK7SYJUoNMXGWwPrp+p4 D/OQ== X-Gm-Message-State: AOAM530/GWPBFDLhag/lyq2Yzo4Vy9J15f6Pkbhz83rUxQTRL1KkA2b2 KGBTmSBHCegVEezIK3FlgWY= X-Google-Smtp-Source: ABdhPJxQsNaElmb369gzt/Yo9RjTX54ks0xKIenxfw0M+AOwyH7+1Qtq1uXVqtfS/ux6tre3ChN/xQ== X-Received: by 2002:aa7:94a4:0:b029:151:d786:d5c2 with SMTP id a4-20020aa794a40000b0290151d786d5c2mr6860664pfl.50.1601555530485; Thu, 01 Oct 2020 05:32:10 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:32:10 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 25/28] scsi: mvumi: use generic power management Date: Thu, 1 Oct 2020 17:55:08 +0530 Message-Id: <20201001122511.1075420-26-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 6a25e6918e26..6c710585a628 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2567,46 +2567,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); @@ -2626,12 +2606,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; @@ -2641,11 +2615,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, @@ -2653,10 +2628,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 Thu Oct 1 12:25: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: 257476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88387C4727C for ; Thu, 1 Oct 2020 12:32:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4583621707 for ; Thu, 1 Oct 2020 12:32:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OTk0Rt4j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732258AbgJAMcV (ORCPT ); Thu, 1 Oct 2020 08:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbgJAMcV (ORCPT ); Thu, 1 Oct 2020 08:32:21 -0400 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 D0F0CC0613D0; Thu, 1 Oct 2020 05:32:20 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 5so3930900pgf.5; Thu, 01 Oct 2020 05:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uVl3TCvbBhvJ5acgqRChRsAsShA7j8oIRrpWgA0mKfY=; b=OTk0Rt4jglWwZ+yz7PsVtVxG6KxnnckXVtI2Opq7bCjfEwQ5gtjDTxaVrUmOAMTg77 lM1QfFnGoonQwGuBML+0QKpHkWM9Tx5oiHBxHrKYhliXy2Y9fSZVHDz+GwmVlfX8F9X7 RXtqSGyQi7kVUut5IfbSV97vZEgNnXq9jjUyYL0ae9ibUv/7OqWh4ruqysGX5S6V8Syj yJNvRTuxy5QV4MVbzNkQiLI7byuedKaskDRu6vAS2/unGhLzsfADsp6RmVnC1tY41UV6 gXt4UTFOFlR8N1/w0hEiM3TTz1DIGewXsc4/xurN3D1dntbsCsIlaqanAI5BHYBMLr2Q vXcw== 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=uVl3TCvbBhvJ5acgqRChRsAsShA7j8oIRrpWgA0mKfY=; b=LD1vC3dbsNHhbXTCm6FwJqIzVMo7/uxDtJrg7Nv78UwYKDYLfYx3PtTQFDlgupSC6/ uO1enctE5sgYI5oWmeiSDF4dfoTLnZcdyCnk82pep76e9fNlOt+8qU/pk7G6/C63DZ+0 rSN3tWc1fiwn7Qr4NYd9/O4FwwfhCbuxJAAxVYqgx2+h/c6SKO6Dwx6sbBf6Xr4Z0hpc C5L2WgLdVMcrYeV1HonZiTiO19PVAYesrcupfqs1f70V9dJSOO4uRRUmu+xdPBiUSNoP QljypL5uzhlX0HkBd4I/dujw7ipIQ5oCoK0JTY53DLSf4a6IvkvKFv2ljpVUYUUyqYyH T+Xg== X-Gm-Message-State: AOAM5300wEjivG1cEN6jTByiR733oPuwDVdOwYnlR6+FIzhObMcYj+kY RJv7DfmaEH4qa37qeS65AT4= X-Google-Smtp-Source: ABdhPJyp/dES1p7s+7zMWL4diu52QUTY16wzfY+9/UX0IZaM5NkaxdbwHIPAKsdOFL6UeptfOPY20A== X-Received: by 2002:a63:1162:: with SMTP id 34mr5512456pgr.329.1601555540370; Thu, 01 Oct 2020 05:32:20 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:32:19 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 26/28] scsi: mvumi: update function description Date: Thu, 1 Oct 2020 17:55:09 +0530 Message-Id: <20201001122511.1075420-27-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 6c710585a628..82dd7c37c14e 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -2558,7 +2558,7 @@ static void mvumi_detach_one(struct pci_dev *pdev) /** * mvumi_shutdown - Shutdown entry point - * @device: Generic device structure + * @pdev: PCI device structure */ static void mvumi_shutdown(struct pci_dev *pdev) { From patchwork Thu Oct 1 12:25: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: 287273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7E32C4727F for ; Thu, 1 Oct 2020 12:32:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82F1E21707 for ; Thu, 1 Oct 2020 12:32:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ofdgbCx8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732315AbgJAMcb (ORCPT ); Thu, 1 Oct 2020 08:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbgJAMcb (ORCPT ); Thu, 1 Oct 2020 08:32:31 -0400 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 EDFA0C0613D0; Thu, 1 Oct 2020 05:32:30 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id z19so4332169pfn.8; Thu, 01 Oct 2020 05:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=upZZCj+92lnDUoFs3NcTq8HG6EWLzQTAbL5PyvIZ1Ek=; b=ofdgbCx87Pg7KvGsN+h1/pPg6myPm0W8WPZNSr0j/mogOK2OYugSZ8RvKrd11oNp58 IRzR2iJfUfRkbx+PmFkA74gJPOFvuCUevKhMJhQRHZS4jYtdUy/wjOFvgUZ4e5j74E0T wYDHAoEH6AMkcuwHJlV9Wi2AydAdFs3z5vzjjWjMA5OOjsEyN5THqaAv/WErFGqhHK1l 06tRJytiTLsv7nRT3z51a9U3Efe5mKihVqTzIkVWEa+XOYCxTQhFY1ELUP9ZPtPeIa1d oTl1gxbYbNdVYibvuNm+CtPTD1N0sUeTwEqingLkfWeq4pVZNv8DpgsvklbaJwHFlGar 38KQ== 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=upZZCj+92lnDUoFs3NcTq8HG6EWLzQTAbL5PyvIZ1Ek=; b=nHwv5ef/XkcTZ1abvAs2owCm9vqbxrYpCXw8aTsdX/WFYbaDg9UhPi56/lVYMm5EM4 S3Ai3nsp3sUd2spXLbSnq1yt3H2xiqWvR75NIvZ4RMwbHZHFrg9Z1AW1I1j9ArgQlKxh lzEsBFvnwHQlXhdlhcX3eVfAc0ZpPCvpKOKI1iPL1DowCwMVB+yjwsj2TRe2FhXtW5im h/yBQS12SGL6GJ0keuBi9Qkov3cUcbKx0K7RAOa0phujOj6nTliDDnh5MsuUHk+TIBlC j9rorVmxD1Sy8eyyqAemCHmFF3msRyOmUQzRWn123jemPHjmArh79tCsAc1pDZVrsAPO h7Mg== X-Gm-Message-State: AOAM530pJWYK2fkzOQpdiyNI3bN2xicPTuyRD8gbA8ZGnedOCPE/ek5b 5PZIVYq/IoESQWIPKJ+nA+g= X-Google-Smtp-Source: ABdhPJyLBix4KXS5HBL5+h0SdbuccaR4mOzkejrjegKjDBqh4tozo/80gsbk6MuG+wZ7gFvLk4ygJQ== X-Received: by 2002:a17:902:b191:b029:d2:6277:3898 with SMTP id s17-20020a170902b191b02900d262773898mr7502813plr.10.1601555550493; Thu, 01 Oct 2020 05:32:30 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:32:29 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 27/28] scsi: pmcraid: Drop PCI Wakeup calls from .resume Date: Thu, 1 Oct 2020 17:55:10 +0530 Message-Id: <20201001122511.1075420-28-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 aa9ae2ae8579..7674b8481f35 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -5274,7 +5274,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 Thu Oct 1 12:25: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: 257475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F25C4741F for ; Thu, 1 Oct 2020 12:32:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D26021D24 for ; Thu, 1 Oct 2020 12:32:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sawYFsfH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732258AbgJAMck (ORCPT ); Thu, 1 Oct 2020 08:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbgJAMck (ORCPT ); Thu, 1 Oct 2020 08:32:40 -0400 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 6F06AC0613D0; Thu, 1 Oct 2020 05:32:40 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id o20so4322558pfp.11; Thu, 01 Oct 2020 05:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ah9td3sQ1fIG5lGgCqIwhgoKZucLujwVmdH4oNX5u+s=; b=sawYFsfHVBmfVwr+8fNWhC16ZKZ6OBox2c8ppWrTzorUUdPDBeJBdRRly59vUZbXbK kLjuXCWBnMg0M8PnQAmCBDTqNBd1d6GLYOFnXbcrzcc3J2674k0q8PTBEIR5gNHahrqK aBIcrsF0Ibdpa9wRCMLQmGcXPs/TO3tgx4nGT5qklHD+Mu0akXCdnJAblTDIUncJThJZ 6yEK/heNpQA2ViatN8s/jZqNijZB2tov3kIqiCZgjzyRQMa2KHbNdb0/nL3IK9tjVnbJ 4RRredMZ/kPZMqfxVugAMebdjTJSQuuBkvF1xyID+YfLuackkR3X2utwQ15gnFTW2VlA N9og== 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=ah9td3sQ1fIG5lGgCqIwhgoKZucLujwVmdH4oNX5u+s=; b=tgFfF7DZccoJQWMY2yJfri5AoIP6niRgmTcycJPE80fiObVKzU8rWB2j+sHE63kaAj N5rQ2a2O4zUkncVTlGkuf7/rvz3Cp6KqQcmxEbPbqVyZ3bd6m+n6bbUfiMV1Km3bLGcw xS4lFJl7pq7TXGCopdjTRl/yu7v45p9tAOU8UPrccPZzgtthZUnLOaI1DM3vpBAftSm6 LYcrS3qJFh0FhWYriqjLi1XQqL8Zt2UKEpirJQMnsk5vxmFOHg6ReJh5vmOB/8Qg+MhO HgqqdJMKRlSYjRE9UhEmTKruVEKigqbDyKFRM07qsgDfZL4bn+A/jpIRkTX/N8t/089j kt4g== X-Gm-Message-State: AOAM532F9Sv05Y64onxITDM4yedtWGJtXf2bm39gbwXeiz8qMLxJ3oDZ PG+xuB7XCsowU7Ay4uroq6I= X-Google-Smtp-Source: ABdhPJzyjl54g6Q+QzgIlbEPt15+tLx1HeyZRUimL2hMqFHVnu7+yHGefhiyhB9n9iU+7NHCnLsMPA== X-Received: by 2002:a17:902:b688:b029:d2:43a9:ef1f with SMTP id c8-20020a170902b688b02900d243a9ef1fmr7169860pls.9.1601555559931; Thu, 01 Oct 2020 05:32:39 -0700 (PDT) Received: from varodek.localdomain ([171.61.143.130]) by smtp.gmail.com with ESMTPSA id m13sm5695199pjl.45.2020.10.01.05.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:32:39 -0700 (PDT) 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 , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang 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 v3 28/28] scsi: pmcraid: use generic power management Date: Thu, 1 Oct 2020 17:55:11 +0530 Message-Id: <20201001122511.1075420-29-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001122511.1075420-1-vaibhavgupta40@gmail.com> References: <20201001122511.1075420-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 7674b8481f35..bbf7fc8d5a2c 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -5237,53 +5237,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))) @@ -5336,18 +5320,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 @@ -5835,6 +5811,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 */ @@ -5843,8 +5821,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 };