Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp128398lql; Fri, 12 Apr 2024 06:03:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXvr8NPYCpcjx5BLRwB5ztNZaI4CrM6EiMH/YUrg5kkrd89/0GvE86b+noWXe81DifFmWX7raCnGxTcx9wlPKMW7ecopuy5+5IrxZ1CA== X-Google-Smtp-Source: AGHT+IGzCZ2prqH7Hjrk7zzmx+QS3MPYoYipx99zki28LS6dJQMuMk/snJ37kIJ21ca4rr19S4u7 X-Received: by 2002:a05:6a20:1225:b0:1a7:516a:199c with SMTP id v37-20020a056a20122500b001a7516a199cmr2471757pzf.51.1712927037931; Fri, 12 Apr 2024 06:03:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712927037; cv=pass; d=google.com; s=arc-20160816; b=wdr6nusg4nGjfv10nvZe18KxZz6F2CgKWMtMj5QvQwmJ0ffsq/5s85OOlIgSNzu+sx /tLRzxsxdsQaNn1RJNiFvq/Thvo1laXu1I1C8Go4+LMtrt44gRFkAAeyO5WmUThdNXis owgslTXNSsU4WTSNi2Dd16vbLc0j1SgSYz/ZlpG8jBqwZ21xYqg9jsN3IHE/my6WI+zz bXpW33YrH/mPxuHvA0oPBC6X6dlH1nPnie+M47X6+UGrIoQIJceh3S8TalclDHPGFuG6 jTtOXsCvILo0Al0Jeta0lo1tUpkhje1Zxk5+NZQ6jix+0W3FdIKaJ77tvb7NyqorX2e7 W76A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=Nm8LSvH+A0aysY1LVMvbC5kt2UeJVTw7St9EkLFip3k=; fh=uU+ZOhgoZOH466zcQfT8tsHspMdT2ENsbf39vJJQ1d4=; b=Zzvn7D3rXsAcPLLLLXNeJNcVV7kH1nLRBs8LoJhCKM2VkS/U1+d5qa4JLz0/LrCXFQ rYsH4XE8n0i0oKU3BkQ4oAXjPTnPYiCbH64JV4GjiqJrbirML15BbhfRZp9sa9l7kRzZ lwDD9wLfWCecuYtQZ8yA8p3yqTVc/dO4xIPJ3d52lrdqF4HZ8HjTbDcRHnZ12o6xIisf 2siS40XQBqs5RV/oa4wEQ8GNB2kGka+exQxKtP8j388S+AcI/+ceHiOq5LMqCnQJFyCK k92FNKdvTB1V4auwtiQqRhrWqwdBO6uEY2mwSnQWWTXcbfmt+MIteBS+FNWf/diGCBZm guvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PIOoV7FF; 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-142678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b30-20020a630c1e000000b005dcbb9ebe61si3162948pgl.821.2024.04.12.06.03.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 06:03:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PIOoV7FF; 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-142678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142678-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2E83AB2188E for ; Fri, 12 Apr 2024 13:03:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF6785F547; Fri, 12 Apr 2024 13:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PIOoV7FF" Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 0463155E4C for ; Fri, 12 Apr 2024 13:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927010; cv=none; b=tcZNwbRnOookFZO1YA9tjtgaBEmNJ3FAMUFnToXodX6QDY6yQbiUt+oG8AMRwotPYAUgrbpJgrElFyb2lpt4oitaAOxWUaAvt79Kr5Bqvj2UHM5z/mY4ysraMbfLXqAzKIM/YwvGuIDKPzRW9sKgSFNIUDgju4D/Kf+VfPf2A3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927010; c=relaxed/simple; bh=fLML18J7yDvY0kAxAiabw/PSTupFBpzee1x9+m9hqUo=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=TyC4rdrhkx+4duDhZ72/RDUBI+S09211dTNHffO7OrfZM8SWEWyt8Zl621Gewg4IyhZ/DvD7rxw5M7B3+gW2ZeVI8rLBGLHgVsb//P1GGT0hXySxECUlN36X+vpmTc47oyfmR8LENzGrzrBwcvH9O7NPU0udkbFc1NxozPdZ7OI= 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=PIOoV7FF; arc=none smtp.client-ip=209.85.208.180 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-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d485886545so13127161fa.2 for ; Fri, 12 Apr 2024 06:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712927007; x=1713531807; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=Nm8LSvH+A0aysY1LVMvbC5kt2UeJVTw7St9EkLFip3k=; b=PIOoV7FFVOm8A4CWOuxzb3QNZR8cJOuyjSqNu51RhhMd8U4G+uaOWmImwfaGdiBOio w+2QZCyenB6qUYgYtmsLvomJKH1T2N+Tq4RGLD01nDx7K8YionwRnua1B6FDeM/Di9Zb rqIYv9tXLHoVqLnOL5Cxn5mwDNSAlvpJTzm2aEPICKNUcR/mWITBjzWsI2CUwD5NzRwt JOJj520HZUN4IomzljoSKpFfhZeEt0CNzH2K0SlUMJKH3QV2lkTBylPRyXBsLA9Hgp4I w7C9sC4tB4WVQKJg2I2qLZa2GyyDuHBtCYyLMj7wqAZzYzGpUhVei+9rzfDqSspUmzzT j0mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712927007; x=1713531807; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Nm8LSvH+A0aysY1LVMvbC5kt2UeJVTw7St9EkLFip3k=; b=qCNFR74UIm++Cj8UMylv3lMUx8kHV9ta+kSlu85hV7chkq9pv16Gtbjjke5InsjN2B 4eVb/cvHR32x8CdRjP1Jw92f9/DP9jX4u0sV3cZQ03BsgzG5hwADWNZDK/2hh2Vf6p7S Yv+Jeefw0flylaOtZznkTgWTjLZrJ4KvuROHG3yX7HTSV5eJaynIVvBaa9yPeC4Ba9YL JBhX1sk2YbHtGBeZsj5TSPSE6X7t+1ouXCRlPlT0bssiCxxmtn6vw96BOWwtGZ8rOBHo yvEtc0fsTWrX/FQ3tIow5CI179bKyfpfS00TOTaUx4l8x5UBki2BMhKQxnBK5rvfxf0W 1EVw== X-Forwarded-Encrypted: i=1; AJvYcCV4HbjoQDwY+7tzW2tEBrGRdjtrVg7IAugMy8kBOO2YkKT/6YJt7XuSeA/uA5jAR3tgdkr+dZHyObEoayZSxPGvYmHKXVpha7eIVlMe X-Gm-Message-State: AOJu0Ywb7ykU90r6zeNqJZSTkcTFGhpL2h4eyOH2sGKh49yxBhFEUYLG mXW7uL1tAw0ASNSWbaSg00SXNXru03ko3L3fjNddkotqH6FguDz8aRIt5g+nFJ4= X-Received: by 2002:a2e:a545:0:b0:2d8:58b6:c10d with SMTP id e5-20020a2ea545000000b002d858b6c10dmr2214877ljn.18.1712927006961; Fri, 12 Apr 2024 06:03:26 -0700 (PDT) Received: from ?IPV6:2a01:e0a:982:cbb0:986c:54c:12ce:a121? ([2a01:e0a:982:cbb0:986c:54c:12ce:a121]) by smtp.gmail.com with ESMTPSA id n9-20020a05651c000900b002d2697570fcsm502800lja.93.2024.04.12.06.03.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Apr 2024 06:03:26 -0700 (PDT) Message-ID: <00b0e513-bb8a-4db7-aa8e-57632add4752@linaro.org> Date: Fri, 12 Apr 2024 15:03:22 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Neil Armstrong Reply-To: neil.armstrong@linaro.org Subject: Re: [PATCH v12 4/7] drm/meson: gate px_clk when setting rate To: Martin Blumenstingl Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Kevin Hilman , Michael Turquette , Stephen Boyd , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jagan Teki , Nicolas Belin , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org References: <20240403-amlogic-v6-4-upstream-dsi-ccf-vim3-v12-0-99ecdfdc87fc@linaro.org> <20240403-amlogic-v6-4-upstream-dsi-ccf-vim3-v12-4-99ecdfdc87fc@linaro.org> Content-Language: en-US, fr Autocrypt: addr=neil.armstrong@linaro.org; keydata= xsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIH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E3gTCS KmbUuLv1CtxKQF+fUV1cVaTPMyT25Od+RC1K+iOR0F54oUJvJeq7fUzbn/KdlhA8XPGzwGRy 4zcsPWvwnXgfe5tk680fEKZVwOZKIEuJC3v+/yZpQzDvGYJvbyix0lHnrCzq43WefRHI5XTT QbM0WUIBIcGmq38+OgUsMYu4NzLu7uZFAcmp6h8g Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/04/2024 21:34, Martin Blumenstingl wrote: > Hi Neil, > > On Wed, Apr 3, 2024 at 9:46 AM Neil Armstrong wrote: >> >> Disable the px_clk when setting the rate to recover a fully >> configured and correctly reset VCLK clock tree after the rate >> is set. >> >> Fixes: 77d9e1e6b846 ("drm/meson: add support for MIPI-DSI transceiver") >> Signed-off-by: Neil Armstrong >> --- >> drivers/gpu/drm/meson/meson_dw_mipi_dsi.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/gpu/drm/meson/meson_dw_mipi_dsi.c b/drivers/gpu/drm/meson/meson_dw_mipi_dsi.c >> index a6bc1bdb3d0d..a10cff3ca1fe 100644 >> --- a/drivers/gpu/drm/meson/meson_dw_mipi_dsi.c >> +++ b/drivers/gpu/drm/meson/meson_dw_mipi_dsi.c >> @@ -95,6 +95,7 @@ static int dw_mipi_dsi_phy_init(void *priv_data) >> return ret; >> } >> >> + clk_disable_unprepare(mipi_dsi->px_clk); > nit-pick: clk_disable(mipi_dsi->px_clk); should be enough here as my > understanding is that we only need to {un,}prepare a clock once. > >> ret = clk_set_rate(mipi_dsi->px_clk, mipi_dsi->mode->clock * 1000); >> >> if (ret) { >> @@ -103,6 +104,12 @@ static int dw_mipi_dsi_phy_init(void *priv_data) >> return ret; >> } >> >> + ret = clk_prepare_enable(mipi_dsi->px_clk); >> + if (ret) { >> + dev_err(mipi_dsi->dev, "Failed to enable DSI Pixel clock (ret %d)\n", ret); >> + return ret; > If we ever hit this error case then there will be a lot of additional > errors in the kernel log: > - initially the clock is prepared and enabled in > meson_dw_mipi_dsi_probe() by calling devm_clk_get_enabled() > - we then disable the clock above (generally disabling a clock is > expected to always succeed) > - if the clock can NOT be re-enabled here we just log the error > - in case a user tries to rmmod the driver (to modprobe it again) to > try and recover from an error the automatic disabling of the pix_clk > (based on devm_clk_get_enabled() where it was enabled initially) there > will be a splat because the clock is already disabled (and enabled > count is zero, so it cannot be disabled any further) > > For the 32-bit SoC video clocks I keep track of them being enabled or > disabled, see [0], [1] and [2]. > In my case this is important because we can run into cases where the > PLL doesn't lock (I am not sure how likely this is for your case). > > It *seems* like we need to do something similar as > dw_mipi_dsi_phy_init() can be called when changing the display > resolution (or whenever drm_bridge_funcs.atomic_pre_enable) is called. > To illustrate what I have in mind I attached a diff (it's based on > this patch) - it's compile tested only as I have no DSI hardware. > In case dw_mipi_dsi_phy_init() is called only once per device > lifecycle things may get easier. Indeed your scheme looks good, I'll try it since indeed we only need to prepare it once in the lifetime of the driver. > > PS: I'm so happy that we don't need any clock notifiers for this! > So: good work with the clock driver bits. Thx ! > > > Let me know what you think, > Martin > > > [0] https://github.com/xdarklight/linux/blob/meson-mx-integration-6.9-20240323/drivers/gpu/drm/meson/meson_vclk.c#L1177-L1179 > [1] https://github.com/xdarklight/linux/blob/meson-mx-integration-6.9-20240323/drivers/gpu/drm/meson/meson_vclk.c#L1077 > [2] https://github.com/xdarklight/linux/blob/meson-mx-integration-6.9-20240323/drivers/gpu/drm/meson/meson_vclk.c#L1053