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=-13.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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=unavailable 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 467F4C433DF for ; Mon, 10 Aug 2020 19:18:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 F1A1F2080C for ; Mon, 10 Aug 2020 19:18:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xunEjH0d"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="mj0VTr8U"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XfIC0l+q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1A1F2080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uBg1C+w8PMHSwjafKGYWCPEnDDxWU8o2mLnb3geodQU=; b=xunEjH0dlKhbTKbpMHWVLoUO8 L9hzpYFzB79gvuKv/NvKQNbKE6L73aGd0weiKwystEbbfY9lQI9PxdcRt29+9olNvJW3x0gs7vj2I Sbuvg4exwSbwijiGzSfWJqjT+5Zf5sp6pFvDMIYJO4vnWbCJVLrFNXOypl1LFhyzHjfki83iGJm5x GDM2N+SeFkP1yXodXqRIsnhWTOUenYrzAL3K1YxU3eOTgSOIZkvzG0oMr6l+d6jw5D643B4q0a9Ia qCPmYEvPuajKHLn0wb2W/NXyiLFvH71eEEOp/Z35+bddWvrIEEKvCCwIHH2RO3x9DfngwYQPTctB8 R8ABhJt1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k5DIT-0001Bo-58; Mon, 10 Aug 2020 19:17:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k5DI7-00010e-C9; Mon, 10 Aug 2020 19:17:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=R+174NPN5cAUcf6KvtsV0Xpgm37coEdke8RyoD2D7Ak=; b=mj0VTr8UkgwcgrWe3Hyol4KqqR yNkYP7OVh3ESYXu6YiFxjJ5IMUYud8OIcu0ADMWlA8tg63OrwpRQnAdD9ffwGtlHHxqUuD6GhDAqi mZdbNOEtKE82uxwGDihkhofgPZquCijJUQUTXlum3DCZdIecOITHByX6TKwh/xVso4YYScbxq7XZk yMnU/+9gHERbVXXBGy7mhdVVN2jZlYM7wNXl30verdJTK5+8RhLDXn9EaFWH3qGqUxLFYRL3/+PBL xcbiRMTpelXoXMM53pTfIYF56o5gZkyTBojaUf5xGIlUmSw6piXhucfhupS9Ciq+a/6l+gAEkkhSc jBoA8qAw==; Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k5D2K-0000s9-TU; Mon, 10 Aug 2020 19:01:05 +0000 Received: by mail-pl1-x644.google.com with SMTP id t10so5516040plz.10; Mon, 10 Aug 2020 12:00: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=R+174NPN5cAUcf6KvtsV0Xpgm37coEdke8RyoD2D7Ak=; b=XfIC0l+qtuFLY5WzdRxHWjMwbOKObVzDTzniqDiZ1cjXBSyr01K921ZPVsmzFKeO/8 /KfYYuOz+4H63OM45aMQ2cAYNVs0izkwa0eHLowgDJZ84f9TOTNHwPuKo3WHWS8YispL j1nwaXnnFtcHlIdENaQIlwfdWl98bx0IqDAhuOKwIVkkI7McegP6DJVotXolhVp69OMY ev7FJeNLM/wyWr8TPU2arOhEerY3oyHUMl0CrRarjueBjEAKJM8/PRvvt3vfCqn9cMR2 8pArOdp5XsEj5hq6j/Cb9E7+uk2gzm67X7bL2AtWUDsuCABpfEmW9+QmkSUlMVjsT92e S/GA== 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=R+174NPN5cAUcf6KvtsV0Xpgm37coEdke8RyoD2D7Ak=; b=kEJzBVYR25mI4i58aS8w3eEJgC7K8FngfVvKXd54AF9SJwqFVeEu9nV9G5hOAaGWNy 6uV8gQR6SDuIQO7p0dOQEeVKhcO2opAhsxfq40Kfxd04nwPMsS2/3FJ0lqhCeNPDpotn 4Vrv5OWiSvqIK/xrsYo3uBL1hU1O/2DvR50uP3YbMhkpHQAk9WlXMj/PKBogrfJk0f9k BRGbciwH+Bm3pexvJa7peh2uS2YQjM2TVyRR2UW2ZHAwdlxYONLbek8KE9eQ+ctkG52O SL0bpe/PkeCJdkwKFVD8Wrb8snW3EOU2ZWkBOy88E8hFNycnOEfG1qb3QStoqdPMXuSP 3bsA== X-Gm-Message-State: AOAM531hYnxT3ifJhuceHKPcA2cbSvICpWDI0RnQynRpxCkCRrvik/6R yiD+o8CGbs2vR9mmFWluEOc= X-Google-Smtp-Source: ABdhPJxt23r0SFVVEHLjk3fUIuS+XluMj98GM01cCkKsQcmnOLrOSdIgi+TvLREGQy1zK92jrxYbjg== X-Received: by 2002:a17:90a:4e8f:: with SMTP id o15mr685304pjh.220.1597086041938; Mon, 10 Aug 2020 12:00:41 -0700 (PDT) Received: from varodek.localdomain ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id f27sm22683547pfk.217.2020.08.10.12.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 12:00:41 -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 v2 11/12] fbdev: s3fb: use generic power management Date: Tue, 11 Aug 2020 00:27:22 +0530 Message-Id: <20200810185723.15540-12-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200810_200046_118948_585E747B X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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/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 */ -- 2.27.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel