Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1138450rdg; Fri, 13 Oct 2023 11:17:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2BW0kX8d808HYj4317L45leGNXGU2c+NQyiAtoFgWM1Fec5bZr9yYqYm+fAt5dD9l3b/F X-Received: by 2002:a05:6a00:1996:b0:693:43b5:aaf3 with SMTP id d22-20020a056a00199600b0069343b5aaf3mr1227373pfl.13.1697221064739; Fri, 13 Oct 2023 11:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697221064; cv=none; d=google.com; s=arc-20160816; b=JYLxeHEmD03ozpnA0KYbvb0pDI2CBIH9lpttd8toavSMtRfuYo3tixUYizxsWn5iOP jOv6da34fgzgUhvA4hzmW9FSIhYl362B1OZVlGgZoV73dkbX2VIYKtQAlaFOuLeWgWyF rsI75eh2q83TezKuhQFRrkD854DMwzBZaCnN7DHs/fU4KXgb94Vlt8RviL8//Gcqzic0 nPuzsuoGLm0shtZao/NhkB79cgAsVxcLhhT8ZtKhGJ8Bl0DpIgdXtvTufsKIHJoGRZpP dAKMGsNBlhME3rbo+D4PS8L4o8WmeuseYIV2Ut+wUY68oOTdUVNeMr6w1XWFHry8ATYI G87w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=U9nTHaFndFfh4gMEpmSZ2pg3B4FHQG8rnUIGTQ2gc1Q=; fh=fwy9Q4JaUsdmY0JT+8TlkCpKnUpOKNSU9oYZYB56x/M=; b=iyLrEt8pRrbgcBqhA6uXaHLRRdPleUrJf3fa1M8mPEC/lSh23d7yDEsyMOIUNeyfX2 wFNtsSTFqMYVJ2NUBnrRhdBDuXU99ftKA3WKBk7wlsKTYEQSoe1gV5FQYTewVCc1zUWV ++BzbREALLtIvDeI9u67msBPkyjsPMdNcxe8AmbadsWDKy/AupLx5y/BND0hz3LPqFaq 6ayfnQmVYu+G1KCw1G70eExDrd7NbHjm6lxFqCh6s9U6G082UAZ7VXdQJuxaB7nwPc7r hxnm9u7R+m9PEq9h8dKeHYjbH7b9oBFd8KdZAqESeR0AYN4sBC9gq7BqJbLyIxK65LVF /XQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eaDVRIET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m189-20020a633fc6000000b005af44ed3142si543423pga.413.2023.10.13.11.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 11:17:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eaDVRIET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 04C498348DB4; Fri, 13 Oct 2023 11:17:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbjJMSRg (ORCPT + 99 others); Fri, 13 Oct 2023 14:17:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbjJMSRd (ORCPT ); Fri, 13 Oct 2023 14:17:33 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9AFF83; Fri, 13 Oct 2023 11:17:31 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4054496bde3so24506175e9.1; Fri, 13 Oct 2023 11:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697221050; x=1697825850; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U9nTHaFndFfh4gMEpmSZ2pg3B4FHQG8rnUIGTQ2gc1Q=; b=eaDVRIETxZjuepcdt4NyIkGX8DjgfMPiCg3UZ1SI3ZOGen8Qv32+NEXu2P1cnpqsG2 nJHMcLpQaUqjzF/lzsl4Dj9JhAilk2YoZMIxQ+tbGdaW2kKDbenYi68D+sO+XmTDJZmt 3EUibuAhdxtAsDT28rUIO/7F9UThZPmnYAAwG5XVHBSb2DIn1retqsc7mypS2gJdOYbK nWP7Tqw7NhBpynaxFctiU59FDP9PNhJQUx3j5Um0xpfFjlpYu4ownkDH/yib/HPkGPzk 9+EAW7l8C6pZ6+TAgr40tu4ODCVdw4GW33bDd8dsoNKp5/s+FXKPJRbmiNnJ5i3E5bZj ii2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697221050; x=1697825850; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U9nTHaFndFfh4gMEpmSZ2pg3B4FHQG8rnUIGTQ2gc1Q=; b=Cwl5xPcL+6x35yFvRgcpZNnTeaLtbzvjWShhdbZQsVZ295ZHAlE2LcbvGQEeychZVI vmknV7SZVR14aImVWsdQpw8V6Fti4OL0XEJztmGcDh1C5qpPQ08kMYfVf1QmLrgZlaMM ekd2DemolqVX41rw23evxOxtQrgUQaqWIJ5ZlqImxr90WtBQyZ7tid3FncgmXDQUH4sB D7ymG5PuyZAAuXfevcymuHLvqhSUaCQqI3dwlokV5ebBEBUydAYJZxA2ZCZeivfdH7lg xXJ99rmefvALx0+MszNptdzwWxZAbLvFQx7k2B+pEarsnAmfpG2+6EvZxNS5AjIq6hCG az8Q== X-Gm-Message-State: AOJu0Yz6n0TiNK5j2VfO5+I2hH8mVQ+64QresdplR1LmaRCw0nzN5ppg bpoZ8h9L9/r7fEydVjBvn3E= X-Received: by 2002:a05:600c:3586:b0:406:849c:52c3 with SMTP id p6-20020a05600c358600b00406849c52c3mr23139477wmq.22.1697221049878; Fri, 13 Oct 2023 11:17:29 -0700 (PDT) Received: from localhost.localdomain ([188.159.248.16]) by smtp.gmail.com with ESMTPSA id r8-20020a05600c458800b004064cd71aa8sm800127wmo.34.2023.10.13.11.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 11:17:29 -0700 (PDT) From: Jernej Skrabec To: wens@csie.org, samuel@sholland.org Cc: sboyd@kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec , Chad Wagner Subject: [PATCH] clk: sunxi-ng: h6: Reparent CPUX during PLL CPUX rate change Date: Fri, 13 Oct 2023 20:17:12 +0200 Message-ID: <20231013181712.2128037-1-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 13 Oct 2023 11:17:42 -0700 (PDT) While PLL CPUX clock rate change when CPU is running from it works in vast majority of cases, now and then it causes instability. This leads to system crashes and other undefined behaviour. After a lot of testing (30+ hours) while also doing a lot of frequency switches, we can't observe any instability issues anymore when doing reparenting to stable clock like 24 MHz oscillator. Fixes: 524353ea480b ("clk: sunxi-ng: add support for the Allwinner H6 CCU") Reported-by: Chad Wagner Link: https://forum.libreelec.tv/thread/27295-orange-pi-3-lts-freezes/ Tested-by: Chad Wagner Signed-off-by: Jernej Skrabec --- drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c index 42568c616181..892df807275c 100644 --- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c +++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c @@ -1181,11 +1181,18 @@ static const u32 usb2_clk_regs[] = { SUN50I_H6_USB3_CLK_REG, }; +static struct ccu_mux_nb sun50i_h6_cpu_nb = { + .common = &cpux_clk.common, + .cm = &cpux_clk.mux, + .delay_us = 1, + .bypass_index = 0, /* index of 24 MHz oscillator */ +}; + static int sun50i_h6_ccu_probe(struct platform_device *pdev) { void __iomem *reg; + int i, ret; u32 val; - int i; reg = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(reg)) @@ -1252,7 +1259,15 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev) val |= BIT(24); writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG); - return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc); + ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc); + if (ret) + return ret; + + /* Reparent CPU during PLL CPUX rate changes */ + ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, + &sun50i_h6_cpu_nb); + + return 0; } static const struct of_device_id sun50i_h6_ccu_ids[] = { -- 2.42.0