Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3668861pjo; Wed, 26 Feb 2020 14:44:03 -0800 (PST) X-Google-Smtp-Source: APXvYqw/KfFIvZE6wZJW8B3fAjyyK6CxIP0F2Gy04JgnqUuhb+zNTw12uewL94mfeGHduma7nR6W X-Received: by 2002:a9d:5c0c:: with SMTP id o12mr872358otk.145.1582757043403; Wed, 26 Feb 2020 14:44:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582757043; cv=none; d=google.com; s=arc-20160816; b=fHgJWnz+cp3XJ7yMSGZyaxvd4qfYecvNBMAJOO+rRQuWdyGD4hXtpEKl4+JW3J+G5w AX9u7lNig9ZMkLQEfMH2KcqZLGbH+gGSMgbzSoZ4M/vm1pdpda6tTHso9INUX0iuisOa mD7wRP4PSKhzoQPEyhhCLEcsVe7Keim0aSGI6Tca/tAVGRDQKIivwG0hiwxlm3ekjn1S QmH/imAR3G6tLUZ4T206sSS7xC0YBtde7Z1HcTeipSUnsmpmISzz6iqMpbQbTzxdLMPn D6rSCywIRDOKZjq9qBroXbdCT4UQYbV7bVVNfcynarIhFmvCqj+GMcPHtzauCINT9wWS H0Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=tmmzbig6kKd2J1vSLS/3+Ly3DK1KMOkPEr7ocA5n8BU=; b=BLpReXaF2T3s8G4XAAZmT31PO9aVIx85V8msJAmxykDdmeBDptbs18Vw4e7rznlxD3 a56NExNJZYdat2pGIDHkoQXwVPUUnsRXGlAw08zoIHbSopPttgXWBThpM1QalSePFh1b 3dCOO1El20odX7HvirWOFNO/PJeyXbZ+vcLn4ooZOUmapSsRyd2NbxouTh6BZuLdLWRC TsQdTw4/XS0sAGrdF7Oiu2c1E8k+Hbq8rEo35Cu3lvC0+MxN7HpKXAnY4zc4IGMLr9uM irHGNzJoN/VQYx1D1JwHh14cb3xNexSz72Y0ELkuKI4+/4K0CWvWYcG6rWc58RkEkdvj D3Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="G4kRN/gb"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j13si445940otq.146.2020.02.26.14.43.50; Wed, 26 Feb 2020 14:44:03 -0800 (PST) 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=pass header.i=@chromium.org header.s=google header.b="G4kRN/gb"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727894AbgBZWn1 (ORCPT + 99 others); Wed, 26 Feb 2020 17:43:27 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37129 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727883AbgBZWn0 (ORCPT ); Wed, 26 Feb 2020 17:43:26 -0500 Received: by mail-pl1-f196.google.com with SMTP id q4so286938pls.4 for ; Wed, 26 Feb 2020 14:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=tmmzbig6kKd2J1vSLS/3+Ly3DK1KMOkPEr7ocA5n8BU=; b=G4kRN/gblOwhZ9Ydgqv7ZiG7wbtZIxzqLwbWe4wGx7O3kdMCtDPX8HYO7WSz9jaYG6 qRDSPJTqBduvJZ5hNUCW9fZ4YUI1AwZd/VN4tmk6kvh3t1vDDgi8WIXh1Na0DTBy+IoV /gLLKqvaHocsv0u8y+Q+IwrIQb/27Gw2n6sy4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=tmmzbig6kKd2J1vSLS/3+Ly3DK1KMOkPEr7ocA5n8BU=; b=Meocnhg2j35rQy+u8eFV9PiNzoTPQL/mDbyn1TckEniAJHr0Be5k2MAeSmFy0KPHfr zXgLDyI/codz9+dCatqFl0MdbZDFr+disrYbwLqtJIhq2jddQJniYrBs4cj0yL4do2cC LA43QwT5ww3ZjKrUrwBKQDtPJciV0MU3Eot63a031sPvgmKu1Kk71lwGtZLyzJ1uKCJq z3G6iygA9SFs4+HOaKhGnOoHYN2mMxY5NpgZOsDEqx1kwPAykbI981MbzXXm44dE1x6b KMF/5IFNMpRmmYNxr2h4xpgYBLhgmAbXh+nAouKYhsw7lz1LMDbX5DzjSAJWNcMIMSze +Tgw== X-Gm-Message-State: APjAAAWXSnZr8pIPrlGx/NTkeNKBy3BZCABOqoHTQ4QX5YxXyWrS9aU9 W+9srSdejK4/LpBT7aKcJqdonQCm5Y0= X-Received: by 2002:a17:902:8d94:: with SMTP id v20mr1565171plo.259.1582757005506; Wed, 26 Feb 2020 14:43:25 -0800 (PST) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id v8sm3944025pgt.52.2020.02.26.14.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 14:43:24 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <1582694833-9407-3-git-send-email-mkshah@codeaurora.org> References: <1582694833-9407-1-git-send-email-mkshah@codeaurora.org> <1582694833-9407-3-git-send-email-mkshah@codeaurora.org> Subject: Re: [PATCH v7 2/3] soc: qcom: rpmh: Update dirty flag only when data changes From: Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, dianders@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah To: Maulik Shah , bjorn.andersson@linaro.org, evgreen@chromium.org, mka@chromium.org Date: Wed, 26 Feb 2020 14:43:23 -0800 Message-ID: <158275700389.177367.5843608826404724304@swboyd.mtv.corp.google.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Maulik Shah (2020-02-25 21:27:12) > Currently rpmh ctrlr dirty flag is set for all cases regardless > of data is really changed or not. Add changes to update it when > data is updated to newer values. >=20 > Also move dirty flag updates to happen from within cache_lock. >=20 > Signed-off-by: Maulik Shah > Reviewed-by: Srinivas Rao L Probably worth adding a Fixes tag here? Doesn't make sense to mark something dirty when it isn't changed. > --- > drivers/soc/qcom/rpmh.c | 21 ++++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c > index eb0ded0..83ba4e0 100644 > --- a/drivers/soc/qcom/rpmh.c > +++ b/drivers/soc/qcom/rpmh.c > @@ -139,20 +139,27 @@ static struct cache_req *cache_rpm_request(struct r= pmh_ctrlr *ctrlr, > existing: > switch (state) { > case RPMH_ACTIVE_ONLY_STATE: > - if (req->sleep_val !=3D UINT_MAX) > + if (req->sleep_val !=3D UINT_MAX) { > req->wake_val =3D cmd->data; > + ctrlr->dirty =3D true; > + } > break; > case RPMH_WAKE_ONLY_STATE: > - req->wake_val =3D cmd->data; > + if (req->wake_val !=3D cmd->data) { > + req->wake_val =3D cmd->data; > + ctrlr->dirty =3D true; > + } > break; > case RPMH_SLEEP_STATE: > - req->sleep_val =3D cmd->data; > + if (req->sleep_val !=3D cmd->data) { > + req->sleep_val =3D cmd->data; > + ctrlr->dirty =3D true; > + } > break; > default: > break; Please remove the default case. There are only three states in the enum. The compiler will warn if a switch statement doesn't cover all cases and we'll know to add something here if another enum value is added in the future. > } > =20 > - ctrlr->dirty =3D true; > unlock: > spin_unlock_irqrestore(&ctrlr->cache_lock, flags); > =20 > @@ -323,6 +331,7 @@ static void invalidate_batch(struct rpmh_ctrlr *ctrlr) > list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) > kfree(req); > INIT_LIST_HEAD(&ctrlr->batch_cache); > + ctrlr->dirty =3D true; > spin_unlock_irqrestore(&ctrlr->cache_lock, flags); > } > =20 > @@ -456,6 +465,7 @@ static int send_single(struct rpmh_ctrlr *ctrlr, enum= rpmh_state state, > int rpmh_flush(struct rpmh_ctrlr *ctrlr) > { > struct cache_req *p; > + unsigned long flags; > int ret; > =20 > if (!ctrlr->dirty) { > @@ -488,7 +498,9 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) > return ret; > } > =20 > + spin_lock_irqsave(&ctrlr->cache_lock, flags); > ctrlr->dirty =3D false; > + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); So we take the spinlock to update it here. But we don't hold the spinlock to test for !dirty up above. Seems like either rpmh_flush() can only be called sequentially, or the lock added here needs to be held during the whole flush. Which way is it?