From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A148C48BDF for ; Tue, 22 Jun 2021 23:49:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8E1C6113D for ; Tue, 22 Jun 2021 23:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbhFVXv5 (ORCPT ); Tue, 22 Jun 2021 19:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbhFVXvz (ORCPT ); Tue, 22 Jun 2021 19:51:55 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3363C061756 for ; Tue, 22 Jun 2021 16:49:38 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id a2so148178pgi.6 for ; Tue, 22 Jun 2021 16:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BoYhYJcoyESGzBZwFcvog/ZaPEUbImqWttNrXwz9hqM=; b=E5M8VEzJlXeHS5fRl8ycOg6lcDdG3ieqKqbtfUXOUrNEAJS61ptU3v24wmF2DULJ97 uNLEYzGC8oLDmHCQKL8x/Y/fV8NpLDJkhNetjmD0DhodgsNm61nEVgvYE6exI905qQIF pb4r4+29+jgRh+o7NRyQWnECnYngQiO34iU74= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BoYhYJcoyESGzBZwFcvog/ZaPEUbImqWttNrXwz9hqM=; b=pcHBtrTBZ+JinijHvT9F4H9iv88RyjPLpTRwcOOQesYoe4iA/h0ChlJKdjM44hB2vU 6qiVEZNqf1BgmmzK1dd052hb5ikUt7JQ4Ixd67GvJs99yIMvmCeXCGkM42h8wRW+8LT6 h6LA+k1F4acjhzpAXRtvSHKk7TpS7RHpenUbrMbO3JWbRe54NlZWLLE52/teChNKfgqc ZR2vCPTZrDZbUVLrofh98NQlObVByuwM2NZxlppt02s1XgCpM+rqHqJ97YRWyr84+Q4k NUfKKNYyguM5tfq9j/ZKClUljpCdKlwSJUAJAF2IvJnVTg0Io4JaSRbdEbLaHsxP+/6o db8w== X-Gm-Message-State: AOAM531t5Eld7CSMxLZLZiOLRnykDKQIsw93zUbRil31afNWSOtyPj8o z9McGjdtSr2v5/9JWocdxK/zSw== X-Google-Smtp-Source: ABdhPJyM+4uG3YUoJSW1N4ZCJHbEb4TeNqR+HMzw8RInxKM7qsctzHDqKc86TsM2hAfIobORJquliQ== X-Received: by 2002:a65:4689:: with SMTP id h9mr1046233pgr.347.1624405778177; Tue, 22 Jun 2021 16:49:38 -0700 (PDT) Received: from localhost ([2620:15c:202:201:dc21:8b6f:f8cd:9070]) by smtp.gmail.com with UTF8SMTPSA id jz10sm3362167pjb.4.2021.06.22.16.49.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Jun 2021 16:49:37 -0700 (PDT) Date: Tue, 22 Jun 2021 16:49:36 -0700 From: Matthias Kaehlcke To: Masahiro Yamada Cc: Linux Kbuild mailing list , Linux Kernel Mailing List , Greg Kroah-Hartman , Douglas Anderson Subject: Re: Looking for help with Kconfig dependencies Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021 at 07:55:30AM -0700, Matthias Kaehlcke wrote: > On Sat, Jun 19, 2021 at 10:30:22AM +0900, Masahiro Yamada wrote: > > On Sat, Jun 19, 2021 at 2:05 AM Matthias Kaehlcke wrote: > > > > > > Hi, > > > > > > I'm adding a new driver and have an issue with Kconfig dependencies > > > that I coulnd't sort out so far. > > > > > > Patch https://lore.kernel.org/patchwork/patch/1444212/ adds the new > > > onboard_usb_hub driver which exports two functions, > > > onboard_hub_create_pdevs() and onboard_hub_destroy_pdevs(). It also > > > provides stubs for these functions which are used when the driver > > > is not selected (CONFIG_USB_ONBOARD_HUB=n). > > > > > > The new exported functions are called by the xhci-plat driver > > > (https://lore.kernel.org/patchwork/patch/1444215/). Since xhci-plat > > > now depends on symbols from the onboard_hub_driver the following > > > dependency was added to its Kconfig entry: > > > > > > config USB_XHCI_PLATFORM > > > tristate "Generic xHCI driver for a platform device" > > > select USB_XHCI_RCAR if ARCH_RENESAS > > > + depends on USB_ONBOARD_HUB || !USB_ONBOARD_HUB > > > > > > This generally seems to work, however when USB_XHCI_PLATFORM is > > > forced to be builtin by another driver that depends on it (e.g. > > > USB_DWC3) it is still possible to build the onboard_hub driver > > > as a module, which results in unresolved symbols: > > > > > > aarch64-linux-gnu-ld: drivers/usb/host/xhci-plat.o: in function > > > `xhci_plat_remove': > > > drivers/usb/host/xhci-plat.c:427: undefined reference to > > > `onboard_hub_destroy_pdevs' > > > drivers/usb/host/xhci-plat.c:427:(.text+0x82c): relocation truncated > > > to fit: R_AARCH64_CALL26 against undefined symbol > > > `onboard_hub_destroy_pdevs' > > > aarch64-linux-gnu-ld: drivers/usb/host/xhci-plat.o: in function > > > `xhci_plat_probe': > > > drivers/usb/host/xhci-plat.c:379: undefined reference to > > > `onboard_hub_create_pdevs' > > > drivers/usb/host/xhci-plat.c:379:(.text+0x131c): relocation truncated > > > to fit: R_AARCH64_CALL26 against undefined symbol > > > `onboard_hub_create_pdevs' > > > > > > Kconfig generates the following warning with this configuration: > > > > > > WARNING: unmet direct dependencies detected for USB_XHCI_PLATFORM > > > Depends on [m]: USB_SUPPORT [=y] && USB [=y] && USB_XHCI_HCD [=y] && (USB_ONBOARD_HUB [=m] || !USB_ONBOARD_HUB [=m]) > > > Selected by [y]: > > > - USB_DWC3 [=y] && USB_SUPPORT [=y] && (USB [=y] || USB_GADGET [=y]) && HAS_DMA [=y] && USB_XHCI_HCD [=y] > > > Selected by [m]: > > > - USB_CDNS_SUPPORT [=m] && USB_SUPPORT [=y] && (USB [=y] || USB_GADGET [=y]) && HAS_DMA [=y] && USB_XHCI_HCD [=y] > > > - USB_BRCMSTB [=m] && USB_SUPPORT [=y] && USB [=y] && (ARCH_BRCMSTB [=y] && PHY_BRCM_USB [=m] || COMPILE_TEST [=y]) && USB_XHCI_HCD [=y] > > > - USB_XHCI_MVEBU [=m] && USB_SUPPORT [=y] && USB [=y] && USB_XHCI_HCD [=y] && HAS_IOMEM [=y] && (ARCH_MVEBU [=y] || COMPILE_TEST [=y]) > > > > > > I read through kconfig-language.rst and experimented a fair bit, > > > but haven't found a working solution. Any advice would be > > > appreciated. > > > > > > Thanks > > > > > > Matthias > > > > > > > > This issue should be discussed in the USB ML, > > That's where it was initially brought up, but it didn't get the attention > of anyone in the position to give advice. Since the issue is more about > kbuild dependencies than USB specifically I brought it up here. The driver > already landed in the USB tree but was reverted due to this issue, I'm > stuck on this problem and really don't want the driver to die on the > finish line. > > A workaround could be to make the driver 'bool' rather than 'tristate', > but I'm not sure if that would be acceptable. > > > but probably 'depends on USB_XHCI_PLATFORM' should be used everywhere instead of > > 'depends on USB_XHCI_PLATFORM'. > > Did you mean 'select USB_XHCI_PLATFORM' rather than 'depends on > USB_XHCI_PLATFORM'? In general that sounds reasonable, since the drivers don't > actually depend on USB_XHCI_PLATFORM from a build perspective, and it's what > some drivers actually do. However it doesn't fix the problem, apparently a > 'select X' from CONFIG_Y still results in CONFIG_X being 'y' if CONFIG_Y is > 'y' (see the USB_DWC3 case above). After some more experimentation it looks like the opposite fixes the conflict, i.e. changing all instances of 'select USB_XHCI_PLATFORM' to 'depends on USB_XHCI_PLATFORM'. That's also in line with the recommendation to limit the use of 'select' to certain use cases: select should be used with care. select will force a symbol to a value without visiting the dependencies. By abusing select you are able to select a symbol FOO even if FOO depends on BAR that is not set. In general use select only for non-visible symbols (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over. https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html