Linux-Modules Archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Cc: <mcgrof@kernel.org>, <linux-modules@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] module: create weak dependecies
Date: Thu, 9 May 2024 08:06:34 -0500	[thread overview]
Message-ID: <5o5jlonbr2ggei7zxh7m2mql3rt6xnmmmo2hv6ktpvi26c7uuw@odtumzc76xoq> (raw)
In-Reply-To: <20240509102442.176958-1-jtornosm@redhat.com>

On Thu, May 09, 2024 at 12:24:40PM GMT, Jose Ignacio Tornos Martinez wrote:
>It has been seen that for some network mac drivers (i.e. lan78xx) the
>related module for the phy is loaded dynamically depending on the current
>hardware. In this case, the associated phy is read using mdio bus and then
>the associated phy module is loaded during runtime (kernel function
>phy_request_driver_module). However, no software dependency is defined, so
>the user tools will no be able to get this dependency. For example, if
>dracut is used and the hardware is present, lan78xx will be included but no
>phy module will be added, and in the next restart the device will not work
>from boot because no related phy will be found during initramfs stage.
>
>In order to solve this, we could define a normal 'pre' software dependency
>in lan78xx module with all the possible phy modules (there may be some),
>but proceeding in that way, all the possible phy modules would be loaded
>while only one is necessary.
>
>The idea is to create a new type of dependency, that we are going to call
>'weak' to be used only by the user tools that need to detect this situation.
>In that way, for example, dracut could check the 'weak' dependency of the
>modules involved in order to install these dependencies in initramfs too.
>That is, for the commented lan78xx module, defining the 'weak' dependency
>with the possible phy modules list, only the necessary phy would be loaded
>on demand keeping the same behavior, but all the possible phy modules would
>be available from initramfs.

I think it's important a note about backward compatibility. If a system
doesn't have a new-enough depmod, it will basically not create the new
weadep file and initrd generators won't be able to use that. Only
downside is not being able to use the new feature, but it should still
work as previously.

>
>The 'weak' dependency support has been included in kmod:
>https://github.com/kmod-project/kmod/commit/05828b4a6e9327a63ef94df544a042b5e9ce4fe7
>
>Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
>---
>V1 -> V2:
>- Include reference to 'weak' dependency support in kmod.
>
> include/linux/module.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
>diff --git a/include/linux/module.h b/include/linux/module.h
>index 1153b0d99a80..231e710d8736 100644
>--- a/include/linux/module.h
>+++ b/include/linux/module.h
>@@ -173,6 +173,11 @@ extern void cleanup_module(void);
>  */
> #define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep)
>
>+/* Weak module dependencies. See man modprobe.d for details.

Documentation/process/coding-style.rst section 8 says to balance the /*
and */, but up to Luis what he enforces in the module tree.

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

Lucas De Marchi

>+ * Example: MODULE_WEAKDEP("module-foo")
>+ */
>+#define MODULE_WEAKDEP(_weakdep) MODULE_INFO(weakdep, _weakdep)
>+
> /*
>  * MODULE_FILE is used for generating modules.builtin
>  * So, make it no-op when this is being built as a module
>-- 
>2.44.0
>

  reply	other threads:[~2024-05-09 13:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 10:24 [PATCH v2] module: create weak dependecies Jose Ignacio Tornos Martinez
2024-05-09 13:06 ` Lucas De Marchi [this message]
2024-05-10  8:54   ` Jose Ignacio Tornos Martinez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5o5jlonbr2ggei7zxh7m2mql3rt6xnmmmo2hv6ktpvi26c7uuw@odtumzc76xoq \
    --to=lucas.demarchi@intel.com \
    --cc=jtornosm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).