Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11289667imu; Mon, 31 Dec 2018 18:25:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN4btpGVuLF4uze6wEhp0ixh6Mx0LMUM8iaEBIjHdE6o+KlNpw2PHft6KZeXUDgGIm994qtb X-Received: by 2002:a63:bd51:: with SMTP id d17mr9465013pgp.443.1546309536875; Mon, 31 Dec 2018 18:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546309536; cv=none; d=google.com; s=arc-20160816; b=dmNxvO3qhDIsMp2uW1ppFYem9FRvM4iUmkxm/5oUvR3oE9bV6ov3lSbshhI6u3TbOJ hgIKOF1JGyqjhmle66gu27nwWCYX3W4xWNZh3/JFDK0Z2P1SG3Off00URwqdsyQVrvsy E01uyqyhLQ4/dlL/iHqvnA9I64CJdHr76xndO4wE4SZSLK5COID6548CzveCyCkmbuWw 6A8HyhHX+94vaSw5S5XWlGrfnMsSojePGZHocQ0dwa2MigYPWOK9Y0rILfqJkthwWlWR 0YsgyI0x4o7fFPedRwiYCCA4BILRuoowzyDpGXBpTt+mBj28ASowHHjVFfA61iTb2Nki q80w== 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=0H6UiZfndVZTEY0GYwxZjQXTfOOqRqBzUDXyczZbJdg=; b=rUMfe+hpJGq8EKvoEYD+BWzcvAlbSqEMNygQVioEKV9Bixcjwo1Pi+S5w/TyOcfJMC VEDadN5cZieoB1E4qH9oAYAJd5gylmFI1jJ35GQ/ALQ10QymL9EqAMjG59XMYBHLUkeJ RB8FZrrY+bAu4/Z9GRZGPoYY2DXAvaVtFI22GnQkr3nI8KNSYwdHwfjnlhUbCCFHMaXa cZEaQkwq4Wq9rYVTo/Cx5Ou68g+lVXLayFT5+zPMy5yS/tDccdmy82HijUkYXUZilEqb 5+OYa1kPRL2/qB7U+7Rtw/wrMlDlFtStH95bEZJZfNTduMCkrRDC7WPyi7iXensgkpav umyw== 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 z2si1717843pgs.267.2018.12.31.18.25.21; Mon, 31 Dec 2018 18:25:36 -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 S1728246AbfAABis (ORCPT + 99 others); Mon, 31 Dec 2018 20:38:48 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:59170 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728232AbfAABis (ORCPT ); Mon, 31 Dec 2018 20:38:48 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 0F38329CD9; Mon, 31 Dec 2018 20:38:41 -0500 (EST) Date: Tue, 1 Jan 2019 12:38:38 +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 Mon, 31 Dec 2018, Arnd Bergmann wrote: > 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. > This "early init time" could be hard to pin down... It has to be after ppc_md methods are initialized but before the nvram_ops methods get used (e.g. by the framebuffer console). Seems a bit fragile (?) Your suggestion to completely remove the ppc_md.nvram* methods might be a better way. It just means functions get assigned to nvram_ops pointers instead of ppc_md pointers. The patch is simple enough, but it assumes that arch_nvram_ops is not const. The struct machdep_calls ppc_md is not const, so should we worry about dropping the const for the struct nvram_ops arch_nvram_ops? -- > Arnd >