Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1504412 > unrolled thread
| Started by | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| First post | 2016-10-20 01:50 +0200 |
| Last post | 2016-10-20 21:00 +0200 |
| Articles | 20 on this page of 24 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH 0/4] make POSIX timers optional with some Kconfig help Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 01:50 +0200
[PATCH 3/4] ptp_clock: allow for it to be optional Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 01:50 +0200
Re: [PATCH 3/4] ptp_clock: allow for it to be optional Thomas Gleixner <tglx@linutronix.de> - 2016-10-20 12:00 +0200
Re: [PATCH 3/4] ptp_clock: allow for it to be optional Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 19:50 +0200
Re: [PATCH 3/4] ptp_clock: allow for it to be optional Thomas Gleixner <tglx@linutronix.de> - 2016-10-20 20:10 +0200
Re: [PATCH 3/4] ptp_clock: allow for it to be optional Richard Cochran <richardcochran@gmail.com> - 2016-10-20 16:10 +0200
Re: [PATCH 3/4] ptp_clock: allow for it to be optional Josh Triplett <josh@joshtriplett.org> - 2016-10-20 17:50 +0200
Re: [PATCH 3/4] ptp_clock: allow for it to be optional Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 18:50 +0200
[PATCH 1/4] kconfig: introduce the "imply" keyword Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 01:50 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-10-20 09:00 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Edward Cree <ecree@solarflare.com> - 2016-10-20 17:00 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Josh Triplett <josh@joshtriplett.org> - 2016-10-20 17:50 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 19:10 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Edward Cree <ecree@solarflare.com> - 2016-10-20 19:50 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 20:30 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Edward Cree <ecree@solarflare.com> - 2016-10-20 21:20 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 22:20 +0200
Re: [PATCH 1/4] kconfig: introduce the "imply" keyword Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-21 05:30 +0200
[PATCH 4/4] posix-timers: make it configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 01:50 +0200
Re: [PATCH 4/4] posix-timers: make it configurable Richard Cochran <richardcochran@gmail.com> - 2016-10-20 16:10 +0200
Re: [PATCH 4/4] posix-timers: make it configurable Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 18:50 +0200
Re: [PATCH 0/4] make POSIX timers optional with some Kconfig help Thomas Gleixner <tglx@linutronix.de> - 2016-10-20 11:50 +0200
Re: [PATCH 0/4] make POSIX timers optional with some Kconfig help Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-10-20 20:40 +0200
Re: [PATCH 0/4] make POSIX timers optional with some Kconfig help Josh Triplett <josh@joshtriplett.org> - 2016-10-20 21:00 +0200
Page 1 of 2 [1] 2 Next page →
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 01:50 +0200 |
| Subject | [PATCH 0/4] make POSIX timers optional with some Kconfig help |
| Message-ID | <su8Mp-881-9@gated-at.bofh.it> |
Many embedded systems don't need the full POSIX timer support. Configuring them out provides a nice kernel image size reduction. When POSIX timers are configured out, the PTP clock subsystem should be left out as well. However a bunch of ethernet drivers currently *select* the later in their Kconfig entries. Therefore some more work was needed to break that hard dependency from those drivers without preventing their usage altogether. Therefore this series also includes kconfig changes to implement a new keyword to express some reverse dependencies like "select" does, named "imply", and still allowing for the target config symbol to be disabled if the user or a direct dependency says so. How to deal with the dependencies across three subsystems for potential upstream merging needs to be figured out. The bulk of the diffstat comes from the kconfig lex parser regeneration. diffstat: Documentation/kbuild/kconfig-language.txt | 28 + drivers/Makefile | 2 +- drivers/net/ethernet/adi/Kconfig | 2 +- drivers/net/ethernet/amd/Kconfig | 2 +- drivers/net/ethernet/amd/xgbe/xgbe-main.c | 6 +- drivers/net/ethernet/broadcom/Kconfig | 4 +- drivers/net/ethernet/cavium/Kconfig | 2 +- drivers/net/ethernet/freescale/Kconfig | 2 +- drivers/net/ethernet/intel/Kconfig | 10 +- drivers/net/ethernet/mellanox/mlx4/Kconfig | 2 +- drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 2 +- drivers/net/ethernet/renesas/Kconfig | 2 +- drivers/net/ethernet/samsung/Kconfig | 2 +- drivers/net/ethernet/sfc/Kconfig | 2 +- drivers/net/ethernet/stmicro/stmmac/Kconfig | 2 +- drivers/net/ethernet/ti/Kconfig | 2 +- drivers/net/ethernet/tile/Kconfig | 2 +- drivers/ptp/Kconfig | 10 +- include/linux/posix-timers.h | 28 +- include/linux/ptp_clock_kernel.h | 65 +- include/linux/sched.h | 10 + init/Kconfig | 17 + kernel/signal.c | 4 + kernel/time/Makefile | 10 +- kernel/time/posix-stubs.c | 118 ++ scripts/kconfig/expr.h | 2 + scripts/kconfig/menu.c | 55 +- scripts/kconfig/symbol.c | 26 +- scripts/kconfig/zconf.gperf | 1 + scripts/kconfig/zconf.hash.c_shipped | 30 +- scripts/kconfig/zconf.tab.c_shipped | 1581 ++++++++--------- scripts/kconfig/zconf.y | 16 +- 32 files changed, 1115 insertions(+), 932 deletions(-)
[toc] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 01:50 +0200 |
| Subject | [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <su8Mq-881-21@gated-at.bofh.it> |
| In reply to | #1504412 |
In order to break the hard dependency between the PTP clock subsystem and
ethernet drivers capable of being clock providers, this patch provides
simple PTP stub functions to allow linkage of those drivers into the
kernel even when the PTP subsystem is configured out. Drivers must be
ready to accept NULL from ptp_clock_register() in that case.
And to make it possible for PTP to be configured out, the select statement
in those driver's Kconfig menu entries is converted to the new "imply"
statement. This way the PTP subsystem may have Kconfig dependencies of
its own, such as POSIX_TIMERS, without having to make those ethernet
drivers unavailable if POSIX timers are cconfigured out. And when support
for POSIX timers is selected again then the default config option for PTP
clock support will automatically be adjusted accordingly.
The pch_gbe driver is a bit special as it relies on extra code in
drivers/ptp/ptp_pch.c. Therefore we let the make process descend into
drivers/ptp/ even if PTP_1588_CLOCK is unselected.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
---
drivers/Makefile | 2 +-
drivers/net/ethernet/adi/Kconfig | 2 +-
drivers/net/ethernet/amd/Kconfig | 2 +-
drivers/net/ethernet/amd/xgbe/xgbe-main.c | 6 ++-
drivers/net/ethernet/broadcom/Kconfig | 4 +-
drivers/net/ethernet/cavium/Kconfig | 2 +-
drivers/net/ethernet/freescale/Kconfig | 2 +-
drivers/net/ethernet/intel/Kconfig | 10 ++--
drivers/net/ethernet/mellanox/mlx4/Kconfig | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 2 +-
drivers/net/ethernet/renesas/Kconfig | 2 +-
drivers/net/ethernet/samsung/Kconfig | 2 +-
drivers/net/ethernet/sfc/Kconfig | 2 +-
drivers/net/ethernet/stmicro/stmmac/Kconfig | 2 +-
drivers/net/ethernet/ti/Kconfig | 2 +-
drivers/net/ethernet/tile/Kconfig | 2 +-
drivers/ptp/Kconfig | 8 +--
include/linux/ptp_clock_kernel.h | 65 ++++++++++++++++---------
18 files changed, 69 insertions(+), 50 deletions(-)
diff --git a/drivers/Makefile b/drivers/Makefile
index f0afdfb3c7..8cfa1ff8f6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -107,7 +107,7 @@ obj-$(CONFIG_INPUT) += input/
obj-$(CONFIG_RTC_LIB) += rtc/
obj-y += i2c/ media/
obj-$(CONFIG_PPS) += pps/
-obj-$(CONFIG_PTP_1588_CLOCK) += ptp/
+obj-y += ptp/
obj-$(CONFIG_W1) += w1/
obj-y += power/
obj-$(CONFIG_HWMON) += hwmon/
diff --git a/drivers/net/ethernet/adi/Kconfig b/drivers/net/ethernet/adi/Kconfig
index 6b94ba6103..98cc8f5350 100644
--- a/drivers/net/ethernet/adi/Kconfig
+++ b/drivers/net/ethernet/adi/Kconfig
@@ -58,7 +58,7 @@ config BFIN_RX_DESC_NUM
config BFIN_MAC_USE_HWSTAMP
bool "Use IEEE 1588 hwstamp"
depends on BFIN_MAC && BF518
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
default y
---help---
To support the IEEE 1588 Precision Time Protocol (PTP), select y here
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index 0038709fd3..713ea7ad22 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -177,7 +177,7 @@ config AMD_XGBE
depends on ARM64 || COMPILE_TEST
select BITREVERSE
select CRC32
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports the AMD 10GbE Ethernet device found on an
AMD SoC.
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 9de078819a..e10e569c0d 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -773,7 +773,8 @@ static int xgbe_probe(struct platform_device *pdev)
goto err_wq;
}
- xgbe_ptp_register(pdata);
+ if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
+ xgbe_ptp_register(pdata);
xgbe_debugfs_init(pdata);
@@ -812,7 +813,8 @@ static int xgbe_remove(struct platform_device *pdev)
xgbe_debugfs_exit(pdata);
- xgbe_ptp_unregister(pdata);
+ if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
+ xgbe_ptp_unregister(pdata);
flush_workqueue(pdata->an_workqueue);
destroy_workqueue(pdata->an_workqueue);
diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig
index bd8c80c0b7..6a8d74aeb6 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -110,7 +110,7 @@ config TIGON3
depends on PCI
select PHYLIB
select HWMON
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
@@ -120,7 +120,7 @@ config TIGON3
config BNX2X
tristate "Broadcom NetXtremeII 10Gb support"
depends on PCI
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
select FW_LOADER
select ZLIB_INFLATE
select LIBCRC32C
diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
index 92f411c9f0..2e64a96661 100644
--- a/drivers/net/ethernet/cavium/Kconfig
+++ b/drivers/net/ethernet/cavium/Kconfig
@@ -53,7 +53,7 @@ config THUNDER_NIC_RGX
config LIQUIDIO
tristate "Cavium LiquidIO support"
depends on 64BIT
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
select FW_LOADER
select LIBCRC32C
---help---
diff --git a/drivers/net/ethernet/freescale/Kconfig b/drivers/net/ethernet/freescale/Kconfig
index d1ca45fbb1..5eb9280973 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -25,7 +25,7 @@ config FEC
ARCH_MXC || SOC_IMX28)
default ARCH_MXC || SOC_IMX28 if ARM
select PHYLIB
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
Say Y here if you want to use the built-in 10/100 Fast ethernet
controller on some Motorola ColdFire and Freescale i.MX processors.
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index c0e17433f6..1349b45f01 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -58,7 +58,7 @@ config E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support"
depends on PCI && (!SPARC32 || BROKEN)
select CRC32
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports the PCI-Express Intel(R) PRO/1000 gigabit
ethernet family of adapters. For PCI or PCI-X e1000 adapters,
@@ -83,7 +83,7 @@ config E1000E_HWTS
config IGB
tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"
depends on PCI
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
select I2C
select I2C_ALGOBIT
---help---
@@ -156,7 +156,7 @@ config IXGBE
tristate "Intel(R) 10GbE PCI Express adapters support"
depends on PCI
select MDIO
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports Intel(R) 10GbE PCI Express family of
adapters. For more information on how to identify your adapter, go
@@ -213,7 +213,7 @@ config IXGBEVF
config I40E
tristate "Intel(R) Ethernet Controller XL710 Family support"
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
depends on PCI
---help---
This driver supports Intel(R) Ethernet Controller XL710 Family of
@@ -264,7 +264,7 @@ config FM10K
tristate "Intel(R) FM10000 Ethernet Switch Host Interface Support"
default n
depends on PCI_MSI
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports Intel(R) FM10000 Ethernet Switch Host
Interface. For more information on how to identify your adapter,
diff --git a/drivers/net/ethernet/mellanox/mlx4/Kconfig b/drivers/net/ethernet/mellanox/mlx4/Kconfig
index 5098e7f219..22b1cc012b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx4/Kconfig
@@ -7,7 +7,7 @@ config MLX4_EN
depends on MAY_USE_DEVLINK
depends on PCI
select MLX4_CORE
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports Mellanox Technologies ConnectX Ethernet
devices.
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index aae46884bf..2cd841590e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -14,7 +14,7 @@ config MLX5_CORE
config MLX5_CORE_EN
bool "Mellanox Technologies ConnectX-4 Ethernet support"
depends on NETDEVICES && ETHERNET && PCI && MLX5_CORE
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
default n
---help---
Ethernet support in Mellanox Technologies ConnectX-4 NIC.
diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig
index 85ec447c2d..27be51f0a4 100644
--- a/drivers/net/ethernet/renesas/Kconfig
+++ b/drivers/net/ethernet/renesas/Kconfig
@@ -37,7 +37,7 @@ config RAVB
select MII
select MDIO_BITBANG
select PHYLIB
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
help
Renesas Ethernet AVB device driver.
This driver supports the following SoCs:
diff --git a/drivers/net/ethernet/samsung/Kconfig b/drivers/net/ethernet/samsung/Kconfig
index 2360d81507..fbd5e06654 100644
--- a/drivers/net/ethernet/samsung/Kconfig
+++ b/drivers/net/ethernet/samsung/Kconfig
@@ -21,7 +21,7 @@ config SXGBE_ETH
depends on HAS_IOMEM && HAS_DMA
select PHYLIB
select CRC32
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This is the driver for the SXGBE 10G Ethernet IP block found on
Samsung platforms.
diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index 4dd92b7b80..83f4766a1d 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -5,7 +5,7 @@ config SFC
select CRC32
select I2C
select I2C_ALGOBIT
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports 10/40-gigabit Ethernet cards based on
the Solarflare SFC4000, SFC9000-family and SFC9100-family
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 3818c5e06e..139c85fa6a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -4,7 +4,7 @@ config STMMAC_ETH
select MII
select PHYLIB
select CRC32
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
select RESET_CONTROLLER
---help---
This is the driver for the Ethernet IPs are built around a
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index 9904d740d5..61b835a7e6 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -76,7 +76,7 @@ config TI_CPSW
config TI_CPTS
bool "TI Common Platform Time Sync (CPTS) Support"
depends on TI_CPSW
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
---help---
This driver supports the Common Platform Time Sync unit of
the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4
diff --git a/drivers/net/ethernet/tile/Kconfig b/drivers/net/ethernet/tile/Kconfig
index f59a6c2653..bdfeaf3d4f 100644
--- a/drivers/net/ethernet/tile/Kconfig
+++ b/drivers/net/ethernet/tile/Kconfig
@@ -9,7 +9,7 @@ config TILE_NET
select CRC32
select TILE_GXIO_MPIPE if TILEGX
select HIGH_RES_TIMERS if TILEGX
- select PTP_1588_CLOCK if TILEGX
+ imply PTP_1588_CLOCK if TILEGX
---help---
This is a standard Linux network device driver for the
on-chip Tilera Gigabit Ethernet and XAUI interfaces.
diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index ee3de3421f..0f7492f8ea 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -28,7 +28,7 @@ config PTP_1588_CLOCK
config PTP_1588_CLOCK_GIANFAR
tristate "Freescale eTSEC as PTP clock"
depends on GIANFAR
- select PTP_1588_CLOCK
+ depends on PTP_1588_CLOCK
default y
help
This driver adds support for using the eTSEC as a PTP
@@ -42,7 +42,7 @@ config PTP_1588_CLOCK_GIANFAR
config PTP_1588_CLOCK_IXP46X
tristate "Intel IXP46x as PTP clock"
depends on IXP4XX_ETH
- select PTP_1588_CLOCK
+ depends on PTP_1588_CLOCK
default y
help
This driver adds support for using the IXP46X as a PTP
@@ -60,7 +60,7 @@ config DP83640_PHY
tristate "Driver for the National Semiconductor DP83640 PHYTER"
depends on NETWORK_PHY_TIMESTAMPING
depends on PHYLIB
- select PTP_1588_CLOCK
+ depends on PTP_1588_CLOCK
---help---
Supports the DP83640 PHYTER with IEEE 1588 features.
@@ -76,7 +76,7 @@ config PTP_1588_CLOCK_PCH
tristate "Intel PCH EG20T as PTP clock"
depends on X86_32 || COMPILE_TEST
depends on HAS_IOMEM && NET
- select PTP_1588_CLOCK
+ imply PTP_1588_CLOCK
help
This driver adds support for using the PCH EG20T as a PTP
clock. The hardware supports time stamping of PTP packets
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index 5ad54fc66c..4b205fb5a4 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -122,30 +122,6 @@ struct ptp_clock_info {
struct ptp_clock;
-/**
- * ptp_clock_register() - register a PTP hardware clock driver
- *
- * @info: Structure describing the new clock.
- * @parent: Pointer to the parent device of the new clock.
- *
- * Returns a valid pointer on success or PTR_ERR on failure. If PHC
- * support is missing at the configuration level, this function
- * returns NULL, and drivers are expected to gracefully handle that
- * case separately.
- */
-
-extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
- struct device *parent);
-
-/**
- * ptp_clock_unregister() - unregister a PTP hardware clock driver
- *
- * @ptp: The clock to remove from service.
- */
-
-extern int ptp_clock_unregister(struct ptp_clock *ptp);
-
-
enum ptp_clock_events {
PTP_CLOCK_ALARM,
PTP_CLOCK_EXTTS,
@@ -171,6 +147,31 @@ struct ptp_clock_event {
};
};
+#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
+
+/**
+ * ptp_clock_register() - register a PTP hardware clock driver
+ *
+ * @info: Structure describing the new clock.
+ * @parent: Pointer to the parent device of the new clock.
+ *
+ * Returns a valid pointer on success or PTR_ERR on failure. If PHC
+ * support is missing at the configuration level, this function
+ * returns NULL, and drivers are expected to gracefully handle that
+ * case separately.
+ */
+
+extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
+ struct device *parent);
+
+/**
+ * ptp_clock_unregister() - unregister a PTP hardware clock driver
+ *
+ * @ptp: The clock to remove from service.
+ */
+
+extern int ptp_clock_unregister(struct ptp_clock *ptp);
+
/**
* ptp_clock_event() - notify the PTP layer about an event
*
@@ -202,4 +203,20 @@ extern int ptp_clock_index(struct ptp_clock *ptp);
int ptp_find_pin(struct ptp_clock *ptp,
enum ptp_pin_function func, unsigned int chan);
+#else
+static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
+ struct device *parent)
+{ return NULL; }
+static inline int ptp_clock_unregister(struct ptp_clock *ptp)
+{ return 0; }
+static inline void ptp_clock_event(struct ptp_clock *ptp,
+ struct ptp_clock_event *event)
+{ (void)event; }
+static inline int ptp_clock_index(struct ptp_clock *ptp)
+{ return -1; }
+static inline int ptp_find_pin(struct ptp_clock *ptp,
+ enum ptp_pin_function func, unsigned int chan)
+{ return -1; }
+#endif
+
#endif
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-10-20 12:00 +0200 |
| Subject | Re: [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <suiiJ-5No-9@gated-at.bofh.it> |
| In reply to | #1504417 |
On Wed, 19 Oct 2016, Nicolas Pitre wrote: > The pch_gbe driver is a bit special as it relies on extra code in > drivers/ptp/ptp_pch.c. Therefore we let the make process descend into > drivers/ptp/ even if PTP_1588_CLOCK is unselected. The above paragraph looks like a leftover of the previous patch set. Thanks, tglx
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 19:50 +0200 |
| Subject | Re: [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <supDz-2fu-19@gated-at.bofh.it> |
| In reply to | #1504727 |
On Thu, 20 Oct 2016, Thomas Gleixner wrote: > On Wed, 19 Oct 2016, Nicolas Pitre wrote: > > The pch_gbe driver is a bit special as it relies on extra code in > > drivers/ptp/ptp_pch.c. Therefore we let the make process descend into > > drivers/ptp/ even if PTP_1588_CLOCK is unselected. > > The above paragraph looks like a leftover of the previous patch set. Not really. Without the change to drivers/Makefile, drivers/ptp/ is not visited when CONFIG_PTP_1588_CLOCK=n. If you then have CONFIG_PCH_GBE=y you end up with: drivers/built-in.o: In function `pch_gbe_ioctl': pch_gbe_main.c:(.text+0x28c914): undefined reference to `pch_ch_control_write' pch_gbe_main.c:(.text+0x28c945): undefined reference to `pch_set_station_address' pch_gbe_main.c:(.text+0x28c964): undefined reference to `pch_ch_event_write' pch_gbe_main.c:(.text+0x28c9ae): undefined reference to `pch_ch_control_write' pch_gbe_main.c:(.text+0x28c9c7): undefined reference to `pch_ch_control_write' pch_gbe_main.c:(.text+0x28c9e6): undefined reference to `pch_ch_control_write' pch_gbe_main.c:(.text+0x28ca17): undefined reference to `pch_set_station_address' drivers/built-in.o: In function `pch_gbe_xmit_frame': pch_gbe_main.c:(.text+0x28ceab): undefined reference to `pch_ch_event_read' pch_gbe_main.c:(.text+0x28cebb): undefined reference to `pch_tx_snap_read' pch_gbe_main.c:(.text+0x28ced8): undefined reference to `pch_ch_event_write' drivers/built-in.o: In function `pch_gbe_napi_poll': pch_gbe_main.c:(.text+0x28da6c): undefined reference to `pch_ch_event_read' pch_gbe_main.c:(.text+0x28da78): undefined reference to `pch_src_uuid_lo_read' pch_gbe_main.c:(.text+0x28da83): undefined reference to `pch_src_uuid_hi_read' pch_gbe_main.c:(.text+0x28db0c): undefined reference to `pch_ch_event_write' pch_gbe_main.c:(.text+0x28df69): undefined reference to `pch_rx_snap_read' pch_gbe_main.c:(.text+0x28df88): undefined reference to `pch_ch_event_write' make: *** [vmlinux] Error 1 Hence the above paragraph. Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-10-20 20:10 +0200 |
| Subject | Re: [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <supWX-2CC-69@gated-at.bofh.it> |
| In reply to | #1505141 |
On Thu, 20 Oct 2016, Nicolas Pitre wrote: > On Thu, 20 Oct 2016, Thomas Gleixner wrote: > > > On Wed, 19 Oct 2016, Nicolas Pitre wrote: > > > The pch_gbe driver is a bit special as it relies on extra code in > > > drivers/ptp/ptp_pch.c. Therefore we let the make process descend into > > > drivers/ptp/ even if PTP_1588_CLOCK is unselected. > > > > The above paragraph looks like a leftover of the previous patch set. > > Not really. Without the change to drivers/Makefile, drivers/ptp/ is not > visited when CONFIG_PTP_1588_CLOCK=n. If you then have CONFIG_PCH_GBE=y > you end up with: > > drivers/built-in.o: In function `pch_gbe_ioctl': > pch_gbe_main.c:(.text+0x28c914): undefined reference to `pch_ch_control_write' > > Hence the above paragraph. Indeed. I misread that. Thanks, tglx
[toc] | [prev] | [next] | [standalone]
| From | Richard Cochran <richardcochran@gmail.com> |
|---|---|
| Date | 2016-10-20 16:10 +0200 |
| Subject | Re: [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <sumcG-ed-31@gated-at.bofh.it> |
| In reply to | #1504417 |
On Wed, Oct 19, 2016 at 07:42:52PM -0400, Nicolas Pitre wrote:
> +static inline void ptp_clock_event(struct ptp_clock *ptp,
> + struct ptp_clock_event *event)
> +{ (void)event; }
Just out of curiosity, why do you need that cast?
(I thought the kernel's gcc settings don't enable the warning for
unused arguments.)
Thanks,
Richard
[toc] | [prev] | [next] | [standalone]
| From | Josh Triplett <josh@joshtriplett.org> |
|---|---|
| Date | 2016-10-20 17:50 +0200 |
| Subject | Re: [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <sunLs-12P-11@gated-at.bofh.it> |
| In reply to | #1504923 |
On Thu, Oct 20, 2016 at 04:06:02PM +0200, Richard Cochran wrote:
> On Wed, Oct 19, 2016 at 07:42:52PM -0400, Nicolas Pitre wrote:
> > +static inline void ptp_clock_event(struct ptp_clock *ptp,
> > + struct ptp_clock_event *event)
> > +{ (void)event; }
>
> Just out of curiosity, why do you need that cast?
>
> (I thought the kernel's gcc settings don't enable the warning for
> unused arguments.)
And if they did, wouldn't you need it for ptp as well?
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 18:50 +0200 |
| Subject | Re: [PATCH 3/4] ptp_clock: allow for it to be optional |
| Message-ID | <suoHv-1G4-3@gated-at.bofh.it> |
| In reply to | #1504923 |
On Thu, 20 Oct 2016, Richard Cochran wrote:
> On Wed, Oct 19, 2016 at 07:42:52PM -0400, Nicolas Pitre wrote:
> > +static inline void ptp_clock_event(struct ptp_clock *ptp,
> > + struct ptp_clock_event *event)
> > +{ (void)event; }
>
> Just out of curiosity, why do you need that cast?
It's redundant and now gone. Probably a remnant from the initial test
code that used macros.
Thanks.
Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 01:50 +0200 |
| Subject | [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <su8Mq-881-29@gated-at.bofh.it> |
| In reply to | #1504412 |
The "imply" keyword is a weak version of "select" where the target
config symbol can still be turned off, avoiding those pitfalls that come
with the "select" keyword.
This is useful e.g. with multiple drivers that want to indicate their
ability to hook into a given subsystem while still being able to
configure that subsystem out and keep those drivers selected.
Currently, the same effect can almost be achieved with:
config DRIVER_A
tristate
config DRIVER_B
tristate
config DRIVER_C
tristate
config DRIVER_D
tristate
[...]
config SUBSYSTEM_X
tristate
default DRIVER_A || DRIVER_B || DRIVER_C || DRIVER_D || [...]
This is unwieldly to maintain especially with a large number of drivers.
Furthermore, there is no easy way to restrict the choice for SUBSYSTEM_X
to y or n, excluding m, when some drivers are built-in. The "select"
keyword allows for excluding m, but it excludes n as well. Hence
this "imply" keyword. The above becomes:
config DRIVER_A
tristate
imply SUBSYSTEM_X
config DRIVER_B
tristate
imply SUBSYSTEM_X
[...]
config SUBSYSTEM_X
tristate
This is much cleaner, and way more flexible than "select". SUBSYSTEM_X
can still be configured out, and it can be set as a module when none of
the drivers are selected or all of them are also modular.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
---
Documentation/kbuild/kconfig-language.txt | 28 ++++++++++++++++
scripts/kconfig/expr.h | 2 ++
scripts/kconfig/menu.c | 55 ++++++++++++++++++++++---------
scripts/kconfig/symbol.c | 26 ++++++++++++++-
scripts/kconfig/zconf.gperf | 1 +
scripts/kconfig/zconf.y | 16 +++++++--
6 files changed, 109 insertions(+), 19 deletions(-)
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index 069fcb3eef..c96127f648 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -113,6 +113,33 @@ applicable everywhere (see syntax).
That will limit the usefulness but on the other hand avoid
the illegal configurations all over.
+- weak reverse dependencies: "imply" <symbol> ["if" <expr>]
+ This is similar to "select" as it enforces a lower limit on another
+ symbol except that the "implied" config symbol's value may still be
+ set to n from a direct dependency or with a visible prompt.
+ Given the following example:
+
+ config FOO
+ tristate
+ imply BAZ
+
+ config BAZ
+ tristate
+ depends on BAr
+
+ The following values are possible:
+
+ FOO BAR BAR's default choice for BAZ
+ --------------- --------------- --------------- --------------
+ n y n N/m/y
+ m y m M/y/n
+ y y y Y/n
+ y n * N
+
+ This is useful e.g. with multiple drivers that want to indicate their
+ ability to hook into a given subsystem while still being able to
+ configure that subsystem out and keep those drivers selected.
+
- limiting menu display: "visible if" <expr>
This attribute is only applicable to menu blocks, if the condition is
false, the menu block is not displayed to the user (the symbols
@@ -481,6 +508,7 @@ historical issues resolved through these different solutions.
b) Match dependency semantics:
b1) Swap all "select FOO" to "depends on FOO" or,
b2) Swap all "depends on FOO" to "select FOO"
+ c) Consider the use of "imply" instead of "select"
The resolution to a) can be tested with the sample Kconfig file
Documentation/kbuild/Kconfig.recursion-issue-01 through the removal
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 973b6f7333..a73f762c48 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -85,6 +85,7 @@ struct symbol {
struct property *prop;
struct expr_value dir_dep;
struct expr_value rev_dep;
+ struct expr_value implied;
};
#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
@@ -136,6 +137,7 @@ enum prop_type {
P_DEFAULT, /* default y */
P_CHOICE, /* choice value */
P_SELECT, /* select BAR */
+ P_IMPLY, /* imply BAR */
P_RANGE, /* range 7..100 (for a symbol) */
P_ENV, /* value from environment variable */
P_SYMBOL, /* where a symbol is defined */
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index aed678e8a7..e9357931b4 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -233,6 +233,8 @@ static void sym_check_prop(struct symbol *sym)
{
struct property *prop;
struct symbol *sym2;
+ char *use;
+
for (prop = sym->prop; prop; prop = prop->next) {
switch (prop->type) {
case P_DEFAULT:
@@ -252,18 +254,20 @@ static void sym_check_prop(struct symbol *sym)
}
break;
case P_SELECT:
+ case P_IMPLY:
+ use = prop->type == P_SELECT ? "select" : "imply";
sym2 = prop_get_symbol(prop);
if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
prop_warn(prop,
- "config symbol '%s' uses select, but is "
- "not boolean or tristate", sym->name);
+ "config symbol '%s' uses %s, but is "
+ "not boolean or tristate", sym->name, use);
else if (sym2->type != S_UNKNOWN &&
sym2->type != S_BOOLEAN &&
sym2->type != S_TRISTATE)
prop_warn(prop,
- "'%s' has wrong type. 'select' only "
+ "'%s' has wrong type. '%s' only "
"accept arguments of boolean and "
- "tristate type", sym2->name);
+ "tristate type", sym2->name, use);
break;
case P_RANGE:
if (sym->type != S_INT && sym->type != S_HEX)
@@ -333,6 +337,10 @@ void menu_finalize(struct menu *parent)
struct symbol *es = prop_get_symbol(prop);
es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
+ } else if (prop->type == P_IMPLY) {
+ struct symbol *es = prop_get_symbol(prop);
+ es->implied.expr = expr_alloc_or(es->implied.expr,
+ expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
}
}
}
@@ -612,13 +620,30 @@ static struct property *get_symbol_prop(struct symbol *sym)
return prop;
}
+static void get_symbol_props_str(struct gstr *r, struct symbol *sym,
+ enum prop_type tok, const char *prefix)
+{
+ bool hit = false;
+ struct property *prop;
+
+ for_all_properties(sym, prop, tok) {
+ if (!hit) {
+ str_append(r, prefix);
+ hit = true;
+ } else
+ str_printf(r, " && ");
+ expr_gstr_print(prop->expr, r);
+ }
+ if (hit)
+ str_append(r, "\n");
+}
+
/*
* head is optional and may be NULL
*/
static void get_symbol_str(struct gstr *r, struct symbol *sym,
struct list_head *head)
{
- bool hit;
struct property *prop;
if (sym && sym->name) {
@@ -648,22 +673,20 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
}
}
- hit = false;
- for_all_properties(sym, prop, P_SELECT) {
- if (!hit) {
- str_append(r, " Selects: ");
- hit = true;
- } else
- str_printf(r, " && ");
- expr_gstr_print(prop->expr, r);
- }
- if (hit)
- str_append(r, "\n");
+ get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
if (sym->rev_dep.expr) {
str_append(r, _(" Selected by: "));
expr_gstr_print(sym->rev_dep.expr, r);
str_append(r, "\n");
}
+
+ get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
+ if (sym->implied.expr) {
+ str_append(r, _(" Implied by: "));
+ expr_gstr_print(sym->implied.expr, r);
+ str_append(r, "\n");
+ }
+
str_append(r, "\n\n");
}
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 2432298487..074fb66d9a 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -258,6 +258,15 @@ static void sym_calc_visibility(struct symbol *sym)
sym->rev_dep.tri = tri;
sym_set_changed(sym);
}
+ tri = no;
+ if (sym->implied.expr)
+ tri = expr_calc_value(sym->implied.expr);
+ if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
+ tri = yes;
+ if (sym->implied.tri != tri) {
+ sym->implied.tri = tri;
+ sym_set_changed(sym);
+ }
}
/*
@@ -397,6 +406,12 @@ void sym_calc_value(struct symbol *sym)
newval.tri = EXPR_AND(expr_calc_value(prop->expr),
prop->visible.tri);
}
+ if (sym->dir_dep.tri != no &&
+ sym->implied.tri != no) {
+ /* implied symbols have implied defaults */
+ sym->flags |= SYMBOL_WRITE;
+ newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
+ }
}
calc_newval:
if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
@@ -413,7 +428,8 @@ void sym_calc_value(struct symbol *sym)
}
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
}
- if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
+ if (newval.tri == mod &&
+ (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes))
newval.tri = yes;
break;
case S_STRING:
@@ -498,6 +514,8 @@ bool sym_tristate_within_range(struct symbol *sym, tristate val)
return false;
if (sym->visible <= sym->rev_dep.tri)
return false;
+ if (sym->implied.tri == yes && val == mod)
+ return false;
if (sym_is_choice_value(sym) && sym->visible == yes)
return val == yes;
return val >= sym->rev_dep.tri && val <= sym->visible;
@@ -750,6 +768,10 @@ const char *sym_get_string_default(struct symbol *sym)
if (sym->type == S_BOOLEAN && val == mod)
val = yes;
+ /* adjust the default value if this symbol is implied by another */
+ if (val < sym->implied.tri)
+ val = sym->implied.tri;
+
switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
@@ -1352,6 +1374,8 @@ const char *prop_get_type_name(enum prop_type type)
return "choice";
case P_SELECT:
return "select";
+ case P_IMPLY:
+ return "imply";
case P_RANGE:
return "range";
case P_SYMBOL:
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index ac498f01b4..ead02edec9 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -38,6 +38,7 @@ int, T_TYPE, TF_COMMAND, S_INT
hex, T_TYPE, TF_COMMAND, S_HEX
string, T_TYPE, TF_COMMAND, S_STRING
select, T_SELECT, TF_COMMAND
+imply, T_IMPLY, TF_COMMAND
range, T_RANGE, TF_COMMAND
visible, T_VISIBLE, TF_COMMAND
option, T_OPTION, TF_COMMAND
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 71bf8bff69..001305fa08 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
%}
-%expect 30
+%expect 32
%union
{
@@ -62,6 +62,7 @@ static struct menu *current_menu, *current_entry;
%token <id>T_TYPE
%token <id>T_DEFAULT
%token <id>T_SELECT
+%token <id>T_IMPLY
%token <id>T_RANGE
%token <id>T_VISIBLE
%token <id>T_OPTION
@@ -124,7 +125,7 @@ stmt_list:
;
option_name:
- T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
+ T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_IMPLY | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
;
common_stmt:
@@ -216,6 +217,12 @@ config_option: T_SELECT T_WORD if_expr T_EOL
printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
};
+config_option: T_IMPLY T_WORD if_expr T_EOL
+{
+ menu_add_symbol(P_IMPLY, sym_lookup($2, 0), $3);
+ printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
+};
+
config_option: T_RANGE symbol symbol if_expr T_EOL
{
menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
@@ -664,6 +671,11 @@ static void print_symbol(FILE *out, struct menu *menu)
expr_fprint(prop->expr, out);
fputc('\n', out);
break;
+ case P_IMPLY:
+ fputs( " imply ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
case P_RANGE:
fputs( " range ", out);
expr_fprint(prop->expr, out);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2016-10-20 09:00 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <sufuy-3ZE-17@gated-at.bofh.it> |
| In reply to | #1504420 |
2016-10-20 8:42 GMT+09:00 Nicolas Pitre <nicolas.pitre@linaro.org>: > diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt > index 069fcb3eef..c96127f648 100644 > --- a/Documentation/kbuild/kconfig-language.txt > +++ b/Documentation/kbuild/kconfig-language.txt > @@ -113,6 +113,33 @@ applicable everywhere (see syntax). > That will limit the usefulness but on the other hand avoid > the illegal configurations all over. > > +- weak reverse dependencies: "imply" <symbol> ["if" <expr>] > + This is similar to "select" as it enforces a lower limit on another > + symbol except that the "implied" config symbol's value may still be > + set to n from a direct dependency or with a visible prompt. > + Given the following example: > + > + config FOO > + tristate > + imply BAZ > + > + config BAZ > + tristate > + depends on BAr s/BAr/BAR/ ? -- Best Regards Masahiro Yamada
[toc] | [prev] | [next] | [standalone]
| From | Edward Cree <ecree@solarflare.com> |
|---|---|
| Date | 2016-10-20 17:00 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <sumZ3-wo-5@gated-at.bofh.it> |
| In reply to | #1504420 |
On 20/10/16 00:42, Nicolas Pitre wrote: > diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt > index 069fcb3eef..c96127f648 100644 > --- a/Documentation/kbuild/kconfig-language.txt > +++ b/Documentation/kbuild/kconfig-language.txt > @@ -113,6 +113,33 @@ applicable everywhere (see syntax). > That will limit the usefulness but on the other hand avoid > the illegal configurations all over. > > +- weak reverse dependencies: "imply" <symbol> ["if" <expr>] > + This is similar to "select" as it enforces a lower limit on another > + symbol except that the "implied" config symbol's value may still be > + set to n from a direct dependency or with a visible prompt. > + Given the following example: > + > + config FOO > + tristate > + imply BAZ > + > + config BAZ > + tristate > + depends on BAr > + > + The following values are possible: > + > + FOO BAR BAR's default choice for BAZ Should the third column not be "BAZ's default"? > + --------------- --------------- --------------- -------------- > + n y n N/m/y > + m y m M/y/n > + y y y Y/n > + y n * N Also, I don't think having any FOO=y should preclude BAZ=m. Suppose both FOO and FOO2 imply BAZ, FOO=y and FOO2=m. Then if BAZ-features are only desired for driver FOO2, BAz=m makes sense. There is also the case of drivers with the ability to detect at runtime whether BAZ is present, rather than making the decision at build time, but I'm not sure how common that is. -Ed
[toc] | [prev] | [next] | [standalone]
| From | Josh Triplett <josh@joshtriplett.org> |
|---|---|
| Date | 2016-10-20 17:50 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <sunLs-12P-9@gated-at.bofh.it> |
| In reply to | #1504952 |
On Thu, Oct 20, 2016 at 03:52:04PM +0100, Edward Cree wrote: > On 20/10/16 00:42, Nicolas Pitre wrote: > > diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt > > index 069fcb3eef..c96127f648 100644 > > --- a/Documentation/kbuild/kconfig-language.txt > > +++ b/Documentation/kbuild/kconfig-language.txt > > @@ -113,6 +113,33 @@ applicable everywhere (see syntax). > > That will limit the usefulness but on the other hand avoid > > the illegal configurations all over. > > > > +- weak reverse dependencies: "imply" <symbol> ["if" <expr>] > > + This is similar to "select" as it enforces a lower limit on another > > + symbol except that the "implied" config symbol's value may still be > > + set to n from a direct dependency or with a visible prompt. > > + Given the following example: > > + > > + config FOO > > + tristate > > + imply BAZ > > + > > + config BAZ > > + tristate > > + depends on BAr > > + > > + The following values are possible: > > + > > + FOO BAR BAR's default choice for BAZ > Should the third column not be "BAZ's default"? > > + --------------- --------------- --------------- -------------- > > + n y n N/m/y > > + m y m M/y/n > > + y y y Y/n > > + y n * N > Also, I don't think having any FOO=y should preclude BAZ=m. Suppose both > FOO and FOO2 imply BAZ, FOO=y and FOO2=m. Then if BAZ-features are only > desired for driver FOO2, BAz=m makes sense. That's exactly the problem that motivated "imply" in the first place: while that's *possible*, it means the user needs to know that they're breaking BAZ support for driver FOO. In theory, someone could extend the UI to note the symbols with an "imply" for a given symbol and provide additional help for the implied symbol that explains the implications. In that case, it might make sense to allow the user to explicitly mark a symbol as 'm', with appropriate explanations of the implications. But in the absence of that, the simple solution seems like preventing 'm' for a symbol implied by a symbol marked as 'y'.
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 19:10 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <sup0S-21Y-23@gated-at.bofh.it> |
| In reply to | #1504952 |
On Thu, 20 Oct 2016, Edward Cree wrote: > On 20/10/16 00:42, Nicolas Pitre wrote: > > diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt > > index 069fcb3eef..c96127f648 100644 > > --- a/Documentation/kbuild/kconfig-language.txt > > +++ b/Documentation/kbuild/kconfig-language.txt > > @@ -113,6 +113,33 @@ applicable everywhere (see syntax). > > That will limit the usefulness but on the other hand avoid > > the illegal configurations all over. > > > > +- weak reverse dependencies: "imply" <symbol> ["if" <expr>] > > + This is similar to "select" as it enforces a lower limit on another > > + symbol except that the "implied" config symbol's value may still be > > + set to n from a direct dependency or with a visible prompt. > > + Given the following example: > > + > > + config FOO > > + tristate > > + imply BAZ > > + > > + config BAZ > > + tristate > > + depends on BAr > > + > > + The following values are possible: > > + > > + FOO BAR BAR's default choice for BAZ > Should the third column not be "BAZ's default"? Indeed. Good catch. > > + --------------- --------------- --------------- -------------- > > + n y n N/m/y > > + m y m M/y/n > > + y y y Y/n > > + y n * N > Also, I don't think having any FOO=y should preclude BAZ=m. Suppose both > FOO and FOO2 imply BAZ, FOO=y and FOO2=m. Some people didn't like the fact that you could turn a driver from m to y and silently lose some features if they were provided by a subsystem that also used to be m, which arguably is not the same as being explicitly disabled. With "select" this is not a problem as the target symbol is also promoted to y in that case, so I wanted to preserve that property. > Then if BAZ-features are only > desired for driver FOO2, BAz=m makes sense. In that case it would make more sense to add a config option related to FOO asking if BAZ features are desired for that driver (there is already one occurrence of that with PTP). Or you could simply drop the "imply" statement from the FOO config entry. > There is also the case of drivers with the ability to detect at runtime > whether BAZ is present, rather than making the decision at build time, but > I'm not sure how common that is. Right now that's how PTP support is done. Drivers can optimize things at build time, but most of them simply cope with a NULL return from ptp_clock_register(). Hence the imply statement becomes a big configuration hint rather than some hard build dependency. Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Edward Cree <ecree@solarflare.com> |
|---|---|
| Date | 2016-10-20 19:50 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <supDz-2fu-5@gated-at.bofh.it> |
| In reply to | #1505106 |
On 20/10/16 18:04, Nicolas Pitre wrote: > On Thu, 20 Oct 2016, Edward Cree wrote: >> Also, I don't think having any FOO=y should preclude BAZ=m. Suppose both >> FOO and FOO2 imply BAZ, FOO=y and FOO2=m. > Some people didn't like the fact that you could turn a driver from m to > y and silently lose some features if they were provided by a subsystem > that also used to be m, which arguably is not the same as being > explicitly disabled. With "select" this is not a problem as the target > symbol is also promoted to y in that case, so I wanted to preserve that > property. Right, but that's an argument for pushing the subsystem's default to y, not for preventing changing the subsystem back to m afterwards. >> Then if BAZ-features are only >> desired for driver FOO2, BAz=m makes sense. > In that case it would make more sense to add a config option related to > FOO asking if BAZ features are desired for that driver (there is already > one occurrence of that with PTP). Or you could simply drop the "imply" > statement from the FOO config entry. But the desire is a property of the user, not of the driver. If you're willing to add CONFIG_FOO_BAZ to every combination of (driver, subsystem) then "imply" becomes unnecessary, doesn't it? Conversely, if you *don't* want to have to do that, then "imply" needs to only ever deal in defaults, not in limitations. >> There is also the case of drivers with the ability to detect at runtime >> whether BAZ is present, rather than making the decision at build time, but >> I'm not sure how common that is. > Right now that's how PTP support is done. Drivers can optimize things > at build time, but most of them simply cope with a NULL return from > ptp_clock_register(). Hence the imply statement becomes a big > configuration hint rather than some hard build dependency. Right, so those drivers can use PTP if they're y and PTP is m, as long as the PTP module is loaded when they probe. But current "imply" semantics won't allow that... I think that Josh's suggestion (have the UI warn you if you set BAZ to m while FOO=y) is the right approach, but I also think it should be done now rather than at some unspecified future time. Otherwise you forbid potentially valid configs. -Ed
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 20:30 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <suqgi-2Md-31@gated-at.bofh.it> |
| In reply to | #1505136 |
On Thu, 20 Oct 2016, Edward Cree wrote: > On 20/10/16 18:04, Nicolas Pitre wrote: > > On Thu, 20 Oct 2016, Edward Cree wrote: > >> Also, I don't think having any FOO=y should preclude BAZ=m. Suppose both > >> FOO and FOO2 imply BAZ, FOO=y and FOO2=m. > > Some people didn't like the fact that you could turn a driver from m to > > y and silently lose some features if they were provided by a subsystem > > that also used to be m, which arguably is not the same as being > > explicitly disabled. With "select" this is not a problem as the target > > symbol is also promoted to y in that case, so I wanted to preserve that > > property. > Right, but that's an argument for pushing the subsystem's default to y, > not for preventing changing the subsystem back to m afterwards. > >> Then if BAZ-features are only > >> desired for driver FOO2, BAz=m makes sense. > > In that case it would make more sense to add a config option related to > > FOO asking if BAZ features are desired for that driver (there is already > > one occurrence of that with PTP). Or you could simply drop the "imply" > > statement from the FOO config entry. > But the desire is a property of the user, not of the driver. If you're > willing to add CONFIG_FOO_BAZ to every combination of (driver, subsystem) > then "imply" becomes unnecessary, doesn't it? Absolutely. And if that's something that inspires you please be my guest. So far, though, this apparently didn't inspire the majority of driver authors who preferred to have a smaller set of config options and forcefully pull in the BAZ features with a "select". But "select" comes with its set of evils which "imply" is meant to overcome. > Conversely, if you *don't* > want to have to do that, then "imply" needs to only ever deal in defaults, > not in limitations. As I explained, It still has to prevent BAZ=m if FOO moves from m to y otherwise this would effectively have the same result as BAZ=n in practice and that is not what people expect if BAZ actually isn't n in your .config file. That's why "select" also has that particular semantic. Here "imply" is meant to be a weaker form of "select". If you prefer not to have that limitation imposed by either "select" and "imply" then simply don't use them at all. Nothing forces you to use any of them if your code can cope with any config combination. In those cases where "imply" is used, you could drop it altogether already. But that's for driver authors to decide. If they went with "select" in the first place, there might be a reason, and "imply" is there to preserve that reason, semantically at least, without the handcuff effect that "select" imposes on the whole thing. > >> There is also the case of drivers with the ability to detect at runtime > >> whether BAZ is present, rather than making the decision at build time, but > >> I'm not sure how common that is. > > Right now that's how PTP support is done. Drivers can optimize things > > at build time, but most of them simply cope with a NULL return from > > ptp_clock_register(). Hence the imply statement becomes a big > > configuration hint rather than some hard build dependency. > Right, so those drivers can use PTP if they're y and PTP is m, as long > as the PTP module is loaded when they probe. Not at the moment. There is no way for PTP to dynamically signal to interested drivers its presence at run time. And drivers, when built-in, typically probe their hardware during the boot process even before you have the chance to load any module. If that ever changes, then the imply or select statement could simply be dropped. > But current "imply" semantics won't allow that... And that's on purpose. > I think that Josh's suggestion (have the UI warn you if you set BAZ to m > while FOO=y) is the right approach, but I also think it should be done > now rather than at some unspecified future time. Please advocate this with kconfig UI authors. My recursion stack is already quite deep. > Otherwise you forbid > potentially valid configs. Like I said, if FOO=y and BAZ=m is a valid config, all you have to do is omit "imply BAZ" or "select BAZ" from the FOO config entry. It's as simple as that. Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Edward Cree <ecree@solarflare.com> |
|---|---|
| Date | 2016-10-20 21:20 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <sur2G-3iX-3@gated-at.bofh.it> |
| In reply to | #1505176 |
On 20/10/16 19:29, Nicolas Pitre wrote: > On Thu, 20 Oct 2016, Edward Cree wrote: >> But the desire is a property of the user, not of the driver. If you're >> willing to add CONFIG_FOO_BAZ to every combination of (driver, subsystem) >> then "imply" becomes unnecessary, doesn't it? > Absolutely. And if that's something that inspires you please be my > guest. So far, though, this apparently didn't inspire the majority of > driver authors who preferred to have a smaller set of config options and > forcefully pull in the BAZ features with a "select". But "select" comes > with its set of evils which "imply" is meant to overcome. It really doesn't inspire me either ;) I was using it as a way to set up the converse, rather than as any kind of serious suggestion. And I agree that "imply", as it stands, is an improvement over "select" for these kinds of cases. I just think it could be further improved. >> Conversely, if you *don't* >> want to have to do that, then "imply" needs to only ever deal in defaults, >> not in limitations. > As I explained, It still has to prevent BAZ=m if FOO moves from m to y > otherwise this would effectively have the same result as BAZ=n in > practice and that is not what people expect if BAZ actually isn't n in > your .config file. That's why "select" also has that particular > semantic. If FOO "moves from" m to y (by which I'm assuming you mean a call to sym_set_tristate_value()), then by all means set BAZ=y. But the user should then still be allowed to move BAZ from y to m without having to change FOO (though hopefully they will get warned about it somehow). > Here "imply" is meant to be a weaker form of "select". If you prefer > not to have that limitation imposed by either "select" and "imply" then > simply don't use them at all. Nothing forces you to use any of them if > your code can cope with any config combination. I'm interpreting "imply" as being more a way of saying "if you want FOO you probably want BAZ as well". But maybe that should be yet another new keyword if it's so different from what you want "imply" to be. "suggests", perhaps. >> Right, so those drivers can use PTP if they're y and PTP is m, as long >> as the PTP module is loaded when they probe. > Not at the moment. There is no way for PTP to dynamically signal to > interested drivers its presence at run time. And drivers, when > built-in, typically probe their hardware during the boot process even > before you have the chance to load any module. If that ever changes, > then the imply or select statement could simply be dropped. At least for PCIe devices, the driver can be un- and re-bound (despite being built-in) through sysfs. So you (already) can re-probe them after loading PTP. So driver=y && PTP=m is valid, today. >> I think that Josh's suggestion (have the UI warn you if you set BAZ to m >> while FOO=y) is the right approach, but I also think it should be done >> now rather than at some unspecified future time. > Please advocate this with kconfig UI authors. My recursion stack is > already quite deep. If I'm reading your patch correctly, your symbol.c additions enforce this restriction, and AFAIK the UI can't override that by saying "Yeah I warned the user and he said it was fine". The kconfig UI API would need to change; sym_set_tristate_value() could grow an 'override-imply' flag, for instance. But I'm not married to the idea; I don't have a real-world use-case this interferes with, so if you still think I'm wrong, feel free to ignore me :) -Ed
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 22:20 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <surYJ-3VP-23@gated-at.bofh.it> |
| In reply to | #1505195 |
On Thu, 20 Oct 2016, Edward Cree wrote:
> On 20/10/16 19:29, Nicolas Pitre wrote:
> > On Thu, 20 Oct 2016, Edward Cree wrote:
> >> But the desire is a property of the user, not of the driver. If you're
> >> willing to add CONFIG_FOO_BAZ to every combination of (driver, subsystem)
> >> then "imply" becomes unnecessary, doesn't it?
> > Absolutely. And if that's something that inspires you please be my
> > guest. So far, though, this apparently didn't inspire the majority of
> > driver authors who preferred to have a smaller set of config options and
> > forcefully pull in the BAZ features with a "select". But "select" comes
> > with its set of evils which "imply" is meant to overcome.
> It really doesn't inspire me either ;)
> I was using it as a way to set up the converse, rather than as any kind of
> serious suggestion.
> And I agree that "imply", as it stands, is an improvement over "select" for
> these kinds of cases. I just think it could be further improved.
> >> Conversely, if you *don't*
> >> want to have to do that, then "imply" needs to only ever deal in defaults,
> >> not in limitations.
> > As I explained, It still has to prevent BAZ=m if FOO moves from m to y
> > otherwise this would effectively have the same result as BAZ=n in
> > practice and that is not what people expect if BAZ actually isn't n in
> > your .config file. That's why "select" also has that particular
> > semantic.
> If FOO "moves from" m to y (by which I'm assuming you mean a call to
> sym_set_tristate_value()), then by all means set BAZ=y. But the user
> should then still be allowed to move BAZ from y to m without having to
> change FOO (though hopefully they will get warned about it somehow).
The case I'm most worried about is:
- open .config in $EDITOR
- change "CONFIG_FOO=m" to "CONFIG_FOO=y"
- save and exit
- make
The warning is most likely to be missed in that case, and if .config
doesn't list CONFIG_BAZ as unset then this is likely to confuse people.
> > Here "imply" is meant to be a weaker form of "select". If you prefer
> > not to have that limitation imposed by either "select" and "imply" then
> > simply don't use them at all. Nothing forces you to use any of them if
> > your code can cope with any config combination.
> I'm interpreting "imply" as being more a way of saying "if you want FOO you
> probably want BAZ as well". But maybe that should be yet another new
> keyword if it's so different from what you want "imply" to be. "suggests",
> perhaps.
Indeed. That's exactly the keyword that came to my mind after I sent my
previous reply.
> >> Right, so those drivers can use PTP if they're y and PTP is m, as long
> >> as the PTP module is loaded when they probe.
> > Not at the moment. There is no way for PTP to dynamically signal to
> > interested drivers its presence at run time. And drivers, when
> > built-in, typically probe their hardware during the boot process even
> > before you have the chance to load any module. If that ever changes,
> > then the imply or select statement could simply be dropped.
> At least for PCIe devices, the driver can be un- and re-bound (despite
> being built-in) through sysfs. So you (already) can re-probe them after
> loading PTP. So driver=y && PTP=m is valid, today.
I agree with the principle, but the implementation just doesn't allow it
at the moment. In a simplified form, what's there now in ptp.h is:
#if IS_REACHABLE(CONFIG_PTP)
extern struct ptp_clock *ptp_clock_register(...);
#else
static inline struct ptp_clock *ptp_clock_register(...) { return NULL; }
#endif
i.e. drivers may cope at runtime with PTP being absent, but there is no
support for PTP to be loaded after drivers referring to it. Hence the
use of "select" that I simply converted to "imply".
> >> I think that Josh's suggestion (have the UI warn you if you set BAZ to m
> >> while FOO=y) is the right approach, but I also think it should be done
> >> now rather than at some unspecified future time.
> > Please advocate this with kconfig UI authors. My recursion stack is
> > already quite deep.
> If I'm reading your patch correctly, your symbol.c additions enforce this
> restriction, and AFAIK the UI can't override that by saying "Yeah I warned
> the user and he said it was fine".
> The kconfig UI API would need to change; sym_set_tristate_value() could
> grow an 'override-imply' flag, for instance.
The UI may tell the user about the restriction and suggest a way to
overcome it by also changing the "impliers" to m.
Otherwise I much prefer to have a kconfig keyword that expresses the
fact that it is actually OK to override it, like this "suggests" idea
could do.
Sidenote: the kconfig language isn't coherent wrt english grammar as
there is "depends on" but "select" rather than "selects". I interpreted
"select" as using the imperative mood, hence the addition of "imply"
rather than "implies".
Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-21 05:30 +0200 |
| Subject | Re: [PATCH 1/4] kconfig: introduce the "imply" keyword |
| Message-ID | <suyGR-8on-7@gated-at.bofh.it> |
| In reply to | #1505233 |
On Thu, 20 Oct 2016, Nicolas Pitre wrote:
> On Thu, 20 Oct 2016, Edward Cree wrote:
>
> > I'm interpreting "imply" as being more a way of saying "if you want FOO you
> > probably want BAZ as well". But maybe that should be yet another new
> > keyword if it's so different from what you want "imply" to be. "suggests",
> > perhaps.
>
> Indeed. That's exactly the keyword that came to my mind after I sent my
> previous reply.
So what about the following on top of my previous series:
From: Nicolas Pitre <nicolas.pitre@linaro.org>
Date: Thu, 20 Oct 2016 23:04:46 -0400
Subject: [PATCH] kconfig: introduce the "suggest" keyword
Similar to "imply" but with no added value restrictions on the target
symbol. Useful for providing a default value to another symbol.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index 5ee0dd3c85..b7f4f0ca1d 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -140,6 +140,12 @@ applicable everywhere (see syntax).
ability to hook into a given subsystem while still being able to
configure that subsystem out and keep those drivers selected.
+- even weaker reverse dependencies: "suggest" <symbol> ["if" <expr>]
+ This is similar to "imply" except that this doesn't add any restrictions
+ on the value the suggested symbol may use. In other words this only
+ provides a default for the specified symbol based on the value for the
+ config entry where this is used.
+
- limiting menu display: "visible if" <expr>
This attribute is only applicable to menu blocks, if the condition is
false, the menu block is not displayed to the user (the symbols
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index a73f762c48..eea3aa3c7a 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -86,6 +86,7 @@ struct symbol {
struct expr_value dir_dep;
struct expr_value rev_dep;
struct expr_value implied;
+ struct expr_value suggested;
};
#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
@@ -138,6 +139,7 @@ enum prop_type {
P_CHOICE, /* choice value */
P_SELECT, /* select BAR */
P_IMPLY, /* imply BAR */
+ P_SUGGEST, /* suggest BAR */
P_RANGE, /* range 7..100 (for a symbol) */
P_ENV, /* value from environment variable */
P_SYMBOL, /* where a symbol is defined */
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index e9357931b4..3abc5c85ac 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -255,7 +255,9 @@ static void sym_check_prop(struct symbol *sym)
break;
case P_SELECT:
case P_IMPLY:
- use = prop->type == P_SELECT ? "select" : "imply";
+ case P_SUGGEST:
+ use = prop->type == P_SELECT ? "select" :
+ prop->type == P_IMPLY ? "imply" : "suggest";
sym2 = prop_get_symbol(prop);
if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
prop_warn(prop,
@@ -341,6 +343,10 @@ void menu_finalize(struct menu *parent)
struct symbol *es = prop_get_symbol(prop);
es->implied.expr = expr_alloc_or(es->implied.expr,
expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
+ } else if (prop->type == P_SUGGEST) {
+ struct symbol *es = prop_get_symbol(prop);
+ es->suggested.expr = expr_alloc_or(es->suggested.expr,
+ expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
}
}
}
@@ -687,6 +693,13 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
str_append(r, "\n");
}
+ get_symbol_props_str(r, sym, P_SUGGEST, _(" Suggests: "));
+ if (sym->suggested.expr) {
+ str_append(r, _(" Suggested by: "));
+ expr_gstr_print(sym->suggested.expr, r);
+ str_append(r, "\n");
+ }
+
str_append(r, "\n\n");
}
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 074fb66d9a..235f11e3f9 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -267,6 +267,16 @@ static void sym_calc_visibility(struct symbol *sym)
sym->implied.tri = tri;
sym_set_changed(sym);
}
+ tri = no;
+ if (sym->suggested.expr)
+ tri = expr_calc_value(sym->suggested.expr);
+ tri = EXPR_AND(tri, sym->visible);
+ if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
+ tri = yes;
+ if (sym->suggested.tri != tri) {
+ sym->suggested.tri = tri;
+ sym_set_changed(sym);
+ }
}
/*
@@ -406,6 +416,10 @@ void sym_calc_value(struct symbol *sym)
newval.tri = EXPR_AND(expr_calc_value(prop->expr),
prop->visible.tri);
}
+ if (sym->suggested.tri != no) {
+ sym->flags |= SYMBOL_WRITE;
+ newval.tri = EXPR_OR(newval.tri, sym->suggested.tri);
+ }
if (sym->dir_dep.tri != no &&
sym->implied.tri != no) {
/* implied symbols have implied defaults */
@@ -768,7 +782,9 @@ const char *sym_get_string_default(struct symbol *sym)
if (sym->type == S_BOOLEAN && val == mod)
val = yes;
- /* adjust the default value if this symbol is implied by another */
+ /* adjust the default value if this symbol is suggested/implied */
+ if (val < sym->suggested.tri)
+ val = sym->suggested.tri;
if (val < sym->implied.tri)
val = sym->implied.tri;
@@ -1376,6 +1392,8 @@ const char *prop_get_type_name(enum prop_type type)
return "select";
case P_IMPLY:
return "imply";
+ case P_SUGGEST:
+ return "suggest";
case P_RANGE:
return "range";
case P_SYMBOL:
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index ead02edec9..0c244a8e95 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -39,6 +39,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX
string, T_TYPE, TF_COMMAND, S_STRING
select, T_SELECT, TF_COMMAND
imply, T_IMPLY, TF_COMMAND
+suggest, T_SUGGEST, TF_COMMAND
range, T_RANGE, TF_COMMAND
visible, T_VISIBLE, TF_COMMAND
option, T_OPTION, TF_COMMAND
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 001305fa08..277415540a 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
%}
-%expect 32
+%expect 34
%union
{
@@ -63,6 +63,7 @@ static struct menu *current_menu, *current_entry;
%token <id>T_DEFAULT
%token <id>T_SELECT
%token <id>T_IMPLY
+%token <id>T_SUGGEST
%token <id>T_RANGE
%token <id>T_VISIBLE
%token <id>T_OPTION
@@ -125,7 +126,7 @@ stmt_list:
;
option_name:
- T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_IMPLY | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
+ T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_IMPLY | T_SUGGEST | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
;
common_stmt:
@@ -223,6 +224,12 @@ config_option: T_IMPLY T_WORD if_expr T_EOL
printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
};
+config_option: T_SUGGEST T_WORD if_expr T_EOL
+{
+ menu_add_symbol(P_SUGGEST, sym_lookup($2, 0), $3);
+ printd(DEBUG_PARSE, "%s:%d:suggest\n", zconf_curname(), zconf_lineno());
+};
+
config_option: T_RANGE symbol symbol if_expr T_EOL
{
menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
@@ -676,6 +683,11 @@ static void print_symbol(FILE *out, struct menu *menu)
expr_fprint(prop->expr, out);
fputc('\n', out);
break;
+ case P_SUGGEST:
+ fputs( " suggest ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
case P_RANGE:
fputs( " range ", out);
expr_fprint(prop->expr, out);
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Pitre <nicolas.pitre@linaro.org> |
|---|---|
| Date | 2016-10-20 01:50 +0200 |
| Subject | [PATCH 4/4] posix-timers: make it configurable |
| Message-ID | <su8Mq-881-35@gated-at.bofh.it> |
| In reply to | #1504412 |
Many embedded systems typically don't need them. This removes about
22KB from the kernel binary size when configured out.
Corresponding syscalls are routed to a stub logging the attempt to
use those syscalls which should be enough of a clue if they were
disabled without proper consideration. They are: timer_create,
timer_gettime: timer_getoverrun, timer_settime, timer_delete,
clock_adjtime.
The clock_settime, clock_gettime, clock_getres and clock_nanosleep syscalls
are replaced by simple wrappers compatible with CLOCK_REALTIME,
CLOCK_MONOTONIC and CLOCK_BOOTTIME only.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
---
drivers/ptp/Kconfig | 2 +-
include/linux/posix-timers.h | 28 +++++++++-
include/linux/sched.h | 10 ++++
init/Kconfig | 17 +++++++
kernel/signal.c | 4 ++
kernel/time/Makefile | 10 +++-
kernel/time/posix-stubs.c | 118 +++++++++++++++++++++++++++++++++++++++++++
7 files changed, 184 insertions(+), 5 deletions(-)
create mode 100644 kernel/time/posix-stubs.c
diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index 0f7492f8ea..bdce332911 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -6,7 +6,7 @@ menu "PTP clock support"
config PTP_1588_CLOCK
tristate "PTP clock support"
- depends on NET
+ depends on NET && POSIX_TIMERS
select PPS
select NET_PTP_CLASSIFY
help
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 62d44c1760..2288c5c557 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -118,6 +118,8 @@ struct k_clock {
extern struct k_clock clock_posix_cpu;
extern struct k_clock clock_posix_dynamic;
+#ifdef CONFIG_POSIX_TIMERS
+
void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock);
/* function to call to trigger timer event */
@@ -131,8 +133,30 @@ void posix_cpu_timers_exit_group(struct task_struct *task);
void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
cputime_t *newval, cputime_t *oldval);
-long clock_nanosleep_restart(struct restart_block *restart_block);
-
void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
+#else
+
+#include <linux/random.h>
+
+static inline void posix_timers_register_clock(const clockid_t clock_id,
+ struct k_clock *new_clock) {}
+static inline int posix_timer_event(struct k_itimer *timr, int si_private)
+{ return 0; }
+static inline void run_posix_cpu_timers(struct task_struct *task) {}
+static inline void posix_cpu_timers_exit(struct task_struct *task)
+{
+ add_device_randomness((const void*) &task->se.sum_exec_runtime,
+ sizeof(unsigned long long));
+}
+static inline void posix_cpu_timers_exit_group(struct task_struct *task) {}
+static inline void set_process_cpu_timer(struct task_struct *task,
+ unsigned int clock_idx, cputime_t *newval, cputime_t *oldval) {}
+static inline void update_rlimit_cpu(struct task_struct *task,
+ unsigned long rlim_new) {}
+
+#endif
+
+long clock_nanosleep_restart(struct restart_block *restart_block);
+
#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 348f51b0ec..ad716d5559 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2946,8 +2946,13 @@ static inline void exit_thread(struct task_struct *tsk)
extern void exit_files(struct task_struct *);
extern void __cleanup_sighand(struct sighand_struct *);
+#ifdef CONFIG_POSIX_TIMERS
extern void exit_itimers(struct signal_struct *);
extern void flush_itimer_signals(void);
+#else
+static inline void exit_itimers(struct signal_struct *s) {}
+static inline void flush_itimer_signals(void) {}
+#endif
extern void do_group_exit(int);
@@ -3450,7 +3455,12 @@ static __always_inline bool need_resched(void)
* Thread group CPU time accounting.
*/
void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
+#ifdef CONFIG_POSIX_TIMERS
void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
+#else
+static inline void thread_group_cputimer(struct task_struct *tsk,
+ struct task_cputime *times) {}
+#endif
/*
* Reevaluate whether the task has signals pending delivery.
diff --git a/init/Kconfig b/init/Kconfig
index 34407f15e6..351d422252 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1445,6 +1445,23 @@ config SYSCTL_SYSCALL
If unsure say N here.
+config POSIX_TIMERS
+ bool "Posix Clocks & timers" if EXPERT
+ default y
+ help
+ This includes native support for POSIX timers to the kernel.
+ Most embedded systems may have no use for them and therefore they
+ can be configured out to reduce the size of the kernel image.
+
+ When this option is disabled, the following syscalls won't be
+ available: timer_create, timer_gettime: timer_getoverrun,
+ timer_settime, timer_delete, clock_adjtime. Furthermore, the
+ clock_settime, clock_gettime, clock_getres and clock_nanosleep
+ syscalls will be limited to CLOCK_REALTIME and CLOCK_MONOTONIC
+ only.
+
+ If unsure say y.
+
config KALLSYMS
bool "Load all symbols for debugging/ksymoops" if EXPERT
default y
diff --git a/kernel/signal.c b/kernel/signal.c
index 75761acc77..0a38c9d646 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -427,6 +427,7 @@ void flush_signals(struct task_struct *t)
spin_unlock_irqrestore(&t->sighand->siglock, flags);
}
+#ifdef CONFIG_POSIX_TIMERS
static void __flush_itimer_signals(struct sigpending *pending)
{
sigset_t signal, retain;
@@ -460,6 +461,7 @@ void flush_itimer_signals(void)
__flush_itimer_signals(&tsk->signal->shared_pending);
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
}
+#endif
void ignore_signals(struct task_struct *t)
{
@@ -611,6 +613,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
*/
current->jobctl |= JOBCTL_STOP_DEQUEUED;
}
+#ifdef CONFIG_POSIX_TIMERS
if ((info->si_code & __SI_MASK) == __SI_TIMER && info->si_sys_private) {
/*
* Release the siglock to ensure proper locking order
@@ -622,6 +625,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
do_schedule_next_timer(info);
spin_lock(&tsk->sighand->siglock);
}
+#endif
return signr;
}
diff --git a/kernel/time/Makefile b/kernel/time/Makefile
index 49eca0beed..fc26c308f5 100644
--- a/kernel/time/Makefile
+++ b/kernel/time/Makefile
@@ -1,6 +1,12 @@
-obj-y += time.o timer.o hrtimer.o itimer.o posix-timers.o posix-cpu-timers.o
+obj-y += time.o timer.o hrtimer.o itimer.o
obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o
-obj-y += timeconv.o timecounter.o posix-clock.o alarmtimer.o
+obj-y += timeconv.o timecounter.o alarmtimer.o
+
+ifeq ($(CONFIG_POSIX_TIMERS),y)
+ obj-y += posix-timers.o posix-cpu-timers.o posix-clock.o
+else
+ obj-y += posix-stubs.o
+endif
obj-$(CONFIG_GENERIC_CLOCKEVENTS) += clockevents.o tick-common.o
ifeq ($(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST),y)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
new file mode 100644
index 0000000000..fe857bd4a0
--- /dev/null
+++ b/kernel/time/posix-stubs.c
@@ -0,0 +1,118 @@
+/*
+ * Dummy stubs used when CONFIG_POSIX_TIMERS=n
+ *
+ * Created by: Nicolas Pitre, July 2016
+ * Copyright: (C) 2016 Linaro Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/linkage.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/syscalls.h>
+#include <linux/ktime.h>
+#include <linux/timekeeping.h>
+#include <linux/posix-timers.h>
+
+asmlinkage long sys_ni_posix_timers(void)
+{
+ pr_err_once("process %d (%s) attempted a POSIX timer syscall "
+ "while CONFIG_POSIX_TIMERS is not set\n",
+ current->pid, current->comm);
+ return -ENOSYS;
+}
+
+#define SYS_NI(name) SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers)
+
+SYS_NI(timer_create);
+SYS_NI(timer_gettime);
+SYS_NI(timer_getoverrun);
+SYS_NI(timer_settime);
+SYS_NI(timer_delete);
+SYS_NI(clock_adjtime);
+
+/*
+ * We preserve minimal support for CLOCK_REALTIME and CLOCK_MONOTONIC
+ * as it is easy to remain compatible with little code. CLOCK_BOOTTIME
+ * is also included for convenience as at least systemd uses it.
+ */
+
+SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
+ const struct timespec __user *, tp)
+{
+ struct timespec new_tp;
+
+ if (which_clock != CLOCK_REALTIME)
+ return -EINVAL;
+ if (copy_from_user(&new_tp, tp, sizeof (*tp)))
+ return -EFAULT;
+ return do_sys_settimeofday(&new_tp, NULL);
+}
+
+SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
+ struct timespec __user *,tp)
+{
+ struct timespec kernel_tp;
+
+ switch (which_clock) {
+ case CLOCK_REALTIME: ktime_get_real_ts(&kernel_tp); break;
+ case CLOCK_MONOTONIC: ktime_get_ts(&kernel_tp); break;
+ case CLOCK_BOOTTIME: get_monotonic_boottime(&kernel_tp); break;
+ default: return -EINVAL;
+ }
+ if (copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
+ return -EFAULT;
+ return 0;
+}
+
+SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct timespec __user *, tp)
+{
+ struct timespec rtn_tp = {
+ .tv_sec = 0,
+ .tv_nsec = hrtimer_resolution,
+ };
+
+ switch (which_clock) {
+ case CLOCK_REALTIME:
+ case CLOCK_MONOTONIC:
+ case CLOCK_BOOTTIME:
+ if (copy_to_user(tp, &rtn_tp, sizeof(rtn_tp)))
+ return -EFAULT;
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
+SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
+ const struct timespec __user *, rqtp,
+ struct timespec __user *, rmtp)
+{
+ struct timespec t;
+
+ switch (which_clock) {
+ case CLOCK_REALTIME:
+ case CLOCK_MONOTONIC:
+ case CLOCK_BOOTTIME:
+ if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
+ return -EFAULT;
+ if (!timespec_valid(&t))
+ return -EINVAL;
+ return hrtimer_nanosleep(&t, rmtp, flags & TIMER_ABSTIME ?
+ HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
+ which_clock);
+ default:
+ return -EINVAL;
+ }
+}
+
+#ifdef CONFIG_COMPAT
+long clock_nanosleep_restart(struct restart_block *restart_block)
+{
+ return hrtimer_nanosleep_restart(restart_block);
+}
+#endif
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Richard Cochran <richardcochran@gmail.com> |
|---|---|
| Date | 2016-10-20 16:10 +0200 |
| Subject | Re: [PATCH 4/4] posix-timers: make it configurable |
| Message-ID | <sumcG-ed-15@gated-at.bofh.it> |
| In reply to | #1504424 |
On Wed, Oct 19, 2016 at 07:42:53PM -0400, Nicolas Pitre wrote: > +config POSIX_TIMERS > + bool "Posix Clocks & timers" if EXPERT > + default y > + help > + This includes native support for POSIX timers to the kernel. > + Most embedded systems may have no use for them and therefore they This sentence doesn't make sense. How about: Some embedded systems have no use for them ... > + can be configured out to reduce the size of the kernel image. Thanks, Richard
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web