Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp305306lqd; Wed, 24 Apr 2024 02:57:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUIhygWNWNeVV3Yl2m0sxaFIz28Z24Xss+a/mLJL3kKs0BVYtroJMgmx3uk1X5AZ/YVw+8hG7pWgndW1btxpce7q5bIoQQuGGfCnvj5g== X-Google-Smtp-Source: AGHT+IEd9tSqWLTWoGKfQDOvVKUV9sXfCin4KclCMxlEYULx8Ao+VZrhqM/GDcDK/VpInp6OBzaA X-Received: by 2002:a17:906:301a:b0:a55:b272:4052 with SMTP id 26-20020a170906301a00b00a55b2724052mr952147ejz.66.1713952630417; Wed, 24 Apr 2024 02:57:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713952630; cv=pass; d=google.com; s=arc-20160816; b=jeiWSV/xVAemWmTGY/NFDPoBlaWYU1IaaNrf+4MObTFpnQPLcnvhiJQIlwI7vZUB+d 6iB/BKHBpcUue4/izFgJ+hDifrIHDIvG86nbR79yt2bzAF9Qe3kkNRXG5WwLY2sLsOuR Pf/xLBN7Z5Mvn07dSDR+fQnvtWqe+UZUKtpQv1CSZcbiDRGMVVgXJaTsXZUZ7RkeOrHV 0wW7PoiLHiVsw1oZUMO8CiPeplMFYTtewfa0FuH1UKzeCScK5kjxjMbIO9Fnef2vhStd UKfQXpxVAnlCM+RAvFwRdh2lJsCJGOHxSC9I2/ZbObrZ7oSIDU35QDoTB5TMyXeawZrK 10Ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=1ynqVW3ECGmeDU6rhv1zDweO2ynf/w2KtnDZdanRG0w=; fh=Go5P+vdWeydeEu7vp2pMCk6xzKfh6uct9CwI8zThV0A=; b=RRqb6q0yxnKjq+9p5V3G0m8KSOY8D6LtbKaz0Epj1uYLdGqoQKxieBuNOjq+MITBaa K3Zub0eTmpBMy3RGLqZJYaBqUu5ZC9SAZOm5o1kgoelBGWO923z8iTB1GgBBu7qIxeRn oPC/B2lnvlo2x9ULqDOptdYF2MA0Ese+64cltQMLIADVxDlBcQF0m034ja+EUUg+68vn 01GojDnrNpYmM7L7r242i85yXO1+9sEPE01bm16j5P2OTkO40JjX57k3Tn5RiiIm17oi E36ZRbpszopk0taU5XqfDUc2s51/JREU3fu4BiFf8HWFrIdmPW3kddxU4/AunZy4C15A mMSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ldn2y5pj; 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-156672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156672-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 k19-20020a170906579300b00a5876598b05si2306488ejq.551.2024.04.24.02.57.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 02:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156672-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=ldn2y5pj; 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-156672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156672-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 02DE71F23030 for ; Wed, 24 Apr 2024 09:57:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 573D61598FD; Wed, 24 Apr 2024 09:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ldn2y5pj" Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) (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 A7A491598FB for ; Wed, 24 Apr 2024 09:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713952554; cv=none; b=fZfDrZ/F7QzAj4nEh795aoAreb3UWyiVlqFRTF6Ao4Dsd1LFHVqhD6/ND/gntWcHrCRcfnTcTxUuOnuVzHpAUahF7+xRUkj1B8QXG0wTC0fX7sEfcV9+C1XALzTIJFPgCA8TxecgEt2UXdz2T+BsEtzfKrzwMDRlBDHfVB0N7PI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713952554; c=relaxed/simple; bh=gmI75FS6suiOP9ogaWAXodFk+XJnFCT0SIL9OaoUmpI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PleiNI/GGaDPSlueuZLaU5lpLFaSI4Kj4UkNVm/Pp0THAXviwhoXTHccWOjr8C2aBahSyFIgS32EjPgHBTU8DaYLfuD8tjDDtcvC/3HA3jMTEiUpVt/pRCnY0kMqGutMkU9Btv1bojmYw89/0zUSr3zUBUT1XQe/EACxZEE3b48= 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=ldn2y5pj; arc=none smtp.client-ip=209.85.221.68 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-wr1-f68.google.com with SMTP id ffacd0b85a97d-347c197a464so5028384f8f.2 for ; Wed, 24 Apr 2024 02:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713952551; x=1714557351; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1ynqVW3ECGmeDU6rhv1zDweO2ynf/w2KtnDZdanRG0w=; b=ldn2y5pjcWxgv6cAavX+wIWBX1kLtZXBgibAdDCEENCFGNa2MM2tIfMkdB3TuyrJt1 ASuxgBNwhGW0cBydZ9nPEMA4KY/R1fFre1VtCXddX9+KRuC0YuIQhgaUI/KAoLGUv3OL ep8uzNNOXTaYcKTFQ6EIsFkGRHv1V+RAaECJF5OPaLmOkEq3aSnezibaSH1jowAMP3SS 8DV3YnXitsDlQ7JeXKqFS7xJ+Byyw9TmLOqrNylhETjIIw6IY9QnhgL5yXUd5PjWAGcZ XJGn+FKoEDG5VESmQ1LuAtEFub2NIb/qDOGV/XpZxLc9vHbr04MjDzdaRozKfMToh0py bUmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713952551; x=1714557351; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1ynqVW3ECGmeDU6rhv1zDweO2ynf/w2KtnDZdanRG0w=; b=xOl1lHQAApwW5nvRPzE9jkvFbAut9lETQ/0wkYaXhc5Ajkc85/1tZZvJymPb/NyIB5 qrj9aQg8JYO/UKFcFcVwAmdriF6FmNZtB4OopABODIdqe69VN4zN+rykU0yVkPLJffAf m+Wx8nnz/utKhWIwp9dFnzXUuUQbKVumE6IZjpLW9SCsmEQz+bHeVZ7EO9ChrDJKqdg6 5zIuly5rZDLeN9VWbZc0EYZbCJBdrGJQZJRQUGBApohQnt0MLO5CQQZKyctRiFI30rKY HX/celXimCMSnGzYopFgix8G9YB0LK1qS0ZNp6IJb4D5CEwG6ug+of1aAPHJZIwVZvM4 5qIg== X-Forwarded-Encrypted: i=1; AJvYcCUc7MOz4DtbLWu2xsjx4KtNJBQyQHrZRtkthZf5KDrkYfeaHRD3z+/pXXyJo9Ur6R7nyhAraZqUTMd9DCZcChxYiBlt94+ikXUgANjc X-Gm-Message-State: AOJu0YwF3zg0UsqNbyNx49iNOrslHwyABl7DMv24fBG5t9anlAUFDe7B zKTKCNjOGCAfcbJ33/yjBepi6ccyH9qZPfzNY2X6d7PoEKiHcA6e+CVNX411P2g= X-Received: by 2002:a5d:56c6:0:b0:347:f6f8:5088 with SMTP id m6-20020a5d56c6000000b00347f6f85088mr1231675wrw.54.1713952550949; Wed, 24 Apr 2024 02:55:50 -0700 (PDT) Received: from [192.168.0.102] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id d14-20020adfe88e000000b0034b86548582sm3233617wrm.102.2024.04.24.02.55.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Apr 2024 02:55:49 -0700 (PDT) Message-ID: <0ed739d8-7ef6-4b0d-bd61-62966c9a9362@linaro.org> Date: Wed, 24 Apr 2024 10:55:48 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V5 RESEND 3/5] clk: qcom: gdsc: Add set and get hwmode callbacks to switch GDSC mode To: Jagadeesh Kona , Bjorn Andersson , Michael Turquette , Stephen Boyd , Stanimir Varbanov , Vikash Garodia , Mauro Carvalho Chehab , Ulf Hansson , "Rafael J . Wysocki" , Kevin Hilman , Pavel Machek , Len Brown , Greg Kroah-Hartman , Konrad Dybcio , Andy Gross , Dmitry Baryshkov , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-pm@vger.kernel.org, Taniya Das , Satya Priya Kakitapalli , Imran Shaik , Ajit Pandey References: <20240413152013.22307-1-quic_jkona@quicinc.com> <20240413152013.22307-4-quic_jkona@quicinc.com> Content-Language: en-US From: Bryan O'Donoghue In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 24/04/2024 10:47, Jagadeesh Kona wrote: > > > On 4/24/2024 5:18 AM, Bryan O'Donoghue wrote: >> On 13/04/2024 16:20, Jagadeesh Kona wrote: >>> Some GDSC client drivers require the GDSC mode to be switched >>> dynamically >>> to HW mode at runtime to gain the power benefits. Typically such client >>> drivers require the GDSC to be brought up in SW mode initially to enable >>> the required dependent clocks and configure the hardware to proper >>> state. >>> Once initial hardware set up is done, they switch the GDSC to HW mode to >>> save power. At the end of usecase, they switch the GDSC back to SW mode >>> and disable the GDSC. >>> >>> Introduce HW_CTRL_TRIGGER flag to register the set_hwmode_dev and >>> get_hwmode_dev callbacks for GDSC's whose respective client drivers >>> require the GDSC mode to be switched dynamically at runtime using >>> dev_pm_genpd_set_hwmode() API. >>> >>> Signed-off-by: Jagadeesh Kona >>> Signed-off-by: Abel Vesa >>> --- >>>   drivers/clk/qcom/gdsc.c | 37 +++++++++++++++++++++++++++++++++++++ >>>   drivers/clk/qcom/gdsc.h |  1 + >>>   2 files changed, 38 insertions(+) >>> >>> diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c >>> index df9618ab7eea..c5f6be8181d8 100644 >>> --- a/drivers/clk/qcom/gdsc.c >>> +++ b/drivers/clk/qcom/gdsc.c >>> @@ -363,6 +363,39 @@ static int gdsc_disable(struct generic_pm_domain >>> *domain) >>>       return 0; >>>   } >>> +static int gdsc_set_hwmode(struct generic_pm_domain *domain, struct >>> device *dev, bool mode) >>> +{ >>> +    struct gdsc *sc = domain_to_gdsc(domain); >>> +    int ret; >>> + >>> +    ret = gdsc_hwctrl(sc, mode); >>> +    if (ret) >>> +        return ret; >>> + >>> +    /* Wait for 1usec for mode transition to properly complete */ >>> +    udelay(1); >> >> A delay I suspect you don't need - if the HW spec says "takes 1 usec >> for this to take effect" that's 1 usec from io write completion from >> APSS to another system agent. >> >> You poll for the state transition down below anyway. >> >> I'd be pretty certain that's a redundant delay. >> > > Thanks Bryan for your review! > > This 1usec delay is needed every time GDSC is moved in and out of HW > control mode and the reason for same is explained in one of the older > gdsc driver change at below link > > https://lore.kernel.org/all/1484027679-18397-1-git-send-email-rnayak@codeaurora.org/ > Right. If that is your precedent then you seem to be missing the mb(); between gdsc_hwctrl(); /* mb(); here */ and this udelay(1); --- bod