Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1762294ybh; Mon, 20 Jul 2020 06:40:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygi7hcJaLBQTxI4UYGcFpk+iuL25weDoVXCHH/A49ZlxjzaNhMDA5LQcO0Te7f1P6rnLPc X-Received: by 2002:a17:906:d78f:: with SMTP id pj15mr19340731ejb.283.1595252405001; Mon, 20 Jul 2020 06:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595252404; cv=none; d=google.com; s=arc-20160816; b=rtBZ5xS/yJLPHQjle3hTrzzhs0vdeHvSVYI0A6ieAqJih63VvPCdoOHsB7varjvwkI +dc04BsUgd5sMRENl8N+GQ8+GgrTCyshW/jBO/i/7SxwkIMwwP0BRhtclY3JboYbznfi esbbb6XOQ0RWnk9rsrOxBYjEO/S69eFun4evfF7vfUq2hRiwFUN5q6r2pYQmsY4SvRPF h/6WvUMfLfSJ3e2iQFkI5T84EEs05D4k54ezmp9qslHsx7acNpY5Agri2Q61Fi+mEQT8 pInb5fDDBKy9zX+X710N/VRzD9Cbuv/gAeV7Pha4mNe1yS+88iBeZzqGzS0rkrsXIhgr /FPg== 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=0aKAKc3QV9tSVn9rtnXDsVWLu3x/6YoSShniIPxhNVg=; b=fQEDOMOU00ojf5y5wmIHMSn0jSpvRQirdkjaG6B+9t8cC0bEXWbJdVjoe2i6Ge0GIF vuCSUxKBo+4adfoH6JBabuZ+T2QZw8oceLRFzJ+oic/FO6CU4JLVmwQ7JbQ/Wc6iJN5x lDgk16U05PV3AcXZvtW4NFpsJQcZQAYP2LS3+e7fS467j7KQNHev//Dw6+3USN3LNZzl 7ZrD1+xP4e57YTYshUewfjubFqUZUTY2XSq93SnFShu12CEa2+LicGatWn9Napwx3yV0 zHthglKZzuY8cSfYIueQWbOwC5h52dJeftbDPR3oLoYb5ISQ3Rfkjfl5z2+HZgEIbMmO ZkXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XOxJz7Q5; 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 g7si9801925ejr.748.2020.07.20.06.39.41; Mon, 20 Jul 2020 06:40:04 -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=XOxJz7Q5; 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 S1727930AbgGTNhL (ORCPT + 99 others); Mon, 20 Jul 2020 09:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbgGTNhK (ORCPT ); Mon, 20 Jul 2020 09:37:10 -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 7A397C061794; Mon, 20 Jul 2020 06:37:10 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id z5so10304417pgb.6; Mon, 20 Jul 2020 06:37: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=0aKAKc3QV9tSVn9rtnXDsVWLu3x/6YoSShniIPxhNVg=; b=XOxJz7Q5cUuoFJe3nTMYE7aAmh8fbUlnM5GnEOMXsP5otcY367tCL62mmdMeJ97u/y kZB+3zADxo7FcuR9+FmXM8yT7XCPYxxW5EOxryHjdO2G560vSlcG7/N2qf9MiIRBS4Hb LHGlOegxf0JWr4g8l0/qiAro7i+2G2IzIYyBRBPYl3nyUtrt2j5Q2XSIF0RgsSlfblC2 Brv2AMDsAlPhyLUscr/rotWoxV3E5fOE7XVgM2wtREy3YwWe5bDZoT+rpdHE7ijgfExt wOsIEC/6vJo2g/w3WEdcItuqxN2SXOq6EzomDl+Zm4XjM3rj0tuFhyn76HXjeWos6n3n qh0Q== 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=0aKAKc3QV9tSVn9rtnXDsVWLu3x/6YoSShniIPxhNVg=; b=hBmI2ga6xPK+4xA0UqNwEbttdI+gAPPI1hkCKMKwsphX9YY45dlKygW+6xTAsdf3Ae sbjpeCoLiQrfdzwRBUcOSEEqN7+tPFG/FouGWICiftrcerd/hcXOP88yu8lVVdglb5Gy 5f6r+PP32QBd0smxf7naSSqi8tQAfJ/zl7r9HRcUMcmV4H91qXJsh9VfM9lgASJpiRqV Omo/5yVrJRqKikQI6WjC0SC1Qny+FUcCLt49NvDRE0mYV3UZooKKNTcdMevye7COi+Sp LanHtBc5ityr7PbhMwUX3ovzZHMNRCpl23/06Po6nFBEfBx7eUc74iIMvacmoUj50Yem kTtg== X-Gm-Message-State: AOAM5307X4kOctlOiGG4DUpZgOdflVhn4RMJp5NLpHWRL+VA0F9Johii OXO8sneTys7L/kfHPrYrTfc= X-Received: by 2002:a62:1ccb:: with SMTP id c194mr20189690pfc.277.1595252229968; Mon, 20 Jul 2020 06:37:09 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 06:37: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 v2 03/15] scsi: aic7xxx: use generic power management Date: Mon, 20 Jul 2020 19:04:16 +0530 Message-Id: <20200720133427.454400-4-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() are invoking other functions for PM, which were againg bounded by "#ifdef CONFIG_PM" directive. Remove the directive and mark those functions as "__maybe_unused". Compile-tested only. 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) -- 2.27.0