Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10422546ybi; Wed, 24 Jul 2019 22:57:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbEbS3ic7dblE/pOeX8oPm7OCMp3dVuG4xuz6AnY26H/0LLkMxzZRD3eQZ0aU3nj2/jlSo X-Received: by 2002:a17:90a:9f4a:: with SMTP id q10mr90897992pjv.95.1564034243162; Wed, 24 Jul 2019 22:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034243; cv=none; d=google.com; s=arc-20160816; b=elmaY+Ae9rxFgJ1180pKS/owLvCEVbGzAULlMFvWGRcu0g6llgtXMjpHVRasPgsyed 7EGZU3sFxZvQ84zUgt5Gn7hvxOvjTZB+ce0VpS9mcmlyeVsNuSvh0wiDVGyiWDWXuzlN tpSd4u1i6FCVYK4OOlMZ+06jSoSqDKuk/QpAWZKfGkG5waPwD8SHGB2bILJl2cDmdzWa hozeDVXEQ0Elp+efIYk9vU9b69t4EGeI2us/cvMdYYl8/bcYWBqxISIOD+/zvSiTxs59 bjyK0Cj7UDMEjvw1eCuGbfd1MvNVDw9M8bfZlvIA1iUj6KWoFFkHu0A7V/sq+04pzxPt X93g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9KbxETKIL10GKxcPRBcaESnVSFrDSXJGz52Sgbzz7TY=; b=ttvDWnNySTpsAq5eu+jUgV2v9heaz1JvduQeZKKnaAOUOQeP2V/e6+6krfdMXMVSzB 8lzB3z8+w6mFzvh9GGQQWP8zAFfcq5W8dOyRSuxq0EjRhYIjCKqEBAZvoCn30nhAAVq5 Set6vnsmrRYf+941aACqvqaCvCOkxTWmJBvOp2WMgOSKMvqXq7BB2hPCV2GQlcM36Eop 9oEyqZsjFLjvZX+tC0U4J5FVdIe5USftByI2l7AV/ILZWJT3OghRwHtwHYLeEeUU1azq E7kKm6jgiPtxMPG0F+CBS7v2QdloyN7oElptjgg2x/c6kdhI36okLjJoXIf8TydSBXQj MtPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVIvWHfp; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si18870479pgn.290.2019.07.24.22.57.08; Wed, 24 Jul 2019 22:57:23 -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=pass header.i=@linaro.org header.s=google header.b=QVIvWHfp; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403959AbfGYFi2 (ORCPT + 99 others); Thu, 25 Jul 2019 01:38:28 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45281 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403951AbfGYFi0 (ORCPT ); Thu, 25 Jul 2019 01:38:26 -0400 Received: by mail-pl1-f195.google.com with SMTP id y8so22941940plr.12 for ; Wed, 24 Jul 2019 22:38:26 -0700 (PDT) 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=9KbxETKIL10GKxcPRBcaESnVSFrDSXJGz52Sgbzz7TY=; b=QVIvWHfpVoQwjxa/sbG+597puJK/8e4mjlXaInhXoeUlj86gGaA2JdXs7ym/gt6i0B B4hBuxUbCKgnit1c2mY0EXEpoq40XwGdXtEjvj0JUFw0io5OWUfK2/B2sCW+o2RMIoRg 0SFhPVb8Gh0GPk8QBNiRwoG68RDyG+1UX8G1u/Q8TxzSyeU5VfgEYBTcTwvRoOhUuii3 piUEjzodony2/N3PvNdf1Gr7EWpLC/BBG+q1r3nfaurq2Thy6D+QHS0yDZHyqKURVOCl IN4cbnD8wSlft20sXgkEuRpj64YfEqV0XR/ixrIsExBjkozjqgBTciqXMQTOeoB8751v kvDQ== 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=9KbxETKIL10GKxcPRBcaESnVSFrDSXJGz52Sgbzz7TY=; b=cmC97BTguTMK5knV86ehnKOPSJ1qLDbzL6o1bOXsM8eZPCJeGQWwD2Fi2Sw4kAzJx6 LFTvT9ZaCFfQd2r/Y4yejJUUBkztgnYgyu9HzREZ7iO8dlDo81Vqf/eDocHIAe5ORQf3 vvksKKIZ4w/qG8HiSixg3BV1Ib14BDjq2VwpC0t9IU4BMWbsIDeSptXvAlZvav8ugist 4FL0hHi+V6w7ykrq+hW26GHkopnGFKVdh/9y6emRvHDq2tZjNKwJlrF11ZzcUocT+xps zq1e1adD5BifCj4EcUBd9y4RRPr/4hpoTUG2wPEmusZOUsIlhW7dtplo07P76coJThX1 NsqQ== X-Gm-Message-State: APjAAAWEqHo3ohtL99rjcEB3w9JIbXkY+ZBMkgg4XPlbEi1L+W4xWbEu rDs/iYxbhgp9Opv9T5VvZbMINQ== X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr90071191pll.321.1564033105968; Wed, 24 Jul 2019 22:38:25 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id o11sm80515271pfh.114.2019.07.24.22.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 22:38:25 -0700 (PDT) Date: Thu, 25 Jul 2019 11:08:23 +0530 From: Viresh Kumar To: Saravana Kannan Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Sibi Sankar , Android Kernel Team , Linux PM , LKML Subject: Re: [PATCH v3 2/5] OPP: Add function to look up required OPP's for a given OPP Message-ID: <20190725053823.yqaxnk2a7geebmqw@vireshk-i7> References: <20190717222340.137578-1-saravanak@google.com> <20190717222340.137578-3-saravanak@google.com> <20190723095316.t5ltprixxd5veuj7@vireshk-i7> <20190725025849.y2xyxmqmgorrny6k@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-391-311a52 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24-07-19, 20:46, Saravana Kannan wrote: > On Wed, Jul 24, 2019 at 7:58 PM Viresh Kumar wrote: > > On 23-07-19, 17:23, Saravana Kannan wrote: > > > I almost said "not sure. Let me just compare pointers". > > > I think (not sure) it has to do with the same OPP table being used to > > > create multiple OPP table copies if the "shared OPP table" flag isn't > > > set? > > > Can you confirm if this makes sense? If so, I can add a comment patch > > > that adds comments to the existing code and then copies it into this > > > function in this patch. > > > > Right, that was the reason but we also need to fix ... > > I know I gave that explanation but I'm still a bit confused by the > existing logic. If the same DT OPP table is used to create multiple in > memory OPP tables, how do you device which in memory OPP table is the > right one to point to? This is a bit broken actually, we don't see any problems right now but may eventually have to fix it someday. We pick the first in-memory OPP table that was created using the DT OPP table. This is done because the DT doesn't provide any explicit linking to the required-opp device right now. Right now the required-opps is only used for power domains and so it is working fine. It may work fine for your case as well. But once we have a case we want to use required-opps in a single OPP table for both power-domains and master/slave thing you are proposing, we may see more problems. > > > > > + break; > > > > > + } > > > > > + > > > > > + if (unlikely(i == src_table->required_opp_count)) { > > > > > + pr_err("%s: Couldn't find matching OPP table (%p: %p)\n", > > > > > + __func__, src_table, dst_table); > > > > > + return NULL; > > > > > + } > > > > > + > > > > > + mutex_lock(&src_table->lock); > > > > > + > > > > > + list_for_each_entry(opp, &src_table->opp_list, node) { > > > > > + if (opp == src_opp) { > > > > ... this as well. We must be comparing node pointers here as well. > > Not really, if an in memory OPP entry is not part of an in memory OPP > table list, I don't think it should be considered part of the OPP > table just because the node pointer is the same. I think that's > explicitly wrong and the above code is correct as is. I understand what you are saying, but because we match the very first OPP table that was there in the list we need to match the DT node here as well. Or somehow we make sure to have the correct in-memory OPP table being pointed by the required-opp-table array. Then we don't need the node pointer anywhere here. -- viresh