Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2117201ybm; Thu, 23 May 2019 11:38:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkQ+kaviWF0zz/cfThczQoLY635PZUltN5iotmqAXSa1WY9BPt4tPukH0PeV2M/5xsJzdw X-Received: by 2002:a17:902:42e2:: with SMTP id h89mr78834164pld.332.1558636685864; Thu, 23 May 2019 11:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558636685; cv=none; d=google.com; s=arc-20160816; b=BobC/A7v8kWSgqQ8EnaUr8mGLwxbKxKpIkJOf31djK/bE2p0kfe66Ru4YjHxUM7l5E iZYTW5A5YeKIxnAxhdKwd/2TJdGxPvBgp6GfUgKrKYap0OSN6Se9OEm7dBKIEQHr5n4d muH5AfonbAsw2Rfr1qgQRga9ddJ+lObZy/A1jy2mtnmzXwRVRW5if55qGQ3eW+xFrnvG VOAXTsYqX/XD7bd1+nF+jgPqMAMpJBDAb2sd9d/cQ9QzwhrM1lEsAALnBp2OTQweZ0Va yX8YXpyK5GiKSYQ2WYQ0CcHZckmDxbk3eGE4vxSPceoZrDaQ3PbGlmOZblwJyawzv1on JCdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rb3kcsO8m+4TP5So6BQHRuZ04N7TnwT1M9UllMU7t6E=; b=qt2997XvsUNUKUgBqtVoWBvaNnEVOm2an5L9TTMAUZPEMZUsfZwofM1u5CJbr0ZIXl NlaRVO6fq6u6pnYbpK9oodzMjlcqHYmXX7vIf7jW2c+mDK0ZfyaNObuFSq1uPIzCSQJj TU6N3tdEMXqytW+xcMjCiwOUxy5DKqihG3V6fBHPosw66ZKYtiBHbQuc+LNnqcIf9KLp Msjh3PkUXcNCjDIvpDuWXUXHCY1QexCshcSp3a1I0A0DGUXbcwv6nQod1BCBt2qLdCQL zDd8K1hc+PXAhtcK7VXpkXKmM7iDZiQw62/Y9lPMUoY+uX/X4BORl+/EouIT/P8ZZbS4 CsJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kBPQm5Pu; 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 a191si339498pge.421.2019.05.23.11.37.50; Thu, 23 May 2019 11:38:05 -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=@chromium.org header.s=google header.b=kBPQm5Pu; 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 S1731564AbfEWSgM (ORCPT + 99 others); Thu, 23 May 2019 14:36:12 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:34773 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731261AbfEWSgM (ORCPT ); Thu, 23 May 2019 14:36:12 -0400 Received: by mail-ua1-f66.google.com with SMTP id 7so2570371uah.1 for ; Thu, 23 May 2019 11:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rb3kcsO8m+4TP5So6BQHRuZ04N7TnwT1M9UllMU7t6E=; b=kBPQm5PuV61p3BztiKcUUjRQQxcFFw2xWcQGZanAo81A1y1Q1yGwTgM4mTChPqVyhO 1Bg09iaXCxSRIbegFzmT05/b966T70N797fQ/TLrvDq8om/GWNeNVmNnnP3XZT5B+rHx 05civqhn8gKGBTvE7N0pXBsR3q7p/Q89UtNqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rb3kcsO8m+4TP5So6BQHRuZ04N7TnwT1M9UllMU7t6E=; b=Wp/ymmu/cjnujHmf6/SBgvqhxJLKrMV3NxBCaYoIl+uLCfwO31oR9IhdDF4xAx9iGd ZGp6nbiuZjZ+IcgdbvDc4RgBIAe1astXfwgrLJc1GOjKC6ZYZz2330fWJlZ2F1/q9DSw eNr/lSPTfLoSgKhOlreV1AE1ST0/TAYGdFnLT75Z6HvwZxHJh/FceuUkTfl/PKgT6Zm8 TlKglKBIMubSzSygZxVl63hA9/d981EzEWd/1qNmPCi0lVJjqW9A0Zu+zFYLjf/T2YeT Go8LCL7OibmqkjjkZ01GRGxbIMBNvW90pY8gvIEWBOkamJ9JYdnzBUoFxC6QSnck24jv Sh+A== X-Gm-Message-State: APjAAAVMg3Dl1+BpKmohofW46dcenEaV9ADKKJ+bgxAbx6ec0mPTGAxn 1npJ7MyBUif1Wdow1ula9ls+2Xp64dE= X-Received: by 2002:ab0:20b3:: with SMTP id y19mr48408955ual.74.1558636570525; Thu, 23 May 2019 11:36:10 -0700 (PDT) Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com. [209.85.222.47]) by smtp.gmail.com with ESMTPSA id v133sm56695vkv.5.2019.05.23.11.36.09 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 23 May 2019 11:36:09 -0700 (PDT) Received: by mail-ua1-f47.google.com with SMTP id r19so2561724uap.5 for ; Thu, 23 May 2019 11:36:09 -0700 (PDT) X-Received: by 2002:ab0:4a97:: with SMTP id s23mr320550uae.19.1558636568655; Thu, 23 May 2019 11:36:08 -0700 (PDT) MIME-Version: 1.0 References: <20190501043734.26706-1-bjorn.andersson@linaro.org> <20190501043734.26706-3-bjorn.andersson@linaro.org> <5ce6e0cd.1c69fb81.9a03e.0260@mx.google.com> In-Reply-To: <5ce6e0cd.1c69fb81.9a03e.0260@mx.google.com> From: Doug Anderson Date: Thu, 23 May 2019 11:35:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 2/4] soc: qcom: Add AOSS QMP driver To: Stephen Boyd Cc: Bjorn Andersson , Andy Gross , David Brown , Rob Herring , Mark Rutland , linux-arm-msm , devicetree@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, May 23, 2019 at 11:05 AM Stephen Boyd wrote: > > Quoting Doug Anderson (2019-05-23 09:38:13) > > Hi, > > > > On Tue, Apr 30, 2019 at 9:38 PM Bjorn Andersson > > wrote: > > > > > +static int qmp_qdss_clk_add(struct qmp *qmp) > > > +{ > > > + struct clk_init_data qdss_init = { > > > + .ops = &qmp_qdss_clk_ops, > > > + .name = "qdss", > > > + }; > > > > Can't qdss_init be "static const"? That had the advantage of not > > needing to construct it on the stack and also of it having a longer > > lifetime. It looks like clk_register() stores the "hw" pointer in its > > structure and the "hw" structure will have a pointer here. While I > > can believe that it never looks at it again, it's nice if that pointer > > doesn't point somewhere on an old stack. > > > > I suppose we could go the other way and try to mark more stuff in this > > module as __init and __initdata, but even then at least the pointer > > won't be onto a stack. ;-) > > > > Const would be nice, but otherwise making it static isn't a good idea. Even aside from the whole "not having it store a pointer to the stack", "static const" is likely to reduce overall memory consumption / number of instructions by a tiny bit because we don't need to copy this structure onto the stack--we can just use it in place. As written (or by just adding const but not static const): qmp_probe() is 1840 bytes long. ...and has this snippet: 0xffffff80084a58d4 <+1152>: adrp x1, 0xffffff8008a5b000 0xffffff80084a58d8 <+1156>: add x1, x1, #0x600 0xffffff80084a58dc <+1160>: add x0, sp, #0x10 0xffffff80084a58e0 <+1164>: mov w2, #0x28 // #40 0xffffff80084a58e4 <+1168>: add x22, sp, #0x10 0xffffff80084a58e8 <+1172>: bl 0xffffff800896e800 With this as static const: qmp_probe is 1820 bytes long. ...and has this snippet: 0xffffff80084a58dc <+1160>: adrp x8, 0xffffff8008a5b000 0xffffff80084a58e0 <+1164>: add x8, x8, #0x550 > The clk_init_data structure is all copied over, although we do leave a > dangling pointer to it stored inside the clk_hw structure we don't use > it after clk registration. Maybe we should overwrite the pointer with > NULL once we're done in clk_register() so that clk providers can't use > it. It might break somebody but would at least clarify this point. Setting it to NULL seems like it would be a good idea. Now that I think on it I believe I've actually tripped over this before trying to read the '.name' from here... :-P > > > +static void qmp_pd_remove(struct qmp *qmp) > > > +{ > > > + struct genpd_onecell_data *data = &qmp->pd_data; > > > + struct device *dev = qmp->dev; > > > + int i; > > > + > > > + of_genpd_del_provider(dev->of_node); > > > + > > > + for (i = 0; i < data->num_domains; i++) > > > + pm_genpd_remove(data->domains[i]); > > > > Still feels like the above loop would be better as: > > for (i = data->num_domains - 1; i >= 0; i--) > > > > Reason being to remove in reverse order? Otherwise this looks like an > opinion. 1. Matches the order of the error handling case above (see unroll_genpds label) 2. In general you avoid more unexpected problems by un-initting in the reverse order you initted. -Doug