Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp878557pxk; Thu, 17 Sep 2020 20:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbiBsYVRUtjJOl1BlT5lIYmdhLOh22wkL1psWMbF9Gazn5AvfVw1Fu1ZW4Kw7i41xh/lkQ X-Received: by 2002:a05:6402:17ed:: with SMTP id t13mr37140285edy.163.1600398456469; Thu, 17 Sep 2020 20:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398456; cv=none; d=google.com; s=arc-20160816; b=hNey2DcqTjk+RdXEL+I5xo4waar75wTKopFSGY1BKpKUds4qd8Tc/sxEEgRwjeC4WN s+8DKiJXpON3qGHKzAu0jrmSG/pr1AfuNlpMaDceYjyzsx97Em6IweP2CChUPJ4A0xfO OvQ9312QHxXjS94yNXOjr2KDP6EpwqRYx6as3acVyCvbV+qEcrkBSuYWqOBHCt/GrhTJ JZkJVDIOsz0T3lvZyBMlb4f8rUiR4r9jKnwA3pKMUZhzXngN59jxhbcry2L5ejiKoh+K kHlC+nqMuNfxwVx/Az72wZS0yL0kRpYcAg5DY/PeFdLUhokDAxg+3M0YmNkT/xJ/1KXA OgSw== 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=l3adzpsyi0h0btlOaei5EGqMVzUmn1mdLsvy/hSftcI=; b=zDMY5XLPJ1Z0cEP/o/DL+MdjKEysVrKUXU/ZUzQY7+CxV+50sCPoBsufW87N41yhxJ SrNR6jxBStpTvCHFUFTF636pj0ujK5qKd6CasVNdr7ZENl49mQsXDtj5wPI+rDv7MGal A7WzR2tS+D9Q9vbRV3U81vlqmNaoJ2dlxUtRVQXiLxN2atpoE2nRcBFn6mr9MMtoEoOw mC3jsmy1pGnmtJ4UTKDC0bWqHHcANgw89VBDEZ7uUPV6l+EL0BeS2/0IJLcMbACPnbnf nn+IouKuxSsD210LeEiuR/252w99YuG3Om50ef6EHbrm2FDSNMfLO4po6AFIS0JULcpK QiIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dxYEuqAw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si1459868ejh.697.2020.09.17.20.07.13; Thu, 17 Sep 2020 20:07:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dxYEuqAw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbgIRCEd (ORCPT + 99 others); Thu, 17 Sep 2020 22:04:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:51878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727264AbgIRCE3 (ORCPT ); Thu, 17 Sep 2020 22:04:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7984723787; Fri, 18 Sep 2020 02:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394668; bh=Adt6RvK5imwNgQL791a9n50jRKgHUDzZKp9JlfVyb6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxYEuqAwsa/EBYtGiFrBhRJ9GCYx8/GlxzTEdxKVq+uaWI95POnpMeaiObce1ECyn nV1bWvN0QTKSBkgzzqSCWL0vd39+l5UWvF8ElB26wkULujvVWd1FNW5lr/2w1fySfH JhWGupSzPfUHTngb3SPGNk+rWvkL8WyecCXBX58s= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anson Huang , Peng Fan , Shawn Guo , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 161/330] clk: imx: Fix division by zero warning on pfdv2 Date: Thu, 17 Sep 2020 21:58:21 -0400 Message-Id: <20200918020110.2063155-161-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anson Huang [ Upstream commit 28b2f82e0383e27476be8a5e13d2aea07ebeb275 ] Fix below division by zero warning: [ 3.176443] Division by zero in kernel. [ 3.181809] CPU: 0 PID: 88 Comm: kworker/0:2 Not tainted 5.3.0-rc2-next-20190730-63758-ge08da51-dirty #124 [ 3.191817] Hardware name: Freescale i.MX7ULP (Device Tree) [ 3.197821] Workqueue: events dbs_work_handler [ 3.202849] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 3.211058] [] (show_stack) from [] (dump_stack+0xd8/0x110) [ 3.218820] [] (dump_stack) from [] (Ldiv0_64+0x8/0x18) [ 3.226263] [] (Ldiv0_64) from [] (clk_pfdv2_set_rate+0x54/0xac) [ 3.234487] [] (clk_pfdv2_set_rate) from [] (clk_change_rate+0x1a4/0x698) [ 3.243468] [] (clk_change_rate) from [] (clk_change_rate+0x280/0x698) [ 3.252180] [] (clk_change_rate) from [] (clk_core_set_rate_nolock+0x1a0/0x278) [ 3.261679] [] (clk_core_set_rate_nolock) from [] (clk_set_rate+0x30/0x64) [ 3.270743] [] (clk_set_rate) from [] (imx7ulp_set_target+0x184/0x2a4) [ 3.279501] [] (imx7ulp_set_target) from [] (__cpufreq_driver_target+0x188/0x514) [ 3.289196] [] (__cpufreq_driver_target) from [] (od_dbs_update+0x130/0x15c) [ 3.298438] [] (od_dbs_update) from [] (dbs_work_handler+0x2c/0x5c) [ 3.306914] [] (dbs_work_handler) from [] (process_one_work+0x2ac/0x704) [ 3.315826] [] (process_one_work) from [] (worker_thread+0x2c/0x574) [ 3.324404] [] (worker_thread) from [] (kthread+0x134/0x148) [ 3.332278] [] (kthread) from [] (ret_from_fork+0x14/0x20) [ 3.339858] Exception stack(0xe82d5fb0 to 0xe82d5ff8) [ 3.345314] 5fa0: 00000000 00000000 00000000 00000000 [ 3.353926] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 3.362519] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 Signed-off-by: Anson Huang Signed-off-by: Peng Fan Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin --- drivers/clk/imx/clk-pfdv2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/clk/imx/clk-pfdv2.c b/drivers/clk/imx/clk-pfdv2.c index a03bbed662c6b..2a46b9b61b466 100644 --- a/drivers/clk/imx/clk-pfdv2.c +++ b/drivers/clk/imx/clk-pfdv2.c @@ -139,6 +139,12 @@ static int clk_pfdv2_set_rate(struct clk_hw *hw, unsigned long rate, u32 val; u8 frac; + if (!rate) + return -EINVAL; + + /* PFD can NOT change rate without gating */ + WARN_ON(clk_pfdv2_is_enabled(hw)); + tmp = tmp * 18 + rate / 2; do_div(tmp, rate); frac = tmp; -- 2.25.1