1. 25 Mar, 2018 30 commits
    • Masahiro Yamada's avatar
      kconfig: use yylineno option instead of manual lineno increments · 18492685
      Masahiro Yamada authored
      Tracking the line number by hand is error-prone since you need to
      increment it in every \n matching pattern.
      
      If '%option yylineno' is set, flex defines 'yylineno' to contain the
      current line number and automatically updates it each time it reads a
      \n character.  This is much more convenient although the lexer does
      not initializes yylineno, so you need to set it to 1 each time you
      start reading a new file, and restore it you go back to the previous
      file.
      
      I tested this with DEBUG_PARSE, and confirmed the same dump message
      was produced.
      
      I removed the perf-report option.  Otherwise, I see the following
      message:
        %option yylineno entails a performance penalty ONLY on rules that
        can match newline characters
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      18492685
    • Masahiro Yamada's avatar
      kconfig: detect recursive inclusion earlier · 379a8eb8
      Masahiro Yamada authored
      Currently, the recursive inclusion is not detected when the offending
      file is about to be included; it is detected the offending file is
      about to include the *next* file.  This is because the detection loop
      does not involve the file being included.
      
      Do this check against the file that is about to be included so that
      the recursive inclusion is detected before unneeded parsing happens.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      379a8eb8
    • Masahiro Yamada's avatar
      kconfig: remove duplicated file name and lineno of recursive inclusion · 32a94b8b
      Masahiro Yamada authored
      As in the unit test, the error message for the recursive inclusion
      looks like this:
      
        Kconfig.inc1:4: recursive inclusion detected. Inclusion path:
          current file : 'Kconfig.inc1'
          included from: 'Kconfig.inc3:1'
          included from: 'Kconfig.inc2:3'
          included from: 'Kconfig.inc1:4'
      
      The 'Kconfig.inc1:4' is duplicated in the first and last lines.
      Also, the single quotes do not help readability.
      
      Change the message like follows:
      
        Recursive inclusion detected.
        Inclusion path:
          current file : Kconfig.inc1
          included from: Kconfig.inc3:1
          included from: Kconfig.inc2:3
          included from: Kconfig.inc1:4
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      32a94b8b
    • Masahiro Yamada's avatar
      kconfig: do not include both curses.h and ncurses.h for nconfig · 26561514
      Masahiro Yamada authored
      nconf.h includes <curses.h> and "ncurses.h", but it does not need to
      include both.  Generally, it should fall back to curses.h only when
      ncurses.h is not found.  But, looks like it has never happened;
      these includes have been here for many years since commit 692d97c3
      ("kconfig: new configuration interface (nconfig)"), and nobody has
      complained about hard-coding of ncurses.h .  Let's simply drop the
      curses.h inclusion.
      
      I replaced "ncurses.h" with <ncurses.h> since it is not a local file.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      26561514
    • Masahiro Yamada's avatar
      kconfig: make unmet dependency warnings readable · f8f69dc0
      Masahiro Yamada authored
      Currently, the unmet dependency warnings end up with endlessly long
      expressions, most of which are false positives.
      
      Here is test code to demonstrate how it currently works.
      
      [Test Case]
      
        config DEP1
                def_bool y
      
        config DEP2
                bool "DEP2"
      
        config A
                bool "A"
                select E
      
        config B
                bool "B"
                depends on DEP2
                select E
      
        config C
                bool "C"
                depends on DEP1 && DEP2
                select E
      
        config D
                def_bool n
                select E
      
        config E
                bool
                depends on DEP1 && DEP2
      
      [Result]
      
        $ make config
        scripts/kconfig/conf  --oldaskconfig Kconfig
        *
        * Linux Kernel Configuration
        *
        DEP2 (DEP2) [N/y/?] (NEW) n
        A (A) [N/y/?] (NEW) y
        warning: (A && B && D) selects E which has unmet direct
        dependencies (DEP1 && DEP2)
      
      Here, I see some points to be improved.
      
      First, '(A || B || D)' would make more sense than '(A && B && D)'.
      I am not sure if this is intentional, but expr_simplify_unmet_dep()
      turns OR expressions into AND, like follows:
      
              case E_OR:
                      return expr_alloc_and(
      
      Second, we see false positives.  'A' is a real unmet dependency.
      'B' is false positive because 'DEP1' is fixed to 'y', and 'B' depends
      on 'DEP2'.  'C' was correctly dropped by expr_simplify_unmet_dep().
      'D' is also false positive because it has no chance to be enabled.
      Current expr_simplify_unmet_dep() cannot avoid those false positives.
      
      After all, I decided to use the same helpers as used for printing
      reverse dependencies in the help.
      
      With this commit, unreadable warnings (most of the reported symbols are
      false positives) in the real world:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      warning: (HWSPINLOCK_QCOM && AHCI_MTK && STMMAC_PLATFORM &&
       DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_OXNAS && DWMAC_ROCKCHIP &&
       DWMAC_SOCFPGA && DWMAC_STI && TI_CPSW && PINCTRL_GEMINI &&
       PINCTRL_OXNAS && PINCTRL_ROCKCHIP && PINCTRL_DOVE &&
       PINCTRL_ARMADA_37XX && PINCTRL_STM32 && S3C2410_WATCHDOG &&
       VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 &&
       LPC18XX_DMAMUX && VIDEO_OMAP4 && COMMON_CLK_GEMINI &&
       COMMON_CLK_ASPEED && COMMON_CLK_NXP && COMMON_CLK_OXNAS &&
       COMMON_CLK_BOSTON && QCOM_ADSP_PIL && QCOM_Q6V5_PIL && QCOM_GSBI &&
       ATMEL_EBI && ST_IRQCHIP && RESET_IMX7 && PHY_HI6220_USB &&
       PHY_RALINK_USB && PHY_ROCKCHIP_PCIE && PHY_DA8XX_USB) selects
       MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM)
      warning: (PINCTRL_AT91 && PINCTRL_AT91PIO4 && PINCTRL_OXNAS &&
       PINCTRL_PISTACHIO && PINCTRL_PIC32 && PINCTRL_MESON &&
       PINCTRL_NOMADIK && PINCTRL_MTK && PINCTRL_MT7622 && GPIO_TB10X)
       selects OF_GPIO which has unmet direct dependencies (GPIOLIB && OF &&
       HAS_IOMEM)
      warning: (FAULT_INJECTION_STACKTRACE_FILTER && LATENCYTOP && LOCKDEP)
       selects FRAME_POINTER which has unmet direct dependencies
       (DEBUG_KERNEL && (CRIS || M68K || FRV || UML || SUPERH || BLACKFIN ||
       MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS)
      
      will be turned into:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      
      WARNING: unmet direct dependencies detected for MFD_SYSCON
        Depends on [n]: HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_STM32 [=y] && PINCTRL [=y] && (ARCH_STM32 ||
       COMPILE_TEST [=y]) && OF [=y]
        - RTC_DRV_AT91SAM9 [=y] && RTC_CLASS [=y] && (ARCH_AT91 ||
       COMPILE_TEST [=y])
        - RESET_IMX7 [=y] && RESET_CONTROLLER [=y]
        - PHY_HI6220_USB [=y] && (ARCH_HISI && ARM64 ||
       COMPILE_TEST [=y])
        - PHY_RALINK_USB [=y] && (RALINK || COMPILE_TEST [=y])
        - PHY_ROCKCHIP_PCIE [=y] && (ARCH_ROCKCHIP && OF [=y] ||
       COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for OF_GPIO
        Depends on [n]: GPIOLIB [=y] && OF [=y] && HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_MTK [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y]
        - PINCTRL_MT7622 [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y] && (ARM64 || COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for FRAME_POINTER
        Depends on [n]: DEBUG_KERNEL [=y] && (CRIS || M68K || FRV || UML ||
       SUPERH || BLACKFIN || MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS [=n]
        Selected by [y]:
        - LATENCYTOP [=y] && DEBUG_KERNEL [=y] && STACKTRACE_SUPPORT [=y] &&
       PROC_FS [=y] && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND &&
       !ARC && !X86
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarPetr Vorel <petr.vorel@gmail.com>
      f8f69dc0
    • Masahiro Yamada's avatar
      kconfig: warn unmet direct dependency of tristate symbols selected by y · f622f827
      Masahiro Yamada authored
      Commit 246cf9c2 ("kbuild: Warn on selecting symbols with unmet
      direct dependencies") forcibly promoted ->dir_dep.tri to yes from mod.
      So, the unmet direct dependencies of tristate symbols are not reported.
      
      [Test Case]
      
        config MODULES
                def_bool y
                option modules
      
        config A
                def_bool y
                select B
      
        config B
                tristate "B"
                depends on m
      
      This causes unmet dependency because 'B' is forced 'y' ignoring
      'depends on m'.  This should be warned.
      
      On the other hand, the following case ('B' is bool) should not be
      warned, so 'depends on m' for bool symbols should be naturally treated
      as 'depends on y'.
      
      [Test Case2 (not unmet dependency)]
      
        config MODULES
                def_bool y
                option modules
      
        config A
                def_bool y
                select B
      
        config B
                bool "B"
                depends on m
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      f622f827
    • Masahiro Yamada's avatar
      kconfig: tests: test if recursive inclusion is detected · e2c75e76
      Masahiro Yamada authored
      If recursive inclusion is detected, it should fail with error
      messages.  Test this.
      
      This also tests the line numbers in the error message, fixed by
      commit 5ae6fcc4 ("kconfig: fix line number in recursive inclusion
      error message").
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      e2c75e76
    • Masahiro Yamada's avatar
      kconfig: tests: test if recursive dependencies are detected · 29c434f3
      Masahiro Yamada authored
      Recursive dependency should be detected and warned.  Test this.
      
      This indirectly tests the line number increments.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      29c434f3
    • Masahiro Yamada's avatar
      kconfig: tests: test randconfig for choice in choice · 3e4888c2
      Masahiro Yamada authored
      Commit 3b9a19e0 ("kconfig: loop as long as we changed some symbols
      in randconfig") fixed randconfig where a choice contains a sub-choice.
      Prior to that commit, the sub-choice values were not set.
      
      I am not sure whether this is an intended feature or just something
      people discovered works, but it is used in the real world;
      drivers/usb/gadget/legacy/Kconfig is source'd in a choice context,
      then creates a sub-choice in it.
      
      For the test case in this commit, there are 3 possible results.
      
      Case 1:
        CONFIG_A=y
        # CONFIG_B is not set
      
      Case 2:
        # CONFIG_A is not set
        CONFIG_B=y
        CONFIG_C=y
        # CONFIG_D is not set
      
      Case 3:
        # CONFIG_A is not set
        CONFIG_B=y
        # CONFIG_C is not set
        CONFIG_D=y
        CONFIG_E=y
      
      So, this test iterates several times, and checks if the result is
      either of the three.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      3e4888c2
    • Masahiro Yamada's avatar
      kconfig: tests: test defconfig when two choices interact · beaaddb6
      Masahiro Yamada authored
      Commit fbe98bb9 ("kconfig: Fix defconfig when one choice menu
      selects options that another choice menu depends on") fixed defconfig
      when two choices interact (i.e. calculating the visibility of a choice
      requires to calculate another choice).
      
      The test code in that commit log was based on the real world example,
      and complicated.  So, I shrunk it down to the following:
      
      defconfig.choice:
      ---8<---
      CONFIG_CHOICE_VAL0=y
      ---8<---
      
      ---8<---
      config MODULES
              def_bool y
              option modules
      
      choice
              prompt "Choice"
      
      config CHOICE_VAL0
              tristate "Choice 0"
      
      config CHOICE_VAL1
              tristate "Choice 1"
      
      endchoice
      
      choice
              prompt "Another choice"
              depends on CHOICE_VAL0
      
      config DUMMY
              bool "dummy"
      
      endchoice
      ---8<---
      
      Prior to commit fbe98bb9,
      
        $ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice
      
      resulted in:
      
        CONFIG_MODULES=y
        CONFIG_CHOICE_VAL0=m
        # CONFIG_CHOICE_VAL1 is not set
        CONFIG_DUMMY=y
      
      where the expected result would be:
      
        CONFIG_MODULES=y
        CONFIG_CHOICE_VAL0=y
        # CONFIG_CHOICE_VAL1 is not set
        CONFIG_DUMMY=y
      
      Roughly, this weird behavior happened like this:
      
      Symbols are calculated a couple of times.  First, all symbols are
      calculated in conf_read().  The first 'choice' is evaluated to 'y'
      due to the SYMBOL_DEF_USER flag, but sym_calc_choice() clears it
      unless all of its choice values are explicitly set by the user.
      
      conf_set_all_new_symbols() clears all SYMBOL_VALID flags.  Then, only
      choices are calculated.  Here, the SYMBOL_DEF_USER for the first choice
      has been forgotten, so it is evaluated to 'm'.  set_all_choice_values()
      sets SYMBOL_DEF_USER again to choice symbols.
      
      When calculating the second choice, due to 'depends on CHOICE_VAL0',
      it triggers the calculation of CHOICE_VAL0.  As a result, SYMBOL_VALID
      is set for CHOICE_VAL0.
      
      Symbols except choices get the final chance of re-calculation in
      conf_write().  In a normal case, CHOICE_VAL0 would be re-calculated,
      then the first choice would be indirectly re-calculated with the
      SYMBOL_DEF_USER which has been recalled by set_all_choice_values(),
      which would be evaluated to 'y'.  But, in this case, CHOICE_VAL0 has
      already been marked as SYMBOL_VALID, so this re-calculation does not
      happen.  Then, =m from the conf_set_all_new_symbols() phase is written
      out to the .config file.
      
      Add a unit test for this naive case.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      beaaddb6
    • Masahiro Yamada's avatar
      kconfig: tests: check visibility of tristate choice values in y choice · ee236610
      Masahiro Yamada authored
      If tristate choice values depend on symbols set to 'm', they should be
      hidden when the choice containing them is changed from 'm' to 'y'
      (i.e. exclusive choice).
      
      This issue was fixed by commit fa64e5f6 ("kconfig/symbol.c: handle
      choice_values that depend on 'm' symbols").
      
      Add a test case to avoid regression.
      
      For the input in this unit test, there is a room for argument if
      "# CONFIG_CHOICE1 is not set" should be written to the .config file.
      
      After commit fa64e5f6, this line was written to the .config file.
      
      With commit cb67ab2c ("kconfig: do not write choice values when
      their dependency becomes n"), it is not written now.
      
      In this test, "# CONFIG_CHOICE1 is not set" is don't care.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      ee236610
    • Masahiro Yamada's avatar
      kconfig: tests: check unneeded "is not set" with unmet dependency · 930c429a
      Masahiro Yamada authored
      Commit cb67ab2c ("kconfig: do not write choice values when their
      dependency becomes n") fixed a problem where "# CONFIG_... is not set"
      for choice values are wrongly written into the .config file when they
      are once visible, then become invisible later.
      
      Add a test for this naive case.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      930c429a
    • Masahiro Yamada's avatar
      kconfig: tests: test if new symbols in choice are asked · b76960c0
      Masahiro Yamada authored
      If new choice values are added with new dependency, and they become
      visible during user configuration, oldconfig should recognize them
      as (NEW), and ask the user for choice.
      
      This issue was fixed by commit 5d09598d ("kconfig: fix new choices
      being skipped upon config update").
      
      This is a subtle corner case.  Add a test case to avoid breakage.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      b76960c0
    • Masahiro Yamada's avatar
      kconfig: tests: test automatic submenu creation · 49ac3c0c
      Masahiro Yamada authored
      If a symbols has dependency on the preceding symbol, the menu entry
      should become the submenu of the preceding one, and displayed with
      deeper indentation.
      
      This is done by restructuring the menu tree in menu_finalize().
      It is a bit complicated computation, so let's add a test case.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      49ac3c0c
    • Masahiro Yamada's avatar
      kconfig: tests: add basic choice tests · 1903c511
      Masahiro Yamada authored
      The calculation of 'choice' is a bit complicated part in Kconfig.
      
      The behavior of 'y' choice is intuitive.  If choice values are tristate,
      the choice can be 'm' where each value can be enabled independently.
      Also, if a choice is marked as 'optional', the whole choice can be
      invisible.
      
      Test basic functionality of choice.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      1903c511
    • Masahiro Yamada's avatar
      kconfig: tests: add framework for Kconfig unit testing · 022a4bf6
      Masahiro Yamada authored
      Many parts in Kconfig are so cryptic and need refactoring.  However,
      its complexity prevents us from moving forward.  There are several
      naive corner cases where it is difficult to notice breakage.  If
      those are covered by unit tests, we will be able to touch the code
      with more confidence.
      
      Here is a simple test framework based on pytest.  The conftest.py
      provides a fixture useful to run commands such as 'oldaskconfig' etc.
      and to compare the resulted .config, stdout, stderr with expectations.
      
      How to add test cases?
      ----------------------
      
      For each test case, you should create a subdirectory under
      scripts/kconfig/tests/ (so test cases are separated from each other).
      Every test case directory should contain the following files:
      
       - __init__.py: describes test functions
       - Kconfig: the top level Kconfig file for the test
      
      To do a useful job, test cases generally need additional data like
      input .config and information about expected results.
      
      How to run tests?
      -----------------
      
      You need python3 and pytest.  Then, run "make testconfig".  O= option
      is supported.  If V=1 is given, detailed logs captured during tests
      are displayed.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      022a4bf6
    • Masahiro Yamada's avatar
      kbuild: add PYTHON2 and PYTHON3 variables · e9781b52
      Masahiro Yamada authored
      The variable 'PYTHON' allows users to specify a proper executable
      name in case the default 'python' does not work.  However, this does
      not address the case where both Python 2.x and 3.x scripts are used
      in one source tree.
      
      PEP 394 (https://www.python.org/dev/peps/pep-0394/) provides a
      convention for Python scripts portability.  Here is a quotation:
      
        In order to tolerate differences across platforms, all new code
        that needs to invoke the Python interpreter should not specify
        'python', but rather should specify either 'python2' or 'python3'.
        This distinction should be made in shebangs, when invoking from a
        shell script, when invoking via the system() call, or when invoking
        in any other context.
        One exception to this is scripts that are deliberately written to
        be source compatible with both Python 2.x and 3.x. Such scripts may
        continue to use python on their shebang line without affecting their
        portability.
      
      To meet this requirement, this commit adds new variables 'PYTHON2'
      and 'PYTHON3'.
      
      arch/ia64/scripts/unwcheck.py is the only script that has ever used
      $(PYTHON).  Recent commit bd5edbe6 ("ia64: convert unwcheck.py to
      python3") converted it to be compatible with both Python 2.x and 3.x,
      so this is the exceptional case where the use of 'python' is allowed.
      So, I did not touch arch/ia64/Makefile.
      
      tools/perf/Makefile.config sets PYTHON and PYTHON2 by itself, so it
      is not affected by this commit.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e9781b52
    • Ulf Magnusson's avatar
      kconfig: remove redundant streamline_config.pl prerequisite · 2a616258
      Ulf Magnusson authored
      The local{yes,mod}config targets currently have streamline_config.pl as
      a prerequisite. This is redundant, because streamline_config.pl is a
      checked-in file with no prerequisites.
      
      Remove the prerequisite and reference streamline_config.pl directly in
      the recipe of the rule instead.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      2a616258
    • Masahiro Yamada's avatar
      kconfig: rename silentoldconfig to syncconfig · 911a91c3
      Masahiro Yamada authored
      As commit cedd55d4 ("kconfig: Remove silentoldconfig from help
      and docs; fix kconfig/conf's help") mentioned, 'silentoldconfig' is a
      historical misnomer.  That commit removed it from help and docs since
      it is an internal interface.  If so, it should be allowed to rename
      it to something more intuitive.  'syncconfig' is the one I came up
      with because it updates the .config if necessary, then synchronize
      include/generated/autoconf.h and include/config/* with it.
      
      You should not manually invoke 'silentoldcofig'.  Display warning if
      used in case existing scripts are doing wrong.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      911a91c3
    • Masahiro Yamada's avatar
      kconfig: invoke oldconfig instead of silentoldconfig from local*config · 81d2bc22
      Masahiro Yamada authored
      The purpose of local{yes,mod}config is to arrange the .config file
      based on actually loaded modules.  It is unnecessary to update
      include/generated/autoconf.h and include/config/* stuff here.
      They will be updated as needed during the build.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      81d2bc22
    • Masahiro Yamada's avatar
      kconfig: hide irrelevant sub-menus for oldconfig · 2aad9b89
      Masahiro Yamada authored
      Historically, "make oldconfig" has changed its behavior several times,
      quieter or louder.  (I attached the history below.)  Currently, it is
      not as quiet as it should be.  This commit addresses it.
      
        Test Case
        ---------
      
      ---------------------------(Kconfig)----------------------------
      menu "menu"
      
      config FOO
              bool "foo"
      
      menu "sub menu"
      
      config BAR
              bool "bar"
      
      endmenu
      
      endmenu
      
      menu "sibling menu"
      
      config BAZ
              bool "baz"
      
      endmenu
      ----------------------------------------------------------------
      
      ---------------------------(.config)----------------------------
      CONFIG_BAR=y
      CONFIG_BAZ=y
      ----------------------------------------------------------------
      
      With the Kconfig and .config above, "make silentoldconfig" and
      "make oldconfig" work differently, like follows:
      
        $ make silentoldconfig
        scripts/kconfig/conf  --silentoldconfig Kconfig
        *
        * Restart config...
        *
        *
        * menu
        *
        foo (FOO) [N/y/?] (NEW) y
        #
        # configuration written to .config
        #
      
        $ make oldconfig
        scripts/kconfig/conf  --oldconfig Kconfig
        *
        * Restart config...
        *
        *
        * menu
        *
        foo (FOO) [N/y/?] (NEW) y
        *
        * sub menu
        *
        bar (BAR) [Y/n/?] y
        #
        # configuration written to .config
        #
      
      Both hide "sibling node" since it is irrelevant.  The difference is
      that silentoldconfig hides "sub menu" whereas oldconfig does not.
      The behavior of silentoldconfig is preferred since the "sub menu"
      does not contain any new symbol.
      
      The root cause is in conf().  There are three input modes that can
      call conf(); oldaskconfig, oldconfig, and silentoldconfig.
      
      Everytime conf() encounters a menu entry, it calls check_conf() to
      check if it contains new symbols.  If no new symbol is found, the
      menu is just skipped.
      
      Currently, this happens only when input_mode == silentoldconfig.
      The oldaskconfig enters into the check_conf() loop as silentoldconfig,
      so oldaskconfig works likewise for the second loop or later, but it
      never happens for oldconfig.  So, irrelevant sub-menus are shown for
      oldconfig.
      
      Change the test condition to "input_mode != oldaskconfig".  This is
      false only for the first loop of oldaskconfig; it must ask the user
      all symbols, so no need to call check_conf().
      
        History of oldconfig
        --------------------
      
      [0] Originally, "make oldconfig" was as loud as "make config"  (It
          showed the entire .config file)
      
      [1] Commit cd9140e1 ("kconfig: make oldconfig is now less chatty")
          made oldconfig quieter, but it was still less quieter than
          silentoldconfig.  (oldconfig did not hide sub-menus)
      
      [2] Commit 204c96f6 ("kconfig: fix silentoldconfig") changed
          the input_mode of oldconfig to "ask_silent" from "ask_new".
          So, oldconfig really became as quiet as silentoldconfig.
          (oldconfig hided irrelevant sub-menus)
      
      [3] Commit 4062f1a4 ("kconfig: use long options in conf") made
          oldconfig as loud as [0] due to misconversion.
      
      [4] Commit 14828349 ("kconfig: fix make oldconfig") addressed
          the misconversion of [3], but it made oldconfig quieter only to
          the same level as [1], not [2].
      
      This commit is restoring the behavior of [2].
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      2aad9b89
    • Masahiro Yamada's avatar
      kconfig: remove redundant input_mode test for check_conf() loop · 99f0b657
      Masahiro Yamada authored
      check_conf() never increments conf_cnt for listnewconfig, so conf_cnt
      is always zero.
      
      In other words, conf_cnt is not zero, "input_mode != listnewconfig"
      is met.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      99f0b657
    • Masahiro Yamada's avatar
      kconfig: remove unneeded input_mode test in conf() · 4bb3a5b0
      Masahiro Yamada authored
      conf() is never called for listnewconfig / olddefconfig.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      4bb3a5b0
    • Masahiro Yamada's avatar
      kconfig: do not call check_conf() for olddefconfig · 59a80b5e
      Masahiro Yamada authored
      check_conf() traverses the menu tree, but it is completely no-op for
      olddefconfig because the following if-else block does nothing.
      
          if (input_mode == listnewconfig) {
                  ...
          } else if (input_mode != olddefconfig) {
                  ...
          }
      
      As the help message says, olddefconfig automatically sets new symbols
      to their default value.  There is no room for manual intervention.
      So, calling check_conf() for olddefconfig is odd in the first place.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      59a80b5e
    • Ulf Magnusson's avatar
      kconfig: only write '# CONFIG_FOO is not set' for visible symbols · f467c564
      Ulf Magnusson authored
      === Background ===
      
       - Visible n-valued bool/tristate symbols generate a
         '# CONFIG_FOO is not set' line in the .config file. The idea is to
         remember the user selection without having to set a Makefile
         variable. Having n correspond to the variable being undefined in the
         Makefiles makes for easy CONFIG_* tests.
      
       - Invisible n-valued bool/tristate symbols normally do not generate a
         '# CONFIG_FOO is not set' line, because user values from .config
         files have no effect on invisible symbols anyway.
      
      Currently, there is one exception to this rule: Any bool/tristate symbol
      that gets the value n through a 'default' property generates a
      '# CONFIG_FOO is not set' line, even if the symbol is invisible.
      
      Note that this only applies to explicitly given defaults, and not when
      the symbol implicitly defaults to n (like bool/tristate symbols without
      'default' properties do).
      
      This is inconsistent, and seems redundant:
      
        - As mentioned, the '# CONFIG_FOO is not set' won't affect the symbol
          once the .config is read back in.
      
        - Even if the symbol is invisible at first but becomes visible later,
          there shouldn't be any harm in recalculating the default value
          rather than viewing the '# CONFIG_FOO is not set' as a previous
          user value of n.
      
      === Changes ===
      
      Change sym_calc_value() to only set SYMBOL_WRITE (write to .config) for
      non-n-valued 'default' properties.
      
      Note that SYMBOL_WRITE is always set for visible symbols regardless of whether
      they have 'default' properties or not, so this change only affects invisible
      symbols.
      
      This reduces the size of the x86 .config on my system by about 1% (due
      to removed '# CONFIG_FOO is not set' entries).
      
      One side effect of (and the main motivation for) this change is making
      the following two definitions behave exactly the same:
      
      	config FOO
      		bool
      
      	config FOO
      		bool
      		default n
      
      With this change, neither of these will generate a
      '# CONFIG_FOO is not set' line (assuming FOO isn't selected/implied).
      That might make it clearer to people that a bare 'default n' is
      redundant.
      
      This change only affects generated .config files and not autoconf.h:
      autoconf.h only includes #defines for non-n bool/tristate symbols.
      
      === Testing ===
      
      The following testing was done with the x86 Kconfigs:
      
       - .config files generated before and after the change were compared to
         verify that the only difference is some '# CONFIG_FOO is not set'
         entries disappearing. A couple of these were inspected manually, and
         most turned out to be from redundant 'default n/def_bool n'
         properties.
      
       - The generated include/generated/autoconf.h was compared before and
         after the change and verified to be identical.
      
       - As a sanity check, the same modification was done to Kconfiglib.
         The Kconfiglib test suite was then run to check for any mismatches
         against the output of the C implementation.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      f467c564
    • Eugeniu Rosca's avatar
      kconfig: Print reverse dependencies in groups · d9119b59
      Eugeniu Rosca authored
      Surprisingly or not, disabling a CONFIG option (which is assumed to
      be unneeded) may be not so trivial. Especially it is not trivial, when
      this CONFIG option is selected by a dozen of other configs. Before the
      moment commit 1ccb2714 ("kconfig: make "Selected by:" and
      "Implied by:" readable") popped up in v4.16-rc1, it was an absolute pain
      to break down the "Selected by" reverse dependency expression in order
      to identify all those configs which select (IOW *do not allow
      disabling*) a certain feature (assumed to be not needed).
      
      This patch tries to make one step further by putting at users'
      fingertips the revdep top level OR sub-expressions grouped/clustered by
      the tristate value they evaluate to. This should allow the users to
      directly concentrate on and tackle the _active_ reverse dependencies.
      
      To give some numbers and quantify the complexity of certain reverse
      dependencies, assuming commit 617aebe6 ("Merge tag
      'usercopy-v4.16-rc1' of
      git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux"), ARCH=arm64
      and vanilla arm64 defconfig, here is the top 10 CONFIG options with
      the highest amount of top level "||" sub-expressions/tokens that make
      up the final "Selected by" reverse dependency expression.
      
      | Config            | All revdep | Active revdep |
      |-------------------|------------|---------------|
      | REGMAP_I2C        | 212        | 9             |
      | CRC32             | 167        | 25            |
      | FW_LOADER         | 128        | 5             |
      | MFD_CORE          | 124        | 9             |
      | FB_CFB_IMAGEBLIT  | 114        | 2             |
      | FB_CFB_COPYAREA   | 111        | 2             |
      | FB_CFB_FILLRECT   | 110        | 2             |
      | SND_PCM           | 103        | 2             |
      | CRYPTO_HASH       | 87         | 19            |
      | WATCHDOG_CORE     | 86         | 6             |
      
      The story behind the above is that users need to visually
      review/evaluate 212 expressions which *potentially* select REGMAP_I2C
      in order to identify the expressions which *actually* select REGMAP_I2C,
      for a particular ARCH and for a particular defconfig used.
      
      To make this experience smoother, change the way reverse dependencies
      are displayed to the user from [1] to [2].
      
      [1] Old representation of DMA_ENGINE_RAID:
        Selected by:
        - AMCC_PPC440SPE_ADMA [=n] && DMADEVICES [=y] && (440SPe || 440SP)
        - BCM_SBA_RAID [=m] && DMADEVICES [=y] && (ARM64 [=y] || ...
        - FSL_RAID [=n] && DMADEVICES [=y] && FSL_SOC && ...
        - INTEL_IOATDMA [=n] && DMADEVICES [=y] && PCI [=y] && X86_64
        - MV_XOR [=n] && DMADEVICES [=y] && (PLAT_ORION || ARCH_MVEBU [=y] ...
        - MV_XOR_V2 [=y] && DMADEVICES [=y] && ARM64 [=y]
        - XGENE_DMA [=n] && DMADEVICES [=y] && (ARCH_XGENE [=y] || ...
        - DMATEST [=n] && DMADEVICES [=y] && DMA_ENGINE [=y]
      
      [2] New representation of DMA_ENGINE_RAID:
        Selected by [y]:
        - MV_XOR_V2 [=y] && DMADEVICES [=y] && ARM64 [=y]
        Selected by [m]:
        - BCM_SBA_RAID [=m] && DMADEVICES [=y] && (ARM64 [=y] || ...
        Selected by [n]:
        - AMCC_PPC440SPE_ADMA [=n] && DMADEVICES [=y] && (440SPe || ...
        - FSL_RAID [=n] && DMADEVICES [=y] && FSL_SOC && ...
        - INTEL_IOATDMA [=n] && DMADEVICES [=y] && PCI [=y] && X86_64
        - MV_XOR [=n] && DMADEVICES [=y] && (PLAT_ORION || ARCH_MVEBU [=y] ...
        - XGENE_DMA [=n] && DMADEVICES [=y] && (ARCH_XGENE [=y] || ...
        - DMATEST [=n] && DMADEVICES [=y] && DMA_ENGINE [=y]
      Suggested-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Reviewed-by: default avatarPetr Vorel <pvorel@suse.cz>
      Reviewed-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d9119b59
    • Masahiro Yamada's avatar
      kconfig: clean-up reverse dependency help implementation · 9a47ceec
      Masahiro Yamada authored
      This commit splits out the special E_OR handling ('-' instead of '||')
      into a dedicated helper expr_print_revdev().
      
      Restore the original expr_print() prior to commit 1ccb2714
      ("kconfig: make "Selected by:" and "Implied by:" readable").
      
      This makes sense because:
      
        - We need to chop those expressions only when printing the reverse
          dependency, and only when E_OR is encountered
      
        - Otherwise, it should be printed as before, so fall back to
          expr_print()
      
      This also improves the behavior; for a single line, it was previously
      displayed in the same line as "Selected by", like this:
      
        Selected by: A [=n] && B [=n]
      
      This will be displayed in a new line, consistently:
      
        Selected by:
        - A [=n] && B [=n]
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarPetr Vorel <pvorel@suse.cz>
      9a47ceec
    • Ulf Magnusson's avatar
      checkpatch: kconfig: prefer 'help' over '---help---' · 84af7a61
      Ulf Magnusson authored
      IMO, we should discourage '---help---' for new help texts, even in cases
      where it would be consistent with other help texts in the file. This
      will help if we ever want to get rid of '---help---' in the future.
      
      Also simplify the code to only check for exactly '---help---'. Since
      commit c2264564 ("kconfig: warn of unhandled characters in Kconfig
      commands"), '---help---' is a proper keyword and can only appear in that
      form. Prior to that commit, '---help---' working was more of a syntactic
      quirk.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      84af7a61
    • Ulf Magnusson's avatar
      checkpatch: kconfig: check help texts for menuconfig and choice · 678ae162
      Ulf Magnusson authored
      Currently, only Kconfig symbols are checked for a missing or short help
      text, and are only checked if they are defined with the 'config'
      keyword.
      
      To make the check more general, extend it to also check help texts for
      choices and for symbols defined with the 'menuconfig' keyword.
      
      This increases the accuracy of the check for symbols that would already
      have been checked as well, since e.g. a 'menuconfig' symbol after a help
      text will be recognized as ending the preceding symbol/choice
      definition.
      
      To increase the accuracy of the check further, also recognize 'if',
      'endif', 'menu', 'endmenu', 'endchoice', and 'source' as ending a
      symbol/choice definition.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      678ae162
    • Ulf Magnusson's avatar
      checkpatch: kconfig: recognize more prompts when checking help texts · 86adf1a0
      Ulf Magnusson authored
      The check for a missing or short help text only considers symbols with a
      prompt, but doesn't recognize any of the following as a prompt:
      
      	bool 'foo'
      	tristate 'foo'
      	prompt "foo"
      	prompt 'foo'
      
      Make the check recognize those too.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      86adf1a0
  2. 12 Mar, 2018 1 commit
  3. 11 Mar, 2018 8 commits
    • Linus Torvalds's avatar
      Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · ed58d66f
      Linus Torvalds authored
      Pull x86/pti updates from Thomas Gleixner:
       "Yet another pile of melted spectrum related updates:
      
         - Drop native vsyscall support finally as it causes more trouble than
           benefit.
      
         - Make microcode loading more robust. There were a few issues
           especially related to late loading which are now surfacing because
           late loading of the IB* microcodes addressing spectre issues has
           become more widely used.
      
         - Simplify and robustify the syscall handling in the entry code
      
         - Prevent kprobes on the entry trampoline code which lead to kernel
           crashes when the probe hits before CR3 is updated
      
         - Don't check microcode versions when running on hypervisors as they
           are considered as lying anyway.
      
         - Fix the 32bit objtool build and a coment typo"
      
      * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/kprobes: Fix kernel crash when probing .entry_trampoline code
        x86/pti: Fix a comment typo
        x86/microcode: Synchronize late microcode loading
        x86/microcode: Request microcode on the BSP
        x86/microcode/intel: Look into the patch cache first
        x86/microcode: Do not upload microcode if CPUs are offline
        x86/microcode/intel: Writeback and invalidate caches before updating microcode
        x86/microcode/intel: Check microcode revision before updating sibling threads
        x86/microcode: Get rid of struct apply_microcode_ctx
        x86/spectre_v2: Don't check microcode versions when running under hypervisors
        x86/vsyscall/64: Drop "native" vsyscalls
        x86/entry/64/compat: Save one instruction in entry_INT80_compat()
        x86/entry: Do not special-case clone(2) in compat entry
        x86/syscalls: Use COMPAT_SYSCALL_DEFINEx() macros for x86-only compat syscalls
        x86/syscalls: Use proper syscall definition for sys_ioperm()
        x86/entry: Remove stale syscall prototype
        x86/syscalls/32: Simplify $entry == $compat entries
        objtool: Fix 32-bit build
      ed58d66f
    • Linus Torvalds's avatar
      Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 1ad5daa6
      Linus Torvalds authored
      Pull timer fix from Thomas Gleixner:
       "Just a single fix which adds a missing Kconfig dependency to avoid
        unmet dependency warnings"
      
      * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        clocksource/atmel-st: Add 'depends on HAS_IOMEM' to fix unmet dependency
      1ad5daa6
    • Linus Torvalds's avatar
      Merge branch 'ras-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · ebb3762e
      Linus Torvalds authored
      Pull RAS fixes from Thomas Gleixner:
       "Two small fixes for RAS/MCE:
      
         - Serialize sysfs changes to avoid concurrent modificaiton of
           underlying data
      
         - Add microcode revision to Machine Check records. This should have
           been there forever, but now with the broken microcode versions in
           the wild it has become important"
      
      * 'ras-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/MCE: Serialize sysfs changes
        x86/MCE: Save microcode revision in machine check records
      ebb3762e
    • Linus Torvalds's avatar
      Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 8ad44243
      Linus Torvalds authored
      Pull perf updates from Thomas Gleixner:
       "Another set of perf updates:
      
         - Fix a Skylake Uncore event format declaration
      
         - Prevent perf pipe mode from crahsing which was caused by a missing
           buffer allocation
      
         - Make the perf top popup message which tells the user that it uses
           fallback mode on older kernels a debug message.
      
         - Make perf context rescheduling work correcctly
      
         - Robustify the jump error drawing in perf browser mode so it does
           not try to create references to NULL initialized offset entries
      
         - Make trigger_on() robust so it does not enable the trigger before
           everything is set up correctly to handle it
      
         - Make perf auxtrace respect the --no-itrace option so it does not
           try to queue AUX data for decoding.
      
         - Prevent having different number of field separators in CVS output
           lines when a counter is not supported.
      
         - Make the perf kallsyms man page usage behave like it does for all
           other perf commands.
      
         - Synchronize the kernel headers"
      
      * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/core: Fix ctx_event_type in ctx_resched()
        perf tools: Fix trigger class trigger_on()
        perf auxtrace: Prevent decoding when --no-itrace
        perf stat: Fix CVS output format for non-supported counters
        tools headers: Sync x86's cpufeatures.h
        tools headers: Sync copy of kvm UAPI headers
        perf record: Fix crash in pipe mode
        perf annotate browser: Be more robust when drawing jump arrows
        perf top: Fix annoying fallback message on older kernels
        perf kallsyms: Fix the usage on the man page
        perf/x86/intel/uncore: Fix Skylake UPI event format
      8ad44243
    • Linus Torvalds's avatar
      Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 02bf0ef0
      Linus Torvalds authored
      Pull locking fix from Thomas Gleixner:
       "rt_mutex_futex_unlock() grew a new irq-off call site, but the function
        assumes that its always called from irq enabled context.
      
        Use (un)lock_irqsafe() to handle the new call site correctly"
      
      * 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        rtmutex: Make rt_mutex_futex_unlock() safe for irq-off callsites
      02bf0ef0
    • Linus Torvalds's avatar
      Merge tag 'dmaengine-fix-4.16-rc5' of git://git.infradead.org/users/vkoul/slave-dma · abeb7521
      Linus Torvalds authored
      Pull dmaengine fixes from Vinod Koul:
       "Two small fixes are for this cycle:
      
         - fix max_chunk_size for rcar-dmac for R-Car Gen3
      
         - fix clock resource of mv_xor_v2"
      
      * tag 'dmaengine-fix-4.16-rc5' of git://git.infradead.org/users/vkoul/slave-dma:
        dmaengine: mv_xor_v2: Fix clock resource by adding a register clock
        dmaengine: rcar-dmac: fix max_chunk_size for R-Car Gen3
      abeb7521
    • Linus Torvalds's avatar
      Merge tag 'gpio-v4.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio · d43be80a
      Linus Torvalds authored
      Pull GPIO fix from Linus Walleij:
       "This is a single GPIO fix for the v4.16 series affecting the Renesas
        driver, and fixes wakeup from external stuff"
      
      * tag 'gpio-v4.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
        gpio: rcar: Use wakeup_path i.s.o. explicit clock handling
      d43be80a
    • Gregory CLEMENT's avatar
      dmaengine: mv_xor_v2: Fix clock resource by adding a register clock · 3cd2c313
      Gregory CLEMENT authored
      On the CP110 components which are present on the Armada 7K/8K SoC we need
      to explicitly enable the clock for the registers. However it is not
      needed for the AP8xx component, that's why this clock is optional.
      
      With this patch both clock have now a name, but in order to be backward
      compatible, the name of the first clock is not used. It allows to still
      use this clock with a device tree using the old binding.
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      3cd2c313
  4. 10 Mar, 2018 1 commit