Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4742223pjb; Mon, 27 Jul 2020 04:06:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlwkf0fc2cZnDrDDjLut0231Vd51oGbjHs5LrhkMbfAyIz7TAnM8p1Cv0nwyjLw13IpVCS X-Received: by 2002:a17:907:aaa:: with SMTP id bz10mr518759ejc.304.1595848004000; Mon, 27 Jul 2020 04:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595848003; cv=none; d=google.com; s=arc-20160816; b=WONFfYgQWv/oZhqe702TVT5sGD4U2AiAyWfDb2YZXbErR+BjxDsblIgCQJnCuoJEO5 /+unPENnlrJ1G7I361im+nhHngg9a66PllmcrbOQryoJhGe5zNsx7KCfV0KCfbSLd6rm oMdr99Ujk4bgQSRpS49DxfaHatyJ3IgyAphcr+Mjd9AGD/RpLWYwFxjn4bSxascyseSS V1oE6dARyyEyn5++RjzYjKzBXNHwDjLNUWFcNKhpx7wkUfF8gX3Jw/t7cj2NDpCOPc+3 V4ybSJmryrnBg4HKJHGQ4EmK8lUEXRRQw0jvuE7KmSazvgAVkK1naTM4scrVxhqg338u kVnQ== 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=4pdtIEMdEHZROMmnLVo236Ck5DopycdDDJwDknG0oGo=; b=MCNHnwDddkKdaPEKZV25I9cdED7ZBXvZEcf3xb7xdbM4XyltCMfgmorPN9ldsV/2UM /dB9pTu3Z/2ab227mqdp4xuZJhNyJeu0gLY89LGDxEJdH3O3jA6aDWB6DapL5Rm5xF8n M7+l9BpBTQPKsibQiZNJ/nQpBYF2QjNF5CC5PnwLRXrdFXk2Tr5+cUThQh3Y18YUhIkh g3QgZPcvoxAhJtxP6QsGxe76RXNJAwCdWhUrD0HJjcrhgwGgTXqeumwTz02vJ3bYcC8+ 61n3u/T43AS92WAX5/S/prgE5oRajK38/E0lXW7NRq8GAykbudBO5x6hqGRe2hUkPXZ2 LJVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si874441ejm.377.2020.07.27.04.06.21; Mon, 27 Jul 2020 04:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728176AbgG0KoY (ORCPT + 99 others); Mon, 27 Jul 2020 06:44:24 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:53339 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727897AbgG0KoX (ORCPT ); Mon, 27 Jul 2020 06:44:23 -0400 Received: from mail-qv1-f54.google.com ([209.85.219.54]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPSA (Nemesis) id 1MjjOl-1kfN7e0U4x-00lGCB; Mon, 27 Jul 2020 12:44:21 +0200 Received: by mail-qv1-f54.google.com with SMTP id s15so2753219qvv.7; Mon, 27 Jul 2020 03:44:20 -0700 (PDT) X-Gm-Message-State: AOAM531kv6+eVfJIW3zBDkVWmVxrXMnUUbxvRBJE/UGhhFdszoH5wuAo IVH6i69BlVcUVe+LbUxMMVs9owJXXAR5nJ/XUEs= X-Received: by 2002:ad4:44e5:: with SMTP id p5mr5320907qvt.197.1595846659806; Mon, 27 Jul 2020 03:44:19 -0700 (PDT) MIME-Version: 1.0 References: <1595382353-17486-1-git-send-email-Anson.Huang@nxp.com> In-Reply-To: From: Arnd Bergmann Date: Mon, 27 Jul 2020 12:44:03 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V2 1/4] gpio: mxc: Support module build To: Anson Huang Cc: Russell King - ARM Linux , Shawn Guo , Sascha Hauer , Sascha Hauer , Fabio Estevam , Catalin Marinas , Will Deacon , Linus Walleij , Bartosz Golaszewski , Peter Chen , "oleksandr.suvorov@toradex.com" , Andreas Kemnade , Peng Fan , Hans Verkuil , Olof Johansson , Krzysztof Kozlowski , Alexandre Torgue , Patrice Chotard , Marek Szyprowski , Joel Stanley , Lubomir Rintel , Christian Gmeiner , Bjorn Andersson , Leo Li , Geert Uytterhoeven , "michael@walle.cc" , Linux ARM , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" , dl-linux-imx Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:z+cy1YNlMdO3jfv0k640ByP7SFEBeCAIaWwTls5vlMvnYEIghax rNxYSGRG2T2kfIcblyQXoCCSKrVWKD9sGaVLT9YQHvFX/u9VzYUTPLllWudZ2J33ubJPxdS v2ccZhiWQ5ap37OQlktljezwQi6WCyrlwPqjRnxEY22i5ro7uJatt0mf+YmLSNLFL+g8nHL lG9fAt/FjXc5/CzWYm5Wg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:wslqdFZ1lh4=:dl/oPsLfIcaHogn6hFEBTp pJM4ej1DWuSSOtjH3pbD6NeZUBn6ly1cZydmbMPEN+d/+ASjQav1gZRnfetrROGmbOHwLGaJe hdSKjst6lbNVHChotg6LS2v835eoZU0e6IsA5drNeieeVPfNKVIWbBoMw87Qbz0rFNqpHQjft cXOWpIon5Tw1u0I4KcGJCXWebrzhJtj2ZKJjyvS/Xr+4MTMydgePrjOl/uEYesNa4+eF462iU PcYH7Y/2fPFkzu4OdLjet4iXlKNYE0MddYSi1IFt6a/IQ7lAj1sE5IC4b7fqKAct1FH8JtrFp 8WH3D5ybbRtST8LCmEXMUuzX9vpnfg1hCaimcgq2CBoDuvOHobBPLhm3YfBi+qepci575Zh4/ t043WzAc88GS8alcl5wijjqwW10Pvb3oG+PKnnA8WVB5soj+dKpq5MQeaIu+i7NOLnTh+emnB 31TRoxoJErfpOeOBIjqVFsrn4Zf4QhTdK6cKKLXxqfQxiKTOl712D5mfS7932spp3UOUoP0vW jQQWEiBi8frgUSnIAGEwU/W6iQMXZvsQU8mcY0PXVQEfERca1Rj58MqwVSUhL4ke0ZPH7cQPI iW3DFhdYXjkt7m/BRqblWtixzafkr65Uu33DFU6xdARXVoSaeKTNPpE/4PhaT14GvwzwtUwhC N7EydnKHaQl7wDQvqPBOwUyEWrf7spkiA9h8yQtTQkNXP5azVrfDEjLClWobu+hJlEtolugGc 2GOdgk03lCBLK+5cGIcYDpxuJHV7HW3haS6mUyghu62KoLf22jK8n1GcyooV3sA3aH2yokWFn uVwNfYnbrE3+xspRxOxxb9pJpcS4UXbm/QUWbKRiDGaigMMuI+XkpDR/tdqs0EU14X8nFd8hf sSkqp5V10ZbVNzBsjxkWYSW9PjR5vnFOtsyYv5izmTVmaMekT6hvOMoEoZ6ZO/eA6BUolaV1g cm5vu3XRodY+Xxjxha0++ExXJx6AFzYAreFqVaT7KVAU1m5m1m1we Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 10:18 AM Anson Huang wrote: > > Subject: Re: [PATCH V2 1/4] gpio: mxc: Support module build > > > > On Wed, Jul 22, 2020 at 3:50 AM Anson Huang > > wrote: > > > > > > Change config to tristate, add module device table, module author, > > > description and license to support module build for i.MX GPIO driver. > > > > > > As this is a SoC GPIO module, it provides common functions for most of > > > the peripheral devices, such as GPIO pins control, secondary interrupt > > > controller for GPIO pins IRQ etc., without GPIO driver, most of the > > > peripheral devices will NOT work properly, so GPIO module is similar > > > with clock, pinctrl driver that should be loaded ONCE and never > > > unloaded. > > > > > > Since MXC GPIO driver needs to have init function to register syscore > > > ops once, here still use subsys_initcall(), NOT module_platform_driver(). > > > > I'm not following this explanation. > > > > Why is this driver using syscore_ops rather than > > SIMPLE_DEV_PM_OPS() or similar? > > Below is the original patch of using syscore_ops, it has explanation: > > commit 1a5287a3dbc34cd0c02c8f64c9131bd23cdfe2bb > Author: Anson Huang > Date: Fri Nov 9 04:56:56 2018 +0000 > > gpio: mxc: move gpio noirq suspend/resume to syscore phase > > During noirq suspend/resume phase, GPIO irq could arrive > and its registers like IMR will be changed by irq handle > process, to make the GPIO registers exactly when it is > powered ON after resume, move the GPIO noirq suspend/resume > callback to syscore suspend/resume phase, local irq is > disabled at this phase so GPIO registers are atomic. The description makes sense, but this must be a problem that other gpio/pinctrl irqchip drivers have as well. Linus, could you have a look? I see these other pinctrl drivers using SIMPLE_DEV_PM_OPS: drivers/pinctrl/nomadik/pinctrl-nomadik.c:static SIMPLE_DEV_PM_OPS(nmk_pinctrl_pm_ops, drivers/pinctrl/pinctrl-rockchip.c:static SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, rockchip_pinctrl_suspend, drivers/pinctrl/pinctrl-stmfx.c:static SIMPLE_DEV_PM_OPS(stmfx_pinctrl_dev_pm_ops, drivers/pinctrl/qcom/pinctrl-msm.c:SIMPLE_DEV_PM_OPS(msm_pinctrl_dev_pm_ops, msm_pinctrl_suspend, drivers/pinctrl/spear/pinctrl-plgpio.c:static SIMPLE_DEV_PM_OPS(plgpio_dev_pm_ops, plgpio_suspend, plgpio_resume); Linus, can you have a look and see if that same problem applies to all of the above? It seems that some drivers use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS() instead, which looks like it is meant to address the same problem, but as I have not used that myself, I may be misunderstanding the problem or what this one does. > > Why do you need subsys_initcall() rather than a device_initcall()? > > The subsys_initcal() is done by below commit, the commit log has detail explanation. > > > commit e188cbf7564fba80e8339b9406e8740f3e495c63 > Author: Vladimir Zapolskiy > Date: Thu Sep 8 04:48:15 2016 +0300 > > gpio: mxc: shift gpio_mxc_init() to subsys_initcall level That commit made the initialization later not earlier, as it originally was a postcore_initcall(). In the loadable module case, you make it even later than that, possibly as the last module loaded when booting up the system (followed by a storm of deferred probes). > > If the subsys_initcall() is indeed required here instead of device_initcall(), how > > can it work if the driver is a loadable module? > > My understanding is: there are two scenarios, one for built-in case, the other is for loadable module, > the subsys_initcall() is for built-in case according to the upper commit, for loadable > module, the user needs to handle the sequence of modules loaded. I don't think we can rely on user space to coordinate module load order. The modules are generally loaded in an arbitrary order during the coldplug phase of the boot when user space looks at the available devices and loads a module for each one of them in the order it finds them in sysfs. This means all drivers that rely on gpio, pinctrl or irqchip interfaces exported from this driver have to be able to deal with them not being there. This can also happen when the pinctrl driver is the only one that is a loadable module, while everything else is built-in. While that is not a configuration that users would likely choose intentionally, I don't see a reason why it shouldn't work. Using module_init() or builtin_platform_driver() here would make give similar behavior for the built-in and modular cases and be somewhat more consistent, so you don't run into bugs only when the driver is a loadable module but make them obvious even to existing users with a builtin driver. Arnd