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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 B6D53C433E1 for ; Mon, 27 Jul 2020 08:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9236F2072E for ; Mon, 27 Jul 2020 08:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595840186; bh=ckrzN6x1hBtNGks7Ouqr9lQX/r6n4nBW5be26Bg/ZCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=qkqs9y1tsO0yXUAJVA8dRNEpAbnofrnTyJvRR12CbyEs8EUHMtGE0jFIHhB1nNYGE iJAtRSKeXz+4AeoTN13qGNsJNuJbWFzYMfFyP91AOPnRTcFFPXG8J/C1oJVngDfgSy zQeBVhgtRalQVRjBAU4124S455MTXnepbu7UQX4c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbgG0I40 (ORCPT ); Mon, 27 Jul 2020 04:56:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:36946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgG0I40 (ORCPT ); Mon, 27 Jul 2020 04:56:26 -0400 Received: from localhost (unknown [122.171.202.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64F0520719; Mon, 27 Jul 2020 08:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595840185; bh=ckrzN6x1hBtNGks7Ouqr9lQX/r6n4nBW5be26Bg/ZCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=w7V0Rk7+G2pBeE7TNO5yE9PaBiyD86DJaUifty8MDZfy+IcqnRFn9vsAJ6HkBKvem LMWb4s/DDoTTlgCDZ441WzPrgoF4YKM+WQN+vdf3p5zfG8oFY5AWxnxXa5oG63KfoQ kdIgLCe+0H3myAnjbOEWhgyxExwtjjsBLmm17jPE= Date: Mon, 27 Jul 2020 14:26:21 +0530 From: Vinod Koul To: Vaibhav Gupta Cc: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Dan Williams , Shuah Khan , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, dmaengine@vger.kernel.org Subject: Re: [PATCH v1] dmaengine: pch_dma: use generic power management Message-ID: <20200727085621.GL12965@vkoul-mobl> References: <20200720113740.353479-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200720113740.353479-1-vaibhavgupta40@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Hi Vaibhav, On 20-07-20, 17:07, Vaibhav Gupta wrote: > Drivers using legacy PM have to manage PCI states and device's PM states > themselves. They also need to take care of configuration registers. > > With improved and powerful support of generic PM, PCI Core takes care of > above mentioned, device-independent, jobs. > > This driver makes use of PCI helper functions like > pci_save/restore_state(), pci_enable/disable_device(), > and pci_set_power_state() to do required operations. In generic mode, they > are no longer needed. > > Change function parameter in both .suspend() and .resume() to > "struct device*" type. Use dev_get_drvdata() to get drv data. You are doing too many things in One patch. Do consider splitting them up to a change per patch. for example using __maybe could be one patch, removing code is suspend-resume callbacks would be other one. > > Compile-tested only. I would like to see some testing before we merge this > > Signed-off-by: Vaibhav Gupta > --- > drivers/dma/pch_dma.c | 35 +++++++++-------------------------- > 1 file changed, 9 insertions(+), 26 deletions(-) > > diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c > index a3b0b4c56a19..e93005837e3f 100644 > --- a/drivers/dma/pch_dma.c > +++ b/drivers/dma/pch_dma.c > @@ -735,8 +735,7 @@ static irqreturn_t pd_irq(int irq, void *devid) > return ret0 | ret2; > } > > -#ifdef CONFIG_PM > -static void pch_dma_save_regs(struct pch_dma *pd) > +static void __maybe_unused pch_dma_save_regs(struct pch_dma *pd) > { > struct pch_dma_chan *pd_chan; > struct dma_chan *chan, *_c; > @@ -759,7 +758,7 @@ static void pch_dma_save_regs(struct pch_dma *pd) > } > } > > -static void pch_dma_restore_regs(struct pch_dma *pd) > +static void __maybe_unused pch_dma_restore_regs(struct pch_dma *pd) > { > struct pch_dma_chan *pd_chan; > struct dma_chan *chan, *_c; > @@ -782,40 +781,25 @@ static void pch_dma_restore_regs(struct pch_dma *pd) > } > } > > -static int pch_dma_suspend(struct pci_dev *pdev, pm_message_t state) > +static int __maybe_unused pch_dma_suspend(struct device *dev) > { > - struct pch_dma *pd = pci_get_drvdata(pdev); > + struct pch_dma *pd = dev_get_drvdata(dev); > > if (pd) > pch_dma_save_regs(pd); > > - pci_save_state(pdev); > - pci_disable_device(pdev); > - pci_set_power_state(pdev, pci_choose_state(pdev, state)); > - > return 0; > } > > -static int pch_dma_resume(struct pci_dev *pdev) > +static int __maybe_unused pch_dma_resume(struct device *dev) > { > - struct pch_dma *pd = pci_get_drvdata(pdev); > - int err; > - > - pci_set_power_state(pdev, PCI_D0); > - pci_restore_state(pdev); > - > - err = pci_enable_device(pdev); > - if (err) { > - dev_dbg(&pdev->dev, "failed to enable device\n"); > - return err; > - } > + struct pch_dma *pd = dev_get_drvdata(dev); > > if (pd) > pch_dma_restore_regs(pd); > > return 0; > } > -#endif > > static int pch_dma_probe(struct pci_dev *pdev, > const struct pci_device_id *id) > @@ -993,15 +977,14 @@ static const struct pci_device_id pch_dma_id_table[] = { > { 0, }, > }; > > +static SIMPLE_DEV_PM_OPS(pch_dma_pm_ops, pch_dma_suspend, pch_dma_resume); > + > static struct pci_driver pch_dma_driver = { > .name = DRV_NAME, > .id_table = pch_dma_id_table, > .probe = pch_dma_probe, > .remove = pch_dma_remove, > -#ifdef CONFIG_PM > - .suspend = pch_dma_suspend, > - .resume = pch_dma_resume, > -#endif > + .driver.pm = &pch_dma_pm_ops, > }; > > module_pci_driver(pch_dma_driver); > -- > 2.27.0 -- ~Vinod 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=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS 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 E9DF3C433E3 for ; Mon, 27 Jul 2020 08:56:27 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 B1E012072E for ; Mon, 27 Jul 2020 08:56:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="w7V0Rk7+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1E012072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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 fraxinus.osuosl.org (Postfix) with ESMTP id 8739B85D70; Mon, 27 Jul 2020 08:56:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ivT18w-v7wR6; Mon, 27 Jul 2020 08:56:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 112CD85D39; Mon, 27 Jul 2020 08:56:27 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E6D2BC0050; Mon, 27 Jul 2020 08:56:26 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2F68FC004D for ; Mon, 27 Jul 2020 08:56:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 16BED85D45 for ; Mon, 27 Jul 2020 08:56:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tZ7GYwPZiKdU for ; Mon, 27 Jul 2020 08:56:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 9111385D39 for ; Mon, 27 Jul 2020 08:56:25 +0000 (UTC) Received: from localhost (unknown [122.171.202.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64F0520719; Mon, 27 Jul 2020 08:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595840185; bh=ckrzN6x1hBtNGks7Ouqr9lQX/r6n4nBW5be26Bg/ZCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=w7V0Rk7+G2pBeE7TNO5yE9PaBiyD86DJaUifty8MDZfy+IcqnRFn9vsAJ6HkBKvem LMWb4s/DDoTTlgCDZ441WzPrgoF4YKM+WQN+vdf3p5zfG8oFY5AWxnxXa5oG63KfoQ kdIgLCe+0H3myAnjbOEWhgyxExwtjjsBLmm17jPE= Date: Mon, 27 Jul 2020 14:26:21 +0530 From: Vinod Koul To: Vaibhav Gupta Message-ID: <20200727085621.GL12965@vkoul-mobl> References: <20200720113740.353479-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200720113740.353479-1-vaibhavgupta40@gmail.com> Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas , Bjorn Helgaas , Dan Williams , linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: [Linux-kernel-mentees] [PATCH v1] dmaengine: pch_dma: 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" Hi Vaibhav, On 20-07-20, 17:07, Vaibhav Gupta wrote: > Drivers using legacy PM have to manage PCI states and device's PM states > themselves. They also need to take care of configuration registers. > > With improved and powerful support of generic PM, PCI Core takes care of > above mentioned, device-independent, jobs. > > This driver makes use of PCI helper functions like > pci_save/restore_state(), pci_enable/disable_device(), > and pci_set_power_state() to do required operations. In generic mode, they > are no longer needed. > > Change function parameter in both .suspend() and .resume() to > "struct device*" type. Use dev_get_drvdata() to get drv data. You are doing too many things in One patch. Do consider splitting them up to a change per patch. for example using __maybe could be one patch, removing code is suspend-resume callbacks would be other one. > > Compile-tested only. I would like to see some testing before we merge this > > Signed-off-by: Vaibhav Gupta > --- > drivers/dma/pch_dma.c | 35 +++++++++-------------------------- > 1 file changed, 9 insertions(+), 26 deletions(-) > > diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c > index a3b0b4c56a19..e93005837e3f 100644 > --- a/drivers/dma/pch_dma.c > +++ b/drivers/dma/pch_dma.c > @@ -735,8 +735,7 @@ static irqreturn_t pd_irq(int irq, void *devid) > return ret0 | ret2; > } > > -#ifdef CONFIG_PM > -static void pch_dma_save_regs(struct pch_dma *pd) > +static void __maybe_unused pch_dma_save_regs(struct pch_dma *pd) > { > struct pch_dma_chan *pd_chan; > struct dma_chan *chan, *_c; > @@ -759,7 +758,7 @@ static void pch_dma_save_regs(struct pch_dma *pd) > } > } > > -static void pch_dma_restore_regs(struct pch_dma *pd) > +static void __maybe_unused pch_dma_restore_regs(struct pch_dma *pd) > { > struct pch_dma_chan *pd_chan; > struct dma_chan *chan, *_c; > @@ -782,40 +781,25 @@ static void pch_dma_restore_regs(struct pch_dma *pd) > } > } > > -static int pch_dma_suspend(struct pci_dev *pdev, pm_message_t state) > +static int __maybe_unused pch_dma_suspend(struct device *dev) > { > - struct pch_dma *pd = pci_get_drvdata(pdev); > + struct pch_dma *pd = dev_get_drvdata(dev); > > if (pd) > pch_dma_save_regs(pd); > > - pci_save_state(pdev); > - pci_disable_device(pdev); > - pci_set_power_state(pdev, pci_choose_state(pdev, state)); > - > return 0; > } > > -static int pch_dma_resume(struct pci_dev *pdev) > +static int __maybe_unused pch_dma_resume(struct device *dev) > { > - struct pch_dma *pd = pci_get_drvdata(pdev); > - int err; > - > - pci_set_power_state(pdev, PCI_D0); > - pci_restore_state(pdev); > - > - err = pci_enable_device(pdev); > - if (err) { > - dev_dbg(&pdev->dev, "failed to enable device\n"); > - return err; > - } > + struct pch_dma *pd = dev_get_drvdata(dev); > > if (pd) > pch_dma_restore_regs(pd); > > return 0; > } > -#endif > > static int pch_dma_probe(struct pci_dev *pdev, > const struct pci_device_id *id) > @@ -993,15 +977,14 @@ static const struct pci_device_id pch_dma_id_table[] = { > { 0, }, > }; > > +static SIMPLE_DEV_PM_OPS(pch_dma_pm_ops, pch_dma_suspend, pch_dma_resume); > + > static struct pci_driver pch_dma_driver = { > .name = DRV_NAME, > .id_table = pch_dma_id_table, > .probe = pch_dma_probe, > .remove = pch_dma_remove, > -#ifdef CONFIG_PM > - .suspend = pch_dma_suspend, > - .resume = pch_dma_resume, > -#endif > + .driver.pm = &pch_dma_pm_ops, > }; > > module_pci_driver(pch_dma_driver); > -- > 2.27.0 -- ~Vinod _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees