From patchwork Mon Mar 2 21:43:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30EA914E3 for ; Mon, 2 Mar 2020 21:44:40 +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 0E35D22B48 for ; Mon, 2 Mar 2020 21:44:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AAOQWTGG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="kjYpl6I2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E35D22B48 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lfdTxOPf1cU0a1Xj0cvym3qFzbXBPncIH60LoXrvLH0=; b=AAOQWTGGHcavxa 7QyP2ueGJ6W6CuZMvgRB2zdauoUlWbucC9Bb+RJPRTgXpnm/JBxXq6+ygbRdfPlEYgSVNgxYVJk5Z aTNTfVlSVzieMmucEbtgsEPVFbQRtfTQpXFoSTqtYU/PaUVqZoeX33pv+1cYBGry8ExTRzSrIzCkF b4o6Ds+zLX/4Ocu0/mwdVAJxaCFDPIan4wGs7U2/IwyUg8ktHFhwWUHkkr3IadrH8xFk7GH8hUAWx 0ZeHRJD2J0Zh8wM2Ow0kW7SAPp6T0CfuzFy4uO0zwIO6tZkd+V/l5HgcAIaAaywIgYzBrerkBTH5Z AmvUZ7PC3UPbHab6NkTg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8src-0003Qm-AP; Mon, 02 Mar 2020 21:44:36 +0000 Received: from mail-eopbgr750058.outbound.protection.outlook.com ([40.107.75.58] helo=NAM02-BL2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sqy-0002kl-IG for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:43:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JuLTwU6pR0MZRWSjIMvtlbDlHCo/dTl6BnynCJVS3IEc8S6ubsoIRzoGOQ40pT0Dj3gFZMOLOgYjRCk+VxCjNAmKffdJ5I0lcAAAQjO7r6spsY45ezepALBUAa/LfTTOPmBPsRyXP5jdHDy0WHsmVgfKloJwqMq4sdB1GJQLPahVs9hhIZwaG359nRoU8rn1VVcfnGnh7sQgfx+cKG30k1Z9VyPyTbwUC0kYtVMutysdYPPWP0UGSYTzQno8QrFmXLbftEolA9AwIeExbzPZREaEcIKIQfj1F3w7WI5xKOQ1b1fFGNGUnZ+SZZjHYzI+ihPcyeOf4VEe7Btgfl551g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3/xVlYc/R+TRQOYmwrrZgcBT+Cj5ANkycUcVaN5jcRg=; b=kSecku/J1nhmfixbj4mYQSyrcFiNj8kiJqnfTX83yrStHtQcwuGM95NtGteW1TCQRZrPCPgJwb3v502Co84yq0wnXWVzJ8uyyAdavYa5U0P/aiATH7oVUY3Pb0mCFC6/YFDl7IADHni2NzVSDihMw5FAgF683XOxwBCi+XyNBKV6sQbwvM2azjLMZg6Q8xNGj4Z9NsZB016myXk6/65x5TSuQTWuj2ASaRY0YTddL6zNBBOaPzHm860vSIg/lZpgAReC9k7om61ZB+0qG8LpJ+vU++WdIV5Lk4IYC0mLWlFgMwF1umrviRRMpiESmHjsaug0wV7fg6fArmPObATuRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3/xVlYc/R+TRQOYmwrrZgcBT+Cj5ANkycUcVaN5jcRg=; b=kjYpl6I2OJvalXvHjSkZA28ZoCpZA8U24dGdgAjxLedyi32hbjS59OI2qFBqHVrueoDVu8eyA7rCo/vluJ1amdqsFVHeN8o05nVHGcOz1iZO0PShBGC2+fz9howHFBX7mtLw3vSdt3woFFFB77/Nt1lkKOv/yEBhleV+Di+TOw0= Received: from DM5PR19CA0013.namprd19.prod.outlook.com (2603:10b6:3:151::23) by SN6PR02MB5663.namprd02.prod.outlook.com (2603:10b6:805:ea::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.16; Mon, 2 Mar 2020 21:43:53 +0000 Received: from CY1NAM02FT028.eop-nam02.prod.protection.outlook.com (2603:10b6:3:151:cafe::b7) by DM5PR19CA0013.outlook.office365.com (2603:10b6:3:151::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18 via Frontend Transport; Mon, 2 Mar 2020 21:43:53 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT028.mail.protection.outlook.com (10.152.75.132) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2772.14 via Frontend Transport; Mon, 2 Mar 2020 21:43:52 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1j8squ-00020D-CV; Mon, 02 Mar 2020 13:43:52 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sqp-00033f-9W; Mon, 02 Mar 2020 13:43:47 -0800 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022Lhi69006055; Mon, 2 Mar 2020 13:43:45 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sqm-00032V-Mq; Mon, 02 Mar 2020 13:43:44 -0800 From: Jolly Shah To: olof@lixom.net, mturquette@baylibre.com, sboyd@kernel.org, michal.simek@xilinx.com, arm@kernel.org, linux-clk@vger.kernel.org Subject: [PATCH 1/4] clk: zynqmp: Limit bestdiv with maxdiv Date: Mon, 2 Mar 2020 13:43:31 -0800 Message-Id: <1583185414-20106-2-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> References: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(346002)(39860400002)(199004)(189003)(4744005)(26005)(5660300002)(426003)(2616005)(356004)(6666004)(81166006)(8676002)(44832011)(81156014)(70206006)(316002)(54906003)(186003)(70586007)(336012)(478600001)(7696005)(4326008)(36756003)(8936002)(2906002)(107886003)(9786002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR02MB5663; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; A:1; MX:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ce618c3-c5d0-4a1a-dd59-08d7bef2cd24 X-MS-TrafficTypeDiagnostic: SN6PR02MB5663: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:923; X-Forefront-PRVS: 033054F29A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2ctZSpmuxmPSZzeNbDOEyXIdi4zVeEMVFGb+yTVC4yDUUor1/bbT8fS027bQkxbbWslFoM4Y2zeZ9ctGvbmw5tbIIfUQ3uWY27bbgyH+Nh1t2O/TnHNzrK0cssZTqv3y208jmee6d5M31ujSAyK0q5sCFjs7+Hi69Odlxg3h7AK8dK6JfLiql/ilfBY3ow6+ykLiPqvnNFE0AUB4VbJLuQZnGmqrDfRIqwtSse8WQdaYM/OIZMl+gMqRR/uk0fR5xSVeni/HXSQ+Y+Ft2a5jAYA8mt3C7UUne4RoZ0LZ6XM6mfGxzD1E1uG5YdfkW7a5048FZQDnbUMBiNSv5r2oDdm/NO9PZbbkI+nqmCivLzW0+AEaWiXWR80IBj1jesMOnNKPkTU3ZQtmTrM7an45+g3blDCHdmKVgHS98H7yAbtqQwRSABUvXXv5dtxNGJyb X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:43:52.8031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ce618c3-c5d0-4a1a-dd59-08d7bef2cd24 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB5663 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_134356_630179_B2636471 X-CRM114-Status: UNSURE ( 8.27 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.75.58 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jolly Shah , Rajan Vaja , rajanv@xilinx.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Rajan Vaja Clock divider value should not be greater than maximum divider value. So use minimum of best divider or maximum divider value. Signed-off-by: Rajan Vaja Signed-off-by: Jolly Shah --- drivers/clk/zynqmp/divider.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c index 973cdf0..7d2cb61 100644 --- a/drivers/clk/zynqmp/divider.c +++ b/drivers/clk/zynqmp/divider.c @@ -198,6 +198,8 @@ static long zynqmp_clk_divider_round_rate(struct clk_hw *hw, if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && divider->is_frac) bestdiv = rate % *prate ? 1 : bestdiv; + + bestdiv = min_t(u32, bestdiv, divider->max_div); *prate = rate * bestdiv; return rate; From patchwork Mon Mar 2 21:43:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9780B14E3 for ; Mon, 2 Mar 2020 21:44:06 +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 74A2622B48 for ; Mon, 2 Mar 2020 21:44:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="g07VxkWA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="lp08jLq4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74A2622B48 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=778jfSt+oQdYmqaSuw6k/jUILnllJ5HdkI8o+stJ1YA=; b=g07VxkWAa+uAdL RoPUJfbG9CvJSv+lPsa71VzW4+RSmM5Am9nrEhkRIjNBSiB/KWPZegmCgii22AnwBSDaLmHbsM2iP 2EaluUd2d+VocpfdM5HEUaPfbHvUzFNWF/j6s2mubtBf1Gq0FM1wUth3+419n9vjK2MyPJnCzY80U 70W0LblsIswmaLEIMm6+pX/Dj/57SICnfYZwewx4m1QmqHCoJDOw7eO/Yl/UZe0rODCzuZDEXjgOE u8kmdRTZwpU6k1J3SLi7tPiHtHj6uR+n7wNYEVctt/s1Covu74Y+k2EOVB8DyCmm1Rhedoxp1a6G8 LyWbsL9sKIo9jY42ZQCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sr6-0002tK-5T; Mon, 02 Mar 2020 21:44:04 +0000 Received: from mail-mw2nam10on2070.outbound.protection.outlook.com ([40.107.94.70] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sqx-0002kK-5X for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:43:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/9oo/XisXLl0dapyNhUlt/qtDdt6BMAAf+f2Qi9vGnzyb5+aSyl0fG38ultgPoG/Xj1u8CRUVJHthN3kInfubBtYJZO6NHtkonpGyzREORqGTtlHdOsRK7GG2psx1ba9m+lej5/AkocXmVEhJlNlBc7HB++sLwpUG1X8BWYntC3GQy+rpc42o6tpNi6mX1O8hoqbZSrL5Y5Dmu0JpSxLwL4z6Ya+o+Mv9G8/jBXhHupqZ+gKdFf6HCEA3ClVPLE7U0azGkvRBDPze4RjZJcB8w3/HDkg5e6cprMKebM7cAoD3M8iApVnxcR7JqcoSN2iufKXot+A66JTXkDaiRwbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HgEIy20wP0B4Bosev/tTDKraK2Es9IvFNhzvT3/KeaE=; b=MpO+sM+CAvZYcM9k78+D4aiGUAOOzAZVYpi67amrNOFjd06T/utxtbxX/H6atxygLy4ALWCcBcDi3y6adFlQ+VE/j2RuiBXucX9I5GGegp56pJtkdWgD4KGaJUqC6G9JsV3puDyqnA7GnviOs38RLk9ZIiUZWmytxvQVkW4ERZovPeIkFJhh2csE+wyjmDmab9ql/7r71f449qXPVUNUIh1/PYAAZPYH8BgBrZS6/Fhi3PJpNgWZDPIsnzjIFj0ktUmToiRNC4RyoFzvzPkqlipzgexv1tXPkm3+Qpy8PUR19PYBmAmTJ2r3bMlHyRGmQ9MOX0ofHZ7Xjb8/VRaWpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HgEIy20wP0B4Bosev/tTDKraK2Es9IvFNhzvT3/KeaE=; b=lp08jLq4VRQ7HoUYLic7Lg4xArSQJuAl31CJZzlQ6KKGCWX8gK0lf4Zrz0q+Bem0j4UEPjMtWELlEAF59NK4oYBtYmXl7cbszOg+E8htzmXJ+Uh8b0v6cWwlMDNtWM1FnC8zdTHAqsAd3JF/yUtyIEbDfoCYmY9qwH9Jwn0Vz6U= Received: from MN2PR16CA0024.namprd16.prod.outlook.com (2603:10b6:208:134::37) by DM6PR02MB5228.namprd02.prod.outlook.com (2603:10b6:5:46::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Mon, 2 Mar 2020 21:43:53 +0000 Received: from BL2NAM02FT008.eop-nam02.prod.protection.outlook.com (2603:10b6:208:134:cafe::88) by MN2PR16CA0024.outlook.office365.com (2603:10b6:208:134::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15 via Frontend Transport; Mon, 2 Mar 2020 21:43:52 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT008.mail.protection.outlook.com (10.152.76.162) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2772.15 via Frontend Transport; Mon, 2 Mar 2020 21:43:52 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1j8squ-00020A-5G; Mon, 02 Mar 2020 13:43:52 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sqp-00033f-2F; Mon, 02 Mar 2020 13:43:47 -0800 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022LhiOC006057; Mon, 2 Mar 2020 13:43:45 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sqm-00032V-Of; Mon, 02 Mar 2020 13:43:44 -0800 From: Jolly Shah To: olof@lixom.net, mturquette@baylibre.com, sboyd@kernel.org, michal.simek@xilinx.com, arm@kernel.org, linux-clk@vger.kernel.org Subject: [PATCH 2/4] drivers: clk: zynqmp: Fix divider2 calculation Date: Mon, 2 Mar 2020 13:43:32 -0800 Message-Id: <1583185414-20106-3-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> References: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(346002)(376002)(396003)(189003)(199004)(2906002)(336012)(26005)(36756003)(478600001)(8676002)(81166006)(81156014)(426003)(9786002)(356004)(6666004)(44832011)(8936002)(2616005)(107886003)(7696005)(316002)(5660300002)(70206006)(70586007)(54906003)(186003)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR02MB5228; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; MX:1; A:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24b7a5ee-a4bb-4379-7d70-08d7bef2cd2a X-MS-TrafficTypeDiagnostic: DM6PR02MB5228: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 033054F29A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DZx7IpN5kayvA+YNK57SvUQp/5YpkBuH0u15DNsK5xG1UZeEKdPFcbswB/HIC7MdNm1HppkRKboD9/dgCVFjWS95wi05RMkeq4nVlRUPqwfRcX6c3m6MyQbdb5Hmi/DgPci8E6kmkWYdpwKsTkeqo8xSeMYgpmFPBDRxO1KRoYfoQeqadvIxSJU448qKDEu96rWhoFi6G6N7Vxcc7ZXZF+LqgdcmFH/dbLz2YR5udfOEMMUKTioLwocNm2DlshcT6Y4xFjUe+KFJOlnnP2Znm8UZZFithdRWt+c/sV7z+eAF7JngosoeFOtmOF2TEwcj2Q1Dr+xg4tbft+697/zlG+DqvwNE7liCs5yshT6CM4aV9BzSf+cT+5QSTdL7iIUC2q+phtwg/R748rwQx8EJve6WLoL4DebUrZi44CltUmnrKQnNi96mSlno/osHqvRe X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:43:52.7289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24b7a5ee-a4bb-4379-7d70-08d7bef2cd2a X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB5228 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_134355_210093_6AA42379 X-CRM114-Status: GOOD ( 10.97 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.94.70 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tejas Patel , Jolly Shah , rajanv@xilinx.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tejas Patel zynqmp_get_divider2_val() calculates, divider value of type DIV2 clock, considering best possible combination of DIV1 and DIV2. To find best possible values of DIV1 and DIV2, DIV1's parent rate should be consider and not DIV2's parent rate since it would rate of div1 clock. Consider a below topology, out_clk->div2_clk->div1_clk->fixed_parent where out_clk = (fixed_parent/div1_clk) / div2_clk, so parent clock of div1_clk (i.e. out_clk) should be divided by div1_clk and div2_clk. Existing code divides parent rate of div2_clk's clock instead of div1_clk's parent rate, which is wrong. Fix the same by considering div1's parent clock rate. Fixes: 4ebd92d2e228 ("clk: zynqmp: Fix divider calculation") Signed-off-by: Tejas Patel Signed-off-by: Jolly Shah --- drivers/clk/zynqmp/divider.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c index 7d2cb61..dea3e21 100644 --- a/drivers/clk/zynqmp/divider.c +++ b/drivers/clk/zynqmp/divider.c @@ -112,23 +112,30 @@ static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw, static void zynqmp_get_divider2_val(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate, struct zynqmp_clk_divider *divider, int *bestdiv) { int div1; int div2; long error = LONG_MAX; - struct clk_hw *parent_hw = clk_hw_get_parent(hw); - struct zynqmp_clk_divider *pdivider = to_zynqmp_clk_divider(parent_hw); + unsigned long div1_prate; + struct clk_hw *div1_parent_hw; + struct clk_hw *div2_parent_hw = clk_hw_get_parent(hw); + struct zynqmp_clk_divider *pdivider = + to_zynqmp_clk_divider(div2_parent_hw); if (!pdivider) return; + div1_parent_hw = clk_hw_get_parent(div2_parent_hw); + if (!div1_parent_hw) + return; + + div1_prate = clk_hw_get_rate(div1_parent_hw); *bestdiv = 1; for (div1 = 1; div1 <= pdivider->max_div;) { for (div2 = 1; div2 <= divider->max_div;) { - long new_error = ((parent_rate / div1) / div2) - rate; + long new_error = ((div1_prate / div1) / div2) - rate; if (abs(new_error) < abs(error)) { *bestdiv = div2; @@ -193,7 +200,7 @@ static long zynqmp_clk_divider_round_rate(struct clk_hw *hw, */ if (div_type == TYPE_DIV2 && (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) { - zynqmp_get_divider2_val(hw, rate, *prate, divider, &bestdiv); + zynqmp_get_divider2_val(hw, rate, divider, &bestdiv); } if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && divider->is_frac) From patchwork Mon Mar 2 21:43:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49E7B109A for ; Mon, 2 Mar 2020 21:44:20 +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 2715B22B48 for ; Mon, 2 Mar 2020 21:44:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rwHrdGBq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="XFbeIFIr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2715B22B48 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pRwBtwV8W5aV9wnSXcu7t2iVPeJQF9KoFHiJczCtjy8=; b=rwHrdGBqBAWio4 +dspyBbw029aCcVpecwu7MFaB8R6AGuCDs5HrlS4xqclQE7Apu9sQ/DjmZ4Rrz/SGmlFhpjhSfhLj TAbWMw5bzZ5zR0Qtz5uD+pamSQJLlctxz03AxDELUXnj5LXEUPzakcvc13Yy2uZfMkBKKoWC74p4n amNWnjX7/R8wQmtQctfRq3DzIhZ2f3mCJQ3RG4MzHyPl6PfmZlm9w06q48oqKU9MxByOkrsQvMEDF zDs0K/RwAVXMJnih3OMv0lWwmj9vTXukfH4RS1OXiBvOJl3/Z7i/9ZX+nyDP2C8/EZH8BcwztOIyM yYNuPX0ZXo8dCmIm0B0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8srL-0003Ap-FB; Mon, 02 Mar 2020 21:44:19 +0000 Received: from mail-co1nam11on2058.outbound.protection.outlook.com ([40.107.220.58] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sqx-0002kM-Fh for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:43:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8SqhFeKNCtGDk/l/ckoGH4XI0ONPQU6XJ57lTwDrhKJ6AFCgEISmPyiFVejMPCPh8Th6syQ8h0wsLF5zkluAfD3597rqZi/f6u68nrkR/UEU5dRmU2vTQxcq3lZ36MtYa+sQyewpM5Cze8+VrCQBzxAqt5afZ3SkoQchpnbQrMvdcKI7YaDVXh6pGKvhSzXRaUfyzFnR7fbWUFSfIiM5nvGH1v+OA80uj5JMD+zrMMP0VTd3K9B27TC+tdInndBPz1l9aA0KF6QBvF2mbE+rm/sIrQs/t9J5frO4X3yQHBHCvvqJhI1xDyMkChNnfTMKR7/tU4MoBY/xL95nJS/YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gqm49iQ2f8b5JNhlyypmPgKznqUkoQ8PeMoIK2kXNy0=; b=LBCJOa24FiI2ypP/D9/kj/Pub2k7E6Vwf+YUum8dUdxftukCohirGHtWh8er14ZV0s390w9zhvkRIcE8CEDZ9T4jF7X1Lk/5GAWLY1kcK6UUx62s1Yh00NCn9ep89F3d8q0Gu9pjZVZCyijiyTJhegrc6I177s1Jb6FP+fZZFtfM+L+S+4mXFTD6CX/nPgBlRRtLD4I3TktbW6H7lFsd/4Pk1QYqbmgEaLiN1M6s41Rj9ySBzcOsTHQj7NHanMYgplhTE6ZD5BWGUrVTLjOI84K1o23h7Zkm9gTeFHrdlUfw0/YbvhYXprnIMOAuxlu/kUgjV8E2yoK5Bu7fyub6KA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gqm49iQ2f8b5JNhlyypmPgKznqUkoQ8PeMoIK2kXNy0=; b=XFbeIFIrTgWNyL21tgQLsC+R0L129UAj+z+o0eLdhJRIXP36hDbidf9S9UdHloZ2bFxhFO0rjUrFZjHoqk5RdyWsr9/JRT/LC4ShLyBdAs0kZncwgPkMs5PjkxWeQB3c70b4qvbGQvRcU1IcHjoDmgvSRMVn7NQJyc7RG6f3+XA= Received: from SN4PR0401CA0006.namprd04.prod.outlook.com (2603:10b6:803:21::16) by BL0PR02MB6498.namprd02.prod.outlook.com (2603:10b6:208:1cb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Mon, 2 Mar 2020 21:43:53 +0000 Received: from SN1NAM02FT049.eop-nam02.prod.protection.outlook.com (2603:10b6:803:21:cafe::74) by SN4PR0401CA0006.outlook.office365.com (2603:10b6:803:21::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19 via Frontend Transport; Mon, 2 Mar 2020 21:43:52 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT049.mail.protection.outlook.com (10.152.72.166) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2772.15 via Frontend Transport; Mon, 2 Mar 2020 21:43:52 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1j8squ-00020B-6b; Mon, 02 Mar 2020 13:43:52 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sqp-00033f-3i; Mon, 02 Mar 2020 13:43:47 -0800 Received: from xsj-pvapsmtp01 (mail.xilinx.com [149.199.38.66] (may be forged)) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022LhiN3014631; Mon, 2 Mar 2020 13:43:45 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sqm-00032V-PI; Mon, 02 Mar 2020 13:43:44 -0800 From: Jolly Shah To: olof@lixom.net, mturquette@baylibre.com, sboyd@kernel.org, michal.simek@xilinx.com, arm@kernel.org, linux-clk@vger.kernel.org Subject: [PATCH 3/4] drivers: clk: Fix invalid clock name queries Date: Mon, 2 Mar 2020 13:43:33 -0800 Message-Id: <1583185414-20106-4-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> References: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(396003)(376002)(136003)(199004)(189003)(70206006)(478600001)(2906002)(107886003)(2616005)(70586007)(54906003)(8936002)(426003)(9786002)(336012)(44832011)(7696005)(4326008)(81166006)(81156014)(8676002)(6666004)(36756003)(316002)(26005)(5660300002)(186003)(356004)(42866002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR02MB6498; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; A:1; MX:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aae393b9-5e71-4eac-e992-08d7bef2cd10 X-MS-TrafficTypeDiagnostic: BL0PR02MB6498: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-Forefront-PRVS: 033054F29A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8YmCTvE8Fww6orzQXJYojZJZ/GBAAqVuNxSrVWKshHRIVIkthdCO2X6qdO623mfmFKoETdrk7CaV1B4+Caxgrz4gW/FByJWO6z/ldmlWsGb9Ueo7YsrrePxB0tThpjoN2tTvUk8TGM9VPzHwFiu0eL/AHIt8vhbZ5l8tJ+Es+ryWI9uCJJmYhS6PAknRPPMcDSLWSI4xhhgskiaj1ghoa4hGs6dSEvRpxanVRmEzmrU9U9wPqLFs8fbY8cUnwBZs7IolrQGkJqs60g0WnLeMCcakxlDua+kZVPUA8Ak8qzuuqd2/7aq8pxrK7ATeAWvTz6t9ASBTRjqWXzMbsTAC9USARbAaArIBcWqDwWdEvfjR173ZgSRcFjPUm9nHrjbMDIAHDd6DwBYRq0DJhme31QIawO252prQwGG6rKRpyMyx3bwgXrT9axjcnRudBrKJJyNoZlb10P3COrLu2yKr34Jn6xTsk+dVrvJjwxyt+PA3MyfHBiJs8dW0hiD+Zv03 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:43:52.6223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aae393b9-5e71-4eac-e992-08d7bef2cd10 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB6498 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_134355_519873_B5D76681 X-CRM114-Status: GOOD ( 10.44 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.220.58 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tejas Patel , Rajan Vaja , linux-kernel@vger.kernel.org, rajanv@xilinx.com, Jolly Shah , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Rajan Vaja The clock driver makes EEMI call to get the name of invalid clk when executing versal_get_clock_info() function. This results in error messages. Added check for validating clock before saving clock attribute and calling zynqmp_pm_clock_get_name() in versal_get_clock_info() function. Signed-off-by: Rajan Vaja Signed-off-by: Tejas Patel Signed-off-by: Jolly Shah --- drivers/clk/zynqmp/clkc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c index 4dd8413..ff2d229 100644 --- a/drivers/clk/zynqmp/clkc.c +++ b/drivers/clk/zynqmp/clkc.c @@ -667,6 +667,11 @@ static void zynqmp_get_clock_info(void) continue; clock[i].valid = FIELD_GET(CLK_ATTR_VALID, attr.attr[0]); + /* skip query for Invalid clock */ + ret = zynqmp_is_valid_clock(i); + if (ret != CLK_ATTR_VALID) + continue; + clock[i].type = FIELD_GET(CLK_ATTR_TYPE, attr.attr[0]) ? CLK_TYPE_EXTERNAL : CLK_TYPE_OUTPUT; From patchwork Mon Mar 2 21:43:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D448109A for ; Mon, 2 Mar 2020 21:44:58 +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 EAA7A20732 for ; Mon, 2 Mar 2020 21:44:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NBcuOObO"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="D4JHE1Ca" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAA7A20732 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hb1w5YTk5vKth93s9n0ShcMHm7tsZSqxpG6W/vqev9U=; b=NBcuOObODW2Qbf HPKpoDwurHC3KcmgfJ4nyS3DkUoRH8r9SJe3qRXhYfniSy0t+gVj4nLo48fOHpKqo4lIKZek6/I9B cLl5HJyasodnSr8Ci+JUBZd2XspGm1NcwZ7Jya+bV7ofYOo97hWAtIQsZYd3B9R1EzEJhv6Bsp9sz V0kSmIj6vaSbDoFQk0Ko+1QisAWtci/VIv9AZT3kDvI7TOP/1UTY640OLhhSLBovcz8P7UeE7Gg7X tiVTFoI76I/6fu32BEUW675H+UgjoyhpYxaDJnh/7XOiphZN7I3VfYDeFuuNePato8idIjY5Eqd6w Ze/0nOmQuZqhANBbokkw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8srx-0003kj-50; Mon, 02 Mar 2020 21:44:57 +0000 Received: from mail-eopbgr680048.outbound.protection.outlook.com ([40.107.68.48] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sqz-0002kz-BN for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:43:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LZ7UmoSNFxu+yK6EeIiQ+cnxQ2W9ojDNL7D7I7gT0nLSKwCHP2xvN+IVdqLZ8ZKJkuCbI9stgNNbQxNQJsNtU2qmtUpN6EOiyMfePmhEW/VLvcVy0IFLw/Id3CLRL/30jALcLjVgKY3yhrfsi9QGjNSWRRwXgBdzEC/X89uw7vEp3ciBXbHp86e0kSZrTqs3fZ2l3aRmxTc+ZsICWTUOISIQ/fp0fQ7cMNmEtK+JGdDhDdj5BLqCvPB/cQUn7mH8tyHCgAle7XTueLnltkRao9mSgKc8ylgbn7ZYreVWX+b87uvCi1QiI56OtV5XFjpQhXlQkfWUeKRduwwGsfIvGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IeK3700B29Xrm0r+nrT9SHIBPOVlJzrE7oOOBaT0oJk=; b=oD7hk/nce0QIROeXsYdRXIc+72seRu9Xg5oEA/mZgYIAZXXx5FflsXHYP1fJwcZ7Hl9MXnbgkkbkvQVud1SN+5fVo74cn1TdV1UiyvBLvkbbcNpy2s4nQaTz/rws8r95tTAm3pcGcQpmxOcR8VIaAjPU5Ln5d0mBA5vB762k82EwVAvihw5JjbNV5mDxpsfsrwjd7vReDJRL7sx+cECr0icxR6hxPVO01T4n6ek/AvYUVUxvp4ImYemKTpC0+dEUnW0gXGaUTbLR2jQ5tnEjMoZH8efHcrDVUvZAifc+N+u8WLDg3s6P/2gSce4HZGgeCL9vxK7keRgts4JV60BKvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=windriver.com smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IeK3700B29Xrm0r+nrT9SHIBPOVlJzrE7oOOBaT0oJk=; b=D4JHE1CavJzdnJBA2zCkWVWqnPcuVDubqz1bDr7pJTGD96kweagKzrhQvia0nr+7YlkB0g1PG8WZzz8Kkqn89GZaFnJ9vpQVHrRzi/g0XUWyPbdm3PTzaR9q2ymP28EaqeQIELLJmei8MGUIsFhpU40WDxKarb26RAunkYoCpjA= Received: from CY4PR1701CA0003.namprd17.prod.outlook.com (2603:10b6:910:5e::13) by BYAPR02MB4727.namprd02.prod.outlook.com (2603:10b6:a03:4b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19; Mon, 2 Mar 2020 21:43:53 +0000 Received: from CY1NAM02FT063.eop-nam02.prod.protection.outlook.com (2603:10b6:910:5e:cafe::be) by CY4PR1701CA0003.outlook.office365.com (2603:10b6:910:5e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14 via Frontend Transport; Mon, 2 Mar 2020 21:43:53 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; windriver.com; dkim=none (message not signed) header.d=none;windriver.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT063.mail.protection.outlook.com (10.152.75.161) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2772.15 via Frontend Transport; Mon, 2 Mar 2020 21:43:52 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1j8squ-00020E-EI; Mon, 02 Mar 2020 13:43:52 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sqp-00033f-Az; Mon, 02 Mar 2020 13:43:47 -0800 Received: from xsj-pvapsmtp01 (mailhub.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022LhiPt014635; Mon, 2 Mar 2020 13:43:45 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sqm-00032V-RJ; Mon, 02 Mar 2020 13:43:44 -0800 From: Jolly Shah To: olof@lixom.net, mturquette@baylibre.com, sboyd@kernel.org, michal.simek@xilinx.com, arm@kernel.org, linux-clk@vger.kernel.org Subject: [PATCH 4/4] clk: zynqmp: fix memory leak in zynqmp_register_clocks Date: Mon, 2 Mar 2020 13:43:34 -0800 Message-Id: <1583185414-20106-5-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> References: <1583185414-20106-1-git-send-email-jolly.shah@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(346002)(396003)(376002)(39860400002)(136003)(189003)(199004)(8936002)(478600001)(8676002)(4326008)(186003)(26005)(81166006)(81156014)(44832011)(9786002)(2906002)(426003)(316002)(336012)(2616005)(54906003)(70586007)(36756003)(70206006)(107886003)(7696005)(6666004)(356004)(5660300002)(505234006); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR02MB4727; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; MX:1; A:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e6142dc-0ec8-44ca-dbed-08d7bef2cd34 X-MS-TrafficTypeDiagnostic: BYAPR02MB4727: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:466; X-Forefront-PRVS: 033054F29A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G/K0i9DW6uA9mruhsjonG43lIW6O7ygzqVrF2hHLEzZ6krY3kZ20okeBcGdoAL2Vu2i7qWNAXB7sMF8UZtv2n92HLIArYxqCFU2aTkRwebSv7PttPnZvh+9B8TeBnG+TopnYS8OUQtUPGumfpjpMLkvg9sRcrN1so9rCRZpW66HNlMWpzVAoyTg/FoYdWPg5d8TT8/JROnULi2eQ4SV1n7nwrHU2XQ0W6idNGXT7ntkfl51i/wt7i4i4FRrwYlnnWxvFgB5tZ9snYZzGXO32+0aOjAnPsqxh8dvtf3nyNKyUkS3YvK3+pTAfcgGQUDU+UaoyaalCSTQNUsAh5B2wbGn+JYkrzNAyFqUoQfsSRitN0r80KqpLfk3ERxyIjr0jByUV8Y6pDn8jcgwhQxdX6mFoeSPDs1/kTV6CmfOeCFEviPsSqVRNmzGKHqYC3oGIMGm27rRaSJMLwkN90H62b6pTkIAbPqWBUQgfQxRXMTCrjAd932chLCUUG5XHOaKi X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:43:52.8629 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e6142dc-0ec8-44ca-dbed-08d7bef2cd34 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4727 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_134357_386593_8DA5A483 X-CRM114-Status: GOOD ( 12.02 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.68.48 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tejas Patel , linux-kernel@vger.kernel.org, rajanv@xilinx.com, Jolly Shah , Quanyang Wang , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Quanyang Wang This is detected by kmemleak running on zcu102 board: unreferenced object 0xffffffc877e48180 (size 128): comm "swapper/0", pid 1, jiffies 4294892909 (age 315.436s) hex dump (first 32 bytes): 64 70 5f 76 69 64 65 6f 5f 72 65 66 5f 64 69 76 dp_video_ref_div 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1............... backtrace: [<00000000c9be883b>] __kmalloc_track_caller+0x200/0x380 [<00000000f02c3809>] kvasprintf+0x7c/0x100 [<00000000e51dde4d>] kasprintf+0x60/0x80 [<0000000092298b05>] zynqmp_register_clocks+0x29c/0x398 [<00000000faaff182>] zynqmp_clock_probe+0x3cc/0x4c0 [<000000005f5986f0>] platform_drv_probe+0x58/0xa8 [<00000000d5810136>] really_probe+0xd8/0x2a8 [<00000000f5b671be>] driver_probe_device+0x5c/0x100 [<0000000038f91fcf>] __device_attach_driver+0x98/0xb8 [<000000008a3f2ac2>] bus_for_each_drv+0x74/0xd8 [<000000001cb2783d>] __device_attach+0xe0/0x140 [<00000000c268031b>] device_initial_probe+0x24/0x30 [<000000006998de4b>] bus_probe_device+0x9c/0xa8 [<00000000647ae6ff>] device_add+0x3c0/0x610 [<0000000071c14bb8>] of_device_add+0x40/0x50 [<000000004bb5d132>] of_platform_device_create_pdata+0xbc/0x138 This is because that when num_nodes is larger than 1, clk_out is allocated using kasprintf for these nodes but only the last node's clk_out is freed. Signed-off-by: Quanyang Wang Signed-off-by: Michal Simek Signed-off-by: Tejas Patel Signed-off-by: Jolly Shah --- drivers/clk/zynqmp/clkc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c index ff2d229..bfc1e7d 100644 --- a/drivers/clk/zynqmp/clkc.c +++ b/drivers/clk/zynqmp/clkc.c @@ -562,7 +562,7 @@ static struct clk_hw *zynqmp_register_clk_topology(int clk_id, char *clk_name, { int j; u32 num_nodes, clk_dev_id; - char *clk_out = NULL; + char *clk_out[MAX_NODES]; struct clock_topology *nodes; struct clk_hw *hw = NULL; @@ -576,16 +576,16 @@ static struct clk_hw *zynqmp_register_clk_topology(int clk_id, char *clk_name, * Intermediate clock names are postfixed with type of clock. */ if (j != (num_nodes - 1)) { - clk_out = kasprintf(GFP_KERNEL, "%s%s", clk_name, + clk_out[j] = kasprintf(GFP_KERNEL, "%s%s", clk_name, clk_type_postfix[nodes[j].type]); } else { - clk_out = kasprintf(GFP_KERNEL, "%s", clk_name); + clk_out[j] = kasprintf(GFP_KERNEL, "%s", clk_name); } if (!clk_topology[nodes[j].type]) continue; - hw = (*clk_topology[nodes[j].type])(clk_out, clk_dev_id, + hw = (*clk_topology[nodes[j].type])(clk_out[j], clk_dev_id, parent_names, num_parents, &nodes[j]); @@ -594,9 +594,12 @@ static struct clk_hw *zynqmp_register_clk_topology(int clk_id, char *clk_name, __func__, clk_dev_id, clk_name, PTR_ERR(hw)); - parent_names[0] = clk_out; + parent_names[0] = clk_out[j]; } - kfree(clk_out); + + for (j = 0; j < num_nodes; j++) + kfree(clk_out[j]); + return hw; }