Re: [PATCH v3 0/4] powerpc: trivial unused functions cleanup

2015-03-20 Thread Arseny Solokha
> On Fri, 2015-03-20 at 11:55 +0700, Arseny Solokha wrote:
>> 
>> And by the way, while revisiting the series I've noticed that though the 
>> patch
>> 4/4 basically reverts [1], it leaves
>> 
>>   #define MPIC_GREG_GLOBAL_CONF_10x00030
>> 
>> in arch/powerpc/include/asm/mpic.h untouched. That define also loses its uses
>> after applying the patch. Compare the following hunk in today's patch w/ the 
>> one
>> you committed:
>> 
>>   @@ -33,11 +33,6 @@
>>#define   MPIC_GREG_GCONF_NO_BIAS 0x1000
>>#define   MPIC_GREG_GCONF_BASE_MASK   0x000f
>>#define   MPIC_GREG_GCONF_MCK 0x0800
>>   -#define MPIC_GREG_GLOBAL_CONF_1   0x00030
>>   -#define   MPIC_GREG_GLOBAL_CONF_1_SIE 0x0800
>>   -#define   MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK  0x7000
>>   -#define   MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO(r)\
>>   -  (((r) << 28) & MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK)
>>#define MPIC_GREG_VENDOR_00x00040
>>#define MPIC_GREG_VENDOR_10x00050
>>#define MPIC_GREG_VENDOR_20x00060
>> 
>> So the question is, should #define MPIC_GREG_GLOBAL_CONF_1 have been also
>> removed, or could be left as is?
>> 
>> [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2006-June/023867.html
>
>
> OK, thanks for the thoroughness.
>
> With #defines like that it's never clear if they should be removed or not. On
> the one hand it's not used, so it should be removed. But, it can be useful to
> keep the #defines there as documentation.
>
> So I'm 50/50 on it. If you send me a patch to remove it I'll merge it, unless
> someone else objects.

So I'd abstain from removing it, for whatever it may be worth. Let it serve the
documentation purposes.

Arsény

> cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/4] kvm/ppc/mpic: drop unused IRQ_testbit

2015-03-20 Thread Arseny Solokha
Drop unused static procedure which doesn't have callers within its
translation unit. It had been already removed independently in QEMU[1]
from the OpenPIC implementation borrowed by the kernel.

[1] https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg01812.html

v4: Fixed the comment regarding the origination of OpenPIC codebase
and CC'ed KVM mailing lists, as suggested by Alexander Graf.

v3: In patch 4/4, do not remove fsl_mpic_primary_get_version() from
arch/powerpc/sysdev/mpic.c because the patch by Jia Hongtao
("powerpc/85xx: workaround for chips with MSI hardware errata") makes
use of it.

v2: Added a brief explanation to each patch description of why removed
functions are unused, as suggested by Michael Ellerman.

Signed-off-by: Arseny Solokha 
---
 arch/powerpc/kvm/mpic.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/powerpc/kvm/mpic.c b/arch/powerpc/kvm/mpic.c
index 39b3a8f..a480d99 100644
--- a/arch/powerpc/kvm/mpic.c
+++ b/arch/powerpc/kvm/mpic.c
@@ -289,11 +289,6 @@ static inline void IRQ_resetbit(struct irq_queue *q, int 
n_IRQ)
clear_bit(n_IRQ, q->queue);
 }
 
-static inline int IRQ_testbit(struct irq_queue *q, int n_IRQ)
-{
-   return test_bit(n_IRQ, q->queue);
-}
-
 static void IRQ_check(struct openpic *opp, struct irq_queue *q)
 {
int irq = -1;
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 07/13] clk: qcom: Add MSM8960/APQ8064's HFPLLs

2015-03-20 Thread Stephen Boyd
Describe the HFPLLs present on MSM8960 and APQ8064 devices.

Signed-off-by: Stephen Boyd 
---
 drivers/clk/qcom/gcc-msm8960.c   | 172 +++
 include/dt-bindings/clock/qcom,gcc-msm8960.h |   2 +
 2 files changed, 174 insertions(+)

diff --git a/drivers/clk/qcom/gcc-msm8960.c b/drivers/clk/qcom/gcc-msm8960.c
index b0b562b9ce0e..0cd3e26f9995 100644
--- a/drivers/clk/qcom/gcc-msm8960.c
+++ b/drivers/clk/qcom/gcc-msm8960.c
@@ -30,6 +30,7 @@
 #include "clk-pll.h"
 #include "clk-rcg.h"
 #include "clk-branch.h"
+#include "clk-hfpll.h"
 #include "reset.h"
 
 static struct clk_pll pll3 = {
@@ -75,6 +76,164 @@ static struct clk_regmap pll8_vote = {
},
 };
 
+static struct hfpll_data hfpll0_data = {
+   .mode_reg = 0x3200,
+   .l_reg = 0x3208,
+   .m_reg = 0x320c,
+   .n_reg = 0x3210,
+   .config_reg = 0x3204,
+   .status_reg = 0x321c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3214,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll0 = {
+   .d = &hfpll0_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll0",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll0.lock),
+};
+
+static struct hfpll_data hfpll1_8064_data = {
+   .mode_reg = 0x3240,
+   .l_reg = 0x3248,
+   .m_reg = 0x324c,
+   .n_reg = 0x3250,
+   .config_reg = 0x3244,
+   .status_reg = 0x325c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3254,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct hfpll_data hfpll1_data = {
+   .mode_reg = 0x3300,
+   .l_reg = 0x3308,
+   .m_reg = 0x330c,
+   .n_reg = 0x3310,
+   .config_reg = 0x3304,
+   .status_reg = 0x331c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3314,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll1 = {
+   .d = &hfpll1_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll1",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll1.lock),
+};
+
+static struct hfpll_data hfpll2_data = {
+   .mode_reg = 0x3280,
+   .l_reg = 0x3288,
+   .m_reg = 0x328c,
+   .n_reg = 0x3290,
+   .config_reg = 0x3284,
+   .status_reg = 0x329c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3294,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll2 = {
+   .d = &hfpll2_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll2",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll2.lock),
+};
+
+static struct hfpll_data hfpll3_data = {
+   .mode_reg = 0x32c0,
+   .l_reg = 0x32c8,
+   .m_reg = 0x32cc,
+   .n_reg = 0x32d0,
+   .config_reg = 0x32c4,
+   .status_reg = 0x32dc,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x32d4,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll3 = {
+   .d = &hfpll3_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll3",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll3.lock),
+};
+
+static struct hfpll_data hfpll_l2_8064_data = {
+   .mode_reg = 0x3300,
+   .l_reg = 0x3308,
+   .m_reg = 0x330c,
+   .n_reg = 0x3310,
+   .config_reg = 0x3304,
+   .status_reg = 0x331c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3314,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct hfpll_data hfpll_l2_data = {
+   .mode_reg = 0x3400,
+   .l_reg = 0x3408,
+   .m_reg = 0x340c,
+   .n_reg = 0x3410,
+   .config_reg = 0x3404,
+   .status_reg = 0x341c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3414,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll_l2 = {
+   .d = &hfpll_l2_data,
+   .clkr.hw.init = &(struct clk_init_d

[PATCH v3 01/13] ARM: Add Krait L2 register accessor functions

2015-03-20 Thread Stephen Boyd
Krait CPUs have a handful of L2 cache controller registers that
live behind a cp15 based indirection register. First you program
the indirection register (l2cpselr) to point the L2 'window'
register (l2cpdr) at what you want to read/write.  Then you
read/write the 'window' register to do what you want. The
l2cpselr register is not banked per-cpu so we must lock around
accesses to it to prevent other CPUs from re-pointing l2cpdr
underneath us.

Cc: Mark Rutland 
Cc: Russell King 
Cc: Courtney Cavin 
Signed-off-by: Stephen Boyd 
---
 arch/arm/common/Kconfig   |  3 ++
 arch/arm/common/Makefile  |  1 +
 arch/arm/common/krait-l2-accessors.c  | 58 +++
 arch/arm/include/asm/krait-l2-accessors.h | 20 +++
 4 files changed, 82 insertions(+)
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h

diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index c3a4e9ceba34..9da52dc6260b 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -9,6 +9,9 @@ config DMABOUNCE
bool
select ZONE_DMA
 
+config KRAIT_L2_ACCESSORS
+   bool
+
 config SHARP_LOCOMO
bool
 
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index 70b1eff477b3..6b2cddf6e8d0 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -7,6 +7,7 @@ obj-y   += firmware.o
 obj-$(CONFIG_ICST) += icst.o
 obj-$(CONFIG_SA)   += sa.o
 obj-$(CONFIG_DMABOUNCE)+= dmabounce.o
+obj-$(CONFIG_KRAIT_L2_ACCESSORS) += krait-l2-accessors.o
 obj-$(CONFIG_SHARP_LOCOMO) += locomo.o
 obj-$(CONFIG_SHARP_PARAM)  += sharpsl_param.o
 obj-$(CONFIG_SHARP_SCOOP)  += scoop.o
diff --git a/arch/arm/common/krait-l2-accessors.c 
b/arch/arm/common/krait-l2-accessors.c
new file mode 100644
index ..5d514bbc88a6
--- /dev/null
+++ b/arch/arm/common/krait-l2-accessors.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+
+static DEFINE_RAW_SPINLOCK(krait_l2_lock);
+
+void krait_set_l2_indirect_reg(u32 addr, u32 val)
+{
+   unsigned long flags;
+
+   raw_spin_lock_irqsave(&krait_l2_lock, flags);
+   /*
+* Select the L2 window by poking l2cpselr, then write to the window
+* via l2cpdr.
+*/
+   asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr));
+   isb();
+   asm volatile ("mcr p15, 3, %0, c15, c0, 7 @ l2cpdr" : : "r" (val));
+   isb();
+
+   raw_spin_unlock_irqrestore(&krait_l2_lock, flags);
+}
+EXPORT_SYMBOL(krait_set_l2_indirect_reg);
+
+u32 krait_get_l2_indirect_reg(u32 addr)
+{
+   u32 val;
+   unsigned long flags;
+
+   raw_spin_lock_irqsave(&krait_l2_lock, flags);
+   /*
+* Select the L2 window by poking l2cpselr, then read from the window
+* via l2cpdr.
+*/
+   asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr));
+   isb();
+   asm volatile ("mrc p15, 3, %0, c15, c0, 7 @ l2cpdr" : "=r" (val));
+
+   raw_spin_unlock_irqrestore(&krait_l2_lock, flags);
+
+   return val;
+}
+EXPORT_SYMBOL(krait_get_l2_indirect_reg);
diff --git a/arch/arm/include/asm/krait-l2-accessors.h 
b/arch/arm/include/asm/krait-l2-accessors.h
new file mode 100644
index ..48fe5527bc01
--- /dev/null
+++ b/arch/arm/include/asm/krait-l2-accessors.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ASMARM_KRAIT_L2_ACCESSORS_H
+#define __ASMARM_KRAIT_L2_ACCESSORS_H
+
+extern void krait_set_l2_indirect_reg(u32 addr, u32 val);
+extern u32 krait_get_l2_indirect_reg(u32 addr);
+
+#endif
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message

[PATCH v3 11/13] clk: qcom: Add Krait clock controller driver

2015-03-20 Thread Stephen Boyd
The Krait CPU clocks are made up of a primary mux and secondary
mux for each CPU and the L2, controlled via cp15 accessors. For
Kraits within KPSSv1 each secondary mux accepts a different aux
source, but on KPSSv2 each secondary mux accepts the same aux
source.

Cc: 
Signed-off-by: Stephen Boyd 
---
 .../devicetree/bindings/clock/qcom,krait-cc.txt|  22 ++
 drivers/clk/qcom/Kconfig   |   8 +
 drivers/clk/qcom/Makefile  |   1 +
 drivers/clk/qcom/krait-cc.c| 352 +
 4 files changed, 383 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
 create mode 100644 drivers/clk/qcom/krait-cc.c

diff --git a/Documentation/devicetree/bindings/clock/qcom,krait-cc.txt 
b/Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
new file mode 100644
index ..874138f88ec6
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
@@ -0,0 +1,22 @@
+Krait Clock Controller
+
+PROPERTIES
+
+- compatible:
+   Usage: required
+   Value type: 
+   Definition: must be one of:
+   "qcom,krait-cc-v1"
+   "qcom,krait-cc-v2"
+
+- #clock-cells:
+   Usage: required
+   Value type: 
+   Definition: must be 1
+
+Example:
+
+   kraitcc: clock-controller {
+   compatible = "qcom,krait-cc-v1";
+   #clock-cells = <1>;
+   };
diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 92eb883533d5..6de898c366ff 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -105,6 +105,14 @@ config KPSS_XCC
  if you want to support CPU frequency scaling on devices such
  as MSM8960, APQ8064, etc.
 
+config KRAITCC
+   tristate "Krait Clock Controller"
+   depends on COMMON_CLK_QCOM && ARM
+   select KRAIT_CLOCKS
+   help
+ Support for the Krait CPU clocks on Qualcomm devices.
+ Say Y if you want to support CPU frequency scaling.
+
 config KRAIT_CLOCKS
bool
select KRAIT_L2_ACCESSORS
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 6327dd623773..2477ce687208 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
 obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
 obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
 obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
+obj-$(CONFIG_KRAITCC) += krait-cc.o
diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c
new file mode 100644
index ..f55b5ecd0df8
--- /dev/null
+++ b/drivers/clk/qcom/krait-cc.c
@@ -0,0 +1,352 @@
+/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk-krait.h"
+
+static unsigned int sec_mux_map[] = {
+   2,
+   0,
+};
+
+static unsigned int pri_mux_map[] = {
+   1,
+   2,
+   0,
+};
+
+static int
+krait_add_div(struct device *dev, int id, const char *s, unsigned offset)
+{
+   struct krait_div2_clk *div;
+   struct clk_init_data init = {
+   .num_parents = 1,
+   .ops = &krait_div2_clk_ops,
+   .flags = CLK_SET_RATE_PARENT,
+   };
+   const char *p_names[1];
+   struct clk *clk;
+
+   div = devm_kzalloc(dev, sizeof(*div), GFP_KERNEL);
+   if (!div)
+   return -ENOMEM;
+
+   div->width = 2;
+   div->shift = 6;
+   div->lpl = id >= 0;
+   div->offset = offset;
+   div->hw.init = &init;
+
+   init.name = kasprintf(GFP_KERNEL, "hfpll%s_div", s);
+   if (!init.name)
+   return -ENOMEM;
+
+   init.parent_names = p_names;
+   p_names[0] = kasprintf(GFP_KERNEL, "hfpll%s", s);
+   if (!p_names[0]) {
+   kfree(init.name);
+   return -ENOMEM;
+   }
+
+   clk = devm_clk_register(dev, &div->hw);
+   kfree(p_names[0]);
+   kfree(init.name);
+
+   return PTR_ERR_OR_ZERO(clk);
+}
+
+static int
+krait_add_sec_mux(struct device *dev, int id, const char *s, unsigned offset,
+ bool unique_aux)
+{
+   struct krait_mux_clk *mux;
+   static const char *sec_mux_list[] = {
+   "acpu_aux",
+   "qsb",
+   };
+   struct clk_init_data init = {
+   .parent_names = sec_mux_list,
+   .num_parents 

[PATCH v3 02/13] clk: mux: Split out register accessors for reuse

2015-03-20 Thread Stephen Boyd
We want to reuse the logic in clk-mux.c for other clock drivers
that don't use readl as register accessors. Fortunately, there
really isn't much to the mux code besides the table indirection
and quirk flags if you assume any bit shifting and masking has
been done already. Pull that logic out into reusable functions
that operate on an optional table and some flags so that other
drivers can use the same logic.

Signed-off-by: Stephen Boyd 
---
 drivers/clk/clk-mux.c| 76 +++-
 include/linux/clk-provider.h |  9 --
 2 files changed, 54 insertions(+), 31 deletions(-)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 69a094c3783d..70a05c7f0fb1 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -29,35 +29,24 @@
 
 #define to_clk_mux(_hw) container_of(_hw, struct clk_mux, hw)
 
-static u8 clk_mux_get_parent(struct clk_hw *hw)
+unsigned int clk_mux_get_parent(struct clk_hw *hw, unsigned int val,
+   unsigned int *table, unsigned long flags)
 {
-   struct clk_mux *mux = to_clk_mux(hw);
int num_parents = __clk_get_num_parents(hw->clk);
-   u32 val;
 
-   /*
-* FIXME need a mux-specific flag to determine if val is bitwise or 
numeric
-* e.g. sys_clkin_ck's clksel field is 3 bits wide, but ranges from 0x1
-* to 0x7 (index starts at one)
-* OTOH, pmd_trace_clk_mux_ck uses a separate bit for each clock, so
-* val = 0x4 really means "bit 2, index starts at bit 0"
-*/
-   val = clk_readl(mux->reg) >> mux->shift;
-   val &= mux->mask;
-
-   if (mux->table) {
+   if (table) {
int i;
 
for (i = 0; i < num_parents; i++)
-   if (mux->table[i] == val)
+   if (table[i] == val)
return i;
return -EINVAL;
}
 
-   if (val && (mux->flags & CLK_MUX_INDEX_BIT))
+   if (val && (flags & CLK_MUX_INDEX_BIT))
val = ffs(val) - 1;
 
-   if (val && (mux->flags & CLK_MUX_INDEX_ONE))
+   if (val && (flags & CLK_MUX_INDEX_ONE))
val--;
 
if (val >= num_parents)
@@ -65,24 +54,53 @@ static u8 clk_mux_get_parent(struct clk_hw *hw)
 
return val;
 }
+EXPORT_SYMBOL_GPL(clk_mux_get_parent);
 
-static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
+static u8 _clk_mux_get_parent(struct clk_hw *hw)
 {
struct clk_mux *mux = to_clk_mux(hw);
u32 val;
-   unsigned long flags = 0;
 
-   if (mux->table)
-   index = mux->table[index];
+   /*
+* FIXME need a mux-specific flag to determine if val is bitwise or 
numeric
+* e.g. sys_clkin_ck's clksel field is 3 bits wide, but ranges from 0x1
+* to 0x7 (index starts at one)
+* OTOH, pmd_trace_clk_mux_ck uses a separate bit for each clock, so
+* val = 0x4 really means "bit 2, index starts at bit 0"
+*/
+   val = clk_readl(mux->reg) >> mux->shift;
+   val &= mux->mask;
+
+   return clk_mux_get_parent(hw, val, mux->table, mux->flags);
+}
 
-   else {
-   if (mux->flags & CLK_MUX_INDEX_BIT)
-   index = 1 << index;
+unsigned int clk_mux_reindex(u8 index, unsigned int *table,
+unsigned long flags)
+{
+   unsigned int val = index;
 
-   if (mux->flags & CLK_MUX_INDEX_ONE)
-   index++;
+   if (table) {
+   val = table[val];
+   } else {
+   if (flags & CLK_MUX_INDEX_BIT)
+   val = 1 << index;
+
+   if (flags & CLK_MUX_INDEX_ONE)
+   val++;
}
 
+   return val;
+}
+EXPORT_SYMBOL_GPL(clk_mux_reindex);
+
+static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+   struct clk_mux *mux = to_clk_mux(hw);
+   u32 val;
+   unsigned long flags = 0;
+
+   index = clk_mux_reindex(index, mux->table, mux->flags);
+
if (mux->lock)
spin_lock_irqsave(mux->lock, flags);
 
@@ -102,21 +120,21 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
 }
 
 const struct clk_ops clk_mux_ops = {
-   .get_parent = clk_mux_get_parent,
+   .get_parent = _clk_mux_get_parent,
.set_parent = clk_mux_set_parent,
.determine_rate = __clk_mux_determine_rate,
 };
 EXPORT_SYMBOL_GPL(clk_mux_ops);
 
 const struct clk_ops clk_mux_ro_ops = {
-   .get_parent = clk_mux_get_parent,
+   .get_parent = _clk_mux_get_parent,
 };
 EXPORT_SYMBOL_GPL(clk_mux_ro_ops);
 
 struct clk *clk_register_mux_table(struct device *dev, const char *name,
const char **parent_names, u8 num_parents, unsigned long flags,
void __iomem *reg, u8 shift, u32 mask,
-   u8 clk_mux_flags, u32 *table, spinlock_t *lock)
+   u8 clk_mux_flags, unsigned int *table, spinlock_t *lock)
 {
stru

[PATCH v3 13/13] ARM: dts: qcom: Add necessary DT data for Krait cpufreq

2015-03-20 Thread Stephen Boyd
Add the necessary DT nodes and data so we can probe the cpufreq
driver on MSM devices with Krait CPUs.

Signed-off-by: Stephen Boyd 
---
 arch/arm/boot/dts/qcom-apq8064.dtsi | 230 ++
 arch/arm/boot/dts/qcom-msm8960.dtsi |  49 ++
 arch/arm/boot/dts/qcom-msm8974.dtsi | 311 +++-
 3 files changed, 586 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi 
b/arch/arm/boot/dts/qcom-apq8064.dtsi
index b3154c071652..a97cbec75abe 100644
--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
@@ -23,6 +23,9 @@
next-level-cache = <&L2>;
qcom,acc = <&acc0>;
qcom,saw = <&saw0>;
+   clocks = <&kraitcc 0>;
+   clock-names = "cpu";
+   clock-latency = <10>;
};
 
cpu@1 {
@@ -33,6 +36,9 @@
next-level-cache = <&L2>;
qcom,acc = <&acc1>;
qcom,saw = <&saw1>;
+   clocks = <&kraitcc 1>;
+   clock-names = "cpu";
+   clock-latency = <10>;
};
 
cpu@2 {
@@ -43,6 +49,9 @@
next-level-cache = <&L2>;
qcom,acc = <&acc2>;
qcom,saw = <&saw2>;
+   clocks = <&kraitcc 2>;
+   clock-names = "cpu";
+   clock-latency = <10>;
};
 
cpu@3 {
@@ -53,6 +62,9 @@
next-level-cache = <&L2>;
qcom,acc = <&acc3>;
qcom,saw = <&saw3>;
+   clocks = <&kraitcc 3>;
+   clock-names = "cpu";
+   clock-latency = <10>;
};
 
L2: l2-cache {
@@ -66,6 +78,214 @@
interrupts = <1 10 0x304>;
};
 
+   qcom,pvs {
+   qcom,pvs-format-a;
+   qcom,speed0-pvs0-bin-v0 =
+   < 38400 95  >,
+   < 48600 975000  >,
+   < 59400 100  >,
+   < 70200 1025000  >,
+   < 81000 1075000  >,
+   < 91800 110  >;
+
+   qcom,speed0-pvs1-bin-v0 =
+   < 38400 90  >,
+   < 48600 925000  >,
+   < 59400 95  >,
+   < 70200 975000  >,
+   < 81000 1025000  >,
+   < 91800 105  >;
+
+   qcom,speed0-pvs3-bin-v0 =
+   < 38400 85  >,
+   < 48600 875000  >,
+   < 59400 90  >,
+   < 70200 925000  >,
+   < 81000 975000  >,
+   < 91800 100  >;
+
+   qcom,speed0-pvs4-bin-v0 =
+   < 38400 85  >,
+   < 48600 875000  >,
+   < 59400 90  >,
+   < 70200 925000  >,
+   < 81000 962500  >,
+   < 91800 975000  >;
+
+   qcom,speed1-pvs0-bin-v0 =
+   < 38400 95  >,
+   < 48600 95  >,
+   < 59400 95  >,
+   < 70200 962500  >,
+   < 81000 100  >,
+   < 91800 1025000  >;
+
+   qcom,speed1-pvs1-bin-v0 =
+   < 38400 95  >,
+   < 48600 95  >,
+   < 59400 95  >,
+   < 70200 962500  >,
+   < 81000 975000  >,
+   < 91800 100  >;
+
+   qcom,speed1-pvs2-bin-v0 =
+   < 38400 925000  >,
+   < 48600 925000  >,
+   < 59400 925000  >,
+   < 70200 925000  >,
+   < 81000 937500  >,
+   < 91800 95  >;
+
+   qcom,speed1-pvs3-bin-v0 =
+   < 38400 90  >,
+   < 48600 90  >,
+   < 59400 90  >,
+   < 70200 90  >,
+   < 81000 90  >,
+   < 91800 925000  >;
+
+   qcom,speed1-pvs4-bin-v0 =
+   < 38400 875000  >,
+   < 48600 875000  >,
+   < 59400 875000  >,
+   < 70200 875000  >,
+   < 81000 8875

[PATCH v3 04/13] clk: Add safe switch hook

2015-03-20 Thread Stephen Boyd
Sometimes clocks can't accept their parent source turning off
while the source is reprogrammed to a different rate. Most
notably CPU clocks require a way to switch away from the current
PLL they're running on, reprogram that PLL to a new rate, and
then switch back to the PLL with the new rate once they're done.
Add a hook that drivers can implement allowing them to return a
'safe parent' that they can switch their parent to while the
upstream source is reprogrammed to support this.

Signed-off-by: Stephen Boyd 
---

This patch is good enough for Krait, but soon I'll need to 
support a "safe rate" where we ask a clock what rate it needs to be running
at to be sure it's within voltage constraints. Right now safe parent
handles that problem on Krait, but on other platforms it won't work.

 drivers/clk/clk.c| 61 ++--
 include/linux/clk-provider.h |  1 +
 2 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 0712bea649c1..ead015a8e047 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -56,9 +56,12 @@ struct clk_core {
struct clk_core **parents;
u8  num_parents;
u8  new_parent_index;
+   u8  safe_parent_index;
unsigned long   rate;
unsigned long   req_rate;
+   unsigned long   old_rate;
unsigned long   new_rate;
+   struct clk_core *safe_parent;
struct clk_core *new_parent;
struct clk_core *new_child;
unsigned long   flags;
@@ -1550,7 +1553,8 @@ out:
 static void clk_calc_subtree(struct clk_core *clk, unsigned long new_rate,
 struct clk_core *new_parent, u8 p_index)
 {
-   struct clk_core *child;
+   struct clk_core *child, *parent;
+   struct clk_hw *parent_hw;
 
clk->new_rate = new_rate;
clk->new_parent = new_parent;
@@ -1560,6 +1564,18 @@ static void clk_calc_subtree(struct clk_core *clk, 
unsigned long new_rate,
if (new_parent && new_parent != clk->parent)
new_parent->new_child = clk;
 
+   if (clk->ops->get_safe_parent) {
+   parent_hw = clk->ops->get_safe_parent(clk->hw);
+   if (parent_hw) {
+   parent = parent_hw->core;
+   p_index = clk_fetch_parent_index(clk, parent);
+   clk->safe_parent_index = p_index;
+   clk->safe_parent = parent;
+   }
+   } else {
+   clk->safe_parent = NULL;
+   }
+
hlist_for_each_entry(child, &clk->children, child_node) {
child->new_rate = clk_recalc(child, new_rate);
clk_calc_subtree(child, child->new_rate, NULL, 0);
@@ -1655,14 +1671,43 @@ static struct clk_core 
*clk_propagate_rate_change(struct clk_core *clk,
  unsigned long event)
 {
struct clk_core *child, *tmp_clk, *fail_clk = NULL;
+   struct clk_core *old_parent;
int ret = NOTIFY_DONE;
 
-   if (clk->rate == clk->new_rate)
+   if (clk->rate == clk->new_rate && event != POST_RATE_CHANGE)
return NULL;
 
+   switch (event) {
+   case PRE_RATE_CHANGE:
+   if (clk->safe_parent)
+   clk->ops->set_parent(clk->hw, clk->safe_parent_index);
+   clk->old_rate = clk->rate;
+   break;
+   case POST_RATE_CHANGE:
+   if (clk->safe_parent) {
+   old_parent = __clk_set_parent_before(clk,
+clk->new_parent);
+   if (clk->ops->set_rate_and_parent) {
+   clk->ops->set_rate_and_parent(clk->hw,
+   clk->new_rate,
+   clk->new_parent ?
+   clk->new_parent->rate : 0,
+   clk->new_parent_index);
+   } else if (clk->ops->set_parent) {
+   clk->ops->set_parent(clk->hw,
+   clk->new_parent_index);
+   }
+   __clk_set_parent_after(clk, clk->new_parent,
+  old_parent);
+   }
+   break;
+   }
+
if (clk->notifier_count) {
-   ret = __clk_notify(clk, event, clk->rate, clk->new_rate);
-   if (ret & NOTIFY_STOP_MASK)
+   if (event != POST_RATE_CHANGE || clk->old_rate != clk->rate)
+   ret = __clk_notify(clk, event, clk->old_rate,
+  clk->new_rate);
+   if (ret & NOTIFY_STOP_MASK && event != POST

[PATCH v3 05/13] clk: qcom: Add support for High-Frequency PLLs (HFPLLs)

2015-03-20 Thread Stephen Boyd
HFPLLs are the main frequency source for Krait CPU clocks. Add
support for changing the rate of these PLLs.

Signed-off-by: Stephen Boyd 
---

I'd really like to get rid of __clk_hfpll_init_once() if possible...

 drivers/clk/qcom/Makefile|   1 +
 drivers/clk/qcom/clk-hfpll.c | 253 +++
 drivers/clk/qcom/clk-hfpll.h |  54 +
 3 files changed, 308 insertions(+)
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h

diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 617826469595..953f792d2133 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -8,6 +8,7 @@ clk-qcom-y += clk-rcg2.o
 clk-qcom-y += clk-branch.o
 clk-qcom-y += clk-regmap-divider.o
 clk-qcom-y += clk-regmap-mux.o
+clk-qcom-y += clk-hfpll.o
 clk-qcom-y += reset.o
 
 obj-$(CONFIG_APQ_GCC_8084) += gcc-apq8084.o
diff --git a/drivers/clk/qcom/clk-hfpll.c b/drivers/clk/qcom/clk-hfpll.c
new file mode 100644
index ..367eb95f1477
--- /dev/null
+++ b/drivers/clk/qcom/clk-hfpll.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk-regmap.h"
+#include "clk-hfpll.h"
+
+#define PLL_OUTCTRLBIT(0)
+#define PLL_BYPASSNL   BIT(1)
+#define PLL_RESET_NBIT(2)
+
+/* Initialize a HFPLL at a given rate and enable it. */
+static void __clk_hfpll_init_once(struct clk_hw *hw)
+{
+   struct clk_hfpll *h = to_clk_hfpll(hw);
+   struct hfpll_data const *hd = h->d;
+   struct regmap *regmap = h->clkr.regmap;
+
+   if (likely(h->init_done))
+   return;
+
+   /* Configure PLL parameters for integer mode. */
+   if (hd->config_val)
+   regmap_write(regmap, hd->config_reg, hd->config_val);
+   regmap_write(regmap, hd->m_reg, 0);
+   regmap_write(regmap, hd->n_reg, 1);
+
+   if (hd->user_reg) {
+   u32 regval = hd->user_val;
+   unsigned long rate;
+
+   rate = __clk_get_rate(hw->clk);
+
+   /* Pick the right VCO. */
+   if (hd->user_vco_mask && rate > hd->low_vco_max_rate)
+   regval |= hd->user_vco_mask;
+   regmap_write(regmap, hd->user_reg, regval);
+   }
+
+   if (hd->droop_reg)
+   regmap_write(regmap, hd->droop_reg, hd->droop_val);
+
+   h->init_done = true;
+}
+
+static void __clk_hfpll_enable(struct clk_hw *hw)
+{
+   struct clk_hfpll *h = to_clk_hfpll(hw);
+   struct hfpll_data const *hd = h->d;
+   struct regmap *regmap = h->clkr.regmap;
+   u32 val;
+
+   __clk_hfpll_init_once(hw);
+
+   /* Disable PLL bypass mode. */
+   regmap_update_bits(regmap, hd->mode_reg, PLL_BYPASSNL, PLL_BYPASSNL);
+
+   /*
+* H/W requires a 5us delay between disabling the bypass and
+* de-asserting the reset. Delay 10us just to be safe.
+*/
+   udelay(10);
+
+   /* De-assert active-low PLL reset. */
+   regmap_update_bits(regmap, hd->mode_reg, PLL_RESET_N, PLL_RESET_N);
+
+   /* Wait for PLL to lock. */
+   if (hd->status_reg) {
+   do {
+   regmap_read(regmap, hd->status_reg, &val);
+   } while (!(val & BIT(hd->lock_bit)));
+   } else {
+   udelay(60);
+   }
+
+   /* Enable PLL output. */
+   regmap_update_bits(regmap, hd->mode_reg, PLL_OUTCTRL, PLL_OUTCTRL);
+}
+
+/* Enable an already-configured HFPLL. */
+static int clk_hfpll_enable(struct clk_hw *hw)
+{
+   unsigned long flags;
+   struct clk_hfpll *h = to_clk_hfpll(hw);
+   struct hfpll_data const *hd = h->d;
+   struct regmap *regmap = h->clkr.regmap;
+   u32 mode;
+
+   spin_lock_irqsave(&h->lock, flags);
+   regmap_read(regmap, hd->mode_reg, &mode);
+   if (!(mode & (PLL_BYPASSNL | PLL_RESET_N | PLL_OUTCTRL)))
+   __clk_hfpll_enable(hw);
+   spin_unlock_irqrestore(&h->lock, flags);
+
+   return 0;
+}
+
+static void __clk_hfpll_disable(struct clk_hfpll *h)
+{
+   struct hfpll_data const *hd = h->d;
+   struct regmap *regmap = h->clkr.regmap;
+
+   /*
+* Disable the PLL output, disable test mode, enable the bypass mode,
+* and assert the reset.
+*/
+   regmap_update_bits(regmap, hd->mode_reg,
+   PLL_BYPASSNL | PLL_RESET_N | PLL_OUTCTRL, 0);
+}
+
+static void

[PATCH v3 06/13] clk: qcom: Add HFPLL driver

2015-03-20 Thread Stephen Boyd
On some devices (MSM8974 for example), the HFPLLs are
instantiated within the Krait processor subsystem as separate
register regions. Add a driver for these PLLs so that we can
provide HFPLL clocks for use by the system.

Cc: 
Signed-off-by: Stephen Boyd 
---
 .../devicetree/bindings/clock/qcom,hfpll.txt   |  40 
 drivers/clk/qcom/Kconfig   |   8 ++
 drivers/clk/qcom/Makefile  |   1 +
 drivers/clk/qcom/hfpll.c   | 109 +
 4 files changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,hfpll.txt
 create mode 100644 drivers/clk/qcom/hfpll.c

diff --git a/Documentation/devicetree/bindings/clock/qcom,hfpll.txt 
b/Documentation/devicetree/bindings/clock/qcom,hfpll.txt
new file mode 100644
index ..fee92bb30344
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/qcom,hfpll.txt
@@ -0,0 +1,40 @@
+High-Frequency PLL (HFPLL)
+
+PROPERTIES
+
+- compatible:
+   Usage: required
+   Value type: 
+   Definition: must be "qcom,hfpll"
+
+- reg:
+   Usage: required
+   Value type: 
+   Definition: address and size of HPLL registers. An optional second
+   element specifies the address and size of the alias
+   register region.
+
+- clock-output-names:
+   Usage: required
+   Value type: 
+   Definition: Name of the PLL. Typically hfpllX where X is a CPU number
+   starting at 0. Otherwise hfpll_Y where Y is more specific
+   such as "l2".
+
+Example:
+
+1) An HFPLL for the L2 cache.
+
+   clock-controller@f9016000 {
+   compatible = "qcom,hfpll";
+   reg = <0xf9016000 0x30>;
+   clock-output-names = "hfpll_l2";
+   };
+
+2) An HFPLL for CPU0. This HFPLL has the alias register region.
+
+   clock-controller@f908a000 {
+   compatible = "qcom,hfpll";
+   reg = <0xf908a000 0x30>, <0xf900a000 0x30>;
+   clock-output-names = "hfpll0";
+   };
diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 0d7ab52b7ab0..d421fd195114 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -88,3 +88,11 @@ config MSM_MMCC_8974
  Support for the multimedia clock controller on msm8974 devices.
  Say Y if you want to support multimedia devices such as display,
  graphics, video encode/decode, camera, etc.
+
+config QCOM_HFPLL
+   tristate "High-Frequency PLL (HFPLL) Clock Controller"
+   depends on COMMON_CLK_QCOM
+   help
+ Support for the high-frequency PLLs present on Qualcomm devices.
+ Say Y if you want to support CPU frequency scaling on devices
+ such as MSM8974, APQ8084, etc.
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 953f792d2133..b1076179fb17 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_MSM_LCC_8960) += lcc-msm8960.o
 obj-$(CONFIG_MSM_GCC_8974) += gcc-msm8974.o
 obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
 obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
+obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c
new file mode 100644
index ..0092017b257d
--- /dev/null
+++ b/drivers/clk/qcom/hfpll.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk-regmap.h"
+#include "clk-hfpll.h"
+
+static const struct hfpll_data hdata = {
+   .mode_reg = 0x00,
+   .l_reg = 0x04,
+   .m_reg = 0x08,
+   .n_reg = 0x0c,
+   .user_reg = 0x10,
+   .config_reg = 0x14,
+   .config_val = 0x430405d,
+   .status_reg = 0x1c,
+   .lock_bit = 16,
+
+   .user_val = 0x8,
+   .user_vco_mask = 0x10,
+   .low_vco_max_rate = 124800,
+   .min_rate = 53760UL,
+   .max_rate = 29UL,
+};
+
+static const struct of_device_id qcom_hfpll_match_table[] = {
+   { .compatible = "qcom,hfpll" },
+   { }
+};
+MODULE_DEVICE_TABLE(of, qcom_hfpll_match_table);
+
+static const struct regmap_config hfpll_regmap_config = {
+   .reg_bits   = 32,
+   .reg_stride = 4,
+   .val_bits   = 32,
+   .max_register   = 0x30,
+   .fast_io= true,
+};
+
+static int qcom_hfpll_probe(struct platform_device *

[PATCH v3 03/13] clk: Avoid sending high rates to downstream clocks during set_rate

2015-03-20 Thread Stephen Boyd
If a clock is on and we call clk_set_rate() on it we may get into
a situation where the clock temporarily increases in rate
dramatically while we walk the tree and call .set_rate() ops. For
example, consider a case where a PLL feeds into a divider.
Initially the divider is set to divide by 1 and the PLL is
running fairly slow (100MHz). The downstream consumer of the
divider output can only handle rates =< 400 MHz, but the divider
can only choose between divisors of 1 and 4.

 +-+   ++
 | PLL |-->| div 1 or div 4 |---> consumer device
 +-+   ++

To achieve a rate of 400MHz on the output of the divider, we
would have to set the rate of the PLL to 1.6 GHz and then divide
it by 4. The current code would set the PLL to 1.6GHz first while
the divider is still set to 1, thus causing the downstream
consumer of the clock to receive a few clock cycles of 1.6GHz
clock (far beyond it's maximum acceptable rate). We should be
changing the divider first before increasing the PLL rate to
avoid this problem.

Therefore, set the rate of any child clocks that are increasing
in rate from their current rate so that they can increase their
dividers if necessary. We assume that there isn't such a thing as
minimum rate requirements.

Signed-off-by: Stephen Boyd 
---
 drivers/clk/clk.c | 34 ++
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index eb0152961d3c..0712bea649c1 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1689,21 +1689,24 @@ static struct clk_core 
*clk_propagate_rate_change(struct clk_core *clk,
  * walk down a subtree and set the new rates notifying the rate
  * change on the way
  */
-static void clk_change_rate(struct clk_core *clk)
+static void
+clk_change_rate(struct clk_core *clk, unsigned long best_parent_rate)
 {
struct clk_core *child;
struct hlist_node *tmp;
unsigned long old_rate;
-   unsigned long best_parent_rate = 0;
bool skip_set_rate = false;
struct clk_core *old_parent;
 
-   old_rate = clk->rate;
+   hlist_for_each_entry(child, &clk->children, child_node) {
+   /* Skip children who will be reparented to another clock */
+   if (child->new_parent && child->new_parent != clk)
+   continue;
+   if (child->new_rate > child->rate)
+   clk_change_rate(child, clk->new_rate);
+   }
 
-   if (clk->new_parent)
-   best_parent_rate = clk->new_parent->rate;
-   else if (clk->parent)
-   best_parent_rate = clk->parent->rate;
+   old_rate = clk->rate;
 
if (clk->new_parent && clk->new_parent != clk->parent) {
old_parent = __clk_set_parent_before(clk, clk->new_parent);
@@ -1723,7 +1726,7 @@ static void clk_change_rate(struct clk_core *clk)
if (!skip_set_rate && clk->ops->set_rate)
clk->ops->set_rate(clk->hw, clk->new_rate, best_parent_rate);
 
-   clk->rate = clk_recalc(clk, best_parent_rate);
+   clk->rate = clk->new_rate;
 
if (clk->notifier_count && old_rate != clk->rate)
__clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate);
@@ -1736,12 +1739,13 @@ static void clk_change_rate(struct clk_core *clk)
/* Skip children who will be reparented to another clock */
if (child->new_parent && child->new_parent != clk)
continue;
-   clk_change_rate(child);
+   if (child->new_rate != child->rate)
+   clk_change_rate(child, clk->new_rate);
}
 
/* handle the new child who might not be in clk->children yet */
-   if (clk->new_child)
-   clk_change_rate(clk->new_child);
+   if (clk->new_child && clk->new_child->new_rate != clk->new_child->rate)
+   clk_change_rate(clk->new_child, clk->new_rate);
 }
 
 static int clk_core_set_rate_nolock(struct clk_core *clk,
@@ -1750,6 +1754,7 @@ static int clk_core_set_rate_nolock(struct clk_core *clk,
struct clk_core *top, *fail_clk;
unsigned long rate = req_rate;
int ret = 0;
+   unsigned long parent_rate;
 
if (!clk)
return 0;
@@ -1775,8 +1780,13 @@ static int clk_core_set_rate_nolock(struct clk_core *clk,
return -EBUSY;
}
 
+   if (top->parent)
+   parent_rate = top->parent->rate;
+   else
+   parent_rate = 0;
+
/* change the rates */
-   clk_change_rate(top);
+   clk_change_rate(top, parent_rate);
 
clk->req_rate = req_rate;
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

[PATCH v3 09/13] clk: qcom: Add support for Krait clocks

2015-03-20 Thread Stephen Boyd
The Krait clocks are made up of a series of muxes and a divider
that choose between a fixed rate clock and dedicated HFPLLs for
each CPU. Instead of using mmio accesses to remux parents, the
Krait implementation exposes the remux control via cp15
registers. Support these clocks.

Signed-off-by: Stephen Boyd 
---
 drivers/clk/qcom/Kconfig |   4 ++
 drivers/clk/qcom/Makefile|   1 +
 drivers/clk/qcom/clk-krait.c | 166 +++
 drivers/clk/qcom/clk-krait.h |  49 +
 4 files changed, 220 insertions(+)
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index d421fd195114..7b82b3c4e259 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -96,3 +96,7 @@ config QCOM_HFPLL
  Support for the high-frequency PLLs present on Qualcomm devices.
  Say Y if you want to support CPU frequency scaling on devices
  such as MSM8974, APQ8084, etc.
+
+config KRAIT_CLOCKS
+   bool
+   select KRAIT_L2_ACCESSORS
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index b1076179fb17..f8d7cfaee4a2 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -8,6 +8,7 @@ clk-qcom-y += clk-rcg2.o
 clk-qcom-y += clk-branch.o
 clk-qcom-y += clk-regmap-divider.o
 clk-qcom-y += clk-regmap-mux.o
+clk-qcom-$(CONFIG_KRAIT_CLOCKS) += clk-krait.o
 clk-qcom-y += clk-hfpll.o
 clk-qcom-y += reset.o
 
diff --git a/drivers/clk/qcom/clk-krait.c b/drivers/clk/qcom/clk-krait.c
new file mode 100644
index ..6506730d085e
--- /dev/null
+++ b/drivers/clk/qcom/clk-krait.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "clk-krait.h"
+
+/* Secondary and primary muxes share the same cp15 register */
+static DEFINE_SPINLOCK(krait_clock_reg_lock);
+
+#define LPL_SHIFT  8
+static void __krait_mux_set_sel(struct krait_mux_clk *mux, int sel)
+{
+   unsigned long flags;
+   u32 regval;
+
+   spin_lock_irqsave(&krait_clock_reg_lock, flags);
+   regval = krait_get_l2_indirect_reg(mux->offset);
+   regval &= ~(mux->mask << mux->shift);
+   regval |= (sel & mux->mask) << mux->shift;
+   if (mux->lpl) {
+   regval &= ~(mux->mask << (mux->shift + LPL_SHIFT));
+   regval |= (sel & mux->mask) << (mux->shift + LPL_SHIFT);
+   }
+   krait_set_l2_indirect_reg(mux->offset, regval);
+   spin_unlock_irqrestore(&krait_clock_reg_lock, flags);
+
+   /* Wait for switch to complete. */
+   mb();
+   udelay(1);
+}
+
+static int krait_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+   struct krait_mux_clk *mux = to_krait_mux_clk(hw);
+   u32 sel;
+
+   sel = clk_mux_reindex(index, mux->parent_map, 0);
+   mux->en_mask = sel;
+   /* Don't touch mux if CPU is off as it won't work */
+   if (__clk_is_enabled(hw->clk))
+   __krait_mux_set_sel(mux, sel);
+   return 0;
+}
+
+static u8 krait_mux_get_parent(struct clk_hw *hw)
+{
+   struct krait_mux_clk *mux = to_krait_mux_clk(hw);
+   u32 sel;
+
+   sel = krait_get_l2_indirect_reg(mux->offset);
+   sel >>= mux->shift;
+   sel &= mux->mask;
+   mux->en_mask = sel;
+
+   return clk_mux_get_parent(hw, sel, mux->parent_map, 0);
+}
+
+static struct clk_hw *krait_mux_get_safe_parent(struct clk_hw *hw)
+{
+   int i;
+   struct krait_mux_clk *mux = to_krait_mux_clk(hw);
+   int num_parents = __clk_get_num_parents(hw->clk);
+
+   i = mux->safe_sel;
+   for (i = 0; i < num_parents; i++)
+   if (mux->safe_sel == mux->parent_map[i])
+   break;
+
+   return __clk_get_hw(clk_get_parent_by_index(hw->clk, i));
+}
+
+static int krait_mux_enable(struct clk_hw *hw)
+{
+   struct krait_mux_clk *mux = to_krait_mux_clk(hw);
+
+   __krait_mux_set_sel(mux, mux->en_mask);
+
+   return 0;
+}
+
+static void krait_mux_disable(struct clk_hw *hw)
+{
+   struct krait_mux_clk *mux = to_krait_mux_clk(hw);
+
+   __krait_mux_set_sel(mux, mux->safe_sel);
+}
+
+const struct clk_ops krait_mux_clk_ops = {
+   .enable = krait_mux_enable,
+   .disable = krait_mux_disable,
+   .set_parent = krait_mux_set_parent,
+   .get_parent = krait_mux_get_parent,
+   .determine_rate =

[PATCH v3 12/13] cpufreq: Add module to register cpufreq on Krait CPUs

2015-03-20 Thread Stephen Boyd
Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.

Cc: 
Signed-off-by: Stephen Boyd 
---
 .../devicetree/bindings/arm/msm/qcom,pvs.txt   |  38 
 drivers/cpufreq/Kconfig.arm|   9 +
 drivers/cpufreq/Makefile   |   1 +
 drivers/cpufreq/qcom-cpufreq.c | 204 +
 4 files changed, 252 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,pvs.txt
 create mode 100644 drivers/cpufreq/qcom-cpufreq.c

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,pvs.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,pvs.txt
new file mode 100644
index ..e7cb10426a3b
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,pvs.txt
@@ -0,0 +1,38 @@
+Qualcomm Process Voltage Scaling Tables
+
+The node name is required to be "qcom,pvs". There shall only be one
+such node present in the root of the tree.
+
+PROPERTIES
+
+- qcom,pvs-format-a or qcom,pvs-format-b:
+   Usage: required
+   Value type: 
+   Definition: Indicates the format of qcom,speedX-pvsY-bin-vZ properties.
+   If qcom,pvs-format-a is used the table is two columns
+   (frequency and voltage in that order). If qcom,pvs-format-b 
is used the table is three columns (frequency, voltage,
+   and current in that order).
+
+- qcom,speedX-pvsY-bin-vZ:
+   Usage: required
+   Value type: 
+   Definition: The PVS table corresponding to the speed bin X, pvs bin Y,
+   and version Z.
+Example:
+
+   qcom,pvs {
+   qcom,pvs-format-a;
+   qcom,speed0-pvs0-bin-v0 =
+   <  38400  95 >,
+   <  48600  975000 >,
+   <  59400 100 >,
+   <  70200 1025000 >,
+   <  81000 1075000 >,
+   <  91800 110 >,
+   < 102600 1125000 >,
+   < 113400 1175000 >,
+   < 124200 120 >,
+   < 135000 1225000 >,
+   < 145800 1237500 >,
+   < 151200 125 >;
+   };
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 1b06fc4640e2..3829d5521dfc 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -137,6 +137,15 @@ config ARM_OMAP2PLUS_CPUFREQ
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS
 
+config ARM_QCOM_CPUFREQ
+   tristate "Qualcomm based"
+   depends on ARCH_QCOM
+   select PM_OPP
+   help
+ This adds the CPUFreq driver for Qualcomm SoC based boards.
+
+ If in doubt, say N.
+
 config ARM_S3C_CPUFREQ
bool
help
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 82a1821471fd..be95ed8d6873 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)+= kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)   += pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)   += pxa3xx-cpufreq.o
+obj-$(CONFIG_ARM_QCOM_CPUFREQ) += qcom-cpufreq.o
 obj-$(CONFIG_ARM_S3C24XX_CPUFREQ)  += s3c24xx-cpufreq.o
 obj-$(CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS) += s3c24xx-cpufreq-debugfs.o
 obj-$(CONFIG_ARM_S3C2410_CPUFREQ)  += s3c2410-cpufreq.o
diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
new file mode 100644
index ..c9f86a062cdd
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -0,0 +1,204 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver)
+{
+   void __iomem *base;
+   u32 pte_efuse;
+
+   *speed = *pvs = *pvs_ver = 0;
+
+   base = ioremap(0x007000c0, 4);
+   if (!base) {
+   pr_warn("Unable to read efuse data. Defaulting to 0!\n");
+   return;
+   }
+
+   pte_efuse = readl_relaxed(base);
+   iounmap(base);
+
+   *speed = pte_efuse & 0xf;
+   if (*speed == 0xf)
+   *speed = (pte_efuse >> 4) & 0xf;
+
+   if (*speed

[PATCH v3 10/13] clk: qcom: Add KPSS ACC/GCC driver

2015-03-20 Thread Stephen Boyd
The ACC and GCC regions present in KPSSv1 contain registers to
control clocks and power to each Krait CPU and L2. For CPUfreq
purposes probe these devices and expose a mux clock that chooses
between PXO and PLL8.

Cc: 
Signed-off-by: Stephen Boyd 
---
 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  7 ++
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  | 28 +++
 drivers/clk/qcom/Kconfig   |  8 ++
 drivers/clk/qcom/Makefile  |  1 +
 drivers/clk/qcom/kpss-xcc.c| 95 ++
 5 files changed, 139 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
 create mode 100644 drivers/clk/qcom/kpss-xcc.c

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt
index 1333db9acfee..382a574a5c55 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt
@@ -21,10 +21,17 @@ PROPERTIES
the register region. An optional second element specifies
the base address and size of the alias register region.
 
+- clock-output-names:
+   Usage: optional
+   Value type: 
+   Definition: Name of the output clock. Typically acpuX_aux where X is a
+   CPU number starting at 0.
+
 Example:
 
clock-controller@2088000 {
compatible = "qcom,kpss-acc-v2";
reg = <0x02088000 0x1000>,
  <0x02008000 0x1000>;
+   clock-output-names = "acpu0_aux";
};
diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt 
b/Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
new file mode 100644
index ..d1e12f16a28c
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
@@ -0,0 +1,28 @@
+Krait Processor Sub-system (KPSS) Global Clock Controller (GCC)
+
+PROPERTIES
+
+- compatible:
+   Usage: required
+   Value type: 
+   Definition: should be one of:
+   "qcom,kpss-gcc"
+
+- reg:
+   Usage: required
+   Value type: 
+   Definition: base address and size of the register region
+
+- clock-output-names:
+   Usage: required
+   Value type: 
+   Definition: Name of the output clock. Typically acpu_l2_aux indicating
+   an L2 cache auxiliary clock.
+
+Example:
+
+   l2cc: clock-controller@2011000 {
+   compatible = "qcom,kpss-gcc";
+   reg = <0x2011000 0x1000>;
+   clock-output-names = "acpu_l2_aux";
+   };
diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 7b82b3c4e259..92eb883533d5 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -97,6 +97,14 @@ config QCOM_HFPLL
  Say Y if you want to support CPU frequency scaling on devices
  such as MSM8974, APQ8084, etc.
 
+config KPSS_XCC
+   tristate "KPSS Clock Controller"
+   depends on COMMON_CLK_QCOM
+   help
+ Support for the Krait ACC and GCC clock controllers. Say Y
+ if you want to support CPU frequency scaling on devices such
+ as MSM8960, APQ8064, etc.
+
 config KRAIT_CLOCKS
bool
select KRAIT_L2_ACCESSORS
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index f8d7cfaee4a2..6327dd623773 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -22,4 +22,5 @@ obj-$(CONFIG_MSM_LCC_8960) += lcc-msm8960.o
 obj-$(CONFIG_MSM_GCC_8974) += gcc-msm8974.o
 obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
 obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
+obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
 obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
diff --git a/drivers/clk/qcom/kpss-xcc.c b/drivers/clk/qcom/kpss-xcc.c
new file mode 100644
index ..abf6bfd053c1
--- /dev/null
+++ b/drivers/clk/qcom/kpss-xcc.c
@@ -0,0 +1,95 @@
+/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char *aux_parents[] = {
+   "pll8_vote",
+   "pxo",
+};
+
+static unsigned int aux_parent_map[] = {
+   3,
+   0,
+};
+
+static const struct of_device_id kpss_xcc_match_table[] = {
+   { .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
+   { .compatible = "qcom,kpss-gcc" },
+   

[PATCH v3 08/13] clk: qcom: Add IPQ806X's HFPLLs

2015-03-20 Thread Stephen Boyd
Describe the HFPLLs present on IPQ806X devices.

Signed-off-by: Stephen Boyd 
---
 drivers/clk/qcom/gcc-ipq806x.c | 83 ++
 1 file changed, 83 insertions(+)

diff --git a/drivers/clk/qcom/gcc-ipq806x.c b/drivers/clk/qcom/gcc-ipq806x.c
index cbdc31dea7f4..5a03e91f1edc 100644
--- a/drivers/clk/qcom/gcc-ipq806x.c
+++ b/drivers/clk/qcom/gcc-ipq806x.c
@@ -30,6 +30,7 @@
 #include "clk-pll.h"
 #include "clk-rcg.h"
 #include "clk-branch.h"
+#include "clk-hfpll.h"
 #include "reset.h"
 
 static struct clk_pll pll0 = {
@@ -113,6 +114,85 @@ static struct clk_regmap pll8_vote = {
},
 };
 
+static struct hfpll_data hfpll0_data = {
+   .mode_reg = 0x3200,
+   .l_reg = 0x3208,
+   .m_reg = 0x320c,
+   .n_reg = 0x3210,
+   .config_reg = 0x3204,
+   .status_reg = 0x321c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3214,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll0 = {
+   .d = &hfpll0_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll0",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll0.lock),
+};
+
+static struct hfpll_data hfpll1_data = {
+   .mode_reg = 0x3240,
+   .l_reg = 0x3248,
+   .m_reg = 0x324c,
+   .n_reg = 0x3250,
+   .config_reg = 0x3244,
+   .status_reg = 0x325c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3314,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll1 = {
+   .d = &hfpll1_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll1",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll1.lock),
+};
+
+static struct hfpll_data hfpll_l2_data = {
+   .mode_reg = 0x3300,
+   .l_reg = 0x3308,
+   .m_reg = 0x330c,
+   .n_reg = 0x3310,
+   .config_reg = 0x3304,
+   .status_reg = 0x331c,
+   .config_val = 0x7845c665,
+   .droop_reg = 0x3314,
+   .droop_val = 0x0108c000,
+   .min_rate = 6UL,
+   .max_rate = 18UL,
+};
+
+static struct clk_hfpll hfpll_l2 = {
+   .d = &hfpll_l2_data,
+   .clkr.hw.init = &(struct clk_init_data){
+   .parent_names = (const char *[]){ "pxo" },
+   .num_parents = 1,
+   .name = "hfpll_l2",
+   .ops = &clk_ops_hfpll,
+   .flags = CLK_IGNORE_UNUSED,
+   },
+   .lock = __SPIN_LOCK_UNLOCKED(hfpll_l2.lock),
+};
+
+
 static struct clk_pll pll14 = {
.l_reg = 0x31c4,
.m_reg = 0x31c8,
@@ -2273,6 +2353,9 @@ static struct clk_regmap *gcc_ipq806x_clks[] = {
[USB_FS1_XCVR_SRC] = &usb_fs1_xcvr_clk_src.clkr,
[USB_FS1_XCVR_CLK] = &usb_fs1_xcvr_clk.clkr,
[USB_FS1_SYSTEM_CLK] = &usb_fs1_sys_clk.clkr,
+   [PLL9] = &hfpll0.clkr,
+   [PLL10] = &hfpll1.clkr,
+   [PLL12] = &hfpll_l2.clkr,
 };
 
 static const struct qcom_reset_map gcc_ipq806x_resets[] = {
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 00/13] Krait clocks + Krait CPUfreq

2015-03-20 Thread Stephen Boyd
These patches provide cpufreq scaling on devices with Krait CPUs.
In Krait CPU designs there's one PLL and two muxes per CPU, allowing
us to switch CPU frequencies independently.

 secondary
 +-++
 | QSB |---+|\
 +-+   || |-+
   |+---|/  |
   ||   +   |
 +-+   ||   |
 | PLL |+---+   |   primary
 +-+|  || +
|  |+-|\   +--+
 +---+  |  |  | \  |  |
 | HFPLL |--+-|  |-| CPU0 |
 +---+  |  || |  | |  |
|  || +-+ | /  +--+
|  |+-| / 2 |-|/
|  |  +-+ +
|  | secondary
|  |+
|  +|\
|   | |-+
+---|/  |   primary
+   | +
+-|\   +--+
 +---+| \  |  |
 | HFPLL ||  |-| CPU1 |
 +---+  | |  | |  |
| +-+ | /  +--+
+-| / 2 |-|/
  +-+ +

To support this in the common clock framework we model the muxes,
dividers, and PLLs as different clocks. CPUfreq only interacts
with the primary mux (farthest right in the diagram). When CPUfreq
sets a rate, the mux code finds the best parent that can provide the rate.
Due to the design, QSB and the top PLL are always a fixed rate and thus
only support one frequency each. These sources provide the lowest
frequencies for the CPUs. The HFPLLs are where we can make the CPU go
faster (GHz range). Sometimes we need to run the HFPLL twice as
fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL because
we need to turn off the output of the PLL when changing its frequency.
This means we have to switch over to the secondary mux and use one of the
fixed sources. This is why we need something like the safe parent patch.

I plan to submit the DTS changes through arm-soc, but I've included everything
here to make it easier to pick things up for testing, etc. If anything can be
picked up right now it would be better to reduce the churn over time as
other pieces settle. Some things are not done, but I'm posting this now
to get it out there and because the clock framework patches needed some rework
due to recent changes.

Changes since v2:
 * Switched to cpufreq-dt
 * Ported over PVS binding
 * Stripped out cpu logical map to make modules work
 * Dropped patches that merged upstream

Changes since v1:
 * Added IPQ and APQ8064 support
 * Switched to cpufreq-generic
 * Added OPP parsing from DT (need to write binding though)
 * New patches to make clk-generic.c go away
  * Made mux and divider reusable for non-MMIO devices
  * Added a mux_determine_rate_closest (not sure if this is really needed)
  * Added unregistration of muxes
 * New patch to avoid sending high frequencies down to devices using clocks

TODO:
 * Add Krait regulator voltage scaling (not strictly necessary)
 * Add some thermal awareness
 * Use efuse/eeprom API instead of hardcoding the location in the driver
 * Figure out how to express number of CPUs without relying on linux's
   concept of number of CPUs and logical CPU mapping
 * Trim down the probe code for krait-cc so that we just register clocks
   and don't enable or set rates

Stephen Boyd (13):
  ARM: Add Krait L2 register accessor functions
  clk: mux: Split out register accessors for reuse
  clk: Avoid sending high rates to downstream clocks during set_rate
  clk: Add safe switch hook
  clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
  clk: qcom: Add HFPLL driver
  clk: qcom: Add MSM8960/APQ8064's HFPLLs
  clk: qcom: Add IPQ806X's HFPLLs
  clk: qcom: Add support for Krait clocks
  clk: qcom: Add KPSS ACC/GCC driver
  clk: qcom: Add Krait clock controller driver
  cpufreq: Add module to register cpufreq on Krait CPUs
  ARM: dts: qcom: Add necessary DT data for Krait cpufreq

 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |   7 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  28 ++
 .../devicetree/bindings/arm/msm/qcom,pvs.txt   |  38 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt   |  40 +++
 .../devicetree/bindings/clock/qcom,krait-cc.txt|  22 ++
 arch/arm/boot/dts/qcom-apq8064.dtsi| 230 ++
 arch/arm/boot/dts/qcom-msm8960.dtsi 

Re: [PATCH V2 2/2] x86, mce, severities: Define mce_severity function pointer

2015-03-20 Thread Borislav Petkov
On Fri, Mar 20, 2015 at 09:35:26PM -0500, Aravind Gopalakrishnan wrote:
> Other function pointers in the mce code like unexpected_machine_check
> and default_threshold_interrupt are assigned to the respective
> function pointers when they are defined.

The "WTF?!" would still fire and we don't want that.

Also, I'm not sure about returning MCE_PANIC_SEVERITY by default.
I mean, the code for !(Intel || AMD) has worked just fine with the
original severities, i.e., mce_severity_intel() now.

So maybe we should assign mce_severity_intel() on static init of the
mce_severity pointer and override it only on AMD...

This keeps the old behaviour for other machines, in the manner of
letting sleeping dogs lie...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/3] dt-bindings: Add I2C bindings for mt65xx/mt81xx.

2015-03-20 Thread Eddie Huang
From: Xudong Chen 

Add devicetree bindings for Mediatek Soc I2C driver.

Signed-off-by: Xudong Chen 
Signed-off-by: Eddie Huang 
---
 .../devicetree/bindings/i2c/i2c-mt6577.txt | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-mt6577.txt

diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt 
b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt
new file mode 100644
index 000..eff52c1
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt
@@ -0,0 +1,41 @@
+* Mediatek's I2C controller
+
+The Mediatek's I2C controller is used to interface with I2C devices.
+
+Required properties:
+  - compatible: value should be either of the following.
+  (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c.
+  (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c.
+  (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c.
+  (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c.
+  (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c.
+  - reg: physical base address of the controller and dma base, length of memory
+mapped region.
+  - interrupts: interrupt number to the cpu.
+  - clock-div: the fixed value for frequency divider of clock source in i2c
+module. Each IC may be different.
+  - clocks: clock name from clock manager
+  - clock-names: Must include "main" and "dma", if enable have-pmic need 
include
+"pmic" extra.
+
+Optional properties:
+  - clock-frequency: Frequency in Hz of the bus when transfer, the default 
value
+is 10.
+  - mediatek,have-pmic: platform can control i2c form special pmic side.
+Only mt6589 and mt8135 support this feature.
+  - mediatek,use-push-pull: IO config use push-pull mode.
+
+Example:
+
+   i2c0: i2c@1100d000 {
+   compatible = "mediatek,mt6577-i2c";
+   reg = <0x1100d000 0x70>,
+ <0x11000300 0x80>;
+   interrupts = ;
+   clock-frequency = <10>;
+   mediatek,have-pmic;
+   clock-div = <16>;
+   clocks = <&i2c0_ck>, <&ap_dma_ck>;
+   clock-names = "main", "dma";
+   };
+
-- 
1.8.1.1.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/3] I2C: mediatek: Add driver for MediaTek I2C controller

2015-03-20 Thread Eddie Huang
From: Xudong Chen 

The mediatek SoCs have I2C controller that handle I2C transfer.
This patch include common I2C bus driver.
This driver is compatible with I2C controller on mt65xx/mt81xx.

Signed-off-by: Xudong Chen 
Signed-off-by: Liguo Zhang 
Signed-off-by: Eddie Huang 
---
 drivers/i2c/busses/Kconfig  |   9 +
 drivers/i2c/busses/Makefile |   1 +
 drivers/i2c/busses/i2c-mt65xx.c | 705 
 3 files changed, 715 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-mt65xx.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 22da9c2..243c4ec 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -602,6 +602,15 @@ config I2C_MPC
  This driver can also be built as a module.  If so, the module
  will be called i2c-mpc.
 
+config I2C_MT65XX
+   tristate "MediaTek I2C adapter"
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   help
+ This selects the MediaTek(R) Integrated Inter Circuit bus driver
+ for MT65xx and MT81xx.
+ If you want to use MediaTek(R) I2C interface, say Y or M here.
+ If unsure, say N.
+
 config I2C_MV64XXX
tristate "Marvell mv64xxx I2C Controller"
depends on MV64X60 || PLAT_ORION || ARCH_SUNXI
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 3638feb..372a711 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_IOP3XX)  += i2c-iop3xx.o
 obj-$(CONFIG_I2C_KEMPLD)   += i2c-kempld.o
 obj-$(CONFIG_I2C_MESON)+= i2c-meson.o
 obj-$(CONFIG_I2C_MPC)  += i2c-mpc.o
+obj-$(CONFIG_I2C_MT65XX)   += i2c-mt65xx.o
 obj-$(CONFIG_I2C_MV64XXX)  += i2c-mv64xxx.o
 obj-$(CONFIG_I2C_MXS)  += i2c-mxs.o
 obj-$(CONFIG_I2C_NOMADIK)  += i2c-nomadik.o
diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
new file mode 100644
index 000..3940112
--- /dev/null
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -0,0 +1,705 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Xudong.chen 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define I2C_HS_NACKERR (1 << 2)
+#define I2C_ACKERR (1 << 1)
+#define I2C_TRANSAC_COMP   (1 << 0)
+#define I2C_TRANSAC_START  (1 << 0)
+#define I2C_TIMING_STEP_DIV_MASK   (0x3f << 0)
+#define I2C_TIMING_SAMPLE_COUNT_MASK   (0x7 << 0)
+#define I2C_TIMING_SAMPLE_DIV_MASK (0x7 << 8)
+#define I2C_TIMING_DATA_READ_MASK  (0x7 << 12)
+#define I2C_DCM_DISABLE0x
+#define I2C_IO_CONFIG_OPEN_DRAIN   0x0003
+#define I2C_IO_CONFIG_PUSH_PULL0x
+#define I2C_SOFT_RST   0x0001
+#define I2C_FIFO_ADDR_CLR  0x0001
+#define I2C_DELAY_LEN  0x0002
+#define I2C_ST_START_CON   0x8001
+#define I2C_FS_START_CON   0x1800
+#define I2C_TIME_CLR_VALUE 0x
+#define I2C_TIME_DEFAULT_VALUE 0x0003
+#define I2C_FS_TIME_INIT_VALUE 0x1303
+#define I2C_WRRD_TRANAC_VALUE  0x0002
+#define I2C_RD_TRANAC_VALUE0x0001
+
+#define I2C_DMA_CON_TX 0x
+#define I2C_DMA_CON_RX 0x0001
+#define I2C_DMA_START_EN   0x0001
+#define I2C_DMA_INT_FLAG_NONE  0x
+#define I2C_DMA_CLR_FLAG   0x
+
+#define I2C_DEFAUT_SPEED   10  /* hz */
+#define MAX_FS_MODE_SPEED  40
+#define MAX_HS_MODE_SPEED  340
+#define MAX_MSG_NUM_MT6577 1
+#define MAX_DMA_TRANS_SIZE_MT6577  255
+#define MAX_WRRD_TRANS_SIZE_MT6577 31
+#define MAX_SAMPLE_CNT_DIV 8
+#define MAX_STEP_CNT_DIV   64
+#define MAX_HS_STEP_CNT_DIV8
+
+#define I2C_CONTROL_RS  (0x1 << 1)
+#define I2C_CONTROL_DMA_EN  (0x1 << 2)
+#define I2C_CONTROL_CLK_EXT_EN  (0x1 << 3)
+#define I2C_CONTROL_DIR_CHANGE  (0x1 << 4)
+#define I2C_CONTROL_ACKERR_DET_EN   (0x1 << 5)
+#define I2C_CONTROL_TRANSFER_LEN_CHANGE (0x1 << 6)
+#define I2C_CONTROL_WRAPPER (0x1 << 0)
+
+#define COMPAT_MT6577  (0x1 << 0)
+#define COMPAT_MT6589  (0x1 << 1)
+
+#define I2C_DRV_NAME   "mt-i2c"
+
+enu

[PATCH v5 3/3] I2C: mediatek: Add driver for MediaTek MT8173 I2C controller

2015-03-20 Thread Eddie Huang
Add mediatek MT8173 I2C controller driver. Compare to I2C controller
of earlier mediatek SoC, MT8173 fix write-then-read limitation, and
also increase message size to 64kb.

Signed-off-by: Xudong Chen 
Signed-off-by: Liguo Zhang 
Signed-off-by: Eddie Huang 
---
 drivers/i2c/busses/i2c-mt65xx.c | 107 
 1 file changed, 75 insertions(+), 32 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index 3940112..17607c8 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -33,10 +33,13 @@
 #include 
 #include 
 
+#define I2C_RS_TRANSFER(1 << 4)
 #define I2C_HS_NACKERR (1 << 2)
 #define I2C_ACKERR (1 << 1)
 #define I2C_TRANSAC_COMP   (1 << 0)
 #define I2C_TRANSAC_START  (1 << 0)
+#define I2C_RS_MUL_CNFG(1 << 15)
+#define I2C_RS_MUL_TRIG(1 << 14)
 #define I2C_TIMING_STEP_DIV_MASK   (0x3f << 0)
 #define I2C_TIMING_SAMPLE_COUNT_MASK   (0x7 << 0)
 #define I2C_TIMING_SAMPLE_DIV_MASK (0x7 << 8)
@@ -67,6 +70,9 @@
 #define MAX_MSG_NUM_MT6577 1
 #define MAX_DMA_TRANS_SIZE_MT6577  255
 #define MAX_WRRD_TRANS_SIZE_MT6577 31
+#define MAX_MSG_NUM_MT8173 65535
+#define MAX_DMA_TRANS_SIZE_MT8173  65535
+#define MAX_WRRD_TRANS_SIZE_MT8173 65535
 #define MAX_SAMPLE_CNT_DIV 8
 #define MAX_STEP_CNT_DIV   64
 #define MAX_HS_STEP_CNT_DIV8
@@ -81,6 +87,7 @@
 
 #define COMPAT_MT6577  (0x1 << 0)
 #define COMPAT_MT6589  (0x1 << 1)
+#define COMPAT_MT8173  (0x1 << 2)
 
 #define I2C_DRV_NAME   "mt-i2c"
 
@@ -172,6 +179,7 @@ struct mtk_i2c {
 static const struct of_device_id mtk_i2c_of_match[] = {
{ .compatible = "mediatek,mt6577-i2c", .data = (void *)COMPAT_MT6577 },
{ .compatible = "mediatek,mt6589-i2c", .data = (void *)COMPAT_MT6589 },
+   { .compatible = "mediatek,mt8173-i2c", .data = (void *)COMPAT_MT8173 },
{}
 };
 MODULE_DEVICE_TABLE(of, mtk_i2c_match);
@@ -236,7 +244,7 @@ static inline void mtk_i2c_init_hw(struct mtk_i2c *i2c)
else
mtk_i2c_writew(I2C_IO_CONFIG_OPEN_DRAIN, i2c, OFFSET_IO_CONFIG);
 
-   if (i2c->platform_compat & COMPAT_MT6577)
+   if (i2c->platform_compat & (COMPAT_MT6577 | COMPAT_MT8173))
mtk_i2c_writew(I2C_DCM_DISABLE, i2c, OFFSET_DCM_EN);
 
mtk_i2c_writew(i2c->timing_reg, i2c, OFFSET_TIMING);
@@ -320,10 +328,12 @@ static int i2c_set_speed(struct mtk_i2c *i2c, unsigned 
int clk_src_in_hz)
return 0;
 }
 
-static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs)
+static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
+   int num, int left_num)
 {
u16 addr_reg;
u16 control_reg;
+   u16 start_reg = 0;
u16 irqstat;
dma_addr_t rpaddr = 0;
dma_addr_t wpaddr = 0;
@@ -344,6 +354,8 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct 
i2c_msg *msgs)
control_reg |= I2C_CONTROL_RS;
if (i2c->op == I2C_MASTER_WRRD)
control_reg |= I2C_CONTROL_DIR_CHANGE | I2C_CONTROL_RS;
+   if (left_num >= 1)
+   control_reg |= I2C_CONTROL_RS;
mtk_i2c_writew(control_reg, i2c, OFFSET_CONTROL);
 
/* set start condition */
@@ -361,13 +373,13 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, 
struct i2c_msg *msgs)
mtk_i2c_writew(addr_reg, i2c, OFFSET_SLAVE_ADDR);
 
/* Clear interrupt status */
-   mtk_i2c_writew(I2C_HS_NACKERR | I2C_ACKERR | I2C_TRANSAC_COMP,
-   i2c, OFFSET_INTR_STAT);
+   mtk_i2c_writew(I2C_RS_TRANSFER | I2C_HS_NACKERR | I2C_ACKERR
+   | I2C_TRANSAC_COMP, i2c, OFFSET_INTR_STAT);
mtk_i2c_writew(I2C_FIFO_ADDR_CLR, i2c, OFFSET_FIFO_ADDR_CLR);
 
/* Enable interrupt */
-   mtk_i2c_writew(I2C_HS_NACKERR | I2C_ACKERR | I2C_TRANSAC_COMP,
-   i2c, OFFSET_INTR_MASK);
+   mtk_i2c_writew(I2C_RS_TRANSFER | I2C_HS_NACKERR | I2C_ACKERR
+   | I2C_TRANSAC_COMP, i2c, OFFSET_INTR_MASK);
 
/* Set transfer and transaction len */
if (i2c->op == I2C_MASTER_WRRD) {
@@ -376,7 +388,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct 
i2c_msg *msgs)
mtk_i2c_writew(I2C_WRRD_TRANAC_VALUE, i2c, OFFSET_TRANSAC_LEN);
} else {
mtk_i2c_writew(msgs->len, i2c, OFFSET_TRANSFER_LEN);
-   mtk_i2c_writew(I2C_RD_TRANAC_VALUE, i2c, OFFSET_TRANSAC_LEN);
+   mtk_i2c_writew(num, i2c, OFFSET_TRANSAC_LEN);
}
 
/* Prepare buffer data to start transfer */
@@ -422,7 +434,17 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct 
i2c_msg *msgs)
/* flush before sending start */
mb

[PATCH v5 0/3] ARM: mediatek: Add driver for Mediatek I2C controller

2015-03-20 Thread Eddie Huang
This series is for Mediatek SoCs I2C controller common bus driver.

Earlier MTK SoC ((for example, MT6589, MT8135)) I2C HW has some limitationes.
New generation SoC like MT8173 fix these limitations.

1. Only support one i2c_msg number. One exception is WRRD (write then read)
mode. WRRD can have two i2c_msg numbers.

2. Mediatek I2C controller support WRRD(write then read) mode, in WRRD
mode the Repeat Start will be issued between 2 messages.
In this driver if 2 messages is first write then read, the driver will
combine 2 messages using Write-Read mode so the RS will be issued between
the 2 messages.

3. The max transfer data length is 255 in one message. In WRRD mode, the
max data length of second msg is 31.

MT8135 and MT6589 can control I2C pins on PMIC(MT6397) by setting the i2c
registers in MT8135 side. In this case, driver should set OFFSET_PATH_DIR
bit first, the operation on other registers are still the same.
For now MT6589/MT8135 support this, MT6577/MT6595/MT8127 do not support.
For example, If want to use I2C4/5/6 pins on MT8135 just need to enable
the pinmux, else if want to use I2C pins on PMIC(MT6397) need to add
"mediatek,have-pmic" property in the .dts file of each platform.

This driver is based on 4.0-rc1.

Change in v5:
Apply new i2c_adapter_quirks patch [2]. Change to use dam_map_single to map
dma buffer. Add spinlock to fix race condition. Check of_property_read_u32
return value. Remove I2C_FUNC_10BIT_ADDR capability due to driver not implement.
Add MT8173 I2C driver.

Change in v4:
Modify to support i2c_adapter_quirks base on Wolfram's patch [1].
Remove check transfer size and WRRD combine code. Instead, fill quirk
property and let i2c_check_for_quirks to do the filter.


[1] 
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/314804.html
[2] 
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-February/325744.html

Eddie Huang (1):
  I2C: mediatek: Add driver for MediaTek MT8173 I2C controller

Xudong Chen (2):
  dt-bindings: Add I2C bindings for mt65xx/mt81xx.
  I2C: mediatek: Add driver for MediaTek I2C controller

 .../devicetree/bindings/i2c/i2c-mt6577.txt |  41 ++
 drivers/i2c/busses/Kconfig |   9 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-mt65xx.c| 748 +
 4 files changed, 799 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-mt6577.txt
 create mode 100644 drivers/i2c/busses/i2c-mt65xx.c

--
1.8.1.1.dirty


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tracing: add trace event for memory-failure

2015-03-20 Thread Xie XiuQi
On 2015/3/21 1:24, Luck, Tony wrote:
>> RAS user space tools like rasdaemon which base on trace event, could
>> receive mce error event, but no memory recovery result event. So, I
>> want to add this event to make this scenario complete.
> 
> Excellent answer.  Are you going to write that patch for rasdaemon?

Yes, I will ;-)

> 
> -Tony
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/3] rtc: mediatek: Add MT6397 RTC driver

2015-03-20 Thread Dmitry Torokhov
Hi Eddie,


On Tue, Mar 17, 2015 at 10:45 PM, Eddie Huang  wrote:
> +static int mtk_rtc_probe(struct platform_device *pdev)
> +{
> +   struct resource *res;
> +   struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);
> +   struct mt6397_rtc *rtc;
> +   int ret = 0;
> +
> +   rtc = devm_kzalloc(&pdev->dev, sizeof(struct mt6397_rtc), GFP_KERNEL);
> +   if (!rtc)
> +   return -ENOMEM;
> +
> +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +   rtc->addr_base = res->start;
> +   rtc->addr_range = res->end - res->start;
> +
> +   res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +   rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
> +   if (rtc->irq <= 0)
> +   goto out_rtc;
> +
> +   rtc->regmap = mt6397_chip->regmap;
> +   rtc->dev = &pdev->dev;
> +   mutex_init(&rtc->lock);
> +
> +   platform_set_drvdata(pdev, rtc);
> +
> +   ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
> +   mtk_rtc_irq_handler_thread,
> +   IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
> +   "mt6397-rtc", rtc);
> +   if (ret) {
> +   dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
> +   rtc->irq, ret);
> +   goto out_rtc;
> +   }
> +
> +   rtc->rtc_dev = rtc_device_register("mt6397-rtc", &pdev->dev,
> +   &mtk_rtc_ops, THIS_MODULE);
> +   if (IS_ERR(rtc->rtc_dev)) {
> +   dev_err(&pdev->dev, "register rtc device failed\n");
> +   return PTR_ERR(rtc->rtc_dev);
> +   }
> +
> +   device_init_wakeup(&pdev->dev, 1);
> +
> +   return 0;
> +
> +out_rtc:
> +   rtc_device_unregister(rtc->rtc_dev);

This is wrong. Whenever you jump to this label the RTC device has not
been registered yet.

> +   return ret;
> +
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 3/6] btwilink: add minimal device tree support

2015-03-20 Thread Marcel Holtmann
Hi Gigi,

> Add minimal device tree support to the btwilink driver that is used
> for binding bluetooth with the ti-st shared transport driver.
> 
> Signed-off-by: Eyal Reizer 
> Signed-off-by: bvijay 
> Signed-off-by: Gigi Joseph 
> ---
> Changes in v2:
>   * Reformat device_id table to match other drivers
>   * Add empty line before MODULE_DEVICE_TABLE
> 
> drivers/bluetooth/btwilink.c | 11 +++
> 1 file changed, 11 insertions(+)

I was wondering if you do not want to document this 
Documentation/devicetree/bindings/ or some place on what this entries actually 
means and how you use it.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Product Inquiry

2015-03-20 Thread Sales

Dear Sir/Madam,

Please can you kindly provide us the FOB price of your products and delivery 
time, i will kindly request your lowest competitive price and want a good 
dealing partner, our company will buy more once first business is successful.

I will kindly advise you send your full quotation. Please note this order is 
urgent.

Looking foward in doing business with you.

Best Regards

Kedar Baral
Procurement Mgr. - Base Supply Co. Inc.
1800-1888-5-888
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/6] btwilink: add minimal device tree support

2015-03-20 Thread Gigi Joseph
Add minimal device tree support to the btwilink driver that is used
for binding bluetooth with the ti-st shared transport driver.

Signed-off-by: Eyal Reizer 
Signed-off-by: bvijay 
Signed-off-by: Gigi Joseph 
---
Changes in v2:
* Reformat device_id table to match other drivers
* Add empty line before MODULE_DEVICE_TABLE

 drivers/bluetooth/btwilink.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
index 55c135b..ae64b2b 100644
--- a/drivers/bluetooth/btwilink.c
+++ b/drivers/bluetooth/btwilink.c
@@ -30,6 +30,7 @@
 
 #include 
 #include 
+#include 
 
 /* Bluetooth Driver Version */
 #define VERSION   "1.0"
@@ -286,6 +287,14 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct 
sk_buff *skb)
return 0;
 }
 
+static const struct of_device_id btwilink_of_match[] = {
+   { .compatible = "btwilink" },
+
+   { } /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(of, btwilink_of_match);
+
 static int bt_ti_probe(struct platform_device *pdev)
 {
static struct ti_st *hst;
@@ -349,6 +358,8 @@ static struct platform_driver btwilink_driver = {
.remove = bt_ti_remove,
.driver = {
.name = "btwilink",
+   .owner = THIS_MODULE,
+   .of_match_table = of_match_ptr(btwilink_of_match),
},
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Hello Dear

2015-03-20 Thread Morris Scott Niall



Hello Dear,

Hello my dear i know you will be very surprised to received this message
from me,how are you doing today,i hope you are fine.Anyway let me introduce
myself to you I am Engineer Scott Niall, am 47yrs old single,from Iceland
but i currently based in United kingdom (ENGLAND)I got your e-mail through
online searching,then i decided to contact you.Having said that,i want to
know you more, and I want to have a good relationship with you i hope you
don't mind.

E-mail me on this : morrisscot...@yahoo.com
I will sent you some of my picture,
Thanks waiting for your respond soon.
Regard
Morris Scott Niall
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] Add virtio-input driver.

2015-03-20 Thread Dmitry Torokhov
Hi Gerd,

On Fri, Mar 20, 2015 at 01:39:29PM +0100, Gerd Hoffmann wrote:
> virtio-input is basically evdev-events-over-virtio, so this driver isn't
> much more than reading configuration from config space and forwarding
> incoming events to the linux input layer.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  MAINTAINERS   |   6 +
>  drivers/virtio/Kconfig|  10 ++
>  drivers/virtio/Makefile   |   1 +
>  drivers/virtio/virtio_input.c | 335 
> ++
>  include/uapi/linux/Kbuild |   1 +
>  include/uapi/linux/virtio_ids.h   |   1 +
>  include/uapi/linux/virtio_input.h |  75 +
>  7 files changed, 429 insertions(+)
>  create mode 100644 drivers/virtio/virtio_input.c
>  create mode 100644 include/uapi/linux/virtio_input.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0e1abe8..585e6cd 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -10435,6 +10435,12 @@ S:   Maintained
>  F:   drivers/vhost/
>  F:   include/uapi/linux/vhost.h
>  
> +VIRTIO INPUT DRIVER
> +M:   Gerd Hoffmann 
> +S:   Maintained
> +F:   drivers/virtio/virtio_input.c
> +F:   include/uapi/linux/virtio_input.h
> +
>  VIA RHINE NETWORK DRIVER
>  M:   Roger Luethi 
>  S:   Maintained
> diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
> index b546da5..cab9f3f 100644
> --- a/drivers/virtio/Kconfig
> +++ b/drivers/virtio/Kconfig
> @@ -48,6 +48,16 @@ config VIRTIO_BALLOON
>  
>If unsure, say M.
>  
> +config VIRTIO_INPUT
> + tristate "Virtio input driver"
> + depends on VIRTIO
> + depends on INPUT
> + ---help---
> +  This driver supports virtio input devices such as
> +  keyboards, mice and tablets.
> +
> +  If unsure, say M.
> +
>   config VIRTIO_MMIO
>   tristate "Platform bus driver for memory mapped virtio devices"
>   depends on HAS_IOMEM
> diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
> index d85565b..41e30e3 100644
> --- a/drivers/virtio/Makefile
> +++ b/drivers/virtio/Makefile
> @@ -4,3 +4,4 @@ obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
>  virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o
>  virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o
>  obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
> +obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o
> diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
> new file mode 100644
> index 000..dd3215e
> --- /dev/null
> +++ b/drivers/virtio/virtio_input.c
> @@ -0,0 +1,335 @@
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +struct virtio_input {
> + struct virtio_device   *vdev;
> + struct input_dev   *idev;
> + char   name[64];
> + char   serial[64];
> + char   phys[64];
> + struct virtqueue   *evt, *sts;
> + struct virtio_input_event  evts[64];
> + struct mutex   lock;
> +};
> +
> +static ssize_t serial_show(struct device *dev,
> +struct device_attribute *attr, char *buf)
> +{
> + struct input_dev *idev = to_input_dev(dev);
> + struct virtio_input *vi = input_get_drvdata(idev);
> +
> + return sprintf(buf, "%s\n", vi->serial);
> +}
> +static DEVICE_ATTR_RO(serial);

Since serial is uniq and uniq is already exposed in sysfs by input core
please remove this attribute (and the rest of attribute group handling).

> +
> +static struct attribute *dev_attrs[] = {
> + &dev_attr_serial.attr,
> + NULL
> +};
> +
> +static umode_t dev_attrs_are_visible(struct kobject *kobj,
> +  struct attribute *a, int n)
> +{
> + struct device *dev = container_of(kobj, struct device, kobj);
> + struct input_dev *idev = to_input_dev(dev);
> + struct virtio_input *vi = input_get_drvdata(idev);
> +
> + if (a == &dev_attr_serial.attr && !strlen(vi->serial))
> + return 0;
> +
> + return a->mode;
> +}
> +
> +static struct attribute_group dev_attr_grp = {
> + .attrs =dev_attrs,
> + .is_visible =   dev_attrs_are_visible,
> +};
> +
> +static const struct attribute_group *dev_attr_groups[] = {
> + &dev_attr_grp,
> + NULL
> +};
> +
> +static void virtinput_queue_evtbuf(struct virtio_input *vi,
> +struct virtio_input_event *evtbuf)
> +{
> + struct scatterlist sg[1];
> +
> + sg_init_one(sg, evtbuf, sizeof(*evtbuf));
> + virtqueue_add_inbuf(vi->evt, sg, 1, evtbuf, GFP_ATOMIC);
> +}
> +
> +static void virtinput_recv_events(struct virtqueue *vq)
> +{
> + struct virtio_input *vi = vq->vdev->priv;
> + struct virtio_input_event *event;
> + unsigned int len;
> +
> + mutex_lock(&vi->lock);
> + while ((event = virtqueue_get_buf(vi->evt, &len)) != NULL) {
> + input_event(vi->idev,
> + le16_to_cpu(event->type),
> + le16_to_cpu(event->code),
> + 

Re: [PATCH] vfs: avoid recopying filename in getname_flags

2015-03-20 Thread Boqun Feng
Hi Al,

Ping and sorry to bother you.
Could you please have a look at my question? Thank you!

Regards,
Boqun Feng

On Wed, Mar 18, 2015 at 01:27:24PM +0800, Boqun Feng wrote:
> On Fri, Mar 13, 2015 at 09:45:59AM -0400, Paul Moore wrote:
> > On Monday, March 09, 2015 04:24:32 PM Boqun Feng wrote:
> > > Ping.
> > > Any opinion?
> > 
> > You might want to look at some of the recent changes to Al's 
> > vfs.git#for-next 
> > branch; at the very least it looks like your patch should be rebased 
> > against 
> > those changes.
> 
> Thank you for your reminder ;-)
> 
> After learning several changes on that branch, I get a question for
> commit ca160d0 "kill struct filename.separate".
>
> I think the two following situations explains how that commit works.
> (`iname` and `name` are fields in struct filename)
> 
> Not separate:
>|---PATH_MAX bytes by names_cachep --|
>|--struct filename--|---space for name---|
>^
>iname/name
> 
> name->iname == name->name is true
>  
> Separate:
>|--by kzalloc --|  |---PATH_MAX bytes by names_cachep---|
>|--struct filename--|..|---space for name---|
>^  ^
>iname  name
> 
> name->iname == name->name is false
> 
> However, I think of a third situation, which we were unlucky, that
> the bytes allocated by kzalloc and the bytes allocated by names_cachep
> somehow become continous, like the following situation:
> 
> Separate:
>|--by kzalloc --|---PATH_MAX bytes by names_cachep --|
>|--struct filename--|---space for name---|
>^  
>iname/name 
> 
> In this situation, the struct and the name are separate but 
> name->iname == name->name is true
> 
> Since struct filename is small, so kzalloc will call kmem_cache_alloc
> actually. As I don't know much about kmem_cache allocators, my question
> is "Can the 'unlucky' situation happen now?" If the answer is no, can it
> happen in the future considering there may be new kmem_cache allocating
> algorithms?
>
> Thanks and Best Regards,
> Boqun Feng
> 
> > 
> > > On Wed, Feb 25, 2015 at 8:31 PM, Boqun Feng  wrote:
> > > > In the current implementation of getname_flags, filename in the
> > > > user-space will be recopied if it takes more space that
> > > > EMBEDDED_NAME_MAX, however, at this moment, EMBEDDED_NAME_MAX bytes of
> > > > the filename are already copied into kernel space, the only reason why
> > > > the recopy is needed is that "kname" needs to be relocated.
> > > > 
> > > > And the recopy can be avoided if we change the memory layout of the
> > > > "names_cache" allocation. By putting the struct "filename" at the tail
> > > > of the allocation instead of the head, relocation of kname is avoided.
> > > > 
> > > > Once putting the struct at the tail, each byte in the user space will be
> > > > copied only one time, so the recopy is avoided and code is more clear.
> > > > 
> > > > Of course, other functions aware of the layout of the names_cache
> > > > allocation, i.e., getname_kernel and putname also need to be modified to
> > > > adapt to the new layout.
> > > > 
> > > > This patch is based on v4.0-rc1.
> > > > 
> > > > Cc: Al Viro 
> > > > Cc: Paul Moore 
> > > > Signed-off-by: Boqun Feng 
> > > > ---
> > > > 
> > > >  fs/namei.c | 50 +++---
> > > >  1 file changed, 31 insertions(+), 19 deletions(-)
> > > > 
> > > > diff --git a/fs/namei.c b/fs/namei.c
> > > > index c83145a..3be372b 100644
> > > > --- a/fs/namei.c
> > > > +++ b/fs/namei.c
> > > > @@ -133,21 +133,20 @@ getname_flags(const char __user *filename, int
> > > > flags, int *empty)> 
> > > > if (result)
> > > > 
> > > > return result;
> > > > 
> > > > -   result = __getname();
> > > > -   if (unlikely(!result))
> > > > +   kname = __getname();
> > > > +   if (unlikely(!kname))
> > > > 
> > > > return ERR_PTR(-ENOMEM);
> > > > 
> > > > -   result->refcnt = 1;
> > > > 
> > > > /*
> > > > 
> > > >  * First, try to embed the struct filename inside the 
> > > > names_cache
> > > >  * allocation
> > > >  */
> > > > 
> > > > -   kname = (char *)result + sizeof(*result);
> > > > +   result = (struct filename *)(kname + EMBEDDED_NAME_MAX);
> > > > 
> > > > result->name = kname;
> > > > result->separate = false;
> > > > 
> > > > +   result->refcnt = 1;
> > > > 
> > > > max = EMBEDDED_NAME_MAX;
> > > > 
> > > > -recopy:
> > > > len = strncpy_from_user(kname, filename, max);
> > > > if (unlikely(len < 0)) {
> > > > 
> > > > err = ERR_PTR(len);
> > > > 
> > > > @@ -157,23 +156,34 @@ recopy:
> > > > /*
> > > > 
> > > >  * Uh-oh. We have a name that's approaching PATH_MAX. Allocate a
> > > >  *

[PATCH] NFS: fix potential NULL deref in nfs_closedir()

2015-03-20 Thread Taesoo Kim
From: Byoungyoung Lee 

When filp->private_data is NULL, put_nfs_open_dir_context()
deferences its pointer (fi->list, fi->cred), similar to what
other file systems handle '.release' api (9p, cifs, btrfs, 
ext4, ocfs2).

Signed-off-by: Byoungyoung Lee 
Signed-off-by: Taesoo Kim 
---
 fs/nfs/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index c19e16f..434ecf1 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -133,7 +133,8 @@ out:
 static int
 nfs_closedir(struct inode *inode, struct file *filp)
 {
-   put_nfs_open_dir_context(file_inode(filp), filp->private_data);
+   if (filp->private_data)
+   put_nfs_open_dir_context(file_inode(filp), filp->private_data);
return 0;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] target fixes for v4.0-rc5

2015-03-20 Thread Nicholas A. Bellinger
Hi Linus,

Here are current target-pending fixes for v4.0-rc5 code that have made
their way into the queue over the last weeks.

Please go ahead and pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

The fixes this round include:

  - Fix long-standing iser-target logout bug related to early conn_logout_comp
completion, resulting in iscsi_conn use-after-tree OOpsen.  (Sagi + nab)

  - Fix long-standing tcm_fc bug in ft_invl_hw_context() failure handing
for DDP hw offload.  (DanC)

  - Fix incorrect use of unprotected __transport_register_session() in
tcm_qla2xxx + other single local se_node_acl fabrics.  (Bart)

  - Fix reference leak in target_submit_cmd() -> target_get_sess_cmd() for
ack_kref=1 failure path.  (Bart)

  - Fix pSCSI backend ->get_device_type() statistics OOPs with un-configured
device.  (Olaf + nab)

  - Fix virtual LUN=0 target_configure_device failure OOPs at modprobe time.
(Claudio + nab)

  - Fix FUA write false positive failure regression in v4.0-rc1 code.
(Christophe Vu-Brugier + HCH)

Thank you,

--nab

Bart Van Assche (3):
  tcm_qla2xxx: Fix incorrect use of __transport_register_session
  loop/usb/vhost-scsi/xen-scsiback: Fix use of
__transport_register_session
  target: Fix reference leak in target_get_sess_cmd() error path

Christophe Vu-Brugier (1):
  target: do not reject FUA CDBs when write cache is enabled but
emulate_write_cache is 0

Dan Carpenter (1):
  tcm_fc: missing curly braces in ft_invl_hw_context()

Nicholas Bellinger (5):
  target: Disallow changing of WRITE cache/FUA attrs after export
  Revert "iscsi-target: Avoid IN_LOGOUT failure case for iser-target"
  iscsi-target: Avoid early conn_logout_comp for iser connections
  target/pscsi: Fix NULL pointer dereference in get_device_type
  target: Fix virtual LUN=0 target_configure_device failure OOPs

 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  2 +-
 drivers/target/iscsi/iscsi_target.c| 14 +
 drivers/target/iscsi/iscsi_target_erl0.c   |  4 +---
 drivers/target/loopback/tcm_loop.c |  7 ++-
 drivers/target/target_core_device.c| 32 +++---
 drivers/target/target_core_pscsi.c |  2 +-
 drivers/target/target_core_sbc.c   |  3 +--
 drivers/target/target_core_spc.c   | 19 +++---
 drivers/target/target_core_transport.c |  4 
 drivers/target/tcm_fc/tfc_io.c |  3 ++-
 drivers/usb/gadget/legacy/tcm_usb_gadget.c |  5 ++---
 drivers/vhost/scsi.c   |  5 ++---
 drivers/xen/xen-scsiback.c |  7 ++-
 include/target/target_core_backend.h   |  1 +
 14 files changed, 61 insertions(+), 47 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 tip 0/9] tracing: attach eBPF programs to kprobes

2015-03-20 Thread Steven Rostedt
On Fri, 20 Mar 2015 16:30:01 -0700
Alexei Starovoitov  wrote:

> Hi Ingo,
> 
> I think it's good to go.
> Patch 1 is already in net-next. Patch 3 depends on it.
> I'm assuming it's not going to be a problem during merge window.
> Patch 3 will have a minor conflict in uapi/linux/bpf.h in linux-next,
> since net-next has added new lines to the bpf_prog_type and bpf_func_id enums.
> I'm assuming it's not a problem either.
> 
> V8->V9:
> - fixed comment style and allowed ispunct after %p
> - added Steven's Reviewed-by. Thanks Steven!

Hi Ingo,

I'm fine with this series, so don't let me hold it up from going into
your tree.

Thanks,

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1

2015-03-20 Thread Hanjun Guo

+CC Parth Dixit, Stefano Stabellini.

On 2015年03月21日 02:54, Will Deacon wrote:

On Thu, Mar 19, 2015 at 04:09:33AM +, Hanjun Guo wrote:

On 2015/3/19 3:05, Will Deacon wrote:

If you can get that in place, I'm not opposed to putting this into
linux-next ahead of the firmware summit in San Jose next week. Note that
this is not a commitment for 4.1, since I'm keen to see the outcomes of
next week before setting anything in stone.


OK, I will stick to this mailing list and respond as soon as I can.


This doesn't even build for me:


$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- allmodconfig
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image

[...]

In file included from drivers/xen/acpi.c:33:0:


Sorry, I didn't build ACPI with XEN enabled on ARM64.


include/xen/acpi.h: In function ‘xen_acpi_sleep_register’:
include/xen/acpi.h:102:3: error: ‘acpi_suspend_lowlevel’ undeclared (first use 
in this function)
acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;


acpi_suspend_lowlevel is defined only for X86 and IA64 for now.


^
include/xen/acpi.h:102:3: note: each undeclared identifier is reported only 
once for each function it appears in
drivers/xen/acpi.c: In function ‘xen_acpi_notify_hypervisor_state’:
drivers/xen/acpi.c:61:2: error: implicit declaration of function 
‘HYPERVISOR_dom0_op’ [-Werror=implicit-function-declaration]
   HYPERVISOR_dom0_op(&op);


And this is only for x86:
./arch/x86/include/asm/xen/hypercall.h:HYPERVISOR_dom0_op(struct 
xen_platform_op *platform_op)



   ^
cc1: some warnings being treated as errors
make[2]: *** [drivers/xen/acpi.o] Error 1
make[2]: *** Waiting for unfinished jobs
make[1]: *** [drivers/xen] Error 2
make[1]: *** Waiting for unfinished jobs
make: *** [drivers] Error 2


Am I missing some other patches?


No, you miss nothing. Parth Dixit is still working on XEN ACPI for
ARM64, before it's in full function, how about introduce a Kconfig
CONFIG_XEN_ACPI and let it depends on x86? when XEN ACPI for ARM64
comes, we can enable ARM64 for CONFIG_XEN_ACPI and fix the problems
above.

Stefano, Parth, what do you think?

Thanks
Hanjun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 2/2] x86, mce, severities: Define mce_severity function pointer

2015-03-20 Thread Aravind Gopalakrishnan


On 3/20/15 5:31 PM, Luck, Tony wrote:

+   default:
+   WARN_ONCE(1, "WTF!?");
+   break;

You meant to type:

mce_severity = mce_severity_default;

just there, right?

Other function pointers in the mce code like unexpected_machine_check 
and default_threshold_interrupt

are assigned to the respective function pointers when they are defined.

So, I just followed a similar assignment for mce_severity_default.

I can do that in the default statement if you prefer.

Thanks,
-Aravind.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next 0/5] NetCP: Add support for version 1.5

2015-03-20 Thread David Miller
From: Murali Karicheri 
Date: Fri, 20 Mar 2015 16:11:20 -0400

> NetCP 1.5 is used in newer K2 SoCs from Texas Instruments
> such as K2E, K2L etc. This patch series add support for Ethss
> driver for this version of NetCP. While at it, fix couple of
> bugs in the original driver.
> 
> One of the earlier patch "net: netcp: select davinci_mdio driver
> by default" is folded onto this series.
> 
> Please review and let me know your comments.

Series applied to net-next, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED

2015-03-20 Thread Rasmus Villemoes
With CONFIG_DEBUG_INFO_REDUCED, we do get quite a lot of debug info
(around 22.7 MB for a defconfig+DEBUG_INFO_REDUCED). However, the
"basenames must match" rule used by -femit-struct-debug-baseonly
option means that we miss some core data structures, such as struct
{device, file, inode, mm_struct, page} etc.

We can easily get these included as well, while still getting the
benefits of CONFIG_DEBUG_INFO_REDUCED (faster build times and smaller
individual object files): All it takes is a dummy translation unit
including a few strategic headers and compiled with a flag overriding
-femit-struct-debug-baseonly.

This increases the size of .debug_info by ~0.3%, but these 90 KB
contain some rather useful info.

Signed-off-by: Rasmus Villemoes 
---
 lib/Makefile |  3 +++
 lib/debug_info.c | 27 +++
 2 files changed, 30 insertions(+)
 create mode 100644 lib/debug_info.c

diff --git a/lib/Makefile b/lib/Makefile
index 58f74d2dd396..3d788091d60c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -45,6 +45,9 @@ CFLAGS_kobject.o += -DDEBUG
 CFLAGS_kobject_uevent.o += -DDEBUG
 endif
 
+obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
+CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
+
 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
 obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
 obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
diff --git a/lib/debug_info.c b/lib/debug_info.c
new file mode 100644
index ..2edbe27517ed
--- /dev/null
+++ b/lib/debug_info.c
@@ -0,0 +1,27 @@
+/*
+ * This file exists solely to ensure debug information for some core
+ * data structures is included in the final image even for
+ * CONFIG_DEBUG_INFO_REDUCED. Please do not add actual code. However,
+ * adding appropriate #includes is fine.
+ */
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: dsa: make NET_DSA manually selectable from the config

2015-03-20 Thread David Miller
From: Mathieu Olivari 
Date: Fri, 20 Mar 2015 18:31:03 -0700

> Change bd76a116707bd2381da36cf7c3183df11293f1d6 made all DSA drivers
> depend on NET_DSA rather than selecting them. However, as the only way
> to select this option was to actually select a driver, it made DSA
> impossible to enable at all.
> 
> This patch adds an explicit entry which the user will have to enable
> prior selecting a driver.
> 
> Signed-off-by: Mathieu Olivari 

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: dsa: make NET_DSA manually selectable from the config

2015-03-20 Thread Guenter Roeck

On 03/20/2015 06:31 PM, Mathieu Olivari wrote:

Change bd76a116707bd2381da36cf7c3183df11293f1d6 made all DSA drivers
depend on NET_DSA rather than selecting them. However, as the only way
to select this option was to actually select a driver, it made DSA
impossible to enable at all.

This patch adds an explicit entry which the user will have to enable
prior selecting a driver.



Fixes: bd76a116707b ("dsa: change "select" to "depends on" for NET_SWITCHDEV and for 
NET_DSA")


Signed-off-by: Mathieu Olivari 


Andrew found the same problem yesterday and was about to submit
the same patch...

Reviewed-by: Guenter Roeck 


---
  net/dsa/Kconfig | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 087e654..4f3cce1 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -5,9 +5,12 @@ config HAVE_NET_DSA
  # Drivers must select NET_DSA and the appropriate tagging format

  config NET_DSA
-   tristate
+   tristate "Distributed Switch Architecture"
depends on HAVE_NET_DSA && NET_SWITCHDEV
select PHYLIB
+   ---help---
+ Say Y if you want to enable support for the hardware switches 
supported
+ by the Distributed Switch Architecture.

  if NET_DSA




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: dsa: make NET_DSA manually selectable from the config

2015-03-20 Thread Mathieu Olivari
Change bd76a116707bd2381da36cf7c3183df11293f1d6 made all DSA drivers
depend on NET_DSA rather than selecting them. However, as the only way
to select this option was to actually select a driver, it made DSA
impossible to enable at all.

This patch adds an explicit entry which the user will have to enable
prior selecting a driver.

Signed-off-by: Mathieu Olivari 
---
 net/dsa/Kconfig | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 087e654..4f3cce1 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -5,9 +5,12 @@ config HAVE_NET_DSA
 # Drivers must select NET_DSA and the appropriate tagging format
 
 config NET_DSA
-   tristate
+   tristate "Distributed Switch Architecture"
depends on HAVE_NET_DSA && NET_SWITCHDEV
select PHYLIB
+   ---help---
+ Say Y if you want to enable support for the hardware switches 
supported
+ by the Distributed Switch Architecture.
 
 if NET_DSA
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 2/9] usb: gadget: add usb_gadget_start/stop()

2015-03-20 Thread Peter Chen
On Fri, Mar 20, 2015 at 01:08:25PM +0200, Roger Quadros wrote:
> On 20/03/15 11:46, Roger Quadros wrote:
> > On 20/03/15 09:18, Peter Chen wrote:
> >> On Thu, Mar 19, 2015 at 04:50:31PM +0200, Roger Quadros wrote:
> >>> On 19/03/15 16:09, Li Jun wrote:
>  On Thu, Mar 19, 2015 at 12:14:39PM +0200, Roger Quadros wrote:
> > On 19/03/15 05:30, Peter Chen wrote:
> >> On Wed, Mar 18, 2015 at 03:55:56PM +0200, Roger Quadros wrote:
> >>> The OTG state machine needs a mechanism to start and
> >>> stop the gadget controller. Add usb_gadget_start()
> >>> and usb_gadget_stop().
> >>>
> >>> Signed-off-by: Roger Quadros 
> >>> ---
> >>>  drivers/usb/gadget/udc/udc-core.c | 166 
> >>> +++---
> >>>  include/linux/usb/gadget.h|   3 +
> >>>  2 files changed, 158 insertions(+), 11 deletions(-)
> >>>
> >>> diff --git a/drivers/usb/gadget/udc/udc-core.c 
> >>> b/drivers/usb/gadget/udc/udc-core.c
> >>> index 5a81cb0..69b4123 100644
> >>> --- a/drivers/usb/gadget/udc/udc-core.c
> >>> +++ b/drivers/usb/gadget/udc/udc-core.c
> >>> @@ -35,6 +35,8 @@
> >>>   * @dev - the child device to the actual controller
> >>>   * @gadget - the gadget. For use by the class code
> >>>   * @list - for use by the udc class driver
> >>> + * @running - udc is running
> >>
> >> Doesn't OTG FSM should know it?
> >
> > Not really, as the gadget driver might not have been loaded yet or 
> > userspace might
> > have disabled softconnect when the OTG FSM wants UDC to start.
> >
> > So only UDC knows if it has really started or not based on this flag.
> >
> 
>  why this can not be known by check the otg fsm state? i.e. if the device 
>  in
>  b_peripheral or a_peripheral state, udc should had started, isn't it?
> >>>
> >>> If gadget function driver (which is different from UDC driver) is not yet 
> >>> loaded
> >>> then we can't start UDC even if otg fsm is in b_peripheral.
> >>> Also, if userspace has disabled softconnect we can't start UDC.
> >>>
> >>> So, b_peripheral != UDC_started.
> >>>
> >>> I've tried to address this issue by adding the checks in 
> >>> usb_gadget_start().
> >>>
> >>
> >> Ok, maybe we have different understanding for 'B-Device' at software,
> >> In spec, it says the Micro-AB receptacle with nothing connected can be
> >> 'B-Device', but in fact, we may not enable device mode before loading
> >> gadget driver, in chipidea fsm design, if the gadget driver is not
> >> loaded, the FSM will not start, and it is at OTG_STATE_UNDEFINED.
> > 
> > Right. I mixed up into thinking that we should respect the softconnect
> > while in OTG mode. It seems that we should ignore it.
> > 
> >>
> >> One more thing is we may need to find a place to issue SRP when we
> >> load gadget driver, since we may at b_idle  at that time due to host
> >> closes the vbus (timeout for a_wait_bcon).
> > 
> > Issuing SRP should be done by the otg-fsm and not udc-core.
> > The udc-core can at the least call usb_otg_kick_fsm() after setting the 
> > gadget
> > driver so that otg-fsm knows that we now have a valid gadget and can take
> > necessary action. i.e. change from b_idle to b_srp_init and then to 
> > b_peripheral.
> 
> To clarify further. Is it right to assume that OTG FSM will not be started 
> till
> both gadget UDC driver _AND_ gadget function driver are loaded?
> 
> And it will be stopped when either of them unloads.
> 
> This simplifies things a lot.

Yes, you are right.

> 
> cheers,
> -roger
> 
> > 
> >>
> >> What is the "softconnect" used for? In otg fsm, we use b_bus_req for FSM.
> >>
> > I understand now that we shouldn't bother with softconnect when we are in 
> > OTG fsm mode.
> > That solves our problem with the running flags.
> > 
> > So now, b_peripheral == UDC_started.
> > 
> > I will address this in v2.
> > 
> > cheers,
> > -roger
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4] ptp/clcok:Introduce the setktime/getktime interfaces with "ktime_t" type

2015-03-20 Thread Arnd Bergmann
On Friday 20 March 2015, Richard Cochran wrote:
> Instead of changing to ktime_t, just use timespec64 instead.  That
> way, each change will be a couple of lines per file.

This was the first idea, but it seems a bit silly when all the drivers
use a 64-bit nanosecond value just like ktime_t. While both of the
current users require a timespec at the moment, it's possible that
there would one day be a third user that actually can make sense of
a ktime_t, and then we'd avoid the expensive back-and-forth conversion.

For now, using ktime_t in the interface merely simplifies the drivers
by moving the conversion into the subsystem, but it is not any more
or less efficient than the previous method.

> > I do agree however that we should merge the entire series at once so
> > we end up with a reasonable state afterwards, and we only need the 
> > conditional
> > in order to have a bisectable git history.
> 
> It is still bisectable with one or two patches.

Of course, but it would be rather bad style.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-20 Thread Lino Sanfilippo
On 21.03.2015 02:01, Lino Sanfilippo wrote:

>> Should that be (marks_mask & FS_ISDIR & marks_ignored_mask)?
>> 
> 
> No, the current logic should be correct, since we want events for
> directories if we have FS_ISDIR set in the marks mask but not in its
> ignored_mask.
> 

Actually this should be: "... since we ONLY want events for directories
if we have FS_ISDIR set in the marks mask but not in its ignored_mask".

With Fabians Code we could even get events for dirs although FAN_ONDIR
has not been set - which is not what we want.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 00/47] mtrr/x86/drivers: bury MTRR

2015-03-20 Thread Andy Lutomirski
On Fri, Mar 20, 2015 at 4:17 PM, Luis R. Rodriguez
 wrote:
> From: "Luis R. Rodriguez" 
>
> When a system has PAT support enabled you don't need to be
> using MTRRs. Andy had added arch_phys_wc_add() long ago to
> help with this but not all drivers were converted over. We
> have to take care to only convert drivers where we know that
> the proper ioremap_wc() API has been used. Doing this requires
> a bit of work on verifying the driver split out the ioremap'd
> areas -- and if not doing that ourselves. Verifying a driver
> uses the same areas can be hard but with a bit of love Coccinelle
> can help with that.
>
> We're motivated to change drivers for a few reasons:
>
> 1) Take advantage of PAT when available
>
> 2) Help with the goal of eventually using _PAGE_CACHE_UC over
>_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

Nice!

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] regulator: stw481x: Remove unused fields from struct stw481x

2015-03-20 Thread Mark Brown
On Fri, Mar 20, 2015 at 07:53:06AM +0800, Axel Lin wrote:
> The mutex lock is not used at all, remove it.
> The *vmmc_regulator is not necessary, use a local variable in
> stw481x_vmmc_regulator_probe() instead.
> 

Applied, thanks.


signature.asc
Description: Digital signature


[PATCH v4] dt-bindings: brcm: rationalize Broadcom documentation naming

2015-03-20 Thread Scott Branden
This patchset attempts to standardize the naming of dt-bindings
documents based on the Broadcom vendor prefix of brcm.

Although there are no guidelines currently present for how to name
the dt-bindings document the "vendor,binding.txt" style is in use by
some of the other vendors.

Acked-by: Lee Jones 
Acked-by: Florian Fainelli 
Acked-by: Gregory Fong 
Acked-by: Stephen Warren 
Signed-off-by: Scott Branden 
---
 .../arm/bcm/{brcm,bcm11351-cpu-method => brcm,bcm11351-cpu-method.txt}| 0
 .../devicetree/bindings/arm/bcm/{bcm11351.txt => brcm,bcm11351.txt}   | 0
 .../devicetree/bindings/arm/bcm/{bcm21664.txt => brcm,bcm21664.txt}   | 0
 .../devicetree/bindings/arm/{bcm2835.txt => bcm/brcm,bcm2835.txt} | 0
 .../devicetree/bindings/arm/{bcm4708.txt => bcm/brcm,bcm4708.txt} | 0
 .../devicetree/bindings/arm/bcm/{bcm63138.txt => brcm,bcm63138.txt}   | 0
 .../devicetree/bindings/arm/{brcm-brcmstb.txt => bcm/brcm,brcmstb.txt}| 0
 Documentation/devicetree/bindings/arm/bcm/{cygnus.txt => brcm,cygnus.txt} | 0
 Documentation/devicetree/bindings/bus/{bcma.txt => brcm,bus-axi.txt}  | 0
 .../devicetree/bindings/clock/{bcm-kona-clock.txt => brcm,kona-ccu.txt}   | 0
 .../devicetree/bindings/dma/{bcm2835-dma.txt => brcm,bcm2835-dma.txt} | 0
 .../devicetree/bindings/gpio/{gpio-bcm-kona.txt => brcm,kona-gpio.txt}| 0
 .../devicetree/bindings/i2c/{i2c-bcm-kona.txt => brcm,kona-i2c.txt}   | 0
 Documentation/devicetree/bindings/mfd/{bcm590xx.txt => brcm,bcm59056.txt} | 0
 .../bindings/mips/brcm/{bcm3384-intc.txt => brcm,bcm3384-intc.txt}| 0
 Documentation/devicetree/bindings/mips/brcm/{bmips.txt => brcm,bmips.txt} | 0
 .../devicetree/bindings/mips/brcm/{cm-dsl.txt => brcm,cm-dsl.txt} | 0
 Documentation/devicetree/bindings/misc/{smc.txt => brcm,kona-smc.txt} | 0
 .../devicetree/bindings/mmc/{kona-sdhci.txt => brcm,kona-sdhci.txt}   | 0
 .../bindings/net/{broadcom-sf2.txt => brcm,bcm7445-switch-v4.0.txt}   | 0
 .../devicetree/bindings/net/{broadcom-bcmgenet.txt => brcm,bcmgenet.txt}  | 0
 .../bindings/net/{broadcom-systemport.txt => brcm,systemport.txt} | 0
 .../bindings/net/{broadcom-mdio-unimac.txt => brcm,unimac-mdio.txt}   | 0
 .../devicetree/bindings/phy/{bcm-phy.txt => brcm,kona-usb2-phy.txt}   | 0
 .../devicetree/bindings/pwm/{bcm-kona-pwm.txt => brcm,kona-pwm.txt}   | 0
 .../{arm/bcm/kona-resetmgr.txt => reset/brcm,bcm21664-resetmgr.txt}   | 0
 .../bindings/serial/{bcm63xx-uart.txt => brcm,bcm6345-uart.txt}   | 0
 .../devicetree/bindings/sound/{bcm2835-i2s.txt => brcm,bcm2835-i2s.txt}   | 0
 .../bindings/{arm/bcm/kona-timer.txt => timer/brcm,kona-timer.txt}| 0
 .../devicetree/bindings/{mips/brcm/usb.txt => usb/brcm,bcm3384-usb.txt}   | 0
 .../bindings/{arm/bcm/kona-wdt.txt => watchdog/brcm,kona-wdt.txt} | 0
 31 files changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/arm/bcm/{brcm,bcm11351-cpu-method => 
brcm,bcm11351-cpu-method.txt} (100%)
 rename Documentation/devicetree/bindings/arm/bcm/{bcm11351.txt => 
brcm,bcm11351.txt} (100%)
 rename Documentation/devicetree/bindings/arm/bcm/{bcm21664.txt => 
brcm,bcm21664.txt} (100%)
 rename Documentation/devicetree/bindings/arm/{bcm2835.txt => 
bcm/brcm,bcm2835.txt} (100%)
 rename Documentation/devicetree/bindings/arm/{bcm4708.txt => 
bcm/brcm,bcm4708.txt} (100%)
 rename Documentation/devicetree/bindings/arm/bcm/{bcm63138.txt => 
brcm,bcm63138.txt} (100%)
 rename Documentation/devicetree/bindings/arm/{brcm-brcmstb.txt => 
bcm/brcm,brcmstb.txt} (100%)
 rename Documentation/devicetree/bindings/arm/bcm/{cygnus.txt => 
brcm,cygnus.txt} (100%)
 rename Documentation/devicetree/bindings/bus/{bcma.txt => brcm,bus-axi.txt} 
(100%)
 rename Documentation/devicetree/bindings/clock/{bcm-kona-clock.txt => 
brcm,kona-ccu.txt} (100%)
 rename Documentation/devicetree/bindings/dma/{bcm2835-dma.txt => 
brcm,bcm2835-dma.txt} (100%)
 rename Documentation/devicetree/bindings/gpio/{gpio-bcm-kona.txt => 
brcm,kona-gpio.txt} (100%)
 rename Documentation/devicetree/bindings/i2c/{i2c-bcm-kona.txt => 
brcm,kona-i2c.txt} (100%)
 rename Documentation/devicetree/bindings/mfd/{bcm590xx.txt => 
brcm,bcm59056.txt} (100%)
 rename Documentation/devicetree/bindings/mips/brcm/{bcm3384-intc.txt => 
brcm,bcm3384-intc.txt} (100%)
 rename Documentation/devicetree/bindings/mips/brcm/{bmips.txt => 
brcm,bmips.txt} (100%)
 rename Documentation/devicetree/bindings/mips/brcm/{cm-dsl.txt => 
brcm,cm-dsl.txt} (100%)
 rename Documentation/devicetree/bindings/misc/{smc.txt => brcm,kona-smc.txt} 
(100%)
 rename Documentation/devicetree/bindings/mmc/{kona-sdhci.txt => 
brcm,kona-sdhci.txt} (100%)
 rename Documentation/devicetree/bindings/net/{broadcom-sf2.txt => 
brcm,bcm7445-switch-v4.0.txt} (100%)
 rename Documentation/devicetree/bindings/net/{broadcom-bcmgenet.txt => 
brcm,bcmgenet.txt} (100%)
 rename Documentation/devicetree/bindings/net/{broadcom-systemport.txt => 
brcm,sy

[PATCH v1 47/47] mtrr: bury MTRR - unexport mtrr_add() and mtrr_del()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The crusade to replace mtrr_add() with architecture agnostic
arch_phys_wc_add() is complete, this will ensure write-combining
implementations (PAT on x86) is taken advantage instead of using
MTRR. With the crusade done now, hide direct MTRR access for
drivers.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 arch/x86/kernel/cpu/mtrr/main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index b68b671..f0e19db 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -446,7 +446,6 @@ int mtrr_add(unsigned long base, unsigned long size, 
unsigned int type,
return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
 increment);
 }
-EXPORT_SYMBOL(mtrr_add);
 
 /**
  * mtrr_del_page - delete a memory type region
@@ -535,7 +534,6 @@ int mtrr_del(int reg, unsigned long base, unsigned long 
size)
return -EINVAL;
return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
 }
-EXPORT_SYMBOL(mtrr_del);
 
 /**
  * __arch_phys_wc_add - add a WC MTRR even if PAT is available
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 46/47] video: fbdev: gxt4500: use pci_ioremap_wc_bar() for framebuffer

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The driver doesn't use mtrr_add() or arch_phys_wc_add() but
since we know the framebuffer is isolated already on an
ioremap() we can take advantage of write combining for
performance where possible.

In this case there are a few motivations for this:

a) Take advantage of PAT when available

b) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/gxt4500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/gxt4500.c b/drivers/video/fbdev/gxt4500.c
index 135d78a..f19133a 100644
--- a/drivers/video/fbdev/gxt4500.c
+++ b/drivers/video/fbdev/gxt4500.c
@@ -662,7 +662,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
info->fix.smem_start = fb_phys;
info->fix.smem_len = pci_resource_len(pdev, 1);
-   info->screen_base = pci_ioremap_bar(pdev, 1);
+   info->screen_base = pci_ioremap_wc_bar(pdev, 1);
if (!info->screen_base) {
dev_err(&pdev->dev, "gxt4500: cannot map framebuffer\n");
goto err_unmap_regs;
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-20 Thread Lino Sanfilippo
On 20.03.2015 22:09, Andrew Morton wrote:
> On Fri, 20 Mar 2015 21:56:08 +0100 Fabian Frederick  wrote:
> 
>> ltp/fanotify02 was locked since commit 66ba93c0d7fe
>> ("fanotify: don't set FAN_ONDIR implicitly on a marks ignored mask")
> 
> What does "ltp/fanotify02 was locked" mean?  That this particular test
> failed to exit, or...?
> 
>> --- a/fs/notify/fanotify/fanotify.c
>> +++ b/fs/notify/fanotify/fanotify.c
>> @@ -140,8 +140,8 @@ static bool fanotify_should_send_event(struct 
>> fsnotify_mark *inode_mark,
>>  }
>>  
>>  if (d_is_dir(path->dentry) &&
>> -!(marks_mask & FS_ISDIR & ~marks_ignored_mask))
>> -return false;
>> +(marks_mask & FS_ISDIR & ~marks_ignored_mask))
>> +return true;
> 
> Should that be (marks_mask & FS_ISDIR & marks_ignored_mask)?
> 

No, the current logic should be correct, since we want events for
directories if we have FS_ISDIR set in the marks mask but not in its
ignored_mask.

Regards,
Lino
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 45/47] video: fbdev: geode gxfb: use ioremap_wc() for framebuffer

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The driver doesn't use mtrr_add() or arch_phys_wc_add() but
since we know the framebuffer is isolated already on an
ioremap() we can take advantage of write combining for
performance where possible.

In this case there are a few motivations for this:

a) Take advantage of PAT when available

b) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/geode/gxfb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/geode/gxfb_core.c 
b/drivers/video/fbdev/geode/gxfb_core.c
index 124d7c7..ec9fc9a 100644
--- a/drivers/video/fbdev/geode/gxfb_core.c
+++ b/drivers/video/fbdev/geode/gxfb_core.c
@@ -263,7 +263,8 @@ static int gxfb_map_video_memory(struct fb_info *info, 
struct pci_dev *dev)
 
info->fix.smem_start = pci_resource_start(dev, 0);
info->fix.smem_len = vram ? vram : gx_frame_buffer_size();
-   info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
+   info->screen_base = ioremap_wc(info->fix.smem_start,
+  info->fix.smem_len);
if (!info->screen_base)
return -ENOMEM;
 
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-20 Thread Lino Sanfilippo
Hi,

On 20.03.2015 21:56, Fabian Frederick wrote:
> ltp/fanotify02 was locked since commit 66ba93c0d7fe
> ("fanotify: don't set FAN_ONDIR implicitly on a marks ignored mask")
> 
> Signed-off-by: Fabian Frederick 
> ---
>  fs/notify/fanotify/fanotify.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index d2f97ec..7b3a50b 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -140,8 +140,8 @@ static bool fanotify_should_send_event(struct 
> fsnotify_mark *inode_mark,
>   }
>  
>   if (d_is_dir(path->dentry) &&
> - !(marks_mask & FS_ISDIR & ~marks_ignored_mask))
> - return false;
> + (marks_mask & FS_ISDIR & ~marks_ignored_mask))
> + return true;
>  
>   if (event_mask & FAN_ALL_OUTGOING_EVENTS & marks_mask &
>~marks_ignored_mask)
> 

I dont think that this is an issue in kernel code. The test code tries
to get events for the current directory but never sets the FAN_ONDIR
flag for the concerning mark - so it hangs because it is waiting for
events that are never generated. Adding FAN_ONDIR to the set of mark
flags should fix the test code.

Regards,
Lino
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 44/47] video: fbdev: atmel_lcdfb: use ioremap_wc() for framebuffer

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The driver doesn't use mtrr_add() or arch_phys_wc_add() but
since we know the framebuffer is isolated already on an
ioremap() we can take advantage of write combining for
performance where possible.

In this case there are a few motivations for this:

a) Take advantage of PAT when available

b) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/atmel_lcdfb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/atmel_lcdfb.c 
b/drivers/video/fbdev/atmel_lcdfb.c
index 94a8d04..abadc49 100644
--- a/drivers/video/fbdev/atmel_lcdfb.c
+++ b/drivers/video/fbdev/atmel_lcdfb.c
@@ -1266,7 +1266,8 @@ static int __init atmel_lcdfb_probe(struct 
platform_device *pdev)
goto stop_clk;
}
 
-   info->screen_base = ioremap(info->fix.smem_start, 
info->fix.smem_len);
+   info->screen_base = ioremap_wc(info->fix.smem_start,
+  info->fix.smem_len);
if (!info->screen_base) {
ret = -ENOMEM;
goto release_intmem;
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/2] Input: touchscreen-iproc: add device tree bindings

2015-03-20 Thread Jonathan Richardson
Documents the touchscreen device tree binding for Broadcom iProc family
of SoCs.

Reviewed-by: Scott Branden 
Tested-by: Scott Branden 
Signed-off-by: Jonathan Richardson 
---
 .../input/touchscreen/brcm,iproc-touchscreen.txt   |   76 
 1 file changed, 76 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
 
b/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
new file mode 100644
index 000..34e3382
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
@@ -0,0 +1,76 @@
+* Broadcom's IPROC Touchscreen Controller
+
+Required properties:
+- compatible: must be "brcm,iproc-touchscreen"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- clocks:  The clock provided by the SOC to driver the tsc
+- clock-name:  name for the clock
+- interrupts: The touchscreen controller's interrupt
+
+Optional properties:
+- scanning_period: Time between scans. Each step is 1024 us.  Valid 1-256.
+- debounce_timeout: Each step is 512 us.  Valid 0-255
+- settling_timeout: The settling duration (in ms) is the amount of time
+the tsc waits to allow the voltage to settle after
+turning on the drivers in detection mode.
+Valid values: 0-11
+0 =  0.008 ms
+1 =  0.01 ms
+2 =  0.02 ms
+3 =  0.04 ms
+4 =  0.08 ms
+5 =  0.16 ms
+6 =  0.32 ms
+7 =  0.64 ms
+8 =  1.28 ms
+9 =  2.56 ms
+   10 =  5.12 ms
+   11 = 10.24 ms
+- touch_timeout: The continuous number of scan periods in which touch is
+not detected before the controller returns to idle state.
+Valid values 0-255.
+- average_data: Number of data samples which are averaged before a final
+data point is placed into the FIFO
+Valid values 0-7
+0 =   1 sample
+1 =   2 samples
+2 =   4 samples
+3 =   8 samples
+4 =  16 samples
+5 =  32 samples
+6 =  64 samples
+7 = 128 samples
+- fifo_threshold: Interrupt is generated whenever the number of fifo
+entries exceeds this value
+Valid values 0-31
+- touchscreen-size-x: horizontal resolution of touchscreen (in pixels)
+- touchscreen-size-y: vertical resolution of touchscreen (in pixels)
+- touchscreen-fuzz-x: horizontal noise value of the absolute input
+  device (in pixels)
+- touchscreen-fuzz-y: vertical noise value of the absolute input
+  device (in pixels)
+- touchscreen-inverted-x: X axis is inverted (boolean)
+- touchscreen-inverted-y: Y axis is inverted (boolean)
+
+Example:
+
+   touchscreen: tsc@0x180A6000 {
+   compatible = "brcm,iproc-touchscreen";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0x180A6000 0x40>;
+   clocks = <&adc_clk>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+
+   scanning_period = <5>;
+   debounce_timeout = <40>;
+   settling_timeout = <7>;
+   touch_timeout = <10>;
+   average_data = <5>;
+   fifo_threshold = <1>;
+   /* Touchscreen is rotated 180 degrees. */
+   touchscreen-inverted-x;
+   touchscreen-inverted-y;
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/2] Input: touchscreen-iproc: Add Broadcom iProc touchscreen driver

2015-03-20 Thread Jonathan Richardson
Add initial version of the Broadcom touchscreen driver.

Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
Tested-by: Scott Branden 
Signed-off-by: Jonathan Richardson 
---
 drivers/input/touchscreen/Kconfig |   11 +
 drivers/input/touchscreen/Makefile|1 +
 drivers/input/touchscreen/bcm_iproc_tsc.c |  518 +
 3 files changed, 530 insertions(+)
 create mode 100644 drivers/input/touchscreen/bcm_iproc_tsc.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 6261fd6..4a8b0e5 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -323,6 +323,17 @@ config TOUCHSCREEN_ILI210X
  To compile this driver as a module, choose M here: the
  module will be called ili210x.
 
+config TOUCHSCREEN_IPROC
+   tristate "IPROC touch panel driver support"
+   help
+ Say Y here if you want to add support for the IPROC touch
+ controller to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bcm_iproc_tsc.
+
 config TOUCHSCREEN_S3C2410
tristate "Samsung S3C2410/generic touchscreen input driver"
depends on ARCH_S3C24XX || SAMSUNG_DEV_TS
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 0242fea..68f69bc 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_TOUCHSCREEN_GOODIX)  += goodix.o
 obj-$(CONFIG_TOUCHSCREEN_ILI210X)  += ili210x.o
 obj-$(CONFIG_TOUCHSCREEN_INEXIO)   += inexio.o
 obj-$(CONFIG_TOUCHSCREEN_INTEL_MID)+= intel-mid-touch.o
+obj-$(CONFIG_TOUCHSCREEN_IPROC)+= bcm_iproc_tsc.o
 obj-$(CONFIG_TOUCHSCREEN_LPC32XX)  += lpc32xx_ts.o
 obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o
 obj-$(CONFIG_TOUCHSCREEN_MC13783)  += mc13783_ts.o
diff --git a/drivers/input/touchscreen/bcm_iproc_tsc.c 
b/drivers/input/touchscreen/bcm_iproc_tsc.c
new file mode 100644
index 000..c02a015
--- /dev/null
+++ b/drivers/input/touchscreen/bcm_iproc_tsc.c
@@ -0,0 +1,518 @@
+/*
+* Copyright (C) 2015 Broadcom Corporation
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation version 2.
+*
+* This program is distributed "as is" WITHOUT ANY WARRANTY of any
+* kind, whether express or implied; without even the implied warranty
+* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IPROC_TS_NAME "iproc-ts"
+
+#define PEN_DOWN_STATUS 1
+#define PEN_UP_STATUS   0
+
+#define X_MIN   0
+#define Y_MIN   0
+#define X_MAX   0xFFF
+#define Y_MAX   0xFFF
+
+/* Value given by controller for invalid coordinate. */
+#define INVALID_COORD   0x
+
+/* Register offsets */
+#define REGCTL1 0x00
+#define REGCTL2 0x04
+#define INTERRUPT_THRES 0x08
+#define INTERRUPT_MASK  0x0c
+
+#define INTERRUPT_STATUS0x10
+#define CONTROLLER_STATUS   0x14
+#define FIFO_DATA   0x18
+#define FIFO_DATA_X_Y_MASK  0x
+#define ANALOG_CONTROL  0x1c
+
+#define AUX_DATA0x20
+#define DEBOUNCE_CNTR_STAT  0x24
+#define SCAN_CNTR_STAT  0x28
+#define REM_CNTR_STAT   0x2c
+
+#define SETTLING_TIMER_STAT 0x30
+#define SPARE_REG   0x34
+#define SOFT_BYPASS_CONTROL 0x38
+#define SOFT_BYPASS_DATA0x3c
+
+
+/* Bit values for INTERRUPT_MASK and INTERRUPT_STATUS regs */
+#define TS_PEN_INTR_MASKBIT(0)
+#define TS_FIFO_INTR_MASK   BIT(2)
+
+/* Bit values for CONTROLLER_STATUS reg1 */
+#define TS_PEN_DOWN BIT(0)
+
+/* Shift values for control reg1 */
+#define SCANNING_PERIOD_SHIFT   24
+#define DEBOUNCE_TIMEOUT_SHIFT  16
+#define SETTLING_TIMEOUT_SHIFT  8
+#define TOUCH_TIMEOUT_SHIFT 0
+
+/* Shift values for coordinates from fifo */
+#define X_COORD_SHIFT  0
+#define Y_COORD_SHIFT  16
+
+/* Bit values for REGCTL2 */
+#define TS_CONTROLLER_EN_BITBIT(16)
+#define TS_CONTROLLER_AVGDATA_SHIFT 8
+#define TS_CONTROLLER_AVGDATA_MASK (0x7 << TS_CONTROLLER_AVGDATA_SHIFT)
+#define TS_CONTROLLER_PWR_LDO   BIT(5)
+#define TS_CONTROLLER_PWR_ADC   BIT(4)
+#define TS_CONTROLLER_PWR_BGP   BIT(3)
+#define TS_CONTROLLER_PWR_TSBIT(2)
+#define TS_WIRE_MODE_BITBIT(1)
+
+#define dbg_reg(dev, priv, reg) \
+   dev_dbg(dev, "%20s= 0x%08x\n", #reg, readl((priv)->regs + reg))
+
+struct tsc_param {
+   /* Each step is 1024 us.  Valid 1-256 */
+   u32 scanning_period;
+
+   /*  Each step is 512 us.  Valid 0-255 */
+   u32 debounce_timeout;
+
+   /*
+* The settling 

[PATCH v5 0/2] Add support for Broadcom iProc touchscreen

2015-03-20 Thread Jonathan Richardson
This patchset contains initial support for the touchscreen on the Broadcom
iProc family of SoCs. This driver has been validated with Cygnus and is expected
to work on other iProc family of SoCs that use the same touchscreen controller.

Changes from v4:
- Debug code cleanup.
- pdev wasn't initialized prior to calling get_tsc_config() in probe resulting
  in null dev pointer being passed to the function.

Changes from v3:
- Fixed typo in Kconfig.

Changes from v2:
- Misc style changes.
- Removed assumptions about interrupts generated in ISR. It now emits all
  events and then syncs if necessary.
- Removed our rotation property and replaced with the latest
  touchscreen-inverted-x/y. Also added support for the standard optional
  properties touchscreen-size-x/y and touchscreen-fuzz-x/y. Did not add support
  for inverted-x/y at this time as our touchscreen is currently only oriented
  180 degres.

Changes from v1:
- Add missing newlines to debug messages
- Use BIT macro for defines
- Fix logic in get_tsc_config to improve readability
- Get rid of unnecessary remove() function

Jonathan Richardson (2):
  Input: touchscreen-iproc: Add Broadcom iProc touchscreen driver
  Input: touchscreen-iproc: add device tree bindings

 .../input/touchscreen/brcm,iproc-touchscreen.txt   |   76 +++
 drivers/input/touchscreen/Kconfig  |   11 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/bcm_iproc_tsc.c  |  518 
 4 files changed, 606 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
 create mode 100644 drivers/input/touchscreen/bcm_iproc_tsc.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 43/47] video: fbdev: vt8623fb: use arch_phys_wc_add() and pci_iomap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/vt8623fb.c | 31 ++-
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c
index ea7f056..60f24828 100644
--- a/drivers/video/fbdev/vt8623fb.c
+++ b/drivers/video/fbdev/vt8623fb.c
@@ -26,13 +26,9 @@
 #include  /* Why should fb driver call console functions? 
because console_lock() */
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 struct vt8623fb_info {
char __iomem *mmio_base;
-   int mtrr_reg;
+   int wc_cookie;
struct vgastate state;
struct mutex open_lock;
unsigned int ref_count;
@@ -99,10 +95,7 @@ static struct svga_timing_regs vt8623_timing_regs = {
 /* Module parameters */
 
 static char *mode_option = "640x480-8@60";
-
-#ifdef CONFIG_MTRR
 static int mtrr = 1;
-#endif
 
 MODULE_AUTHOR("(c) 2006 Ondrej Zajicek ");
 MODULE_LICENSE("GPL");
@@ -112,11 +105,8 @@ module_param(mode_option, charp, 0644);
 MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
 module_param_named(mode, mode_option, charp, 0);
 MODULE_PARM_DESC(mode, "Default video mode e.g. '648x480-8@60' (deprecated)");
-
-#ifdef CONFIG_MTRR
 module_param(mtrr, int, 0444);
 MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, 
default=1)");
-#endif
 
 
 /* - */
@@ -710,7 +700,7 @@ static int vt8623_pci_probe(struct pci_dev *dev, const 
struct pci_device_id *id)
info->fix.mmio_len = pci_resource_len(dev, 1);
 
/* Map physical IO memory address into kernel space */
-   info->screen_base = pci_iomap(dev, 0, 0);
+   info->screen_base = pci_iomap_wc(dev, 0, 0);
if (! info->screen_base) {
rc = -ENOMEM;
dev_err(info->device, "iomap for framebuffer failed\n");
@@ -781,12 +771,9 @@ static int vt8623_pci_probe(struct pci_dev *dev, const 
struct pci_device_id *id)
/* Record a reference to the driver data */
pci_set_drvdata(dev, info);
 
-#ifdef CONFIG_MTRR
-   if (mtrr) {
-   par->mtrr_reg = -1;
-   par->mtrr_reg = mtrr_add(info->fix.smem_start, 
info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
-   }
-#endif
+   if (mtrr)
+   par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
+ info->fix.smem_len);
 
return 0;
 
@@ -816,13 +803,7 @@ static void vt8623_pci_remove(struct pci_dev *dev)
if (info) {
struct vt8623fb_info *par = info->par;
 
-#ifdef CONFIG_MTRR
- 

[PATCH v1 42/47] video: fbdev: tdfxfb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/tdfxfb.c | 41 ++---
 include/video/tdfx.h |  2 +-
 2 files changed, 7 insertions(+), 36 deletions(-)

diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c
index f761fe3..621fa44 100644
--- a/drivers/video/fbdev/tdfxfb.c
+++ b/drivers/video/fbdev/tdfxfb.c
@@ -78,24 +78,6 @@
 
 #define DPRINTK(a, b...) pr_debug("fb: %s: " a, __func__ , ## b)
 
-#ifdef CONFIG_MTRR
-#include 
-#else
-/* duplicate asm/mtrr.h defines to work on archs without mtrr */
-#define MTRR_TYPE_WRCOMB 1
-
-static inline int mtrr_add(unsigned long base, unsigned long size,
-   unsigned int type, char increment)
-{
-return -ENODEV;
-}
-static inline int mtrr_del(int reg, unsigned long base,
-   unsigned long size)
-{
-return -ENODEV;
-}
-#endif
-
 #define BANSHEE_MAX_PIXCLOCK 27
 #define VOODOO3_MAX_PIXCLOCK 30
 #define VOODOO5_MAX_PIXCLOCK 35
@@ -167,7 +149,6 @@ static int nopan;
 static int nowrap = 1;  /* not implemented (yet) */
 static int hwcursor = 1;
 static char *mode_option;
-/* mtrr option */
 static bool nomtrr;
 
 /* -
@@ -1454,8 +1435,8 @@ static int tdfxfb_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
goto out_err_regbase;
}
 
-   info->screen_base = ioremap_nocache(info->fix.smem_start,
-   info->fix.smem_len);
+   info->screen_base = ioremap_wc(info->fix.smem_start,
+  info->fix.smem_len);
if (!info->screen_base) {
printk(KERN_ERR "fb: Can't remap %s framebuffer.\n",
info->fix.id);
@@ -1473,11 +1454,9 @@ static int tdfxfb_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
printk(KERN_INFO "fb: %s memory = %dK\n", info->fix.id,
info->fix.smem_len >> 10);
 
-   default_par->mtrr_handle = -1;
if (!nomtrr)
-   default_par->mtrr_handle =
-   mtrr_add(info->fix.smem_start, info->fix.smem_len,
-MTRR_TYPE_WRCOMB, 1);
+   default_par->wc_cookie= arch_phys_wc_add(info->fix.smem_start,
+info->fix.smem_len);
 
info->fix.ypanstep  = nopan ? 0 : 1;
info->fix.ywrapstep = nowrap ? 0 : 1;
@@ -1566,9 +1545,7 @@ out_err_iobase:
 #ifdef CONFIG_FB_3DFX_I2C
tdfxfb_delete_i2c_busses(default_par);
 #endif
-   if (default_pa

[PATCH v1 41/47] video: fbdev: rivafb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/riva/fbdev.c  | 39 +++
 drivers/video/fbdev/riva/rivafb.h |  4 +---
 2 files changed, 8 insertions(+), 35 deletions(-)

diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c
index be73727..854b86d 100644
--- a/drivers/video/fbdev/riva/fbdev.c
+++ b/drivers/video/fbdev/riva/fbdev.c
@@ -41,9 +41,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 #ifdef CONFIG_PPC_OF
 #include 
 #include 
@@ -208,9 +205,7 @@ MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
 static int flatpanel = -1; /* Autodetect later */
 static int forceCRTC = -1;
 static bool noaccel  = 0;
-#ifdef CONFIG_MTRR
 static bool nomtrr = 0;
-#endif
 #ifdef CONFIG_PMAC_BACKLIGHT
 static int backlight = 1;
 #else
@@ -2013,28 +2008,18 @@ static int rivafb_probe(struct pci_dev *pd, const 
struct pci_device_id *ent)
 
rivafb_fix.smem_len = riva_get_memlen(default_par) * 1024;
default_par->dclk_max = riva_get_maxdclk(default_par) * 1000;
-   info->screen_base = ioremap(rivafb_fix.smem_start,
-   rivafb_fix.smem_len);
+   info->screen_base = ioremap_wc(rivafb_fix.smem_start,
+  rivafb_fix.smem_len);
if (!info->screen_base) {
printk(KERN_ERR PFX "cannot ioremap FB base\n");
ret = -EIO;
goto err_iounmap_pramin;
}
 
-#ifdef CONFIG_MTRR
-   if (!nomtrr) {
-   default_par->mtrr.vram = mtrr_add(rivafb_fix.smem_start,
- rivafb_fix.smem_len,
- MTRR_TYPE_WRCOMB, 1);
-   if (default_par->mtrr.vram < 0) {
-   printk(KERN_ERR PFX "unable to setup MTRR\n");
-   } else {
-   default_par->mtrr.vram_valid = 1;
-   /* let there be speed */
-   printk(KERN_INFO PFX "RIVA MTRR set to ON\n");
-   }
-   }
-#endif /* CONFIG_MTRR */
+   if (!nomtrr)
+   default_par->wc_cookie =
+   arch_phys_wc_add(rivafb_fix.smem_start,
+rivafb_fix.smem_len);
 
info->fbops = &riva_fb_ops;
info->fix = rivafb_fix;
@@ -2108,13 +2093,7 @@ static void rivafb_remove(struct pci_dev *pd)
unregister_framebuffer(info);
 
riva_bl_exit(info);
-
-#ifdef CONFIG_MTRR
-   if (par->mtrr.vram_valid)
-   mtrr_del(par->mtrr.vram, info->fix.smem_start,
-info->fix.smem_len);
-#endif /* CON

[PATCH v1 40/47] video: fbdev: pm3fb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/pm3fb.c | 30 ++
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c
index 77b99ed..6ff5077 100644
--- a/drivers/video/fbdev/pm3fb.c
+++ b/drivers/video/fbdev/pm3fb.c
@@ -32,9 +32,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 
 #include 
 
@@ -58,11 +55,7 @@
 static int hwcursor = 1;
 static char *mode_option;
 static bool noaccel;
-
-/* mtrr option */
-#ifdef CONFIG_MTRR
 static bool nomtrr;
-#endif
 
 /*
  * This structure defines the hardware state of the graphics card. Normally
@@ -76,7 +69,7 @@ struct pm3_par {
u32 video;  /* video flags before blanking */
u32 base;   /* screen base in 128 bits unit */
u32 palette[16];
-   int mtrr_handle;
+   int wc_cookie;
 };
 
 /*
@@ -1374,8 +1367,8 @@ static int pm3fb_probe(struct pci_dev *dev, const struct 
pci_device_id *ent)
printk(KERN_WARNING "pm3fb: Can't reserve smem.\n");
goto err_exit_mmio;
}
-   info->screen_base =
-   ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
+   info->screen_base = ioremap_wc(pm3fb_fix.smem_start,
+  pm3fb_fix.smem_len);
if (!info->screen_base) {
printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n");
release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
@@ -1383,12 +1376,9 @@ static int pm3fb_probe(struct pci_dev *dev, const struct 
pci_device_id *ent)
}
info->screen_size = pm3fb_fix.smem_len;
 
-#ifdef CONFIG_MTRR
if (!nomtrr)
-   par->mtrr_handle = mtrr_add(pm3fb_fix.smem_start,
-   pm3fb_fix.smem_len,
-   MTRR_TYPE_WRCOMB, 1);
-#endif
+   par->wc_cookie = arch_phys_wc_add(pm3fb_fix.smem_start,
+ pm3fb_fix.smem_len);
info->fbops = &pm3fb_ops;
 
par->video = PM3_READ_REG(par, PM3VideoControl);
@@ -1478,11 +1468,7 @@ static void pm3fb_remove(struct pci_dev *dev)
unregister_framebuffer(info);
fb_dealloc_cmap(&info->cmap);
 
-#ifdef CONFIG_MTRR
-   if (par->mtrr_handle >= 0)
-   mtrr_del(par->mtrr_handle, info->fix.smem_start,
-info->fix.smem_len);
-#endif /* CONFIG_MTRR */
+   arch_phys_wc_del(par->wc_cookie);
   

Re: 4.0.0-rc4: panic in free_block

2015-03-20 Thread Linus Torvalds
On Fri, Mar 20, 2015 at 5:18 PM, David Ahern  wrote:
> On 3/20/15 4:49 PM, David Ahern wrote:
>>
>> I did ask around and apparently this bug is hit only with the new M7
>> processors. DaveM: that's why you are not hitting this.

Quite frankly, this smells even more like an architecture bug. It
could be anywhere: it could be a CPU memory ordering issue, a compiler
bug, or a missing barrier or other thing.

How confident are you in the M7 memory ordering rules? It's a fairly
new core, no? With new speculative reads etc? Maybe the Linux
spinlocks don't have the right serialization, and more aggressive
reordering in the new core shows a bug?

Looking at this code, if this is a race, I see a few things that are
worth checking out

 - it does a very much overlapping "memmove()". The
sparc/lib/memmove.S file looks suspiciously bad (is that a
byte-at-a-time loop? Is it even correctly checking overlap?)

 - it relies on both percpu data and a spinlock. I'm sure the sparc
spinlock code has been tested *extensively* with old cores, but maybe
some new speculative read ends up breaking them?

I'm assuming M7 still TSO and 'ldsub' has acquire semantics? Is it
configurable like some sparc versions? I'm wondering whether the
Solaris locks might have some extra memory barriers due to supporting
the other (weaker) sparc memory models, and maybe they hid some M7
"feature" by mistake...

*Some* of the sparc memcpy routines have odd membar's in them.  Why
would a TSO machine need a memory barrier inside a memcpy. That just
makes me go "Ehh?"

> Here's another data point: If I disable NUMA I don't see the problem.
> Performance drops, but no NULL pointer splats which would have been panics.

So the NUMA case triggers the per-node "n->shared" logic, which
*should* be protected by "n->list_lock". Maybe there is some bug there
- but since that code seems to do ok on x86-64 (and apparently older
sparc too), I really would look at arch-specific issues first.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 11/11] powerpc/8xx: Add support for TASK_SIZE greater than 0x80000000

2015-03-20 Thread Scott Wood
On Tue, 2015-01-20 at 10:57 +0100, Christophe Leroy wrote:
> By default, TASK_SIZE is set to 0x8000 for PPC_8xx, which is most likely
> sufficient for most cases. However, kernel configuration allows to set 
> TASK_SIZE
> to another value, so the 8xx shall handle it.
> 
> Signed-off-by: Christophe Leroy 
> 
> ---
> v2: no change
> 
>  arch/powerpc/kernel/head_8xx.S | 25 +++--
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
> index ead6448..92a6456 100644
> --- a/arch/powerpc/kernel/head_8xx.S
> +++ b/arch/powerpc/kernel/head_8xx.S
> @@ -48,6 +48,19 @@
>   mtspr   spr, reg
>  #endif
>  
> +/* Macro to test if an address is a kernel address */
> +#if CONFIG_TASK_SIZE <= 0x8000
> +#define IS_KERNEL(tmp, addr) \
> + andis.  tmp, addr, 0x8000   /* Address >= 0x8000 */
> +#define BRANCH_UNLESS_KERNEL(label)  beq label
> +#else

This works if CONFIG_TASK_SIZE == 0x8000, but what if it's less, and
you have a kernel address < 0x8000?

-Scott


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 39/47] video: fbdev: pm2fb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/pm2fb.c | 31 +--
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c
index 3b85b64..aa8d288 100644
--- a/drivers/video/fbdev/pm2fb.c
+++ b/drivers/video/fbdev/pm2fb.c
@@ -38,10 +38,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include 
 #include 
 
@@ -81,10 +77,7 @@ static char *mode_option;
 static bool lowhsync;
 static bool lowvsync;
 static bool noaccel;
-/* mtrr option */
-#ifdef CONFIG_MTRR
 static bool nomtrr;
-#endif
 
 /*
  * The hardware state of the graphics card that isn't part of the
@@ -100,7 +93,7 @@ struct pm2fb_par
u32 mem_control;/* MemControl reg at probe */
u32 boot_address;   /* BootAddress reg at probe */
u32 palette[16];
-   int mtrr_handle;
+   int wc_cookie;
 };
 
 /*
@@ -1637,21 +1630,16 @@ static int pm2fb_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
goto err_exit_mmio;
}
info->screen_base =
-   ioremap_nocache(pm2fb_fix.smem_start, pm2fb_fix.smem_len);
+   ioremap_wc(pm2fb_fix.smem_start, pm2fb_fix.smem_len);
if (!info->screen_base) {
printk(KERN_WARNING "pm2fb: Can't ioremap smem area.\n");
release_mem_region(pm2fb_fix.smem_start, pm2fb_fix.smem_len);
goto err_exit_mmio;
}
 
-#ifdef CONFIG_MTRR
-   default_par->mtrr_handle = -1;
if (!nomtrr)
-   default_par->mtrr_handle =
-   mtrr_add(pm2fb_fix.smem_start,
-pm2fb_fix.smem_len,
-MTRR_TYPE_WRCOMB, 1);
-#endif
+   default_par->wc_cookie = arch_phys_wc_add(pm2fb_fix.smem_start,
+ pm2fb_fix.smem_len);
 
info->fbops = &pm2fb_ops;
info->fix   = pm2fb_fix;
@@ -1733,12 +1721,7 @@ static void pm2fb_remove(struct pci_dev *pdev)
struct pm2fb_par *par = info->par;
 
unregister_framebuffer(info);
-
-#ifdef CONFIG_MTRR
-   if (par->mtrr_handle >= 0)
-   mtrr_del(par->mtrr_handle, info->fix.smem_start,
-info->fix.smem_len);
-#endif /* CONFIG_MTRR */
+   arch_phys_wc_del(par->wc_cookie);
iounmap(info->screen_base);
release_mem_region(fix->smem_start, fix->smem_len);
iounmap(par->v_regs);
@@ -1791,10 +1774,8 @@ static int __init pm2fb_setup(char *options)
  

[PATCH v1 38/47] video: fbdev: kyrofb: use arch_phys_wc_add() and pci_ioremap_wc_bar()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/kyro/fbdev.c | 33 +++--
 include/video/kyro.h |  4 +---
 2 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 65041e1..5bb0153 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -22,9 +22,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 
 #include 
 
@@ -84,9 +81,7 @@ static device_info_t deviceInfo;
 static char *mode_option = NULL;
 static int nopan = 0;
 static int nowrap = 1;
-#ifdef CONFIG_MTRR
 static int nomtrr = 0;
-#endif
 
 /* PCI driver prototypes */
 static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
@@ -570,10 +565,8 @@ static int __init kyrofb_setup(char *options)
nopan = 1;
} else if (strcmp(this_opt, "nowrap") == 0) {
nowrap = 1;
-#ifdef CONFIG_MTRR
} else if (strcmp(this_opt, "nomtrr") == 0) {
nomtrr = 1;
-#endif
} else {
mode_option = this_opt;
}
@@ -691,17 +684,16 @@ static int kyrofb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
currentpar->regbase = deviceInfo.pSTGReg =
ioremap_nocache(kyro_fix.mmio_start, kyro_fix.mmio_len);
+   if (!currentpar->regbase)
+   goto out_free_fb;
 
-   info->screen_base = ioremap_nocache(kyro_fix.smem_start,
-   kyro_fix.smem_len);
+   info->screen_base = pci_ioremap_wc_bar(pdev, 0);
+   if (!info->screen_base)
+   goto out_unmap_regs;
 
-#ifdef CONFIG_MTRR
if (!nomtrr)
-   currentpar->mtrr_handle =
-   mtrr_add(kyro_fix.smem_start,
-kyro_fix.smem_len,
-MTRR_TYPE_WRCOMB, 1);
-#endif
+   currentpar->wc_cookie = arch_phys_wc_add(kyro_fix.smem_start,
+kyro_fix.smem_len);
 
kyro_fix.ypanstep   = nopan ? 0 : 1;
kyro_fix.ywrapstep  = nowrap ? 0 : 1;
@@ -745,8 +737,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return 0;
 
 out_unmap:
-   iounmap(currentpar->regbase);
iounmap(info->screen_base);
+out_unmap_regs:
+   iounmap(currentpar->regbase);
+out_free_fb:
framebuffer_release(info);
 
return -EINVAL;
@@ -770,12 +764,7 @@ static void kyrofb_remove(struct pci_dev *pdev)
iounmap(info->screen_base);
iounmap(par->regbase);
 
-#ifde

[PATCH v1 37/47] video: fbdev: i740fb: use arch_phys_wc_add() and pci_ioremap_wc_bar()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/i740fb.c | 35 ++-
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c
index a2b4204..452e116 100644
--- a/drivers/video/fbdev/i740fb.c
+++ b/drivers/video/fbdev/i740fb.c
@@ -27,24 +27,15 @@
 #include 
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include "i740_reg.h"
 
 static char *mode_option;
-
-#ifdef CONFIG_MTRR
 static int mtrr = 1;
-#endif
 
 struct i740fb_par {
unsigned char __iomem *regs;
bool has_sgram;
-#ifdef CONFIG_MTRR
-   int mtrr_reg;
-#endif
+   int wc_cookie;
bool ddc_registered;
struct i2c_adapter ddc_adapter;
struct i2c_algo_bit_data ddc_algo;
@@ -1040,7 +1031,7 @@ static int i740fb_probe(struct pci_dev *dev, const struct 
pci_device_id *ent)
goto err_request_regions;
}
 
-   info->screen_base = pci_ioremap_bar(dev, 0);
+   info->screen_base = pci_ioremap_wc_bar(dev, 0);
if (!info->screen_base) {
dev_err(info->device, "error remapping base\n");
ret = -ENOMEM;
@@ -1144,13 +1135,9 @@ static int i740fb_probe(struct pci_dev *dev, const 
struct pci_device_id *ent)
 
fb_info(info, "%s frame buffer device\n", info->fix.id);
pci_set_drvdata(dev, info);
-#ifdef CONFIG_MTRR
-   if (mtrr) {
-   par->mtrr_reg = -1;
-   par->mtrr_reg = mtrr_add(info->fix.smem_start,
-   info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
-   }
-#endif
+   if (mtrr)
+   par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
+ info->fix.smem_len);
return 0;
 
 err_reg_framebuffer:
@@ -1177,13 +1164,7 @@ static void i740fb_remove(struct pci_dev *dev)
 
if (info) {
struct i740fb_par *par = info->par;
-
-#ifdef CONFIG_MTRR
-   if (par->mtrr_reg >= 0) {
-   mtrr_del(par->mtrr_reg, 0, 0);
-   par->mtrr_reg = -1;
-   }
-#endif
+   arch_phys_wc_del(par->wc_cookie);
unregister_framebuffer(info);
fb_dealloc_cmap(&info->cmap);
if (par->ddc_registered)
@@ -1287,10 +1268,8 @@ static int  __init i740fb_setup(char *options)
while ((opt = strsep(&options, ",")) != NULL) {
if (!*opt)
continue;
-#ifdef CONFIG_MTRR
else if (!strncmp(opt, "mtrr:", 5))
mtrr = simple_strtoul(opt + 5, NULL, 0);
-#endif
else
mode_option = opt;
}
@@ -1327,7 +1

[PATCH v1 36/47] video: fbdev: i810: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The same area used for MTRR is used for the ioremap() area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/i810/i810.h  |  3 +--
 drivers/video/fbdev/i810/i810_main.c | 11 +++
 drivers/video/fbdev/i810/i810_main.h | 26 --
 3 files changed, 8 insertions(+), 32 deletions(-)

diff --git a/drivers/video/fbdev/i810/i810.h b/drivers/video/fbdev/i810/i810.h
index 1414b73..7b1c002 100644
--- a/drivers/video/fbdev/i810/i810.h
+++ b/drivers/video/fbdev/i810/i810.h
@@ -199,7 +199,6 @@
 #define HAS_FONTCACHE   8 
 
 /* driver flags */
-#define HAS_MTRR1
 #define HAS_ACCELERATION2
 #define ALWAYS_SYNC 4
 #define LOCKUP  8
@@ -281,7 +280,7 @@ struct i810fb_par {
u32 ovract;
u32 cur_state;
u32 ddc_num;
-   int mtrr_reg;
+   int wc_cookie;
u16 bltcntl;
u8 interlace;
 };
diff --git a/drivers/video/fbdev/i810/i810_main.c 
b/drivers/video/fbdev/i810/i810_main.c
index bb674e4..025b882 100644
--- a/drivers/video/fbdev/i810/i810_main.c
+++ b/drivers/video/fbdev/i810/i810_main.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1816,7 +1817,9 @@ static void i810_init_device(struct i810fb_par *par)
u8 reg;
u8 __iomem *mmio = par->mmio_start_virtual;
 
-   if (mtrr) set_mtrr(par);
+   if (mtrr)
+   par->wc_cookie= arch_phys_wc_add((u32) par->aperture.physical,
+par->aperture.size);
 
i810_init_cursor(par);
 
@@ -1865,8 +1868,8 @@ static int i810_allocate_pci_resource(struct i810fb_par 
*par,
}
par->res_flags |= FRAMEBUFFER_REQ;
 
-   par->aperture.virtual = ioremap_nocache(par->aperture.physical, 
-   par->aperture.size);
+   par->aperture.virtual = ioremap_wc(par->aperture.physical,
+  par->aperture.size);
if (!par->aperture.virtual) {
printk("i810fb_init: cannot remap framebuffer region\n");
return -ENODEV;
@@ -2096,7 +2099,7 @@ static void i810fb_release_resource(struct fb_info *info,
struct i810fb_par *par)
 {
struct gtt_data *gtt = &par->i810_gtt;
-   unset_mtrr(par);
+   arch_phys_wc_del(par->wc_cookie);
 
i810_delete_i2c_busses(par);
 
diff --git a/drivers/video/fbdev/i810/i810_main.h 
b/drivers/video/fbdev/i810/i

Re: 4.0.0-rc4: panic in free_block

2015-03-20 Thread David Ahern

On 3/20/15 6:34 PM, David Rientjes wrote:

On Fri, 20 Mar 2015, David Ahern wrote:


Here's another data point: If I disable NUMA I don't see the problem.
Performance drops, but no NULL pointer splats which would have been panics.

The 128 cpu ldom with NUMA enabled shows the problem every single time I do a
kernel compile (-j 128). With NUMA disabled I have done 3 allyesconfig
compiles without hitting the problem. I'll put the compiles into a loop while
I head out for dinner.



It might be helpful to enable CONFIG_DEBUG_SLAB if you're reproducing it.



I enabled that and a few other DEBUG configs earlier -- nothing popped 
out. I'll do it again -- and others when I return.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 35/47] video: fbdev: aty: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/aty/aty128fb.c | 36 ++--
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/drivers/video/fbdev/aty/aty128fb.c 
b/drivers/video/fbdev/aty/aty128fb.c
index aedf2fb..f41955b 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -80,10 +80,6 @@
 #include 
 #endif /* CONFIG_BOOTX_TEXT */
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include 
 
 /* Debug flag */
@@ -399,10 +395,7 @@ static int default_cmode = CMODE_8;
 
 static int default_crt_on = 0;
 static int default_lcd_on = 1;
-
-#ifdef CONFIG_MTRR
 static bool mtrr = true;
-#endif
 
 #ifdef CONFIG_FB_ATY128_BACKLIGHT
 #ifdef CONFIG_PMAC_BACKLIGHT
@@ -456,9 +449,7 @@ struct aty128fb_par {
u32 vram_size;  /* onboard video ram   */
int chip_gen;
const struct aty128_meminfo *mem;   /* onboard mem info*/
-#ifdef CONFIG_MTRR
-   struct { int vram; int vram_valid; } mtrr;
-#endif
+   int wc_cookie;
int blitter_may_be_busy;
int fifo_slots; /* free slots in FIFO (64 max) */
 
@@ -1725,12 +1716,10 @@ static int aty128fb_setup(char *options)
 #endif
continue;
}
-#ifdef CONFIG_MTRR
if(!strncmp(this_opt, "nomtrr", 6)) {
mtrr = 0;
continue;
}
-#endif
 #ifdef CONFIG_PPC_PMAC
/* vmode and cmode deprecated */
if (!strncmp(this_opt, "vmode:", 6)) {
@@ -2133,7 +2122,7 @@ static int aty128_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FF;
 
/* Virtualize the framebuffer */
-   info->screen_base = ioremap(fb_addr, par->vram_size);
+   info->screen_base = ioremap_wc(fb_addr, par->vram_size);
if (!info->screen_base)
goto err_unmap_out;
 
@@ -2170,15 +2159,9 @@ static int aty128_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (!aty128_init(pdev, ent))
goto err_out;
 
-#ifdef CONFIG_MTRR
-   if (mtrr) {
-   par->mtrr.vram = mtrr_add(info->fix.smem_start,
-   par->vram_size, MTRR_TYPE_WRCOMB, 1);
-   par->mtrr.vram_valid = 1;
-   /* let there be speed */
-   printk(KERN_INFO "aty128fb: Rage128 MTRR set to ON\n");
-   }
-#endif /* CONFIG_MTRR */
+   if (mtrr)
+   par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
+ par->vram_size);
return 0;
 
 err_out:
@@ -2212,11 +2195,7 @@ static void aty128_rem

[PATCH v1 34/47] video: fbdev: sisfb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/sis/sis.h  |  2 +-
 drivers/video/fbdev/sis/sis_main.c | 27 ++-
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/video/fbdev/sis/sis.h b/drivers/video/fbdev/sis/sis.h
index 1987f1b7..ea1d1c9 100644
--- a/drivers/video/fbdev/sis/sis.h
+++ b/drivers/video/fbdev/sis/sis.h
@@ -458,7 +458,7 @@ struct sis_video_info {
 
unsigned char   *bios_abase;
 
-   int mtrr;
+   int wc_cookie;
 
u32 sisfb_mem;
 
diff --git a/drivers/video/fbdev/sis/sis_main.c 
b/drivers/video/fbdev/sis/sis_main.c
index fcf610e..e923038 100644
--- a/drivers/video/fbdev/sis/sis_main.c
+++ b/drivers/video/fbdev/sis/sis_main.c
@@ -53,9 +53,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 
 #include "sis.h"
 #include "sis_main.h"
@@ -4130,13 +4127,13 @@ static void sisfb_post_map_vram(struct sis_video_info 
*ivideo,
if (*mapsize < (min << 20))
return;
 
-   ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize));
+   ivideo->video_vbase = ioremap_wc(ivideo->video_base, (*mapsize));
 
if(!ivideo->video_vbase) {
printk(KERN_ERR
"sisfb: Unable to map maximum video RAM for size 
detection\n");
(*mapsize) >>= 1;
-   while((!(ivideo->video_vbase = ioremap(ivideo->video_base, 
(*mapsize) {
+   while((!(ivideo->video_vbase = ioremap_wc(ivideo->video_base, 
(*mapsize) {
(*mapsize) >>= 1;
if((*mapsize) < (min << 20))
break;
@@ -6186,7 +6183,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto error_2;
}
 
-   ivideo->video_vbase = ioremap(ivideo->video_base, ivideo->video_size);
+   ivideo->video_vbase = ioremap_wc(ivideo->video_base, 
ivideo->video_size);
ivideo->SiS_Pr.VideoMemoryAddress = ivideo->video_vbase;
if(!ivideo->video_vbase) {
printk(KERN_ERR "sisfb: Fatal error: Unable to map framebuffer 
memory\n");
@@ -6254,8 +6251,6 @@ error_3:  vfree(ivideo->bios_abase);
ivideo->SiS_Pr.VideoMemoryAddress += ivideo->video_offset;
ivideo->SiS_Pr.VideoMemorySize = ivideo->sisfb_mem;
 
-   ivideo->mtrr = -1;
-
ivideo->vbflags = 0;
ivideo->lcddefmodeidx = DEFAULT_LCDMODE;
ivideo->tvdefmodeidx  = DEFAULT_TVMODE;
@@ -6443,14 +6438,8 @@ error_3: vfree(ivideo->bios_abase);
 
printk(KERN_DEBUG "sisfb: Initial vbflags 0x%x\n", 
(int)ivideo->vbfl

Re: 4.0.0-rc4: panic in free_block

2015-03-20 Thread David Rientjes
On Fri, 20 Mar 2015, David Ahern wrote:

> Here's another data point: If I disable NUMA I don't see the problem.
> Performance drops, but no NULL pointer splats which would have been panics.
> 
> The 128 cpu ldom with NUMA enabled shows the problem every single time I do a
> kernel compile (-j 128). With NUMA disabled I have done 3 allyesconfig
> compiles without hitting the problem. I'll put the compiles into a loop while
> I head out for dinner.
> 

It might be helpful to enable CONFIG_DEBUG_SLAB if you're reproducing it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 33/47] video: fbdev: savagefb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/savage/savagefb.h|  4 +---
 drivers/video/fbdev/savage/savagefb_driver.c | 17 +++--
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/video/fbdev/savage/savagefb.h 
b/drivers/video/fbdev/savage/savagefb.h
index 8ff4ab1..aba04af 100644
--- a/drivers/video/fbdev/savage/savagefb.h
+++ b/drivers/video/fbdev/savage/savagefb.h
@@ -213,9 +213,7 @@ struct savagefb_par {
void   __iomem *vbase;
u32pbase;
u32len;
-#ifdef CONFIG_MTRR
-   intmtrr;
-#endif
+   intwc_cookie;
} video;
 
struct {
diff --git a/drivers/video/fbdev/savage/savagefb_driver.c 
b/drivers/video/fbdev/savage/savagefb_driver.c
index 4dbf45f..6c77ab0 100644
--- a/drivers/video/fbdev/savage/savagefb_driver.c
+++ b/drivers/video/fbdev/savage/savagefb_driver.c
@@ -57,10 +57,6 @@
 #include 
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include "savagefb.h"
 
 
@@ -1775,7 +1771,7 @@ static int savage_map_video(struct fb_info *info, int 
video_len)
 
par->video.pbase = pci_resource_start(par->pcidev, resource);
par->video.len   = video_len;
-   par->video.vbase = ioremap(par->video.pbase, par->video.len);
+   par->video.vbase = ioremap_wc(par->video.pbase, par->video.len);
 
if (!par->video.vbase) {
printk("savagefb: unable to map screen memory\n");
@@ -1787,11 +1783,7 @@ static int savage_map_video(struct fb_info *info, int 
video_len)
info->fix.smem_start = par->video.pbase;
info->fix.smem_len   = par->video.len - par->cob_size;
info->screen_base= par->video.vbase;
-
-#ifdef CONFIG_MTRR
-   par->video.mtrr = mtrr_add(par->video.pbase, video_len,
-  MTRR_TYPE_WRCOMB, 1);
-#endif
+   par->video.wc_cookie = arch_phys_wc_add(par->video.pbase, video_len);
 
/* Clear framebuffer, it's all white in memory after boot */
memset_io(par->video.vbase, 0, par->video.len);
@@ -1806,10 +1798,7 @@ static void savage_unmap_video(struct fb_info *info)
DBG("savage_unmap_video");
 
if (par->video.vbase) {
-#ifdef CONFIG_MTRR
-   mtrr_del(par->video.mtrr, par->video.pbase, par->video.len);
-#endif
-
+   arch_phys_wc_del(par->video.wc_cookie);
iounmap(par->video.vbase);
par->video.vbase = NULL;
info->screen_base = NULL;
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo 

[GIT PULL] Power management and ACPI fixes for 4.0-rc5

2015-03-20 Thread Rafael J. Wysocki
Hi Linus,

Please pull from

 git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
 pm+acpi-4.0-rc5

to receive power management and ACPI fixes for v4.0-rc5 with top-most
commit 9c86286a60b28bd25cb1c70eb2aba34f182d1063

 Merge branches 'pm-cpuidle', 'powercap', 'irq-pm' and 'acpi-resources'

on top of commit 06e5801b8cb3fc057d88cb4dc03c0b64b2744cda

 Linux 4.0-rc4

These are fixes for recent regressions (PCI/ACPI resources and
at91 RTC locking), a stable-candidate powercap RAPL driver fix
and two ARM cpuidle fixes (one stable-candidate too).

Specifics:

 - Revert a recent PCI commit related to IRQ resources management
   that introduced a regression for drivers attempting to bind to
   devices whose previous drivers did not balance pci_enable_device()
   and pci_disable_device() as expected (Rafael J Wysocki).

 - Fix a deadlock in at91_rtc_interrupt() introduced by a typo in a
   recent commit related to wakeup interrupt handling (Dan Carpenter).

 - Allow the power capping RAPL (Running-Average Power Limit) driver
   to use different energy units for domains within one CPU package
   which is necessary to handle Intel Haswell EP processors correctly
   (Jacob Pan).

 - Improve the cpuidle mvebu driver's handling of Armada XP SoCs by
   updating the target residency and exit latency numbers for those
   chips (Sebastien Rannou).

 - Prevent the cpuidle mvebu driver from calling cpu_pm_enter() twice
   in a row before cpu_pm_exit() is called on the same CPU which
   breaks the core's assumptions regarding the usage of those
   functions (Gregory Clement).

Thanks!


---

Dan Carpenter (1):
  rtc: at91rm9200: double locking bug in at91_rtc_interrupt()

Gregory CLEMENT (1):
  cpuidle: mvebu: Fix the CPU PM notifier usage

Jacob Pan (1):
  powercap / RAPL: handle domains with different energy units

Rafael J. Wysocki (1):
  Revert "x86/PCI: Refine the way to release PCI IRQ resources"

Sebastien Rannou (1):
  cpuidle: mvebu: Update cpuidle thresholds for Armada XP SOCs

---

 arch/x86/include/asm/pci_x86.h |  2 ++
 arch/x86/pci/common.c  | 34 +---
 arch/x86/pci/intel_mid_pci.c   |  4 +--
 arch/x86/pci/irq.c | 15 ++-
 drivers/acpi/pci_irq.c |  9 ++-
 drivers/cpuidle/cpuidle-mvebu-v7.c | 12 -
 drivers/powercap/intel_rapl.c  | 54 +++---
 drivers/rtc/rtc-at91rm9200.c   |  2 +-
 8 files changed, 78 insertions(+), 54 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 32/47] video: fbdev: nvidia: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR and ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/nvidia/nv_type.h |  7 +--
 drivers/video/fbdev/nvidia/nvidia.c  | 37 ++--
 2 files changed, 7 insertions(+), 37 deletions(-)

diff --git a/drivers/video/fbdev/nvidia/nv_type.h 
b/drivers/video/fbdev/nvidia/nv_type.h
index c03f7f5..6ff321a 100644
--- a/drivers/video/fbdev/nvidia/nv_type.h
+++ b/drivers/video/fbdev/nvidia/nv_type.h
@@ -148,12 +148,7 @@ struct nvidia_par {
u32 forceCRTC;
u32 open_count;
u8 DDCBase;
-#ifdef CONFIG_MTRR
-   struct {
-   int vram;
-   int vram_valid;
-   } mtrr;
-#endif
+   int wc_cookie;
struct nvidia_i2c_chan chan[3];
 
volatile u32 __iomem *REGS;
diff --git a/drivers/video/fbdev/nvidia/nvidia.c 
b/drivers/video/fbdev/nvidia/nvidia.c
index def0412..781f5e7 100644
--- a/drivers/video/fbdev/nvidia/nvidia.c
+++ b/drivers/video/fbdev/nvidia/nvidia.c
@@ -21,9 +21,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 #ifdef CONFIG_PPC_OF
 #include 
 #include 
@@ -80,9 +77,7 @@ static int paneltweak = 0;
 static int vram = 0;
 static int bpp = 8;
 static int reverse_i2c;
-#ifdef CONFIG_MTRR
 static bool nomtrr = false;
-#endif
 #ifdef CONFIG_PMAC_BACKLIGHT
 static int backlight = 1;
 #else
@@ -1365,7 +1360,8 @@ static int nvidiafb_probe(struct pci_dev *pd, const 
struct pci_device_id *ent)
par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize;
par->CursorStart = par->FbUsableSize + (32 * 1024);
 
-   info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize);
+   info->screen_base = ioremap_wc(nvidiafb_fix.smem_start,
+  par->FbMapSize);
info->screen_size = par->FbUsableSize;
nvidiafb_fix.smem_len = par->RamAmountKBytes * 1024;
 
@@ -1376,20 +1372,9 @@ static int nvidiafb_probe(struct pci_dev *pd, const 
struct pci_device_id *ent)
 
par->FbStart = info->screen_base;
 
-#ifdef CONFIG_MTRR
-   if (!nomtrr) {
-   par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start,
- par->RamAmountKBytes * 1024,
- MTRR_TYPE_WRCOMB, 1);
-   if (par->mtrr.vram < 0) {
-   printk(KERN_ERR PFX "unable to setup MTRR\n");
-   } else {
-   par->mtrr.vram_valid = 1;
-   /* let there be speed */
-   printk(KERN_INFO PFX "MTRR set to ON\n");
-   }
-   }
-#endif /* CONFIG_MTRR */
+   if (!nomtrr)
+   par->wc_cookie = 

[PATCH v1 31/47] video: fbdev: s3fb: use arch_phys_wc_add() and pci_iomap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/s3fb.c | 35 ++-
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c
index f0ae61a..13b1090 100644
--- a/drivers/video/fbdev/s3fb.c
+++ b/drivers/video/fbdev/s3fb.c
@@ -28,13 +28,9 @@
 #include 
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 struct s3fb_info {
int chip, rev, mclk_freq;
-   int mtrr_reg;
+   int wc_cookie;
struct vgastate state;
struct mutex open_lock;
unsigned int ref_count;
@@ -154,11 +150,7 @@ static const struct svga_timing_regs s3_timing_regs = {
 
 
 static char *mode_option;
-
-#ifdef CONFIG_MTRR
 static int mtrr = 1;
-#endif
-
 static int fasttext = 1;
 
 
@@ -170,11 +162,8 @@ module_param(mode_option, charp, 0444);
 MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
 module_param_named(mode, mode_option, charp, 0444);
 MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) 
(deprecated)");
-
-#ifdef CONFIG_MTRR
 module_param(mtrr, int, 0444);
 MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, 
default=1)");
-#endif
 
 module_param(fasttext, int, 0644);
 MODULE_PARM_DESC(fasttext, "Enable S3 fast text mode (1=enable, 0=disable, 
default=1)");
@@ -1168,7 +1157,7 @@ static int s3_pci_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
info->fix.smem_len = pci_resource_len(dev, 0);
 
/* Map physical IO memory address into kernel space */
-   info->screen_base = pci_iomap(dev, 0, 0);
+   info->screen_base = pci_iomap_wc(dev, 0, 0);
if (! info->screen_base) {
rc = -ENOMEM;
dev_err(info->device, "iomap for framebuffer failed\n");
@@ -1365,12 +1354,9 @@ static int s3_pci_probe(struct pci_dev *dev, const 
struct pci_device_id *id)
/* Record a reference to the driver data */
pci_set_drvdata(dev, info);
 
-#ifdef CONFIG_MTRR
-   if (mtrr) {
-   par->mtrr_reg = -1;
-   par->mtrr_reg = mtrr_add(info->fix.smem_start, 
info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
-   }
-#endif
+   if (mtrr)
+   par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
+ info->fix.smem_len);
 
return 0;
 
@@ -1405,14 +1391,7 @@ static void s3_pci_remove(struct pci_dev *dev)
 
if (info) {
par = info->par;
-
-#ifdef CONFIG_MTRR
-   if (par->mtrr_reg >= 0) {
-   mtrr_del(par->mtrr_reg, 0, 0);
-   par->mtrr_reg = -1;
-   }

[PATCH v1 30/47] video: fbdev: neofb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/neofb.c | 26 +++---
 include/video/neomagic.h|  5 +
 2 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c
index 44f99a6..db023a9 100644
--- a/drivers/video/fbdev/neofb.c
+++ b/drivers/video/fbdev/neofb.c
@@ -71,11 +71,6 @@
 #include 
 #include 
 #include 
-
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include 
 #include 
 
@@ -1710,6 +1705,7 @@ static int neo_map_video(struct fb_info *info, struct 
pci_dev *dev,
 int video_len)
 {
//unsigned long addr;
+   struct neofb_par *par = info->par;
 
DBG("neo_map_video");
 
@@ -1723,7 +1719,7 @@ static int neo_map_video(struct fb_info *info, struct 
pci_dev *dev,
}
 
info->screen_base =
-   ioremap(info->fix.smem_start, info->fix.smem_len);
+   ioremap_wc(info->fix.smem_start, info->fix.smem_len);
if (!info->screen_base) {
printk("neofb: unable to map screen memory\n");
release_mem_region(info->fix.smem_start,
@@ -1733,11 +1729,8 @@ static int neo_map_video(struct fb_info *info, struct 
pci_dev *dev,
printk(KERN_INFO "neofb: mapped framebuffer at %p\n",
   info->screen_base);
 
-#ifdef CONFIG_MTRR
-   ((struct neofb_par *)(info->par))->mtrr =
-   mtrr_add(info->fix.smem_start, pci_resource_len(dev, 0),
-   MTRR_TYPE_WRCOMB, 1);
-#endif
+   par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
+ pci_resource_len(dev, 0));
 
/* Clear framebuffer, it's all white in memory after boot */
memset_io(info->screen_base, 0, info->fix.smem_len);
@@ -1754,16 +1747,11 @@ static int neo_map_video(struct fb_info *info, struct 
pci_dev *dev,
 
 static void neo_unmap_video(struct fb_info *info)
 {
-   DBG("neo_unmap_video");
+   struct neofb_par *par = info->par;
 
-#ifdef CONFIG_MTRR
-   {
-   struct neofb_par *par = info->par;
+   DBG("neo_unmap_video");
 
-   mtrr_del(par->mtrr, info->fix.smem_start,
-info->fix.smem_len);
-   }
-#endif
+   arch_phys_wc_del(par->wc_cookie);
iounmap(info->screen_base);
info->screen_base = NULL;
 
diff --git a/include/video/neomagic.h b/include/video/neomagic.h
index bc5013e..91e225a 100644
--- a/include/video/neomagic.h
+++ b/include/video/neomagic.h
@@ -159,10 +159,7 @@ struct neofb_par {
unsigned char VCLK3NumeratorHigh;
unsigned char VCLK3Denominator;
unsigned char VerticalExt;
-
-#ifdef CONFIG_MTRR
-   int mtrr;
-#endif
+   

[PATCH v1 29/47] video: fbdev: matrox: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same ioremap()'d area for the MTRR.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/matrox/matroxfb_base.c | 36 +++---
 drivers/video/fbdev/matrox/matroxfb_base.h | 27 +-
 2 files changed, 14 insertions(+), 49 deletions(-)

diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c 
b/drivers/video/fbdev/matrox/matroxfb_base.c
index 62539ca..2f70365 100644
--- a/drivers/video/fbdev/matrox/matroxfb_base.c
+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
@@ -370,12 +370,9 @@ static void matroxfb_remove(struct matrox_fb_info *minfo, 
int dummy)
matroxfb_unregister_device(minfo);
unregister_framebuffer(&minfo->fbcon);
matroxfb_g450_shutdown(minfo);
-#ifdef CONFIG_MTRR
-   if (minfo->mtrr.vram_valid)
-   mtrr_del(minfo->mtrr.vram, minfo->video.base, minfo->video.len);
-#endif
-   mga_iounmap(minfo->mmio.vbase);
-   mga_iounmap(minfo->video.vbase);
+   arch_phys_wc_del(minfo->wc_cookie);
+   iounmap(minfo->mmio.vbase.vaddr);
+   iounmap(minfo->video.vbase.vaddr);
release_mem_region(minfo->video.base, minfo->video.len_maximum);
release_mem_region(minfo->mmio.base, 16384);
kfree(minfo);
@@ -1256,9 +1253,7 @@ static int nobios;/* 
"matroxfb:nobios" */
 static int noinit = 1; /* "matroxfb:init" */
 static int inverse;/* "matroxfb:inverse" */
 static int sgram;  /* "matroxfb:sgram" */
-#ifdef CONFIG_MTRR
 static int mtrr = 1;   /* "matroxfb:nomtrr" */
-#endif
 static int grayscale;  /* "matroxfb:grayscale" */
 static int dev = -1;   /* "matroxfb:dev:x" */
 static unsigned int vesa = ~0; /* "matroxfb:vesa:x" */
@@ -1717,14 +1712,17 @@ static int initMatrox2(struct matrox_fb_info *minfo, 
struct board *b)
if (mem && (mem < memsize))
memsize = mem;
err = -ENOMEM;
-   if (mga_ioremap(ctrlptr_phys, 16384, MGA_IOREMAP_MMIO, 
&minfo->mmio.vbase)) {
+
+   minfo->mmio.vbase.vaddr = ioremap_nocache(ctrlptr_phys, 16384);
+   if (!minfo->mmio.vbase.vaddr) {
printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb 
disabled\n", ctrlptr_phys);
goto failVideoMR;
}
minfo->mmio.base = ctrlptr_phys;
minfo->mmio.len = 16384;
minfo->video.base = video_base_phys;
-   if (mga_ioremap(video_base_phys, memsize, MGA_IOREMAP_FB, 
&minfo->video.vbase)) {
+   minfo->video.vbase.vaddr = ioremap_wc(video_base_phys, memsize);
+   if (!minfo->video.vbase.vaddr) {
printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), ma

[PATCH v1 28/47] video: fbdev: intelfb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Although this driver gives the framebuffer layer a different
size for the framebuffer it uses the entire aperture PCI BAR
size for the MTRR. Since the framebuffer is included in that
range and MTRR was used on the entire PCI BAR WC will have
been preferred on that range as well. This propagates the
WC preference on the same entire PCI BAR.

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/intelfb/intelfb.h|  4 +---
 drivers/video/fbdev/intelfb/intelfbdrv.c | 38 
 2 files changed, 5 insertions(+), 37 deletions(-)

diff --git a/drivers/video/fbdev/intelfb/intelfb.h 
b/drivers/video/fbdev/intelfb/intelfb.h
index 6b51175..37f8339 100644
--- a/drivers/video/fbdev/intelfb/intelfb.h
+++ b/drivers/video/fbdev/intelfb/intelfb.h
@@ -285,9 +285,7 @@ struct intelfb_info {
/* use a gart reserved fb mem */
u8 fbmem_gart;
 
-   /* mtrr support */
-   int mtrr_reg;
-   u32 has_mtrr;
+   int wc_cookie;
 
/* heap data */
struct intelfb_heap_data aperture;
diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c 
b/drivers/video/fbdev/intelfb/intelfbdrv.c
index b847d53..bbec737 100644
--- a/drivers/video/fbdev/intelfb/intelfbdrv.c
+++ b/drivers/video/fbdev/intelfb/intelfbdrv.c
@@ -124,10 +124,6 @@
 
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include "intelfb.h"
 #include "intelfbhw.h"
 #include "../edid.h"
@@ -411,33 +407,6 @@ module_init(intelfb_init);
 module_exit(intelfb_exit);
 
 /***
- * mtrr support functions  *
- ***/
-
-#ifdef CONFIG_MTRR
-static inline void set_mtrr(struct intelfb_info *dinfo)
-{
-   dinfo->mtrr_reg = mtrr_add(dinfo->aperture.physical,
-  dinfo->aperture.size, MTRR_TYPE_WRCOMB, 1);
-   if (dinfo->mtrr_reg < 0) {
-   ERR_MSG("unable to set MTRR\n");
-   return;
-   }
-   dinfo->has_mtrr = 1;
-}
-static inline void unset_mtrr(struct intelfb_info *dinfo)
-{
-   if (dinfo->has_mtrr)
-   mtrr_del(dinfo->mtrr_reg, dinfo->aperture.physical,
-dinfo->aperture.size);
-}
-#else
-#define set_mtrr(x) WRN_MSG("MTRR is disabled in the kernel\n")
-
-#define unset_mtrr(x) do { } while (0)
-#endif /* CONFIG_MTRR */
-
-/***
  *driver init / cleanup*
  ***/
 
@@ -456,7 +425,7 @@ static void cleanup(struct intelfb_info *dinfo)
if (dinfo->registered)
unregister_framebuffer(dinfo-

[PATCH v1 27/47] video: fbdev: gbefb: use arch_phys_wc_add() and devm_ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/gbefb.c | 26 +++---
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c
index f48ea7e..ef81215 100644
--- a/drivers/video/fbdev/gbefb.c
+++ b/drivers/video/fbdev/gbefb.c
@@ -22,9 +22,6 @@
 #include 
 #include 
 
-#ifdef CONFIG_X86
-#include 
-#endif
 #ifdef CONFIG_MIPS
 #include 
 #endif
@@ -1176,8 +1173,8 @@ static int gbefb_probe(struct platform_device *p_dev)
 
if (gbe_mem_phys) {
/* memory was allocated at boot time */
-   gbe_mem = devm_ioremap_nocache(&p_dev->dev, gbe_mem_phys,
-  gbe_mem_size);
+   gbe_mem = devm_ioremap_wc(&p_dev->dev, gbe_mem_phys,
+ gbe_mem_size);
if (!gbe_mem) {
printk(KERN_ERR "gbefb: couldn't map framebuffer\n");
ret = -ENOMEM;
@@ -1188,8 +1185,8 @@ static int gbefb_probe(struct platform_device *p_dev)
} else {
/* try to allocate memory with the classical allocator
 * this has high chance to fail on low memory machines */
-   gbe_mem = dma_alloc_coherent(NULL, gbe_mem_size, &gbe_dma_addr,
-GFP_KERNEL);
+   gbe_mem = dma_alloc_writecombine(NULL, gbe_mem_size,
+&gbe_dma_addr, GFP_KERNEL);
if (!gbe_mem) {
printk(KERN_ERR "gbefb: couldn't allocate framebuffer 
memory\n");
ret = -ENOMEM;
@@ -1199,10 +1196,7 @@ static int gbefb_probe(struct platform_device *p_dev)
gbe_mem_phys = (unsigned long) gbe_dma_addr;
}
 
-#ifdef CONFIG_X86
-   info->wc_cookie = mtrr_add(gbe_mem_phys, gbe_mem_size,
-  MTRR_TYPE_WRCOMB, 1);
-#endif
+   info->wc_cookie = arch_phys_wc_add(gbe_mem_phys, gbe_mem_size);
 
/* map framebuffer memory into tiles table */
for (i = 0; i < (gbe_mem_size >> TILE_SHIFT); i++)
@@ -1242,10 +1236,7 @@ static int gbefb_probe(struct platform_device *p_dev)
return 0;
 
 out_gbe_unmap:
-#ifdef CONFIG_MTRR
-   if (info->wc_cookie >= 0)
-   mtrr_del(info->wc_cookie, 0, 0);
-#endif
+   arch_phys_wc_del(info->wc_cookie);
if (gbe_dma_addr)
dma_free_coherent(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys);
 out_tiles_free:
@@ -1265,10 +1256,7 @@ static int gbefb_remove(struct platform_device* p_dev)
 
unregister_framebuffer(info);
gbe_turn_off();
-#ifdef CONFIG_MTRR
-   if (info->wc_cookie >=

Re: 4.0.0-rc4: panic in free_block

2015-03-20 Thread David Ahern

On 3/20/15 4:49 PM, David Ahern wrote:

On 3/20/15 3:17 PM, Linus Torvalds wrote:

In other words, if I read that sparc asm right (and it is very likely
that I do *not*), then "objp" is NULL, and that's why you crash.


That does appear to be why. I put a WARN_ON before
clear_obj_pfmemalloc() if objpp[i] is NULL. I got 2 splats during an
'allyesconfig' build and the system stayed up.



That's odd, because we know that objp cannot be NULL in
kmem_slab_free() (even if we allowed it, like with kfree(),
remove_vma() cannot possibly have a NULL vma, since ti dereferences it
multiple times).

So I must be misreading this completely. Somebody with better sparc
debugging mojo should double-check my logic. How would objp be NULL?


I'll add checks to higher layers and see if it reveals anything.

I did ask around and apparently this bug is hit only with the new M7
processors. DaveM: that's why you are not hitting this.


Here's another data point: If I disable NUMA I don't see the problem. 
Performance drops, but no NULL pointer splats which would have been panics.


The 128 cpu ldom with NUMA enabled shows the problem every single time I 
do a kernel compile (-j 128). With NUMA disabled I have done 3 
allyesconfig compiles without hitting the problem. I'll put the compiles 
into a loop while I head out for dinner.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 26/47] video: fbdev: gbefb: add missing mtrr_del() calls

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver never removed the MTRRs. Fix that.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/gbefb.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c
index 6d9ef39..f48ea7e 100644
--- a/drivers/video/fbdev/gbefb.c
+++ b/drivers/video/fbdev/gbefb.c
@@ -38,6 +38,7 @@ static struct sgi_gbe *gbe;
 struct gbefb_par {
struct fb_var_screeninfo var;
struct gbe_timing_info timing;
+   int wc_cookie;
int valid;
 };
 
@@ -1199,7 +1200,8 @@ static int gbefb_probe(struct platform_device *p_dev)
}
 
 #ifdef CONFIG_X86
-   mtrr_add(gbe_mem_phys, gbe_mem_size, MTRR_TYPE_WRCOMB, 1);
+   info->wc_cookie = mtrr_add(gbe_mem_phys, gbe_mem_size,
+  MTRR_TYPE_WRCOMB, 1);
 #endif
 
/* map framebuffer memory into tiles table */
@@ -1240,6 +1242,10 @@ static int gbefb_probe(struct platform_device *p_dev)
return 0;
 
 out_gbe_unmap:
+#ifdef CONFIG_MTRR
+   if (info->wc_cookie >= 0)
+   mtrr_del(info->wc_cookie, 0, 0);
+#endif
if (gbe_dma_addr)
dma_free_coherent(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys);
 out_tiles_free:
@@ -1259,6 +1265,10 @@ static int gbefb_remove(struct platform_device* p_dev)
 
unregister_framebuffer(info);
gbe_turn_off();
+#ifdef CONFIG_MTRR
+   if (info->wc_cookie >= 0)
+   mtrr_del(info->wc_cookie, 0, 0);
+#endif
if (gbe_dma_addr)
dma_free_coherent(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys);
dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t),
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 25/47] video: fbdev: radeonfb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/aty/radeon_base.c | 29 ++---
 drivers/video/fbdev/aty/radeonfb.h|  2 +-
 2 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/video/fbdev/aty/radeon_base.c 
b/drivers/video/fbdev/aty/radeon_base.c
index 26d80a4..922e8fc 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -85,10 +85,6 @@
 
 #endif /* CONFIG_PPC_OF */
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include 
 #include 
 
@@ -271,9 +267,7 @@ static bool mirror = 0;
 static int panel_yres = 0;
 static bool force_dfp = 0;
 static bool force_measure_pll = 0;
-#ifdef CONFIG_MTRR
 static bool nomtrr = 0;
-#endif
 static bool force_sleep;
 static bool ignore_devlist;
 #ifdef CONFIG_PMAC_BACKLIGHT
@@ -2260,8 +2254,8 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM, 
rinfo->video_ram);
 
do {
-   rinfo->fb_base = ioremap (rinfo->fb_base_phys,
- rinfo->mapped_vram);
+   rinfo->fb_base = ioremap_wc(rinfo->fb_base_phys,
+   rinfo->mapped_vram);
} while (rinfo->fb_base == NULL &&
 ((rinfo->mapped_vram /= 2) >= MIN_MAPPED_VRAM));
 
@@ -2359,11 +2353,9 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
goto err_unmap_fb;
}
 
-#ifdef CONFIG_MTRR
-   rinfo->mtrr_hdl = nomtrr ? -1 : mtrr_add(rinfo->fb_base_phys,
-rinfo->video_ram,
-MTRR_TYPE_WRCOMB, 1);
-#endif
+   if (!nomtrr)
+   rinfo->wc_cookie = arch_phys_wc_add(rinfo->fb_base_phys,
+   rinfo->video_ram);
 
if (backlight)
radeonfb_bl_init(rinfo);
@@ -2428,12 +2420,7 @@ static void radeonfb_pci_unregister(struct pci_dev *pdev)
  #endif
 
del_timer_sync(&rinfo->lvds_timer);
-
-#ifdef CONFIG_MTRR
-   if (rinfo->mtrr_hdl >= 0)
-   mtrr_del(rinfo->mtrr_hdl, 0, 0);
-#endif
-
+   arch_phys_wc_del(rinfo->wc_cookie);
 unregister_framebuffer(info);
 
 radeonfb_bl_exit(rinfo);
@@ -2489,10 +2476,8 @@ static int __init radeonfb_setup (char *options)
panel_yres = simple_strtoul((this_opt+11), NULL, 0);
} else if (!strncmp(this_opt, "backlight:", 10)) {
backlight = simple_strtoul(this_opt+10, NULL, 0);
-#ifdef CONFIG_MTRR
} else if (!strncmp(this_opt, "nomtrr", 6)) {
nomtrr = 1;
-#endif
} else i

[PATCH v1 24/47] video: fbdev: arkfb: use arch_phys_wc_add() and pci_iomap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/arkfb.c | 36 +---
 1 file changed, 5 insertions(+), 31 deletions(-)

diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
index b305a1e..6a317de 100644
--- a/drivers/video/fbdev/arkfb.c
+++ b/drivers/video/fbdev/arkfb.c
@@ -26,13 +26,9 @@
 #include  /* Why should fb driver call console functions? 
because console_lock() */
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 struct arkfb_info {
int mclk_freq;
-   int mtrr_reg;
+   int wc_cookie;
 
struct dac_info *dac;
struct vgastate state;
@@ -102,10 +98,6 @@ static const struct svga_timing_regs ark_timing_regs = {
 
 static char *mode_option = "640x480-8@60";
 
-#ifdef CONFIG_MTRR
-static int mtrr = 1;
-#endif
-
 MODULE_AUTHOR("(c) 2007 Ondrej Zajicek ");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("fbdev driver for ARK 2000PV");
@@ -115,11 +107,6 @@ MODULE_PARM_DESC(mode_option, "Default video mode 
('640x480-8@60', etc)");
 module_param_named(mode, mode_option, charp, 0444);
 MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) 
(deprecated)");
 
-#ifdef CONFIG_MTRR
-module_param(mtrr, int, 0444);
-MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, 
default=1)");
-#endif
-
 static int threshold = 4;
 
 module_param(threshold, int, 0644);
@@ -1002,7 +989,7 @@ static int ark_pci_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
info->fix.smem_len = pci_resource_len(dev, 0);
 
/* Map physical IO memory address into kernel space */
-   info->screen_base = pci_iomap(dev, 0, 0);
+   info->screen_base = pci_iomap_wc(dev, 0, 0);
if (! info->screen_base) {
rc = -ENOMEM;
dev_err(info->device, "iomap for framebuffer failed\n");
@@ -1057,14 +1044,8 @@ static int ark_pci_probe(struct pci_dev *dev, const 
struct pci_device_id *id)
 
/* Record a reference to the driver data */
pci_set_drvdata(dev, info);
-
-#ifdef CONFIG_MTRR
-   if (mtrr) {
-   par->mtrr_reg = -1;
-   par->mtrr_reg = mtrr_add(info->fix.smem_start, 
info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
-   }
-#endif
-
+   par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
+ info->fix.smem_len);
return 0;
 
/* Error handling */
@@ -1092,14 +1073,7 @@ static void ark_pci_remove(struct pci_dev *dev)
 
if (info) {
struct arkfb_info *par = info->par;
-
-#ifdef CONFIG_MTRR
-   if (par->mtrr_reg >= 0) {
-   mtrr_del(par->mtrr_reg, 0, 0);
-   par->mtrr_reg = -1;
-   }
-

[PATCH v1 23/47] staging: xgifb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/staging/xgifb/XGI_main_26.c | 27 ++-
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 74e8820..943d463 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -8,10 +8,7 @@
 
 #include 
 #include 
-
-#ifdef CONFIG_MTRR
-#include 
-#endif
+#include 
 
 #include "XGI_main.h"
 #include "vb_init.h"
@@ -1770,7 +1767,7 @@ static int xgifb_probe(struct pci_dev *pdev,
}
 
xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress =
-   ioremap(xgifb_info->video_base, xgifb_info->video_size);
+   ioremap_wc(xgifb_info->video_base, xgifb_info->video_size);
xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base,
xgifb_info->mmio_size);
 
@@ -2014,12 +2011,8 @@ static int xgifb_probe(struct pci_dev *pdev,
 
fb_alloc_cmap(&fb_info->cmap, 256, 0);
 
-#ifdef CONFIG_MTRR
-   xgifb_info->mtrr = mtrr_add(xgifb_info->video_base,
-   xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1);
-   if (xgifb_info->mtrr >= 0)
-   dev_info(&pdev->dev, "Added MTRR\n");
-#endif
+   xgifb_info->mtrr = arch_phys_wc_add(xgifb_info->video_base,
+   xgifb_info->video_size);
 
if (register_framebuffer(fb_info) < 0) {
ret = -EINVAL;
@@ -2031,11 +2024,7 @@ static int xgifb_probe(struct pci_dev *pdev,
return 0;
 
 error_mtrr:
-#ifdef CONFIG_MTRR
-   if (xgifb_info->mtrr >= 0)
-   mtrr_del(xgifb_info->mtrr, xgifb_info->video_base,
-   xgifb_info->video_size);
-#endif /* CONFIG_MTRR */
+   arch_phys_wc_del(xgifb_info->mtrr);
 error_1:
iounmap(xgifb_info->mmio_vbase);
iounmap(xgifb_info->video_vbase);
@@ -2059,11 +2048,7 @@ static void xgifb_remove(struct pci_dev *pdev)
struct fb_info *fb_info = xgifb_info->fb_info;
 
unregister_framebuffer(fb_info);
-#ifdef CONFIG_MTRR
-   if (xgifb_info->mtrr >= 0)
-   mtrr_del(xgifb_info->mtrr, xgifb_info->video_base,
-   xgifb_info->video_size);
-#endif /* CONFIG_MTRR */
+   arch_phys_wc_del(xgifb_info->mtrr);
iounmap(xgifb_info->mmio_vbase);
iounmap(xgifb_info->video_vbase);
release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);
-- 
2.3.2.209.gd67f9d5.dirty

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

[PATCH v1 22/47] staging: sm750fb: use arch_phys_wc_add() and ioremap_wc()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/staging/sm750fb/sm750.c| 34 --
 drivers/staging/sm750fb/sm750.h|  3 ---
 drivers/staging/sm750fb/sm750_hw.c |  3 +--
 3 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index aa0888c..ea59471 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -16,9 +16,6 @@
 #include
 #include
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 #include 
 #include "sm750.h"
 #include "sm750_hw.h"
@@ -47,9 +44,7 @@ typedef int (*PROC_SPEC_INITHW)(struct lynx_share*,struct 
pci_dev*);
 /* common var for all device */
 static int g_hwcursor = 1;
 static int g_noaccel = 0;
-#ifdef CONFIG_MTRR
 static int g_nomtrr  = 0;
-#endif
 static const char * g_fbmode[] = {NULL,NULL};
 static const char * g_def_fbmode = "800x600-16@60";
 static char * g_settings = NULL;
@@ -1102,11 +1097,8 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
 
pr_info("share->revid = %02x\n",share->revid);
share->pdev = pdev;
-#ifdef CONFIG_MTRR
share->mtrr_off = g_nomtrr;
share->mtrr.vram = 0;
-   share->mtrr.vram_added = 0;
-#endif
share->accel_off = g_noaccel;
share->dual = g_dualview;
spin_lock_init(&share->slock);
@@ -1134,22 +1126,9 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
goto err_map;
}
 
-#ifdef CONFIG_MTRR
-   if(!share->mtrr_off){
-   pr_info("enable mtrr\n");
-   share->mtrr.vram = mtrr_add(share->vidmem_start,
-   share->vidmem_size,
-   MTRR_TYPE_WRCOMB,1);
-
-   if(share->mtrr.vram < 0){
-   /* don't block driver with the failure of MTRR */
-   pr_err("Unable to setup MTRR.\n");
-   }else{
-   share->mtrr.vram_added = 1;
-   pr_info("MTRR added succesfully\n");
-   }
-   }
-#endif
+   if (!share->mtrr_off)
+   share->mtrr.vram = arch_phys_wc_add(share->vidmem_start,
+   share->vidmem_size);
 
memset(share->pvMem,0,share->vidmem_size);
 
@@ -1250,10 +1229,7 @@ static void __exit lynxfb_pci_remove(struct pci_dev * 
pdev)
/* release frame buffer*/
framebuffer_release(info);
}
-#ifdef CONFIG_MTRR
-   if(share->mtrr.vram_added)
-   
mtrr_del(share->mtrr.vram,share->vidmem_start,share->vidmem_size);
-#endif
+   arch_phys_wc_del(share->mtrr.vram);
//  pci_rel

[PATCH v1 21/47] ethernet: myri10ge: use arch_phys_wc_add()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver already uses ioremap_wc() on the same range
so when write-combining is available that will be used
instead.

Cc: Andy Lutomirski 
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Hyong-Youb Kim 
Cc: net...@vger.kernel.org
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 36 ++--
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c 
b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index 1412f5a..01e4069 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -69,11 +69,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 #include 
 
 #include "myri10ge_mcp.h"
@@ -242,8 +238,7 @@ struct myri10ge_priv {
unsigned int rdma_tags_available;
int intr_coal_delay;
__be32 __iomem *intr_coal_delay_ptr;
-   int mtrr;
-   int wc_enabled;
+   int wc_cookie;
int down_cnt;
wait_queue_head_t down_wq;
struct work_struct watchdog_work;
@@ -1984,7 +1979,6 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
data[i] = ((u64 *)&link_stats)[i];
 
data[i++] = (unsigned int)mgp->tx_boundary;
-   data[i++] = (unsigned int)mgp->wc_enabled;
data[i++] = (unsigned int)mgp->pdev->irq;
data[i++] = (unsigned int)mgp->msi_enabled;
data[i++] = (unsigned int)mgp->msix_enabled;
@@ -4040,14 +4034,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
mgp->board_span = pci_resource_len(pdev, 0);
mgp->iomem_base = pci_resource_start(pdev, 0);
-   mgp->mtrr = -1;
-   mgp->wc_enabled = 0;
-#ifdef CONFIG_MTRR
-   mgp->mtrr = mtrr_add(mgp->iomem_base, mgp->board_span,
-MTRR_TYPE_WRCOMB, 1);
-   if (mgp->mtrr >= 0)
-   mgp->wc_enabled = 1;
-#endif
+   mgp->wc_cookie = arch_phys_wc_add(mgp->iomem_base, mgp->board_span);
mgp->sram = ioremap_wc(mgp->iomem_base, mgp->board_span);
if (mgp->sram == NULL) {
dev_err(&pdev->dev, "ioremap failed for %ld bytes at 0x%lx\n",
@@ -4146,14 +4133,14 @@ static int myri10ge_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto abort_with_state;
}
if (mgp->msix_enabled)
-   dev_info(dev, "%d MSI-X IRQs, tx bndry %d, fw %s, WC %s\n",
+   dev_info(dev, "%d MSI-X IRQs, tx bndry %d, fw %s, MTRR %s, WC 
Enabled\n",
 mgp->num_slices, mgp->tx_boundary, mgp->fw_name,
-(mgp->wc_enabled ? "Enabled" : "Disabled"));
+(mgp->wc_cookie > 0 ? "Enabled" : "Disabled"));
else
-   dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
+   dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, MTRR %s, WC 
Enabled\n",
 mgp->msi_enabled ? "MSI" : "xPIC",
 pdev->irq, mgp->tx_boundary, mgp->fw_name,
-(mgp->wc_enabled ? "Enabled" : "Disabled"));
+(mgp->wc_cookie > 0 ? "Enabled" : "Disabled"));
 
board_number++;
return 0;
@@ -4175,10 +4162,7 @@ abort_with_ioremap:
iounmap(mgp->sram);
 
 abort_with_mtrr:
-#ifdef CONFIG_MTRR
-   if (mgp->mtrr >= 0)
-   mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
-#endif
+   arch_phys_wc_del(mgp->wc_cookie);
dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
  mgp->cmd, mgp->cmd_bus);
 
@@ -4220,11 +4204,7 @@ static void myri10ge_remove(struct pci_dev *pdev)
pci_restore_state(pdev);
 
iounmap(mgp->sram);
-
-#ifdef CONFIG_MTRR
-   if (mgp->mtrr >= 0)
-   mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
-#endif
+   arch_phys_wc_del(mgp->wc_cookie);
myri10ge_free_slices(mgp);
kfree(mgp->msix_vectors);
dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 20/47] mtrr: avoid ifdef'ery with phys_wc_to_mtrr_index()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

There is only one user but since we're going to bury
MTRR next out of access to drivers expose this last
piece of API to drivers in a general fashion only
needing io.h for access to helpers.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 arch/x86/include/asm/io.h   |  2 ++
 arch/x86/include/asm/mtrr.h |  5 -
 arch/x86/kernel/cpu/mtrr/main.c |  6 +++---
 drivers/gpu/drm/drm_ioctl.c | 14 +-
 include/linux/io.h  |  6 ++
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index a144d05..5e3f1f2 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -346,6 +346,8 @@ extern int __must_check arch_phys_wc_add(unsigned long base,
 unsigned long size);
 extern void arch_phys_wc_del(int handle);
 #define arch_phys_wc_add arch_phys_wc_add
+extern int arch_phys_wc_index(int handle);
+#define arch_phys_wc_index arch_phys_wc_index
 #endif
 
 #endif /* _ASM_X86_IO_H */
diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
index cade917..380bb4b 100644
--- a/arch/x86/include/asm/mtrr.h
+++ b/arch/x86/include/asm/mtrr.h
@@ -49,7 +49,6 @@ extern void mtrr_aps_init(void);
 extern void mtrr_bp_restore(void);
 extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
 extern int amd_special_default_mtrr(void);
-extern int phys_wc_to_mtrr_index(int handle);
 #  else
 static const int mtrr_enabled;
 static inline u8 mtrr_type_lookup(u64 addr, u64 end)
@@ -86,10 +85,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long 
end_pfn)
 static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
 {
 }
-static inline int phys_wc_to_mtrr_index(int handle)
-{
-   return -1;
-}
 
 #define mtrr_ap_init() do {} while (0)
 #define mtrr_bp_init() do {} while (0)
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 5ae830b..b68b671 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -607,7 +607,7 @@ void arch_phys_wc_del(int handle)
 EXPORT_SYMBOL(arch_phys_wc_del);
 
 /*
- * phys_wc_to_mtrr_index - translates arch_phys_wc_add's return value
+ * arch_phys_wc_index - translates arch_phys_wc_add's return value
  * @handle: Return value from arch_phys_wc_add
  *
  * This will turn the return value from arch_phys_wc_add into an mtrr
@@ -617,14 +617,14 @@ EXPORT_SYMBOL(arch_phys_wc_del);
  * in printk line.  Alas there is an illegitimate use in some ancient
  * drm ioctls.
  */
-int phys_wc_to_mtrr_index(int handle)
+int arch_phys_wc_index(int handle)
 {
if (handle < MTRR_TO_PHYS_WC_OFFSET)
return -1;
else
return handle - MTRR_TO_PHYS_WC_OFFSET;
 }
-EXPORT_SYMBOL_GPL(phys_wc_to_mtrr_index);
+EXPORT_SYMBOL_GPL(arch_phys_wc_index);
 
 /*
  * HACK ALERT!
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index a6d773a..e597cdd 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -36,9 +36,6 @@
 
 #include 
 #include 
-#ifdef CONFIG_X86
-#include 
-#endif
 
 static int drm_version(struct drm_device *dev, void *data,
   struct drm_file *file_priv);
@@ -197,16 +194,7 @@ static int drm_getmap(struct drm_device *dev, void *data,
map->type = r_list->map->type;
map->flags = r_list->map->flags;
map->handle = (void *)(unsigned long) r_list->user_token;
-
-#ifdef CONFIG_X86
-   /*
-* There appears to be exactly one user of the mtrr index: dritest.
-* It's easy enough to keep it working on non-PAT systems.
-*/
-   map->mtrr = phys_wc_to_mtrr_index(r_list->map->mtrr);
-#else
-   map->mtrr = -1;
-#endif
+   map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
 
mutex_unlock(&dev->struct_mutex);
 
diff --git a/include/linux/io.h b/include/linux/io.h
index ecc51c3..1676437 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -115,6 +115,12 @@ static inline void arch_phys_wc_del(int handle)
 #define __arch_phys_wc_add arch_phys_wc_add
 #endif
 
+#ifndef arch_phys_wc_index
+static inline int arch_phys_wc_index(int handle)
+{
+   return -1;
+}
+#define arch_phys_wc_index arch_phys_wc_index
 #endif
 
 #endif /* _LINUX_IO_H */
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 19/47] video: fbdev: vesafb: use arch_phys_wc_add()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver uses the same area for MTRR as for the ioremap_wc(), if
anything it just uses a smaller size in case MTRR reservation fails.
ioremap_wc() API is already used to take advantage of architecture
write-combining when available.

Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e)

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/vesafb.c | 29 -
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index a2261d0..5bc94d3 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -19,10 +19,9 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
-#include 
-#include 
 
 #define dac_reg(0x3c8)
 #define dac_val(0x3c9)
@@ -179,16 +178,10 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, 
unsigned green,
 
 static void vesafb_destroy(struct fb_info *info)
 {
-#ifdef CONFIG_MTRR
struct vesafb_par *par = info->par;
-#endif
 
fb_dealloc_cmap(&info->cmap);
-
-#ifdef CONFIG_MTRR
-   if (par->wc_cookie >= 0)
-   mtrr_del(par->wc_cookie, 0, 0);
-#endif
+   arch_phys_wc_del(par->wc_cookie);
if (info->screen_base)
iounmap(info->screen_base);
release_mem_region(info->apertures->ranges[0].base, 
info->apertures->ranges[0].size);
@@ -419,7 +412,6 @@ static int vesafb_probe(struct platform_device *dev)
request_region(0x3c0, 32, "vesafb");
 
if (mtrr == 3) {
-#ifdef CONFIG_MTRR
unsigned int temp_size = size_total;
 
/* Find the largest power-of-two */
@@ -427,18 +419,16 @@ static int vesafb_probe(struct platform_device *dev)
 
/* Try and find a power of two to add */
do {
-   par->wc_cookie = mtrr_add(vesafb_fix.smem_start,
- temp_size,
- MTRR_TYPE_WRCOMB, 1);
+   par->wc_cookie =
+   arch_phys_wc_add(vesafb_fix.smem_start,
+temp_size);
temp_size >>= 1;
-   } while (temp_size >= PAGE_SIZE && par->wc_cookie == -EINVAL);
-#endif
+   } while (temp_size >= PAGE_SIZE && par->wc_cookie < 0);
+
info->screen_base = ioremap_wc(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
} else {
-#ifdef CONFIG_MTRR
if (mtrr && mtrr != 3)
WARN_ONCE(1, "Only MTRR_TYPE_WRCOMB (3) make sense\n");
-#endif
info->screen_base = ioremap(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
}
 
@@ -476,10 +466,7 @@ static int vesafb_probe(struct platform_device *dev)
fb_info(info, "%s frame buffer device\n", info->fix.id);
return 0;
 err:
-#ifdef CONF

Re: powerpc32: fix warning from include/asm-generic/termios-base.h

2015-03-20 Thread Scott Wood
On Fri, Dec 05, 2014 at 12:20:25PM +0100, LEROY Christophe wrote:
> When size is equal to 1, the test is always true so lets eliminate both 0 and 
> 1
> at first.
> 
> include/asm-generic/termios-base.h: In function 
> 'user_termio_to_kernel_termios':
> include/asm-generic/termios-base.h:35:2: warning: comparison of unsigned 
> expression >= 0 is always true [-Wtype-limits]
>   if (get_user(termios->c_line, &termio->c_line) < 0)
>   ^
> include/asm-generic/termios-base.h: In function 
> 'kernel_termios_to_user_termio':
> include/asm-generic/termios-base.h:57:6: warning: comparison of unsigned 
> expression >= 0 is always true [-Wtype-limits]
>   put_user(termios->c_line,  &termio->c_line) < 0 ||
>   ^
> 
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/uaccess.h 
> b/arch/powerpc/include/asm/uaccess.h
> index 9485b43..f3028d2 100644
> --- a/arch/powerpc/include/asm/uaccess.h
> +++ b/arch/powerpc/include/asm/uaccess.h
> @@ -54,7 +54,7 @@
>  
>  #define __access_ok(addr, size, segment) \
>   (((addr) <= (segment).seg) &&   \
> -  (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)
> +  (((size) <= 1) || (((size) - 1) <= ((segment).seg - (addr)

Again, I don't think Linux enables this warning.  What did you do to
produce this?  In any case, it's a bad warning that doesn't take macros
into account, and the answer is not to make the code less clear by hiding
the fact that zero is a special case.

-Scott
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 18/47] vidoe: fbdev: vesafb: add missing mtrr_del() for added MTRR

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The MTRR added was never being deleted.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/vesafb.c | 30 --
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index 191156b..a2261d0 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -29,6 +29,10 @@
 
 /* - */
 
+struct vesafb_par {
+   int wc_cookie;
+};
+
 static struct fb_var_screeninfo vesafb_defined = {
.activate   = FB_ACTIVATE_NOW,
.height = -1,
@@ -175,7 +179,16 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, 
unsigned green,
 
 static void vesafb_destroy(struct fb_info *info)
 {
+#ifdef CONFIG_MTRR
+   struct vesafb_par *par = info->par;
+#endif
+
fb_dealloc_cmap(&info->cmap);
+
+#ifdef CONFIG_MTRR
+   if (par->wc_cookie >= 0)
+   mtrr_del(par->wc_cookie, 0, 0);
+#endif
if (info->screen_base)
iounmap(info->screen_base);
release_mem_region(info->apertures->ranges[0].base, 
info->apertures->ranges[0].size);
@@ -228,6 +241,7 @@ static int vesafb_setup(char *options)
 static int vesafb_probe(struct platform_device *dev)
 {
struct fb_info *info;
+   struct vesafb_par *par;
int i, err;
unsigned int size_vmode;
unsigned int size_remap;
@@ -297,8 +311,8 @@ static int vesafb_probe(struct platform_device *dev)
return -ENOMEM;
}
platform_set_drvdata(dev, info);
-   info->pseudo_palette = info->par;
-   info->par = NULL;
+   info->pseudo_palette = NULL;
+   par = info->par;
 
/* set vesafb aperture size for generic probing */
info->apertures = alloc_apertures(1);
@@ -407,17 +421,17 @@ static int vesafb_probe(struct platform_device *dev)
if (mtrr == 3) {
 #ifdef CONFIG_MTRR
unsigned int temp_size = size_total;
-   int rc;
 
/* Find the largest power-of-two */
temp_size = roundup_pow_of_two(temp_size);
 
/* Try and find a power of two to add */
do {
-   rc = mtrr_add(vesafb_fix.smem_start, temp_size,
- MTRR_TYPE_WRCOMB, 1);
+   par->wc_cookie = mtrr_add(vesafb_fix.smem_start,
+ temp_size,
+ MTRR_TYPE_WRCOMB, 1);
temp_size >>= 1;
-   } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
+   } while (temp_size >= PAGE_SIZE && par->wc_cookie == -EINVAL);
 #endif
info->screen_base = ioremap_wc(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
} else {
@@ -462,6 +476,10 @@ static int vesafb_probe(struct platform_device *dev)
fb_info(info, "%s frame buffer device\n", info->fix.id);
return 0;
 err:
+#ifdef CONFIG_MTRR
+   if (par->wc_cookie >= 0)
+   mtrr_del(par->wc_cookie, 0, 0);
+#endif
if (info->screen_base)
iounmap(info->screen_base);
framebuffer_release(info);
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 17/47] video: fbdev: vesafb: only support MTRR_TYPE_WRCOMB

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

No other video driver uses MTRR types except for MTRR_TYPE_WRCOMB,
the other MTRR types were implemented and supported here but with
no real good reason. The ioremap() APIs are architecture agnostic and
at least on x86 PAT is a new design that extends MTRRs and
can replace it in a much cleaner way, where so long as the
proper ioremap_wc() or variant API is used the right thing will
be done behind the scenes. This is the only driver left using the
other MTRR types -- and since there is no good reason for it now
rip them out.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/video/fbdev/vesafb.c | 62 
 1 file changed, 16 insertions(+), 46 deletions(-)

diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index d79a0ac..191156b 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -404,60 +404,30 @@ static int vesafb_probe(struct platform_device *dev)
 * region already (FIXME) */
request_region(0x3c0, 32, "vesafb");
 
+   if (mtrr == 3) {
 #ifdef CONFIG_MTRR
-   if (mtrr) {
unsigned int temp_size = size_total;
-   unsigned int type = 0;
+   int rc;
 
-   switch (mtrr) {
-   case 1:
-   type = MTRR_TYPE_UNCACHABLE;
-   break;
-   case 2:
-   type = MTRR_TYPE_WRBACK;
-   break;
-   case 3:
-   type = MTRR_TYPE_WRCOMB;
-   break;
-   case 4:
-   type = MTRR_TYPE_WRTHROUGH;
-   break;
-   default:
-   type = 0;
-   break;
-   }
-
-   if (type) {
-   int rc;
-
-   /* Find the largest power-of-two */
-   temp_size = roundup_pow_of_two(temp_size);
+   /* Find the largest power-of-two */
+   temp_size = roundup_pow_of_two(temp_size);
 
-   /* Try and find a power of two to add */
-   do {
-   rc = mtrr_add(vesafb_fix.smem_start, temp_size,
- type, 1);
-   temp_size >>= 1;
-   } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
-   }
-   }
+   /* Try and find a power of two to add */
+   do {
+   rc = mtrr_add(vesafb_fix.smem_start, temp_size,
+ MTRR_TYPE_WRCOMB, 1);
+   temp_size >>= 1;
+   } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
 #endif
-   
-   switch (mtrr) {
-   case 1: /* uncachable */
-   info->screen_base = ioremap_nocache(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
-   break;
-   case 2: /* write-back */
-   info->screen_base = ioremap_cache(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
-   break;
-   case 3: /* write-combining */
info->screen_base = ioremap_wc(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
-   break;
-   case 4: /* write-through */
-   default:
+   } else {
+#ifdef CONFIG_MTRR
+   if (mtrr && mtrr != 3)
+   WARN_ONCE(1, "Only MTRR_TYPE_WRCOMB (3) make sense\n");
+#endif
info->screen_base = ioremap(vesafb_fix.smem_start, 
vesafb_fix.smem_len);
-   break;
}
+
if (!info->screen_base) {
printk(KERN_ERR
   "vesafb: abort, cannot ioremap video memory 0x%x @ 
0x%lx\n",
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 16/47] fusion: use __arch_phys_wc_add()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

If and when this gets enabled the driver should address
using ioremap_wc() on the same area, that could require
a bit of work as it would mean a split with two ioremap'd
areas. Annotate this.

Cc: Andy Lutomirski 
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Nagalakshmi Nandigama 
Cc: Praveen Krishnamoorthy 
Cc: Sreekanth Reddy 
Cc: Abhijit Mahajan 
Cc: Juergen Gross 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Tomi Valkeinen 
Cc: Jean-Christophe Plagniol-Villard 
Cc: mpt-fusionlinux@avagotech.com
Cc: linux-s...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/message/fusion/mptbase.c | 19 ---
 drivers/message/fusion/mptbase.h |  2 +-
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 187f836..c7b1a55 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -59,10 +59,6 @@
 #include 
 #include/* needed for in_interrupt() proto */
 #include 
-#include 
-#ifdef CONFIG_MTRR
-#include 
-#endif
 #include 
 #include 
 
@@ -2820,11 +2816,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
pci_disable_device(ioc->pcidev);
pci_release_selected_regions(ioc->pcidev, ioc->bars);
 
-#if defined(CONFIG_MTRR) && 0
-   if (ioc->mtrr_reg > 0) {
-   mtrr_del(ioc->mtrr_reg, 0, 0);
-   dprintk(ioc, printk(MYIOC_s_INFO_FMT "MTRR region 
de-registered\n", ioc->name));
-   }
+#if 0
+   __arch_phys_wc_del(ioc->wc_cookie);
 #endif
 
/*  Zap the adapter lookup ptr!  */
@@ -4512,17 +4505,13 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
 
ioc->req_frames_low_dma = (u32) (alloc_dma & 0x);
 
-#if defined(CONFIG_MTRR) && 0
+#if 0
/*
 *  Enable Write Combining MTRR for IOC's memory region.
 *  (at least as much as we can; "size and base must be
 *  multiples of 4 kiB"
 */
-   ioc->mtrr_reg = mtrr_add(ioc->req_frames_dma,
-sz,
-MTRR_TYPE_WRCOMB, 1);
-   dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MTRR region registered 
(base:size=%08x:%x)\n",
-   ioc->name, ioc->req_frames_dma, sz));
+   ioc->wc_cookie = arch_phys_wc_add(ioc->req_frames_dma, sz);
 #endif
 
for (i = 0; i < ioc->req_depth; i++) {
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 8f14090..f0bff11 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -671,7 +671,7 @@ typedef struct _MPT_ADAPTER
u8  *HostPageBuffer; /* SAS - host page buffer 
support */
u32 HostPageBuffer_sz;
dma_addr_t  HostPageBuffer_dma;
-   int  mtrr_reg;
+   int wc_cookie;
struct pci_dev  *pcidev;/* struct pci_dev pointer */
int bars;   /* bitmask of BAR's that must 
be configured */
int msi_enable;
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 15/47] [media] media: ivtv: use __arch_phys_wc_add()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Sadly this driver requires a bit of work in order
to use ioremap_wc() on the range currently used
for MTRR write-combining. We'd need to ensure two
ioremap() calls are done. Annotate this.

Cc: Andy Lutomirski 
Cc: Andy Walls 
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: Bjorn Helgaas 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Dave Hansen 
Cc: Arnd Bergmann 
Cc: Michael S. Tsirkin 
Cc: venkatesh.pallip...@intel.com
Cc: Stefan Bader 
Cc: konrad.w...@oracle.com
Cc: ville.syrj...@linux.intel.com
Cc: david.vra...@citrix.com
Cc: jbeul...@suse.com
Cc: toshi.k...@hp.com
Cc: Roger Pau Monné 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: ivtv-de...@ivtvdriver.org
Cc: linux-me...@vger.kernel.org
Cc: xen-de...@lists.xensource.com
Signed-off-by: Luis R. Rodriguez 
---
 drivers/media/pci/ivtv/ivtvfb.c | 51 +++--
 1 file changed, 14 insertions(+), 37 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
index 9ff1230..ceefa6f 100644
--- a/drivers/media/pci/ivtv/ivtvfb.c
+++ b/drivers/media/pci/ivtv/ivtvfb.c
@@ -44,10 +44,6 @@
 #include 
 #include 
 
-#ifdef CONFIG_MTRR
-#include 
-#endif
-
 #include "ivtv-driver.h"
 #include "ivtv-cards.h"
 #include "ivtv-i2c.h"
@@ -155,12 +151,11 @@ struct osd_info {
/* Buffer size */
u32 video_buffer_size;
 
-#ifdef CONFIG_MTRR
/* video_base rounded down as required by hardware MTRRs */
unsigned long fb_start_aligned_physaddr;
/* video_base rounded up as required by hardware MTRRs */
unsigned long fb_end_aligned_physaddr;
-#endif
+   int wc_cookie;
 
/* Store the buffer offset */
int set_osd_coords_x;
@@ -1099,6 +1094,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
 static int ivtvfb_init_io(struct ivtv *itv)
 {
struct osd_info *oi = itv->osd_info;
+   /* Find the largest power of two that maps the whole buffer */
+   int size_shift = 31;
 
mutex_lock(&itv->serialize_lock);
if (ivtv_init_on_first_open(itv)) {
@@ -1132,29 +1129,16 @@ static int ivtvfb_init_io(struct ivtv *itv)
oi->video_pbase, oi->video_vbase,
oi->video_buffer_size / 1024);
 
-#ifdef CONFIG_MTRR
-   {
-   /* Find the largest power of two that maps the whole buffer */
-   int size_shift = 31;
-
-   while (!(oi->video_buffer_size & (1 << size_shift))) {
-   size_shift--;
-   }
-   size_shift++;
-   oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << 
size_shift) - 1);
-   oi->fb_end_aligned_physaddr = oi->video_pbase + 
oi->video_buffer_size;
-   oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
-   oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
-   if (mtrr_add(oi->fb_start_aligned_physaddr,
-   oi->fb_end_aligned_physaddr - 
oi->fb_start_aligned_physaddr,
-MTRR_TYPE_WRCOMB, 1) < 0) {
-   IVTVFB_INFO("disabled mttr\n");
-   oi->fb_start_aligned_physaddr = 0;
-   oi->fb_end_aligned_physaddr = 0;
-   }
-   }
-#endif
-
+   while (!(oi->video_buffer_size & (1 << size_shift)))
+   size_shift--;
+   size_shift++;
+   oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 
1);
+   oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
+   oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
+   oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
+   oi->wc_cookie = __arch_phys_wc_add(oi->fb_start_aligned_physaddr,
+  oi->fb_end_aligned_physaddr -
+  oi->fb_start_aligned_physaddr);
/* Blank the entire osd. */
memset_io(oi->video_vbase, 0, oi->video_buffer_size);
 
@@ -1172,14 +1156,7 @@ static void ivtvfb_release_buffers (struct ivtv *itv)
 
/* Release pseudo palette */
kfree(oi->ivtvfb_info.pseudo_palette);
-
-#ifdef CONFIG_MTRR
-   if (oi->fb_end_aligned_physaddr) {
-   mtrr_del(-1, oi->fb_start_aligned_physaddr,
-   oi->fb_end_aligned_physaddr - 
oi->fb_start_aligned_physaddr);
-   }
-#endif
-
+   arch_phys_wc_del(oi->wc_cookie);
kfree(oi);
itv->osd_info = NULL;
 }
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 09/47] vidoe: fbdev: atyfb: remove and fix MTRR MMIO "hole" work around

2015-03-20 Thread Andy Lutomirski
On Fri, Mar 20, 2015 at 4:17 PM, Luis R. Rodriguez
 wrote:
> From: "Luis R. Rodriguez" 
>
> The atyfb driver uses an MTRR work around since some
> cards use the same PCI BAR for the framebuffer and MMIO.
> In such cards the last page is used for MMIO, the rest for
> the framebuffer, so on those cards we ioremap() the MMIO
> page alone, then again ioremap() the full framebuffer
> including the MMIO space *and* ___then___ use an MTRR with
> MTRR_TYPE_WRCOMB on the full PCI BAR... and finally "hole"
> in an MTRR_TYPE_UNCACHABLE MTRR only for MMIO.
>
> This is a terrible fucking work around, and should by no means
> be necessary however evidence through a large series of conversion
> of drivers to ioremap_wc() for the framebuffer shows that around
> the time MTRR started becoming popular devices did not have things
> lined up for easily separating the framebuffer and MMIO register
> access. In some cases a driver requires significant intrusive
> changes in order to make the split for an ioremap() for MMIO registers
> and another ioremap_wc() for the framebuffer, at other times a
> bit of careful study of the driver suffices. This example driver
> falls into the later category.
>
> We can replace the MTRR MTRR_TYPE_UNCACHABLE
> work around by using ioremap_nocache(), the length of the
> MMIO space should already be correct. The other part we
> need to correct is ensuring we ioremap() for the framebuffer
> only the required size. Since the ioremap() happens early
> on probe for PCI devices before aty_init() where we typically
> adjust the length and know how to do it, we can fix this by
> pegging the bus type as PCI on PCI probe, and finally fudging
> and framebuffer length just as we do on aty_init().
>
> The last thing we do must do to remain sane is ensure we
> use the info->fix.smem_start and info->fix.smem_len for
> the framebuffer MTRR as we know that is always well adjusted.
> The *one* concern here would be if the MTRR is not in units
> of 4K __but__ we already know that in the PCI case this cannot
> happen, in the shared space setting the MTRR would be up to
> 0x7ff000 and assuming a 4K page:
>
> ; 0x7ff000 / 0x1000
> 2047
>
> Also, internally when MTRR is used mtrr_add() will use mtrr_check()
> and that should splat a warning when the MTRR base and size are
> not compatible with what is expected for MTRR usage.
>
> This fix lets us nuke the MTRR_TYPE_UNCACHABLE MTRR "hole".
>
> Cc: Suresh Siddha 
> Cc: Venkatesh Pallipadi 
> Cc: Ingo Molnar 
> Cc: Linus Torvalds 
> Cc: Thomas Gleixner 
> Cc: Juergen Gross 
> Cc: Daniel Vetter 
> Cc: Andy Lutomirski 
> Cc: Dave Airlie 
> Cc: Antonino Daplas 
> Cc: Jean-Christophe Plagniol-Villard 
> Cc: Tomi Valkeinen 
> Cc: linux-fb...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Luis R. Rodriguez 
> ---
>  drivers/video/fbdev/aty/atyfb.h  |  1 -
>  drivers/video/fbdev/aty/atyfb_base.c | 28 ++--
>  2 files changed, 6 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/video/fbdev/aty/atyfb.h b/drivers/video/fbdev/aty/atyfb.h
> index 1f39a62..89ec439 100644
> --- a/drivers/video/fbdev/aty/atyfb.h
> +++ b/drivers/video/fbdev/aty/atyfb.h
> @@ -184,7 +184,6 @@ struct atyfb_par {
> spinlock_t int_lock;
>  #ifdef CONFIG_MTRR
> int mtrr_aper;
> -   int mtrr_reg;
>  #endif
> u32 mem_cntl;
> struct crtc saved_crtc;
> diff --git a/drivers/video/fbdev/aty/atyfb_base.c 
> b/drivers/video/fbdev/aty/atyfb_base.c
> index 8025624..8875e56 100644
> --- a/drivers/video/fbdev/aty/atyfb_base.c
> +++ b/drivers/video/fbdev/aty/atyfb_base.c
> @@ -2630,21 +2630,10 @@ static int aty_init(struct fb_info *info)
>
>  #ifdef CONFIG_MTRR
> par->mtrr_aper = -1;
> -   par->mtrr_reg = -1;
> if (!nomtrr) {
> -   /* Cover the whole resource. */
> -   par->mtrr_aper = mtrr_add(par->res_start, par->res_size,
> +   par->mtrr_aper = mtrr_add(info->fix.smem_start,
> + info->fix.smem_len,
>   MTRR_TYPE_WRCOMB, 1);
> -   if (par->mtrr_aper >= 0 && !par->aux_start) {
> -   /* Make a hole for mmio. */
> -   par->mtrr_reg = mtrr_add(par->res_start + 0x80 -
> -GUI_RESERVE, GUI_RESERVE,
> -MTRR_TYPE_UNCACHABLE, 1);
> -   if (par->mtrr_reg < 0) {
> -   mtrr_del(par->mtrr_aper, 0, 0);
> -   par->mtrr_aper = -1;
> -   }
> -   }
> }
>  #endif
>
> @@ -2776,10 +2765,6 @@ aty_init_exit:
> par->pll_ops->set_pll(info, &par->saved_pll);
>
>  #ifdef CONFIG_MTRR
> -   if (par->mtrr_reg >= 0) {
> -   mtrr_del(par->mtrr_reg, 0, 0);
> -   par->mtrr_reg = -1;
> -   }
> if (par->mtrr_aper >=

Re: powerpc32: fix warning from include/linux/mm.h

2015-03-20 Thread Scott Wood
On Fri, Dec 05, 2014 at 12:20:20PM +0100, LEROY Christophe wrote:
> include/linux/mm.h: In function 'is_vmalloc_addr':
> include/linux/mm.h:367:14: warning: comparison between signed and unsigned 
> integer expressions [-Wsign-compare]
>   return addr >= VMALLOC_START && addr < VMALLOC_END;
>   ^
> 
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/include/asm/pgtable-ppc32.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

That warning doesn't appear to be enabled.  What config are you seeing
this with?

I'm also not clear on why this was assigned to me in patchwork.

-Scott
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 14/47] IB/ipath: use __arch_phys_wc_add()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver sadly does not have the MMIO registers and WC
desired areas (PIO buffers in this case) properly split up
and addressing a split is considerable work, as such this
such requires using the __arch_phys_wc_add() call to
ensure write combining is enforced using MTRR on x86
even when PAT is available.

Cc: Rickard Strandqvist 
Cc: Mike Marciniszyn 
Cc: Roland Dreier 
Cc: Andy Lutomirski 
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Linus Torvalds 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: Bjorn Helgaas 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Dave Hansen 
Cc: Arnd Bergmann 
Cc: Michael S. Tsirkin 
Cc: venkatesh.pallip...@intel.com
Cc: Stefan Bader 
Cc: konrad.w...@oracle.com
Cc: ville.syrj...@linux.intel.com
Cc: david.vra...@citrix.com
Cc: jbeul...@suse.com
Cc: toshi.k...@hp.com
Cc: Roger Pau Monné 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: xen-de...@lists.xensource.com
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/ipath/ipath_driver.c|  7 ++--
 drivers/infiniband/hw/ipath/ipath_kernel.h|  4 +--
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 47 ++-
 3 files changed, 20 insertions(+), 38 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c 
b/drivers/infiniband/hw/ipath/ipath_driver.c
index bd0caed..464f39c 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -542,6 +542,7 @@ static int ipath_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
dd->ipath_kregbase = __ioremap(addr, len,
(_PAGE_NO_CACHE|_PAGE_WRITETHRU));
 #else
+   /* XXX: split pio on a separate ioremap_wc() */
dd->ipath_kregbase = ioremap_nocache(addr, len);
 #endif
 
@@ -587,12 +588,8 @@ static int ipath_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
ret = ipath_enable_wc(dd);
 
-   if (ret) {
-   ipath_dev_err(dd, "Write combining not enabled "
- "(err %d): performance may be poor\n",
- -ret);
+   if (ret)
ret = 0;
-   }
 
ipath_verify_pioperf(dd);
 
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h 
b/drivers/infiniband/hw/ipath/ipath_kernel.h
index e08db70..f0f9471 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -463,9 +463,7 @@ struct ipath_devdata {
/* offset in HT config space of slave/primary interface block */
u8 ipath_ht_slave_off;
/* for write combining settings */
-   unsigned long ipath_wc_cookie;
-   unsigned long ipath_wc_base;
-   unsigned long ipath_wc_len;
+   int wc_cookie;
/* ref count for each pkey */
atomic_t ipath_pkeyrefs[4];
/* shadow copy of struct page *'s for exp tid pages */
diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c 
b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 70c1f3a..88709c1 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -37,7 +37,6 @@
  */
 
 #include 
-#include 
 #include 
 
 #include "ipath_kernel.h"
@@ -122,27 +121,26 @@ int ipath_enable_wc(struct ipath_devdata *dd)
}
 
if (!ret) {
-   int cookie;
ipath_cdbg(VERBOSE, "Setting mtrr for chip to WC "
   "(addr %llx, len=0x%llx)\n",
   (unsigned long long) pioaddr,
   (unsigned long long) piolen);
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
-   if (cookie < 0) {
-   {
-   dev_info(&dd->pcidev->dev,
-"mtrr_add()  WC for PIO bufs "
-"failed (%d)\n",
-cookie);
-   ret = -EINVAL;
-   }
-   } else {
-   ipath_cdbg(VERBOSE, "Set mtrr for chip to WC, "
-  "cookie is %d\n", cookie);
-   dd->ipath_wc_cookie = cookie;
-   dd->ipath_wc_base = (unsigned long) pioaddr;
-   dd->ipath_wc_len = (unsigned long) piolen;
-   }
+   dd->wc_cookie = __arch_phys_wc_add(pioaddr, piolen);
+   if (dd->wc_cookie <= 0) {
+   /*
+* If MTRR is not available on an architecture
+* or if it could not be enabled at run time
+* folks who care should work towards the
+* ioremap_wc() split.
+*/
+   

Re: [PATCH v1 04/47] pci: add pci_ioremap_wc_bar()

2015-03-20 Thread Andy Lutomirski
On Fri, Mar 20, 2015 at 4:17 PM, Luis R. Rodriguez
 wrote:
> From: "Luis R. Rodriguez" 
>
> This lets drivers take advanate of PAT when available. This
> should help with the transition of converting video drivers over
> to ioremap_wc() to help with the goal of eventually using
> _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on
> ioremap_nocache() (de33c442e)
>
> Cc: Suresh Siddha 
> Cc: Venkatesh Pallipadi 
> Cc: Ingo Molnar 
> Cc: Thomas Gleixner 
> Cc: Juergen Gross 
> Cc: Daniel Vetter 
> Cc: Andy Lutomirski 
> Cc: Dave Airlie 
> Cc: Antonino Daplas 
> Cc: Jean-Christophe Plagniol-Villard 
> Cc: Tomi Valkeinen 
> Cc: linux-fb...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Luis R. Rodriguez 
> ---
>  drivers/pci/pci.c   | 14 ++
>  include/linux/pci.h |  1 +
>  2 files changed, 15 insertions(+)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 81f06e8..6afd507 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -137,6 +137,20 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int 
> bar)
>  pci_resource_len(pdev, bar));
>  }
>  EXPORT_SYMBOL_GPL(pci_ioremap_bar);
> +
> +void __iomem *pci_ioremap_wc_bar(struct pci_dev *pdev, int bar)
> +{
> +   /*
> +* Make sure the BAR is actually a memory resource, not an IO resource
> +*/
> +   if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
> +   WARN_ON(1);
> +   return NULL;
> +   }

if (WARN_ON(...))?

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 03/47] devres: add devm_ioremap_wc()

2015-03-20 Thread Andy Lutomirski
On Fri, Mar 20, 2015 at 4:17 PM, Luis R. Rodriguez
 wrote:
> From: "Luis R. Rodriguez" 
>
> We have devm_ioremap_nocache() but no devm_ioremap_wc()
> so add that. This will be used later.
>
> Cc: Suresh Siddha 
> Cc: Venkatesh Pallipadi 
> Cc: Ingo Molnar 
> Cc: Thomas Gleixner 
> Cc: Juergen Gross 
> Cc: Daniel Vetter 
> Cc: Andy Lutomirski 
> Cc: Dave Airlie 
> Cc: Antonino Daplas 
> Cc: Jean-Christophe Plagniol-Villard 
> Cc: Tomi Valkeinen 
> Cc: linux-fb...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Luis R. Rodriguez 

Looks good to me.

> ---
>  Documentation/driver-model/devres.txt |  1 +
>  include/linux/io.h|  2 ++
>  lib/devres.c  | 29 +
>  3 files changed, 32 insertions(+)
>
> diff --git a/Documentation/driver-model/devres.txt 
> b/Documentation/driver-model/devres.txt
> index e1e2bbd..831a536 100644
> --- a/Documentation/driver-model/devres.txt
> +++ b/Documentation/driver-model/devres.txt
> @@ -276,6 +276,7 @@ IOMAP
>devm_ioport_unmap()
>devm_ioremap()
>devm_ioremap_nocache()
> +  devm_ioremap_wc()
>devm_ioremap_resource() : checks resource, requests memory region, ioremaps
>devm_iounmap()
>pcim_iomap()
> diff --git a/include/linux/io.h b/include/linux/io.h
> index 4cc299c..91101a1 100644
> --- a/include/linux/io.h
> +++ b/include/linux/io.h
> @@ -72,6 +72,8 @@ void __iomem *devm_ioremap(struct device *dev, 
> resource_size_t offset,
>resource_size_t size);
>  void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t 
> offset,
>resource_size_t size);
> +void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
> + resource_size_t size);
>  void devm_iounmap(struct device *dev, void __iomem *addr);
>  int check_signature(const volatile void __iomem *io_addr,
> const unsigned char *signature, int length);
> diff --git a/lib/devres.c b/lib/devres.c
> index 0f1dd2e..2eb2bfe 100644
> --- a/lib/devres.c
> +++ b/lib/devres.c
> @@ -72,6 +72,35 @@ void __iomem *devm_ioremap_nocache(struct device *dev, 
> resource_size_t offset,
>  EXPORT_SYMBOL(devm_ioremap_nocache);
>
>  /**
> + * devm_ioremap_wc - Managed ioremap_wc()
> + * @dev: Generic device to remap IO address for
> + * @offset: BUS offset to map
> + * @size: Size of map
> + *
> + * Managed ioremap_wc().  Map is automatically unmapped on driver
> + * detach.
> + */
> +void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
> + resource_size_t size)
> +{
> +   void __iomem **ptr, *addr;
> +
> +   ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
> +   if (!ptr)
> +   return NULL;
> +
> +   addr = ioremap_wc(offset, size);
> +   if (addr) {
> +   *ptr = addr;
> +   devres_add(dev, ptr);
> +   } else
> +   devres_free(ptr);
> +
> +   return addr;
> +}
> +EXPORT_SYMBOL_GPL(devm_ioremap_wc);
> +
> +/**
>   * devm_iounmap - Managed iounmap()
>   * @dev: Generic device to unmap for
>   * @addr: Address to unmap
> --
> 2.3.2.209.gd67f9d5.dirty
>



-- 
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 13/47] IB/ipath: add counting for MTRR

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

There is no good reason not to, we eventually delete it as well.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c 
b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 4ad0b93..70c1f3a 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -127,7 +127,7 @@ int ipath_enable_wc(struct ipath_devdata *dd)
   "(addr %llx, len=0x%llx)\n",
   (unsigned long long) pioaddr,
   (unsigned long long) piolen);
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
if (cookie < 0) {
{
dev_info(&dd->pcidev->dev,
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 06/47] mtrr: add __arch_phys_wc_add()

2015-03-20 Thread Andy Lutomirski
On Fri, Mar 20, 2015 at 4:17 PM, Luis R. Rodriguez
 wrote:
> From: "Luis R. Rodriguez" 
>
> Ideally on systems using PAT we can expect a swift
> transition away from MTRR. There can be a few exceptions
> to this, one is where device drivers are known to exist
> on PATs with errata, another situation is observed on
> old device drivers where devices had combined MMIO
> register access with whatever area they typically
> later wanted to end up using MTRR for on the same
> PCI BAR. This situation can still be addressed by
> splitting up ioremap'd PCI BAR into two ioremap'd
> calls, one for MMIO registers, and another for whatever
> is desirable for write-combining -- in order to
> accomplish this though quite a bit of driver
> restructuring is required.
>
> Device drivers which are known to require large
> amount of re-work in order to split ioremap'd areas
> can use __arch_phys_wc_add() to avoid regressions
> when PAT is enabled.
>
> For a good example driver where things are neatly
> split up on a PCI BAR refer the infiniband qib
> driver. For a good example of a driver where good
> amount of work is required refer to the infiniband
> ipath driver.
>
> This is *only* a transitive API -- and as such no new
> drivers are ever expected to use this.

What's the exact layout that this helps?  I'm sceptical that this can
ever be correct.

Is there some awful driver that has a large ioremap that's supposed to
contain multiple different memtypes?  If so, can we ioremap +
set_page_xyz instead?

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 12/47] IB/qib: use arch_phys_wc_add()

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver already makes use of ioremap_wc() on PIO buffers,
so convert it to use arch_phys_wc_add().

Cc: Rickard Strandqvist 
Cc: Dennis Dalessandro 
Cc: Mike Marciniszyn 
Cc: Roland Dreier 
Cc: Andy Lutomirski 
Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: Bjorn Helgaas 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Dave Hansen 
Cc: Arnd Bergmann 
Cc: Michael S. Tsirkin 
Cc: venkatesh.pallip...@intel.com
Cc: Stefan Bader 
Cc: konrad.w...@oracle.com
Cc: ville.syrj...@linux.intel.com
Cc: david.vra...@citrix.com
Cc: jbeul...@suse.com
Cc: toshi.k...@hp.com
Cc: Roger Pau Monné 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: xen-de...@lists.xensource.com
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 31 ---
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_wc_x86_64.c 
b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
index fe0850a..6d61ef9 100644
--- a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
+++ b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
@@ -116,21 +116,9 @@ int qib_enable_wc(struct qib_devdata *dd)
}
 
if (!ret) {
-   int cookie;
-
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
-   if (cookie < 0) {
-   {
-   qib_devinfo(dd->pcidev,
-"mtrr_add()  WC for PIO bufs failed 
(%d)\n",
-cookie);
-   ret = -EINVAL;
-   }
-   } else {
-   dd->wc_cookie = cookie;
-   dd->wc_base = (unsigned long) pioaddr;
-   dd->wc_len = (unsigned long) piolen;
-   }
+   dd->wc_cookie = arch_phys_wc_add(pioaddr, piolen);
+   if (dd->wc_cookie < 0)
+   ret = -EINVAL;
}
 
return ret;
@@ -142,18 +130,7 @@ int qib_enable_wc(struct qib_devdata *dd)
  */
 void qib_disable_wc(struct qib_devdata *dd)
 {
-   if (dd->wc_cookie) {
-   int r;
-
-   r = mtrr_del(dd->wc_cookie, dd->wc_base,
-dd->wc_len);
-   if (r < 0)
-   qib_devinfo(dd->pcidev,
-"mtrr_del(%lx, %lx, %lx) failed: %d\n",
-dd->wc_cookie, dd->wc_base,
-dd->wc_len, r);
-   dd->wc_cookie = 0; /* even on failure */
-   }
+   arch_phys_wc_del(dd->wc_cookie);
 }
 
 /**
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 11/47] IB/qib: add acounting for MTRR

2015-03-20 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

There is no good reason not to, we eventually delete it as well.

Cc: Suresh Siddha 
Cc: Venkatesh Pallipadi 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: linux-fb...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/qib/qib_wc_x86_64.c 
b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
index 81b225f..fe0850a 100644
--- a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
+++ b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
@@ -118,7 +118,7 @@ int qib_enable_wc(struct qib_devdata *dd)
if (!ret) {
int cookie;
 
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
if (cookie < 0) {
{
qib_devinfo(dd->pcidev,
-- 
2.3.2.209.gd67f9d5.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFT OMAP1 PATCH 7/8] gpio: omap: get rid of omap_irq_to_gpio()

2015-03-20 Thread Javier Martinez Canillas
Hello Grygorii,

On Fri, Mar 20, 2015 at 9:39 PM, grygorii.stras...@linaro.org
 wrote:
> On 03/20/2015 08:56 PM, Javier Martinez Canillas wrote:
>> Hello Grygorii,
>>
>> On Thu, Mar 19, 2015 at 6:25 PM,   wrote:
>>> From: Grygorii Strashko 
>>>
>>> Now OMAP GPIO driver prepared for omap_irq_to_gpio() removing.
>>> Do it ;)
>>>
>>> Signed-off-by: Grygorii Strashko 
>>
>> I don't have access to OMAP1 boards to test but Tony did it o an
>> osk5912 and Aaro can confirm that it doesn't cause regressions on
>> other OMAP1 boards.
>
> Thanks. But could you clarify one point to me please?
> "Aaro can confirm that it doesn't cause regressions on
> other OMAP1 boards" - Does It mean I can add his Tested-by?
> Or I still have to wait for his direct reply?
> Just to avoid any confusions ;)
>

I meant that as far as I know Aaro has access to more OMAP1 systems so
he should be able to test that no regressions are added for those. But
I don't know if he would be able to test and I think your cleanups are
good so that's why I acked the patches.

Sorry for the confusion.

Best regards,
Javier
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   >