From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 752EFC433DB for ; Fri, 12 Mar 2021 03:51:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4365664ED6 for ; Fri, 12 Mar 2021 03:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231983AbhCLDu3 (ORCPT ); Thu, 11 Mar 2021 22:50:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbhCLDtv (ORCPT ); Thu, 11 Mar 2021 22:49:51 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596BAC061574 for ; Thu, 11 Mar 2021 19:49:51 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id w7so7795056pll.8 for ; Thu, 11 Mar 2021 19:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=iClR6zNoYi1tdWvry+Z+GUDxBYD0gbeye1VeSZY/vbw=; b=nQ9nVaAjkMgb+JuywXQnMMRSNJsrArWT9wZe0Zt4UQcm027HVtc9YmUY0Tgq6pB75n avK7mjuDcA6fHWOOKt16Bn6zzPsVXHfXglJLiMuchEDS6iKrGF1BJQ0dsWTentn0DKT0 RiexBqsQv2mJqfbO8ZCxs8a0Y7+eGkUf4f4UMuSN4XtC2kgNqdJNnnS4B0+LcRsySYrI H/54aXYJ+eCSCPLQnLIWnZV6s3uVGake/hY+nXeOmSREonL8Kkaf0VNEIy7kfTaZ/pCP xYZuWJSjxST95dEnRYgfh9eYdYRIxgg+QpzRz3snWYZXW3wTl1rPE5YbDXPqpkdliCyH b2uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=iClR6zNoYi1tdWvry+Z+GUDxBYD0gbeye1VeSZY/vbw=; b=QuPDLwBuzmn1FGtkZ1gsWKayv+9pw9sl3G7qUbrdNpc/POj/iN2mvOlX9He4SFCISf NF3aD12QsJ7h5vA04zSXtCspmdCoNh9wolQCE3XFDceHYLlzGlAU+1jvu7j+28aU7aLz 39sYr+aDVl+/lhmk9xshRO2+ajEn9UG+UQkaFhfWQ/f0w3tg6ZwT2Cb7ugUTF17b0Cwd F6QIms29F3ywTFxI7Phmx9uFX40l61vyIlCpb4G+EkQKGRyuROT+Q7zxzPxplUNXvWZX ErAUb0OQbzd/g4ZlqTKcBcovI0wZubySv13QqTwzW4QV9XqINTWHB5WAi0+q3VInV3dB qNHQ== X-Gm-Message-State: AOAM533+w9SDg9tsX6OzIIiDjQ+ie7fLZN9pt51iTkmEuR5DNattFuPZ 8zmfOIjBibYYaBxN2PlvVn1ViA== X-Google-Smtp-Source: ABdhPJx1/YXBd5rjm1d6Lv3nqKUlMq082FYhUb2KfFzoFV4X/hbMyfw19avz6xZ5rBO4iKEs9shvNw== X-Received: by 2002:a17:90a:400f:: with SMTP id u15mr11904527pjc.80.1615520990723; Thu, 11 Mar 2021 19:49:50 -0800 (PST) Received: from localhost ([122.171.124.15]) by smtp.gmail.com with ESMTPSA id v35sm3454767pga.3.2021.03.11.19.49.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 19:49:49 -0800 (PST) Date: Fri, 12 Mar 2021 09:19:42 +0530 From: Viresh Kumar To: Beata Michalska Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, vireshk@kernel.org, nm@ti.com, sboyd@kernel.org Subject: Re: [PATCH] opp: Invalidate current opp when draining the opp list Message-ID: <20210312034942.jh3txxoowbo2ekyn@vireshk-i7> References: <1614870454-18709-1-git-send-email-beata.michalska@arm.com> <20210305042401.gktrgach4dzxp7on@vireshk-i7> <418fc3cb-d5ec-9216-269a-e055e78718e5@arm.com> <20210308115053.ua2gfo6kfnfjslyd@vireshk-i7> <20210308181446.GA26783@e120325.cambridge.arm.com> <20210309043121.546mlvl4jmshogor@vireshk-i7> <20210309121455.GA13095@e120325.cambridge.arm.com> <20210310084738.pe7ppyeq6hn7wbvv@vireshk-i7> <20210310230300.GA26976@e120325.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210310230300.GA26976@e120325.cambridge.arm.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10-03-21, 23:03, Beata Michalska wrote: > > diff --git a/drivers/opp/core.c b/drivers/opp/core.c > > index c2689386a906..150be4c28c99 100644 > > --- a/drivers/opp/core.c > > +++ b/drivers/opp/core.c > > @@ -1492,7 +1492,11 @@ static struct dev_pm_opp *_opp_get_next(struct opp_table *opp_table, > > > > mutex_lock(&opp_table->lock); > > list_for_each_entry(temp, &opp_table->opp_list, node) { > > - if (dynamic == temp->dynamic) { > > + /* > > + * Refcount must be dropped only once for each OPP by OPP core, > > + * do that with help of "removed" flag. > > + */ > > + if (!temp->removed && dynamic == temp->dynamic) { > > opp = temp; > > break; > > } > How about tweaking the _opp_get_next to use list_for_each_entry_continue > instead ? It would eliminate the need of tracking the 'removed' status > and could save few cycles as it wouldn't have to go through the list > starting from it's beginning each time it is being called. > Happy to draft another version. I tried that as well, but the problem is that we need to drop locks in between and if the next OPP somehow gets freed or another one gets added there, we can be in trouble. To make this work without any side effects, the new field was kind of required. -- viresh