Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1238569rdb; Mon, 19 Feb 2024 08:27:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9gE7ubiMVjaK7ueUtJMEx7uRhWrmq6RTaa5mJJJk7cncGNRTujfCP9wgvyXqLstky0Yzhj75ivlB5T5T0ExdCl0OnONBgzB3Ihy0nOg== X-Google-Smtp-Source: AGHT+IG8dZ3Cthn1UU9udmGH1FC4p5qF+NvUn3LyB497NDIaxMRjZy6xqZ4e8e+5fCks1GQGNfHA X-Received: by 2002:a17:90a:ea04:b0:299:35ef:1d5f with SMTP id w4-20020a17090aea0400b0029935ef1d5fmr6300331pjy.44.1708360051350; Mon, 19 Feb 2024 08:27:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708360051; cv=pass; d=google.com; s=arc-20160816; b=E2JPdqxaky7RT0gXWyTupUkAZkD6YuZmBVnIvF/PGmObDPN9C1zIecCOASYsoGZLhi 4aSwtxxKrO+XkOkDw00EE3BOEf/EGDkEdw67/UIDbtGpFNFDVZdn8ivkJ1CU1TDRUsJd 9DTgGaM0dt4M3KVhfy88M4sSPon9G6qjEQ75HpJP7MrpUl/I28wnpKCoG1HnLSBfLL/N xjOVjGJOU29zLDGuWGfbv9eLJ8he8AtXydlWyWGIkZ5OIjyqPDUXad92+4ed8n9FWrNC dq1uUc5Bnnho+apLDifUZOTyMJnHPpjM/Z3dxSIN7HOviWfl2918T/FlYNe8BWpWN9PR ZFHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=NaDQiik2JDIL0PeKm9y0F/+8tJ/709psGRLRage4RWk=; fh=O9CDoiLCSO7JR/gaaKjygTPduNsDMwiEFeUc7vRmzpI=; b=DUAOlsUb5ENB6OtxYy8qfSbHjmAjLirif15nj+1SrtE4fAKNeaoMiovCbSybH++gLm Bz7A7xjWiZFXUSOaxWndGNhMDu2qOXlIAyhRmG8nzyoNY+fMZqnNlR0wypQtIW/rA8VZ uzlod1ekUOMT5pgN0hUY22S21Z97oOLdzV2D+jXy5rfm6YuNkA6BOyzpR/Ii1VcWs9MO vG9BI9pNVO92pdnSsbJ/Wp2bX9TrsIgyKPzYq2NnDZIfoQQ9rAmQQofQGWVs1heps0Zm wzbBr7hjg+KVuJ0xCLHI+eNbwpmDVVt+JJWoiHoQbZcIRhGD7qqxWgfsgBDdX2tRbmDb /SQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mAA/wdWv"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-71674-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71674-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g4-20020a17090a578400b002964afac9dbsi4785371pji.2.2024.02.19.08.27.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 08:27:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71674-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mAA/wdWv"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-71674-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71674-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 043742819C1 for ; Mon, 19 Feb 2024 16:24:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B79C93CF63; Mon, 19 Feb 2024 16:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mAA/wdWv" Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89E363BB3B for ; Mon, 19 Feb 2024 16:24:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708359889; cv=none; b=qzSkf6r+GIF9rNqXrwxyOXd/1GjbzIsAzEjxuieQ1wcy52ixyKf7B7WJgXMnv/wx/7Knf/IYGp4+dwNz5ns434zw0jPAs/EpxQca+NTkksWT3kDGrNXhYhUDLGvl4ZX46jTuiy+7K8O2WIZ5/TlIuZL5jRusp8dMzOZp1XYLSME= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708359889; c=relaxed/simple; bh=KC1W4movdiLyZiAw8wBIqLm4qc3oLkCh4hFtZmiJuK0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XEHRsBkWOqJSNGwo+FkmVNoOr+/MtIv6apNDT4oFtOgryQCAE4n/ivsoNbwPMHU0kvE317ow42T2t1mvQIMKrGLAPQLru7DJLwZXL81tcKy732AKTMOvD8E5P6PGJN9Fo6yZy+VeU83D7ep2OOPf5oZcIl8l1bEfkxD8ohFRiH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mAA/wdWv; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6081bc96387so13590727b3.0 for ; Mon, 19 Feb 2024 08:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708359885; x=1708964685; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=NaDQiik2JDIL0PeKm9y0F/+8tJ/709psGRLRage4RWk=; b=mAA/wdWvqWzkD7A8FrtUWj31p3c4CV9lyayh52fJFcx4PV8qej5ecFFuZkdhHfpaMK D0vJ96kVH7BQS0f+GFFhiyWUSufd0OWc8pqX+VtQq03eItQFs5hOfDqO6WuOgvBMII4B HR+Vk7wBbpPpXXEPVxqULIw/v5m8afvbeYNsFt/Jfj/i1Ln+8Ffj0RxCUz6/NfO0pTf+ xuhcSQEz2pHZdomiy9GL3FUQ30WmMCWGThZVDnHCLBeLiZP0rjWQPt+DfziFUf/JJESg k/F1dqeu2BsomC3dQEDfatkXnfaSIfz1QtSQCKErYhKdnaGZUYkaPNbde+l9ifzO9oHh +z0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708359885; x=1708964685; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NaDQiik2JDIL0PeKm9y0F/+8tJ/709psGRLRage4RWk=; b=e8jvvRb089zHfBxHMO5LwAl12Z3mbnrvDHj+sl4IEvXoSjMDPLQhAYWTVCBqOSfiO6 Zh+WwKmlXrPdulpP2RaF+N0j/D+fYpWxov99Il7LCfqR49tjh6kDKzA8FpucKBlI85xu 511ZWPF0secrVRO928Qxldqo16mKnLKkyVN/rfZJ+oFQ/qhquU3hpwHw+3ymL26yoHH7 nti39emWMNh2sQPnz24YoQvMtDpS097CejR6Mu+olcd6AXoDgJB7UjMvFliTtg4JIvTN 28c74dimwpz+t9pQ1kG7HWbRgwJlAGwdVeMqY7LX80xMSgs3a00C1m6JkpXfE4eh0bH9 A+vg== X-Forwarded-Encrypted: i=1; AJvYcCVAapBtKNyxmEnURkfibxl7QEUC372G2I728Atq+AZyIKYUmkVFIjB85r0fgcOzZqmMXInNHbQjf1UE6ydeMVXXkewUdXgxkLvLmxa6 X-Gm-Message-State: AOJu0YzogJUDlq9h8VHv5gVyylE9UJiX5bVh7LzlwGh8GApSpyo/TpcV hP1rxgHcq40ulcxWO+iv88cGsrMizMVzUsEZx4gx3tElWbSkD3FHHI+YP1sCDAEqBk10Ejof/v0 XpRqjGyZws7iZgFUgTGAJK5ujGzguIiGsiXBapA== X-Received: by 2002:a81:ad09:0:b0:607:8351:bbe8 with SMTP id l9-20020a81ad09000000b006078351bbe8mr12764734ywh.14.1708359885613; Mon, 19 Feb 2024 08:24:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240219-topic-rb1_gpu-v1-0-d260fa854707@linaro.org> <20240219-topic-rb1_gpu-v1-3-d260fa854707@linaro.org> In-Reply-To: From: Dmitry Baryshkov Date: Mon, 19 Feb 2024 18:24:34 +0200 Message-ID: Subject: Re: [PATCH 3/8] clk: qcom: clk-alpha-pll: Add HUAYRA_2290 support To: Konrad Dybcio Cc: Andrew Halaney , Will Deacon , Robin Murphy , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Michael Turquette , Stephen Boyd , Rob Clark , Abhinav Kumar , Sean Paul , David Airlie , Daniel Vetter , Marijn Suijten , linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" On Mon, 19 Feb 2024 at 17:01, Konrad Dybcio wrote: > > On 19.02.2024 15:54, Andrew Halaney wrote: > > On Mon, Feb 19, 2024 at 02:35:48PM +0100, Konrad Dybcio wrote: > >> Commit 134b55b7e19f ("clk: qcom: support Huayra type Alpha PLL") > >> introduced an entry to the alpha offsets array, but diving into QCM2290 > >> downstream and some documentation, it turned out that the name Huayra > >> apparently has been used quite liberally across many chips, even with > >> noticeably different hardware. > >> > >> Introduce another set of offsets and a new configure function for the > >> Huayra PLL found on QCM2290. This is required e.g. for the consumers > >> of GPUCC_PLL0 to properly start. > >> > >> Signed-off-by: Konrad Dybcio > >> --- > >> drivers/clk/qcom/clk-alpha-pll.c | 45 ++++++++++++++++++++++++++++++++++++++++ > >> drivers/clk/qcom/clk-alpha-pll.h | 3 +++ > >> 2 files changed, 48 insertions(+) > >> > >> diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c > >> index 8a412ef47e16..61b5abd13782 100644 > >> --- a/drivers/clk/qcom/clk-alpha-pll.c > >> +++ b/drivers/clk/qcom/clk-alpha-pll.c > >> @@ -244,6 +244,19 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = { > >> [PLL_OFF_OPMODE] = 0x30, > >> [PLL_OFF_STATUS] = 0x3c, > >> }, > >> + [CLK_ALPHA_PLL_TYPE_HUAYRA_2290] = { > >> + [PLL_OFF_L_VAL] = 0x04, > >> + [PLL_OFF_ALPHA_VAL] = 0x08, > >> + [PLL_OFF_USER_CTL] = 0x0c, > >> + [PLL_OFF_CONFIG_CTL] = 0x10, > >> + [PLL_OFF_CONFIG_CTL_U] = 0x14, > >> + [PLL_OFF_CONFIG_CTL_U1] = 0x18, > >> + [PLL_OFF_TEST_CTL] = 0x1c, > >> + [PLL_OFF_TEST_CTL_U] = 0x20, > >> + [PLL_OFF_TEST_CTL_U1] = 0x24, > >> + [PLL_OFF_OPMODE] = 0x28, > >> + [PLL_OFF_STATUS] = 0x38, > >> + }, > >> }; > >> EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); > >> > >> @@ -779,6 +792,38 @@ static long clk_alpha_pll_round_rate(struct clk_hw *hw, unsigned long rate, > >> return clamp(rate, min_freq, max_freq); > >> } > >> > >> +void clk_huayra_2290_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, > >> + const struct alpha_pll_config *config) > >> +{ > >> + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL(pll), config->config_ctl_val); > >> + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL_U(pll), config->config_ctl_hi_val); > >> + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL_U1(pll), config->config_ctl_hi1_val); > >> + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL(pll), config->test_ctl_val); > >> + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL_U(pll), config->test_ctl_hi_val); > >> + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL_U1(pll), config->test_ctl_hi1_val); > >> + clk_alpha_pll_write_config(regmap, PLL_L_VAL(pll), config->l); > >> + clk_alpha_pll_write_config(regmap, PLL_ALPHA_VAL(pll), config->alpha); > >> + clk_alpha_pll_write_config(regmap, PLL_USER_CTL(pll), config->user_ctl_val); > >> + > >> + /* Set PLL_BYPASSNL */ > >> + regmap_update_bits(regmap, PLL_MODE(pll), PLL_BYPASSNL, PLL_BYPASSNL); > >> + > >> + /* Wait 5 us between setting BYPASS and deasserting reset */ > >> + mb(); > >> + udelay(5); > >> + > >> + /* Take PLL out from reset state */ > >> + regmap_update_bits(regmap, PLL_MODE(pll), PLL_RESET_N, PLL_RESET_N); > >> + > >> + /* Wait 50us for PLL_LOCK_DET bit to go high */ > >> + mb(); > >> + usleep_range(50, 55); > > > > I *think* you'd want to use a read to ensure your write goes through > > prior to your sleep... from memory-barriers.txt: > > > > 5. A readX() by a CPU thread from the peripheral will complete before > > any subsequent delay() loop can begin execution on the same thread. > > This ensures that two MMIO register writes by the CPU to a peripheral > > will arrive at least 1us apart if the first write is immediately read > > back with readX() and udelay(1) is called prior to the second > > writeX(): > > > > writel(42, DEVICE_REGISTER_0); // Arrives at the device... > > readl(DEVICE_REGISTER_0); > > udelay(1); > > writel(42, DEVICE_REGISTER_1); // ...at least 1us before this. > > > > also https://youtu.be/i6DayghhA8Q?si=7lp0be35q1HRmlnV&t=1677 > > for more references on this topic. > > I mentioned this feels very iffy in the cover letter, but it's a combination > of two things: > > 1. i followed what qualcomm downstream code did > > 2. qualcomm downstream code is not known for being always correct > > > > I suppose a readback would be the correct solution, but then it should be > done for all similar calls in this driver. > > Although this code has shipped in literally hundreds of millions of devices > and it didn't explode badly :P (i'm not defending it, though) I think the idea behind the code looks pretty close to clk_alpha_pll_stromer_plus_set_rate(), which uses neither wmb() nor read-back. -- With best wishes Dmitry