Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8194799rwi; Tue, 25 Oct 2022 03:50:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM418JB4lXkg7OjgXUj2FaE93gcAREfc+xGh3TpHGzsGHof2OqlF0WeaQQy0reATj7BRWMoN X-Received: by 2002:a05:6402:348b:b0:45c:b22b:c4a9 with SMTP id v11-20020a056402348b00b0045cb22bc4a9mr36015524edc.65.1666695016852; Tue, 25 Oct 2022 03:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666695016; cv=none; d=google.com; s=arc-20160816; b=O7jP1GDZm2wQ6TXB5lNr0oKvgDqHJqv2eg0hS/+HU9EpyeIHTNr5KVqbL25aak5XN7 hUAKTLRKwZpSkf5R67OW8KbHN9hlu9qYIMPMVxvnLhHtmo6Dl4TTHo/dK91SAgYbz/cF g2J7doo4di33lBTRTTUqMFjGKG73/jdqoUFSVRoXYsvlQHxKLQ0Jfhu969xJ1GqhA3ZD QAZanFEdbA2EwON9RKOdmXkgbzJfgfDoGTYkRwkbtvgWcFiBVKAqPHF/OT6uF+hGwmYG qnTR3hLxCrdM3/E8nQJBsVW1yI4KzNaOLJhSPSb6hDktzxbduOu4236lbLGVW2uRaq0P rY1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VQczvz+g3URTXPLukX1U3rCOQSu42hoB10XM7APyb7Q=; b=pK8P3DYdCU0TgFdk0fyjY0SuoYBuFwMOdvSQhA6QYS/VD8eLCYCW0B04oxHKWm9eIT 49O9h3RXbElbtatsi2kuBFZ8f6KsfVzjMCkuJihnFwIgXLtq+TxfqfhVJw4ALHATxkUM inI9R7ZVu3BQ+jgzH9fwtl3KuONXSbAocNTpk48h5XuPboMsP5mtNuoZEpUHhcLpJKdV 89F/jGfcpf7OWFfgg1fuAEr+tbjuKR4O/2oJmF98gnfNq/C3MCP7ABTr43nIKGf9C8z6 /7cdO04Cc2bkmRBQvCQLSULuuIC8bkcatgNCPYSvN6jHyHL5O5ZcxNc6XuOCIvJHE9Vl OHcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aNxRpUtz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u19-20020a1709067d1300b00711da52c6e4si2217620ejo.309.2022.10.25.03.49.49; Tue, 25 Oct 2022 03:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aNxRpUtz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbiJYKWN (ORCPT + 99 others); Tue, 25 Oct 2022 06:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbiJYKVd (ORCPT ); Tue, 25 Oct 2022 06:21:33 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2558713669F; Tue, 25 Oct 2022 03:18:47 -0700 (PDT) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 38415660239C; Tue, 25 Oct 2022 11:18:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1666693125; bh=oPF1o7oWPbryY18wvQiyqLyaSGkoOyYT6E+3DLkyLxs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aNxRpUtzvLMgc0F9bQ4w3Pla8RcdaRHv8Cryqkg+evUgzf2jE9kuUy6pcnO1hkucl Jxs+diruWGkYOA5oU2Ydei2qtQTk2zOPW8nOwQ9P6wgrPpb1tnG0ghdJUGwuzOoFA4 +OuqXMVALz5ew3SouzOGDkE75nmFAkIzvs5/N7157pve+pFQ72TchQWZvqYE0G2ywj XP9Ek3H4XfIEHoEw6kSfPSsCX0Im0z7EL2shxzG0l9lTgD2le5qep7g43dQBdxqEse 4kvlwIAGfvJBU13l1Y3aXlo/y8+BThw2hlbrBHzTRyfMALtthobTNh9w44it19NZhX bYp2HlOWhlALQ== Message-ID: <473d67ed-198f-82c6-9f32-5827c1f8c852@collabora.com> Date: Tue, 25 Oct 2022 12:18:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v2 03/12] ASoC: mediatek: mt8188: support audsys clock Content-Language: en-US To: =?UTF-8?B?VHJldm9yIFd1ICjlkLPmlofoia8p?= , "robh+dt@kernel.org" , "matthias.bgg@gmail.com" , "p.zabel@pengutronix.de" , "broonie@kernel.org" , "tiwai@suse.com" Cc: "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "alsa-devel@alsa-project.org" , Project_Global_Chrome_Upstream_Group , "devicetree@vger.kernel.org" References: <20221021082719.18325-1-trevor.wu@mediatek.com> <20221021082719.18325-4-trevor.wu@mediatek.com> <776557c0fda5a538549ee0d4f4b7f482b0d69934.camel@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <776557c0fda5a538549ee0d4f4b7f482b0d69934.camel@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 21/10/22 11:58, Trevor Wu (吳文良) ha scritto: > On Fri, 2022-10-21 at 10:41 +0200, AngeloGioacchino Del Regno wrote: >> Il 21/10/22 10:27, Trevor Wu ha scritto: >>> Add mt8188 audio cg clock control. Audio clock gates are registered >>> to CCF >>> for reference count and clock parent management. >>> >>> Signed-off-by: Trevor Wu >>> --- >>> sound/soc/mediatek/mt8188/mt8188-audsys-clk.c | 206 >>> ++++++++++++++++++ >>> sound/soc/mediatek/mt8188/mt8188-audsys-clk.h | 15 ++ >>> .../soc/mediatek/mt8188/mt8188-audsys-clkid.h | 83 +++++++ >>> 3 files changed, 304 insertions(+) >>> create mode 100644 sound/soc/mediatek/mt8188/mt8188-audsys-clk.c >>> create mode 100644 sound/soc/mediatek/mt8188/mt8188-audsys-clk.h >>> create mode 100644 sound/soc/mediatek/mt8188/mt8188-audsys- >>> clkid.h >>> >>> diff --git a/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c >>> b/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c >>> new file mode 100644 >>> index 000000000000..1f294231d4c2 >>> --- /dev/null >>> +++ b/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c >>> @@ -0,0 +1,206 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +/* >>> + * mt8188-audsys-clk.c -- MediaTek 8188 audsys clock control >>> + * >>> + * Copyright (c) 2022 MediaTek Inc. >>> + * Author: Chun-Chia Chiu >>> + */ >>> + >>> +#include >>> +#include >>> +#include >>> +#include "mt8188-afe-common.h" >>> +#include "mt8188-audsys-clk.h" >>> +#include "mt8188-audsys-clkid.h" >>> +#include "mt8188-reg.h" >>> + >>> +struct afe_gate { >>> + int id; >>> + const char *name; >>> + const char *parent_name; >>> + int reg; >>> + u8 bit; >>> + const struct clk_ops *ops; >>> + unsigned long flags; >>> + u8 cg_flags; >>> +}; >>> + >>> +#define GATE_AFE_FLAGS(_id, _name, _parent, _reg, _bit, _flags, >>> _cgflags) {\ >>> + .id = _id, \ >>> + .name = _name, \ >>> + .parent_name = _parent, \ >>> + .reg = _reg, \ >>> + .bit = _bit, \ >>> + .flags = _flags, \ >>> + .cg_flags = _cgflags, \ >>> + } >>> + >>> +#define GATE_AFE(_id, _name, _parent, _reg, _bit) \ >>> + GATE_AFE_FLAGS(_id, _name, _parent, _reg, _bit, \ >>> + CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, >>> CLK_GATE_SET_TO_DISABLE) >> >> Can you please explain what's the reason for CLK_IGNORE_UNUSED here? >> Maybe we can solve some issue that you're facing in a cleaner way. >> >> Regards, >> Angelo > > Hi Angelo, > > Because clk_disable_unused() calls clk_core_is_enabled(), register > access happens in is_enabled() ops. > At the moment, the power for register access is not enabled, so the > register read results in CPU hang. > > That's why I added CLK_IGNORE_UNUSED here, but it can't resolve all > issues. Actually, we met same problem when "cat > /sys/kernel/debug/clk/clk_summary" is used. We are still suffering the > problem. > > I'm not sure if I can implement clk ops by myself, and exclude the > registration of is_enabled() ops. > Is the power for register access enabled with a power domain? Check drivers/clk/clk.c, grep for core->rpm_enabled. If you enable runtime PM before registering the clocks, and you register them with the right struct device, the clock API will enable power for you before trying to read the clock enable status. Regards, Angelo