From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A18BFC433E1 for ; Wed, 19 Aug 2020 18:59:37 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 6BCB7207FF for ; Wed, 19 Aug 2020 18:59:37 +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 6BCB7207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 0D119221B5; Wed, 19 Aug 2020 18:59:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YRdcciOUbZ6v; Wed, 19 Aug 2020 18:59:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 4281C221AB; Wed, 19 Aug 2020 18:59:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D080C07FF; Wed, 19 Aug 2020 18:59:34 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0D7F8C0051 for ; Wed, 19 Aug 2020 18:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E287A221B1 for ; Wed, 19 Aug 2020 18:59:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u+-MXMbCRran for ; Wed, 19 Aug 2020 18:59:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by silver.osuosl.org (Postfix) with ESMTPS id BBA2F221AB for ; Wed, 19 Aug 2020 18:59:31 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id v16so1670091plo.1 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=ipeW12PFWCP8+wl3JlckLU1duMlzunU1WExzdkbNt/R35D3QlS7h69bGkwssKoA9x4 wZ9DaFv0nBrWmrUMzkwKzxoYz3Je2YhJdRT3dFJ+c+8qb4Fv96spyb5ECg/by5qBxDxG 3RxTwAehM8o9fipPgOtTdUh9tkXC3krZQIBy+pWXrG7pc2/Xwb21FWVDT96T52H5tNHp OEgUXVqIUXn94ai9CwWr4+ESO17W23iBrN9h64ihT75nbYCSmpOgfEuURzJxF299Cz5y 6qa3Jlg1e3fVfOSiLzy8p/OlSQZHkDruHQ/392hJ789wsxawwOcLLgb6DzkoSvqY4Q5L ZhVA== X-Gm-Message-State: AOAM532cPoke/sDNT8QSAc57FkHdASnItFD+T9Li7UsQMr0arBFBcPfW B/CZyIZnMV57AYWZiftI2dM= 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 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 Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-geode@lists.infradead.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org Subject: [Linux-kernel-mentees] [PATCH v3 05/12] fbdev: aty128fb: use generic power management X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" 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; -- 2.28.0 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees