From mboxrd@z Thu Jan 1 00:00:00 1970 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_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 86BD4C433E0 for ; Mon, 20 Jul 2020 13:31:54 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B18522BF3 for ; Mon, 20 Jul 2020 13:31:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bzw05a6g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B18522BF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4943387E60; Mon, 20 Jul 2020 13:31:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B4FrDILKEfqt; Mon, 20 Jul 2020 13:31:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id AFC2C878A8; Mon, 20 Jul 2020 13:31:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 96AADC089F; Mon, 20 Jul 2020 13:31:53 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D5C4C016F for ; Mon, 20 Jul 2020 13:31:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 39FD187688 for ; Mon, 20 Jul 2020 13:31:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CjCLPqvvIo30 for ; Mon, 20 Jul 2020 13:31:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by whitealder.osuosl.org (Postfix) with ESMTPS id AC95787680 for ; Mon, 20 Jul 2020 13:31:51 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id gc9so10245688pjb.2 for ; Mon, 20 Jul 2020 06: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=PZjzGiciE1mRdv57FSEZmpziMkegKz0PO+BIzmQwRfA=; b=bzw05a6gk51C2yd1FBssAkJPG1LVfOBywHQPUwbmRKXfu+jA+DfssuhmxRncn9dQNQ oJgenuKpN1Dus8Hv2Vd5nLa/6NOdeX47TonvsvMDe14cysjtEAZ0nu/mMbacAJqboqnm gpDwvCUEexQjN/7qSUOVdtadjTUw2nXNonRa40T3LrzuUbgZXUfV/lTY0/h7i0t0HDjx t86vBPEncGHX1M+pvNOXozW00K15BoLKJGPwSdMpm2eqziCaZQjaalw+IXp1PEizhLG+ TMsJ800WHopDFIRzCKctMPasxhnWj2OtqNfUBX93KeU6OKcQ7ItFn1s9egJ/tawpzFFp X3kg== 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=PZjzGiciE1mRdv57FSEZmpziMkegKz0PO+BIzmQwRfA=; b=mpstXLz6/lygyk9jijg/L99My6WmShDaWQxUaU8TudCZaQPCf2d8FWCZxuJXPNCmAx XwM+8amJSfnRc9+eLhCifoElog4h+tuhpjzEYv2u9RXgrPczHDUladUOnwO7E1EgeO2d 7v6pEkDmFQfCeGd/OMYXSEKqmknLqoErn4adDVe9EtaOFFNe5ykQTX47CaINsoOCh2EU 0UEODy3108G9amex5aLCDFDxOz0JsGFyx3FMD0yaaEZ/MfxMmRbXsOCQvmgw1eTGNACu PApjWkxG/Zymr146SID1JHu1OONtG2ga/J5p3ZPZxZam3Nj52ViUw+EepDF1TerSGaQX o1Ow== X-Gm-Message-State: AOAM532rvwV0hxFsnQLDLMBri2nR4jnLWjbqmRXZrHi859roXrU7+QZ5 Sv1YH1i2D55WUW0p/nYWosY= X-Google-Smtp-Source: ABdhPJw9vk9NP6XxFmMyM/2EeMLZVUTlXr1BsNwtGbmp/wnpbXjTGcXLG/qRRf5LzwMhMZUyvqln6g== X-Received: by 2002:a17:902:6bc2:: with SMTP id m2mr18658312plt.158.1595251911142; Mon, 20 Jul 2020 06:31:51 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id t5sm14814356pgl.38.2020.07.20.06.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 06:31:50 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Jens Axboe , Joshua Morris , Philip Kelleher , Damien Le Moal Date: Mon, 20 Jul 2020 19:00:00 +0530 Message-Id: <20200720133002.448809-2-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720133002.448809-1-vaibhavgupta40@gmail.com> References: <20200720133002.448809-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Cc: linux-block@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, Vaibhav Gupta Subject: [Linux-kernel-mentees] [PATCH v2 1/3] mtip32xx: use generic power management X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" Drivers using legacy PM have to manage PCI states and device's PM states themselves. They also need to take care of configuration registers. With improved and powerful support of generic PM, PCI Core takes care of above mentioned, device-independent, jobs. This driver makes use of PCI helper functions like pci_save/restore_state(), pci_disable_device(), pcim_enable_device(), pci_set_power_state() and pci_set_master() to do required operations. In generic mode, they are no longer needed. Change function parameter in both .suspend() and .resume() to "struct device*" type. Use dev_get_drvdata() to get drv data. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/block/mtip32xx/mtip32xx.c | 54 +++++++------------------------ 1 file changed, 12 insertions(+), 42 deletions(-) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index f6bafa9a68b9..7d1280952b35 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -4246,14 +4246,13 @@ static void mtip_pci_remove(struct pci_dev *pdev) * 0 Success * <0 Error */ -static int mtip_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) +static int __maybe_unused mtip_pci_suspend(struct device *dev) { int rv = 0; - struct driver_data *dd = pci_get_drvdata(pdev); + struct driver_data *dd = dev_get_drvdata(dev); if (!dd) { - dev_err(&pdev->dev, - "Driver private datastructure is NULL\n"); + dev_err(dev, "Driver private datastructure is NULL\n"); return -EFAULT; } @@ -4261,21 +4260,8 @@ static int mtip_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) /* Disable ports & interrupts then send standby immediate */ rv = mtip_block_suspend(dd); - if (rv < 0) { - dev_err(&pdev->dev, - "Failed to suspend controller\n"); - return rv; - } - - /* - * Save the pci config space to pdev structure & - * disable the device - */ - pci_save_state(pdev); - pci_disable_device(pdev); - - /* Move to Low power state*/ - pci_set_power_state(pdev, PCI_D3hot); + if (rv < 0) + dev_err(dev, "Failed to suspend controller\n"); return rv; } @@ -4287,42 +4273,25 @@ static int mtip_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) * 0 Success * <0 Error */ -static int mtip_pci_resume(struct pci_dev *pdev) +static int __maybe_unused mtip_pci_resume(struct device *dev) { int rv = 0; struct driver_data *dd; - dd = pci_get_drvdata(pdev); + dd = dev_get_drvdata(dev); if (!dd) { - dev_err(&pdev->dev, - "Driver private datastructure is NULL\n"); + dev_err(dev, "Driver private datastructure is NULL\n"); return -EFAULT; } - /* Move the device to active State */ - pci_set_power_state(pdev, PCI_D0); - - /* Restore PCI configuration space */ - pci_restore_state(pdev); - - /* Enable the PCI device*/ - rv = pcim_enable_device(pdev); - if (rv < 0) { - dev_err(&pdev->dev, - "Failed to enable card during resume\n"); - goto err; - } - pci_set_master(pdev); - /* * Calls hbaReset, initPort, & startPort function * then enables interrupts */ rv = mtip_block_resume(dd); if (rv < 0) - dev_err(&pdev->dev, "Unable to resume\n"); + dev_err(dev, "Unable to resume\n"); -err: clear_bit(MTIP_DDF_RESUME_BIT, &dd->dd_flag); return rv; @@ -4353,14 +4322,15 @@ static const struct pci_device_id mtip_pci_tbl[] = { { 0 } }; +static SIMPLE_DEV_PM_OPS(mtip_pci_pm_ops, mtip_pci_suspend, mtip_pci_resume); + /* Structure that describes the PCI driver functions. */ static struct pci_driver mtip_pci_driver = { .name = MTIP_DRV_NAME, .id_table = mtip_pci_tbl, .probe = mtip_pci_probe, .remove = mtip_pci_remove, - .suspend = mtip_pci_suspend, - .resume = mtip_pci_resume, + .driver.pm = &mtip_pci_pm_ops, .shutdown = mtip_pci_shutdown, }; -- 2.27.0 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees