From patchwork Thu Sep 30 19:12:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 12529275 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5881AC433F5 for ; Thu, 30 Sep 2021 19:15:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 24D55619F5 for ; Thu, 30 Sep 2021 19:15:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 24D55619F5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=F+2jlhWlte7wqMd0vOVB4DP3R4HC42fJ3DVIUs43QN4=; b=UmnjxmZByUqZs/ uSNubRIb5kVA+daNsG6z+vezcQ6zrGhDlUfhuxaGry7hFFhkGrjY6yOfiaXMaNH+WwEuL1O0Y/DXE FVX/hNeFji+FcxOxxs7ddwla5+9wznlj5vZe/Y5vmEaugYtEwnQtkuzKq6hZSjibniQ+dvoi0iiVk 2sI+GZXmp2jdi86fBlwIWUvZToM8ZctGZ4pazWt/l23daTJhjsVWBQ+fzD2UqmWNhviCGmnvZFN13 Fn4DuL4/d6INpF/pp57d6GTo5x8rZVAVk2QmDWOGAbQ3Y7L4fQSxtJ/ckyr3ogm/nNo1TBCidvBEX 0xY+BYWvunq3pksju0og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mW1UL-00FqFW-Om; Thu, 30 Sep 2021 19:13:01 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mW1UH-00FqEf-FP for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 19:12:59 +0000 Received: by mail-wm1-x32b.google.com with SMTP id b192so5479660wmb.2 for ; Thu, 30 Sep 2021 12:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y3dpOnDXlgJcFTCuS+F/+JL7imW1C4nTJ31Epoj0e+I=; b=bwAS4qXyVy5lrCFNe3bp3qWlLe4NhL1c36wauGEWB6DyD18i4Ss7dObFv4YdMqDGZW skhpVHNiYGzPXclorFKhF9zPBjfhDnzW/qpNsANXsPMKKYLxc/XviSoH+sJAiBkMzdgI wKEx5UKAxPCIL8hdltmLbcOlHDNP+AQ4PpzueOtP9j4vx22We2l03/wwpCea8a9o0T2V FYwNPUkk8C7WfQan6eDbF8HI4PDVuZ33RSefMmtiPDFQFj+l6izgK1Uz42X2AnQ0QTli O0xEhuaqx4DgcH5xDKKHJE/F5qeaUOit6yCZTajclWlYqEC+pG3Tr1nZweP/b/RMnrEw 1vWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y3dpOnDXlgJcFTCuS+F/+JL7imW1C4nTJ31Epoj0e+I=; b=1Fm428Z4eNEOevoZo5MLuhFm3JaXvRGFpZ3hfrT8+/2ZWCSTVwKKzR/otGc0b/46wL 76MMXY8fxt5YVZoHhZiAYoAX1DiaKio4AEzoBqJPzTN2Er+6lKm9/4RG9YQTs1SV/9C9 3aftXptvipkWvGJL19taNL5kzk2wmKAZRSQofUH8tvJOSeJcE1t/Priu6d9msmmGgV7V znnu0ZdsvBImy4R2xSO8Ye6DpLJoz0iqwabxXTHy8x3B51fVDcBYv8NfY1Wz9SYR9mc/ CkUa9fQKxTh1X8jFwTXsicoEP2HYmGR2XGvUhABzpiYTLXIE4IfdZhoFjfO760Br+EX6 Vkgw== X-Gm-Message-State: AOAM533FgN9x7inctqWNzJhsWMmUfr+BWlj7kppicvxipz2ROmF6S0O0 Dq5G51Nfpy4MpSmqX5Aj7vPV/w== X-Google-Smtp-Source: ABdhPJwrtPqllvSZg5XcCvZ2XXZZaUirsC+ZKZwYlgp++pji+2vnfiAHalOo1fEL4a19NSKpsLasvA== X-Received: by 2002:a05:600c:3506:: with SMTP id h6mr782894wmq.62.1633029172329; Thu, 30 Sep 2021 12:12:52 -0700 (PDT) Received: from blmsp.lan ([2a02:2454:3e6:c900::97e]) by smtp.gmail.com with ESMTPSA id l11sm4813809wms.45.2021.09.30.12.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 12:12:52 -0700 (PDT) From: Markus Schneider-Pargmann To: Sean Wang , Herbert Xu , Matt Mackall Cc: linux-mediatek@lists.infradead.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops Date: Thu, 30 Sep 2021 21:12:42 +0200 Message-Id: <20210930191242.2542315-1-msp@baylibre.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210930_121257_584463_7D3CA3C1 X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently mtk_rng_runtime_suspend/resume is called for both runtime pm and system sleep operations. This is wrong as these should only be runtime ops as the name already suggests. Currently freezing the system will lead to a call to mtk_rng_runtime_suspend even if the device currently isn't active. This leads to a clock warning because it is disabled/unprepared although it isn't enabled/prepared currently. This patch fixes this by only setting the runtime pm ops and forces to call the runtime pm ops from the system sleep ops as well if active but not otherwise. Signed-off-by: Markus Schneider-Pargmann --- drivers/char/hw_random/mtk-rng.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c index 8ad7b515a51b..6c00ea008555 100644 --- a/drivers/char/hw_random/mtk-rng.c +++ b/drivers/char/hw_random/mtk-rng.c @@ -166,8 +166,13 @@ static int mtk_rng_runtime_resume(struct device *dev) return mtk_rng_init(&priv->rng); } -static UNIVERSAL_DEV_PM_OPS(mtk_rng_pm_ops, mtk_rng_runtime_suspend, - mtk_rng_runtime_resume, NULL); +static const struct dev_pm_ops mtk_rng_pm_ops = { + SET_RUNTIME_PM_OPS(mtk_rng_runtime_suspend, + mtk_rng_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +}; + #define MTK_RNG_PM_OPS (&mtk_rng_pm_ops) #else /* CONFIG_PM */ #define MTK_RNG_PM_OPS NULL