Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1761072ybh; Mon, 20 Jul 2020 06:38:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnckIfqjzPAjmxrIwT5n19v/CAbv/pUyGo2SEBSJAGyh1WljeWb24/QToYgViGqa9f4tue X-Received: by 2002:a05:6402:2c2:: with SMTP id b2mr21323793edx.184.1595252304748; Mon, 20 Jul 2020 06:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595252304; cv=none; d=google.com; s=arc-20160816; b=XnVG6rzTPmOf+bg9x+ke8jmkJY6EBRdoHbWLKFPmO6EJxSzfk4NPNbwyGzcQ7U3K+j GVqvbkU7I8q4B4rJL8mWCbMpDs2z+kg/lDWRMbTUDGnXZhri9ZTZDVlKGNLTsTjnYmeG rcVfKaGFQ80znT/PFgMKDACrM5f5ZHcH4R1aOVMAC09k+kQ68TRth6Zg3HY4Zc9O37rU HqyCGLMUgxFpZXkbJYKAJ3N0HxWwfl7RMLx+EygQTl2lz8qCR1vE7mt2gdR7FeYf2mCp GkLrOFD/2XoN4ybYLw64dapjUXp9QUqf9MAj5XO9yEFOQITI62fgMAlBv4iPqMECVq9m cxyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g7GZQzL62FHm4zfeW7Rur2Q7XHclDeIeHZT7uPwrmpo=; b=LxdsGGc0ieaB51iZsDqa+uL3sXoOy1oZpaUODHm1b7dZniM0Uy9/l0Lxy1e0HlmYx7 XUMBl3MElF0UZdzJIZ92ekqUmuvulkQtKinQYLytoeEl5XnHtzHqA+TEeKuv07IPR5a6 1naj2x+lYsFGlspwKzWIn3W2+W5GIW96zC0QN3d/KTR0lBIeGltbtLDbE/GN9jjlFBOk zhfWyVSrDxhZbsn3eeEfZ5uZxIeK0ssFsjlF9b4+9lHqEtQF1qamrHrBlrftoSzqK/3v lSFupa6k1i5ULal8BmjqsNBOV5V6QHdFhLjoifh5KAC1NhAEv+9nKiw+0yheBnXXaUyS 0i/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="vESND/m2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si10410883ejw.332.2020.07.20.06.38.01; Mon, 20 Jul 2020 06:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="vESND/m2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbgGTNhT (ORCPT + 99 others); Mon, 20 Jul 2020 09:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbgGTNhT (ORCPT ); Mon, 20 Jul 2020 09:37:19 -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 ED3C2C061794; Mon, 20 Jul 2020 06:37:18 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ls15so10255474pjb.1; Mon, 20 Jul 2020 06:37: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=g7GZQzL62FHm4zfeW7Rur2Q7XHclDeIeHZT7uPwrmpo=; b=vESND/m26eUm2DZbM2aO9zSHOhUWlbMIZV+svD+NnkEbhtaRsLBtpYXKBsHj8FBf3q Ps+VZkAfNONqzF+H/12H0mcII1xm6LdXCz+RR+niEmGuIYYCwEBIZuU6WvRvQNdwR47P 1jWztMZ+0ZIOc8lUkq7ry1gxRsoCH5e4ebq5RCKb+QEWITl9l65aOZJo7mH3FBGFYCWB zARAjLWbnCLdGr9MN2fhdxRWj1BPMYMkk2lr7DTS8BN6FHe1iq/nvix8EdsTsAlC8DqH K50hAyC9OqenMqmNU55gkrAQ8Nxj+Lu3iHiPjRqIXep8jOFv1tQ1F/H5H/oVA6O9o+qv 1Lmw== 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=g7GZQzL62FHm4zfeW7Rur2Q7XHclDeIeHZT7uPwrmpo=; b=AK+ynpv8jEnP/2xhenXoTbDW4eVzUHdtk9knhKGUsN2s3yn2sGEEdgnMXyQvuBP9tX owaWh0nyiRdUeBzRvGPB2nZFvMCdHZpVVt5YWWW65EG/E8I9r7g3D89OYIq2XkZBzXQR FunUTK8f0+bejfRa6OGmZ5vsbgiUfLDAVC94p5BZmodTIvU+rvoYUl4VC6QB6LMQgw7C erFqCGnsA2L+X22mH6t4aJsa+T6ldmBBGgQEChKhV0EoCSnoe11yDBOyJ5sucLF+xnpd hONxf56MUNO4Yor0txFxLCdIPWT5Kk0WuzrNW+UnQnJeJer2c0CAnTf5wjo6dLpm0jL3 RbYA== X-Gm-Message-State: AOAM530HA7fB0V2GctEPRU9TgkVQIu6/dqDlCpozMKvPceGMBTfj4RTF z1Rcv+OH/5U+4xvoo527frE= X-Received: by 2002:a17:90a:d3cf:: with SMTP id d15mr22599054pjw.202.1595252238471; Mon, 20 Jul 2020 06:37:18 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id s6sm17042183pfd.20.2020.07.20.06.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 06:37: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 v2 04/15] scsi: aic79xx: use generic power management Date: Mon, 20 Jul 2020 19:04:17 +0530 Message-Id: <20200720133427.454400-5-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720133427.454400-1-vaibhavgupta40@gmail.com> References: <20200720133427.454400-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With legacy PM hooks, it was the responsibility of a driver to manage PCI states and also the device's power state. The generic approach is to let the PCI core handle the work. PCI core passes "struct device*" as an argument to the .suspend() and .resume() callbacks. Driver was using PCI helper functions like pci_save/restore_state(), pci_disable/enable_device(), pci_set_power_state() and pci_enable_wake(). They should not be invoked by the driver. Also, .suspend() and .resume() were invoking other functions for PM, which were againg bounded by "#ifdef CONFIG_PM" directive. Remove them and mark them as "__maybe_unused". Compile-tested only. 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 -- 2.27.0