Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp405633pxk; Thu, 1 Oct 2020 05:31:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgeGT+7LQ1W1cHLQYj52moyIrtbIFXbNbcloAk10GehDmHaj7QqFr/gLDSs2SgSoCgEQpI X-Received: by 2002:a05:6402:17b9:: with SMTP id j25mr7964000edy.203.1601555468928; Thu, 01 Oct 2020 05:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601555468; cv=none; d=google.com; s=arc-20160816; b=cmeCGqMjL2+Cvd4bsb2Wli/vAj1nyX51z8OkB4SqFAuCPC2gI/CgI0KkLenW9aPZ8r iyZhsLay+p1sii7aY0wUiUgDHrqoAwtTaSdPWNB9c594i47/N5tMDhDtQuef0/3GFfXK 52jq4FDRrjpYs3UqjArQuX4y44RBYXfUwSc2Xlki+K0saEjaJucvhvtUqo78l8AJl9y0 Gzjt2nCzU/qeuOVXWNYqEvjOct6ewzR2UnL/q/L5aYUNOxxiVn/wJEBV2yuzR39nSx2H sEqieFiC1WamAzWLQ8Nss88JVschIsIhvwVg4YMGIIVw7ODkko3RxHj4aq7BW3f2k2h8 M69Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yhtxGQNhK3T+ylubBdKrbNFuuXsZgQN7Noq0oMcBTh0=; b=B+TU4aVly8x+brJqNiBI9lujuLyiMbUkhs1Pj0TpwR4jZ3Hd6sUgdMAe/+qm4W7S0l 2JEDBTIsOZHH1dG1D40H7GBBaFo6yaJzSJtTCUfH/KRZaR3BpJinmQnys9IAU98ne4pk l1ekyqyAPF9ptLkSA+gwu+oFQhLLcg2lRDzsxx8gbjcsBxFaLOP1ySC+gcmlCRoLJThu FtRcXUaYqnl1JvhqxmIMkgZH8X/AOie9oY0XPGxN1uM0dD9vyRSBnqk+sB2iZT9/9Ze7 lwaTDDSJgbwSC0K1/h7WoiunQAymQ/v6e92OvQtKf7hNPOl4ZLAGz/sRvDjCkYRfFe7x KhGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PBjWADf9; 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 f17si3634223eja.524.2020.10.01.05.30.44; Thu, 01 Oct 2020 05:31:08 -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=PBjWADf9; 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 S1732279AbgJAM2w (ORCPT + 99 others); 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-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) -- 2.28.0