Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp830927pxb; Tue, 12 Apr 2022 14:41:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwUYeQL00pPY7matvF+XUpV4Nfqkg6qMUgncCllVI+jBNcFWM4OGNpEbIN8hwUVS/zScD1 X-Received: by 2002:a05:6a00:1701:b0:505:c49b:d2eb with SMTP id h1-20020a056a00170100b00505c49bd2ebmr11895394pfc.12.1649799672312; Tue, 12 Apr 2022 14:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649799672; cv=none; d=google.com; s=arc-20160816; b=gvukjVRqcxAWPPPNRfgmB17ZTYNsjnjqnuP5aP0IIx0ml6gylLINi/DT8VITPLwfSe VOAuh0uCRgYPMrzaPo2qvlLKi9GXW8imOxBBkmxFk8sy2U1U7JJYVPm/akkg/m0mBHiB w/iQvepq+vYlYe4IIGUx/yIqzbGKKxnfhnDuElcb/Jrwd8aXql8yJIGjhQFou6XRBIBl PCAEC0d5ZPG3jsfJw5gGwYhs4P7MrrwlLhLs3a3ynLMMvVcUFAPhnMZvpJ1yQRZz4MFA AXGQrk1iNTKb9zSUL+y6FspCxJ/+M4b84ZzeChbBV2hb4DkX588fWyQykW1/aEkVrwRv TBRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=R41hcNskYvCznNDmOyxQUN5KldJzQl0F7yh3jWVjHMg=; b=LmB5/3cN/0sPZcU5Qcl+lk5jtgmkJWAnEAnV0F64ao7H6Yp9J3AFNlHjxP2z4RuPpx O1AO2CwTKPkVJAj1BILeJ+zDTiNfyCyyeKbj0NAv8cMI6AcGz4mq3Oww7p84babj+sgf Guy2eveLcgr4UzYI52850nZfVQBDggJ/fsxm459jr0sSoE6AqKAZqCCYr67ZYpH8dvDn QQTe3indkuuQLEvfLbcG0aM4BP0VsG5CY5Jg8/cIHQDh46JJG8i5veenY+IJoRTrg1np SFfp3pTUhcOQeEyQjwPuCHAfjbZgly6w8uVgbdnzEPl3ZD6QbzVUEwi8aw1cRFTNunLk OSOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@pqrs.dk header.s=google header.b="nM/Cqb83"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a190-20020a6390c7000000b0039d698d71c9si3563028pge.275.2022.04.12.14.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:41:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@pqrs.dk header.s=google header.b="nM/Cqb83"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F2C7F1229A8; Tue, 12 Apr 2022 13:42:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353786AbiDLP6E (ORCPT + 99 others); Tue, 12 Apr 2022 11:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349079AbiDLP6C (ORCPT ); Tue, 12 Apr 2022 11:58:02 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC63D26130 for ; Tue, 12 Apr 2022 08:55:37 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id s18so15760666ejr.0 for ; Tue, 12 Apr 2022 08:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R41hcNskYvCznNDmOyxQUN5KldJzQl0F7yh3jWVjHMg=; b=nM/Cqb83xekaaMw+WCaocT6vW9NU9dez6JLdVXMOsiig3P2zQkG/QAiqrUf1Wv1rMX dTpfdKVFsSoRifIR/ubBGHmvVbIglUJnv55DxQnpLCJ8Pd7RaQAfzN6/N579TboBOFXC YankKB127eLO/nKoV8GAsEVzIQoe32h+hFW98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R41hcNskYvCznNDmOyxQUN5KldJzQl0F7yh3jWVjHMg=; b=pw3u9THRO+8q9tBbJVcO39FtLmNXNmNofjLD/6uDR5OL9AFJhMgkxlWCfoB8c0rKSd +kXP4O470bmHhqIuZDmB8wZFePCWOp1wqJnTJMwngBPpAAwiyp6OObSu7/s6v/SNYILn TWQzs+jX2XFcQda5QVvmwfezd3NTBEnsGYlDOtscXTkySIU/zj0DJJBA+GnRSNTZEoJ6 ZA7xd8tKsL44ccyD1pGsmOWvh5YwloX1kzOafYmSdgTIiuAW5IWmXbbrwvYu3Ofy1fG6 EWnJWjTQmDHDYXhGwnqVyxOqrhHIyrc3a0T7JD6s4PxF9XzeOIhd5W4SOC9q6cuKomCI 3P7w== X-Gm-Message-State: AOAM532X1FqI6JqkE+MJjUc5JeOkzFG6jC64mbaW5b5GVR1bCUhcTThP sN3zW7QJGpQjEJDN8zlNRMSNKw== X-Received: by 2002:a17:906:730c:b0:6e6:c512:49c8 with SMTP id di12-20020a170906730c00b006e6c51249c8mr35471265ejc.405.1649778936500; Tue, 12 Apr 2022 08:55:36 -0700 (PDT) Received: from capella.. (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id jl28-20020a17090775dc00b006e05cdf3a95sm13354161ejc.163.2022.04.12.08.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 08:55:35 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Luiz Angelo Daros de Luca Cc: kernel test robot , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] net: dsa: realtek: fix Kconfig to assure consistent driver linkage Date: Tue, 12 Apr 2022 17:55:27 +0200 Message-Id: <20220412155527.1824118-1-alvin@pqrs.dk> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin Šipraga The kernel test robot reported a build failure: or1k-linux-ld: drivers/net/dsa/realtek/realtek-smi.o:(.rodata+0x16c): undefined reference to `rtl8366rb_variant' ... with the following build configuration: CONFIG_NET_DSA_REALTEK=y CONFIG_NET_DSA_REALTEK_SMI=y CONFIG_NET_DSA_REALTEK_RTL8365MB=y CONFIG_NET_DSA_REALTEK_RTL8366RB=m The problem here is that the realtek-smi interface driver gets built-in, while the rtl8366rb switch subdriver gets built as a module, hence the symbol rtl8366rb_variant is not reachable when defining the OF device table in the interface driver. The Kconfig dependencies don't help in this scenario because they just say that the subdriver(s) depend on at least one interface driver. In fact, the subdrivers don't depend on the interface drivers at all, and can even be built even in their absence. Somewhat strangely, the interface drivers can also be built in the absence of any subdriver, BUT, if a subdriver IS enabled, then it must be reachable according to the linkage of the interface driver: effectively what the IS_REACHABLE() macro achieves. If it is not reachable, the above kind of linker error will be observed. Rather than papering over the above build error by simply using IS_REACHABLE(), we can do a little better and admit that it is actually the interface drivers that have a dependency on the subdrivers. So this patch does exactly that. Specifically, we ensure that: 1. The interface drivers' Kconfig symbols must have a value no greater than the value of any subdriver Kconfig symbols. 2. The subdrivers should by default enable both interface drivers, since most users probably want at least one of them; those interface drivers can be explicitly disabled however. What this doesn't do is prevent a user from building only a subdriver, without any interface driver. To that end, add an additional line of help in the menu to guide users in the right direction. Link: https://lore.kernel.org/all/202204110757.XIafvVnj-lkp@intel.com/ Reported-by: kernel test robot Fixes: aac94001067d ("net: dsa: realtek: add new mdio interface for drivers") Signed-off-by: Alvin Šipraga --- Note that the Fixes: tag could arguably go back to: 765c39a4fafe ("net: dsa: realtek: convert subdrivers into modules") ... but this would not help the stable branches, since the following commit (which is the chosen point of my Fixes: tag) changes things a lot. I will have to send a separate backport for stable. --- drivers/net/dsa/realtek/Kconfig | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig index 1aa79735355f..060165a85fb7 100644 --- a/drivers/net/dsa/realtek/Kconfig +++ b/drivers/net/dsa/realtek/Kconfig @@ -9,34 +9,46 @@ menuconfig NET_DSA_REALTEK help Select to enable support for Realtek Ethernet switch chips. + Note that at least one interface driver must be enabled for the + subdrivers to be loaded. Moreover, an interface driver cannot achieve + anything without at least one subdriver enabled. + +if NET_DSA_REALTEK + config NET_DSA_REALTEK_MDIO - tristate "Realtek MDIO connected switch driver" - depends on NET_DSA_REALTEK + tristate "Realtek MDIO interface driver" depends on OF + depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB + depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB + depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB help Select to enable support for registering switches configured through MDIO. config NET_DSA_REALTEK_SMI - tristate "Realtek SMI connected switch driver" - depends on NET_DSA_REALTEK + tristate "Realtek SMI interface driver" depends on OF + depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB + depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB + depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB help Select to enable support for registering switches connected through SMI. config NET_DSA_REALTEK_RTL8365MB tristate "Realtek RTL8365MB switch subdriver" - depends on NET_DSA_REALTEK - depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO + imply NET_DSA_REALTEK_SMI + imply NET_DSA_REALTEK_MDIO select NET_DSA_TAG_RTL8_4 help Select to enable support for Realtek RTL8365MB-VC and RTL8367S. config NET_DSA_REALTEK_RTL8366RB tristate "Realtek RTL8366RB switch subdriver" - depends on NET_DSA_REALTEK - depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO + imply NET_DSA_REALTEK_SMI + imply NET_DSA_REALTEK_MDIO select NET_DSA_TAG_RTL4_A help - Select to enable support for Realtek RTL8366RB + Select to enable support for Realtek RTL8366RB. + +endif -- 2.35.1