Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp376821lqd; Wed, 24 Apr 2024 05:24:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOweHzI2zN295lziUUP9rrhoM4O05LUXZ9VWkImnqMSePeJOqb0hY0L5OLgC30IWySlKJWAao5blh8ja4iJyB3JTUYSs9rAlTLGE0Tpg== X-Google-Smtp-Source: AGHT+IG/6TnhstDEzEG8rmJfd/8BfbRm5aqQTM3fmj41ynzHsSmrt/K9NdiU3832C6Y7JArMs3HZ X-Received: by 2002:a05:6e02:b47:b0:36b:837:db0e with SMTP id f7-20020a056e020b4700b0036b0837db0emr3601508ilu.1.1713961468784; Wed, 24 Apr 2024 05:24:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713961468; cv=pass; d=google.com; s=arc-20160816; b=CNQId+dWLGWpqMtf377p6IFyopI36h9T7YNPgk2q+K+CicJIHizeHFjqu/QUESbYO9 sBfrxHOzgjgYhqmfSoUHmkmXH+73cJTXrp0tXHwXzIxC8kOt+lEPEfjtypHc13FmBlTM N307P6jgDjgxBnJf9Y4D8HZAddM02Kcq9rzQR7I1LhNoxPrnTcWxI0e+aOtuDk1yj9VD nKgtMUgek7tMItJkpNDDkejblD7Gyvv7RbTEovOq/abplWMZTufPpaIES8w67+6knJsc ZUm+0VQUYMwG2EQl3ONEw95HvUTdPXDgv8a6b6A1FVkLw6EWvnItNBgHXJwYNtW6gasd HawQ== 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=wrwSu6K9f3l7AxMNZgK7qc0Fh0lkJOEbmkGCWsVk/v8=; fh=6oSaN7Yft9YXBzgLi46upKHTB7OK2Tp6lwRhnm+tvkc=; b=BebfdQVpYV9H53o/HCHopH+yH7QPxGJW48YRYc8Ip0PnyXJHDb5kO6yYQqfMpBvGsh n5cd/7sCy7gNi1oAfeCWD/no6fM92gj6Fsjg+PUQnrI7ywX9cX0yBLP455+NbECvmjm0 pjToAYfRKIfunXmGlE49OS+dOSt8R+dPQ9fW0thbM+pnKfYi151ule0V24pJBf7k5bOH PrPSc/lr8MT/XGS3SsC53WF7X6ILwiI0UAEP5tO9/ktW+7RdZJLvkchk1Yjg0QGI+IDE Y4jIgzwqRBwDis4z2z6ptdya7zrFAzWQAfzx9GGb6hJXPUOF/UDD0cK5jzob5AwnvkqY f70w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IO7gDWt7; 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-156854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 c198-20020a6335cf000000b0060477fd5367si2082671pga.702.2024.04.24.05.24.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 05:24:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156854-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=@linaro.org header.s=google header.b=IO7gDWt7; 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-156854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156854-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 88B0E289121 for ; Wed, 24 Apr 2024 12:23:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C42615B130; Wed, 24 Apr 2024 12:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IO7gDWt7" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 7C90015ADAE for ; Wed, 24 Apr 2024 12:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713961384; cv=none; b=BislF6GXJyMvxnhLzM2phyVUhCj1+a30Iu/HrhR67JSss+YHj7s/zZHnePaTfFYVULjR7ftdsPY0lIhYyKG3fTsxIxwD90uBqZLjVVBvT2CDiC3tchXGKqMpekno9HXjrWmK1KcKICEx/ytkP8N3hNoh0O25+TYOS4zveAucM3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713961384; c=relaxed/simple; bh=7EVAxZ43e6M9EqakVg8G5iPomQiclYYtKEY7SU0BQVY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ufm/KfHLHocYccr+7Yg+FCJlPB+3R0+S8LTFdTRg3gRtgZfQJaVZOvYJAojoNtk8VyJ9UBdsfhejxK0og4BsqWLDeKrKmyi+uKCvLYz8HKhBha7kXl6D4ACFkSsw8ThSl0m8FcXsaQQ7EVZWfrD7IRqx5qcDsyt7XvKU+JlisS8= 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=IO7gDWt7; arc=none smtp.client-ip=209.85.167.43 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-lf1-f43.google.com with SMTP id 2adb3069b0e04-51ab4ee9df8so7079717e87.1 for ; Wed, 24 Apr 2024 05:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713961381; x=1714566181; 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=wrwSu6K9f3l7AxMNZgK7qc0Fh0lkJOEbmkGCWsVk/v8=; b=IO7gDWt7YQAFaTBUpD7YgRJeYIb4RLs7YrftnlHEi8vQcQvHYxZMwATIpGG5vKCEjy nTbiAoVLeUtzlKPPqZL1sLjk32domfv5Kau6Kd7wWBNeGeYzMR7stBkG4aiSMu/pNe9b VTRFp7yCdzniirClYlowH7FuJyL/tFNNwTT+dTNBXMINQqeUyrMmoBkmvNlbomUaWnem l/e/1QUARtc9ovYmbaOLF1pGhYO/QNiLsfetP7kGKRcyIgAp4R6UbU6WhSVWPlV+xvD1 AYzwQg/P/wHL4WBYl5FGNYLutz4XYF+pJr31oI6nuEZ8wk4yjUwQn1JZKKlob244UAOb 33wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713961381; x=1714566181; 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=wrwSu6K9f3l7AxMNZgK7qc0Fh0lkJOEbmkGCWsVk/v8=; b=ONVxsRwKVTQ/AIZBRcfq7S7GDKLwnZlBkxj3OI/fUEkHAfjWAOVC+x4/tkGqd+rw7J qQDeLCVf3c4m0DiEdh1ZM6iaqYBD1DCnaHetnszzx+qOQhJagFPQzLmOet9GU/Vtt2/9 IuCjP2MndSqroz5k8afWAzvCueJvM4e8feEJQbLGakms4VqmhworxwA6Rj5uDY2fJWof q8tBiXUAQqMsH3v+IpsJcwu0tU9Tsh2eKLHceoUB3dYbVfch5fnJEdDl4J52jvqvwUYy PCOvHJIESBaUR8zEqc67Frl716G8VfnxaymJlZ2PjseGlTms2bJ4S/qtWb1hdHVBsbLJ MnDw== X-Forwarded-Encrypted: i=1; AJvYcCVctJzTnzmL5Ykc+13Gfm0A+vOZikrgk2J4ForRYhOybEP7GmKJ30xlXbSp/6a1b1f5Dc4YtU9gBqlcetkZGq1ZVp5yaXZsI1TEXCSl X-Gm-Message-State: AOJu0Yx8xB/CPCCgmzu9I4PXRUiJ/6HcFXxLoCnMwFJDut8X7Ue4yi8k aK9MxEhEXWwybKCFI3ZVhleZYnBX65hdqlESQ9hpZvBJlph0tFUw7FRKU8VZXhk= X-Received: by 2002:a05:6512:310d:b0:51b:1f12:4844 with SMTP id n13-20020a056512310d00b0051b1f124844mr1876706lfb.64.1713961380616; Wed, 24 Apr 2024 05:23:00 -0700 (PDT) Received: from [172.30.204.128] (UNUSED.212-182-62-129.lubman.net.pl. [212.182.62.129]) by smtp.gmail.com with ESMTPSA id t3-20020a056512068300b0051b5835f3f9sm831432lfe.278.2024.04.24.05.22.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Apr 2024 05:23:00 -0700 (PDT) Message-ID: <603aef24-a8ad-4c39-8c5a-846139f77a77@linaro.org> Date: Wed, 24 Apr 2024 14:22:54 +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 Subject: Re: [PATCH V5 RESEND 3/5] clk: qcom: gdsc: Add set and get hwmode callbacks to switch GDSC mode To: Jagadeesh Kona , Bryan O'Donoghue , 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 , 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> <0ed739d8-7ef6-4b0d-bd61-62966c9a9362@linaro.org> <2e8f5e93-1f24-4451-ab9f-ad1e7d98bc65@quicinc.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <2e8f5e93-1f24-4451-ab9f-ad1e7d98bc65@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/24/24 12:27, Jagadeesh Kona wrote: > > > On 4/24/2024 3:25 PM, Bryan O'Donoghue wrote: >> 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); >> > > Sorry, earlier I shared the link to base patch series which has mb() used, but in the mainlined series of the same patch mb() is removed as per the review comments. > > Please find the mainlined series link:- > https://lore.kernel.org/all/1485145581-517-1-git-send-email-rnayak@codeaurora.org/ Mostly because mb is a solution to a different problem. See this talk for more details: https://youtu.be/i6DayghhA8Q Konrad