1. 20 Jul, 2024 5 commits
  2. 16 Jul, 2024 9 commits
  3. 15 Jul, 2024 26 commits
    • Masahiro Yamada's avatar
      kbuild: deb-pkg: remove support for "name <email>" form for DEBEMAIL · c5209080
      Masahiro Yamada authored
      Commit d5940c60 ("kbuild: deb-pkg improve maintainer address
      generation") supported the "name <email>" form for DEBEMAIL, with
      behavior slightly different from devscripts.
      
      In Kbuild, if DEBEMAIL is given in the form "name <email>", it is used
      as-is, and DEBFULLNAME is ignored.
      
      In contrast, debchange takes the name from DEBFULLNAME (or NAME) if set,
      as described in 'man debchange':
      
        If this variable has the form "name <email>", then the maintainer name
        will also be taken from here if neither DEBFULLNAME nor NAME is set.
      
      This commit removes support for the "name <email> form for DEBEMAIL,
      as the current behavior is already different from debchange, and the
      Debian manual suggests setting the email address and name separately in
      DEBEMAIL and DEBFULLNAME. [1]
      
      If there are any complaints about this removal, we can re-add it,
      with better alignment with the debchange implementation. [2]
      
      [1]: https://www.debian.org/doc/manuals/debmake-doc/ch03.en.html#email-setup
      [2]: https://salsa.debian.org/debian/devscripts/-/blob/v2.23.7/scripts/debchange.pl#L802Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <nicolas@fjasle.eu>
      c5209080
    • Masahiro Yamada's avatar
      kbuild: deb-pkg: remove support for EMAIL environment variable · 62767619
      Masahiro Yamada authored
      Commit edec611d ("kbuild, deb-pkg: improve maintainer
      identification") added the EMAIL and NAME environment variables.
      
      Commit d5940c60 ("kbuild: deb-pkg improve maintainer address
      generation") removed support for NAME, but kept support for EMAIL.
      
      The EMAIL and NAME environment variables are supported by some tools
      (see 'man debchange'), but not by all.
      
      We should support both of them, or neither of them. We should not stop
      halfway.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <nicolas@fjasle.eu>
      62767619
    • Masahiro Yamada's avatar
      kconfig: refactor error messages in sym_check_print_recursive() · d5afb482
      Masahiro Yamada authored
      Improve the error messages and clean up redundant code.
      
      [1] remove redundant next_sym->name checks
      
      If 'next_sym' is a choice, the first 'if' block is executed. In the
      subsequent 'else if' blocks, 'next_sym" is not a choice, hence
      next_sym->name is not NULL.
      
      [2] remove redundant sym->name checks
      
      A choice is never selected or implied by anyone because it has no name
      (it is syntactically impossible). If it is, sym->name is not NULL.
      
      [3] Show the location of choice instead of "<choice>"
      
      "part of choice <choice>" does not convey useful information. Since a
      choice has no name, it is more informative to display the file name and
      line number.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d5afb482
    • Masahiro Yamada's avatar
      kconfig: improve error message for recursive dependency in choice · d67624d8
      Masahiro Yamada authored
      Kconfig detects recursive dependencies in a choice block, but the error
      message is unclear.
      
      [Test Code]
      
          choice
                  prompt "choose"
                  depends on A
      
          config A
                  bool "A"
      
          config B
                  bool "B"
      
          endchoice
      
      [Result]
      
          Kconfig:1:error: recursive dependency detected!
          Kconfig:1:      choice <choice> contains symbol A
          Kconfig:5:      symbol A is part of choice <choice>
          For a resolution refer to Documentation/kbuild/kconfig-language.rst
          subsection "Kconfig recursive dependency limitations"
      
      The phrase "contains symbol A" does not accurately describe the problem.
      The issue is that the choice depends on A, which is a member of itself.
      
      The first if-block does not print a sensible message. Remove it.
      
      This commit improves the error message to:
      
          Kconfig:1:error: recursive dependency detected!
          Kconfig:1:      symbol <choice> symbol is visible depending on A
          Kconfig:5:      symbol A is part of choice <choice>
          For a resolution refer to Documentation/kbuild/kconfig-language.rst
          subsection "Kconfig recursive dependency limitations"
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d67624d8
    • Masahiro Yamada's avatar
      kconfig: improve error message for dependency between choice members · 1a7d0ea8
      Masahiro Yamada authored
      A choice member must not depend on another member within the same choice
      block.
      
      Kconfig detects this, but the error message is not sensible.
      
      [Test Code]
      
          choice
                  prompt "choose"
      
          config A
                  bool "A"
                  depends on B
      
          config B
                  bool "B"
      
          endchoice
      
      [Result]
      
          Kconfig:1:error: recursive dependency detected!
          Kconfig:1:      choice <choice> contains symbol A
          Kconfig:4:      symbol A is part of choice B
          Kconfig:8:      symbol B is part of choice <choice>
          For a resolution refer to Documentation/kbuild/kconfig-language.rst
          subsection "Kconfig recursive dependency limitations"
      
      The phrase "part of choice B" is weird because B is not a choice block,
      but a choice member.
      
      To determine whether the current symbol is a part of a choice block,
      sym_is_choice(next_sym) must be checked.
      
      This commit improves the error message to:
      
          Kconfig:1:error: recursive dependency detected!
          Kconfig:1:      choice <choice> contains symbol A
          Kconfig:4:      symbol A symbol is visible depending on B
          Kconfig:8:      symbol B is part of choice <choice>
          For a resolution refer to Documentation/kbuild/kconfig-language.rst
          subsection "Kconfig recursive dependency limitations"
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      1a7d0ea8
    • Masahiro Yamada's avatar
      kconfig: fix conditional prompt behavior for choice · d533828e
      Masahiro Yamada authored
      When a prompt is followed by "if <expr>", the symbol is configurable
      when the if-conditional evaluates to true.
      
      A typical usage is as follows:
      
          menuconfig BLOCK
                  bool "Enable the block layer" if EXPERT
                  default y
      
      When EXPERT=n, the prompt is hidden, but this config entry is still
      active, and BLOCK is set to its default value 'y'. When EXPERT=y, the
      prompt is shown, making BLOCK a user-configurable option.
      
      This usage is common throughout the kernel tree, but it has never worked
      within a choice block.
      
      [Test Code]
      
          config EXPERT
                  bool "Allow expert users to modify more options"
      
          choice
                  prompt "Choose" if EXPERT
      
          config A
                  bool "A"
      
          config B
                  bool "B"
      
          endchoice
      
      [Result]
      
          # CONFIG_EXPERT is not set
      
      When the prompt is hidden, the choice block should produce the default
      without asking for the user's preference. Hence, the output should be:
      
          # CONFIG_EXPERT is not set
          CONFIG_A=y
          # CONFIG_B is not set
      
      Removing unnecessary hacks fixes the issue.
      
      This commit also changes the behavior of 'select' by choice members.
      
      [Test Code 2]
      
          config MODULES
                  def_bool y
                  modules
      
          config DEP
                  def_tristate m
      
          if DEP
      
          choice
                  prompt "choose"
      
          config A
                  bool "A"
                  select C
      
          endchoice
      
          config B
                  def_bool y
                  select D
      
          endif
      
          config C
                  tristate
      
          config D
                  tristate
      
      The current output is as follows:
      
          CONFIG_MODULES=y
          CONFIG_DEP=m
          CONFIG_A=y
          CONFIG_B=y
          CONFIG_C=y
          CONFIG_D=m
      
      With this commit, the output will be changed as follows:
      
          CONFIG_MODULES=y
          CONFIG_DEP=m
          CONFIG_A=y
          CONFIG_B=y
          CONFIG_C=m
          CONFIG_D=m
      
      CONFIG_C will be changed to 'm' because 'select C' will inherit the
      dependency on DEP, which is 'm'.
      
      This change is aligned with the behavior of 'select' outside a choice
      block; 'select D' depends on DEP, therefore D is selected by (B && DEP).
      
      Note:
      
      With this commit, allmodconfig will set CONFIG_USB_ROLE_SWITCH to 'm'
      instead of 'y'. I did not see any build regression with this change.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d533828e
    • Masahiro Yamada's avatar
      treewide: change conditional prompt for choices to 'depends on' · b9d73218
      Masahiro Yamada authored
      While Documentation/kbuild/kconfig-language.rst provides a brief
      explanation, there are recurring confusions regarding the usage of a
      prompt followed by 'if <expr>'. This conditional controls _only_ the
      prompt.
      
      A typical usage is as follows:
      
          menuconfig BLOCK
                  bool "Enable the block layer" if EXPERT
                  default y
      
      When EXPERT=n, the prompt is hidden, but this config entry is still
      active, and BLOCK is set to its default value 'y'. This is reasonable
      because you are likely want to enable the block device support. When
      EXPERT=y, the prompt is shown, allowing you to toggle BLOCK.
      
      Please note that it is different from 'depends on EXPERT', which would
      enable and disable the entire config entry.
      
      However, this conditional prompt has never worked in a choice block.
      
      The following two work in the same way: when EXPERT is disabled, the
      choice block is entirely disabled.
      
      [Test Code 1]
      
          choice
                  prompt "choose" if EXPERT
      
          config A
                  bool "A"
      
          config B
                  bool "B"
      
          endchoice
      
      [Test Code 2]
      
          choice
                  prompt "choose"
                  depends on EXPERT
      
          config A
                  bool "A"
      
          config B
                  bool "B"
      
          endchoice
      
      I believe the first case should hide only the prompt, producing the
      default:
      
         CONFIG_A=y
         # CONFIG_B is not set
      
      The next commit will change (fix) the behavior of the conditional prompt
      in choice blocks.
      
      I see several choice blocks wrongly using a conditional prompt, where
      'depends on' makes more sense.
      
      To preserve the current behavior, this commit converts such misuses.
      
      I did not touch the following entry in arch/x86/Kconfig:
      
          choice
                  prompt "Memory split" if EXPERT
                  default VMSPLIT_3G
      
      This is truly the correct use of the conditional prompt; when EXPERT=n,
      this choice block should silently select the reasonable VMSPLIT_3G,
      although the resulting PAGE_OFFSET will not be affected anyway.
      
      Presumably, the one in fs/jffs2/Kconfig is also correct, but I converted
      it to 'depends on' to avoid any potential behavioral change.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      b9d73218
    • Masahiro Yamada's avatar
      kconfig: remove E_LIST expression type · 7c9bb07a
      Masahiro Yamada authored
      E_LIST was preveously used to form an expression tree consisting of
      choice members.
      
      It is no longer used.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7c9bb07a
    • Masahiro Yamada's avatar
      kconfig: remove P_CHOICE property · ca4c74ba
      Masahiro Yamada authored
      P_CHOICE is a pseudo property used to link a choice with its members.
      
      There is no more code relying on this, except for some debug code.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ca4c74ba
    • Masahiro Yamada's avatar
      kconfig: use sym_get_choice_menu() in sym_check_deps() · b139b43e
      Masahiro Yamada authored
      Choices and their members are associated via the P_CHOICE property.
      
      Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain
      the choice of the given choice member.
      
      Replace it with sym_get_choice_menu(), which retrieves the choice
      without relying on P_CHOICE.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      b139b43e
    • Masahiro Yamada's avatar
      kconfig: use sym_get_choice_menu() in sym_check_choice_deps() · 609fc409
      Masahiro Yamada authored
      Choices and their members are associated via the P_CHOICE property.
      
      Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain
      the choice of the given choice member.
      
      Replace it with sym_get_choice_menu(), which retrieves the choice
      without relying on P_CHOICE.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      609fc409
    • Masahiro Yamada's avatar
      kconfig: use sym_get_choice_menu() in sym_check_print_recursive() · d8f8bbcf
      Masahiro Yamada authored
      Choices and their members are associated via the P_CHOICE property.
      
      Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain
      the choice of the given choice member.
      
      Replace it with sym_get_choice_menu(), which retrieves the choice
      without relying on P_CHOICE.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d8f8bbcf
    • Masahiro Yamada's avatar
      kconfig: remove expr_list_for_each_sym() macro · 8926bc90
      Masahiro Yamada authored
      All users of this macro have been converted. Remove it.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      8926bc90
    • Masahiro Yamada's avatar
      kconfig: use menu_list_for_each_sym() in sym_choice_default() · 6e6d0e91
      Masahiro Yamada authored
      Choices and their members are associated via the P_CHOICE property.
      
      Currently, sym_get_choice_prop() and expr_list_for_each_sym() are
      used to iterate on choice members.
      
      Replace them with menu_for_each_sub_entry(), which achieves the same
      without relying on P_CHOICE.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      6e6d0e91
    • Masahiro Yamada's avatar
      kconfig: change sym_choice_default() to take the choice menu · e8fcd915
      Masahiro Yamada authored
      Change the argument of sym_choice_default() to ease further cleanups.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      e8fcd915
    • Masahiro Yamada's avatar
      kconfig: remove conf_unsaved in conf_read_simple() · cca31837
      Masahiro Yamada authored
      This variable is unnecessary. Call conf_set_changed(true) directly.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      cca31837
    • Masahiro Yamada's avatar
      kconfig: remove sym_get_choice_value() · bd0db4b6
      Masahiro Yamada authored
      sym_get_choice_value(menu->sym) is equivalent to sym_calc_choice(menu).
      
      Convert all call sites of sym_get_choice_value() and then remove it.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      bd0db4b6
    • Masahiro Yamada's avatar
      kconfig: refactor choice value calculation · f79dc03f
      Masahiro Yamada authored
      Handling choices has always been in a PITA in Kconfig.
      
      For example, fixes and reverts were repeated for randconfig with
      KCONFIG_ALLCONFIG:
      
       - 422c809f ("kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG")
       - 23a5dfda ("Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG"")
       - 8357b485 ("kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG")
       - 490f1617 ("Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG"")
      
      As these commits pointed out, randconfig does not randomize choices when
      KCONFIG_ALLCONFIG is used. This issue still remains.
      
      [Test Case]
      
          choice
                  prompt "choose"
      
          config A
                  bool "A"
      
          config B
                  bool "B"
      
          endchoice
      
          $ echo > all.config
          $ make KCONFIG_ALLCONFIG=1 randconfig
      
      The output is always as follows:
      
          CONFIG_A=y
          # CONFIG_B is not set
      
      Not only randconfig, but other all*config variants are also broken with
      KCONFIG_ALLCONFIG.
      
      With the same Kconfig,
      
          $ echo '# CONFIG_A is not set' > all.config
          $ make KCONFIG_ALLCONFIG=1 allyesconfig
      
      You will get this:
      
          CONFIG_A=y
          # CONFIG_B is not set
      
      This is incorrect because it does not respect all.config.
      
      The correct output should be:
      
          # CONFIG_A is not set
          CONFIG_B=y
      
      To handle user inputs more accurately, this commit refactors the code
      based on the following principles:
      
       - When a user value is given, Kconfig must set it immediately.
         Do not defer it by setting SYMBOL_NEED_SET_CHOICE_VALUES.
      
       - The SYMBOL_DEF_USER flag must not be cleared, unless a new config
         file is loaded. Kconfig must not forget user inputs.
      
      In addition, user values for choices must be managed with priority.
      If user inputs conflict within a choice block, the newest value wins.
      The values given by randconfig have lower priority than explicit user
      inputs.
      
      This commit implements it by using a linked list. Every time a choice
      block gets a new input, it is moved to the top of the list.
      
      Let me explain how it works.
      
      Let's say, we have a choice block that consists of five symbols:
      A, B, C, D, and E.
      
      Initially, the linked list looks like this:
      
          A(=?) --> B(=?) --> C(=?) --> D(=?) --> E(=?)
      
      Suppose randconfig is executed with the following KCONFIG_ALLCONFIG:
      
          CONFIG_C=y
          # CONFIG_A is not set
          CONFIG_D=y
      
      First, CONFIG_C=y is read. C is set to 'y' and moved to the top.
      
          C(=y) --> A(=?) --> B(=?) --> D(=?) --> E(=?)
      
      Next, '# CONFIG_A is not set' is read. A is set to 'n' and moved to
      the top.
      
          A(=n) --> C(=y) --> B(=?) --> D(=?) --> E(=?)
      
      Then, 'CONFIG_D=y' is read. D is set to 'y' and moved to the top.
      
          D(=y) --> A(=n) --> C(=y) --> B(=?) --> E(=?)
      
      Lastly, randconfig shuffles the order of the remaining symbols,
      resulting in:
      
          D(=y) --> A(=n) --> C(=y) --> B(=y) --> E(=y)
      or
          D(=y) --> A(=n) --> C(=y) --> E(=y) --> B(=y)
      
      When calculating the output, the linked list is traversed and the first
      visible symbol with 'y' is taken. In this case, it is D if visible.
      
      If D is hidden by 'depends on', the next node, A, is examined. Since
      it is already specified as 'n', it is skipped. Next, C is checked, and
      selected if it is visible.
      
      If C is also invisible, either B or E is chosen as a result of the
      randomization.
      
      If B and E are also invisible, the linked list is traversed in the
      reverse order, and the least prioritized 'n' symbol is chosen. It is
      A in this case.
      
      Now, Kconfig remembers all user values. This is a big difference from
      the previous implementation, where Kconfig would forget CONFIG_C=y when
      CONFIG_D=y appeared in the same input file.
      
      The new appaorch respects user-specified values as much as possible.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      f79dc03f
    • Masahiro Yamada's avatar
      kconfig: import list_move(_tail) and list_for_each_entry_reverse macros · ee29e620
      Masahiro Yamada authored
      Import more macros from include/linux/list.h.
      
      These will be used in the next commit.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ee29e620
    • Chen-Yu Tsai's avatar
      scripts/make_fit: Support decomposing DTBs · 17c31ade
      Chen-Yu Tsai authored
      The kernel tree builds some "composite" DTBs, where the final DTB is the
      result of applying one or more DTB overlays on top of a base DTB with
      fdtoverlay.
      
      The FIT image specification already supports configurations having one
      base DTB and overlays applied on top. It is then up to the bootloader to
      apply said overlays and either use or pass on the final result. This
      allows the FIT image builder to reuse the same FDT images for multiple
      configurations, if such cases exist.
      
      The decomposition function depends on the kernel build system, reading
      back the .cmd files for the to-be-packaged DTB files to check for the
      fdtoverlay command being called. This will not work outside the kernel
      tree. The function is off by default to keep compatibility with possible
      existing users.
      
      To facilitate the decomposition and keep the code clean, the model and
      compatitble string extraction have been moved out of the output_dtb
      function. The FDT image description is replaced with the base file name
      of the included image.
      Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      17c31ade
    • Rafael Aquini's avatar
      kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec · e61b190b
      Rafael Aquini authored
      Fix the following rpmbuild warning:
      
        $ make srcrpm-pkg
        ...
        RPM build warnings:
            line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
      Signed-off-by: default avatarRafael Aquini <aquini@redhat.com>
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      e61b190b
    • Uwe Kleine-König's avatar
      modpost: Enable section warning from *driver to .exit.text · 7308bf8a
      Uwe Kleine-König authored
      There used to be several offenders, but now that for all of them patches
      were sent and most of them were applied, enable the warning also for
      builds without W=1.
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@baylibre.com>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7308bf8a
    • Masahiro Yamada's avatar
      kbuild: move init/build-version to scripts/ · ae4c4cee
      Masahiro Yamada authored
      At first, I thought this script would be needed only in init/Makefile.
      
      However, commit 5db8face ("kbuild: Restore .version auto-increment
      behaviour for Debian packages") and commit 1789fc91 ("kbuild:
      rpm-pkg: invoke the kernel build from rpmbuild for binrpm-pkg")
      revealed that it was actually needed for scripts/package/mk* as well.
      
      After all, scripts/ is a better place for it.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      ae4c4cee
    • Masahiro Yamada's avatar
      kconfig: remember the current choice while parsing the choice block · 9b114520
      Masahiro Yamada authored
      Instead of the boolean flag, it will be more useful to remember the
      current choice being parsed.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      9b114520
    • Masahiro Yamada's avatar
      kconfig: introduce choice_set_value() helper · bd988e7c
      Masahiro Yamada authored
      Currently, sym_set_tristate_value() is used to set 'y' to a choice
      member, which is confusing because it not only sets 'y' to the given
      symbol but also tweaks flags of other symbols as a side effect.
      
      Add a dedicated function for setting the value of the given choice.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      bd988e7c
    • Masahiro Yamada's avatar
      kconfig: add fallthrough comments to expr_compare_type() · dfe8e56f
      Masahiro Yamada authored
      Clarify the missing 'break' is intentional.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      dfe8e56f