Re: [PATCH 06/47] net: smsc: remove m32r specific smc91x configuration

2018-03-14 Thread Nicolas Pitre
On Wed, 14 Mar 2018, Arnd Bergmann wrote:

> The m32r architecture is getting removed, so this part can be
> cleaned up as well.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

Acked-by: Nicolas Pitre <n...@fluxnic.net>

> ---
>  drivers/net/ethernet/smsc/Kconfig  |  4 ++--
>  drivers/net/ethernet/smsc/smc91x.h | 26 --
>  2 files changed, 2 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/ethernet/smsc/Kconfig 
> b/drivers/net/ethernet/smsc/Kconfig
> index 4c2f612e4414..1c2b6663f7ce 100644
> --- a/drivers/net/ethernet/smsc/Kconfig
> +++ b/drivers/net/ethernet/smsc/Kconfig
> @@ -37,8 +37,8 @@ config SMC91X
>   select CRC32
>   select MII
>   depends on !OF || GPIOLIB
> - depends on ARM || ARM64 || ATARI_ETHERNAT || BLACKFIN || COLDFIRE || \
> -M32R || MIPS || MN10300 || NIOS2 || SUPERH || XTENSA || H8300
> + depends on ARM || ARM64 || ATARI_ETHERNAT || COLDFIRE || \
> +MIPS || NIOS2 || SUPERH || XTENSA || H8300
>   ---help---
> This is a driver for SMC's 91x series of Ethernet chipsets,
> including the SMC91C94 and the SMC91C111. Say Y if you want it
> diff --git a/drivers/net/ethernet/smsc/smc91x.h 
> b/drivers/net/ethernet/smsc/smc91x.h
> index 08b17adf0a65..b337ee97e0c0 100644
> --- a/drivers/net/ethernet/smsc/smc91x.h
> +++ b/drivers/net/ethernet/smsc/smc91x.h
> @@ -144,32 +144,6 @@ static inline void _SMC_outw_align4(u16 val, void 
> __iomem *ioaddr, int reg,
>  
>  #define SMC_IRQ_FLAGS(0)
>  
> -#elif   defined(CONFIG_M32R)
> -
> -#define SMC_CAN_USE_8BIT 0
> -#define SMC_CAN_USE_16BIT1
> -#define SMC_CAN_USE_32BIT0
> -
> -#define SMC_inb(a, r)inb(((u32)a) + (r))
> -#define SMC_inw(a, r)inw(((u32)a) + (r))
> -#define SMC_outb(v, a, r)outb(v, ((u32)a) + (r))
> -#define SMC_outw(lp, v, a, r)outw(v, ((u32)a) + (r))
> -#define SMC_insw(a, r, p, l) insw(((u32)a) + (r), p, l)
> -#define SMC_outsw(a, r, p, l)outsw(((u32)a) + (r), p, l)
> -
> -#define SMC_IRQ_FLAGS(0)
> -
> -#define RPC_LSA_DEFAULT  RPC_LED_TX_RX
> -#define RPC_LSB_DEFAULT  RPC_LED_100_10
> -
> -#elif defined(CONFIG_MN10300)
> -
> -/*
> - * MN10300/AM33 configuration
> - */
> -
> -#include 
> -
>  #elif defined(CONFIG_ATARI)
>  
>  #define SMC_CAN_USE_8BIT1
> -- 
> 2.9.0
> 
> 


Re: [PATCH] [v2, -net] cpsw/netcp: cpts depends on posix_timers

2017-03-20 Thread Nicolas Pitre
On Mon, 20 Mar 2017, Arnd Bergmann wrote:

> With posix timers having become optional, we get a build error with
> the cpts time sync option of the CPSW driver:
> 
> drivers/net/ethernet/ti/cpts.c: In function 'cpts_find_ts':
> drivers/net/ethernet/ti/cpts.c:291:23: error: implicit declaration of 
> function 'ptp_classify_raw';did you mean 'ptp_classifier_init'? 
> [-Werror=implicit-function-declaration]
> 
> This adds a hard dependency on PTP_CLOCK to avoid the problem, as
> building it without PTP support makes no sense anyway.
> 
> Fixes: baa73d9e478f ("posix-timers: Make them configurable")
> Cc: Nicolas Pitre <nicolas.pi...@linaro.org>
> Cc: sta...@vger.kernel.org
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

Acked-by: Nicolas Pitre <n...@linaro.org>

> ---
> v2: use 'depends on' instead of 'select' as suggested by Nico.
> ---
>  drivers/net/ethernet/ti/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
> index d923890a9fda..9e631952b86f 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 || TI_KEYSTONE_NETCP
> - imply PTP_1588_CLOCK
> + depends on PTP_1588_CLOCK
>   ---help---
> This driver supports the Common Platform Time Sync unit of
> the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
> -- 
> 2.9.0
> 
> 


Re: [RESEND PATCH -net] cpsw/netcp: cpts depends on posix_timers

2017-03-13 Thread Nicolas Pitre
On Mon, 13 Mar 2017, Nicolas Pitre wrote:

> So unless I'm mistaken I don't see any problem using "depends on 
> PTP_1588_CLOCK" here.

Furthermore that wouldn't be a first. See for example 
PTP_1588_CLOCK_GIANFAR, PTP_1588_CLOCK_IXP46X, DP83640_PHY, etc.


Nicolas


Re: [RESEND PATCH -net] cpsw/netcp: cpts depends on posix_timers

2017-03-13 Thread Nicolas Pitre
On Mon, 13 Mar 2017, Arnd Bergmann wrote:

> On Mon, Mar 13, 2017 at 9:09 PM, Nicolas Pitre <nicolas.pi...@linaro.org> 
> wrote:
> > On Mon, 13 Mar 2017, Arnd Bergmann wrote:
> >
> >> With posix timers having become optional, we get a build error with
> >> the cpts time sync option of the CPSW driver:
> >>
> >> drivers/net/ethernet/ti/cpts.c: In function 'cpts_find_ts':
> >> drivers/net/ethernet/ti/cpts.c:291:23: error: implicit declaration of 
> >> function 'ptp_classify_raw';did you mean 'ptp_classifier_init'? 
> >> [-Werror=implicit-function-declaration]
> >>
> >> It really makes no sense to build this driver if we can't use PTP,
> >> so it's better to go back to 'select PTP_1588_CLOCK' but instead
> >> add a dependency on POSIX_TIMERS. Adding 'depends on PTP_1588_CLOCK'
> >> might also work, but has the risk of circular dependencies when
> >> mixed with other drivers using 'imply'.
> >
> > Could you elaborate on that risk please?
> 
> I have seen many circular dependencies in the past that tend to be of type
> 
> config FOO
>  depends on A
>  select B
> 
> config BAR
>  select A
>  depends on B

This is really a problem?  I mean in this example there is nothing that 
prevents A or B to be enabled independently.  Of course if you had:

config A
depends on B

config B
depends on A

then the circular dependency is obvious.

> The best way to avoid this problem is to only ever use either 'select' or
> 'depends on' for any given dependency, but not both. In this case, almost
> all references to PTP_1588_CLOCK use 'select' or 'implies', so I don't
> want to introduce any more 'depends on'.

I can't find any "select PTP_1588_CLOCK" in the tree.

The "imply" keyword in itself doesn't create nor inforce any 
dependencies -- that's why it was created in the first place.

So unless I'm mistaken I don't see any problem using "depends on 
PTP_1588_CLOCK" here.


Nicolas


Re: [RESEND PATCH -net] cpsw/netcp: cpts depends on posix_timers

2017-03-13 Thread Nicolas Pitre
On Mon, 13 Mar 2017, Arnd Bergmann wrote:

> With posix timers having become optional, we get a build error with
> the cpts time sync option of the CPSW driver:
> 
> drivers/net/ethernet/ti/cpts.c: In function 'cpts_find_ts':
> drivers/net/ethernet/ti/cpts.c:291:23: error: implicit declaration of 
> function 'ptp_classify_raw';did you mean 'ptp_classifier_init'? 
> [-Werror=implicit-function-declaration]
> 
> It really makes no sense to build this driver if we can't use PTP,
> so it's better to go back to 'select PTP_1588_CLOCK' but instead
> add a dependency on POSIX_TIMERS. Adding 'depends on PTP_1588_CLOCK'
> might also work, but has the risk of circular dependencies when
> mixed with other drivers using 'imply'.

Could you elaborate on that risk please?


> Fixes: baa73d9e478f ("posix-timers: Make them configurable")
> Cc: Nicolas Pitre <nicolas.pi...@linaro.org>
> Cc: sta...@vger.kernel.org
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
> Originally submitted on Dec 16, but not applied after I missed a
> reply from Nico. I confirmed that this is still needed for v4.10
> and v4.11-rc2 and am resending it without changes.
> ---
>  drivers/net/ethernet/ti/Kconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
> index d42257fbe9d9..c114efcd1575 100644
> --- a/drivers/net/ethernet/ti/Kconfig
> +++ b/drivers/net/ethernet/ti/Kconfig
> @@ -76,7 +76,8 @@ config TI_CPSW
>  config TI_CPTS_ENABLE
>   bool "TI Common Platform Time Sync (CPTS) Support"
>   depends on TI_CPSW || TI_KEYSTONE_NETCP
> - imply PTP_1588_CLOCK
> + depends on POSIX_TIMERS
> + select PTP_1588_CLOCK
>   ---help---
> This driver supports the Common Platform Time Sync unit of
> the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
> -- 
> 2.9.0
> 
> 


Re: [PATCH net 1/3] cpsw/netcp: cpts depends on posix_timers

2016-12-16 Thread Nicolas Pitre
On Fri, 16 Dec 2016, Arnd Bergmann wrote:

> With posix timers having become optional, we get a build error with
> the cpts time sync option of the CPSW driver:
> 
> drivers/net/ethernet/ti/cpts.c: In function 'cpts_find_ts':
> drivers/net/ethernet/ti/cpts.c:291:23: error: implicit declaration of 
> function 'ptp_classify_raw';did you mean 'ptp_classifier_init'? 
> [-Werror=implicit-function-declaration]
> 
> It really makes no sense to build this driver if we can't use PTP,
> so it's better to go back to 'select PTP_1588_CLOCK' but instead
> add a dependency on POSIX_TIMERS.

Why not depend on PTP_1588_CLOCK directly instead?

> Fixes: baa73d9e478f ("posix-timers: Make them configurable")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/net/ethernet/ti/Kconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
> index 296c8efd0038..366e29ff8605 100644
> --- a/drivers/net/ethernet/ti/Kconfig
> +++ b/drivers/net/ethernet/ti/Kconfig
> @@ -76,7 +76,8 @@ config TI_CPSW
>  config TI_CPTS
>   tristate "TI Common Platform Time Sync (CPTS) Support"
>   depends on TI_CPSW || TI_KEYSTONE_NETCP
> - imply PTP_1588_CLOCK
> + depends on POSIX_TIMERS
> + select PTP_1588_CLOCK
>   ---help---
> This driver supports the Common Platform Time Sync unit of
> the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
> -- 
> 2.9.0
> 
> 


Re: [PATCH net-next] liquidio: 'imply' ptp instead of 'select'

2016-12-05 Thread Nicolas Pitre
On Mon, 5 Dec 2016, David Miller wrote:

> From: Nicolas Pitre <nicolas.pi...@linaro.org>
> Date: Mon, 5 Dec 2016 10:44:32 -0500 (EST)
> 
> > On Sat, 3 Dec 2016, David Miller wrote:
> > 
> >> From: Arnd Bergmann <a...@arndb.de>
> >> Date: Sat,  3 Dec 2016 00:04:32 +0100
> >> 
> >> > ptp now depends on the optional POSIX_TIMERS setting and fails to build
> >> > if we select it without that:
> >> > 
> >> > warning: (LIQUIDIO_VF && TI_CPTS) selects PTP_1588_CLOCK which has unmet 
> >> > direct dependencies (NET && POSIX_TIMERS)
> >> > warning: (LIQUIDIO_VF && TI_CPTS) selects PTP_1588_CLOCK which has unmet 
> >> > direct dependencies (NET && POSIX_TIMERS)
> >> > ERROR: "posix_clock_unregister" [drivers/ptp/ptp.ko] undefined!
> >> > ERROR: "posix_clock_register" [drivers/ptp/ptp.ko] undefined!
> >> > ERROR: "pps_unregister_source" [drivers/ptp/ptp.ko] undefined!
> >> > ERROR: "pps_event" [drivers/ptp/ptp.ko] undefined!
> >> > ERROR: "pps_register_source" [drivers/ptp/ptp.ko] undefined!
> >> > 
> >> > It seems that two patches have collided here, the build failure
> >> > is a result of the combination. Changing the new option to 'imply'
> >> > as well fixes it.
> >> > 
> >> > Fixes: 111fc64a237f ("liquidio CN23XX: VF registration")
> >> > Fixes: d1cbfd771ce8 ("ptp_clock: Allow for it to be optional")
> >> > Signed-off-by: Arnd Bergmann <a...@arndb.de>
> >> 
> >> Like the kbuild robot, when I apply this it complains about 'imply' being
> >> an unknown option.
> >> 
> >> I guess it worked for you because support for 'imply' exists in the -next
> >> tree and gets pulled in from somewhere else.
> > 
> > Exact.
> > 
> >> In any event, as-is I cannot apply this.
> > 
> > It should be carried in linux-next for the time being, and suggested as 
> > a probable "merge resolution" to Linus when submitting your tree for 
> > merging.  I think that's the best that can be done.
> 
> This means the build of pure net-next is broken, which is unacceptble, as
> this is the tree that many developers do their work and build tests against.

Why would it be broken?

The only thing that needs to happen is for that "select" to be turned 
into a "imply" when your tree is merged into Linus' tree.  Or when your 
tree is merged into linux-next (I'm sure Stephen can carry a patch to 
that effect). It doesn't have to live in net-next directly.

The "imply" support has been available in linux-next for almost a month 
now, and it has been discussed for much longer than that.

And if people forget then we'll fix it then. That's not a big issue.


Nicolas


Re: [PATCH net-next] liquidio: 'imply' ptp instead of 'select'

2016-12-05 Thread Nicolas Pitre
On Sat, 3 Dec 2016, David Miller wrote:

> From: Arnd Bergmann 
> Date: Sat,  3 Dec 2016 00:04:32 +0100
> 
> > ptp now depends on the optional POSIX_TIMERS setting and fails to build
> > if we select it without that:
> > 
> > warning: (LIQUIDIO_VF && TI_CPTS) selects PTP_1588_CLOCK which has unmet 
> > direct dependencies (NET && POSIX_TIMERS)
> > warning: (LIQUIDIO_VF && TI_CPTS) selects PTP_1588_CLOCK which has unmet 
> > direct dependencies (NET && POSIX_TIMERS)
> > ERROR: "posix_clock_unregister" [drivers/ptp/ptp.ko] undefined!
> > ERROR: "posix_clock_register" [drivers/ptp/ptp.ko] undefined!
> > ERROR: "pps_unregister_source" [drivers/ptp/ptp.ko] undefined!
> > ERROR: "pps_event" [drivers/ptp/ptp.ko] undefined!
> > ERROR: "pps_register_source" [drivers/ptp/ptp.ko] undefined!
> > 
> > It seems that two patches have collided here, the build failure
> > is a result of the combination. Changing the new option to 'imply'
> > as well fixes it.
> > 
> > Fixes: 111fc64a237f ("liquidio CN23XX: VF registration")
> > Fixes: d1cbfd771ce8 ("ptp_clock: Allow for it to be optional")
> > Signed-off-by: Arnd Bergmann 
> 
> Like the kbuild robot, when I apply this it complains about 'imply' being
> an unknown option.
> 
> I guess it worked for you because support for 'imply' exists in the -next
> tree and gets pulled in from somewhere else.

Exact.

> In any event, as-is I cannot apply this.

It should be carried in linux-next for the time being, and suggested as 
a probable "merge resolution" to Linus when submitting your tree for 
merging.  I think that's the best that can be done.


Nicolas


Re: [PATCH net-next] liquidio: 'imply' ptp instead of 'select'

2016-12-02 Thread Nicolas Pitre
On Sat, 3 Dec 2016, Arnd Bergmann wrote:

> ptp now depends on the optional POSIX_TIMERS setting and fails to build
> if we select it without that:
> 
> warning: (LIQUIDIO_VF && TI_CPTS) selects PTP_1588_CLOCK which has unmet 
> direct dependencies (NET && POSIX_TIMERS)
> warning: (LIQUIDIO_VF && TI_CPTS) selects PTP_1588_CLOCK which has unmet 
> direct dependencies (NET && POSIX_TIMERS)
> ERROR: "posix_clock_unregister" [drivers/ptp/ptp.ko] undefined!
> ERROR: "posix_clock_register" [drivers/ptp/ptp.ko] undefined!
> ERROR: "pps_unregister_source" [drivers/ptp/ptp.ko] undefined!
> ERROR: "pps_event" [drivers/ptp/ptp.ko] undefined!
> ERROR: "pps_register_source" [drivers/ptp/ptp.ko] undefined!
> 
> It seems that two patches have collided here, the build failure
> is a result of the combination. Changing the new option to 'imply'
> as well fixes it.
> 
> Fixes: 111fc64a237f ("liquidio CN23XX: VF registration")
> Fixes: d1cbfd771ce8 ("ptp_clock: Allow for it to be optional")
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

Acked-by: Nicolas Pitre <n...@linaro.org>

> ---
>  drivers/net/ethernet/cavium/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/cavium/Kconfig 
> b/drivers/net/ethernet/cavium/Kconfig
> index bbc8bd16cb97..dcbce6cac63e 100644
> --- a/drivers/net/ethernet/cavium/Kconfig
> +++ b/drivers/net/ethernet/cavium/Kconfig
> @@ -77,7 +77,7 @@ config OCTEON_MGMT_ETHERNET
>  config LIQUIDIO_VF
>   tristate "Cavium LiquidIO VF support"
>   depends on 64BIT && PCI_MSI
> - select PTP_1588_CLOCK
> + imply PTP_1588_CLOCK
>   ---help---
> This driver supports Cavium LiquidIO Intelligent Server Adapter
> based on CN23XX chips.
> -- 
> 2.9.0
> 
> 


[PATCH v4 2/6] kconfig: regenerate *.c_shipped files after previous changes

2016-11-10 Thread Nicolas Pitre
Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 scripts/kconfig/zconf.hash.c_shipped |   30 +-
 scripts/kconfig/zconf.tab.c_shipped  | 1581 --
 2 files changed, 753 insertions(+), 858 deletions(-)

diff --git a/scripts/kconfig/zconf.hash.c_shipped 
b/scripts/kconfig/zconf.hash.c_shipped
index 360a62df2b..d51b15de07 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -55,10 +55,10 @@ kconf_id_hash (register const char *str, register unsigned 
int len)
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73,  5, 25, 25,
+  73, 73, 73, 73, 73, 73, 73, 10, 25, 25,
0,  0,  0,  5,  0,  0, 73, 73,  5,  0,
   10,  5, 45, 73, 20, 20,  0, 15, 15, 73,
-  20,  5, 73, 73, 73, 73, 73, 73, 73, 73,
+  20,  0, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
@@ -120,6 +120,7 @@ struct kconf_id_strings_t
 char kconf_id_strings_str43[sizeof("hex")];
 char kconf_id_strings_str46[sizeof("config")];
 char kconf_id_strings_str47[sizeof("boolean")];
+char kconf_id_strings_str50[sizeof("imply")];
 char kconf_id_strings_str51[sizeof("string")];
 char kconf_id_strings_str54[sizeof("help")];
 char kconf_id_strings_str56[sizeof("prompt")];
@@ -157,6 +158,7 @@ static const struct kconf_id_strings_t 
kconf_id_strings_contents =
 "hex",
 "config",
 "boolean",
+"imply",
 "string",
 "help",
 "prompt",
@@ -174,7 +176,7 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
 {
   enum
 {
-  TOTAL_KEYWORDS = 34,
+  TOTAL_KEYWORDS = 35,
   MIN_WORD_LENGTH = 2,
   MAX_WORD_LENGTH = 14,
   MIN_HASH_VALUE = 2,
@@ -205,15 +207,15 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12,   
T_DEFAULT,  TF_COMMAND, S_TRISTATE},
 #line 36 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13,   
T_DEFAULT,  TF_COMMAND, S_BOOLEAN},
-#line 46 "scripts/kconfig/zconf.gperf"
+#line 47 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14,   
T_OPT_DEFCONFIG_LIST,TF_OPTION},
   {-1}, {-1},
-#line 44 "scripts/kconfig/zconf.gperf"
+#line 45 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17,   
T_ON,   TF_PARAM},
 #line 29 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18,   
T_OPTIONAL, TF_COMMAND},
   {-1}, {-1},
-#line 43 "scripts/kconfig/zconf.gperf"
+#line 44 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21,   
T_OPTION,   TF_COMMAND},
 #line 17 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22,   
T_ENDMENU,  TF_COMMAND},
@@ -223,9 +225,9 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
 #line 23 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25,   
T_MENUCONFIG,   TF_COMMAND},
   {-1},
-#line 45 "scripts/kconfig/zconf.gperf"
+#line 46 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27,   
T_OPT_MODULES,  TF_OPTION},
-#line 48 "scripts/kconfig/zconf.gperf"
+#line 49 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28,   
T_OPT_ALLNOCONFIG_Y,TF_OPTION},
 #line 16 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29,   
T_MENU, TF_COMMAND},
@@ -234,10 +236,10 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31,   
T_SELECT,   TF_COMMAND},
 #line 21 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32,   
T_COMMENT,  TF_COMMAND},
-#line 47 "scripts/kconfig/zconf.gperf"
+#line 48 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, 

[PATCH v4 1/6] kconfig: introduce the "imply" keyword

2016-11-10 Thread Nicolas Pitre
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 secondary subsystem while allowing the user to
configure that subsystem out without also having to unset these drivers.

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 unwieldy 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 configured in or all of them are modular.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
Acked-by: Thomas Gleixner <t...@linutronix.de>
---
 Documentation/kbuild/kconfig-language.txt | 29 
 scripts/kconfig/expr.h|  2 ++
 scripts/kconfig/menu.c| 55 ++-
 scripts/kconfig/symbol.c  | 24 +-
 scripts/kconfig/zconf.gperf   |  1 +
 scripts/kconfig/zconf.y   | 16 +++--
 6 files changed, 108 insertions(+), 19 deletions(-)

diff --git a/Documentation/kbuild/kconfig-language.txt 
b/Documentation/kbuild/kconfig-language.txt
index 069fcb3eef..262722d886 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -113,6 +113,34 @@ applicable everywhere (see syntax).
That will limit the usefulness but on the other hand avoid
the illegal configurations all over.
 
+- weak reverse dependencies: "imply"  ["if" ]
+  This is similar to "select" as it enforces a lower limit on another
+  symbol except that the "implied" 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 BAZ'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 secondary subsystem while allowing the user to
+  configure that subsystem out without also having to unset these drivers.
+
 - limiting menu display: "visible if" 
   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 +509,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 envi

[PATCH v4 6/6] posix-timers: make it configurable

2016-11-10 Thread Nicolas Pitre
Some embedded systems have no use for them.  This removes about
25KB 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, setitimer, getitimer, alarm.

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 which should cover the vast
majority of use cases with very little code.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
Acked-by: Thomas Gleixner <t...@linutronix.de>
---
 arch/alpha/kernel/osf_sys.c |   8 +++
 drivers/char/Kconfig|   1 +
 drivers/ptp/Kconfig |   2 +-
 fs/exec.c   |   2 +
 init/Kconfig|  17 ++
 kernel/compat.c |   8 +++
 kernel/exit.c   |  11 +++-
 kernel/fork.c   |   2 +
 kernel/signal.c |   6 +++
 kernel/sys.c|   3 +-
 kernel/time/Makefile|  10 +++-
 kernel/time/alarmtimer.c|   6 ++-
 kernel/time/posix-stubs.c   | 123 
 kernel/time/timer.c |   3 +-
 security/selinux/hooks.c|  11 ++--
 15 files changed, 200 insertions(+), 13 deletions(-)
 create mode 100644 kernel/time/posix-stubs.c

diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index ffb93f499c..56e427c7aa 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1029,11 +1029,16 @@ SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 
__user *, tv,
return do_sys_settimeofday(tv ?  : NULL, tz ?  : NULL);
 }
 
+asmlinkage long sys_ni_posix_timers(void);
+
 SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
 {
struct itimerval kit;
int error;
 
+   if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
+   return sys_ni_posix_timers();
+
error = do_getitimer(which, );
if (!error && put_it32(it, ))
error = -EFAULT;
@@ -1047,6 +1052,9 @@ SYSCALL_DEFINE3(osf_setitimer, int, which, struct 
itimerval32 __user *, in,
struct itimerval kin, kout;
int error;
 
+   if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
+   return sys_ni_posix_timers();
+
if (in) {
if (get_it32(, in))
return -EFAULT;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index dcc09739a5..45ba878ae0 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -542,6 +542,7 @@ config HANGCHECK_TIMER
 config MMTIMER
tristate "MMTIMER Memory mapped RTC for SGI Altix"
depends on IA64_GENERIC || IA64_SGI_SN2
+   depends on POSIX_TIMERS
default y
help
  The mmtimer device allows direct userspace access to the
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/fs/exec.c b/fs/exec.c
index 6fcfb3f7b1..a67a172332 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1164,8 +1164,10 @@ static int de_thread(struct task_struct *tsk)
/* we have changed execution domain */
tsk->exit_signal = SIGCHLD;
 
+#ifdef CONFIG_POSIX_TIMERS
exit_itimers(sig);
flush_itimer_signals();
+#endif
 
if (atomic_read(>count) != 1) {
struct sighand_struct *newsighand;
diff --git a/init/Kconfig b/init/Kconfig
index 34407f15e6..456e0b8912 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.
+ Some embedded systems 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, getitimer,
+ setitimer, alarm. Furthermore, the clock_settime, clock_gettime,
+ clock_getres and clock_nanosleep syscalls will be limited to
+ CLOCK_REALTIME, CLOCK_MONOTONIC and CLOCK_BOOTTIME only.
+
+ If unsure say y.
+
 config KALLSYMS
 

[PATCH v4 3/6] ptp_clock: allow for it to be optional

2016-11-10 Thread Nicolas Pitre
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 <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
Acked-by: Edward Cree <ec...@solarflare.com>
Acked-by: Thomas Gleixner <t...@linutronix.de>
---
 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

[PATCH v4 5/6] posix_cpu_timers_exit: wrong place to collect entropy

2016-11-10 Thread Nicolas Pitre
There is no logical relation between add_device_randomness() and
posix_cpu_timers_exit(). Let's move the former to where the later
is called. This way, when posix-cpu-timers.c is compiled out, there
is no need to worry about not losing a call to add_device_randomness().

Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 kernel/exit.c  | 4 
 kernel/time/posix-cpu-timers.c | 4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 9d68c45ebb..d16bcdd89d 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -54,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -116,6 +117,9 @@ static void __exit_signal(struct task_struct *tsk)
sig->curr_target = next_thread(tsk);
}
 
+   add_device_randomness((const void*) >se.sum_exec_runtime,
+ sizeof(unsigned long long));
+
/*
 * Accumulate here the counters for all threads as they die. We could
 * skip the group leader because it is the last user of signal_struct,
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 39008d7892..e582f20f47 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -9,7 +9,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -447,10 +446,7 @@ static void cleanup_timers(struct list_head *head)
  */
 void posix_cpu_timers_exit(struct task_struct *tsk)
 {
-   add_device_randomness((const void*) >se.sum_exec_runtime,
-   sizeof(unsigned long long));
cleanup_timers(tsk->cpu_timers);
-
 }
 void posix_cpu_timers_exit_group(struct task_struct *tsk)
 {
-- 
2.7.4



[PATCH v4 4/6] timer: move sys_alarm from timer.c to itimer.c

2016-11-10 Thread Nicolas Pitre
Move the only user of alarm_setitimer to itimer.c where it is defined.
This allows for making alarm_setitimer static, and dropping it from the
build when __ARCH_WANT_SYS_ALARM is not defined.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 include/linux/time.h |  2 --
 kernel/time/itimer.c | 15 ++-
 kernel/time/timer.c  | 13 -
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 4cea09d942..23f0f5ce30 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -172,8 +172,6 @@ extern int do_setitimer(int which, struct itimerval *value,
struct itimerval *ovalue);
 extern int do_getitimer(int which, struct itimerval *value);
 
-extern unsigned int alarm_setitimer(unsigned int seconds);
-
 extern long do_utimes(int dfd, const char __user *filename, struct timespec 
*times, int flags);
 
 struct tms;
diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c
index 1d5c7204dd..2b9f45bc95 100644
--- a/kernel/time/itimer.c
+++ b/kernel/time/itimer.c
@@ -238,6 +238,8 @@ int do_setitimer(int which, struct itimerval *value, struct 
itimerval *ovalue)
return 0;
 }
 
+#ifdef __ARCH_WANT_SYS_ALARM
+
 /**
  * alarm_setitimer - set alarm in seconds
  *
@@ -250,7 +252,7 @@ int do_setitimer(int which, struct itimerval *value, struct 
itimerval *ovalue)
  * On 32 bit machines the seconds value is limited to (INT_MAX/2) to avoid
  * negative timeval settings which would cause immediate expiry.
  */
-unsigned int alarm_setitimer(unsigned int seconds)
+static unsigned int alarm_setitimer(unsigned int seconds)
 {
struct itimerval it_new, it_old;
 
@@ -275,6 +277,17 @@ unsigned int alarm_setitimer(unsigned int seconds)
return it_old.it_value.tv_sec;
 }
 
+/*
+ * For backwards compatibility?  This can be done in libc so Alpha
+ * and all newer ports shouldn't need it.
+ */
+SYSCALL_DEFINE1(alarm, unsigned int, seconds)
+{
+   return alarm_setitimer(seconds);
+}
+
+#endif
+
 SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
struct itimerval __user *, ovalue)
 {
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 2d47980a1b..3ed6c67e17 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1662,19 +1662,6 @@ void run_local_timers(void)
raise_softirq(TIMER_SOFTIRQ);
 }
 
-#ifdef __ARCH_WANT_SYS_ALARM
-
-/*
- * For backwards compatibility?  This can be done in libc so Alpha
- * and all newer ports shouldn't need it.
- */
-SYSCALL_DEFINE1(alarm, unsigned int, seconds)
-{
-   return alarm_setitimer(seconds);
-}
-
-#endif
-
 static void process_timeout(unsigned long __data)
 {
wake_up_process((struct task_struct *)__data);
-- 
2.7.4



[PATCH v4 0/6] make POSIX timers optional with some Kconfig help

2016-11-10 Thread Nicolas Pitre
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.

At this point I'd like to gather ACKs especially from people in the "To"
field. Ideally this would need to go upstream as a single series to avoid
cross subsystem dependency issues.  So far it was suggested that this could
go via the kbuild tree. Given the end goal and the included timer cleanup
patches I'd lean towards the timer tree but any tree would suit me just
as well.

This is also available here for those who prefer a git tree:
git://git.linaro.org/people/nicolas.pitre/linux/ configurable_posix_timers

Changes from v3:

- Added a patch to move sys_alarm to itimer.c where the support code lives.
- Added a patch to move entropy collection out of posix-cpu-timers.c.
- Remove itimer as well when POSIX_TIMERS=n as they rely on code already
  removed. This means the getitimer, setitimer and alarm syscalls are also
  stubbed out in that case.
- Reverted the addition of empty timer stubs from posix-timers.h. Since
  there is only a few callers, it's better to conditionalize call sites
  instead, and get a link error if some were missed. Easier to clearly
  ponder the implications that way.
- Collected more ACKs.

Changes from v2:

- Dropped the patch adding the "suggest" keyword as nothing uses it.
  Requested by Paul Bolle.
- Various documentation and commit log clarifications, prompted also
  by Paul Bolle.
- Collected more ACKs.

Changes from v1:

- added "suggest" to kconfig for completeness
- various typo fixes
- small "imply" effect visibility fix

The bulk of the diffstat comes from the kconfig lex parser regeneration.

Diffstat:

 Documentation/kbuild/kconfig-language.txt   |   29 +
 arch/alpha/kernel/osf_sys.c |8 +
 drivers/Makefile|2 +-
 drivers/char/Kconfig|1 +
 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 +-
 fs/exec.c   |2 +
 include/linux/ptp_clock_kernel.h|   65 +-
 include/linux/time.h|2 -
 init/Kconfig|   17 +
 kernel/compat.c |8 +
 kernel/exit.c   |   15 +-
 kernel/fork.c   |2 +
 kernel/signal.c |6 +
 kernel/sys.c|3 +-
 kernel/time/Makefile|   10 +-
 kernel/time/alarmtimer.c|6 +-
 kernel/time/itimer.c|   15 +-
 kernel/time/posix-cpu-timers.c  |4 -
 kernel/time/posix-stubs.c   |  123 ++
 kernel/time/timer.c |   16 +-
 scripts/kconfig/expr.h  |2 +
 scripts/kconfig/menu.c  |   55 +-
 scripts/kconfig/symbol.c|   24 +-
 scripts/kconfig/zconf.gperf |1 +
 scripts/kconfig/zconf.hash.c_shipped|   30 +-
 scripts/kconfig/zconf.tab.c_shipped | 1581 +++
 scripts/kconfig/zconf.y |   16 +-
 security/selinux/hooks.c|   11 +-
 43 files changed, 1148 insertions(+), 960 deletions(-)


Re: [PATCH v3 4/4] posix-timers: make it configurable

2016-11-08 Thread Nicolas Pitre
On Tue, 8 Nov 2016, John Stultz wrote:

> One spot of concern is that the
> tools/testing/selftests/timers/posix_timers.c test hangs testing
> virtual itimers. Looking through the code I'm not seeing where an
> error case is missed.
> 
> The strace looks like:
> ...
> write(1, "Testing posix timers. False nega"..., 66Testing posix
> timers. False negative may happen on CPU execution
> ) = 66
> write(1, "based timers if other threads ru"..., 48based timers if
> other threads run on the CPU...
> ) = 48
> write(1, "Check itimer virtual... ", 24Check itimer virtual... ) = 24
> rt_sigaction(SIGVTALRM, {0x400a80, [VTALRM], SA_RESTORER|SA_RESTART,
> 0x7fb73306ccb0}, {SIG_DFL, [], 0}, 8) = 0
> gettimeofday({1478710402, 937476}, NULL) = 0
> setitimer(ITIMER_VIRTUAL, {it_interval={0, 0}, it_value={2, 0}}, NULL) = 0
> 
> 
> 
> Where as with posix timers enabled:
> ...
> write(1, "Testing posix timers. False nega"..., 138Testing posix
> timers. False negative may happen on CPU execution
> based timers if other threads run on the CPU...
> Check itimer virtual... ) = 138
> rt_sigaction(SIGVTALRM, {0x400a80, [VTALRM], SA_RESTORER|SA_RESTART,
> 0x7f231ba8ccb0}, {SIG_DFL, [], 0}, 8) = 0
> gettimeofday({1478626751, 904856}, NULL) = 0
> setitimer(ITIMER_VIRTUAL, {it_interval={0, 0}, it_value={2, 0}}, NULL) = 0
> --- SIGVTALRM {si_signo=SIGVTALRM, si_code=SI_KERNEL} ---
> rt_sigreturn()  = 0

I'll have a look.

> So I suspect you were a little too aggressive with the #ifdefs around
> the itimers/signal code, or we need to make sure we return an error on
> the setitimer ITIMER_VIRTUAL case as well.

Well, it seemed to me that with POSIX_TIMERS=n, all the code that would 
set up that signal is gone, so there was no point keeping the code to 
deliver it.

Now... would it make more sense to remove itimer support as well when 
POSIX_TIMERS=n?  The same reasoning would apply.


Nicolas


Re: [PATCH v3 2/4] kconfig: regenerate *.c_shipped files after previous changes

2016-11-07 Thread Nicolas Pitre
On Mon, 7 Nov 2016, Josh Triplett wrote:

> [snipping large patch]
> 
> One suggestion that might make this patch easier to review: you might
> consider first regenerating the unchanged parser with Bison 3.0.4, then
> regenerating it again after the "imply" change.  I think that'd
> eliminate quite a lot of noise in this patch.

I tried that. This made two large patches instead of just one, both 
equally obscure.

So this patch stands on its own, containing changes that are 
mechanically generated and therefore shouldn't require manual review.


Nicolas


Re: [PATCH v3 0/4] make POSIX timers optional with some Kconfig help

2016-11-07 Thread Nicolas Pitre
On Mon, 7 Nov 2016, Nicolas Pitre wrote:

> 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.
> 
> At this point I'd like to gather ACKs especially from people in the "To"
> field. Ideally this would need to go upstream as a single series to avoid
> cross subsystem dependency issues.  So far it was suggested that this should 
> go
> via the kbuild tree.

This is also available here for those who prefer a git tree:

git://git.linaro.org/people/nicolas.pitre/linux/ configurable_posix_timers


Nicolas


[PATCH v3 2/4] kconfig: regenerate *.c_shipped files after previous changes

2016-11-07 Thread Nicolas Pitre
Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 scripts/kconfig/zconf.hash.c_shipped |   30 +-
 scripts/kconfig/zconf.tab.c_shipped  | 1581 --
 2 files changed, 753 insertions(+), 858 deletions(-)

diff --git a/scripts/kconfig/zconf.hash.c_shipped 
b/scripts/kconfig/zconf.hash.c_shipped
index 360a62df2b..d51b15de07 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -55,10 +55,10 @@ kconf_id_hash (register const char *str, register unsigned 
int len)
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73,  5, 25, 25,
+  73, 73, 73, 73, 73, 73, 73, 10, 25, 25,
0,  0,  0,  5,  0,  0, 73, 73,  5,  0,
   10,  5, 45, 73, 20, 20,  0, 15, 15, 73,
-  20,  5, 73, 73, 73, 73, 73, 73, 73, 73,
+  20,  0, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
@@ -120,6 +120,7 @@ struct kconf_id_strings_t
 char kconf_id_strings_str43[sizeof("hex")];
 char kconf_id_strings_str46[sizeof("config")];
 char kconf_id_strings_str47[sizeof("boolean")];
+char kconf_id_strings_str50[sizeof("imply")];
 char kconf_id_strings_str51[sizeof("string")];
 char kconf_id_strings_str54[sizeof("help")];
 char kconf_id_strings_str56[sizeof("prompt")];
@@ -157,6 +158,7 @@ static const struct kconf_id_strings_t 
kconf_id_strings_contents =
 "hex",
 "config",
 "boolean",
+"imply",
 "string",
 "help",
 "prompt",
@@ -174,7 +176,7 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
 {
   enum
 {
-  TOTAL_KEYWORDS = 34,
+  TOTAL_KEYWORDS = 35,
   MIN_WORD_LENGTH = 2,
   MAX_WORD_LENGTH = 14,
   MIN_HASH_VALUE = 2,
@@ -205,15 +207,15 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12,   
T_DEFAULT,  TF_COMMAND, S_TRISTATE},
 #line 36 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13,   
T_DEFAULT,  TF_COMMAND, S_BOOLEAN},
-#line 46 "scripts/kconfig/zconf.gperf"
+#line 47 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14,   
T_OPT_DEFCONFIG_LIST,TF_OPTION},
   {-1}, {-1},
-#line 44 "scripts/kconfig/zconf.gperf"
+#line 45 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17,   
T_ON,   TF_PARAM},
 #line 29 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18,   
T_OPTIONAL, TF_COMMAND},
   {-1}, {-1},
-#line 43 "scripts/kconfig/zconf.gperf"
+#line 44 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21,   
T_OPTION,   TF_COMMAND},
 #line 17 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22,   
T_ENDMENU,  TF_COMMAND},
@@ -223,9 +225,9 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
 #line 23 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25,   
T_MENUCONFIG,   TF_COMMAND},
   {-1},
-#line 45 "scripts/kconfig/zconf.gperf"
+#line 46 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27,   
T_OPT_MODULES,  TF_OPTION},
-#line 48 "scripts/kconfig/zconf.gperf"
+#line 49 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28,   
T_OPT_ALLNOCONFIG_Y,TF_OPTION},
 #line 16 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29,   
T_MENU, TF_COMMAND},
@@ -234,10 +236,10 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31,   
T_SELECT,   TF_COMMAND},
 #line 21 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32,   
T_COMMENT,  TF_COMMAND},
-#line 47 "scripts/kconfig/zconf.gperf"
+#line 48 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, 

[PATCH v3 4/4] posix-timers: make it configurable

2016-11-07 Thread Nicolas Pitre
Some embedded systems have no use for 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 which should cover the vast
majority of use cases with very little code.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
---
 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 
+
+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*) >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..f430f776e8 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 t

[PATCH v3 3/4] ptp_clock: allow for it to be optional

2016-11-07 Thread Nicolas Pitre
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 <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
---
 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
 

[PATCH v3 1/4] kconfig: introduce the "imply" keyword

2016-11-07 Thread Nicolas Pitre
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 secondary subsystem while allowing the user to
configure that subsystem out without also having to unset these drivers.

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 unwieldy 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 configured in or all of them are modular.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
---
 Documentation/kbuild/kconfig-language.txt | 29 
 scripts/kconfig/expr.h|  2 ++
 scripts/kconfig/menu.c| 55 ++-
 scripts/kconfig/symbol.c  | 24 +-
 scripts/kconfig/zconf.gperf   |  1 +
 scripts/kconfig/zconf.y   | 16 +++--
 6 files changed, 108 insertions(+), 19 deletions(-)

diff --git a/Documentation/kbuild/kconfig-language.txt 
b/Documentation/kbuild/kconfig-language.txt
index 069fcb3eef..262722d886 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -113,6 +113,34 @@ applicable everywhere (see syntax).
That will limit the usefulness but on the other hand avoid
the illegal configurations all over.
 
