From nobody Fri Sep 12 02:47:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7053CC05027 for ; Tue, 14 Feb 2023 15:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233353AbjBNPUn (ORCPT ); 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D at_xdmac_read(atxdmac, AT_XDMAC_GIM); =20 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; } =20 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; =20 - ret =3D pm_runtime_force_resume(atxdmac->dev); - if (ret < 0) + ret =3D clk_prepare_enable(atxdmac->clk); + if (ret) return ret; =20 + pm_runtime_get_noresume(atxdmac->dev); + at_xdmac_axi_config(pdev); =20 /* Clear pending interrupts. */ --=20 2.34.1