Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8527344ybi; Thu, 6 Jun 2019 14:03:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1z2OLCV2YYXYHV9GDlIdLR+FsyV5TtUQgmsOZvUmA+6FtHrdxhl7KaHM0eeNUHAz7Wt/T X-Received: by 2002:a17:90a:cb97:: with SMTP id a23mr1763806pju.67.1559855001011; Thu, 06 Jun 2019 14:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559855001; cv=none; d=google.com; s=arc-20160816; b=kHGNRFSOS7jCbjlMgR12yVq4RC7tBDLMf6bqqD6xkrO5Q9Wv4V9melGOF+kLhrLA4Z zqvM51jhAyj7oIaJJ0BsE2w1VLmg6E4PuNXYh8uhPzieqkX8T29Bs69jG0LqhWkPeCJ2 9vLFV0coMN9JjAajRhmQRxRrhsSYdQ79vKwhFnu+ki5dLvi+6n2JKNdELg13Kk8RM+5G G8u4GSik6Zy13A2oDpBMvBq4QTCfVKy/zUYh5cLBW5bUCfanMtIDHZyN2f0/qm3e/f52 93WTYgD225Tn4knCj+iWe72CPf5txU18e/8v+dk62joo3e+2R3z9PV1b4MLCHDt7pPhD wMlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:user-agent:cc:subject :from:to:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=/OLm/nCPGdwNaC60nmI5GB6tkWF19F2DpYOYqXjuuKQ=; b=RGpux/w7sDxScQKl45im9m9ciAMyN8Z5JwmD+/oryAMymOlPAKYUd5m8vLz4LHFsUo QExOSPtLBBkewWWSpn/DSkUl66KW7pasZ+HbTXyG0+pQCfs9GGgBmil1059KQobSwK82 lb+D63fNvOnUWjGeCq+jE3FIfhSYkqBahTEx3CyiRK/10AyUB9EIKer4yigzNBnQpuGN S7E7GP/6exk8A+kk+1/fkOS41zIuRgsdEtsH4cmuYkLUNtjVQ5shQoReLyvtqsLztxop PqjgvhK2k/9dz5orRniQkgg4xOI8CRQCnV2c+vIn+Fispzl5nLCbyxun5Dk6yG8VJ2u6 xAVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XKHKw5Ao; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si17096pfc.193.2019.06.06.14.03.04; Thu, 06 Jun 2019 14:03:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XKHKw5Ao; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730407AbfFFSFK (ORCPT + 99 others); Thu, 6 Jun 2019 14:05:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:49748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbfFFSFJ (ORCPT ); Thu, 6 Jun 2019 14:05:09 -0400 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A76F20868; Thu, 6 Jun 2019 18:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559844308; bh=roTh66Wfk1nFLbDkmqhx6O5MZXierIvjjQKEXHkrTvE=; h=In-Reply-To:References:To:From:Subject:Cc:Date:From; b=XKHKw5Ao+X2KNNiVVemOLkKuoMeS3NE7fP053Mat+egu94amOowaVTlopsA4hUIf4 pJcVCamp1Tte8uoFUneMts+HLGdXbRxx8UsHaUAEaqaHxmawuQYPTcOSxbPAx3eT5b FwWtldpA7XFUUjBZd3WcaFrV4cBHOsx4fqDfo7P4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <96cb1e730ea5afd651d4c79f20f365df5fe8a29b.camel@upb.ro> References: <1472247978-29312-1-git-send-email-york.sun@nxp.com> <96cb1e730ea5afd651d4c79f20f365df5fe8a29b.camel@upb.ro> To: Radu Nicolae Pirea , York Sun , linux-clk@vger.kernel.org From: Stephen Boyd Subject: Re: [Patch v9] driver/clk/clk-si5338: Add common clock framework driver for si5338 Cc: York Sun , Mike Turquette , Sebastian Hesselbarth , Guenter Roeck , Andrey Filippov , Paul Bolle , Stephen Boyd , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org User-Agent: alot/0.8.1 Date: Thu, 06 Jun 2019 11:05:07 -0700 Message-Id: <20190606180508.1A76F20868@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Radu Nicolae Pirea (2019-05-31 07:06:03) > > + remove_common_factor(&rate[1]); > > + dev_dbg(&drvdata->client->dev, > > + "PLL output frequency: %llu+%llu/%llu Hz\n", > > + rate[0], rate[1], rate[2]); > > + > > + return rate[0]; > > +} > > + > > +static long si5338_pll_round_rate(struct clk_hw *hw, unsigned long > > rate, > > + unsigned long *parent_rate) > > +{ > I think is a designs problem in clock subsystem. > Description of the function round_rate is this. >=20 > @round_rate: Given a target rate as input, returns the closest rate > actually supported by the clock. The parent rate is an input/output > parameter. >=20 > If given rate is unsigned long and the return value is long, we have a > problem. Return value can be an error value but can also be a 32 bit > frequency value that can be huge enoguh to set MSB bit and if MSB bit > is set, the return value is a negative value and will be considered > error code. >=20 > In drivers/clk/clk.c, in function clk_core_determine_round_nolock, on > line 1199 is this sequence of code that checks if the value returned by > round_rate function is negative: >=20 > } else if (core->ops->round_rate) { > rate =3D core->ops->round_rate(core->hw, req->rate, > &req->best_parent_rate); > if (rate < 0) > return rate; >=20 > In drivers/clk/clk.c, in function clk_calc_new_rates, on line 1780, is > the next sequence of code that checks if > clk_core_determine_round_nolock returns a negative value: >=20 > ret =3D clk_core_determine_round_nolock(core, &req); > if (ret < 0) > return NULL; >=20 > and... if function clk_calc_new_rates returns NULL, in function > clk_core_set_rate_nolock from drivers/clk/clk.c, on line 2023, is the > next sequence of code that evaluates NULL, returned by > clk_calc_new_rates as -EINVAL >=20 > top =3D clk_calc_new_rates(core, req_rate); > if (!top) > return -EINVAL; >=20 > So... si5338_pll_round_rate can return 32 bit values like 2500000000 Hz > who have MSB bit set and are interpreted as error codes. >=20 > Have someone a suggestion to fix this issue? >=20 Can you use the determine_rate clk op? It won't work for rounding outside of the framework though so things like clk_round_rate() still fail.