Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1756617ybh; Mon, 20 Jul 2020 06:32:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgOqsZCQI3X2Qs2U5/lNSL0dCth0YYJgjijWz7aWGYsGS+pJCvk2Qq5dJA4mvx8ldGt6o/ X-Received: by 2002:a17:906:3650:: with SMTP id r16mr19903280ejb.465.1595251948088; Mon, 20 Jul 2020 06:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595251948; cv=none; d=google.com; s=arc-20160816; b=xmfClQ8K4MDuWa0qyCV/fyP0lGMye6Ir+YsLr51qzwdH7uRmAjUfh8fQZ4Oz9C3yk0 t/tdwZeCL4fl5YpGtgM4csk6VRn8oydavPJ9rKnIAxg+mAtjTl+S5xVin2U4I1HBKNpC jOobjJqgYWTmmXwwYcxznatPI+PuHHAfOlDcneTk9KI75Ksa6Di/iQXv3TfnwzDwL29R uD3/1qp48rtPvojdfYmej8sNPKn/V/hrWLQH2g2udOYkZOSRqiUT5XSWIzjujFj/aDQk SaMv6ex2xXyH04Q7BibRyVy2ZsR4n8RHjcQQwWnvvQ6tPAywx97Upn9PiAIvb+UvMAwf tSEw== 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=PZjzGiciE1mRdv57FSEZmpziMkegKz0PO+BIzmQwRfA=; b=n1rYpfzL1D9lIRMKrHLRH8Xigpc35NXzk1RH/8Yk0TX30RwErpASXbmistgp+c801c bnPylyNj6yhm9mpI5dlWWBcqUgubr+goO/vhjTkvNGdqvTTPl3nfTz0QRRwhWPCp4AT+ bhH3k5JQJ9pxivDMIVGDgluZN4Y7J8val8iUpcThhme+0HIFVWZ0kjGUU1eE4GJFxss8 rLFWXlssvquyhpOfgVIUoRYkAZLrXCsWp7hT9UYc+fZ6rNhrChfAYk5vdib0+My9P093 IPPfVNdlnj5WtLbDFytHHiB09lIKjQikTv0iPDYCqgmbpgLAi8ueMAbmoqgmYA96GrdP GebA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bzw05a6g; 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 qp2si11136496ejb.598.2020.07.20.06.32.05; Mon, 20 Jul 2020 06:32:28 -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=bzw05a6g; 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 S1726771AbgGTNbw (ORCPT + 99 others); Mon, 20 Jul 2020 09:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbgGTNbv (ORCPT ); Mon, 20 Jul 2020 09:31:51 -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 B6917C061794; Mon, 20 Jul 2020 06:31:51 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id md7so10113674pjb.1; 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=oJb5WEnR9tPJb0kzTOkItK78LrhJ/KcXHxDPDPU/bd9dwaUPRrrWFVz0f70/6j/Vb6 Vfpry2gRNYVj1IGmVM1wtTzCSRTNCP4EVsrrqlCGGljTN0kF/ZSqpvTsZtAorIevPK7o dmXrRIxUs46fdhuFD4N/5VEc7fAG+dMi9XBBAgFGvCr2e5su8zP8h0BR+TaoIWU22vax j2t6O5sew2Exr9bFmkhM/Q2ls29VY9T/TjF2nXSHhWDgTmIWsKVj8Vs/IX9dn09IVLEl JD3DQhWcO/GpdOvD4r8fezfporwNJKkg2RyvchEN2HhGXq1LXc11Dx3aQwcZ7qzbLYnl kemg== X-Gm-Message-State: AOAM533wgsuH4mZXjpTPpuk3mUHDwMfQoRzzy4+7tH4P/9hSqpMIv5tR u1ouCqB9a+U59+6VM7f+PVk= 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 Cc: Vaibhav Gupta , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v2 1/3] mtip32xx: use generic power management 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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