Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp293201ybh; Mon, 20 Jul 2020 17:08:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu+IXfMIbzbDsXW0JYagAl+FQzCouabAKKUBp6+a5nBd7LjIMVq8Vedlb744Jd36KtJ5li X-Received: by 2002:a17:906:cd18:: with SMTP id oz24mr23636320ejb.118.1595290098536; Mon, 20 Jul 2020 17:08:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595290098; cv=none; d=google.com; s=arc-20160816; b=tl3Og0lY4eq+tzQoQQNW2s5AV2PfGc+d1cdqiccSQpKdcGN5nQVSk26WGx19lu0Jm8 ERsDOsE9pSyKFkwtX7SWcn1Nt4SLKU6feLW3w2jVb+TivksT4QBJIZo21tfyOCtXWwRd q0ySFzQf8YqLyxPAusCLmkgmK2Uf44xvraToml8L5EaM2sMlYzO98T1vBmTxNstgu2Zw 6yHphTAz3rKkaUGVuyPz2LDdSYAoFkHtYqR0t9cq/dMmkVRsAi/0yOOrWQZx5CrkTM96 AjAMFkDaSMte939G/zUq0leF6Rl3L0SS2t1oAcGyYn5t4msCROeY6oB25k1mN7sULOY7 BmCg== 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:dkim-signature; bh=xOY9CX+MZHC2V2Y5UgG6sQVWIz0SPS7mgtXJ/kyBZLQ=; b=qM/Ytk/zk8e/zf/7WqtxM7gTeNQXx/S6IBXBsCFTZbZ38NlNQacD+BitCMkJP3Rou1 /bnFe79bE6Fj120ME2dGvrRn39NyRWZWMOKCnb80wh6zsTWKdMeeYscPo0+V1Fy8bh14 1POxP11Q+/W+DHJXW0AwuamMp6LOMEFz6aaiNvEFwkyxBPvxBwLSYW/NE0e1oIZax/Hh B3u7ltPTkgReQbtYXN1Qjur6FkB6ghnBNuKdoHWyTO5h1hoA0jHJemlFYg2pQHFO2b63 uhewNNv7fo9PVu619kBte+v0JJmkQiABaKtmlBbMQ4iZwjSpk7Lttopoxt54WwHj8AFi MsQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OI1GkTyW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si12548199edq.569.2020.07.20.17.07.55; Mon, 20 Jul 2020 17:08:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=OI1GkTyW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728158AbgGUAEn (ORCPT + 99 others); Mon, 20 Jul 2020 20:04:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgGUAEm (ORCPT ); Mon, 20 Jul 2020 20:04:42 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF16C061794 for ; Mon, 20 Jul 2020 17:04:42 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id t198so15806136oie.7 for ; Mon, 20 Jul 2020 17:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xOY9CX+MZHC2V2Y5UgG6sQVWIz0SPS7mgtXJ/kyBZLQ=; b=OI1GkTyWGwpZMaOMU8iZTFA5YLZeTO4J0Gi6nqF6lqBL8xCBBte3BfsQtK+anpB/UZ WagIowBQjTb81OiMOAVj9dHWBzpmq1XzrYVi5LKy0cODqOLYm0NgkKgyxVD0ZNC5Wlf5 JfRr4uQ3/RTR4r/PU1cg2DbuaPGaos3ufKUlJYYkW+bDqbjuTedVYKYGILWMdD84AefQ Ob1vx8oKp2oFepYfJS2UAmvnOVVQuq6wqAwDnXIjfQFza5V8BrrRC1xeV8aJNCYNG/zp 7BqyIfKubSLmw/3cB1q40v0c6kAairj9PAnDAJoMrAV2K5yLUdZIH0wBYVZYhJSki4aW y9kA== 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=xOY9CX+MZHC2V2Y5UgG6sQVWIz0SPS7mgtXJ/kyBZLQ=; b=qKGzYbGlSNs4ngz7/hz1z3iWaoPufIwebAKOI650mf4ZgWGJvCuTK6NJsDlIiSI0bX GTWceAG6p2ZcJuLcauMGQ4VfLH9hlW9KKRopsYuXCbD5JVVbWUM9EldRgqUWJ5sB9XVI Gry9CU2RXPaxcWOdZ0vOHJ+fhiFDv9auD9l2dzXKZlp62RNhiqgfXltQ2np9kbS42JK4 /2e1Z426JcE4Hrd2H9uI+bYI39NPD/5aR3ULzJ+Q+rKcvFOfxHYhygswTbmL4Q+7ePYF OeZ7afewhvNHJ4o4N2UfC91QboiqR6ZoUgHzqUbXlD2nucrjfXt2Rd1vJ9i6VKApH7fA kSdw== X-Gm-Message-State: AOAM532A+hzqfQPIr1cBhzrKPL4aYhH4WjAyCe1a0TSfjCY1HPeMC+6A bglxyEdQTExKkMmlwu4QWTd6o0aQQx+V0nvC/myGyA== X-Received: by 2002:aca:c4d5:: with SMTP id u204mr1225134oif.169.1595289881299; Mon, 20 Jul 2020 17:04:41 -0700 (PDT) MIME-Version: 1.0 References: <1594164323-14920-1-git-send-email-Anson.Huang@nxp.com> In-Reply-To: From: John Stultz Date: Mon, 20 Jul 2020 17:04:29 -0700 Message-ID: Subject: Re: [PATCH 1/3] gpio: mxc: Support module build To: Linus Walleij Cc: Anson Huang , Greg KH , Russell King , Shawn Guo , Sascha Hauer , Sascha Hauer , Fabio Estevam , Catalin Marinas , Will Deacon , Bartosz Golaszewski , "oleksandr.suvorov@toradex.com" , Adam Ford , Andreas Kemnade , "hverkuil-cisco@xs4all.nl" , Bjorn Andersson , Leo Li , Vinod Koul , Geert Uytterhoeven , Olof Johansson , Linux ARM , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" , dl-linux-imx , Jon Corbet 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 Fri, Jul 17, 2020 at 5:01 AM Linus Walleij wrote: > > Greg, John, > > we need some guidance here. See below. > > On Thu, Jul 16, 2020 at 4:38 PM Anson Huang wrote: > > [Me] > > > On Wed, Jul 15, 2020 at 4:44 AM Anson Huang > > > > > I tried to replace the subsys_initcall() with > > > > module_platform_driver(), but met issue about " > > > > register_syscore_ops(&mxc_gpio_syscore_ops);" which is called in > > > > gpio_mxc_init() function, this function should be called ONLY once, > > > > moving it to .probe function is NOT working, so we may need to keep the > > > > gpio_mxc_init(), that is another reason that we may need to keep > > > > subsys_initcall()? > > > > > > This looks a bit dangerous to keep like this while allowing this code to be used > > > from a module. > > > > > > What happens if you insmod and rmmod this a few times, really? > > > How is this tested? > > > > > > This is not really modularized if that isn't working, just that modprobing once > > > works isn't real modularization IMO, it seems more like a quick and dirty way > > > to get Androids GKI somewhat working with the module while not properly > > > making the module a module. > > > > > > You need input from the driver maintainers on how to handle this. > > > > As far as I know, some general/critical modules are NOT supporting rmmod, like > > clk, pinctrl, gpio etc., and I am NOT sure whether Android GKI need to support > > rmmod for these system-wide-used module, I will ask them for more detail about > > this. > > > > The requirement I received is to support loadable module, but so far no hard requirement > > to support module remove for gpio driver, so, is it OK to add it step by step, and this patch > > series ONLY to support module build and one time modprobe? > > While I am a big fan of the Android GKI initiative this needs to be aligned > with the Linux core maintainers, so let's ask Greg. I am also paging > John Stultz on this: he is close to this action. > > They both know the Android people very well. > > So there is a rationale like this going on: in order to achieve GKI goals > and have as much as possible of the Linux kernel stashed into loadable > kernel modules, it has been elevated to modus operandi amongst > the developers pushing this change that it is OK to pile up a load of > modules that cannot ever be unloaded. > > This is IIUC regardless of whether all consumers of the module are > actually gone: it would be OK to say make it impossible to rmmod > a clk driver even of zero clocks from that driver is in use. So it is not > dependency-graph problem, it is a "load once, never remove" approach. > > This rationale puts me as subsystem maintainer in an unpleasant spot: > it is really hard to tell case-to-case whether that change really is a > technical advantage for the kernel per se or whether it is done for the > greater ecosystem of Android. > > Often I would say it makes it possible to build a smaller kernel vmlinux > so OK that is an advantage. On the other hand I have an inkling that I > should be pushing developers to make sure that rmmod works. > > As a minimum requirement I would expect this to be marked by > > struct device_driver { > (...) > /* This module absolutely cannot be unbound */ > .suppress_bind_attrs = true; > }; > > So that noone would be able to try to unbind this (could even be an > attack vector!) > > What is our broader reasoning when it comes to this? (I might have > missed some mail thread here.) Sorry for being a little late here, was out for a few days. So yea, wrt to some of the Android GKI related efforts I've been involved with, loading once and not unloading is fine for the usage model. I can understand it being a bit ugly compared to drivers with proper unloading support, and I think for most new driver submissions, maintainers can reasonably push to see proper unloading being implemented. But there are some pragmatic cases with low-level drivers (as you mentioned: clk, pinctrl, gpio, etc) where sorting out the unloading is particularly complicated, or there is some missing infrastructure, and in those cases being able to load a "permanent" module seems to me like a clear benefit. After all, it seems a bit strange to enforce that drivers be unloadable when the same code was considered ok to be merged as a built-in. So I think there's a reasonable case for the preference order to be: "built-in" < "permanent module" < "unloadable module". And of course, it can be more complicated, as enabling a driver to be a module can have rippling effects on other code that may call into it. But I think maintainers have the best sense of how to draw the line there. thanks -john