Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9429880imu; Sat, 29 Dec 2018 19:30:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/XtwRGB75zqnoPhLmywTRn9M95BdYbdj2dj0MDIbnDI0b/YGgwk3nkoztmPj74JTA9L+Nsk X-Received: by 2002:a62:6b8a:: with SMTP id g132mr33405598pfc.201.1546140617734; Sat, 29 Dec 2018 19:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546140617; cv=none; d=google.com; s=arc-20160816; b=r9VX18zUVyW5tnzH6kgqqLrn0M9D6R6xiCWwfbw4etf814CEKlBwhFkPWnyZ1Wl+ef 3jiJ9jZO7bBqJUFpHG7vN74xk9bS3ldpatG52uO2Z2c0GHQqtQ334O8kWY6bOxn3Q+gz 1kSH/chpPalYry75vkv8NPFEraauVZFL95OH9f/YM/KL+AC3CgfL+FwO16EW6VYMfKz+ 2ouU7ZaIbhJAJ2zxnl+Gi8e54spJlZ75+OJp8sVNEHv9TsBAcGy9Y3dl2Fxz32ghaKt3 oV2ZOQJbOI9Bj72E9GHEgdfjCKiK8mEesOnJQeK85iTgCOJFe4CRFMhtn6f5ndKlBte0 QOPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=dSXAa6qa07YJwoHZhh34pFXq6p3zrwTjOBaBvZnaeaQ=; b=DCsjamTkl1letCC1lho75JnxJVqwBYliWx759VQpGa+6ECLKUZWVZjpxWvKLvHRVeP Y8FfTHRlLJ1RV0tC5V5EpeVWCm1mY9wqGv7OpesCMr0zcckDphkRpuyIdNjuwxJgjhqr fDLs87a0rPhf0JP+RLdzfIlZuCMVfqhtvZdkneMeBEK3YAuV0sC9/0FhIhsPypgIzvBB dtELv4wagOot16kS+7IhaICdrv3ddJcSxlXEJEmTy1nHK/+PFyuUxTIKHWwjp+VQ5Kku 1iWvD+9GUJ3WxvV6FNzlPJJJxijA31iAPWgMKEzNKuqzouz6bKlv6v4B8MlfVvCXqPIW XsGQ== 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 m30si45180246pff.158.2018.12.29.19.29.59; Sat, 29 Dec 2018 19:30:17 -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 S1725926AbeL3D3I (ORCPT + 99 others); Sat, 29 Dec 2018 22:29:08 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:50362 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbeL3D3H (ORCPT ); Sat, 29 Dec 2018 22:29:07 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id CF1AB28EDF; Sat, 29 Dec 2018 22:29:03 -0500 (EST) Date: Sun, 30 Dec 2018 14:28:56 +1100 (AEDT) From: Finn Thain To: Arnd Bergmann cc: Greg Kroah-Hartman , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Linux Kernel Mailing List , linux-m68k , linuxppc-dev Subject: Re: [PATCH v8 24/25] powerpc: Adopt nvram module for PPC64 In-Reply-To: Message-ID: References: <2fe2b8e6395aeacfafcbde590a50922d4e632189.1545784679.git.fthain@telegraphics.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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. -- > Arnd >