Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10674319imu; Mon, 31 Dec 2018 04:35:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN6SXSp2AXVdab8rjxz9wmpViEbXAdjQLH58AsKkRSnB2VLR4J7ySy1S6s1ZPGpeg7alR64K X-Received: by 2002:a63:9e19:: with SMTP id s25mr7420791pgd.203.1546259748284; Mon, 31 Dec 2018 04:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546259748; cv=none; d=google.com; s=arc-20160816; b=jQOy8IB0gGftl1MJsIp7fPtszvoAxsrPDzYxLf+oXeaGDjf0auoYxflvb/Gpwo8x1D uT4EZgmoikGVofVBmJBcJswFxf9JVc5CI8HD02dhsL1FLE8FWtbweLbY41mac9CHz3ZH Gf3vwSjso+Gf/kfqllMEyuPLJZWhOQPwM7EEsNUYhuATgMm+a4s8LDPVKPiWSiH6DLTM Yf9j8vGeZwzZFpbRjpFk9TCCMjZDcvb1dq88zSoAWfyiLogvVDhtPnYhX/2GIHrVhezQ lsBwvYdgCRKv8KKz0oKUV4TZWgmyouARWcLk3vuHUz3jcLKkejdRsF4ZPT9cMT2npMRY fl2Q== 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; bh=RwU2Y+gpTZt+nue9fhxVSylTa7plk4FrzInK4LqoluI=; b=1GT9ermZHXo2rqjOeJAEA2lPzVMZ49U3L6ThRB+AjvkiAI39gPLN2CNAQZw4iGWLbV HwWg2PqgH6y3wZYotSk4wtnFrdSUwxrgXpMVKaj08oMW7/BU7XXqbsUjzgHIrulLhDb+ X5Dbi9Ng8jVeWcu8fB/AtbT1uJ0PKNzJsjrQMJSwgk/z6FDbpKNPWuRXr5c9Etjv3x9l l0tUnmWcWJEDdy9zbiTjuyJnyDet7/LqH/SUNWjH2C7lWvyfTAUHmeGRX/EqWadfQjQg lTzUJC05kRGZIMadTU4ABds+H7U6HNsJDsLf7BqNDdX0/2F/3KUXWPYV9mjfwfODQB7I hTUg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si36677091pfz.249.2018.12.31.04.35.32; Mon, 31 Dec 2018 04:35:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbeLaMdO (ORCPT + 99 others); Mon, 31 Dec 2018 07:33:14 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:36099 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727220AbeLaMdN (ORCPT ); Mon, 31 Dec 2018 07:33:13 -0500 Received: by mail-qt1-f194.google.com with SMTP id t13so29186932qtn.3 for ; Mon, 31 Dec 2018 04:33:13 -0800 (PST) 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=RwU2Y+gpTZt+nue9fhxVSylTa7plk4FrzInK4LqoluI=; b=PY7tuM8J6UGp9DMtdlObosrhaDLjkQ5KEhASoyFGqUGpOCk8WCRoHkyvd0x0PvLHZy si1+fzB9igTHtEWh6Rbt5HGOCeERQS7FIMTQZeL6LUV1sUsK3H4z9DgT1GNY8CAR7Y6g OxB2DmoJllAICmVQazEq0XX8yCl0IulKj0RzBb4l/yIOH98xFMenNi5FTriUm6Z2Zukk MJEzEeMJ7bsWdZeOePTPPCtpGeWE0s2xXumO93EJUjWowPpt1z1SpLxti0IauW/lDeEI Rnws/7ZKKeUtkTYx20sg/Hl8BV7GCmxiHUAd2KI/XVLFVVZBlv6f9gK0nNNp7Q5GaUH3 iCdg== X-Gm-Message-State: AJcUukcMTcGFcmUQw7T48ky5rGerG7b7QAx8WKmJNkCEenwshXk+TXVQ Cs6YydIQ/dr3MwLXanse8R1bvlTXaQhefKqOwTA= X-Received: by 2002:a0c:f50c:: with SMTP id j12mr35192233qvm.149.1546259592841; Mon, 31 Dec 2018 04:33:12 -0800 (PST) MIME-Version: 1.0 References: <2fe2b8e6395aeacfafcbde590a50922d4e632189.1545784679.git.fthain@telegraphics.com.au> In-Reply-To: From: Arnd Bergmann Date: Mon, 31 Dec 2018 13:32:56 +0100 Message-ID: Subject: Re: [PATCH v8 24/25] powerpc: Adopt nvram module for PPC64 To: Finn Thain Cc: Greg Kroah-Hartman , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Linux Kernel Mailing List , linux-m68k , linuxppc-dev 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 On Sun, Dec 30, 2018 at 4:29 AM Finn Thain wrote: > > On Sat, 29 Dec 2018, Arnd Bergmann wrote: > > > On Wed, Dec 26, 2018 at 1:43 AM Finn Thain wrote: > > > > > +static ssize_t ppc_nvram_get_size(void) > > > +{ > > > + if (ppc_md.nvram_size) > > > + return ppc_md.nvram_size(); > > > + return -ENODEV; > > > +} > > > > > +const struct nvram_ops arch_nvram_ops = { > > > + .read = ppc_nvram_read, > > > + .write = ppc_nvram_write, > > > + .get_size = ppc_nvram_get_size, > > > + .sync = ppc_nvram_sync, > > > +}; > > > > Coming back to this after my comment on the m68k side, I notice that > > there is now a double indirection through function pointers. Have you > > considered completely removing the operations from ppc_md instead by > > having multiple copies of nvram_ops? > > > > I considered a few alternatives. I figured that it was refactoring that > could be deferred, as it would be confined to arch/powerpc. I was more > interested in the cross-platform API. Fair enough. > > With the current method, it does seem odd to have a single > > per-architecture instance of the exported structure containing function > > pointers. This doesn't give us the flexibility of having multiple copies > > in the kernel the way that ppc_md does, but it adds overhead compared to > > simply exporting the functions directly. > > > > You're right, there is overhead here. > > With a bit of auditing, wrappers like the one you quoted (which merely > checks whether or not a ppc_md method is implemented) could surely be > avoided. > > The arch_nvram_ops methods are supposed to optional (that is, they are > allowed to be NULL). > > We could call exactly the same function pointers though either ppc_md or > arch_nvram_ops. That would avoid the double indirection. I think you can have a 'const' structure in the __ro_after_init section, so without changing anything else, powerpc could just copy the function pointers from ppc_md into the arch_nvram_ops at early init time, which should ideally simplify your implementation as well. Arnd