Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp267136ybt; Tue, 23 Jun 2020 21:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrnk7wnxdaQgqBDVz4/mNT23qV80AZPGHy3sjOPGIKyIZAfzkrZFVnN0yNFjMsRfEwhXcn X-Received: by 2002:aa7:c752:: with SMTP id c18mr24506760eds.55.1592973897924; Tue, 23 Jun 2020 21:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592973897; cv=none; d=google.com; s=arc-20160816; b=Y0V9BjQtnjj6iVsUGV/IFKz1FAOql4bquTWVsl/TdK3vQDhZvnM+TvvkCzf6GjSgxH C3mzv4CihKAxav0+8LKXMFdmCMyzV3J5nZ5a3M3WJ2A4AlZxav/ZqEH4QLrRIznKZ4gh R22oJkjOj9LZjsyiBqX/A35DmnX2gDueop1hRXJpT6mfwTpwgo05ffvRA0Pq7xHvFz5x d/oi/aXWt9AFQhmRsPsJLjstCmC8Vsm9KcrncV4hGTYzsJeq+oaEorhiYKrfEcoAbosj dn5DMKjAdYYtr8VS++FyGJiYKvb0tfHa5FPCv5yyeIZIIqOwoKiDztDrcb99d2LgsvJY O7Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=0dYginMgi1k67n62RpmbKWeGpkiw6FuM0+tyuL4cBzo=; b=ELb91su91FJ+ikXg9Kuk7neUOBV6OAJxlRT+y48Zl26yU6T+YOFMI/XirMBxgCdwCC iplPn6VXm6PHGApKifiwrAfIz8F8gqLStWkjF2zPPunMydn4XvRsDqBjO+Hgfopw/kRb q4hCzIsOAY0ozLbGCv4FkUzytb1+JHGgmDGlv0MKR5TmhF2447vD6GFaVF2ajgRUEyJi 2R2rtWc/P40WmHUQqQv/VYqGdLpyavI1UfBZr7tcon4a95msh+2RdSIqclGDs/X94N6b vD9JVmks0wXMzCNcCa3zVo2UVtA7gm/MISnj8j6+SVaCPZD0CrvrpQmvcsGzbYJjvqKt YqIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=n4aeXeNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si354478edv.570.2020.06.23.21.44.34; Tue, 23 Jun 2020 21:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=n4aeXeNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728793AbgFXEmE (ORCPT + 99 others); Wed, 24 Jun 2020 00:42:04 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:41995 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727056AbgFXEmD (ORCPT ); Wed, 24 Jun 2020 00:42:03 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1592973722; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=0dYginMgi1k67n62RpmbKWeGpkiw6FuM0+tyuL4cBzo=; b=n4aeXeNgtOW4ZB4vVk9f9ESiQrBB9ZP8qNXSh84lvd5e/StMTRzSeV2PNb5Va98XD/e//A5u 0d3jy5c1wMR7u1Fk+4DdiWmXaSixakxJEdJKih/bnk4OlnOjO0/NylgDM26qK8jwn44UOlua WzEWG+UYkJzD8Xxtw0ysi3vyq98= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n12.prod.us-west-2.postgun.com with SMTP id 5ef2d9953a8a8b20b8f36001 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 24 Jun 2020 04:41:57 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D510BC433CB; Wed, 24 Jun 2020 04:41:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.29.129] (unknown [49.36.73.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 411B9C433C6; Wed, 24 Jun 2020 04:41:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 411B9C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org Subject: Re: [PATCH] soc: qcom: rpmh-rsc: Don't use ktime for timeout in write_tcs_reg_sync() To: Douglas Anderson , Andy Gross , Bjorn Andersson Cc: Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200528074530.1.Ib86e5b406fe7d16575ae1bb276d650faa144b63c@changeid> From: Maulik Shah Message-ID: <2eb7c28e-d7af-8bc8-c308-46f4df5c995c@codeaurora.org> Date: Wed, 24 Jun 2020 10:11:52 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200528074530.1.Ib86e5b406fe7d16575ae1bb276d650faa144b63c@changeid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reviewed-by: Maulik Shah Thanks, Maulik On 5/28/2020 8:18 PM, Douglas Anderson wrote: > The write_tcs_reg_sync() may be called after timekeeping is suspended > so it's not OK to use ktime. The readl_poll_timeout_atomic() macro > implicitly uses ktime. This was causing a warning at suspend time. > > Change to just loop 1000000 times with a delay of 1 us between loops. > This may give a timeout of more than 1 second but never less and is > safe even if timekeeping is suspended. > > NOTE: I don't have any actual evidence that we need to loop here. > It's possibly that all we really need to do is just read the value > back to ensure that the pipes are cleaned and the looping/comparing is > totally not needed. I never saw the loop being needed in my tests. > However, the loop shouldn't hurt. > > Fixes: 91160150aba0 ("soc: qcom: rpmh-rsc: Timeout after 1 second in write_tcs_reg_sync()") > Reported-by: Maulik Shah > Signed-off-by: Douglas Anderson > --- > > drivers/soc/qcom/rpmh-rsc.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c > index 076fd27f3081..906778e2c1fa 100644 > --- a/drivers/soc/qcom/rpmh-rsc.c > +++ b/drivers/soc/qcom/rpmh-rsc.c > @@ -175,13 +175,21 @@ static void write_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id, > static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, > u32 data) > { > - u32 new_data; > + int i; > > writel(data, tcs_reg_addr(drv, reg, tcs_id)); > - if (readl_poll_timeout_atomic(tcs_reg_addr(drv, reg, tcs_id), new_data, > - new_data == data, 1, USEC_PER_SEC)) > - pr_err("%s: error writing %#x to %d:%#x\n", drv->name, > - data, tcs_id, reg); > + > + /* > + * Wait until we read back the same value. Use a counter rather than > + * ktime for timeout since this may be called after timekeeping stops. > + */ > + for (i = 0; i < USEC_PER_SEC; i++) { > + if (readl(tcs_reg_addr(drv, reg, tcs_id)) == data) > + return; > + udelay(1); > + } > + pr_err("%s: error writing %#x to %d:%#x\n", drv->name, > + data, tcs_id, reg); > } > > /** -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation