Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4555916pxa; Mon, 10 Aug 2020 12:01:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1HN7O0cPqooz38jXxCtlune1jz+fuNp42lsgr/LLMq71OWVeEJ51ZUxPNZpanFAOjN/Th X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr21958230edb.151.1597086072132; Mon, 10 Aug 2020 12:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597086072; cv=none; d=google.com; s=arc-20160816; b=vXIGbI1wBbDD8kNVkqn6lJUjcdpgZAo21Q1/znrjTh4ay8WeWZA1+TgHmOXn5P0Eed 8Bvg2RVesnP6L50uRhaubP93e6rWAi2szuEGRZHZAFmGvHjo3INLJD9hIE0vwJP4OnUV gq9/3tQ7VV6QCfbgpluomq0z773+iP+n0UXPHsSlShSikOTtiSavWl2667WonzQt7SE3 3cG15Yfcw0tGzyRtIjQBgMP3kyCU9m1LjTZTFmtSuS2GgMqlRdmgR6VeMvdaGcx/b6V9 tz0FyI4DgPiONQroFrAcXiVaQaVLWf/GrX6+LMMVvyo0grDLl+UnuHhnL0EdMBJNTEWv Dszw== 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=ITe/X6Xdx2CY6PsGQ/PduP0lNpkYq6j7vCmUAE4nQQU=; b=v3VJhFOnGSpBWdh2w17ZqnmDvAPXkYAGlvFIR0VAsFSNBM73IcpWQdbd5ncvkS+bw5 wH+SIvfXXyPkq0FV6y61yNiGKiTxY94bwLMtV1APqpu8LADdbg0Av4H4qAZCuSTOcDzb NnFzDrI5tTzuphNRbXBxy3cTGHwJcJJrzGRQjJPCq0bo7Bru6rgE3psoAVhuhmv1Fb5m coUbOk3iWs3jFDipdfNfj1jghWyBRBPbeya1EkVgG/eWe8yx2tJk/DbF9G6m2ayEpm/M ZZf7egVfkaieOtLL5aaKGb9hpGY79hoCwfgSfStK/iqZC6EW3b5Amcv7stPy/nVbh/vE KK8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=czbuPi5a; 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 x9si11515151edj.121.2020.08.10.12.00.48; Mon, 10 Aug 2020 12:01:12 -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=czbuPi5a; 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 S1728353AbgHJS7s (ORCPT + 99 others); Mon, 10 Aug 2020 14:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbgHJS7s (ORCPT ); Mon, 10 Aug 2020 14:59:48 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ABB8C061756; Mon, 10 Aug 2020 11:59:48 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id y6so5524585plt.3; Mon, 10 Aug 2020 11:59:48 -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=ITe/X6Xdx2CY6PsGQ/PduP0lNpkYq6j7vCmUAE4nQQU=; b=czbuPi5aq2XuD3n/veDuyK14hELrmZZeTQMlep+v0poheUKc/VGPDdaT3NGxicOZva nV/ngVMDinb52OW5KIsARx9WODXexCfN5ctiykdzyh5PxaDvtI1Yk4AXTFZxAXVcZu9I yjQ2mZTizSoPt4DuEpazlR61p+rT74RYezw6+TV8W+rjG93z8n5xeXTpFVm5FfoI3i3x ciqh4/PSLKbyhVQAg4eBcl2Ex0LaGKhfCl6rwNr6i6QESouOOkjJ8onckjM78SCI9Gio lCPj9c97zOEPE6mP0ldBLP+93GLitOE3juMoyVHuVs4cquYNurzkT5gPHX840vtNvLBq dTdg== 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=ITe/X6Xdx2CY6PsGQ/PduP0lNpkYq6j7vCmUAE4nQQU=; b=ULvVAnuE8OXTDOYa6lWXj7P2dzAafWYlRcfYEGN0oABaYOPd/BPjKX1BMoUujiCMUX xMenRbuA8Duv5iNMyuv4Nl9ZIXUo/5xyvtiYViy2TkfcpjnFr4eEIUK2fuuSFr2iVni2 hnc7ytnXv+HESr2FVRZYEK37vXoQYLDo7BFeyVJ8kndoFiRAui9wcIh3Fj+yB6dJSEou Mue2LKnsfCKk3OsFZCUqIuElsyIjTRpewIZZGm9YNRk28Oy3zuS9j3O80uevwI0mZ545 GYyOYCrhioGyIb5p1Y2lR7/xKWZQuMwK9c3UMWtaoMWLWAYBX395dHGoKmSoZuuI5tjK EJSQ== X-Gm-Message-State: AOAM533JaGDXfcOqqqJFpLQ+czYS5ekpuRs6soqPb54iCoX7AvsuHN2O gR/AR+zxHEOyibNhS+WM5dE= X-Received: by 2002:a17:90b:581:: with SMTP id t1mr670372pjz.215.1597085987631; Mon, 10 Aug 2020 11:59:47 -0700 (PDT) Received: from varodek.localdomain ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id f27sm22683547pfk.217.2020.08.10.11.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 11:59:47 -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 04/12] fbdev: aty: use generic power management Date: Tue, 11 Aug 2020 00:27:15 +0530 Message-Id: <20200810185723.15540-5-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200810185723.15540-1-vaibhavgupta40@gmail.com> References: <20200810165458.GA292825@ravnborg.org> <20200810185723.15540-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them. Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings. Signed-off-by: Vaibhav Gupta --- drivers/video/fbdev/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 */ -- 2.27.0