Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4555785pxa; Mon, 10 Aug 2020 12:01:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLI3tEvgm+zm3csKVkzvWoY7FdsAXotNtf91pFT3RrNoOhobnp9MVdaYZd9wgnAUaJv5hM X-Received: by 2002:a17:906:1f15:: with SMTP id w21mr6141599ejj.152.1597086062573; Mon, 10 Aug 2020 12:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597086062; cv=none; d=google.com; s=arc-20160816; b=0UuoPwug53RY8XmymyRP0F0QpQLUWw27oYxCSO6px7gW6fZqjuw1uPdhzDkcmjQIXU 7E8wLhpn1eecy6wjfvXkmsIWNYXQwPEcdWz+wuFDO9Lw6HTFmsa9q8W0KZ1r0YFTdhEi f6CFjJVzRvQhcH2Wul8XFfYzGqGY1ibANZMYbFGOVoo6UQpHol09Q9kuMTmdbeKm8HVz 1siY/pxm5rN4nmNzFkEmhOg5wJHk+KwwhIMZgx6To9czm2Majl5+Fpp1K5J9xmrQW7/o ZAOl3GcPs7VStPmBWueRJ7N8f/v2tKMH/0fKCW+wPtD5Vv+0Ln/OSJxPh9WHal1B9/HY 11Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7LL2LyOuD9BBiMNUCCPwJGjjmVKfT+kRnyt53U08dq8=; b=hl911TGWIhJzasK6kAVh5rQh3qAoK+O2NE7Jor1D8rcAvzV0hLu+AkiSWUg30e8Jm8 2yCjwXm7YoPgj9Pa4aV5ksOd5ygt2TQfA194RRjig32rpgrQNoNMp8rIk074aXg+RCyw aIwvd2Y6lJwoAw+EahjaTABn+j/egYjbnqY5HDu/UcQAdoJCNB9ttbdR86UhuK4r3Xad zSYTRpazmT0gFbuqUcLSfN4znlknoVaNdy6gaCiWvIkGEI/D2M6uPyAb/D8SmGtRB7Yw Y3uvbc+0CFFtHEESma1CZzW/7zusNUUmKCP8WAQTrPDGo2V27Dw+RDv5jpOPxvfMJ0Hu 8mSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dZZ5T60t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si10654488edk.332.2020.08.10.12.00.39; Mon, 10 Aug 2020 12:01:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dZZ5T60t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728330AbgHJS7g (ORCPT + 99 others); Mon, 10 Aug 2020 14:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbgHJS7d (ORCPT ); Mon, 10 Aug 2020 14:59:33 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6502C061756; Mon, 10 Aug 2020 11:59:33 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o13so5461349pgf.0; Mon, 10 Aug 2020 11:59:33 -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=7LL2LyOuD9BBiMNUCCPwJGjjmVKfT+kRnyt53U08dq8=; b=dZZ5T60tKK68ZrPUUOgfYhPYNT6E6QERQQUaIyjxHPTQOzlRjvqdvmUQA/7xq+1WbY gXGtSHaYELmBxPiZD/ppA/iHYCPpqsp3/rNo3v732JIG1ubwOWpOQ7fkfIojzD6Ll+ZR 9pJdzs3bWrFs253Fruem9jY/3tzX6XN5Vf1KjvJBme0Rq0JRpIYDMgR3AnQ7tLLhIHPu I5DPWSej7OpE9HghJ7W8KrfeL5pNypjL4EtdTwC5Ta17kbw2go1iz/Faa5XahiKtl2OW 09rXzdr1XVxLRhb30oFypNZi6ol3jbmIKk2OLzyNbmT3PG7xOPmkk6x0coi3jLlW0jWG nwjg== 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=7LL2LyOuD9BBiMNUCCPwJGjjmVKfT+kRnyt53U08dq8=; b=unT5b5sd01u/VWkmxF9z3zf0P3KxA6HdscSYLS9FfZQEqXqvLkJq1C4V3Eq5y1r8gy zTpJ/c5GCgCPyOqniRFu1QKiJCLPvnGjVpSl2hmQ0Wv6p2M2HtuggkHxcplnMPfnqSvu dPAmDZimjh3/povqFoSwkJ2YAjqLCrAjku/cmKFuRX22JkMcIcVXXV+paLKPnCAy/fl/ K5r/61Zmz1Sv63/HnttDSERhTDlo7dCOmIcxe4eWwaMXLiqUzHlZcnu22e9hMb3EdHB4 DvGoDEYjkYwvTG2//PpadLuV8SEcqnBz9IYwOddFJxCh8YyN+OxEnajpkk9g7YAOOTrk TZkw== X-Gm-Message-State: AOAM532v8xnzBXJGpDUl5P9hWZxG5xew4aldCcOcKYLY1GOx45eDvo1Y QqSti39Bh1rrYmmCgw08kJ0= X-Received: by 2002:a63:d812:: with SMTP id b18mr11090977pgh.353.1597085973216; Mon, 10 Aug 2020 11:59:33 -0700 (PDT) Received: from varodek.localdomain ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id f27sm22683547pfk.217.2020.08.10.11.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 11:59:32 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bartlomiej Zolnierkiewicz , Sam Ravnborg , Paul Mackerras , Russell King , Andres Salomon , Antonino Daplas Cc: Vaibhav Gupta , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-geode@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v2 02/12] fbdev: lxfb: use generic power management Date: Tue, 11 Aug 2020 00:27:13 +0530 Message-Id: <20200810185723.15540-3-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200810185723.15540-1-vaibhavgupta40@gmail.com> References: <20200810165458.GA292825@ravnborg.org> <20200810185723.15540-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them. Although the lxfb driver does not have that extra load, we should switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks so that we can remove the legacy .suspend & .resume bindings. Additionally, this helps us to remove the unnecessary call to lxfb_suspend() in the event of Freeze and Hibernate, as the function does nothing in their case. 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 -- 2.27.0