From patchwork Wed Aug 19 18:56:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F186014F6 for ; Thu, 20 Aug 2020 07:15:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D02B620786 for ; Thu, 20 Aug 2020 07:15:24 +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="C/qtghbr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D02B620786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DAAF6E8CC; Thu, 20 Aug 2020 07:14:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5FAC46E5CC for ; Wed, 19 Aug 2020 18:59:05 +0000 (UTC) Received: by mail-pj1-x1043.google.com with SMTP id ds1so1195521pjb.1 for ; Wed, 19 Aug 2020 11:59:05 -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=YOa3gLvydrZ+M8ZPM8t68nbD2HobP2Ca0rk36tt9kOs=; b=C/qtghbrD1UJlZHs7y6FJYluRDf7CVLYC6umtiDsiG0okaZ48xgOnCZVaDIDNIqm/b FW/eWMbuVSTGJEPCgzwngz09k3+JNnmeQ1e/J5WIdsdMK3bzSljXkTU30HJW1pAM/709 JQeRjaK/A0CtwlHIXPKI4SThX1dJcWQqZd4KOfv8VXarjBl2fzLsY1YgeEVy3bCsqwgG fK4xtmeJXjK5V5h08cOj22kPjtmMfZgNCgO1ZzZJ86ug3h1sAQunascNG24dFQs2TIaO XIpVOvJ1QJzcMPICCMmjfCJ5g/BZkJmy5rQ2qkmCDZ23R3rPG7itSNv40EQheWT4zv0P I2PQ== 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=YOa3gLvydrZ+M8ZPM8t68nbD2HobP2Ca0rk36tt9kOs=; b=O5WKoD0m+7mrzkZR3LkEiLOik9h/snHFq3LYeTF+8Zw6ZmBL+xBcyGWgTPZVjnVLsA 9PMXHUbbF3zd0yxrc1/40LMswK3NLUfRtbvie/eehl+UCTGfG1kkrZ+lcXIyBLN1SK0R w/ZUSXL8q54z2MhOVhS/gdBCOH8b5HImR67jwtK8Y1StnWR3DetmT/2Lj6MSmnyoL/SO idV1qgFPE4Ty1/MCItDoVthLhAnO2ZFXIeHwQipE5xprckFA/DADNbjp8Bx1tUCNj3jZ gwTQRBIfpiWcAoYpJVWDDpWdfIMn/dcLLIkAuzAalnJjCjrl+lEhjDmRsxiXSTPRhydj wVSA== X-Gm-Message-State: AOAM5337J9W5/8NtvdFfX+foLYiipRQEoxW3CJ8n0gfYb+qbFioJm2dJ ZLnSSvz/NH4Ep6NRHidlrCU= X-Google-Smtp-Source: ABdhPJxER7aCHiNOQ/dUrb1nUfSCAIhoucl6lnSouMre2qYP5XjMMuE9m++iANKwAsbi1PazpLm+Zg== X-Received: by 2002:a17:90b:378d:: with SMTP id mz13mr5175546pjb.98.1597863544886; Wed, 19 Aug 2020 11:59:04 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:04 -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 Subject: [PATCH v3 01/12] fbdev: gxfb: use generic power management Date: Thu, 20 Aug 2020 00:26:43 +0530 Message-Id: <20200819185654.151170-2-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. This way we can remove the legacy .suspend & .resume bindings from "gxfb_driver". The gxfb_suspend() is designed to function only in the case of Suspend. Thus, the code was kept inside "if (state.event == PM_EVENT_SUSPEND)" container. This is because, in the legacy framework, this callback was invoked even in the event of Freeze and Hibernate. Hence, added the load of unnecessary function-calls. The goal can be achieved by binding the callback with only "gxfb_pm_ops.suspend" in the new framework. This also avoids the step of checking "if (state.event == PM_EVENT_SUSPEND)" every time the callback is invoked. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/geode/gxfb.h | 5 ---- drivers/video/fbdev/geode/gxfb_core.c | 36 ++++++++++++++------------ drivers/video/fbdev/geode/suspend_gx.c | 4 --- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/video/fbdev/geode/gxfb.h b/drivers/video/fbdev/geode/gxfb.h index d2e9c5c8e294..792c111c21e4 100644 --- a/drivers/video/fbdev/geode/gxfb.h +++ b/drivers/video/fbdev/geode/gxfb.h @@ -21,7 +21,6 @@ struct gxfb_par { void __iomem *dc_regs; void __iomem *vid_regs; void __iomem *gp_regs; -#ifdef CONFIG_PM int powered_down; /* register state, for power management functionality */ @@ -36,7 +35,6 @@ struct gxfb_par { uint64_t fp[FP_REG_COUNT]; uint32_t pal[DC_PAL_COUNT]; -#endif }; unsigned int gx_frame_buffer_size(void); @@ -49,11 +47,8 @@ void gx_set_dclk_frequency(struct fb_info *info); void gx_configure_display(struct fb_info *info); int gx_blank_display(struct fb_info *info, int blank_mode); -#ifdef CONFIG_PM int gx_powerdown(struct fb_info *info); int gx_powerup(struct fb_info *info); -#endif - /* Graphics Processor registers (table 6-23 from the data book) */ enum gp_registers { diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c index d38a148d4746..44089b331f91 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -322,17 +322,14 @@ static struct fb_info *gxfb_init_fbinfo(struct device *dev) return info; } -#ifdef CONFIG_PM -static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused gxfb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(pdev); + struct fb_info *info = dev_get_drvdata(dev); - if (state.event == PM_EVENT_SUSPEND) { - console_lock(); - gx_powerdown(info); - fb_set_suspend(info, 1); - console_unlock(); - } + console_lock(); + gx_powerdown(info); + fb_set_suspend(info, 1); + console_unlock(); /* there's no point in setting PCI states; we emulate PCI, so * we don't end up getting power savings anyways */ @@ -340,9 +337,9 @@ static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } -static int gxfb_resume(struct pci_dev *pdev) +static int __maybe_unused gxfb_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(pdev); + struct fb_info *info = dev_get_drvdata(dev); int ret; console_lock(); @@ -356,7 +353,6 @@ static int gxfb_resume(struct pci_dev *pdev) console_unlock(); return 0; } -#endif static int gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { @@ -467,15 +463,23 @@ static const struct pci_device_id gxfb_id_table[] = { MODULE_DEVICE_TABLE(pci, gxfb_id_table); +static const struct dev_pm_ops gxfb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = gxfb_suspend, + .resume = gxfb_resume, + .freeze = NULL, + .thaw = gxfb_resume, + .poweroff = NULL, + .restore = gxfb_resume, +#endif +}; + static struct pci_driver gxfb_driver = { .name = "gxfb", .id_table = gxfb_id_table, .probe = gxfb_probe, .remove = gxfb_remove, -#ifdef CONFIG_PM - .suspend = gxfb_suspend, - .resume = gxfb_resume, -#endif + .driver.pm = &gxfb_pm_ops, }; #ifndef MODULE diff --git a/drivers/video/fbdev/geode/suspend_gx.c b/drivers/video/fbdev/geode/suspend_gx.c index 1110a527c35c..8c49d4e98772 100644 --- a/drivers/video/fbdev/geode/suspend_gx.c +++ b/drivers/video/fbdev/geode/suspend_gx.c @@ -11,8 +11,6 @@ #include "gxfb.h" -#ifdef CONFIG_PM - static void gx_save_regs(struct gxfb_par *par) { int i; @@ -259,5 +257,3 @@ int gx_powerup(struct fb_info *info) par->powered_down = 0; return 0; } - -#endif From patchwork Wed Aug 19 18:56:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725767 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E079618 for ; Thu, 20 Aug 2020 07:17:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5D11020786 for ; Thu, 20 Aug 2020 07:17:30 +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="NBcnrI+I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D11020786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 441D46E905; Thu, 20 Aug 2020 07:16:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC1D36E5C8 for ; Wed, 19 Aug 2020 18:59:11 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id m8so12156028pfh.3 for ; Wed, 19 Aug 2020 11:59:11 -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=EueH97o6VIVtEIiLMj1CkjU5GKTUR/PQiOa7YU1wTr0=; b=NBcnrI+ILjh3jELjrGG+qDgvlGLTfpZWaAD8dfjOYKDeId+yC5B/nedpjjEDPs7MJt ibC4avtU4xcpmoE5ULoOcJAmmYq4qNB7MUEmgYPubcHq2yGCcKTDG+yTvrs6xY1+duLn MJoV/YDWfMQJJ8xM1MvvfzlICMUDpBWEKZyOkmSI0S6rGlGxJwU4BMhwzeeaBJLpAhWn Y/q7sMI+06WGFnSR1Jku2olJy2n4ROcztnPEXC78DSlVZPg1TDbD1jchPUnoa6BdHZR+ S0WZ/lmNZ5AcpUf6QP4Im7SBijhLCA2/2VprKYFChPl+VrA5wp86Ko3I6BpmT9eL2O6M kGqA== 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=EueH97o6VIVtEIiLMj1CkjU5GKTUR/PQiOa7YU1wTr0=; b=ehMuFwxi81uDGKiWzNFKXje6hwSmx9BGs9w7vXTh9v1UoXTp4ulTljqc+KUEre76Gp gzflrz0Z1VdR2HMZTqGiwGrGuv9RqvmNdx01a+qSCqRz7rkMZs43csv1ZOrDR8OSw9P4 +47walbutkAZ1UGiDWOr2kas4StlCIcrblFSZmG07BoCKXdeSGXYZY6J3OXdoMSnlJ4H /oI+Y5tWqUO0klxCC2HIQ1dLAwh7K5zovWM8khNVb3zW776ztiJMFeOkmTPa7nDV2dl0 k8raZUl+g92Zh3s+H6NldiWRSE+392zPQDC/TGyVo9Kg88U6Pnn3GzcphdW8NEWlQJ28 ZtHw== X-Gm-Message-State: AOAM530PMn4GEusIFIHDZs/YsBnDSzT/hafh18xN5fzjutD3mQmj2/Hk mndSKILBtViqBWYfFGH6SNU= X-Google-Smtp-Source: ABdhPJzycF9YEJOQ5XOCi+2XKILR/b07UiFGPGDk2y6A/OtI9ObJBJksHh+9i+w9mHTz6yRi1btLzQ== X-Received: by 2002:a63:de4e:: with SMTP id y14mr18144996pgi.106.1597863551453; Wed, 19 Aug 2020 11:59:11 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:11 -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 Subject: [PATCH v3 02/12] fbdev: lxfb: use generic power management Date: Thu, 20 Aug 2020 00:26:44 +0530 Message-Id: <20200819185654.151170-3-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. This way we can remove the legacy .suspend & .resume bindings from "lxfb_driver". The lxfb_suspend() is designed to function only in the case of Suspend. Thus, the code was kept inside "if (state.event == PM_EVENT_SUSPEND)" container. This is because, in the legacy framework, this callback was invoked even in the event of Freeze and Hibernate. Hence, added the load of unnecessary function-calls. The goal can be achieved by binding the callback with only "lxfb_pm_ops.suspend" in the new framework. This also avoids the step of checking "if (state.event == PM_EVENT_SUSPEND)" every time the callback is invoked. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/geode/lxfb.h | 5 ---- drivers/video/fbdev/geode/lxfb_core.c | 37 +++++++++++++++------------ drivers/video/fbdev/geode/lxfb_ops.c | 4 --- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/video/fbdev/geode/lxfb.h b/drivers/video/fbdev/geode/lxfb.h index ef24bf6d49dc..d37b32dbcd68 100644 --- a/drivers/video/fbdev/geode/lxfb.h +++ b/drivers/video/fbdev/geode/lxfb.h @@ -29,7 +29,6 @@ struct lxfb_par { void __iomem *gp_regs; void __iomem *dc_regs; void __iomem *vp_regs; -#ifdef CONFIG_PM int powered_down; /* register state, for power mgmt functionality */ @@ -50,7 +49,6 @@ struct lxfb_par { uint32_t hcoeff[DC_HFILT_COUNT * 2]; uint32_t vcoeff[DC_VFILT_COUNT]; uint32_t vp_coeff[VP_COEFF_SIZE / 4]; -#endif }; static inline unsigned int lx_get_pitch(unsigned int xres, int bpp) @@ -64,11 +62,8 @@ int lx_blank_display(struct fb_info *, int); void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int, unsigned int, unsigned int); -#ifdef CONFIG_PM int lx_powerdown(struct fb_info *info); int lx_powerup(struct fb_info *info); -#endif - /* Graphics Processor registers (table 6-29 from the data book) */ enum gp_registers { diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c index adc2d9c2395e..66c81262d18f 100644 --- a/drivers/video/fbdev/geode/lxfb_core.c +++ b/drivers/video/fbdev/geode/lxfb_core.c @@ -443,17 +443,14 @@ static struct fb_info *lxfb_init_fbinfo(struct device *dev) return info; } -#ifdef CONFIG_PM -static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused lxfb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(pdev); + struct fb_info *info = dev_get_drvdata(dev); - if (state.event == PM_EVENT_SUSPEND) { - console_lock(); - lx_powerdown(info); - fb_set_suspend(info, 1); - console_unlock(); - } + console_lock(); + lx_powerdown(info); + fb_set_suspend(info, 1); + console_unlock(); /* there's no point in setting PCI states; we emulate PCI, so * we don't end up getting power savings anyways */ @@ -461,9 +458,9 @@ static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } -static int lxfb_resume(struct pci_dev *pdev) +static int __maybe_unused lxfb_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(pdev); + struct fb_info *info = dev_get_drvdata(dev); int ret; console_lock(); @@ -477,10 +474,6 @@ static int lxfb_resume(struct pci_dev *pdev) console_unlock(); return 0; } -#else -#define lxfb_suspend NULL -#define lxfb_resume NULL -#endif static int lxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { @@ -600,13 +593,23 @@ static struct pci_device_id lxfb_id_table[] = { MODULE_DEVICE_TABLE(pci, lxfb_id_table); +static const struct dev_pm_ops lxfb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = lxfb_suspend, + .resume = lxfb_resume, + .freeze = NULL, + .thaw = lxfb_resume, + .poweroff = NULL, + .restore = lxfb_resume, +#endif +}; + static struct pci_driver lxfb_driver = { .name = "lxfb", .id_table = lxfb_id_table, .probe = lxfb_probe, .remove = lxfb_remove, - .suspend = lxfb_suspend, - .resume = lxfb_resume, + .driver.pm = &lxfb_pm_ops, }; #ifndef MODULE diff --git a/drivers/video/fbdev/geode/lxfb_ops.c b/drivers/video/fbdev/geode/lxfb_ops.c index 5be8bc62844c..b3a041fce570 100644 --- a/drivers/video/fbdev/geode/lxfb_ops.c +++ b/drivers/video/fbdev/geode/lxfb_ops.c @@ -580,8 +580,6 @@ int lx_blank_display(struct fb_info *info, int blank_mode) return 0; } -#ifdef CONFIG_PM - static void lx_save_regs(struct lxfb_par *par) { uint32_t filt; @@ -837,5 +835,3 @@ int lx_powerup(struct fb_info *info) par->powered_down = 0; return 0; } - -#endif From patchwork Wed Aug 19 18:56:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725769 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08895618 for ; Thu, 20 Aug 2020 07:17:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 DB4B72078B for ; Thu, 20 Aug 2020 07:17:34 +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="XRI53D3h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB4B72078B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CEFA86E918; Thu, 20 Aug 2020 07:16:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id AF44D6E5CD for ; Wed, 19 Aug 2020 18:59:18 +0000 (UTC) Received: by mail-pl1-x641.google.com with SMTP id y6so11282033plt.3 for ; Wed, 19 Aug 2020 11:59:18 -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=5gu1L1DJx3HZoPEqXvBU7h0G5D/PQrdVvm6X6301gs8=; b=XRI53D3hmlnwd6aCroLhIz21NDdW0P2mVstADmsVDG+e0ejag70GGABL3/HXR5kaPQ 6AgnJQHVfgwQH1Y4r19MSJUL92/LvoOfdo6XIWEyAjIiIx4qlUZRSJppQfsSoF+igE3k gaj9S8c+4AQbPaSGREm0duechoKwcUIa1XeBWR61Ey2hbIeQLP6i9yO+pdeYdxoA1GwW w1BcEHxHCslecf14xvl5tXlj+my9yEBz3hXxzN2AOP67thiCRGsYSSFFB8dYCCjsKbxm v3jyeM13isALOM349gQTJWR5B+c6+x/8lw85ecktWMCTFLc+J+orIRcxchE1CrNAdcbi tuyA== 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=5gu1L1DJx3HZoPEqXvBU7h0G5D/PQrdVvm6X6301gs8=; b=Xx/XKZIqeqBZTlTHQMSRQXFxE0JkTaB8jfzqv1aTHNaFs3lT1FDTioSxsEcMG0cYyO HZR0L4WzRwYqLpr/mX1M5Fk6Ay3KcndH+suD9GIhS0Qpq2nCe3xrfvE5VIOrJmBqR+4l 7kSRzNbhEelh8ZJEbIHCHv1gxM7NUkalYqPTyAwGQdOiX65kcoxINLOy/VT8/Slbl+89 Jqr4jeyizp/94JP2OLqE6vMH0FWwH/QAWBjdEULnZqk/xGspnrbcMWy7QkhLpiL4GtDz mUqgQPfL75w5H1YQlfE5DwUZBnateNJcajSGhy3BUfAvhoKarTosgMGVoE0FKn0ajuk4 wAqg== X-Gm-Message-State: AOAM530Tsn7VrDO7ICsuPB7Eha4wta2s1RaumEosFDesTJl55D5M7iny gQcXAU/BEebaJKLvgBZHGrI= X-Google-Smtp-Source: ABdhPJzRMuPqM05NiCBiCDG5w1q8EIlZqgTaIxB3DmIfl9PFQS4Xr6+hIyQiWWSHjmx/62qPjMtQNA== X-Received: by 2002:a17:90b:368c:: with SMTP id mj12mr4711893pjb.152.1597863558293; Wed, 19 Aug 2020 11:59:18 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:17 -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 Subject: [PATCH v3 03/12] fbdev: via-core: use generic power management Date: Thu, 20 Aug 2020 00:26:45 +0530 Message-Id: <20200819185654.151170-4-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. The via_suspend() is designed to function only in the case of Suspend. Thus, the code checked for "if (state.event != PM_EVENT_SUSPEND)". This is because, in the legacy framework, this callback was invoked even in the event of Freeze and Hibernate. Hence, added the load of unnecessary function-calls. The goal can be achieved by binding the callback with only "via_pm_ops.suspend" in the new framework. This also avoids the step of checking "if (state.event != PM_EVENT_SUSPEND)" every time the callback is invoked. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/via/via-core.c | 39 ++++++++++++------------------ include/linux/via-core.h | 2 -- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/video/fbdev/via/via-core.c b/drivers/video/fbdev/via/via-core.c index 703ddee9a244..89d75079b730 100644 --- a/drivers/video/fbdev/via/via-core.c +++ b/drivers/video/fbdev/via/via-core.c @@ -558,9 +558,8 @@ static void via_teardown_subdevs(void) /* * Power management functions */ -#ifdef CONFIG_PM -static LIST_HEAD(viafb_pm_hooks); -static DEFINE_MUTEX(viafb_pm_hooks_lock); +static __maybe_unused LIST_HEAD(viafb_pm_hooks); +static __maybe_unused DEFINE_MUTEX(viafb_pm_hooks_lock); void viafb_pm_register(struct viafb_pm_hooks *hooks) { @@ -580,12 +579,10 @@ void viafb_pm_unregister(struct viafb_pm_hooks *hooks) } EXPORT_SYMBOL_GPL(viafb_pm_unregister); -static int via_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused via_suspend(struct device *dev) { struct viafb_pm_hooks *hooks; - if (state.event != PM_EVENT_SUSPEND) - return 0; /* * "I've occasionally hit a few drivers that caused suspend * failures, and each and every time it was a driver bug, and @@ -600,24 +597,13 @@ static int via_suspend(struct pci_dev *pdev, pm_message_t state) hooks->suspend(hooks->private); mutex_unlock(&viafb_pm_hooks_lock); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -static int via_resume(struct pci_dev *pdev) +static int __maybe_unused via_resume(struct device *dev) { struct viafb_pm_hooks *hooks; - /* Get the bus side powered up */ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - if (pci_enable_device(pdev)) - return 0; - - pci_set_master(pdev); - /* Now bring back any subdevs */ mutex_lock(&viafb_pm_hooks_lock); list_for_each_entry(hooks, &viafb_pm_hooks, list) @@ -626,7 +612,6 @@ static int via_resume(struct pci_dev *pdev) return 0; } -#endif /* CONFIG_PM */ static int via_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -712,15 +697,23 @@ static const struct pci_device_id via_pci_table[] = { }; MODULE_DEVICE_TABLE(pci, via_pci_table); +static const struct dev_pm_ops via_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = via_suspend, + .resume = via_resume, + .freeze = NULL, + .thaw = via_resume, + .poweroff = NULL, + .restore = via_resume, +#endif +}; + static struct pci_driver via_driver = { .name = "viafb", .id_table = via_pci_table, .probe = via_pci_probe, .remove = via_pci_remove, -#ifdef CONFIG_PM - .suspend = via_suspend, - .resume = via_resume, -#endif + .driver.pm = &via_pm_ops, }; static int __init via_core_init(void) diff --git a/include/linux/via-core.h b/include/linux/via-core.h index 9e802deedb2d..8737599b9148 100644 --- a/include/linux/via-core.h +++ b/include/linux/via-core.h @@ -47,7 +47,6 @@ struct via_port_cfg { /* * Allow subdevs to register suspend/resume hooks. */ -#ifdef CONFIG_PM struct viafb_pm_hooks { struct list_head list; int (*suspend)(void *private); @@ -57,7 +56,6 @@ struct viafb_pm_hooks { void viafb_pm_register(struct viafb_pm_hooks *hooks); void viafb_pm_unregister(struct viafb_pm_hooks *hooks); -#endif /* CONFIG_PM */ /* * This is the global viafb "device" containing stuff needed by From patchwork Wed Aug 19 18:56:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17C6F14F6 for ; Thu, 20 Aug 2020 07:16:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 EAD9820786 for ; Thu, 20 Aug 2020 07:16:48 +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="YSsPXgdb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAD9820786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73FCC6E8F3; Thu, 20 Aug 2020 07:15:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 738CF6E5CC for ; Wed, 19 Aug 2020 18:59:25 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id 128so11843200pgd.5 for ; Wed, 19 Aug 2020 11:59:25 -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=6SwW9DvsaTVzEe8rYytiBA176ZEm49NeUyegN/TvZxk=; b=YSsPXgdbsE6HMZQBWbvHa516SeqorDSP49+EHMEd67zIXPQeYtQtmOAjF56GHZ4ENC Xes44b5QftvrU0bHvqmBY/RJBqIT/mqJOJMuwq5oR550n1Dt39WkwKAtb56Jp/BNpapU n5xcaM+eXqCMXR11855GweHH4jxNv8qQVFzY8PxtYAY32anTsYLwg42iteXgiQv3cVoH jyaR9706HrP9cwbBlREmMl7vs9xrggzmsyU2mJgfjvc/r1XVeumsdfG61K8EDi+P9Vx0 xOhdUfcyDgzEOOsSKCza8JUml+9+kIoZ2cc/CG4h5ByYWhQfiFmQ0so34lSoaOfYBJV1 kbkg== 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=6SwW9DvsaTVzEe8rYytiBA176ZEm49NeUyegN/TvZxk=; b=BV8sCLysnYW2Uxwm2OVb7062fAfHFhtiSvLlcoij4aYKlTfe0c+PjdJ6vNm5EaH9ZN 6lhMpxMbIYkHo3DkHLT2byQeZJ3lRUDGcS0fkSZRJRPL6T3y4TL6ye76RfY3KoTCntQ/ vWXT4rsMYiUHODM0deybLe2ekmoSGWuTimQ1PXX6ltP1bxDMsfeZgckEcl6p7MRMTRjW Qoy+IumYVF8BJSNq/fAiFJaJxhXNFPN70FvlphZVo1+UtXuIjd49iAZ4zY1C7p2imLLP 3o2vOslmAklC/Qprtb1qJk1zcFPc0cTtrKWQo/HeRizd7Lkyu3wKS84DD3rBNL2rI6ZE nAtw== X-Gm-Message-State: AOAM533lESfSrdCfLZ3J7ZIyd7jLSoLGnEAMko95XZ6ma6YNk9epOIfV HfkTlme9J73zcrKNSLMmD2gNtCSle3CWT511 X-Google-Smtp-Source: ABdhPJzlZoB9mX9uX/0f4umZ3wploRhwn9d7X9NR1Pk93n4y87Cd9Zl8KupRYvEiMnjWyJTmoxrHHQ== X-Received: by 2002:aa7:8757:: with SMTP id g23mr20042724pfo.283.1597863564965; Wed, 19 Aug 2020 11:59:24 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:24 -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 Subject: [PATCH v3 04/12] fbdev: aty: use generic power management Date: Thu, 20 Aug 2020 00:26:46 +0530 Message-Id: <20200819185654.151170-5-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Now, - atyfb_pci_suspend() had a "pm_message_t" type parameter as per legacy PCI PM framework, that got deprecated in generic. - Rename the callback as atyfb_pci_suspend_late() and preserve the parameter. - Define 3 new callbacks as: * atyfb_pci_suspend() * atyfb_pci_freeze() * atyfb_pci_hibernate() which in turn call atyfb_pci_suspend_late() by passing appropriate value for "pm_message_t" type parameter. - Bind the callbacks in "struct dev_pm_ops" type variable "atyfb_pci_pm_ops". Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/aty/atyfb_base.c | 50 ++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c index b0ac895e5ac9..a24d5bf6ade1 100644 --- a/drivers/video/fbdev/aty/atyfb_base.c +++ b/drivers/video/fbdev/aty/atyfb_base.c @@ -132,8 +132,8 @@ #define PRINTKI(fmt, args...) printk(KERN_INFO "atyfb: " fmt, ## args) #define PRINTKE(fmt, args...) printk(KERN_ERR "atyfb: " fmt, ## args) -#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \ -defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT) +#if defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_GENERIC_LCD) || \ +defined(CONFIG_FB_ATY_BACKLIGHT) static const u32 lt_lcd_regs[] = { CNFG_PANEL_LG, LCD_GEN_CNTL_LG, @@ -175,7 +175,7 @@ u32 aty_ld_lcd(int index, const struct atyfb_par *par) return aty_ld_le32(LCD_DATA, par); } } -#endif /* defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */ +#endif /* defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */ #ifdef CONFIG_FB_ATY_GENERIC_LCD /* @@ -1994,7 +1994,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma) -#if defined(CONFIG_PM) && defined(CONFIG_PCI) +#if defined(CONFIG_PCI) #ifdef CONFIG_PPC_PMAC /* Power management routines. Those are used for PowerBook sleep. @@ -2055,8 +2055,9 @@ static int aty_power_mgmt(int sleep, struct atyfb_par *par) } #endif /* CONFIG_PPC_PMAC */ -static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) +static int atyfb_pci_suspend_late(struct device *dev, pm_message_t state) { + struct pci_dev *pdev = to_pci_dev(dev); struct fb_info *info = pci_get_drvdata(pdev); struct atyfb_par *par = (struct atyfb_par *) info->par; @@ -2082,7 +2083,6 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) * first save the config space content so the core can * restore it properly on resume. */ - pci_save_state(pdev); #ifdef CONFIG_PPC_PMAC /* Set chip to "suspend" mode */ @@ -2094,8 +2094,6 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) console_unlock(); return -EIO; } -#else - pci_set_power_state(pdev, pci_choose_state(pdev, state)); #endif console_unlock(); @@ -2105,6 +2103,21 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } +static int __maybe_unused atyfb_pci_suspend(struct device *dev) +{ + return atyfb_pci_suspend_late(dev, PMSG_SUSPEND); +} + +static int __maybe_unused atyfb_pci_hibernate(struct device *dev) +{ + return atyfb_pci_suspend_late(dev, PMSG_HIBERNATE); +} + +static int __maybe_unused atyfb_pci_freeze(struct device *dev) +{ + return atyfb_pci_suspend_late(dev, PMSG_FREEZE); +} + static void aty_resume_chip(struct fb_info *info) { struct atyfb_par *par = info->par; @@ -2119,8 +2132,9 @@ static void aty_resume_chip(struct fb_info *info) aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par); } -static int atyfb_pci_resume(struct pci_dev *pdev) +static int __maybe_unused atyfb_pci_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct fb_info *info = pci_get_drvdata(pdev); struct atyfb_par *par = (struct atyfb_par *) info->par; @@ -2162,7 +2176,18 @@ static int atyfb_pci_resume(struct pci_dev *pdev) return 0; } -#endif /* defined(CONFIG_PM) && defined(CONFIG_PCI) */ +static const struct dev_pm_ops atyfb_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = atyfb_pci_suspend, + .resume = atyfb_pci_resume, + .freeze = atyfb_pci_freeze, + .thaw = atyfb_pci_resume, + .poweroff = atyfb_pci_hibernate, + .restore = atyfb_pci_resume, +#endif /* CONFIG_PM_SLEEP */ +}; + +#endif /* defined(CONFIG_PCI) */ /* Backlight */ #ifdef CONFIG_FB_ATY_BACKLIGHT @@ -3801,10 +3826,7 @@ static struct pci_driver atyfb_driver = { .id_table = atyfb_pci_tbl, .probe = atyfb_pci_probe, .remove = atyfb_pci_remove, -#ifdef CONFIG_PM - .suspend = atyfb_pci_suspend, - .resume = atyfb_pci_resume, -#endif /* CONFIG_PM */ + .driver.pm = &atyfb_pci_pm_ops, }; #endif /* CONFIG_PCI */ From patchwork Wed Aug 19 18:56:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F10414F6 for ; Thu, 20 Aug 2020 07:15:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 48D1B206DA for ; Thu, 20 Aug 2020 07:15:12 +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="WmNYstIS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48D1B206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27C1F6E8BB; Thu, 20 Aug 2020 07:14:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by gabe.freedesktop.org (Postfix) with ESMTPS id B45546E5C8 for ; Wed, 19 Aug 2020 18:59:31 +0000 (UTC) Received: by mail-pj1-x1044.google.com with SMTP id j13so1539956pjd.4 for ; Wed, 19 Aug 2020 11:59:31 -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=KtowsW54CIH+aT0/jhxelve2MZUhDg13YFERcRrbgHw=; b=WmNYstISRHwOeAf0FGSM0IPG3HBnf4AqyKlBux3aJdNzth/QrG5bn8O+IRhd/BjIFj 3QA/UCGwVBNfa5Gx8QbudVrcTQev3fH2OmmFxOJMpbprkhCx2sG4ciLLKgQVsbLJJF/i 31Hg5QdbhFKr86rLw/4NetVyLqGHQ+BXbxJAxKkCjmCBBaVy9gcb9IQz+sAG/LChmWyS RQD3sIO/Tv/7BHUrAz2QnvU8d2OKErKh1vhgXQBH2qcRoG/RDhLt3v4gHwV+JQrVacq1 /Wfb3n9sped8ReXXl/Os5u/rchvZMA2nz34+vDOWZe+Ds4/dHqnik1aV8JMNTNfrWVcz z/zA== 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=KtowsW54CIH+aT0/jhxelve2MZUhDg13YFERcRrbgHw=; b=pWo5hLwTW+b9hJb+A7vQSI0irI+SJr7QnCUik0yGXMGcuB7A1SYx54A2vdbTv4M+i2 F4t1m1ewc/czfz4cH/85nhH5DQsRHuUdKz830wM2auNnVxpm9d3eAXWlRqt61wHqZYy1 lwI40z5OOKCfo2jZ8qzD/8ZF2hjBdC9CK9Hg9HiT3VMr/q88OvgPY+01FO58onIkGzuo qrAlSOoWqfqIJdi+UTcFGhb0M1aLGjfce4Z42LBNY81HbvSzoIP08n//zQsIG1AFc0cO 3jtt2Uw9FUCzvWwhnBvBfer/KahaGoB8RRAJfvvOyyPDv2N5vuEf1NT7CeYwruqutKb0 j1fA== X-Gm-Message-State: AOAM531KSOTYCgvGhe19MxKpJij+pqz0q7UEVIArY9XUjCtQXAPt8hgo ZuirctW1k2QHKNxcBhIRaAnCwgkJ04HbDTJE X-Google-Smtp-Source: ABdhPJyWWnkREn6S/ocS/XEl7VBCiZNYSvodonqmmXZ2LmuacmcagP6m5NS2PU76whZYNetYqJxs3g== X-Received: by 2002:a17:90a:dd45:: with SMTP id u5mr2892253pjv.198.1597863571216; Wed, 19 Aug 2020 11:59:31 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:30 -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 Subject: [PATCH v3 05/12] fbdev: aty128fb: use generic power management Date: Thu, 20 Aug 2020 00:26:47 +0530 Message-Id: <20200819185654.151170-6-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Now, - aty128_pci_suspend() had a "pm_message_t" type parameter as per legacy PCI PM framework that got deprecated in generic. - Rename the callback as aty128_pci_suspend_late() and preserve the parameter. - Define 3 new callbacks as: * aty128_pci_suspend() * aty128_pci_freeze() * aty128_pci_hibernate() which in turn call aty128_pci_suspend_late() by passing appropriate value for "pm_message_t" type parameter. - Bind the callbacks in "struct dev_pm_ops" type variable "aty128_pci_pm_ops". Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/aty/aty128fb.c | 51 ++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index d05d4195acad..dd7762fea058 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -162,10 +162,22 @@ static char * const r128_family[] = { static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent); static void aty128_remove(struct pci_dev *pdev); -static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state); -static int aty128_pci_resume(struct pci_dev *pdev); +static int aty128_pci_suspend_late(struct device *dev, pm_message_t state); +static int __maybe_unused aty128_pci_suspend(struct device *dev); +static int __maybe_unused aty128_pci_hibernate(struct device *dev); +static int __maybe_unused aty128_pci_freeze(struct device *dev); +static int __maybe_unused aty128_pci_resume(struct device *dev); static int aty128_do_resume(struct pci_dev *pdev); +static const struct dev_pm_ops aty128_pci_pm_ops = { + .suspend = aty128_pci_suspend, + .resume = aty128_pci_resume, + .freeze = aty128_pci_freeze, + .thaw = aty128_pci_resume, + .poweroff = aty128_pci_hibernate, + .restore = aty128_pci_resume, +}; + /* supported Rage128 chipsets */ static const struct pci_device_id aty128_pci_tbl[] = { { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_LE, @@ -272,8 +284,7 @@ static struct pci_driver aty128fb_driver = { .id_table = aty128_pci_tbl, .probe = aty128_probe, .remove = aty128_remove, - .suspend = aty128_pci_suspend, - .resume = aty128_pci_resume, + .driver.pm = &aty128_pci_pm_ops, }; /* packed BIOS settings */ @@ -2320,7 +2331,6 @@ static int aty128fb_ioctl(struct fb_info *info, u_int cmd, u_long arg) static void aty128_set_suspend(struct aty128fb_par *par, int suspend) { u32 pmgt; - struct pci_dev *pdev = par->pdev; if (!par->pdev->pm_cap) return; @@ -2347,23 +2357,15 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend) aty_st_le32(BUS_CNTL1, 0x00000010); aty_st_le32(MEM_POWER_MISC, 0x0c830000); msleep(100); - - /* Switch PCI power management to D2 */ - pci_set_power_state(pdev, PCI_D2); } } -static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state) +static int aty128_pci_suspend_late(struct device *dev, pm_message_t state) { + struct pci_dev *pdev = to_pci_dev(dev); struct fb_info *info = pci_get_drvdata(pdev); struct aty128fb_par *par = info->par; - /* Because we may change PCI D state ourselves, we need to - * first save the config space content so the core can - * restore it properly on resume. - */ - pci_save_state(pdev); - /* We don't do anything but D2, for now we return 0, but * we may want to change that. How do we know if the BIOS * can properly take care of D3 ? Also, with swsusp, we @@ -2422,6 +2424,21 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } +static int __maybe_unused aty128_pci_suspend(struct device *dev) +{ + return aty128_pci_suspend_late(dev, PMSG_SUSPEND); +} + +static int __maybe_unused aty128_pci_hibernate(struct device *dev) +{ + return aty128_pci_suspend_late(dev, PMSG_HIBERNATE); +} + +static int __maybe_unused aty128_pci_freeze(struct device *dev) +{ + return aty128_pci_suspend_late(dev, PMSG_FREEZE); +} + static int aty128_do_resume(struct pci_dev *pdev) { struct fb_info *info = pci_get_drvdata(pdev); @@ -2468,12 +2485,12 @@ static int aty128_do_resume(struct pci_dev *pdev) return 0; } -static int aty128_pci_resume(struct pci_dev *pdev) +static int __maybe_unused aty128_pci_resume(struct device *dev) { int rc; console_lock(); - rc = aty128_do_resume(pdev); + rc = aty128_do_resume(to_pci_dev(dev)); console_unlock(); return rc; From patchwork Wed Aug 19 18:56:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E77A14F6 for ; Thu, 20 Aug 2020 07:17:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4D5752080C for ; Thu, 20 Aug 2020 07:17:09 +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="GBeCzwqs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D5752080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D67FF6E902; Thu, 20 Aug 2020 07:16:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D9646E5CD for ; Wed, 19 Aug 2020 18:59:38 +0000 (UTC) Received: by mail-pl1-x642.google.com with SMTP id h2so852540plr.0 for ; Wed, 19 Aug 2020 11:59:38 -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=y37/kWCMTqf8s6gGg+tFqzxGakyiseEA9ztTG8nsWho=; b=GBeCzwqsj3ZeAG74990Ziv0CxhO+QUcVbRxtOQdnSuDF8Xd/VnUz5QxKLks73a+wlE I3OGimKyk9cSa/lBnn4kd1nyJRsjzY02fzxxQYbU3guQZlb4da/uEN+0w41Ot3pmLQm8 hBEnNN6EeeE0ga+okEUo5FzQOg9mFkBHJX+7klIRlyRh10z8SsLYJjpcu/osxTH5hBw5 tKkljVmCg4GRroOUVuylmDgLevEi7xkVHqpvx93iQ20yqvBVADCyrI8zp+FmzNDm4Ykw W8Gb8koZylQcLmDFo0FWKtI9AiD2HB1HZBEodXiRMyDWBhMMps8jWV7sGQc+Q4488DUx LNwg== 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=y37/kWCMTqf8s6gGg+tFqzxGakyiseEA9ztTG8nsWho=; b=WlfdpWTapZaupul3Btc3rmsqRr6mtlgFqZT3w/xBFl4asVKyS7HuFxsTsZtIRzwYhM a/nEY5PkInnrnIxum2um1DeeAH2NcNc+ukbOTiToCRhj7V6NSsE314Q3Eu4dVwELHAWf RaCWwoNW3mpVCudqqD2svovEjB6iA/rTN/RdvN6/qP8lWNmtWgPtVCYtlKmUcWaxspwF j9N/JNMYD1ocSu50e9nFqEcf87KgYFi8Sp9Ofjz/cJQGRwPKTW9j04YI1NQtYY1/Luzr XDo7bD92TS8vHxC7UHbwAJsJFrAXqPXCceKQHOB9G3k+NvjfF010kQzmLFuHQXpfVwhB t/ZA== X-Gm-Message-State: AOAM531Cw6f9stVS82uZR57vzPhYYM7YqyYETVi0UEBgnD6fKT+EP8cN +VxLDnxSv+G0bYFrJLw9SQA= X-Google-Smtp-Source: ABdhPJy4l+YIe+ysFdNOKW6pXx+49Pe57xxd6fOaE3aQbos/QLIyW+ybtU24lNhwcVloGHIxkAaIpA== X-Received: by 2002:a17:902:9307:: with SMTP id bc7mr367517plb.213.1597863577593; Wed, 19 Aug 2020 11:59:37 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:37 -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 Subject: [PATCH v3 06/12] fbdev: nvidia: use generic power management Date: Thu, 20 Aug 2020 00:26:48 +0530 Message-Id: <20200819185654.151170-7-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Now, - nvidiafb_suspend() had a "pm_message_t" type parameter as per legacy PCI PM framework that got deprecated in generic. - Rename the callback as nvidiafb_suspend_late() and preserve the parameter. - Define 3 new callbacks as: * nvidiafb_suspend() * nvidiafb_freeze() * nvidiafb_hibernate() which in turn call nvidiafb_suspend_late() by passing appropriate value for "pm_message_t" type parameter. - Bind the callbacks in "struct dev_pm_ops" type variable "nvidiafb_pm_ops". Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/nvidia/nvidia.c | 64 ++++++++++++++++------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index c24de9107958..3a1a4330e0d3 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -1041,10 +1041,9 @@ static struct fb_ops nvidia_fb_ops = { .fb_sync = nvidiafb_sync, }; -#ifdef CONFIG_PM -static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg) +static int nvidiafb_suspend_late(struct device *dev, pm_message_t mesg) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct nvidia_par *par = info->par; if (mesg.event == PM_EVENT_PRETHAW) @@ -1056,46 +1055,54 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg) fb_set_suspend(info, 1); nvidiafb_blank(FB_BLANK_POWERDOWN, info); nvidia_write_regs(par, &par->SavedReg); - pci_save_state(dev); - pci_disable_device(dev); - pci_set_power_state(dev, pci_choose_state(dev, mesg)); } - dev->dev.power.power_state = mesg; + dev->power.power_state = mesg; console_unlock(); return 0; } -static int nvidiafb_resume(struct pci_dev *dev) +static int __maybe_unused nvidiafb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); - struct nvidia_par *par = info->par; + return nvidiafb_suspend_late(dev, PMSG_SUSPEND); +} - console_lock(); - pci_set_power_state(dev, PCI_D0); +static int __maybe_unused nvidiafb_hibernate(struct device *dev) +{ + return nvidiafb_suspend_late(dev, PMSG_HIBERNATE); +} - if (par->pm_state != PM_EVENT_FREEZE) { - pci_restore_state(dev); +static int __maybe_unused nvidiafb_freeze(struct device *dev) +{ + return nvidiafb_suspend_late(dev, PMSG_FREEZE); +} - if (pci_enable_device(dev)) - goto fail; +static int __maybe_unused nvidiafb_resume(struct device *dev) +{ + struct fb_info *info = dev_get_drvdata(dev); + struct nvidia_par *par = info->par; - pci_set_master(dev); - } + console_lock(); par->pm_state = PM_EVENT_ON; nvidiafb_set_par(info); fb_set_suspend (info, 0); nvidiafb_blank(FB_BLANK_UNBLANK, info); -fail: console_unlock(); return 0; } -#else -#define nvidiafb_suspend NULL -#define nvidiafb_resume NULL -#endif + +static const struct dev_pm_ops nvidiafb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = nvidiafb_suspend, + .resume = nvidiafb_resume, + .freeze = nvidiafb_freeze, + .thaw = nvidiafb_resume, + .poweroff = nvidiafb_hibernate, + .restore = nvidiafb_resume, +#endif /* CONFIG_PM_SLEEP */ +}; static int nvidia_set_fbinfo(struct fb_info *info) { @@ -1496,12 +1503,11 @@ static int nvidiafb_setup(char *options) #endif /* !MODULE */ static struct pci_driver nvidiafb_driver = { - .name = "nvidiafb", - .id_table = nvidiafb_pci_tbl, - .probe = nvidiafb_probe, - .suspend = nvidiafb_suspend, - .resume = nvidiafb_resume, - .remove = nvidiafb_remove, + .name = "nvidiafb", + .id_table = nvidiafb_pci_tbl, + .probe = nvidiafb_probe, + .driver.pm = &nvidiafb_pm_ops, + .remove = nvidiafb_remove, }; /* ------------------------------------------------------------------------- * From patchwork Wed Aug 19 18:56:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725785 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B771618 for ; Thu, 20 Aug 2020 07:17:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 EE58920786 for ; Thu, 20 Aug 2020 07:17:55 +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="j9weShmp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE58920786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C9376E912; Thu, 20 Aug 2020 07:16:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F6F96E5CC for ; Wed, 19 Aug 2020 18:59:44 +0000 (UTC) Received: by mail-pj1-x1043.google.com with SMTP id kr4so1528870pjb.2 for ; Wed, 19 Aug 2020 11:59:44 -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=/PnvTk/kHTtwtuhrKUF4/4Z0DLvA5D0wPf+6EQmvILk=; b=j9weShmp9w8NdEjKn+8wHD82M28wwjIBek0qlTSljbzMhZ6V2D71CHctHml590TuhJ DH+V/z8oGnuoJuhoBJmx1myEE27byAbXgxTZ0FnwecAziOjAkZUpUQtx4ASQ4dkny8dv QZlXUkznyNcXnj40j28Wiy4rVVvp5NX2Ajv1wOVS+9CfYaF2/1ZqXYi42GCxsDfjfuYu +eOClnYjPqk0qXuiJtoOEsWQTHTSeZ3QIqrsCwtJu3Oqxd0Ald4Xq+AzQSA/E15KYugO vR26w7QLwDyEdbPJHca6jeu3QqLW1GuVOR+3VlXqrWs4QCTzxFmuJTALUwdbpXifyvik UCPg== 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=/PnvTk/kHTtwtuhrKUF4/4Z0DLvA5D0wPf+6EQmvILk=; b=SXrfHgxxqAUDWN1Ll+O3vDLIfxr72qZW2mu22VWZVxieUUNoJVOkL8ru8vp1Hu4OcZ tBztjcgvwa3vPGKwg6zukSNedd3vNaVtnxv/ZvhIWe/5Bm5XwoEcP3y0NNVEX0wcLm/6 /AOSR3K1JeEeVddE5i7QHEd5IZPRDIN3ALLkJFrhGmz4JryJ31db479JncVq3GpTSsOL YZXX3EfxArDp4Xa81q2dS8nnB5ZJPpsKYiie2TkfB6oHL6pUvzLZ3MfPprDCuc8M/f3f plLm9RoipylA4Zr5EpVGxkeGVnMFZIZtPoOp5EcrhUA2Sj+20RwjrAt5zDhHbUGtvciy JSZA== X-Gm-Message-State: AOAM531arqIzdywCZjAJrSyBfHVdUCe/IVfQsR6GNkzV/1wWa5gQ7Qho U3Emy12So9z4l6yYTtImHus= X-Google-Smtp-Source: ABdhPJykp5P9DECge6+rFcgcZmO8HBXWZ4w14gLGRsu++ctWmFAvSEW3594tXESeHwQWS5ZM3h6f8Q== X-Received: by 2002:a17:90a:17a7:: with SMTP id q36mr5210622pja.61.1597863583632; Wed, 19 Aug 2020 11:59:43 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:43 -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 Subject: [PATCH v3 07/12] fbdev: savagefb: use generic power management Date: Thu, 20 Aug 2020 00:26:49 +0530 Message-Id: <20200819185654.151170-8-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Now, - savagefb_suspend() had a "pm_message_t" type parameter as per legacy PCI PM framework that got deprecated in generic. - Rename the callback as savagefb_suspend_late() and preserve the parameter. - Define 3 new callbacks as: * savagefb_suspend() * savagefb_freeze() * savagefb_hibernate() which in turn call savagefb_suspend_late() by passing appropriate value for "pm_message_t" type parameter. - Bind the callbacks in "struct dev_pm_ops" type variable "savagefb_pm_ops". Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/savage/savagefb_driver.c | 52 ++++++++++++-------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 3c8ae87f0ea7..d6aae759e90f 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -2346,9 +2346,9 @@ static void savagefb_remove(struct pci_dev *dev) } } -static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) +static int savagefb_suspend_late(struct device *dev, pm_message_t mesg) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct savagefb_par *par = info->par; DBG("savagefb_suspend"); @@ -2356,7 +2356,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) if (mesg.event == PM_EVENT_PRETHAW) mesg.event = PM_EVENT_FREEZE; par->pm_state = mesg.event; - dev->dev.power.power_state = mesg; + dev->power.power_state = mesg; /* * For PM_EVENT_FREEZE, do not power down so the console @@ -2374,17 +2374,29 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) savagefb_blank(FB_BLANK_POWERDOWN, info); savage_set_default_par(par, &par->save); savage_disable_mmio(par); - pci_save_state(dev); - pci_disable_device(dev); - pci_set_power_state(dev, pci_choose_state(dev, mesg)); console_unlock(); return 0; } -static int savagefb_resume(struct pci_dev* dev) +static int __maybe_unused savagefb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + return savagefb_suspend_late(dev, PMSG_SUSPEND); +} + +static int __maybe_unused savagefb_hibernate(struct device *dev) +{ + return savagefb_suspend_late(dev, PMSG_HIBERNATE); +} + +static int __maybe_unused savagefb_freeze(struct device *dev) +{ + return savagefb_suspend_late(dev, PMSG_FREEZE); +} + +static int __maybe_unused savagefb_resume(struct device *dev) +{ + struct fb_info *info = dev_get_drvdata(dev); struct savagefb_par *par = info->par; int cur_state = par->pm_state; @@ -2396,20 +2408,11 @@ static int savagefb_resume(struct pci_dev* dev) * The adapter was not powered down coming back from a * PM_EVENT_FREEZE. */ - if (cur_state == PM_EVENT_FREEZE) { - pci_set_power_state(dev, PCI_D0); + if (cur_state == PM_EVENT_FREEZE) return 0; - } console_lock(); - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - - if (pci_enable_device(dev)) - DBG("err"); - - pci_set_master(dev); savage_enable_mmio(par); savage_init_hw(par); savagefb_set_par(info); @@ -2420,6 +2423,16 @@ static int savagefb_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops savagefb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = savagefb_suspend, + .resume = savagefb_resume, + .freeze = savagefb_freeze, + .thaw = savagefb_resume, + .poweroff = savagefb_hibernate, + .restore = savagefb_resume, +#endif +}; static const struct pci_device_id savagefb_devices[] = { {PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_MX128, @@ -2500,8 +2513,7 @@ static struct pci_driver savagefb_driver = { .name = "savagefb", .id_table = savagefb_devices, .probe = savagefb_probe, - .suspend = savagefb_suspend, - .resume = savagefb_resume, + .driver.pm = &savagefb_pm_ops, .remove = savagefb_remove, }; From patchwork Wed Aug 19 18:56:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725763 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC0A7618 for ; Thu, 20 Aug 2020 07:17:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 CA81F20786 for ; Thu, 20 Aug 2020 07:17:25 +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="Mn+ymFH5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA81F20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CB056E911; Thu, 20 Aug 2020 07:16:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B8E56E5C8 for ; Wed, 19 Aug 2020 18:59:50 +0000 (UTC) Received: by mail-pl1-x644.google.com with SMTP id h2so852813plr.0 for ; Wed, 19 Aug 2020 11:59:50 -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=7pp7ILrXVpYWERUNp+y3FKEvGmfdJxafp13Cd61iIdo=; b=Mn+ymFH5Tc2xZr4mSSRBUl7CNfTA0DlesWU0Sq0Xu1T+OqneWcVq4ekASysyYI2ETT NOSB7C2Cedt19yXvJ2upXqZodaCRErUqHBJvXJ+y1AG0d1s3aeoXWgX4ydW1wonG1AQJ KyyYcwn0E1nHoVzOPWBujC3D3P2PPODBG13GhGBCib7jUZw+yShRX9TFZfqK5/8JvmIY Q9fAysRWcGK4QLyVjz9u8ryaERCmVOEyPJXSzbd+3ZARafIcqDvcV2dqniZXDul1xz43 LQjdek9dXEkDQpvBHd7Ur9Oo/o0EtG2HR0sFPQG850ujw/PavQIQaX7UXDdE6ivpyEku Cp4Q== 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=7pp7ILrXVpYWERUNp+y3FKEvGmfdJxafp13Cd61iIdo=; b=N1/Oaos/Wnq3wvm2dEQBROlSiH0U3hmIINt9l5zUTBoAN7cJJmpjhFMWi0MKtKTxYk cIEtZfmQca45Wssl5hGaeEeO0gbZqfFQWiXobiKJxVOCfrBYqbaRGd7uEWhBJxdFhewC ZXEJC0l2iy9tvwB8bBtdW/59OQE64fFD3GwrSDdgb1Pk/wxZxblP4MexOXC5X/SGM6mQ gMy6+EbE8RyU509Dhgoi9tD5sHCEKyTfoK7neMlkLucqnjskpPQKpTZK5C3sggOEDSBQ 0VZ1sUMrYe6r/nJVPhktn49VE6yFx/opn4LKFcDt0j+FrNaYbJugof/5WW9cAXjCDMiD mrtg== X-Gm-Message-State: AOAM530wQX+dhzI6a896Pjp0hVNsY8w6BykSHMHeBKhloWsBNd3cG7qY PvYeIvj8DpI94NqKUuV/afU= X-Google-Smtp-Source: ABdhPJyPQYzgR72iLGG6L45iOOLTCC87J2wjbMAQqVqpLvOesvLqGUTY8VuELv+F5IyITtz4hTGtcA== X-Received: by 2002:a17:90a:498b:: with SMTP id d11mr5130955pjh.179.1597863589786; Wed, 19 Aug 2020 11:59:49 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:49 -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 Subject: [PATCH v3 08/12] fbdev: cyber2000fb: use generic power management Date: Thu, 20 Aug 2020 00:26:50 +0530 Message-Id: <20200819185654.151170-9-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. This way we can remove the legacy .suspend & .resume bindings from "lxfb_driver". Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/cyber2000fb.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/cyber2000fb.c b/drivers/video/fbdev/cyber2000fb.c index 42d37bed518a..d45355b9a58c 100644 --- a/drivers/video/fbdev/cyber2000fb.c +++ b/drivers/video/fbdev/cyber2000fb.c @@ -1810,7 +1810,7 @@ static void cyberpro_pci_remove(struct pci_dev *dev) } } -static int cyberpro_pci_suspend(struct pci_dev *dev, pm_message_t state) +static int __maybe_unused cyberpro_pci_suspend(struct device *dev) { return 0; } @@ -1818,9 +1818,9 @@ static int cyberpro_pci_suspend(struct pci_dev *dev, pm_message_t state) /* * Re-initialise the CyberPro hardware */ -static int cyberpro_pci_resume(struct pci_dev *dev) +static int __maybe_unused cyberpro_pci_resume(struct device *dev) { - struct cfb_info *cfb = pci_get_drvdata(dev); + struct cfb_info *cfb = dev_get_drvdata(dev); if (cfb) { cyberpro_pci_enable_mmio(cfb); @@ -1846,12 +1846,15 @@ static struct pci_device_id cyberpro_pci_table[] = { MODULE_DEVICE_TABLE(pci, cyberpro_pci_table); +static SIMPLE_DEV_PM_OPS(cyberpro_pci_pm_ops, + cyberpro_pci_suspend, + cyberpro_pci_resume); + static struct pci_driver cyberpro_driver = { .name = "CyberPro", .probe = cyberpro_pci_probe, .remove = cyberpro_pci_remove, - .suspend = cyberpro_pci_suspend, - .resume = cyberpro_pci_resume, + .driver.pm = &cyberpro_pci_pm_ops, .id_table = cyberpro_pci_table }; From patchwork Wed Aug 19 18:56:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F261714F6 for ; Thu, 20 Aug 2020 07:16:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D12B220786 for ; Thu, 20 Aug 2020 07:16: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="WvDYup/K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D12B220786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 313A36E8FA; Thu, 20 Aug 2020 07:15:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9E116E5CC for ; Wed, 19 Aug 2020 18:59:56 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id y206so12126145pfb.10 for ; Wed, 19 Aug 2020 11:59:56 -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=Mos/Rf0TNw2iPmzlPoU65K3iMb1m4mvroOxp61hE7Bc=; b=WvDYup/Kp1NP5gsb3QLWv7Jw7zQT9EK0LsuAPX29ihhdIYei2e6sP8ZOSwFbJBVA7A ta2CILvXyFXMkCKX1E3BhS7dgpZEurOt3qSG40eL6bvDwDjQyCIdmnK3NU9w0J4j2BgC JJZUCVs3oSeiJClFYUixNODeI5caI1l6/cYxvQErqUZ+qF5k8O+TUH7FVa5pULf+/AWO uqLQdyb5Z7Qz0ayAJOVWiVRNPc7iZioUD1GrHfM30nBFXUVftE4ibvYfffXNe8hM488y d9HcZpaPJqC70ZvkdmRfMqp8kUEffjDVwNmtD3oJPusUE94/S01C7o/XL/NmeYKBcn2m mGug== 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=Mos/Rf0TNw2iPmzlPoU65K3iMb1m4mvroOxp61hE7Bc=; b=lD4OiEitTlOIjAxKpjQQzprDqh5UGS/6+kRV9xymKjN8H8n41Nw+ObKMQoSi4TH4oS O1NqDinpvBeKYuiMykB+HcdZzNjP5Hoq5wzd2iZy2T0SrcubO/j1Rtgx8iXspz3qb8Ss kKRHcUSXXYAVp+ai1B0x8nhQ/7bLZrL4feCKfXGNsDYdDwkFJub5g/CbVjH7F6ZCbIaO zdD4MV8VL54H7zRRikLSs1KRx1Yk7ltpyXeNiV6fqjXwtHH5+lIPugvRzlkQSIyJAxvB hnKzMmEc214lHzBCmIyIqDGiVN+H8TvUIZFVh2v/YCf+vbLl2E+gNEtHJs+6IOQ+ZbC1 PLRg== X-Gm-Message-State: AOAM53398+7vIe2zAiuK3ADe6ZsniZJRZNOf6BRBuySX8I59FWIfKFWx fjyW6fWUdhIcMP+3IVq0b+E= X-Google-Smtp-Source: ABdhPJwDsXvmSlbi9dGwbb/sMCjJSWXePcYUjMwpqIZJfFJhndLVz+PO9CUrhtWaRPyT2nFY++fp4g== X-Received: by 2002:a63:5552:: with SMTP id f18mr16741377pgm.298.1597863596269; Wed, 19 Aug 2020 11:59:56 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:59:55 -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 Subject: [PATCH v3 09/12] fbdev: i740fb: use generic power management Date: Thu, 20 Aug 2020 00:26:51 +0530 Message-Id: <20200819185654.151170-10-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. The i740fb_suspend() is not designed to function in the case of Freeze. Thus, the code checked for "if (state.event == PM_EVENT_FREEZE....)". This is because, in the legacy framework, this callback was invoked even in the event of Freeze. Hence, added the load of unnecessary function-call. The goal can be achieved by binding the callback with only ".suspend" and ".poweroff" in the "i740fb_pm_ops" const variable. This also avoids the step of checking "if (state.event == PM_EVENT_FREEZE....)" every time the callback is invoked. 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 From patchwork Wed Aug 19 18:56:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73052618 for ; Thu, 20 Aug 2020 07:15:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4CFEF20786 for ; Thu, 20 Aug 2020 07:15:19 +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="gx7mrlJc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CFEF20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 512256E8CE; Thu, 20 Aug 2020 07:14:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id C84736E5CE for ; Wed, 19 Aug 2020 19:00:02 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id x25so12157330pff.4 for ; Wed, 19 Aug 2020 12:00:02 -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=OQnwLM4dHzJRAnTfJIXhUQMR/ExLuRw9KF4MfB1j53g=; b=gx7mrlJc35T2/ZQi9Ht3XPkUZr4qb95Oiy+82MqtFzf59AJSK64W3nD5D3fcnSWRX0 GL0MzqVUQTqzN6QVh20pRmm4cs2nTigUzBtI7lJWyOx8nme6vpWqrvujXYEZP0ZFMVnF 5NcmEZTeEZbgtIm5jgRdekRSCAtjU2wN7iBsbqlcB7LRdNasMVRuh7VDUVwfI5vkXqNx 9e903tRxOZIZXUTNPbQ+/y1y+Ij8Sj4FGiwjxF10BsepnmkBN5i4x3MMbQD23/v4dWQ4 J+comHnnOQiu3+IYsOml/pdcZp4DqO1I2qSDpq8NYQD1Xr+dE8cT/9rqGrrv/Pcgi9Yw nlnA== 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=OQnwLM4dHzJRAnTfJIXhUQMR/ExLuRw9KF4MfB1j53g=; b=VkF/ihbW13eI+HkRw9D1V5Co8LAX3LwEitrK61yhLuMEPmOtZiVNIZ7cdH6fsmf9BV KIAV2KDLSQ9ZS79c6MWFZCj/948IL7ws77p+IxQ1tcAnqoh+XO1PtzuFCECFRf32ytDu 0YMjoarv6TpVv8QaRuU89Ejy6EtFzXYnfaXQklkfjXtN5gPYUi42LfmfhelvvFWlJxYG 8qkhg5hFB6htChzpujTdRsbVivR+GQpxPsfnORnhKc11Y4EzbYfiRzUMgNUJUoqynSaF PSAns28PqWutPtT8eWfP64F8L3QKu9mysqeDry3GwmD/UgtejsAEnMAaVYb/8Zg1TZ0P BG+w== X-Gm-Message-State: AOAM531DyVb8OvhcdVVlZe0RlIz5QdNIDyVR+fbCpBrTdXzS3VCHJIfD GuplfsMF4BwXp1WEVMYPB+Q= X-Google-Smtp-Source: ABdhPJzm11Z34Nqrnp+qvsYMrTkcaR7D2rExSpbg+/9OJiJa4mSJ6ucaTtuHJAAE+GQf5g0kqlgVqg== X-Received: by 2002:aa7:92c7:: with SMTP id k7mr19149604pfa.239.1597863602281; Wed, 19 Aug 2020 12:00:02 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.11.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 12:00:01 -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 Subject: [PATCH v3 10/12] fbdev: vt8623fb: use generic power management Date: Thu, 20 Aug 2020 00:26:52 +0530 Message-Id: <20200819185654.151170-11-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. The vt8623_pci_suspend() is not designed to function in the case of Freeze. Thus, the code checked for "if (state.event == PM_EVENT_FREEZE....)". This is because, in the legacy framework, this callback was invoked even in the event of Freeze. Hence, added the load of unnecessary function-call. The goal can be achieved by binding the callback with only ".suspend" and ".poweroff" in the "vt8623_pci_pm_ops" const variable. This also avoids the step of checking "state.event == PM_EVENT_FREEZE" every time the callback is invoked. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/vt8623fb.c | 41 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 7b3eef1b893f..c488e0117758 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -815,12 +815,11 @@ static void vt8623_pci_remove(struct pci_dev *dev) } -#ifdef CONFIG_PM /* PCI suspend */ -static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused vt8623_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct vt8623fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -828,7 +827,7 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) console_lock(); mutex_lock(&(par->open_lock)); - if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { + if (par->ref_count == 0) { mutex_unlock(&(par->open_lock)); console_unlock(); return 0; @@ -836,10 +835,6 @@ static int vt8623_pci_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(); @@ -849,9 +844,9 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int vt8623_pci_resume(struct pci_dev* dev) +static int __maybe_unused vt8623_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct vt8623fb_info *par = info->par; dev_info(info->device, "resume\n"); @@ -862,14 +857,6 @@ static int vt8623_pci_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; - - pci_set_master(dev); - vt8623fb_set_par(info); fb_set_suspend(info, 0); @@ -879,10 +866,17 @@ static int vt8623_pci_resume(struct pci_dev* dev) return 0; } -#else -#define vt8623_pci_suspend NULL -#define vt8623_pci_resume NULL -#endif /* CONFIG_PM */ + +static const struct dev_pm_ops vt8623_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = vt8623_pci_suspend, + .resume = vt8623_pci_resume, + .freeze = NULL, + .thaw = vt8623_pci_resume, + .poweroff = vt8623_pci_suspend, + .restore = vt8623_pci_resume, +#endif /* CONFIG_PM_SLEEP */ +}; /* List of boards that we are trying to support */ @@ -898,8 +892,7 @@ static struct pci_driver vt8623fb_pci_driver = { .id_table = vt8623_devices, .probe = vt8623_pci_probe, .remove = vt8623_pci_remove, - .suspend = vt8623_pci_suspend, - .resume = vt8623_pci_resume, + .driver.pm = &vt8623_pci_pm_ops, }; /* Cleanup */ From patchwork Wed Aug 19 18:56:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725717 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0AB214F6 for ; Thu, 20 Aug 2020 07:16:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 AF58C20786 for ; Thu, 20 Aug 2020 07:16:26 +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="NPOdczkm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF58C20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C6046E8B8; Thu, 20 Aug 2020 07:15:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1C586E5C8 for ; Wed, 19 Aug 2020 19:00:08 +0000 (UTC) Received: by mail-pl1-x642.google.com with SMTP id v16so1670871plo.1 for ; Wed, 19 Aug 2020 12:00:08 -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=XLfkemIewMnv6fWXsuoj50p89vkQ+fIdkZyVTqqSC0w=; b=NPOdczkm8lCaPc6hqEnbm8QT2k0i8mBDItJfr17oxdrZunK8ENFSzHEv5xVfidUNIW OGYdNBuVRARt7mJXqI17qIFiN9cWIVi81qrAlw/vJG5uvQ3F7dqO995Ht6gVR2pPiCRO P+LUHIR+gikF9BD2ZcOZdMZjZMtnQ2ho64gLApnObthVMxslDtsvrAOYL8BPlsVfpzTQ lQYbUGWLxU4ge5mmjlUoZIeeFP4540khThN3/5+2lC3IKQz/Fjbt1OGPhgPjTyCTB2h6 E06FFPhYwUu/0p6gdqmVodpJjW5c1hBqnR1flrko5R54+pcTHV1SLiuCuUwks1eJ+d5s xgKw== 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=XLfkemIewMnv6fWXsuoj50p89vkQ+fIdkZyVTqqSC0w=; b=ZKwmXnrovrf0YU6i8I1ftVGkyRiflTauShV5MYUkshVIS0KPDIHmW87Rk2ZP9mNbQo +kfGlmEH3lL0DrMpU2yr3zmmTJUbfeftu1mDnIcSRUr+qKt0P69uT6u7dnaHKGTMotNj sbNCJuZqBRehmeGah+fFaTQPQYiWF3I3v4j+czEJyeEphW8IESAF7ORzHKbTgpfjOmw9 3sy4qKk9sR6LMBZH22a2d78sEVGzgoB+xse5JqvX0SYLaXnEM5KnJNPyedNWo4lnqaF4 4u75tymOnVO82VbgBtiV58J+egmohp0XrcG69Uo3n0BFFlV0qSXrHXwmxWA6ohzi0Owz k54Q== X-Gm-Message-State: AOAM532Wpo4ArGbIKZuoktl+kC7KXvvL0eto31SNiRR0HFRzO14ZmLZ2 V8cTEkgeipZclsEYwzhlAiE= X-Google-Smtp-Source: ABdhPJwUudB7IAaebcACVT0UwUwTEHj0ow63qmV1JZSDadWqM6xmOLbjCyJqGdDo7xDmGHtKh7qYLg== X-Received: by 2002:a17:90a:9485:: with SMTP id s5mr1100437pjo.189.1597863608327; Wed, 19 Aug 2020 12:00:08 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.12.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 12:00:07 -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 Subject: [PATCH v3 11/12] fbdev: s3fb: use generic power management Date: Thu, 20 Aug 2020 00:26:53 +0530 Message-Id: <20200819185654.151170-12-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. The s3_pci_suspend() is not designed to function in the case of Freeze. Thus, the code checked for "if (state.event == PM_EVENT_FREEZE....)". This is because, in the legacy framework, this callback was invoked even in the event of Freeze. Hence, added the load of unnecessary function-call. The goal can be achieved by binding the callback with only ".suspend" and ".poweroff" in the "s3_pci_pm_ops" const variable. This also avoids the step of checking "state.event == PM_EVENT_FREEZE" every time the callback is invoked. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/s3fb.c | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 60c424fae988..5c74253e7b2c 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -1410,9 +1410,9 @@ static void s3_pci_remove(struct pci_dev *dev) /* PCI suspend */ -static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) +static int __maybe_unused s3_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1420,7 +1420,7 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) console_lock(); mutex_lock(&(par->open_lock)); - if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { + if (par->ref_count == 0) { mutex_unlock(&(par->open_lock)); console_unlock(); return 0; @@ -1428,10 +1428,6 @@ static int s3_pci_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(); @@ -1441,11 +1437,10 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int s3_pci_resume(struct pci_dev* dev) +static int __maybe_unused s3_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct s3fb_info *par = info->par; - int err; dev_info(info->device, "resume\n"); @@ -1458,17 +1453,6 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - err = pci_enable_device(dev); - if (err) { - mutex_unlock(&(par->open_lock)); - console_unlock(); - dev_err(info->device, "error %d enabling device for resume\n", err); - return err; - } - pci_set_master(dev); - s3fb_set_par(info); fb_set_suspend(info, 0); @@ -1478,6 +1462,16 @@ static int s3_pci_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops s3_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = s3_pci_suspend, + .resume = s3_pci_resume, + .freeze = NULL, + .thaw = s3_pci_resume, + .poweroff = s3_pci_suspend, + .restore = s3_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1510,8 +1504,7 @@ static struct pci_driver s3fb_pci_driver = { .id_table = s3_devices, .probe = s3_pci_probe, .remove = s3_pci_remove, - .suspend = s3_pci_suspend, - .resume = s3_pci_resume, + .driver.pm = &s3_pci_pm_ops, }; /* Parse user specified options */ From patchwork Wed Aug 19 18:56:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Gupta X-Patchwork-Id: 11725711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90F8514F6 for ; Thu, 20 Aug 2020 07:16:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 6FD7420786 for ; Thu, 20 Aug 2020 07:16:20 +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="XlyEM40X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FD7420786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B4B46E8FC; Thu, 20 Aug 2020 07:14:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id DEFC16E5CD for ; Wed, 19 Aug 2020 19:00:14 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id d19so11834759pgl.10 for ; Wed, 19 Aug 2020 12:00:14 -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=0Gdix+uPKbEr2q1rAkmQ4/zXt/qoiwYZqyXTLXnmDDk=; b=XlyEM40XfAobLwrCnJxZ+PpEMMRq+xMolyrVrj2Tww7bjz1hZdQsPVecl2oXGO2qAP Q8Oq7jWKduW4VFOrONqraQQKRNouWLsvhjGuFErzhO9S5d5F2F/LoY+IivVJja8W2rVz G0H9ILJHMA16FuIjSL/G3o8gHb32786BH7x3EkMOnGeBgqiczEFCZTDuIt7Re78Zyo11 dorsoAnyjfy+je/HYLmnVCi5njPmKRQa/icsPmDmqBYtF5I2TOYrIg4gQfkxUE2Eah8l +sM0imdXocGmRkbXfFZh4hyoamEY3SxoIce9Zk0IRNLN6x0XdYQgCr5VLk0+/xltYYtI OXYA== 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=0Gdix+uPKbEr2q1rAkmQ4/zXt/qoiwYZqyXTLXnmDDk=; b=WeibS/P8symjBvwJq0HGKBmoEhMCwK/rX/yWORcns6+0dlbA65H5xY3xaDgI9BANhv r/graugaZGAmZh58Z3/FXP6sK53w7bkKgCoHdK3h+s7Fy+3obZ4RGNu/+tArsrjCLy8C bKxpbzQ7EQglmfKL+FraNSehYACxX6mgqa9ncq/P6ASzY3DOLHnYrjZSJT7yb58Od4iA AXw0Z0m6GZDW5dfq0qGhfOuLWENrYN7SnN4SxGC+wevg5S+E7/Ky+1pitDYNf6byEqZ3 vXpdoiwiev9Kf/SXG/hkl24TNatP9AsxaetC3DlAI1qCn24HJoxXXYkJ/Cg7Nva9ygph svwA== X-Gm-Message-State: AOAM5339IvXzUA8CilYUava8lr3y1+VfVX+ldLKsAxTJX3Gvyf6uiTHk rMZ5kykXe7HlHsfnZ2gMwdo= X-Google-Smtp-Source: ABdhPJwNjXe8tcUGVq2N5g8hi4ZArg84gR7x1vh/f1D6Q037+6BQVLbl9UZX8Prk6wIYdvu218PL0A== X-Received: by 2002:a63:1342:: with SMTP id 2mr17049990pgt.214.1597863614285; Wed, 19 Aug 2020 12:00:14 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id o134sm29149305pfg.200.2020.08.19.12.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 12:00:13 -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 Subject: [PATCH v3 12/12] fbdev: arkfb: use generic power management Date: Thu, 20 Aug 2020 00:26:54 +0530 Message-Id: <20200819185654.151170-13-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200819185654.151170-1-vaibhavgupta40@gmail.com> References: <20200819185654.151170-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Aug 2020 07:14:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Vaibhav Gupta , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. The ark_pci_suspend() is not designed to function in the case of Freeze. Thus, the code checked for "if (state.event == PM_EVENT_FREEZE....)". This is because, in the legacy framework, this callback was invoked even in the event of Freeze. Hence, added the load of unnecessary function-call. The goal can be achieved by binding the callback with only ".suspend" and ".poweroff" in the "ark_pci_pm_ops" const variable. This also avoids the step of checking "state.event == PM_EVENT_FREEZE" every time the callback is invoked. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/arkfb.c | 41 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c index 11ab9a153860..edf169d0816e 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -1085,12 +1085,11 @@ static void ark_pci_remove(struct pci_dev *dev) } -#ifdef CONFIG_PM /* PCI suspend */ -static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state) +static int __maybe_unused ark_pci_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct arkfb_info *par = info->par; dev_info(info->device, "suspend\n"); @@ -1098,7 +1097,7 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state) console_lock(); mutex_lock(&(par->open_lock)); - if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { + if (par->ref_count == 0) { mutex_unlock(&(par->open_lock)); console_unlock(); return 0; @@ -1106,10 +1105,6 @@ static int ark_pci_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(); @@ -1119,9 +1114,9 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state) /* PCI resume */ -static int ark_pci_resume (struct pci_dev* dev) +static int __maybe_unused ark_pci_resume(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct arkfb_info *par = info->par; dev_info(info->device, "resume\n"); @@ -1132,14 +1127,6 @@ static int ark_pci_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; - - pci_set_master(dev); - arkfb_set_par(info); fb_set_suspend(info, 0); @@ -1148,10 +1135,17 @@ static int ark_pci_resume (struct pci_dev* dev) console_unlock(); return 0; } -#else -#define ark_pci_suspend NULL -#define ark_pci_resume NULL -#endif /* CONFIG_PM */ + +static const struct dev_pm_ops ark_pci_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = ark_pci_suspend, + .resume = ark_pci_resume, + .freeze = NULL, + .thaw = ark_pci_resume, + .poweroff = ark_pci_suspend, + .restore = ark_pci_resume, +#endif +}; /* List of boards that we are trying to support */ @@ -1168,8 +1162,7 @@ static struct pci_driver arkfb_pci_driver = { .id_table = ark_devices, .probe = ark_pci_probe, .remove = ark_pci_remove, - .suspend = ark_pci_suspend, - .resume = ark_pci_resume, + .driver.pm = &ark_pci_pm_ops, }; /* Cleanup */