Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2407585ybb; Fri, 27 Mar 2020 05:05:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vujlZhlDEzSwut4oBOB1EMbGcq7O5rfXu4fPFC7tXjo1jXVryz/sZT+K10byHYiQqqNLgHf X-Received: by 2002:a4a:919b:: with SMTP id d27mr8871331ooh.76.1585310728766; Fri, 27 Mar 2020 05:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585310728; cv=none; d=google.com; s=arc-20160816; b=Zjc/7ivfYXcOkgQefHX1f/ajl+SzHHjcIKt3/rJk/z1UwdqELvvyx9LUToSVia/6jI 8tQJcv24b4oqBq/TTkVNV8oSeUIpbJYtfQQcyzi0IlS9/EhYO0BrWWpQuH4L2Qw8fMpt B7JkIRD2l3hZblngMqvOgNG7SmTcUdhibXI5j3lbqYDSQC3xRaOsPeBaiTnIrz1EyDD/ 0IEJhgg2LSBUX7kw5In0H+n+IiTv5b3iL1+GdDy2RHKr59tyt2VrgEUFRVWuQn9ZNLoo +YVg0AyJ9EGbSyZ6c6A7Of7gjbUh2oAoa7BlKq1mpPRPI5rJ8zKJHmKkhEys/4/YRwQO aQoA== 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=WKPprADW7GaHUNyw/PHeP+u/8K2DkZNryKIcozt3Bdo=; b=sLhu/8Lc3yRnMrFSNBECptlwrlv1+bWfVqWk8kFWD4FN0On3aojivGHyZZRVkN1PuE 04cJSGP58zrP4iFF101ylKkct07XMOsYc2OBWmYT2soEHOmtFZ6E9lqqQnLgThS6SeJG lSwkJxYC599g4QgkPOn6c4cS4rRs+gGrC1Y7Q7btAjLf5fxOKwkcCmEfHIZmjGDEOuhW nQAd8VgosFJb03YwlOhv/Wuscs1DTUTbeJfsYN2elzCefeRpV5+RT5bKYzgkwShLOSlm 6/qv/QjkV2Kz6JVito9x7P4DtTtpMMxFizWBdrY7QvAGZmKlme4g9ABaY4TQbIUlDQt4 fI8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=tw0546cz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si2633581oth.230.2020.03.27.05.05.15; Fri, 27 Mar 2020 05:05:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=tw0546cz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727242AbgC0MEu (ORCPT + 99 others); Fri, 27 Mar 2020 08:04:50 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:64771 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbgC0MEt (ORCPT ); Fri, 27 Mar 2020 08:04:49 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1585310688; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=WKPprADW7GaHUNyw/PHeP+u/8K2DkZNryKIcozt3Bdo=; b=tw0546czURVt3JqUZKtGw/twd7Ptz4/6uvDLRZxi+GXrLKgnuQUZMfr3LbTDEY06h3t3YISA h+gPRbwKvES5pC5gKXDPWMPkE+6JYaWdDRb9ju8DohRj/M0mJEZgtx+YEvk6p2ABnmbIdWyA jhuAI4ij6cezN8jivdid8Wo5Ka4= X-Mailgun-Sending-Ip: 104.130.122.27 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 mxa.mailgun.org with ESMTP id 5e7debd2.7feaa61c4998-smtp-out-n01; Fri, 27 Mar 2020 12:04:34 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id DDDB3C43637; Fri, 27 Mar 2020 12:04:33 +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.43.129] (unknown [106.222.5.70]) (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 5F482C433D2; Fri, 27 Mar 2020 12:04:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5F482C433D2 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 v14 6/6] soc: qcom: rpmh-rsc: Allow using free WAKE TCS for active request To: Doug Anderson Cc: Stephen Boyd , Evan Green , Bjorn Andersson , LKML , linux-arm-msm , Andy Gross , Matthias Kaehlcke , Rajendra Nayak , Lina Iyer , lsrao@codeaurora.org References: <1585244270-637-1-git-send-email-mkshah@codeaurora.org> <1585244270-637-7-git-send-email-mkshah@codeaurora.org> From: Maulik Shah Message-ID: <8d19958d-7334-ca4e-d7ba-f5919a56b279@codeaurora.org> Date: Fri, 27 Mar 2020 17:34:26 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 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 Hi, On 3/27/2020 3:16 AM, Doug Anderson wrote: > Hi, > > On Thu, Mar 26, 2020 at 10:38 AM Maulik Shah wrote: >> When there are more than one WAKE TCS available and there is no dedicated >> ACTIVE TCS available, invalidating all WAKE TCSes and waiting for current >> transfer to complete in first WAKE TCS blocks using another free WAKE TCS >> to complete current request. >> >> Remove rpmh_rsc_invalidate() to happen from tcs_write() when WAKE TCSes >> is re-purposed to be used for Active mode. Clear only currently used >> WAKE TCS's register configuration. >> >> Mark the caches as dirty so next time when rpmh_flush() is invoked it >> can invalidate and program cached sleep and wake sets again. >> >> Fixes: 2de4b8d33eab (drivers: qcom: rpmh-rsc: allow active requests from wake TCS) >> Signed-off-by: Maulik Shah >> --- >> drivers/soc/qcom/rpmh-rsc.c | 29 +++++++++++++++++++---------- >> 1 file changed, 19 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c >> index 8fa70b4..c0513af 100644 >> --- a/drivers/soc/qcom/rpmh-rsc.c >> +++ b/drivers/soc/qcom/rpmh-rsc.c >> @@ -154,8 +154,9 @@ int rpmh_rsc_invalidate(struct rsc_drv *drv) >> static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, >> const struct tcs_request *msg) >> { >> - int type, ret; >> + int type; >> struct tcs_group *tcs; >> + unsigned long flags; >> >> switch (msg->state) { >> case RPMH_ACTIVE_ONLY_STATE: >> @@ -175,18 +176,18 @@ static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, >> * If we are making an active request on a RSC that does not have a >> * dedicated TCS for active state use, then re-purpose a wake TCS to >> * send active votes. >> - * NOTE: The driver must be aware that this RSC does not have a >> - * dedicated AMC, and therefore would invalidate the sleep and wake >> - * TCSes before making an active state request. >> + * >> + * NOTE: Mark caches as dirty here since existing data in wake TCS will >> + * be lost. rpmh_flush() will processed for dirty caches to restore >> + * data. >> */ >> tcs = get_tcs_of_type(drv, type); >> if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs) { >> tcs = get_tcs_of_type(drv, WAKE_TCS); >> - if (tcs->num_tcs) { >> - ret = rpmh_rsc_invalidate(drv); >> - if (ret) >> - return ERR_PTR(ret); >> - } >> + >> + spin_lock_irqsave(&drv->client.cache_lock, flags); >> + drv->client.dirty = true; >> + spin_unlock_irqrestore(&drv->client.cache_lock, flags); > This seems like a huge abstraction violation. Agree that cache_lock and dirty flag are used in rpmh.c I will address this to either notify rpmh.c to mark it dirty or think of other solution. > Why can't rpmh_write() > / rpmh_write_async() / rpmh_write_batch() just always unconditionally > mark the cache dirty? Are there really lots of cases when those calls > are made and they do nothing? At rpmh.c, it doesn't know that rpmh-rsc.c worked on borrowed TCS to finish the request. We should not blindly mark caches dirty everytime. > > > Other than that this patch seems sane to me and addresses one of the > comments I had in: > > https://lore.kernel.org/r/CAD=FV=XmBQb8yfx14T-tMQ68F-h=3UHog744b3X3JZViu15+4g@mail.gmail.com > > ...interestingly after your patch I guess now I guess tcs_invalidate() > no longer needs spinlocks since it's only ever called from PM code on > the last CPU. ...if you agree, I can always do it in my cleanup > series. See: > > https://lore.kernel.org/r/CAD=FV=Xp1o68HnC2-hMnffDDsi+jjgc9pNrdNuypjQZbS5K4nQ@mail.gmail.com > > -Doug There are other RSCs which use same driver, so lets keep spinlock. I still didn't get chance to validate your patch (i will have update sometime next week), just to update I have never seen any issue internally using spin_lock even on nosmp case, that might require it to change to _irq_save/restore variant. Thanks, Maulik -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation