[PATCH v4 6/7] Revert "scsi: ufs: disable vccq if it's not needed by UFS device"

2019-02-08 Thread Marc Gonzalez
This reverts commit 60f0187031c05e04cbadffb62f557d0ff3564490.

Calling ufshcd_set_vccq_rail_unused() breaks UFS init on two boards.
I would say that vccq is *not* not needed.

Reviewed-by: Jeffrey Hugo 
Signed-off-by: Marc Gonzalez 
---
 drivers/scsi/ufs/ufs.h|  1 -
 drivers/scsi/ufs/ufshcd.c | 59 +++
 2 files changed, 4 insertions(+), 56 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 6d176815e6ce..21e4ccb5ba6e 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -514,7 +514,6 @@ struct ufs_vreg {
struct regulator *reg;
const char *name;
bool enabled;
-   bool unused;
int min_uV;
int max_uV;
int min_uA;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 4bc55a2f5689..c78f5f199aff 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -254,7 +254,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba);
 static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
 bool skip_ref_clk);
 static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on);
-static int ufshcd_set_vccq_rail_unused(struct ufs_hba *hba, bool unused);
 static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
 static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
 static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba);
@@ -5857,11 +5856,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
ufs_fixup_device_setup(hba, );
ufshcd_tune_unipro_params(hba);
 
-   ret = ufshcd_set_vccq_rail_unused(hba,
-   (hba->dev_quirks & UFS_DEVICE_NO_VCCQ) ? true : false);
-   if (ret)
-   goto out;
-
/* UFS device is also active now */
ufshcd_set_ufs_dev_active(hba);
ufshcd_force_reset_auto_bkops(hba);
@@ -6030,24 +6024,13 @@ static int ufshcd_config_vreg_load(struct device *dev, 
struct ufs_vreg *vreg,
 static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
 struct ufs_vreg *vreg)
 {
-   if (!vreg)
-   return 0;
-   else if (vreg->unused)
-   return 0;
-   else
-   return ufshcd_config_vreg_load(hba->dev, vreg,
-  UFS_VREG_LPM_LOAD_UA);
+   return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
 }
 
 static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
 struct ufs_vreg *vreg)
 {
-   if (!vreg)
-   return 0;
-   else if (vreg->unused)
-   return 0;
-   else
-   return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
+   return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
 }
 
 static int ufshcd_config_vreg(struct device *dev,
@@ -6085,9 +6068,7 @@ static int ufshcd_enable_vreg(struct device *dev, struct 
ufs_vreg *vreg)
 {
int ret = 0;
 
-   if (!vreg)
-   goto out;
-   else if (vreg->enabled || vreg->unused)
+   if (!vreg || vreg->enabled)
goto out;
 
ret = ufshcd_config_vreg(dev, vreg, true);
@@ -6107,9 +6088,7 @@ static int ufshcd_disable_vreg(struct device *dev, struct 
ufs_vreg *vreg)
 {
int ret = 0;
 
-   if (!vreg)
-   goto out;
-   else if (!vreg->enabled || vreg->unused)
+   if (!vreg || !vreg->enabled)
goto out;
 
ret = regulator_disable(vreg->reg);
@@ -6215,36 +6194,6 @@ static int ufshcd_init_hba_vreg(struct ufs_hba *hba)
return 0;
 }
 
-static int ufshcd_set_vccq_rail_unused(struct ufs_hba *hba, bool unused)
-{
-   int ret = 0;
-   struct ufs_vreg_info *info = >vreg_info;
-
-   if (!info)
-   goto out;
-   else if (!info->vccq)
-   goto out;
-
-   if (unused) {
-   /* shut off the rail here */
-   ret = ufshcd_toggle_vreg(hba->dev, info->vccq, false);
-   /*
-* Mark this rail as no longer used, so it doesn't get enabled
-* later by mistake
-*/
-   if (!ret)
-   info->vccq->unused = true;
-   } else {
-   /*
-* rail should have been already enabled hence just make sure
-* that unused flag is cleared.
-*/
-   info->vccq->unused = false;
-   }
-out:
-   return ret;
-}
-
 static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on,
bool skip_ref_clk)
 {
-- 
2.17.1


[PATCH v4 5/7] arm64: dts: qcom: msm8998: Allow drivers to set-load

2019-02-08 Thread Marc Gonzalez
The UFS host controller driver needs to set the load on 3 power rails
(l20, l26, s4) but the operation fails silently unless we specify the
regulator-allow-set-load property in the corresponding DT nodes.

Reviewed-by: Jeffrey Hugo 
Signed-off-by: Marc Gonzalez 
---
 arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi 
b/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi
index f0901067b043..19775cae1381 100644
--- a/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi
@@ -111,6 +111,7 @@
vreg_s4a_1p8: s4 {
regulator-min-microvolt = <180>;
regulator-max-microvolt = <180>;
+   regulator-allow-set-load;
};
vreg_s5a_2p04: s5 {
regulator-min-microvolt = <1904000>;
@@ -195,6 +196,7 @@
vreg_l20a_2p95: l20 {
regulator-min-microvolt = <296>;
regulator-max-microvolt = <296>;
+   regulator-allow-set-load;
};
vreg_l21a_2p95: l21 {
regulator-min-microvolt = <296>;
@@ -221,6 +223,7 @@
vreg_l26a_1p2: l26 {
regulator-min-microvolt = <120>;
regulator-max-microvolt = <120>;
+   regulator-allow-set-load;
};
vreg_l28_3p0: l28 {
regulator-min-microvolt = <3008000>;
-- 
2.17.1


Re: [PATCH tip/core/rcu 0/19] SPDX changes for v5.1

2019-02-08 Thread Thomas Gleixner
On Wed, 6 Feb 2019, Paul E. McKenney wrote:
> 
> This series makes SPDX and email-address changes to RCU source files.

Reviewed-by: Thomas Gleixner 

>  26 files changed, 56 insertions(+), 394 deletions(-)

Nice! Thanks for doing that!

  tglx


Re: [PATCH v6 6/6] arm64: dts: Add Mediatek SoC MT8183 and evaluation board dts and Makefile

2019-02-08 Thread Erin Lo
On Thu, 2019-02-07 at 16:08 +0100, Matthias Brugger wrote:
> 
> On 01/02/2019 06:11, Erin Lo wrote:
> > Add back more people since mail server issue
> > 
> > On Fri, 2019-02-01 at 11:33 +0800, Erin Lo wrote:
> >> On Thu, 2019-01-31 at 15:10 -0600, Rob Herring wrote:
> >>> On Wed, Jan 30, 2019 at 8:34 PM Erin Lo  wrote:
> 
>  On Wed, 2019-01-30 at 10:22 -0600, Rob Herring wrote:
> > On Thu, Jan 24, 2019 at 04:07:20PM +0800, Erin Lo wrote:
> >> From: Ben Ho 
> >>
> >> Add basic chip support for Mediatek 8183, include
> >> pinctrl file, uart node with correct uart clocks, pwrap device
> >>
> >> Add clock controller nodes, include topckgen, infracfg,
> >> apmixedsys and subsystem.
> >>
> >> Signed-off-by: Ben Ho 
> >> Signed-off-by: Erin Lo 
> >> Signed-off-by: Seiya Wang 
> >> Signed-off-by: Zhiyong Tao 
> >> Signed-off-by: Weiyi Lu 
> >> Signed-off-by: Mengqi Zhang 
> >> Signed-off-by: Hsin-Hsiung Wang 
> >> Signed-off-by: Eddie Huang 
> >> ---
> >
> >
> >> +   sysirq: intpol-controller@c530a80 {
> >
> > interrupt-controller@...
> 
>  I will modify it in next version.
> >
> >
> > Place all the MMIO peripherals under one or more simple-bus nodes.
> >
> > Rob
> >
> 
>  Do you mean need to add simple-bus like this?
> >>>
> >>> Yes.
> >>
> >> We remove soc because Matthias suggested it in former MTK SoC maybe in
> >> 2015 year.
> >>
> >> We will add it back by your comment.
> >>
> >> Thank you. 
> >>
> >> Best Regards,
> >> Erin
> > 
> > Hi, Matthias,
> > Do you have any comment here?
> 
> Although I wasn't able to find it in the documentation my understanding is, 
> that
> all devices on-chip should be under soc "bus".
> 
> I'm sorry if I created confusion with comments in the past.
> 
> Regards,
> Matthias
> 

OK! we will add soc "bus" back in next version.
Thank you for your comment.

Best Regards,
Erin

> > Thanks
> > 
> > Best Regards,
> > Erin
> >>>
> 
>  +   soc: soc {
>  +#address-cells = <0x1>;
>  +#size-cells = <0x1>;
>  +ranges = <0 0 0 0x>;
>  +compatible = "simple-bus";
> 
>  soc_data: soc_data@0800 {
>  compatible = "mediatek,mt8183-efuse",
>   "mediatek,efuse";
>  reg = <0 0x0800 0 0x0010>;
>  #address-cells = <1>;
>  #size-cells = <1>;
>  status = "disabled";
>  };
> 
>  gic: interrupt-controller@0c00 {
>  compatible = "arm,gic-v3";
>  #interrupt-cells = <4>;
> 
>  Best Regards,
>  Erin
> 
> > ___
> > Linux-mediatek mailing list
> > linux-media...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek
> 
> 
> 
>  ___
>  linux-arm-kernel mailing list
>  linux-arm-ker...@lists.infradead.org
>  http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >>
> > 
> > 
> 
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek




Re: [PATCH net-next] ethtool: Remove unnecessary null check in ethtool_rx_flow_rule_create

2019-02-08 Thread David Miller
From: Nathan Chancellor 
Date: Thu,  7 Feb 2019 21:46:53 -0700

> net/core/ethtool.c:3023:19: warning: address of array
> 'ext_m_spec->h_dest' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
> if (ext_m_spec->h_dest) {
> ~~  ^~
> 
> h_dest is an array, it can't be null so remove this check.
> 
> Fixes: eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule 
> structure translator")
> Link: https://github.com/ClangBuiltLinux/linux/issues/353
> Signed-off-by: Nathan Chancellor 

Applied.


Re: [PATCH net-next] ixgbe: Use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 22:22:58 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = kzalloc(size, GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
> 
> Notice that, in this case, variable size is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] igb: use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 22:15:40 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = alloc(size, GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> size = struct_size(instance, entry, count);
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] igc: Use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 22:19:45 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = kzalloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable size is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH] net: stmmac: Variable "val" in function sun8i_dwmac_set_syscon() could be uninitialized

2019-02-08 Thread David Miller
From: Yizhuo 
Date: Thu,  7 Feb 2019 09:46:23 -0800

> In function sun8i_dwmac_set_syscon(), local variable "val" could
> be uninitialized if function regmap_read() returns -EINVAL.
> However, it will be used directly in the if statement, which
> is potentially unsafe.
> 
> Signed-off-by: Yizhuo 

This doesn't apply to any of my trees.


Re: [PATCH net-next] fm10k: use struct_size() in kzalloc()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:55:37 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = kzalloc(size, GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
> 
> Notice that, in this case, variable size is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] nfp: flower: cmsg: use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:47:25 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> void *entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(void *);
> instance = alloc(size, GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = alloc(struct_size(instance, entry, count), GFP_KERNEL);
> 
> Notice that, in this case, variable size is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] wimax/i2400m: use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:22:17 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> void *entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(void *);
> instance = alloc(size, GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> size = struct_size(instance, entry, count);
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] bridge: use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 18:58:56 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = alloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> size = struct_size(instance, entry, count);
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] mpls_iptunnel: use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 19:10:52 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> instance = alloc(sizeof(struct foo) + count * sizeof(struct boo));
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = alloc(struct_size(instance, entry, count));
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] bnx2x: Use struct_size() in kzalloc()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:29:10 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = kzalloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable fsz is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] mlxsw: spectrum_router: Use struct_size() in kzalloc()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:42:41 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = kzalloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable alloc_size is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] wan: wanxl: use struct_size() in kzalloc()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:16:48 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = alloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = alloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable alloc_size is not necessary, hence
> it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] net: usb: cdc-phonet: use struct_size() in alloc_netdev()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 21:13:13 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> void *entry[];
> };
> 
> instance = alloc(sizeof(struct foo) + count * sizeof(void *));
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = alloc(struct_size(instance, entry, count));
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] net: dsa: use struct_size() in devm_kzalloc()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 19:16:03 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = alloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = alloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable size is not necessary, hence it is
> removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


Re: [PATCH net-next] net/sched: use struct_size() helper

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" 
Date: Thu, 7 Feb 2019 19:02:52 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
> int stuff;
> struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = alloc(size, GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> size = struct_size(instance, entry, count);
> instance = alloc(size, GFP_KERNEL)
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 

Applied.


[LINUX PATCH v13] rawnand: pl353: Add basic driver for arm pl353 smc nand interface

2019-02-08 Thread Naga Sureshkumar Relli
Add driver for arm pl353 static memory controller nand interface with
HW ECC support. This controller is used in Xilinx Zynq SoC for
interfacing the NAND flash memory.

Signed-off-by: Naga Sureshkumar Relli 
---
xilinx zynq TRM link:
https://www.xilinx.com/support/documentation/user_guides/ug585-Zynq-7000-TRM.pdf

ARM pl353 smc TRM link:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0380g/DDI0380G_smc_pl350_series_r2p1_trm.pdf

Tested Micron MT29F2G08ABAEAWP (On-die capable) and AMD/Spansion S34ML01G1.

SMC memory controller driver is at drivers/memory/pl353-smc.c

Changes in v13:
 - Rebased the driver to mtd/next
Changes in v12:
 - Rebased the driver on top of v4.19 nand tree
 - Removed nand_scan_ident() and nand_scan_tail(), and added nand_controller_ops
   with ->attach_chip() and used nand_scan() instead.
 - Renamed pl353_nand_info structure to pl353_nand_controller
 - Renamed nand_base and nandaddr in pl353_nand_controller to 'regs' and 
'buf_addr'
 - Added new API pl353_wait_for_ecc_done() to wait for ecc done and call it from
   pl353_nand_write_page_hwecc() and pl353_nand_read_page_hwecc()
 - Defined new macro for max ECC blocks
 - Added return value check for ecc.calculate()
 - Renamed pl353_nand_cmd_function() to pl353_nand_exec_op_cmd()
 - Added x16 bus-width support
 - The dependent driver pl353-smc is already reviewed and hence dropped the
   smc driver
Changes in v11:
 - Removed Documentation patch and added the required info in driver as
   per Boris comments.
 - Removed unwanted variables from pl353_nand_info as per Miquel comments
 - Removed IO_ADDR_R/W.
 - Replaced onhot() with hweight32()
 - Defined macros for static values in function pl353_nand_correct_data()
 - Removed all unnecessary delays
 - Used nand_wait_ready() where ever is required
 - Modifed the pl353_setup_data_interface() logic as per Miquel comments.
 - Taken array instead of 7 values in pl353_setup_data_interface() and pass
   it to smc driver.
 - Added check to collect the return value of mtd_device_register().
Changes in 10:
 - Typos correction like nand to NAND and soc to SOC etc..
 - Defined macros for the values in pl353_nand_calculate_hwecc()
 - Modifed ecc_status from int to char in pl353_nand_calculate_hwecc()
 - Changed the return type form int to bool to the function
   onehot()
 - Removed udelay(1000) in pl353_cmd_function, as it is not required
 - Dropped ecc->hwctl = NULL in pl353_ecc_init()
 - Added an error message in pl353_ecc_init(), when there is no matching
   oobsize
 - Changed the variable from xnand to xnfc
 - Added logic to get mtd->name from DT, if it is specified in DT
Changes in v9:
 - Addressed the below comments given by Miquel
 - instead of using pl353_nand_write32, use directly writel_relaxed
 - Fixed check patch warnings
 - Renamed write_buf/read_buf to write_data_op/read_data_op
 - use BIT macro instead of 1 << nr
 - Use NAND_ROW_ADDR_3 flag
 - Use nand_wait_ready()
 - Removed swecc functions
 - Use address cycles as per size, instead of reading it from Parameter page
 - Instead of writing too many patterns, use optional property
Changes in v8:
 - Added exec_op() implementation
 - Fixed the below v7 review comments
 - removed mtd_info from pl353_nand_info struct
 - Corrected ecc layout offsets
 - Added on-die ecc support
Changes in v7:
 - Currently not implemented the memclk rate adjustments. I will
   look into this later and once the basic driver is accepted.
 - Fixed GPL licence ident
Changes in v6:
 - Fixed the checkpatch.pl reported warnings
 - Using the address cycles information from the onfi param page
   earlier it is hardcoded to 5 in driver
Changes in v5:
 - Configure the nand timing parameters as per the onfi spec Changes in v4:
 - Updated the driver to sync with pl353_smc driver APIs
Changes in v3:
 - implemented the proper error codes
 - further breakdown this patch to multiple sets
 - added the controller and driver details to Documentation section
 - updated the licenece to GPLv2
 - reorganized the pl353_nand_ecc_init function
Changes in v2:
 - use "depends on" rather than "select" option in kconfig
 - remove unused variable parts
---
 drivers/mtd/nand/raw/Kconfig  |8 +
 drivers/mtd/nand/raw/Makefile |1 +
 drivers/mtd/nand/raw/pl353_nand.c | 1380 +
 3 files changed, 1389 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/pl353_nand.c

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 1a55d3e..bc6c0a0 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -541,4 +541,12 @@ config MTD_NAND_TEGRA
  is supported. Extra OOB bytes when using HW ECC are currently
  not supported.
 
+config MTD_NAND_PL353
+   tristate "ARM Pl353 NAND flash driver"
+   depends on MTD_NAND && ARM
+   depends on PL353_SMC
+   help
+ Enables support for PrimeCell Static Memory Controller PL353.
+
+
 endif # MTD_NAND
diff --git 

Re: [PATCH 3/3] leaking_addresses: Expand tilde in output file name

2019-02-08 Thread Tobin C. Harding
On Thu, Feb 07, 2019 at 04:35:55PM -0700, Tycho Andersen wrote:
> On Fri, Feb 08, 2019 at 09:50:26AM +1100, Tobin C. Harding wrote:
> > Currently if user passes an output file to the script via
> > --output-raw we do not handle expansion of tilde.
> > 
> > Use perl function glob() to expand tilde in output file name.
> > 
> > Signed-off-by: Tobin C. Harding 
> > ---
> >  scripts/leaking_addresses.pl | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
> > index ef9e5b2a1614..ce545ca3fb70 100755
> > --- a/scripts/leaking_addresses.pl
> > +++ b/scripts/leaking_addresses.pl
> > @@ -150,7 +150,7 @@ if (!(is_supported_architecture() or $opt_32bit or 
> > $page_offset_32bit)) {
> >  }
> >  
> >  if ($output_raw) {
> > -   open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
> > +   open my $fh, '>', glob($output_raw) or die "$0: $output_raw: $!\n";
> 
> Seems like you might also have the same problem with $input_raw? I
> wonder if you can just do this in GetOptions somehow, so that all
> users of these further down in the script don't have to remember to do
> this.

Thanks for the review, good idea - I'll look into it.

   Tobin


Re: [PATCH] watchdog/hpwdt: Update Kconfig documentation

2019-02-08 Thread Guenter Roeck

On 2/8/19 9:48 AM, Jerry Hoemann wrote:

Update documentation relating to HPWDT_NMI_DECODING to reflect its
current usage.

Signed-off-by: Jerry Hoemann 


Reviewed-by: Guenter Roeck 


---
  drivers/watchdog/Kconfig | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 57f017d..846dd07 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1145,7 +1145,7 @@ config HP_WATCHDOG
select WATCHDOG_CORE
depends on X86 && PCI
help
- A software monitoring watchdog and NMI sourcing driver. This driver
+ A software monitoring watchdog and NMI handling driver. This driver
  will detect lockups and provide a stack trace. This is a driver that
  will only load on an HP ProLiant system with a minimum of iLO2 
support.
  To compile this driver as a module, choose M here: the module will be
@@ -1163,12 +1163,13 @@ config KEMPLD_WDT
  called kempld_wdt.
  
  config HPWDT_NMI_DECODING

-   bool "NMI decoding support for the HP ProLiant iLO2+ Hardware Watchdog 
Timer"
+   bool "NMI support for the HP ProLiant iLO2+ Hardware Watchdog Timer"
depends on HP_WATCHDOG
default y
help
- When an NMI occurs this feature will make the necessary BIOS calls to
- log the cause of the NMI.
+ Enables the NMI handler for the watchdog pretimeout NMI and the iLO
+ "Generate NMI to System" virtual button.  When an NMI is claimed
+ by the driver, panic is called.
  
  config SC1200_WDT

tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"





Re: [PATCH v1 1/2] PCI: ATS: Add function to check ATS page aligned request status.

2019-02-08 Thread Sinan Kaya

On 2/8/2019 8:02 PM, sathyanarayanan kuppuswamy wrote:

This means that you should probably have some kind of version check
here.


There is no version field in ATS v1.0 spec. Also, If I follow the 
history log in PCI spec, I think ATS if first added at v1.2. Please 
correct me if I am wrong.


v1.2 was incorporated into PCIe spec at that time. However, the ATS spec
is old and there could be some HW that could claim to be ATS compatible.
I know AMD GPUs declare ATS capability.

See this ECN

https://composter.com.ua/documents/ats_r1.1_26Jan09.pdf

You need to validate the version field from ATS capability header to be
1 before reading this register.

See Table 5-1:  ATS Extended Capability Header


Re: Linux 4.4.174

2019-02-08 Thread Mark D Rustad

On Feb 8, 2019, at 2:54 AM, Greg KH  wrote:

diff --git a/Documentation/networking/ip-sysctl.txt  
b/Documentation/networking/ip-sysctl.txt

index 2ea4c45cf1c8..7c229f59016f 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -112,14 +112,11 @@ min_adv_mss - INTEGER

 IP Fragmentation:

-ipfrag_high_thresh - INTEGER
-   Maximum memory used to reassemble IP fragments. When
-   ipfrag_high_thresh bytes of memory is allocated for this purpose,
-   the fragment handler will toss packets until ipfrag_low_thresh
-   is reached. This also serves as a maximum limit to namespaces
-   different from the initial one.
-
-ipfrag_low_thresh - INTEGER
+ipfrag_high_thresh - LONG INTEGER
+   Maximum memory used to reassemble IP fragments.
+
+ipfrag_low_thresh - LONG INTEGER
+   (Obsolete since linux-4.17)


It seems very strange to say that it is obsolete since 4.17 in a 4.4 kernel.


Maximum memory used to reassemble IP fragments before the kernel
begins to remove incomplete fragment queues to free up resources.
The kernel still accepts new fragments for defragmentation.


--
Mark Rustad, mrus...@gmail.com


signature.asc
Description: Message signed with OpenPGP


[PATCH] slub: fix SLAB_CONSISTENCY_CHECKS + KASAN_SW_TAGS

2019-02-08 Thread Qian Cai
Enabling SLUB_DEBUG's SLAB_CONSISTENCY_CHECKS with KASAN_SW_TAGS
triggers endless false positives during boot below due to
check_valid_pointer() checks tagged pointers which have no addresses
that is valid within slab pages.

[0.00] BUG radix_tree_node (Tainted: GB): Freelist 
Pointer check fails
[0.00] 
-
[0.00]
[0.00] INFO: Slab 0x(ptrval) objects=69 used=69 fp=0x  
(null) flags=0x7ffc000200
[0.00] INFO: Object 0x(ptrval) @offset=15060037153926966016 
fp=0x(ptrval)
[0.00]
[0.00] Redzone (ptrval): bb bb bb bb bb bb bb bb bb bb bb bb bb 
bb bb bb  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 18 6b 06 00 08 
80 ff d0  .k..
[0.00] Object (ptrval): 18 6b 06 00 08 80 ff d0 00 00 00 00 00 
00 00 00  .k..
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Object (ptrval): 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00  
[0.00] Redzone (ptrval): bb bb bb bb bb bb bb bb
  
[0.00] Padding (ptrval): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 
5a 5a 5a  
[0.00] CPU: 0 PID: 0 Comm: swapper/0 Tainted: GB 
5.0.0-rc5+ #18
[0.00] Call trace:
[0.00]  dump_backtrace+0x0/0x450
[0.00]  

[PATCH] regulator: stpmic1: Remove regul_id and *regmap from struct stpmic1_regulator

2019-02-08 Thread Axel Lin
At the context with *rdev available, there is no problem to get regulator
id and *regmap, so no need to store them in struct stpmic1_regulator.

Signed-off-by: Axel Lin 
---
 drivers/regulator/stpmic1_regulator.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/stpmic1_regulator.c 
b/drivers/regulator/stpmic1_regulator.c
index 963e67fa9ca6..dd5c8fb1ff86 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -30,20 +30,16 @@ struct stpmic1_regulator_cfg {
 
 /**
  * stpmic1 regulator data: this structure is used as driver data
- * @regul_id: regulator id
  * @reg_node: DT node of regulator (unused on non-DT platforms)
  * @cfg: stpmic specific regulator description
  * @mask_reset: mask_reset bit value
  * @irq_curlim: current limit interrupt number
- * @regmap: point to parent regmap structure
  */
 struct stpmic1_regulator {
-   unsigned int regul_id;
struct device_node *reg_node;
const struct stpmic1_regulator_cfg *cfg;
u8 mask_reset;
int irq_curlim;
-   struct regmap *regmap;
 };
 
 static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode);
@@ -477,7 +473,7 @@ static int stpmic1_set_icc(struct regulator_dev *rdev)
struct stpmic1_regulator *regul = rdev_get_drvdata(rdev);
 
/* enable switch off in case of over current */
-   return regmap_update_bits(regul->regmap, regul->cfg->icc_reg,
+   return regmap_update_bits(rdev->regmap, regul->cfg->icc_reg,
  regul->cfg->icc_mask, regul->cfg->icc_mask);
 }
 
@@ -505,7 +501,7 @@ static int stpmic1_regulator_init(struct platform_device 
*pdev,
 
/* set mask reset */
if (regul->mask_reset && regul->cfg->mask_reset_reg != 0) {
-   ret = regmap_update_bits(regul->regmap,
+   ret = regmap_update_bits(rdev->regmap,
 regul->cfg->mask_reset_reg,
 regul->cfg->mask_reset_mask,
 regul->cfg->mask_reset_mask);
@@ -584,10 +580,8 @@ regulator_dev *stpmic1_regulator_register(struct 
platform_device *pdev, int id,
config.regmap = pmic_dev->regmap;
config.driver_data = regul;
 
-   regul->regul_id = id;
regul->reg_node = config.of_node;
regul->cfg = _regulator_cfgs[id];
-   regul->regmap = pmic_dev->regmap;
 
rdev = devm_regulator_register(>dev, >cfg->desc, );
if (IS_ERR(rdev)) {
-- 
2.17.1



Re: [v3 PATCH 8/8] RISC-V: Assign hwcap only according to boot cpu.

2019-02-08 Thread David Abdurachmanov
On Sat, Feb 9, 2019 at 12:03 AM Atish Patra  wrote:
>
> On 2/8/19 1:11 AM, Christoph Hellwig wrote:
> >> + * We don't support running Linux on hertergenous ISA systems.
> >> + * But first "okay" processor might not be the boot cpu.
> >> + * Check the ISA of boot cpu.
> >
> > Please use up your available 80 characters per line in comments.
> >
> I will fix it.
>
> >> +/*
> >> + * All "okay" hart should have same isa. We don't know how to
> >> + * handle if they don't. Throw a warning for now.
> >> + */
> >> +if (elf_hwcap && temp_hwcap != elf_hwcap)
> >> +pr_warn("isa mismatch: 0x%lx != 0x%lx\n",
> >> +elf_hwcap, temp_hwcap);
> >> +
> >> +if (hartid == boot_cpu_hartid)
> >> +boot_hwcap = temp_hwcap;
> >> +elf_hwcap = temp_hwcap;
> >
> > So we always set elf_hwcap to the capabilities of the previous cpu.
> >
> >> +temp_hwcap = 0;
> >
> > I think tmp_hwcap should be declared and initialized inside the outer loop
> > instead having to manually reset it like this.
> >
> >> +}
> >>
> >> +elf_hwcap = boot_hwcap;
> >
> > And then reset it here to the boot cpu.
> >
> > Shoudn't we only report the features supported by all cores?  Otherwise
> > we'll still have problems if the boot cpu supports a feature, but not
> > others.
> >
>
> Hmm. The other side of the argument is boot cpu does have a feature that
> is not supported by other hart that didn't even boot.
> The user space may execute something based on boot cpu capability but
> that won't be enabled.
>
> At least, in this way we know that we are compatible completely with
> boot cpu capabilities. Thoughts ?

There is one example on the market, e.g., Samsung Exynos 9810.

Mongoose 3 (big cores) only support ARMv8.0, while Cortex-A55
(little ones) support ARMv8.2 (and that brings atomics support).
I think, it's the only ARM SOC that supports different ISA extensions
between cores on the same package.

Kernel scheduler doesn't know that big cores are missing atomics
support or that applications needs it and moves the thread
resulting in illegal instruction.

E.g., see Golang issue: https://github.com/golang/go/issues/28431

I also recall Jon Masters (Computer Architect at Red Hat) advocating
against having cores with mismatched capabilities on the server market.

It just causes more problems down the line.

david


Re: [Breakage] Git v2.21.0-rc0 - t5318 (NonStop)

2019-02-08 Thread Jeff King
On Fri, Feb 08, 2019 at 05:53:53PM -0500, Randall S. Becker wrote:

> > diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index
> > 92cf8f812c..4afab14431 100644
> > --- a/t/test-lib-functions.sh
> > +++ b/t/test-lib-functions.sh
> > @@ -1302,3 +1302,8 @@ test_set_port () {
> > port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
> > eval $var=$port
> >  }
> > +
> > +# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
> > +gen_zero_bytes () {
> > +   perl -e 'print "\0" x $ARGV[0]' "$@"
> > +}
> 
> This function does work on platform, so it's good.

Great. Since it sounds like you're preparing some patches to deal with
/dev/zero elsewhere, do you want to wrap it up in a patch as part of
that?

-Peff


Re: [PATCH 0/2] udf: Fix corrupt on-disk integrity descriptor following sync()

2019-02-08 Thread Steve Magnani

On 2/8/19 11:34 AM, Steve Magnani wrote:

In cases where the next unique ID or file/directory count of the
in-core Logical Volume Integrity Descriptor have been updated,
a sync() causes a (corrupt) LVID with a stale CRC to be written to disk.

Ordinarily, this is corrected by an update of the on-disk LVID that occurs
when the filesystem is unmounted. However, if power is lost or the
filesystem resides on a device that is surprise-removed, the corrupt LVID
remains and can complicate later remounting or fsck/chkdsk.


"Complicate later remounting" turns out to be an understatement.
Actually it seems that this one event can trigger more silent corruption
of the filesystem on future remounts.

The driver will mount without complaint a filesystem that lacks a valid LVID.
But in this scenario, every time lvid_get_unique_id() is called to generate
an ID for a new inode or link, it returns zero. It appears that callers
happily assign this zero to all new inodes or links, with no indication to
the user or in the syslog that a problem is brewing.

I lost the entire contents of a flash disk to what was probably an
instance of this kind of corruption, when I told Windows chkdsk to
repair it.

I'll try to solve that in a separate followon patchset.
The simplest solution I can think of is to force read-only mount when
no LVID is available.

Regards,

 Steven J. Magnani   "I claim this network for MARS!
 www.digidescorp.com  Earthling, return my space modulator!"

 #include 



Re: [PATCH 1/2] Revert "mm: don't reclaim inodes with many attached pages"

2019-02-08 Thread Roman Gushchin
On Fri, Feb 08, 2019 at 02:49:44PM -0800, Andrew Morton wrote:
> On Fri, 8 Feb 2019 13:50:49 +0100 Jan Kara  wrote:
> 
> > > > Has anyone done significant testing with Rik's maybe-fix?
> > > 
> > > I will give it a spin with bonnie++ today. We'll see what comes out.
> > 
> > OK, I did a bonnie++ run with Rik's patch (on top of 4.20 to rule out other
> > differences). This machine does not show so big differences in bonnie++
> > numbers but the difference is still clearly visible. The results are
> > (averages of 5 runs):
> > 
> >  Revert BaseRik
> > SeqCreate del78.04 (   0.00%)   98.18 ( -25.81%)90.90 ( -16.48%)
> > RandCreate del   87.68 (   0.00%)   95.01 (  -8.36%)87.66 (   0.03%)
> > 
> > 'Revert' is 4.20 with "mm: don't reclaim inodes with many attached pages"
> > and "mm: slowly shrink slabs with a relatively small number of objects"
> > reverted. 'Base' is the kernel without any reverts. 'Rik' is a 4.20 with
> > Rik's patch applied.
> > 
> > The numbers are time to do a batch of deletes so lower is better. You can 
> > see
> > that the patch did help somewhat but it was not enough to close the gap
> > when files are deleted in 'readdir' order.
> 
> OK, thanks.
> 
> I guess we need a rethink on Roman's fixes.   I'll queued the reverts.

Agree.

I still believe that we should cause the machine-wide memory pressure
to clean up any remains of dead cgroups, and Rik's patch is a step into
the right direction. But we need to make some experiments and probably
some code changes here to guarantee that we don't regress on performance.

> 
> 
> BTW, one thing I don't think has been discussed (or noticed) is the
> effect of "mm: don't reclaim inodes with many attached pages" on 32-bit
> highmem machines.  Look why someone added that code in the first place:
> 
> : commit f9a316fa9099053a299851762aedbf12881cff42
> : Author: Andrew Morton 
> : Date:   Thu Oct 31 04:09:37 2002 -0800
> : 
> : [PATCH] strip pagecache from to-be-reaped inodes
> : 
> : With large highmem machines and many small cached files it is possible
> : to encounter ZONE_NORMAL allocation failures.  This can be demonstrated
> : with a large number of one-byte files on a 7G machine.
> : 
> : All lowmem is filled with icache and all those inodes have a small
> : amount of highmem pagecache which makes them unfreeable.
> : 
> : The patch strips the pagecache from inodes as they come off the tail of
> : the inode_unused list.
> : 
> : I play tricks in there peeking at the head of the inode_unused list to
> : pick up the inode again after running iput().  The alternatives seemed
> : to involve more widespread changes.
> : 
> : Or running invalidate_inode_pages() under inode_lock which would be a
> : bad thing from a scheduling latency and lock contention point of view.
> 
> I guess I shold have added a comment.  Doh.
> 

It's a very useful link.

Thanks!


Re: [patch V2 1/2] genriq: Avoid summation loops for /proc/stat

2019-02-08 Thread Matthew Wilcox
On Fri, Feb 08, 2019 at 03:21:51PM -0800, Andrew Morton wrote:
> It sounds like it.  A 10khz interrupt will overflow in 4 days...

If you've got a 10kHz interrupt, you have a bigger problem.  Anything
happening 10,000 times a second is going to need interrupt mitigation
to perform acceptably.

More importantly, userspace can (and must) cope with wrapping.  This isn't
anything new from Thomas' patch.  As long as userspace is polling more
often than once a day, it's going to see a wrapped value before it wraps
again, so it won't miss 4 billion interrupts.


[PATCH -mmotm/-next] fs: fs_parser: fix printk format warning

2019-02-08 Thread Randy Dunlap
From: Randy Dunlap 

Fix printk format warning (seen on i386 builds) by using ptrdiff
format specifier (%t):

../fs/fs_parser.c:413:6: warning: format ‘%lu’ expects argument of type ‘long 
unsigned int’, but argument 3 has type ‘int’ [-Wformat=]

Signed-off-by: Randy Dunlap 
Cc: David Howells 
Cc: Alexander Viro 
---
 fs/fs_parser.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- mmotm-2019-0208-1633.orig/fs/fs_parser.c
+++ mmotm-2019-0208-1633/fs/fs_parser.c
@@ -410,7 +410,7 @@ bool fs_validate_description(const struc
for (param = desc->specs; param->name; param++) {
if (param->opt == e->opt &&
param->type != fs_param_is_enum) {
-   pr_err("VALIDATE %s: e[%lu] enum val 
for %s\n",
+   pr_err("VALIDATE %s: e[%tu] enum val 
for %s\n",
   name, e - desc->enums, 
param->name);
good = false;
}




[PATCH -mmotm/-next] pinctrl: fix pxa2xx.c build warnings

2019-02-08 Thread Randy Dunlap
From: Randy Dunlap 

Add #include of  to fix build
warnings in pinctrl-pxa2xx.c.  Fixes these warnings:

In file included from ../drivers/pinctrl/pxa/pinctrl-pxa2xx.c:24:0:
../drivers/pinctrl/pxa/../pinctrl-utils.h:36:8: warning: ‘enum 
pinctrl_map_type’ declared inside parameter list [enabled by default]
   enum pinctrl_map_type type);
^
../drivers/pinctrl/pxa/../pinctrl-utils.h:36:8: warning: its scope is only this 
definition or declaration, which is probably not what you want [enabled by 
default]

Signed-off-by: Randy Dunlap 
Cc: Robert Jarzmik 
Cc: linux-arm-ker...@lists.infradead.org
---
Seen in linux-next and mmotm.

 drivers/pinctrl/pxa/pinctrl-pxa2xx.c |1 +
 1 file changed, 1 insertion(+)

--- mmotm-2019-0208-1633.orig/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
+++ mmotm-2019-0208-1633/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 




make[2]: *** No rule to make target 'arch/sh/boot/dts/.dtb.o', needed by 'arch/sh/boot/dts/built-in.a'.

2019-02-08 Thread kbuild test robot
Hi Masahiro,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f17b5f06cb92ef2250513a1e154c47b78df07d40
commit: 8e9b61b293d98f878cf1e6d1ae164e41c0219959 kbuild: move .SECONDARY 
special target to Kbuild.include
date:   10 weeks ago
config: sh-j2_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 8e9b61b293d98f878cf1e6d1ae164e41c0219959
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=sh 

All errors (new ones prefixed by >>):

>> make[2]: *** No rule to make target 'arch/sh/boot/dts/.dtb.o', needed by 
>> 'arch/sh/boot/dts/built-in.a'.
   make[2]: Target '__build' not remade because of errors.

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


.config.gz
Description: application/gzip


[PATCH v4 2/4] gpu: ipu-v3: ipu-ic: Simplify selection of encoding matrix

2019-02-08 Thread Steve Longerbeam
Simplify the selection of the Y'CbCr encoding matrices in init_csc().
A side-effect of this change is that init_csc() now allows YUV->YUV
using the identity matrix, intead of returning error.

Signed-off-by: Steve Longerbeam 
---
 drivers/gpu/ipu-v3/ipu-ic.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c
index 3ef61f0b509b..e459615a49a1 100644
--- a/drivers/gpu/ipu-v3/ipu-ic.c
+++ b/drivers/gpu/ipu-v3/ipu-ic.c
@@ -244,16 +244,12 @@ static int init_csc(struct ipu_ic *ic,
base = (u32 __iomem *)
(priv->tpmem_base + ic->reg->tpmem_csc[csc_index]);
 
-   if (inf == IPUV3_COLORSPACE_YUV && outf == IPUV3_COLORSPACE_RGB)
+   if (inf == outf)
+   params = _csc_identity;
+   else if (inf == IPUV3_COLORSPACE_YUV)
params = _csc_ycbcr2rgb_bt601;
-   else if (inf == IPUV3_COLORSPACE_RGB && outf == IPUV3_COLORSPACE_YUV)
+   else
params = _csc_rgb2ycbcr_bt601;
-   else if (inf == IPUV3_COLORSPACE_RGB && outf == IPUV3_COLORSPACE_RGB)
-   params = _csc_identity;
-   else {
-   dev_err(priv->ipu->dev, "Unsupported color space conversion\n");
-   return -EINVAL;
-   }
 
/* Cast to unsigned */
c = (const u16 (*)[3])params->coeff;
-- 
2.17.1



[PATCH v4 4/4] media: imx: Allow BT.709 encoding for IC routes

2019-02-08 Thread Steve Longerbeam
The IC now supports BT.709 Y'CbCr encoding, in addition to existing BT.601
encoding, so allow both, for pipelines that route through the IC.

Reported-by: Tim Harvey 
Signed-off-by: Steve Longerbeam 
---
Changes in v2:
- move ic_route check above default colorimetry checks, and fill default
  colorimetry for ic_route, otherwise it's not possible to set BT.709
  encoding for ic routes.
---
 drivers/staging/media/imx/imx-media-utils.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-utils.c 
b/drivers/staging/media/imx/imx-media-utils.c
index 5f110d90a4ef..dde0e47550d7 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -544,6 +544,19 @@ void imx_media_fill_default_mbus_fields(struct 
v4l2_mbus_framefmt *tryfmt,
if (tryfmt->field == V4L2_FIELD_ANY)
tryfmt->field = fmt->field;
 
+   if (ic_route) {
+   if (tryfmt->colorspace == V4L2_COLORSPACE_DEFAULT)
+   tryfmt->colorspace = fmt->colorspace;
+
+   tryfmt->quantization = is_rgb ?
+   V4L2_QUANTIZATION_FULL_RANGE :
+   V4L2_QUANTIZATION_LIM_RANGE;
+
+   if (tryfmt->ycbcr_enc != V4L2_YCBCR_ENC_601 &&
+   tryfmt->ycbcr_enc != V4L2_YCBCR_ENC_709)
+   tryfmt->ycbcr_enc = V4L2_YCBCR_ENC_601;
+   }
+
/* fill colorimetry if necessary */
if (tryfmt->colorspace == V4L2_COLORSPACE_DEFAULT) {
tryfmt->colorspace = fmt->colorspace;
@@ -566,13 +579,6 @@ void imx_media_fill_default_mbus_fields(struct 
v4l2_mbus_framefmt *tryfmt,
tryfmt->ycbcr_enc);
}
}
-
-   if (ic_route) {
-   tryfmt->quantization = is_rgb ?
-   V4L2_QUANTIZATION_FULL_RANGE :
-   V4L2_QUANTIZATION_LIM_RANGE;
-   tryfmt->ycbcr_enc = V4L2_YCBCR_ENC_601;
-   }
 }
 EXPORT_SYMBOL_GPL(imx_media_fill_default_mbus_fields);
 
-- 
2.17.1



[PATCH v4 3/4] gpu: ipu-v3: ipu-ic: Add support for BT.709 encoding

2019-02-08 Thread Steve Longerbeam
Pass v4l2 encoding enum to the ipu_ic task init functions, and add
support for the BT.709 encoding and inverse encoding matrices.

Reported-by: Tim Harvey 
Signed-off-by: Steve Longerbeam 
---
Changes in v4:
- fix compile error.
Chnges in v3:
- none.
Changes in v2:
- only return "Unsupported YCbCr encoding" error if inf != outf,
  since if inf == outf, the identity matrix can be used. Reported
  by Tim Harvey.
---
 drivers/gpu/ipu-v3/ipu-ic.c | 71 +++--
 drivers/gpu/ipu-v3/ipu-image-convert.c  |  1 +
 drivers/staging/media/imx/imx-ic-prpencvf.c |  4 +-
 include/video/imx-ipu-v3.h  |  5 +-
 4 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c
index e459615a49a1..c5f83d7e357f 100644
--- a/drivers/gpu/ipu-v3/ipu-ic.c
+++ b/drivers/gpu/ipu-v3/ipu-ic.c
@@ -212,6 +212,23 @@ static const struct ic_csc_params ic_csc_identity = {
.scale = 2,
 };
 
+/*
+ * BT.709 encoding from RGB full range to YUV limited range:
+ *
+ * Y = R *  .2126 + G *  .7152 + B *  .0722;
+ * U = R * -.1146 + G * -.3854 + B *  .5000 + 128.;
+ * V = R *  .5000 + G * -.4542 + B * -.0458 + 128.;
+ */
+static const struct ic_csc_params ic_csc_rgb2ycbcr_bt709 = {
+   .coeff = {
+   { 54, 183, 18 },
+   { 483, 413, 128 },
+   { 128, 396, 500 },
+   },
+   .offset = { 0, 512, 512 },
+   .scale = 1,
+};
+
 /*
  * Inverse BT.601 encoding from YUV limited range to RGB full range:
  *
@@ -229,12 +246,31 @@ static const struct ic_csc_params ic_csc_ycbcr2rgb_bt601 
= {
.scale = 2,
 };
 
+/*
+ * Inverse BT.709 encoding from YUV limited range to RGB full range:
+ *
+ * R = (1. * (Y - 16)) + (1.5748 * (Cr - 128));
+ * G = (1. * (Y - 16)) - (0.1873 * (Cb - 128)) - (0.4681 * (Cr - 128));
+ * B = (1. * (Y - 16)) + (1.8556 * (Cb - 128);
+ */
+static const struct ic_csc_params ic_csc_ycbcr2rgb_bt709 = {
+   .coeff = {
+   { 128, 0, 202 },
+   { 128, 488, 452 },
+   { 128, 238, 0 },
+   },
+   .offset = { -435, 136, -507 },
+   .scale = 2,
+};
+
 static int init_csc(struct ipu_ic *ic,
enum ipu_color_space inf,
enum ipu_color_space outf,
+   enum v4l2_ycbcr_encoding encoding,
int csc_index)
 {
struct ipu_ic_priv *priv = ic->priv;
+   const struct ic_csc_params *params_rgb2yuv, *params_yuv2rgb;
const struct ic_csc_params *params;
u32 __iomem *base;
const u16 (*c)[3];
@@ -244,12 +280,30 @@ static int init_csc(struct ipu_ic *ic,
base = (u32 __iomem *)
(priv->tpmem_base + ic->reg->tpmem_csc[csc_index]);
 
+   switch (encoding) {
+   case V4L2_YCBCR_ENC_601:
+   params_rgb2yuv =  _csc_rgb2ycbcr_bt601;
+   params_yuv2rgb = _csc_ycbcr2rgb_bt601;
+   break;
+   case V4L2_YCBCR_ENC_709:
+   params_rgb2yuv =  _csc_rgb2ycbcr_bt709;
+   params_yuv2rgb = _csc_ycbcr2rgb_bt709;
+   break;
+   default:
+   if (inf != outf) {
+   dev_err(priv->ipu->dev,
+   "Unsupported YCbCr encoding\n");
+   return -EINVAL;
+   }
+   break;
+   }
+
if (inf == outf)
params = _csc_identity;
else if (inf == IPUV3_COLORSPACE_YUV)
-   params = _csc_ycbcr2rgb_bt601;
+   params = params_yuv2rgb;
else
-   params = _csc_rgb2ycbcr_bt601;
+   params = params_rgb2yuv;
 
/* Cast to unsigned */
c = (const u16 (*)[3])params->coeff;
@@ -390,6 +444,7 @@ EXPORT_SYMBOL_GPL(ipu_ic_task_disable);
 
 int ipu_ic_task_graphics_init(struct ipu_ic *ic,
  enum ipu_color_space in_g_cs,
+ enum v4l2_ycbcr_encoding encoding,
  bool galpha_en, u32 galpha,
  bool colorkey_en, u32 colorkey)
 {
@@ -408,7 +463,7 @@ int ipu_ic_task_graphics_init(struct ipu_ic *ic,
if (!(ic_conf & ic->bit->ic_conf_csc1_en)) {
/* need transparent CSC1 conversion */
ret = init_csc(ic, IPUV3_COLORSPACE_RGB,
-  IPUV3_COLORSPACE_RGB, 0);
+  IPUV3_COLORSPACE_RGB, encoding, 0);
if (ret)
goto unlock;
}
@@ -416,7 +471,7 @@ int ipu_ic_task_graphics_init(struct ipu_ic *ic,
ic->g_in_cs = in_g_cs;
 
if (ic->g_in_cs != ic->out_cs) {
-   ret = init_csc(ic, ic->g_in_cs, ic->out_cs, 1);
+   ret = init_csc(ic, ic->g_in_cs, ic->out_cs, encoding, 1);
if (ret)
goto unlock;
}
@@ -450,6 +505,7 @@ int ipu_ic_task_init_rsc(struct ipu_ic *ic,
 int 

[PATCH v4 1/4] gpu: ipu-v3: ipu-ic: Rename yuv2rgb encoding matrices

2019-02-08 Thread Steve Longerbeam
The ycbcr2rgb and inverse rgb2ycbcr matrices define the BT.601 encoding
coefficients, so rename them to indicate that. And add some comments
to make clear these are BT.601 coefficients encoding between YUV limited
range and RGB full range. The ic_csc_rgb2rgb matrix is just an identity
matrix, so rename to ic_csc_identity. No functional changes.

Signed-off-by: Steve Longerbeam 
---
Changes in v2:
- rename ic_csc_rgb2rgb matrix to ic_csc_identity.
---
 drivers/gpu/ipu-v3/ipu-ic.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c
index 594c3cbc8291..3ef61f0b509b 100644
--- a/drivers/gpu/ipu-v3/ipu-ic.c
+++ b/drivers/gpu/ipu-v3/ipu-ic.c
@@ -183,11 +183,13 @@ struct ic_csc_params {
 };
 
 /*
+ * BT.601 encoding from RGB full range to YUV limited range:
+ *
  * Y = R *  .299 + G *  .587 + B *  .114;
  * U = R * -.169 + G * -.332 + B *  .500 + 128.;
  * V = R *  .500 + G * -.419 + B * -.0813 + 128.;
  */
-static const struct ic_csc_params ic_csc_rgb2ycbcr = {
+static const struct ic_csc_params ic_csc_rgb2ycbcr_bt601 = {
.coeff = {
{ 77, 150, 29 },
{ 469, 427, 128 },
@@ -197,8 +199,11 @@ static const struct ic_csc_params ic_csc_rgb2ycbcr = {
.scale = 1,
 };
 
-/* transparent RGB->RGB matrix for graphics combining */
-static const struct ic_csc_params ic_csc_rgb2rgb = {
+/*
+ * identity matrix, used for transparent RGB->RGB graphics
+ * combining.
+ */
+static const struct ic_csc_params ic_csc_identity = {
.coeff = {
{ 128, 0, 0 },
{ 0, 128, 0 },
@@ -208,11 +213,13 @@ static const struct ic_csc_params ic_csc_rgb2rgb = {
 };
 
 /*
+ * Inverse BT.601 encoding from YUV limited range to RGB full range:
+ *
  * R = (1.164 * (Y - 16)) + (1.596 * (Cr - 128));
  * G = (1.164 * (Y - 16)) - (0.392 * (Cb - 128)) - (0.813 * (Cr - 128));
  * B = (1.164 * (Y - 16)) + (2.017 * (Cb - 128);
  */
-static const struct ic_csc_params ic_csc_ycbcr2rgb = {
+static const struct ic_csc_params ic_csc_ycbcr2rgb_bt601 = {
.coeff = {
{ 149, 0, 204 },
{ 149, 462, 408 },
@@ -238,11 +245,11 @@ static int init_csc(struct ipu_ic *ic,
(priv->tpmem_base + ic->reg->tpmem_csc[csc_index]);
 
if (inf == IPUV3_COLORSPACE_YUV && outf == IPUV3_COLORSPACE_RGB)
-   params = _csc_ycbcr2rgb;
+   params = _csc_ycbcr2rgb_bt601;
else if (inf == IPUV3_COLORSPACE_RGB && outf == IPUV3_COLORSPACE_YUV)
-   params = _csc_rgb2ycbcr;
+   params = _csc_rgb2ycbcr_bt601;
else if (inf == IPUV3_COLORSPACE_RGB && outf == IPUV3_COLORSPACE_RGB)
-   params = _csc_rgb2rgb;
+   params = _csc_identity;
else {
dev_err(priv->ipu->dev, "Unsupported color space conversion\n");
return -EINVAL;
-- 
2.17.1



Re: [PATCH net-next v5 12/12] sock: Add SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW

2019-02-08 Thread Deepa Dinamani
> You touched powerpc in the previous patch but not this one.
>
> That's because we use the asm-generic version I assume.

That is correct.

> Would be good to mention in the change log though to avoid any confusion.

I'm not sure how to do that now. It looks like the series has already
been applied to net-next with a couple of merge conflicts fixed.

-Deepa


Re: [PATCH] LSM: Allow syzbot to ignore security= parameter.

2019-02-08 Thread Tetsuo Handa
On 2019/02/09 9:28, Tetsuo Handa wrote:
> On 2019/02/09 1:23, Casey Schaufler wrote:
>> On 2/8/2019 2:52 AM, Tetsuo Handa wrote:
>>> To help administrators easily understand what LSM modules are possibly 
>>> enabled by default (which
>>> have to be fetched from e.g. /boot/config-`uname -r`)
>>
>> $ cat /sys/kernel/security/lsm
>>
> 
> /sys/kernel/security/lsm is list of "actually" enabled modules, isn't it?
> What I want is "possibly" enabled modules. Ubuntu would chose from either
> 
>   (a) explicitly add security=apparmor to kernel command line
> 
> or
> 
>   (b) explicitly remove tomoyo from CONFIG_LSM at kernel config
> 
> in order not to enable TOMOYO for those who want to enable only one of 
> SELinux/Smack/AppArmor. And for those who want to enable TOMOYO, I think
> that (b) (in other words, add
> 
>   lsm="modules listed in CONFIG_LSM" + ",tomoyo"
> 
> ) will retain compatibility when it becomes possible to enable more than
> one of SELinux/Smack/AppArmor at the same time.
> 
> If we can know "possibly" enabled modules from dmesg, users don't need to
> look at e.g. /boot/config-`uname -r`. It is not essential, but it's handy.
> 

Well, thinking again, specifying

lsm="modules listed in /sys/kernel/security/lsm" + ",tomoyo"

makes sense, for there is no need to care about disabled modules when
enabling TOMOYO. Therefore,

+   pr_info("Security Framework initializing: %s\n", order);
-   pr_info("Security Framework initializing\n");

won't be needed.

On 2019/02/09 6:33, Kees Cook wrote:
> On Thu, Feb 7, 2019 at 8:24 AM Casey Schaufler  wrote:
>> I added Kees to the CC list. Kees, what to you think about
>> ignoring security= if lsm= is specified? I'm ambivalent.
> 
> This was one of many earlier suggestions, and the consensus seemed to
> be "don't mix security= and lsm=". Why would anyone use both?
> 

Then, can we add this change?

+   if (chosen_lsm_order) {
+   if (chosen_major_lsm) {
+   pr_info("security= is ignored because of lsm=\n");
+   chosen_major_lsm = NULL;
+   }
+   }



Re: [PATCH v3 3/4] gpu: ipu-v3: ipu-ic: Add support for BT.709 encoding

2019-02-08 Thread Steve Longerbeam




On 2/8/19 4:20 PM, Tim Harvey wrote:

On Fri, Feb 8, 2019 at 11:28 AM Steve Longerbeam  wrote:

 if (inf == outf)
 params = _csc_identity;
 else if (inf == IPUV3_COLORSPACE_YUV)
-   params = _csc_ycbcr2rgb_bt601;
+   params = _csc_ycbcr2rgb;


Steve,

compile issue...

params = params_yuv2rgb;


 else
-   params = _csc_rgb2ycbcr_bt601;
+   params = _csc_rgb2ycbcr;

params = params_rgb2yuv;


Wow, did I not even compile test that? Must be my head cold :-/
Sending v4.



But, I'm still failing when using the mem2mem element (gst-launch-1.0
v4l2src device=/dev/video4 ! v4l2video8convert
output-io-mode=dmabuf-import ! fbdevsink) with 'Unsupported YCbCr
encoding' because of inf=IPU_COLORSPACE_YCBCR outf=IPU_COLORSPACE_RGB
and a seemingly unset encoding being passed in.

It looks like maybe something in the mem2mem driver isn't defaulting
encoding. The call path is (v4l2_m2m_streamon -> device_run ->
ipu_image_convert_queue -> convert_start -> ipu_ic_task_init_rsc ->
init_csc).


Looking at v7 of the mem2mem driver, it will set ycbcr_enc at the output 
side to V4L2_YCBCR_ENC_DEFAULT if colorspace is default. So colorspace 
will need to be set to something non-default in addition to setting 
ycbcr_enc, at the output side. I don't know whether gstreamer 
v4l2videoNconvertelement will do this, but you could hack the driver for 
now to get around it, and let Philipp know this may need a workaround in 
mem2mem for v8.


Steve


[PATCH 6/9] perf, bpf: save btf in a rbtree in perf_env

2019-02-08 Thread Song Liu
btf contains information necessary to annotate bpf programs. This patch
saves btf for bpf programs loaded in the system.

perf-record saves btf information as headers to perf.data. A new header
type HEADER_BTF is introduced for this data.

Signed-off-by: Song Liu 
---
 tools/perf/util/bpf-event.c | 22 +
 tools/perf/util/bpf-event.h |  7 +++
 tools/perf/util/env.c   | 65 
 tools/perf/util/env.h   |  3 ++
 tools/perf/util/header.c| 99 -
 tools/perf/util/header.h|  1 +
 6 files changed, 196 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index ead599bc4f4e..37a5b8134e00 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -30,6 +30,27 @@ int machine__process_bpf_event(struct machine *machine 
__maybe_unused,
return 0;
 }
 
+static int perf_fetch_btf(struct perf_env *env, u32 btf_id, struct btf *btf)
+{
+   struct btf_node *node;
+   u32 data_size;
+   const void *data;
+
+   data = btf__get_raw_data(btf, _size);
+
+   node = malloc(data_size + sizeof(struct btf_node));
+
+   if (!node)
+   return -1;
+
+   node->id = btf_id;
+   node->data_size = data_size;
+   memcpy(node->data, data, data_size);
+
+   perf_env__insert_btf(env, node);
+   return 0;
+}
+
 /*
  * Synthesize PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT for one bpf
  * program. One PERF_RECORD_BPF_EVENT is generated for the program. And
@@ -109,6 +130,7 @@ static int perf_event__synthesize_one_bpf_prog(struct 
perf_session *session,
goto out;
}
has_btf = true;
+   perf_fetch_btf(env, info->btf_id, btf);
}
 
/* Synthesize PERF_RECORD_KSYMBOL */
diff --git a/tools/perf/util/bpf-event.h b/tools/perf/util/bpf-event.h
index 11e6730b6105..60ce24e4e5c6 100644
--- a/tools/perf/util/bpf-event.h
+++ b/tools/perf/util/bpf-event.h
@@ -20,6 +20,13 @@ struct bpf_prog_info_node {
struct rb_node  rb_node;
 };
 
+struct btf_node {
+   struct rb_node  rb_node;
+   u32 id;
+   u32 data_size;
+   chardata[];
+};
+
 #ifdef HAVE_LIBBPF_SUPPORT
 int machine__process_bpf_event(struct machine *machine, union perf_event 
*event,
   struct perf_sample *sample);
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 665b6fe3c7b2..6f9e3d4b94bc 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -61,6 +61,57 @@ struct bpf_prog_info_node 
*perf_env__find_bpf_prog_info(struct perf_env *env,
return node;
 }
 
+void perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node)
+{
+   struct rb_node *parent = NULL;
+   __u32 btf_id = btf_node->id;
+   struct btf_node *node;
+   struct rb_node **p;
+
+   down_write(>bpf_info_lock);
+   p = >btfs.rb_node;
+
+   while (*p != NULL) {
+   parent = *p;
+   node = rb_entry(parent, struct btf_node, rb_node);
+   if (btf_id < node->id) {
+   p = &(*p)->rb_left;
+   } else if (btf_id > node->id) {
+   p = &(*p)->rb_right;
+   } else {
+   pr_debug("duplicated btf %u\n", btf_id);
+   up_write(>bpf_info_lock);
+   return;
+   }
+   }
+
+   rb_link_node(_node->rb_node, parent, p);
+   rb_insert_color(_node->rb_node, >btfs);
+   up_write(>bpf_info_lock);
+}
+
+struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
+{
+   struct btf_node *node = NULL;
+   struct rb_node *n;
+
+   down_read(>bpf_info_lock);
+   n = env->btfs.rb_node;
+
+   while (n) {
+   node = rb_entry(n, struct btf_node, rb_node);
+   if (btf_id < node->id)
+   n = n->rb_left;
+   else if (btf_id > node->id)
+   n = n->rb_right;
+   else
+   break;
+   }
+
+   up_read(>bpf_info_lock);
+   return node;
+}
+
 /* purge data in bpf_prog_infos tree */
 static void purge_bpf_info(struct perf_env *env)
 {
@@ -80,6 +131,19 @@ static void purge_bpf_info(struct perf_env *env)
rb_erase_init(>rb_node, root);
free(node);
}
+
+   root = >btfs;
+   next = rb_first(root);
+
+   while (next) {
+   struct btf_node *node;
+
+   node = rb_entry(next, struct btf_node, rb_node);
+   next = rb_next(>rb_node);
+   rb_erase_init(>rb_node, root);
+   free(node);
+   }
+
up_write(>bpf_info_lock);
 }
 
@@ -117,6 +181,7 @@ void perf_env__exit(struct perf_env *env)
 static void init_bpf_rb_trees(struct perf_env *env)
 {
env->bpf_prog_infos = RB_ROOT;
+   

[PATCH 7/9] perf-top: add option --bpf-event

2019-02-08 Thread Song Liu
bpf events are only tracked when opts->bpf_event is enabled. This patch
adds command line flag to enable this for perf-top.

Signed-off-by: Song Liu 
---
 tools/perf/builtin-top.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 27d8d42e0a4d..5271d7211b9c 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1492,6 +1492,7 @@ int cmd_top(int argc, const char **argv)
"Display raw encoding of assembly instructions (default)"),
OPT_BOOLEAN(0, "demangle-kernel", _conf.demangle_kernel,
"Enable kernel symbol demangling"),
+   OPT_BOOLEAN(0, "bpf-event", >bpf_event, "record bpf events"),
OPT_STRING(0, "objdump", _opts.objdump_path, "path",
"objdump binary to use for disassembly and annotations"),
OPT_STRING('M', "disassembler-style", 
_opts.disassembler_style, "disassembler style",
-- 
2.17.1



[PATCH 8/9] perf, bpf: enable annotation of bpf program

2019-02-08 Thread Song Liu
This patch enables the annotation of bpf program.

A new dso type DSO_BINARY_TYPE__BPF_PROG_INFO is introduced to for BPF
programs. In symbol__disassemble(), DSO_BINARY_TYPE__BPF_PROG_INFO dso
calls into a new function symbol__disassemble_bpf(), where annotation
line information is filled based bpf_prog_info and btf saved in given
perf_env.

symbol__disassemble_bpf() uses libbfd to disassemble bpf programs.

Signed-off-by: Song Liu 
---
 tools/perf/Makefile.config  |   2 +-
 tools/perf/util/annotate.c  | 149 +++-
 tools/perf/util/bpf-event.c |  48 
 tools/perf/util/bpf-event.h |   4 +
 tools/perf/util/dso.c   |   1 +
 tools/perf/util/dso.h   |  33 +---
 tools/perf/util/symbol.c|   1 +
 7 files changed, 225 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index b441c88cafa1..e0bafbc273af 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -701,7 +701,7 @@ else
 endif
 
 ifeq ($(feature-libbfd), 1)
-  EXTLIBS += -lbfd
+  EXTLIBS += -lbfd -lopcodes
 else
   # we are on a system that requires -liberty and (maybe) -lz
   # to link against -lbfd; test each case individually here
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 70de8f6b3aee..078017d31ca9 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -22,6 +22,7 @@
 #include "annotate.h"
 #include "evsel.h"
 #include "evlist.h"
+#include "bpf-event.h"
 #include "block-range.h"
 #include "string2.h"
 #include "arch/common.h"
@@ -29,6 +30,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 /* FIXME: For the HE_COLORSET */
 #include "ui/browser.h"
@@ -1672,6 +1676,147 @@ static int dso__disassemble_filename(struct dso *dso, 
char *filename, size_t fil
return 0;
 }
 
+static void get_exec_path(char *tpath, size_t size)
+{
+   const char *path = "/proc/self/exe";
+   ssize_t len;
+
+   len = readlink(path, tpath, size - 1);
+   assert(len > 0);
+   tpath[len] = 0;
+}
+
+static int symbol__disassemble_bpf(struct symbol *sym,
+  struct annotate_args *args)
+{
+   struct annotation *notes = symbol__annotation(sym);
+   struct annotation_options *opts = args->options;
+   struct bpf_prog_info_linear *info_linear;
+   struct bpf_prog_linfo *prog_linfo = NULL;
+   struct bpf_prog_info_node *info_node;
+   int len = sym->end - sym->start;
+   disassembler_ftype disassemble;
+   struct map *map = args->ms.map;
+   struct disassemble_info info;
+   struct dso *dso = map->dso;
+   int pc = 0, count, sub_id;
+   struct btf *btf = NULL;
+   char tpath[PATH_MAX];
+   size_t buf_size;
+   int nr_skip = 0;
+   __u64 arrays;
+   char *buf;
+   bfd *bfdf;
+   FILE *s;
+
+   if (dso->binary_type != DSO_BINARY_TYPE__BPF_PROG_INFO)
+   return -1;
+
+   pr_debug("%s: handling sym %s addr %lx len %lx\n", __func__,
+sym->name, sym->start, sym->end - sym->start);
+
+   memset(tpath, 0, sizeof(tpath));
+   get_exec_path(tpath, sizeof(tpath));
+
+   bfdf = bfd_openr(tpath, NULL);
+   assert(bfdf);
+   assert(bfd_check_format(bfdf, bfd_object));
+
+   s = open_memstream(, _size);
+   init_disassemble_info(, s,
+ (fprintf_ftype) fprintf);
+
+   info.arch = bfd_get_arch(bfdf);
+   info.mach = bfd_get_mach(bfdf);
+
+   arrays = 1UL << BPF_PROG_INFO_JITED_INSNS;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_KSYMS;
+   arrays |= 1UL << BPF_PROG_INFO_LINE_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_FUNC_INFO;
+
+   info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
+dso->bpf_prog.id);
+   if (!info_node)
+   return -1;
+   info_linear = info_node->info_linear;
+   sub_id = dso->bpf_prog.sub_id;
+
+   info.buffer = (void *)(info_linear->info.jited_prog_insns);
+   info.buffer_length = info_linear->info.jited_prog_len;
+
+   if (info_linear->info.nr_line_info)
+   prog_linfo = bpf_prog_linfo__new(_linear->info);
+   prog_linfo = prog_linfo;
+
+   if (info_linear->info.btf_id) {
+   struct btf_node *node;
+
+   node = perf_env__find_btf(dso->bpf_prog.env,
+ info_linear->info.btf_id);
+   if (node)
+   btf = btf__new((__u8 *)(node->data),
+  node->data_size);
+   }
+
+   disassemble_init_for_target();
+
+#ifdef DISASM_FOUR_ARGS_SIGNATURE
+   disassemble = disassembler(info.arch,
+  bfd_big_endian(bfdf),
+  info.mach,
+  bfdf);
+#else
+   disassemble = disassembler(bfdf);
+#endif
+   

[PATCH 9/9] perf, bpf: save information about short living bpf programs

2019-02-08 Thread Song Liu
To annotate bpf programs in perf, it is necessary to save information in
bpf_prog_info and btf. For short living bpf program, it is necessary to
save these information before it is unloaded.

This patch saves these information in a separate thread. This thread
creates its own evlist, that only tracks bpf events. This evlists uses
ring buffer with very low watermark for lower latency. When bpf load
events are received, this thread tries to gather information via sys_bpf
and save it in perf_env.

Signed-off-by: Song Liu 
---
 tools/perf/builtin-record.c |  13 
 tools/perf/builtin-top.c|  12 
 tools/perf/util/bpf-event.c | 126 
 tools/perf/util/bpf-event.h |  22 +++
 tools/perf/util/evlist.c|  20 ++
 tools/perf/util/evlist.h|   2 +
 6 files changed, 195 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2355e0a9eda0..46abb44b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1106,6 +1106,8 @@ static int __cmd_record(struct record *rec, int argc, 
const char **argv)
struct perf_data *data = >data;
struct perf_session *session;
bool disabled = false, draining = false;
+   struct bpf_event_poll_args poll_args;
+   bool bpf_thread_running = false;
int fd;
 
atexit(record__sig_exit);
@@ -1206,6 +1208,14 @@ static int __cmd_record(struct record *rec, int argc, 
const char **argv)
goto out_child;
}
 
+   if (rec->opts.bpf_event) {
+   poll_args.env = >header.env;
+   poll_args.target = >opts.target;
+   poll_args.done = 
+   if (bpf_event__start_polling_thread(_args) == 0)
+   bpf_thread_running = true;
+   }
+
err = record__synthesize(rec, false);
if (err < 0)
goto out_child;
@@ -1456,6 +1466,9 @@ static int __cmd_record(struct record *rec, int argc, 
const char **argv)
 
 out_delete_session:
perf_session__delete(session);
+
+   if (bpf_thread_running)
+   bpf_event__stop_polling_thread(_args);
return status;
 }
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5271d7211b9c..2586ee081967 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1524,10 +1524,12 @@ int cmd_top(int argc, const char **argv)
"number of thread to run event synthesize"),
OPT_END()
};
+   struct bpf_event_poll_args poll_args;
const char * const top_usage[] = {
"perf top []",
NULL
};
+   bool bpf_thread_running = false;
int status = hists__init();
 
if (status < 0)
@@ -1652,8 +1654,18 @@ int cmd_top(int argc, const char **argv)
signal(SIGWINCH, winch_sig);
}
 
+   if (top.record_opts.bpf_event) {
+   poll_args.env = _env;
+   poll_args.target = target;
+   poll_args.done = 
+   if (bpf_event__start_polling_thread(_args) == 0)
+   bpf_thread_running = true;
+   }
status = __cmd_top();
 
+   if (bpf_thread_running)
+   bpf_event__stop_polling_thread(_args);
+
 out_delete_evlist:
perf_evlist__delete(top.evlist);
 
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 4f347d61ed96..23a3b0605de7 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -8,6 +8,7 @@
 #include "machine.h"
 #include "env.h"
 #include "session.h"
+#include "evlist.h"
 
 #define ptr_to_u64(ptr)((__u64)(unsigned long)(ptr))
 
@@ -316,3 +317,128 @@ int perf_event__synthesize_bpf_events(struct perf_session 
*session,
free(event);
return err;
 }
+
+static void perf_env_add_bpf_info(struct perf_env *env, u32 id)
+{
+   struct bpf_prog_info_linear *info_linear;
+   struct bpf_prog_info_node *info_node;
+   struct btf *btf;
+   u64 arrays;
+   u32 btf_id;
+   int fd;
+
+   fd = bpf_prog_get_fd_by_id(id);
+   if (fd < 0)
+   return;
+
+   arrays = 1UL << BPF_PROG_INFO_JITED_KSYMS;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_FUNC_LENS;
+   arrays |= 1UL << BPF_PROG_INFO_FUNC_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_PROG_TAGS;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_INSNS;
+   arrays |= 1UL << BPF_PROG_INFO_LINE_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_LINE_INFO;
+
+   info_linear = bpf_program__get_prog_info_linear(fd, arrays);
+   if (IS_ERR_OR_NULL(info_linear)) {
+   pr_debug("%s: failed to get BPF program info. aborting\n", 
__func__);
+   close(fd);
+   return;
+   }
+
+   btf_id = info_linear->info.btf_id;
+
+   info_node = malloc(sizeof(struct bpf_prog_info_node));
+   if (info_node) {
+   info_node->info_linear = info_linear;
+ 

[PATCH 1/9] perf, bpf: consider events with attr.bpf_event as side-band events

2019-02-08 Thread Song Liu
Events with bpf_event should be considered as side-band event, as they
carry information about BPF programs.

Fixes: 6ee52e2a3fe4 ("perf, bpf: Introduce PERF_RECORD_BPF_EVENT")
Signed-off-by: Song Liu 
---
 kernel/events/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 0a8dab322111..9403bdda5f8c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4238,7 +4238,8 @@ static bool is_sb_event(struct perf_event *event)
if (attr->mmap || attr->mmap_data || attr->mmap2 ||
attr->comm || attr->comm_exec ||
attr->task || attr->ksymbol ||
-   attr->context_switch)
+   attr->context_switch ||
+   attr->bpf_event)
return true;
return false;
 }
-- 
2.17.1



[PATCH 0/9] perf annotation of BPF programs

2019-02-08 Thread Song Liu
This series enables annotation of BPF programs in perf.

perf tool gathers information via sys_bpf and (optionally) stores them in
perf.data as headers.

Patch 1/9 fixes a minor issue in kernel;
Patch 2/9 to 4/9 introduce new helper functions and use them in perf and
 bpftool;
Patch 5/9 and 6/9 saves information of bpf program in perf_env;
Patch 7/9 adds --bpf-event options to perf-top;
Patch 8/9 enables annotation of bpf programs based on information gathered
 in 5/9 and 6/9;
Patch 9/9 handles information of short living BPF program that are loaded
 during perf-record or perf-top.

Commands tested during developments are perf-top, perf-record, perf-report,
and perf-annotate.

= Note on patch dependency  
This set has dependency in both bpf-next tree and tip/perf/core. Current
version is developed on bpf-next tree with the following commits
cherry-picked from tip/perf/core:

(from 1/10 to 10/10)
commit 76193a94522f ("perf, bpf: Introduce PERF_RECORD_KSYMBOL")
commit d764ac646491 ("tools headers uapi: Sync 
tools/include/uapi/linux/perf_event.h")
commit 6ee52e2a3fe4 ("perf, bpf: Introduce PERF_RECORD_BPF_EVENT")
commit df063c83aa2c ("tools headers uapi: Sync 
tools/include/uapi/linux/perf_event.h")
commit 9aa0bfa370b2 ("perf tools: Handle PERF_RECORD_KSYMBOL")
commit 45178a928a4b ("perf tools: Handle PERF_RECORD_BPF_EVENT")
commit 7b612e291a5a ("perf tools: Synthesize PERF_RECORD_* for loaded BPF 
programs")
commit a40b95bcd30c ("perf top: Synthesize BPF events for pre-existing loaded 
BPF programs")
commit 6934058d9fb6 ("bpf: Add module name [bpf] to ksymbols for bpf programs")
commit 811184fb6977 ("perf bpf: Fix synthesized PERF_RECORD_KSYMBOL/BPF_EVENT")


Song Liu (9):
  perf, bpf: consider events with attr.bpf_event as side-band events
  bpf: libbpf: introduce bpf_program__get_prog_info_linear()
  bpf: bpftool: use bpf_program__get_prog_info_linear() in
prog.c:do_dump()
  perf, bpf: synthesize bpf events with
bpf_program__get_prog_info_linear()
  perf, bpf: save bpf_prog_info in a rbtree in perf_env
  perf, bpf: save btf in a rbtree in perf_env
  perf-top: add option --bpf-event
  perf, bpf: enable annotation of bpf program
  perf, bpf: save information about short living bpf programs

 kernel/events/core.c|   3 +-
 tools/bpf/bpftool/prog.c| 266 ++-
 tools/lib/bpf/libbpf.c  | 251 ++
 tools/lib/bpf/libbpf.h  |  63 +++
 tools/lib/bpf/libbpf.map|   3 +
 tools/perf/Makefile.config  |   2 +-
 tools/perf/builtin-record.c |  15 +-
 tools/perf/builtin-top.c|  15 +-
 tools/perf/util/annotate.c  | 149 ++-
 tools/perf/util/bpf-event.c | 351 +++-
 tools/perf/util/bpf-event.h |  48 -
 tools/perf/util/dso.c   |   1 +
 tools/perf/util/dso.h   |  33 ++--
 tools/perf/util/env.c   | 148 +++
 tools/perf/util/env.h   |  12 ++
 tools/perf/util/evlist.c|  20 ++
 tools/perf/util/evlist.h|   2 +
 tools/perf/util/header.c| 231 +++-
 tools/perf/util/header.h|   2 +
 tools/perf/util/symbol.c|   1 +
 20 files changed, 1304 insertions(+), 312 deletions(-)

--
2.17.1


[PATCH 5/9] perf, bpf: save bpf_prog_info in a rbtree in perf_env

2019-02-08 Thread Song Liu
bpf_prog_info contains information necessary to annotate bpf programs.
This patch saves bpf_prog_info for bpf programs loaded in the system.

perf-record saves bpf_prog_info information as headers to perf.data.
A new header type HEADER_BPF_PROG_INFO is introduced for this data.

Signed-off-by: Song Liu 
---
 tools/perf/builtin-record.c |   2 +-
 tools/perf/builtin-top.c|   2 +-
 tools/perf/util/bpf-event.c |  39 ---
 tools/perf/util/bpf-event.h |  15 +++-
 tools/perf/util/env.c   |  83 ++
 tools/perf/util/env.h   |   9 +++
 tools/perf/util/header.c| 134 +++-
 tools/perf/util/header.h|   1 +
 8 files changed, 271 insertions(+), 14 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 88ea11d57c6f..2355e0a9eda0 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1083,7 +1083,7 @@ static int record__synthesize(struct record *rec, bool 
tail)
return err;
}
 
-   err = perf_event__synthesize_bpf_events(tool, process_synthesized_event,
+   err = perf_event__synthesize_bpf_events(session, 
process_synthesized_event,
machine, opts);
if (err < 0)
pr_warning("Couldn't synthesize bpf events.\n");
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a486d4de56e..27d8d42e0a4d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1216,7 +1216,7 @@ static int __cmd_top(struct perf_top *top)
 
init_process_thread(top);
 
-   ret = perf_event__synthesize_bpf_events(>tool, perf_event__process,
+   ret = perf_event__synthesize_bpf_events(top->session, 
perf_event__process,
>session->machines.host,
>record_opts);
if (ret < 0)
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index e6dfb95029e5..ead599bc4f4e 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -1,15 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include "bpf-event.h"
 #include "debug.h"
 #include "symbol.h"
 #include "machine.h"
+#include "env.h"
+#include "session.h"
 
 #define ptr_to_u64(ptr)((__u64)(unsigned long)(ptr))
 
@@ -42,7 +40,7 @@ int machine__process_bpf_event(struct machine *machine 
__maybe_unused,
  *   -1 for failures;
  *   -2 for lack of kernel support.
  */
-static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
+static int perf_event__synthesize_one_bpf_prog(struct perf_session *session,
   perf_event__handler_t process,
   struct machine *machine,
   int fd,
@@ -52,17 +50,29 @@ static int perf_event__synthesize_one_bpf_prog(struct 
perf_tool *tool,
struct ksymbol_event *ksymbol_event = >ksymbol_event;
struct bpf_event *bpf_event = >bpf_event;
struct bpf_prog_info_linear *info_linear;
+   struct perf_tool *tool = session->tool;
+   struct bpf_prog_info_node *info_node;
struct bpf_prog_info *info;
struct btf *btf = NULL;
bool has_btf = false;
+   struct perf_env *env;
u32 sub_prog_cnt, i;
int err = 0;
u64 arrays;
 
+   /*
+* for perf-record and perf-report use header.env;
+* otherwise, use global perf_env.
+*/
+   env = session->data ? >header.env : _env;
+
arrays = 1UL << BPF_PROG_INFO_JITED_KSYMS;
arrays |= 1UL << BPF_PROG_INFO_JITED_FUNC_LENS;
arrays |= 1UL << BPF_PROG_INFO_FUNC_INFO;
arrays |= 1UL << BPF_PROG_INFO_PROG_TAGS;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_INSNS;
+   arrays |= 1UL << BPF_PROG_INFO_LINE_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_LINE_INFO;
 
info_linear = bpf_program__get_prog_info_linear(fd, arrays);
if (IS_ERR_OR_NULL(info_linear)) {
@@ -151,8 +161,8 @@ static int perf_event__synthesize_one_bpf_prog(struct 
perf_tool *tool,
 machine, process);
}
 
-   /* Synthesize PERF_RECORD_BPF_EVENT */
if (opts->bpf_event) {
+   /* Synthesize PERF_RECORD_BPF_EVENT */
*bpf_event = (struct bpf_event){
.header = {
.type = PERF_RECORD_BPF_EVENT,
@@ -165,6 +175,19 @@ static int perf_event__synthesize_one_bpf_prog(struct 
perf_tool *tool,
memcpy(bpf_event->tag, info->tag, BPF_TAG_SIZE);
memset((void *)event + event->header.size, 0, 
machine->id_hdr_size);
event->header.size += machine->id_hdr_size;
+
+   /* save bpf_prog_info to env */
+   info_node = 

[PATCH 3/9] bpf: bpftool: use bpf_program__get_prog_info_linear() in prog.c:do_dump()

2019-02-08 Thread Song Liu
This patches uses bpf_program__get_prog_info_linear() to simplify the
logic in prog.c do_dump().

Cc: Daniel Borkmann 
Cc: Alexei Starovoitov 
Signed-off-by: Song Liu 
---
 tools/bpf/bpftool/prog.c | 266 +--
 1 file changed, 59 insertions(+), 207 deletions(-)

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 0640e9bc0ada..206b820df7c2 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -393,41 +393,31 @@ static int do_show(int argc, char **argv)
 
 static int do_dump(int argc, char **argv)
 {
-   unsigned int finfo_rec_size, linfo_rec_size, jited_linfo_rec_size;
-   void *func_info = NULL, *linfo = NULL, *jited_linfo = NULL;
-   unsigned int nr_finfo, nr_linfo = 0, nr_jited_linfo = 0;
+   struct bpf_prog_info_linear *info_linear;
struct bpf_prog_linfo *prog_linfo = NULL;
-   unsigned long *func_ksyms = NULL;
-   struct bpf_prog_info info = {};
-   unsigned int *func_lens = NULL;
+   enum {DUMP_JITED, DUMP_XLATED} mode;
const char *disasm_opt = NULL;
-   unsigned int nr_func_ksyms;
-   unsigned int nr_func_lens;
+   struct bpf_prog_info *info;
struct dump_data dd = {};
-   __u32 len = sizeof(info);
+   void *func_info = NULL;
struct btf *btf = NULL;
-   unsigned int buf_size;
char *filepath = NULL;
bool opcodes = false;
bool visual = false;
char func_sig[1024];
unsigned char *buf;
bool linum = false;
-   __u32 *member_len;
-   __u64 *member_ptr;
+   __u32 member_len;
+   __u64 arrays;
ssize_t n;
-   int err;
int fd;
 
if (is_prefix(*argv, "jited")) {
if (disasm_init())
return -1;
-
-   member_len = _prog_len;
-   member_ptr = _prog_insns;
+   mode = DUMP_JITED;
} else if (is_prefix(*argv, "xlated")) {
-   member_len = _prog_len;
-   member_ptr = _prog_insns;
+   mode = DUMP_XLATED;
} else {
p_err("expected 'xlated' or 'jited', got: %s", *argv);
return -1;
@@ -466,175 +456,50 @@ static int do_dump(int argc, char **argv)
return -1;
}
 
-   err = bpf_obj_get_info_by_fd(fd, , );
-   if (err) {
-   p_err("can't get prog info: %s", strerror(errno));
-   return -1;
-   }
-
-   if (!*member_len) {
-   p_info("no instructions returned");
-   close(fd);
-   return 0;
-   }
+   if (mode == DUMP_JITED)
+   arrays = 1UL << BPF_PROG_INFO_JITED_INSNS;
+   else
+   arrays = 1UL << BPF_PROG_INFO_XLATED_INSNS;
 
-   buf_size = *member_len;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_KSYMS;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_FUNC_LENS;
+   arrays |= 1UL << BPF_PROG_INFO_FUNC_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_LINE_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_LINE_INFO;
 
-   buf = malloc(buf_size);
-   if (!buf) {
-   p_err("mem alloc failed");
-   close(fd);
+   info_linear = bpf_program__get_prog_info_linear(fd, arrays);
+   close(fd);
+   if (IS_ERR_OR_NULL(info_linear)) {
+   p_err("can't get prog info: %s", strerror(errno));
return -1;
}
 
-   nr_func_ksyms = info.nr_jited_ksyms;
-   if (nr_func_ksyms) {
-   func_ksyms = malloc(nr_func_ksyms * sizeof(__u64));
-   if (!func_ksyms) {
-   p_err("mem alloc failed");
-   close(fd);
-   goto err_free;
-   }
-   }
-
-   nr_func_lens = info.nr_jited_func_lens;
-   if (nr_func_lens) {
-   func_lens = malloc(nr_func_lens * sizeof(__u32));
-   if (!func_lens) {
-   p_err("mem alloc failed");
-   close(fd);
+   info = _linear->info;
+   if (mode == DUMP_JITED) {
+   if (info->jited_prog_len == 0) {
+   p_info("no instructions returned");
goto err_free;
}
-   }
-
-   nr_finfo = info.nr_func_info;
-   finfo_rec_size = info.func_info_rec_size;
-   if (nr_finfo && finfo_rec_size) {
-   func_info = malloc(nr_finfo * finfo_rec_size);
-   if (!func_info) {
-   p_err("mem alloc failed");
-   close(fd);
+   buf = (unsigned char *)(info->jited_prog_insns);
+   member_len = info->jited_prog_len;
+   } else {/* DUMP_XLATED */
+   if (info->xlated_prog_len == 0) {
+   p_err("error retrieving insn dump: kernel.kptr_restrict 
set?");
goto err_free;
}
+   buf = (unsigned char 

[PATCH 2/9] bpf: libbpf: introduce bpf_program__get_prog_info_linear()

2019-02-08 Thread Song Liu
Currently, bpf_prog_info includes 9 arrays. The user has the option to
fetch any combination of these arrays. However, this requires a lot of
handling of these arrays. This work becomes more tricky when we need to
store bpf_prog_info to a file, because these arrays are allocated
independently.

This patch introduces struct bpf_prog_info_linear, which stores arrays
of bpf_prog_info in continues memory. Helper functions are introduced
to unify the work to get different information of bpf_prog_info.
Specifically, bpf_program__get_prog_info_linear() allows the user to
select which arrays to fetch, and handles details for the user.

Plesae see the comments before enum bpf_prog_info_array for more details
and examples.

Cc: Daniel Borkmann 
Cc: Alexei Starovoitov 
Signed-off-by: Song Liu 
---
 tools/lib/bpf/libbpf.c   | 251 +++
 tools/lib/bpf/libbpf.h   |  63 ++
 tools/lib/bpf/libbpf.map |   3 +
 3 files changed, 317 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index e3c39edfb9d3..1f808c555747 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -113,6 +113,11 @@ void libbpf_print(enum libbpf_print_level level, const 
char *format, ...)
 # define LIBBPF_ELF_C_READ_MMAP ELF_C_READ
 #endif
 
+static inline __u64 ptr_to_u64(const void *ptr)
+{
+   return (__u64) (unsigned long) ptr;
+}
+
 struct bpf_capabilities {
/* v4.14: kernel support for program & map names. */
__u32 name:1;
@@ -2979,3 +2984,249 @@ bpf_perf_event_read_simple(void *mmap_mem, size_t 
mmap_size, size_t page_size,
ring_buffer_write_tail(header, data_tail);
return ret;
 }
+
+struct bpf_prog_info_array_desc {
+   int array_offset;   /* e.g. offset of jited_prog_insns */
+   int count_offset;   /* e.g. offset of jited_prog_len */
+   int size_offset;/* > 0: offset of rec size,
+* < 0: fix size of -size_offset
+*/
+};
+
+static struct bpf_prog_info_array_desc bpf_prog_info_array_desc[] = {
+   [BPF_PROG_INFO_JITED_INSNS] = {
+   offsetof(struct bpf_prog_info, jited_prog_insns),
+   offsetof(struct bpf_prog_info, jited_prog_len),
+   -1,
+   },
+   [BPF_PROG_INFO_XLATED_INSNS] = {
+   offsetof(struct bpf_prog_info, xlated_prog_insns),
+   offsetof(struct bpf_prog_info, xlated_prog_len),
+   -1,
+   },
+   [BPF_PROG_INFO_MAP_IDS] = {
+   offsetof(struct bpf_prog_info, map_ids),
+   offsetof(struct bpf_prog_info, nr_map_ids),
+   -(int)sizeof(__u32),
+   },
+   [BPF_PROG_INFO_JITED_KSYMS] = {
+   offsetof(struct bpf_prog_info, jited_ksyms),
+   offsetof(struct bpf_prog_info, nr_jited_ksyms),
+   -(int)sizeof(__u64),
+   },
+   [BPF_PROG_INFO_JITED_FUNC_LENS] = {
+   offsetof(struct bpf_prog_info, jited_func_lens),
+   offsetof(struct bpf_prog_info, nr_jited_func_lens),
+   -(int)sizeof(__u32),
+   },
+   [BPF_PROG_INFO_FUNC_INFO] = {
+   offsetof(struct bpf_prog_info, func_info),
+   offsetof(struct bpf_prog_info, nr_func_info),
+   offsetof(struct bpf_prog_info, func_info_rec_size),
+   },
+   [BPF_PROG_INFO_LINE_INFO] = {
+   offsetof(struct bpf_prog_info, line_info),
+   offsetof(struct bpf_prog_info, nr_line_info),
+   offsetof(struct bpf_prog_info, line_info_rec_size),
+   },
+   [BPF_PROG_INFO_JITED_LINE_INFO] = {
+   offsetof(struct bpf_prog_info, jited_line_info),
+   offsetof(struct bpf_prog_info, nr_jited_line_info),
+   offsetof(struct bpf_prog_info, jited_line_info_rec_size),
+   },
+   [BPF_PROG_INFO_PROG_TAGS] = {
+   offsetof(struct bpf_prog_info, prog_tags),
+   offsetof(struct bpf_prog_info, nr_prog_tags),
+   -(int)sizeof(__u8) * BPF_TAG_SIZE,
+   },
+
+};
+
+static __u32 bpf_prog_info_read_offset_u32(struct bpf_prog_info *info, int 
offset)
+{
+   __u32 *array = (__u32 *)info;
+
+   if (offset >= 0)
+   return array[offset / sizeof(__u32)];
+   return -(int)offset;
+}
+
+static __u64 bpf_prog_info_read_offset_u64(struct bpf_prog_info *info, int 
offset)
+{
+   __u64 *array = (__u64 *)info;
+
+   if (offset >= 0)
+   return array[offset / sizeof(__u64)];
+   return -(int)offset;
+}
+
+static void bpf_prog_info_set_offset_u32(struct bpf_prog_info *info, int 
offset,
+__u32 val)
+{
+   __u32 *array = (__u32 *)info;
+
+   if (offset >= 0)
+   array[offset / sizeof(__u32)] = val;
+}
+
+static void bpf_prog_info_set_offset_u64(struct bpf_prog_info *info, int 
offset,
+__u64 val)
+{
+   

[PATCH 4/9] perf, bpf: synthesize bpf events with bpf_program__get_prog_info_linear()

2019-02-08 Thread Song Liu
With bpf_program__get_prog_info_linear, we can simplify the logic that
synthesizes bpf events.

This patch doesn't change the behavior of the code.

Signed-off-by: Song Liu 
---
 tools/perf/util/bpf-event.c | 118 
 1 file changed, 40 insertions(+), 78 deletions(-)

diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 796ef793f4ce..e6dfb95029e5 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -3,7 +3,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include "bpf-event.h"
 #include "debug.h"
 #include "symbol.h"
@@ -49,99 +51,62 @@ static int perf_event__synthesize_one_bpf_prog(struct 
perf_tool *tool,
 {
struct ksymbol_event *ksymbol_event = >ksymbol_event;
struct bpf_event *bpf_event = >bpf_event;
-   u32 sub_prog_cnt, i, func_info_rec_size = 0;
-   u8 (*prog_tags)[BPF_TAG_SIZE] = NULL;
-   struct bpf_prog_info info = { .type = 0, };
-   u32 info_len = sizeof(info);
-   void *func_infos = NULL;
-   u64 *prog_addrs = NULL;
+   struct bpf_prog_info_linear *info_linear;
+   struct bpf_prog_info *info;
struct btf *btf = NULL;
-   u32 *prog_lens = NULL;
bool has_btf = false;
-   char errbuf[512];
+   u32 sub_prog_cnt, i;
int err = 0;
+   u64 arrays;
 
-   /* Call bpf_obj_get_info_by_fd() to get sizes of arrays */
-   err = bpf_obj_get_info_by_fd(fd, , _len);
+   arrays = 1UL << BPF_PROG_INFO_JITED_KSYMS;
+   arrays |= 1UL << BPF_PROG_INFO_JITED_FUNC_LENS;
+   arrays |= 1UL << BPF_PROG_INFO_FUNC_INFO;
+   arrays |= 1UL << BPF_PROG_INFO_PROG_TAGS;
 
-   if (err) {
-   pr_debug("%s: failed to get BPF program info: %s, aborting\n",
-__func__, str_error_r(errno, errbuf, sizeof(errbuf)));
+   info_linear = bpf_program__get_prog_info_linear(fd, arrays);
+   if (IS_ERR_OR_NULL(info_linear)) {
+   info_linear = NULL;
+   pr_debug("%s: failed to get BPF program info. aborting\n", 
__func__);
return -1;
}
-   if (info_len < offsetof(struct bpf_prog_info, prog_tags)) {
+
+   if (info_linear->info_len < offsetof(struct bpf_prog_info, prog_tags)) {
pr_debug("%s: the kernel is too old, aborting\n", __func__);
return -2;
}
 
+   info = _linear->info;
+
/* number of ksyms, func_lengths, and tags should match */
-   sub_prog_cnt = info.nr_jited_ksyms;
-   if (sub_prog_cnt != info.nr_prog_tags ||
-   sub_prog_cnt != info.nr_jited_func_lens)
+   sub_prog_cnt = info->nr_jited_ksyms;
+   if (sub_prog_cnt != info->nr_prog_tags ||
+   sub_prog_cnt != info->nr_jited_func_lens)
return -1;
 
/* check BTF func info support */
-   if (info.btf_id && info.nr_func_info && info.func_info_rec_size) {
+   if (info->btf_id && info->nr_func_info && info->func_info_rec_size) {
/* btf func info number should be same as sub_prog_cnt */
-   if (sub_prog_cnt != info.nr_func_info) {
+   if (sub_prog_cnt != info->nr_func_info) {
pr_debug("%s: mismatch in BPF sub program count and BTF 
function info count, aborting\n", __func__);
-   return -1;
-   }
-   if (btf__get_from_id(info.btf_id, )) {
-   pr_debug("%s: failed to get BTF of id %u, aborting\n", 
__func__, info.btf_id);
-   return -1;
+   err = -1;
+   goto out;
}
-   func_info_rec_size = info.func_info_rec_size;
-   func_infos = calloc(sub_prog_cnt, func_info_rec_size);
-   if (!func_infos) {
-   pr_debug("%s: failed to allocate memory for func_infos, 
aborting\n", __func__);
-   return -1;
+   if (btf__get_from_id(info->btf_id, )) {
+   pr_debug("%s: failed to get BTF of id %u, aborting\n", 
__func__, info->btf_id);
+   err = -1;
+   btf = NULL;
+   goto out;
}
has_btf = true;
}
 
-   /*
-* We need address, length, and tag for each sub program.
-* Allocate memory and call bpf_obj_get_info_by_fd() again
-*/
-   prog_addrs = calloc(sub_prog_cnt, sizeof(u64));
-   if (!prog_addrs) {
-   pr_debug("%s: failed to allocate memory for prog_addrs, 
aborting\n", __func__);
-   goto out;
-   }
-   prog_lens = calloc(sub_prog_cnt, sizeof(u32));
-   if (!prog_lens) {
-   pr_debug("%s: failed to allocate memory for prog_lens, 
aborting\n", __func__);
-   goto out;
-   }
-   prog_tags = calloc(sub_prog_cnt, BPF_TAG_SIZE);
-   if (!prog_tags) {
-   

Re: [PATCH v1 1/2] PCI: ATS: Add function to check ATS page aligned request status.

2019-02-08 Thread sathyanarayanan kuppuswamy



On 2/7/19 5:58 PM, Sinan Kaya wrote:


On 2/7/2019 5:16 PM, sathyanarayanan kuppuswamy wrote:

If I remember this right, aligned request is only supported on ATS v1.1
but not supported on v1.0.

Its added in v1.1.


This means that you should probably have some kind of version check
here.


There is no version field in ATS v1.0 spec. Also, If I follow the 
history log in PCI spec, I think ATS if first added at v1.2. Please 
correct me if I am wrong.


--
Sathyanarayanan Kuppuswamy
Linux kernel developer



Re: [PATCH] ASoC: codecs: jz4725b: Remove unnecessary const qualifier

2019-02-08 Thread Nick Desaulniers
On Thu, Feb 7, 2019 at 9:00 PM Nathan Chancellor
 wrote:
>
> Clang warns:
>
> sound/soc/codecs/jz4725b.c:177:14: warning: duplicate 'const' declaration 
> specifier [-Wduplicate-decl-specifier]
> static const SOC_VALUE_ENUM_SINGLE_DECL(jz4725b_codec_adc_src_enum,
>  ^
> include/sound/soc.h:356:2: note: expanded from macro 
> 'SOC_VALUE_ENUM_SINGLE_DECL'
> SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, 
> xvalues)
> ^
> include/sound/soc.h:353:2: note: expanded from macro 
> 'SOC_VALUE_ENUM_DOUBLE_DECL'
> const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, 
> xshift_r, xmask, \
> ^
>
> As it points out, SOC_VALUE_ENUM_DOUBLE_DECL has the const attribute in
> its definition so remove it here.
>
> Fixes: e9d97b05a80f ("ASoC: codecs: Add jz4725b-codec driver")
> Link: https://github.com/ClangBuiltLinux/linux/issues/354
> Signed-off-by: Nathan Chancellor 

Thanks for the fix.  Looks like the struct instance declaration
already contains a const.  That's a curious (not bad, per se) pattern
that probably results in a few other instances of this warning, I'll
bet.
Reviewed-by: Nick Desaulniers 

> ---
>  sound/soc/codecs/jz4725b.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/codecs/jz4725b.c b/sound/soc/codecs/jz4725b.c
> index e3dba92f30bd..5cc8c7ca24c6 100644
> --- a/sound/soc/codecs/jz4725b.c
> +++ b/sound/soc/codecs/jz4725b.c
> @@ -174,12 +174,12 @@ static const char * const jz4725b_codec_adc_src_texts[] 
> = {
> "Mic 1", "Mic 2", "Line In", "Mixer",
>  };
>  static const unsigned int jz4725b_codec_adc_src_values[] = { 0, 1, 2, 3, };
> -static const SOC_VALUE_ENUM_SINGLE_DECL(jz4725b_codec_adc_src_enum,
> -   JZ4725B_CODEC_REG_CR3,
> -   REG_CR3_INSEL_OFFSET,
> -   REG_CR3_INSEL_MASK,
> -   jz4725b_codec_adc_src_texts,
> -   jz4725b_codec_adc_src_values);
> +static SOC_VALUE_ENUM_SINGLE_DECL(jz4725b_codec_adc_src_enum,
> + JZ4725B_CODEC_REG_CR3,
> + REG_CR3_INSEL_OFFSET,
> + REG_CR3_INSEL_MASK,
> + jz4725b_codec_adc_src_texts,
> + jz4725b_codec_adc_src_values);
>  static const struct snd_kcontrol_new jz4725b_codec_adc_src_ctrl =
> SOC_DAPM_ENUM("Route", jz4725b_codec_adc_src_enum);
>
> --
> 2.20.1
>


-- 
Thanks,
~Nick Desaulniers


Re: [RFC v3 14/19] Documentation: kunit: add documentation for KUnit

2019-02-08 Thread Brendan Higgins
On Thu, Dec 6, 2018 at 4:16 AM Kieran Bingham
 wrote:
>
> Hi Brendan,
>
> On 03/12/2018 23:53, Brendan Higgins wrote:
> > On Thu, Nov 29, 2018 at 7:45 PM Luis Chamberlain  wrote:
> >>
> >> On Thu, Nov 29, 2018 at 01:56:37PM +, Kieran Bingham wrote:
> >>> Hi Brendan,
> >>>
> >>> Please excuse the top posting, but I'm replying here as I'm following
> >>> the section "Creating a kunitconfig" in Documentation/kunit/start.rst.
> >>>
> >>> Could the three line kunitconfig file live under say
> >>>arch/um/configs/kunit_defconfig?
>
>
> Further consideration to this topic - I mentioned putting it in
>   arch/um/configs
>
> - but I think this is wrong.
>
> We now have a location for config-fragments, which is essentially what
> this is, under kernel/configs
>
> So perhaps an addition as :
>
>  kernel/configs/kunit.config
>
> Would be more appropriate - and less (UM) architecture specific.

Sorry for the long radio silence.

I just got around to doing this and I found that there are some
configs that are desirable to have when running KUnit under x86 in a
VM, but not UML. So should we have one that goes in with
config-fragments and others that go into architectures? Another idea,
it would be nice to have a KUnit config that runs all known tests
(this probably won't work in practice once we start testing mutually
exclusive things or things with lots of ifdeffery, but it probably
something we should try to maintain as best as we can?); this probably
shouldn't go in with the fragments, right?

I will be sending another revision out soon, but I figured I might be
able to catch you before I did so.


[RFC 2/3] arm_pmu: acpi: spe: Add initial MADT/SPE probing

2019-02-08 Thread Jeremy Linton
ACPI 6.3 adds additional fields to the MADT GICC
structure to describe SPE PPI's. We pick these out
of the cached reference to the madt_gicc structure
similarly to the core PMU code. We then create a platform
device referring to the IRQ and let the user/module loader
decide whether to load the SPE driver.

Signed-off-by: Jeremy Linton 
---
 arch/arm64/include/asm/acpi.h |  3 ++
 drivers/perf/arm_pmu_acpi.c   | 67 +++
 2 files changed, 70 insertions(+)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 2def77ec14be..f9f9f2eb5d54 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -40,6 +40,9 @@
(!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \
(unsigned long)(entry) + (entry)->header.length > (end))
 
+#define ACPI_MADT_GICC_SPE  (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \
+   spe_overflow_interrupt) + sizeof(u16))
+
 /* Basic configuration for ACPI */
 #ifdef CONFIG_ACPI
 pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
index 0f197516d708..725d413b47dc 100644
--- a/drivers/perf/arm_pmu_acpi.c
+++ b/drivers/perf/arm_pmu_acpi.c
@@ -74,6 +74,71 @@ static void arm_pmu_acpi_unregister_irq(int cpu)
acpi_unregister_gsi(gsi);
 }
 
+static struct resource spe_resources[] = {
+   {
+   /* irq */
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
+static struct platform_device spe_dev = {
+   .name = "arm,spe-v1",
+   .id = -1,
+   .resource = spe_resources,
+   .num_resources = ARRAY_SIZE(spe_resources)
+};
+
+/*
+ * For lack of a better place, hook the normal PMU MADT walk
+ * and create a SPE device if we detect a recent MADT with
+ * a homogeneous PPI mapping.
+ */
+static int arm_spe_acpi_parse_irqs(void)
+{
+   int cpu, ret, irq;
+   u16 gsi = 0;
+   bool first = true;
+
+   struct acpi_madt_generic_interrupt *gicc;
+
+   /*
+* sanity check all the GICC tables for the same interrupt number
+* for now we only support homogeneous ACPI/SPE machines.
+*/
+   for_each_possible_cpu(cpu) {
+   gicc = acpi_cpu_get_madt_gicc(cpu);
+
+   if (gicc->header.length < ACPI_MADT_GICC_SPE)
+   return -ENODEV;
+
+   if (first) {
+   gsi = gicc->spe_overflow_interrupt;
+   if (!gsi)
+   return -ENODEV;
+   first = false;
+   } else if (gsi != gicc->spe_overflow_interrupt) {
+   pr_warn("ACPI: SPE must have homogeneous interrupts\n");
+   return -EINVAL;
+   }
+   }
+
+   irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE,
+   ACPI_ACTIVE_HIGH);
+   if (irq < 0) {
+   pr_warn("ACPI: SPE Unable to register interrupt: %d\n", gsi);
+   return irq;
+   }
+
+   spe_resources[0].start = irq;
+   ret = platform_device_register(_dev);
+   if (ret < 0) {
+   pr_warn("ACPI: SPE: Unable to register device\n");
+   acpi_unregister_gsi(gsi);
+   }
+
+   return ret;
+}
+
 static int arm_pmu_acpi_parse_irqs(void)
 {
int irq, cpu, irq_cpu, err;
@@ -279,6 +344,8 @@ static int arm_pmu_acpi_init(void)
if (acpi_disabled)
return 0;
 
+   arm_spe_acpi_parse_irqs(); /* failures are expected */
+
ret = arm_pmu_acpi_parse_irqs();
if (ret)
return ret;
-- 
2.17.2



[RFC 1/3] ACPICA: ACPI 6.3: Add MADT/GICC/SPE extension.

2019-02-08 Thread Jeremy Linton
[Placeholder patch for upstream ACPICA commit]

Add just ACPI 6.3 changes associated with the arm64 SPE.

Signed-off-by: Jeremy Linton 
---
 include/acpi/actbl2.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index c50ef7e6b942..4b58eb6cf64e 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -623,7 +623,7 @@ struct acpi_madt_local_x2apic_nmi {
u8 reserved[3]; /* reserved - must be zero */
 };
 
-/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
+/* 11: Generic Interrupt (ACPI 5.0 + 6.0 + 6.3 changes) */
 
 struct acpi_madt_generic_interrupt {
struct acpi_subtable_header header;
@@ -641,7 +641,8 @@ struct acpi_madt_generic_interrupt {
u64 gicr_base_address;
u64 arm_mpidr;
u8 efficiency_class;
-   u8 reserved2[3];
+   u8 reserved2;
+   u16 spe_overflow_interrupt;
 };
 
 /* Masks for Flags field above */
-- 
2.17.2



[RFC 0/3] arm64: SPE ACPI enablement

2019-02-08 Thread Jeremy Linton
This patch series enables the Arm Statistical
Profiling Extension (SPE) on ACPI platforms.

This is possible because ACPI 6.3 uses a previously
reserved field in the MADT to store the SPE interrupt
number, similarly to how the normal PMU is
described. If a consistent valid interrupt exists
across all the cores in the system, a platform
device is registered. That then triggers the SPE module,
which runs as normal.

Jeremy Linton (3):
  ACPICA: ACPI 6.3: Add MADT/GICC/SPE extension.
  arm_pmu: acpi: spe: Add initial MADT/SPE probing
  perf: arm_spe: Enable ACPI/Platform automatic module loading

 arch/arm64/include/asm/acpi.h |  4 +++
 drivers/perf/arm_pmu_acpi.c   | 67 +++
 drivers/perf/arm_spe_pmu.c| 11 --
 include/acpi/actbl2.h |  5 +--
 4 files changed, 83 insertions(+), 4 deletions(-)

-- 
2.17.2



[RFC 3/3] perf: arm_spe: Enable ACPI/Platform automatic module loading

2019-02-08 Thread Jeremy Linton
Lets add the MODULE_TABLE and platform id_table entries so that
the SPE driver can attach to the ACPI platform device created by
the core pmu code.

Signed-off-by: Jeremy Linton 
---
 drivers/perf/arm_spe_pmu.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index 8e46a9dad2fa..9be11d814fa5 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -1176,7 +1176,13 @@ static const struct of_device_id arm_spe_pmu_of_match[] 
= {
 };
 MODULE_DEVICE_TABLE(of, arm_spe_pmu_of_match);
 
-static int arm_spe_pmu_device_dt_probe(struct platform_device *pdev)
+static const struct platform_device_id arm_spe_match[] = {
+   { "arm,spe-v1", 0},
+   { }
+};
+MODULE_DEVICE_TABLE(platform, arm_spe_match);
+
+static int arm_spe_pmu_device_probe(struct platform_device *pdev)
 {
int ret;
struct arm_spe_pmu *spe_pmu;
@@ -1236,11 +1242,12 @@ static int arm_spe_pmu_device_remove(struct 
platform_device *pdev)
 }
 
 static struct platform_driver arm_spe_pmu_driver = {
+   .id_table = arm_spe_match,
.driver = {
.name   = DRVNAME,
.of_match_table = of_match_ptr(arm_spe_pmu_of_match),
},
-   .probe  = arm_spe_pmu_device_dt_probe,
+   .probe  = arm_spe_pmu_device_probe,
.remove = arm_spe_pmu_device_remove,
 };
 
-- 
2.17.2



Re: [PATCH 2/3] Compiler Attributes: add support for __copy (gcc >= 9)

2019-02-08 Thread Nick Desaulniers
On Fri, Feb 8, 2019 at 4:09 PM Miguel Ojeda
 wrote:
>
> From the GCC manual:
>
>   copy
>   copy(function)
>
> The copy attribute applies the set of attributes with which function
> has been declared to the declaration of the function to which
> the attribute is applied. The attribute is designed for libraries
> that define aliases or function resolvers that are expected
> to specify the same set of attributes as their targets. The copy
> attribute can be used with functions, variables, or types. However,
> the kind of symbol to which the attribute is applied (either
> function or variable) must match the kind of symbol to which
> the argument refers. The copy attribute copies only syntactic and
> semantic attributes but not attributes that affect a symbol’s
> linkage or visibility such as alias, visibility, or weak.
> The deprecated attribute is also not copied.
>
>   https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
>
> The upcoming GCC 9 release extends the -Wmissing-attributes warnings
> (enabled by -Wall) to C and aliases: it warns when particular function
> attributes are missing in the aliases but not in their target, e.g.:
>
> void __cold f(void) {}
> void __alias("f") g(void);
>
> diagnoses:
>
> warning: 'g' specifies less restrictive attribute than
> its target 'f': 'cold' [-Wmissing-attributes]
>
> Using __copy(f) we can copy the __cold attribute from f to g:
>
> void __cold f(void) {}
> void __copy(f) __alias("f") g(void);
>
> This attribute is most useful to deal with situations where an alias
> is declared but we don't know the exact attributes the target has.
>
> For instance, in the kernel, the widely used module_init/exit macros
> define the init/cleanup_module aliases, but those cannot be marked
> always as __init/__exit since they some modules do not have their
> functions marked as such.

Drop "they" from this sentence if there's a respin, otherwise looks helpful.
Reviewed-by: Nick Desaulniers 

>
> Suggested-by: Martin Sebor 
> Signed-off-by: Miguel Ojeda 
> ---
>  include/linux/compiler_attributes.h | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/include/linux/compiler_attributes.h 
> b/include/linux/compiler_attributes.h
> index 19f32b0c29af..6b318efd8a74 100644
> --- a/include/linux/compiler_attributes.h
> +++ b/include/linux/compiler_attributes.h
> @@ -34,6 +34,7 @@
>  #ifndef __has_attribute
>  # define __has_attribute(x) __GCC4_has_attribute_##x
>  # define __GCC4_has_attribute___assume_aligned__  (__GNUC_MINOR__ >= 9)
> +# define __GCC4_has_attribute___copy__0
>  # define __GCC4_has_attribute___designated_init__ 0
>  # define __GCC4_has_attribute___externally_visible__  1
>  # define __GCC4_has_attribute___noclone__ 1
> @@ -100,6 +101,19 @@
>   */
>  #define __attribute_const__ __attribute__((__const__))
>
> +/*
> + * Optional: only supported since gcc >= 9
> + * Optional: not supported by clang
> + * Optional: not supported by icc
> + *
> + *   gcc: 
> https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-copy-function-attribute
> + */
> +#if __has_attribute(__copy__)
> +# define __copy(symbol) __attribute__((__copy__(symbol)))
> +#else
> +# define __copy(symbol)
> +#endif
> +
>  /*
>   * Don't. Just don't. See commit 771c035372a0 ("deprecate the '__deprecated'
>   * attribute warnings entirely and for good") for more information.
> --
> 2.17.1
>


-- 
Thanks,
~Nick Desaulniers


Re: [GIT PULL] PCI fixes for v5.0

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Fri, 8 Feb 2019 08:23:53 -0600:

> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git 
> tags/pci-v5.0-fixes-4

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/70be9ac2b64c0d0db4f0e3004b764df33b1098e2

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [RFC v3 11/19] kunit: add Python libraries for handing KUnit config and kernel

2019-02-08 Thread Brendan Higgins
On Tue, Dec 11, 2018 at 9:02 AM Anton Ivanov
 wrote:
>
>
> On 12/11/18 2:41 PM, Steven Rostedt wrote:
> > On Tue, 11 Dec 2018 15:09:26 +0100
> > Petr Mladek  wrote:
> >
> >>> We have liburcu already, which is good.  The main sticking points are:
> >>>
> >>>   - printk has started adding a lot of %pX enhancements which printf
> >>> obviously doesn't know about.
> >> I wonder how big problem it is and if it is worth using another
> >> approach.
> > No, please do not change the %pX approach.
> >
> >> An alternative would be to replace them with helper functions
> >> the would produce the same string. The meaning would be easier
> >> to understand. But concatenating with the surrounding text
> >> would be less elegant. People might start using pr_cont()
> >> that is problematic (mixed lines).
> >>
> >> Also the %pX formats are mostly used to print context of some
> >> structures. Even the helper functions would need some maintenance
> >> to keep them compatible.
> >>
> >> BTW: The printk() feature has been introduced 10 years ago by
> >> the commit 4d8a743cdd2690c0bc8 ("vsprintf: add infrastructure
> >> support for extended '%p' specifiers").
> > trace-cmd and perf know about most of the %pX data and how to read it.
> > Perhaps we can extend the libtraceevent library to export a generic way
> > to read data from printk() output for other tools to use.
>
> Going back for a second to using UML for this. UML console at present is
> interrupt driven - it emulates serial IO using several different
> back-ends (file descriptors, xterm or actual tty/ptys). Epoll events on
> the host side are used to trigger the UML interrupts - both read and write.
>
> This works OK for normal use, but may result in all kinds of interesting
> false positives/false negatives when UML is used to run unit tests
> against a change which changes interrupt behavior.
>
> IMO it may be useful to consider some alternatives specifically for unit
> test coverage purposes where printk and/or the whole console output
> altogether bypass some of the IRQ driven semantics.

Whoops, sorry, didn't see your comment before I went on vacation.

I completely agree. It is also annoying when trying to test other
really low level parts of the kernel. I would really like to get KUnit
to the point where it does not have any dependencies on anything in
the kernel, but that is very challenging for many reasons. This
loosely relates to what Luis, myself, and others have talked about in
other threads about having a stricter notion of code dependencies in
the kernel. Thinking about it now, I suspect it might be easier to
limit KUnit's dependency on kernel infrastructure first; that could
kind of motivate the later work.


Re: [GIT PULL] arm64: fixes for -rc6

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Fri, 8 Feb 2019 17:35:15 +:

> git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git tags/arm64-fixes

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5bb513ed838c9eaae1704a3389eabc04e4cc0da5

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] signal fixes for v5.0-rc6

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Fri, 08 Feb 2019 09:52:02 -0600:

> git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
> for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/6b2912cedc238c984e6a4039836ed9c911121076

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH v7 4/4] platform/chrome: rtc: Add RTC driver

2019-02-08 Thread Nick Crews
Sorry all, there is one more error in here I just found, I just sent
out v8 that corrects it.
Sorry Enric if you already started trying to merge this version.

On Fri, Feb 8, 2019 at 12:38 PM Nick Crews  wrote:
>
> This Embedded Controller has an internal RTC that is exposed
> as a standard RTC class driver with read/write functionality.
>
> The driver is added to the drivers/rtc/ so that the maintainer of that
> directory will be able to comment on this change, as that maintainer is
> the expert on this system. In addition, the driver code is called
> indirectly after a corresponding device is registered from core.c,
> as opposed to core.c registering the driver callbacks directly.
>
> To test:
> > hwclock --show --rtc /dev/rtc1
> 2007-12-31 16:01:20.460959-08:00
> > hwclock --systohc --rtc /dev/rtc1
> > hwclock --show --rtc /dev/rtc1
> 2018-11-29 17:08:00.780793-08:00
>
> > hwclock --show --rtc /dev/rtc1
> 2007-12-31 16:01:20.460959-08:00
> > hwclock --systohc --rtc /dev/rtc1
> > hwclock --show --rtc /dev/rtc1
> 2018-11-29 17:08:00.780793-08:00
>
> Signed-off-by: Duncan Laurie 
> Acked-by: Enric Balletbo i Serra 
> Acked-by: Alexandre Belloni 
> Signed-off-by: Nick Crews 
> ---
>
> Changes in v7: None
> Changes in v6:
> - In the core, actually unregister the RTC child platform_device.
>
> Changes in v5: None
> Changes in v4:
> - Change me email to @chromium.org from @google.com
> - Move "Add RTC driver" before "Add sysfs attributes" so that
>   it could get accepted earlier, since it is less contentious
>
> Changes in v3:
> - rm #define for driver name
> - Don't compute weekday when reading from RTC.
>   Still set weekday when writing, as RTC needs this
>   to control advanced power scheduling
> - rm check for invalid month data
> - Set range_min and range_max on rtc_device
>
> Changes in v2:
> - rm license boiler plate
> - rm "wilco_ec_rtc -" prefix in docstring
> - Make rtc driver its own module within the drivers/rtc/ directory
> - Register a rtc device from core.c that is picked up by this driver
>
>  drivers/platform/chrome/wilco_ec/core.c |  22 ++-
>  drivers/rtc/Kconfig |  11 ++
>  drivers/rtc/Makefile|   1 +
>  drivers/rtc/rtc-wilco-ec.c  | 177 
>  include/linux/platform_data/wilco-ec.h  |   2 +
>  5 files changed, 211 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/rtc/rtc-wilco-ec.c
>
> diff --git a/drivers/platform/chrome/wilco_ec/core.c 
> b/drivers/platform/chrome/wilco_ec/core.c
> index ae86cae216fd..e67385ec5103 100644
> --- a/drivers/platform/chrome/wilco_ec/core.c
> +++ b/drivers/platform/chrome/wilco_ec/core.c
> @@ -42,6 +42,7 @@ static int wilco_ec_probe(struct platform_device *pdev)
>  {
> struct device *dev = >dev;
> struct wilco_ec_device *ec;
> +   int ret;
>
> ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
> if (!ec)
> @@ -70,21 +71,38 @@ static int wilco_ec_probe(struct platform_device *pdev)
>  ec->io_packet->start + EC_MAILBOX_DATA_SIZE);
>
> /*
> -* Register a debugfs platform device that will get picked up by the
> -* debugfs driver. Ignore failure.
> +* Register a child device that will be found by the RTC driver.
> +* Ignore failure.

I did some sloppy duplication here. I modified this and the
previous commit to fix this.

>  */
> ec->debugfs_pdev = platform_device_register_data(dev,
>  "wilco-ec-debugfs",
>  PLATFORM_DEVID_AUTO,
>  NULL, 0);
>
> +   /* Register a child device that will be found by the RTC driver. */
> +   ec->rtc_pdev = platform_device_register_data(dev, "rtc-wilco-ec",
> +PLATFORM_DEVID_AUTO,
> +NULL, 0);
> +   if (IS_ERR(ec->rtc_pdev)) {
> +   dev_err(dev, "Failed to create RTC platform device\n");
> +   ret = PTR_ERR(ec->rtc_pdev);
> +   goto unregister_debugfs;
> +   }
> +
> return 0;
> +
> +unregister_debugfs:
> +   if (ec->debugfs_pdev)
> +   platform_device_unregister(ec->debugfs_pdev);
> +   cros_ec_lpc_mec_destroy();
> +   return ret;
>  }
>
>  static int wilco_ec_remove(struct platform_device *pdev)
>  {
> struct wilco_ec_device *ec = platform_get_drvdata(pdev);
>
> +   platform_device_unregister(ec->rtc_pdev);
> if (ec->debugfs_pdev)
> platform_device_unregister(ec->debugfs_pdev);
>
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 225b0b8516f3..d5063c791515 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -1814,4 +1814,15 @@ config RTC_DRV_GOLDFISH
>   Goldfish is a code name for the virtual platform developed 

Re: [git pull] IOMMU Fixes for Linux v5.0-rc5

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Fri, 8 Feb 2019 17:49:43 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git 
> tags/iommu-fixes-v5.0-rc5

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2e277fa0893936bb4ab8432828f5d422a9ed0a7f

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.0-4 tag

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Sat, 09 Feb 2019 00:12:56 +1100:

> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
> tags/powerpc-5.0-4

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/820828bffeb11eee41e197a0c9be1b72afa37482

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] ARM: SoC fixes for linux-5.0

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Sat, 9 Feb 2019 00:27:26 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git armsoc-fixes-5.0

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/46c291e277f93737877305f5626a2c5c35522cb1

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] ACPI fix for v5.0-rc6

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Fri, 8 Feb 2019 12:22:20 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-5.0-rc6

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e2dac603d4bcb98c65d6f97848b72a217d0dd854

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] SCSI fixes for 5.0-rc5

2019-02-08 Thread pr-tracker-bot
The pull request you sent on Fri, 08 Feb 2019 14:17:59 -0500:

> git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/3b6e8204a997510718949fd177f01da1860c738a

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


[PATCH v8 2/4] platform/chrome: Add new driver for Wilco EC

2019-02-08 Thread Nick Crews
This EC is an incompatible variant of the typical Chrome OS embedded
controller.  It uses the same low-level communication and a similar
protocol with some significant differences.  The EC firmware does
not support the same mailbox commands so it is not registered as a
cros_ec device type.  This commit exports the wilco_ec_mailbox()
function so that other modules can use it to communicate with the EC.

Signed-off-by: Duncan Laurie 
Signed-off-by: Nick Crews 
---

Changes in v8: None
Changes in v7: None
Changes in v6:
- Re-added WILCO_EC_FLAG_EXTENDED_DATA and went back to always
  reading either EC_MAILBOX_DATA_SIZE or EC_MAILBOX_DATA_SIZE_EXTENDED
  bytes, since it turns out the EC always expects you to calculate the
  checksum over all of them.
- Split WILCO_EC_MSG_TELEMETRY into WILCO_EC_MSG_TELEMETRY_SHORT and
  WILCO_EC_MSG_TELEMETRY_LONG, since there will be two different
  commands.
- A couple comment and err message polishes

Changes in v5:
- move checking of NO_RESPONSE flag before timeout check,
  so now timeout doesn't always happen when EC isn't supposed
  to respond.
- rm WILCO_EC_FLAG_EXTENDED_DATA, that is already obvious from
  wilco_ec_message.response_size

Changes in v4:
- add #define DRV_NAME
- remove redundant Kconfig nesting
- changed my email to @chromium.org
- Add better explanation of what core.c does

Changes in v3:
- remove unused ret in probe()
- Add newline spacer in probe()
- rm unnecessary res in get_resource()
- s/8bit/8-bit
- rm first sleep when sending command to EC

Changes in v2:
- Remove COMPILE_TEST from Kconfig because inb()/outb()
won't work on anything but X86
- Add myself as module author
- Tweak mailbox()

 drivers/platform/chrome/Kconfig|   4 +-
 drivers/platform/chrome/Makefile   |   2 +
 drivers/platform/chrome/wilco_ec/Kconfig   |  11 +
 drivers/platform/chrome/wilco_ec/Makefile  |   4 +
 drivers/platform/chrome/wilco_ec/core.c| 104 +
 drivers/platform/chrome/wilco_ec/mailbox.c | 236 +
 include/linux/platform_data/wilco-ec.h | 140 
 7 files changed, 500 insertions(+), 1 deletion(-)
 create mode 100644 drivers/platform/chrome/wilco_ec/Kconfig
 create mode 100644 drivers/platform/chrome/wilco_ec/Makefile
 create mode 100644 drivers/platform/chrome/wilco_ec/core.c
 create mode 100644 drivers/platform/chrome/wilco_ec/mailbox.c
 create mode 100644 include/linux/platform_data/wilco-ec.h

diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index 16b1615958aa..bf889adfd4ef 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -49,6 +49,8 @@ config CHROMEOS_TBMC
  To compile this driver as a module, choose M here: the
  module will be called chromeos_tbmc.
 
+source "drivers/platform/chrome/wilco_ec/Kconfig"
+
 config CROS_EC_CTL
 tristate
 
@@ -86,7 +88,7 @@ config CROS_EC_LPC
 
 config CROS_EC_LPC_MEC
bool "ChromeOS Embedded Controller LPC Microchip EC (MEC) variant"
-   depends on CROS_EC_LPC
+   depends on CROS_EC_LPC || WILCO_EC
default n
help
  If you say Y here, a variant LPC protocol for the Microchip EC
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index cd591bf872bb..7242ee2b13c5 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -13,3 +13,5 @@ cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC)+= 
cros_ec_lpc_mec.o
 obj-$(CONFIG_CROS_EC_LPC)  += cros_ec_lpcs.o
 obj-$(CONFIG_CROS_EC_PROTO)+= cros_ec_proto.o
 obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT)   += cros_kbd_led_backlight.o
+
+obj-$(CONFIG_WILCO_EC) += wilco_ec/
diff --git a/drivers/platform/chrome/wilco_ec/Kconfig 
b/drivers/platform/chrome/wilco_ec/Kconfig
new file mode 100644
index ..20945a301ec6
--- /dev/null
+++ b/drivers/platform/chrome/wilco_ec/Kconfig
@@ -0,0 +1,11 @@
+config WILCO_EC
+   tristate "ChromeOS Wilco Embedded Controller"
+   depends on ACPI && X86
+   select CROS_EC_LPC_MEC
+   help
+ If you say Y here, you get support for talking to the ChromeOS
+ Wilco EC over an eSPI bus. This uses a simple byte-level protocol
+ with a checksum.
+
+ To compile this driver as a module, choose M here: the
+ module will be called wilco_ec.
diff --git a/drivers/platform/chrome/wilco_ec/Makefile 
b/drivers/platform/chrome/wilco_ec/Makefile
new file mode 100644
index ..03b32301dc61
--- /dev/null
+++ b/drivers/platform/chrome/wilco_ec/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+wilco_ec-objs  := core.o mailbox.o
+obj-$(CONFIG_WILCO_EC) += wilco_ec.o
diff --git a/drivers/platform/chrome/wilco_ec/core.c 
b/drivers/platform/chrome/wilco_ec/core.c
new file mode 100644
index ..20ecc580d108
--- /dev/null
+++ b/drivers/platform/chrome/wilco_ec/core.c
@@ -0,0 +1,104 @@
+// 

[PATCH v8 1/4] cros_ec: Remove cros_ec dependency in lpc_mec

2019-02-08 Thread Nick Crews
In order to allow this code to be re-used, remove the dependency
on the rest of the cros_ec code from the cros_ec_lpc_mec functions.

Instead of using a hardcoded register base address of 0x800 have
this be passed in to cros_ec_lpc_mec_init().  The existing cros_ec
use case now passes in the 0x800 base address this way.

There are some error checks that happen in cros_ec_lpc_mec_in_range()
that probably shouldn't be there, as they are checking kernel-space
callers and not user-space input. However, we'll just do the refactor in
this patch, and in a future patch might remove this error checking and
fix all the instances of code that calls this.

There's a similar problem in cros_ec_lpc_read_bytes(), where we return a
checksum, but on error just return 0. This should probably be changed so
that it returns int, but we don't want to have to mess with all the
calling code for this fix. Maybe we'll come back through later and fix
this.

Signed-off-by: Duncan Laurie 
Acked-for-chrome-platform-by: Enric Balletbo i Serra 

Signed-off-by: Nick Crews 
---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Change <= to >= in mec_in_range()
- Add " - EC_HOST_CMD_REGION0" to offset arg for io_bytes_mec()

Changes in v2:
- Fixed kernel-doc comments
- Fixed include of linux/mfd/cros_ec_lpc_mec.h
- cros_ec_lpc_mec_in_range() returns -EINVAL on error
- Added parens around macro variables

 drivers/platform/chrome/cros_ec_lpc_mec.c | 52 +++
 drivers/platform/chrome/cros_ec_lpc_mec.h | 43 ++-
 drivers/platform/chrome/cros_ec_lpc_reg.c | 47 +++-
 3 files changed, 83 insertions(+), 59 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc_mec.c 
b/drivers/platform/chrome/cros_ec_lpc_mec.c
index c4edfa83e493..782e238a8d4e 100644
--- a/drivers/platform/chrome/cros_ec_lpc_mec.c
+++ b/drivers/platform/chrome/cros_ec_lpc_mec.c
@@ -23,7 +23,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -34,6 +33,7 @@
  * EC mutex because memmap data may be accessed without it being held.
  */
 static struct mutex io_mutex;
+static u16 mec_emi_base, mec_emi_end;
 
 /*
  * cros_ec_lpc_mec_emi_write_address
@@ -46,10 +46,37 @@ static struct mutex io_mutex;
 static void cros_ec_lpc_mec_emi_write_address(u16 addr,
enum cros_ec_lpc_mec_emi_access_mode access_type)
 {
-   /* Address relative to start of EMI range */
-   addr -= MEC_EMI_RANGE_START;
-   outb((addr & 0xfc) | access_type, MEC_EMI_EC_ADDRESS_B0);
-   outb((addr >> 8) & 0x7f, MEC_EMI_EC_ADDRESS_B1);
+   outb((addr & 0xfc) | access_type, MEC_EMI_EC_ADDRESS_B0(mec_emi_base));
+   outb((addr >> 8) & 0x7f, MEC_EMI_EC_ADDRESS_B1(mec_emi_base));
+}
+
+/**
+ * cros_ec_lpc_mec_in_range() - Determine if addresses are in MEC EMI range.
+ *
+ * @offset: Address offset
+ * @length: Number of bytes to check
+ *
+ * Return: 1 if in range, 0 if not, and -EINVAL on failure
+ * such as the mec range not being initialized
+ */
+int cros_ec_lpc_mec_in_range(unsigned int offset, unsigned int length)
+{
+   if (length == 0)
+   return -EINVAL;
+
+   if (WARN_ON(mec_emi_base == 0 || mec_emi_end == 0))
+   return -EINVAL;
+
+   if (offset >= mec_emi_base && offset < mec_emi_end) {
+   if (WARN_ON(offset + length - 1 >= mec_emi_end))
+   return -EINVAL;
+   return 1;
+   }
+
+   if (WARN_ON(offset + length > mec_emi_base && offset < mec_emi_end))
+   return -EINVAL;
+
+   return 0;
 }
 
 /*
@@ -71,6 +98,11 @@ u8 cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type 
io_type,
u8 sum = 0;
enum cros_ec_lpc_mec_emi_access_mode access, new_access;
 
+   /* Return checksum of 0 if window is not initialized */
+   WARN_ON(mec_emi_base == 0 || mec_emi_end == 0);
+   if (mec_emi_base == 0 || mec_emi_end == 0)
+   return 0;
+
/*
 * Long access cannot be used on misaligned data since reading B0 loads
 * the data register and writing B3 flushes.
@@ -86,9 +118,9 @@ u8 cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type 
io_type,
cros_ec_lpc_mec_emi_write_address(offset, access);
 
/* Skip bytes in case of misaligned offset */
-   io_addr = MEC_EMI_EC_DATA_B0 + (offset & 0x3);
+   io_addr = MEC_EMI_EC_DATA_B0(mec_emi_base) + (offset & 0x3);
while (i < length) {
-   while (io_addr <= MEC_EMI_EC_DATA_B3) {
+   while (io_addr <= MEC_EMI_EC_DATA_B3(mec_emi_base)) {
if (io_type == MEC_IO_READ)
buf[i] = inb(io_addr++);
else
@@ -118,7 +150,7 @@ u8 cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type 
io_type,
}
 
/* Access [B0, B3] on each loop pass */
-   io_addr = MEC_EMI_EC_DATA_B0;
+

[PATCH v8 4/4] platform/chrome: rtc: Add RTC driver

2019-02-08 Thread Nick Crews
This Embedded Controller has an internal RTC that is exposed
as a standard RTC class driver with read/write functionality.

The driver is added to the drivers/rtc/ so that the maintainer of that
directory will be able to comment on this change, as that maintainer is
the expert on this system. In addition, the driver code is called
indirectly after a corresponding device is registered from core.c,
as opposed to core.c registering the driver callbacks directly.

To test:
> hwclock --show --rtc /dev/rtc1
2007-12-31 16:01:20.460959-08:00
> hwclock --systohc --rtc /dev/rtc1
> hwclock --show --rtc /dev/rtc1
2018-11-29 17:08:00.780793-08:00

> hwclock --show --rtc /dev/rtc1
2007-12-31 16:01:20.460959-08:00
> hwclock --systohc --rtc /dev/rtc1
> hwclock --show --rtc /dev/rtc1
2018-11-29 17:08:00.780793-08:00

Signed-off-by: Duncan Laurie 
Acked-by: Enric Balletbo i Serra 
Acked-by: Alexandre Belloni 
Signed-off-by: Nick Crews 
---

Changes in v8: None
Changes in v7: None
Changes in v6:
- In the core, actually unregister the RTC child platform_device.

Changes in v5: None
Changes in v4:
- Change me email to @chromium.org from @google.com
- Move "Add RTC driver" before "Add sysfs attributes" so that
  it could get accepted earlier, since it is less contentious

Changes in v3:
- rm #define for driver name
- Don't compute weekday when reading from RTC.
  Still set weekday when writing, as RTC needs this
  to control advanced power scheduling
- rm check for invalid month data
- Set range_min and range_max on rtc_device

Changes in v2:
- rm license boiler plate
- rm "wilco_ec_rtc -" prefix in docstring
- Make rtc driver its own module within the drivers/rtc/ directory
- Register a rtc device from core.c that is picked up by this driver

 drivers/platform/chrome/wilco_ec/core.c |  18 +++
 drivers/rtc/Kconfig |  11 ++
 drivers/rtc/Makefile|   1 +
 drivers/rtc/rtc-wilco-ec.c  | 177 
 include/linux/platform_data/wilco-ec.h  |   2 +
 5 files changed, 209 insertions(+)
 create mode 100644 drivers/rtc/rtc-wilco-ec.c

diff --git a/drivers/platform/chrome/wilco_ec/core.c 
b/drivers/platform/chrome/wilco_ec/core.c
index af5fd288b63b..05e1e2be1c91 100644
--- a/drivers/platform/chrome/wilco_ec/core.c
+++ b/drivers/platform/chrome/wilco_ec/core.c
@@ -42,6 +42,7 @@ static int wilco_ec_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
struct wilco_ec_device *ec;
+   int ret;
 
ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
if (!ec)
@@ -78,13 +79,30 @@ static int wilco_ec_probe(struct platform_device *pdev)
 PLATFORM_DEVID_AUTO,
 NULL, 0);
 
+   /* Register a child device that will be found by the RTC driver. */
+   ec->rtc_pdev = platform_device_register_data(dev, "rtc-wilco-ec",
+PLATFORM_DEVID_AUTO,
+NULL, 0);
+   if (IS_ERR(ec->rtc_pdev)) {
+   dev_err(dev, "Failed to create RTC platform device\n");
+   ret = PTR_ERR(ec->rtc_pdev);
+   goto unregister_debugfs;
+   }
+
return 0;
+
+unregister_debugfs:
+   if (ec->debugfs_pdev)
+   platform_device_unregister(ec->debugfs_pdev);
+   cros_ec_lpc_mec_destroy();
+   return ret;
 }
 
 static int wilco_ec_remove(struct platform_device *pdev)
 {
struct wilco_ec_device *ec = platform_get_drvdata(pdev);
 
+   platform_device_unregister(ec->rtc_pdev);
if (ec->debugfs_pdev)
platform_device_unregister(ec->debugfs_pdev);
 
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 225b0b8516f3..d5063c791515 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1814,4 +1814,15 @@ config RTC_DRV_GOLDFISH
  Goldfish is a code name for the virtual platform developed by Google
  for Android emulation.
 
+config RTC_DRV_WILCO_EC
+   tristate "Wilco EC RTC"
+   depends on WILCO_EC
+   default m
+   help
+ If you say yes here, you get read/write support for the Real Time
+ Clock on the Wilco Embedded Controller (Wilco is a kind of Chromebook)
+
+ This can also be built as a module. If so, the module will
+ be named "rtc_wilco_ec".
+
 endif # RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index df022d820bee..6255ea78da25 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -172,6 +172,7 @@ obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
 obj-$(CONFIG_RTC_DRV_VR41XX)   += rtc-vr41xx.o
 obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
 obj-$(CONFIG_RTC_DRV_VT8500)   += rtc-vt8500.o
+obj-$(CONFIG_RTC_DRV_WILCO_EC) += rtc-wilco-ec.o
 obj-$(CONFIG_RTC_DRV_WM831X)   += rtc-wm831x.o
 obj-$(CONFIG_RTC_DRV_WM8350)   += rtc-wm8350.o
 obj-$(CONFIG_RTC_DRV_X1205)

[PATCH v8 0/4] platform/chrome: Add basic support for Wilco EC

2019-02-08 Thread Nick Crews


There is a new chromebook that contains a different Embedded Controller
(codename Wilco) than the rest of the chromebook series. Thus the kernel
requires a different driver than the already existing and generalized
cros_ec_* drivers. The core of the communication with the EC
is implemented in wilco_ec/mailbox.c, using a simple byte-level protocol
with a checksum, transmitted over an eSPI bus.

In this patch series I only introduce a very barebones
driver with a debugfs interface for sending/receiving raw byte
sequences to the EC, as well as a standard RTC driver with read/write
functionality.  Later, I will hopefully include more specialized
drivers such as a keyboard backlight driver, an EC event notification node,
telemetry data query node, etc.

The entry point of the driver is wilco_ec/core.c,
which is responsible for several tasks:
- Initialize the register interface that is used by wilco_ec_mailbox()
- Create a platform device which is picked up by the debugfs driver
- Create a platform device which is picked up by the RTC driver

A full thread of the development of these patches can be found at
https://chromium-review.googlesource.com/c/1356082. This thread contains
comments and revisions that could be helpful in understanding how the
driver arrived at the state it is in now. The thread also contains some
ChromeOS specific patches that actually enable the driver. If you want
to test the patch yourself, you would have to install the ChromeOS SDK
and cherry pick in these patches, and even then you would need a Sarien
device to actually run it.

Thank you for your comments!

Changes in v8:
- Fix a comment about registering the debugfs driver

Changes in v7:
- Switch to #define for MAX_WORD_SIZE so array size
  can be determined at compile time.

Changes in v6:
- Re-added WILCO_EC_FLAG_EXTENDED_DATA and went back to always
  reading either EC_MAILBOX_DATA_SIZE or EC_MAILBOX_DATA_SIZE_EXTENDED
  bytes, since it turns out the EC always expects you to calculate the
  checksum over all of them.
- Split WILCO_EC_MSG_TELEMETRY into WILCO_EC_MSG_TELEMETRY_SHORT and
  WILCO_EC_MSG_TELEMETRY_LONG, since there will be two different
  commands.
- A couple comment and err message polishes
- s/4.19/5.1/ for kernel version in documentation, since that is
  the version this patch should land in.
- Instead of requiring at least 3 bytes for msg type and command,
  now just require two for msg type. We can skip the command.
- Fixed error checking in probe() so that errors are hidden, without
  causing more errors or unextpected behavior.
- Some comment polishing.
- In the core, actually unregister the debugfs child platform_device
- In the core, actually unregister the RTC child platform_device.

Changes in v5:
- move checking of NO_RESPONSE flag before timeout check,
  so now timeout doesn't always happen when EC isn't supposed
  to respond.
- rm WILCO_EC_FLAG_EXTENDED_DATA, that is already obvious from
  wilco_ec_message.response_size
- core now always continues regardless of debugfs failure
- mv documentation to file header
- Check for OOM
- rm unneeded check if debug_info is allocqated
- rm bogus comment
- add space around "+"
- rm WILCO_EC_FLAG_EXTENDED_DATA, that is already obvious from
  wilco_ec_message.response_size

Changes in v4:
- add #define DRV_NAME
- remove redundant Kconfig nesting
- changed my email to @chromium.org
- Add better explanation of what core.c does
- Change debugfs driver to be a separate module
- Change me email to @chromium.org from @google.com
- Change CONFIG_WILCO_EC_SYSFS_RAW to
  CONFIG_WILCO_EC_DEBUGFS
- Change me email to @chromium.org from @google.com
- Move "Add RTC driver" before "Add sysfs attributes" so that
  it could get accepted earlier, since it is less contentious

Changes in v3:
- Change <= to >= in mec_in_range()
- Add " - EC_HOST_CMD_REGION0" to offset arg for io_bytes_mec()
- remove unused ret in probe()
- Add newline spacer in probe()
- rm unnecessary res in get_resource()
- s/8bit/8-bit
- rm first sleep when sending command to EC
- Move the attribute to the debugfs system
- Move the implementation to debugfs.c
- Improve the raw hex parsing
- Encapsulate global variables in one object
- Add safety check when passing less than 3 bytes
- Move documentation to debugfs-wilco-ec
- rm #define for driver name
- Don't compute weekday when reading from RTC.
  Still set weekday when writing, as RTC needs this
  to control advanced power scheduling
- rm check for invalid month data
- Set range_min and range_max on rtc_device

Changes in v2:
- Fixed kernel-doc comments
- Fixed include of linux/mfd/cros_ec_lpc_mec.h
- cros_ec_lpc_mec_in_range() returns -EINVAL on error
- Added parens around macro variables
- Remove COMPILE_TEST from Kconfig because inb()/outb()
won't work on anything but X86
- Add myself as module author
- Tweak mailbox()
- Add sysfs documentation
- rm duplicate EC_MAILBOX_DATA_SIZE defs
- Make docstrings follow kernel style
- Fix tags in commit msg
- Move 

[PATCH v8 3/4] platform/chrome: Add support for raw commands in debugfs

2019-02-08 Thread Nick Crews
Add a debugfs attribute that allows sending raw commands to the EC.
This is useful for development and debug but should not be enabled
in a production environment.

To test:
Get the EC firmware build date
First send the request command
> echo 00 f0 38 00 03 00 > raw
Then read the result. "12/21/18" is in the middle of the response
> cat raw
00 31 32 2f 32 31 2f 31 38 00 00 0f 01 00 01 00  .12/21/18...

Get the EC firmware build date
First send the request command
> echo 00 f0 38 00 03 00 > raw
Then read the result. "12/21/18" is in the middle of the response
> cat raw
00 31 32 2f 32 31 2f 31 38 00 00 0f 01 00 01 00  .12/21/18...

Signed-off-by: Duncan Laurie 
Signed-off-by: Nick Crews 
---

Changes in v8:
- Fix a comment about registering the debugfs driver

Changes in v7:
- Switch to #define for MAX_WORD_SIZE so array size
  can be determined at compile time.

Changes in v6:
- s/4.19/5.1/ for kernel version in documentation, since that is
  the version this patch should land in.
- Instead of requiring at least 3 bytes for msg type and command,
  now just require two for msg type. We can skip the command.
- Fixed error checking in probe() so that errors are hidden, without
  causing more errors or unextpected behavior.
- Some comment polishing.
- In the core, actually unregister the debugfs child platform_device

Changes in v5:
- core now always continues regardless of debugfs failure
- mv documentation to file header
- Check for OOM
- rm unneeded check if debug_info is allocqated
- rm bogus comment
- add space around "+"
- rm WILCO_EC_FLAG_EXTENDED_DATA, that is already obvious from
  wilco_ec_message.response_size

Changes in v4:
- Change debugfs driver to be a separate module
- Change me email to @chromium.org from @google.com
- Change CONFIG_WILCO_EC_SYSFS_RAW to
  CONFIG_WILCO_EC_DEBUGFS

Changes in v3:
- Move the attribute to the debugfs system
- Move the implementation to debugfs.c
- Improve the raw hex parsing
- Encapsulate global variables in one object
- Add safety check when passing less than 3 bytes
- Move documentation to debugfs-wilco-ec

Changes in v2:
- Add sysfs documentation
- rm duplicate EC_MAILBOX_DATA_SIZE defs
- Make docstrings follow kernel style
- Fix tags in commit msg
- Move Kconfig to subdirectory
- Reading raw now includes ASCII translation

 Documentation/ABI/testing/debugfs-wilco-ec |  23 ++
 drivers/platform/chrome/wilco_ec/Kconfig   |  10 +
 drivers/platform/chrome/wilco_ec/Makefile  |   2 +
 drivers/platform/chrome/wilco_ec/core.c|  14 ++
 drivers/platform/chrome/wilco_ec/debugfs.c | 238 +
 include/linux/platform_data/wilco-ec.h |   2 +
 6 files changed, 289 insertions(+)
 create mode 100644 Documentation/ABI/testing/debugfs-wilco-ec
 create mode 100644 drivers/platform/chrome/wilco_ec/debugfs.c

diff --git a/Documentation/ABI/testing/debugfs-wilco-ec 
b/Documentation/ABI/testing/debugfs-wilco-ec
new file mode 100644
index ..f814f112e213
--- /dev/null
+++ b/Documentation/ABI/testing/debugfs-wilco-ec
@@ -0,0 +1,23 @@
+What:  /sys/kernel/debug/wilco_ec/raw
+Date:  January 2019
+KernelVersion: 5.1
+Description:
+   Write and read raw mailbox commands to the EC.
+
+   For writing:
+   Bytes 0-1 indicate the message type:
+   00 F0 = Execute Legacy Command
+   00 F2 = Read/Write NVRAM Property
+   Byte 2 provides the command code
+   Bytes 3+ consist of the data passed in the request
+
+   At least three bytes are required, for the msg type and command,
+   with additional bytes optional for additional data.
+
+   Example:
+   // Request EC info type 3 (EC firmware build date)
+   $ echo 00 f0 38 00 03 00 > raw
+   // View the result. The decoded ASCII result "12/21/18" is
+   // included after the raw hex.
+   $ cat raw
+   00 31 32 2f 32 31 2f 31 38 00 38 00 01 00 2f 00  .12/21/18.8...
diff --git a/drivers/platform/chrome/wilco_ec/Kconfig 
b/drivers/platform/chrome/wilco_ec/Kconfig
index 20945a301ec6..fb6d9ff33e41 100644
--- a/drivers/platform/chrome/wilco_ec/Kconfig
+++ b/drivers/platform/chrome/wilco_ec/Kconfig
@@ -9,3 +9,13 @@ config WILCO_EC
 
  To compile this driver as a module, choose M here: the
  module will be called wilco_ec.
+
+config WILCO_EC_DEBUGFS
+   tristate "Enable raw access to EC via debugfs"
+   depends on WILCO_EC
+   help
+ If you say Y here, you get support for sending raw commands to
+ the Wilco EC via debugfs.  These commands do not do any byte
+ manipulation and allow for testing arbitrary commands.  This
+ interface is intended for debug only and will not be present
+ on production devices.
diff --git a/drivers/platform/chrome/wilco_ec/Makefile 
b/drivers/platform/chrome/wilco_ec/Makefile
index 

Re: [PATCH net-next 15/16] net: switchdev: Replace port attr set SDO with a notification

2019-02-08 Thread Florian Fainelli
On 2/8/19 4:32 PM, Florian Fainelli wrote:
> Drop switchdev_ops.switchdev_port_attr_set. Drop the uses of this field
> from all clients, which were migrated to use switchdev notification in
> the previous patches.
> 
> Add a new function switchdev_port_attr_notify() that sends the switchdev
> notifications SWITCHDEV_PORT_ATTR_SET.
> 
> Drop __switchdev_port_attr_set() and update switchdev_port_attr_set()
> likewise.
> 
> Signed-off-by: Florian Fainelli 
> ---
>  include/net/switchdev.h   | 18 
>  net/switchdev/switchdev.c | 92 ++-
>  2 files changed, 22 insertions(+), 88 deletions(-)
> 
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index 4c5f7e5430cf..5387ff6f41c5 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -111,21 +111,6 @@ void *switchdev_trans_item_dequeue(struct 
> switchdev_trans *trans);
>  
>  typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
>  
> -/**
> - * struct switchdev_ops - switchdev operations
> - *
> - * @switchdev_port_attr_get: Get a port attribute (see switchdev_attr).
> - *
> - * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr).
> - */
> -struct switchdev_ops {
> - int (*switchdev_port_attr_get)(struct net_device *dev,
> -struct switchdev_attr *attr);
> - int (*switchdev_port_attr_set)(struct net_device *dev,
> -const struct switchdev_attr *attr,
> -struct switchdev_trans *trans);
> -};
> -

This and the hunk below bisection, I will move that into patch #16 after
receiving feedback on this.
-- 
Florian


[PATCH net-next 09/16] switchdev: Add SWITCHDEV_PORT_ATTR_SET

2019-02-08 Thread Florian Fainelli
In preparation for allowing switchdev enabled drivers to veto specific
attribute settings from within the context of the caller, introduce a
new switchdev notifier type for port attributes.

Suggested-by: Ido Schimmel 
Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 96cd3e795f7f..4c5f7e5430cf 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -141,6 +141,8 @@ enum switchdev_notifier_type {
SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE,
SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE,
SWITCHDEV_VXLAN_FDB_OFFLOADED,
+
+   SWITCHDEV_PORT_ATTR_SET, /* Blocking. */
 };
 
 struct switchdev_notifier_info {
@@ -163,6 +165,13 @@ struct switchdev_notifier_port_obj_info {
bool handled;
 };
 
+struct switchdev_notifier_port_attr_info {
+   struct switchdev_notifier_info info; /* must be first */
+   const struct switchdev_attr *attr;
+   struct switchdev_trans *trans;
+   bool handled;
+};
+
 static inline struct net_device *
 switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
 {
-- 
2.17.1



[PATCH net-next 14/16] staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-08 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare ethsw to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
swdev_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index b195b09e0d1d..d40bdcadd569 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1092,6 +1092,24 @@ ethsw_switchdev_port_obj_event(unsigned long event, 
struct net_device *netdev,
return notifier_from_errno(err);
 }
 
+static int
+ethsw_switchdev_port_attr_event(unsigned long event,
+   struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err = -EOPNOTSUPP;
+
+   switch (event) {
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = swdev_port_attr_set(netdev, port_attr_info->attr,
+ port_attr_info->trans);
+   break;
+   }
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int port_switchdev_blocking_event(struct notifier_block *unused,
 unsigned long event, void *ptr)
 {
@@ -1104,6 +1122,8 @@ static int port_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD: /* fall through */
case SWITCHDEV_PORT_OBJ_DEL:
return ethsw_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return ethsw_switchdev_port_attr_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1



[PATCH net-next 16/16] net: Remove switchdev_ops

2019-02-08 Thread Florian Fainelli
Now that we have converted all possible callers to using a switchdev
notifier for attributes we do not have a need for implementing
switchdev_ops anymore, and this can be removed from all drivers the
net_device structure.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c   | 12 
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h   |  2 --
 .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 12 
 drivers/net/ethernet/mscc/ocelot.c   |  1 -
 drivers/net/ethernet/rocker/rocker_main.c|  5 -
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  |  5 -
 include/linux/netdevice.h|  3 ---
 net/dsa/slave.c  |  5 -
 8 files changed, 45 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 8dd808b7f931..18b56afbd5d7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3220,7 +3220,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
}
mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan;
 
-   mlxsw_sp_port_switchdev_init(mlxsw_sp_port);
mlxsw_sp->ports[local_port] = mlxsw_sp_port;
err = register_netdev(dev);
if (err) {
@@ -3237,7 +3236,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
 
 err_register_netdev:
mlxsw_sp->ports[local_port] = NULL;
-   mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_destroy(mlxsw_sp_port_vlan);
 err_port_vlan_create:
 err_port_pvid_set:
@@ -3280,7 +3278,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp);
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
mlxsw_sp->ports[local_port] = NULL;
-   mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true);
mlxsw_sp_port_nve_fini(mlxsw_sp_port);
mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port);
@@ -4001,12 +3998,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
goto err_span_init;
}
 
-   err = mlxsw_sp_switchdev_init(mlxsw_sp);
-   if (err) {
-   dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize 
switchdev\n");
-   goto err_switchdev_init;
-   }
-
err = mlxsw_sp_counter_pool_init(mlxsw_sp);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter 
pool\n");
@@ -4077,8 +4068,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
 err_afa_init:
mlxsw_sp_counter_pool_fini(mlxsw_sp);
 err_counter_pool_init:
-   mlxsw_sp_switchdev_fini(mlxsw_sp);
-err_switchdev_init:
mlxsw_sp_span_fini(mlxsw_sp);
 err_span_init:
mlxsw_sp_lag_fini(mlxsw_sp);
@@ -4141,7 +4130,6 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
mlxsw_sp_nve_fini(mlxsw_sp);
mlxsw_sp_afa_fini(mlxsw_sp);
mlxsw_sp_counter_pool_fini(mlxsw_sp);
-   mlxsw_sp_switchdev_fini(mlxsw_sp);
mlxsw_sp_span_fini(mlxsw_sp);
mlxsw_sp_lag_fini(mlxsw_sp);
mlxsw_sp_buffers_fini(mlxsw_sp);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 4fe0996c7cdd..76f51087e35a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -375,8 +375,6 @@ u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, 
u32 bytes);
 /* spectrum_switchdev.c */
 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
-void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
-void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
bool adding);
 void
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 29ffb5cac777..9951cfe0b244 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1925,10 +1925,6 @@ static struct mlxsw_sp_port 
*mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp,
return NULL;
 }
 
-static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = {
-   .switchdev_port_attr_set= mlxsw_sp_port_attr_set,
-};
-
 static int
 mlxsw_sp_bridge_8021q_port_join(struct mlxsw_sp_bridge_device *bridge_device,
struct mlxsw_sp_bridge_port *bridge_port,
@@ -3539,11 +3535,3 @@ void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp)
kfree(mlxsw_sp->bridge);
 }
 
-void 

mmotm 2019-02-08-16-33 uploaded

2019-02-08 Thread akpm
The mm-of-the-moment snapshot 2019-02-08-16-33 has been uploaded to

   http://www.ozlabs.org/~akpm/mmotm/

mmotm-readme.txt says

README for mm-of-the-moment:

http://www.ozlabs.org/~akpm/mmotm/

This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
more than once a week.

You will need quilt to apply these patches to the latest Linus release (4.x
or 4.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
http://ozlabs.org/~akpm/mmotm/series

The file broken-out.tar.gz contains two datestamp files: .DATE and
.DATE--mm-dd-hh-mm-ss.  Both contain the string -mm-dd-hh-mm-ss,
followed by the base kernel version against which this patch series is to
be applied.

This tree is partially included in linux-next.  To see which patches are
included in linux-next, consult the `series' file.  Only the patches
within the #NEXT_PATCHES_START/#NEXT_PATCHES_END markers are included in
linux-next.

A git tree which contains the memory management portion of this tree is
maintained at git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
by Michal Hocko.  It contains the patches which are between the
"#NEXT_PATCHES_START mm" and "#NEXT_PATCHES_END" markers, from the series
file, http://www.ozlabs.org/~akpm/mmotm/series.


A full copy of the full kernel tree with the linux-next and mmotm patches
already applied is available through git within an hour of the mmotm
release.  Individual mmotm releases are tagged.  The master branch always
points to the latest release, so it's constantly rebasing.

http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/

To develop on top of mmotm git:

  $ git remote add mmotm 
git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
  $ git remote update mmotm
  $ git checkout -b topic mmotm/master
  
  $ git send-email mmotm/master.. [...]

To rebase a branch with older patches to a new mmotm release:

  $ git remote update mmotm
  $ git rebase --onto mmotm/master  topic




The directory http://www.ozlabs.org/~akpm/mmots/ (mm-of-the-second)
contains daily snapshots of the -mm tree.  It is updated more frequently
than mmotm, and is untested.

A git copy of this tree is available at

http://git.cmpxchg.org/cgit.cgi/linux-mmots.git/

and use of this tree is similar to
http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/, described above.


This mmotm tree contains the following patches against 5.0-rc5:
(patches marked "*" will be included in linux-next)

  origin.patch
* checkpatch-dont-interpret-stack-dumps-as-commit-ids.patch
* revert-mm-dont-reclaim-inodes-with-many-attached-pages.patch
* revert-mm-slowly-shrink-slabs-with-a-relatively-small-number-of-objects.patch
* mm-gup-fix-gup_pmd_range-for-dax.patch
* huegtlbfs-fix-page-leak-during-migration-of-file-pages.patch
* revert-mm-use-early_pfn_to_nid-in-page_ext_init.patch
* rename-include-uapi-=-asm-generic-shmparamh-really.patch
* mm-swapc-workaround-for_each_cpu-bug-on-up-kernel.patch
* revert-initramfs-cleanup-incomplete-rootfs.patch
* mm-proc-smaps_rollup-fix-pss_locked-calculation.patch
* kasan-remove-use-after-scope-bugs-detection.patch
* page_poison-play-nicely-with-kasan.patch
* kasan-fix-kasan_check_read-write-definitions.patch
* scripts-decode_stacktracesh-handle-rip-address-with-segment.patch
* sh-remove-nargs-from-__syscall.patch
* debugobjects-move-printk-out-of-db-lock-critical-sections.patch
* ocfs2-fix-a-panic-problem-caused-by-o2cb_ctl.patch
* ocfs2-fix-the-application-io-timeout-when-fstrim-is-running.patch
* ocfs2-use-zero-sized-array-and-struct_size-in-kzalloc.patch
* ocfs2-clear-zero-in-unaligned-direct-io.patch
* ocfs2-clear-zero-in-unaligned-direct-io-checkpatch-fixes.patch
* 
ocfs2-dlm-clean-dlm_lksb_get_lvb-and-dlm_lksb_put_lvb-when-the-cancel_pending-is-set.patch
* 
ocfs2-dlm-return-dlm_cancelgrant-if-the-lock-is-on-granted-list-and-the-operation-is-canceled.patch
* ramfs-support-o_tmpfile.patch
* fs-inode_set_flags-replace-opencoded-set_mask_bits.patch
* fs-filec-initialize-init_filesresize_wait.patch
  mm.patch
* mm-slubc-freelist-is-ensured-to-be-null-when-new_slab-fails.patch
* mm-slub-introduce-slab_warn_on_error.patch
* mm-slub-introduce-slab_warn_on_error-fix.patch
* slab-kmemleak-no-scan-alien-caches.patch
* slub-capitialize-comment-string.patch
* memory_hotplug-free-pages-as-higher-order.patch
* mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v11.patch
* mm-page_allocc-memory_hotplug-free-pages-as-higher-order-v11-fix.patch
* mm-balloon-update-comment-about-isolation-migration-compaction.patch
* mm-convert-pg_balloon-to-pg_offline.patch
* mm-convert-pg_balloon-to-pg_offline-fix.patch
* kexec-export-pg_offline-to-vmcoreinfo.patch
* xen-balloon-mark-inflated-pages-pg_offline.patch
* hv_balloon-mark-inflated-pages-pg_offline.patch
* vmw_balloon-mark-inflated-pages-pg_offline.patch
* vmw_balloon-mark-inflated-pages-pg_offline-v2.patch
* pm-hibernate-use-pfn_to_online_page.patch
* pm-hibernate-exclude-all-pageoffline-pages.patch
* 

[PATCH net-next 03/16] staging: fsl-dpaa2: ethsw: Check bridge port flags during set

2019-02-08 Thread Florian Fainelli
In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
have ethsw check that the bridge port flags that are being set are
supported.

Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index e559f4c25cf7..6228c4375835 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -680,8 +680,11 @@ static int port_attr_br_flags_set(struct net_device 
*netdev,
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int err = 0;
 
-   if (switchdev_trans_ph_prepare(trans))
+   if (switchdev_trans_ph_prepare(trans)) {
+   if (flags & ~(BR_LEARNING | BR_FLOOD))
+   return -EOPNOTSUPP;
return 0;
+   }
 
/* Learning is enabled per switch */
err = ethsw_set_learning(port_priv->ethsw_data, flags & BR_LEARNING);
-- 
2.17.1



[PATCH net-next 15/16] net: switchdev: Replace port attr set SDO with a notification

2019-02-08 Thread Florian Fainelli
Drop switchdev_ops.switchdev_port_attr_set. Drop the uses of this field
from all clients, which were migrated to use switchdev notification in
the previous patches.

Add a new function switchdev_port_attr_notify() that sends the switchdev
notifications SWITCHDEV_PORT_ATTR_SET.

Drop __switchdev_port_attr_set() and update switchdev_port_attr_set()
likewise.

Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h   | 18 
 net/switchdev/switchdev.c | 92 ++-
 2 files changed, 22 insertions(+), 88 deletions(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 4c5f7e5430cf..5387ff6f41c5 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -111,21 +111,6 @@ void *switchdev_trans_item_dequeue(struct switchdev_trans 
*trans);
 
 typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
 
-/**
- * struct switchdev_ops - switchdev operations
- *
- * @switchdev_port_attr_get: Get a port attribute (see switchdev_attr).
- *
- * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr).
- */
-struct switchdev_ops {
-   int (*switchdev_port_attr_get)(struct net_device *dev,
-  struct switchdev_attr *attr);
-   int (*switchdev_port_attr_set)(struct net_device *dev,
-  const struct switchdev_attr *attr,
-  struct switchdev_trans *trans);
-};
-
 enum switchdev_notifier_type {
SWITCHDEV_FDB_ADD_TO_BRIDGE = 1,
SWITCHDEV_FDB_DEL_TO_BRIDGE,
@@ -224,7 +209,6 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
int (*del_cb)(struct net_device *dev,
  const struct switchdev_obj *obj));
 
-#define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
 #else
 
 static inline void switchdev_deferred_process(void)
@@ -311,8 +295,6 @@ switchdev_handle_port_obj_del(struct net_device *dev,
return 0;
 }
 
-#define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)
-
 #endif
 
 #endif /* _LINUX_SWITCHDEV_H_ */
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 7e1357db33d7..5a053e20363e 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -174,81 +174,31 @@ static int switchdev_deferred_enqueue(struct net_device 
*dev,
return 0;
 }
 
-/**
- * switchdev_port_attr_get - Get port attribute
- *
- * @dev: port device
- * @attr: attribute to get
- */
-int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr 
*attr)
+static int switchdev_port_attr_notify(enum switchdev_notifier_type nt,
+ struct net_device *dev,
+ struct switchdev_attr *attr,
+ struct switchdev_trans *trans)
 {
-   const struct switchdev_ops *ops = dev->switchdev_ops;
-   struct net_device *lower_dev;
-   struct list_head *iter;
-   struct switchdev_attr first = {
-   .id = SWITCHDEV_ATTR_ID_UNDEFINED
-   };
-   int err = -EOPNOTSUPP;
+   int err;
+   int rc;
 
-   if (ops && ops->switchdev_port_attr_get)
-   return ops->switchdev_port_attr_get(dev, attr);
+   struct switchdev_notifier_port_attr_info attr_info = {
+   .attr = attr,
+   .trans = trans,
+   .handled = false,
+   };
 
-   if (attr->flags & SWITCHDEV_F_NO_RECURSE)
+   rc = call_switchdev_blocking_notifiers(nt, dev, _info.info, NULL);
+   err = notifier_to_errno(rc);
+   if (err) {
+   WARN_ON(!attr_info.handled);
return err;
-
-   /* Switch device port(s) may be stacked under
-* bond/team/vlan dev, so recurse down to get attr on
-* each port.  Return -ENODATA if attr values don't
-* compare across ports.
-*/
-
-   netdev_for_each_lower_dev(dev, lower_dev, iter) {
-   err = switchdev_port_attr_get(lower_dev, attr);
-   if (err)
-   break;
-   if (first.id == SWITCHDEV_ATTR_ID_UNDEFINED)
-   first = *attr;
-   else if (memcmp(, attr, sizeof(*attr)))
-   return -ENODATA;
}
 
-   return err;
-}
-EXPORT_SYMBOL_GPL(switchdev_port_attr_get);
-
-static int __switchdev_port_attr_set(struct net_device *dev,
-const struct switchdev_attr *attr,
-struct switchdev_trans *trans)
-{
-   const struct switchdev_ops *ops = dev->switchdev_ops;
-   struct net_device *lower_dev;
-   struct list_head *iter;
-   int err = -EOPNOTSUPP;
-
-   if (ops && ops->switchdev_port_attr_set) {
-   err = ops->switchdev_port_attr_set(dev, attr, trans);
-   goto done;
-   }
-
-   if (attr->flags & 

[PATCH net-next 11/16] net: dsa: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-08 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare DSA to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
dsa_slave_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 net/dsa/slave.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index ae34be949d79..f8c7c1b2cd2f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1544,6 +1544,24 @@ dsa_slave_switchdev_port_obj_event(unsigned long event,
return notifier_from_errno(err);
 }
 
+static int
+dsa_slave_switchdev_port_attr_event(unsigned long event,
+   struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err = -EOPNOTSUPP;
+
+   switch (event) {
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = dsa_slave_port_attr_set(netdev, port_attr_info->attr,
+ port_attr_info->trans);
+   break;
+   }
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused,
  unsigned long event, void *ptr)
 {
@@ -1556,6 +1574,8 @@ static int dsa_slave_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD: /* fall through */
case SWITCHDEV_PORT_OBJ_DEL:
return dsa_slave_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET: /* fallthrough */
+   return dsa_slave_switchdev_port_attr_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1



[PATCH net-next 12/16] mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-08 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare mlxsw to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
mlxsw_sp_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 .../mellanox/mlxsw/spectrum_switchdev.c   | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 6b09d68671cf..29ffb5cac777 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -3410,6 +3410,23 @@ mlxsw_sp_switchdev_handle_vxlan_obj_del(struct 
net_device *vxlan_dev,
}
 }
 
+static int
+mlxsw_sp_switchdev_port_attr_event(unsigned long event, struct net_device *dev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err = -EOPNOTSUPP;
+
+   switch (event) {
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = mlxsw_sp_port_attr_set(dev, port_attr_info->attr,
+port_attr_info->trans);
+   break;
+   }
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused,
 unsigned long event, void *ptr)
 {
@@ -3433,6 +3450,8 @@ static int mlxsw_sp_switchdev_blocking_event(struct 
notifier_block *unused,
mlxsw_sp_port_dev_check,
mlxsw_sp_port_obj_del);
return notifier_from_errno(err);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return mlxsw_sp_switchdev_port_attr_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1



[PATCH net-next 07/16] net: Remove SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT

2019-02-08 Thread Florian Fainelli
Now that we have converted the bridge code and the drivers to check for
bridge port(s) flags at the time we try to set them, there is no need
for a get() -> set() sequence anymore and
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT therefore becomes unused.

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c   |  4 
 drivers/net/ethernet/rocker/rocker_main.c  |  4 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c|  3 ---
 include/net/switchdev.h|  2 --
 net/dsa/slave.c| 10 +-
 5 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 468a6d513074..8242a373f6e7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -455,10 +455,6 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
   >u.brport_flags);
break;
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   attr->u.brport_flags_support = BR_LEARNING | BR_FLOOD |
-  BR_MCAST_FLOOD;
-   break;
default:
return -EOPNOTSUPP;
}
diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 8657313b6f30..375c4c908bea 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2075,10 +2075,6 @@ static int rocker_port_attr_get(struct net_device *dev,
err = rocker_world_port_attr_bridge_flags_get(rocker_port,
  
>u.brport_flags);
break;
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   err = 
rocker_world_port_attr_bridge_flags_support_get(rocker_port,
- 
>u.brport_flags_support);
-   break;
default:
return -EOPNOTSUPP;
}
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index 6228c4375835..79635d1091df 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -651,9 +651,6 @@ static int swdev_port_attr_get(struct net_device *netdev,
(port_priv->ethsw_data->learning ? BR_LEARNING : 0) |
(port_priv->flood ? BR_FLOOD : 0);
break;
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   attr->u.brport_flags_support = BR_LEARNING | BR_FLOOD;
-   break;
default:
return -EOPNOTSUPP;
}
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 5e87b54c5dc5..e2083824e577 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -45,7 +45,6 @@ enum switchdev_attr_id {
SWITCHDEV_ATTR_ID_UNDEFINED,
SWITCHDEV_ATTR_ID_PORT_STP_STATE,
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
-   SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
SWITCHDEV_ATTR_ID_PORT_MROUTER,
SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,
@@ -62,7 +61,6 @@ struct switchdev_attr {
union {
u8 stp_state;   /* PORT_STP_STATE */
unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
-   unsigned long brport_flags_support; /* 
PORT_BRIDGE_FLAGS_SUPPORT */
bool mrouter;   /* PORT_MROUTER */
clock_t ageing_time;/* BRIDGE_AGEING_TIME */
bool vlan_filtering;/* 
BRIDGE_VLAN_FILTERING */
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 212fc1cc27fc..5797da954e77 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -382,15 +382,7 @@ static int dsa_slave_get_port_parent_id(struct net_device 
*dev,
 static int dsa_slave_port_attr_get(struct net_device *dev,
   struct switchdev_attr *attr)
 {
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   attr->u.brport_flags_support = 0;
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
+   return -EOPNOTSUPP;
 }
 
 static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,
-- 
2.17.1



[PATCH net-next 10/16] rocker: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-08 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare rocker to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
rocker_port_attr_set call.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index ff3f14504f4f..f10e4888ecff 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2811,6 +2811,24 @@ rocker_switchdev_port_obj_event(unsigned long event, 
struct net_device *netdev,
return notifier_from_errno(err);
 }
 
+static int
+rocker_switchdev_port_attr_event(unsigned long event, struct net_device 
*netdev,
+struct switchdev_notifier_port_attr_info
+*port_attr_info)
+{
+   int err = -EOPNOTSUPP;
+
+   switch (event) {
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = rocker_port_attr_set(netdev, port_attr_info->attr,
+  port_attr_info->trans);
+   break;
+   }
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int rocker_switchdev_blocking_event(struct notifier_block *unused,
   unsigned long event, void *ptr)
 {
@@ -2823,6 +2841,8 @@ static int rocker_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD:
case SWITCHDEV_PORT_OBJ_DEL:
return rocker_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return rocker_switchdev_port_attr_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1



[PATCH net-next 08/16] net: Get rid of switchdev_port_attr_get()

2019-02-08 Thread Florian Fainelli
With the bridge no longer calling switchdev_port_attr_get() to obtain
the supported bridge port flags from a driver but instead trying to set
the bridge port flags directly and relying on driver to reject
unsupported configurations, we can effectively get rid of
switchdev_port_attr_get() entirely since this was the only place where
it was called.

Signed-off-by: Florian Fainelli 
---
 Documentation/networking/switchdev.txt|  5 ++-
 .../mellanox/mlxsw/spectrum_switchdev.c   | 32 ---
 drivers/net/ethernet/rocker/rocker_main.c | 30 -
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 19 ---
 include/net/switchdev.h   |  8 -
 net/dsa/slave.c   |  7 
 6 files changed, 2 insertions(+), 99 deletions(-)

diff --git a/Documentation/networking/switchdev.txt 
b/Documentation/networking/switchdev.txt
index 2842f63ad47b..0d9530bf745b 100644
--- a/Documentation/networking/switchdev.txt
+++ b/Documentation/networking/switchdev.txt
@@ -233,9 +233,8 @@ the bridge's FDB.  It's possible, but not optimal, to 
enable learning on the
 device port and on the bridge port, and disable learning_sync.
 
 To support learning and learning_sync port attributes, the driver implements
-switchdev op switchdev_port_attr_get/set for
-SWITCHDEV_ATTR_PORT_ID_BRIDGE_FLAGS. The driver should initialize the 
attributes
-to the hardware defaults.
+switchdev op switchdev_port_attr_set for SWITCHDEV_ATTR_PORT_ID_BRIDGE_FLAGS.
+The driver should initialize the attributes to the hardware defaults.
 
 FDB Ageing
 ^^
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 8242a373f6e7..6b09d68671cf 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -431,37 +431,6 @@ static void mlxsw_sp_bridge_vlan_put(struct 
mlxsw_sp_bridge_vlan *bridge_vlan)
mlxsw_sp_bridge_vlan_destroy(bridge_vlan);
 }
 
-static void mlxsw_sp_port_bridge_flags_get(struct mlxsw_sp_bridge *bridge,
-  struct net_device *dev,
-  unsigned long *brport_flags)
-{
-   struct mlxsw_sp_bridge_port *bridge_port;
-
-   bridge_port = mlxsw_sp_bridge_port_find(bridge, dev);
-   if (WARN_ON(!bridge_port))
-   return;
-
-   memcpy(brport_flags, _port->flags, sizeof(*brport_flags));
-}
-
-static int mlxsw_sp_port_attr_get(struct net_device *dev,
- struct switchdev_attr *attr)
-{
-   struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
-   struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
-   mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
-  >u.brport_flags);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
-}
-
 static int
 mlxsw_sp_port_bridge_vlan_stp_set(struct mlxsw_sp_port *mlxsw_sp_port,
  struct mlxsw_sp_bridge_vlan *bridge_vlan,
@@ -1957,7 +1926,6 @@ static struct mlxsw_sp_port *mlxsw_sp_lag_rep_port(struct 
mlxsw_sp *mlxsw_sp,
 }
 
 static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = {
-   .switchdev_port_attr_get= mlxsw_sp_port_attr_get,
.switchdev_port_attr_set= mlxsw_sp_port_attr_set,
 };
 
diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 375c4c908bea..ff3f14504f4f 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1606,17 +1606,6 @@ rocker_world_port_attr_bridge_flags_set(struct 
rocker_port *rocker_port,
trans);
 }
 
-static int
-rocker_world_port_attr_bridge_flags_get(const struct rocker_port *rocker_port,
-   unsigned long *p_brport_flags)
-{
-   struct rocker_world_ops *wops = rocker_port->rocker->wops;
-
-   if (!wops->port_attr_bridge_flags_get)
-   return -EOPNOTSUPP;
-   return wops->port_attr_bridge_flags_get(rocker_port, p_brport_flags);
-}
-
 static int
 rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
  u32 ageing_time,
@@ -2064,24 +2053,6 @@ static const struct net_device_ops 
rocker_port_netdev_ops = {
  * swdev interface
  /
 
-static int rocker_port_attr_get(struct net_device *dev,
-   struct switchdev_attr *attr)
-{
-   const struct rocker_port *rocker_port = netdev_priv(dev);
-   int err = 0;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
-   err = 

[PATCH net-next 13/16] net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-08 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare ocelot to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
ocelot_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mscc/ocelot.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c 
b/drivers/net/ethernet/mscc/ocelot.c
index 195306d05bcd..adab478d36f1 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1324,10 +1324,6 @@ static int ocelot_port_obj_del(struct net_device *dev,
return ret;
 }
 
-static const struct switchdev_ops ocelot_port_switchdev_ops = {
-   .switchdev_port_attr_set= ocelot_port_attr_set,
-};
-
 static int ocelot_port_bridge_join(struct ocelot_port *ocelot_port,
   struct net_device *bridge)
 {
@@ -1582,6 +1578,24 @@ struct notifier_block ocelot_netdevice_nb __read_mostly 
= {
 };
 EXPORT_SYMBOL(ocelot_netdevice_nb);
 
+static int
+ocelot_switchdev_port_attr_event(unsigned long event,
+   struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err = -EOPNOTSUPP;
+
+   switch (event) {
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = ocelot_port_attr_set(netdev, port_attr_info->attr,
+  port_attr_info->trans);
+   break;
+   }
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int ocelot_switchdev_blocking_event(struct notifier_block *unused,
   unsigned long event, void *ptr)
 {
@@ -1600,6 +1614,8 @@ static int ocelot_switchdev_blocking_event(struct 
notifier_block *unused,
ocelot_netdevice_dev_check,
ocelot_port_obj_del);
return notifier_from_errno(err);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return ocelot_switchdev_port_attr_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1



[PATCH net-next 04/16] net: dsa: Add setter for SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS

2019-02-08 Thread Florian Fainelli
In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
add support for a function that processes the
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS attribute and returns not supported
for any flag set, since DSA does not currently support toggling those
bridge port attributes (yet).

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa_priv.h |  3 +++
 net/dsa/port.c | 10 ++
 net/dsa/slave.c|  4 
 3 files changed, 17 insertions(+)

diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 1f4972dab9f2..97594f0b6efb 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -150,6 +150,9 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool 
vlan_filtering,
struct switchdev_trans *trans);
 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
 struct switchdev_trans *trans);
+int dsa_port_bridge_port_flags_set(struct dsa_port *dp,
+  unsigned long brport_flags,
+  struct switchdev_trans *trans);
 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
 u16 vid);
 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 2d7e01b23572..2ce3752203cf 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -177,6 +177,16 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t 
ageing_clock,
return dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, );
 }
 
+int dsa_port_bridge_port_flags_set(struct dsa_port *dp,
+  unsigned long brport_flags,
+  struct switchdev_trans *trans)
+{
+   if (brport_flags)
+   return -EOPNOTSUPP;
+
+   return 0;
+}
+
 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
 u16 vid)
 {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 70395a0ae52e..212fc1cc27fc 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -292,6 +292,10 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
ret = dsa_port_ageing_time(dp, attr->u.ageing_time, trans);
break;
+   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
+   ret = dsa_port_bridge_port_flags_set(dp, attr->u.brport_flags,
+trans);
+   break;
default:
ret = -EOPNOTSUPP;
break;
-- 
2.17.1



[PATCH net-next 06/16] net: bridge: Stop calling switchdev_port_attr_get()

2019-02-08 Thread Florian Fainelli
Now that all switchdev drivers have been converted to checking the
bridge port flags during the prepare phase of the
switchdev_port_attr_set(), we can move straight to trying to set the
desired flag through SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS.

Signed-off-by: Florian Fainelli 
---
 net/bridge/br_switchdev.c | 20 +++-
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index db9e8ab96d48..939f300522c5 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -64,29 +64,15 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
 {
struct switchdev_attr attr = {
.orig_dev = p->dev,
-   .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
+   .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
+   .flags = SWITCHDEV_F_DEFER,
+   .u.brport_flags = flags,
};
int err;
 
if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD)
return 0;
 
-   err = switchdev_port_attr_get(p->dev, );
-   if (err == -EOPNOTSUPP)
-   return 0;
-   if (err)
-   return err;
-
-   /* Check if specific bridge flag attribute offload is supported */
-   if (!(attr.u.brport_flags_support & mask)) {
-   br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",
-   (unsigned int)p->port_no, p->dev->name);
-   return -EOPNOTSUPP;
-   }
-
-   attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS;
-   attr.flags = SWITCHDEV_F_DEFER;
-   attr.u.brport_flags = flags;
err = switchdev_port_attr_set(p->dev, );
if (err) {
br_warn(p->br, "error setting offload flag on port %u(%s)\n",
-- 
2.17.1



[PATCH net-next 05/16] rocker: Check bridge flags during prepare phase

2019-02-08 Thread Florian Fainelli
In preparation for getting rid of switchdev_port_attr_get(), have rocker
check for the bridge flags being set through switchdev_port_attr_set()
with the SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS attribute identifier.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 40 ++-
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 66f72f8c46e5..8657313b6f30 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1565,18 +1565,42 @@ static int rocker_world_port_attr_stp_state_set(struct 
rocker_port *rocker_port,
return wops->port_attr_stp_state_set(rocker_port, state);
 }
 
+static int
+rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *
+   rocker_port,
+   unsigned long *
+   p_brport_flags_support)
+{
+   struct rocker_world_ops *wops = rocker_port->rocker->wops;
+
+   if (!wops->port_attr_bridge_flags_support_get)
+   return -EOPNOTSUPP;
+   return wops->port_attr_bridge_flags_support_get(rocker_port,
+   p_brport_flags_support);
+}
+
 static int
 rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
unsigned long brport_flags,
struct switchdev_trans *trans)
 {
struct rocker_world_ops *wops = rocker_port->rocker->wops;
+   unsigned long brport_flags_s;
+   int err;
 
if (!wops->port_attr_bridge_flags_set)
return -EOPNOTSUPP;
 
-   if (switchdev_trans_ph_prepare(trans))
+   if (switchdev_trans_ph_prepare(trans)) {
+   err = 
rocker_world_port_attr_bridge_flags_support_get(rocker_port,
+ _flags_s);
+   if (err)
+   return err;
+
+   if (brport_flags & ~brport_flags_s)
+   return -EOPNOTSUPP;
return 0;
+   }
 
return wops->port_attr_bridge_flags_set(rocker_port, brport_flags,
trans);
@@ -1593,20 +1617,6 @@ rocker_world_port_attr_bridge_flags_get(const struct 
rocker_port *rocker_port,
return wops->port_attr_bridge_flags_get(rocker_port, p_brport_flags);
 }
 
-static int
-rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *
-   rocker_port,
-   unsigned long *
-   p_brport_flags_support)
-{
-   struct rocker_world_ops *wops = rocker_port->rocker->wops;
-
-   if (!wops->port_attr_bridge_flags_support_get)
-   return -EOPNOTSUPP;
-   return wops->port_attr_bridge_flags_support_get(rocker_port,
-   p_brport_flags_support);
-}
-
 static int
 rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
  u32 ageing_time,
-- 
2.17.1



[PATCH net-next 02/16] mlxsw: spectrum: Check bridge flags during prepare phase

2019-02-08 Thread Florian Fainelli
In preparation for getting rid of switchdev_port_attr_get(), have mlxsw
check for the bridge flags being set through switchdev_port_attr_set()
with the SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS attribute identifier.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 95e37de3e48f..468a6d513074 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -623,8 +623,11 @@ static int mlxsw_sp_port_attr_br_flags_set(struct 
mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_bridge_port *bridge_port;
int err;
 
-   if (switchdev_trans_ph_prepare(trans))
+   if (switchdev_trans_ph_prepare(trans)) {
+   if (brport_flags & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD))
+   return -EOPNOTSUPP;
return 0;
+   }
 
bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp_port->mlxsw_sp->bridge,
orig_dev);
-- 
2.17.1



[PATCH net-next 01/16] Documentation: networking: switchdev: Update port parent ID section

2019-02-08 Thread Florian Fainelli
Update the section about switchdev drivers having to implement a
switchdev_port_attr_get() function to return
SWITCHDEV_ATTR_ID_PORT_PARENT_ID since that is no longer valid after
commit bccb30254a4a ("net: Get rid of
SWITCHDEV_ATTR_ID_PORT_PARENT_ID").

Fixes: bccb30254a4a ("net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID")
Signed-off-by: Florian Fainelli 
---
 Documentation/networking/switchdev.txt | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/networking/switchdev.txt 
b/Documentation/networking/switchdev.txt
index f3244d87512a..2842f63ad47b 100644
--- a/Documentation/networking/switchdev.txt
+++ b/Documentation/networking/switchdev.txt
@@ -92,11 +92,11 @@ device.
 Switch ID
 ^
 
-The switchdev driver must implement the switchdev op switchdev_port_attr_get
-for SWITCHDEV_ATTR_ID_PORT_PARENT_ID for each port netdev, returning the same
-physical ID for each port of a switch.  The ID must be unique between switches
-on the same system.  The ID does not need to be unique between switches on
-different systems.
+The switchdev driver must implement the net_device operation
+ndo_get_port_parent_id for each port netdev,  returning the same physical ID
+for each port of a switch. The ID must be unique between switches on the same
+system. The ID does not need to be unique between switches on different
+systems.
 
 The switch ID is used to locate ports on a switch and to know if aggregated
 ports belong to the same switch.
-- 
2.17.1



[PATCH net-next 00/16] net: Remove switchdev_ops

2019-02-08 Thread Florian Fainelli
Hi all,

This patch series finishes by the removal of switchdev_ops. To get there
we need to do a few things:

- get rid of the one and only call to switchdev_port_attr_get() which is
  used to fetch the device's bridge port flags capabilities, instead we
  can just check what flags are being programmed during the prepare
  phase

- once we get rid of getting switchdev port attributes we convert the
  setting of such attributes using a blocking notifier

And then remove switchdev_ops completely.

Please review and let me know what you think!

Florian Fainelli (16):
  Documentation: networking: switchdev: Update port parent ID section
  mlxsw: spectrum: Check bridge flags during prepare phase
  staging: fsl-dpaa2: ethsw: Check bridge port flags during set
  net: dsa: Add setter for SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS
  rocker: Check bridge flags during prepare phase
  net: bridge: Stop calling switchdev_port_attr_get()
  net: Remove SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT
  net: Get rid of switchdev_port_attr_get()
  switchdev: Add SWITCHDEV_PORT_ATTR_SET
  rocker: Handle SWITCHDEV_PORT_ATTR_SET
  net: dsa: Handle SWITCHDEV_PORT_ATTR_SET
  mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET
  net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET
  staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET
  net: switchdev: Replace port attr set SDO with a notification
  net: Remove switchdev_ops

 Documentation/networking/switchdev.txt| 15 ++-
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 12 ---
 .../net/ethernet/mellanox/mlxsw/spectrum.h|  2 -
 .../mellanox/mlxsw/spectrum_switchdev.c   | 72 +-
 drivers/net/ethernet/mscc/ocelot.c| 25 -
 drivers/net/ethernet/rocker/rocker_main.c | 99 +--
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 52 +-
 include/linux/netdevice.h |  3 -
 include/net/switchdev.h   | 37 ++-
 net/bridge/br_switchdev.c | 20 +---
 net/dsa/dsa_priv.h|  3 +
 net/dsa/port.c| 10 ++
 net/dsa/slave.c   | 44 +
 net/switchdev/switchdev.c | 92 +
 14 files changed, 190 insertions(+), 296 deletions(-)

-- 
2.17.1



Re: [PATCH] LSM: Allow syzbot to ignore security= parameter.

2019-02-08 Thread Tetsuo Handa
On 2019/02/09 1:23, Casey Schaufler wrote:
> On 2/8/2019 2:52 AM, Tetsuo Handa wrote:
>> To help administrators easily understand what LSM modules are possibly 
>> enabled by default (which
>> have to be fetched from e.g. /boot/config-`uname -r`)
> 
> $ cat /sys/kernel/security/lsm
> 

/sys/kernel/security/lsm is list of "actually" enabled modules, isn't it?
What I want is "possibly" enabled modules. Ubuntu would chose from either

  (a) explicitly add security=apparmor to kernel command line

or

  (b) explicitly remove tomoyo from CONFIG_LSM at kernel config

in order not to enable TOMOYO for those who want to enable only one of 
SELinux/Smack/AppArmor. And for those who want to enable TOMOYO, I think
that (b) (in other words, add

  lsm="modules listed in CONFIG_LSM" + ",tomoyo"

) will retain compatibility when it becomes possible to enable more than
one of SELinux/Smack/AppArmor at the same time.

If we can know "possibly" enabled modules from dmesg, users don't need to
look at e.g. /boot/config-`uname -r`. It is not essential, but it's handy.



Re: [PATCH v8 0/3] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory

2019-02-08 Thread Masayoshi Mizuma
Hi Boris,

Thank you for your review.

On Fri, Feb 08, 2019 at 07:26:00PM +0100, Borislav Petkov wrote:
> On Tue, Feb 05, 2019 at 10:05:16AM -0500, Masayoshi Mizuma wrote:
> > From: Masayoshi Mizuma 
> > Date: Tue, 5 Feb 2019 10:00:59 -0500
> > Subject: [PATCH] x86/mm: Introduce adjustment the padding size for KASLR
> 
>   "Adjust the padding size for KASLR"
> 
> > If the physical memory layout has huge space for hotplug, the padding
> > used for the physical memory mapping section is not enough.
> > So, such system may crash while memory hot-adding on KASLR enabled system.
> 
> Crash why?
> 
> Why is the padding not enough?
> 
> > For example, SRAT has the following layout, the maximum possible memory
> > size is 32TB, and the memory is installed as 2TB actually, then the padding
> > size should set 30TB (== possible memory size - actual memory size).
> > 
> >   SRAT: Node 3 PXM 7 [mem 0x1c00-0x1fff] hotplug
> 
> What is that supposed to exemplify: that range is 3T not 2 and that
> range start is not at 2T but 28T. So I have absolutely no clue what
> you're trying to explain here.
> 
> Please go back, take your time and structure your commit message like
> this:
> 
> Problem is A.
> 
> It happens because of B.
> 
> Fix it by doing C.
> 
> (Potentially do D).
> 
> For more detailed info, see
> Documentation/process/submitting-patches.rst, Section "2) Describe your
> changes".

Got it, thanks.

> 
> > This patch introduces adjustment the padding size if the default
> 
> Avoid having "This patch" or "This commit" in the commit message. It is
> tautologically useless.
> 
> Also, do
> 
> $ git grep 'This patch' Documentation/process
> 
> for more details.

Thanks. I see.

> 
> > padding size isn't enough.
> > 
> > Signed-off-by: Masayoshi Mizuma 
> > ---
> >  Documentation/x86/zero-page.txt   |  1 +
> >  arch/x86/boot/compressed/acpi.c   | 19 +++
> >  arch/x86/include/uapi/asm/bootparam.h |  2 +-
> >  arch/x86/mm/kaslr.c   | 26 +-
> >  4 files changed, 42 insertions(+), 6 deletions(-)
> > 
> > diff --git a/Documentation/x86/zero-page.txt 
> > b/Documentation/x86/zero-page.txt
> > index 68aed077f..343fe1a90 100644
> > --- a/Documentation/x86/zero-page.txt
> > +++ b/Documentation/x86/zero-page.txt
> > @@ -15,6 +15,7 @@ OffsetProto   NameMeaning
> >  058/008ALL tboot_addr  Physical address of tboot shared page
> >  060/010ALL ist_infoIntel SpeedStep (IST) BIOS support 
> > information
> > (struct ist_info)
> > +078/010ALL possible_mem_addr The possible maximum physical memory 
> > address.
> 
> Why isn't this called max_phys_addr then?
> 
> Also, please explain what it means at the end of this file.
> 
> >  080/010ALL hd0_infohd0 disk parameter, OBSOLETE!!
> >  090/010ALL hd1_infohd1 disk parameter, OBSOLETE!!
> >  0A0/010ALL sys_desc_table  System description table (struct 
> > sys_desc_table),
> > diff --git a/arch/x86/boot/compressed/acpi.c 
> > b/arch/x86/boot/compressed/acpi.c
> > index c5a949335..7dd61b943 100644
> > --- a/arch/x86/boot/compressed/acpi.c
> > +++ b/arch/x86/boot/compressed/acpi.c
> > @@ -288,6 +288,7 @@ int count_immovable_mem_regions(void)
> > struct acpi_subtable_header *sub_table;
> > struct acpi_table_header *table_header;
> > char arg[MAX_ACPI_ARG_LENGTH];
> > +   unsigned long long possible_addr, max_possible_addr = 0;
> > int num = 0;
> >  
> > if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 &&
> > @@ -308,10 +309,19 @@ int count_immovable_mem_regions(void)
> > struct acpi_srat_mem_affinity *ma;
> >  
> > ma = (struct acpi_srat_mem_affinity *)sub_table;
> > -   if (!(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && 
> > ma->length) {
> > -   immovable_mem[num].start = ma->base_address;
> > -   immovable_mem[num].size = ma->length;
> > -   num++;
> > +   if (ma->length) {
> > +   if (ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) {
> > +   possible_addr =
> > +   ma->base_address + ma->length;
> > +   if (possible_addr > max_possible_addr)
> > +   max_possible_addr =
> > +   possible_addr;
> > +   } else {
> > +   immovable_mem[num].start =
> > +   ma->base_address;
> > +   immovable_mem[num].size = ma->length;
> > +   num++;
> > +   }
> 
> This piece has some ugly linebreaks which makes it impossible to read.
> Perhaps 

[PATCH v7 0/2] Amlogic Meson6/8/8b/8m2 SoC RTC driver

2019-02-08 Thread Martin Blumenstingl
This series adds support for the RTC on the 32-bit Amlogic Meson SoCs.

The series does not have any build dependencies, but does require
device-tree entries for the relevant boards.

The series is tested by myself on the Meson8b EC-100 board. Earlier
versions of this series were tested on an Odroid-C1 board with a
battery pack attached by Ben Dooks and Kevin Hilman.

I will send the DT changes in a second series so that they can be
merged once the dependencies have been satisfied.


Changes since v6 at [2]:
- added NVMEM_TYPE_BATTERY_BACKED (thanks to Alexandre Belloni for the
  hint)
- fixed dt-bindings description: #address-cells was duplicated but
  #size-cells was missing. While here also add these to the example.
  Spotted by Alexandre Belloni - thanks!

Changes since v5 at [1]:
- get rid of a dependency on the SZ_16 macro (fixes a kbuild test robot
  compile error)
- rebased on top of v5.0-rc1
- I kept the copyrights / author as in v4 because Ben didn't ask me to
  do it yet (please speak up if I should change it)

Changes since v4 at [0]:
- resurrected Ben's patches after 2 years: first I made it apply
  onto linux-next again
- I decided to update the author of the patch to my own name since I
  made a lot of changes compared to Ben's implementation (list of
  changes below, the diff-stat was: 223 insertions, 163 deletions)
- make the dt-bindings file name (rtc-meson.txt) match the driver name
- add a Meson8m2 compatible
- add the clocks and vdd-supply properties to the match the actual IP
  block implementation
- make the resets and interrupts properties mandatory to match the
  actual IP block implementation
- removed the status property from the dt-bindings example
- fix MODULE_LICENSE to match the actual license (GPL v2)
- switch to SPDX-License-Identifier
- sort the Kconfig option alphabetically
- use BIT() and GENMASK() macros consistenly
- replace #define RTC_REG(x) with actual #defines which match the names
  from the public S805 datasheet
- adjust existing #defines to align with the public S805 datasheet
- add support for the 4x32bit NVMEM (regmem) data
- implement regmap_bus to access the serial registers. this allows
  getting rid of the custom locking code and makes the NVMEM
  implementation much easier.
- use regmap also for accessing the peripheral registers to make the
  code shorter
- add support for the vdd-supply regulator
- switch from devm_rtc_device_register to devm_rtc_allocate_device and
  rtc_register_device
- set range_max to U32_MAX
- use rtc_time64_to_tm and rtc_tm_to_time64
- simplify timeout handling and use shorter timeouts (the driver from
  the 3.10 BSP kernel uses udelay resolution (100us after the reset, 5us
  for the "comm delay") as well as busy-looping from 0..4 to wait
  for "s_ready"
- removed debug messages which are only printing register values (as
  these can now be seen in
  /regmap/c8100740.rtc-peripheral-registers/registers)


[0] https://www.spinics.net/lists/devicetree/msg135413.html
[1] https://patchwork.ozlabs.org/cover/1006597/
[2] https://patchwork.ozlabs.org/cover/1027951/


Martin Blumenstingl (2):
  dt-bindings: rtc: add device-tree bindings for the Amlogic Meson RTC
  rtc: support for the Amlogic Meson RTC

 .../devicetree/bindings/rtc/rtc-meson.txt |  35 ++
 drivers/rtc/Kconfig   |  11 +
 drivers/rtc/Makefile  |   1 +
 drivers/rtc/rtc-meson.c   | 410 ++
 4 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-meson.txt
 create mode 100644 drivers/rtc/rtc-meson.c

-- 
2.20.1



Re: [PATCH v3 3/4] gpu: ipu-v3: ipu-ic: Add support for BT.709 encoding

2019-02-08 Thread Tim Harvey
On Fri, Feb 8, 2019 at 11:28 AM Steve Longerbeam  wrote:
>
> Pass v4l2 encoding enum to the ipu_ic task init functions, and add
> support for the BT.709 encoding and inverse encoding matrices.
>
> Reported-by: Tim Harvey 
> Signed-off-by: Steve Longerbeam 
> ---
> Changes in v2:
> - only return "Unsupported YCbCr encoding" error if inf != outf,
>   since if inf == outf, the identity matrix can be used. Reported
>   by Tim Harvey.
> ---
>  drivers/gpu/ipu-v3/ipu-ic.c | 71 +++--
>  drivers/gpu/ipu-v3/ipu-image-convert.c  |  1 +
>  drivers/staging/media/imx/imx-ic-prpencvf.c |  4 +-
>  include/video/imx-ipu-v3.h  |  5 +-
>  4 files changed, 71 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c
> index e459615a49a1..0d57ca7ba18e 100644
> --- a/drivers/gpu/ipu-v3/ipu-ic.c
> +++ b/drivers/gpu/ipu-v3/ipu-ic.c
> @@ -212,6 +212,23 @@ static const struct ic_csc_params ic_csc_identity = {
> .scale = 2,
>  };
>
> +/*
> + * BT.709 encoding from RGB full range to YUV limited range:
> + *
> + * Y = R *  .2126 + G *  .7152 + B *  .0722;
> + * U = R * -.1146 + G * -.3854 + B *  .5000 + 128.;
> + * V = R *  .5000 + G * -.4542 + B * -.0458 + 128.;
> + */
> +static const struct ic_csc_params ic_csc_rgb2ycbcr_bt709 = {
> +   .coeff = {
> +   { 54, 183, 18 },
> +   { 483, 413, 128 },
> +   { 128, 396, 500 },
> +   },
> +   .offset = { 0, 512, 512 },
> +   .scale = 1,
> +};
> +
>  /*
>   * Inverse BT.601 encoding from YUV limited range to RGB full range:
>   *
> @@ -229,12 +246,31 @@ static const struct ic_csc_params 
> ic_csc_ycbcr2rgb_bt601 = {
> .scale = 2,
>  };
>
> +/*
> + * Inverse BT.709 encoding from YUV limited range to RGB full range:
> + *
> + * R = (1. * (Y - 16)) + (1.5748 * (Cr - 128));
> + * G = (1. * (Y - 16)) - (0.1873 * (Cb - 128)) - (0.4681 * (Cr - 128));
> + * B = (1. * (Y - 16)) + (1.8556 * (Cb - 128);
> + */
> +static const struct ic_csc_params ic_csc_ycbcr2rgb_bt709 = {
> +   .coeff = {
> +   { 128, 0, 202 },
> +   { 128, 488, 452 },
> +   { 128, 238, 0 },
> +   },
> +   .offset = { -435, 136, -507 },
> +   .scale = 2,
> +};
> +
>  static int init_csc(struct ipu_ic *ic,
> enum ipu_color_space inf,
> enum ipu_color_space outf,
> +   enum v4l2_ycbcr_encoding encoding,
> int csc_index)
>  {
> struct ipu_ic_priv *priv = ic->priv;
> +   const struct ic_csc_params *params_rgb2yuv, *params_yuv2rgb;
> const struct ic_csc_params *params;
> u32 __iomem *base;
> const u16 (*c)[3];
> @@ -244,12 +280,30 @@ static int init_csc(struct ipu_ic *ic,
> base = (u32 __iomem *)
> (priv->tpmem_base + ic->reg->tpmem_csc[csc_index]);
>
> +   switch (encoding) {
> +   case V4L2_YCBCR_ENC_601:
> +   params_rgb2yuv =  _csc_rgb2ycbcr_bt601;
> +   params_yuv2rgb = _csc_ycbcr2rgb_bt601;
> +   break;
> +   case V4L2_YCBCR_ENC_709:
> +   params_rgb2yuv =  _csc_rgb2ycbcr_bt709;
> +   params_yuv2rgb = _csc_ycbcr2rgb_bt709;
> +   break;
> +   default:
> +   if (inf != outf) {
> +   dev_err(priv->ipu->dev,
> +   "Unsupported YCbCr encoding\n");
> +   return -EINVAL;
> +   }
> +   break;
> +   }
> +
> if (inf == outf)
> params = _csc_identity;
> else if (inf == IPUV3_COLORSPACE_YUV)
> -   params = _csc_ycbcr2rgb_bt601;
> +   params = _csc_ycbcr2rgb;


Steve,

compile issue...

params = params_yuv2rgb;

> else
> -   params = _csc_rgb2ycbcr_bt601;
> +   params = _csc_rgb2ycbcr;

params = params_rgb2yuv;

But, I'm still failing when using the mem2mem element (gst-launch-1.0
v4l2src device=/dev/video4 ! v4l2video8convert
output-io-mode=dmabuf-import ! fbdevsink) with 'Unsupported YCbCr
encoding' because of inf=IPU_COLORSPACE_YCBCR outf=IPU_COLORSPACE_RGB
and a seemingly unset encoding being passed in.

It looks like maybe something in the mem2mem driver isn't defaulting
encoding. The call path is (v4l2_m2m_streamon -> device_run ->
ipu_image_convert_queue -> convert_start -> ipu_ic_task_init_rsc ->
init_csc).

Tim


[PATCH v7 2/2] rtc: support for the Amlogic Meson RTC

2019-02-08 Thread Martin Blumenstingl
Add support for the RTC block on the 32-bit Amlogic Meson6, Meson8,
Meson8b and Meson8m2 SoCs.

The RTC is split in to two parts, which are both managed by this driver:
- the AHB front end
- and a simple serial connection to the actual registers

The RTC_COUNTER register which holds the time is 32-bits wide.

There are four 32-bit wide (in total: 16 bytes) "regmem" registers which
are exposed using nvmem. On Amlogic's 3.10 kernel this is used to store
data which needs to survive a suspend / resume cycle.

Signed-off-by: Ben Dooks 
[resurrected Ben's patches after 2 years]
Signed-off-by: Martin Blumenstingl 
---
 drivers/rtc/Kconfig |  11 ++
 drivers/rtc/Makefile|   1 +
 drivers/rtc/rtc-meson.c | 410 
 3 files changed, 422 insertions(+)
 create mode 100644 drivers/rtc/rtc-meson.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 225b0b8516f3..7f10e5e5ce05 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1285,6 +1285,17 @@ config RTC_DRV_IMXDI
   This driver can also be built as a module, if so, the module
   will be called "rtc-imxdi".
 
+config RTC_DRV_MESON
+   tristate "Amlogic Meson RTC"
+   depends on (ARM && ARCH_MESON) || COMPILE_TEST
+   select REGMAP_MMIO
+   help
+  Support for the RTC block on the Amlogic Meson6, Meson8, Meson8b
+  and Meson8m2 SoCs.
+
+  This driver can also be built as a module, if so, the module
+  will be called "rtc-meson".
+
 config RTC_DRV_OMAP
tristate "TI OMAP Real Time Clock"
depends on ARCH_OMAP || ARCH_DAVINCI || COMPILE_TEST
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index df022d820bee..cf02a5c7a38b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -100,6 +100,7 @@ obj-$(CONFIG_RTC_DRV_MAX8997)   += rtc-max8997.o
 obj-$(CONFIG_RTC_DRV_MAX8998)  += rtc-max8998.o
 obj-$(CONFIG_RTC_DRV_MC13XXX)  += rtc-mc13xxx.o
 obj-$(CONFIG_RTC_DRV_MCP795)   += rtc-mcp795.o
+obj-$(CONFIG_RTC_DRV_MESON)+= rtc-meson.o
 obj-$(CONFIG_RTC_DRV_MOXART)   += rtc-moxart.o
 obj-$(CONFIG_RTC_DRV_MPC5121)  += rtc-mpc5121.o
 obj-$(CONFIG_RTC_DRV_MSM6242)  += rtc-msm6242.o
diff --git a/drivers/rtc/rtc-meson.c b/drivers/rtc/rtc-meson.c
new file mode 100644
index ..6fc4b09e7ebd
--- /dev/null
+++ b/drivers/rtc/rtc-meson.c
@@ -0,0 +1,410 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * RTC driver for the interal RTC block in the Amlogic Meson6, Meson8,
+ * Meson8b and Meson8m2 SoCs.
+ *
+ * The RTC is split in to two parts, the AHB front end and a simple serial
+ * connection to the actual registers. This driver manages both parts.
+ *
+ * Copyright (c) 2018 Martin Blumenstingl 
+ * Copyright (c) 2015 Ben Dooks  for Codethink Ltd
+ * Based on origin by Carlo Caione 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* registers accessed from cpu bus */
+#define RTC_ADDR0  0x00
+   #define RTC_ADDR0_LINE_SCLK BIT(0)
+   #define RTC_ADDR0_LINE_SEN  BIT(1)
+   #define RTC_ADDR0_LINE_SDI  BIT(2)
+   #define RTC_ADDR0_START_SER BIT(17)
+   #define RTC_ADDR0_WAIT_SER  BIT(22)
+   #define RTC_ADDR0_DATA  GENMASK(31, 24)
+
+#define RTC_ADDR1  0x04
+   #define RTC_ADDR1_SDO   BIT(0)
+   #define RTC_ADDR1_S_READY   BIT(1)
+
+#define RTC_ADDR2  0x08
+#define RTC_ADDR3  0x0c
+
+#define RTC_REG4   0x10
+   #define RTC_REG4_STATIC_VALUE   GENMASK(7, 0)
+
+/* rtc registers accessed via rtc-serial interface */
+#define RTC_COUNTER(0)
+#define RTC_SEC_ADJ(2)
+#define RTC_REGMEM_0   (4)
+#define RTC_REGMEM_1   (5)
+#define RTC_REGMEM_2   (6)
+#define RTC_REGMEM_3   (7)
+
+#define RTC_ADDR_BITS  (3) /* number of address bits to send */
+#define RTC_DATA_BITS  (32)/* number of data bits to tx/rx */
+
+#define MESON_STATIC_BIAS_CUR  (0x5 << 1)
+#define MESON_STATIC_VOLTAGE   (0x3 << 11)
+#define MESON_STATIC_DEFAULT(MESON_STATIC_BIAS_CUR | MESON_STATIC_VOLTAGE)
+
+struct meson_rtc {
+   struct rtc_device   *rtc;   /* rtc device we created */
+   struct device   *dev;   /* device we bound from */
+   struct reset_control*reset; /* reset source */
+   struct regulator*vdd;   /* voltage input */
+   struct regmap   *peripheral;/* peripheral registers */
+   struct regmap   *serial;/* serial registers */
+};
+
+static const struct regmap_config meson_rtc_peripheral_regmap_config = {
+   .name   = "peripheral-registers",
+   .reg_bits   = 8,
+   

[PATCH v7 1/2] dt-bindings: rtc: add device-tree bindings for the Amlogic Meson RTC

2019-02-08 Thread Martin Blumenstingl
The 32-bit Amlogic Meson SoCs (Meson6, Meson8, Meson8b and Meson8m2)
have a built-in RTC block.
It has the following inputs:
- an 32.768kHz crystal oscillator
- an interrupt line
- a reset line
- 0.9V voltage input

Signed-off-by: Ben Dooks 
[resurrected patches from Ben after 2 years]
Signed-off-by: Martin Blumenstingl 
---
 .../devicetree/bindings/rtc/rtc-meson.txt | 35 +++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-meson.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-meson.txt 
b/Documentation/devicetree/bindings/rtc/rtc-meson.txt
new file mode 100644
index ..e921fe66a362
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-meson.txt
@@ -0,0 +1,35 @@
+* Amlogic Meson6, Meson8, Meson8b and Meson8m2 RTC
+
+Required properties:
+- compatible: should be one of the following describing the hardware:
+   * "amlogic,meson6-rtc"
+   * "amlogic,meson8-rtc"
+   * "amlogic,meson8b-rtc"
+   * "amlogic,meson8m2-rtc"
+
+- reg: physical register space for the controller's memory mapped registers.
+- interrupts: the interrupt line of the RTC block.
+- clocks: reference to the external 32.768kHz crystal oscillator.
+- vdd-supply: reference to the power supply of the RTC block.
+- resets: reset controller reference to allow reset of the controller
+
+Optional properties for the battery-backed non-volatile memory:
+- #address-cells: should be 1 to address the battery-backed non-volatile memory
+- #size-cells: should be 1 to reference the battery-backed non-volatile memory
+
+Optional child nodes:
+- see ../nvmem/nvmem.txt
+
+Example:
+
+   rtc: rtc@740 {
+   compatible = "amlogic,meson6-rtc";
+   reg = <0x740 0x14>;
+   interrupts = ;
+   clocks = <_xtal>;
+   vdd-supply = <_vdd>;
+   resets = < RESET_RTC>;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+   };
-- 
2.20.1



  1   2   3   4   5   6   7   8   9   10   >