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 B6565C433DF for ; Wed, 5 Aug 2020 18:11:11 +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 738D720656 for ; Wed, 5 Aug 2020 18:11:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m4YC9vuU"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AZ+Ob5Uw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738D720656 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=eZ2ZtBkWnzb2AlOk5AMQ9W0dmGM8c8igEA9bNbYPFC0=; b=m4YC9vuUFzBA2dfj+GCRTZqI2 nf36+NpWO8o5jEJHNZdzIwcTbuDD+VbiYwqBXkPkrKCimTf97V5b5HbIz3rYU/ryMnp411YrHUiQx AClNnINBjKKh+8b5qxAEGsBReqzD2gmwo5IC4jNLrL0+cOkfk6Hcz5QqEvy07sNuHYLkLDyowaag3 50jxRy5HrFW7UuKeWexEhFSrgLxZI/ctT7M/KqgFMa86i8trnCZg/UGO9VEd23lRk5n8gcvso0Ip4 AGIe8ZQ/Z37Z8ndC6bueMhIP+AAIELoKSAy1XW5FPew64vA/AhJN8xyO8xP4/b9JeYuTt2Q2bDzEB Lz2ya9qaw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3NrE-0005Zc-Pp; Wed, 05 Aug 2020 18:09:44 +0000 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3NrC-0005Y6-Cd; Wed, 05 Aug 2020 18:09:43 +0000 Received: by mail-pj1-x1041.google.com with SMTP id l60so4997029pjb.3; Wed, 05 Aug 2020 11:09:40 -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=3uItQaxawuJpK5je/oUH/UET1q9rEg6Zl2yCHgObWaU=; b=AZ+Ob5UwDYRFspLaKbnD3yYh2qZsQKHrcZDLyvODYGY1YbkFdqYvUpnWs+STSiKBit WLz2kwHe+aE4KxOc7yBn6ML9QYCd1mGW2siMD2WhuF/q9YMMA4dquWeum7W973iiC2YV X1u0h6MRWU2/yNBeQAjyu+4MW5mPWkvLREPJ1FzwtTQIezg31a3imnvvrKmTR12u9f5Y ueaIfnxZgNw4QSD1onlwxzEvBGGcMOek4BTA6qbPo+b8eO1x3SNxStKvABVAhIcpcVDb r/gcMW4yBFwRb4oRr6EeUXKxmKQ2qSLzJzytfLwwSm8M418t+2GulbS2UlAJoMrhdD1e l1Mw== 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=3uItQaxawuJpK5je/oUH/UET1q9rEg6Zl2yCHgObWaU=; b=hCg9XWgtYsZ5l/fTxUArCx6uK1O40UG8nTSqiVmsJFYLa0PSFuZIi7wjKaNDr17Ip2 ADBPpuyKxqIhCslaZh76YdcJGWGBiQ/4btVXB71bQoWl7WI8ikGCvrk8VIAt4ADneghg wdD0UGqmvixO/VemIZ17J437MODxBCe2xeNJG2UCz8su4WonDY29wHbvSLXUZjULTeiS AwwQJRVa+mQg44+tuhEiN21qKthzkT2NtGfCYTc57+9rBJ40+i0e1nhAHnXVZr0jNSHJ ZYNSgw1/9qVjqrvFk5drJbns+fWdHG8o1Mg3tvSJXRB5aeK+ujmo6U8ZDAdxXvOgZAbI hhqA== X-Gm-Message-State: AOAM532/vxBbEpgGEiHKsAH+Qa19F1AeqatxbflXeGeGIQygcQ1ZU+Zd Z2pg0XBIgLO5fCFeTK7BXMY= X-Google-Smtp-Source: ABdhPJzmv6N0E9VbwZH7UnXkgxlJLDvMP70umANYnnNhbgOzcfqOc8j7WNngIOLBGMiismfsUWErjw== X-Received: by 2002:a17:90a:f192:: with SMTP id bv18mr4155781pjb.21.1596650978416; Wed, 05 Aug 2020 11:09:38 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.152.86]) by smtp.gmail.com with ESMTPSA id t63sm4977510pfb.210.2020.08.05.11.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:09:38 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bartlomiej Zolnierkiewicz , Paul Mackerras , Russell King , Andres Salomon , Antonino Daplas , Florian Tobias Schandinat Subject: [PATCH v1 03/12] fbdev: via-core: use generic power management Date: Wed, 5 Aug 2020 23:37:13 +0530 Message-Id: <20200805180722.244008-4-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200805180722.244008-1-vaibhavgupta40@gmail.com> References: <20200805180722.244008-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_140942_467109_5310F76B X-CRM114-Status: GOOD ( 17.78 ) 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 using legacy power management .suspen()/.resume() callbacks have to manage PCI states and device's PM states themselves. They also need to take care of standard configuration registers. Switch to generic power management framework using a single "struct dev_pm_ops" variable to take the unnecessary load from the driver. This also avoids the need for the driver to directly call most of the PCI helper functions and device power state control functions, as through the generic framework PCI Core takes care of the necessary operations, and drivers are required to do only device-specific jobs. 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 -- 2.27.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel