Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4557161pxa; Mon, 10 Aug 2020 12:02:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTMPLN+wzCa6b7Sr4KAHxRZy+2E3V3DDOqM0K3iDx0utiHFR/G5utoxV8Opl/1OLqvOM+A X-Received: by 2002:aa7:dd94:: with SMTP id g20mr21885241edv.238.1597086168243; Mon, 10 Aug 2020 12:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597086168; cv=none; d=google.com; s=arc-20160816; b=0HwvEwT2NOomihFLJkVOXKJHLqsY44q7wrJZXyCTlZbgIHxPpVSjjgPnFvxSxeJ6Py yrIuICTGKQmkJsXxX89SpvJCf14kGDpyavY76ugZmJcQTfB4ZCmIVx4UnNow05Jj19WU tIBBLy5c1AgYw8EeDg/qja6tp7cZL+ErGC/J9Pu9f6md0+PQp8wUdSHuQk4oX1xFNaza /CGto2TrE4Zs17LMiYQH7g3Aj76u8XLW2N8ATqM0qMgh/b4TyfKRRm47oxk3DESqbt2/ InMQN3uJngaucq0DU86EC81CLz34RjQGlz9WjL5CNQZ1EpjwFy8heX2MHkvlHnCs6NHV jUxQ== 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=R+174NPN5cAUcf6KvtsV0Xpgm37coEdke8RyoD2D7Ak=; b=vbkZ9VIbnNv9g7InHIRH2r4bui0/fK0mWbntP918/RJ8EDNhZcM1DYJ0Km3tuhqcU8 f4T8LvXosO2idtZ12V0QM3ka3PEnXZtUSbclUfWiOmzf9ERtyJNW47jIplud/HD6iX+f ZRqfejXMx4DIU0TyxNgR/jNND2Blu25rdW0T/7yt+VmBk7YcRDO09Avujm0MBSZQL7aM RGOH7/Dp5v0IERo3BD7kAWSZ1crPW4zLJoue/LRTAUqcr7SnD5m1gYv3MDA0bOymQJ/Z o6vug8HgFm/BzHbXj/GZZArZDIOV2Hy02sl45MHVhuKS6ZT+MtPDOKP5cvmS+nfzNQLp CKRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XfIC0l+q; 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 d11si11006713edr.595.2020.08.10.12.02.25; Mon, 10 Aug 2020 12:02:48 -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=XfIC0l+q; 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 S1728433AbgHJTAo (ORCPT + 99 others); Mon, 10 Aug 2020 15:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728135AbgHJTAn (ORCPT ); Mon, 10 Aug 2020 15:00:43 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71832C061756; Mon, 10 Aug 2020 12:00:42 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id y6so5526495plt.3; Mon, 10 Aug 2020 12:00:42 -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=DYK31BWW16BFuivQbgnWtrMzAAeNyZo5dNCRLw4n+pHSm/Q0t0up42O1TcuewSudjq UU80nmtqzA28mNZPIdoPNKYYf3kggCh423g02xlzqAbJCOecizEOHRgIe/q9u572LeBl ZLSPPMHdCmZj9iaKT51IZnUXVhpX7aXT4izVdIG4XungFIDJBKeJac2ilRBOcjWOtMQ9 Qt1KFZIq5nZ656QC24dPguyM8LMJWvsSKnnMLdgykmifz36EsL3PL/1IigkWuGKNVl+N Loc2uSEg6yA20lkqaZ0H0R97PYL6lbpqktBuiFiQ3jdpbye5oSWdi1DS0yS2TLKee+Z7 ewRA== X-Gm-Message-State: AOAM533RT+8BIGbgmpwf45fcFrLxrCJ7BO9KaFiBNpqiqJHOhAhVbeR2 TKY0O7iKI7jDckQYhX49AD4= 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 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 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 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/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