Re: [PATCH v4 3/5] pinctrl: add mt2712 pinctrl driver

2018-03-23 Thread Sean Wang
Hi, Zhiyong

I got a warning when I applied the patch.

Applying: pinctrl: add mt2712 pinctrl driver
.git/rebase-apply/patch:679: new blank line at EOF.
+
warning: 1 line adds whitespace errors.

It should probably happen at the last line in pinctrl-2712.c

Apart from that 

Reviewed-by: Sean Wang 


On Thu, 2018-03-22 at 10:58 +0800, Zhiyong Tao wrote:
> The commit includes mt2712 pinctrl driver.
> 
> Signed-off-by: Zhiyong Tao 
> ---
>  drivers/pinctrl/mediatek/Kconfig  |7 +
>  drivers/pinctrl/mediatek/Makefile |1 +
>  drivers/pinctrl/mediatek/pinctrl-mt2712.c |  634 +
>  drivers/pinctrl/mediatek/pinctrl-mtk-mt2712.h | 1757 
> +
>  4 files changed, 2399 insertions(+)
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt2712.c
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt2712.h
> 
> diff --git a/drivers/pinctrl/mediatek/Kconfig 
> b/drivers/pinctrl/mediatek/Kconfig
> index 3e59874..862c5db 100644
> --- a/drivers/pinctrl/mediatek/Kconfig
> +++ b/drivers/pinctrl/mediatek/Kconfig
> @@ -32,6 +32,13 @@ config PINCTRL_MT8127
>   select PINCTRL_MTK
>  
>  # For ARMv8 SoCs
> +config PINCTRL_MT2712
> + bool "MediaTek MT2712 pin control"
> + depends on OF
> + depends on ARM64 || COMPILE_TEST
> + default ARM64 && ARCH_MEDIATEK
> + select PINCTRL_MTK
> +
>  config PINCTRL_MT7622
>   bool "MediaTek MT7622 pin control"
>   depends on OF
> diff --git a/drivers/pinctrl/mediatek/Makefile 
> b/drivers/pinctrl/mediatek/Makefile
> index ed7d2b2..7959e77 100644
> --- a/drivers/pinctrl/mediatek/Makefile
> +++ b/drivers/pinctrl/mediatek/Makefile
> @@ -4,6 +4,7 @@ obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o
>  
>  # SoC Drivers
>  obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o
> +obj-$(CONFIG_PINCTRL_MT2712) += pinctrl-mt2712.o
>  obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o
>  obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o
>  obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2712.c 
> b/drivers/pinctrl/mediatek/pinctrl-mt2712.c
> new file mode 100644
> index 000..d14511f
> --- /dev/null
> +++ b/drivers/pinctrl/mediatek/pinctrl-mt2712.c
> @@ -0,0 +1,634 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2018 MediaTek Inc.
> + * Author: Zhiyong Tao 
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "pinctrl-mtk-common.h"
> +#include "pinctrl-mtk-mt2712.h"
> +
> +static const struct mtk_pin_spec_pupd_set_samereg mt2712_spec_pupd[] = {
> + MTK_PIN_PUPD_SPEC_SR(18, 0xe50, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(19, 0xe60, 12, 11, 10),
> + MTK_PIN_PUPD_SPEC_SR(20, 0xe50, 5, 4, 3),
> + MTK_PIN_PUPD_SPEC_SR(21, 0xe60, 15, 14, 13),
> + MTK_PIN_PUPD_SPEC_SR(22, 0xe50, 8, 7, 6),
> + MTK_PIN_PUPD_SPEC_SR(23, 0xe70, 2, 1, 0),
> +
> + MTK_PIN_PUPD_SPEC_SR(30, 0xf30, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(31, 0xf30, 6, 5, 4),
> + MTK_PIN_PUPD_SPEC_SR(32, 0xf30, 10, 9, 8),
> + MTK_PIN_PUPD_SPEC_SR(33, 0xf30, 14, 13, 12),
> + MTK_PIN_PUPD_SPEC_SR(34, 0xf40, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(35, 0xf40, 6, 5, 4),
> + MTK_PIN_PUPD_SPEC_SR(36, 0xf40, 10, 9, 8),
> + MTK_PIN_PUPD_SPEC_SR(37, 0xc40, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(38, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(39, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(40, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(41, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(42, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(43, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(44, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(45, 0xc60, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(46, 0xc50, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(47, 0xda0, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(48, 0xd90, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(49, 0xdf0, 14, 13, 12),
> + MTK_PIN_PUPD_SPEC_SR(50, 0xdf0, 10, 9, 8),
> + MTK_PIN_PUPD_SPEC_SR(51, 0xdf0, 6, 5, 4),
> + MTK_PIN_PUPD_SPEC_SR(52, 0xdf0, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(53, 0xd50, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(54, 0xd80, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(55, 0xe00, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(56, 0xd40, 2, 1, 0),
> +
> + MTK_PIN_PUPD_SPEC_SR(63, 0xc80, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(64, 0xdb0, 14, 13, 12),
> + MTK_PIN_PUPD_SPEC_SR(65, 0xdb0, 6, 5, 4),
> + MTK_PIN_PUPD_SPEC_SR(66, 0xdb0, 10, 9, 8),
> + MTK_PIN_PUPD_SPEC_SR(67, 0xcd0, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(68, 0xdb0, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(69, 0xc90, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(70, 0xcc0, 2, 1, 0),
> +
> + MTK_PIN_PUPD_SPEC_SR(89, 0xce0, 2, 1, 0),
> + MTK_PIN_PUPD_SPEC_SR(90, 0xdd0, 14, 13, 12),
> + MTK_PIN_PUPD_SPEC_SR(91, 0xdd0, 10, 9, 8),
> + MTK_PIN_PUPD_SPEC_SR(92, 0xdd0, 6, 5, 4),
> + MTK_PIN_PUPD_SPEC_SR(93, 0xdd0, 2, 1, 0),
> + MTK_PIN_P

Re: Problem with commit 31e77c93e432 "sched/fair: Update blocked load when newly idle"

2018-03-23 Thread Vincent Guittot
Hi Heiner,

Le Friday 23 Mar 2018 à 22:28:09 (+0100), Heiner Kallweit a écrit :
> Recently I started to get the following problems with linux-next:
> 
> - When working via Putty/SSH on the system the console frequently freezes
>   for few seconds. Sometimes only opening a second console makes the
>   first one react again.
> 
> - I get "INFO: rcu_sched detected stalls on CPUs/tasks:" warnings as
>   described in [1].
> 
> Bisecting the issue resulted in:
> 
> 31e77c93e432dec79c7d90b888bbfc3652592741 is the first bad commit
> commit 31e77c93e432dec79c7d90b888bbfc3652592741
> Author: Vincent Guittot 
> Date:   Wed Feb 14 16:26:46 2018 +0100
> 
> sched/fair: Update blocked load when newly idle
> 
> When NEWLY_IDLE load balance is not triggered, we might need to update the
> blocked load anyway. We can kick an ilb so an idle CPU will take care of
> updating blocked load or we can try to update them locally before entering
> idle. In the latter case, we reuse part of the nohz_idle_balance.
>
> After reversing this commit at least the issue with the freezing console
> is gone. The second one appeared only sporadically, I still have to see
> whether it pops up again.
>

Can you check if the change below fix the problem ? 

---
 kernel/sched/fair.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 3582117..672f212 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9430,6 +9430,9 @@ static bool _nohz_idle_balance(struct rq *this_rq, 
unsigned int flags,
 
has_blocked_load |= update_nohz_stats(rq, true);
 
+   if (flags == NOHZ_STATS_KICK)
+   continue;
+
/*
 * If time for next balance is due,
 * do the balance.
-- 

> System is a Zotac CI321 mini PC with Intel Celeron 2961Y CPU.
> If you need more details, please let me know.
> 
> Regards, Heiner
> 
> [1] https://lkml.org/lkml/2018/3/22/605


[PATCH 2/2] staging: ks7010: Fix spelling mistakes.

2018-03-23 Thread Quytelda Kahja
Fix two spelling mistakes in comments.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.h | 2 +-
 drivers/staging/ks7010/ks_wlan.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 7f6647f3b337..f42a5921528f 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -59,7 +59,7 @@
 
 /*
  * HOST-MAC I/F data structure
- * Byte alignmet Little Endian
+ * Byte alignment Little Endian
  */
 
 struct hostif_hdr {
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index c94a88028710..a76c5bef5605 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -54,7 +54,7 @@ struct ks_wlan_parameter {
 #define BEACON_LOST_COUNT_MAX 65535
u32 beacon_lost_count;  /*  Beacon Lost Count */
u32 rts;/*  RTS Threashold */
-   u32 fragment;   /*  Fragmentation Threashold */
+   u32 fragment;   /*  Fragmentation Threshold */
u32 privacy_invoked;
u32 wep_index;
struct {
-- 
2.16.2



[PATCH 1/2] staging: ks7010: Remove trailing "_t" from all structure names.

2018-03-23 Thread Quytelda Kahja
The "_t" suffix is not needed for structure names in this driver,
and is a reflection of an older typedef system that is no longer
in place.  Remove the "_t" suffix from every structure defined in this
driver.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c |   2 +-
 drivers/staging/ks7010/ks_hostif.c   |  80 ++--
 drivers/staging/ks7010/ks_hostif.h   | 142 +--
 drivers/staging/ks7010/ks_wlan.h |  66 
 drivers/staging/ks7010/ks_wlan_net.c |  12 +--
 drivers/staging/ks7010/michael_mic.c |   8 +-
 drivers/staging/ks7010/michael_mic.h |   4 +-
 7 files changed, 157 insertions(+), 157 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a11ee1c..d083bf8d238e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -950,7 +950,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 /* send stop request to MAC */
 static int send_stop_request(struct sdio_func *func)
 {
-   struct hostif_stop_request_t *pp;
+   struct hostif_stop_request *pp;
struct ks_sdio_card *card;
size_t size;
 
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 143413c3cae2..d558fdf48e28 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -110,16 +110,16 @@ int ks_wlan_do_power_save(struct ks_wlan_private *priv)
 }
 
 static
-int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t 
*ap_info)
+int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info)
 {
-   struct local_ap_t *ap;
+   struct local_ap *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
 
ap = &priv->current_ap;
 
if (is_disconnect_status(priv->connect_status)) {
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
return -EPERM;
}
 
@@ -226,13 +226,13 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
 
 
 static
-int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
-  struct local_ap_t *ap)
+int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
+  struct local_ap *ap)
 {
unsigned char *bp;
int bsize, offset;
 
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
 
/* bssid */
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
@@ -317,11 +317,11 @@ int hostif_data_indication_wpa(struct ks_wlan_private 
*priv,
unsigned char recv_mic[8];
char buf[128];
unsigned long now;
-   struct mic_failure_t *mic_failure;
-   struct michael_mic_t michael_mic;
+   struct mic_failure *mic_failure;
+   struct michael_mic michael_mic;
union iwreq_data wrqu;
unsigned int key_index = auth_type - 1;
-   struct wpa_key_t *key = &priv->wpa.key[key_index];
+   struct wpa_key *key = &priv->wpa.key[key_index];
 
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
@@ -748,7 +748,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
break;
}
 
-   get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
+   get_current_ap(priv, (struct link_ap_info *)priv->rxp);
if (is_connect_status(priv->connect_status) &&
is_disconnect_status(old_status)) {
/* for power save */
@@ -774,10 +774,10 @@ static
 void hostif_scan_indication(struct ks_wlan_private *priv)
 {
int i;
-   struct ap_info_t *ap_info;
+   struct ap_info *ap_info;
 
netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", 
priv->scan_ind_count);
-   ap_info = (struct ap_info_t *)(priv->rxp);
+   ap_info = (struct ap_info *)(priv->rxp);
 
if (priv->scan_ind_count) {
/* bssid check */
@@ -797,7 +797,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: 
aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
-   get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
+   get_ap_information(priv, (struct ap_info *)(priv->rxp),
   &(priv->aplist.ap[priv->scan_ind_count - 
1]));
priv->aplist.size = priv->scan_ind_count;
} else {
@@ -866,8 +866,8 @@ void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
 static
 void hostif_associate_indication(struct ks_wlan_private *priv)
 {
-   struct association_request_t *assoc_req;
-   struct association_response_t *assoc_resp;
+   struct association_request *assoc_req;
+   struct as

Re: [PATCH v4 7/8] clocksource: Add a new timer-ingenic driver

2018-03-23 Thread Daniel Lezcano
On 18/03/2018 00:29, Paul Cercueil wrote:
> This driver will use the TCU (Timer Counter Unit) present on the Ingenic
> JZ47xx SoCs to provide the kernel with a clocksource and timers.

Please provide a more detailed description about the timer.

Where is the clocksource ?

I don't see the point of using channel idx and pwm checking here.

There is one clockevent, why create multiple channels ? Can't you stick
to the usual init routine for a timer.

> Signed-off-by: Paul Cercueil 
> ---
>  drivers/clocksource/Kconfig |   8 ++
>  drivers/clocksource/Makefile|   1 +
>  drivers/clocksource/timer-ingenic.c | 278 
> 
>  3 files changed, 287 insertions(+)
>  create mode 100644 drivers/clocksource/timer-ingenic.c
> 
>  v2: Use SPDX identifier for the license
>  v3: - Move documentation to its own patch
>  - Search the devicetree for PWM clients, and use all the TCU
>  channels that won't be used for PWM
>  v4: - Add documentation about why we search for PWM clients
>  - Verify that the PWM clients are for the TCU PWM driver
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index d2e5382821a4..481422145fb4 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -592,4 +592,12 @@ config CLKSRC_ST_LPC
> Enable this option to use the Low Power controller timer
> as clocksource.
>  
> +config INGENIC_TIMER
> + bool "Clocksource/timer using the TCU in Ingenic JZ SoCs"
> + depends on MACH_INGENIC || COMPILE_TEST

bool "Clocksource/timer using the TCU in Ingenic JZ SoCs" if COMPILE_TEST

Remove the depends MACH_INGENIC.

> + select CLKSRC_OF
> + default y

No default, Kconfig platform selects the timer.

> + help
> +   Support for the timer/counter unit of the Ingenic JZ SoCs.
> +
>  endmenu
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index d6dec4489d66..98691e8999fe 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -74,5 +74,6 @@ obj-$(CONFIG_ASM9260_TIMER) += asm9260_timer.o
>  obj-$(CONFIG_H8300_TMR8) += h8300_timer8.o
>  obj-$(CONFIG_H8300_TMR16)+= h8300_timer16.o
>  obj-$(CONFIG_H8300_TPU)  += h8300_tpu.o
> +obj-$(CONFIG_INGENIC_TIMER)  += timer-ingenic.o
>  obj-$(CONFIG_CLKSRC_ST_LPC)  += clksrc_st_lpc.o
>  obj-$(CONFIG_X86_NUMACHIP)   += numachip.o
> diff --git a/drivers/clocksource/timer-ingenic.c 
> b/drivers/clocksource/timer-ingenic.c
> new file mode 100644
> index ..8c777c0c0023
> --- /dev/null
> +++ b/drivers/clocksource/timer-ingenic.c
> @@ -0,0 +1,278 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Ingenic JZ47xx SoC TCU clocksource driver
> + * Copyright (C) 2018 Paul Cercueil 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define NUM_CHANNELS 8
> +
> +struct ingenic_tcu;
> +
> +struct ingenic_tcu_channel {
> + unsigned int idx;
> + struct clk *clk;
> +};
> +
> +struct ingenic_tcu {
> + struct ingenic_tcu_channel channels[NUM_CHANNELS];
> + unsigned long requested;
> + struct regmap *map;
> +};
> +
> +struct ingenic_clock_event_device {
> + struct clock_event_device cevt;
> + struct ingenic_tcu_channel *channel;
> + char name[32];
> +};
> +
> +#define ingenic_cevt(_evt) \
> + container_of(_evt, struct ingenic_clock_event_device, cevt)
> +
> +static inline struct ingenic_tcu *to_ingenic_tcu(struct ingenic_tcu_channel 
> *ch)
> +{
> + return container_of(ch, struct ingenic_tcu, channels[ch->idx]);
> +}
> +
> +static int ingenic_tcu_cevt_set_state_shutdown(struct clock_event_device 
> *evt)
> +{
> + struct ingenic_clock_event_device *jzcevt = ingenic_cevt(evt);
> + struct ingenic_tcu_channel *channel = jzcevt->channel;
> + struct ingenic_tcu *tcu = to_ingenic_tcu(channel);
> + unsigned int idx = channel->idx;
> +
> + regmap_write(tcu->map, TCU_REG_TECR, BIT(idx));
> + return 0;
> +}
> +
> +static int ingenic_tcu_cevt_set_next(unsigned long next,
> + struct clock_event_device *evt)
> +{
> + struct ingenic_clock_event_device *jzcevt = ingenic_cevt(evt);
> + struct ingenic_tcu_channel *channel = jzcevt->channel;
> + struct ingenic_tcu *tcu = to_ingenic_tcu(channel);
> + unsigned int idx = channel->idx;
> +
> + if (next > 0x)
> + return -EINVAL;
> +
> + regmap_write(tcu->map, TCU_REG_TDFRc(idx), (unsigned int) next);
> + regmap_write(tcu->map, TCU_REG_TCNTc(idx), 0);
> + regmap_write(tcu->map, TCU_REG_TESR, BIT(idx));
> +
> + return 0;
> +}
> +
> +static irqreturn_t ingenic_tcu_cevt_cb(int irq, void *dev_id)
> +{
> + struct clock_event_device *cevt = dev_id;
> + struct ingenic_clock_event_device *jzcevt = ingenic_cevt(cevt);
> + struct ingeni

Re: [PATCH v5 00/13] ARM: dts: ipq: updates to enable a few peripherals

2018-03-23 Thread sricharan

On 2018-03-24 07:47, Richard Cochran wrote:

On Fri, Mar 23, 2018 at 03:48:43PM +0530, Sricharan R wrote:

[v5]
* Fixed a minor comment that i missed earlier.


I tried booting this series with qcom_defconfig on my custom,
dk07-like board.  It works!


 Thanks.
 Can i take that as a Tested-by: Richard Cochran 


 on DK07 ?

Regards,
 Sricharan


Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up

2018-03-23 Thread Joel Fernandes


On March 23, 2018 6:34:22 PM PDT, Quentin Perret  wrote:
>On Friday 23 Mar 2018 at 18:13:56 (-0700), Joel Fernandes wrote:
>> Hi Morten,
>> 
>> On Fri, Mar 23, 2018 at 8:47 AM, Morten Rasmussen
>>  wrote:
>> > On Thu, Mar 22, 2018 at 01:10:22PM -0700, Joel Fernandes wrote:
>
>[...]
>
>> > You mean if SD_BALANCE_WAKE isn't set on sched_domains?
>> 
>> Yes.
>> 
>> > The current code seems to rely on that flag to be set to work
>correctly.
>> > Otherwise, the loop might bail out on !want_affine and we end up
>doing
>> > the find_energy_efficient_cpu() on the lowest level sched_domain
>even if
>> > there is higher level one which isn't over-utilized.
>> >
>> > However, SD_BALANCE_WAKE should be set if SD_ASYM_CPUCAPACITY is
>set so
>> > sd == NULL shouldn't be possible? This only holds as long as we
>only
>> > want EAS for asymmetric systems.
>> 
>> Yes, I see you had topology code that set SD_BALANCE_WAKE for ASYM.
>It
>> makes sense to me then, thanks for the clarification.
>> 
>> Still I feel it is a bit tedious/confusing when reading code to draw
>> the conclusion about why sd is checked first before doing
>> find_energy_efficient_cpu (and that sd will != NULL for ASYM
>systems).
>> If energy_sd is set, then we can just proceed with EAS without
>> checking that sd != NULL. This function in mainline is already pretty
>> confusing as it is :-(
>
>Right I see your point. The code is correct as is, but I agree that
>having
>a code structured as
>
>   if (energy_sd) {
>   new_cpu = find_energy_efficient_cpu(energy_sd, p, prev_cpu);
>   } else if (!sd) {
>   ...
>
>might be easier to understand and functionally equivalent. What do you
>think ?

Yeah definitely. Go for it.

- Joel


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: [PATCH 3/3] Storvsc: Select channel based on available percentage of ring buffer to write

2018-03-23 Thread kbuild test robot
Hi Long,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v4.16-rc6]
[cannot apply to linus/master net-next/master net/master next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Long-Li/Vmbus-Add-function-to-report-available-ring-buffer-to-write-in-total-ring-size-percentage/20180324-124431
config: x86_64-rhel (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers//scsi/storvsc_drv.c: In function 'storvsc_do_io':
>> drivers//scsi/storvsc_drv.c:1402:1: warning: the frame size of 2064 bytes is 
>> larger than 2048 bytes [-Wframe-larger-than=]
}
^

vim +1402 drivers//scsi/storvsc_drv.c

d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1287  
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1288  
c1b3d067 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1289  
static int storvsc_do_io(struct hv_device *device,
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1290 
 struct storvsc_cmd_request *request, u16 q_num)
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1291  {
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1292 
struct storvsc_device *stor_device;
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1293 
struct vstor_packet *vstor_packet;
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1294 
struct vmbus_channel *outgoing_channel, *channel;
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1295 
int ret = 0;
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1296 
struct cpumask alloced_mask, other_numa_mask;
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1297 
int tgt_cpu;
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1298  
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1299 
vstor_packet = &request->vstor_packet;
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1300 
stor_device = get_out_stor_device(device);
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1301  
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1302 
if (!stor_device)
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1303 
return -ENODEV;
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1304  
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1305  
8dcf37d4 drivers/staging/hv/storvsc_drv.c K. Y. Srinivasan 2011-08-27  1306 
request->device  = device;
6f94d5de drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2013-06-04  1307 
/*
6f94d5de drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2013-06-04  1308 
 * Select an an appropriate channel to send the request out.
6f94d5de drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2013-06-04  1309 
 */
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1310 
if (stor_device->stor_chns[q_num] != NULL) {
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1311 
outgoing_channel = stor_device->stor_chns[q_num];
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1312 
if (outgoing_channel->target_cpu == q_num) {
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1313 
/*
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1314 
 * Ideally, we want to pick a different channel if
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1315 
 * available on the same NUMA node.
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1316 
 */
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1317 
cpumask_and(&alloced_mask, &stor_device->alloced_cpus,
d86adf48 drivers/scsi/storvsc_drv.c   K. Y. Srinivasan 2016-12-14  1318 
cpumask_of_node(cpu_to_node(q_num)));
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1319  
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1320 
for_each_cpu_wrap(tgt_cpu, &alloced_mask, q_num + 1) {
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1321 
if (tgt_cpu == q_num)
e75adf20 drivers/scsi/storvsc_drv.c   Long Li  2018-03-22  1322 
continue;
e75adf2

[REVIEW][PATCH 13/11] ipc/smack: Tidy up from the change in type of the ipc security hooks

2018-03-23 Thread Eric W. Biederman

Rename the variables shp, sma, msq to isp. As that is how the code already
refers to those variables.

Collapse smack_of_shm, smack_of_sem, and smack_of_msq into smack_of_ipc,
as the three functions had become completely identical.

Collapse smack_shm_alloc_security, smack_sem_alloc_security and
smack_msg_queue_alloc_security into smack_ipc_alloc_security as the
three functions had become identical.

Collapse smack_shm_free_security, smack_sem_free_security and
smack_msg_queue_free_security into smack_ipc_free_security as the three
functions had become identical.

Requested-by: Casey Schaufler 
Signed-off-by: "Eric W. Biederman" 
---
 security/smack/smack_lsm.c | 197 +
 1 file changed, 58 insertions(+), 139 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index d960c2ea8d79..0735b8db158b 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -2945,25 +2945,24 @@ static void smack_msg_msg_free_security(struct msg_msg 
*msg)
 }
 
 /**
- * smack_of_shm - the smack pointer for the shm
- * @shp: the object
+ * smack_of_ipc - the smack pointer for the ipc
+ * @isp: the object
  *
  * Returns a pointer to the smack value
  */
-static struct smack_known *smack_of_shm(struct kern_ipc_perm *shp)
+static struct smack_known *smack_of_ipc(struct kern_ipc_perm *isp)
 {
-   return (struct smack_known *)shp->security;
+   return (struct smack_known *)isp->security;
 }
 
 /**
- * smack_shm_alloc_security - Set the security blob for shm
- * @shp: the object
+ * smack_ipc_alloc_security - Set the security blob for ipc
+ * @isp: the object
  *
  * Returns 0
  */
-static int smack_shm_alloc_security(struct kern_ipc_perm *shp)
+static int smack_ipc_alloc_security(struct kern_ipc_perm *isp)
 {
-   struct kern_ipc_perm *isp = shp;
struct smack_known *skp = smk_of_current();
 
isp->security = skp;
@@ -2971,34 +2970,32 @@ static int smack_shm_alloc_security(struct 
kern_ipc_perm *shp)
 }
 
 /**
- * smack_shm_free_security - Clear the security blob for shm
- * @shp: the object
+ * smack_ipc_free_security - Clear the security blob for ipc
+ * @isp: the object
  *
  * Clears the blob pointer
  */
-static void smack_shm_free_security(struct kern_ipc_perm *shp)
+static void smack_ipc_free_security(struct kern_ipc_perm *isp)
 {
-   struct kern_ipc_perm *isp = shp;
-
isp->security = NULL;
 }
 
 /**
  * smk_curacc_shm : check if current has access on shm
- * @shp : the object
+ * @isp : the object
  * @access : access requested
  *
  * Returns 0 if current has the requested access, error code otherwise
  */
-static int smk_curacc_shm(struct kern_ipc_perm *shp, int access)
+static int smk_curacc_shm(struct kern_ipc_perm *isp, int access)
 {
-   struct smack_known *ssp = smack_of_shm(shp);
+   struct smack_known *ssp = smack_of_ipc(isp);
struct smk_audit_info ad;
int rc;
 
 #ifdef CONFIG_AUDIT
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_IPC);
-   ad.a.u.ipc_id = shp->id;
+   ad.a.u.ipc_id = isp->id;
 #endif
rc = smk_curacc(ssp, access, &ad);
rc = smk_bu_current("shm", ssp, access, rc);
@@ -3007,27 +3004,27 @@ static int smk_curacc_shm(struct kern_ipc_perm *shp, 
int access)
 
 /**
  * smack_shm_associate - Smack access check for shm
- * @shp: the object
+ * @isp: the object
  * @shmflg: access requested
  *
  * Returns 0 if current has the requested access, error code otherwise
  */
-static int smack_shm_associate(struct kern_ipc_perm *shp, int shmflg)
+static int smack_shm_associate(struct kern_ipc_perm *isp, int shmflg)
 {
int may;
 
may = smack_flags_to_may(shmflg);
-   return smk_curacc_shm(shp, may);
+   return smk_curacc_shm(isp, may);
 }
 
 /**
  * smack_shm_shmctl - Smack access check for shm
- * @shp: the object
+ * @isp: the object
  * @cmd: what it wants to do
  *
  * Returns 0 if current has the requested access, error code otherwise
  */
-static int smack_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
+static int smack_shm_shmctl(struct kern_ipc_perm *isp, int cmd)
 {
int may;
 
@@ -3051,81 +3048,42 @@ static int smack_shm_shmctl(struct kern_ipc_perm *shp, 
int cmd)
default:
return -EINVAL;
}
-   return smk_curacc_shm(shp, may);
+   return smk_curacc_shm(isp, may);
 }
 
 /**
  * smack_shm_shmat - Smack access for shmat
- * @shp: the object
+ * @isp: the object
  * @shmaddr: unused
  * @shmflg: access requested
  *
  * Returns 0 if current has the requested access, error code otherwise
  */
-static int smack_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr,
+static int smack_shm_shmat(struct kern_ipc_perm *ipc, char __user *shmaddr,
   int shmflg)
 {
int may;
 
may = smack_flags_to_may(shmflg);
-   return smk_curacc_shm(shp, may);
-}
-
-/**
- * smack_of_sem - the smack pointer for the sem
- * @sma: the object
- *
- *

[REVIEW][PATCH 12/11] ipc: Directly call the security hook in ipc_ops.associate

2018-03-23 Thread Eric W. Biederman

After the last round of cleanups the shm, sem, and msg associate
operations just became trivial wrappers around the appropriate security
method.  Simplify things further by just calling the security method
directly.

Signed-off-by: "Eric W. Biederman" 
---
 ipc/msg.c | 10 +-
 ipc/sem.c | 10 +-
 ipc/shm.c | 10 +-
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index 825ad585a6ff..d667dd8e97ab 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -272,20 +272,12 @@ static void freeque(struct ipc_namespace *ns, struct 
kern_ipc_perm *ipcp)
ipc_rcu_putref(&msq->q_perm, msg_rcu_free);
 }
 
-/*
- * Called with msg_ids.rwsem and ipcp locked.
- */
-static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
-{
-   return security_msg_queue_associate(ipcp, msgflg);
-}
-
 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
 {
struct ipc_namespace *ns;
static const struct ipc_ops msg_ops = {
.getnew = newque,
-   .associate = msg_security,
+   .associate = security_msg_queue_associate,
};
struct ipc_params msg_params;
 
diff --git a/ipc/sem.c b/ipc/sem.c
index 47b263960524..09d54af076a4 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -564,14 +564,6 @@ static int newary(struct ipc_namespace *ns, struct 
ipc_params *params)
 }
 
 
-/*
- * Called with sem_ids.rwsem and ipcp locked.
- */
-static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg)
-{
-   return security_sem_associate(ipcp, semflg);
-}
-
 /*
  * Called with sem_ids.rwsem and ipcp locked.
  */
@@ -592,7 +584,7 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
struct ipc_namespace *ns;
static const struct ipc_ops sem_ops = {
.getnew = newary,
-   .associate = sem_security,
+   .associate = security_sem_associate,
.more_checks = sem_more_checks,
};
struct ipc_params sem_params;
diff --git a/ipc/shm.c b/ipc/shm.c
index 932b7e411c6c..018db3d0e70e 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -656,14 +656,6 @@ static int newseg(struct ipc_namespace *ns, struct 
ipc_params *params)
return error;
 }
 
-/*
- * Called with shm_ids.rwsem and ipcp locked.
- */
-static inline int shm_security(struct kern_ipc_perm *ipcp, int shmflg)
-{
-   return security_shm_associate(ipcp, shmflg);
-}
-
 /*
  * Called with shm_ids.rwsem and ipcp locked.
  */
@@ -684,7 +676,7 @@ SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, 
shmflg)
struct ipc_namespace *ns;
static const struct ipc_ops shm_ops = {
.getnew = newseg,
-   .associate = shm_security,
+   .associate = security_shm_associate,
.more_checks = shm_more_checks,
};
struct ipc_params shm_params;
-- 
2.14.1



Re: [REVIEW][PATCH 03/11] msg/security: Pass kern_ipc_perm not msg_queue into the msg_queue security hooks

2018-03-23 Thread Eric W. Biederman
Casey Schaufler  writes:

> On 3/23/2018 12:16 PM, Eric W. Biederman wrote:
>> All of the implementations of security hooks that take msg_queue only
>> access q_perm the struct kern_ipc_perm member.  This means the
>> dependencies of the msg_queue security hooks can be simplified by
>> passing the kern_ipc_perm member of msg_queue.
>>
>> Making this change will allow struct msg_queue to become private to
>> ipc/msg.c.
>>
>> Signed-off-by: "Eric W. Biederman" 
>> ---
>>  include/linux/lsm_hooks.h  | 12 ++--
>>  include/linux/security.h   | 25 -
>>  ipc/msg.c  | 18 --
>>  security/security.c| 12 ++--
>>  security/selinux/hooks.c   | 36 ++--
>>  security/smack/smack_lsm.c | 24 
>
> Can I reference the comments I made in PATCH 01 of this set
> regarding the Smack changes? The problem in all of your changes
> is the same. You aren't preserving the naming conventions, and
> you've left in some code that is just silly.

Being silly like that is actually important to make a sweeping patch
like that boring and trivial to show that it is correct.  Anything
that is not a rule based transformation is much more likely to hide
a bug.  So for the push down of the type change I think it was the right
way to go.

That said I am happy to add a clean up patch that makes the obvious
cleanups and simplifications to smack_lsm.c.

Eric






Re: [PATCH]cgroup: __cpuset_node_allowed return bool

2018-03-23 Thread yuankuiz

From 304cec1cc42255fbd9e231a810f4eea20ab74b90 Mon Sep 17 00:00:00 2001
From: John Zhao 
Date: Sat, 24 Mar 2018 13:01:32 +0800
Subject: [PATCH] cgroup: __cpuset_node_allowed return bool

as a bool, __cpuset_node_allowed(...) return should be bool.

Signed-off-by: John Zhao 
---
 kernel/cgroup/cpuset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index b42037e..42338b7 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2552,7 +2552,7 @@ static struct cpuset 
*nearest_hardwall_ancestor(struct cpuset *cs)

 bool __cpuset_node_allowed(int node, gfp_t gfp_mask)
 {
struct cpuset *cs;  /* current cpuset ancestors */
-   int allowed;/* is allocation in zone z allowed? */
+   bool allowed;   /* is allocation in zone z allowed? */
unsigned long flags;

if (in_interrupt())
--
2.7.4


[PATCH]cgroup: __cpuset_node_allowed return bool

2018-03-23 Thread yuankuiz

as a bool, __cpuset_node_allowed(...) return should be bool.

Signed-off-by: John Zhao 

--- kernel/cgroup/cpuset.c.orig 2018-03-24 12:39:27.854178608 +0800
+++ kernel/cgroup/cpuset.c  2018-03-24 12:40:51.020708670 +0800
@@ -2552,7 +2552,7 @@ static struct cpuset *nearest_hardwall_a
 bool __cpuset_node_allowed(int node, gfp_t gfp_mask)
 {
struct cpuset *cs;  /* current cpuset ancestors */
-   int allowed;/* is allocation in zone z allowed? */
+   bool allowed;   /* is allocation in zone z allowed? */
unsigned long flags;

if (in_interrupt())


Re: [PATCH v2 0/2] Fix __earlycon_table stride... again

2018-03-23 Thread Daniel Kurtz
On Fri, Mar 23, 2018 at 7:34 AM Greg Kroah-Hartman <
gre...@linuxfoundation.org> wrote:

> On Tue, Mar 20, 2018 at 11:57:10AM -0600, Daniel Kurtz wrote:
> > The __earlycon_table lives in a special "__earlycon_table" section.  The
> > contents of this table are added using some macros that deposit
individual
> > struct earlycon_id entries into this section.  The linker then defines
a symbol
> > __earlycon_table that is supposed to contain the addresss of the first
of these
> > entries.  The code in earlycon.c and fdt.c then tries to access the
memory
> > pointed to by __earlycon_table as an array of struct earlycon_id
entries.
> >
> > Unfortunately, the compiler doesn't always place the entries such that
they
> > are an array.  Let's fix that.
> >
> > Patch 1 of the series is a fix that should hopefully fix a kbuild error
that
> > seems to be triggered by Patch 2.

> Doesn't seem like that worked :(

> And I have a bunch of different versions of this patch in my to-review
> queue, and I can't figure out which is the "latest" one.

> Can you resend it, after getting the build error fixed, so I know which
> to attempt to apply?

Please take Patch Set v5 (fixes kbuild errors and commit message typos):
https://patchwork.kernel.org/patch/10298043/

thanks,
-djk


> thanks,

> greg k-h


Re: [PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct

2018-03-23 Thread Matthew Wilcox
> So, introduce a new rwlock in mm_struct to protect the concurrent access
> to arg_start|end and env_start|end.

I don't think an rwlock makes much sense here.  There is almost no
concurrency on the read side, and an rwlock is more expensive than
a spinlock.  Just use a spinlock.


[PATCH 2/3] ieee80211: Replace bit shifts with the BIT() macro for measurement masks.

2018-03-23 Thread Quytelda Kahja
It is neater and more consistent with the rest of the document to use the
BIT() macro from 'linux/bitops.h' to define the
IEEE80211_SPCT_MSR_RPRT_MODE_* bitmasks.

Signed-off-by: Quytelda Kahja 
---
 include/linux/ieee80211.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 58069176b432..dc361ed2fb7e 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1632,9 +1632,9 @@ struct ieee80211_vht_operation {
 #define WLAN_CAPABILITY_DMG_RADIO_MEASURE  BIT(12)
 
 /* measurement */
-#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE  (1<<0)
-#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
-#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED   (1<<2)
+#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE  BIT(0)
+#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE BIT(1)
+#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED   BIT(2)
 
 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA   1
-- 
2.16.2



[PATCH 3/3] ieee80211: Replace bit shifts with the BIT() macro for 802.11g ERP IEs.

2018-03-23 Thread Quytelda Kahja
It is neater and more consistent with the rest of the document to use the
BIT() macro from 'linux/bitops.h' to define the WLAN_ERP_* bitmasks.

Signed-off-by: Quytelda Kahja 
---
 include/linux/ieee80211.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index dc361ed2fb7e..bc68d542f082 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1641,9 +1641,9 @@ struct ieee80211_vht_operation {
 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI   2
 
 /* 802.11g ERP information element */
-#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
-#define WLAN_ERP_USE_PROTECTION (1<<1)
-#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
+#define WLAN_ERP_NON_ERP_PRESENT BIT(0)
+#define WLAN_ERP_USE_PROTECTION  BIT(1)
+#define WLAN_ERP_BARKER_PREAMBLE BIT(2)
 
 /* WLAN_ERP_BARKER_PREAMBLE values */
 enum {
-- 
2.16.2



[PATCH 1/3] ieee80211: Replace bit shifts with the BIT() macro for WLAN_CAPABILITY_*.

2018-03-23 Thread Quytelda Kahja
It is neater and more consistent with the rest of the document to use the
BIT() macro from 'linux/bitops.h' to define the WLAN_CAPABILITY_*
bitmasks.  In the case of WLAN_CAPABILITY_DMG_TYPE_{IBSS, PBSS, AP},
bitshifting integers by 0 does nothing, so there is no reason to do it in
the code; replace these values with plain integers.

Signed-off-by: Quytelda Kahja 
---
 include/linux/ieee80211.h | 56 +++
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index ee6657a0ed69..58069176b432 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1588,8 +1588,8 @@ struct ieee80211_vht_operation {
 
 #define WLAN_AUTH_CHALLENGE_LEN 128
 
-#define WLAN_CAPABILITY_ESS(1<<0)
-#define WLAN_CAPABILITY_IBSS   (1<<1)
+#define WLAN_CAPABILITY_ESSBIT(0)
+#define WLAN_CAPABILITY_IBSS   BIT(1)
 
 /*
  * A mesh STA sets the ESS and IBSS capability bits to zero.
@@ -1599,37 +1599,37 @@ struct ieee80211_vht_operation {
 #define WLAN_CAPABILITY_IS_STA_BSS(cap)\
(!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
 
-#define WLAN_CAPABILITY_CF_POLLABLE(1<<2)
-#define WLAN_CAPABILITY_CF_POLL_REQUEST(1<<3)
-#define WLAN_CAPABILITY_PRIVACY(1<<4)
-#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
-#define WLAN_CAPABILITY_PBCC   (1<<6)
-#define WLAN_CAPABILITY_CHANNEL_AGILITY(1<<7)
+#define WLAN_CAPABILITY_CF_POLLABLEBIT(2)
+#define WLAN_CAPABILITY_CF_POLL_REQUESTBIT(3)
+#define WLAN_CAPABILITY_PRIVACYBIT(4)
+#define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
+#define WLAN_CAPABILITY_PBCC   BIT(6)
+#define WLAN_CAPABILITY_CHANNEL_AGILITYBIT(7)
 
 /* 802.11h */
-#define WLAN_CAPABILITY_SPECTRUM_MGMT  (1<<8)
-#define WLAN_CAPABILITY_QOS(1<<9)
-#define WLAN_CAPABILITY_SHORT_SLOT_TIME(1<<10)
-#define WLAN_CAPABILITY_APSD   (1<<11)
-#define WLAN_CAPABILITY_RADIO_MEASURE  (1<<12)
-#define WLAN_CAPABILITY_DSSS_OFDM  (1<<13)
-#define WLAN_CAPABILITY_DEL_BACK   (1<<14)
-#define WLAN_CAPABILITY_IMM_BACK   (1<<15)
+#define WLAN_CAPABILITY_SPECTRUM_MGMT  BIT(8)
+#define WLAN_CAPABILITY_QOSBIT(9)
+#define WLAN_CAPABILITY_SHORT_SLOT_TIMEBIT(10)
+#define WLAN_CAPABILITY_APSD   BIT(11)
+#define WLAN_CAPABILITY_RADIO_MEASURE  BIT(12)
+#define WLAN_CAPABILITY_DSSS_OFDM  BIT(13)
+#define WLAN_CAPABILITY_DEL_BACK   BIT(14)
+#define WLAN_CAPABILITY_IMM_BACK   BIT(15)
 
 /* DMG (60gHz) 802.11ad */
 /* type - bits 0..1 */
-#define WLAN_CAPABILITY_DMG_TYPE_MASK  (3<<0)
-#define WLAN_CAPABILITY_DMG_TYPE_IBSS  (1<<0) /* Tx by: STA */
-#define WLAN_CAPABILITY_DMG_TYPE_PBSS  (2<<0) /* Tx by: PCP */
-#define WLAN_CAPABILITY_DMG_TYPE_AP(3<<0) /* Tx by: AP */
-
-#define WLAN_CAPABILITY_DMG_CBAP_ONLY  (1<<2)
-#define WLAN_CAPABILITY_DMG_CBAP_SOURCE(1<<3)
-#define WLAN_CAPABILITY_DMG_PRIVACY(1<<4)
-#define WLAN_CAPABILITY_DMG_ECPAC  (1<<5)
-
-#define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT  (1<<8)
-#define WLAN_CAPABILITY_DMG_RADIO_MEASURE  (1<<12)
+#define WLAN_CAPABILITY_DMG_TYPE_MASK   (BIT(0) | BIT(1))
+#define WLAN_CAPABILITY_DMG_TYPE_IBSS   1 /* Tx by: STA */
+#define WLAN_CAPABILITY_DMG_TYPE_PBSS   2 /* Tx by: PCP */
+#define WLAN_CAPABILITY_DMG_TYPE_AP 3 /* Tx by: AP */
+
+#define WLAN_CAPABILITY_DMG_CBAP_ONLY  BIT(2)
+#define WLAN_CAPABILITY_DMG_CBAP_SOURCEBIT(3)
+#define WLAN_CAPABILITY_DMG_PRIVACYBIT(4)
+#define WLAN_CAPABILITY_DMG_ECPAC  BIT(5)
+
+#define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT  BIT(8)
+#define WLAN_CAPABILITY_DMG_RADIO_MEASURE  BIT(12)
 
 /* measurement */
 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE  (1<<0)
-- 
2.16.2



Re: [PATCH v6 6/6] bnxt_en: Eliminate duplicate barriers on weakly-ordered archs

2018-03-23 Thread Sinan Kaya
On 3/23/2018 6:36 PM, Michael Chan wrote:
>> +   mmiowb();
> Sorry for the late review.  mmiowb() is not required here because we
> are in NAPI context, so only one CPU will be updating this doorbell.
> 
> Other than that, it looks good.
> 

OK, I'll fix this on the next version.

-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.


Re: [PATCH v3 01/11] PCI/P2PDMA: Support peer-to-peer memory

2018-03-23 Thread Bjorn Helgaas
On Fri, Mar 23, 2018 at 03:59:14PM -0600, Logan Gunthorpe wrote:
> On 23/03/18 03:50 PM, Bjorn Helgaas wrote:
> > Popping way up the stack, my original point was that I'm trying to
> > remove restrictions on what devices can participate in
> > peer-to-peer DMA.  I think it's fairly clear that in conventional
> > PCI, any devices in the same PCI hierarchy, i.e., below the same
> > host-to-PCI bridge, should be able to DMA to each other.
> 
> Yup, we are working on this.
> 
> > The routing behavior of PCIe is supposed to be compatible with
> > conventional PCI, and I would argue that this effectively requires
> > multi-function PCIe devices to have the internal routing required
> > to avoid the route-to-self issue.
> 
> That would be very nice but many devices do not support the internal
> route. We've had to work around this in the past and as I mentioned
> earlier that NVMe devices have a flag indicating support. However,
> if a device wants to be involved in P2P it must support it and we
> can exclude devices that don't support it by simply not enabling
> their drivers.

Do you think these devices that don't support internal DMA between
functions are within spec, or should we handle them as exceptions,
e.g., via quirks?

If NVMe defines a flag indicating peer-to-peer support, that would
suggest to me that these devices are within spec.

I looked up the CMBSZ register you mentioned (NVMe 1.3a, sec 3.1.12).
You must be referring to the WDS, RDS, LISTS, CQS, and SQS bits.  If
WDS is set, the controller supports having Write-related data and
metadata in the Controller Memory Buffer.  That would mean the driver
could put certain queues in controller memory instead of in host
memory.  The controller could then read the queue from its own
internal memory rather than issuing a PCIe transaction to read it from
host memory.

That makes sense to me, but I don't see the connection to
peer-to-peer.  There's no multi-function device in this picture, so
it's not about internal DMA between functions.

WDS, etc., tell us about capabilities of the controller.  If WDS is
set, the CPU (or a peer PCIe device) can write things to controller
memory.  If it is clear, neither the CPU nor a peer device can put
things there.  So it doesn't seem to tell us anything about
peer-to-peer specifically.  It looks like information needed by the
NVMe driver, but not by the PCI core.

Bjorn


[PATCH net-next 1/5] net: hns3: fix for returning wrong value problem in hns3_get_rss_key_size

2018-03-23 Thread Peng Li
From: Fuyun Liang 

The return type of hns3_get_rss_key_size is u32. But a negative value is
returned. This patch fixes it by replacing the negative value with zero.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 9d07116..ac523c9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -638,7 +638,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev)
 
if (!h->ae_algo || !h->ae_algo->ops ||
!h->ae_algo->ops->get_rss_key_size)
-   return -EOPNOTSUPP;
+   return 0;
 
return h->ae_algo->ops->get_rss_key_size(h);
 }
-- 
2.9.3



[PATCH net-next 4/5] net: hns3: fix for not initializing VF rss_hash_key problem

2018-03-23 Thread Peng Li
From: Fuyun Liang 

Default rss_hash_key value should be given to all vports. But just the
PF rss_hash_key has the default value here. This patch adds rss_hash_key
Initialization for all vports.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index bede411..ce093c3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -3466,8 +3466,6 @@ static void hclge_rss_init_cfg(struct hclge_dev *hdev)
struct hclge_vport *vport = hdev->vport;
int i;
 
-   netdev_rss_key_fill(vport->rss_hash_key, HCLGE_RSS_KEY_SIZE);
-
for (i = 0; i < hdev->num_vmdq_vport + 1; i++) {
vport[i].rss_tuple_sets.ipv4_tcp_en =
HCLGE_RSS_INPUT_TUPLE_OTHER;
@@ -3487,6 +3485,8 @@ static void hclge_rss_init_cfg(struct hclge_dev *hdev)
HCLGE_RSS_INPUT_TUPLE_OTHER;
 
vport[i].rss_algo = HCLGE_RSS_HASH_ALGO_TOEPLITZ;
+
+   netdev_rss_key_fill(vport[i].rss_hash_key, HCLGE_RSS_KEY_SIZE);
}
 
hclge_rss_indir_init_cfg(hdev);
-- 
2.9.3



[PATCH net-next 5/5] net: hns3: never send command queue message to IMP when reset

2018-03-23 Thread Peng Li
IMP will not handle and command queue message any more when it is
in core/global, driver should not send command queue message to
IMP until reinitialize the NIC HW.

This patch checks the status and avoid the message sent to IMP when
reset.

Signed-off-by: Peng Li 
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 23 +-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c|  6 ++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index ce093c3..2066dd7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -3584,6 +3584,9 @@ static int hclge_unmap_ring_frm_vector(struct 
hnae3_handle *handle,
struct hclge_dev *hdev = vport->back;
int vector_id, ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+   return 0;
+
vector_id = hclge_get_vector_index(hdev, vector);
if (vector_id < 0) {
dev_err(&handle->pdev->dev,
@@ -3781,13 +3784,16 @@ static int hclge_ae_start(struct hnae3_handle *handle)
clear_bit(HCLGE_STATE_DOWN, &hdev->state);
mod_timer(&hdev->service_timer, jiffies + HZ);
 
+   /* reset tqp stats */
+   hclge_reset_tqp_stats(handle);
+
+   if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+   return 0;
+
ret = hclge_mac_start_phy(hdev);
if (ret)
return ret;
 
-   /* reset tqp stats */
-   hclge_reset_tqp_stats(handle);
-
return 0;
 }
 
@@ -3797,6 +3803,12 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
struct hclge_dev *hdev = vport->back;
int i;
 
+   del_timer_sync(&hdev->service_timer);
+   cancel_work_sync(&hdev->service_task);
+
+   if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+   return;
+
for (i = 0; i < vport->alloc_tqps; i++)
hclge_tqp_enable(hdev, i, 0, false);
 
@@ -3807,8 +3819,6 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
 
/* reset tqp stats */
hclge_reset_tqp_stats(handle);
-   del_timer_sync(&hdev->service_timer);
-   cancel_work_sync(&hdev->service_task);
hclge_update_link_status(hdev);
 }
 
@@ -4940,6 +4950,9 @@ void hclge_reset_tqp(struct hnae3_handle *handle, u16 
queue_id)
u16 queue_gid;
int ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+   return;
+
queue_gid = hclge_covert_handle_qid_global(handle, queue_id);
 
ret = hclge_tqp_enable(hdev, queue_id, 0, false);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index c1dea3a..682c2d6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -60,6 +60,9 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, 
int regnum,
struct hclge_desc desc;
int ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+   return 0;
+
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false);
 
mdio_cmd = (struct hclge_mdio_cfg_cmd *)desc.data;
@@ -95,6 +98,9 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, 
int regnum)
struct hclge_desc desc;
int ret;
 
+   if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+   return 0;
+
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true);
 
mdio_cmd = (struct hclge_mdio_cfg_cmd *)desc.data;
-- 
2.9.3



[PATCH net-next 3/5] net: hns3: fix for the wrong shift problem in hns3_set_txbd_baseinfo

2018-03-23 Thread Peng Li
From: Fuyun Liang 

Third parameter of hnae_set_field is shift, But a mask is given. This
patch fixes it by replacing HNS3_TXD_BDTYPE_M with HNS3_TXD_BDTYPE_S.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 40a3eb7..a31b4ad 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -764,7 +764,7 @@ static void hns3_set_txbd_baseinfo(u16 
*bdtp_fe_sc_vld_ra_ri, int frag_end)
 {
/* Config bd buffer end */
hnae_set_field(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_BDTYPE_M,
-  HNS3_TXD_BDTYPE_M, 0);
+  HNS3_TXD_BDTYPE_S, 0);
hnae_set_bit(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_FE_B, !!frag_end);
hnae_set_bit(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_VLD_B, 1);
hnae_set_field(*bdtp_fe_sc_vld_ra_ri, HNS3_TXD_SC_M, HNS3_TXD_SC_S, 0);
-- 
2.9.3



[PATCH net-next 2/5] net: hns3: fix for returning wrong value problem in hns3_get_rss_indir_size

2018-03-23 Thread Peng Li
From: Fuyun Liang 

The return type of hns3_get_rss_indir_size is u32. But a negative value is
returned. This patch fixes it by replacing the negative value with zero.

Signed-off-by: Fuyun Liang 
Signed-off-by: Peng Li 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index ac523c9..eb3c34f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -649,7 +649,7 @@ static u32 hns3_get_rss_indir_size(struct net_device 
*netdev)
 
if (!h->ae_algo || !h->ae_algo->ops ||
!h->ae_algo->ops->get_rss_indir_size)
-   return -EOPNOTSUPP;
+   return 0;
 
return h->ae_algo->ops->get_rss_indir_size(h);
 }
-- 
2.9.3



[PATCH net-next 0/5] fix some bugs for HNS3

2018-03-23 Thread Peng Li
This patchset fixes some bugs for HNS3 driver:
[Patch 1/5 - 2/5] fix 2 return vlaue issues.
[Patch 3/5 - 4/5] fix 2 comments reported by code review.
[Ptach 5/5] avoid sending message to IMP because IMP will not
handle any message when it is resetting.

Fuyun Liang (4):
  net: hns3: fix for returning wrong value problem in
hns3_get_rss_key_size
  net: hns3: fix for returning wrong value problem in
hns3_get_rss_indir_size
  net: hns3: fix for the wrong shift problem in hns3_set_txbd_baseinfo
  net: hns3: fix for not initializing VF rss_hash_key problem

Peng Li (1):
  net: hns3: never send command queue message to IMP when reset

 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c|  2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  4 ++--
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 27 --
 .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c|  6 +
 4 files changed, 29 insertions(+), 10 deletions(-)

-- 
2.9.3



[PATCH 3/3] module: Support to disable validity enforcement in runtime

2018-03-23 Thread Jia Zhang
In order to disable the module validity enforcement, writing
a PKCS#7 signature corresponding the signed content '0' is
required. Given a simple way to archive this:

$ echo -n 0 > no_sig_enforce
$ openssl smime -sign -nocerts -noattr -binary \
-in no_sig_enforce -inkey  \
-signer  -outform der -out no_sig_enforce.p7s
$ sudo cat no_sig_enforce.p7s \
> /sys/kernel/security/modsign/disable_enforce

Note that the signing key must be a trust key located in
system trusted keyring. So even the root privilige cannot
simply disable the enforcement.

Signed-off-by: Jia Zhang 
---
 kernel/module.c | 140 
 1 file changed, 140 insertions(+)

diff --git a/kernel/module.c b/kernel/module.c
index 79825ea..3dd35ac 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "module-internal.h"
 
@@ -288,6 +289,11 @@ bool is_module_sig_enforced(void)
 }
 EXPORT_SYMBOL(is_module_sig_enforced);
 
+static void set_module_sig_enforce(bool enforce)
+{
+   sig_enforce = enforce;
+}
+
 /* Block module loading/unloading? */
 int modules_disabled = 0;
 core_param(nomodule, modules_disabled, bint, 0);
@@ -2794,11 +2800,139 @@ static int module_sig_check(struct load_info *info, 
int flags)
 
return err;
 }
+
+#ifdef CONFIG_SECURITYFS
+/*
+ * Check the input for disabling enforcement policy.
+ *
+ * Return 0 if inteding to disabling the policy. Note that the root
+ * privilege cannot simply disable the policy without the
+ * authentication given by a trusted key.
+ */
+static int check_disable_enforce(char *buf, size_t count)
+{
+   u8 *p;
+
+   /*
+* In order to disable the enforcement policy, a PKCS#7 signature
+* is supplied.
+*
+* Assuming ASN.1 encoding supplied, the minimal length would be
+* 4-byte header plus at least 256-byte payload.
+*/
+   if (count < 260)
+   return -EINVAL;
+
+   p = (u8 *)buf;
+
+   /* The primitive type must be a sequnce */
+   if (p[0] != 0x30 || p[1] != 0x82)
+   return -EINVAL;
+
+   /* Match up the length of the supplied buffer */
+   if (be16_to_cpup((__be16 *)(p + 2)) != count - 4)
+   return -EINVAL;
+
+   return 0;
+}
+
+/*
+ * Disable the enforceme and verify the supplied PKCS#7 signature.
+ * The signed content is simply the charactoror '0'.
+ */
+static int disable_enforce(void *pkcs7, size_t pkcs7_len)
+{
+   char data = '0';
+
+   return verify_pkcs7_signature(&data, sizeof(data), pkcs7, pkcs7_len,
+ NULL, VERIFYING_UNSPECIFIED_SIGNATURE,
+ NULL, NULL);
+}
+
+static ssize_t modsign_disable_enforce_write(struct file *filp,
+const char __user *ubuf,
+size_t count, loff_t *offp)
+{
+   char *buf;
+   ssize_t ret;
+   size_t max_buf_size = 1 << MAX_ORDER;
+
+   if (*offp > 1)
+   return -EFBIG;
+
+   if (count > max_buf_size)
+   return -EFBIG;
+
+   buf = kmalloc(count, GFP_KERNEL);
+   if (!buf)
+   return -ENOMEM;
+
+   ret = simple_write_to_buffer(buf, count, offp, ubuf, count);
+   if (ret <= 0) {
+   kfree(buf);
+   return ret;
+   }
+
+   ret = check_disable_enforce(buf, count);
+   if (!ret) {
+   if (is_module_sig_enforced()) {
+   ret = disable_enforce(buf, count);
+   if (!ret) {
+   set_module_sig_enforce(false);
+   pr_notice("Kernel module validity enforcement 
disabled\n");
+   ret = count;
+   }
+   } else
+   ret = count;
+   }
+
+   kfree(buf);
+
+   return ret;
+}
+
+static const struct file_operations modsign_disable_enforce_ops = {
+   .write = modsign_disable_enforce_write,
+   .llseek = generic_file_llseek,
+};
+
+static int __init securityfs_init(void)
+{
+   struct dentry *modsign_dir;
+   struct dentry *disable_enforce;
+
+   modsign_dir = securityfs_create_dir("modsign", NULL);
+   if (IS_ERR(modsign_dir))
+   return -1;
+
+   disable_enforce = securityfs_create_file("disable_enforce", S_IWUSR,
+modsign_dir, NULL,
+&modsign_disable_enforce_ops);
+   if (IS_ERR(disable_enforce))
+   goto out;
+
+   return 0;
+out:
+   securityfs_remove(modsign_dir);
+
+   return -1;
+}
+#else /* !CONFIG_SECURITYFS */
+static int __init securityfs_init(void)
+{
+   return 0;
+}
+#endif
 #else /* !CONFIG_MODULE_SIG */
 static int module_sig_check(struct load_info *info, int flags)
 {
   

[PATCH 2/3] module: Create the entry point initialize_module()

2018-03-23 Thread Jia Zhang
This entry point currently includes the procfs initialization,
and will include a securityfs initialization.

Signed-off-by: Jia Zhang 
---
 kernel/module.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/kernel/module.c b/kernel/module.c
index 003d0ab..79825ea 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -4243,7 +4243,11 @@ static int __init proc_modules_init(void)
proc_create("modules", 0, NULL, &proc_modules_operations);
return 0;
 }
-module_init(proc_modules_init);
+#else  /* CONFIG_PROC_FS */
+static int __init proc_modules_init(void)
+{
+return 0;
+}
 #endif
 
 /* Given an address, look for it in the module exception tables. */
@@ -4388,3 +4392,11 @@ void module_layout(struct module *mod,
 }
 EXPORT_SYMBOL(module_layout);
 #endif
+
+static int __init initialize_module(void)
+{
+   proc_modules_init();
+
+   return 0;
+}
+module_init(initialize_module);
-- 
1.8.3.1



[PATCH 1/3] module: Do not access sig_enforce directly

2018-03-23 Thread Jia Zhang
Call is_module_sig_enforced() instead.

Signed-off-by: Jia Zhang 
---
 kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/module.c b/kernel/module.c
index ad2d420..003d0ab 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2789,7 +2789,7 @@ static int module_sig_check(struct load_info *info, int 
flags)
}
 
/* Not having a signature is only an error if we're strict. */
-   if (err == -ENOKEY && !sig_enforce)
+   if (err == -ENOKEY && !is_module_sig_enforced())
err = 0;
 
return err;
-- 
1.8.3.1



[PATCH v3 0/3][RESEND] modsign enhancement

2018-03-23 Thread Jia Zhang
This patch series allows to disable module validity enforcement
in runtime through the control switch located in securityfs.

In order to keep /sys/module/module/parameters/sig_enforce simple,
the disablement switch is located at
/sys/kernel/security/modsign/disable_enforce.

Assuming CONFIG_MODULE_SIG_FORCE=n, here are the instructions to
test this control switch.

# cat /sys/module/module/parameters/sig_enforce
N
# echo 1 > /sys/module/module/parameters/sig_enforce
# cat /sys/module/module/parameters/sig_enforce
Y
# echo -n 0 > no_sig_enforce
# openssl smime -sign -nocerts -noattr -binary -in no_sig_enforce \
-inkey  -signer  -outform der \
-out /sys/kernel/security/modsign/disable_enforce
# cat /sys/module/module/parameters/sig_enforce
N

Changelog:
v3:
- The control switch now doesn't support showing the status of sig_enforce.

v2:
- Support to disable validity enforcement in runtime.



Re: [PATCH v5 00/13] ARM: dts: ipq: updates to enable a few peripherals

2018-03-23 Thread Richard Cochran
On Fri, Mar 23, 2018 at 03:48:43PM +0530, Sricharan R wrote:
> [v5]
> * Fixed a minor comment that i missed earlier.

I tried booting this series with qcom_defconfig on my custom,
dk07-like board.  It works!

Thanks a bunch,
Richard


Re: [PATCH] [media] vcodec: fix error return value from mtk_jpeg_clk_init()

2018-03-23 Thread Rick Chang
On Fri, 2018-03-23 at 11:44 +0800, Ryder Lee wrote:
> The error return value should be fixed as it may return EPROBE_DEFER.
> 
> Cc: Rick Chang 
> Cc: Bin Liu 
> Signed-off-by: Ryder Lee 
> ---
>  drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> index 226f908..af17aaa 100644
> --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> @@ -1081,11 +1081,11 @@ static int mtk_jpeg_clk_init(struct
> mtk_jpeg_dev *jpeg)
>  
>   jpeg->clk_jdec = devm_clk_get(jpeg->dev, "jpgdec");
>   if (IS_ERR(jpeg->clk_jdec))
> - return -EINVAL;
> + return PTR_ERR(jpeg->clk_jdec);
>  
>   jpeg->clk_jdec_smi = devm_clk_get(jpeg->dev, "jpgdec-smi");
>   if (IS_ERR(jpeg->clk_jdec_smi))
> - return -EINVAL;
> + return PTR_ERR(jpeg->clk_jdec_smi);
>  
>   return 0;
>  }

Acked-by: Rick Chang 


Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up

2018-03-23 Thread Quentin Perret
On Thursday 22 Mar 2018 at 13:19:03 (-0700), Joel Fernandes wrote:
> On Thu, Mar 22, 2018 at 11:06 AM, Patrick Bellasi
>  wrote:

[...]

> >> > @@ -6555,6 +6613,14 @@ select_task_rq_fair(struct task_struct *p, int 
> >> > prev_cpu, int sd_flag, int wake_f
> >> > break;
> >> > }
> >> >
> >> > +   /*
> >> > +* Energy-aware task placement is performed on the 
> >> > highest
> >> > +* non-overutilized domain spanning over cpu and 
> >> > prev_cpu.
> >> > +*/
> >> > +   if (want_energy && !sd_overutilized(tmp) &&
> >> > +   cpumask_test_cpu(prev_cpu, sched_domain_span(tmp)))
> >>
> >> Shouldn't you check for the SD_ASYM_CPUCAPACITY flag here for tmp level?
> >
> > ... and this then should be covered by the previous check in
> > wake_energy(), which sets want_energy.
> 
> Right, but in a scenario which probably doesn't exist today where we
> have both SD_ASYM_CPUCAPACITY and !SD_ASYM_CPUCAPACITY domains in the
> hierarchy for which want_energy = 1, I was thinking if its more future
> proof to check it and not make assumptions...

So we can definitely have cases where SD_ASYM_CPUCAPACITY is not set at all
sd levels. Today, on mobile systems, this flag is typically set only at DIE
level for big.LITTLE platforms, and not at MC level.
We enable EAS if we find _at least_ one domain that has this flag in the
hierarchy, just to make sure we don't enable EAS for symmetric platform.
It's just a way to check a property about the topology when EAS starts, not
really a way to actually select the sd at which we do scheduling at
runtime.

I hope that helps !

Thanks,
Quentin



Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up

2018-03-23 Thread Quentin Perret
On Friday 23 Mar 2018 at 18:13:56 (-0700), Joel Fernandes wrote:
> Hi Morten,
> 
> On Fri, Mar 23, 2018 at 8:47 AM, Morten Rasmussen
>  wrote:
> > On Thu, Mar 22, 2018 at 01:10:22PM -0700, Joel Fernandes wrote:

[...]

> > You mean if SD_BALANCE_WAKE isn't set on sched_domains?
> 
> Yes.
> 
> > The current code seems to rely on that flag to be set to work correctly.
> > Otherwise, the loop might bail out on !want_affine and we end up doing
> > the find_energy_efficient_cpu() on the lowest level sched_domain even if
> > there is higher level one which isn't over-utilized.
> >
> > However, SD_BALANCE_WAKE should be set if SD_ASYM_CPUCAPACITY is set so
> > sd == NULL shouldn't be possible? This only holds as long as we only
> > want EAS for asymmetric systems.
> 
> Yes, I see you had topology code that set SD_BALANCE_WAKE for ASYM. It
> makes sense to me then, thanks for the clarification.
> 
> Still I feel it is a bit tedious/confusing when reading code to draw
> the conclusion about why sd is checked first before doing
> find_energy_efficient_cpu (and that sd will != NULL for ASYM systems).
> If energy_sd is set, then we can just proceed with EAS without
> checking that sd != NULL. This function in mainline is already pretty
> confusing as it is :-(

Right I see your point. The code is correct as is, but I agree that having
a code structured as

if (energy_sd) {
new_cpu = find_energy_efficient_cpu(energy_sd, p, prev_cpu);
} else if (!sd) {
...

might be easier to understand and functionally equivalent. What do you
think ?

Thanks,
Quentin


Re: [PATCH] USB: announce bcdDevice as well as idVendor, idProduct.

2018-03-23 Thread Benson Leung
On Fri, Mar 23, 2018 at 06:08:07PM -0700, Andrew Chant wrote:
> >> +"New USB device found, idVendor=%04x, idProduct=%04x, 
> >> bcdDevice=%04x\n",
> > Can you please decode bcdDevice into a decimal string?
> >
> > lsusb -v does this (bcdDevice: 0.03 for example) and in my experience
> > it has generally matched up with how hardware manufacturers refer
> > to their firmware.
> 
> Nevermind, %x should show bcd properly.  looks fine.

I like the way lsusb -v does it better. Take a look at v2.

Thanks,
Benson

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
ble...@google.com
Chromium OS Project
ble...@chromium.org


signature.asc
Description: PGP signature


[PATCH v2] USB: announce bcdDevice as well as idVendor, idProduct.

2018-03-23 Thread Benson Leung
Print bcdDevice which is used by vendors to identify different versions
of the same product (or different versions of firmware).

Adding this to the logs will be useful for support purposes.

Match the %2x.%02x formatting that's used by lsusb -v for this same value.

Signed-off-by: Benson Leung 
--
v2: Format for decimal output.
---
 drivers/usb/core/hub.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index aaeef03c0d83..624cde7ffcea 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2192,14 +2192,19 @@ static void show_string(struct usb_device *udev, char 
*id, char *string)
 
 static void announce_device(struct usb_device *udev)
 {
-   dev_info(&udev->dev, "New USB device found, idVendor=%04x, 
idProduct=%04x\n",
-   le16_to_cpu(udev->descriptor.idVendor),
-   le16_to_cpu(udev->descriptor.idProduct));
+   u16 bcdDevice;
+
+   bcdDevice = le16_to_cpu(udev->descriptor.bcdDevice);
+   dev_info(&udev->dev,
+"New USB device found, idVendor=%04x, idProduct=%04x, 
bcdDevice=%2x.%02x\n",
+le16_to_cpu(udev->descriptor.idVendor),
+le16_to_cpu(udev->descriptor.idProduct),
+bcdDevice >> 8, bcdDevice & 0xff);
dev_info(&udev->dev,
-   "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
-   udev->descriptor.iManufacturer,
-   udev->descriptor.iProduct,
-   udev->descriptor.iSerialNumber);
+"New USB device strings: Mfr=%d, Product=%d, 
SerialNumber=%d\n",
+udev->descriptor.iManufacturer,
+udev->descriptor.iProduct,
+udev->descriptor.iSerialNumber);
show_string(udev, "Product", udev->product);
show_string(udev, "Manufacturer", udev->manufacturer);
show_string(udev, "SerialNumber", udev->serial);
-- 
2.17.0.rc0.231.g781580f067-goog



Re: [PATCH] [RFC] drm: rcar-du: keep temporary dtb files around during build

2018-03-23 Thread Frank Rowand
Hi Geert,

On 03/22/18 07:26, Geert Uytterhoeven wrote:
> Hi Frank,
> 
> On Fri, Mar 16, 2018 at 2:39 AM,   wrote:
>> On Thursday, March 15, 2018 8:37 AM, Arnd Bergmann [mailto:a...@arndb.de]  
>> wrote:
>>>
>>> The *.dtb and *.dtb.S files get removed by 'make' during the build
>>> process,
>>> and later seem to be missed during the 'modpost' stage:
>>>
>>> rm drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dtb
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dtb
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dtb.S
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dtb.S
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb.S
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dtb
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dtb
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dtb.S
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dtb.S
>>> WARNING: could not open
>>> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb.S: No such file or
>>> directory
>>>
>>> As a workaround, this adds all those files to the 'extra-y' target list,
>>> but that's really ugly. Any ideas for a better fix?
>>
>> Does this work for you (untested, but the way it is done in
>> drivers/of/unittest-data/Makefile):
>>
>> .PRECIOUS: \
>> $(obj)/%.dtb.S \
>> $(obj)/%.dtb
> 
> Shouldn't that just be moved to scripts/Makefile.lib, just above the rule
> to make dtb.S, like is done for other precious objects?
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 

Thank you for adding Yamada-san (later in this thread).

I acked his patch series that does what you suggest.

-Frank


Re: [PATCH 01/10] .gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore

2018-03-23 Thread Frank Rowand
On 03/23/18 06:04, Masahiro Yamada wrote:
> These patterns are common to host programs that require lexer and parser.
> Move them to the top .gitignore.
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Frank Rowand 

-Frank
> ---
> 
>  .gitignore  | 2 ++
>  scripts/dtc/.gitignore  | 3 ---
>  scripts/genksyms/.gitignore | 3 ---
>  scripts/kconfig/.gitignore  | 3 ---
>  4 files changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/.gitignore b/.gitignore
> index 85bcc26..1e82be1 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -22,6 +22,7 @@
>  *.gz
>  *.i
>  *.ko
> +*.lex.c
>  *.ll
>  *.lst
>  *.lz4
> @@ -37,6 +38,7 @@
>  *.so.dbg
>  *.su
>  *.symtypes
> +*.tab.[ch]
>  *.tar
>  *.xz
>  Module.symvers
> diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore
> index cdabdc9..2e6e60d 100644
> --- a/scripts/dtc/.gitignore
> +++ b/scripts/dtc/.gitignore
> @@ -1,4 +1 @@
>  dtc
> -dtc-lexer.lex.c
> -dtc-parser.tab.c
> -dtc-parser.tab.h
> diff --git a/scripts/genksyms/.gitignore b/scripts/genksyms/.gitignore
> index e7836b4..b119c7d 100644
> --- a/scripts/genksyms/.gitignore
> +++ b/scripts/genksyms/.gitignore
> @@ -1,4 +1 @@
> -*.lex.c
> -*.tab.c
> -*.tab.h
>  genksyms
> diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
> index a76856e..2da579e 100644
> --- a/scripts/kconfig/.gitignore
> +++ b/scripts/kconfig/.gitignore
> @@ -1,9 +1,6 @@
>  #
>  # Generated files
>  #
> -*.lex.c
> -*.tab.c
> -*.tab.h
>  *.moc
>  gconf.glade.h
>  *.pot
> 



Re: [PATCH 10/10] kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS specifier

2018-03-23 Thread Frank Rowand
On 03/23/18 06:04, Masahiro Yamada wrote:
> GNU Make automatically deletes intermediate files that are updated
> in a chain of pattern rules.
> 
> Example 1) %.dtb.o <- %.dtb.S <- %.dtb.S <- %.dts
> Example 2) %.o <- %.c <- %.c_shipped
> 
> A couple of makefiles mark such targets as .PRECIOUS to prevent Make
> from deleting them, but the correct way is to use .SECONDARY.
> 
>   .SECONDARY
> Prerequisites of this special target are treated as intermediate
> files but are never automatically deleted.
> 
>   .PRECIOUS
> When make is interrupted during execution, it may delete the target
> file it is updating if the file was modified since make started.
> If you mark the file as precious, make will never delete the file
> if interrupted.
> 
> Both can avoid deletion of intermediate files, but the difference is
> the behavior when Make is interrupted; .SECONDARY deletes the target,
> but .PRECIOUS does not.
> 
> The use of .PRECIOUS is relatively rare since we do not want to keep
> partially constructed (possibly corrupted) targets.
> 
> Another difference is that .PRECIOUS works with pattern rules whereas
> .SECONDARY does not.
> 
>   .PRECIOUS: $(obj)/%.lex.c
> 
> works, but
> 
>   .SECONDARY: $(obj)/%.lex.c
> 
> has no effect.  However, for the reason above, I do not want to use
> .PRECIOUS to avoid obscure build breakage.
> 
> The targets specified as .SECONDARY must be explicit.  $(targets)
> contains all targets that need to include .*.cmd files.  So, the
> intermediates you want to keep are likely to be contained in
> $(targets).  So, mark it as .SECONDARY.  The exception is when they
> are created by $(call cmd,...) instead of $(call if_changed,...)
> since the former does not need to include .*.cmd file.  In this
> case, makefiles need to mark them .SECONDARY by themselves, like
> arch/arm(64)/crypto/Makefile.
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Frank Rowand 

-Frank

> ---
> 
>  arch/arc/boot/dts/Makefile| 2 --
>  arch/arm/crypto/Makefile  | 2 +-
>  arch/arm64/crypto/Makefile| 2 +-
>  arch/metag/boot/dts/Makefile  | 2 --
>  drivers/of/unittest-data/Makefile | 4 
>  scripts/Makefile.build| 6 --
>  scripts/Makefile.lib  | 3 ---
>  7 files changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/arc/boot/dts/Makefile b/arch/arc/boot/dts/Makefile
> index 22a4c5d..a83c4f5 100644
> --- a/arch/arc/boot/dts/Makefile
> +++ b/arch/arc/boot/dts/Makefile
> @@ -9,8 +9,6 @@ endif
>  obj-y   += $(builtindtb-y).dtb.o
>  dtb-y := $(builtindtb-y).dtb
>  
> -.SECONDARY: $(obj)/$(builtindtb-y).dtb.S
> -
>  # for CONFIG_OF_ALL_DTBS test
>  dtstree  := $(srctree)/$(src)
>  dtb- := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
> diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile
> index 30ef8e2..3d59567 100644
> --- a/arch/arm/crypto/Makefile
> +++ b/arch/arm/crypto/Makefile
> @@ -63,4 +63,4 @@ $(src)/sha256-core.S_shipped: $(src)/sha256-armv4.pl
>  $(src)/sha512-core.S_shipped: $(src)/sha512-armv4.pl
>   $(call cmd,perl)
>  
> -.PRECIOUS: $(obj)/sha256-core.S $(obj)/sha512-core.S
> +.SECONDARY: $(obj)/sha256-core.S $(obj)/sha512-core.S
> diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile
> index cee9b8d9..fceb638 100644
> --- a/arch/arm64/crypto/Makefile
> +++ b/arch/arm64/crypto/Makefile
> @@ -76,4 +76,4 @@ $(src)/sha256-core.S_shipped: $(src)/sha512-armv8.pl
>  $(src)/sha512-core.S_shipped: $(src)/sha512-armv8.pl
>   $(call cmd,perlasm)
>  
> -.PRECIOUS: $(obj)/sha256-core.S $(obj)/sha512-core.S
> +.SECONDARY: $(obj)/sha256-core.S $(obj)/sha512-core.S
> diff --git a/arch/metag/boot/dts/Makefile b/arch/metag/boot/dts/Makefile
> index f0a180f..16505aa 100644
> --- a/arch/metag/boot/dts/Makefile
> +++ b/arch/metag/boot/dts/Makefile
> @@ -12,5 +12,3 @@ endif
>  
>  dtb-$(CONFIG_METAG_BUILTIN_DTB)  += $(builtindtb-y).dtb
>  obj-$(CONFIG_METAG_BUILTIN_DTB)  += $(builtindtb-y).dtb.o
> -
> -.SECONDARY: $(obj)/$(builtindtb-y).dtb.S
> diff --git a/drivers/of/unittest-data/Makefile 
> b/drivers/of/unittest-data/Makefile
> index 333bc4c..0fb87cb 100644
> --- a/drivers/of/unittest-data/Makefile
> +++ b/drivers/of/unittest-data/Makefile
> @@ -12,7 +12,3 @@ DTC_FLAGS_overlay := -@
>  DTC_FLAGS_overlay_bad_phandle := -@
>  DTC_FLAGS_overlay_bad_symbol := -@
>  DTC_FLAGS_overlay_base := -@
> -
> -.PRECIOUS: \
> - $(obj)/%.dtb.S \
> - $(obj)/%.dtb
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index cc081af..4397adb 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -430,8 +430,6 @@ quiet_cmd_asn1_compiler = ASN.1   $@
>cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
>   $(subst .h,.c,$@) $(subst .c,.h,$@)
>  
> -.PRECIOUS: $(objtree)/$(obj)/%.asn1.c $(objtree)/$(obj)/%.asn1.h
> -
>  $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 \
>   $(

Re: [PATCH 05/10] kbuild: add %.dtb.S and %.dtb to 'targets' automatically

2018-03-23 Thread Frank Rowand
On 03/23/18 06:04, Masahiro Yamada wrote:
> Another common pattern that consists of chained commands is to compile
> a DTB as binary data into the kernel image or a module.  It is used in
> several places in the source tree.  Let's support it in the build core.
> 
> $(call if_changed,dt_S_dtb) is more suitable than $(call cmd,dt_S_dtb)
> in case cmd_dt_S_dtb is changed in the future.
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Frank Rowand 

-Frank

> ---
> 
>  drivers/of/unittest-data/Makefile | 2 --
>  scripts/Makefile.build| 4 +++-
>  scripts/Makefile.lib  | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/of/unittest-data/Makefile 
> b/drivers/of/unittest-data/Makefile
> index df69797..333bc4c 100644
> --- a/drivers/of/unittest-data/Makefile
> +++ b/drivers/of/unittest-data/Makefile
> @@ -7,8 +7,6 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
>   overlay_bad_symbol.dtb.o \
>   overlay_base.dtb.o
>  
> -targets += $(foreach suffix, dtb dtb.S, $(patsubst 
> %.dtb.o,%.$(suffix),$(obj-y)))
> -
>  # enable creation of __symbols__ node
>  DTC_FLAGS_overlay := -@
>  DTC_FLAGS_overlay_bad_phandle := -@
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 36f7990..15b3bbb 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -544,9 +544,11 @@ targets := $(filter-out $(PHONY), $(targets))
>  intermediate_targets = $(foreach sfx, $(2), \
>   $(patsubst %$(strip $(1)),%$(sfx), \
>   $(filter %$(strip $(1)), $(targets
> +# %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
>  # %.lex.o <- %.lex.c <- %.l
>  # %.tab.o <- %.tab.[ch] <- %.y
> -targets += $(call intermediate_targets, .lex.o, .lex.c) \
> +targets += $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
> +$(call intermediate_targets, .lex.o, .lex.c) \
>  $(call intermediate_targets, .tab.o, .tab.c .tab.h)
>  
>  # Descending
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index b7d2c97..7a1fa92 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -278,8 +278,8 @@ cmd_dt_S_dtb= 
> \
>   echo '.balign STRUCT_ALIGNMENT';\
>  ) > $@
>  
> -$(obj)/%.dtb.S: $(obj)/%.dtb
> - $(call cmd,dt_S_dtb)
> +$(obj)/%.dtb.S: $(obj)/%.dtb FORCE
> + $(call if_changed,dt_S_dtb)
>  
>  quiet_cmd_dtc = DTC $@
>  cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
> 



Re: [PATCH 04/10] kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically

2018-03-23 Thread Frank Rowand
On 03/23/18 06:04, Masahiro Yamada wrote:
> Files generated by if_changed* must be added to 'targets' to include
> *.cmd files.  Otherwise, they would be regenerated every time.
> 
> The build system automatically adds objects to 'targets' where
> appropriate, such as obj-y, extra-y, etc. but does nothing for
> intermediate files.  So, each Makefile needs to add them by itself.
> 
> There are some common cases where objects are generated by chained
> rules.  Lexers and parsers are compiled like follows:
> 
>%.lex.o <- %.lex.c <- %.l
>%.tab.o <- %.tab.c <- %.y
> 
> They are common patterns, so it is reasonable to take care of them
> in the core Makefile instead of requiring each Makefile to do so.
> 
> At this moment, you cannot delete 'target += zconf.lex.c' because
> zconf.lex.c is included from zconf.tab.c instead of being compiled.
> This will be possible with further refactoring in the future.
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Frank Rowand 

-Frank

> ---
> 
>  scripts/Makefile.build| 11 +++
>  scripts/dtc/Makefile  |  3 ---
>  scripts/genksyms/Makefile |  2 --
>  scripts/kconfig/Makefile  |  2 +-
>  4 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 77cce68..36f7990 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -538,6 +538,17 @@ $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
>  targets += $(multi-used-m)
>  targets := $(filter-out $(PHONY), $(targets))
>  
> +# Add intermediate targets:
> +# When building objects with specific suffix patterns, add intermediate
> +# targets that the final targets are derived from.
> +intermediate_targets = $(foreach sfx, $(2), \
> + $(patsubst %$(strip $(1)),%$(sfx), \
> + $(filter %$(strip $(1)), $(targets
> +# %.lex.o <- %.lex.c <- %.l
> +# %.tab.o <- %.tab.[ch] <- %.y
> +targets += $(call intermediate_targets, .lex.o, .lex.c) \
> +$(call intermediate_targets, .tab.o, .tab.c .tab.h)
> +
>  # Descending
>  # ---
>  
> diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
> index d17ba64..9cac65b 100644
> --- a/scripts/dtc/Makefile
> +++ b/scripts/dtc/Makefile
> @@ -27,6 +27,3 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
>  
>  # dependencies on generated files need to be listed explicitly
>  $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
> -
> -# generated files need to include *.cmd
> -targets := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
> diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
> index f4749e8..aeefd47 100644
> --- a/scripts/genksyms/Makefile
> +++ b/scripts/genksyms/Makefile
> @@ -32,5 +32,3 @@ HOSTCFLAGS_lex.lex.o := -I$(src)
>  
>  # dependencies on generated files need to be listed explicitly
>  $(obj)/lex.lex.o: $(obj)/parse.tab.h
> -
> -targets := lex.lex.c parse.tab.c parse.tab.h
> diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
> index 1dcd797..5def877 100644
> --- a/scripts/kconfig/Makefile
> +++ b/scripts/kconfig/Makefile
> @@ -207,7 +207,7 @@ gconf-objs:= gconf.o zconf.tab.o
>  
>  hostprogs-y := conf nconf mconf kxgettext qconf gconf
>  
> -targets  += zconf.tab.c zconf.lex.c
> +targets  += zconf.lex.c
>  clean-files  := qconf.moc .tmp_qtcheck .tmp_gtkcheck
>  clean-files  += gconf.glade.h
>  clean-files += config.pot linux.pot
> 



Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up

2018-03-23 Thread Quentin Perret
On Friday 23 Mar 2018 at 15:47:45 (+), Morten Rasmussen wrote:
> On Thu, Mar 22, 2018 at 01:10:22PM -0700, Joel Fernandes wrote:
> > On Wed, Mar 21, 2018 at 8:35 AM, Patrick Bellasi
> >  wrote:
> > > [...]
> > >
> > >> @@ -6555,6 +6613,14 @@ select_task_rq_fair(struct task_struct *p, int 
> > >> prev_cpu, int sd_flag, int wake_f
> > >>   break;
> > >>   }
> > >>
> > >> + /*
> > >> +  * Energy-aware task placement is performed on the highest
> > >> +  * non-overutilized domain spanning over cpu and prev_cpu.
> > >> +  */
> > >> + if (want_energy && !sd_overutilized(tmp) &&
> > >> + cpumask_test_cpu(prev_cpu, sched_domain_span(tmp)))
> > >> + energy_sd = tmp;
> > >> +
> > >
> > > Not entirely sure, but I was trying to understand if we can avoid to
> > > modify the definition of want_affine (in the previous chunk) and move
> > > this block before the previous "if (want_affine..." (in mainline but
> > > not in this chunk), which will became an else, e.g.
> > >
> > > if (want_energy && !sd_overutilized(tmp) &&
> > > // ...
> > > else if (want_energy && !sd_overutilized(tmp) &&
> > > // ...
> > >
> > > Isn't that the same?
> > >
> > > Maybe there is a code path I'm missing... but otherwise it seems a
> > > more self contained modification of select_task_rq_fair...
> > 
> > Just replying to this here Patrick instead of the other thread.
> > 
> > I think this is the right place for the block from Quentin quoted
> > above because we want to search for the highest domain that is
> > !overutilized and look among those for the candidates. So from that
> > perspective, we can't move the block to the beginning and it seems to
> > be in the right place. My main concern on the other thread was
> > different, I was talking about the cases where sd_flag & tmp->flags
> > don't match. In that case, sd = NULL would trump EAS and I was
> > wondering if that's the right thing to do...
> 
> You mean if SD_BALANCE_WAKE isn't set on sched_domains?
> 
> The current code seems to rely on that flag to be set to work correctly.
> Otherwise, the loop might bail out on !want_affine and we end up doing
> the find_energy_efficient_cpu() on the lowest level sched_domain even if
> there is higher level one which isn't over-utilized.
> 
> However, SD_BALANCE_WAKE should be set if SD_ASYM_CPUCAPACITY is set so
> sd == NULL shouldn't be possible? This only holds as long as we only
> want EAS for asymmetric systems.

That's correct, we are under the assumption that the SD_ASYM_CPUCAPACITY
flag is set somewhere in the hierarchy here. If a sched domain has this
flag set, SD_BALANCE_WAKE is propagated to all lower sched domains
(see sd_init() in kernel/sched/topology.c) so we should be fine.


Re: rcu: Add might_sleep() check to synchronize_rcu()

2018-03-23 Thread Steven Rostedt
On Fri, 23 Mar 2018 15:57:04 -0700
Joel Fernandes  wrote:

> > diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> > index 194a7483bb93..857b494bee29 100644
> > --- a/net/l2tp/l2tp_core.c
> > +++ b/net/l2tp/l2tp_core.c
> > @@ -1677,6 +1677,8 @@ void __l2tp_session_unhash(struct l2tp_session 
> > *session)
> >  {
> > struct l2tp_tunnel *tunnel = session->tunnel;
> >
> > +   might_sleep();
> > +
> > /* Remove the session from core hashes */
> > if (tunnel) {
> > /* Remove from the per-tunnel hash */  
> 
> Thanks Thomas and Steven, also shouldn't this code be calling
> synchronize_rcu_bh instead of synchronize_rcu, to complement the
> rcu_read_lock_bh? In which situations would you call one versus the
> other?

Probably, as the comment above rcu_read_lock_bh is:

 * rcu_read_lock_bh() - mark the beginning of an RCU-bh critical section
 *
 * This is equivalent of rcu_read_lock(), but to be used when updates
 * are being done using call_rcu_bh() or synchronize_rcu_bh(). Since
 * both call_rcu_bh() and synchronize_rcu_bh() consider completion of a
 * softirq handler to be a quiescent state, a process in RCU read-side
 * critical section must be protected by disabling softirqs.

It appears that the reason to use rcu_read_lock_bh() is if you are
calling synchronize_rcu_bh(). Otherwise, one could just be using
straight rcu_read_lock().

-- Steve



Re: [PATCH 02/10] kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile

2018-03-23 Thread Frank Rowand
On 03/23/18 06:04, Masahiro Yamada wrote:
> Files suffixed by .lex.c, .tab.[ch] are generated lexers, parsers,
> respectively.  Clean them up globally from the top Makefile.
> 
> Some of the final host programs they are linked into are needed for
> building external modules, but those intermediates are unneeded.
> They can be cleaned away by 'make clean' instead of 'make mrproper'.
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Frank Rowand 

-Frank

> ---
> 
>  Makefile  | 1 +
>  scripts/dtc/Makefile  | 6 ++
>  scripts/genksyms/Makefile | 2 --
>  scripts/kconfig/Makefile  | 2 +-
>  4 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 493e267..168432e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1613,6 +1613,7 @@ clean: $(clean-dirs)
>   -o -name '*.dwo' -o -name '*.lst' \
>   -o -name '*.su'  \
>   -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
> + -o -name '*.lex.c' -o -name '*.tab.[ch]' \
>   -o -name '*.symtypes' -o -name 'modules.order' \
>   -o -name modules.builtin -o -name '.tmp_*.o.*' \
>   -o -name .cache.mk \
> diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
> index a88b8c9..d17ba64 100644
> --- a/scripts/dtc/Makefile
> +++ b/scripts/dtc/Makefile
> @@ -28,7 +28,5 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
>  # dependencies on generated files need to be listed explicitly
>  $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
>  
> -# generated files need to include *.cmd and be cleaned explicitly
> -generated-files  := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
> -targets  := $(generated-files)
> -clean-files  := $(generated-files)
> +# generated files need to include *.cmd
> +targets := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
> diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
> index 34d6ab1..0ccac51 100644
> --- a/scripts/genksyms/Makefile
> +++ b/scripts/genksyms/Makefile
> @@ -11,5 +11,3 @@ HOSTCFLAGS_lex.lex.o := -I$(src)
>  
>  # dependencies on generated files need to be listed explicitly
>  $(obj)/lex.lex.o: $(obj)/parse.tab.h
> -
> -clean-files  := lex.lex.c parse.tab.c parse.tab.h
> diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
> index f9bdd02..1dcd797 100644
> --- a/scripts/kconfig/Makefile
> +++ b/scripts/kconfig/Makefile
> @@ -209,7 +209,7 @@ hostprogs-y := conf nconf mconf kxgettext qconf gconf
>  
>  targets  += zconf.tab.c zconf.lex.c
>  clean-files  := qconf.moc .tmp_qtcheck .tmp_gtkcheck
> -clean-files  += zconf.tab.c zconf.lex.c gconf.glade.h
> +clean-files  += gconf.glade.h
>  clean-files += config.pot linux.pot
>  
>  # Check that we have the required ncurses stuff installed for lxdialog 
> (menuconfig)
> 



Re: ftrace on MIPS/ath79

2018-03-23 Thread Steven Rostedt
On Fri, 23 Mar 2018 23:20:10 +0100
Matthias Schiffer  wrote:

> Hi,
> I'm currently trying to debug a performance bottleneck on low-end ath79
> hardware running OpenWrt/LEDE, but it seems that ftrace is not working
> correctly on these systems. I have tried this with recent 4.4.y and 4.9.y
> with similar results; unfortunately, switching to a newer kernel is not
> easily possible on this hardware at the moment. Please let me know if there
> are any known issues or patches that I should backport.

I don't know of any for mips (nothing in the git logs). The last
updates to the mips code looks to be from 3.17. Also, I have no idea
why try_to_get_module() would be crashing.

> 
> There seem to be two separate issues:
> 
> 1) Building with CONFIG_DYNAMIC_FTRACE leads to a kernel panic as soon as
> kernel modules are loaded (logs attached).
> 
> 2) function_graph tracer does not show anything useful: the trace output
> looks like what was reported in [1]. Building with
> CONFIG_FUNCTION_GRAPH_TRACER leads to a completely empty
> trace_stat/function0 (except for the header); profiling is working as
> expected when CONFIG_FUNCTION_GRAPH_TRACER is disabled.
> 
> I would be thankful for any pointers that might help me to make this work.
> 
> Kind regards,
> Matthias
> 
> 
> [1] https://www.linux-mips.org/archives/linux-mips/2014-11/msg00295.html
> 

>From the last email in that thread:

"But yeah, don't go too much by that document. It is out of date, and
when I get time, I'll have to update it. I'll probably do that when I
bring powerpc up to speed with x86 (except for the fentry part).

I want dynamic trampolines for powerpc and such, and when I do that, it
will make all the changes fresh in my mind to go back and tackle the
design documentation."

The sad part is, I've said the same thing recently about updating that
document. But in the mean time, my powerpc box died and I never got to
do what I wanted with that box. My mips board is pretty useless today,
so I don't touch other archs much anymore (don't have the time
either, maybe I will when I retire. That's why I still keep all my
boards around).

I wish I could be of help, but MIPS has been cached out of my brain for
some time. If you want to investigate, I would be willing to give you
help in generic ftrace support, but anything MIPS specific would
require someone from the MIPS team.

-- Steve


Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up

2018-03-23 Thread Joel Fernandes
Hi Morten,

On Fri, Mar 23, 2018 at 8:47 AM, Morten Rasmussen
 wrote:
> On Thu, Mar 22, 2018 at 01:10:22PM -0700, Joel Fernandes wrote:
>> On Wed, Mar 21, 2018 at 8:35 AM, Patrick Bellasi
>>  wrote:
>> > [...]
>> >
>> >> @@ -6555,6 +6613,14 @@ select_task_rq_fair(struct task_struct *p, int 
>> >> prev_cpu, int sd_flag, int wake_f
>> >>   break;
>> >>   }
>> >>
>> >> + /*
>> >> +  * Energy-aware task placement is performed on the highest
>> >> +  * non-overutilized domain spanning over cpu and prev_cpu.
>> >> +  */
>> >> + if (want_energy && !sd_overutilized(tmp) &&
>> >> + cpumask_test_cpu(prev_cpu, sched_domain_span(tmp)))
>> >> + energy_sd = tmp;
>> >> +
>> >
>> > Not entirely sure, but I was trying to understand if we can avoid to
>> > modify the definition of want_affine (in the previous chunk) and move
>> > this block before the previous "if (want_affine..." (in mainline but
>> > not in this chunk), which will became an else, e.g.
>> >
>> > if (want_energy && !sd_overutilized(tmp) &&
>> > // ...
>> > else if (want_energy && !sd_overutilized(tmp) &&
>> > // ...
>> >
>> > Isn't that the same?
>> >
>> > Maybe there is a code path I'm missing... but otherwise it seems a
>> > more self contained modification of select_task_rq_fair...
>>
>> Just replying to this here Patrick instead of the other thread.
>>
>> I think this is the right place for the block from Quentin quoted
>> above because we want to search for the highest domain that is
>> !overutilized and look among those for the candidates. So from that
>> perspective, we can't move the block to the beginning and it seems to
>> be in the right place. My main concern on the other thread was
>> different, I was talking about the cases where sd_flag & tmp->flags
>> don't match. In that case, sd = NULL would trump EAS and I was
>> wondering if that's the right thing to do...
>
> You mean if SD_BALANCE_WAKE isn't set on sched_domains?

Yes.

> The current code seems to rely on that flag to be set to work correctly.
> Otherwise, the loop might bail out on !want_affine and we end up doing
> the find_energy_efficient_cpu() on the lowest level sched_domain even if
> there is higher level one which isn't over-utilized.
>
> However, SD_BALANCE_WAKE should be set if SD_ASYM_CPUCAPACITY is set so
> sd == NULL shouldn't be possible? This only holds as long as we only
> want EAS for asymmetric systems.

Yes, I see you had topology code that set SD_BALANCE_WAKE for ASYM. It
makes sense to me then, thanks for the clarification.

Still I feel it is a bit tedious/confusing when reading code to draw
the conclusion about why sd is checked first before doing
find_energy_efficient_cpu (and that sd will != NULL for ASYM systems).
If energy_sd is set, then we can just proceed with EAS without
checking that sd != NULL. This function in mainline is already pretty
confusing as it is :-(

Regards,

- Joel


Re: [PATCH] USB: announce bcdDevice as well as idVendor, idProduct.

2018-03-23 Thread Andrew Chant
On Fri, Mar 23, 2018 at 5:48 PM, Andrew Chant  wrote:
> On Fri, Mar 23, 2018 at 5:33 PM, Benson Leung  wrote:
>> Print bcdDevice which is used by vendors to identify different versions
>> of the same product (or different versions of firmware).
>>
>> Adding this to the logs will be useful for support purposes.
>>
>> Signed-off-by: Benson Leung 
>> ---
>>  drivers/usb/core/hub.c | 16 +---
>>  1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>> index aaeef03c0d83..739d599814b6 100644
>> --- a/drivers/usb/core/hub.c
>> +++ b/drivers/usb/core/hub.c
>> @@ -2192,14 +2192,16 @@ static void show_string(struct usb_device *udev, 
>> char *id, char *string)
>>
>>  static void announce_device(struct usb_device *udev)
>>  {
>> -   dev_info(&udev->dev, "New USB device found, idVendor=%04x, 
>> idProduct=%04x\n",
>> -   le16_to_cpu(udev->descriptor.idVendor),
>> -   le16_to_cpu(udev->descriptor.idProduct));
>> dev_info(&udev->dev,
>> -   "New USB device strings: Mfr=%d, Product=%d, 
>> SerialNumber=%d\n",
>> -   udev->descriptor.iManufacturer,
>> -   udev->descriptor.iProduct,
>> -   udev->descriptor.iSerialNumber);
>> +"New USB device found, idVendor=%04x, idProduct=%04x, 
>> bcdDevice=%04x\n",
>> +le16_to_cpu(udev->descriptor.idVendor),
>> +le16_to_cpu(udev->descriptor.idProduct),
>> +le16_to_cpu(udev->descriptor.bcdDevice));
>> +   dev_info(&udev->dev,
>> +"New USB device strings: Mfr=%d, Product=%d, 
>> SerialNumber=%d\n",
>> +udev->descriptor.iManufacturer,
>> +udev->descriptor.iProduct,
>> +udev->descriptor.iSerialNumber);
>> show_string(udev, "Product", udev->product);
>> show_string(udev, "Manufacturer", udev->manufacturer);
>> show_string(udev, "SerialNumber", udev->serial);
>> --
>> 2.17.0.rc0.231.g781580f067-goog
>>
>
>> +"New USB device found, idVendor=%04x, idProduct=%04x, 
>> bcdDevice=%04x\n",
> Can you please decode bcdDevice into a decimal string?
>
> lsusb -v does this (bcdDevice: 0.03 for example) and in my experience
> it has generally matched up with how hardware manufacturers refer
> to their firmware.

Nevermind, %x should show bcd properly.  looks fine.


Re: [PATCH v3 2/2] x86, cpuid: allow cpuid_read() to schedule

2018-03-23 Thread Eric Dumazet


On 03/23/2018 03:17 PM, H. Peter Anvin wrote:
> On 03/23/18 14:58, Eric Dumazet wrote:
>> I noticed high latencies caused by a daemon periodically reading various
>> MSR and cpuid on all cpus. KASAN kernels would see ~10ms latencies
>> simply reading one cpuid. Even without KASAN, sending IPI to CPU
>> in deep sleep state or blocking hard IRQ in a a long section,
>> then waiting for the answer can consume hundreds of usec or more.
>>
>> Switching to smp_call_function_single_async() and a completion
>> allows to reschedule and not burn cpu cycles.
> 
> That being said, the Right Way for a daemon to read multiple MSRs and
> CPUIDs on multiple CPUs is to spawn a thread for each CPU and use CPU
> affinity to lock them down.  No IPI is needed to access MSRs on the
> current CPU, and CPUID doesn't even need kernel entry.

Indeed, assuming a daemon can have threads running on all cpus :/

Some environments like to partition cpus for different jobs/containers.

Yes, we can avoid IPI by carefully re-designing these user programs.


Re: [PATCH 00/11] Use global pages with PTI

2018-03-23 Thread Linus Torvalds
On Fri, Mar 23, 2018 at 5:46 PM, Linus Torvalds
 wrote:
>
> It is, of course, possible that I misunderstood what you actually
> benchmarked. But I assume the above benchmark numbers are with the
> whole "don't even do global entries if you have PCID".

Oh, I went back and read your description, and realized that I _had_
misunderstood what you did.

I thought you didn't bother with global pages at all when you had PCID.

But that's not what you meant. You always do global for the actual
user-mapped kernel pages, but when you don't have PCID you do *all*
kernel test as global, whether shared or not.

So I entirely misread what the latest change was.

 Linus


Re: [PATCH] USB: announce bcdDevice as well as idVendor, idProduct.

2018-03-23 Thread Andrew Chant
On Fri, Mar 23, 2018 at 5:33 PM, Benson Leung  wrote:
> Print bcdDevice which is used by vendors to identify different versions
> of the same product (or different versions of firmware).
>
> Adding this to the logs will be useful for support purposes.
>
> Signed-off-by: Benson Leung 
> ---
>  drivers/usb/core/hub.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index aaeef03c0d83..739d599814b6 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2192,14 +2192,16 @@ static void show_string(struct usb_device *udev, char 
> *id, char *string)
>
>  static void announce_device(struct usb_device *udev)
>  {
> -   dev_info(&udev->dev, "New USB device found, idVendor=%04x, 
> idProduct=%04x\n",
> -   le16_to_cpu(udev->descriptor.idVendor),
> -   le16_to_cpu(udev->descriptor.idProduct));
> dev_info(&udev->dev,
> -   "New USB device strings: Mfr=%d, Product=%d, 
> SerialNumber=%d\n",
> -   udev->descriptor.iManufacturer,
> -   udev->descriptor.iProduct,
> -   udev->descriptor.iSerialNumber);
> +"New USB device found, idVendor=%04x, idProduct=%04x, 
> bcdDevice=%04x\n",
> +le16_to_cpu(udev->descriptor.idVendor),
> +le16_to_cpu(udev->descriptor.idProduct),
> +le16_to_cpu(udev->descriptor.bcdDevice));
> +   dev_info(&udev->dev,
> +"New USB device strings: Mfr=%d, Product=%d, 
> SerialNumber=%d\n",
> +udev->descriptor.iManufacturer,
> +udev->descriptor.iProduct,
> +udev->descriptor.iSerialNumber);
> show_string(udev, "Product", udev->product);
> show_string(udev, "Manufacturer", udev->manufacturer);
> show_string(udev, "SerialNumber", udev->serial);
> --
> 2.17.0.rc0.231.g781580f067-goog
>

> +"New USB device found, idVendor=%04x, idProduct=%04x, 
> bcdDevice=%04x\n",
Can you please decode bcdDevice into a decimal string?

lsusb -v does this (bcdDevice: 0.03 for example) and in my experience
it has generally matched up with how hardware manufacturers refer
to their firmware.


Re: [PATCH 00/11] Use global pages with PTI

2018-03-23 Thread Linus Torvalds
On Fri, Mar 23, 2018 at 5:40 PM, Dave Hansen
 wrote:
>
> Well, rats.  This somehow makes things slower with PCIDs on.

.. what happens when you enable global pages with PCID? You disabled
them explicitly because you thought they wouldn't matter..

Even with PCID, a global TLB entry for the shared pages would make
sense, because it's now just *one* entry in the TLB rather that "one
per PCID and one for the kernel mapping".

So even if in theory the lifetime of the TLB entry is the same, when
you have capacity misses it most definitely isn't.

And for process tear-down and build-up the per-PCID TLB entry does
nothing at all. While for a true global entry, it gets shared even
across process creation/deletion. So even ignoring TLB capacity
issues, with lots of shortlived processes global TLB entries are much
better.

It is, of course, possible that I misunderstood what you actually
benchmarked. But I assume the above benchmark numbers are with the
whole "don't even do global entries if you have PCID".

   Linus


Re: [PATCH 00/11] Use global pages with PTI

2018-03-23 Thread Dave Hansen
On 03/23/2018 11:26 AM, Linus Torvalds wrote:
> On Fri, Mar 23, 2018 at 10:44 AM, Dave Hansen
>  wrote:
>>
>> This adds one major change from the last version of the patch set
>> (present in the last patch).  It makes all kernel text global for non-
>> PCID systems.  This keeps kernel data protected always, but means that
>> it will be easier to find kernel gadgets via meltdown on old systems
>> without PCIDs.  This heuristic is, I think, a reasonable one and it
>> keeps us from having to create any new pti=foo options
> 
> Sounds sane.
> 
> The patches look reasonable, but I hate seeing a patch series like
> this where the only ostensible reason is performance, and there are no
> performance numbers anywhere..

Well, rats.  This somehow makes things slower with PCIDs on.  I thought
I reversed the numbers, but I actually do a "grep -c GLB
/sys/kernel/debug/page_tables/kernel" and record that in my logs right
next to the output of time(1), so it's awfully hard to screw up.

This is time doing a modestly-sized kernel compile on a 4-core Skylake
desktop.

User Time   Kernel Time Clock Elapsed
Baseline ( 0 GLB PTEs)  803.79  67.77   237.30
w/series (28 GLB PTEs)  807.70 (+0.7%)  68.07 (+0.7%)   238.07 (+0.3%)

Without PCIDs, it behaves the way I would expect.

I'll ask around, but I'm open to any ideas about what the heck might be
causing this.


[PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct

2018-03-23 Thread Yang Shi
mmap_sem is on the hot path of kernel, and it very contended, but it is
abused too. It is used to protect arg_start|end and evn_start|end when
reading /proc/$PID/cmdline and /proc/$PID/environ, but it doesn't make
sense since those proc files just expect to read 4 values atomically and
not related to VM, they could be set to arbitrary values by C/R.

And, the mmap_sem contention may cause unexpected issue like below:

INFO: task ps:14018 blocked for more than 120 seconds.
   Tainted: GE 4.9.79-009.ali3000.alios7.x86_64 #1
 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this
message.
 ps  D0 14018  1 0x0004
  885582f84000 885e8682f000 880972943000 885ebf499bc0
  8828ee12 c900349bfca8 817154d0 0040
  00ff812f872a 885ebf499bc0 024000d000948300 880972943000
 Call Trace:
  [] ? __schedule+0x250/0x730
  [] schedule+0x36/0x80
  [] rwsem_down_read_failed+0xf0/0x150
  [] call_rwsem_down_read_failed+0x18/0x30
  [] down_read+0x20/0x40
  [] proc_pid_cmdline_read+0xd9/0x4e0
  [] ? do_filp_open+0xa5/0x100
  [] __vfs_read+0x37/0x150
  [] ? security_file_permission+0x9b/0xc0
  [] vfs_read+0x96/0x130
  [] SyS_read+0x55/0xc0
  [] entry_SYSCALL_64_fastpath+0x1a/0xc5

Both Alexey Dobriyan and Michal Hocko suggested to use dedicated lock
for them to mitigate the abuse of mmap_sem.

So, introduce a new rwlock in mm_struct to protect the concurrent access
to arg_start|end and env_start|end.

Signed-off-by: Yang Shi 
Cc: Alexey Dobriyan 
Cc: Michal Hocko 
---
 fs/proc/base.c   | 8 
 include/linux/mm_types.h | 2 ++
 kernel/fork.c| 1 +
 kernel/sys.c | 6 ++
 mm/init-mm.c | 1 +
 5 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 28fa852..0bc3107 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -239,12 +239,12 @@ static ssize_t proc_pid_cmdline_read(struct file *file, 
char __user *buf,
goto out_mmput;
}
 
-   down_read(&mm->mmap_sem);
+   read_lock(&mm->arg_lock);
arg_start = mm->arg_start;
arg_end = mm->arg_end;
env_start = mm->env_start;
env_end = mm->env_end;
-   up_read(&mm->mmap_sem);
+   read_unlock(&mm->arg_lock);
 
BUG_ON(arg_start > arg_end);
BUG_ON(env_start > env_end);
@@ -926,10 +926,10 @@ static ssize_t environ_read(struct file *file, char 
__user *buf,
if (!mmget_not_zero(mm))
goto free;
 
-   down_read(&mm->mmap_sem);
+   read_lock(&mm->arg_lock);
env_start = mm->env_start;
env_end = mm->env_end;
-   up_read(&mm->mmap_sem);
+   read_unlock(&mm->arg_lock);
 
while (count > 0) {
size_t this_len, max_len;
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index cfd0ac4..92bd9cc 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -419,6 +419,8 @@ struct mm_struct {
unsigned long def_flags;
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack;
+
+   rwlock_t arg_lock; /* protect concurrent access to arg_* and env_* */
unsigned long arg_start, arg_end, env_start, env_end;
 
unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
diff --git a/kernel/fork.c b/kernel/fork.c
index 432eadf..94cdf28 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -823,6 +823,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, 
struct task_struct *p,
mm->pinned_vm = 0;
memset(&mm->rss_stat, 0, sizeof(mm->rss_stat));
spin_lock_init(&mm->page_table_lock);
+   rwlock_init(&mm->arg_lock);
mm_init_cpumask(mm);
mm_init_aio(mm);
mm_init_owner(mm, p);
diff --git a/kernel/sys.c b/kernel/sys.c
index 83ffd7d..de357e1 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1980,10 +1980,13 @@ static int prctl_set_mm_map(int opt, const void __user 
*addr, unsigned long data
mm->start_brk   = prctl_map.start_brk;
mm->brk = prctl_map.brk;
mm->start_stack = prctl_map.start_stack;
+
+   write_lock(&mm->arg_lock);
mm->arg_start   = prctl_map.arg_start;
mm->arg_end = prctl_map.arg_end;
mm->env_start   = prctl_map.env_start;
mm->env_end = prctl_map.env_end;
+   write_unlock(&mm->arg_lock);
 
/*
 * Note this update of @saved_auxv is lockless thus
@@ -2149,10 +2152,13 @@ static int prctl_set_mm(int opt, unsigned long addr,
mm->start_brk   = prctl_map.start_brk;
mm->brk = prctl_map.brk;
mm->start_stack = prctl_map.start_stack;
+
+   write_lock(&mm->arg_lock);
mm->arg_start   = prctl_map.arg_start;
mm->arg_end = prctl_map.arg_end;
mm->env_start   = prctl_map.env_start;
mm->env_end = prctl_map.env_end;
+   write_unlock(&mm->arg_l

Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up

2018-03-23 Thread Joel Fernandes
On Fri, Mar 23, 2018 at 9:00 AM, Morten Rasmussen
 wrote:
> On Thu, Mar 22, 2018 at 09:27:43AM -0700, Joel Fernandes wrote:
>> >
>> > In case an energy model is available, waking tasks are re-routed into a
>> > new energy-aware placement algorithm. The eligible CPUs to be used in the
>> > energy-aware wakeup path are restricted to the highest non-overutilized
>> > sched_domain containing prev_cpu and this_cpu. If no such domain is found,
>> > the tasks go through the usual wake-up path, hence energy-aware placement
>> > happens only in lightly utilized scenarios.
>> >
>> > The selection of the most energy-efficient CPU for a task is achieved by
>> > estimating the impact on system-level active energy resulting from the
>> > placement of the task on each candidate CPU. The best CPU energy-wise is
>> > then selected if it saves a large enough amount of energy with respect to
>> > prev_cpu.
>> >
>> > Although it has already shown significant benefits on some existing
>> > targets, this brute force approach clearly cannot scale to platforms with
>> > numerous CPUs. This patch is an attempt to do something useful as writing
>> > a fast heuristic that performs reasonably well on a broad spectrum of
>> > architectures isn't an easy task. As a consequence, the scope of usability
>> > of the energy-aware wake-up path is restricted to systems with the
>> > SD_ASYM_CPUCAPACITY flag set. These systems not only show the most
>> > promising opportunities for saving energy but also typically feature a
>> > limited number of logical CPUs.
>> >
>> > Cc: Ingo Molnar 
>> > Cc: Peter Zijlstra 
>> > Signed-off-by: Quentin Perret 
>> > Signed-off-by: Dietmar Eggemann 
>> > ---
>> >  kernel/sched/fair.c | 74 
>> > ++---
>> >  1 file changed, 71 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> > index 76bd46502486..65a1bead0773 100644
>> > --- a/kernel/sched/fair.c
>> > +++ b/kernel/sched/fair.c
>> > @@ -6513,6 +6513,60 @@ static unsigned long compute_energy(struct 
>> > task_struct *p, int dst_cpu)
>> > return energy;
>> >  }
>> >
>> > +static bool task_fits(struct task_struct *p, int cpu)
>> > +{
>> > +   unsigned long next_util = cpu_util_next(cpu, p, cpu);
>> > +
>> > +   return util_fits_capacity(next_util, capacity_orig_of(cpu));
>> > +}
>> > +
>> > +static int find_energy_efficient_cpu(struct sched_domain *sd,
>> > +   struct task_struct *p, int 
>> > prev_cpu)
>> > +{
>> > +   unsigned long cur_energy, prev_energy, best_energy;
>> > +   int cpu, best_cpu = prev_cpu;
>> > +
>> > +   if (!task_util(p))
>> > +   return prev_cpu;
>> > +
>> > +   /* Compute the energy impact of leaving the task on prev_cpu. */
>> > +   prev_energy = best_energy = compute_energy(p, prev_cpu);
>>
>> Is it possible that before the wakeup, the task's affinity is changed
>> so that p->cpus_allowed no longer contains prev_cpu ? In that case
>> prev_energy wouldn't matter since previous CPU is no longer an option?
>
> It is possible to wake-up with a disallowed prev_cpu. In fact
> select_idle_sibling() may happily return a disallowed cpu in that case.
> The mistake gets fixed in select_task_rq() which uses
> select_fallback_rq() to find an allowed cpu instead.
>
> Could we fix the issue in find_energy_efficient_cpu() by a simple test
> like below
>
> if (cpumask_test_cpu(prev_cpu, &p->cpus_allowed))
> prev_energy = best_energy = compute_energy(p, prev_cpu);
> else
> prev_energy = best_energy = ULONG_MAX;

Yes, I think setting to ULONG_MAX in this case is Ok with me.

thanks,

- Joel


[PATCH] USB: announce bcdDevice as well as idVendor, idProduct.

2018-03-23 Thread Benson Leung
Print bcdDevice which is used by vendors to identify different versions
of the same product (or different versions of firmware).

Adding this to the logs will be useful for support purposes.

Signed-off-by: Benson Leung 
---
 drivers/usb/core/hub.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index aaeef03c0d83..739d599814b6 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2192,14 +2192,16 @@ static void show_string(struct usb_device *udev, char 
*id, char *string)
 
 static void announce_device(struct usb_device *udev)
 {
-   dev_info(&udev->dev, "New USB device found, idVendor=%04x, 
idProduct=%04x\n",
-   le16_to_cpu(udev->descriptor.idVendor),
-   le16_to_cpu(udev->descriptor.idProduct));
dev_info(&udev->dev,
-   "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
-   udev->descriptor.iManufacturer,
-   udev->descriptor.iProduct,
-   udev->descriptor.iSerialNumber);
+"New USB device found, idVendor=%04x, idProduct=%04x, 
bcdDevice=%04x\n",
+le16_to_cpu(udev->descriptor.idVendor),
+le16_to_cpu(udev->descriptor.idProduct),
+le16_to_cpu(udev->descriptor.bcdDevice));
+   dev_info(&udev->dev,
+"New USB device strings: Mfr=%d, Product=%d, 
SerialNumber=%d\n",
+udev->descriptor.iManufacturer,
+udev->descriptor.iProduct,
+udev->descriptor.iSerialNumber);
show_string(udev, "Product", udev->product);
show_string(udev, "Manufacturer", udev->manufacturer);
show_string(udev, "SerialNumber", udev->serial);
-- 
2.17.0.rc0.231.g781580f067-goog



[PATCH 0/4] tty/nozomi: general module cleanup

2018-03-23 Thread Joey Pabalinas
The nozomi module code has a fair amount of sections which could
use a bit of improvement; both style and clarity could be improved
while maintaining equivalent semantics.

Cleanup messy portions of the module code while preserving existing
behavior by:

 - Replacing constructs like `len__ > TMP_BUF_MAX ? TMP_BUF_MAX : len__`
   with `min_t(u32, len__, TMP_BUF_MAX)` and function calls like
   snprintf(tbuf, ..., "%s", ...). with strscpy(tbuf, ..., ...).
 - Rename identifiers more descriptively (where appropriate).
 - Simplify deeply nested conditionals by replacing them with shallower
   (but semantically equivalent) logic.
 - Coalesce return paths / loop conditionals.
 - Remove pointless initializations and redundant parentheses/break
   statements.
 - Correct inconsistently indented lines and extraneous whitespace.

CC: Greg Kroah-Hartman 
CC: Arnd Bergmann 
CC: Jiri Slaby 
CC: Tomasz Kramkowsk 

Joey Pabalinas (4):
  tty/nozomi: cleanup DUMP() macro
  tty/nozomi: fix inconsistent indentation
  tty/nozomi: improve code readability and style
  tty/nozomi: refactor conditional statements

 drivers/tty/nozomi.c | 362 +--
 1 file changed, 181 insertions(+), 181 deletions(-)

-- 
2.16.3



[PATCH 3/4] tty/nozomi: improve code readability and style

2018-03-23 Thread Joey Pabalinas
Improve code clarity by renaming identifiers and reorganizing
function control flow.

Signed-off-by: Joey Pabalinas 

 1 file changed, 92 insertions(+), 91 deletions(-)

 1 file changed, 76 insertions(+), 90 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index 0fcb4db721d2a42f08..a5074a59d3e3d33e68 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -401,7 +401,7 @@ static inline struct port *get_port_by_tty(const struct 
tty_struct *tty)
 static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
u32 size_bytes)
 {
-   u32 i = 0;
+   u32 nread = 0;
const u32 __iomem *ptr = mem_addr_start;
u16 *buf16;
 
@@ -411,30 +411,27 @@ static void read_mem32(u32 *buf, const void __iomem 
*mem_addr_start,
/* shortcut for extremely often used cases */
switch (size_bytes) {
case 2: /* 2 bytes */
-   buf16 = (u16 *) buf;
+   buf16 = (u16 *)buf;
*buf16 = __le16_to_cpu(readw(ptr));
goto out;
-   break;
case 4: /* 4 bytes */
-   *(buf) = __le32_to_cpu(readl(ptr));
+   *buf = __le32_to_cpu(readl(ptr));
goto out;
-   break;
}
 
-   while (i < size_bytes) {
-   if (size_bytes - i == 2) {
+   for (; nread < size_bytes; buf++, ptr++) {
+   if (size_bytes - nread == 2) {
/* Handle 2 bytes in the end */
-   buf16 = (u16 *) buf;
-   *(buf16) = __le16_to_cpu(readw(ptr));
-   i += 2;
+   buf16 = (u16 *)buf;
+   *buf16 = __le16_to_cpu(readw(ptr));
+   nread += 2;
} else {
/* Read 4 bytes */
-   *(buf) = __le32_to_cpu(readl(ptr));
-   i += 4;
+   *buf = __le32_to_cpu(readl(ptr));
+   nread += 4;
}
-   buf++;
-   ptr++;
}
+
 out:
return;
 }
@@ -447,7 +444,7 @@ static void read_mem32(u32 *buf, const void __iomem 
*mem_addr_start,
 static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
u32 size_bytes)
 {
-   u32 i = 0;
+   u32 nwritten = 0;
u32 __iomem *ptr = mem_addr_start;
const u16 *buf16;
 
@@ -460,7 +457,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), ptr);
return 2;
-   break;
case 1: /*
 * also needs to write 4 bytes in this case
 * so falling through..
@@ -468,24 +464,22 @@ static u32 write_mem32(void __iomem *mem_addr_start, 
const u32 *buf,
case 4: /* 4 bytes */
writel(__cpu_to_le32(*buf), ptr);
return 4;
-   break;
}
 
-   while (i < size_bytes) {
-   if (size_bytes - i == 2) {
+   for (; nwritten < size_bytes; buf++, ptr++) {
+   if (size_bytes - nwritten == 2) {
/* 2 bytes */
buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), ptr);
-   i += 2;
+   nwritten += 2;
} else {
/* 4 bytes */
writel(__cpu_to_le32(*buf), ptr);
-   i += 4;
+   nwritten += 4;
}
-   buf++;
-   ptr++;
}
-   return i;
+
+   return nwritten;
 }
 
 /* Setup pointers to different channels and also setup buffer sizes. */
@@ -632,9 +626,10 @@ static int nozomi_read_config_table(struct nozomi *dc)
return 0;
}
 
-   if ((dc->config_table.version == 0)
-   || (dc->config_table.toggle.enabled == TOGGLE_VALID)) {
+   if (!dc->config_table.version
+   || dc->config_table.toggle.enabled == TOGGLE_VALID) {
int i;
+
DBG1("Second phase, configuring card");
 
nozomi_setup_memory(dc);
@@ -659,12 +654,14 @@ static int nozomi_read_config_table(struct nozomi *dc)
 
dc->state = NOZOMI_STATE_ALLOCATED;
dev_info(&dc->pdev->dev, "Initialization OK!\n");
+
return 1;
}
 
-   if ((dc->config_table.version > 0)
-   && (dc->config_table.toggle.enabled != TOGGLE_VALID)) {
+   if (dc->config_table.version > 0
+   && dc->config_table.toggle.enabled != TOGGLE_VALID) {
u32 offset = 0;
+
DBG1("First phase: pushing upload buffers, clearing download");
 
dev_info(&dc->pdev->dev, "Version of card: %d\n",
@@ -752,7 +749,7 @@ static void disable_transmit_d

[PATCH 2/4] tty/nozomi: fix inconsistent indentation

2018-03-23 Thread Joey Pabalinas
Correct misaligned indentation and remove extraneous spaces.

Signed-off-by: Joey Pabalinas 

 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index f26bf1d1e9ee0e74eb..0fcb4db721d2a42f08 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -102,41 +102,41 @@ do {  
\
 #define RECEIVE_BUF_MAX4
 
 
-#define R_IIR  0x  /* Interrupt Identity Register */
-#define R_FCR  0x  /* Flow Control Register */
-#define R_IER  0x0004  /* Interrupt Enable Register */
+#define R_IIR  0x  /* Interrupt Identity Register */
+#define R_FCR  0x  /* Flow Control Register */
+#define R_IER  0x0004  /* Interrupt Enable Register */
 
 #define NOZOMI_CONFIG_MAGIC0xEFEFFEFE
 #define TOGGLE_VALID   0x
 
 /* Definition of interrupt tokens */
-#define MDM_DL10x0001
-#define MDM_UL10x0002
-#define MDM_DL20x0004
-#define MDM_UL20x0008
-#define DIAG_DL1   0x0010
-#define DIAG_DL2   0x0020
-#define DIAG_UL0x0040
-#define APP1_DL0x0080
-#define APP1_UL0x0100
-#define APP2_DL0x0200
-#define APP2_UL0x0400
-#define CTRL_DL0x0800
-#define CTRL_UL0x1000
-#define RESET  0x8000
+#define MDM_DL10x0001
+#define MDM_UL10x0002
+#define MDM_DL20x0004
+#define MDM_UL20x0008
+#define DIAG_DL1   0x0010
+#define DIAG_DL2   0x0020
+#define DIAG_UL0x0040
+#define APP1_DL0x0080
+#define APP1_UL0x0100
+#define APP2_DL0x0200
+#define APP2_UL0x0400
+#define CTRL_DL0x0800
+#define CTRL_UL0x1000
+#define RESET  0x8000
 
-#define MDM_DL (MDM_DL1  | MDM_DL2)
-#define MDM_UL (MDM_UL1  | MDM_UL2)
-#define DIAG_DL(DIAG_DL1 | DIAG_DL2)
+#define MDM_DL (MDM_DL1  | MDM_DL2)
+#define MDM_UL (MDM_UL1  | MDM_UL2)
+#define DIAG_DL(DIAG_DL1 | DIAG_DL2)
 
 /* modem signal definition */
-#define CTRL_DSR   0x0001
-#define CTRL_DCD   0x0002
-#define CTRL_RI0x0004
-#define CTRL_CTS   0x0008
+#define CTRL_DSR   0x0001
+#define CTRL_DCD   0x0002
+#define CTRL_RI0x0004
+#define CTRL_CTS   0x0008
 
-#define CTRL_DTR   0x0001
-#define CTRL_RTS   0x0002
+#define CTRL_DTR   0x0001
+#define CTRL_RTS   0x0002
 
 #define MAX_PORT   4
 #define NOZOMI_MAX_PORTS   5
@@ -365,7 +365,7 @@ struct buffer {
u8 *data;
 } __attribute__ ((packed));
 
-/*Global variables */
+/* Global variables */
 static const struct pci_device_id nozomi_pci_tbl[] = {
{PCI_DEVICE(0x1931, 0x000c)},   /* Nozomi HSDPA */
{},
@@ -1686,12 +1686,12 @@ static int ntty_tiocmget(struct tty_struct *tty)
 
/* Note: these could change under us but it is not clear this
   matters if so */
-   return  (ctrl_ul->RTS ? TIOCM_RTS : 0) |
-   (ctrl_ul->DTR ? TIOCM_DTR : 0) |
-   (ctrl_dl->DCD ? TIOCM_CAR : 0) |
-   (ctrl_dl->RI  ? TIOCM_RNG : 0) |
-   (ctrl_dl->DSR ? TIOCM_DSR : 0) |
-   (ctrl_dl->CTS ? TIOCM_CTS : 0);
+   return (ctrl_ul->RTS ? TIOCM_RTS : 0)
+   | (ctrl_ul->DTR ? TIOCM_DTR : 0)
+   | (ctrl_dl->DCD ? TIOCM_CAR : 0)
+   | (ctrl_dl->RI  ? TIOCM_RNG : 0)
+   | (ctrl_dl->DSR ? TIOCM_DSR : 0)
+   | (ctrl_dl->CTS ? TIOCM_CTS : 0);
 }
 
 /* Sets io controls parameters */
@@ -1722,10 +1722,10 @@ static int ntty_cflags_changed(struct port *port, 
unsigned long flags,
const struct async_icount cnow = port->tty_icount;
int ret;
 
-   ret =   ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
-   ((flags & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) ||
-   ((flags & TIOCM_CD)  && (cnow.dcd != cprev->dcd)) ||
-   ((flags & TIOCM_CTS) && (cnow.cts != cprev->cts));
+   ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng))
+   || ((flags & TIOCM_DSR) && (cnow.dsr != cprev->dsr))
+   || ((flags & TIOCM_CD)  && (cnow.dcd != cprev->dcd))
+   || ((flags & TIOCM_CTS) && (cnow.cts != cprev->cts));
 
*cprev = cnow;
 
-- 
2.16.3



[PATCH 4/4] tty/nozomi: refactor conditional statements

2018-03-23 Thread Joey Pabalinas
Reduce unnecessarily deep nesting of blocks and simplify
control flow (e.g. "if/else" constructs changed to "if/return"
and single case "switch" statements changed to "if" conditionals
where possible).

Signed-off-by: Joey Pabalinas 

 1 file changed, 52 insertions(+), 50 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index a5074a59d3e3d33e68..0ea3e1de23c093e808 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -694,12 +694,13 @@ static void enable_transmit_ul(enum port_type port, 
struct nozomi *dc)
 {
static const u16 mask[] = {MDM_UL, DIAG_UL, APP1_UL, APP2_UL, CTRL_UL};
 
-   if (port < NOZOMI_MAX_PORTS) {
-   dc->last_ier |= mask[port];
-   writew(dc->last_ier, dc->reg_ier);
-   } else {
+   if (port >= NOZOMI_MAX_PORTS) {
dev_err(&dc->pdev->dev, "Called with wrong port?\n");
+   return;
}
+
+   dc->last_ier |= mask[port];
+   writew(dc->last_ier, dc->reg_ier);
 }
 
 /* Disable uplink interrupts  */
@@ -708,12 +709,13 @@ static void disable_transmit_ul(enum port_type port, 
struct nozomi *dc)
static const u16 mask[] =
{~MDM_UL, ~DIAG_UL, ~APP1_UL, ~APP2_UL, ~CTRL_UL};
 
-   if (port < NOZOMI_MAX_PORTS) {
-   dc->last_ier &= mask[port];
-   writew(dc->last_ier, dc->reg_ier);
-   } else {
+   if (port >= NOZOMI_MAX_PORTS) {
dev_err(&dc->pdev->dev, "Called with wrong port?\n");
+   return;
}
+
+   dc->last_ier &= mask[port];
+   writew(dc->last_ier, dc->reg_ier);
 }
 
 /* Enable downlink interrupts */
@@ -721,12 +723,13 @@ static void enable_transmit_dl(enum port_type port, 
struct nozomi *dc)
 {
static const u16 mask[] = {MDM_DL, DIAG_DL, APP1_DL, APP2_DL, CTRL_DL};
 
-   if (port < NOZOMI_MAX_PORTS) {
-   dc->last_ier |= mask[port];
-   writew(dc->last_ier, dc->reg_ier);
-   } else {
+   if (port >= NOZOMI_MAX_PORTS) {
dev_err(&dc->pdev->dev, "Called with wrong port?\n");
+   return;
}
+
+   dc->last_ier |= mask[port];
+   writew(dc->last_ier, dc->reg_ier);
 }
 
 /* Disable downlink interrupts */
@@ -735,12 +738,13 @@ static void disable_transmit_dl(enum port_type port, 
struct nozomi *dc)
static const u16 mask[] =
{~MDM_DL, ~DIAG_DL, ~APP1_DL, ~APP2_DL, ~CTRL_DL};
 
-   if (port < NOZOMI_MAX_PORTS) {
-   dc->last_ier &= mask[port];
-   writew(dc->last_ier, dc->reg_ier);
-   } else {
+   if (port >= NOZOMI_MAX_PORTS) {
dev_err(&dc->pdev->dev, "Called with wrong port?\n");
+   return;
}
+
+   dc->last_ier &= mask[port];
+   writew(dc->last_ier, dc->reg_ier);
 }
 
 /*
@@ -1028,33 +1032,31 @@ static int handle_data_dl(struct nozomi *dc, enum 
port_type port, u8 *toggle,
if (*toggle == 0 && read_iir & mask1) {
if (receive_data(port, dc)) {
writew(mask1, dc->reg_fcr);
-   *toggle = !(*toggle);
+   *toggle = !*toggle;
}
 
-   if (read_iir & mask2) {
-   if (receive_data(port, dc)) {
-   writew(mask2, dc->reg_fcr);
-   *toggle = !(*toggle);
-   }
+   if (read_iir & mask2 && receive_data(port, dc)) {
+   writew(mask2, dc->reg_fcr);
+   *toggle = !*toggle;
}
+
+   return 1;
} else if (*toggle == 1 && read_iir & mask2) {
if (receive_data(port, dc)) {
writew(mask2, dc->reg_fcr);
-   *toggle = !(*toggle);
+   *toggle = !*toggle;
}
 
-   if (read_iir & mask1) {
-   if (receive_data(port, dc)) {
-   writew(mask1, dc->reg_fcr);
-   *toggle = !(*toggle);
-   }
+   if (read_iir & mask1 && receive_data(port, dc)) {
+   writew(mask1, dc->reg_fcr);
+   *toggle = !*toggle;
}
-   } else {
-   dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n",
-   *toggle);
-   return 0;
+
+   return 1;
}
-   return 1;
+
+   dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n", *toggle);
+   return 0;
 }
 
 /*
@@ -1087,6 +1089,7 @@ static int handle_data_ul(struct nozomi *dc, enum 
port_type port, u16 read_iir)
}
}
 
+   return 1;
} else if (*toggle == 1 && read_iir & MDM_UL2) {
dc->last_ier &= ~MDM_UL;
writew(dc->last_ier, dc->reg_ier);
@@ -1107,12 +1110,13 @@ static int handle_data_ul(

Re: [PATCH v4 0/8] ARM: davinci: complete the conversion to using the reset framework

2018-03-23 Thread Suman Anna
Hi Bart,

On 03/23/2018 12:16 PM, Bartosz Golaszewski wrote:
> 2018-03-23 18:08 GMT+01:00 Stephen Boyd :
>> Quoting Bartosz Golaszewski (2018-03-23 09:55:47)
>>> 2018-03-23 17:49 GMT+01:00 Stephen Boyd :
 Quoting Bartosz Golaszewski (2018-03-23 06:04:47)
> From: Bartosz Golaszewski 
>
> This series converts the only user of the handcoded, mach-specific reset
> routines in the davinci platform to using the reset framework.
>
> Patch 1 modifies the way lookup entries are registered with the reset
> framework.
>
> Patches 2-4 add necessary lookups/DT-properties.
>
> Patches 5-7 convert the davinci-rproc driver to the reset framework.
>
> Patch 8 removes now dead code.
>
> Philipp: it turned out that it's indeed better to use the reset
> controller's device name for the entry lookup.
>
> Tested both in DT and legacy modes by booting the examples from
> ti-ipc-rtos recipe in meta-ti.
>
> This series applies on top of David Lechner's common-clk-v9 branch[1]
> with Philipp Zabel's reset/next branch[2] pulled in.
>
> It can be found in my github tree as well[3].
>

 What's the merge strategy for the rest of the patches? I should apply
 the clk ones after the next -rc1?
>>>
>>> Or maybe Philipp can provide us with an immutable branch with the reset 
>>> patches?
>>>
>>> The you could apply the driver patches and let Sekhar take all the
>>> platform code?
>>>
>>
>> Ok that could work too.
> 
> Ohad, Bjorn can you ack the remoteproc patches? Are you OK with
> Stephen taking them through the clock tree? Otherwise it would get
> complicated since they depend on the first clk patch and the last clk
> patch depends on them.

I will take a closer look and test on Mon. A quick glance of the
remoteproc changes seem to be fine. I will let Bjorn comment on the
patch flow.

The only reason I had to use the clock in the driver was for the reset
before, and hopefully this will allow me to actually switch to using
pm_runtime API like I do with the rest of the TI remoteproc drivers
(Keystone remoteproc driver also uses PSC for clock and reset but then
it goes through different set of drivers).

So, I see a mix of driver and dts patches in the series, are all the dts
patches coming through Sekhar?

regards
Suman

> 
> Thanks,
> Bart
> --
> To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



[PATCH 1/4] tty/nozomi: cleanup DUMP() macro

2018-03-23 Thread Joey Pabalinas
Replace snprint() with strscpy() and use max_t() instead of
the conditional operator.

Signed-off-by: Joey Pabalinas 

 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index b57b35066ebea94639..f26bf1d1e9ee0e74eb 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -72,19 +72,19 @@ do {
\
 
 #define TMP_BUF_MAX 256
 
-#define DUMP(buf__,len__) \
-  do {  \
-char tbuf[TMP_BUF_MAX] = {0};\
-if (len__ > 1) {\
-   snprintf(tbuf, len__ > TMP_BUF_MAX ? TMP_BUF_MAX : len__, "%s", buf__);\
-   if (tbuf[len__-2] == '\r') {\
-   tbuf[len__-2] = 'r';\
-   } \
-   DBG1("SENDING: '%s' (%d+n)", tbuf, len__);\
-} else {\
-   DBG1("SENDING: '%s' (%d)", tbuf, len__);\
-} \
-} while (0)
+#define DUMP(buf__, len__) \
+   do {\
+   char tbuf[TMP_BUF_MAX] = {0};   \
+   if (len__ > 1) {\
+   u32 data_len = min_t(u32, len__, TMP_BUF_MAX);  \
+   strscpy(tbuf, buf__, data_len); \
+   if (tbuf[data_len - 2] == '\r') \
+   tbuf[data_len - 2] = 'r';   \
+   DBG1("SENDING: '%s' (%d+n)", tbuf, len__);  \
+   } else {\
+   DBG1("SENDING: '%s' (%d)", tbuf, len__);\
+   }   \
+   } while (0)
 
 /*Defines */
 #define NOZOMI_NAME"nozomi"
-- 
2.16.3



Re: Return checks for clock calls

2018-03-23 Thread Fabio Estevam
Hi Abel,

On Fri, Mar 23, 2018 at 6:49 AM, Abel Vesa  wrote:
> Hi Shawn, Fabio,
>
> I'm trying to get the imx clks changes upstreamed. To that end, I reached this
> old commit that adds some wrappers over the generic clk API. Here is the 
> commit
> message:
>
> ARM: imx6: add return check for clock calls
>
> There are a bunch of clk_enable_prepare, clk_set_parent and 
> clk_set_rate
> calls in imx6 clock driver's initialization.  They are called without
> retunr check.  If there is something going wrong with the calls, they
> will just fail silently.
>
> The patch creates a set of helper functions imx_clk_enable_prepare,
> imx_clk_set_parent and imx_clk_set_rate, and use them instead from 
> clock
> initialization to check the return and print error message to tell
> failures if any.
>
> Signed-off-by: Shawn Guo 
>
> And it adds the imx_clk_set_parent, imx_clk_prepare_enable and
> imx_clk_set_rate which basically just print an error message if the generic
> functions have failed.
>
> The only plus of these wrappers is that we at least see that the generic
> functions have failed, but the behaviour is not changed in any way.
>
> Question is, do we want this upstreamed considering that we need to replace 
> the
> calls throughout all the older imx socs ?

IMHO we should not introduce these new helper functions.

We can simply explicitly check for errors with the existing clock
functions when needed.


[PATCH] kfifo: fix comment

2018-03-23 Thread Valentin Vidic
Cleanup unusual formatting in the note about locking.

Signed-off-by: Valentin Vidic 
---
 include/linux/kfifo.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index e251533a5939..89fc8dc7bf38 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -41,11 +41,11 @@
  */
 
 /*
- * Note about locking : There is no locking required until only * one reader
- * and one writer is using the fifo and no kfifo_reset() will be * called
- *  kfifo_reset_out() can be safely used, until it will be only called
+ * Note about locking: There is no locking required until only one reader
+ * and one writer is using the fifo and no kfifo_reset() will be called.
+ * kfifo_reset_out() can be safely used, until it will be only called
  * in the reader thread.
- *  For multiple writer and one reader there is only a need to lock the writer.
+ * For multiple writer and one reader there is only a need to lock the writer.
  * And vice versa for only one writer and multiple reader there is only a need
  * to lock the reader.
  */
-- 
2.16.2



Re: [PATCH v3] usb: dwc2: dwc2_vbus_supply_init: fix error check

2018-03-23 Thread kbuild test robot
Hi Tomeu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on balbi-usb/next]
[also build test WARNING on next-20180323]
[cannot apply to v4.16-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Tomeu-Vizoso/usb-dwc2-dwc2_vbus_supply_init-fix-error-check/20180324-063752
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next


coccinelle warnings: (new ones prefixed by >>)

>> drivers/usb/dwc2/hcd.c:367:9-16: ERROR: PTR_ERR applied after initialization 
>> to constant on line 366

vim +367 drivers/usb/dwc2/hcd.c

   358  
   359  static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg)
   360  {
   361  hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, 
"vbus");
   362  if (PTR_ERR(hsotg->vbus_supply) == -ENODEV) {
   363  hsotg->vbus_supply = NULL;
   364  return 0;
   365  } else if (IS_ERR(hsotg->vbus_supply)) {
 > 366  hsotg->vbus_supply = NULL;
 > 367  return PTR_ERR(hsotg->vbus_supply);
   368  }
   369  
   370  return regulator_enable(hsotg->vbus_supply);
   371  }
   372  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH][next] apparmor: fix error returns checks by making size a ssize_t

2018-03-23 Thread John Johansen
On 03/23/2018 04:34 PM, Colin King wrote:
> From: Colin Ian King 
> 
> Currently variable size is a unsigned size_t, hence comparisons to
> see if it is less than zero (for error checking) will always be
> false.  Fix this by making size a ssize_t
> 
> Detected by CoverityScan, CID#1466080 ("Unsigned compared against 0")
> 
> Fixes: 8e51f9087f40 ("apparmor: Add support for attaching profiles via xattr, 
> presence and value")
> Signed-off-by: Colin Ian King 
Acked-by: John Johansen 

and pulled into apparmor-next

> ---
>  security/apparmor/domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
> index 57cc892e05a2..590b7e8cd21c 100644
> --- a/security/apparmor/domain.c
> +++ b/security/apparmor/domain.c
> @@ -314,7 +314,7 @@ static int aa_xattrs_match(const struct linux_binprm 
> *bprm,
>  struct aa_profile *profile, unsigned int state)
>  {
>   int i;
> - size_t size;
> + ssize_t size;
>   struct dentry *d;
>   char *value = NULL;
>   int value_size = 0, ret = profile->xattr_count;
> 



Re: [PATCH] watchdog: davinci_wdt: fix error handling in davinci_wdt_probe()

2018-03-23 Thread Guenter Roeck

On 03/23/2018 02:36 PM, Alexey Khoroshilov wrote:

clk_disable_unprepare() was added to one error path,
but there is another one. The patch makes sure clk is
disabled at the both of them.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 


Reviewed-by: Guenter Roeck 


---
  drivers/watchdog/davinci_wdt.c | 15 +++
  1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index 3e4c592c239f..6c6594261cb7 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -236,15 +236,22 @@ static int davinci_wdt_probe(struct platform_device *pdev)
  
  	wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);

davinci_wdt->base = devm_ioremap_resource(dev, wdt_mem);
-   if (IS_ERR(davinci_wdt->base))
-   return PTR_ERR(davinci_wdt->base);
+   if (IS_ERR(davinci_wdt->base)) {
+   ret = PTR_ERR(davinci_wdt->base);
+   goto err_clk_disable;
+   }
  
  	ret = watchdog_register_device(wdd);

-   if (ret < 0) {
-   clk_disable_unprepare(davinci_wdt->clk);
+   if (ret) {
dev_err(dev, "cannot register watchdog device\n");
+   goto err_clk_disable;
}
  
+	return 0;

+
+err_clk_disable:
+   clk_disable_unprepare(davinci_wdt->clk);
+
return ret;
  }
  





Re: [PATCH v2] x86,sched: allow topologies where NUMA nodes share an LLC

2018-03-23 Thread Alison Schofield
On Thu, Mar 22, 2018 at 05:42:41PM -0700, Tim Chen wrote:
> On 03/22/2018 01:49 PM, Alison Schofield wrote:
> >
> > +*/
> > +   if (!topology_same_node(c, o) &&
> > +   (c->x86_vendor == X86_VENDOR_INTEL &&
> > +c->x86_model == INTEL_FAM6_SKYLAKE_X)) {
> > +   /* Use NUMA instead of coregroups for scheduling: */
> > +   x86_has_numa_in_package = true;
> 
> x86_has_numa_in_package will only be set true for SKYLAKE in the above? 
> 
> This boolean probably should be set for (!topology_same_node(c, o) && 
> match_die(c, o)) and not
> dependent on cpu family.  Only the return value should depend on cpu family.
> 
> Tim

Tim,

x86_has_numa_in_package is being set in set_cpu_sibling_map()  with the
same criteria you describe: (!topology_same_node(c, o) &&  match_die(c,
o))

Skylake in SNC mode takes that path and it gets set correctly, so I'm
thinking and seeing that the setting of it in match_llc() is redundant.

The intent of the patch is to skip the topology_sane() check to avoid
the warning message it spits out at boot time. 

This has me wondering if, aside from it being redundant, if it may be
incorrect? Should we set that boolean based on vendor/model alone in
match_llc().  I guess I need to understand what happens w a Skylake that
doesn't have SNC turned on. I can try that configuration next.

Thanks for reviewing!
alisons
> 
> 
> > +
> > +   /*
> > +* Return value doesn't actually matter because we
> > +* are throwing away coregroups for scheduling anyway.
> > +* Return false to bypass topology broken bug messages
> > +* and fixups in sched_domain().
> > +*/
> > +   return false;
> > +   }
> > +
> > +   return topology_sane(c, o, "llc");
> >  }
> >  
> >  /*
> > @@ -454,12 +492,6 @@ static struct sched_domain_topology_level 
> > x86_topology[] = {
> > { NULL, },
> >  };
> >  
> > -/*
> > - * Set if a package/die has multiple NUMA nodes inside.
> > - * AMD Magny-Cours and Intel Cluster-on-Die have this.
> > - */
> > -static bool x86_has_numa_in_package;
> > -
> >  void set_cpu_sibling_map(int cpu)
> >  {
> > bool has_smt = smp_num_siblings > 1;
> > 
> 


Re: [PATCH 4.15 00/84] 4.15.13-stable review

2018-03-23 Thread Guenter Roeck

On 03/23/2018 02:53 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.15.13 release.
There are 84 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun Mar 25 09:53:34 UTC 2018.
Anything received after that time might be too late.



For v4.15.12-84-g85ccdc8:

Build results:
total: 147 pass: 147 fail: 0
Qemu test results:
total: 141 pass: 141 fail: 0

Guenter


Re: [PATCH 4.14 00/77] 4.14.30-stable review

2018-03-23 Thread Guenter Roeck

On 03/23/2018 02:53 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.14.30 release.
There are 77 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun Mar 25 09:41:18 UTC 2018.
Anything received after that time might be too late.



For v4.14.29-77-g8a1e5a4:

Build results:
total: 145 pass: 145 fail: 0
Qemu test results:
total: 141 pass: 141 fail: 0

Guenter


Re: [PATCH 4.9 000/177] 4.9.90-stable review

2018-03-23 Thread Guenter Roeck

On 03/23/2018 02:52 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.9.90 release.
There are 177 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun Mar 25 09:41:28 UTC 2018.
Anything received after that time might be too late.



For v4.9.89-177-g87485cf:

Build results:
total: 145 pass: 145 fail: 0
Qemu test results:
total: 137 pass: 137 fail: 0

Guenter


Re: [PATCH 4.4 00/97] 4.4.124-stable review

2018-03-23 Thread Guenter Roeck

On 03/23/2018 02:53 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.4.124 release.
There are 97 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun Mar 25 09:41:34 UTC 2018.
Anything received after that time might be too late.



Build results:
total: 145 pass: 145 fail: 0
Qemu test results:
total: 127 pass: 127 fail: 0

Guenter


Re: [PATCH 3.18 00/47] 3.18.102-stable review

2018-03-23 Thread Guenter Roeck

On 03/23/2018 02:54 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 3.18.102 release.
There are 47 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun Mar 25 09:42:36 UTC 2018.
Anything received after that time might be too late.



Build results:
total: 136 pass: 136 fail: 0
Qemu test results:
total: 119 pass: 119 fail: 0

Guenter




Re: [PATCH 2/2] drivers: soc: Add LLCC driver

2018-03-23 Thread Channa

On 2018-03-19 07:55, Jordan Crouse wrote:

On Thu, Jan 25, 2018 at 03:55:13PM -0800, Channagoud Kadabi wrote:

LLCC (Last Level Cache Controller) provides additional cache memory
in the system. LLCC is partitioned into muliple slices and each
slice gets its own priority, size, ID and other config parameters.
LLCC driver programs these parameters for each slice. Clients that
are assigned to use LLCC need to get information such size & ID of the
slice for their usecase and activate or deactivate the slice as 
needed.

LLCC driver provides API interfaces for the clients to perform these
operations.





+/**
+ * llcc_slice_deactivate - Deactivate the llcc slice
+ * @desc: Pointer to llcc slice descriptor
+ *
+ * A value zero will be returned on success and a negative errno will
+ * be returned in error cases
+ */
+int llcc_slice_deactivate(struct llcc_slice_desc *desc)
+{
+   u32 act_ctrl_val;
+   int rc = -EINVAL;
+   struct llcc_drv_data *drv;
+
+   if (desc == NULL) {
+   pr_err("Input descriptor supplied is invalid\n");


Sorry that this is out of the blue, but I was reviewing a client driver 
that
uses this API. This should not print an error - we should be allowed to 
safely

pass a null pointer from an aborted sequence in the driver without the
conditional checks and it shouldn't generate a bit of log spam as it 
goes about

it's business.


Thanks Jordan. I will incorporate this change in my next patchset.



Jordan


--
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,

a Linux Foundation Collaborative Project


Re: [PATCH v2] venus: vdec: fix format enumeration

2018-03-23 Thread Stanimir Varbanov

Hi Hans,

Could you take this patch it not too late.

On 20.03.2018 15:42, Stanimir Varbanov wrote:

Hi Alex,

Thanks!

On 03/19/2018 11:32 AM, Alexandre Courbot wrote:

find_format_by_index() stops enumerating formats as soon as the index
matches, and returns NULL if venus_helper_check_codec() finds out that
the format is not supported. This prevents formats to be properly
enumerated if a non-supported format is present, as the enumeration will
end with it.

Fix this by moving the call to venus_helper_check_codec() into the loop,
and keep enumerating when it fails.

Fixes: 29f0133ec6 media: venus: use helper function to check supported codecs

Signed-off-by: Alexandre Courbot 
---
  drivers/media/platform/qcom/venus/vdec.c | 13 +++--
  drivers/media/platform/qcom/venus/venc.c | 13 +++--
  2 files changed, 14 insertions(+), 12 deletions(-)


Acked-by: Stanimir Varbanov 



regards,
Stan


[PATCH] net: qualcomm: rmnet: check for null ep to avoid null pointer dereference

2018-03-23 Thread Colin King
From: Colin Ian King 

The call to rmnet_get_endpoint can potentially return NULL so check
for this to avoid any subsequent null pointer dereferences on a NULL
ep.

Detected by CoverityScan, CID#1465385 ("Dereference null return value")

Fixes: 23790ef12082 ("net: qualcomm: rmnet: Allow to configure flags for 
existing devices")
Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c 
b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 38d9356ebcc4..d33988570217 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -312,6 +312,8 @@ static int rmnet_changelink(struct net_device *dev, struct 
nlattr *tb[],
if (data[IFLA_RMNET_MUX_ID]) {
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
ep = rmnet_get_endpoint(port, priv->mux_id);
+   if (!ep)
+   return -ENODEV;
 
hlist_del_init_rcu(&ep->hlnode);
hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
-- 
2.15.1



Re: [PATCH v4 0/5] Support qcom pinctrl protected pins

2018-03-23 Thread Timur Tabi

On 03/23/2018 11:34 AM, Stephen Boyd wrote:

Stephen Boyd (5):
   dt-bindings: gpio: Add a gpio-reserved-ranges property
   gpiolib: Extract mask allocation into subroutine
   gpiolib: Change bitmap allocation to kmalloc_array
   gpiolib: Support 'gpio-reserved-ranges' property
   pinctrl: qcom: Don't allow protected pins to be requested


ACPI parts:

Tested-by: Timur Tabi 

I posted a pair of patches that should be applied on top of yours.  The 
first one fixed pinctrl-msm when there is more than one TLMM device. 
The second adds support for my SOC.


--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.


[alsa-devel][PATCH 3/3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-23 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate, which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |  6 ++
 sound/soc/codecs/tscs42xx.c| 98 ++
 sound/soc/codecs/tscs42xx.h|  2 +-
 3 files changed, 69 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <&audio_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..081af0e05d33 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
 
-   switch (clk_id) {
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, ®);
+   if (ret < 0)
+   return ret;
+
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, ®);
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, ®);
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, ®);
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_widgets),
.dapm_routes= tscs42xx_intercon,
@@ -1387,11 +1397,15 @@ static const struct reg_sequence tscs42xx_patch[] = {
{ R_AIC2, RV_AIC2_

[PATCH v1 2/2] drivers: soc: Add LLCC driver

2018-03-23 Thread Rishabh Bhatnagar
From: "ckad...@codeaurora.org" 

LLCC (Last Level Cache Controller) provides additional cache memory
in the system. LLCC is partitioned into muliple slices and each
slice getting its own priority, size, ID and other config parameters.
LLCC driver programs these parameters for each slice. Clients that
are assigned to use LLCC need to get information such size & ID of the
 slice they get and activate or deactivate the slice as needed. LLCC driver
provides API interfaces for the clients to perform these operations.

Change-Id: I93c5f3225d0a917f0d6c64c7588a4e64e33a59ed
Signed-off-by: Channagoud Kadabi 
Signed-off-by: Rishabh Bhatnagar 
---
 drivers/soc/qcom/llcc-sdm845.c | 120 ++
 drivers/soc/qcom/llcc-slice.c  | 454 +
 include/linux/soc/qcom/llcc-qcom.h | 178 +++
 3 files changed, 752 insertions(+)
 create mode 100644 drivers/soc/qcom/llcc-sdm845.c
 create mode 100644 drivers/soc/qcom/llcc-slice.c
 create mode 100644 include/linux/soc/qcom/llcc-qcom.h

diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c
new file mode 100644
index 000..cd431d9
--- /dev/null
+++ b/drivers/soc/qcom/llcc-sdm845.c
@@ -0,0 +1,120 @@
+/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+ 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+/*
+ * SCT entry contains of the following parameters
+ * name: Name of the client's use case for which the llcc slice is used
+ * uid: Unique id for the client's use case
+ * slice_id: llcc slice id for each client
+ * max_cap: The maximum capacity of the cache slice provided in KB
+ * priority: Priority of the client used to select victim line for replacement
+ * fixed_size: Determine of the slice has a fixed capacity
+ * bonus_ways: Bonus ways to be used by any slice, bonus way is used only if
+ * it't not a reserved way.
+ * res_ways: Reserved ways for the cache slice, the reserved ways cannot be 
used
+ *   by any other client than the one its assigned to.
+ * cache_mode: Each slice operates as a cache, this controls the mode of the
+ * slice normal or TCM
+ * probe_target_ways: Determines what ways to probe for access hit. When
+ *configured to 1 only bonus and reseved ways are probed.
+ *when configured to 0 all ways in llcc are probed.
+ * dis_cap_alloc: Disable capacity based allocation for a client
+ * retain_on_pc: If this bit is set and client has maitained active vote
+ *   then the ways assigned to this client are not flushed on power
+ *   collapse.
+ * activate_on_init: Activate the slice immidiately after the SCT is programmed
+ */
+#define SCT_ENTRY(n, uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) \
+   {   \
+   .name = n,  \
+   .usecase_id = uid,  \
+   .slice_id = sid,\
+   .max_cap = mc,  \
+   .priority = p,  \
+   .fixed_size = fs,   \
+   .bonus_ways = bway, \
+   .res_ways = rway,   \
+   .cache_mode = cmod, \
+   .probe_target_ways = ptw,   \
+   .dis_cap_alloc = dca,   \
+   .retain_on_pc = rp, \
+   .activate_on_init = a,  \
+   }
+
+
+static struct llcc_slice_config sdm845_data[] =  {
+   SCT_ENTRY("cpuss",   1, 1, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 1),
+   SCT_ENTRY("vidsc0",  2, 2, 512, 2, 1, 0x0,  0x0F0, 0, 0, 1, 1, 0),
+   SCT_ENTRY("vidsc1",  3, 3, 512, 2, 1, 0x0,  0x0F0, 0, 0, 1, 1, 0),
+   SCT_ENTRY("rotator", 4, 4, 563, 2, 1, 0x0,  0x00e, 2, 0, 1, 1, 0),
+   SCT_ENTRY("voice",   5, 5, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+   SCT_ENTRY("audio",   6, 6, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+   SCT_ENTRY("modemhp_grow", 7, 7, 1024, 2, 0, 0x0FC, 0xF00, 0, 0, 1, 1, 
0),
+   SCT_ENTRY("modem",   8, 8, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+   SCT_ENTRY("compute", 10, 10, 2816, 1, 0, 0xFFC, 0x2, 0, 0, 1, 1, 0),
+   SCT_ENTRY("gpuhtw",  11, 11, 512, 1, 1, 0xC,  0x0, 0, 0, 1, 1, 0),
+   SCT_ENTRY("gpu", 12, 12, 2304, 1, 0, 0xFF0, 0x2, 0, 0, 1, 1, 0),
+   SCT_ENTRY("mmuhwt",  13, 13, 2

[PATCH v1 1/2] Documentation: Documentaion for qcom, llcc

2018-03-23 Thread Rishabh Bhatnagar
From: "ckad...@codeaurora.org" 

Documentation for last level cache controller device tree bindings,
client bindings usage examples.

Change-Id: Ic2d6d6154ab8269cfce6828e9f2250320a0572e8
Signed-off-by: Channagoud Kadabi 
Signed-off-by: Rishabh Bhatnagar 
---
 .../devicetree/bindings/arm/msm/qcom,llcc.txt  | 70 ++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
new file mode 100644
index 000..ceb20a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
@@ -0,0 +1,70 @@
+== Introduction==
+
+LLCC (Last Level Cache Controller) driver is implemented as a platform device.
+The driver Programs the SCT (system configuration table). The SCT programming 
+divides the system cache into slices. Each slice is assigned an ID A.K.A 
+SCID(Sub-cache ID).
+HW modules that are designated to use the system cache are known as clients.   
+Each client must also be represented as a node in the device tree just like
+any other hw module.   
+One client can have multiple SCID's assigned meaning each client could get 

+multiple slices in the cache. Client can use the slices for various pre-defined
+usecases. Each client defines a set of names for these usecases in its 
+device tree binding.   
+Client makes a request to LLCC device to get cache-slices properties for each  
+of its usecase. Client gets the information like cache slice ID and size of the
+cache slice.
+
+== llcc device ==
+
+Properties:
+- compatible:
+Usage: required
+Value type: 
+Definition: must be "qcom,sdm855-llcc"
+
+- reg:
+Usage: required
+Value Type: 
+Definition: must be addresses and sizes of the LLCC registers
+
+- #cache-cells:
+Usage: required
+Value Type: 
+Definition: Number of cache cells, must be 1
+
+- max-slices:
+usage: required
+Value Type: 
+Definition: Number of cache slices supported by hardware
+
+Example:
+
+   llcc: qcom,sdm855-llcc@0110 {
+   compatible = "qcom,sdm845-llcc";
+   reg = <0x0110 0x25>;
+   #cache-cells = <1>;
+   max-slices = <32>;
+   };
+
+== Client ==
+
+Required properties:
+- cache-slice-names:
+Usage: required
+Value type: 
+Definition: A set of names that identify the usecase names of a client 
that
+   uses cache slice. These strings are used to look up the 
cache slice
+   entries by name.
+
+- cache-slices:
+Usage: required
+Value type: 
+Definition: The tuple has phandle to llcc device as the first argument 
and 
+   the second argument is the usecase id of the client.
+For Example:
+
+venus {
+   cache-slice-names = "vidsc0", "vidsc1";
+   cache-slices = <&llcc 2>, <&llcc 3>;
+};
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 0/2] SDM845 System Cache Driver

2018-03-23 Thread Rishabh Bhatnagar
This series implements system cache or LLCC(Last Level Cache Controller) driver
for SDM845 SOC. The purpose of the driver is to partition the system cache and
program the settings such as priortiy, lines to probe while doing a look up
in the system cache, low power related settings etc. The partitions are called
cache slices. Each cache slice is associated with size and SCID(System Cache ID)
The driver also provides API for clients to query the cache slice details,
activate and deactivate them.

The driver can be broadly classified into:
* SOC specific driver: llcc-sdm845.c: Cache partitioning and cache slice
properties for usecases on sdm845 that need to use system cache.

* API : llcc-slice.c: Exports APIs to clients to query cache slice details,
activate and deactivate cache slices. Register the child devices using platform 
APIs.

Changes since v0:
* Removed the syscon and simple-mfd approach
* Updated the device tree nodes to mention LLCC as a single HW block
* Moved llcc bank offsets from device tree and handled the offset
  in the driver.


ckad...@codeaurora.org (2):
  Documentation: Documentaion for qcom, llcc
  drivers: soc: Add LLCC driver

 .../devicetree/bindings/arm/msm/qcom,llcc.txt  |  78 
 drivers/soc/qcom/llcc-sdm845.c | 120 ++
 drivers/soc/qcom/llcc-slice.c  | 460 +
 include/linux/soc/qcom/llcc-qcom.h | 178 
 4 files changed, 836 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,llcc.txt
 create mode 100644 drivers/soc/qcom/llcc-sdm845.c
 create mode 100644 drivers/soc/qcom/llcc-slice.c
 create mode 100644 include/linux/soc/qcom/llcc-qcom.h

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH][next] apparmor: fix error returns checks by making size a ssize_t

2018-03-23 Thread Colin King
From: Colin Ian King 

Currently variable size is a unsigned size_t, hence comparisons to
see if it is less than zero (for error checking) will always be
false.  Fix this by making size a ssize_t

Detected by CoverityScan, CID#1466080 ("Unsigned compared against 0")

Fixes: 8e51f9087f40 ("apparmor: Add support for attaching profiles via xattr, 
presence and value")
Signed-off-by: Colin Ian King 
---
 security/apparmor/domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
index 57cc892e05a2..590b7e8cd21c 100644
--- a/security/apparmor/domain.c
+++ b/security/apparmor/domain.c
@@ -314,7 +314,7 @@ static int aa_xattrs_match(const struct linux_binprm *bprm,
   struct aa_profile *profile, unsigned int state)
 {
int i;
-   size_t size;
+   ssize_t size;
struct dentry *d;
char *value = NULL;
int value_size = 0, ret = profile->xattr_count;
-- 
2.15.1



[alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Cleanup private data members

2018-03-23 Thread Steven Eckhoff
In the TSCS42xx driver there are some unnecesarry private data members

Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 37636d6efe60..d41852a37ac6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = &i2c->dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, &tscs42xx_regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(&i2c->dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(&i2c->dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(&i2c->dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(&i2c->dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(&tscs42xx->coeff_ram_lock);
mutex_init(&tscs42xx->pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_tscs42xx, &tscs42xx_dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(&i2c->dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



[alsa-devel][PATCH 1/3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-03-23 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index cfc71b5411ee..37636d6efe60 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_ADCSR, RM_DACSR_DBR, 
br);
+   ret = snd_so

Re: [PATCH 1/2] fs: Extend mount_ns with support for a fast namespace to vfsmount function

2018-03-23 Thread Al Viro
On Fri, Mar 23, 2018 at 04:41:40PM -0500, Eric W. Biederman wrote:

>  struct dentry *mount_ns(struct file_system_type *fs_type,
>   int flags, void *data, void *ns, struct user_namespace *user_ns,
> + struct vfsmount *(*ns_to_mnt)(void *ns),
>   int (*fill_super)(struct super_block *, void *, int))
>  {
>   struct super_block *sb;
> -
> + int (*test_super)(struct super_block *, void *) = ns_test_super;
>   /* Don't allow mounting unless the caller has CAP_SYS_ADMIN
>* over the namespace.
>*/
>   if (!(flags & SB_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN))
>   return ERR_PTR(-EPERM);
>  
> - sb = sget_userns(fs_type, ns_test_super, ns_set_super, flags,
> -  user_ns, ns);
> + if (ns_to_mnt) {
> + test_super = NULL;
> + if (!(flags & SB_KERNMOUNT)) {
> + struct vfsmount *m = ns_to_mnt(ns);
> + if (IS_ERR(m))
> + return ERR_CAST(m);
> + atomic_inc(&m->mnt_sb->s_active);
> + down_write(&m->mnt_sb->s_umount);
> + return dget(m->mnt_root);

This is completely wrong.  Look:
* SB_KERNMOUNT and !SB_KERNMOUNT cases are almost entirely isolated;
completely so once that ns_to_mnt becomes unconditionally non-NULL.  
* in !SB_KERNMOUNT passing ns_to_mnt() is pointless - you might as
well pass existing vfsmount (or ERR_PTR()) and use _that_.  fill_super()
is not used at all in that case.
* is SB_KERNMOUNT ns_to_mnt serves only as a flag, eventually
constant true.

So let's split it in two helpers and give them sane arguments.


[PATCH 4/8] cgroup: Reorganize kernel/cgroup/rstat.c

2018-03-23 Thread Tejun Heo
Currently, rstat.c has rstat and base stat implementations intermixed.
Collect base stat implementation at the end of the file.  Also,
reorder the prototypes.

This patch doesn't make any functional changes.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup/cgroup-internal.h |   2 +-
 kernel/cgroup/rstat.c   | 182 +---
 2 files changed, 95 insertions(+), 89 deletions(-)

diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index aab4d0a..2bf6fb4 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -206,8 +206,8 @@ int cgroup_task_count(const struct cgroup *cgrp);
 void cgroup_rstat_flush(struct cgroup *cgrp);
 int cgroup_rstat_init(struct cgroup *cgrp);
 void cgroup_rstat_exit(struct cgroup *cgrp);
-void cgroup_base_stat_cputime_show(struct seq_file *seq);
 void cgroup_rstat_boot(void);
+void cgroup_base_stat_cputime_show(struct seq_file *seq);
 
 /*
  * namespace.c
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index 7670191..87d7252 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -5,6 +5,8 @@
 static DEFINE_MUTEX(cgroup_rstat_mutex);
 static DEFINE_PER_CPU(raw_spinlock_t, cgroup_rstat_cpu_lock);
 
+static void cgroup_base_stat_flush(struct cgroup *cgrp, int cpu);
+
 static struct cgroup_rstat_cpu *cgroup_rstat_cpu(struct cgroup *cgrp, int cpu)
 {
return per_cpu_ptr(cgrp->rstat_cpu, cpu);
@@ -128,6 +130,98 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct 
cgroup *pos,
return pos;
 }
 
+/* see cgroup_rstat_flush() */
+static void cgroup_rstat_flush_locked(struct cgroup *cgrp)
+{
+   int cpu;
+
+   lockdep_assert_held(&cgroup_rstat_mutex);
+
+   for_each_possible_cpu(cpu) {
+   raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock,
+  cpu);
+   struct cgroup *pos = NULL;
+
+   raw_spin_lock_irq(cpu_lock);
+   while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu)))
+   cgroup_base_stat_flush(pos, cpu);
+   raw_spin_unlock_irq(cpu_lock);
+   }
+}
+
+/**
+ * cgroup_rstat_flush - flush stats in @cgrp's subtree
+ * @cgrp: target cgroup
+ *
+ * Collect all per-cpu stats in @cgrp's subtree into the global counters
+ * and propagate them upwards.  After this function returns, all cgroups in
+ * the subtree have up-to-date ->stat.
+ *
+ * This also gets all cgroups in the subtree including @cgrp off the
+ * ->updated_children lists.
+ */
+void cgroup_rstat_flush(struct cgroup *cgrp)
+{
+   mutex_lock(&cgroup_rstat_mutex);
+   cgroup_rstat_flush_locked(cgrp);
+   mutex_unlock(&cgroup_rstat_mutex);
+}
+
+int cgroup_rstat_init(struct cgroup *cgrp)
+{
+   int cpu;
+
+   /* the root cgrp has rstat_cpu preallocated */
+   if (!cgrp->rstat_cpu) {
+   cgrp->rstat_cpu = alloc_percpu(struct cgroup_rstat_cpu);
+   if (!cgrp->rstat_cpu)
+   return -ENOMEM;
+   }
+
+   /* ->updated_children list is self terminated */
+   for_each_possible_cpu(cpu) {
+   struct cgroup_rstat_cpu *rstatc = cgroup_rstat_cpu(cgrp, cpu);
+
+   rstatc->updated_children = cgrp;
+   u64_stats_init(&rstatc->bsync);
+   }
+
+   return 0;
+}
+
+void cgroup_rstat_exit(struct cgroup *cgrp)
+{
+   int cpu;
+
+   cgroup_rstat_flush(cgrp);
+
+   /* sanity check */
+   for_each_possible_cpu(cpu) {
+   struct cgroup_rstat_cpu *rstatc = cgroup_rstat_cpu(cgrp, cpu);
+
+   if (WARN_ON_ONCE(rstatc->updated_children != cgrp) ||
+   WARN_ON_ONCE(rstatc->updated_next))
+   return;
+   }
+
+   free_percpu(cgrp->rstat_cpu);
+   cgrp->rstat_cpu = NULL;
+}
+
+void __init cgroup_rstat_boot(void)
+{
+   int cpu;
+
+   for_each_possible_cpu(cpu)
+   raw_spin_lock_init(per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu));
+
+   BUG_ON(cgroup_rstat_init(&cgrp_dfl_root.cgrp));
+}
+
+/*
+ * Functions for cgroup basic resource statistics implemented on top of
+ * rstat.
+ */
 static void cgroup_base_stat_accumulate(struct cgroup_base_stat *dst_bstat,
struct cgroup_base_stat *src_bstat)
 {
@@ -170,43 +264,6 @@ static void cgroup_base_stat_flush(struct cgroup *cgrp, 
int cpu)
cgroup_base_stat_accumulate(&parent->pending_bstat, &delta);
 }
 
-/* see cgroup_rstat_flush() */
-static void cgroup_rstat_flush_locked(struct cgroup *cgrp)
-{
-   int cpu;
-
-   lockdep_assert_held(&cgroup_rstat_mutex);
-
-   for_each_possible_cpu(cpu) {
-   raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock,
-  cpu);
-   struct cgroup *pos = NULL;
-
-   raw_spin_lock_irq(cpu_lock);
-   while ((pos = cg

[PATCH 3/8] cgroup: Distinguish base resource stat implementation from rstat

2018-03-23 Thread Tejun Heo
Base resource stat accounts universial (not specific to any
controller) resource consumptions on top of rstat.  Currently, its
implementation is intermixed with rstat implementation making the code
confusing to follow.

This patch clarifies the distintion by doing the followings.

* Encapsulate base resource stat counters, currently only cputime, in
  struct cgroup_base_stat.

* Move prev_cputime into struct cgroup and initialize it with cgroup.

* Rename the related functions so that they start with cgroup_base_stat.

* Prefix the related variables and field names with b.

This patch doesn't make any functional changes.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup-defs.h | 29 ++
 kernel/cgroup/cgroup-internal.h |  2 +-
 kernel/cgroup/cgroup.c  |  4 ++-
 kernel/cgroup/rstat.c   | 67 -
 4 files changed, 52 insertions(+), 50 deletions(-)

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 02625cf..cf9db7b 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -258,6 +258,10 @@ struct css_set {
struct rcu_head rcu_head;
 };
 
+struct cgroup_base_stat {
+   struct task_cputime cputime;
+};
+
 /*
  * rstat - cgroup scalable recursive statistics.  Accounting is done
  * per-cpu in cgroup_rstat_cpu which is then lazily propagated up the
@@ -273,20 +277,24 @@ struct css_set {
  * aren't active and stat may be read frequently.  The combination can
  * become very expensive.  By propagating selectively, increasing reading
  * frequency decreases the cost of each read.
+ *
+ * This struct hosts both the fields which implement the above -
+ * updated_children and updated_next - and the fields which track basic
+ * resource statistics on top of it - bsync, bstat and last_bstat.
  */
 struct cgroup_rstat_cpu {
/*
-* ->sync protects all the current counters.  These are the only
-* fields which get updated in the hot path.
+* ->bsync protects ->bstat.  These are the only fields which get
+* updated in the hot path.
 */
-   struct u64_stats_sync sync;
-   struct task_cputime cputime;
+   struct u64_stats_sync bsync;
+   struct cgroup_base_stat bstat;
 
/*
 * Snapshots at the last reading.  These are used to calculate the
 * deltas to propagate to the global counters.
 */
-   struct task_cputime last_cputime;
+   struct cgroup_base_stat last_bstat;
 
/*
 * Child cgroups with stat updates on this cpu since the last read
@@ -303,12 +311,6 @@ struct cgroup_rstat_cpu {
struct cgroup *updated_next;/* NULL iff not on the list */
 };
 
-struct cgroup_stat {
-   /* per-cpu statistics are collected into the folowing global counters */
-   struct task_cputime cputime;
-   struct prev_cputime prev_cputime;
-};
-
 struct cgroup {
/* self css with NULL ->ss, points back to this cgroup */
struct cgroup_subsys_state self;
@@ -412,8 +414,9 @@ struct cgroup {
struct cgroup_rstat_cpu __percpu *rstat_cpu;
 
/* cgroup basic resource statistics */
-   struct cgroup_stat pending_stat;/* pending from children */
-   struct cgroup_stat stat;
+   struct cgroup_base_stat pending_bstat;  /* pending from children */
+   struct cgroup_base_stat bstat;
+   struct prev_cputime prev_cputime;   /* for printing out cputime */
 
/*
 * list of pidlists, up to two for each namespace (one for procs, one
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index 0927111..aab4d0a 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -206,7 +206,7 @@ int cgroup_task_count(const struct cgroup *cgrp);
 void cgroup_rstat_flush(struct cgroup *cgrp);
 int cgroup_rstat_init(struct cgroup *cgrp);
 void cgroup_rstat_exit(struct cgroup *cgrp);
-void cgroup_stat_show_cputime(struct seq_file *seq);
+void cgroup_base_stat_cputime_show(struct seq_file *seq);
 void cgroup_rstat_boot(void);
 
 /*
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 5549a7c..0d3d093 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -54,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define CREATE_TRACE_POINTS
@@ -1859,6 +1860,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
cgrp->dom_cgrp = cgrp;
cgrp->max_descendants = INT_MAX;
cgrp->max_depth = INT_MAX;
+   prev_cputime_init(&cgrp->prev_cputime);
 
for_each_subsys(ss, ssid)
INIT_LIST_HEAD(&cgrp->e_csets[ssid]);
@@ -3396,7 +3398,7 @@ static int cpu_stat_show(struct seq_file *seq, void *v)
struct cgroup __maybe_unused *cgrp = seq_css(seq)->cgroup;
int ret = 0;
 
-   cgroup_stat_show_cputime(seq);
+   cgroup_base_stat_cputime_show(seq);
 #ifdef CONFIG_CGROUP_SCHED
ret = c

[PATCH 5/8] cgroup: Factor out and expose cgroup_rstat_*() interface functions

2018-03-23 Thread Tejun Heo
cgroup_rstat is being generalized so that controllers can use it too.
This patch factors out and exposes the following interface functions.

* cgroup_rstat_updated(): Renamed from cgroup_rstat_cpu_updated() for
  consistency.

* cgroup_rstat_flush_hold/release(): Factored out from base stat
  implementation.

* cgroup_rstat_flush(): Verbatim expose.

While at it, drop assert on cgroup_rstat_mutex in
cgroup_base_stat_flush() as it crosses layers and make a minor comment
update.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup.h  | 11 +--
 kernel/cgroup/cgroup-internal.h |  1 -
 kernel/cgroup/rstat.c   | 41 +
 3 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 473e0c0..5c6018f 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -690,11 +690,18 @@ static inline void cgroup_path_from_kernfs_id(const union 
kernfs_node_id *id,
char *buf, size_t buflen) {}
 #endif /* !CONFIG_CGROUPS */
 
+#ifdef CONFIG_CGROUPS
 /*
- * Basic resource stats.
+ * cgroup scalable recursive statistics.
  */
-#ifdef CONFIG_CGROUPS
+void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
+void cgroup_rstat_flush(struct cgroup *cgrp);
+void cgroup_rstat_flush_hold(struct cgroup *cgrp);
+void cgroup_rstat_flush_release(void);
 
+/*
+ * Basic resource stats.
+ */
 #ifdef CONFIG_CGROUP_CPUACCT
 void cpuacct_charge(struct task_struct *tsk, u64 cputime);
 void cpuacct_account_field(struct task_struct *tsk, int index, u64 val);
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index 2bf6fb4..b68e1a7 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -203,7 +203,6 @@ int cgroup_task_count(const struct cgroup *cgrp);
 /*
  * rstat.c
  */
-void cgroup_rstat_flush(struct cgroup *cgrp);
 int cgroup_rstat_init(struct cgroup *cgrp);
 void cgroup_rstat_exit(struct cgroup *cgrp);
 void cgroup_rstat_boot(void);
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index 87d7252..e3c4461 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -13,7 +13,7 @@ static struct cgroup_rstat_cpu *cgroup_rstat_cpu(struct 
cgroup *cgrp, int cpu)
 }
 
 /**
- * cgroup_rstat_cpu_updated - keep track of updated rstat_cpu
+ * cgroup_rstat_updated - keep track of updated rstat_cpu
  * @cgrp: target cgroup
  * @cpu: cpu on which rstat_cpu was updated
  *
@@ -21,7 +21,7 @@ static struct cgroup_rstat_cpu *cgroup_rstat_cpu(struct 
cgroup *cgrp, int cpu)
  * rstat_cpu->updated_children list.  See the comment on top of
  * cgroup_rstat_cpu definition for details.
  */
-static void cgroup_rstat_cpu_updated(struct cgroup *cgrp, int cpu)
+void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
 {
raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu);
struct cgroup *parent;
@@ -167,6 +167,29 @@ void cgroup_rstat_flush(struct cgroup *cgrp)
mutex_unlock(&cgroup_rstat_mutex);
 }
 
+/**
+ * cgroup_rstat_flush_begin - flush stats in @cgrp's subtree and hold
+ * @cgrp: target cgroup
+ *
+ * Flush stats in @cgrp's subtree and prevent further flushes.  Must be
+ * paired with cgroup_rstat_flush_release().
+ */
+void cgroup_rstat_flush_hold(struct cgroup *cgrp)
+   __acquires(&cgroup_rstat_mutex)
+{
+   mutex_lock(&cgroup_rstat_mutex);
+   cgroup_rstat_flush_locked(cgrp);
+}
+
+/**
+ * cgroup_rstat_flush_release - release cgroup_rstat_flush_hold()
+ */
+void cgroup_rstat_flush_release(void)
+   __releases(&cgroup_rstat_mutex)
+{
+   mutex_unlock(&cgroup_rstat_mutex);
+}
+
 int cgroup_rstat_init(struct cgroup *cgrp)
 {
int cpu;
@@ -239,15 +262,13 @@ static void cgroup_base_stat_flush(struct cgroup *cgrp, 
int cpu)
struct cgroup_base_stat delta;
unsigned seq;
 
-   lockdep_assert_held(&cgroup_rstat_mutex);
-
/* fetch the current per-cpu values */
do {
seq = __u64_stats_fetch_begin(&rstatc->bsync);
cputime = rstatc->bstat.cputime;
} while (__u64_stats_fetch_retry(&rstatc->bsync, seq));
 
-   /* accumulate the deltas to propgate */
+   /* calculate the delta to propgate */
delta.cputime.utime = cputime.utime - last_cputime->utime;
delta.cputime.stime = cputime.stime - last_cputime->stime;
delta.cputime.sum_exec_runtime = cputime.sum_exec_runtime -
@@ -278,7 +299,7 @@ static void cgroup_base_stat_cputime_account_end(struct 
cgroup *cgrp,
 struct cgroup_rstat_cpu 
*rstatc)
 {
u64_stats_update_end(&rstatc->bsync);
-   cgroup_rstat_cpu_updated(cgrp, smp_processor_id());
+   cgroup_rstat_updated(cgrp, smp_processor_id());
put_cpu_ptr(rstatc);
 }
 
@@ -323,14 +344,10 @@ void cgroup_base_stat_cputime_show(struct seq_file *seq)
if (!cgroup_parent(cgrp))
return;
 
-   mutex_lock(&cgroup_rstat_mut

[PATCH 2/8] cgroup: Rename stat to rstat

2018-03-23 Thread Tejun Heo
stat is too generic a name and ends up causing subtle confusions.
It'll be made generic so that controllers can plug into it, which will
make the problem worse.  Let's rename it to something more specific -
cgroup_rstat for cgroup recursive stat.

This patch does the following renames.  No other changes.

* cpu_stat  -> rstat_cpu
* stat  -> rstat
* ?cstat-> ?rstatc

Note that the renames are selective.  The unrenamed are the ones which
implement basic resource statistics on top of rstat.  This will be
further cleaned up in the following patches.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup-defs.h |  16 ++--
 kernel/cgroup/cgroup-internal.h |  10 +--
 kernel/cgroup/cgroup.c  |  14 ++--
 kernel/cgroup/rstat.c   | 180 
 4 files changed, 112 insertions(+), 108 deletions(-)

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 90ede40..02625cf 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -259,11 +259,11 @@ struct css_set {
 };
 
 /*
- * cgroup basic resource usage statistics.  Accounting is done per-cpu in
- * cgroup_cpu_stat which is then lazily propagated up the hierarchy on
- * reads.
+ * rstat - cgroup scalable recursive statistics.  Accounting is done
+ * per-cpu in cgroup_rstat_cpu which is then lazily propagated up the
+ * hierarchy on reads.
  *
- * When a stat gets updated, the cgroup_cpu_stat and its ancestors are
+ * When a stat gets updated, the cgroup_rstat_cpu and its ancestors are
  * linked into the updated tree.  On the following read, propagation only
  * considers and consumes the updated tree.  This makes reading O(the
  * number of descendants which have been active since last read) instead of
@@ -274,7 +274,7 @@ struct css_set {
  * become very expensive.  By propagating selectively, increasing reading
  * frequency decreases the cost of each read.
  */
-struct cgroup_cpu_stat {
+struct cgroup_rstat_cpu {
/*
 * ->sync protects all the current counters.  These are the only
 * fields which get updated in the hot path.
@@ -297,7 +297,7 @@ struct cgroup_cpu_stat {
 * to the cgroup makes it unnecessary for each per-cpu struct to
 * point back to the associated cgroup.
 *
-* Protected by per-cpu cgroup_cpu_stat_lock.
+* Protected by per-cpu cgroup_rstat_cpu_lock.
 */
struct cgroup *updated_children;/* terminated by self cgroup */
struct cgroup *updated_next;/* NULL iff not on the list */
@@ -408,8 +408,10 @@ struct cgroup {
 */
struct cgroup *dom_cgrp;
 
+   /* per-cpu recursive resource statistics */
+   struct cgroup_rstat_cpu __percpu *rstat_cpu;
+
/* cgroup basic resource statistics */
-   struct cgroup_cpu_stat __percpu *cpu_stat;
struct cgroup_stat pending_stat;/* pending from children */
struct cgroup_stat stat;
 
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index b928b27..0927111 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -201,13 +201,13 @@ int cgroup_show_path(struct seq_file *sf, struct 
kernfs_node *kf_node,
 int cgroup_task_count(const struct cgroup *cgrp);
 
 /*
- * stat.c
+ * rstat.c
  */
-void cgroup_stat_flush(struct cgroup *cgrp);
-int cgroup_stat_init(struct cgroup *cgrp);
-void cgroup_stat_exit(struct cgroup *cgrp);
+void cgroup_rstat_flush(struct cgroup *cgrp);
+int cgroup_rstat_init(struct cgroup *cgrp);
+void cgroup_rstat_exit(struct cgroup *cgrp);
 void cgroup_stat_show_cputime(struct seq_file *seq);
-void cgroup_stat_boot(void);
+void cgroup_rstat_boot(void);
 
 /*
  * namespace.c
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index ea31ec5..5549a7c 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -144,14 +144,14 @@ static struct static_key_true *cgroup_subsys_on_dfl_key[] 
= {
 };
 #undef SUBSYS
 
-static DEFINE_PER_CPU(struct cgroup_cpu_stat, cgrp_dfl_root_cpu_stat);
+static DEFINE_PER_CPU(struct cgroup_rstat_cpu, cgrp_dfl_root_rstat_cpu);
 
 /*
  * The default hierarchy, reserved for the subsystems that are otherwise
  * unattached - it never has more than a single cgroup, and all tasks are
  * part of that cgroup.
  */
-struct cgroup_root cgrp_dfl_root = { .cgrp.cpu_stat = &cgrp_dfl_root_cpu_stat 
};
+struct cgroup_root cgrp_dfl_root = { .cgrp.rstat_cpu = 
&cgrp_dfl_root_rstat_cpu };
 EXPORT_SYMBOL_GPL(cgrp_dfl_root);
 
 /*
@@ -4592,7 +4592,7 @@ static void css_free_work_fn(struct work_struct *work)
cgroup_put(cgroup_parent(cgrp));
kernfs_put(cgrp->kn);
if (cgroup_on_dfl(cgrp))
-   cgroup_stat_exit(cgrp);
+   cgroup_rstat_exit(cgrp);
kfree(cgrp);
} else {
/*
@@ -46

[PATCH 6/8] cgroup: Replace cgroup_rstat_mutex with a spinlock

2018-03-23 Thread Tejun Heo
Currently, rstat flush path is protected with a mutex which is fine as
all the existing users are from interface file show path.  However,
rstat is being generalized for use by controllers and flushing from
atomic contexts will be necessary.

This patch replaces cgroup_rstat_mutex with a spinlock and adds a
irq-safe flush function - cgroup_rstat_flush_irqsafe().  Explicit
yield handling is added to the flush path so that other flush
functions can yield to other threads and flushers.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup.h |  1 +
 kernel/cgroup/rstat.c  | 57 ++
 2 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5c6018f..c9fdf6f 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -696,6 +696,7 @@ static inline void cgroup_path_from_kernfs_id(const union 
kernfs_node_id *id,
  */
 void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
 void cgroup_rstat_flush(struct cgroup *cgrp);
+void cgroup_rstat_flush_irqsafe(struct cgroup *cgrp);
 void cgroup_rstat_flush_hold(struct cgroup *cgrp);
 void cgroup_rstat_flush_release(void);
 
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index e3c4461..a5f9338 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -2,7 +2,7 @@
 
 #include 
 
-static DEFINE_MUTEX(cgroup_rstat_mutex);
+static DEFINE_SPINLOCK(cgroup_rstat_lock);
 static DEFINE_PER_CPU(raw_spinlock_t, cgroup_rstat_cpu_lock);
 
 static void cgroup_base_stat_flush(struct cgroup *cgrp, int cpu);
@@ -131,21 +131,30 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct 
cgroup *pos,
 }
 
 /* see cgroup_rstat_flush() */
-static void cgroup_rstat_flush_locked(struct cgroup *cgrp)
+static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep)
 {
int cpu;
 
-   lockdep_assert_held(&cgroup_rstat_mutex);
+   lockdep_assert_held(&cgroup_rstat_lock);
 
for_each_possible_cpu(cpu) {
raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock,
   cpu);
struct cgroup *pos = NULL;
 
-   raw_spin_lock_irq(cpu_lock);
+   raw_spin_lock(cpu_lock);
while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu)))
cgroup_base_stat_flush(pos, cpu);
-   raw_spin_unlock_irq(cpu_lock);
+   raw_spin_unlock(cpu_lock);
+
+   /* if @may_sleep, play nice and yield if necessary */
+   if (may_sleep && (need_resched() ||
+ spin_needbreak(&cgroup_rstat_lock))) {
+   spin_unlock_irq(&cgroup_rstat_lock);
+   if (!cond_resched())
+   cpu_relax();
+   spin_lock_irq(&cgroup_rstat_lock);
+   }
}
 }
 
@@ -159,12 +168,31 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp)
  *
  * This also gets all cgroups in the subtree including @cgrp off the
  * ->updated_children lists.
+ *
+ * This function may block.
  */
 void cgroup_rstat_flush(struct cgroup *cgrp)
 {
-   mutex_lock(&cgroup_rstat_mutex);
-   cgroup_rstat_flush_locked(cgrp);
-   mutex_unlock(&cgroup_rstat_mutex);
+   might_sleep();
+
+   spin_lock_irq(&cgroup_rstat_lock);
+   cgroup_rstat_flush_locked(cgrp, true);
+   spin_unlock_irq(&cgroup_rstat_lock);
+}
+
+/**
+ * cgroup_rstat_flush_irqsafe - irqsafe version of cgroup_rstat_flush()
+ * @cgrp: target cgroup
+ *
+ * This function can be called from any context.
+ */
+void cgroup_rstat_flush_irqsafe(struct cgroup *cgrp)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&cgroup_rstat_lock, flags);
+   cgroup_rstat_flush_locked(cgrp, false);
+   spin_unlock_irqrestore(&cgroup_rstat_lock, flags);
 }
 
 /**
@@ -173,21 +201,24 @@ void cgroup_rstat_flush(struct cgroup *cgrp)
  *
  * Flush stats in @cgrp's subtree and prevent further flushes.  Must be
  * paired with cgroup_rstat_flush_release().
+ *
+ * This function may block.
  */
 void cgroup_rstat_flush_hold(struct cgroup *cgrp)
-   __acquires(&cgroup_rstat_mutex)
+   __acquires(&cgroup_rstat_lock)
 {
-   mutex_lock(&cgroup_rstat_mutex);
-   cgroup_rstat_flush_locked(cgrp);
+   might_sleep();
+   spin_lock_irq(&cgroup_rstat_lock);
+   cgroup_rstat_flush_locked(cgrp, true);
 }
 
 /**
  * cgroup_rstat_flush_release - release cgroup_rstat_flush_hold()
  */
 void cgroup_rstat_flush_release(void)
-   __releases(&cgroup_rstat_mutex)
+   __releases(&cgroup_rstat_lock)
 {
-   mutex_unlock(&cgroup_rstat_mutex);
+   spin_unlock_irq(&cgroup_rstat_lock);
 }
 
 int cgroup_rstat_init(struct cgroup *cgrp)
-- 
2.9.5



[PATCH 7/8] cgroup: Add cgroup_subsys->css_rstat_flush()

2018-03-23 Thread Tejun Heo
This patch adds cgroup_subsys->css_rstat_flush().  If a subsystem has
this callback, its csses are linked on cgrp->css_rstat_list and rstat
will call the function whenever the associated cgroup is flushed.
Flush is also performed when such csses are released so that residual
counts aren't lost.

Combined with the rstat API previous patches factored out, this allows
controllers to plug into rstat to manage their statistics in a
scalable way.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup-defs.h |  5 +
 kernel/cgroup/cgroup.c  | 11 +++
 kernel/cgroup/rstat.c   | 11 ++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index cf9db7b..8b8dd17 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -130,6 +130,9 @@ struct cgroup_subsys_state {
struct list_head sibling;
struct list_head children;
 
+   /* flush target list anchored at cgrp->rstat_css_list */
+   struct list_head rstat_css_node;
+
/*
 * PI: Subsys-unique ID.  0 is unused and root is always 1.  The
 * matching css can be looked up using css_from_id().
@@ -412,6 +415,7 @@ struct cgroup {
 
/* per-cpu recursive resource statistics */
struct cgroup_rstat_cpu __percpu *rstat_cpu;
+   struct list_head rstat_css_list;
 
/* cgroup basic resource statistics */
struct cgroup_base_stat pending_bstat;  /* pending from children */
@@ -577,6 +581,7 @@ struct cgroup_subsys {
void (*css_released)(struct cgroup_subsys_state *css);
void (*css_free)(struct cgroup_subsys_state *css);
void (*css_reset)(struct cgroup_subsys_state *css);
+   void (*css_rstat_flush)(struct cgroup_subsys_state *css, int cpu);
int (*css_extra_stat_show)(struct seq_file *seq,
   struct cgroup_subsys_state *css);
 
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 0d3d093..f29f84e 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1860,6 +1860,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
cgrp->dom_cgrp = cgrp;
cgrp->max_descendants = INT_MAX;
cgrp->max_depth = INT_MAX;
+   INIT_LIST_HEAD(&cgrp->rstat_css_list);
prev_cputime_init(&cgrp->prev_cputime);
 
for_each_subsys(ss, ssid)
@@ -4630,6 +4631,11 @@ static void css_release_work_fn(struct work_struct *work)
 
if (ss) {
/* css release path */
+   if (!list_empty(&css->rstat_css_node)) {
+   cgroup_rstat_flush(cgrp);
+   list_del_rcu(&css->rstat_css_node);
+   }
+
cgroup_idr_replace(&ss->css_idr, NULL, css->id);
if (ss->css_released)
ss->css_released(css);
@@ -4690,6 +4696,7 @@ static void init_and_link_css(struct cgroup_subsys_state 
*css,
css->id = -1;
INIT_LIST_HEAD(&css->sibling);
INIT_LIST_HEAD(&css->children);
+   INIT_LIST_HEAD(&css->rstat_css_node);
css->serial_nr = css_serial_nr_next++;
atomic_set(&css->online_cnt, 0);
 
@@ -4698,6 +4705,9 @@ static void init_and_link_css(struct cgroup_subsys_state 
*css,
css_get(css->parent);
}
 
+   if (cgroup_on_dfl(cgrp) && ss->css_rstat_flush)
+   list_add_rcu(&css->rstat_css_node, &cgrp->rstat_css_list);
+
BUG_ON(cgroup_css(cgrp, ss));
 }
 
@@ -4799,6 +4809,7 @@ static struct cgroup_subsys_state *css_create(struct 
cgroup *cgrp,
 err_list_del:
list_del_rcu(&css->sibling);
 err_free_css:
+   list_del_rcu(&css->rstat_css_node);
call_rcu(&css->rcu_head, css_free_rcu_fn);
return ERR_PTR(err);
 }
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index a5f9338..18b464a 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -143,8 +143,17 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp, 
bool may_sleep)
struct cgroup *pos = NULL;
 
raw_spin_lock(cpu_lock);
-   while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu)))
+   while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu))) {
+   struct cgroup_subsys_state *css;
+
cgroup_base_stat_flush(pos, cpu);
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(css, &pos->rstat_css_list,
+   rstat_css_node)
+   css->ss->css_rstat_flush(css, cpu);
+   rcu_read_unlock();
+   }
raw_spin_unlock(cpu_lock);
 
/* if @may_sleep, play nice and yield if necessary */
-- 
2.9.5



[PATCH 8/8] cgroup: Add memory barriers to plug cgroup_rstat_updated() race window

2018-03-23 Thread Tejun Heo
cgroup_rstat_updated() has a small race window where an updated
signaling can race with flush and could be lost till the next update.
This wasn't a problem for the existing usages, but we plan to use
rstat to track counters which need to be accurate.

This patch plugs the race window by synchronizing
cgroup_rstat_updated() and flush path with memory barriers around
cgroup_rstat_cpu->updated_next pointer.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup/rstat.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index 18b464a..662d7ae 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -28,9 +28,12 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
unsigned long flags;
 
/*
-* Speculative already-on-list test.  This may race leading to
-* temporary inaccuracies, which is fine.
-*
+* Paired with the one in cgroup_rstat_cpu_pop_upated().  Either we
+* see NULL updated_next or they see our updated stat.
+*/
+   smp_mb();
+
+   /*
 * Because @parent's updated_children is terminated with @parent
 * instead of NULL, we can tell whether @cgrp is on the list by
 * testing the next pointer for NULL.
@@ -125,6 +128,13 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct 
cgroup *pos,
 
*nextp = rstatc->updated_next;
rstatc->updated_next = NULL;
+
+   /*
+* Paired with the one in cgroup_rstat_cpu_updated().
+* Either they see NULL updated_next or we see their
+* updated stat.
+*/
+   smp_mb();
}
 
return pos;
-- 
2.9.5



[PATCHSET] cgroup/for-4.17: Make cgroup_rstat available to controllers

2018-03-23 Thread Tejun Heo
Hello,

cgroup has scalable recursive stat mechanism implemented in
kernel/stat.c.  It's currently only used to track cpu consumptions and
difficult to use outside of cgroup core.  This patchset generalizes
the mechanism and exposes it as cgroup_rstat so that controllers can
use it.

This patchset contains the following eight patches.  A follow-up
patchset will add usages.

 0001-cgroup-Rename-kernel-cgroup-stat.c-to-kernel-cgroup-.patch
 0002-cgroup-Rename-stat-to-rstat.patch
 0003-cgroup-Distinguish-base-resource-stat-implementation.patch
 0004-cgroup-Reorganize-kernel-cgroup-rstat.c.patch
 0005-cgroup-Factor-out-and-expose-cgroup_rstat_-interface.patch
 0006-cgroup-Replace-cgroup_rstat_mutex-with-a-spinlock.patch
 0007-cgroup-Add-cgroup_subsys-css_rstat_flush.patch
 0008-cgroup-Add-memory-barriers-to-plug-cgroup_rstat_upda.patch

This patchset is also available in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-cgroup_rstat

diffstat follows.

 include/linux/cgroup-defs.h |   50 ++--
 include/linux/cgroup.h  |   12 -
 kernel/cgroup/Makefile  |2 
 kernel/cgroup/cgroup-internal.h |   11 -
 kernel/cgroup/cgroup.c  |   29 ++
 kernel/cgroup/rstat.c   |  410 
 kernel/cgroup/stat.c|  338 
 7 files changed, 477 insertions(+), 375 deletions(-)

Thanks.

--
tejun


[PATCH 1/8] cgroup: Rename kernel/cgroup/stat.c to kernel/cgroup/rstat.c

2018-03-23 Thread Tejun Heo
stat is too generic a name and ends up causing subtle confusions.
It'll be made generic so that controllers can plug into it, which will
make the problem worse.  Let's rename it to something more specific -
cgroup_rstat for cgroup recursive stat.

First, rename kernel/cgroup/stat.c to kernel/cgroup/rstat.c.  No
content changes.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup/Makefile| 2 +-
 kernel/cgroup/{stat.c => rstat.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename kernel/cgroup/{stat.c => rstat.c} (100%)

diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile
index 2be89a00..bfcdae8 100644
--- a/kernel/cgroup/Makefile
+++ b/kernel/cgroup/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y := cgroup.o stat.o namespace.o cgroup-v1.o
+obj-y := cgroup.o rstat.o namespace.o cgroup-v1.o
 
 obj-$(CONFIG_CGROUP_FREEZER) += freezer.o
 obj-$(CONFIG_CGROUP_PIDS) += pids.o
diff --git a/kernel/cgroup/stat.c b/kernel/cgroup/rstat.c
similarity index 100%
rename from kernel/cgroup/stat.c
rename to kernel/cgroup/rstat.c
-- 
2.9.5



Re: [PATCH] x86/speculation: Fill the RSB on context switch also on non-IBPB CPUs

2018-03-23 Thread Maciej S. Szmigiero
On 22.03.2018 16:46, Dave Hansen wrote:
> On 03/21/2018 05:09 PM, Maciej S. Szmigiero wrote:
>> As far as I understand the issue this should provide a good protection
>> for userspace processes that were recompiled with retpolines as they
>> won't have any indirect jumps and calls.
> 
> Instead of saying "good protection", let's just say that it could
> mitigate attacks that require consumption of attacker-placed RSB entries.

All right.

>>> Do you perhaps want to do RSB manipulation in lieu of IBPB when
>>> switching *to* a non-dumpable process and IBPB is not available?
>>
>> Is it worth differentiating such processes in this case?
>> IBPB is supposed to be very expensive so certainly it is worthwhile
>> to do it only for high-value processes (=non-dumpable).
>>
>> However, it is unlikely that existing RSB entries from the previous
>> task match the new task call stack anyway.
>> We already do unconditional RSB-filling-on-context-switch in many
>> cases.
> 
> I think this case is a bit too obscure and theoretical to complicate the
> kernel with it.  You need an unmitigated processor, a
> userspace-to-userspace attack that manages to satisfy the five "exploit
> composition" steps of Spectre/V2[1], and an application that has been
> retpoline-mitigated.
> 
> While RSB manipulation is almost certainly less onerous than IBPB, it's
> still going to hurt context-switch rates, especially if applied
> indiscriminately like this patch does.
> 
> So, I totally agree with your analysis about the theoretical potential
> for an issue, I'm just not really convinced the fix is worth it.

Yes, Spectre v2 looks really hard to exploit, but this doesn't mean the
kernel shouldn't do its best to mitigate it.

As I wrote two messages ago, basing on the Intel guidance document you
linked above as "[1]" I think that the mitigation introduced by this
patch should not be done on Intel CPUs, however, since that document
clearly suggests that this may not be enough to cover the issue.
And I think we shouldn't give people a false sense of security.

Maciej


Re: [PATCH v1 0/4] platform/x86: mlx-platform: Add bus differed and auto detection functionalities

2018-03-23 Thread Darren Hart
On Fri, Mar 23, 2018 at 03:59:22PM +, Vadim Pasternak wrote:
> 
> 
> > -Original Message-
> > From: Darren Hart [mailto:dvh...@infradead.org]
> > Sent: Friday, March 23, 2018 1:56 AM
> > To: Vadim Pasternak 
> > Cc: andy.shevche...@gmail.com; gre...@linuxfoundation.org; platform-
> > driver-...@vger.kernel.org; linux-kernel@vger.kernel.org; j...@resnulli.us;
> > Michael Shych 
> > Subject: Re: [PATCH v1 0/4] platform/x86: mlx-platform: Add bus differed and
> > auto detection functionalities
> > 
> > On Tue, Feb 13, 2018 at 10:09:32PM +, Vadim Pasternak wrote:
> > > This patchset:
> > > - Adds define for the channels number for mux device.
> > > - Adds differed bus functionality.
> > > - Changes input for device create routine in mlxreg-hotplug driver.
> > > - Adds physical bus number auto detection.
> > >
> > > Vadim Pasternak (4):
> > >   platform/x86: mlx-platform: Use define for the channel numbers
> > >   platform/x86: mlx-platform: Add differed bus functionality
> > >   platform/mellanox: mlxreg-hotplug: Change input for device create
> > > routine
> > >   platform/x86: mlx-platform: Add physical bus number auto detection
> > 
> > Vadim,
> > 
> > I have rewritten most of the commit messages after parsing through them and
> > reviewing the code. I believe they are much more concise now, and make the
> > intent of the patches much clearer. I have not changed the patch content 
> > (code).
> > 
> > Please review the commit messages for the top 4 commits:
> > http://git.infradead.org/linux-platform-drivers-
> > x86.git/shortlog/refs/heads/review-dvhart-mellanox
> > 
> > Does this still match your intent?
> > 
> 
> Hi Darren,
> Thank you very much for review.
> 
> Looks good.

Thanks Vadim. I have queued these plus the Kconfig build dep fix for 4.17.

-- 
Darren Hart
VMware Open Source Technology Center


Re: [QUESTION] Mainline support for B43_PHY_AC wifi cards

2018-03-23 Thread Rafał Miłecki
On 23 March 2018 at 15:09, Juri Lelli  wrote:
> On 23/03/18 14:43, Rafał Miłecki wrote:
>> Hi,
>>
>> On 23 March 2018 at 10:47, Juri Lelli  wrote:
>> > I've got a Dell XPS 13 9343/0TM99H (BIOS A15 01/23/2018) mounting a
>> > BCM4352 802.11ac (rev 03) wireless card and so far I've been using it on
>> > Fedora with broadcom-wl package (which I believe installs Broadcom's STA
>> > driver?). It works good apart from occasional hiccups after suspend.
>> >
>> > I'd like to get rid of that dependency (you can understand that it's
>> > particularly annoying when testing mainline kernels), but I found out
>> > that support for my card is BROKEN in mainline [1]. Just to see what
>> > happens, I forcibly enabled it witnessing that it indeed crashes like
>> > below as Kconfig warns. :)
>> >
>> >  bcma: bus0: Found chip with id 0x4352, rev 0x03 and package 0x00
>> >  bcma: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800, rev 0x2B, 
>> > class 0x0)
>> >  bcma: bus0: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812, rev 0x2A, 
>> > class 0x0)
>> >  bcma: bus0: Core 2 found: ARM CR4 (manuf 0x4BF, id 0x83E, rev 0x02, class 
>> > 0x0)
>> >  bcma: bus0: Core 3 found: PCIe Gen2 (manuf 0x4BF, id 0x83C, rev 0x01, 
>> > class 0x0)
>> >  bcma: bus0: Core 4 found: USB 2.0 Device (manuf 0x4BF, id 0x81A, rev 
>> > 0x11, class 0x0)
>> >  bcma: Unsupported SPROM revision: 11
>> >  bcma: bus0: Invalid SPROM read from the PCIe card, trying to use fallback 
>> > SPROM
>> >  bcma: bus0: Using fallback SPROM failed (err -2)
>> >  bcma: bus0: No SPROM available
>> >  bcma: bus0: Bus registered
>> >  b43-phy0: Broadcom 4352 WLAN found (core revision 42)
>> >  b43-phy0: Found PHY: Analog 12, Type 11 (AC), Revision 1
>> >  b43-phy0: Found Radio: Manuf 0x17F, ID 0x2069, Revision 4, Version 0
>> >  BUG: unable to handle kernel NULL pointer dereference at 
>>
>> This isn't really useful without a full backtrace.
>
> Sure. I cut it here because I didn't expect people to debug what is
> already known to be broken (but still it seemed to carry useful
> information about the hw). :)

Please paste the remaining part if you still got it.


>> > So, question: is replacing my card the only way I can get rid of this
>> > downstream dependency? :(
>>
>> It's definitely the cheapest way. Getting AC PHY into anything usable
>> (proper setup that will allow Tx & Rx anything) would probably take
>> weeks or months of development. I'm not even going to estimate cost of
>> adding support for 802.11n and 802.11ac features. I was the last
>> person actively working on b43, right now I spend my free time on
>> other hobby projects. Few people were planning to help but it seems it
>> never worked out for them.
>
> I see. Just wondering why even if Broadcom's STA solution seems to work
> fine, it is not mainline. Maybe a maintenance problem? But Fedora ships
> with very recent kernels, so I'd expect the driver to work with mainline
> (I tried compiling that against mainline, but I got errors that I didn't
> spend time figuring out how to fix).
>
> Do you know what's the deal w.r.t. the STA driver?

Driver being closed source and company not willing to open source it
is usually a big problem getting it mainline...

-- 
Rafał


Re: rcu: Add might_sleep() check to synchronize_rcu()

2018-03-23 Thread Joel Fernandes
On Fri, Mar 23, 2018 at 2:40 PM, Steven Rostedt  wrote:
> On Fri, 23 Mar 2018 22:33:29 +0100 (CET)
> Thomas Gleixner  wrote:
>
>> On Fri, 23 Mar 2018, Steven Rostedt wrote:
>>
>> > On Fri, 23 Mar 2018 22:12:24 +0100 (CET)
>> > Thomas Gleixner  wrote:
>> >
>> > > synchronize_rcu() lacks a might_sleep() check which would have caught 
>> > > that
>> > > issue way earlier because it would trigger with the minimal debug options
>> > > enabled.
>> > >
>> > > Add a might_sleep() check to catch such cases.
>> >
>> > I'm not against the patch, but really? I would think that
>> > synchronize_rcu() would pretty much always schedule, and scheduling
>> > from atomic would have triggered with minimal debug options enabled.
>>
>> Dunno. The reported splat is here:
>>
>>https://pastebin.com/raw/puvh0cXE
>
> [  150.560848] ODEBUG: object is not on stack, but annotated
> [  150.566398] [ cut here ]
> [  150.571133] WARNING: CPU: 1 PID: 0 at lib/debugobjects.c:300 
> __debug_object_init+0x526/0xc40
> [  150.579682] Kernel panic - not syncing: panic_on_warn set ...
> [  150.579682]
> [  150.587012] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.9.89-g960923f #61
> [  150.593906] Hardware name: Google Google Compute Engine/Google Compute 
> Engine, BIOS Google 01/01/2011
> [  150.603233]  8801db307a08 81d96069 83a482c0 
> 8801db307ae0
> [  150.611190]  83c19700 81dfefb6 0009 
> 8801db307ad0
> [  150.619157]  8142fbd1 41b58ab3 8418bd08 
> 8142fa15
> [  150.627118] Call Trace:
> [  150.629667]   [  150.631700]  [] 
> dump_stack+0xc1/0x128
> [  150.637051]  [] ? __debug_object_init+0x526/0xc40
> [  150.643431]  [] panic+0x1bc/0x3a8
> [  150.648416]  [] ? 
> percpu_up_read_preempt_enable.constprop.53+0xd7/0xd7
> [  150.656611]  [] ? load_image_and_restore+0xf9/0xf9
> [  150.663070]  [] ? vprintk_default+0x1d/0x30
> [  150.668925]  [] ? __warn+0x1a9/0x1e0
> [  150.674170]  [] ? __debug_object_init+0x526/0xc40
> [  150.680543]  [] __warn+0x1c4/0x1e0
> [  150.685614]  [] warn_slowpath_null+0x2c/0x40
> [  150.691972]  [] __debug_object_init+0x526/0xc40
> [  150.698174]  [] ? debug_object_fixup+0x30/0x30
> [  150.704283]  [] debug_object_init_on_stack+0x19/0x20
> [  150.710917]  [] __wait_rcu_gp+0x93/0x1b0
> [  150.716508]  [] synchronize_rcu.part.65+0x101/0x110
> [  150.723054]  [] ? rcu_pm_notify+0xc0/0xc0
> [  150.728735]  [] ? __call_rcu.constprop.72+0x910/0x910
> [  150.735459]  [] ? __lock_is_held+0xa1/0xf0
> [  150.741223]  [] synchronize_rcu+0x27/0x90
> [  150.746908]  [] __l2tp_session_unhash+0x3d5/0x550
>
> Looks like __l2tp_session_unhash() is the real culprit here.
>
> [  150.753281]  [] ? __l2tp_session_unhash+0x1bf/0x550
> [  150.759828]  [] ? __local_bh_enable_ip+0x6a/0xd0
> [  150.766123]  [] ? l2tp_udp_encap_recv+0xd90/0xd90
> [  150.772497]  [] l2tp_tunnel_closeall+0x1e7/0x3a0
> [  150.778782]  [] l2tp_tunnel_destruct+0x30e/0x5a0
> [  150.785067]  [] ? l2tp_tunnel_destruct+0x1aa/0x5a0
> [  150.791537]  [] ? l2tp_tunnel_del_work+0x460/0x460
> [  150.797997]  [] __sk_destruct+0x53/0x570
> [  150.803588]  [] rcu_process_callbacks+0x898/0x1300
> [  150.810048]  [] ? rcu_process_callbacks+0x977/0x1300
> [  150.816684]  [] ? __sk_dst_check+0x240/0x240
> [  150.822625]  [] __do_softirq+0x206/0x951
> [  150.828223]  [] irq_exit+0x165/0x190
> [  150.833557]  [] smp_apic_timer_interrupt+0x7b/0xa0
> [  150.840018]  [] apic_timer_interrupt+0xa0/0xb0
> [  150.846132]   [  150.848166]  [] ? 
> native_safe_halt+0x6/0x10
> [  150.854036]  [] ? trace_hardirqs_on+0xd/0x10
> [  150.859973]  [] default_idle+0x55/0x360
> [  150.865478]  [] arch_cpu_idle+0xa/0x10
>
> I think you want this instead, as __l2tp_session_unhash is what looks
> like might be hiding the call to synchronize_rcu(). It's not called in
> all instances, and I don't think your patch would have triggered the
> issues before hand. You want this:
>
> diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> index 194a7483bb93..857b494bee29 100644
> --- a/net/l2tp/l2tp_core.c
> +++ b/net/l2tp/l2tp_core.c
> @@ -1677,6 +1677,8 @@ void __l2tp_session_unhash(struct l2tp_session *session)
>  {
> struct l2tp_tunnel *tunnel = session->tunnel;
>
> +   might_sleep();
> +
> /* Remove the session from core hashes */
> if (tunnel) {
> /* Remove from the per-tunnel hash */

Thanks Thomas and Steven, also shouldn't this code be calling
synchronize_rcu_bh instead of synchronize_rcu, to complement the
rcu_read_lock_bh? In which situations would you call one versus the
other?

Also it seems rcu_read_lock_bh does a might_sleep already in rcu_blocking_is_gp.

thanks,

- Joel


[PATCH 4/4] drivers/net: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 drivers/net/bonding/bond_procfs.c  |  2 +-
 drivers/net/bonding/bond_sysfs.c   | 73 +-
 drivers/net/bonding/bond_sysfs_slave.c |  4 +-
 drivers/net/caif/caif_serial.c | 32 +++
 drivers/net/caif/caif_spi.c| 16 
 drivers/net/caif/caif_virtio.c | 16 
 drivers/net/can/at91_can.c |  3 +-
 drivers/net/can/cc770/cc770.c  |  4 +-
 drivers/net/can/cc770/cc770_isa.c  | 16 
 drivers/net/can/grcan.c|  4 +-
 drivers/net/can/janz-ican3.c   |  6 +--
 drivers/net/can/sja1000/sja1000_isa.c  | 14 +++
 drivers/net/can/softing/softing_main.c |  4 +-
 drivers/net/can/spi/mcp251x.c  |  2 +-
 drivers/net/can/usb/esd_usb2.c |  6 +--
 drivers/net/can/vcan.c |  2 +-
 drivers/net/hamradio/bpqether.c|  3 +-
 drivers/net/hamradio/yam.c |  2 +-
 drivers/net/hyperv/netvsc_drv.c|  4 +-
 drivers/net/ieee802154/at86rf230.c |  2 +-
 drivers/net/phy/spi_ks8995.c   |  2 +-
 drivers/net/ppp/ppp_generic.c  |  2 +-
 drivers/net/ppp/pppoe.c|  2 +-
 drivers/net/usb/cdc_ncm.c  | 12 +++---
 drivers/net/usb/hso.c  |  8 ++--
 drivers/net/xen-netback/xenbus.c   |  4 +-
 drivers/net/xen-netfront.c |  6 +--
 27 files changed, 124 insertions(+), 127 deletions(-)

diff --git a/drivers/net/bonding/bond_procfs.c 
b/drivers/net/bonding/bond_procfs.c
index f7799321dffb..01059f1a7bca 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -287,7 +287,7 @@ void bond_create_proc_entry(struct bonding *bond)
 
if (bn->proc_dir) {
bond->proc_entry = proc_create_data(bond_dev->name,
-   S_IRUGO, bn->proc_dir,
+   0444, bn->proc_dir,
&bond_info_fops, bond);
if (bond->proc_entry == NULL)
netdev_warn(bond_dev, "Cannot create /proc/net/%s/%s\n",
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 040b493f60ae..6096440e96ea 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -147,7 +147,7 @@ static ssize_t bonding_store_bonds(struct class *cls,
 static const struct class_attribute class_attr_bonding_masters = {
.attr = {
.name = "bonding_masters",
-   .mode = S_IWUSR | S_IRUGO,
+   .mode = 0644,
},
.show = bonding_show_bonds,
.store = bonding_store_bonds,
@@ -202,7 +202,7 @@ static ssize_t bonding_show_slaves(struct device *d,
 
return res;
 }
-static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
+static DEVICE_ATTR(slaves, 0644, bonding_show_slaves,
   bonding_sysfs_store_option);
 
 /* Show the bonding mode. */
@@ -216,8 +216,7 @@ static ssize_t bonding_show_mode(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond));
 }
-static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
-  bonding_show_mode, bonding_sysfs_store_option);
+static DEVICE_ATTR(mode, 0644, bonding_show_mode, bonding_sysfs_store_option);
 
 /* Show the bonding transmit hash method. */
 static ssize_t bonding_show_xmit_hash(struct device *d,
@@ -231,7 +230,7 @@ static ssize_t bonding_show_xmit_hash(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.xmit_policy);
 }
-static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(xmit_hash_policy, 0644,
   bonding_show_xmit_hash, bonding_sysfs_store_option);
 
 /* Show arp_validate. */
@@ -247,7 +246,7 @@ static ssize_t bonding_show_arp_validate(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.arp_validate);
 }
-static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
+static DEVICE_ATTR(arp_validate, 0644, bonding_show_arp_validate,
   bonding_sysfs_store_option);
 
 /* Show arp_all_targets. */
@@ -263,7 +262,7 @@ static ssize_t bonding_show_arp_all_targets(struct device 
*d,
return sprintf(buf, "%s %d\n",
   val->string, bond->params.arp_all_targets);
 }
-static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(arp_all_targets, 0644,
   bonding_show_arp_all_targets, bonding_sysfs_store_option);
 
 /* Show fail_over_mac. */
@@ -279,7 +278,7 @@ static ssize_t bonding_show_fail_over_mac(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.fail_over_mac);
 }
-stat

[PATCH 3/4] net: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 net/8021q/vlanproc.c   |  6 ++---
 net/appletalk/atalk_proc.c |  8 +++---
 net/atm/atm_sysfs.c| 12 -
 net/atm/clip.c |  2 +-
 net/atm/lec.c  |  2 +-
 net/atm/proc.c |  2 +-
 net/ax25/af_ax25.c |  6 ++---
 net/bluetooth/rfcomm/tty.c |  4 +--
 net/bridge/br_sysfs_br.c   |  2 +-
 net/bridge/br_sysfs_if.c   | 36 -
 net/can/af_can.c   |  2 +-
 net/can/gw.c   |  2 +-
 net/ceph/ceph_common.c |  2 +-
 net/core/net-procfs.c  |  6 ++---
 net/core/net-sysfs.c   | 12 -
 net/core/sock.c|  2 +-
 net/decnet/af_decnet.c |  2 +-
 net/decnet/dn_dev.c|  2 +-
 net/decnet/dn_neigh.c  |  2 +-
 net/decnet/dn_route.c  |  2 +-
 net/dns_resolver/dns_key.c |  2 +-
 net/ipv4/arp.c |  2 +-
 net/ipv4/fib_trie.c|  6 ++---
 net/ipv4/igmp.c|  4 +--
 net/ipv4/ipconfig.c|  2 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c |  2 +-
 net/ipv4/ping.c|  2 +-
 net/ipv4/proc.c|  6 ++---
 net/ipv4/raw.c |  2 +-
 net/ipv4/route.c   |  4 +--
 net/ipv4/tcp_ipv4.c|  2 +-
 net/ipv4/udp.c |  2 +-
 net/ipv6/addrconf.c|  2 +-
 net/ipv6/anycast.c |  2 +-
 net/ipv6/ip6_flowlabel.c   |  2 +-
 net/ipv6/mcast.c   |  4 +--
 net/ipv6/proc.c|  6 ++---
 net/ipv6/raw.c |  2 +-
 net/ipv6/route.c   |  2 +-
 net/kcm/kcmproc.c  |  4 +--
 net/l2tp/l2tp_ppp.c|  2 +-
 net/llc/llc_proc.c |  4 +--
 net/mac80211/rc80211_minstrel.c|  2 +-
 net/mac80211/rc80211_minstrel_debugfs.c|  8 +++---
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  8 +++---
 net/netfilter/nf_conntrack_netbios_ns.c|  2 +-
 net/netfilter/nf_conntrack_snmp.c  |  2 +-
 net/netfilter/nf_conntrack_standalone.c|  2 +-
 net/netfilter/nf_log.c |  2 +-
 net/netfilter/nf_synproxy_core.c   |  2 +-
 net/netfilter/xt_IDLETIMER.c   |  2 +-
 net/netfilter/xt_recent.c  |  4 +--
 net/netrom/af_netrom.c |  6 ++---
 net/rose/af_rose.c |  8 +++---
 net/rxrpc/af_rxrpc.c   |  2 +-
 net/sctp/proc.c| 16 ++--
 net/sunrpc/auth_gss/svcauth_gss.c  |  2 +-
 net/sunrpc/cache.c | 10 +++
 net/sunrpc/debugfs.c   |  6 ++---
 net/sunrpc/rpc_pipe.c  | 42 +++---
 net/wireless/wext-proc.c   |  2 +-
 net/x25/x25_proc.c | 12 -
 net/xfrm/xfrm_proc.c   |  2 +-
 63 files changed, 161 insertions(+), 161 deletions(-)

diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index a662ccc166df..a627a5db2125 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -148,8 +148,8 @@ int __net_init vlan_proc_init(struct net *net)
if (!vn->proc_vlan_dir)
goto err;
 
-   vn->proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
-vn->proc_vlan_dir, &vlan_fops);
+   vn->proc_vlan_conf = proc_create(name_conf, S_IFREG | 0600,
+vn->proc_vlan_dir, &vlan_fops);
if (!vn->proc_vlan_conf)
goto err;
return 0;
@@ -172,7 +172,7 @@ int vlan_proc_add_dev(struct net_device *vlandev)
if (!strcmp(vlandev->name, name_conf))
return -EINVAL;
vlan->dent =
-   proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
+   proc_create_data(vlandev->name, S_IFREG | 0600,
 vn->proc_vlan_dir, &vlandev_fops, vlandev);
if (!vlan->dent)
return -ENOBUFS;
diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
index a3bf9d519193..7214aea14cb3 100644
--- a/net/appletalk/atalk_proc.c
+++ b/net/appletalk/atalk_proc.c
@@ -257,22 +257,22 @@ int __init atalk_proc_init(v

[PATCH 2/4] wireless: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches 
---
 drivers/net/wireless/ath/ath5k/base.c  |   6 +-
 drivers/net/wireless/ath/ath5k/debug.c |  37 +++
 drivers/net/wireless/ath/ath5k/sysfs.c |   8 +-
 drivers/net/wireless/ath/ath6kl/debug.c|  43 
 drivers/net/wireless/ath/ath9k/common-debug.c  |   9 +-
 drivers/net/wireless/ath/ath9k/common-spectral.c   |  10 +-
 drivers/net/wireless/ath/ath9k/debug.c |  40 
 drivers/net/wireless/ath/ath9k/debug_sta.c |   6 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c |   4 +-
 drivers/net/wireless/ath/ath9k/htc_drv_debug.c |  16 +--
 drivers/net/wireless/ath/ath9k/tx99.c  |   4 +-
 drivers/net/wireless/ath/carl9170/debug.c  |   8 +-
 drivers/net/wireless/ath/carl9170/main.c   |   4 +-
 drivers/net/wireless/ath/wcn36xx/debug.c   |   5 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |   6 +-
 .../wireless/broadcom/brcm80211/brcmsmac/debug.c   |   2 +-
 .../broadcom/brcm80211/brcmsmac/mac80211_if.c  |   2 +-
 drivers/net/wireless/cisco/airo.c  |   6 +-
 drivers/net/wireless/intel/ipw2x00/ipw2100.c   |  29 +++---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c   |  51 +-
 drivers/net/wireless/intel/ipw2x00/libipw_module.c |   2 +-
 drivers/net/wireless/intel/iwlegacy/3945-mac.c |  35 +++
 drivers/net/wireless/intel/iwlegacy/4965-mac.c |  19 ++--
 drivers/net/wireless/intel/iwlegacy/4965-rs.c  |   8 +-
 drivers/net/wireless/intel/iwlegacy/common.c   |   4 +-
 drivers/net/wireless/intel/iwlegacy/debug.c|  58 ++-
 drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c   |  78 +++
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c|  16 +--
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c|   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c   |  43 
 .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   |  40 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 110 ++---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   |   6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c|  12 +--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c|  12 +--
 drivers/net/wireless/intersil/p54/main.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/debugfs.c   |  10 +-
 .../net/wireless/mediatek/mt76/mt76x2_debugfs.c|   8 +-
 drivers/net/wireless/mediatek/mt7601u/debugfs.c|  16 ++-
 drivers/net/wireless/ralink/rt2x00/rt2500usb.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00debug.c   |  64 ++--
 drivers/net/wireless/ralink/rt2x00/rt61pci.c   |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt73usb.c   |   2 +-
 drivers/net/wireless/ray_cs.c  |   8 +-
 drivers/net/wireless/st/cw1200/debug.c |   6 +-
 drivers/net/wireless/st/cw1200/main.c  |   2 +-
 drivers/net/wireless/ti/wl18xx/main.c  |  27 +++--
 drivers/net/wireless/ti/wlcore/main.c  |   8 +-
 drivers/net/wireless/ti/wlcore/sdio.c  |   2 +-
 drivers/net/wireless/ti/wlcore/sysfs.c |   7 +-
 53 files changed, 427 insertions(+), 486 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c 
b/drivers/net/wireless/ath/ath5k/base.c
index 527afcf39246..a2351ef45ae0 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -73,16 +73,16 @@
 #include "trace.h"
 
 bool ath5k_modparam_nohwcrypt;
-module_param_named(nohwcrypt, ath5k_modparam_nohwcrypt, bool, S_IRUGO);
+module_param_named(nohwcrypt, ath5k_modparam_nohwcrypt, bool, 0444);
 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
 
 static bool modparam_fastchanswitch;
-module_param_named(fastchanswitch, modparam_fastchanswitch, bool, S_IRUGO);
+module_param_named(fastchanswitch, modparam_fastchanswitch, bool, 0444);
 MODULE_PARM_DESC(fastchanswitch, "Enable fast channel switching for 
AR2413/AR5413 radios.");
 
 static bool ath5k_modparam_no_hw_rfkill_switch;
 module_param_named(no_hw_rfkill_switch, ath5k_modparam_no_hw_rfkill_switch,
-   bool, S_IRUGO);
+  bool, 0444);
 MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state");
 
 
diff --git a/drivers/net/wireless/ath/ath5k/debug.c 
b/drivers/net/wireless/ath/ath5k/debug.c
index bd7f6d7b199e..3513bbec4639 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -1004,32 +1004,17 @@ ath5k_debug_init_device

  1   2   3   4   5   6   7   8   9   10   >