Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp13971rdb; Fri, 5 Jan 2024 00:40:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHWqqAAaNAqY0wO0zVhlccedhOffJzQXixitXwVN4dJczw09CK4dK8kF9FVGY6s2zgsnt+ X-Received: by 2002:a05:6358:52c6:b0:175:611a:8e94 with SMTP id z6-20020a05635852c600b00175611a8e94mr2078592rwz.55.1704444017530; Fri, 05 Jan 2024 00:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704444017; cv=none; d=google.com; s=arc-20160816; b=KJXF988zQOxgXLuypiA1ZEvJ2pfugBJFiqdXsIWuXYeUNFalK+qn7pCFuF1NI8scy4 gx9DEFmH42M+9YrWR40B3NVO1PEvp//5RSMXlYFF8jqXN1NIkBLcctZpMvRFWvZe8+hG 9rgCQCZRFLk8/pFIYB0+mkm286FofthNBY6vCvjVszPh7RofDn5JuDv7drwKVRMeyxm4 6qw/Nj5vLeBuCux6rgcf0cvuyB1rsWFiIR39+yxEp2ZDUMwt7HuJsF5wqUv07S9BsvRP stbch8l/vOTcWUwRQLUYz33nVLw/mLwkr9qeK5xUU1MpVMLPXdhh3z/EfQC2tKa+TSqt LEvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=8hYTNkHTn/zV3BgYDxe7QnouYI4dlQvnLZozWj8iLVc=; fh=qRg784gGTFR9ShcOak5ACiDlpqXSuGbTV+ouLQD1lgM=; b=e87CPraSKadfjEAiAPxl43ZE9LmMqKEkUyN5gdhaN8ClMOnS3/F2CdiNh+6jXe2Eb2 reXy+VpupXjMOx2SXwl93WB4q9Zs42Y2QvwPNcgCziYw5lGYyYj7YV9MqI2tyGdmyHQS bc8lTjhtEqDiVWfIrMkgLNhA6PMGGDHMIzX4TROHLxaCihR5g8nd/PpCgPVQ+f7zPaPm R1W0m/qatKU/lR6AH+zbQ5EcNxn4Hx5vpa8Ro+O3v37LZ+PPzNHfpYpqdm5yhrbJVcLP 5ojwGQflkcjGit4FDtYYoBiWBsA2RjKtqeP8NCVaeXSMxhDaqPz2B41KBNMs/xHbhYsg 07JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PWRVAEeG; spf=pass (google.com: domain of linux-kernel+bounces-17607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 z3-20020a633303000000b005c693ea6618si927418pgz.523.2024.01.05.00.40.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17607-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=@chromium.org header.s=google header.b=PWRVAEeG; spf=pass (google.com: domain of linux-kernel+bounces-17607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 2C1A3284357 for ; Fri, 5 Jan 2024 08:40:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ACFF21376; Fri, 5 Jan 2024 08:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PWRVAEeG" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.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 C1FD0219FE for ; Fri, 5 Jan 2024 08:40:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-3606ebda57cso1663375ab.2 for ; Fri, 05 Jan 2024 00:40:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1704444006; x=1705048806; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8hYTNkHTn/zV3BgYDxe7QnouYI4dlQvnLZozWj8iLVc=; b=PWRVAEeGlxA8QXY+YfFjBK53ZxGIpi39YdCIZ2eQO3ZK3yEapdOZSPhSQFytjwNnX6 GcMTvzbTnbwHE6atKoiZuBBUpP2CVL1OWxpAI3hUjFmu/Z5vUOjW+xcDnvwSV043EfVP VLoeReGCrdG+yzn6eESJcXFK5wr2Q+JAOVSLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704444006; x=1705048806; h=content-transfer-encoding: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=8hYTNkHTn/zV3BgYDxe7QnouYI4dlQvnLZozWj8iLVc=; b=O0+e3R/7788NOn2ptxgVcjIEN8PGvuRcyAOye9KjAgh224PtRBp0043wZACKFAUNyA XQ5GC/99fERK9qBGRMBZnb4SzAOfs6x5mQMHMKWU32+dRr/rj7hZbzExFzexgNFlsizW tW13zEIiabJtYlWfdpqBGXrQ0ZomgGnv7mt+Bu1euCuMaAYnMJR9BQ1kPmoqbgS0/Yud isrol3Inf6NI/VseVofjVhcRi4Z8evsGum9atzojQ6nxrTSp8jUaOTXyidMEHD48P8wF xle/O6b4ezQgn7yJL1c22OUY4ktsyO+cqgXJO9JAKEA0IrIdK5oBFVWaYZqjbTNXr8+S lpjQ== X-Gm-Message-State: AOJu0YyJdOpmajmh23PUYQmS/pjLboHEjJAyAJ1HwkLdazIpKedN5cZL k7H2z1pVkOaFdDLqiPaqGxI92kujX122hJLVUQKiWFgncWrB X-Received: by 2002:a05:6e02:1aac:b0:35f:ea02:7491 with SMTP id l12-20020a056e021aac00b0035fea027491mr2019344ilv.60.1704444005875; Fri, 05 Jan 2024 00:40:05 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240102081402.1226795-1-treapking@chromium.org> <5520e8e3-c75b-480f-b831-c40b5cca029f@collabora.com> In-Reply-To: From: Pin-yen Lin Date: Fri, 5 Jan 2024 16:39:55 +0800 Message-ID: Subject: Re: [PATCH v2 1/2] clk: mediatek: Introduce need_pm_runtime to mtk_clk_desc To: Eugen Hristev , AngeloGioacchino Del Regno Cc: Michael Turquette , Stephen Boyd , Matthias Brugger , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Weiyi Lu , linux-mediatek@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 4, 2024 at 10:51=E2=80=AFPM Pin-yen Lin wrote: > > Hi Eugen and Angelo, > > Unfortunately, I don't have a way to reliably reproduce this either. > > We notice this issue from the automatic crash reports sent from the > users, but we are still not able to reproduce this locally. So our > plan is to ship this patch to the users and see if the crash rate goes > down after a month or so. > > Regards, > Pin-yen > > On Wed, Jan 3, 2024 at 9:20=E2=80=AFPM Eugen Hristev > wrote: > > > > On 1/3/24 14:19, AngeloGioacchino Del Regno wrote: > > > Il 02/01/24 09:12, Pin-yen Lin ha scritto: > > >> Introduce a new need_pm_runtime variable to mtk_clk_desc to indicate > > >> this clock needs a runtime PM get on the clock controller during the > > >> probing stage. > > >> > > >> Signed-off-by: Pin-yen Lin > > > > > > Hello Pin-yen, > > > > > > We have experienced something similar, but it was really hard to repr= oduce after > > > some changes. > > > > > > In an effort to try to solve this issue (but again, reproducing is re= ally hard), > > > Eugen has sent a commit in the hope that someone else found a way to = easily > > > reproduce. Please look at [1]. > > > > > > I'm also adding Eugen to the Cc's of this email. > > > > > > Cheers, > > > Angelo > > > > > > [1]: > > > https://patchwork.kernel.org/project/linux-pm/patch/20231225133615.78= 993-1-eugen.hristev@collabora.com/ > > > > Hello Pin-yen, > > > > Can you try my patch and let me know if this changes anything for you ? > > > > If it does not change anything, can you also try this one as well ? It'= s another > > attempt to fix the synchronization with genpd. > > > > https://lore.kernel.org/linux-arm-kernel/20231129113120.4907-1-eugen.hr= istev@collabora.com/ > > > > Thanks, > > Eugen Hi Eugen and Angelo, After the offline discussion with Chen-yu, we think this series is solving a different issue from the patches you mentioned. This one is trying to resolve a deadlock in the probe stage, and more details can be found in the commit message of the next patch. The referenced patches seem to be fixing other race conditions on powering on/off the power domain. Sorry for adding the wrong commit message and maybe leading to incorrect understanding on this series. By the way, sorry for the top posting in the previous mail. Regards, Pin-yen > > > > > > > >> --- > > >> > > >> Changes in v2: > > >> - Fix the order of error handling > > >> - Update the commit message and add a comment before the runtime PM = call > > >> > > >> drivers/clk/mediatek/clk-mtk.c | 15 +++++++++++++++ > > >> drivers/clk/mediatek/clk-mtk.h | 2 ++ > > >> 2 files changed, 17 insertions(+) > > >> > > >> diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/c= lk-mtk.c > > >> index 2e55368dc4d8..c31e535909c8 100644 > > >> --- a/drivers/clk/mediatek/clk-mtk.c > > >> +++ b/drivers/clk/mediatek/clk-mtk.c > > >> @@ -13,6 +13,7 @@ > > >> #include > > >> #include > > >> #include > > >> +#include > > >> #include > > >> > > >> #include "clk-mtk.h" > > >> @@ -494,6 +495,14 @@ static int __mtk_clk_simple_probe(struct platfo= rm_device *pdev, > > >> return IS_ERR(base) ? PTR_ERR(base) : -ENOMEM; > > >> } > > >> > > >> + > > >> + if (mcd->need_runtime_pm) { > > >> + devm_pm_runtime_enable(&pdev->dev); > > >> + r =3D pm_runtime_resume_and_get(&pdev->dev); > > >> + if (r) > > >> + return r; > > >> + } > > >> + > > >> /* Calculate how many clk_hw_onecell_data entries to allocate *= / > > >> num_clks =3D mcd->num_clks + mcd->num_composite_clks; > > >> num_clks +=3D mcd->num_fixed_clks + mcd->num_factor_clks; > > >> @@ -574,6 +583,9 @@ static int __mtk_clk_simple_probe(struct platfor= m_device *pdev, > > >> goto unregister_clks; > > >> } > > >> > > >> + if (mcd->need_runtime_pm) > > >> + pm_runtime_put(&pdev->dev); > > >> + > > >> return r; > > >> > > >> unregister_clks: > > >> @@ -604,6 +616,9 @@ static int __mtk_clk_simple_probe(struct platfor= m_device *pdev, > > >> free_base: > > >> if (mcd->shared_io && base) > > >> iounmap(base); > > >> + > > >> + if (mcd->need_runtime_pm) > > >> + pm_runtime_put(&pdev->dev); > > >> return r; > > >> } > > >> > > >> diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/c= lk-mtk.h > > >> index 22096501a60a..c17fe1c2d732 100644 > > >> --- a/drivers/clk/mediatek/clk-mtk.h > > >> +++ b/drivers/clk/mediatek/clk-mtk.h > > >> @@ -237,6 +237,8 @@ struct mtk_clk_desc { > > >> > > >> int (*clk_notifier_func)(struct device *dev, struct clk *clk); > > >> unsigned int mfg_clk_idx; > > >> + > > >> + bool need_runtime_pm; > > >> }; > > >> > > >> int mtk_clk_pdev_probe(struct platform_device *pdev); > > > > > > > > > > > > > >