From patchwork Mon Mar 2 21:50:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416443 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 00D3B14E3 for ; Mon, 2 Mar 2020 21:51:11 +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 D11112467E for ; Mon, 2 Mar 2020 21:51:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lPCrEg3m"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="Y1b1dIR7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D11112467E 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=lPCrEg3m286hwN kSzhXvTKckUJcyeNc7/MR2TFuN6QxW4RIxjEtzLSDSiO3/ApoHYfwm3aV/UlnFPz6GbnsCSbxtuj9 DmO37md1dNSFFwWAahTe4/TwOo9TPRfT4j0YRszR5QwhZtAkDl+4iiUPwo4jQp+PcSZIVYvkaHAlm PO2+4Q8DwHQyw+VWheQx4wc5OKBUo/2sdIp1ehChBdNO6b7JYl1nsjaI+AV++7cXK5GPeAPiy71u2 H8zX7QStcf4LFFD5x4uC0nfDyFmtMf7fbOVf2ZdhDwm1MHNV29m/t0LXPp6KVhu0Cn+ZJ5kg8RCFi nl56YmiTSVZwP3UMyraA==; 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 1j8sxx-0006zD-Bp; Mon, 02 Mar 2020 21:51:09 +0000 Received: from mail-mw2nam12on2080.outbound.protection.outlook.com ([40.107.244.80] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sxu-0006y4-SB for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:51:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oOZq6tTRqiBdP+y9eiYIGjybgFYZbzNQZV+Qt/holNV0LhiVK1Ba0+QQhC5kT9z1rVUkpUI2l0Unj1c9eF3Jm9yz9tFtks2+rBiw35rfFgTJ8twKzDK6syDKs9Ze4C/PuVinGUF15aUfW7Y0kzTRhOwz/eHGs0nDzHZzRbSQaFg8nxiPn9+vRn3MwXPZ/lb9DagFQ9sJOiKKdbwvRuBf/rw+CwKjEN0mGUk3ZVb3MA8doxw9dld0MgLf9NrpeiY4e1Ay7zp4DUBBlT6lQ8L25hUMnpR475W1sqCMrd3/sPltAmFBHcXGvKO0K5/bv9C+kXkaqizV9PQyusRLTQVEgA== 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=S1Bk+4vBeOqvM5lEIebaS5f2y6gXZjoWiz+ptsjPjAvh5C1YPtwsFFHShZ4QyB/NR7e4hN5lP2kD6eMS1FjV7WZUfiFvMEY+gpjvW/uSQhUcRHGnzOmRBe+C4fWB4owr8NjzxAezSFGpfDUWZadYCgXi6PTvU5C9ablm9AOztOOUfrDCQpifAuTXDEE6y8RQmRP5jj6YSEImGZStJRa9hy4V4N3tWw2spTuDV9fiiASfSTSXjsBUSPXQzd+0YGK14tRr+WSwyOA/F+6LhRV6vCPd7KldtLXDK+eNYW+c/bLtKLfY2jSSuYadol7j/FS9cwwr8tI5BP8TnsLOkCGOMw== 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=Y1b1dIR7GetVB9CE9bFytF3WS51jekDqI+ymSX3dHwijiOycHuAdqNL2kTG4wVhurhhLM9r1AbcyHVf71sfEoUmbTpAlc3lJMZz3uNHvuTMbTaoMnaehjhvpRl3aXxqTO2Iuv4gi6HUAPyC3dJs+e1tWDNiEVKE3Gg/D+ZP98lg= Received: from CY4PR21CA0022.namprd21.prod.outlook.com (2603:10b6:903:dd::32) by DM5PR0201MB3607.namprd02.prod.outlook.com (2603:10b6:4:77::37) 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:51:05 +0000 Received: from CY1NAM02FT032.eop-nam02.prod.protection.outlook.com (2603:10b6:903:dd:cafe::74) by CY4PR21CA0022.outlook.office365.com (2603:10b6:903:dd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.2 via Frontend Transport; Mon, 2 Mar 2020 21:51:05 +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 CY1NAM02FT032.mail.protection.outlook.com (10.152.75.184) 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:51:04 +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 1j8sxr-00022Y-RF; Mon, 02 Mar 2020 13:51:03 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sxm-0005jv-OF; Mon, 02 Mar 2020 13:50:58 -0800 Received: from xsj-pvapsmtp01 (mailhost.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022Lops6009838; Mon, 2 Mar 2020 13:50:51 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sxf-0005fm-JR; Mon, 02 Mar 2020 13:50:51 -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 v2 1/4] drivers: clk: zynqmp: Limit bestdiv with maxdiv Date: Mon, 2 Mar 2020 13:50:40 -0800 Message-Id: <1583185843-20707-2-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185843-20707-1-git-send-email-jolly.shah@xilinx.com> References: <1583185843-20707-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)(376002)(136003)(39860400002)(396003)(346002)(199004)(189003)(107886003)(336012)(5660300002)(2906002)(356004)(6666004)(4744005)(316002)(70206006)(44832011)(8936002)(426003)(478600001)(36756003)(9786002)(70586007)(81156014)(81166006)(8676002)(7696005)(186003)(26005)(54906003)(2616005)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0201MB3607; 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: 95ac7238-35b9-413c-85c1-08d7bef3ce99 X-MS-TrafficTypeDiagnostic: DM5PR0201MB3607: 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: agpgrUPPk6TKZQvp8603OK+YBXQrhHSe2WUqi7DWwrPgH+Le8XpWL7VWlfzYc9N/4PGTP8PxVb5apN/DuIHqogTckFB6mABYJWoTREKJy7ZkMY0aqb5/+er9b/2s4RbQhXPB2vZKBOqxv0jxHfbTzlH9o3JzrWDGL1RNwx7SEHgzsInSGWJg+g/S3zZidU01r+cHCBaY/jYIw6w3g445H6ocw3JNL8GKQrKRu5JW4bOnhhJttc/frXbJ07LRfxMbxAriW9JfbhBXUMtXh1TuS2gr5qep3H2i0HILVOF2D3ZSUuXAxX4Q2HVYN7L5HFkb/tVOut0eDMaD3GmrYdg9nO7lKL/nJBqbPQ3YnwcQkNKSfxz2hHArVSCNr9y9P1hsrnLlSrIlKhVkYap2m8iDDDLH9VO6cjagAx16KrvqogdG7UTll540LOzyaiaxcfaH X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:51:04.7421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 95ac7238-35b9-413c-85c1-08d7bef3ce99 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: DM5PR0201MB3607 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_135106_908817_FD117985 X-CRM114-Status: UNSURE ( 8.38 ) 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.244.80 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:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416459 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 910B214E3 for ; Mon, 2 Mar 2020 21:52:04 +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 6448F20873 for ; Mon, 2 Mar 2020 21:52:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V4bkx5sa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="eg1M/Ew/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6448F20873 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=V4bkx5sa4Blxkp Wwvmvm7XPOMShacpl2Yqvc/wWaN2bH0PsNggWHGgUYsQHDs7uovkPjW1lvzavzNhcCK8odsvwSSjX O3XYUf0UlvWhdM5Q1+xx8WNKp99HVoEp1pxJrMUXx1h7dwDpd7P/+sl+dZfwuAePaBsVYp/Gb4bTE aL3RVSjJpdx/0EbYw6biG6cCmkNDNBiV82ribHjsqVXRVC963MUffonAa05X4umSTvpqBotdAZACM UeLyDJyc9Hxt/PLcaxKqkglovkEel/06J/FqUXPzwKE2OsRgAnJw6JsITme3yH2zH7P6v+AmoyvVp KZPoPuQRczD2N/WOdxwQ==; 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 1j8syo-0007w0-Vz; Mon, 02 Mar 2020 21:52:02 +0000 Received: from mail-dm6nam10on2080.outbound.protection.outlook.com ([40.107.93.80] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sxx-0006yy-6H for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:51:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oRPyG4wjIoeCpX2SO9Mu/ez5RvntO8R96OiuYzZFTTxGj9W2rUqwA0Ge1ximhOaCUSp0sAb+zr0evFvk7woLPbnnskAEyB7F4ylgPWxz7CSrFHgIgmP7cTdv4KHtdoiryy2k/8E3dTN9VwVdOqVbjbxYWwEbi18yt2hjLNWka7bh258wxhYPgvNZFYOyYi8CerJN1co6n9qDe5SMLSCPqM4EL4uD6i/wGXu22H7bhHQtH0NiNL5xIFI2E0y8bpnfSS3JZDoRU4oTzyMg/xNxHv6wi5dxzkc+V4Jvd6GFxhImL35pat9Gb1dkKlh/tadtvJhCVWOmNEh69cbVAxq+VA== 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=brh+VI+dre1UFilzePgjsgXDdW1UOR6Zfk7YEckD5idbrdJpm1AZK4rmpQvccmfhNGEEy7bZICxIO48UZ9W/C12Q+2gYuFltT8DQGCn9Vu+dkhs9C7gSZW+ghOM/zv3IC7Cm9DU0R6e8RW9+GUjCpcKalkQ7pFsQbRUiY7NfunQbAN6TR1hwyC/MF4wgejvhgDADiMMaOS90S4LtS5IekC/eBNkVnL/Q5DOSvP74I1/lgTSAxCxr1kXc1vT5Au+NG5M9nWq+L+p7QE1VURaZk4lrcp0sAwOMxM6RuYrkDvUMYBDrMpENVzpz0e3e1qdFq7vDD82FcKdYATmBOEoRvQ== 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=eg1M/Ew/+Qk85o/HiybAK87ouTSDDiOrG3TfOP7GqUPonnysk8jBTN4rQr2O9PgcQl813FYhGn9D2XdcZNTbVzlzENXeJKsXTW6GUTrXefzasrJL4N9URdyDGi9ZdE3USBx3gTcRlsz3e0btqx0tYsgjKb5RHbxYtNuVWt5KzUs= Received: from MN2PR20CA0006.namprd20.prod.outlook.com (2603:10b6:208:e8::19) by BN7PR02MB4241.namprd02.prod.outlook.com (2603:10b6:406:ff::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15; Mon, 2 Mar 2020 21:51:05 +0000 Received: from BL2NAM02FT040.eop-nam02.prod.protection.outlook.com (2603:10b6:208:e8:cafe::f9) by MN2PR20CA0006.outlook.office365.com (2603:10b6:208:e8::19) 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:51:05 +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 BL2NAM02FT040.mail.protection.outlook.com (10.152.77.193) 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:51:04 +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 1j8sxs-00022b-4E; Mon, 02 Mar 2020 13:51:04 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sxn-0005jv-17; Mon, 02 Mar 2020 13:50:59 -0800 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022LopWX009840; Mon, 2 Mar 2020 13:50:51 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sxf-0005fm-LL; Mon, 02 Mar 2020 13:50:51 -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 v2 2/4] drivers: clk: zynqmp: Fix divider2 calculation Date: Mon, 2 Mar 2020 13:50:41 -0800 Message-Id: <1583185843-20707-3-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185843-20707-1-git-send-email-jolly.shah@xilinx.com> References: <1583185843-20707-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)(376002)(346002)(396003)(136003)(39860400002)(199004)(189003)(356004)(6666004)(70586007)(2616005)(9786002)(336012)(70206006)(186003)(26005)(7696005)(36756003)(54906003)(426003)(316002)(4326008)(478600001)(5660300002)(8676002)(81156014)(8936002)(107886003)(2906002)(44832011)(81166006); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR02MB4241; 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: 6d327200-cf4c-4da0-210e-08d7bef3cea9 X-MS-TrafficTypeDiagnostic: BN7PR02MB4241: 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: CxAmGCosOshgyKEecsb+nsqRkz58GmXC6piMXS6gqvfsEetZ9ntFiBNlaZ+kfIAwBrP40qW5KLRXUCglADNgt1OOpuBJnz3zc02Q9uBzZk13Dz5FrxxrWz1qRKGy4QL82MwlWsdzIYWcgGdEFjfNaNKCtW/o7wROt8WaacQHseM39LwAjpMN7U8NuHlmPjsHl7iWKyrq5DDlMeaiVGgeiXVFZKYasczKTjw+QcWmJL4yp/LSjhdFEFFtYKtQGJu9nYISeuDvasSEnGoq1Yg43d2MTt6D6zJIkLyRAKq7HiAsnD8ioH0TqubehJx/wJtYKAye6Glz9qMS6l10M/swrU+8LQiQP6eLmjshu9O8OFf2EvKd4Yt40Un5OdLj4/hnh4lcZWTThk8phSI4uQ4mZIK6rMdC5eNbLsIRVJ7LXIAjpDpkYer+9F5qj4mmknPF X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:51:04.7323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d327200-cf4c-4da0-210e-08d7bef3cea9 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: BN7PR02MB4241 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_135109_236659_39F2A52A X-CRM114-Status: GOOD ( 11.30 ) 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.93.80 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:50:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416455 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 A0D4E17E0 for ; Mon, 2 Mar 2020 21:51:54 +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 7158A21739 for ; Mon, 2 Mar 2020 21:51:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Xa7ksfd3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="aKks50wl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7158A21739 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=Xa7ksfd3IJehdz TcDsV4boivGFe8WxnrR6GbBF4Lx8xoBXS3kWHh74y0q4RBNJHSLr3HUAEbP2xNWY1wqOqzFar0wq7 ELLMfmNJfZKxbeUUVcWpYpmIoHn7bNcmowkmgAiF9rfWDlRkniaBjgrTf6+WdgjFrJ22vZR6Sq+Z+ l9EylmHrj2QamV4PKQta84ZysYyPPnLAm0G85xLhOpemsdAOtov49t5xixbeo6STzoMCMEpMj5N6C yyfgNGRV5ikGJHKofs1fW1sgMj8Cfko4WgJHLzrq/Lzsqd7SJle+kXqhwgqe2WvCvh2sZbVwO3Ssw w2dBUlybCuCPhJwMVqcA==; 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 1j8syd-0007hV-Hq; Mon, 02 Mar 2020 21:51:51 +0000 Received: from mail-mw2nam10on2057.outbound.protection.outlook.com ([40.107.94.57] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sxv-0006y6-LI for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:51:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TTLzRpNB1i3/5zvz4mJ9oErqZ1lgDat7y21oEzbPntfYkCxBVtpAW8wMIw6pjbUItpbclPoW8xjWVlecaduBUCO3rhaWuRAWMwuU3lp0q2zjCDVvYIOtHK+6I4Y2JR3g9h3RoA1CVlxf7aDxFoTvC8ewqKdUjdemwstcnjQfOpIzSxAjF+vY1kX6lghzxuo0xWoucA0zxf4PqimVvZR+BZjEkR8S9up+Z8Dl8nOO4lFlSvZZi65IuO0tER52leXrOYvoN8IzrvekgmjFnF7N81YVJ7hTWVXb+m+GY5Ebju0RYmZBVR64LBSYMSxZd7D2khzCsFMBEd9HBYodPzj6LQ== 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=MVkirSrFuc5jgqqCRv63Cax7+I6tK+n8bGpIVZ/sy5IHSiSv3jzdzktUmx11piHSNFECcFo5G84tliWdQeL095Rb22DSSyWcGCXXkLBJkVymGfXPRDsYbPbflhkn3/DUiVEZu14mU+zB/5MElJY7Fta8staIHDzoL3QMQoyxfltJ/6UKBMEMUhLgyROBQeRQ22/QDlzk+kIlsyuubJQCzOu3ZiuOwkVMc6AxtPQ4kwJ+0btLhNiwo6aoEreOvtLUSlUUuXaPg4kJbvTGlKtw5a9jDcabvwjAYYymRH7UBXk8Ci0A3kEEp+lkXY3SAmkO5U4USdWWacIW8zsVOA3LIw== 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=aKks50wlII2dhklK6Roj0gcmz7VquefHnUHPeaV40vjDmmRgRoyMk9Izzu9WQoBw/Yh/otjSGqC4xF17Wec255XCy3etmKgUwBdO4RHZmX3T+Bo8yAZfeTxK1NPIoVoPW5CTvTBk57oF1DunXI3ssH2UYrfWuFf8fs0P8pyqXc0= Received: from MN2PR20CA0020.namprd20.prod.outlook.com (2603:10b6:208:e8::33) by DM6PR02MB5340.namprd02.prod.outlook.com (2603:10b6:5:46::18) 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:51:05 +0000 Received: from BL2NAM02FT040.eop-nam02.prod.protection.outlook.com (2603:10b6:208:e8:cafe::86) by MN2PR20CA0020.outlook.office365.com (2603:10b6:208:e8::33) 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:51:04 +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 BL2NAM02FT040.mail.protection.outlook.com (10.152.77.193) 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:51:04 +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 1j8sxr-00022Z-Vu; Mon, 02 Mar 2020 13:51:03 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sxm-0005jv-Se; Mon, 02 Mar 2020 13:50:58 -0800 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022LopGL018613; Mon, 2 Mar 2020 13:50:51 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sxf-0005fm-NP; Mon, 02 Mar 2020 13:50:51 -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 v2 3/4] drivers: clk: zynqmp: Fix invalid clock name queries Date: Mon, 2 Mar 2020 13:50:42 -0800 Message-Id: <1583185843-20707-4-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185843-20707-1-git-send-email-jolly.shah@xilinx.com> References: <1583185843-20707-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)(346002)(39860400002)(396003)(376002)(199004)(189003)(107886003)(316002)(478600001)(2616005)(336012)(8936002)(8676002)(81156014)(81166006)(44832011)(36756003)(9786002)(426003)(2906002)(186003)(26005)(6666004)(54906003)(70586007)(5660300002)(4326008)(7696005)(356004)(70206006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR02MB5340; 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: 3c7d54bd-edb9-478b-637c-08d7bef3ce90 X-MS-TrafficTypeDiagnostic: DM6PR02MB5340: 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: E0WrAVdh41JsP0iULhWJkTQMqwRu/kj10/+t0Znh+qwxWT0NuVak5YOaYHajLQ9EG6i3weXIRm8pquLuOFpIT6ojRStl7/TwLuba9vnnRVtaaTXnAM/o0mhD9nbl15Z4meGyldl4dN6GKxJgL77Xympt0zXWu4hNYNL1OlcYeBW44AsqN3trHLpWQi5V/Ut4TGJRK/BFDiHGUeas+JMzRqcbyunPnR96OdqnVPUyEd0a3bQE60LVGaQFhAdfWLADy7XNlWdnDR9kp2QOpYjbeVan81jwo2cKdPgpPN4EVdw+NVwXDGjEtrtFtmeHawioYE8/VqHEhsw48Z8cp3Ge8EUnXQpanGQ4xTImuW7eOTyuF3zsk+rm+AhtMxymWIzR8M3hciqJEgQt/eY/OAvF4NynFXZYgH9tHL/fYo1aPB3Dh6rCVpc4vBatLz66zdql X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:51:04.5862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c7d54bd-edb9-478b-637c-08d7bef3ce90 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: DM6PR02MB5340 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_135107_692947_E1D3689F X-CRM114-Status: GOOD ( 10.40 ) 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.57 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:50:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 11416451 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 39ACD14E3 for ; Mon, 2 Mar 2020 21:51:23 +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 1305524677 for ; Mon, 2 Mar 2020 21:51:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k6tvLp/H"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="bydHTUIG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1305524677 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=k6tvLp/Htt/iR3 TO4erW3jp55JyZ30j9zrrh6RjE65vMJ1y5kvI0/spibTCK6cHKRDhZaZljN96gdcI5gD+URBCqO/b 9vBGZr3HEVaVlL0jqAAdyVNQ8fD4XXMUVQUeZPWOhloZX8LFhKaN4C29IuXcTyG5iWUuiVcoa3zpT iuQgGEZm1tGUessn6+NoHnRw3q0mvd1jBFSkbaCq0xvWm8TRKBWViJXi7W2pB3UiTF+KToqMrhr63 ma+ijhCrnCc/YgxyIZoySw2vnfp7VgbijIhcz1+GP5DKcuEBgarWQOz/5RWmx5s01XeDcvjl4pdug kfdWxbxZm7tggo2KtaTA==; 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 1j8sy7-00078c-Ow; Mon, 02 Mar 2020 21:51:19 +0000 Received: from mail-dm6nam11on2080.outbound.protection.outlook.com ([40.107.223.80] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8sxu-0006y3-RI for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2020 21:51:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EDKUhgpGMof3YErKCQn0/OjZCPtz8MTSuPpDjeeovPHTUhaJn78CHPAjfK4H0geIHrx0UD6bTaNjIHEQ4EjkF/eYypSBbXHMpZKg8JF4vFdeE8UbP/AeWPZ/NeRIo7rG9K2Kzc9oL80igYHiZUFLtFkSu3L+worxEvRGQw9SckSNiaRUpAxHlODYv4gjvl0MwL6H+m4Wz2/73JtnW10pp+PX9MAXXrMC0f7OF3Fvl0cYa2523k45IJ75oQjC/Q4RlJZLLgUMUvfCJdy4B29xKZPVUdZQ5VogpxV7NuaYUKPzt47shwE3PHJJDAx8YIte6ytThlB4wMrW8KyWwOVBMg== 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=Nde0RgFNdwts6Z8JU+iT57EOOZtjfu4nDsYCTckL9PGl+XPSZAAY5veM8fI7vPeoP00wsJvx4wzivctcC4eVW58U/CSlFq3F3bxmgcU3Zbj3X6Ax8Y5I2mlEUqFoVCIB3GYLwE2Ha9TXxQTBODGvkiaS2FzQzzpAjc/2jmSewCXZ397goGLV51B91h2zJYMYKcoWG1lnVtpNuPIaYDgV/TMF0bmQIaxM5LAgXbDeElr0dIN3PisM4/9MEnZ5yfJFkVV7WPmx4ntsWI0XipYUT1QGbrmWJPpEYC28kEsf4LzFEgHpcA8LSfgoLIDD3uzDkiNqg1o7yJfJtdBrDN1oyA== 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=bydHTUIGovcavaYYP6NS8CTnjJGWqV8fBM1LlQQ5yrdlkl6qZ75rDXbSrFMcjFj/JYxmNhKhs+MH80kQOwL20xAvBtU1jdxfa+YMraFbWa4YgeO2GWoPq/zxDNpgQMk9zvLFCS7MLyCKmpVMGs0sCnHlj6N7xRNY1uVVNovvZ48= Received: from DM6PR17CA0013.namprd17.prod.outlook.com (2603:10b6:5:1b3::26) by DM5PR02MB3702.namprd02.prod.outlook.com (2603:10b6:4:b3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15; Mon, 2 Mar 2020 21:51:04 +0000 Received: from CY1NAM02FT024.eop-nam02.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::fe) by DM6PR17CA0013.outlook.office365.com (2603:10b6:5:1b3::26) 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:51:04 +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 CY1NAM02FT024.mail.protection.outlook.com (10.152.74.210) 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:51:04 +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 1j8sxr-00022X-Pp; Mon, 02 Mar 2020 13:51:03 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1j8sxm-0005jv-Mj; Mon, 02 Mar 2020 13:50:58 -0800 Received: from xsj-pvapsmtp01 (xsj-smtp1.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 022Lopoo009844; Mon, 2 Mar 2020 13:50:52 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1j8sxf-0005fm-PL; Mon, 02 Mar 2020 13:50:51 -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 v2 4/4] drivers: clk: zynqmp: fix memory leak in zynqmp_register_clocks Date: Mon, 2 Mar 2020 13:50:43 -0800 Message-Id: <1583185843-20707-5-git-send-email-jolly.shah@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583185843-20707-1-git-send-email-jolly.shah@xilinx.com> References: <1583185843-20707-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)(376002)(346002)(136003)(396003)(39860400002)(199004)(189003)(5660300002)(54906003)(70586007)(186003)(336012)(426003)(26005)(316002)(70206006)(2616005)(356004)(6666004)(4326008)(44832011)(107886003)(8936002)(81166006)(81156014)(8676002)(9786002)(2906002)(7696005)(36756003)(478600001)(505234006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR02MB3702; 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: b906819b-7952-403d-c5d3-08d7bef3ce69 X-MS-TrafficTypeDiagnostic: DM5PR02MB3702: 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: 1ovpOR00TZ+sBHoTaATXcuolrFFg7dsiE6R2GokATg0aGrAXBZc4nuXA5tKR4ruSPg/OA0CTnRXyiq4EdxHXq1+N7t8dai3Bzrhqef9PceIlCXRXPRhqD/Ut7lu0Rg2XAyV4YcT19cuTYJRdTMiZQkA8peQ/3NLxZyQ4WySU0kKZjFZE35Mv7bRFAbCbBzRqgv7htnu+8zaWvmGf/fcGCk/xnR11wtM0RII/XuuvzJG8/pzlwiKgGU1STQBidaIuqTIByyICOvHBpjCcm7kuTUgEzTa9x7rrqEPvCfHYdrnWlb+sdywD4W4sQNi6LSdlpMCIt1HnbOq/GF+Bw+J9vy3NJLQA/TOrrDwQhJjk010Gg3DqunA9SKb5sIBn94+AYqQf06Mxm7MGN2Xsj9M9C5Mtb/OIuQM6gKinT/uFn6b+JJIpZf/uXJk713EQE+4qO9KBsrfx5p9XEKqhTv11HtsP1IZBPo2xipo3YcoG+I6hQ4ThR45D/IS2rw+3T8A7 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 21:51:04.3851 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b906819b-7952-403d-c5d3-08d7bef3ce69 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: DM5PR02MB3702 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_135106_893108_8FFF120A X-CRM114-Status: GOOD ( 12.14 ) 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.223.80 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; }