Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2409380lqt; Mon, 22 Apr 2024 09:51:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTGbidCmeDCpXvPYkXiw4hr4X+OVlAPm52h1ibKO83uXmWZnfYpPEdhhrw1fADEQP4gR/EvQah32DvQIgIZVhXPVQ3KVYiHGNu1sRSWw== X-Google-Smtp-Source: AGHT+IGKxPpOVF3bCcU11Ss3Ps5HRLYLrcb+VD6gzX0lCWDxefwmgElVPJ4Cy8hf/6aggzXvBm/U X-Received: by 2002:a17:907:1183:b0:a52:3ca9:9bda with SMTP id uz3-20020a170907118300b00a523ca99bdamr201256ejb.22.1713804715305; Mon, 22 Apr 2024 09:51:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713804715; cv=pass; d=google.com; s=arc-20160816; b=QbT3mxgjpRb36GWxoDfMuq/31lYOBH5GbToKu2cE5grg8qFNZNBQH6SOhdTVBC5tjw pkDYfQC5ERVAbUkUC8dJnSpKgujM4fiuIDDXDwQmweysyDoCMFGZLBvPR03h1tDUHKEV JUBSXVQzo3/ck7YQ12islsvnIB5NOmB7fKP+5x9C6hhci7VJvCTNy/Zz5YIeeMAaW0Tu QNbOW7Hw05AzVexeiWFEEiQFYSSRz7ROaIvH2+HJdG5Tqtw3gK/C3otJjb6DrNySX3ir g8QnNCv120jov8m5G2iMqbsOyMuTmj92laBPcOFX9hPYkg53NgFql3m1M/JB7208dRBT 0Rgw== 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=EJE4rl1eEAUqGfBZC2SJPu8F2JMT82hT5pkxBZ1KzUY=; fh=Hacb0rKBRDtKA4XgBPbRTRXfNtlXmRUn9+qSWngQKck=; b=dhgnh0aJp3c0m/kTI4ctgA14W64gYx1T9ffQftT7FmZw0u6RQDkRHyJkhvO/UtWuh0 oF8OV9J+yO17hBEKoSBTInUt3rmycGRuar2bxacb8zgukyN7Q/GAE1OEeiYj5XMSc7Fg BPTZ2wZ5MSAX5Urljfr41GDdFeJZ2fHT2JknD7b+UabjQS4er1W2xADvW7NLyJyWPGVz /vi8p1zJEazVBECImG3LusAcSwuDOJ6iMUPTqdhPgyakV4fhV8KVatz7dh29NHroRpK5 NYZd6A59+lu6msnHdmCpXPLGIZyLOdnncdF7QJe6Lp9biOfuM6JfymzUxMOg9kg17jEh inmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mDwYwW8v; 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-153753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kj7-20020a170907764700b00a57bf8b57fdsi485028ejc.383.2024.04.22.09.51.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 09:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mDwYwW8v; 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-153753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153753-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2923C1F21B86 for ; Mon, 22 Apr 2024 16:51:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7CB5153831; Mon, 22 Apr 2024 16:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mDwYwW8v" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 0AAE32EB11 for ; Mon, 22 Apr 2024 16:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713804702; cv=none; b=rA4BXK5kWWLzOIwDo7iBvDnOFZ0nQVh1GsIIMQNTTu4KNA5iOGxyAe3y7ohi3O/4Y1o1YuNYyjxJSINLEhJ8bXjCB2xOnZ+OK097iUd66BQkYibXSaVstgGRDIlIHME9MenKsr6pTxER/zXtp3NKRJnTD0ZFnjZGeZqPbHMUHkQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713804702; c=relaxed/simple; bh=tVqTYD1FvxyKRph9YfxGJap4Bei1YEEakxE59J2eS8c=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=TUeo+0NaFAmYokqdqkU0eoFZbqcB3wmF1hYqOPXQXrG76opc2LSEfX2FDe9Hqag0m4I3XDLU4it5O3oyFfYx4d2xlhazX0E4l0UGeHPKs6yqUvlRBfqiLdvzbQks4LoA+qL70jkQSgwfsL4mDgkJ6TJ/LLoJOwm9qzhy4geGtBQ= 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=mDwYwW8v; arc=none smtp.client-ip=209.85.128.45 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-wm1-f45.google.com with SMTP id 5b1f17b1804b1-41a1d2a7b81so9070875e9.0 for ; Mon, 22 Apr 2024 09:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713804698; x=1714409498; 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=EJE4rl1eEAUqGfBZC2SJPu8F2JMT82hT5pkxBZ1KzUY=; b=mDwYwW8vc4RSNt8jpwHE+5EIojxVjaHPoBiB+p9cKX1Vrl1z+kEkpPNx0K5NJiqHBR oMFabc3SxFOm5YXJKhexNUtjm+reMLdlvtC18va2jbFqlkIY2cekQCwnYqkJFVkgTHZ+ wsEJvg1lpsUKNLBXPtRb3w2ir+e++MC3hZkH7OvE+x6xQ9p6WettBFskWnaErL3MKUjS hVuEioWpj1Dw5dbsID92lXJgznEZvr+vU8C/ugmtUXjlkMnXym3b56aY+dl7vq/qo613 GCc8gyQEvPIYpXtfNND6uFxZ44VVRqnP1THqLo4XV8yUZTYvOpYDCrL+fqL9tzC548vT K84A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713804698; x=1714409498; 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=EJE4rl1eEAUqGfBZC2SJPu8F2JMT82hT5pkxBZ1KzUY=; b=GxxJSEqnPNeYuIW8f9vFgtPBiJt/GHH7vg7lg/MZ2u61XoNUnJqI3Fl1cyZC4Pd4IU Cq2VT6Tg2CIvzQ3vXYNj6x8Jjcrig1n9AOKjs4BGu0DEJWzBSLFQfqpteDq8SkXu4rgp Hv4L97aeRfhEYbi6kDjs/rBGu9G5AnkTsDySiZ3d/9NqZ1YYqKpHbGVDOjTVfuFlRp66 H1I+Sxk+fQ7X0ZbhTcD0m93zJFyFmJTesr693F173C2l7ZprAFoskUTOlMiQ2vuA3joy RvfhKNSEDWHkln6L3YCJ1X+F9hA34k4pzfD4IX85p+Y20zC/GGUgJp2dG0wqWt3/jB5K OmAw== X-Forwarded-Encrypted: i=1; AJvYcCUg78TTgjcrbim4n2AX5BuKXJhn/B7ypsZAY45poawAJoNl5VH+/AA4M2u/4IR+iTvZqs+06SnyKOOd1WCvgAoVrJ5huvcHTgYZH/Dw X-Gm-Message-State: AOJu0YwtY3UX3x58t4SVeVj/PKuM101qTX0t3K+mh1sY4x0C1Gh2rArJ qluITyR8tisIVR/z/WohAwZhkENzB0Ik8IU6gl8Jbgzgu6Uaee8+qskBLGf1f90= X-Received: by 2002:a05:600c:a05:b0:41a:5d49:97e9 with SMTP id z5-20020a05600c0a0500b0041a5d4997e9mr157502wmp.9.1713804698013; Mon, 22 Apr 2024 09:51:38 -0700 (PDT) Received: from ?IPV6:2a01:e0a:982:cbb0:e5e5:892f:e81f:7cad? ([2a01:e0a:982:cbb0:e5e5:892f:e81f:7cad]) by smtp.gmail.com with ESMTPSA id fc14-20020a05600c524e00b004161af729f4sm17228944wmb.31.2024.04.22.09.51.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Apr 2024 09:51:37 -0700 (PDT) Message-ID: Date: Mon, 22 Apr 2024 18:51:36 +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/3NU3oti3nrIHmHABEB AAHNKk5laWw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txKQF+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 Hi Martin, 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. > > PS: I'm so happy that we don't need any clock notifiers for this! > So: good work with the clock driver bits. I checked and tested your patches and it doesn't work because the pc_clk needs to be disabled & prepared in order to correctly reset and setup again the video clock tree. dw_mipi_dsi_phy_init() is called at each DSI mode change, but it requires a full clock tree recalc and reset, so it's safer to keep the current design. I'll try to send a change to better handle the disable_unprepare() failure, but definitely only calling clk_disable() wasn't enough. Thanks, Neil > > > 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