Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3081228ybi; Mon, 29 Jul 2019 00:28:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpDp4owrtl/4YprGURQak7l5RcvmC1Ofo7NFZZrOqnvnqSLA1RMv9JqJF2x1bwizhIqKoX X-Received: by 2002:a17:902:b789:: with SMTP id e9mr105817614pls.294.1564385314635; Mon, 29 Jul 2019 00:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564385314; cv=none; d=google.com; s=arc-20160816; b=IeMzrSvHVHvurCdNw7zRvPuKFqa5YTXzT+RSB9iBfrkT30cs9+lcpcE6q47I4f1b03 RIxA5lktLtoC1AAkLS1rIsaeelqdilcikhoAicyFaEGx2WU2QHnXUu2X7ykT0udroPPH lp7H8NJLeVwLjFrZc3AIoKNfXjOzevBR8CXgoA3JO6RTx8T0t/dH+kZX0HbiXrI2r9SX /yF4J02YJ0HLwj1af+TyGvp1v9MNRZzEb9B/JBoO3lhLtzkUvfV2HZ7vxdIIdgloH5zc ZOeXN2iws5+utQ/jT8XNLkhvzibrq+bRh7muB33GrKCgEneE8VGbSxU6jlMyNS60aNY3 yVKQ== 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=AAOCHi1uoiP/+mbnKKUKoIyKr6l7IjQC5tq27atwBuQ=; b=XtO618tp9Cs8JtamwocLVUXUCKwPdhsI0hXGDVAWRYdMwOwHIILnTAa0g+dVfmOAo/ 2ETW2pYWhKx3q8CDhv2zgCdtP9+8usg8RXN3++PjMJQ/QtH4/Ou+RlVoJla9r6U8/Ab/ gp48lbke9l5SJRK2MvsXBgY2VBqeJ8WOT2j+WfMLx0ygBZQ/EFGBQMevDKxBSsfjOPQ2 FHDBbwF7UjQYboCTLZQB6+23ZJAxuyAaYdJTlXG6aMIR3F/MuVFtnvNuQkbWc0CWq38J EktYOqgDvedsfjEWGOZM+t4XSeEHZrUoiRa5RFtElWcdACMVawEm6Bcrhood/teqdSji TXHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+ykbA9Z; 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 x21si10470692pgh.477.2019.07.29.00.28.13; Mon, 29 Jul 2019 00:28:34 -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=H+ykbA9Z; 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 S1726768AbfG2H0S (ORCPT + 99 others); Mon, 29 Jul 2019 03:26:18 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45043 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbfG2H0S (ORCPT ); Mon, 29 Jul 2019 03:26:18 -0400 Received: by mail-pl1-f196.google.com with SMTP id t14so27122841plr.11 for ; Mon, 29 Jul 2019 00:26:17 -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=AAOCHi1uoiP/+mbnKKUKoIyKr6l7IjQC5tq27atwBuQ=; b=H+ykbA9Z7NONKWqLzOkdKL3UOrUarVOJRcCf1+onRhzFuJhb18OdlPeAtKETJJ1XkN R1n6c98gsxeQTFLoiPUGb0ZtFy2UKoATYernPJ9xV2RMWbicXQBsRE+58TAoRYrU3zcJ RH4fDzCD3bIO3KBmPCFm+UmrIHZ2vnYP/c2vEE5aBClJshOVztzKcFGWpYSEPlJ2amuD 6ifapqhfLwc8PQVGDI7tAIqCkvRoyPWOCE2eccpANl4bec9Rr2n7foLLaVlk4O4P2AVf ygYYGCvzDnEC9NzvKgHMtF2jONebX8M6KWAWATNEPzfvU5EnLaCEyKQvWqMGGecV4PIs /5Lw== 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=AAOCHi1uoiP/+mbnKKUKoIyKr6l7IjQC5tq27atwBuQ=; b=ZC3WhmUppQcOMThfQ5n02vF8rbHq1MiogUh9lSQsmjbkd7CQnNEKE/vlDscJoSaYNT 4lEDApAlIuTvRnoeRhJ1msnqSH7VO48Vy//cQIM39xXZ2LEt3DU5w8bzgWT8FXDfnCz4 NaUKobztGNvInbu6ajQKXPWbChTYm/VnhhJ94eT6+O7+hba2dXzH4jSdTkraDeTl4NQ7 sW+pVBhyhobZikbLNT5U3m6NKEetenSTJG589LD9pScx1rpWHaDFqUmMaEukW7Vjj+iX +425OkBAxwjfWlZWRlbv3kCfAMPHbqzJf2JjCkDO4/QPqWTVm+JNumEP2FD1AzVgM9Mh yKaA== X-Gm-Message-State: APjAAAVIvMzej/jkqV8EBKlTRELFcMIhkfgy+kfNW1BveJzh0JwhrP5v l844YWgrKOjBaiJ1nFchN+YAGA== X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr108558587plb.270.1564385176808; Mon, 29 Jul 2019 00:26:16 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id e189sm38867037pgc.15.2019.07.29.00.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 00:26:15 -0700 (PDT) Date: Mon, 29 Jul 2019 12:56:12 +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 3/5] OPP: Improve require-opps linking Message-ID: <20190729072612.pdxoguwheawtrf6d@vireshk-i7> References: <20190717222340.137578-1-saravanak@google.com> <20190717222340.137578-4-saravanak@google.com> <20190723102842.t2s45zzylsjuccm4@vireshk-i7> <20190725030712.lx3cjogo5r7kc262@vireshk-i7> <20190725051742.mn54pi722txkpddg@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 26-07-19, 14:23, Saravana Kannan wrote: > I was taking a closer look at the OPP framework code to try and do > what you ask above, but it's kind of a mess. The whole "the same OPP > table can be used by multiple devices without the opp-shared flag set" > is effectively breaking "required-opps" at a minimum and probably a > lot more cases. I don't think I can rewrite my patch the way you want > it without fixing the existing bugs. > > Let's take this example DT (leaving out the irrelevant part): > > OPP table 1: > required-opps = ; > > OPP table 2: > > > Device A: > operating-points-v2 = <&OPP table 1> > > Device B: > operating-points-v2 = <&OPP table 2> > > Device C: > operating-points-v2 = <&OPP table 2> > > Let's say device B and C add their OPP tables. They both get their own > "in-memory" copy of the OPP table. They can then enabled/disable > different OPP entries (rows) and not affect each other's OPP table. > Which is how it's expected to work. > > Now if device A adds its OPP table 1, the "in-memory" > required_opp_tables pointer of OPP table 1 can end up pointing to > either Device A's copy of the OPP table or Device B's copy of the OPP > table depending on which happens to be added first. This effectively > random linking of OPP tables is mutually exclusive to the point of > required-opps. > Also, at a DT definition level, OPP table 1 pointing to OPP table 2 > when OPP table 2 is used by more than one device doesn't make any > sense. Which device/genpd is OPP table 1 saying it "requires to > operate at a certain level"? I will say that this data is present at least for the present set of users, i.e. power domains. Just that it isn't present so directly within the OPP table. But if you look at the device's node, it will point you to some power domain, etc. I didn't do anything about it earlier because it required more work and I thought "required-opps" property is there to get us some data and it does get that data to us right now. Just that we don't know the device for which this data is there in the OPP core. If we do want to get this linking, how should we get it ? - Using another property in device's DT node, like "required-opp-devices" ? I didn't like it earlier because that would be like duplicating data we already had for the power domains. - Using some in-kernel function, using which other drivers can give us this data ? Maybe yes. Probably that's the best way of doing it ? > So I propose that we should consider the OPP table DT configuration > invalid if one OPP table points to another OPP tables that's NOT > shared but is ALSO pointed to by multiple devices. Basically the > example above would be considered an invalid DT configuration. Does > that sound okay to you? If I make changes to enforce that, will that > be acceptable? I don't think that would be the right thing to do as the idea of sharing the DT OPP tables to avoid duplicate tables in DT was the correct thing to do and is getting used very much right now as well. Perhaps we should fix the problem instead. > If this sounds okay to you, then in the example above, assume Device C > isn't present. Then when OPP table 1 is added by device A, if OPP > table 2 hasn't been added already, I can just go ahead and allocate > OPP table 2. And then when device B tries to add OPP table 2, I can > just tie device B to OPP table 2 and fill up any of the missing > pieces. I can assure you that it would be a big mess. Specially the reference counting using which we free OPP tables and OPPs right now will come in your way. > This sounds better than trying to loop through existing OPP tables and > seeing if any other table is waiting for the newly added table and > marking the waiting tables as "linked". Especially because it gets a > lot more complicated and inefficient when you consider a chain of OPP > tables and many-to-many linking of OPP tables. Firstly, this is all going to be initialization code and will not run after boot normally. And we will probably not have very complex linking cases as well I believe. Maybe 2-3 levels at the best. And this will keep code much simpler compared to the above idea. So here is the thing. I think you should separate out the lazy-linking thing from this patchset as this is a completely different problem you are trying to solve and is unnecessarily blocking other patches. And if you don't want to get into solving the lazy linking thing yourself, because that is consuming your time unnecessarily, then I can see if I can put some of my cycles on it. -- viresh