Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3793217ybg; Mon, 28 Oct 2019 19:40:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzi8+O6zaUkwUV2S+KMDaciQyX37B2mEYs/biUzqSBZ4c6NnohzjKX7BtmK8fkXV2+fbSc X-Received: by 2002:a50:eb42:: with SMTP id z2mr23026862edp.291.1572316848253; Mon, 28 Oct 2019 19:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572316848; cv=none; d=google.com; s=arc-20160816; b=KBdmOUC0iLGIPlKPkFbtiguVMGwkl3+1iUevB6BOQwsJvOdgJe2/Mp+vjzaFRlK77o seoxFUBYkDPSZ8IACWNCZ3+7FmD0aSU+rGMHigUcrE9QXVmmBjJlMplxFN85brpIs4nC YZ2a5ViAhhGcN3frFiJn3p6Ru+u2YLE605V/aSuqd4IFi4zSxjMuvS1bk7q/i1YlpU1k v52n0MBaebicSS0rHybIUJx07golzh3BEDfoIIrFKanWcWTQekuaMHJTeX/c+LvAEZN0 FOp1P4N94hOyZIG/XQJu5lcQlIh0rfkPWZegd8ZzEIibqBtaR4eKEeHZUsKNys2cf4Y1 tEdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=dyrpC3p6vL18b1O3dLqA/KgcilibjGWnZgSsfyy6puw=; b=mlT8inAF+/oCcOXVhqQbzoLmISvDtEKN2FM+qlqLpam2/jJke5mE0hwND37mXGPUsX wUK987gdnweMqZZISQfZWIu+Gk4VL7MxTFnprMBIp0e/LW/ZV70ZrjHLPe2wY5SpVan9 XZEMbQVDYNEma5vFRXhE5eoz0yq2vx1srJUvDSYEqbmZxXkP1ZZIvhkVTL4ZEFOOi0I4 8zM8Wk9xrqiqBgy58f2g1aYjPNW7Cc6wB+Xim8kjuBl3Fc0zknQ4iXSvf0qoDbbBcL9P gtNvWXCj1WSILg5Uk6RNl8OovAIhhk/u5ujG/LGkxKL0FJKrC6or/uTSAtVQn3rV6j4T mpIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i7knxtPb; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rk26si7315833ejb.303.2019.10.28.19.40.24; Mon, 28 Oct 2019 19:40:48 -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=@gmail.com header.s=20161025 header.b=i7knxtPb; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390027AbfJ1ORq (ORCPT + 99 others); Mon, 28 Oct 2019 10:17:46 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:40913 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730033AbfJ1ORq (ORCPT ); Mon, 28 Oct 2019 10:17:46 -0400 Received: by mail-il1-f194.google.com with SMTP id d83so8308625ilk.7; Mon, 28 Oct 2019 07:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dyrpC3p6vL18b1O3dLqA/KgcilibjGWnZgSsfyy6puw=; b=i7knxtPbtmf3aegRshvbyPqat9NZGgNvYw9ZueFZpr89A9061oAXpfFiQMQcx/eMI8 wFnFrpqTvWp/BVUd9YtJkOFPM1QRobOFKIm6jpxHH+FqbGRkWdZnecyVJoCtDT7aj/B4 2L5wqaS4cG5DtyhyE/oSfY+n+y6Gxbw46l66/hc/qbXyjW4FgkGhDvJ+tb3w5Scy6RHs p5dOEzHl/aaT8SNc/0o4hHInX60YvP7lm5SMaXIsc3FP9ogz42MAsm1vPKGv4yEni8zn D67ZqKK5imsvCpSAgdnv5xOUb9TBnmXjYzH6V+d2Uemuoc/nzkMZb3zjFGfH8tQZH+QU tCug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dyrpC3p6vL18b1O3dLqA/KgcilibjGWnZgSsfyy6puw=; b=VujhB107jXp/9pRiW316rfRGOU4hrQpofk8vgC1TfSlATts8ZV5AreUCLgnV3EK6UC i7YfAxoiPcQwebkb/JwzBHbwcWkXmG98xT2c4zxgM8YyuwUYcFgoW1YuwZMjFrhyXV3y NAlT3611rxzd80yLMKcDxRYg8xcziGtSovFt8Vh+AqG32vcExYRfdk5HPzUNYI5tyt2/ wnY7Ke6BdDb7zSEcoEXqrcLSAbDdZo+DeWCFg7KwdptIdD88rO3f6OY0tVoyMoDsNhV1 pfGM7OFoE3690d++iYmie9K3ZkqzlDuhJr9mYZ6giQv0YScemT8dCnDYYP52hpJnUF+R zruQ== X-Gm-Message-State: APjAAAVDn5Q9g+x3EjfIxnbq219GkxvNkBdnjDTt1weAE7jstbgG0M2w HGchNQa317L1zoO/TuwtMoNOJf2ky7CChS2f0B8= X-Received: by 2002:a92:17c8:: with SMTP id 69mr21100233ilx.42.1572272264815; Mon, 28 Oct 2019 07:17:44 -0700 (PDT) MIME-Version: 1.0 References: <20191002011555.36571-1-jeffrey.l.hugo@gmail.com> <20191002011640.36624-1-jeffrey.l.hugo@gmail.com> <20191017215023.2BFEC20872@mail.kernel.org> <20191027213659.23423205F4@mail.kernel.org> In-Reply-To: <20191027213659.23423205F4@mail.kernel.org> From: Jeffrey Hugo Date: Mon, 28 Oct 2019 08:17:33 -0600 Message-ID: Subject: Re: [PATCH v4 1/2] clk: qcom: Add MSM8998 GPU Clock Controller (GPUCC) driver To: Stephen Boyd Cc: Michael Turquette , Andy Gross , Bjorn Andersson , Marc Gonzalez , MSM , linux-clk@vger.kernel.org, lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 27, 2019 at 3:36 PM Stephen Boyd wrote: > > Quoting Jeffrey Hugo (2019-10-18 14:11:09) > > On Thu, Oct 17, 2019 at 5:16 PM Jeffrey Hugo wrote: > > > > > > On Thu, Oct 17, 2019 at 3:50 PM Stephen Boyd wrote: > > > > > > > > Quoting Jeffrey Hugo (2019-10-01 18:16:40) > > > > > +static const struct freq_tbl ftbl_gfx3d_clk_src[] = { > > > > > + F(180000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(257000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(342000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(414000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(515000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(596000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(670000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + F(710000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0), > > > > > + { } > > > > > > > > I guess this one doesn't do PLL ping pong? Instead we just reprogram the > > > > PLL all the time? Can we have rcg2 clk ops that set the rate on the > > > > parent to be exactly twice as much as the incoming frequency? I thought > > > > we already had this support in the code. Indeed, it is part of > > > > _freq_tbl_determine_rate() in clk-rcg.c, but not yet implemented in the > > > > same function name in clk-rcg2.c! Can you implement it? That way we > > > > don't need this long frequency table, just this weird one where it looks > > > > like: > > > > > > > > { .src = P_GPUPLL0_OUT_EVEN, .pre_div = 3 } > > > > { } > > > > > > > > And then some more logic in the rcg2 ops to allow this possibility for a > > > > frequency table when CLK_SET_RATE_PARENT is set. > > > > > > Does not do PLL ping pong. I'll look at extending the rcg2 ops like > > > you describe. > > > > Am I missing something? From what I can tell, what you describe is > > not implemented. > > > > The only in-tree example of a freq_tbl with only a src and a pre_div > > defined for rcg ops is for the tv_src clk in mmcc-msm8960 [1] > > However, that uses a variant of rcg ops, clk_rcg_bypass_ops, not clk_rcg_ops. > > > > clk_rcg_bypass_ops has its own determine_rate implementation which > > does not utilize _freq_tbl_determine_rate(), and can only do a 1:1 > > input rate to output ratio (we want a 1:2). > > > > _freq_tbl_determine_rate() in either rcg_ops or rcg2_ops won't work, > > because they both use qcom_find_freq() which doesn't work when your > > table doesn't specify any frequencies (f->freq is 0). > > Yes. You have to have some sort of frequency table to tell us what the > source and predivider to use. > > > qcom_find_freq() won't iterate through the table, therefore f in > > qcom_find_freq() won't be pointing at the end of the table (the null > > entry), so when qcom_find_freq decrements f in the return, it actually > > goes off the beginning of the array in an array out of bounds > > violation. > > Ouch! > > > > > Please advise how you would like to proceed. > > Please have a frequency table like > > { .src = SOME_PLL, .div = 4 } > > > > > > I can still extend rcg2_ops to do what you want, but it won't be based > > on what rcg_ops is doing. > > Why isn't rcg_ops doing it? The idea is to copy whatever is happening > with this snippet in the _freq_tbl_determine_rate() in rcg.c to rcg2.c That more or less exists in both cases, although rcg2_ops may need a bit of additional work. The problem is that in both cases, before this snippet, we've already called qcom_find_freq(), and in both cases (rcg_ops and rcg2_ops), f will be an invalid entry and we won't have the proper pre_div value. > > clk_flags = clk_hw_get_flags(hw); > p = clk_hw_get_parent_by_index(hw, index); > if (clk_flags & CLK_SET_RATE_PARENT) { > rate = rate * f->pre_div; > > We have checked for CLK_SET_RATE_PARENT from the beginning. Maybe it was > always broken! If the frequency table pointer can return us the pre div > and source then we can do math to ask the parent PLL for something. > > > > > I can spin a rcg2_ops variant to do what you want, with a custom > > determine_rate, but it doesn't seem like I'll really be saving any > > lines of code. Whatever I eliminate by minimizing the gfx3d > > freq_table I will surely be putting into clk-rcg2.c > > > > Or, I can just drop this idea and keep the freq_tbl as it is. Seems > > like just a one off scenario. > > Please make rcg2 clk ops "do the right thing" when the flag > CLK_SET_RATE_PARENT is set and the frequency table is just a > source/divider sort of thing. That way we don't have to have different > clk ops or even put anything in the frequency table besides the source > PLL we want to use and the predivider we want to configure. > Got it. Will do.