Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4556898pxa; Mon, 10 Aug 2020 12:02:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuUHEmSdtgTt1/xwgLUSJ/NrEnBn9zDGt86tNtPH6sRDWD+QKpMxy2usvD9x6pavZYCKRN X-Received: by 2002:a17:907:9483:: with SMTP id dm3mr23783022ejc.333.1597086149468; Mon, 10 Aug 2020 12:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597086149; cv=none; d=google.com; s=arc-20160816; b=Vs6hP4QiIK9PQ4viEW+wfMepIUa+mxtyDmFUDqaBGNvNbEqsehMLMy3ovkTGkUR4bn Txm+NP78+p4gSe0OWRsp1fFniLlO85BY3JjFIWLXk5lRKPl5RezKbP9euO4pe7mfr+I1 DOlUf6OePQdZ2z3fsL320VItWULPpkj82JSfkR+pxbVrVzajYrZAs0XsrWyoBQpIf8Gw gu+4bBQ+jkdubNwv1ofn9FMgtXYgTAq8VjSmxz/VVTyO7y4d7OAJCRc7I7EnGfQEnRnK z8OtsuaeNIF4TnDlDz+O+OmwyQTkTd4N6lUmPk3L+nPJyq0y6ueprcKMJfu+7kXn2h9J uuDw== 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=Z0+jOHm8rOkNKyaunCdMu5yjlq5vV0eABQayoJ0528s=; b=TvAaG4f+6WV0oolYR5ZMOOqKZKrYd1d00QoK8qIO7PfUh6Uh8TbCW7rgHOWAA+hiOP PX23sLXQKYjx26lVUamZ3lwd7Y+BAqkl9/oX16PUrT7sWZxG5N5fTls67rF49Lw6T36E 7ax8E3O+asMWw00Xurzjp+4j1aZ9xQ4CNrbnwcUe5zE6jXpmFxtrE2aOYdVywHULv50T ++c/riE49JAsV4dQ7mZpQ/En2hId1WlLWaZaZsZFDu2/cLzwH/VnXCBaizQeTFUURyOP LpA0N3D5Z8bMuAzTi+FRPBnU2tiwamKSCn87h3c33Fg1+PpIaDPvJbhgeh5e2uAuQrcs jdLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ivA1aaBU; 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 bq11si11300768ejb.126.2020.08.10.12.02.06; Mon, 10 Aug 2020 12:02:29 -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=ivA1aaBU; 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 S1728215AbgHJTA3 (ORCPT + 99 others); Mon, 10 Aug 2020 15:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728135AbgHJTA2 (ORCPT ); Mon, 10 Aug 2020 15:00:28 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F17C061756; Mon, 10 Aug 2020 12:00:27 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id k13so5504325plk.13; Mon, 10 Aug 2020 12:00:27 -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=Z0+jOHm8rOkNKyaunCdMu5yjlq5vV0eABQayoJ0528s=; b=ivA1aaBUqdfgaLxoUgpllPwcVHSBM7bdP5tm1sTOPej3S/pjrIeus2jhbAdE9ZCRop gpw9DTZU6CMqhQ2FTPFyjfblMdEJxh8L03aZXKBEdOKPFbT/eAImT6/HCoVWAVeijQhb wQSPdivqd9TnHrk0p1sSpE3hDkzM/sxbQ0NZSJTkVZNWjgd+kvrUhV3mdEGMmEVRyk0Y cKew74EKthOegKVQ8badipz12z+tyVUExgN9P74Swhb0zjXBKnckcSS3ngLcheVdW8Jj /uSJnGJqPSz+yBss5ED6Es1OvvXbxXKz1KFMi++RJhz8DlNDQdi4soe5evQc45D0yoTW Z1kA== 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=Z0+jOHm8rOkNKyaunCdMu5yjlq5vV0eABQayoJ0528s=; b=rYiMMY5zVE6ekdBVR/ULfsTTeAzk2WTFy0e7mOM0Y/m7Spl2b4Gzkg64XKdcXKGl5K OcDpv/2t6IVzgWSciXa0mp7aTb7Ck6Nf1Sgi/686tfTiIPpPQlvHr2XxrBONv9KsEy72 MBjPlkL11e5MvpTGty/xbKCgKlbgFnFxvBU8pQRfSX+tVaFyCjolukYzRYEe34yg8Hm8 8G/bE2Oki8ej+YyD2ohtzIy/fwm9hd9xk7HUppSjn6OcxBXO2WLpwWTJkBySBrsq2lpK 0oAr82amoo7uQ+M6SqeRVsgd+RA+UtiBlgdkiyuNX2TytlZf9vrR7t55i/3v7KcwThqy +Sbw== X-Gm-Message-State: AOAM533SjNyPbZxlOSSspQE49cmKaiRDHmImFAFQ0njWQ/N489CTqh8s X5Lad+pxE/anjCyEpkN+cL7JPB2o4ks9TQ== X-Received: by 2002:a17:902:8d94:: with SMTP id v20mr14878457plo.298.1597086027479; Mon, 10 Aug 2020 12:00:27 -0700 (PDT) Received: from varodek.localdomain ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id f27sm22683547pfk.217.2020.08.10.12.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 12:00:27 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bartlomiej Zolnierkiewicz , Sam Ravnborg , Paul Mackerras , Russell King , Andres Salomon , Antonino Daplas Cc: Vaibhav Gupta , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-geode@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v2 09/12] fbdev: i740fb: use generic power management Date: Tue, 11 Aug 2020 00:27:20 +0530 Message-Id: <20200810185723.15540-10-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200810185723.15540-1-vaibhavgupta40@gmail.com> References: <20200810165458.GA292825@ravnborg.org> <20200810185723.15540-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 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/video/fbdev/i740fb.c | 40 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c index c65ec7386e87..8d7f06fc8a5a 100644 --- a/drivers/video/fbdev/i740fb.c +++ b/drivers/video/fbdev/i740fb.c @@ -1175,16 +1175,11 @@ static void i740fb_remove(struct pci_dev *dev) } } -#ifdef CONFIG_PM -static int i740fb_suspend(struct pci_dev *dev, pm_message_t state) +static int __maybe_unused i740fb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct i740fb_par *par = info->par; - /* don't disable console during hibernation and wakeup from it */ - if (state.event == PM_EVENT_FREEZE || state.event == PM_EVENT_PRETHAW) - return 0; - console_lock(); mutex_lock(&(par->open_lock)); @@ -1197,19 +1192,15 @@ static int i740fb_suspend(struct pci_dev *dev, pm_message_t state) fb_set_suspend(info, 1); - pci_save_state(dev); - pci_disable_device(dev); - pci_set_power_state(dev, pci_choose_state(dev, state)); - mutex_unlock(&(par->open_lock)); console_unlock(); return 0; } -static int i740fb_resume(struct pci_dev *dev) +static int __maybe_unused i740fb_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct i740fb_par *par = info->par; console_lock(); @@ -1218,11 +1209,6 @@ static int i740fb_resume(struct pci_dev *dev) if (par->ref_count == 0) goto fail; - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - if (pci_enable_device(dev)) - goto fail; - i740fb_set_par(info); fb_set_suspend(info, 0); @@ -1231,10 +1217,17 @@ static int i740fb_resume(struct pci_dev *dev) console_unlock(); return 0; } -#else -#define i740fb_suspend NULL -#define i740fb_resume NULL -#endif /* CONFIG_PM */ + +static const struct dev_pm_ops i740fb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = i740fb_suspend, + .resume = i740fb_resume, + .freeze = NULL, + .thaw = i740fb_resume, + .poweroff = i740fb_suspend, + .restore = i740fb_resume, +#endif /* CONFIG_PM_SLEEP */ +}; #define I740_ID_PCI 0x00d1 #define I740_ID_AGP 0x7800 @@ -1251,8 +1244,7 @@ static struct pci_driver i740fb_driver = { .id_table = i740fb_id_table, .probe = i740fb_probe, .remove = i740fb_remove, - .suspend = i740fb_suspend, - .resume = i740fb_resume, + .driver.pm = &i740fb_pm_ops, }; #ifndef MODULE -- 2.27.0