Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2372328rwd; Wed, 14 Jun 2023 01:42:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7P/dWNFTrgrvLu8iRlXABkpxcbWUbiRCowySF8/jet9XFCGEaimAMUjx9TkbVKfLz9W0uk X-Received: by 2002:a05:6358:c10f:b0:129:cf92:6908 with SMTP id fh15-20020a056358c10f00b00129cf926908mr7686375rwb.21.1686732152515; Wed, 14 Jun 2023 01:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686732152; cv=none; d=google.com; s=arc-20160816; b=V9zPYVn9l8K/LQcXDR4IS1uTZxtfxPGftABRg6kXG2C6JqrVrLZtOwFvCmQNvMO1zp 6pNDxQU3AD2kZ5G6bKREEAR7hr0bPJqGfjtDhFDPxZ6yVd8pWObsjIjcm2wjn3m2bHiz EcfITvhbKl6YVXjWwHm3Tyt7pfSmvCAG3pSIiTx6jpPmgEDODofhyLITbhqWquR2XkMu DIynZtqTuB0KUX6Xy1SS9Ij6NcCT3Fp/xF6c/sKFRuzlVl9E3xlBboTjvtkqhIDtNHeC 8/GmnHH9iqDYPty6e18TjfqMVL+YJ4QcWSpYW6AVOJSK5OqzBYYjWLqjVMcMmPWKzUIp +1qg== 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=c6mbYVsucPtb8Fgp96u8s1FWtpBEzsGwPtcwS4cvfFs=; b=vx7Zud9kx7FXFXxfMDZwD1fBkqsElLpsUVal4KhmXeRlBA8XvUTPd8muJpHrHB6Fhe AW0B/gOr8xRt+VZYUwqQ/IiGO2i8MoMtyPL2sax/O6by1gjqqqJAHkGhjWvB4eDR14LA MRfqxDTfA7Sy/8j0RvOgY/YFzq/Cuj3aumMO7+BTimeEWDZiTLWcIgjnMi69Ri4sUlAA urfPYX/GhkUmuO5SuSMLJa9n+Btx+wjJF/LtzuWe7SB0fRoqKyPHUYml1/88phvY8LVt ZdCnsysMpOOlK/hBMQ3cZK5ci39LRGXp+47bMbJpiN086JtzSqL0Bf0Zo436W9VwqmVn ryUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nJFxFvrV; 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=QUARANTINE sp=QUARANTINE 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 az9-20020a056a02004900b005404f8dd0e8si10286637pgb.215.2023.06.14.01.42.20; Wed, 14 Jun 2023 01:42:32 -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=nJFxFvrV; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242548AbjFNINv (ORCPT + 99 others); Wed, 14 Jun 2023 04:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbjFNINt (ORCPT ); Wed, 14 Jun 2023 04:13:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62D4FDF; Wed, 14 Jun 2023 01:13:48 -0700 (PDT) Received: from [IPV6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2] (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 183A2660217A; Wed, 14 Jun 2023 09:13:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686730426; bh=hyikFg5Dz7zmi/EIssCCeZgYJGF+cMu28Xs3zEK/yXg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nJFxFvrVLB3tCXlMcGaXRilrFAQLRM/fy7Vi1Bi3RXUVY74Y1Vglz24j4iFuelm15 OjYBDuIBDQXiu7iBFiNWZvn48twBqLM39gOIO/kOYV1IGaPL+ysUQvuZY6uXPcSZAq RrpNUIGxEws9kQWdSwZWb0IK1/D8iJYA7gy3PNnxw07/WkvfkU1JebbpJj28/BBsRz jNC/a1xM1l44nT64E73hbb8BEPMt5uX5tJLbYUDJE53kCiGtg6rtF+fG3LyvZN12vc DrkmYUhO5LrIDa1btKYJjTY/5XJ7+JxD8Ul/hPasZ+PftQ8PTn7vdVjb8jGG/NycYN NkyaqbxadSoOA== Message-ID: Date: Wed, 14 Jun 2023 10:13:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v2 3/5] media: mediatek: vcodec: Read HW active status from clock Content-Language: en-US To: Stephen Boyd , Chen-Yu Tsai , =?UTF-8?B?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Cc: Matthias Brugger , Hans Verkuil , kernel@collabora.com, Andrew-CT Chen , Mauro Carvalho Chehab , Tiffany Lin , Yunfei Dong , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org References: <20230607205714.510012-1-nfraprado@collabora.com> <20230607205714.510012-4-nfraprado@collabora.com> <83770481aa762b69738c27f9d9934dd9.sboyd@kernel.org> <90781ea3-d43a-6267-278c-184050fe456e@collabora.com> From: AngeloGioacchino Del Regno In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,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 12/06/23 21:19, Stephen Boyd ha scritto: > Quoting AngeloGioacchino Del Regno (2023-06-09 00:42:13) >> Il 09/06/23 01:56, Stephen Boyd ha scritto: >>> Quoting AngeloGioacchino Del Regno (2023-06-08 02:01:58) >>>> Il 08/06/23 10:12, Chen-Yu Tsai ha scritto: >>>>> On Thu, Jun 8, 2023 at 4:57 AM Nícolas F. R. A. Prado >>>>> wrote: >>>>>> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c >>>>>> index 9c652beb3f19..8038472fb67b 100644 >>>>>> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c >>>>>> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c >>>>> >>>>> AFAIK this is still around for clk drivers that haven't moved to clk_hw. >>>>> It shouldn't be used by clock consumers. Would it be better to just pass >>>>> a syscon? >>>>> >>>> >>>> This is a legit usage of __clk_is_enabled().... because that's what we're really >>>> doing here, we're checking if a clock got enabled by the underlying MCU (as that >>>> clock goes up after the VDEC boots). >>>> >>>> If this is *not* acceptable as it is, we will have to add a clock API call to >>>> check if a clock is enabled... but it didn't seem worth doing since we don't >>>> expect anyone else to have any legit usage of that, or at least, we don't know >>>> about anyone else needing that... >>> >>> The design of the clk.h API has been that no clk consumer should need to >>> find out if a clk is enabled. Instead, the clk consumer should enable >>> the clk if they want it enabled. Is there no other way to know that the >>> vcodec hardware is active? >>> >> >> The firmware gives an indication of "boot done", but that's for the "core" part >> of the vcodec... then it manages this clock internally to enable/disable the >> "compute" IP of the decoder. >> >> As far as I know (and I've been researching about this) the firmware will not >> give any "decoder powered, clocked - ready to get data" indication, and the >> only way that we have to judge whether it is in this specific state or not is >> to check if the "VDEC_ACTIVE" clock got enabled by the firmware. > > Is Linux ever going to use clk consumer APIs like clk_enable/clk_disable > on this VDEC_ACTIVE clk? If the answer is no, then there isn't any > reason to put it in the clk framework, and probably syscon is the way to > go for now. > Not for the current platform, but that may change in future SoCs... we're not sure. > Another approach could be to wait for some amount of time after telling > firmware to power up and assume the hardware is active. > That would be highly error prone though. Expecting that the HW is alive means that we're 100% sure that both firmware and driver are doing the right thing at every moment, which is something that we'd like to assume but, realistically, for safety reasons we just don't. Should we anyway go for a syscon *now* and then change it to a clock later, if any new platform needs this as a clock? I'm in doubt now on how to proceed. > ---- > > I see that the __clk_is_enabled() API is being used in some other > consumer drivers. I think at one point we were down to one or two users. > I'll try to remove this function entirely, but it will still be possible > to get at the clk_hw for a clk with __clk_get_hw() and then call > clk_hw_is_enabled(). > Makes sense. Regards, Angelo