Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4520899imu; Tue, 8 Jan 2019 01:30:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN558pRUif/RDubwwO39a4DK1w4B049TVXOwDTqMiMXL6CifcMs7pMMCazeXjOG4fcW5BgCY X-Received: by 2002:a17:902:4503:: with SMTP id m3mr1029874pld.23.1546939803845; Tue, 08 Jan 2019 01:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546939803; cv=none; d=google.com; s=arc-20160816; b=y9VRf8Xl/5kpz3YVdw1nMactJA6VnLVDX/aef8veFUZPOc4YZiyfRL0cqH7FxMRFY+ BLA8ZnGjQulQ9/HtNAEXWYqYHqotFiwMmoWMw10SYlLI5IgS5kSRa2UG6YhY18GU2D5h Mp7ceisLsMou5/YSYbdJe5rEHFi+D8PNcx+Y56kH9ZxeTpDZgr6flGTL9AMxASN4aIrW ks7FJRntoRQH/E1j+Ba1QNdM1GIFKPMJYTIp0hY0tXScKDYNSIi6iNradk7WhDc8ZiuL ZfVGf31NsnT7eJKtV1xpIFNRJ7YjihW517moDzLNq0x+wvB+84CcfjkFhLOMemdXzpDz UZAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=LJ302+IKmGlPG0FIAXbMYxctxFfK6VsY8zQ4sCFKoWw=; b=xSYBCIEDeS5hXHUlYpT8VrCqrs1E5wc/Hjq9mblaH6YIXcF5zX1AfV8leY2461QvKi SazoCPcy0rHAlBtNiF+F8k/m8I9DEqVSLPULeMd5nk7aVrCdYtfmpxWqPTqro0A2Ychy DUzZpih1Z3U7Z3ADHnv1+8pGMJv8oW2bgLF240tP7cjOwGbWrVHoWLMy/5DrVilPJzBx /S2lt3YDZSu41gLZx45jzn9Ogb/wZILsEqV+/8jGZvYk9LwucvkR7j44opRaWcYwJrfy Ntml12pCrVbDhJcAbX11aI3QKpV//sah0aFeXZcSbtwMTZlkO1lu2rK52JG+/RoRz1EC iTjQ== 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 v185si12920565pfb.65.2019.01.08.01.29.48; Tue, 08 Jan 2019 01:30:03 -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 S1728442AbfAHJ1d (ORCPT + 99 others); Tue, 8 Jan 2019 04:27:33 -0500 Received: from ozlabs.org ([203.11.71.1]:60031 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727381AbfAHJ1d (ORCPT ); Tue, 8 Jan 2019 04:27:33 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 43Yn3N4vjcz9sMQ; Tue, 8 Jan 2019 20:27:28 +1100 (AEDT) From: Michael Ellerman To: Finn Thain Cc: Arnd Bergmann , Greg Kroah-Hartman , Benjamin Herrenschmidt , Paul Mackerras , Linux Kernel Mailing List , linux-m68k , linuxppc-dev Subject: Re: [PATCH v8 24/25] powerpc: Adopt nvram module for PPC64 In-Reply-To: References: <2fe2b8e6395aeacfafcbde590a50922d4e632189.1545784679.git.fthain@telegraphics.com.au> <8736q5xst1.fsf@concordia.ellerman.id.au> Date: Tue, 08 Jan 2019 20:27:27 +1100 Message-ID: <87h8ejts74.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Finn Thain writes: > On Mon, 7 Jan 2019, Michael Ellerman wrote: > >> Arnd Bergmann writes: >> > 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? >> > >> > 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. >> >> Yeah TBH I'm not convinced the arch ops is the best solution. >> >> Why can't each arch just implement the required ops functions? On ppc >> we'd still use ppc_md but that would be a ppc detail. >> >> Optional ops are fairly easy to support by providing a default >> implementation, eg. instead of: >> >> + if (arch_nvram_ops.get_size == NULL) >> + return -ENODEV; >> + >> + nvram_size = arch_nvram_ops.get_size(); >> + if (nvram_size < 0) >> + return nvram_size; >> >> >> We do in some header: >> >> #ifndef arch_nvram_get_size >> static inline int arch_nvram_get_size(void) >> { >> return -ENODEV; >> } >> #endif >> >> And then: >> >> nvram_size = arch_nvram_get_size(); >> if (nvram_size < 0) >> return nvram_size; >> >> >> But I haven't digested the whole series so maybe I'm missing something? >> > > The reason why that doesn't work boils down to introspection. (This was > mentioned elsewhere in this email thread.) For example, we presently have > code like this, > > ssize_t nvram_get_size(void) > { > if (ppc_md.nvram_size) > return ppc_md.nvram_size(); > return -1; > } > EXPORT_SYMBOL(nvram_get_size); > > This construction means we get to decide at run-time which of the NVRAM > functions should be used. (Whereas your example makes a build-time decision.) Right, but we only need to make a runtime decision on powerpc (right?). So it seems to me we should isolate that in the powerpc code. > The purpose of arch_nvram_ops is much the same. That is, it does for m68k > and x86 what ppc_md already does for ppc32 and ppc64. (And once these > platforms share an API like this, they can share more driver code, and > reduce duplicated code.) > The approach taken in this series was to push the arch_nvram_ops approach > as far as possible, because by making everything fit into that regime it > immediately became apparent where architectures and platforms have > diverged, creating weird inconsistencies like the differences in sync > ioctl behaviour between ppc32 and ppc64 for core99. (Early revisions of > this series exposed more issues like bugs and dead code that got addressed > elsewhere.) I just don't see the advantage of having arch_nvram_ops which is a structure of function pointers that are always the same on a given arch, vs some static inlines that implement the same ops for that arch. > Problem is, as Arnd pointed out, powerpc doesn't need both kinds of ops > struct. So I'm rewriting this series in such a way that powerpc doesn't > have to implement both. This rewrite is going to look totally different > for powerpc (though not for x86 or m68k) so you might want to wait for me > to post v9 before spending more time on code review. OK. I know you've been working on this series for a long time and I don't want to roadblock it, so at the end of the day I don't feel that strongly about it as long as the code works. I'll wait for v9 and have another look then. cheers