From patchwork Tue Feb 14 15:18:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 57067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3037885wrn; Tue, 14 Feb 2023 07:21:52 -0800 (PST) X-Google-Smtp-Source: AK7set++j3uZEIk5KCyV8g3jbSqk/kyabb8/KTX4Cy3vU3duSSQ3VmnHjJnhT1szhEF1q2mh/F6t X-Received: by 2002:a17:906:707:b0:82e:a57b:cc9b with SMTP id y7-20020a170906070700b0082ea57bcc9bmr2205056ejb.24.1676388112309; Tue, 14 Feb 2023 07:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676388112; cv=none; d=google.com; s=arc-20160816; b=oWzEOLYbsGjtAxyXrf6STZ2kdnXoX+o+pP6VGBuxWtaqz5jaNkd5ZTyINx8L/72CDi Jv/25aTkLaTWB8rIdCGiK24yho6pp7ksFM+Evw93kaJN5tZWZntFNcPHlP5boln2eVLQ qlUzCdFH5BNRg3tisKE3iUARi+lQQZcD2CIqk26rUGHDC9ku3UDpsnBQg8nkNcXkAu/Z 6zh7NmLgelqQHMCgcTJYR+LNpwIXQ/Siw+kwINR6aegfIQ7rXiVzxQMnjoNpqfRM5dr+ oVnGy91R5rQw4AJR7VPC2C5vje5nyQyknhPBrsianmqaoX0cvvs8sIl5Figcwz9XPSPR eKAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r7c/7zv6SNHxFuTYna2Q0EDRQll0CCF/mSl/fUqbh58=; b=rjAolsz//kFJcMmSMKEQlZ+1kpxBEaQtCfQtK4anPpTXizLU9KGTRWJkF9WVNZ0doi UjEJLcIXMDHFwAX3LxMPvUVPP827rR3/UXePTkH3EMy0uVJL7msc3LCPCoHioxz5KKP1 p1GS4t7eIIV3oGduo963VHJWr/hPexWiGct4BeKh7Cdmv2P+44i0rJtfWNqXYlDLCYU1 afhBekQc+qGehYj6F7fsA8KEmc3Cdvt41MKkDTvKJFGJizr/EDjjNNBOecP+7K9cqzWb KjyBFcbnB0L/hO+L1SQA8V9opQ8MxtG5hCWd+uWmFRIKrFVJWE+TuuVN0zOMOSbbvhUL e89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=KNhOaVsm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fu22-20020a170907b01600b008b1300684fesi2119384ejc.953.2023.02.14.07.21.29; Tue, 14 Feb 2023 07:21:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=KNhOaVsm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233297AbjBNPUn (ORCPT + 99 others); Tue, 14 Feb 2023 10:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232894AbjBNPUk (ORCPT ); Tue, 14 Feb 2023 10:20:40 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB49228212; Tue, 14 Feb 2023 07:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676388039; x=1707924039; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LeoNu19ctumugWsUgvjuvpWta4VcOo9UFPCAqgHpXDw=; b=KNhOaVsmVOrGSqj5ZBHpLx9QLffV2ZqOssk4a61dIu8Rz1J9ltViel7e 9zfl4BJy/9YwS1ARwU871KR9vnnFI9RbfNHdlUsYjmIras15DTpBnoAc8 kfLBTQZO3quk6FqFQ9Mm0QNYVczRPXxMt7bgEmrZq6jIll781pEERFW3o 276uDyl0hCWcBY+XmsImAYS8snjmswzRpoxuNssQqSews+Xb6d9OlQgba kkxN6kvuLLHSPgiKziD5dKGO4cMFFspzxxqKldNRH7tTKridlkzRuW31M dXHH7dlK6+nJPis957kB/TiFaUfRiDkrKem3PIyFHarYaVXUwE1xJPaTV Q==; X-IronPort-AV: E=Sophos;i="5.97,296,1669100400"; d="scan'208";a="211939034" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2023 08:20:39 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 14 Feb 2023 08:20:39 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 14 Feb 2023 08:20:36 -0700 From: Claudiu Beznea To: , , , CC: , , , Claudiu Beznea Subject: [PATCH 1/7] dmaengine: at_xdmac: disable/enable clock directly on suspend/resume Date: Tue, 14 Feb 2023 17:18:21 +0200 Message-ID: <20230214151827.1050280-2-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230214151827.1050280-1-claudiu.beznea@microchip.com> References: <20230214151827.1050280-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757820341184550510?= X-GMAIL-MSGID: =?utf-8?q?1757820341184550510?= Runtime PM APIs for at_xdmac just plays with clk_enable()/clk_disable() letting aside the clk_prepare()/clk_unprepare() that needs to be executed as the clock is also prepared on probe. Thus instead of using runtime PM force suspend/resume APIs use clk_disable_unprepare() + pm_runtime_put_noidle() on suspend and clk_prepare_enable() + pm_runtime_get_noresume() on resume. This approach as been chosen instead of using runtime PM force suspend/resume with clk_unprepare()/clk_prepare() as it looks simpler and the final code is better. While at it added the missing pm_runtime_mark_last_busy() on suspend before decrementing the reference counter. Fixes: 650b0e990cbd ("dmaengine: at_xdmac: add runtime pm support") Signed-off-by: Claudiu Beznea --- drivers/dma/at_xdmac.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 1f0fab180f8f..f654ecaafb90 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -2130,7 +2130,11 @@ static int __maybe_unused atmel_xdmac_suspend(struct device *dev) atxdmac->save_gim = at_xdmac_read(atxdmac, AT_XDMAC_GIM); at_xdmac_off(atxdmac); - return pm_runtime_force_suspend(atxdmac->dev); + pm_runtime_mark_last_busy(atxdmac->dev); + pm_runtime_put_noidle(atxdmac->dev); + clk_disable_unprepare(atxdmac->clk); + + return 0; } static int __maybe_unused atmel_xdmac_resume(struct device *dev) @@ -2142,10 +2146,12 @@ static int __maybe_unused atmel_xdmac_resume(struct device *dev) int i; int ret; - ret = pm_runtime_force_resume(atxdmac->dev); - if (ret < 0) + ret = clk_prepare_enable(atxdmac->clk); + if (ret) return ret; + pm_runtime_get_noresume(atxdmac->dev); + at_xdmac_axi_config(pdev); /* Clear pending interrupts. */