From patchwork Tue Oct 18 13:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1971532wrs; Tue, 18 Oct 2022 06:54:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40lO/HVhAb2Y6U2PSIpynfETiJWBLVNXt1H7t62aeqXlAYDRv8gbgSpjFQJMlWdFySYZQH X-Received: by 2002:a17:907:2d91:b0:78d:8747:71b4 with SMTP id gt17-20020a1709072d9100b0078d874771b4mr2489341ejc.545.1666101245037; Tue, 18 Oct 2022 06:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666101245; cv=none; d=google.com; s=arc-20160816; b=lj7AKJTR37lELurxAGvhaloHJhsaxWQy/R0J3H80N+sMqx3C9MAd52Q2FVM7BUmVFz x3FoPeD2BFP4bREi+GZEvzuEFFUJQ9uTIHgO+jeLFGdCu8167qBGjgupx1Blekwy46Iz f2xJLRdQMYR0eFXGKSRKoML5y96tnLIlxZWMHN9NPOpE2Gc6JIYTEDzIhnhsTum7Sj3J XrnQEh6yCpAoxytBQ8bL70ggR0mg3yRVOekNdF0SJ4Pl7nMvjdv3B8NZGnlX2iWh63Ln 5Mumq0LE8iKN3t4JLpIYlX99otoW/QlYixRPsOFtdi3NQrBmUCDfQQDEvoBFilGAfGZX ++2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :feedback-id:dkim-signature:dkim-signature; bh=gtRPidfBht3s3mfnhidv0jmAjwR4x/ZpX6vTRpwG0a4=; b=1KnYtZFPqgGxU/1x8HYG7S2dhf7CwZiFUHjbYcn5lmCIDqmx8l2bA0gEViAQNrI2hH wvUxVDY9DMOy9yJa9Z9idS7yEeMcpagLXqxGqxRCwxqPIVRIRerfvpSY4JrX+2HGtR0l pCfZ7N8SAtaekIqpaSO11ShQeGqysVPzXtOuM2ZvQBzmxaguuo3Yte+QFVulDR53mImA HajfvjcJ12onVtKxs7PQJHMXgjQRzvbNC/SvD6WhH9Yk0uj5W+xjmb/VSgxUPVIQxgLS iFEo9y1hpKQcSoP0Cgc4TNdJYBPiceNadYl8lV+cTSWwrYQT5E0xoU0zO2HqVltqrQop 9DWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Ixbn3kSr; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=lgbGJKF9; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay17-20020a170906d29100b00782b261ea21si9531959ejb.729.2022.10.18.06.53.40; Tue, 18 Oct 2022 06:54:05 -0700 (PDT) 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=@cerno.tech header.s=fm3 header.b=Ixbn3kSr; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=lgbGJKF9; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbiJRNxV (ORCPT + 99 others); Tue, 18 Oct 2022 09:53:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbiJRNxG (ORCPT ); Tue, 18 Oct 2022 09:53:06 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89691CF1A0; Tue, 18 Oct 2022 06:53:04 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 4C01D3200564; Tue, 18 Oct 2022 09:53:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 18 Oct 2022 09:53:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1666101181; x= 1666187581; bh=gtRPidfBht3s3mfnhidv0jmAjwR4x/ZpX6vTRpwG0a4=; b=I xbn3kSr195n1Ku828GGqT9LNGbZYN9khyCSnY4wBk2NpoD+ADDKH3qhEt74snp1G RkEToqTq3c5poMxn53/x9SHOi52Unf0jEkIhGXczJPFHbdR6xIYramB39TqmXGzj 9S61cbdqFEfVn7E72pn7JNi+U3sDTcanQpulGCWURIGPujZlcJhhtr7zqiLGd3Ht 5HnqP2zpq9gqVdas81sGMJnY2sC84gknwP72baruxA9pfi4kHS9/SxTCLGHWisYG /LKaMmzckbVDHFXBGCDfAexwLKJClaGMHiE7J/zr+oXh1IUZ61I/L9KCPR5BFpkx Df9oLN+RIZOO4nz3fNTIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666101181; x= 1666187581; bh=gtRPidfBht3s3mfnhidv0jmAjwR4x/ZpX6vTRpwG0a4=; b=l gbGJKF9TJJX4ozkCOqMcnIH8mEjozHYZ+NCoIuZmSiqkUueqPlGGWVYc70mEyBR7 Lt6A5QNi4p1CrVZSikL9uH0hJwF30AsjnZjJlsnFqYj3QpYHiZVwxKs1m2PAtyAD 5FEMtOA+D+MUkNh3XLJVP9CiyKtB3CRSX0XkwJGXRbhaP32WDY5PC2UjTVkpvfYC q2eO5mWRZeKTeQFB/crV5Baqnwp7LtZacSRJf2RrnhNKd8NPab+ypkFbPGggMXiX yYKJZdu0Ed1nAmXQ/08ZjD2X0s9IrkWCo4Bdqe8tOyk1TX7XR9qweMHGesjQZrA9 sj5ZGV9eW3bbe5H6M8e5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Oct 2022 09:53:01 -0400 (EDT) From: Maxime Ripard Date: Tue, 18 Oct 2022 15:52:56 +0200 Subject: [PATCH 1/4] clk: Remove WARN_ON NULL parent in clk_core_init_rate_req() MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v1-1-f3ef80518140@cerno.tech> References: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> To: Stephen Boyd , Michael Turquette Cc: linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , Maxime Ripard , linux-clk@vger.kernel.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=1452; i=maxime@cerno.tech; h=from:subject:message-id; bh=zafRG0QXl+PXtxAm4Bsu+gNoZDPQ5i9BnzeNzVpJFUE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMl+63fq613QnCGifVvqiPD2noefCzazdHF/+TPhz8sfsZFO Res+dpSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiPcIM/2Pv8Wd5/pdo477bt0JXNm bVO+U1bRMX3tW+MltY4mr8WhZGhrasfcuLNZfc7rsz//mT6oKOO48e7jukfercAt3HPEq2J7kA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1747033779096094151?= X-GMAIL-MSGID: =?utf-8?q?1747033779096094151?= If a clock has CLK_SET_RATE_PARENT, but core->parent is NULL (most likely because it's orphan), callers of clk_core_init_rate_req() will blindly call this function leading to a very verbose warning. Since it's a fairly common situation, let's just remove the WARN_ON but keep the check that prevents us from dereferencing the pointer. Interestingly, it fixes a regression on the Mediatek MT8195 where the GPU would stall during a clk_set_rate for its main clock. We couldn't come up with a proper explanation since the condition is essentially the same. It was then assumed that it could be timing related since printing the warning stacktrace takes a while, but we couldn't replicate the failure by using fairly large (10ms) mdelays. Fixes: 262ca38f4b6e ("clk: Stop forwarding clk_rate_requests to the parent") Reported-by: AngeloGioacchino Del Regno Signed-off-by: Maxime Ripard Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c3c3f8c07258..37d623c7b73b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1459,7 +1459,7 @@ static void clk_core_init_rate_req(struct clk_core * const core, { struct clk_core *parent; - if (WARN_ON(!core || !req)) + if (!core || WARN_ON(!req)) return; memset(req, 0, sizeof(*req)); From patchwork Tue Oct 18 13:52:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1975814wrs; Tue, 18 Oct 2022 07:03:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6TwjCZsCVn7E3IiiykaqMXmGd0tjEFVNrEFU5oTJZgY2g6uPGIEDgcq/hF1UAfRcVcvpv6 X-Received: by 2002:a05:6a02:199:b0:469:d0e6:dab8 with SMTP id bj25-20020a056a02019900b00469d0e6dab8mr2819843pgb.97.1666101789614; Tue, 18 Oct 2022 07:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666101789; cv=none; d=google.com; s=arc-20160816; b=U4x1PKp5Og9umgQd+oeY6ySQn0A6jW5xDfiLYoExIgsNMklWUIiNn3adhPxHGGR16e VD7lS5Qt57vqj0n7yKngwHV24kOm6qzFPF8mhqD00E22xyrqL1qSrAhqKHRSlY6hfScX nJzruHI+wfUApjOcaVTFaiEL7hSz6M7pMphGOKlX2XNnDQcFLXaizGg2QZteS/ODIOXg xTYafhMlY++5QNWD2Hke5+1zMFc4ekIyUKnWrI/4Z65WyZD6nrISbwY7a6CAsjSmr4J7 bziyp8T20e7dgjsV9eLki1y5zEh7tk3WbQZREmeg1Jh932/ymbcqr/f+OilVfrXdK296 cO2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :feedback-id:dkim-signature:dkim-signature; bh=DXf8wDkwySWMLPkhlz7v5fI4HEF/Edy2/upUN3ptl1c=; b=fPHoG6sBdPRaH3D1iAhe9bQmjAFe+4nrK5W8tkybKXWHa1T9DhFky9ZNmitFkT0iSC ryWsvM0xG5Iqn4RJ1Yj5nHyq/eIwMC7cMW4WWPJknfn9tHlnNMVOxTW5QNz60IIP844q cE/Mv0KN4xPtDTyjTGb8AAGB6JsLLbIm1jqmxJvZK9Iv5yPIAvb5EsuPMywTfxgppojP REqWdkF8wYuMGOxIgsYJPp/vjghXvBHDWMyiOeHWcindnPKT31TgtPKnFf58EgVpgXeo Jy7KOXHa492fkAJfVjbXLNi1EttMER9IQK+x1RKzgczQ/sH0XUFQKC3VncPGKy3VtRY+ 4POA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=WxK35r7l; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=qgVUOHXs; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a170902e55200b0016d9c8479b5si17553809plf.344.2022.10.18.07.02.42; Tue, 18 Oct 2022 07:03:09 -0700 (PDT) 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=@cerno.tech header.s=fm3 header.b=WxK35r7l; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=qgVUOHXs; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbiJRNxZ (ORCPT + 99 others); Tue, 18 Oct 2022 09:53:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiJRNxH (ORCPT ); Tue, 18 Oct 2022 09:53:07 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE43ACF1B5; Tue, 18 Oct 2022 06:53:05 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 001613200923; Tue, 18 Oct 2022 09:53:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 18 Oct 2022 09:53:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1666101184; x= 1666187584; bh=DXf8wDkwySWMLPkhlz7v5fI4HEF/Edy2/upUN3ptl1c=; b=W xK35r7ljU4BDtTKPrb9jYhjuGcnQnK2WXcIAwVfIpYeor0GSJ51iXD4fOufGMKCE Cfldod0W+LyMeNCGtOaqeOW6A97X4E6DJsYMxpgt/vaMX+6lzk65vfdyuj5JpzBQ 7DLopwQmcdoFFDRuPYGPb17k4H278/z7APijWRfg5TvyvZnbdouWv2mml+D5pBMd Xh7PyAxG7jSNAttkp2mf01H5ZpnfdsrDiSRFS3V0RRdHewzc9j93MKz4bs+RrfJd udxZicRl/2g20E3sjS15ev8MYZJHM3LEp57+v86SxaSBVwK0gUjy12MWCA2fMTqu lixSGPyC0VQtK1xhnCPYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666101184; x= 1666187584; bh=DXf8wDkwySWMLPkhlz7v5fI4HEF/Edy2/upUN3ptl1c=; b=q gVUOHXso0KugiT5m88dJHddyV03nCg07zZ/v0WJ815HbV9M8WUrCO2e9lrfK7wak ropcDjrukykTcOf0DB9m924vbcs1Tpyf7rCmZ+ldO23p0SyBkFCN3v0L1fffJcN0 kPP2/MzmULSAYWUK7fAwpR6NDgZV1ELF/g8JFjdhPxmLP62MPWLxI02rgdSNBzon 3echaQabWeyY9klS5IdPSQe8xVdaR/FCNyKvpkhemXBVoB+Ij9JrdmomsLjU9klJ eaSi9wDRMC5lSFR6jUtKtyrIOl0MHNPRXhKGF3+FOTno7bUcQBZo4OePGf61IFe7 RiqsAT1BVeKbFNtmNkiNg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Oct 2022 09:53:04 -0400 (EDT) From: Maxime Ripard Date: Tue, 18 Oct 2022 15:52:57 +0200 Subject: [PATCH 2/4] clk: Initialize the clk_rate_request even if clk_core is NULL MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v1-2-f3ef80518140@cerno.tech> References: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> To: Stephen Boyd , Michael Turquette Cc: linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , Maxime Ripard , linux-clk@vger.kernel.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=1541; i=maxime@cerno.tech; h=from:subject:message-id; bh=iJZ09jCGM7ggARymjXyYWOUrb3STDwvqi5POK1c/Slg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMl+63dq6W9+fcX56nXN+4c3tdwLyl5TKfcgpiBuVa3Mm6qj W/5GdJSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiq44wMixx/7ZvGuvy/wZeW2asiP l48fcxszdK7Sc8vtzIjE89+WUTI8Nthynz/lo+K1i6aplencGqY/sWd2+/Zdvw3PLerc+JE59yAgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1747034350001165206?= X-GMAIL-MSGID: =?utf-8?q?1747034350001165206?= Since commit c35e84b09776 ("clk: Introduce clk_hw_init_rate_request()"), users that used to initialize their clk_rate_request by initializing their local structure now rely on clk_hw_init_rate_request(). This function is backed by clk_core_init_rate_req(), which will skip the initialization if either the pointer to struct clk_core or to struct clk_rate_request are NULL. However, the core->parent pointer might be NULL because the clock is orphan, and we will thus end up with our local struct clk_rate_request left untouched. And since clk_hw_init_rate_request() doesn't return an error, we will then call a determine_rate variant with that unitialized structure. In order to avoid this, let's clear our clk_rate_request if the pointer to it is valid but the pointer to struct clk_core isn't. Fixes: c35e84b09776 ("clk: Introduce clk_hw_init_rate_request()") Signed-off-by: Maxime Ripard Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/clk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 37d623c7b73b..eb2f9be9b9aa 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1459,11 +1459,14 @@ static void clk_core_init_rate_req(struct clk_core * const core, { struct clk_core *parent; - if (!core || WARN_ON(!req)) + if (WARN_ON(!req)) return; memset(req, 0, sizeof(*req)); + if (!core) + return; + req->rate = rate; clk_core_get_boundaries(core, &req->min_rate, &req->max_rate); From patchwork Tue Oct 18 13:52:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1977013wrs; Tue, 18 Oct 2022 07:04:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4s2sZ8uYWeedsbmODXgYZg6AeZ9p8K1X/d0qYbtA8Gxn66hbmDR7JI8umWZRg/ys+TXArt X-Received: by 2002:a17:906:cc4f:b0:78d:fdd5:9ea9 with SMTP id mm15-20020a170906cc4f00b0078dfdd59ea9mr2517568ejb.57.1666101893474; Tue, 18 Oct 2022 07:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666101893; cv=none; d=google.com; s=arc-20160816; b=v17Ow3dUL5Red2uYr2Cc/7rH2an/stAe1A9QHxK+lqxAim7VLjfk1gss66AVOsh4Ax Gnln9FOhsqEzAG4H8tVCyHISt0wJpColisnPPmo5KiEns9E2SIZG1UJiGGhonj7xQ5sP Jc9maZ8hrpqwmexzWcJ1m0GDK6LnPvdzO6oys7J/RrAs2+EojUAoB91fVqUhn9VqOPhh 19NVaUPEAU8u6EywFOeVbpk7Dc2ePiXh8huHSm42c8dGiWTTZD3i78JvqaG73UdkMxmC 2IrDhmfpqodRN9T5koD9bma/d4ervhCmQZTti4MiABOlviRu4K1ou1+qdqgiFXy1bFtN Fjqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :feedback-id:dkim-signature:dkim-signature; bh=zC15H4SSLDkQqZpq7Xp4KXOnBwWt4isnG8QaWwdlOMk=; b=SI3uD/IH5APDclW5M4/glq+IkdGFRHyOo/KhelASSZjzcAxpux6Xg6y0RcRVSFvGAc O4lVzVXgmumQG4HEAJhZCleTh3maDxbuTrrCf/JJzg5+mUYclS6Gk7ZdrvbEJ8xNLGoc +qcGafHLroWCB+XSqkgfUyaR5YCiX79TONG17tMwXTJFAq9GtG1BlarYrqSd9PSWDjXN Z+0Vf+zb2ouXDJvC9F8H0DMTySGsDmWbgxXuc9nTofX+SlMxO9HaLIOm3sSayOBrNa2F escAgDmBCZA4Y6/YyqNrUpU2gNf+/6GLmikADExkHsrxll+nYDN8zX/0qRhDAXxohK+n fRBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=LBjRCMBK; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="Po/xgpCs"; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a170906704b00b0078d44b51f66si10686717ejj.1008.2022.10.18.07.04.04; Tue, 18 Oct 2022 07:04:53 -0700 (PDT) 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=@cerno.tech header.s=fm3 header.b=LBjRCMBK; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="Po/xgpCs"; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbiJRNxe (ORCPT + 99 others); Tue, 18 Oct 2022 09:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbiJRNxN (ORCPT ); Tue, 18 Oct 2022 09:53:13 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFDE5CF849; Tue, 18 Oct 2022 06:53:09 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C982C3200973; Tue, 18 Oct 2022 09:53:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 18 Oct 2022 09:53:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1666101187; x= 1666187587; bh=zC15H4SSLDkQqZpq7Xp4KXOnBwWt4isnG8QaWwdlOMk=; b=L BjRCMBKIUkxLIcjsUnNNdEB4Kp7tt9FyxpDktf7DsYL0O/AIi7EASW0Ab7ZhiAkI Q1cV1StyiFtpW3o3j+sUm9OZYDDnrNLNp53W43uqNXT+6jOOL8UM+G+w4U84kvLi Q1QLLLRfFSo/aHTacVn19aDY19vJGVvd9CA+MVQ5s9bvC59mDwuEbKtQ3hxvu6lB EqJLGc2h4cWyj/U17j8b0VsyHY2tyfJMeZx8exQjyGZWNENP2cAUI9e3iSuIbrBL n9IQ3F37HUuhhBgFk98faIdsjRcxgonWfYVUXY+nJIjUyHJ8Mnpl3380ZNUb5lZo 3jfH/HCWQBxCm0AZGtw5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666101187; x= 1666187587; bh=zC15H4SSLDkQqZpq7Xp4KXOnBwWt4isnG8QaWwdlOMk=; b=P o/xgpCsDKQzNYrOVioK7CmTbSlZDVtgut8Dcm3EjbEF1d5F2DfZLZStGGqq+7JtI DMNMjvBeZRmRonobaeF1mb1pNHGUr99dslC/ZD8mPjtS3XItrKXPeXPqW4LDgOoo QcJs6qm5BUrjc5FWuY6ppK5LTGnJCTeT7odFUIwa7q6/KJ5agcDrRXbhv4IWtTS8 rrXCprXGmDzhvM0tGZg6jiuZieELhuxkOyvoobxuys4kVELulGCWy4WKVp9wtKpx qfZxifB9ATSuial+oWMyXuko7XyjxQP5GcIreLgrRhwXlcaOq/yNxw62tJ2y44T9 w5CMZrUNFdPdzZWNIFwkA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Oct 2022 09:53:06 -0400 (EDT) From: Maxime Ripard Date: Tue, 18 Oct 2022 15:52:58 +0200 Subject: [PATCH 3/4] clk: Initialize max_rate in struct clk_rate_request MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v1-3-f3ef80518140@cerno.tech> References: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> To: Stephen Boyd , Michael Turquette Cc: linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , Maxime Ripard , linux-clk@vger.kernel.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=917; i=maxime@cerno.tech; h=from:subject:message-id; bh=KLxniowvB7k1BDJbP1S+8WEzaS8XpK4dLNHTLmCyBkY=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMl+63dmftq4nj95n16R8bn7TR8fpVjWHfl56O7VgO7s65v0 tkeJdZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAike4Mf4U6k3ecfq7uysi1T06Q23 t++63S6nSWiasXrc+71Hnr0DOG/75mlwvMWq+W6+REamywuvLRWm1uvIILi9JCG8GL35v3cQIA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1747034458931773846?= X-GMAIL-MSGID: =?utf-8?q?1747034458931773846?= Since commit b46fd8dbe8ad ("clk: Zero the clk_rate_request structure"), the clk_core_init_rate_req() function clears the struct clk_rate_request passed as argument. However, the default value for max_rate isn't 0 but ULONG_MAX, and we end up creating a clk_rate_request instance where the maximum rate is 0. Let's initialize max_rate to ULONG_MAX properly. Fixes: b46fd8dbe8ad ("clk: Zero the clk_rate_request structure") Signed-off-by: Maxime Ripard Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/clk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index eb2f9be9b9aa..57b83665e5c3 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1463,6 +1463,7 @@ static void clk_core_init_rate_req(struct clk_core * const core, return; memset(req, 0, sizeof(*req)); + req->max_rate = ULONG_MAX; if (!core) return; From patchwork Tue Oct 18 13:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1975910wrs; Tue, 18 Oct 2022 07:03:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+xUBffnHZSclWz8zWXBDCEoUwBGi82Tfd+RxBrcBtoHpkb83vcB1C0UzRM120AUpH1YMs X-Received: by 2002:aa7:96e6:0:b0:562:6f4e:151 with SMTP id i6-20020aa796e6000000b005626f4e0151mr3393932pfq.35.1666101798058; Tue, 18 Oct 2022 07:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666101798; cv=none; d=google.com; s=arc-20160816; b=BZJbKh8lOKtIVusvWW8WOIgT402lygKBnVZt684YqNDR4vZREBet5VsvG3/bgFiV9w KaDN7T7qJYN+iaroFCFzbrSCAqlODVlZRuEO/OD30Wr58wKBxbG2ykFGe2tN2Q14fZHm J+gdfykjBmjBDMVVMwyBtiMlFRaERr5TNobOy3QBr+EhoDXLUqDDhthB4FUnNJFQ31rI Hg/pEY6vTHlgHAGhk4IcSAZn7FpFCF9mcYffFYUilEY8iF66y3njQG8eHItDVf5+TNJF VPe2QOLpfwFso0PYHWg2U5iXhYLzrvHaYyzIDQjEfeEaXR6kWEX1M+SP2kZ2PqQN/erW HtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :feedback-id:dkim-signature:dkim-signature; bh=ibUWEHKj/QGYphdrbN1NQxPjpBdpTfdPpbW8Zfp5n24=; b=FnvxJmlVI9PVggnoqwyFIFd4V/IcNM/UyCITIl0yiRSEjW989nK9//r7Kgeqymo7MT Zt86MwhITanTbOlnaG2kbwXLjaVE6d8yD8ESX36dA8rmGhipV/c5Id8ismQA1ZVpl5NT CFy88NAUT7kn1cdaZPS0cNlzL76uEV+7mEcoxAoO5UW9zNKyc+TqPrSL+S7LekHYsrLT OEqBouVAAc3t/w17Qfzo1+4hkGE2wKxoJdvxH+y0UM67IQGAZO4cnJgWVDV2xSAjK7Jh WMaL41Xl861cNjEaSHTkq3eAFdSx/MZHi157KR6CnDpocCZU9FSLOcrd1XXP35PfiQB7 wggQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=qfdt2iuJ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=g1B5U4uP; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902b68600b00174418919a6si14323951pls.513.2022.10.18.07.02.54; Tue, 18 Oct 2022 07:03:18 -0700 (PDT) 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=@cerno.tech header.s=fm3 header.b=qfdt2iuJ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=g1B5U4uP; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231296AbiJRNxi (ORCPT + 99 others); Tue, 18 Oct 2022 09:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbiJRNxd (ORCPT ); Tue, 18 Oct 2022 09:53:33 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05375CF86D; Tue, 18 Oct 2022 06:53:11 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 78F173200923; Tue, 18 Oct 2022 09:53:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 18 Oct 2022 09:53:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1666101190; x= 1666187590; bh=ibUWEHKj/QGYphdrbN1NQxPjpBdpTfdPpbW8Zfp5n24=; b=q fdt2iuJGXRsapKcoIvKsndV90b43m3LdWkH/T7RkSR37uK3Nf75NrrJTWAPsIWRl QhKGn23g0Z5onkcIaAi2zzoIhQ2nWQuCd9PbfZM3pRM76w/TY+yC9SRtT1jBSpZn 8B1Sv4OUP5A58Rw7C50iU/TARLMoEUElP5n+KpAwSSQuhTdTmpbgKFWWSWsFD/vD EyNmXdZNVridtOg9lGdYTW8J2w6WyOGDY33ZhZeuT/1tziodY5KwmUKB7nTPV+y/ bMEP7Jw7J6IdgwsS/3NsOeKI4VOHQPl/IJ6/hyAvINzNUdd3f0V122q4IuFws5y1 4l6px5eFUT3L2KgJNzwNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666101190; x= 1666187590; bh=ibUWEHKj/QGYphdrbN1NQxPjpBdpTfdPpbW8Zfp5n24=; b=g 1B5U4uPMB2vzrOREFU+bd7TP+W4tMKIawGq74S8XCMEPT3rdOQlrxJgKApq3+10D qKJw8MjqMOlba/tCmAXE7pR67YYDkFrcgMV0n7ZlHR1jtQyIkXSafp1ThM3+BtAP pTcsHhwrGmHmjWrV8Bahoc1t8oXGSvg76bE3XwybOqBUg/UKO4c4ZCjWGP/UVU/E MMtZl0cuk3/PbyewIHO5EYA2q+VjV2iyqPLenhwPeCROk5Sj/q3r73FLbVnny39O KIAMozQyWo56b3GXammZP5O18PpqOkRNXwl9cVTzchror5rH6h5Wh5s9TSvMg5NN y0D7yY9RfuO4d6xhNzg6w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Oct 2022 09:53:09 -0400 (EDT) From: Maxime Ripard Date: Tue, 18 Oct 2022 15:52:59 +0200 Subject: [PATCH 4/4] clk: Warn if we register a mux without determine_rate MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v1-4-f3ef80518140@cerno.tech> References: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v1-0-f3ef80518140@cerno.tech> To: Stephen Boyd , Michael Turquette Cc: linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , Maxime Ripard , linux-clk@vger.kernel.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=1775; i=maxime@cerno.tech; h=from:subject:message-id; bh=oxdhfLzGwvzQhDYbvHA+Mn0OUJuj34vZoXZ5WdkABms=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMl+63fu+nej4e7DpG87NtquvJnTrMMx62dzYNLNbXErnauY 2wrvdZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAi6coM/90MRYpaOizO27CvW3v6es tUDa/H0y/p5RuocE679bJngxAjw8lgu7haNeP4yMWLlsUXLdALn5O/vTs66PqqVbcPXPIM5wYA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1747034359111702616?= X-GMAIL-MSGID: =?utf-8?q?1747034359111702616?= The determine_rate hook allows to select the proper parent and its rate for a given clock configuration. On another hand, set_parent is there to change the parent of a mux. Some clocks provide a set_parent hook but don't implement determine_rate. In such a case, set_parent is pretty much useless since the clock framework will always assume the current parent is to be used, and we will thus never change it. This situation can be solved in two ways: - either we don't need to change the parent, and we thus shouldn't implement set_parent; - or we don't want to change the parent, in this case we should set CLK_SET_RATE_NO_REPARENT; - or we're missing a determine_rate implementation. The latter is probably just an oversight from the driver's author, and we should thus raise their awareness about the fact that the current state of the driver is confusing. It's not clear at this point how many drivers are affected though, so let's make it a warning instead of an error for now. Signed-off-by: Maxime Ripard Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/clk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 57b83665e5c3..11c41d987ff4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3700,6 +3700,11 @@ static int __clk_core_init(struct clk_core *core) goto out; } + /* TODO: Promote to an error */ + if (core->ops->set_parent && !core->ops->determine_rate) + pr_warn("%s: %s must implement .set_parent & .determine_rate\n", + __func__, core->name); + if (core->num_parents > 1 && !core->ops->get_parent) { pr_err("%s: %s must implement .get_parent as it has multi parents\n", __func__, core->name);