+- weak reverse dependencies: "imply"  ["if" ]
+  This is similar to "select" as it enforces a lower limit on another
+  symbol except that the "implied" 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 BAZ'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 secondary subsystem while allowing the user to
+  configure that subsystem out without also having to unset these drivers.
+
 - limiting menu display: "visible if" 
   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 +509,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,   /* whe

[PATCH v3 0/4] make POSIX timers optional with some Kconfig help

2016-11-07 Thread Nicolas Pitre
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.

At this point I'd like to gather ACKs especially from people in the "To"
field. Ideally this would need to go upstream as a single series to avoid
cross subsystem dependency issues.  So far it was suggested that this should go
via the kbuild tree.

Changes from v2:

- Dropped the patch adding the "suggest" keyword as nothing uses it.
  Requested by Paul Bolle.
- Various documentation and commit log clarifications, prompted also
  by Paul Bolle.
- Collected more ACKs.

Changes from v1:

- added "suggest" to kconfig for completeness
- various typo fixes
- small "imply" effect visibility fix

The bulk of the diffstat comes from the kconfig lex parser regeneration.

Diffstat:

 Documentation/kbuild/kconfig-language.txt   |   29 +
 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|   24 +-
 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, 1114 insertions(+), 932 deletions(-)


Re: [PATCH v2 0/5] make POSIX timers optional with some Kconfig help

2016-10-28 Thread Nicolas Pitre
On Sat, 29 Oct 2016, Paul Bolle wrote:

> On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> > 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.
> 
> By the way: would you have pointers to threads that discussed attempts
> to achieve this using currently available Kconfig options?

You could probably go backward from here:
https://lkml.org/lkml/2016/9/20/606


Nicolas


Re: [PATCH v2 1/5] kconfig: introduce the "imply" keyword

2016-10-28 Thread Nicolas Pitre
On Fri, 28 Oct 2016, Paul Bolle wrote:

> On Thu, 2016-10-27 at 23:10 -0400, Nicolas Pitre wrote:
> > On Fri, 28 Oct 2016, Paul Bolle wrote:
> > > What happens when a tristate symbol is implied by a symbol set to 'y'
> > > and by a symbol set to 'm'?
> > 
> > That's respectively the third and second rows in the table above.
> 
> I meant: two separate symbols implying the same symbol at the same
> time. One of those symbols set to 'y' and the other set to 'm'.

Then it's the greatest of the set i.e. y.


Nicolas


Re: [PATCH v2 1/5] kconfig: introduce the "imply" keyword

2016-10-27 Thread Nicolas Pitre
On Fri, 28 Oct 2016, Paul Bolle wrote:

> On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> > 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
> 
> "hook into a [...] subsystem" is rather vague.

You could say: benefit from, contribute to, register with, or any 
combination of those. At some point there is no good way to remain 
generic. At least none came to my mind.

> >  while still being able to configure that subsystem out
> 
> s/being able to/allowing the user to/, correct? 

Correct.

> > and keep those drivers selected.
> 
> Perhaps replace that with: "without also having to unset these
> drivers"?

Sure. I currently have:

  This is useful e.g. with multiple drivers that want to indicate their
  ability to hook into an important secondary subsystem while allowing
  the user to configure that subsystem out without also having to unset
  these drivers.

> > +- weak reverse dependencies: "imply"  ["if" ]
> 
> You probably got "["if" ]" for free by copying what's there for
> select. But this series doesn't use it, so perhaps it would be better
> to not document it yet. But that is rather sneaky. Dunno.

If it is not documented then the chance that someone uses it are slim. 
And since it comes "for free" I don't see the point of making the tool 
less flexible. And not having this flexibility could make some 
transitions from "select" to "imply" needlessly difficult.

> > +  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.
> 
> This is seriously hard to parse. But it's late here, so it might just
> be me.

I tried to follow the existing style. I removed the word "config" from 
that paragraph as it looked redundant. Other than that, any improvements 
from someone more inspired than myself is welcome.

> > +  Given the following example:
> > +
> > +  config FOO
> > +   tristate
> > +   imply BAZ
> > +
> > +  config BAZ
> > +   tristate
> > +   depends on BAR
> > +
> > +  The following values are possible:
> > +
> > +   FOO BAR BAZ's default   choice for BAZ
> > +   --- --- -   --
> > +   n   y   n   N/m/y
> > +   m   y   m   M/y/n
> > +   y   y   y   Y/n
> 
> Also
>   n   n   *   N
>   m   n   *   N
> 
> Is that right?

Right.  Is it clearer if I list all combinations, or maybe:

*   n   *   N

> > +   y   n   *   N
> 
> But what does '*' mean?

It's a wildcard meaning either of n, m, or y.

> What happens when a tristate symbol is implied by a symbol set to 'y'
> and by a symbol set to 'm'?

That's respectively the third and second rows in the table above.

> And in your example BAR is bool, right? Does the above get more
> complicated if BAR would be tristate?

If BAR=m then implying BAZ from FOO=y will force BAZ to y or n, 
bypassing the restriction provided by BAR like "select" does.  This is 
somewhat questionable for "select" to do that, and the code emits a 
warning when "select" bypasses a direct dependency set to n, but not 
when set to m. For now "imply" simply tries to be consistent with 
the "select" behavior.

> How does setting a direct default for BAZ interfere with the implied
> values?

It doesn't. An implied symbol may be promoted to a higher value than the 
default, not a lower value. So if the direct default is higher than the 
implied value then the default wins.

> >    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"
> 
> If memory serves me right this text was added after a long discussion
> with Luis Rodriguez. Luis might want to have a look at any 

The "imply" statement doesn't create the kind of dependency conflicts a

Re: [PATCH v2 2/5] kconfig: introduce the "suggest" keyword

2016-10-26 Thread Nicolas Pitre
On Thu, 27 Oct 2016, Paul Bolle wrote:

> On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> > Similar to "imply" but with no added restrictions on the target symbol's
> > value. Useful for providing a default value to another symbol.
> > 
> > Suggested by Edward Cree.
> > 
> > Signed-off-by: Nicolas Pitre <n...@linaro.org>
> 
> As far as I can see this series doesn't add a user of "suggest". So I
> see no reason to add it.
> 
> NAK.

Fine.

Given the discussion from the "imply" patch I thought "suggest" could 
become popular. But if/when someone actually wants it then this patch 
could be picked up later.


Nicolas


Re: [PATCH v2 1/5] kconfig: introduce the "imply" keyword

2016-10-26 Thread Nicolas Pitre
On Thu, 27 Oct 2016, Paul Bolle wrote:

> On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> > 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.
> 
> Short note, to highlight a pet peeve: "select" (and therefor
> "selected") has a special meaning in kconfig land. I guess you meant
> something neutral like "set" here. Is that correct?

Right. Will fix.

> By the way: "also" makes this sentence hard to parse.

s/also //


Nicolas


Re: [PATCH v2 0/5] make POSIX timers optional with some Kconfig help

2016-10-26 Thread Nicolas Pitre
On Thu, 27 Oct 2016, Paul Bolle wrote:

> On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> > From: Nicolas Pitre <nicolas.pi...@linaro.org>
> > Subject: [PATCH v2 0/5] make POSIX timers optional with some Kconfig help
> 
> This doesn't work. I received this message with an empty subject.

Hmmm... must have dome something stupid with git send-patch.

> If you'll have to send another update don't bother including Yann. Yann
> hasn't be heard of in years. MAINTAINERS doesn't reflect reality for
> kconfig.

What about updating it then?


Nicolas


Re: [PATCH v2 5/5] posix-timers: make it configurable

2016-10-26 Thread Nicolas Pitre
On Wed, 26 Oct 2016, Richard Cochran wrote:

> On Wed, Oct 26, 2016 at 09:56:13AM -0400, Nicolas Pitre wrote:
> > So if my Fedora usage doesn't need them, we can infer that 
> > the number of embedded systems also not needing them might tend towards 
> > a high percentage.
> 
> (I wouldn't call Fedora an embedded distro, but heh...)

Indeed it is not. Non-embedded distros usually make more extensive usage 
of the kernel.  Still, disabling POSIX timers doesn't affect it.

> > But let's be conservative and say "some".
> 
> Sounds good to me.

Does the PTP related part of this series also sounds good to you?
May I have your ACK?


Nicolas


Re: [PATCH v2 5/5] posix-timers: make it configurable

2016-10-26 Thread Nicolas Pitre
On Wed, 26 Oct 2016, Richard Cochran wrote:

> On Tue, Oct 25, 2016 at 10:28:51PM -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
> > + can be configured out to reduce the size of the kernel image.
> 
> Can you please fix this sentence?  It doesn't make any sense.  "Most"
> is making a definite statement of fact, while "may have no use" is
> not.

I'm not a native speaker. I'm afraid I just don't appreciate such 
nuances.

> Either you mean:
> 
>   1. Most embedded systems have no use for them.
> 
>   2. Embedded systems may have no use for them.
> 
> or expressing #2 in other words:
> 
>   3. Many embedded systems have no use for them.
> 
>   4. Some embedded systems have no use for them.
> 
> Take your pick.  (But I doubt #1 is really true, and so I would like
> to see some numbers to back up that claim.)

I used 4 to match the commit message, which incidentally is the result 
of a prior suggestion from you. Sorry for not being consistent then.

As for numbers... I don't have any, but I probably mentioned already 
that I can run a copy of Fedora on top of a kernel with POSIX timers 
disabled and none of the warnings about those disabled syscalls are 
triggered. So if my Fedora usage doesn't need them, we can infer that 
the number of embedded systems also not needing them might tend towards 
a high percentage. But let's be conservative and say "some".

Thanks for your review.


Nicolas


[PATCH v2 3/5] kconfig: regenerate *.c_shipped files after previous changes

2016-10-25 Thread Nicolas Pitre
Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 scripts/kconfig/zconf.hash.c_shipped |  228 ++---
 scripts/kconfig/zconf.tab.c_shipped  | 1631 --
 2 files changed, 888 insertions(+), 971 deletions(-)

diff --git a/scripts/kconfig/zconf.hash.c_shipped 
b/scripts/kconfig/zconf.hash.c_shipped
index 360a62df2b..bf7f1378b3 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -32,7 +32,7 @@
 struct kconf_id;
 
 static const struct kconf_id *kconf_id_lookup(register const char *str, 
register unsigned int len);
-/* maximum key range = 71, duplicates = 0 */
+/* maximum key range = 72, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -46,32 +46,32 @@ kconf_id_hash (register const char *str, register unsigned 
int len)
 {
   static const unsigned char asso_values[] =
 {
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73,  0, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73,  5, 25, 25,
-   0,  0,  0,  5,  0,  0, 73, 73,  5,  0,
-  10,  5, 45, 73, 20, 20,  0, 15, 15, 73,
-  20,  5, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74,  0, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74,  0, 20, 10,
+   0,  0,  0, 30,  0,  0, 74, 74,  5, 15,
+   0, 25, 40, 74, 15,  0,  0, 10, 35, 74,
+  10,  0, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
+  74, 74, 74, 74, 74, 74
 };
   register int hval = len;
 
@@ -97,33 +97,35 @@ struct kconf_id_strings_t
 char kconf_id_strings_str8[sizeof("tristate")];
 char kconf_id_strings_str9[sizeof("endchoice")];
 char kconf_id_strings_str10[sizeof("---help---")];
+char kconf_id_strings_str11[sizeof("select")];
 char kconf_id_strings_str12[sizeof("def_tristate")];
 char kconf_id_strings_str13[sizeof("def_bool")];
 char kconf_id_strings_str14[sizeof("defconfig_list")];
-char kconf_id_strings_str17[sizeof("on")];
-char kconf_id_strings_str18[sizeof("optional")];
-char kconf_id_strings_str21[sizeof("option")];
-char kconf_id_strings_str22[sizeof("endmenu")];
-char kconf_id_strings_str23[sizeof("mainmenu")];
-char kconf_id_strings_str25[sizeof("menuconfig")];
-char kconf_id_strings_str27[sizeof("modules")];
-char kconf_id_strings_str28[sizeof("allnoconfig_y")];
+char kconf_id_strings_str16[sizeof("source")];
+char kconf_id_strings_str17[sizeof("endmenu")];
+char kconf_id_strings_str18[sizeof("allnoconfig_y")];
+char kconf_id_strings_str20[sizeof("range")];
+char kconf_id_strings_str22[sizeof("modules")];
+char kconf_id_strings_str23[sizeof("hex")];
+char kconf_id_strings_str27[sizeof("on")];
 char kconf_id_strings_str29[sizeof("menu")];
-char kconf_id_strings_str31[sizeof("select")];
+char kconf_id_strings_str31[sizeof("option")];
 char kconf_id_strings_str32[sizeof("

[PATCH v2 5/5] posix-timers: make it configurable

2016-10-25 Thread Nicolas Pitre
Some embedded systems have no use for 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 which should cover the vast
majority of use cases with very little code.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.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 
+
+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*) >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 fo

[PATCH v2 1/5] kconfig: introduce the "imply" keyword

2016-10-25 Thread Nicolas Pitre
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 <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.org>
---
 Documentation/kbuild/kconfig-language.txt | 28 
 scripts/kconfig/expr.h|  2 ++
 scripts/kconfig/menu.c| 55 ++-
 scripts/kconfig/symbol.c  | 24 +-
 scripts/kconfig/zconf.gperf   |  1 +
 scripts/kconfig/zconf.y   | 16 +++--
 6 files changed, 107 insertions(+), 19 deletions(-)

diff --git a/Documentation/kbuild/kconfig-language.txt 
b/Documentation/kbuild/kconfig-language.txt
index 069fcb3eef..5ee0dd3c85 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"  ["if" ]
+  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 BAZ'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" 
   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
in

[PATCH v2 4/5] ptp_clock: allow for it to be optional

2016-10-25 Thread Nicolas Pitre
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 <n...@linaro.org>
Reviewed-by: Josh Triplett <j...@joshtriplett.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_CLOC

[PATCH v2 2/5] kconfig: introduce the "suggest" keyword

2016-10-25 Thread Nicolas Pitre
Similar to "imply" but with no added restrictions on the target symbol's
value. Useful for providing a default value to another symbol.

Suggested by Edward Cree.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 Documentation/kbuild/kconfig-language.txt |  6 ++
 scripts/kconfig/expr.h|  2 ++
 scripts/kconfig/menu.c| 15 ++-
 scripts/kconfig/symbol.c  | 20 +++-
 scripts/kconfig/zconf.gperf   |  1 +
 scripts/kconfig/zconf.y   | 16 ++--
 6 files changed, 56 insertions(+), 4 deletions(-)

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"  ["if" ]
+  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" 
   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 20136ffefb..4a8094a63c 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-

[no subject]

2016-10-25 Thread Nicolas Pitre
From: Nicolas Pitre <nicolas.pi...@linaro.org>
Subject: [PATCH v2 0/5] make POSIX timers optional with some Kconfig help

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. The "suggest" keyword is
also provided to complement "imply" but without the restrictions from
"imply" or "select".

At this point I'd like to gather ACKs especially from people in the "To"
field. Ideally this would need to go upstream as a single series to avoid
cross subsystem dependency issues, and we should decide which maintainer
tree to use.  Suggestions welcome.

Changes from v1:

- added "suggest" to kconfig for completeness
- various typo fixes
- small "imply" effect visibility fix

The bulk of the diffstat comes from the kconfig lex parser regeneration.

Diffstat:

 Documentation/kbuild/kconfig-language.txt   |   34 +
 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  |4 +
 scripts/kconfig/menu.c  |   68 +-
 scripts/kconfig/symbol.c|   42 +-
 scripts/kconfig/zconf.gperf |2 +
 scripts/kconfig/zconf.hash.c_shipped|  228 +--
 scripts/kconfig/zconf.tab.c_shipped | 1631 -
 scripts/kconfig/zconf.y |   28 +-
 32 files changed, 1300 insertions(+), 1045 deletions(-)


Re: [PATCH 1/4] kconfig: introduce the "imply" keyword

2016-10-20 Thread Nicolas Pitre
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.pi...@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 <n...@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"  ["if" ]
+  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" 
   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

Re: [PATCH 1/4] kconfig: introduce the "imply" keyword

2016-10-20 Thread Nicolas Pitre
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


Re: [PATCH 0/4] make POSIX timers optional with some Kconfig help

2016-10-20 Thread Nicolas Pitre
On Thu, 20 Oct 2016, Thomas Gleixner wrote:

> On Wed, 19 Oct 2016, Nicolas Pitre wrote:
> > 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.
> 
> That's really nice work! Thanks for doing that. It makes the whole thing
> more palatable.

Thanks.

Now I'd need some review tags...  ;-)


Nicolas


Re: [PATCH 1/4] kconfig: introduce the "imply" keyword

2016-10-20 Thread Nicolas Pitre
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


Re: [PATCH 3/4] ptp_clock: allow for it to be optional

2016-10-20 Thread Nicolas Pitre
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


Re: [PATCH 1/4] kconfig: introduce the "imply" keyword

2016-10-20 Thread Nicolas Pitre
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"  ["if" ]
> > +  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


Re: [PATCH 3/4] ptp_clock: allow for it to be optional

2016-10-20 Thread Nicolas Pitre
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


Re: [PATCH 4/4] posix-timers: make it configurable

2016-10-20 Thread Nicolas Pitre
On Thu, 20 Oct 2016, Richard Cochran wrote:

> 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 ...

As you wish.

Turns out that my own use of Fedora currently makes no use of them 
either.


Nicolas


[PATCH 1/4] kconfig: introduce the "imply" keyword

2016-10-19 Thread Nicolas Pitre
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 <n...@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"  ["if" ]
+  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" 
   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/kconfi

[PATCH 3/4] ptp_clock: allow for it to be optional

2016-10-19 Thread Nicolas Pitre
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 <n...@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---
  

[PATCH 2/4] kconfig: re-generate *.c_shipped files after previous change

2016-10-19 Thread Nicolas Pitre
Signed-off-by: Nicolas Pitre <n...@linaro.org>
---
 scripts/kconfig/zconf.hash.c_shipped |   30 +-
 scripts/kconfig/zconf.tab.c_shipped  | 1581 --
 2 files changed, 753 insertions(+), 858 deletions(-)

diff --git a/scripts/kconfig/zconf.hash.c_shipped 
b/scripts/kconfig/zconf.hash.c_shipped
index 360a62df2b..d51b15de07 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -55,10 +55,10 @@ kconf_id_hash (register const char *str, register unsigned 
int len)
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
-  73, 73, 73, 73, 73, 73, 73,  5, 25, 25,
+  73, 73, 73, 73, 73, 73, 73, 10, 25, 25,
0,  0,  0,  5,  0,  0, 73, 73,  5,  0,
   10,  5, 45, 73, 20, 20,  0, 15, 15, 73,
-  20,  5, 73, 73, 73, 73, 73, 73, 73, 73,
+  20,  0, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
   73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
@@ -120,6 +120,7 @@ struct kconf_id_strings_t
 char kconf_id_strings_str43[sizeof("hex")];
 char kconf_id_strings_str46[sizeof("config")];
 char kconf_id_strings_str47[sizeof("boolean")];
+char kconf_id_strings_str50[sizeof("imply")];
 char kconf_id_strings_str51[sizeof("string")];
 char kconf_id_strings_str54[sizeof("help")];
 char kconf_id_strings_str56[sizeof("prompt")];
@@ -157,6 +158,7 @@ static const struct kconf_id_strings_t 
kconf_id_strings_contents =
 "hex",
 "config",
 "boolean",
+"imply",
 "string",
 "help",
 "prompt",
@@ -174,7 +176,7 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
 {
   enum
 {
-  TOTAL_KEYWORDS = 34,
+  TOTAL_KEYWORDS = 35,
   MIN_WORD_LENGTH = 2,
   MAX_WORD_LENGTH = 14,
   MIN_HASH_VALUE = 2,
@@ -205,15 +207,15 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12,   
T_DEFAULT,  TF_COMMAND, S_TRISTATE},
 #line 36 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13,   
T_DEFAULT,  TF_COMMAND, S_BOOLEAN},
-#line 46 "scripts/kconfig/zconf.gperf"
+#line 47 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14,   
T_OPT_DEFCONFIG_LIST,TF_OPTION},
   {-1}, {-1},
-#line 44 "scripts/kconfig/zconf.gperf"
+#line 45 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17,   
T_ON,   TF_PARAM},
 #line 29 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18,   
T_OPTIONAL, TF_COMMAND},
   {-1}, {-1},
-#line 43 "scripts/kconfig/zconf.gperf"
+#line 44 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21,   
T_OPTION,   TF_COMMAND},
 #line 17 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22,   
T_ENDMENU,  TF_COMMAND},
@@ -223,9 +225,9 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
 #line 23 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25,   
T_MENUCONFIG,   TF_COMMAND},
   {-1},
-#line 45 "scripts/kconfig/zconf.gperf"
+#line 46 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27,   
T_OPT_MODULES,  TF_OPTION},
-#line 48 "scripts/kconfig/zconf.gperf"
+#line 49 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28,   
T_OPT_ALLNOCONFIG_Y,TF_OPTION},
 #line 16 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29,   
T_MENU, TF_COMMAND},
@@ -234,10 +236,10 @@ kconf_id_lookup (register const char *str, register 
unsigned int len)
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31,   
T_SELECT,   TF_COMMAND},
 #line 21 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32,   
T_COMMENT,  TF_COMMAND},
-#line 47 "scripts/kconfig/zconf.gperf"
+#line 48 "scripts/kconfig/zconf.gperf"
   {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, 

[PATCH 0/4] make POSIX timers optional with some Kconfig help

2016-10-19 Thread Nicolas Pitre
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(-)


[PATCH 4/4] posix-timers: make it configurable

2016-10-19 Thread Nicolas Pitre
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 <n...@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 
+
+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*) >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 th

Re: [PATCH (net.git)] stmmac: fix and review the ptp registration.

2016-10-19 Thread Nicolas Pitre
[ added Richard to CC ]

On Wed, 19 Oct 2016, Giuseppe Cavallaro wrote:

> The commit commit 7086605a6ab5 ("stmmac: fix error check when init ptp")
> breaks the procedure added by the
> commit efee95f42b5d ("ptp_clock: future-proofing drivers against PTP
> subsystem becoming optional")
> 
> So this patch tries to re-import the logic added by the latest
> commit above: it makes sense to have the stmmac_ptp_register
> as void function and, inside the main, the stmmac_init_ptp can fails
> in case of the capability cannot be supported by the HW.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavall...@st.com>
> Cc: Alexandre TORGUE <alexandre.tor...@st.com>
> Cc: Rayagond Kokatanur <rayag...@vayavyalabs.com>
> Cc: Dan Carpenter <dan.carpen...@oracle.com>
> Cc: Nicolas Pitre <n...@linaro.org>

Acked-by: Nicolas Pitre <n...@linaro.org>

> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  6 --
>  drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c  | 15 ---
>  3 files changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> index 8dc9056..b15fc55 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> @@ -145,7 +145,7 @@ int stmmac_mdio_register(struct net_device *ndev);
>  int stmmac_mdio_reset(struct mii_bus *mii);
>  void stmmac_set_ethtool_ops(struct net_device *netdev);
>  
> -int stmmac_ptp_register(struct stmmac_priv *priv);
> +void stmmac_ptp_register(struct stmmac_priv *priv);
>  void stmmac_ptp_unregister(struct stmmac_priv *priv);
>  int stmmac_resume(struct device *dev);
>  int stmmac_suspend(struct device *dev);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 6c85b61..48e71fa 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -676,7 +676,9 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)
>   priv->hwts_tx_en = 0;
>   priv->hwts_rx_en = 0;
>  
> - return stmmac_ptp_register(priv);
> + stmmac_ptp_register(priv);
> +
> + return 0;
>  }
>  
>  static void stmmac_release_ptp(struct stmmac_priv *priv)
> @@ -1710,7 +1712,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool 
> init_ptp)
>   if (init_ptp) {
>   ret = stmmac_init_ptp(priv);
>   if (ret)
> - netdev_warn(priv->dev, "PTP support cannot init.\n");
> + netdev_warn(priv->dev, "fail to init PTP.\n");
>   }
>  
>  #ifdef CONFIG_DEBUG_FS
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
> index 5d61fb2..1477471 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
> @@ -177,7 +177,7 @@ static struct ptp_clock_info stmmac_ptp_clock_ops = {
>   * Description: this function will register the ptp clock driver
>   * to kernel. It also does some house keeping work.
>   */
> -int stmmac_ptp_register(struct stmmac_priv *priv)
> +void stmmac_ptp_register(struct stmmac_priv *priv)
>  {
>   spin_lock_init(>ptp_lock);
>   priv->ptp_clock_ops = stmmac_ptp_clock_ops;
> @@ -185,17 +185,10 @@ int stmmac_ptp_register(struct stmmac_priv *priv)
>   priv->ptp_clock = ptp_clock_register(>ptp_clock_ops,
>priv->device);
>   if (IS_ERR(priv->ptp_clock)) {
> - int ret = PTR_ERR(priv->ptp_clock);
> -
> + netdev_err(priv->dev, "ptp_clock_register failed\n");
>   priv->ptp_clock = NULL;
> - return ret;
> - }
> -
> - spin_lock_init(>ptp_lock);
> -
> - netdev_dbg(priv->dev, "Added PTP HW clock successfully\n");
> -
> - return 0;
> + } else if (priv->ptp_clock)
> + netdev_info(priv->dev, "registered PTP clock\n");
>  }
>  
>  /**
> -- 
> 2.7.4
> 
> 


bad commit touching stmmac_ptp.c

2016-10-18 Thread Nicolas Pitre
Hello,

I noticed a recently added commit 7086605a6a ("stmmac: fix error check 
when init ptp") to the mainline linux tree from you. This commit is 
wrong.  The affected code now reads as:

int stmmac_ptp_register(struct stmmac_priv *priv)
{
spin_lock_init(>ptp_lock);
priv->ptp_clock_ops = stmmac_ptp_clock_ops;

priv->ptp_clock = ptp_clock_register(>ptp_clock_ops,
 priv->device);
if (IS_ERR(priv->ptp_clock)) {
priv->ptp_clock = NULL;
return PTR_ERR(priv->ptp_clock);
}

spin_lock_init(>ptp_lock);

netdev_dbg(priv->dev, "Added PTP HW clock successfully\n");

return 0;
}

Firstly, you basically reverted the change I did with commit 
efee95f42b ("ptp_clock: future-proofing drivers against PTP subsystem 
becoming optional").  Please have a look at that commit and ponder its 
implications.

Secondly, the error you're actually returning to the caller with your 
patch is actually PTR_ERR(NULL) which is basically a more convoluted way 
to return the same value as what was returned before your patch, which 
is probably not what you intended.

And finally you added a needless initialization of priv->ptp_lock given 
that this was already done a few lines before that addition.

Was this patch actually reviewed?


Nicolas


[PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional

2016-09-20 Thread Nicolas Pitre

Drivers must be ready to accept NULL from ptp_clock_register() if the
PTP clock subsystem is configured out.

This patch documents that and ensures that all drivers cope well
with a NULL return.

Signed-off-by: Nicolas Pitre <n...@linaro.org>
Reviewed-by: Eugenia Emantayev <euge...@mellanox.com>

---

Let's have the basics merged now and work out the actual Kconfig issue 
separately. Richard, if you agree with this patch, I think this could go 
via the netdev tree.

diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c 
b/drivers/net/ethernet/intel/e1000e/ptp.c
index 2e1b17ad52..ad03763e00 100644
--- a/drivers/net/ethernet/intel/e1000e/ptp.c
+++ b/drivers/net/ethernet/intel/e1000e/ptp.c
@@ -334,7 +334,7 @@ void e1000e_ptp_init(struct e1000_adapter *adapter)
if (IS_ERR(adapter->ptp_clock)) {
adapter->ptp_clock = NULL;
e_err("ptp_clock_register failed\n");
-   } else {
+   } else if (adapter->ptp_clock) {
e_info("registered PHC clock\n");
}
 }
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c 
b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index ed39cbad24..f1feceab75 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -669,7 +669,7 @@ void i40e_ptp_init(struct i40e_pf *pf)
pf->ptp_clock = NULL;
dev_err(>pdev->dev, "%s: ptp_clock_register failed\n",
__func__);
-   } else {
+   } else if (pf->ptp_clock) {
struct timespec64 ts;
u32 regval;
 
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c 
b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 336c103ae3..7531892b08 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -1159,7 +1159,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
if (IS_ERR(adapter->ptp_clock)) {
adapter->ptp_clock = NULL;
dev_err(>pdev->dev, "ptp_clock_register failed\n");
-   } else {
+   } else if (adapter->ptp_clock) {
dev_info(>pdev->dev, "added PHC on %s\n",
 adapter->netdev->name);
adapter->ptp_flags |= IGB_PTP_ENABLED;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index e5431bfe33..a92277683a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -1254,7 +1254,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter 
*adapter)
adapter->ptp_clock = NULL;
e_dev_err("ptp_clock_register failed\n");
return err;
-   } else
+   } else if (adapter->ptp_clock)
e_dev_info("registered PHC device on %s\n", netdev->name);
 
/* set default timestamp mode to disabled here. We do this in
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c 
b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 1494997c4f..08fc5fc56d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -298,7 +298,7 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
if (IS_ERR(mdev->ptp_clock)) {
mdev->ptp_clock = NULL;
mlx4_err(mdev, "ptp_clock_register failed\n");
-   } else {
+   } else if (mdev->ptp_clock) {
mlx4_info(mdev, "registered PHC clock\n");
}
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
index 847a8f3ac2..13dc388667 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
@@ -273,7 +273,7 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
 
tstamp->ptp = ptp_clock_register(>ptp_info,
 >mdev->pdev->dev);
-   if (IS_ERR_OR_NULL(tstamp->ptp)) {
+   if (IS_ERR(tstamp->ptp)) {
mlx5_core_warn(priv->mdev, "ptp_clock_register failed %ld\n",
   PTR_ERR(tstamp->ptp));
tstamp->ptp = NULL;
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index c771e0af4e..f105a170b4 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -1269,13 +1269,13 @@ int efx_ptp_probe(struct efx_nic *efx, struct 
efx_channel *channel)
if (IS_ERR(ptp->phc_clock)) {
rc = PTR_ERR(ptp->phc_clock);
goto fail3;
-   }
-
-   INIT_WORK(>pps_work, efx_ptp_pps_worker);
-   ptp->pps_workwq = create_singlethread_w

Re: [PATCH v2 0/2] make POSIX timers optional

2016-09-20 Thread Nicolas Pitre
On Tue, 20 Sep 2016, Thomas Gleixner wrote:

> I think the whole approach is wrong because it makes the PTP split at the
> wrong level.
> 
> Currently we have:
> 
> DRIVER_X
> tristate "Driver X"
> select PTP
> 
> In order to make POSIX_CLOCK configurable we should have
> 
> PTP
> tristate "PTP"
> select POSIX_CLOCK
> 
> Now if you want to distangle PTP from a driver then you split it at the
> driver level and not at the PTP level:
> 
> DRIVER_X
> tristate "Driver X"
> 
> DRIVER_X_PTP
> bool "Enable PTP support"
> default y if !MAKE_IT_TINY
> depends on DRIVER_X
> select PTP
> 
> We have already drivers following that scheme. That way you make the PTP
> support in the driver conditional on DRIVER_X_PTP and have no hassle with
> modules and dependencies.

I beg to disagree.

There are way more drivers than subsystems and if you had to go around 
unselecting all NIC drivers for CONFIG_ETHERNET to be turned off, and 
with CONFIG_ETHERNET=n you'd finally be able to turn networking off, 
then this would be a nightmare.

IMHO it is much nicer for the poor user configuring the kernel to have a 
single configuration prompt for PTP support, and then have whatever 
driver that can provide a PTP clock just do it (or omit it) based on 
that single prompt.  Prompting for PTP support for each individual 
ethernet driver is silly.


Nicolas


Re: [PATCH v2 0/2] make POSIX timers optional

2016-09-20 Thread Nicolas Pitre
On Tue, 20 Sep 2016, Richard Cochran wrote:

> On Tue, Sep 20, 2016 at 10:25:56PM +0200, Richard Cochran wrote:
> > After this series, if I don't pay enough attention to dmesg, then I
> > have lost functionality that I had in step #1.  That sucks, and it has
> > nothing to do with the tinification option at all.  It will bite even
> > if I have no knowledge of it.  That isn't acceptable to me.
> 
> Can't you leave all the "select PTP_1588_CLOCK" alone and simply add
> 
> #ifdef CONFIG_POSIX_TIMERS
>   // global declarations
> #else
>   // static inlines
> #endif
> 
> to ptp_clock_kernel.h, and then sandwich ptp_clock.c in
> #ifdef CONFIG_POSIX_TIMERS ... #endif ?

Sure I could... but I'm sure I'll be flamed by others for making things 
even more obscure and hackish than they are right now.

Oh well...  Let's go fix the Kconfig parser then.


Nicolas


Re: [PATCH v2 0/2] make POSIX timers optional

2016-09-20 Thread Nicolas Pitre
On Tue, 20 Sep 2016, Richard Cochran wrote:

> On Tue, Sep 20, 2016 at 03:56:38PM -0400, Nicolas Pitre wrote:
> > - Add a warning for the case where PTP clock subsystem is modular and a
> >   driver providing a clock is built-in rather than silently ignoring it.
> >   Suggested by Jiri Benc.
> 
> So I am really not happy with this.  Here is a common embedded
> workflow, at least for me:
> 
> 1. take some given Kconfig and get it running on the target.
> 
> 2. for the given HW, change the modules into built-ins, and forget
>module loading
> 
> After this series, if I don't pay enough attention to dmesg, then I
> have lost functionality that I had in step #1.

Would that given config from #1 typically have CONFIG_EXPERT actually 
set?

Ultimately, do you know a way to restrict a tristate to y or n? A 
tristate can be limited to m or n with "depends on m" but it doesn't 
appear to be possible to exclude m with a promotion to y.


Nicolas


[PATCH 1/2] ptp_clock: allow for it to be optional

2016-09-20 Thread Nicolas Pitre
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.

And to make it possible for PTP to be configured out, the select statement
in the Kconfig entry for those ethernet drivers is changed from selecting
PTP_1588_CLOCK to PTP_1588_CLOCK_SELECTED whose purpose is to indicate the
default Kconfig value for the PTP subsystem.

This way the PTP subsystem may have Kconfig dependencies of its own, such
as POSIX_TIMERS, without making those ethernet drivers unavailable if
POSIX timers are cconfigured out. And when support for POSIX timers is
selected again then PTP clock support will also be selected accordingly.

Drivers must be ready to accept NULL from ptp_clock_register().
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 <n...@linaro.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
Reviewed-by: Eugenia Emantayev <euge...@mellanox.com>
---
 drivers/Makefile   |  2 +-
 drivers/net/ethernet/adi/Kconfig   |  8 ++-
 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/intel/e1000e/ptp.c|  2 +-
 drivers/net/ethernet/intel/i40e/i40e_ptp.c |  2 +-
 drivers/net/ethernet/intel/igb/igb_ptp.c   |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c   |  2 +-
 drivers/net/ethernet/mellanox/mlx4/Kconfig |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_clock.c  |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/Kconfig|  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_clock.c |  2 +-
 drivers/net/ethernet/renesas/Kconfig   |  2 +-
 drivers/net/ethernet/samsung/Kconfig   |  2 +-
 drivers/net/ethernet/sfc/Kconfig   |  2 +-
 drivers/net/ethernet/sfc/ptp.c | 14 ++---
 drivers/net/ethernet/stmicro/stmmac/Kconfig|  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c   |  2 +-
 drivers/net/ethernet/ti/Kconfig|  2 +-
 drivers/net/ethernet/tile/Kconfig  |  2 +-
 drivers/ptp/Kconfig| 12 ++--
 include/linux/ptp_clock_kernel.h   | 64 --
 26 files changed, 97 insertions(+), 59 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 53abb4a5f7..8a538d0856 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -105,7 +105,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..67094a9cfe 100644
--- a/drivers/net/ethernet/adi/Kconfig
+++ b/drivers/net/ethernet/adi/Kconfig
@@ -55,10 +55,14 @@ config BFIN_RX_DESC_NUM
---help---
  Set the number of buffer packets used in driver.
 
+config BFIN_MAC_HAS_HWSTAMP
+   def_tristate BFIN_MAC
+   depends on BF518
+   select PTP_1588_CLOCK_SELECTED
+
 config BFIN_MAC_USE_HWSTAMP
bool "Use IEEE 1588 hwstamp"
-   depends on BFIN_MAC && BF518
-   select PTP_1588_CLOCK
+   depends on BFIN_MAC_HAS_HWSTAMP && 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..327e71a554 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
+   select PTP_1588_CLOCK_SELECTED
---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 3eee3201b5..4aeeb018b6 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 platfo

[PATCH 2/2] posix-timers: make it configurable

2016-09-20 Thread Nicolas Pitre
Many embedded systems typically don't need them.  This removes about
22KB from the kernel binary size on ARM 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 <n...@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/Kconfig  |   1 +
 kernel/time/Makefile |  10 +++-
 kernel/time/posix-stubs.c| 118 +++
 8 files changed, 185 insertions(+), 5 deletions(-)
 create mode 100644 kernel/time/posix-stubs.c

diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index f34b3748c0..940fa10907 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -10,7 +10,7 @@ config PTP_1588_CLOCK_SELECTED
 config PTP_1588_CLOCK
tristate "PTP clock support"
default PTP_1588_CLOCK_SELECTED
-   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 
+
+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*) >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 54182d52a0..39a1d6d3f5 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2924,8 +2924,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);
 
@@ -3382,7 +3387,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 a117738afd..3fdea723dd 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1449,6 +1449,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 config

[PATCH v2 0/2] make POSIX timers optional

2016-09-20 Thread Nicolas Pitre
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*
it in their Kconfig entries. Therefore some more tweaks were needed to
break that hard dependency for those drivers to still be configured in
if desired.

It was agreed that the best path upstream for those patches is via
John Stultz's timer tree.

Previous itterations of those patches and the discussion threads can be
found here:

  https://lkml.org/lkml/2016/9/14/992
  https://lkml.org/lkml/2016/9/14/803
  https://lkml.org/lkml/2016/9/8/793

Changes from v1:

- Add a warning for the case where PTP clock subsystem is modular and a
  driver providing a clock is built-in rather than silently ignoring it.
  Suggested by Jiri Benc.
- Added Eugenia Emantayev's reviewed-by tag.

diffstat:

 drivers/Makefile|   2 +-
 drivers/net/ethernet/adi/Kconfig|   8 +-
 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/intel/e1000e/ptp.c |   2 +-
 drivers/net/ethernet/intel/i40e/i40e_ptp.c  |   2 +-
 drivers/net/ethernet/intel/igb/igb_ptp.c|   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c|   2 +-
 drivers/net/ethernet/mellanox/mlx4/Kconfig  |   2 +-
 drivers/net/ethernet/mellanox/mlx4/en_clock.c   |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/Kconfig |   2 +-
 .../net/ethernet/mellanox/mlx5/core/en_clock.c  |   2 +-
 drivers/net/ethernet/renesas/Kconfig|   2 +-
 drivers/net/ethernet/samsung/Kconfig|   2 +-
 drivers/net/ethernet/sfc/Kconfig|   2 +-
 drivers/net/ethernet/sfc/ptp.c  |  14 +--
 drivers/net/ethernet/stmicro/stmmac/Kconfig |   2 +-
 .../net/ethernet/stmicro/stmmac/stmmac_ptp.c|   2 +-
 drivers/net/ethernet/ti/Kconfig |   2 +-
 drivers/net/ethernet/tile/Kconfig   |   2 +-
 drivers/ptp/Kconfig |  14 ++-
 include/linux/posix-timers.h|  28 -
 include/linux/ptp_clock_kernel.h|  64 +++---
 include/linux/sched.h   |  10 ++
 init/Kconfig|  17 +++
 kernel/signal.c |   4 +
 kernel/time/Kconfig |   1 +
 kernel/time/Makefile|  10 +-
 kernel/time/posix-stubs.c   | 118 ++
 33 files changed, 282 insertions(+), 64 deletions(-)


Re: [PATCH 1/2] ptp_clock: allow for it to be optional

2016-09-19 Thread Nicolas Pitre
On Mon, 19 Sep 2016, Josh Triplett wrote:

> But it does seem unfortunate that this can't happen at build time via
> Kconfig.  CCing linux-kbuild in case someone has an idea for how to fix
> this.

I hoped something like this could work:

config FOO
prompt "Blah-blah"
tristate if (BAR != y)
bool if (BAR = y)
default BAR

This way FOO could be y, m or n when BAR is m or n, otherwise FOO could 
be y or n only.

But that didn't work.


Nicolas


Re: [PATCH 1/2] ptp_clock: allow for it to be optional

2016-09-19 Thread Nicolas Pitre
On Mon, 19 Sep 2016, Jiri Benc wrote:

> On Sun, 18 Sep 2016 23:51:09 -0400, Nicolas Pitre wrote:
> > And to make it possible for PTP to be configured out, the select statement
> > in the Kconfig entry for those ethernet drivers is changed from selecting
> > PTP_1588_CLOCK to PTP_1588_CLOCK_SELECTED whose purpose is to indicate the
> > default Kconfig value for the PTP subsystem.
> 
> With this patch applied, the user is free to set a NIC driver as built
> in and PTP_1588_CLOCK as a module, right? If so, that would lead to
> non-functional PTP without any warning due to the use of IS_REACHABLE.
> That doesn't sound right. Could easily cause hours of headache to
> someone.
> 
> Or is this handled somehow?

I don't see how to remove the ability to select m for PTP_1588_CLOCK 
based on (PTP_1588_CLOCK_SELECTED = y).

What about this on top then:

diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index 4c29eb8e53..74079b2fcf 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -207,7 +207,16 @@ int ptp_find_pin(struct ptp_clock *ptp,
 #else
 static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
   struct device *parent)
-{ return NULL; }
+{
+   if (IS_MODULE(CONFIG_PTP_1588_CLOCK)) {
+   pr_warn("%s is built-in while PTP clock subsystem is modular, "
+   "PTP clock ignored\n", KBUILD_MODNAME);
+   } else {
+   pr_warn("ignoring PTP clock from %s as PTP clock subsystem "
+   "is configured out\n", KBUILD_MODNAME);
+   }
+   return NULL;
+}
 static inline int ptp_clock_unregister(struct ptp_clock *ptp)
 { return 0; }
 static inline void ptp_clock_event(struct ptp_clock *ptp,


[PATCH 2/2] posix-timers: make it configurable

2016-09-18 Thread Nicolas Pitre
Many embedded systems typically don't need them.  This removes about
22KB from the kernel binary size on ARM 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 <n...@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/Kconfig  |   1 +
 kernel/time/Makefile |  10 +++-
 kernel/time/posix-stubs.c| 118 +++
 8 files changed, 185 insertions(+), 5 deletions(-)
 create mode 100644 kernel/time/posix-stubs.c

diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index f34b3748c0..940fa10907 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -10,7 +10,7 @@ config PTP_1588_CLOCK_SELECTED
 config PTP_1588_CLOCK
tristate "PTP clock support"
default PTP_1588_CLOCK_SELECTED
-   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 
+
+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*) >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 54182d52a0..39a1d6d3f5 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2924,8 +2924,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);
 
@@ -3382,7 +3387,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 a117738afd..3fdea723dd 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1449,6 +1449,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 config

[PATCH 0/2] make POSIX timers configurable

2016-09-18 Thread Nicolas Pitre
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*
it in their Kconfig entries. Therefore some more tweaks were needed to
break that hard dependency for those drivers to still be configured in
if desired.

It was agreed that the best path upstream for those patches is via
John Stultz's timer tree.

Previous itterations of those patches and the discussion threads can be
found here:

  https://lkml.org/lkml/2016/9/14/992

  https://lkml.org/lkml/2016/9/14/803

  https://lkml.org/lkml/2016/9/8/793

diffstat:

 drivers/Makefile|   2 +-
 drivers/net/ethernet/adi/Kconfig|   8 +-
 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/intel/e1000e/ptp.c |   2 +-
 drivers/net/ethernet/intel/i40e/i40e_ptp.c  |   2 +-
 drivers/net/ethernet/intel/igb/igb_ptp.c|   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c|   2 +-
 drivers/net/ethernet/mellanox/mlx4/Kconfig  |   2 +-
 drivers/net/ethernet/mellanox/mlx4/en_clock.c   |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/Kconfig |   2 +-
 .../net/ethernet/mellanox/mlx5/core/en_clock.c  |   2 +-
 drivers/net/ethernet/renesas/Kconfig|   2 +-
 drivers/net/ethernet/samsung/Kconfig|   2 +-
 drivers/net/ethernet/sfc/Kconfig|   2 +-
 drivers/net/ethernet/sfc/ptp.c  |  14 +--
 drivers/net/ethernet/stmicro/stmmac/Kconfig |   2 +-
 .../net/ethernet/stmicro/stmmac/stmmac_ptp.c|   2 +-
 drivers/net/ethernet/ti/Kconfig |   2 +-
 drivers/net/ethernet/tile/Kconfig   |   2 +-
 drivers/ptp/Kconfig |  14 ++-
 include/linux/posix-timers.h|  28 -
 include/linux/ptp_clock_kernel.h|  59 ++---
 include/linux/sched.h   |  10 ++
 init/Kconfig|  17 +++
 kernel/signal.c |   4 +
 kernel/time/Kconfig |   1 +
 kernel/time/Makefile|  10 +-
 kernel/time/posix-stubs.c   | 118 ++
 33 files changed, 277 insertions(+), 64 deletions(-)


[PATCH 1/2] ptp_clock: allow for it to be optional

2016-09-18 Thread Nicolas Pitre
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.

And to make it possible for PTP to be configured out, the select statement
in the Kconfig entry for those ethernet drivers is changed from selecting
PTP_1588_CLOCK to PTP_1588_CLOCK_SELECTED whose purpose is to indicate the
default Kconfig value for the PTP subsystem.

This way the PTP subsystem may have Kconfig dependencies of its own, such
as POSIX_TIMERS, without making those ethernet drivers unavailable if
POSIX timers are cconfigured out. And when support for POSIX timers is
selected again then PTP clock support will also be selected accordingly.

Drivers must be ready to accept NULL from ptp_clock_register().
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 <n...@linaro.org>
Acked-by: Richard Cochran <richardcoch...@gmail.com>
---
 drivers/Makefile   |  2 +-
 drivers/net/ethernet/adi/Kconfig   |  8 ++-
 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/intel/e1000e/ptp.c|  2 +-
 drivers/net/ethernet/intel/i40e/i40e_ptp.c |  2 +-
 drivers/net/ethernet/intel/igb/igb_ptp.c   |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c   |  2 +-
 drivers/net/ethernet/mellanox/mlx4/Kconfig |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_clock.c  |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/Kconfig|  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_clock.c |  2 +-
 drivers/net/ethernet/renesas/Kconfig   |  2 +-
 drivers/net/ethernet/samsung/Kconfig   |  2 +-
 drivers/net/ethernet/sfc/Kconfig   |  2 +-
 drivers/net/ethernet/sfc/ptp.c | 14 ++---
 drivers/net/ethernet/stmicro/stmmac/Kconfig|  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c   |  2 +-
 drivers/net/ethernet/ti/Kconfig|  2 +-
 drivers/net/ethernet/tile/Kconfig  |  2 +-
 drivers/ptp/Kconfig| 12 +++--
 include/linux/ptp_clock_kernel.h   | 59 +++---
 26 files changed, 92 insertions(+), 59 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 53abb4a5f7..8a538d0856 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -105,7 +105,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..67094a9cfe 100644
--- a/drivers/net/ethernet/adi/Kconfig
+++ b/drivers/net/ethernet/adi/Kconfig
@@ -55,10 +55,14 @@ config BFIN_RX_DESC_NUM
---help---
  Set the number of buffer packets used in driver.
 
+config BFIN_MAC_HAS_HWSTAMP
+   def_tristate BFIN_MAC
+   depends on BF518
+   select PTP_1588_CLOCK_SELECTED
+
 config BFIN_MAC_USE_HWSTAMP
bool "Use IEEE 1588 hwstamp"
-   depends on BFIN_MAC && BF518
-   select PTP_1588_CLOCK
+   depends on BFIN_MAC_HAS_HWSTAMP && 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..327e71a554 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
+   select PTP_1588_CLOCK_SELECTED
---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 3eee3201b5..4aeeb018b6 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;
 

Re: [PATCH] net: smsc: remove build warning of duplicate definition

2016-08-31 Thread Nicolas Pitre
On Wed, 31 Aug 2016, Sudip Mukherjee wrote:

> The build of m32r was giving warning:
> 
> In file included from drivers/net/ethernet/smsc/smc91x.c:92:0:
> drivers/net/ethernet/smsc/smc91x.h:448:0: warning: "SMC_inb" redefined
>  #define SMC_inb(ioaddr, reg)  ({ BUG(); 0; })
>  
> drivers/net/ethernet/smsc/smc91x.h:106:0:
>   note: this is the location of the previous definition
>  #define SMC_inb(a, r)  inb(((u32)a) + (r))
>  
> drivers/net/ethernet/smsc/smc91x.h:449:0: warning: "SMC_outb" redefined
>  #define SMC_outb(x, ioaddr, reg) BUG()
>  
> drivers/net/ethernet/smsc/smc91x.h:108:0:
>   note: this is the location of the previous definition
>  #define SMC_outb(v, a, r) outb(v, ((u32)a) + (r))
> 
> Signed-off-by: Sudip Mukherjee 
> ---
> 
> m32r allmodconfig build of next-20160825 is at:
> https://travis-ci.org/sudipm-mukherjee/parport/jobs/154943795
> 
>  drivers/net/ethernet/smsc/smc91x.h | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/ethernet/smsc/smc91x.h 
> b/drivers/net/ethernet/smsc/smc91x.h
> index 1a55c79..0b0bb74 100644
> --- a/drivers/net/ethernet/smsc/smc91x.h
> +++ b/drivers/net/ethernet/smsc/smc91x.h
> @@ -445,7 +445,14 @@ smc_pxa_dma_insw(void __iomem *ioaddr, struct smc_local 
> *lp, int reg, int dma,
>  #endif
>  
>  #if ! SMC_CAN_USE_8BIT
> +#ifdef SMC_inb
> +#undef SMC_inb
> +#endif
>  #define SMC_inb(ioaddr, reg) ({ BUG(); 0; })
> +
> +#ifdef SMC_outb
> +#undef SMC_outb
> +#endif

Please just do the undef without any conditional.



>  #define SMC_outb(x, ioaddr, reg) BUG()
>  #define SMC_insb(a, r, p, l) BUG()
>  #define SMC_outsb(a, r, p, l)BUG()
> -- 
> 1.9.1
> 
> 


Re: [PATCH 0/4] SA11x0 Clocks and removal of Neponset SMC91x hack

2016-08-30 Thread Nicolas Pitre
On Tue, 30 Aug 2016, Russell King - ARM Linux wrote:

> This mini-series (which follows several other series on which it
> depends) gets rid of the Assabet/Neponset hack in the smc91x driver.
> 
> In order to do that, we need to get several pieces in place first:
> * gpiolib support throughout SA11x0/Assabet/Neponset so that we can
>   represent control signals through gpiolib
> * CCF support, so we can re-use the code in drivers/clk to implement
>   the external crystal oscillator attached to the SMC91x.  This
>   external crystal oscillator is enabled via a control signal.
> 
> This series:
> - performs the SA11x0 CCF conversion
> - adds an optional clock to SMC91x to cater for an external crystal
>   oscillator
> - switches the Neponset code to provide a 'struct clk' representing
>   this oscillator
> - removes the SMC91x hack to assert the enable signal
> 
> This results in the platform specific includes being removed from the
> SMC91x driver.
> 
> Please ack these changes; due to the dependencies, I wish to merge
> them through my tree.  Thanks.

Looks nice to me.

Acked-by: Nicolas Pitre <n...@linaro.org>

>  arch/arm/Kconfig   |   1 +
>  arch/arm/mach-sa1100/clock.c   | 191 
> +
>  arch/arm/mach-sa1100/neponset.c|  42 
>  drivers/net/ethernet/smsc/smc91x.c |  47 ++---
>  drivers/net/ethernet/smsc/smc91x.h |   1 +
>  5 files changed, 166 insertions(+), 116 deletions(-)
> 
> -- 
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


Re: [PATCH 2/2] smc91x: remove ARM hack for unaligned 16-bit writes

2016-08-25 Thread Nicolas Pitre
On Thu, 25 Aug 2016, Arnd Bergmann wrote:

> The ARM specific I/O operations are almost the same as the generic
> ones, with the exception of the SMC_outw macro that works around
> a problem of some platforms that cannot write to 16-bit registers
> at an address that is not 32-bit aligned.
> 
> By inspection, I found that this is handled already in the
> register abstractions for almost all cases, the exceptions being
> SMC_SET_MAC_ADDR() and SMC_SET_MCAST(). I assume that all
> platforms that require the hack for the other registers also
> need it here, so the ones listed explictly here are the only
> ones that work correctly, while the other ones either don't
> need the hack at all, or they will set an incorrect MAC
> address (which can often go unnoticed).

Probably that all PXA based platforms that use the SMC91x with 32-bit 
accesses need this.  The others simply wired only 16 data lines, or 
only 8 like the Neponset.

However I no longer have the concerned hardware and can't test it.

> This changes the two macros that set the unaligned registers
> to use 32-bit writes if possible, which should do the right
> thing in all combinations. The ARM specific SMC_outw gets removed
> as a consequence.
> 
> The only difference between the ARM behavior and the default is
> the selection of the LED settings. The fact that we have different
> defaults based on the CPU architectures here is a bit suspicious,
> but probably harmless, and I have no plan of touching that.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/net/ethernet/smsc/smc91x.h | 50 
> +++---
>  1 file changed, 30 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/ethernet/smsc/smc91x.h 
> b/drivers/net/ethernet/smsc/smc91x.h
> index 22333477d0b5..908473d9ede0 100644
> --- a/drivers/net/ethernet/smsc/smc91x.h
> +++ b/drivers/net/ethernet/smsc/smc91x.h
> @@ -58,6 +58,7 @@
>  #define SMC_inw(a, r)readw((a) + (r))
>  #define SMC_inl(a, r)readl((a) + (r))
>  #define SMC_outb(v, a, r)writeb(v, (a) + (r))
> +#define SMC_outw(v, a, r)writew(v, (a) + (r))
>  #define SMC_outl(v, a, r)writel(v, (a) + (r))
>  #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
>  #define SMC_outsw(a, r, p, l)writesw((a) + (r), p, l)
> @@ -65,19 +66,6 @@
>  #define SMC_outsl(a, r, p, l)writesl((a) + (r), p, l)
>  #define SMC_IRQ_FLAGS(-1)/* from resource */
>  
> -/* We actually can't write halfwords properly if not word aligned */
> -static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
> -{
> - if ((machine_is_mainstone() || machine_is_stargate2() ||
> -  machine_is_pxa_idp()) && reg & 2) {
> - unsigned int v = val << 16;
> - v |= readl(ioaddr + (reg & ~2)) & 0x;
> - writel(v, ioaddr + (reg & ~2));
> - } else {
> - writew(val, ioaddr + reg);
> - }
> -}
> -
>  #elifdefined(CONFIG_SH_SH4202_MICRODEV)
>  
>  #define SMC_CAN_USE_8BIT 0
> @@ -1029,18 +1017,40 @@ static const char * chip_ids[ 16 ] =  {
>  
>  #define SMC_SET_MAC_ADDR(lp, addr)   \
>   do {\
> - SMC_out16(addr[0]|(addr[1] << 8), ioaddr, ADDR0_REG(lp)); \
> - SMC_out16(addr[2]|(addr[3] << 8), ioaddr, ADDR1_REG(lp)); \
> - SMC_out16(addr[4]|(addr[5] << 8), ioaddr, ADDR2_REG(lp)); \
> + if (SMC_32BIT(lp)) {\
> + SMC_outl((addr[0]  )|(addr[1] <<  8) |  \
> +  (addr[2] << 16)|(addr[3] << 24),   \
> +  ioaddr, ADDR0_REG(lp));\
> + } else {\
> + SMC_out16(addr[0]|(addr[1] << 8), ioaddr,   \
> +   ADDR0_REG(lp));   \
> + SMC_out16(addr[2]|(addr[3] << 8), ioaddr,   \
> +   ADDR1_REG(lp));   \
> + }   \
> + SMC_out16(addr[4]|(addr[5] << 8), ioaddr,   \
> +   ADDR2_REG(lp)); \
>   } while (0)
>  
>  #define SMC_SET_MCAST(lp, x) \
>   do {\
>   const unsigned char *mt = (x);  \
> - SMC_out16(mt[0] | (mt[1] << 8), ioaddr, MCAST_REG1(lp)); \
> - SMC_out16(mt[2] | (mt[3] << 8), ioaddr, MCAST_REG2(lp)); \
> - SMC_out16(mt[4] | (mt[5] << 8), ioaddr, MCAST_REG3(lp)); \
> - SMC_out16(mt[6] | (mt[7] << 8), ioaddr, MCAST_REG4(lp)); \
> + if (SMC_32BIT(lp)) {\
> +  

Re: [PATCH v2 1/2] smc91x: always use 8-bit access if necessary

2016-08-25 Thread Nicolas Pitre
On Thu, 25 Aug 2016, Arnd Bergmann wrote:

> As Russell King found out the hard way, a change I did to fix multiplatform
> builds with this driver broke the old Assabet/Neponset platform: It turns
> out that while the driver is runtime configurable in principle, the
> runtime configuration does not cover the specific case of machines that
> can not do any 16-bit I/O on the smc91x registers.
> 
> The driver currently provides helpers to access 16-bit registers for
> architectures that are known at compile-time to only have 8-bit I/O,
> but my patch changed it to a runtime flag that never gets consulted
> most register accesses.
> 
> This introduces new SMC_out16()/SMC_in16 helpers (if anyone can suggest
> a better name, I'm glad to modify this) that behaves like SMC_outw()/SMC_inw()
> most of the time, but uses a pair of 8-bit accesses on platforms that
> have no support for wider register accesses.

Why don't you fold this directly into SMC_outw() instead?


Nicolas


Re: [PATCH] iwlegacy: mark il_adjust_beacon_interval as noinline

2015-12-09 Thread Nicolas Pitre
On Wed, 9 Dec 2015, Arnd Bergmann wrote:

> With the new optimized do_div() code, some versions of gcc
> produce obviously incorrect code that leads to a link error
> in iwlegacy/common.o:
> 
> drivers/built-in.o: In function `il_send_rxon_timing':
> :(.text+0xa6b4d4): undefined reference to `ilog2_NaN'
> :(.text+0xa6b4f0): undefined reference to `__aeabi_uldivmod'
> 
> In a few thousand randconfig builds, I have seen this problem
> a couple of times in this file, but never anywhere else in the
> kernel, so we can try to work around this in the only file
> that shows the behavior, by marking the il_adjust_beacon_interval
> function as noinline, which convinces gcc to use the unoptimized
> do_div() all the time.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

Acked-by: Nicolas Pitre <n...@linaro.org>

> 
> diff --git a/drivers/net/wireless/intel/iwlegacy/common.c 
> b/drivers/net/wireless/intel/iwlegacy/common.c
> index 887114582583..6308bb217454 100644
> --- a/drivers/net/wireless/intel/iwlegacy/common.c
> +++ b/drivers/net/wireless/intel/iwlegacy/common.c
> @@ -3602,7 +3602,7 @@ il_is_ht40_tx_allowed(struct il_priv *il, struct 
> ieee80211_sta_ht_cap *ht_cap)
>  }
>  EXPORT_SYMBOL(il_is_ht40_tx_allowed);
>  
> -static u16
> +static u16 noinline
>  il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
>  {
>   u16 new_val;
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/04] smc91x: pass along private data V2

2008-02-22 Thread Nicolas Pitre
On Fri, 22 Feb 2008, Magnus Damm wrote:

 Pass a private data pointer to macros and functions. This makes it easy
 to later on make run time decisions. This patch does not change any logic.
 These changes should be optimized away during compilation.
 
 V2 changes the macro argument name from priv to lp.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]

Acked-by: Nicolas Pitre [EMAIL PROTECTED]


 ---
 
  drivers/net/smc91x.c |  301 
 +-
  drivers/net/smc91x.h |  254 +-
  2 files changed, 280 insertions(+), 275 deletions(-)
 
 --- 0001/drivers/net/smc91x.c
 +++ work/drivers/net/smc91x.c 2008-02-22 14:07:43.0 +0900
 @@ -220,22 +220,22 @@ static void PRINT_PKT(u_char *buf, int l
  
  
  /* this enables an interrupt in the interrupt mask register */
 -#define SMC_ENABLE_INT(x) do {   
 \
 +#define SMC_ENABLE_INT(lp, x) do {   \
   unsigned char mask; \
   spin_lock_irq(lp-lock);   \
 - mask = SMC_GET_INT_MASK();  \
 + mask = SMC_GET_INT_MASK(lp);\
   mask |= (x);\
 - SMC_SET_INT_MASK(mask); \
 + SMC_SET_INT_MASK(lp, mask); \
   spin_unlock_irq(lp-lock); \
  } while (0)
  
  /* this disables an interrupt from the interrupt mask register */
 -#define SMC_DISABLE_INT(x) do {  
 \
 +#define SMC_DISABLE_INT(lp, x) do {  \
   unsigned char mask; \
   spin_lock_irq(lp-lock);   \
 - mask = SMC_GET_INT_MASK();  \
 + mask = SMC_GET_INT_MASK(lp);\
   mask = ~(x);   \
 - SMC_SET_INT_MASK(mask); \
 + SMC_SET_INT_MASK(lp, mask); \
   spin_unlock_irq(lp-lock); \
  } while (0)
  
 @@ -244,10 +244,10 @@ static void PRINT_PKT(u_char *buf, int l
   * if at all, but let's avoid deadlocking the system if the hardware
   * decides to go south.
   */
 -#define SMC_WAIT_MMU_BUSY() do { \
 - if (unlikely(SMC_GET_MMU_CMD()  MC_BUSY)) {\
 +#define SMC_WAIT_MMU_BUSY(lp) do {   \
 + if (unlikely(SMC_GET_MMU_CMD(lp)  MC_BUSY)) {  \
   unsigned long timeout = jiffies + 2;\
 - while (SMC_GET_MMU_CMD()  MC_BUSY) {   \
 + while (SMC_GET_MMU_CMD(lp)  MC_BUSY) { \
   if (time_after(jiffies, timeout)) { \
   printk(%s: timeout %s line %d\n,  \
   dev-name, __FILE__, __LINE__); \
 @@ -273,8 +273,8 @@ static void smc_reset(struct net_device 
  
   /* Disable all interrupts, block TX tasklet */
   spin_lock_irq(lp-lock);
 - SMC_SELECT_BANK(2);
 - SMC_SET_INT_MASK(0);
 + SMC_SELECT_BANK(lp, 2);
 + SMC_SET_INT_MASK(lp, 0);
   pending_skb = lp-pending_tx_skb;
   lp-pending_tx_skb = NULL;
   spin_unlock_irq(lp-lock);
 @@ -290,15 +290,15 @@ static void smc_reset(struct net_device 
* This resets the registers mostly to defaults, but doesn't
* affect EEPROM.  That seems unnecessary
*/
 - SMC_SELECT_BANK(0);
 - SMC_SET_RCR(RCR_SOFTRST);
 + SMC_SELECT_BANK(lp, 0);
 + SMC_SET_RCR(lp, RCR_SOFTRST);
  
   /*
* Setup the Configuration Register
* This is necessary because the CONFIG_REG is not affected
* by a soft reset
*/
 - SMC_SELECT_BANK(1);
 + SMC_SELECT_BANK(lp, 1);
  
   cfg = CONFIG_DEFAULT;
  
 @@ -316,7 +316,7 @@ static void smc_reset(struct net_device 
*/
   cfg |= CONFIG_EPH_POWER_EN;
  
 - SMC_SET_CONFIG(cfg);
 + SMC_SET_CONFIG(lp, cfg);
  
   /* this should pause enough for the chip to be happy */
   /*
 @@ -329,12 +329,12 @@ static void smc_reset(struct net_device 
   udelay(1);
  
   /* Disable transmit and receive functionality */
 - SMC_SELECT_BANK(0);
 - SMC_SET_RCR(RCR_CLEAR);
 - SMC_SET_TCR(TCR_CLEAR);
 + SMC_SELECT_BANK(lp, 0);
 + SMC_SET_RCR(lp, RCR_CLEAR);
 + SMC_SET_TCR(lp, TCR_CLEAR);
  
 - SMC_SELECT_BANK(1);
 - ctl = SMC_GET_CTL() | CTL_LE_ENABLE;
 + SMC_SELECT_BANK(lp, 1);
 + ctl = SMC_GET_CTL(lp) | CTL_LE_ENABLE

Re: [PATCH 02/04] smc91x: introduce platform data flags V2

2008-02-22 Thread Nicolas Pitre
On Fri, 22 Feb 2008, Magnus Damm wrote:

 This patch introduces struct smc91x_platdata and modifies the driver so
 bus width is checked during run time using SMC_nBIT() instead of
 SMC_CAN_USE_nBIT.
 
 V2 keeps static configuration lean using SMC_DYNAMIC_BUS_CONFIG.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]

Acked-by: Nicolas Pitre [EMAIL PROTECTED]

 ---
 
  drivers/net/smc91x.c   |   34 
  drivers/net/smc91x.h   |   57 
 +---
  include/linux/smc91x.h |   13 ++
  3 files changed, 77 insertions(+), 27 deletions(-)
 
 --- 0002/drivers/net/smc91x.c
 +++ work/drivers/net/smc91x.c 2008-02-22 15:11:44.0 +0900
 @@ -1997,6 +1997,8 @@ err_out:
  
  static int smc_enable_device(struct platform_device *pdev)
  {
 + struct net_device *ndev = platform_get_drvdata(pdev);
 + struct smc_local *lp = netdev_priv(ndev);
   unsigned long flags;
   unsigned char ecor, ecsr;
   void __iomem *addr;
 @@ -2039,7 +2041,7 @@ static int smc_enable_device(struct plat
* Set the appropriate byte/word mode.
*/
   ecsr = readb(addr + (ECSR  SMC_IO_SHIFT))  ~ECSR_IOIS8;
 - if (!SMC_CAN_USE_16BIT)
 + if (!SMC_16BIT(lp))
   ecsr |= ECSR_IOIS8;
   writeb(ecsr, addr + (ECSR  SMC_IO_SHIFT));
   local_irq_restore(flags);
 @@ -2124,10 +2126,11 @@ static void smc_release_datacs(struct pl
   */
  static int smc_drv_probe(struct platform_device *pdev)
  {
 + struct smc91x_platdata *pd = pdev-dev.platform_data;
 + struct smc_local *lp;
   struct net_device *ndev;
   struct resource *res, *ires;
   unsigned int __iomem *addr;
 - unsigned long irq_flags = SMC_IRQ_FLAGS;
   int ret;
  
   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, smc91x-regs);
 @@ -2152,6 +2155,27 @@ static int smc_drv_probe(struct platform
   }
   SET_NETDEV_DEV(ndev, pdev-dev);
  
 + /* get configuration from platform data, only allow use of
 +  * bus width if both SMC_CAN_USE_xxx and SMC91X_USE_xxx are set.
 +  */
 +
 + lp = netdev_priv(ndev);
 + lp-cfg.irq_flags = SMC_IRQ_FLAGS;
 +
 +#ifdef SMC_DYNAMIC_BUS_CONFIG
 + if (pd)
 + memcpy(lp-cfg, pd, sizeof(lp-cfg));
 + else {
 + lp-cfg.flags = SMC91X_USE_8BIT;
 + lp-cfg.flags |= SMC91X_USE_16BIT;
 + lp-cfg.flags |= SMC91X_USE_32BIT;
 + }
 +
 + lp-cfg.flags = ~(SMC_CAN_USE_8BIT ? 0 : SMC91X_USE_8BIT);
 + lp-cfg.flags = ~(SMC_CAN_USE_16BIT ? 0 : SMC91X_USE_16BIT);
 + lp-cfg.flags = ~(SMC_CAN_USE_32BIT ? 0 : SMC91X_USE_32BIT);
 +#endif
 +
   ndev-dma = (unsigned char)-1;
  
   ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 @@ -2162,7 +2186,7 @@ static int smc_drv_probe(struct platform
  
   ndev-irq = ires-start;
   if (SMC_IRQ_FLAGS == -1)
 - irq_flags = ires-flags  IRQF_TRIGGER_MASK;
 + lp-cfg.irq_flags = ires-flags  IRQF_TRIGGER_MASK;
  
   ret = smc_request_attrib(pdev);
   if (ret)
 @@ -2170,6 +2194,7 @@ static int smc_drv_probe(struct platform
  #if defined(CONFIG_SA1100_ASSABET)
   NCR_0 |= NCR_ENET_OSC_EN;
  #endif
 + platform_set_drvdata(pdev, ndev);
   ret = smc_enable_device(pdev);
   if (ret)
   goto out_release_attrib;
 @@ -2188,8 +2213,7 @@ static int smc_drv_probe(struct platform
   }
  #endif
  
 - platform_set_drvdata(pdev, ndev);
 - ret = smc_probe(ndev, addr, irq_flags);
 + ret = smc_probe(ndev, addr, lp-cfg.irq_flags);
   if (ret != 0)
   goto out_iounmap;
  
 --- 0002/drivers/net/smc91x.h
 +++ work/drivers/net/smc91x.h 2008-02-22 15:01:30.0 +0900
 @@ -34,6 +34,7 @@
  #ifndef _SMC91X_H_
  #define _SMC91X_H_
  
 +#include linux/smc91x.h
  
  /*
   * Define your architecture specific bus configuration parameters here.
 @@ -481,6 +482,7 @@ static inline void LPD7_SMC_outsw (unsig
  #define RPC_LSA_DEFAULT  RPC_LED_100_10
  #define RPC_LSB_DEFAULT  RPC_LED_TX_RX
  
 +#define SMC_DYNAMIC_BUS_CONFIG
  #endif
  
  
 @@ -526,8 +528,19 @@ struct smc_local {
  #endif
   void __iomem *base;
   void __iomem *datacs;
 +
 + struct smc91x_platdata cfg;
  };
  
 +#ifdef SMC_DYNAMIC_BUS_CONFIG
 +#define SMC_8BIT(p) (((p)-cfg.flags  SMC91X_USE_8BIT)  SMC_CAN_USE_8BIT)
 +#define SMC_16BIT(p) (((p)-cfg.flags  SMC91X_USE_16BIT)  
 SMC_CAN_USE_16BIT)
 +#define SMC_32BIT(p) (((p)-cfg.flags  SMC91X_USE_32BIT)  
 SMC_CAN_USE_32BIT)
 +#else
 +#define SMC_8BIT(p) SMC_CAN_USE_8BIT
 +#define SMC_16BIT(p) SMC_CAN_USE_16BIT
 +#define SMC_32BIT(p) SMC_CAN_USE_32BIT
 +#endif
  
  #ifdef SMC_USE_PXA_DMA
  /*
 @@ -1108,41 +1121,41 @@ static const char * chip_ids[ 16 ] =  {
   *
   * Enforce it on any 32-bit capable setup for now.
   */
 -#define SMC_MUST_ALIGN_WRITE SMC_CAN_USE_32BIT
 +#define SMC_MUST_ALIGN_WRITE(lp) SMC_32BIT(lp)
  
  #define SMC_GET_PN(lp

Re: [PATCH 03/04] smc91x: add insw/outsw to default config V2

2008-02-22 Thread Nicolas Pitre
On Fri, 22 Feb 2008, Magnus Damm wrote:

 This patch makes sure SMC_insw()/SMC_outsw() are defined for the
 default configuration. Without this change BUG()s will be triggered
 when using 16-bit only platform data and the default configuration.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]

Acked-by: Nicolas Pitre [EMAIL PROTECTED]

 ---
 
  drivers/net/smc91x.h |2 ++
  1 file changed, 2 insertions(+)
 
 --- 0003/drivers/net/smc91x.h
 +++ work/drivers/net/smc91x.h 2008-02-22 15:25:39.0 +0900
 @@ -476,6 +476,8 @@ static inline void LPD7_SMC_outsw (unsig
  #define SMC_outb(v, a, r)writeb(v, (a) + (r))
  #define SMC_outw(v, a, r)writew(v, (a) + (r))
  #define SMC_outl(v, a, r)writel(v, (a) + (r))
 +#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
 +#define SMC_outsw(a, r, p, l)writesw((a) + (r), p, l)
  #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
  #define SMC_outsl(a, r, p, l)writesl((a) + (r), p, l)
  
 


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/04] smc91x: make superh use default config V2

2008-02-22 Thread Nicolas Pitre
On Fri, 22 Feb 2008, Magnus Damm wrote:

 Removes superh board specific configuration from the header file. These boards
 will instead be configured using platform data.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]

Acked-by: Nicolas Pitre [EMAIL PROTECTED]

 ---
 
  drivers/net/smc91x.h |   30 --
  1 file changed, 30 deletions(-)
 
 --- 0004/drivers/net/smc91x.h
 +++ work/drivers/net/smc91x.h 2008-02-22 15:26:42.0 +0900
 @@ -292,36 +292,6 @@ SMC_outw(u16 val, void __iomem *ioaddr, 
  #define SMC_insw(a, r, p, l) insw((a) + (r), p, l)
  #define SMC_outsw(a, r, p, l)outsw((a) + (r), p, l)
  
 -#elif   defined(CONFIG_SUPERH)
 -
 -#ifdef CONFIG_SOLUTION_ENGINE
 -#define SMC_IRQ_FLAGS(0)
 -#define SMC_CAN_USE_8BIT   0
 -#define SMC_CAN_USE_16BIT  1
 -#define SMC_CAN_USE_32BIT  0
 -#define SMC_IO_SHIFT   0
 -#define SMC_NOWAIT 1
 -
 -#define SMC_inw(a, r)  inw((a) + (r))
 -#define SMC_outw(v, a, r)  outw(v, (a) + (r))
 -#define SMC_insw(a, r, p, l)   insw((a) + (r), p, l)
 -#define SMC_outsw(a, r, p, l)  outsw((a) + (r), p, l)
 -
 -#else /* BOARDS */
 -
 -#define SMC_CAN_USE_8BIT   1
 -#define SMC_CAN_USE_16BIT  1
 -#define SMC_CAN_USE_32BIT  0
 -
 -#define SMC_inb(a, r)  inb((a) + (r))
 -#define SMC_inw(a, r)  inw((a) + (r))
 -#define SMC_outb(v, a, r)  outb(v, (a) + (r))
 -#define SMC_outw(v, a, r)  outw(v, (a) + (r))
 -#define SMC_insw(a, r, p, l)   insw((a) + (r), p, l)
 -#define SMC_outsw(a, r, p, l)  outsw((a) + (r), p, l)
 -
 -#endif  /* BOARDS */
 -
  #elif   defined(CONFIG_M32R)
  
  #define SMC_CAN_USE_8BIT 0
 


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/04] smc91x: request bus width using platform data

2008-02-20 Thread Nicolas Pitre
On Wed, 20 Feb 2008, Magnus Damm wrote:

 These patches make it possible to request bus width in the platform data.
 
 Instead of keep on updating smc91x.h with board specific configuration,
 use platform data to pass along bus width and irq flags to the driver.
 This change is designed to be backwards-compatible, so all boards configured
 in the header file should just work as usual.

Thank you for doing this work.  I really meant to do it, and commit 
09779c6df2dbe95483269d194b327d41fe2cc57e was the first step towards that 
goal, but as you can see we're nearly two years later and I didn't do 
it.

I have a few comments though.  I will reply to those messages 
separately.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/04] smc91x: pass along private data

2008-02-20 Thread Nicolas Pitre
On Wed, 20 Feb 2008, Magnus Damm wrote:

 Pass a private data pointer to macros and functions. This makes it easy
 to later on make run time decisions. This patch does not change any logic.
 These changes should be optimized away during compilation.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]
 ---
 --- 0001/drivers/net/smc91x.c
 +++ work/drivers/net/smc91x.c 2008-02-20 16:52:48.0 +0900
 @@ -220,23 +220,23 @@ static void PRINT_PKT(u_char *buf, int l
  
  
  /* this enables an interrupt in the interrupt mask register */
 -#define SMC_ENABLE_INT(x) do {   
 \
 +#define SMC_ENABLE_INT(priv, x) do { \
   unsigned char mask; \
 - spin_lock_irq(lp-lock);   \
 - mask = SMC_GET_INT_MASK();  \
 + spin_lock_irq(priv-lock); \
 + mask = SMC_GET_INT_MASK(priv);  \

Since lp is already used all over the place, could you simply use lp 
for the macro argument name as well instead of priv?  This will make 
the code more uniform and reduce the patch size.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/04] smc91x: introduce platform data flags

2008-02-20 Thread Nicolas Pitre
On Wed, 20 Feb 2008, Magnus Damm wrote:

 This patch introduces struct smc91x_platdata and modifies the driver so
 bus width is checked during run time using SMC_nBIT() instead of
 SMC_CAN_USE_nBIT.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]
 ---

NAK.

The SMC91C111 (for example) is often used on devices which have a CPU 
clock barely higher than the network throughput, hence it is crutial for 
those devices to have the most efficient access possible to the chip or 
performance will suffer.  This is the main reason behind the heavily 
macroized register access so things are always optimized for the data 
bus capabilities at compile time.

This patch introduces a runtimes test on lp-cfg.flags for every 
register access even on those platforms not using the platform data 
based bus configuration at all.

I think you should add a SMC_DYNAMIC_BUS_CONFIG and redefine SMC_nBITS() 
so they dereference cfg.flags only when it is defined.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/04] smc91x: add insw/outsw to default config

2008-02-20 Thread Nicolas Pitre
On Wed, 20 Feb 2008, Magnus Damm wrote:

 This patch makes sure SMC_insw()/SMC_outsw() are defined for the
 default configuration. Without this change BUG()s will be triggered
 when using 16-bit only platform data and the default configuration.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]

You should have introduced this patch as 3/4 instead of 4/4 so to make 
sure the series won't  create a non functional kernel between 3/4 and 
4/4.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/04] smc91x: introduce platform data flags

2008-02-20 Thread Nicolas Pitre
On Thu, 21 Feb 2008, Magnus Damm wrote:

 On Thu, Feb 21, 2008 at 12:58 AM, Nicolas Pitre [EMAIL PROTECTED] wrote:
  On Wed, 20 Feb 2008, Magnus Damm wrote:
 
This patch introduces struct smc91x_platdata and modifies the driver so
bus width is checked during run time using SMC_nBIT() instead of
SMC_CAN_USE_nBIT.
   
Signed-off-by: Magnus Damm [EMAIL PROTECTED]
---
 
   NAK.
 
   The SMC91C111 (for example) is often used on devices which have a CPU
   clock barely higher than the network throughput, hence it is crutial for
   those devices to have the most efficient access possible to the chip or
   performance will suffer.  This is the main reason behind the heavily
   macroized register access so things are always optimized for the data
   bus capabilities at compile time.
 
 I understand that you want to keep the code as fast as possible. So do
 I. But I want to remove the need to modify smc91x.h for each board I
 want to support. It is much better in my opinion to have a wide range
 of boards supported but a little bit lower throughput compared to only
 a few boards supported and excellent performance... People can always
 modify the header file by themselves if they want to squeeze out that
 extra percent of performance.

Sure.  That's perfectly fine for new boards.  But existing setups should 
not regress due to this change.

   I think you should add a SMC_DYNAMIC_BUS_CONFIG and redefine SMC_nBITS()
   so they dereference cfg.flags only when it is defined.
 
 Sure, good idea. I'll fix that. Do you mind if I make that the default
 behavior? So boards that doesn't have any hard coded configuration in
 smc91x.h can use the platform data flags method for configuration
 instead.

Yes, that's fine.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/04] smc91x: pass along private data

2008-02-20 Thread Nicolas Pitre
On Thu, 21 Feb 2008, Magnus Damm wrote:

 On Thu, Feb 21, 2008 at 12:42 AM, Nicolas Pitre [EMAIL PROTECTED] wrote:
  On Wed, 20 Feb 2008, Magnus Damm wrote:
 
Pass a private data pointer to macros and functions. This makes it easy
to later on make run time decisions. This patch does not change any 
  logic.
These changes should be optimized away during compilation.
   
Signed-off-by: Magnus Damm [EMAIL PROTECTED]
---
 
   --- 0001/drivers/net/smc91x.c
+++ work/drivers/net/smc91x.c 2008-02-20 16:52:48.0 +0900
@@ -220,23 +220,23 @@ static void PRINT_PKT(u_char *buf, int l
   
   
 /* this enables an interrupt in the interrupt mask register */
-#define SMC_ENABLE_INT(x) do {  
   \
+#define SMC_ENABLE_INT(priv, x) do { \
  unsigned char mask; \
- spin_lock_irq(lp-lock);   \
- mask = SMC_GET_INT_MASK();  \
+ spin_lock_irq(priv-lock); \
+ mask = SMC_GET_INT_MASK(priv);  \
 
   Since lp is already used all over the place, could you simply use lp
   for the macro argument name as well instead of priv?  This will make
   the code more uniform and reduce the patch size.
 
 I used the name priv instead of lp intentionally to make sure I
 got compile errors if I missed something. Some variables like ioaddr
 are today not passed as arguments to the macros but simply assumed to
 be present as local variables. I wanted to avoid using the local lp
 variable by mistake. So the priv name is actually a feature. =)

Well, you end up using the local lp variable in all cases anyway.

 I'd be happy to rewrite the patch to use lp though, but I have to
 confess that I don't see the point in redoing it. Anyway, please let
 me know what you prefer.

I do prefer to have lp everywhere.  But you simply have to search and 
replace priv with lp in the patch directly.  Then just applying it 
and rediffing will take care of the simplification.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] SMC91x: don't flag spurious interrupts when polling

2008-01-24 Thread Nicolas Pitre
On Thu, 24 Jan 2008, Kevin Hilman wrote:

 When using polling, smc_poll_controller() can call smc_interrupt()
 when there are likely to be no real interrups.  This will trigger the
 spurious interrupt printk whenever the driver is being polled.
 
 This adds an 'is_polling' flags, and doesn't trigger the spurious
 warning when in polling mode.
 
 Signed-off-by: Kevin Hilman [EMAIL PROTECTED]
 Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

NAK

Kevin: you sent the wrong patch !


Nicolas
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add support for smc91x ethernet interface on zylonite

2007-11-05 Thread Nicolas Pitre
On Tue, 6 Nov 2007, eric miao wrote:

 From 9363662844b6373ddf4265e7007eb29ff963a377 Mon Sep 17 00:00:00 2001
 From: eric miao [EMAIL PROTECTED]

According to the SOB line below, shouldn't this be:
From: Aleksey Makarov [EMAIL PROTECTED]
?

 Date: Tue, 30 Oct 2007 09:48:41 +0800
 Subject: [PATCH] add support for smc91x ethernet interface on zylonite
 
 This patch adds LAN91C111 ethernet interface support for zylonite
 (a.k.a Marvell's PXA3xx Development Platform) with smc91x driver.
 
 It would be better if a patch would support zylonite along with all
 other PXA boards with a single binary of smc91x driver, but it looks
 quite difficult for the moment, so ugly #ifdef is still used here.
 
 Signed-off-by: Aleksey Makarov [EMAIL PROTECTED]
 Acked-by: eric miao [EMAIL PROTECTED]

Acked-by: Nicolas Pitre [EMAIL PROTECTED]

 ---
  drivers/net/smc91x.h |   15 +++
  1 files changed, 15 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
 index 729fd28..db34e1e 100644
 --- a/drivers/net/smc91x.h
 +++ b/drivers/net/smc91x.h
 @@ -224,6 +224,21 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
   }
  }
 
 +#elif defined(CONFIG_MACH_ZYLONITE)
 +
 +#define SMC_CAN_USE_8BIT1
 +#define SMC_CAN_USE_16BIT   1
 +#define SMC_CAN_USE_32BIT   0
 +#define SMC_IO_SHIFT0
 +#define SMC_NOWAIT  1
 +#define SMC_USE_PXA_DMA  1
 +#define SMC_inb(a, r)   readb((a) + (r))
 +#define SMC_inw(a, r)   readw((a) + (r))
 +#define SMC_insw(a, r, p, l)insw((a) + (r), p, l)
 +#define SMC_outsw(a, r, p, l)   outsw((a) + (r), p, l)
 +#define SMC_outb(v, a, r)   writeb(v, (a) + (r))
 +#define SMC_outw(v, a, r)   writew(v, (a) + (r))
 +
  #elifdefined(CONFIG_ARCH_OMAP)
 
  /* We can only do 16-bit reads and writes in the static memory space. */
 -- 
 1.5.2.5.GIT
 


Nicolas
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 32/41] lockdep: fix smc91x

2006-08-16 Thread Nicolas Pitre
On Mon, 14 Aug 2006, [EMAIL PROTECTED] wrote:

 From: Russell King [EMAIL PROTECTED]
 
 When booting using root-nfs, I'm seeing (independently) two lockdep dumps
 in the smc91x driver.  The patch below fixes both.  Both dumps look like
 real locking issues.
 
 Nico - please review and ack if you think the patch is correct.

The lock validator is rightfully complaining and the patch is correct.

Acked-by: Nicolas Pitre [EMAIL PROTECTED]


Nicolas
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] smc91x: add support for LogicPD PXA270 platform

2006-03-28 Thread Nicolas Pitre
On Tue, 28 Mar 2006, Lennert Buytenhek wrote:

 This patch adds support for the smc91x on the LogicPD PXA270 to
 the smc91x driver.
 
 Signed-off-by: Lennert Buytenhek [EMAIL PROTECTED]

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

 Index: linux-2.6.16/drivers/net/smc91x.h
 ===
 --- linux-2.6.16.orig/drivers/net/smc91x.h
 +++ linux-2.6.16/drivers/net/smc91x.h
 @@ -129,6 +129,24 @@
  #define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l))
  #define SMC_outsb(a, r, p, l)writesb((a) + (r), p, (l))
  
 +#elifdefined(CONFIG_MACH_LOGICPD_PXA270)
 +
 +#define SMC_CAN_USE_8BIT 0
 +#define SMC_CAN_USE_16BIT1
 +#define SMC_CAN_USE_32BIT0
 +#define SMC_IO_SHIFT 0
 +#define SMC_NOWAIT   1
 +#define SMC_USE_PXA_DMA  1
 +
 +#define SMC_inb(a, r)readb((a) + (r))
 +#define SMC_inw(a, r)readw((a) + (r))
 +#define SMC_inl(a, r)readl((a) + (r))
 +#define SMC_outb(v, a, r)writeb(v, (a) + (r))
 +#define SMC_outw(v, a, r)writew(v, (a) + (r))
 +#define SMC_outl(v, a, r)writel(v, (a) + (r))
 +#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
 +#define SMC_outsw(a, r, p, l)writesw((a) + (r), p, l)
 +
  #elifdefined(CONFIG_ARCH_INNOKOM) || \
   defined(CONFIG_MACH_MAINSTONE) || \
   defined(CONFIG_ARCH_PXA_IDP) || \
 


Nicolas
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] smc91x: allow for dynamic bus access configs

2006-01-09 Thread Nicolas Pitre
On Mon, 9 Jan 2006, Jeff Garzik wrote:

 Nicolas Pitre wrote:
  All accessor's different methods are now selected with C code and unused
  ones statically optimized away at compile time instead of being selected
  with #if's and #ifdef's.  This has many advantages such as allowing the
  compiler to validate the syntax of the whole code, making it cleaner and
  easier to understand, and ultimately allowing people to define configuration
  symbols in terms of variables if they really want to dynamically support
  multiple bus configurations at the same time (with the unavoidable
  performance cost).
  
  Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]
 
 OK, but patch doesn't apply:
 
 
 Applying 'smc91x: allow for dynamic bus access configs'
 
 error: patch failed: drivers/net/smc91x.h:342
 error: drivers/net/smc91x.h: patch does not apply

Gah...  Resynched patch follows.


Nicolas
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] smc91x: allow for dynamic bus access configs

2006-01-09 Thread Nicolas Pitre
All accessor's different methods are now selected with C code and unused 
ones statically optimized away at compile time instead of being selected 
with #if's and #ifdef's.  This has many advantages such as allowing the 
compiler to validate the syntax of the whole code, making it cleaner and 
easier to understand, and ultimately allowing people to define 
configuration symbols in terms of variables if they really want to 
dynamically support multiple bus configurations at the same time (with 
the unavoidable performance cost).

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

---

Index: linux-2.6/drivers/net/smc91x.c
===
--- linux-2.6.orig/drivers/net/smc91x.c
+++ linux-2.6/drivers/net/smc91x.c
@@ -215,15 +215,12 @@ struct smc_local {
 
spinlock_t lock;
 
-#ifdef SMC_CAN_USE_DATACS
-   u32 __iomem *datacs;
-#endif
-
 #ifdef SMC_USE_PXA_DMA
/* DMA needs the physical address of the chip */
u_long physaddr;
 #endif
void __iomem *base;
+   void __iomem *datacs;
 };
 
 #if SMC_DEBUG  0
@@ -2104,9 +2101,8 @@ static int smc_enable_device(struct plat
 * Set the appropriate byte/word mode.
 */
ecsr = readb(addr + (ECSR  SMC_IO_SHIFT))  ~ECSR_IOIS8;
-#ifndef SMC_CAN_USE_16BIT
-   ecsr |= ECSR_IOIS8;
-#endif
+   if (SMC_CAN_USE_16BIT)
+   ecsr |= ECSR_IOIS8;
writeb(ecsr, addr + (ECSR  SMC_IO_SHIFT));
local_irq_restore(flags);
 
@@ -2143,40 +2139,39 @@ static void smc_release_attrib(struct pl
release_mem_region(res-start, ATTRIB_SIZE);
 }
 
-#ifdef SMC_CAN_USE_DATACS
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev)
+static inline void smc_request_datacs(struct platform_device *pdev, struct 
net_device *ndev)
 {
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
-   struct smc_local *lp = netdev_priv(ndev);
+   if (SMC_CAN_USE_DATACS) {
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   struct smc_local *lp = netdev_priv(ndev);
 
-   if (!res)
-   return;
+   if (!res)
+   return;
 
-   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
-   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
-   return;
-   }
+   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
+   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
+   return;
+   }
 
-   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   }
 }
 
 static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev)
 {
-   struct smc_local *lp = netdev_priv(ndev);
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   if (SMC_CAN_USE_DATACS) {
+   struct smc_local *lp = netdev_priv(ndev);
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
 
-   if (lp-datacs)
-   iounmap(lp-datacs);
+   if (lp-datacs)
+   iounmap(lp-datacs);
 
-   lp-datacs = NULL;
+   lp-datacs = NULL;
 
-   if (res)
-   release_mem_region(res-start, SMC_DATA_EXTENT);
+   if (res)
+   release_mem_region(res-start, SMC_DATA_EXTENT);
+   }
 }
-#else
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-#endif
 
 /*
  * smc_init(void)
Index: linux-2.6/drivers/net/smc91x.h
===
--- linux-2.6.orig/drivers/net/smc91x.h
+++ linux-2.6/drivers/net/smc91x.h
@@ -275,7 +275,10 @@ SMC_outw(u16 val, void __iomem *ioaddr, 
 #define SMC_insw(a,r,p,l)  readsw ((void*) ((a) + (r)), p, l)
 #define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); 
LPD7A40X_IOBARRIER; })
 
-static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
+#define SMC_outsw  LPD7A40X_SMC_outsw
+
+static inline void LPD7A40X_SMC_outsw(unsigned long a, int r,
+unsigned char* p, int l)
 {
unsigned short* ps = (unsigned short*) p;
while (l--  0) {
@@ -342,10 +345,6 @@ static inline void SMC_outsw (unsigned l
 
 #endif
 
-#ifndefSMC_IRQ_FLAGS
-#defineSMC_IRQ_FLAGS   SA_TRIGGER_RISING
-#endif
-
 #ifdef SMC_USE_PXA_DMA
 /*
  * Let's use the DMA engine on the XScale PXA2xx for RX packets. This is
@@ -441,10 +440,85 @@ smc_pxa_dma_irq(int dma, void *dummy

[PATCH] smc91x: allow for dynamic bus access configs

2006-01-08 Thread Nicolas Pitre
All accessor's different methods are now selected with C code and unused 
ones statically optimized away at compile time instead of being selected 
with #if's and #ifdef's.  This has many advantages such as allowing the 
compiler to validate the syntax of the whole code, making it cleaner and 
easier to understand, and ultimately allowing people to define 
configuration symbols in terms of variables if they really want to 
dynamically support multiple bus configurations at the same time (with 
the unavoidable performance cost).

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

---

Index: linux-2.6/drivers/net/smc91x.c
===
--- linux-2.6.orig/drivers/net/smc91x.c
+++ linux-2.6/drivers/net/smc91x.c
@@ -216,15 +216,12 @@ struct smc_local {
 
spinlock_t lock;
 
-#ifdef SMC_CAN_USE_DATACS
-   u32 __iomem *datacs;
-#endif
-
 #ifdef SMC_USE_PXA_DMA
/* DMA needs the physical address of the chip */
u_long physaddr;
 #endif
void __iomem *base;
+   void __iomem *datacs;
 };
 
 #if SMC_DEBUG  0
@@ -2107,9 +2104,8 @@ static int smc_enable_device(struct plat
 * Set the appropriate byte/word mode.
 */
ecsr = readb(addr + (ECSR  SMC_IO_SHIFT))  ~ECSR_IOIS8;
-#ifndef SMC_CAN_USE_16BIT
-   ecsr |= ECSR_IOIS8;
-#endif
+   if (SMC_CAN_USE_16BIT)
+   ecsr |= ECSR_IOIS8;
writeb(ecsr, addr + (ECSR  SMC_IO_SHIFT));
local_irq_restore(flags);
 
@@ -2146,40 +2142,39 @@ static void smc_release_attrib(struct pl
release_mem_region(res-start, ATTRIB_SIZE);
 }
 
-#ifdef SMC_CAN_USE_DATACS
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev)
+static inline void smc_request_datacs(struct platform_device *pdev, struct 
net_device *ndev)
 {
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
-   struct smc_local *lp = netdev_priv(ndev);
+   if (SMC_CAN_USE_DATACS) {
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   struct smc_local *lp = netdev_priv(ndev);
 
-   if (!res)
-   return;
+   if (!res)
+   return;
 
-   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
-   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
-   return;
-   }
+   if(!request_mem_region(res-start, SMC_DATA_EXTENT, CARDNAME)) {
+   printk(KERN_INFO %s: failed to request datacs memory 
region.\n, CARDNAME);
+   return;
+   }
 
-   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   lp-datacs = ioremap(res-start, SMC_DATA_EXTENT);
+   }
 }
 
 static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev)
 {
-   struct smc_local *lp = netdev_priv(ndev);
-   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
+   if (SMC_CAN_USE_DATACS) {
+   struct smc_local *lp = netdev_priv(ndev);
+   struct resource * res = platform_get_resource_byname(pdev, 
IORESOURCE_MEM, smc91x-data32);
 
-   if (lp-datacs)
-   iounmap(lp-datacs);
+   if (lp-datacs)
+   iounmap(lp-datacs);
 
-   lp-datacs = NULL;
+   lp-datacs = NULL;
 
-   if (res)
-   release_mem_region(res-start, SMC_DATA_EXTENT);
+   if (res)
+   release_mem_region(res-start, SMC_DATA_EXTENT);
+   }
 }
-#else
-static void smc_request_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-static void smc_release_datacs(struct platform_device *pdev, struct net_device 
*ndev) {}
-#endif
 
 /*
  * smc_init(void)
Index: linux-2.6/drivers/net/smc91x.h
===
--- linux-2.6.orig/drivers/net/smc91x.h
+++ linux-2.6/drivers/net/smc91x.h
@@ -275,7 +275,10 @@ SMC_outw(u16 val, void __iomem *ioaddr, 
 #define SMC_insw(a,r,p,l)  readsw ((void*) ((a) + (r)), p, l)
 #define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); 
LPD7A40X_IOBARRIER; })
 
-static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
+#define SMC_outsw  LPD7A40X_SMC_outsw
+
+static inline void LPD7A40X_SMC_outsw(unsigned long a, int r,
+unsigned char* p, int l)
 {
unsigned short* ps = (unsigned short*) p;
while (l--  0) {
@@ -342,10 +345,6 @@ static inline void SMC_outsw (unsigned l
 
 #endif
 
-#ifndefSMC_IRQ_TRIGGER_TYPE
-#defineSMC_IRQ_TRIGGER_TYPEIRQT_RISING
-#endif
-
 #ifdef SMC_USE_PXA_DMA
 /*
  * Let's use the DMA engine on the XScale PXA2xx for RX packets. This is
@@ -441,10 +440,85 @@ smc_pxa_dma_irq(int dma, void *dummy

[PATCH] smc91x: fix one source of spurious interrupts

2005-11-17 Thread Nicolas Pitre

Not only SMC_ACK_INT(IM_TX_EMPTY_INT) in in smc_hardware_send_pkt) 
appears to be unnecessary (tested with an SMC91C94 and SMC91C111), but 
it seems to trigger spurious interrupts on some machines as well.  
Removed.

While at it, let's log any remaining spurious interrupts if any (and 
clean usage of the max IRQ loop count value).

Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index c91e2e8..1021108 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -155,6 +155,12 @@ MODULE_LICENSE(GPL);
 #define MEMORY_WAIT_TIME   16
 
 /*
+ * The maximum number of processing loops allowed for each call to the
+ * IRQ handler.  
+ */
+#define MAX_IRQ_LOOPS  8
+
+/*
  * This selects whether TX packets are sent one by one to the SMC91x internal
  * memory and throttled until transmission completes.  This may prevent
  * RX overruns a litle by keeping much of the memory free for RX packets
@@ -684,7 +690,6 @@ static void smc_hardware_send_pkt(unsign
 
/* queue the packet for TX */
SMC_SET_MMU_CMD(MC_ENQUEUE);
-   SMC_ACK_INT(IM_TX_EMPTY_INT);
smc_special_unlock(lp-lock);
 
dev-trans_start = jiffies;
@@ -1305,7 +1310,7 @@ static irqreturn_t smc_interrupt(int irq
SMC_SET_INT_MASK(0);
 
/* set a timeout value, so I don't stay here forever */
-   timeout = 8;
+   timeout = MAX_IRQ_LOOPS;
 
do {
status = SMC_GET_INT();
@@ -1372,10 +1377,13 @@ static irqreturn_t smc_interrupt(int irq
/* restore register states */
SMC_SET_PTR(saved_pointer);
SMC_SET_INT_MASK(mask);
-
spin_unlock(lp-lock);
 
-   DBG(3, %s: Interrupt done (%d loops)\n, dev-name, 8-timeout);
+   if (timeout == MAX_IRQ_LOOPS)
+   PRINTK(%s: spurious interrupt (mask = 0x%02x)\n,
+  dev-name, mask);
+   DBG(3, %s: Interrupt done (%d loops)\n,
+  dev-name, MAX_IRQ_LOOPS - timeout);
 
/*
 * We return IRQ_HANDLED unconditionally here even if there was
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html