Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3360C4708F for ; Fri, 4 Jun 2021 04:40:57 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A57FE6140C for ; Fri, 4 Jun 2021 04:40:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A57FE6140C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9175882CA0; Fri, 4 Jun 2021 06:40:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="g6wM7KbS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A8BC82FEA; Fri, 4 Jun 2021 06:40:52 +0200 (CEST) Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 03EBA82B8D for ; Fri, 4 Jun 2021 06:40:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf29.google.com with SMTP id e18so4348042qvm.10 for ; Thu, 03 Jun 2021 21:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Fx6e0iodFpKHs+lCjwmWL/obLSoVpV97kiaDwlonk8M=; b=g6wM7KbSwBq7oksgKu192ldaOKGRXTkhOr6N+VWK2ZQ/lG8ENILxJTo8ub1yitqZSr vtlfkVus6syGyHaP7qDQcxGF3YN+sFDEQklL4G3YbAzIZ5k0J3QLYLW/VYExA50Fd9lE pfZH0GaoKjF4IXYWcHtl7oslP0G7kjZ681MbFaUx0TT79vEPBCCY3jvG6nR2IqqAt8IX RMUqWLDefZVGMPdIkBHv+DYCRDKlbSgm2l41FnI19SvyrRG7hB734QrgUU0DVztWiG79 ZjBAZ+65sIUQAsOD34ozbA9Y0qJeOt5lKsyiHncKl4GP2Fu/vTD47SYQW3HdEIAY4aIl 5/vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Fx6e0iodFpKHs+lCjwmWL/obLSoVpV97kiaDwlonk8M=; b=FhTYMPSPP3C2MQIw6zMlhqRwcC/TZ5/vjVefu6SXbCz1kSuzM6NBpOTo3pGDyO3Fgi +w5ojfroCjab+axCU2YgvK4axsQ+5dfwr80V8uix5JFMG+dNu2fUAi43aGkpTzLzW2iC Vegr8QuQQtmF8UzLxBMxwEwsIm1nY/KjjbkubXR1tP91kA/lh49XLv2nYQRVW/LxyowT nMfFLzvQs7scndqgBLwSCY4yajjqxlLR4s5wcdCEN7E/RLt25jqC66TL4VfSdJjxMqfm B5OOxM53DFLr/LRIXgomxGVicG8StzCRaCIA1MzQcuDeL3q5pxvaHesXnqQEGFwFhTD1 uR5Q== X-Gm-Message-State: AOAM533Da/O1ll4zovohtWkSb2GcIk+j0cwpjlztNP3j1ljChsiMXvV2 Z/Aa5ux7yl3PZgmMU7T8Rhg= X-Google-Smtp-Source: ABdhPJwMF56qFRedylN3woh2IpqZ2IDa2NC/HHTfGln8PGKniC5icITqmrW8dulXwZxSc4gAATicPA== X-Received: by 2002:a05:6214:321:: with SMTP id j1mr2858793qvu.38.1622781647940; Thu, 03 Jun 2021 21:40:47 -0700 (PDT) Received: from [192.168.1.201] (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.googlemail.com with ESMTPSA id f8sm3352347qko.131.2021.06.03.21.40.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 21:40:45 -0700 (PDT) Subject: Re: [PATCH v2 00/11] clk: k210: Rewrite K210 clock without CCF To: Damien Le Moal , "u-boot@lists.denx.de" Cc: Lukasz Majewski , Leo Liang , Andreas Dannenberg , Lokesh Vutla , Philipp Tomsich References: <20210604035834.625772-1-seanga2@gmail.com> From: Sean Anderson Message-ID: Date: Fri, 4 Jun 2021 00:40:44 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean On 6/4/21 12:28 AM, Damien Le Moal wrote: > On 2021/06/04 12:58, Sean Anderson wrote: >> This is something I've been meaning to do for a while but only just got around >> to. The CCF has been quite unwieldy in a few ways: >> >> * It is very rigid, and there are not easy ways to hook into it without >> rewriting many things. See e.g. things like the bypass clock and all the _half >> clocks which were created because CCF didn't support the dividers used on the >> k210. While preparing this series, I encountered several edge cases which I >> had initially overlooked (or which were not supported in the initial release). >> These would have been very difficult to fix with CCF, but were much easier to >> address because each funcion is implemented in one place. >> * There is a lot of magic going on under the curtains because of all the CCF >> code which lives in many different files. Some things live in drivers, but >> many things live in e.g. clk-uclass.c. So many things live in so many files >> and it can be very difficult to get a handle on what exactly happens. >> Complicating this is that there is a conflation of struct clk as a handle and >> struct clk as a device. In this regard, refcounting is completely broken. IMO >> we should just do away with refcounts and only disable clocks when explicitly >> asked for. >> * It is very dependent on runtime initialization. Typically, everything is >> initialized by calling into various register() functions, usually with several >> wrappers to avoid specifying all the arguments. This balloons the runtime >> memory usage since there are so many devices created. It also makes it hard to >> debug, since if you do it the "typical" way it is easy to accidentally assign >> a clock to the wrong register. >> * It inflates code size by pulling in not just some dead code (e.g. this driver >> does not use divider tables but they are in clk-divider anyway) but also >> pulling in numerous imx-specific clocks. This could be fixed, but I don't want >> to due to the other reasons listed. >> >> I am very happy to have completely excised it from my driver. IMO there should >> be big warning signs on the CCF warning not to use it for new code. This would >> hopefully dissuade those like myself who had no idea that CCF was *not* in fact >> a good way to write a clock driver. >> >> Overall there is a total savings of 12k from this series. >> text data bss dec hex filename >> 292485 32672 12624 337781 52775 before/u-boot >> 283125 29856 12624 325605 4f7e5 after/u-boot >> >> This series depends on >> https://patchwork.ozlabs.org/project/uboot/list/?series=238211 >> >> Changes in v2: >> - Convert stage to enum >> - Only force probe clocks pre-reloc >> - Rebase on u-boot/master >> >> Sean Anderson (11): >> clk: Allow force setting clock defaults before relocation >> clk: k210: Rewrite to remove CCF >> clk: k210: Move pll into the rest of the driver >> clk: k210: Implement soc_clk_dump >> clk: k210: Re-add support for setting rate >> clk: k210: Don't set PLL rates if we are already at the correct rate >> clk: k210: Remove bypass driver >> clk: k210: Move k210 clock out of its own subdirectory >> k210: dts: Set PLL1 to the same rate as PLL0 >> k210: Don't imply CCF >> test: Add K210 PLL tests to sandbox defconfigs >> >> MAINTAINERS | 4 +- >> arch/riscv/dts/k210.dtsi | 2 + >> board/sipeed/maix/Kconfig | 2 - >> configs/sandbox64_defconfig | 2 + >> configs/sandbox_defconfig | 2 + >> configs/sandbox_flattree_defconfig | 2 + >> configs/sipeed_maix_bitm_defconfig | 1 - >> drivers/clk/Kconfig | 14 +- >> drivers/clk/Makefile | 2 +- >> drivers/clk/clk-uclass.c | 27 +- >> drivers/clk/clk_kendryte.c | 1320 +++++++++++++++++++++++ >> drivers/clk/kendryte/Kconfig | 12 - >> drivers/clk/kendryte/Makefile | 1 - >> drivers/clk/kendryte/bypass.c | 273 ----- >> drivers/clk/kendryte/clk.c | 668 ------------ >> drivers/clk/kendryte/pll.c | 585 ---------- >> drivers/clk/rockchip/clk_rk3308.c | 2 +- >> drivers/core/device.c | 2 +- >> drivers/net/gmac_rockchip.c | 2 +- >> include/clk.h | 30 +- >> include/dt-bindings/clock/k210-sysctl.h | 94 +- >> include/kendryte/bypass.h | 31 - >> include/kendryte/clk.h | 35 - >> include/kendryte/pll.h | 34 - >> 24 files changed, 1436 insertions(+), 1711 deletions(-) > > Awesome cleanup ! > > I will try to revisit the clock rate setting in Linux and re-check where we diverge. I don't believe there are any divergences other than the fix mentioned in 02/11. > > FYI: I have a draft series adding K210 builds to buildroot here: > > https://github.com/damien-lemoal/buildroot (k210-v2 branch) Ok, I will try and check it out. (you have a typo in board/canaan/k210/README.txt: Sipedd -> Sipeed) --Sean > > I cannot get userspace to run with kernel 5.12, even adding the binfmt_flat > change in 5.13 (commit 04d82a6d0881 "binfmt_flat: allow not offsetting data > start"). Not sure what is going on yet. 5.13-rc4 kernel works perfectly. > > >> create mode 100644 drivers/clk/clk_kendryte.c >> delete mode 100644 drivers/clk/kendryte/Kconfig >> delete mode 100644 drivers/clk/kendryte/Makefile >> delete mode 100644 drivers/clk/kendryte/bypass.c >> delete mode 100644 drivers/clk/kendryte/clk.c >> delete mode 100644 drivers/clk/kendryte/pll.c >> delete mode 100644 include/kendryte/bypass.h >> delete mode 100644 include/kendryte/clk.h >> > >