Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp358831lqo; Fri, 10 May 2024 01:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVL0iOlZ+Rz5jccoROSKdrGGimjPSM1S+/7fPKxIbjzf4DibM3iDFUUEWmK0Lkd/tlF/SRXpbUt3CQLAnUmGND2MgBP8V9mmgSmUdgkuA== X-Google-Smtp-Source: AGHT+IHv/mYdeLuzO2zcpaSRuJu7xVJk1vPeQUn25s1vZJSqfwLDY1Lhk/uNdG12rjp4WYdrPUqV X-Received: by 2002:a05:6a20:1044:b0:1a9:5e63:501b with SMTP id adf61e73a8af0-1afde1c54efmr1799347637.44.1715331470235; Fri, 10 May 2024 01:57:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715331470; cv=pass; d=google.com; s=arc-20160816; b=WKQGyz4ULb2PI5IsJ26HdqId/mL07HCMUz9Ku7/rw0VkED2+sykVmRfvq8n3JHbvmC YpSkpkksVnuFxDMAdeBezBZR9EP7zS7DuTVs7+M7p3ZNP48SbFs6JZMfDdNXek3YCwoE Z/SiaEZgfo8AAr6jruhkv0PxgFqUKxFJKHM5bJWDft8bOEmlA5T1Ki8ptrrYYjCZVysP LqNBVwnUSoll2P4UhGioBNceBnL03loQu26hty5iFNb+2GDssYW8HGbsDb3cMx12roed dypCsBY2K4rdoaoMOxoWbJ8koqjh3TeRBSEHyMc/F4JxduxyOcq7aYMSmZvsWbZS4vBV Wlqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=67Tjslp/ob1JH0/G6tnxQC8C57IHxzX8yRCE85hX0kc=; fh=huohozts8Q/YluA7D1DyCcvnhc9s+Ps1wv2voH2dRB4=; b=ed68emyocvM5oZYyQHcR1or6wWOPst8sQGdDdmMQ+fa+RsMYRK6ccKCnPpNe8j2Kcj viTrsLwYSs+EyvhuOEDYeE1QKh0gX4vhTk0PuGMyRAH/t1BV7S9TB/Ip346+G2+J49UA uYmzinlXzUtAYWpSBkCOGkYeUF247ant8zd9h3m0FH92g8xcmDkXFNXkV95M+RMJ4Rgx f4snQEl+JD8ItxL3Ok7KiSZgyZZIcUYqUYSfWwbMYGC8x66HUViDkDUnhej/U3wXraYp VDP+ktHr56AD0UvA7X/vNZ+PAzgJvBbm7FtLtTfofXH6zznYG6jEeuwCAmafaNE6sF7Q 0lAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sggz6lFb; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-175471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6288695d0si5611824a91.4.2024.05.10.01.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 01:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sggz6lFb; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-175471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D9406281CBA for ; Fri, 10 May 2024 08:57:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38E3215F41D; Fri, 10 May 2024 08:57:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sggz6lFb" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5B9F1A2C0F for ; Fri, 10 May 2024 08:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715331464; cv=none; b=uK9FjiAtOM+DcbkRsVbfM9IJZBvkPM+6BTxPNIK+fW9caSq2yUkAdHr2mNDZzhnTOuaBfhePnYKam0+8cLsiv3Tt+DdRUUpWHy1+FHUsGNIxjolGNzdbtpeCIT44YwOCQn0mplisxom0Nsi9yyEHWpWzDjHhnLXtsyARxCjbc3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715331464; c=relaxed/simple; bh=i7lzNbNU766SPvXgvLbc9nKxUz6ZhlRWGGhNlC8Djwo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YtJy/SiHdnX7hvtZogU3gWV9LEVqL7Cag9cEMlQbngylLjaK3Gi/IPM9lws3JQRe6YWNB1bq/YR7aohpcr58EBV3mEIdzORnRDIdpHsgEOPSdw8H5H/pCHKaDI1s2G/PIuUDMvziXqilcTZl1i4JypwhEM0YpDq8mYcnRvqyyOU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Sggz6lFb; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715331461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=67Tjslp/ob1JH0/G6tnxQC8C57IHxzX8yRCE85hX0kc=; b=Sggz6lFbMy8PyEGNCN8Acy8VDebJ6y0znIFJNu5jufJc9zxaQruisnviDB1BE7+kCPTECA sMi21bcmbiUQaZJ+T8qpbT9FwNd5t1K0uuF8dGNwBd014jBmqjvuRiv5RAaK5sOnCM4Vfl lNkrH/1CTT7QCtLO1kh7evOoR6bkG6E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-FUWC7ru5OjOluU0xYKoIlA-1; Fri, 10 May 2024 04:57:35 -0400 X-MC-Unique: FUWC7ru5OjOluU0xYKoIlA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C75A9800CA5; Fri, 10 May 2024 08:57:34 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FBFE5751D3; Fri, 10 May 2024 08:57:33 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: mcgrof@kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Cc: lucas.demarchi@intel.com, Jose Ignacio Tornos Martinez Subject: [PATCH v3] module: create weak dependecies Date: Fri, 10 May 2024 10:57:22 +0200 Message-ID: <20240510085726.327831-1-jtornosm@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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. The 'weak' dependency support has been included in kmod: https://github.com/kmod-project/kmod/commit/05828b4a6e9327a63ef94df544a042b5e9ce4fe7 But, take into account that this can only be used if depmod is new enough. If it isn't, depmod will have the same behavior as always (keeping backward compatibility) and the information for the 'weak' dependency will not be provided. Signed-off-by: Jose Ignacio Tornos Martinez --- V2 -> V3: - Include note about backward compatibility. - Balance the /* and */. V1 -> V2: - Include reference to 'weak' dependency support in kmod. include/linux/module.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/module.h b/include/linux/module.h index 1153b0d99a80..2a056017df5b 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -173,6 +173,12 @@ extern void cleanup_module(void); */ #define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep) +/* + * Weak module dependencies. See man modprobe.d for details. + * 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