Re: [RFC v2] ARM: memory: da8xx-ddrctl: new driver

2016-10-25 Thread Kevin Hilman
Kevin Hilman  writes:

> Bartosz Golaszewski  writes:
>
>> Create a new driver for the da8xx DDR2/mDDR controller and implement
>> support for writing to the Peripheral Bus Burst Priority Register.
>>
>> Signed-off-by: Bartosz Golaszewski 
>> ---
>>  .../memory-controllers/ti-da8xx-ddrctl.txt |  20 +++
>>  drivers/memory/Kconfig |   8 +
>>  drivers/memory/Makefile|   1 +
>>  drivers/memory/da8xx-ddrctl.c  | 175 
>> +
>>  4 files changed, 204 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt
>>  create mode 100644 drivers/memory/da8xx-ddrctl.c
>>
>> diff --git
>> a/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt
>> b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt
>> new file mode 100644
>> index 000..7e271dd
>> --- /dev/null
>> +++ 
>> b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt
>> @@ -0,0 +1,20 @@
>> +* Device tree bindings for Texas Instruments da8xx DDR2/mDDR memory 
>> controller
>> +
>> +The DDR2/mDDR memory controller present on Texas Instruments da8xx SoCs 
>> features
>> +a set of registers which allow to tweak the controller's behavior.
>> +
>> +Documentation:
>> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
>> +
>> +Required properties:
>> +
>> +- compatible:   "ti,da850-ddr-controller" - for da850 SoC based 
>> boards
>> +- reg:  a tuple containing the base address of the 
>> memory
>> +controller and the size of the memory area to map
>> +
>> +Example for da850 shown below.
>> +
>> +ddrctl {
>> +compatible = "ti,da850-ddr-controller";
>> +reg = <0xB000 0x100>;
>> +};
>
> Axel's series for the USB PHY reminded me that the PHY also has some
> config registers in this same area, and his series creates a syscon for
> a similar range of registers.
>
> Could you create a syscon for the SYSCFG0 registers, which would then
> be used by ths driver and your other drivers/bus driver?  Then the
> binding  would just reference the sysconf via phandle, and your driver
> can use syscon_regmap_lookup_by_phandle()

Nevermind. I though that the config register in this driver was also in
SYSCFG0, but I see now that it's in the reg region of the DDR controller
itself, so no syscon is needed.

Kevin


[RFC PATCH 08/13] of: Update structure of code, remove BUG_ON()

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 48 +---
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 0778747cdd58..708daca1d522 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -136,8 +136,8 @@ static int update_usages_of_a_phandle_reference(struct 
device_node *overlay,
err = -EINVAL;
goto err_fail;
}
-
*s++ = '\0';
+
err = kstrtoint(s, 10, );
if (err)
goto err_fail;
@@ -219,11 +219,9 @@ static int adjust_local_phandle_references(struct 
device_node *local_fixups,
if (off >= prop->length || (off + 4) > prop->length)
return -EINVAL;
 
-   if (phandle_delta) {
-   phandle = be32_to_cpu(*(__be32 *)(prop->value + 
off));
-   phandle += phandle_delta;
-   *(__be32 *)(prop->value + off) = 
cpu_to_be32(phandle);
-   }
+   phandle = be32_to_cpu(*(__be32 *)(prop->value + off));
+   phandle += phandle_delta;
+   *(__be32 *)(prop->value + off) = cpu_to_be32(phandle);
}
}
 
@@ -267,48 +265,36 @@ int of_resolve_phandles(struct device_node *overlay)
phandle phandle, phandle_delta;
int err;
 
-   if (!overlay)
-   pr_err("%s: null overlay\n", __func__);
-   if (overlay && !of_node_check_flag(overlay, OF_DETACHED))
-   pr_err("%s: node %s not detached\n", __func__,
-overlay->full_name);
-   if (!overlay || !of_node_check_flag(overlay, OF_DETACHED))
+   if (!overlay) {
+   pr_err("null overlay\n");
+   return -EINVAL;
+   }
+   if (!of_node_check_flag(overlay, OF_DETACHED)) {
+   pr_err("overlay not detached\n");
return -EINVAL;
+   }
 
phandle_delta = live_tree_max_phandle() + 1;
adjust_overlay_phandles(overlay, phandle_delta);
 
-   local_fixups = NULL;
for_each_child_of_node(overlay, local_fixups)
if (!of_node_cmp(local_fixups->name, "__local_fixups__"))
break;
 
-   if (local_fixups != NULL) {
-   err = adjust_local_phandle_references(local_fixups,
-   overlay, 0);
-   if (err)
-   return err;
+   err = adjust_local_phandle_references(local_fixups, overlay, 
phandle_delta);
+   if (err)
+   return err;
 
-   BUG_ON(adjust_local_phandle_references(local_fixups,
-   overlay, phandle_delta));
-   }
-
-   tree_symbols = NULL;
overlay_symbols = NULL;
overlay_fixups = NULL;
 
tree_symbols = of_find_node_by_path("/__symbols__");
 
for_each_child_of_node(overlay, child) {
-
-   if (!overlay_symbols && !of_node_cmp(child->name, 
"__symbols__"))
+   if (!of_node_cmp(child->name, "__symbols__"))
overlay_symbols = child;
-
-   if (!overlay_fixups && !of_node_cmp(child->name, "__fixups__"))
+   if (!of_node_cmp(child->name, "__fixups__"))
overlay_fixups = child;
-
-   if (overlay_symbols && overlay_fixups)
-   break;
}
 
if (!overlay_fixups) {
@@ -317,7 +303,7 @@ int of_resolve_phandles(struct device_node *overlay)
}
 
if (!tree_symbols) {
-   pr_err("%s: no symbols in root of device tree.\n", __func__);
+   pr_err("no symbols in root of device tree.\n");
err = -EINVAL;
goto out;
}
-- 
1.9.1



[PATCH 0/5] Add generic pinctrl helpers for managing groups and functions

2016-10-25 Thread Tony Lindgren
Hi all,

Here are some changes to add generic helpers for managing pinctrl groups and
functions.

Regards,

Tony


Tony Lindgren (5):
  pinctrl: core: Use delayed work for hogs
  pinctrl: core: Add generic pinctrl functions for managing groups
  pinctrl: core: Add generic pinctrl functions for managing groups
  pinctrl: single: Use generic pinctrl helpers for managing groups
  pinctrl: single: Use generic pinmux helpers for managing functions

 drivers/pinctrl/Kconfig  |  11 +-
 drivers/pinctrl/core.c   | 233 ---
 drivers/pinctrl/core.h   |  67 +
 drivers/pinctrl/pinctrl-single.c | 289 ---
 drivers/pinctrl/pinmux.c | 173 +++
 drivers/pinctrl/pinmux.h |  42 ++
 6 files changed, 532 insertions(+), 283 deletions(-)

-- 
2.9.3


[RFC PATCH 01/13] of: Remove comments that state the obvious

2016-10-25 Thread frowand . list
From: Frank Rowand 

Remove comments that state the obvious, to reduce clutter

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 46325d6394cf..4ff0220d7aa2 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -36,7 +36,6 @@ static struct device_node *__of_find_node_by_full_name(struct 
device_node *node,
if (node == NULL)
return NULL;
 
-   /* check */
if (of_node_cmp(node->full_name, full_name) == 0)
return of_node_get(node);
 
@@ -60,7 +59,6 @@ static phandle of_get_tree_max_phandle(void)
phandle phandle;
unsigned long flags;
 
-   /* now search recursively */
raw_spin_lock_irqsave(_lock, flags);
phandle = 0;
for_each_of_allnodes(node) {
@@ -75,8 +73,6 @@ static phandle of_get_tree_max_phandle(void)
 
 /*
  * Adjust a subtree's phandle values by a given delta.
- * Makes sure not to just adjust the device node's phandle value,
- * but modify the phandle properties values as well.
  */
 static void __of_adjust_tree_phandles(struct device_node *node,
int phandle_delta)
@@ -85,32 +81,25 @@ static void __of_adjust_tree_phandles(struct device_node 
*node,
struct property *prop;
phandle phandle;
 
-   /* first adjust the node's phandle direct value */
if (node->phandle != 0 && node->phandle != OF_PHANDLE_ILLEGAL)
node->phandle += phandle_delta;
 
-   /* now adjust phandle & linux,phandle values */
for_each_property_of_node(node, prop) {
 
-   /* only look for these two */
if (of_prop_cmp(prop->name, "phandle") != 0 &&
of_prop_cmp(prop->name, "linux,phandle") != 0)
continue;
 
-   /* must be big enough */
if (prop->length < 4)
continue;
 
-   /* read phandle value */
phandle = be32_to_cpup(prop->value);
-   if (phandle == OF_PHANDLE_ILLEGAL)  /* unresolved */
+   if (phandle == OF_PHANDLE_ILLEGAL)
continue;
 
-   /* adjust */
*(uint32_t *)prop->value = cpu_to_be32(node->phandle);
}
 
-   /* now do the children recursively */
for_each_child_of_node(node, child)
__of_adjust_tree_phandles(child, phandle_delta);
 }
@@ -125,7 +114,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
int offset, propcurlen;
int err = 0;
 
-   /* make a copy */
propval = kmalloc(rprop->length, GFP_KERNEL);
if (!propval) {
pr_err("%s: Could not copy value of '%s'\n",
@@ -165,7 +153,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
goto err_fail;
}
 
-   /* look into the resolve node for the full path */
refnode = __of_find_node_by_full_name(node, nodestr);
if (!refnode) {
pr_warn("%s: Could not find refnode '%s'\n",
@@ -173,7 +160,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
continue;
}
 
-   /* now find the property */
for_each_property_of_node(refnode, sprop) {
if (of_prop_cmp(sprop->name, propstr) == 0)
break;
@@ -240,7 +226,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
}
count = rprop->length / sizeof(__be32);
 
-   /* now find the target property */
for_each_property_of_node(target, sprop) {
if (of_prop_cmp(sprop->name, rprop->name) == 0)
break;
@@ -254,7 +239,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
 
for (i = 0; i < count; i++) {
off = be32_to_cpu(((__be32 *)rprop->value)[i]);
-   /* make sure the offset doesn't overstep (even wrap) */
if (off >= sprop->length ||
(off + 4) > sprop->length) {
pr_err("%s: Illegal property '%s' @%s\n",
@@ -264,7 +248,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
}
 
if (phandle_delta) {
-   /* adjust */
phandle = be32_to_cpu(*(__be32 *)(sprop->value 
+ off));
phandle += phandle_delta;
*(__be32 *)(sprop->value + off) = 
cpu_to_be32(phandle);
@@ -320,22 +303,18 @@ int 

[PATCH 1/2] ARM: imx: mmdc perf function support i.MX6QP

2016-10-25 Thread Frank Li
i.MX6QP added new reigster bit PROFILE_SEL in MADPCR0.
need set it at perf start.

Signed-off-by: Frank Li 
---
 arch/arm/mach-imx/mmdc.c | 45 +++--
 1 file changed, 39 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c
index d82d14c..d833b87 100644
--- a/arch/arm/mach-imx/mmdc.c
+++ b/arch/arm/mach-imx/mmdc.c
@@ -44,6 +44,7 @@
 #define DBG_RST0x2
 #define PRF_FRZ0x4
 #define CYC_OVF0x8
+#define PROFILE_SEL0x10
 
 #define MMDC_MADPCR0   0x410
 #define MMDC_MADPSR0   0x418
@@ -55,10 +56,36 @@
 
 #define MMDC_NUM_COUNTERS  6
 
+#define FSL_MMDC_QUIRK_PROFILE_SEL 0x1
+
 #define to_mmdc_pmu(p) container_of(p, struct mmdc_pmu, pmu)
 
 static int ddr_type;
 
+enum fsl_mmdc_devtype {
+   FSL_MMDC_IMX6Q,
+   FSL_MMDC_IMX6QP,
+};
+
+struct fsl_mmdc_devtype_data {
+   enum fsl_mmdc_devtype devtype;
+   int driver_data;
+};
+
+static struct fsl_mmdc_devtype_data imx6q_data = {
+   .devtype = FSL_MMDC_IMX6Q,
+};
+
+static struct fsl_mmdc_devtype_data imx6qp_data = {
+   .driver_data = FSL_MMDC_QUIRK_PROFILE_SEL,
+};
+
+static const struct of_device_id imx_mmdc_dt_ids[] = {
+   { .compatible = "fsl,imx6q-mmdc", .data = (void *)_data},
+   { .compatible = "fsl,imx6qp-mmdc", .data = (void *)_data},
+   { /* sentinel */ }
+};
+
 #ifdef CONFIG_PERF_EVENTS
 
 static DEFINE_IDA(mmdc_ida);
@@ -83,6 +110,7 @@ struct mmdc_pmu {
struct device *dev;
struct perf_event *mmdc_events[MMDC_NUM_COUNTERS];
struct hlist_node node;
+   struct fsl_mmdc_devtype_data *devtype_data;
 };
 
 /*
@@ -307,6 +335,7 @@ static void mmdc_pmu_event_start(struct perf_event *event, 
int flags)
struct mmdc_pmu *pmu_mmdc = to_mmdc_pmu(event->pmu);
struct hw_perf_event *hwc = >hw;
void __iomem *mmdc_base, *reg;
+   int val;
 
mmdc_base = pmu_mmdc->mmdc_base;
reg = mmdc_base + MMDC_MADPCR0;
@@ -321,7 +350,12 @@ static void mmdc_pmu_event_start(struct perf_event *event, 
int flags)
local64_set(>prev_count, 0);
 
writel(DBG_RST, reg);
-   writel(DBG_EN, reg);
+
+   val = DBG_EN;
+   if (pmu_mmdc->devtype_data->driver_data & FSL_MMDC_QUIRK_PROFILE_SEL)
+   val |= PROFILE_SEL;
+
+   writel(val, reg);
 }
 
 static int mmdc_pmu_event_add(struct perf_event *event, int flags)
@@ -436,6 +470,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, 
void __iomem *mmdc_b
char *name;
int mmdc_num;
int ret;
+   const struct of_device_id *of_id =
+   of_match_device(imx_mmdc_dt_ids, >dev);
 
pmu_mmdc = kzalloc(sizeof(*pmu_mmdc), GFP_KERNEL);
if (!pmu_mmdc) {
@@ -450,6 +486,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, 
void __iomem *mmdc_b
name = devm_kasprintf(>dev,
GFP_KERNEL, "mmdc%d", mmdc_num);
 
+   pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data;
+
hrtimer_init(_mmdc->hrtimer, CLOCK_MONOTONIC,
HRTIMER_MODE_REL);
pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler;
@@ -524,11 +562,6 @@ int imx_mmdc_get_ddr_type(void)
return ddr_type;
 }
 
-static const struct of_device_id imx_mmdc_dt_ids[] = {
-   { .compatible = "fsl,imx6q-mmdc", },
-   { /* sentinel */ }
-};
-
 static struct platform_driver imx_mmdc_driver = {
.driver = {
.name   = "imx-mmdc",
-- 
2.5.2



[RFC PATCH 05/13] of: Rename functions to more accurately reflect what they do

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 31fd3800787a..3d123b612789 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -53,7 +53,7 @@ static struct device_node *__of_find_node_by_full_name(struct 
device_node *node,
 /*
  * Find live tree's maximum phandle value.
  */
-static phandle of_get_tree_max_phandle(void)
+static phandle live_tree_max_phandle(void)
 {
struct device_node *node;
phandle phandle;
@@ -74,7 +74,7 @@ static phandle of_get_tree_max_phandle(void)
 /*
  * Adjust a subtree's phandle values by a given delta.
  */
-static void __of_adjust_tree_phandles(struct device_node *node,
+static void adjust_overlay_phandles(struct device_node *node,
int phandle_delta)
 {
struct device_node *child;
@@ -101,10 +101,10 @@ static void __of_adjust_tree_phandles(struct device_node 
*node,
}
 
for_each_child_of_node(node, child)
-   __of_adjust_tree_phandles(child, phandle_delta);
+   adjust_overlay_phandles(child, phandle_delta);
 }
 
-static int __of_adjust_phandle_ref(struct device_node *node,
+static int update_usages_of_a_phandle_reference(struct device_node *node,
struct property *rprop, int value)
 {
phandle phandle;
@@ -184,7 +184,7 @@ static int __of_node_name_cmp(const struct device_node *dn1,
  * Does not take any devtree locks so make sure you call this on a tree
  * which is at the detached state.
  */
-static int __of_adjust_tree_phandle_references(struct device_node *node,
+static int adjust_local_phandle_references(struct device_node *node,
struct device_node *target, int phandle_delta)
 {
struct device_node *child, *childtarget;
@@ -238,7 +238,7 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
if (!childtarget)
return -EINVAL;
 
-   err = __of_adjust_tree_phandle_references(child, childtarget,
+   err = adjust_local_phandle_references(child, childtarget,
phandle_delta);
if (err)
return err;
@@ -277,8 +277,8 @@ int of_resolve_phandles(struct device_node *resolve)
if (!resolve || !of_node_check_flag(resolve, OF_DETACHED))
return -EINVAL;
 
-   phandle_delta = of_get_tree_max_phandle() + 1;
-   __of_adjust_tree_phandles(resolve, phandle_delta);
+   phandle_delta = live_tree_max_phandle() + 1;
+   adjust_overlay_phandles(resolve, phandle_delta);
 
childroot = NULL;
for_each_child_of_node(resolve, childroot)
@@ -286,12 +286,12 @@ int of_resolve_phandles(struct device_node *resolve)
break;
 
if (childroot != NULL) {
-   err = __of_adjust_tree_phandle_references(childroot,
+   err = adjust_local_phandle_references(childroot,
resolve, 0);
if (err)
return err;
 
-   BUG_ON(__of_adjust_tree_phandle_references(childroot,
+   BUG_ON(adjust_local_phandle_references(childroot,
resolve, phandle_delta));
}
 
@@ -344,7 +344,7 @@ int of_resolve_phandles(struct device_node *resolve)
phandle = refnode->phandle;
of_node_put(refnode);
 
-   err = __of_adjust_phandle_ref(resolve, rprop, phandle);
+   err = update_usages_of_a_phandle_reference(resolve, rprop, 
phandle);
if (err)
break;
}
-- 
1.9.1



[RFC PATCH 11/13] of: Add back an error message, restructured

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 4e6df385118b..664c97e1ecb4 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -278,13 +278,17 @@ int of_resolve_phandles(struct device_node *overlay)
phandle phandle, phandle_delta;
int err;
 
+   tree_symbols = NULL;
+
if (!overlay) {
pr_err("null overlay\n");
-   return -EINVAL;
+   err = -EINVAL;
+   goto err_out;
}
if (!of_node_check_flag(overlay, OF_DETACHED)) {
pr_err("overlay not detached\n");
-   return -EINVAL;
+   err = -EINVAL;
+   goto err_out;
}
 
phandle_delta = live_tree_max_phandle() + 1;
@@ -296,7 +300,7 @@ int of_resolve_phandles(struct device_node *overlay)
 
err = adjust_local_phandle_references(local_fixups, overlay, 
phandle_delta);
if (err)
-   return err;
+   goto err_out;
 
overlay_symbols = NULL;
overlay_fixups = NULL;
@@ -318,7 +322,7 @@ int of_resolve_phandles(struct device_node *overlay)
if (!tree_symbols) {
pr_err("no symbols in root of device tree.\n");
err = -EINVAL;
-   goto out;
+   goto err_out;
}
 
for_each_property_of_node(overlay_fixups, prop) {
@@ -330,12 +334,12 @@ int of_resolve_phandles(struct device_node *overlay)
err = of_property_read_string(tree_symbols,
prop->name, );
if (err)
-   goto out;
+   goto err_out;
 
refnode = of_find_node_by_path(refpath);
if (!refnode) {
err = -ENOENT;
-   goto out;
+   goto err_out;
}
 
phandle = refnode->phandle;
@@ -346,6 +350,8 @@ int of_resolve_phandles(struct device_node *overlay)
break;
}
 
+err_out:
+   pr_err("overlay phandle fixup failed: %d\n", err);
 out:
of_node_put(tree_symbols);
 
-- 
1.9.1



[RFC PATCH 10/13] of: Update comments to reflect changes and increase clarity

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 51 ---
 1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 76c09cb57eae..4e6df385118b 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -50,9 +50,6 @@ static struct device_node *find_node_by_full_name(struct 
device_node *node,
return NULL;
 }
 
-/*
- * Find live tree's maximum phandle value.
- */
 static phandle live_tree_max_phandle(void)
 {
struct device_node *node;
@@ -71,9 +68,6 @@ static phandle live_tree_max_phandle(void)
return phandle;
 }
 
-/*
- * Adjust a subtree's phandle values by a given delta.
- */
 static void adjust_overlay_phandles(struct device_node *overlay,
int phandle_delta)
 {
@@ -118,6 +112,7 @@ static int update_usages_of_a_phandle_reference(struct 
device_node *overlay,
return -ENOMEM;
memcpy(value, prop_fixup->value, prop_fixup->length);
 
+   /* prop_fixup contains a list of tuples of path:property_name:offset */
end = value + prop_fixup->length;
for (cur = value; cur < end; cur += len + 1) {
len = strlen(cur);
@@ -177,10 +172,14 @@ static int node_name_cmp(const struct device_node *dn1,
 
 /*
  * Adjust the local phandle references by the given phandle delta.
- * Assumes the existances of a __local_fixups__ node at the root.
- * Assumes that __of_verify_tree_phandle_references has been called.
- * Does not take any devtree locks so make sure you call this on a tree
- * which is at the detached state.
+ *
+ * Subtree @local_fixups, which is overlay node __local_fixups__,
+ * mirrors the fragment node structure at the root of the overlay.
+ *
+ * For each property in the fragments that contains a phandle reference,
+ * @local_fixups has a property of the same name that contains a list
+ * of offsets of the phandle reference(s) within the respective property
+ * value(s).  The values at these offsets will be fixed up.
  */
 static int adjust_local_phandle_references(struct device_node *local_fixups,
struct device_node *overlay, int phandle_delta)
@@ -225,6 +224,13 @@ static int adjust_local_phandle_references(struct 
device_node *local_fixups,
}
}
 
+   /*
+* These nested loops recurse down two subtrees in parallel, where the
+* node names in the two subtrees match.
+*
+* The roots of the subtrees are the overlay's __local_fixups__ node
+* and the overlay's root node.
+*/
for_each_child_of_node(local_fixups, child) {
 
for_each_child_of_node(overlay, overlay_child)
@@ -244,17 +250,24 @@ static int adjust_local_phandle_references(struct 
device_node *local_fixups,
 }
 
 /**
- * of_resolve  - Resolve the given node against the live tree.
+ * of_resolve_phandles - Relocate and resolve overlay against live tree
+ *
+ * @overlay:   Pointer to devicetree overlay to relocate and resolve
+ *
+ * Modify (relocate) values of local phandles in @overlay to a range that
+ * does not conflict with the live expanded devicetree.  Update references
+ * to the local phandles in @overlay.  Update (resolve) phandle references
+ * in @overlay that refer to the live expanded devicetree.
+ *
+ * @overlay must be detached.
  *
- * @resolve:   Node to resolve
+ * Resolving and applying @overlay to the live expanded devicetree must be
+ * protected by a mechanism to ensure that multiple overlays are processed
+ * in a single threaded manner so that multiple overlays will not relocate
+ * phandles to overlapping ranges.  The mechanism to enforce this is not
+ * yet implemented.
  *
- * Perform dynamic Device Tree resolution against the live tree
- * to the given node to resolve. This depends on the live tree
- * having a __symbols__ node, and the resolve node the __fixups__ &
- * __local_fixups__ nodes (if needed).
- * The result of the operation is a resolve node that it's contents
- * are fit to be inserted or operate upon the live tree.
- * Returns 0 on success or a negative error value on error.
+ * Return: %0 on success or a negative error value on error.
  */
 int of_resolve_phandles(struct device_node *overlay)
 {
-- 
1.9.1



[RFC PATCH 07/13] of: Rename variables to better reflect purpose or follow convention

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 172 +-
 1 file changed, 85 insertions(+), 87 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 0ce38aa0ed3c..0778747cdd58 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -74,17 +74,17 @@ static phandle live_tree_max_phandle(void)
 /*
  * Adjust a subtree's phandle values by a given delta.
  */
-static void adjust_overlay_phandles(struct device_node *node,
+static void adjust_overlay_phandles(struct device_node *overlay,
int phandle_delta)
 {
struct device_node *child;
struct property *prop;
phandle phandle;
 
-   if (node->phandle != 0 && node->phandle != OF_PHANDLE_ILLEGAL)
-   node->phandle += phandle_delta;
+   if (overlay->phandle != 0 && overlay->phandle != OF_PHANDLE_ILLEGAL)
+   overlay->phandle += phandle_delta;
 
-   for_each_property_of_node(node, prop) {
+   for_each_property_of_node(overlay, prop) {
 
if (of_prop_cmp(prop->name, "phandle") &&
of_prop_cmp(prop->name, "linux,phandle"))
@@ -97,41 +97,40 @@ static void adjust_overlay_phandles(struct device_node 
*node,
if (phandle == OF_PHANDLE_ILLEGAL)
continue;
 
-   *(uint32_t *)prop->value = cpu_to_be32(node->phandle);
+   *(uint32_t *)prop->value = cpu_to_be32(overlay->phandle);
}
 
-   for_each_child_of_node(node, child)
+   for_each_child_of_node(overlay, child)
adjust_overlay_phandles(child, phandle_delta);
 }
 
-static int update_usages_of_a_phandle_reference(struct device_node *node,
-   struct property *rprop, int value)
+static int update_usages_of_a_phandle_reference(struct device_node *overlay,
+   struct property *prop_fixup, phandle phandle)
 {
-   phandle phandle;
struct device_node *refnode;
-   struct property *sprop;
-   char *propval, *propcur, *propend, *nodestr, *propstr, *s;
-   int offset, propcurlen;
+   struct property *prop;
+   char *value, *cur, *end, *node_path, *prop_name, *s;
+   int offset, len;
int err = 0;
 
-   propval = kmalloc(rprop->length, GFP_KERNEL);
-   if (!propval)
+   value = kmalloc(prop_fixup->length, GFP_KERNEL);
+   if (!value)
return -ENOMEM;
-   memcpy(propval, rprop->value, rprop->length);
+   memcpy(value, prop_fixup->value, prop_fixup->length);
 
-   propend = propval + rprop->length;
-   for (propcur = propval; propcur < propend; propcur += propcurlen + 1) {
-   propcurlen = strlen(propcur);
+   end = value + prop_fixup->length;
+   for (cur = value; cur < end; cur += len + 1) {
+   len = strlen(cur);
 
-   nodestr = propcur;
-   s = strchr(propcur, ':');
+   node_path = cur;
+   s = strchr(cur, ':');
if (!s) {
err = -EINVAL;
goto err_fail;
}
*s++ = '\0';
 
-   propstr = s;
+   prop_name = s;
s = strchr(s, ':');
if (!s) {
err = -EINVAL;
@@ -143,27 +142,26 @@ static int update_usages_of_a_phandle_reference(struct 
device_node *node,
if (err)
goto err_fail;
 
-   refnode = find_node_by_full_name(node, nodestr);
+   refnode = find_node_by_full_name(overlay, node_path);
if (!refnode)
continue;
 
-   for_each_property_of_node(refnode, sprop) {
-   if (!of_prop_cmp(sprop->name, propstr))
+   for_each_property_of_node(refnode, prop) {
+   if (!of_prop_cmp(prop->name, prop_name))
break;
}
of_node_put(refnode);
 
-   if (!sprop) {
+   if (!prop) {
err = -ENOENT;
goto err_fail;
}
 
-   phandle = value;
-   *(__be32 *)(sprop->value + offset) = cpu_to_be32(phandle);
+   *(__be32 *)(prop->value + offset) = cpu_to_be32(phandle);
}
 
 err_fail:
-   kfree(propval);
+   kfree(value);
return err;
 }
 
@@ -184,61 +182,61 @@ static int node_name_cmp(const struct device_node *dn1,
  * Does not take any devtree locks so make sure you call this on a tree
  * which is at the detached state.
  */
-static int adjust_local_phandle_references(struct device_node *node,
-   struct device_node *target, int phandle_delta)
+static int adjust_local_phandle_references(struct device_node *local_fixups,
+   struct device_node *overlay, 

[PATCH 5/5] pinctrl: single: Use generic pinmux helpers for managing functions

2016-10-25 Thread Tony Lindgren
We can now drop the driver specific code for managing functions.

Signed-off-by: Tony Lindgren 
---
 drivers/pinctrl/Kconfig  |   2 +-
 drivers/pinctrl/pinctrl-single.c | 134 ++-
 2 files changed, 19 insertions(+), 117 deletions(-)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -158,7 +158,7 @@ config PINCTRL_SINGLE
tristate "One-register-per-pin type device tree based pinctrl driver"
depends on OF
select GENERIC_PINCTRL
-   select PINMUX
+   select GENERIC_PINMUX
select GENERIC_PINCONF
help
  This selects the device tree based generic pinctrl driver.
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -33,6 +33,7 @@
 #include "core.h"
 #include "devicetree.h"
 #include "pinconf.h"
+#include "pinmux.h"
 
 #define DRIVER_NAME"pinctrl-single"
 #define PCS_OFF_DISABLED   ~0U
@@ -160,13 +161,10 @@ struct pcs_soc_data {
  * @bits_per_mux: number of bits per mux
  * @bits_per_pin: number of bits per pin
  * @pins:  physical pins on the SoC
- * @ftree: function index radix tree
- * @functions: list of functions
  * @gpiofuncs: list of gpio functions
  * @irqs:  list of interrupt registers
  * @chip:  chip container for this instance
  * @domain:IRQ domain for this instance
- * @nfuncs:number of functions
  * @desc:  pin controller descriptor
  * @read:  register read function to use
  * @write: register write function to use
@@ -194,13 +192,10 @@ struct pcs_device {
bool bits_per_mux;
unsigned bits_per_pin;
struct pcs_data pins;
-   struct radix_tree_root ftree;
-   struct list_head functions;
struct list_head gpiofuncs;
struct list_head irqs;
struct irq_chip chip;
struct irq_domain *domain;
-   unsigned nfuncs;
struct pinctrl_desc desc;
unsigned (*read)(void __iomem *reg);
void (*write)(unsigned val, void __iomem *reg);
@@ -306,59 +301,13 @@ static const struct pinctrl_ops pcs_pinctrl_ops = {
.dt_free_map = pcs_dt_free_map,
 };
 
-static int pcs_get_functions_count(struct pinctrl_dev *pctldev)
-{
-   struct pcs_device *pcs;
-
-   pcs = pinctrl_dev_get_drvdata(pctldev);
-
-   return pcs->nfuncs;
-}
-
-static const char *pcs_get_function_name(struct pinctrl_dev *pctldev,
-   unsigned fselector)
-{
-   struct pcs_device *pcs;
-   struct pcs_function *func;
-
-   pcs = pinctrl_dev_get_drvdata(pctldev);
-   func = radix_tree_lookup(>ftree, fselector);
-   if (!func) {
-   dev_err(pcs->dev, "%s could not find function%i\n",
-   __func__, fselector);
-   return NULL;
-   }
-
-   return func->name;
-}
-
-static int pcs_get_function_groups(struct pinctrl_dev *pctldev,
-   unsigned fselector,
-   const char * const **groups,
-   unsigned * const ngroups)
-{
-   struct pcs_device *pcs;
-   struct pcs_function *func;
-
-   pcs = pinctrl_dev_get_drvdata(pctldev);
-   func = radix_tree_lookup(>ftree, fselector);
-   if (!func) {
-   dev_err(pcs->dev, "%s could not find function%i\n",
-   __func__, fselector);
-   return -EINVAL;
-   }
-   *groups = func->pgnames;
-   *ngroups = func->npgnames;
-
-   return 0;
-}
-
 static int pcs_get_function(struct pinctrl_dev *pctldev, unsigned pin,
struct pcs_function **func)
 {
struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
struct pin_desc *pdesc = pin_desc_get(pctldev, pin);
const struct pinctrl_setting_mux *setting;
+   struct function_desc *function;
unsigned fselector;
 
/* If pin is not described in DTS & enabled, mux_setting is NULL. */
@@ -366,7 +315,8 @@ static int pcs_get_function(struct pinctrl_dev *pctldev, 
unsigned pin,
if (!setting)
return -ENOTSUPP;
fselector = setting->func;
-   *func = radix_tree_lookup(>ftree, fselector);
+   function = pinmux_generic_get_function(pctldev, fselector);
+   *func = function->data;
if (!(*func)) {
dev_err(pcs->dev, "%s could not find function%i\n",
__func__, fselector);
@@ -379,6 +329,7 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, 
unsigned fselector,
unsigned group)
 {
struct pcs_device *pcs;
+   struct function_desc *function;
struct pcs_function *func;
int i;
 
@@ -386,7 +337,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, 
unsigned 

[RFC PATCH 09/13] of: Remove redundant size check

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 708daca1d522..76c09cb57eae 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -216,7 +216,7 @@ static int adjust_local_phandle_references(struct 
device_node *local_fixups,
 
for (i = 0; i < count; i++) {
off = be32_to_cpu(((__be32 *)prop_fix->value)[i]);
-   if (off >= prop->length || (off + 4) > prop->length)
+   if ((off + 4) > prop->length)
return -EINVAL;
 
phandle = be32_to_cpu(*(__be32 *)(prop->value + off));
-- 
1.9.1



[PATCH 3/5] pinctrl: core: Add generic pinctrl functions for managing groups

2016-10-25 Thread Tony Lindgren
We can add generic helpers for function handling for cases where the pin
controller driver does not need to use static arrays.

Signed-off-by: Tony Lindgren 
---
 drivers/pinctrl/Kconfig  |   4 ++
 drivers/pinctrl/core.c   |   2 +
 drivers/pinctrl/core.h   |  18 +
 drivers/pinctrl/pinmux.c | 173 +++
 drivers/pinctrl/pinmux.h |  42 
 5 files changed, 239 insertions(+)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -14,6 +14,10 @@ config GENERIC_PINCTRL
 config PINMUX
bool "Support pin multiplexing controllers" if COMPILE_TEST
 
+config GENERIC_PINMUX
+   bool
+   select PINMUX
+
 config PINCONF
bool "Support pin configuration controllers" if COMPILE_TEST
 
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1971,6 +1971,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc 
*pctldesc,
pctldev->driver_data = driver_data;
INIT_RADIX_TREE(>pin_desc_tree, GFP_KERNEL);
INIT_RADIX_TREE(>pin_group_tree, GFP_KERNEL);
+   INIT_RADIX_TREE(>pin_function_tree, GFP_KERNEL);
INIT_LIST_HEAD(>gpio_ranges);
INIT_DELAYED_WORK(>hog_work, pinctrl_hog_work);
pctldev->dev = dev;
@@ -2049,6 +2050,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
mutex_lock(>mutex);
/* TODO: check that no pinmuxes are still active? */
list_del(>node);
+   pinmux_generic_free_functions(pctldev);
pinctrl_generic_free_groups(pctldev);
/* Destroy descriptor tree */
pinctrl_free_pindescs(pctldev, pctldev->desc->pins,
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -25,7 +25,9 @@ struct pinctrl_gpio_range;
  * @pin_desc_tree: each pin descriptor for this pin controller is stored in
  * this radix tree
  * @pin_group_tree: optionally each pin group can be stored in this radix tree
+ * @pin_function_tree: optionally each function can be stored in this radix 
tree
  * @num_groups: optionally number of groups can be kept here
+ * @num_functions: optionally number of functions can be kept here
  * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
  * ranges are added to this list at runtime
  * @dev: the device entry for this pin controller
@@ -44,7 +46,9 @@ struct pinctrl_dev {
struct pinctrl_desc *desc;
struct radix_tree_root pin_desc_tree;
struct radix_tree_root pin_group_tree;
+   struct radix_tree_root pin_function_tree;
unsigned int num_groups;
+   unsigned int num_functions;
struct list_head gpio_ranges;
struct device *dev;
struct module *owner;
@@ -180,6 +184,20 @@ struct group_desc {
 };
 
 /**
+ * struct function_desc - generic function descriptor
+ * @name: name of the function
+ * @group_names: array of pin group names
+ * @num_group_names: number of pin group names
+ * @data: pin controller driver specific data
+ */
+struct function_desc {
+   const char *name;
+   const char **group_names;
+   int num_group_names;
+   void *data;
+};
+
+/**
  * struct pinctrl_maps - a list item containing part of the mapping table
  * @node: mapping table list node
  * @maps: array of mapping table entries
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -695,3 +695,176 @@ void pinmux_init_device_debugfs(struct dentry *devroot,
 }
 
 #endif /* CONFIG_DEBUG_FS */
+
+#ifdef CONFIG_GENERIC_PINMUX
+
+/**
+ * pinmux_generic_get_function_count() - returns number of functions
+ * @pctldev: pin controller device
+ */
+int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev)
+{
+   return pctldev->num_functions;
+}
+EXPORT_SYMBOL_GPL(pinmux_generic_get_function_count);
+
+/**
+ * pinmux_generic_get_function_name() - returns the function name
+ * @pctldev: pin controller device
+ * @selector: function number
+ */
+const char *
+pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
+unsigned int selector)
+{
+   struct function_desc *function;
+
+   function = radix_tree_lookup(>pin_function_tree,
+selector);
+   if (!function)
+   return NULL;
+
+   return function->name;
+}
+EXPORT_SYMBOL_GPL(pinmux_generic_get_function_name);
+
+/**
+ * pinmux_generic_get_function_groups() - gets the function groups
+ * @pctldev: pin controller device
+ * @selector: function number
+ * @groups: array of pin groups
+ * @num_groups: number of pin groups
+ */
+int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
+  unsigned int selector,
+  const char * 

[RFC PATCH 00/13] of: Make drivers/of/resolver.c more readable

2016-10-25 Thread frowand . list
From: Frank Rowand 

drivers/of/resolve.c is a bit difficult to read.  Clean it up so
that review of future overlay related patches will be easier.

Most of the patches are intended to be reformatting, with no functional
change.  Patches that are expected to have a functional change are:

  Remove comments that state the obvious, to reduce clutter
  Remove excessive printks to reduce clutter.
  Update structure of code to be clearer, also remove BUG_ON()
Any functional change would reflect undefined behavior on bad overlay.
Some error message text modified.
BUG_ON() removed.
  Add back an error message, restructured

The patches are grouped into sets of changes that are intended
to be easy to verify correctness through simple inspection.

Some of the individual patches have checkpatch warnings or errors.
But after all patches are applied, the number of errors and
warnings from running checkpatch against the entire file are
reduced to two line size warnings.

These patches are only tested via the unit tests. I do not have
expansion boards to test with real hardware.


Frank Rowand (13):
  Remove comments that state the obvious, to reduce clutter
  Remove excessive printks to reduce clutter.
  Remove braces around single line blocks.
  Convert comparisons to zero or NULL to simplify logical expressions
  Rename functions to more accurately reflect what they do
  Remove prefix "__of_" and prefix "__" from local function names
  Rename variables to better reflect purpose or follow convention
  Update structure of code to be clearer, also remove BUG_ON()
  Remove redundant size check
  Update comments to reflect changes and increase clarity
  Add back an error message, restructured
  Move setting of pointer to beside test for non-null
  Remove unused variable overlay_symbols

 drivers/of/resolver.c | 349 --
 1 file changed, 141 insertions(+), 208 deletions(-)

-- 
1.9.1



Re: [PATCH net-next] ibmveth: calculate correct gso_size and set gso_type

2016-10-25 Thread Jonathan Maxwell
>> + u16 hdr_len = ETH_HLEN + sizeof(struct tcphdr);

> Compiler may optmize this, but maybe move hdr_len to [*] ?>

There are other places in the stack where a u16 is used for the
same purpose. So I'll rather stick to that convention.

I'll make the other formatting changes you suggested and
resubmit as v1.

Thanks

Jon

On Tue, Oct 25, 2016 at 9:31 PM, Marcelo Ricardo Leitner
 wrote:
> On Tue, Oct 25, 2016 at 04:13:41PM +1100, Jon Maxwell wrote:
>> We recently encountered a bug where a few customers using ibmveth on the
>> same LPAR hit an issue where a TCP session hung when large receive was
>> enabled. Closer analysis revealed that the session was stuck because the
>> one side was advertising a zero window repeatedly.
>>
>> We narrowed this down to the fact the ibmveth driver did not set gso_size
>> which is translated by TCP into the MSS later up the stack. The MSS is
>> used to calculate the TCP window size and as that was abnormally large,
>> it was calculating a zero window, even although the sockets receive buffer
>> was completely empty.
>>
>> We were able to reproduce this and worked with IBM to fix this. Thanks Tom
>> and Marcelo for all your help and review on this.
>>
>> The patch fixes both our internal reproduction tests and our customers tests.
>>
>> Signed-off-by: Jon Maxwell 
>> ---
>>  drivers/net/ethernet/ibm/ibmveth.c | 19 +++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
>> b/drivers/net/ethernet/ibm/ibmveth.c
>> index 29c05d0..3028c33 100644
>> --- a/drivers/net/ethernet/ibm/ibmveth.c
>> +++ b/drivers/net/ethernet/ibm/ibmveth.c
>> @@ -1182,6 +1182,8 @@ static int ibmveth_poll(struct napi_struct *napi, int 
>> budget)
>>   int frames_processed = 0;
>>   unsigned long lpar_rc;
>>   struct iphdr *iph;
>> + bool large_packet = 0;
>> + u16 hdr_len = ETH_HLEN + sizeof(struct tcphdr);
>
> Compiler may optmize this, but maybe move hdr_len to [*] ?
>
>>
>>  restart_poll:
>>   while (frames_processed < budget) {
>> @@ -1236,10 +1238,27 @@ static int ibmveth_poll(struct napi_struct *napi, 
>> int budget)
>>   iph->check = 0;
>>   iph->check = 
>> ip_fast_csum((unsigned char *)iph, iph->ihl);
>>   adapter->rx_large_packets++;
>> + large_packet = 1;
>>   }
>>   }
>>   }
>>
>> + if (skb->len > netdev->mtu) {
>
> [*]
>
>> + iph = (struct iphdr *)skb->data;
>> + if (be16_to_cpu(skb->protocol) == ETH_P_IP && 
>> iph->protocol == IPPROTO_TCP) {
>
> The if line above is too long, should be broken in two.
>
>> + hdr_len += sizeof(struct iphdr);
>> + skb_shinfo(skb)->gso_type = 
>> SKB_GSO_TCPV4;
>> + skb_shinfo(skb)->gso_size = 
>> netdev->mtu - hdr_len;
>> + } else if (be16_to_cpu(skb->protocol) == 
>> ETH_P_IPV6 &&
>> + iph->protocol == IPPROTO_TCP) {
> ^
> And this one should start 3 spaces later, right below be16_
>
>   Marcelo
>
>> + hdr_len += sizeof(struct ipv6hdr);
>> + skb_shinfo(skb)->gso_type = 
>> SKB_GSO_TCPV6;
>> + skb_shinfo(skb)->gso_size = 
>> netdev->mtu - hdr_len;
>> + }
>> + if (!large_packet)
>> + adapter->rx_large_packets++;
>> + }
>> +
>>   napi_gro_receive(napi, skb);/* send it up */
>>
>>   netdev->stats.rx_packets++;
>> --
>> 1.8.3.1
>>


Re: [PATCH v2] Input: synaptics-rmi4 - stop scanning PDT after two empty pages

2016-10-25 Thread Chris Healy
On Tue, Oct 25, 2016 at 1:36 PM, Nick Dyer  wrote:
> We have encountered some RMI4 firmwares where there are blank pages in
> between PDT pages which contain functions. This change makes them
> correctly enumerate all functions on the device.
>
> Tested on S7817 (has empty page 2).
>
> Signed-off-by: Nick Dyer 
> ---
>  drivers/input/rmi4/rmi_driver.c | 16 ++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 4a88312..425bd19 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -422,6 +422,7 @@ static void rmi_driver_copy_pdt_to_fd(const struct 
> pdt_entry *pdt,
>
>  static int rmi_scan_pdt_page(struct rmi_device *rmi_dev,
>  int page,
> +int *empty_pages,
>  void *ctx,
>  int (*callback)(struct rmi_device *rmi_dev,
>  void *ctx,
> @@ -449,7 +450,16 @@ static int rmi_scan_pdt_page(struct rmi_device *rmi_dev,
> return retval;
> }
>
> -   return (data->f01_bootloader_mode || addr == pdt_start) ?
> +   /*
> +* Count number of empty PDT pages. If a gap of two pages
> +* or more is found, stop scanning.
> +*/
> +   if (addr == pdt_start)
> +   ++*empty_pages;
> +   else
> +   *empty_pages = 0;
> +
> +   return (data->f01_bootloader_mode || *empty_pages >= 2) ?
> RMI_SCAN_DONE : RMI_SCAN_CONTINUE;
>  }
>
> @@ -459,10 +469,12 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev, 
> void *ctx,
> const struct pdt_entry *entry))
>  {
> int page;
> +   int empty_pages = 0;
> int retval = RMI_SCAN_DONE;
>
> for (page = 0; page <= RMI4_MAX_PAGE; page++) {
> -   retval = rmi_scan_pdt_page(rmi_dev, page, ctx, callback);
> +   retval = rmi_scan_pdt_page(rmi_dev, page, _pages,
> +  ctx, callback);
> if (retval != RMI_SCAN_CONTINUE)
> break;
> }
> --
> 2.7.4
>

Tested successfully on S7817 and S7300 Synaptics touch controllers.
The S7300 has no regressions and the S7817 now shows fn55 in the
sysfs.  (It did not show fn55 before the patch.)

Tested-by: Chris Healy 


[PATCH v2 1/2] staging: lustre: remove broken dead code in cfs_cpt_table_create_pattern

2016-10-25 Thread Arnd Bergmann
After a recent bugfix, we get a warning about the use of an uninitialized
variable:

drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c: In function 
'cfs_cpt_table_create_pattern':
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c:833:7: error: 'str' may be 
used uninitialized in this function [-Werror=maybe-uninitialized]

This part of the function used to not do anything as we would reassign
the 'str' pointer to something else right away, but now we pass an
uninitialized pointer into 'strchr', which can cause a kernel page fault
or worse.

Fixes: 239fd5d41f9b ("staging: lustre: libcfs: shortcut to create CPT from NUMA 
topology")
Signed-off-by: Arnd Bergmann 
---
 drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c 
b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
index 464b27923ac0..6a31521f6ae0 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -829,13 +829,6 @@ cfs_cpt_table_create_pattern(char *pattern)
int c;
int i;
 
-   for (ncpt = 0;; ncpt++) { /* quick scan bracket */
-   str = strchr(str, '[');
-   if (!str)
-   break;
-   str++;
-   }
-
str = cfs_trimwhite(pattern);
if (*str == 'n' || *str == 'N') {
pattern = str + 1;
-- 
2.9.0



Re: [PATCH 1/3] perf sched map: Apply cpu color when there's an activity

2016-10-25 Thread Namhyung Kim
Hi Arnaldo,

On Tue, Oct 25, 2016 at 03:07:46PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 24, 2016 at 11:02:43AM +0900, Namhyung Kim escreveu:
> > Applying cpu color always doesn't help readability IMHO.  Instead it
> > might be better to applying the color when there's an activity on those
> > CPUs.
> 
> thanks, applied the three patches.

Thanks, but unfortunately the patch 3/3 has a bug.  Could you please
fold the fix below into the patch?

Thanks,
Namhyung


diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f0ab715b4923..a8e58d495a66 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1218,7 +1218,7 @@ static void output_lat_thread(struct perf_sched *sched, 
struct work_atoms *work_
  (double)work_list->total_runtime / NSEC_PER_MSEC,
 work_list->nb_atoms, (double)avg / NSEC_PER_MSEC,
 (double)work_list->max_lat / NSEC_PER_MSEC,
-timestamp_in_usec(buf, sizeof(buf), work_list->max_lat));
+timestamp_in_usec(buf, sizeof(buf), work_list->max_lat_at));
 }
 
 static int pid_cmp(struct work_atoms *l, struct work_atoms *r)


Re: [RFC PATCH 0/6] UART slave devices using serio

2016-10-25 Thread Rob Herring
On Tue, Oct 25, 2016 at 4:55 PM, Sebastian Reichel  wrote:
> Hi,
>
> On Wed, Aug 24, 2016 at 06:24:30PM -0500, Rob Herring wrote:
>> This is a new approach to supporting UART slave devices using the
>> existing serio bus. After Arnd's proding, I took another look at serio
>> and decided extending it does make sense. Using serio primarily requires
>> adding DT based device matching and supporting buffer based write and
>> receive.
>>
>> Currently, I'm using the existing serio serport ldisc for testing. This
>> requires using inputattach to open the tty and set the ldisc which in
>> turn registers a serio port with the serio core:
>>
>> inputattach -bare /dev/ttyAMA1
>>
>> Once a tty_port based serio port driver is in place, this step will not
>> be needed. Supporting cases like a USB UART will also work if the USB
>> UART is described in DT. If not described in DT, I'm not sure if the
>> existing serio manual binding is sufficient (Need to figure out how that
>> works). Slave drivers also need other ways to specify additional data
>> using module params perhaps. Getting DT overlays to work for
>> non-discoverable devices behind discoverable buses (i.e. detached from
>> a base DT) is another option, but that's not yet supported in general.
>>
>> I've done all the serio changes in place, but ultimately I think at
>> least the core of serio should be moved out of drivers/input/. I don't
>> think it belongs under drivers/tty/ or drivers/tty/serial/, so
>> drivers/serio/?
>>
>> BT is working under QEMU to the point a slave driver can bind to a
>> serio port device via DT, register as a BT device, start sending out
>> initial packets and receive data (typed at a terminal). Now I need to
>> find a real device.
>
> I had a more detailed look at the series during the last two weeks.
> For me the approach looks ok and it should work for the nokia bluetooth
> use case. Actually my work on that driver is more or less stalled until
> this is solved, so it would be nice to get this forward. Whose feedback
> is this waiting from? I guess

I think it is mainly waiting for me to spend more time on it and get
the tty port part done. I could use help especially for converting the
BT part properly.

>  * Alan & Greg for the serial parts
>  * Marcel for the bluetooth parts
>  * Dmitry for the serio parts
>
> Maybe you can try to find some minutes at the Kernel Summit to talk
> about this?

Still waiting for my invite...

But I will be at Plumbers if folks want to discuss this.

Rob


Re: [RFC][PATCH] usb: dwc2: Make sure we disconnect the gadget state on reset

2016-10-25 Thread John Youn
On 10/25/2016 2:56 PM, John Stultz wrote:
> On Tue, Oct 25, 2016 at 2:29 PM, John Youn  wrote:
>> On 10/19/2016 11:00 PM, John Stultz wrote:
>>> I had seen some odd behavior with HiKey's usb-gadget interface
>>> that I finally seemed to have chased down. Basically every other
>>> time I pluged in the OTG port, the gadget interface would
>>> properly initialize. The other times, I'd get a big WARN_ON
>>> in dwc2_hsotg_init_fifo() about the fifo_map not being clear.
>>>
>>> Ends up If we don't disconnect the gadget state on reset, the
>>> fifo-map doesn't get cleared properly, which causes WARN_ON
>>> messages and also results in the device not properly being
>>> setup as a gadget every other time the OTG port is connected.
>>>
>>> So this patch adds a call to dwc2_hsotg_disconnect() in the
>>> reset path so the state is properly cleared.
>>>
>>> With it, the gadget interface initializes properly on every
>>> plug in.
>>>
>>> I don't know if this is actually the right fix, but it seems
>>> to work well. Feedback would be greatly appreciated!
>>>
>>> Cc: Wei Xu 
>>> Cc: Guodong Xu 
>>> Cc: Chen Yu 
>>> Cc: Amit Pundir 
>>> Cc: Rob Herring 
>>> Cc: Mark Rutland 
>>> Cc: John Youn 
>>> Cc: Douglas Anderson 
>>> Cc: Greg Kroah-Hartman 
>>> Cc: linux-...@vger.kernel.org
>>> Signed-off-by: John Stultz 
>>> ---
>>>  drivers/usb/dwc2/gadget.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>>> index 24fbebc..5505001 100644
>>> --- a/drivers/usb/dwc2/gadget.c
>>> +++ b/drivers/usb/dwc2/gadget.c
>>> @@ -2519,6 +2519,8 @@ void dwc2_hsotg_core_init_disconnected(struct 
>>> dwc2_hsotg *hsotg,
>>>
>>>   /* Kill any ep0 requests as controller will be reinitialized */
>>>   kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
>>> + /* Make sure everything is disconnected */
>>> + dwc2_hsotg_disconnect(hsotg);
>>>
>>>   if (!is_usb_reset)
>>>   if (dwc2_core_reset(hsotg))
>>>
>>
>> Seems fine with our testing.
>>
>> Acked-by: John Youn 
> 
> Awesome! Thanks so much for the review and testing!
> 
> I'm curious, did you happen to have any thoughts or objections on the
> "dwc2: Force port resume on switching to device mode" patch
> (https://patchwork.kernel.org/patch/9375965/ ) as well?

Sorry, must have missed that one. We'll take a look.

Regards,
John




Re: [PATCH] PCI: pci-stub: accept exceptions to the ID- and class-based matching

2016-10-25 Thread Laszlo Ersek
On 10/25/16 21:24, Laszlo Ersek wrote:
> On 10/25/16 20:42, Alex Williamson wrote:

>> FWIW, I think the reason
>> this hasn't been done to date is that PCI bus addresses (except for
>> root bus devices) are not stable.  Depending on the system, the address
>> of a given device may change, not only based on the slot where the
>> device is installed, but whether other devices in other slots are
>> populated.
> 
> I agree.
> 
> However, while the addresses are not stable in the face of hardware
> changes, I think the addresses don't change haphazardly (that is,
> without hardware changes).
> 
> So, if you plug in another card, your current pci-stub.except=...
> parameter might become invalid; but that's not very different from the
> case when you plug in the second instance of a preexistent card right
> now -- then the pci-stub.ids=... filter won't match uniquely anymore,
> and assignment vs. host-side use might not work as intented.

Sorry about the self-followup; I just wanted to add -- although it might
not carry a lot of weight for the host kernel -- that the libvirt domain
XML hard-codes the host-side PCI BDF anyway, for assigned devices:

http://libvirt.org/formatdomain.html#elementsHostDev

"""
  

  

  
  ...

  

  ...

  source
The source element describes the device as seen from the host using
the following mechanism to describe:

...

pci
  PCI devices can only be described by their address.
"""

Thanks
Laszlo


Re: [RFC 5/8] mm: Add new flag VM_CDM for coherent device memory

2016-10-25 Thread Dave Hansen
On 10/25/2016 12:20 PM, Aneesh Kumar K.V wrote:
> Dave Hansen  writes:
>> On 10/23/2016 09:31 PM, Anshuman Khandual wrote:
>>> VMAs containing coherent device memory should be marked with VM_CDM. These
>>> VMAs need to be identified in various core kernel paths and this new flag
>>> will help in this regard.
>>
>> ... and it's sticky?  So if a VMA *ever* has one of these funky pages in
>> it, it's stuck being VM_CDM forever?  Never to be merged with other
>> VMAs?  Never to see the light of autonuma ever again?
>>
>> What if a 100TB VMA has one page of fancy pants device memory, and the
>> rest normal vanilla memory?  Do we really want to consider the whole
>> thing fancy?
> 
> This definitely needs fine tuning. I guess we should look at this as
> possibly stating that, coherent device would like to not participate in
> auto numa balancing
...

Right, in this one, particular case you don't want NUMA balancing.  But,
if you have to take an _explicit_ action to even get access to this
coherent memory (setting a NUMA policy), why keeps that explicit action
from also explicitly disabling NUMA migration?

I really don't think we should tie together the isolation aspect with
anything else, including NUMA balancing.

For instance, on x86, we have the ability for devices to grok the CPU's
page tables, including doing faults.  There's very little to stop us
from doing things like autonuma.

> One possible option is to use a software pte bit (may be steal
> _PAGE_DEVMAP) and prevent a numa pte setup from change_prot_numa().
> ie, if the pfn backing the pte is from coherent device we don't allow
> that to be converted to a prot none pte for numa faults ?

Why would you need to tag individual pages, especially if the VMA has a
policy set on it that disallows migration?

But, even if you did need to identify individual pages from the PTE, you
can easily do:

page_to_nid(pfn_to_page(pte_pfn(pte)))

and then tell if the node is a fancy-pants device node.


RE: [PATCH] drm/amd/powerplay: mark symbols static where possible

2016-10-25 Thread Deucher, Alexander
> -Original Message-
> From: Arnd Bergmann [mailto:a...@arndb.de]
> Sent: Tuesday, October 25, 2016 4:15 AM
> To: Baoyou Xie
> Cc: Deucher, Alexander; Dave Airlie; Zhu, Rex; Zhou, Jammy; Huang,
> JinHuiEric; StDenis, Tom; Edward O'Callaghan; Prosyak, Vitaly; Yang, Eric;
> Yang, Young; Huang, Ray; Dan Carpenter; Cui, Flora; Nils Wallménius; Liu,
> Monk; Wang, Ken; Min, Frank; dri-devel; Linux Kernel Mailing List;
> xie.bao...@zte.com.cn; han@zte.com.cn; tang.qiang...@zte.com.cn
> Subject: Re: [PATCH] drm/amd/powerplay: mark symbols static where
> possible
> 
> On Tuesday, October 25, 2016 10:31:21 AM CEST Baoyou Xie wrote:
> > On 25 October 2016 at 04:51, Arnd Bergmann  wrote:
> > > On Saturday, October 22, 2016 4:56:22 PM CEST Baoyou Xie wrote:
> > > The function has no callers, so the easiest way would be to remove it
> > > entirely, but it's possible that there are plans to add users soon.
> > >
> > > It was assumed that this function will be used soon, so this patch remains
> > it.
> > if it still not be used in 4.10, then we can remove it.
> > is it right?
> 
> There is no such rule in general, it's up to the maintainer and
> it depends on the specific reason for why the function ended up
> being unused in the first place.
> 
> However, we can expect the maintainer to come up with some solution
> to address the warning. Possible options include:
> 
> - calling the function from where it was meant to be used
> - removing the function
> - adding __maybe_unused
> - adding an #if 0
> 
> I have not looked at this specific example and do not know
> which of them would be appropriate here. If you look at the
> output of 'git log -p
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c'
> you might find it out yourself.

This is mostly fallout from a big cleanup/re-org of the powerplay code in the 
4.9.  Rex said he was going to use these soon.  

Alex



Re: [PATCH] cw1200: fix bogus maybe-uninitialized warning

2016-10-25 Thread Arnd Bergmann
On Tuesday, October 25, 2016 1:24:55 PM CEST David Laight wrote:
> > diff --git a/drivers/net/wireless/st/cw1200/wsm.c 
> > b/drivers/net/wireless/st/cw1200/wsm.c
> > index 680d60eabc75..094e6637ade2 100644
> > --- a/drivers/net/wireless/st/cw1200/wsm.c
> > +++ b/drivers/net/wireless/st/cw1200/wsm.c
> > @@ -385,14 +385,13 @@ static int wsm_multi_tx_confirm(struct cw1200_common 
> > *priv,
> >   if (WARN_ON(count <= 0))
> >   return -EINVAL;
> > 
> > - if (count > 1) {
> > - /* We already released one buffer, now for the rest */
> > - ret = wsm_release_tx_buffer(priv, count - 1);
> > - if (ret < 0)
> > - return ret;
> > - else if (ret > 0)
> > - cw1200_bh_wakeup(priv);
> > - }
> > + /* We already released one buffer, now for the rest */
> > + ret = wsm_release_tx_buffer(priv, count - 1);
> > + if (ret < 0)
> > + return ret;
> > +
> > + if (ret > 0)
> > + cw1200_bh_wakeup(priv);
> 
> That doesn't look equivalent to me (when count == 1).

Ah, that's what I missed, thanks for pointing that out!

> > 
> >   cw1200_debug_txed_multi(priv, count);
> >   for (i = 0; i < count; ++i) {
> 
> Convert this loop into a do ... while so the body executes at least once.

Good idea. Version 2 coming now.

Arnd


Re: [PATCH 3/3] clk: keystone: Fix missing iounmap calls in an error handling path

2016-10-25 Thread Stephen Boyd
On 10/25, walter harms wrote:
> Am 24.10.2016 22:43, schrieb Christophe JAILLET:
> > @@ -220,6 +218,12 @@ static void __init _of_pll_clk_init(struct device_node 
> > *node, bool pllctrl)
> >  
> >  out:
> > pr_err("%s: error initializing pll %s\n", __func__, node->name);
> > +   if (pll_data->pllm)
> > +   iounmap(pll_data->pllm);
> > +   if (pll_data->pll_ctl0)
> > +   iounmap(pll_data->pll_ctl0);
> > +   if (pll_data->pllod)
> > +   iounmap(pll_data->pllod);
> > kfree(pll_data);
> >  }
> >  
> 
> IMHO calles the iounmap() need no check for NULL.
> 

ARM doesn't seem to check for NULL there though. So that would be
a bug.

It would be nice to remove the checks though. Perhaps someone
could do that by unifying ionumap into asm-generic with the NULL
check and then have architecture specific functions for the rest
of it?

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


Re: [PATCH V5 1/2] ACPI: Add support for ResourceSource/IRQ domain mapping

2016-10-25 Thread agustinv

Hi Marc, Lorenzo,

On 2016-10-20 13:51, Marc Zyngier wrote:

On 20/10/16 17:48, Lorenzo Pieralisi wrote:

Hi Agustin,

On Tue, Oct 18, 2016 at 01:41:48PM -0400, Agustin Vega-Frias wrote:

This allows irqchip drivers to associate an ACPI DSDT device to
an IRQ domain and provides support for using the ResourceSource
in Extended IRQ Resources to find the domain and map the IRQs
specified on that domain.

Signed-off-by: Agustin Vega-Frias 
---
 drivers/acpi/Makefile |   1 +
 drivers/acpi/irqdomain.c  | 141 
++

 drivers/acpi/resource.c   |  21 +++---
 include/asm-generic/vmlinux.lds.h |   1 +
 include/linux/acpi.h  |  71 +++
 include/linux/irqchip.h   |  17 -
 6 files changed, 240 insertions(+), 12 deletions(-)
 create mode 100644 drivers/acpi/irqdomain.c

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 9ed0878..880401b 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -57,6 +57,7 @@ acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
 acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o
 acpi-$(CONFIG_ACPI_WATCHDOG)   += acpi_watchdog.o
+acpi-$(CONFIG_IRQ_DOMAIN)  += irqdomain.o

 # These are (potentially) separate modules

diff --git a/drivers/acpi/irqdomain.c b/drivers/acpi/irqdomain.c
new file mode 100644
index 000..c53b9f4
--- /dev/null
+++ b/drivers/acpi/irqdomain.c
@@ -0,0 +1,141 @@
+/*
+ * ACPI ResourceSource/IRQ domain mapping support
+ *
+ * Copyright (c) 2016, 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 
+
+/**
+ * acpi_irq_domain_ensure_probed() - Check if the device has 
registered
+ *   an IRQ domain and probe as 
necessary

+ *
+ * @device: Device to check and probe
+ *
+ * Returns: 0 on success, -ENODEV otherwise


This is not correct (ie it depends on what

struct acpi_dsdt_probe_entry.probe

returns) and I would like to take this nit as an opportunity
to take a step back and ask you a question below.


+ */
+static int acpi_irq_domain_ensure_probed(struct acpi_device *device)
+{
+   struct acpi_dsdt_probe_entry *entry;
+
+   if (irq_find_matching_fwnode(>fwnode, DOMAIN_BUS_ANY) != 0)
+   return 0;
+
+   for (entry = &__dsdt_acpi_probe_table;
+entry < &__dsdt_acpi_probe_table_end; entry++)
+   if (strcmp(entry->_hid, acpi_device_hid(device)) == 0)
+   return entry->probe(device);


Through this approch we are forcing an irqchip (that by the way it
has a physical node ACPI companion by being a DSDT device object so it
could be managed by a platform driver) to be probed. The question is: 
is

there a reason (apart from the current ACPI resource parsing API) why
this can't be implemented through deferred probing and the device
dependencies framework Rafael is working on:

http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1246897.html

The DT layer, through the of_irq_get() API, supports probe deferral
and what I am asking you is if there is any blocking point (again,
apart from the current ACPI API) to implement the same mechanism.

I have not reviewed the previous versions so I am certainly missing
some of the bits and pieces already discussed, apologies for that.


Also, this function scares me to no end: lack of locking and recursion
are the main things that worry me. My vote would be to implement
something based on Rafael's approach (which conveniently solves all 
kind

of other issues).



I have looked at the latest version of Rafael's patchset for device 
functional
dependency tracking and in its current form it does not address the 
issues

we see with dependencies on irqchips under ACPI boot.

The problem is that the conversion of ACPI IRQ resources to Linux IRQ 
resources
for most DSDT devices occurs before the device is even added and is not 
retried
when a device is re-probed after returning -EPROBE_DEFER. The call chain 
in most

cases is:

acpi_init()
acpi_scan_init()
acpi_bus_scan()
acpi_bus_attach()
acpi_default_enumeration()
acpi_create_platform_device()
acpi_dev_get_resources() /* Resources are 
converted here */

platform_device_register_full()
platform_device_add()

Re: [PATCH] soc: qcom: Add SoC info driver

2016-10-25 Thread Arnd Bergmann
On Tuesday, October 25, 2016 3:23:34 PM CEST Imran Khan wrote:
> On 10/21/2016 4:03 PM, Arnd Bergmann wrote:
> >> +/* socinfo: sysfs functions */
> > 
> > This seems overly verbose, having both raw and human-readable
> > IDs is generally not necessary, pick one of the two. If you
> > need any fields that we don't already support in soc_device,
> > let's talk about adding them to the generic structure.
> > 
> > 
> 
> Okay. I will go for human readable IDs. Can we add 2 more fields
> in the generic structure.
> These 2 fields would be:
> 
> vendor: A string for vendor name
> serial_number: A string containing serial number for the platform


serial_number seems straightforward, adding this seems like a good
idea. I don't understand yet what would go into the vendor field
though. For this particular driver, is it always "Qualcomm", or
would it be a third-party that makes a device based on that chip?

Arnd


[RFC PATCH 04/13] of: Convert comparisons to zero or NULL to simplify logical expressions

2016-10-25 Thread frowand . list
From: Frank Rowand 

A small number of such comparisons remain where they provide more
clarity of the numeric nature of a variable.

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index c61ba99a1792..31fd3800787a 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -33,10 +33,10 @@ static struct device_node 
*__of_find_node_by_full_name(struct device_node *node,
 {
struct device_node *child, *found;
 
-   if (node == NULL)
+   if (!node)
return NULL;
 
-   if (of_node_cmp(node->full_name, full_name) == 0)
+   if (!of_node_cmp(node->full_name, full_name))
return of_node_get(node);
 
for_each_child_of_node(node, child) {
@@ -86,8 +86,8 @@ static void __of_adjust_tree_phandles(struct device_node 
*node,
 
for_each_property_of_node(node, prop) {
 
-   if (of_prop_cmp(prop->name, "phandle") != 0 &&
-   of_prop_cmp(prop->name, "linux,phandle") != 0)
+   if (of_prop_cmp(prop->name, "phandle") &&
+   of_prop_cmp(prop->name, "linux,phandle"))
continue;
 
if (prop->length < 4)
@@ -140,7 +140,7 @@ static int __of_adjust_phandle_ref(struct device_node *node,
 
*s++ = '\0';
err = kstrtoint(s, 10, );
-   if (err != 0)
+   if (err)
goto err_fail;
 
refnode = __of_find_node_by_full_name(node, nodestr);
@@ -148,7 +148,7 @@ static int __of_adjust_phandle_ref(struct device_node *node,
continue;
 
for_each_property_of_node(refnode, sprop) {
-   if (of_prop_cmp(sprop->name, propstr) == 0)
+   if (!of_prop_cmp(sprop->name, propstr))
break;
}
of_node_put(refnode);
@@ -193,15 +193,15 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
unsigned int off;
phandle phandle;
 
-   if (node == NULL)
+   if (!node)
return 0;
 
for_each_property_of_node(node, rprop) {
 
/* skip properties added automatically */
-   if (of_prop_cmp(rprop->name, "name") == 0 ||
-   of_prop_cmp(rprop->name, "phandle") == 0 ||
-   of_prop_cmp(rprop->name, "linux,phandle") == 0)
+   if (!of_prop_cmp(rprop->name, "name") ||
+   !of_prop_cmp(rprop->name, "phandle") ||
+   !of_prop_cmp(rprop->name, "linux,phandle"))
continue;
 
if ((rprop->length % 4) != 0 || rprop->length == 0)
@@ -209,11 +209,11 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
count = rprop->length / sizeof(__be32);
 
for_each_property_of_node(target, sprop) {
-   if (of_prop_cmp(sprop->name, rprop->name) == 0)
+   if (!of_prop_cmp(sprop->name, rprop->name))
break;
}
 
-   if (sprop == NULL)
+   if (!sprop)
return -EINVAL;
 
for (i = 0; i < count; i++) {
@@ -232,7 +232,7 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
for_each_child_of_node(node, child) {
 
for_each_child_of_node(target, childtarget)
-   if (__of_node_name_cmp(child, childtarget) == 0)
+   if (!__of_node_name_cmp(child, childtarget))
break;
 
if (!childtarget)
@@ -240,7 +240,7 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
 
err = __of_adjust_tree_phandle_references(child, childtarget,
phandle_delta);
-   if (err != 0)
+   if (err)
return err;
}
 
@@ -282,13 +282,13 @@ int of_resolve_phandles(struct device_node *resolve)
 
childroot = NULL;
for_each_child_of_node(resolve, childroot)
-   if (of_node_cmp(childroot->name, "__local_fixups__") == 0)
+   if (!of_node_cmp(childroot->name, "__local_fixups__"))
break;
 
if (childroot != NULL) {
err = __of_adjust_tree_phandle_references(childroot,
resolve, 0);
-   if (err != 0)
+   if (err)
return err;
 
BUG_ON(__of_adjust_tree_phandle_references(childroot,
@@ -303,12 +303,10 @@ int of_resolve_phandles(struct device_node *resolve)
 
for_each_child_of_node(resolve, child) {
 
-

[RFC PATCH 06/13] of: Remove prefix "__of_" and prefix "__" from local function names

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 3d123b612789..0ce38aa0ed3c 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -28,7 +28,7 @@
  * Find a node with the give full name by recursively following any of
  * the child node links.
  */
-static struct device_node *__of_find_node_by_full_name(struct device_node 
*node,
+static struct device_node *find_node_by_full_name(struct device_node *node,
const char *full_name)
 {
struct device_node *child, *found;
@@ -40,7 +40,7 @@ static struct device_node *__of_find_node_by_full_name(struct 
device_node *node,
return of_node_get(node);
 
for_each_child_of_node(node, child) {
-   found = __of_find_node_by_full_name(child, full_name);
+   found = find_node_by_full_name(child, full_name);
if (found != NULL) {
of_node_put(child);
return found;
@@ -143,7 +143,7 @@ static int update_usages_of_a_phandle_reference(struct 
device_node *node,
if (err)
goto err_fail;
 
-   refnode = __of_find_node_by_full_name(node, nodestr);
+   refnode = find_node_by_full_name(node, nodestr);
if (!refnode)
continue;
 
@@ -168,7 +168,7 @@ static int update_usages_of_a_phandle_reference(struct 
device_node *node,
 }
 
 /* compare nodes taking into account that 'name' strips out the @ part */
-static int __of_node_name_cmp(const struct device_node *dn1,
+static int node_name_cmp(const struct device_node *dn1,
const struct device_node *dn2)
 {
const char *n1 = strrchr(dn1->full_name, '/') ? : "/";
@@ -232,7 +232,7 @@ static int adjust_local_phandle_references(struct 
device_node *node,
for_each_child_of_node(node, child) {
 
for_each_child_of_node(target, childtarget)
-   if (!__of_node_name_cmp(child, childtarget))
+   if (!node_name_cmp(child, childtarget))
break;
 
if (!childtarget)
-- 
1.9.1



[RFC PATCH 12/13] of: Move setting of pointer to beside test for non-null

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 664c97e1ecb4..3f7cf569c7ea 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -305,8 +305,6 @@ int of_resolve_phandles(struct device_node *overlay)
overlay_symbols = NULL;
overlay_fixups = NULL;
 
-   tree_symbols = of_find_node_by_path("/__symbols__");
-
for_each_child_of_node(overlay, child) {
if (!of_node_cmp(child->name, "__symbols__"))
overlay_symbols = child;
@@ -319,6 +317,7 @@ int of_resolve_phandles(struct device_node *overlay)
goto out;
}
 
+   tree_symbols = of_find_node_by_path("/__symbols__");
if (!tree_symbols) {
pr_err("no symbols in root of device tree.\n");
err = -EINVAL;
-- 
1.9.1



[RFC PATCH 13/13] of: Remove unused variable overlay_symbols

2016-10-25 Thread frowand . list
From: Frank Rowand 

This unused variable is a reminder that symbols in overlays are
not available to subsequent overlays.  If such a feature is
desired then there are several ways it could be implemented.

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 3f7cf569c7ea..b48d16200ccd 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -272,7 +272,7 @@ static int adjust_local_phandle_references(struct 
device_node *local_fixups,
 int of_resolve_phandles(struct device_node *overlay)
 {
struct device_node *child, *local_fixups, *refnode;
-   struct device_node *tree_symbols, *overlay_symbols, *overlay_fixups;
+   struct device_node *tree_symbols, *overlay_fixups;
struct property *prop;
const char *refpath;
phandle phandle, phandle_delta;
@@ -302,12 +302,9 @@ int of_resolve_phandles(struct device_node *overlay)
if (err)
goto err_out;
 
-   overlay_symbols = NULL;
overlay_fixups = NULL;
 
for_each_child_of_node(overlay, child) {
-   if (!of_node_cmp(child->name, "__symbols__"))
-   overlay_symbols = child;
if (!of_node_cmp(child->name, "__fixups__"))
overlay_fixups = child;
}
-- 
1.9.1



Re: [RFC PATCH 01/13] of: Remove comments that state the obvious

2016-10-25 Thread Joe Perches
On Tue, 2016-10-25 at 13:58 -0700, frowand.l...@gmail.com wrote:
> From: Frank Rowand 
> 
> Remove comments that state the obvious, to reduce clutter

Some of these removals might be overly aggressive.

> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
[]
> @@ -125,7 +114,6 @@ static int __of_adjust_phandle_ref(struct device_node 
> *node,
>   int offset, propcurlen;
>   int err = 0;
>  
> - /* make a copy */
>   propval = kmalloc(rprop->length, GFP_KERNEL);
>   if (!propval) {
>   pr_err("%s: Could not copy value of '%s'\n",ld

This kmalloc/memcpy could use kmemdup instead.

It doesn't really need the pr_err either as kmalloc and/or
kmemdup get a generic OOM message.



[PATCH] crypto: caam: fix type mismatch warning

2016-10-25 Thread Arnd Bergmann
Building the caam driver on arm64 produces a harmless warning:

drivers/crypto/caam/caamalg.c:140:139: warning: comparison of distinct pointer 
types lacks a cast

We can use min_t to tell the compiler which type we want it to use
here.

Fixes: 5ecf8ef9103c ("crypto: caam - fix sg dump")
Signed-off-by: Arnd Bergmann 
---
This is currently the only warning reported by kernelci.org for
linux-4.9 on arm, arm64 and x86.
---
 drivers/crypto/caam/caamalg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 156aad167cd6..8de85dfb1b04 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -137,7 +137,7 @@ static void dbg_dump_sg(const char *level, const char 
*prefix_str,
}
 
buf = it_page + it->offset;
-   len = min(tlen, it->length);
+   len = min_t(size_t, tlen, it->length);
print_hex_dump(level, prefix_str, prefix_type, rowsize,
   groupsize, buf, len, ascii);
tlen -= len;
-- 
2.9.0



Regression caused by commit c83ed4c9dbb3 "ubifs: Abort readdir on error"

2016-10-25 Thread Peter Rosin
Hi!

Early on in my boot procedure I create an overlay and shuffle
things around a bit so that the original rootfs stays readonly
at the bottom of an overlayed readwrite fs. This way I can just
toss out the overlayed fs and have a clean and reliable way to
do a "factory-reset". Both the read-only root and and the overlay
are ubifs on nand.

Bisection points to commit c83ed4c9dbb3 "ubifs: Abort readdir
on error". Reverting that commit on top of v4.9-rc2 fixes things.

My "shuffle script" is as follows (with an added comment
indicating the first point of failure) and runs as the first
script by init.

If I add a line
ls -l /mnt || echo "ls -l /mnt failed"
where that comment is right before the failure, I get no failure
indication even with the broken commit, so directory traversal
seems ok.

Cheers,
Peter

#! /bin/bash

test "x$1" == xstart || exit 0

mkdir /tmp/log

/bin/mount -o remount,rw /dev

/bin/mount | /bin/grep -q "^overlay on / type overlay" && exit 0

if test -e /etc/factory-reset; then
  /usr/sbin/ubiformat /dev/mtd7
  rm /etc/factory-reset
fi

/usr/sbin/ubiattach /dev/ubi_ctrl -m 7
/usr/sbin/ubimkvol /dev/ubi1 -N ovl -m

/bin/mkdir -p /mnt/ovl
/bin/mkdir -p /mnt/roroot
/bin/mkdir -p /mnt/merge
/bin/mount -t ubifs /dev/ubi1_0 /mnt/ovl

/bin/mkdir -p /mnt/ovl/ovl
/bin/mkdir -p /mnt/ovl/work
# with c83ed4c9dbb3, the following mount fails with
# mount: mounting overlay on /mnt/merge failed: No such file or directory
/bin/mount -t overlay -o lowerdir=/,upperdir=/mnt/ovl/ovl,workdir=/mnt/ovl/work 
overlay /mnt/merge

cd /mnt/merge

/sbin/pivot_root . /mnt/merge/mnt/roroot

/bin/mount --rbind /mnt/roroot/proc /proc
/bin/mount --rbind /mnt/roroot/sys /sys
/bin/mount --rbind /mnt/roroot/dev /dev
/bin/mount --rbind /mnt/roroot/tmp /tmp
/bin/mount --rbind /mnt/roroot/run /run
/bin/mount --rbind /mnt/roroot/mnt/ovl /mnt/ovl

kill $PPID
kill -QUIT 1


[DOC] Missing completions-design.txt?

2016-10-25 Thread Brian Norris
Hi,

It looks like Nicholas submitted this doc a while back as patch 2/2:

"[PATCH 2/2] doc: detailed documentation for completion"
http://lkml.iu.edu/hypermail/linux/kernel/1412.2/03676.html

where patch 1/2 got merged as this:

202799be447b doc: brief user documentation for completion

References in the introduced completion.txt doc have pointed lost souls
at an elusive completion-design.txt:

  "for details on completion design and implementation see
  completions-design.txt"

Since as we well know, most developers are religious readers of
documentation, presumably there are people out there waiting expectantly
for such a file to appear in their otherwise exhaustive Documentation/.
Can you help such lost souls out?

Thanks,
Brian

P.S. I haven't actually read the design doc that closely yet. Who would
trust such a random patch off the archives, after all? So just removing
the mention of this file might be a satisfactory solution.


[PATCH v2 net-next] virtio-net: Update the mtu code to match virtio spec

2016-10-25 Thread Aaron Conole
The virtio committee recently ratified a change, VIRTIO-152, which
defines the mtu field to be 'max' MTU, not simply desired MTU.

This commit brings the virtio-net device in compliance with VIRTIO-152.

Additionally, drop the max_mtu branch - it cannot be taken since the u16
returned by virtio_cread16 will never exceed the initial value of
max_mtu.

Signed-off-by: Aaron Conole 
Acked-by: "Michael S. Tsirkin" 
Acked-by: Jarod Wilson 
---
Nothing code-wise has changed, but I've included the ACKs and fixed up the
subject line.

 drivers/net/virtio_net.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 720809f..2cafd12 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1870,10 +1870,12 @@ static int virtnet_probe(struct virtio_device *vdev)
mtu = virtio_cread16(vdev,
 offsetof(struct virtio_net_config,
  mtu));
-   if (mtu < dev->min_mtu || mtu > dev->max_mtu)
+   if (mtu < dev->min_mtu) {
__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
-   else
+   } else {
dev->mtu = mtu;
+   dev->max_mtu = mtu;
+   }
}
 
if (vi->any_header_sg)
-- 
2.7.4



Re: [PATCH 3/3] usb: dwc3: host: Do not use dma_coerce_mask_and_coherent

2016-10-25 Thread Arnd Bergmann
On Tuesday, October 25, 2016 4:26:28 PM CEST Sriram Dash wrote:
> Do not use dma_coerce_mask_and_coherent for hcd.
> 
> Signed-off-by: Arnd Bergmann 

The patch is good, but please follow the usual rules for submitting
someone else's patch:

- As the first line, have "From: Arnd Bergmann ".
  "git format-patch" adds this automatically if you pass that
  address as the "--author" argument to "git commit".

- Add you "Signed-off-by" line at below mine (or any other lines)

I would also suggest a more elaborate changelog text, the
free-form text should explain why something is done, rather than
repeat the subject:

| The dma mask is correctly set up by the DT probe function, no
| need to override it any more.

Arnd


Re: [PATCH] clk: Register clkdev after setup of fixed-rate and fixed-factor clocks

2016-10-25 Thread Stephen Boyd
On 10/22, Xiaolong Zhang wrote:
> On 四, 10月 20, 2016 at 04:01:03下午 -0700, Stephen Boyd wrote:
> > On 10/11, Orson Zhai wrote:
> > > From: Xiaolong Zhang 
> > > 
> > > When common kernel setups fixed clock, of_clk_provider will be 
> > > registerred.
> > > But there is no clkdev being registerred at the same time. This will make
> > > it difficult to get the clock by using clk_get(NULL, con_id).
> > > 
> > > Add clkdev register for fixed-rate and fixed-factor clock and ignore
> > > the error if any.
> > > 
> > > Signed-off-by: Xiaolong Zhang 
> > > Signed-off-by: Orson Zhai 
> > > ---
> > 
> > Why are we using clkdev lookups for clks populated from DT?
> > Shouldn't we be able to point to them from the consumers that
> > would also be in DT? I'm a little lost.
> > 
> The clk_get interface allows the first argument as NULL. We just assure
> consumers can get the clock from DT or by clock name.

Ok. The first argument to clk_get() really shouldn't be NULL. It
should be the device pointer for the device that is associated
with the clk you want to get. The clock name (second argument to
clk_get()) should be device specific and not some globally unique
identifier. It seems that you're using the clk_get() API
incorrectly.

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


[PATCH 2/7] powerpc/vdso: remove unused params in vdso_do_func_patch{32,64}

2016-10-25 Thread Dmitry Safonov
Impact: cleanup

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Andy Lutomirski 
Cc: Oleg Nesterov 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux...@kvack.org 
Signed-off-by: Dmitry Safonov 
---
 arch/powerpc/kernel/vdso.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 4ffb82a2d9e9..278b9aa25a1c 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -309,7 +309,6 @@ static unsigned long __init find_function32(struct 
lib32_elfinfo *lib,
 }
 
 static int __init vdso_do_func_patch32(struct lib32_elfinfo *v32,
-  struct lib64_elfinfo *v64,
   const char *orig, const char *fix)
 {
Elf32_Sym *sym32_gen, *sym32_fix;
@@ -344,7 +343,6 @@ static unsigned long __init find_function32(struct 
lib32_elfinfo *lib,
 }
 
 static int __init vdso_do_func_patch32(struct lib32_elfinfo *v32,
-  struct lib64_elfinfo *v64,
   const char *orig, const char *fix)
 {
return 0;
@@ -419,8 +417,7 @@ static unsigned long __init find_function64(struct 
lib64_elfinfo *lib,
 #endif
 }
 
-static int __init vdso_do_func_patch64(struct lib32_elfinfo *v32,
-  struct lib64_elfinfo *v64,
+static int __init vdso_do_func_patch64(struct lib64_elfinfo *v64,
   const char *orig, const char *fix)
 {
Elf64_Sym *sym64_gen, *sym64_fix;
@@ -619,11 +616,9 @@ static __init int vdso_fixup_alt_funcs(struct 
lib32_elfinfo *v32,
 * It would be easy to do, but doesn't seem to be necessary,
 * patching the OPD symbol is enough.
 */
-   vdso_do_func_patch32(v32, v64, patch->gen_name,
-patch->fix_name);
+   vdso_do_func_patch32(v32, patch->gen_name, patch->fix_name);
 #ifdef CONFIG_PPC64
-   vdso_do_func_patch64(v32, v64, patch->gen_name,
-patch->fix_name);
+   vdso_do_func_patch64(v64, patch->gen_name, patch->fix_name);
 #endif /* CONFIG_PPC64 */
}
 
-- 
2.10.0



[RFC 2/2] mmc: sdhci: Use sdhci-caps-mask and sdhci-caps to change the caps read during __sdhci_read_caps

2016-10-25 Thread Zach Brown
The sdhci capabilities registers can be incorrect. The sdhci-caps-mask
and sdhci-caps dt properties specify which bits of the registers are
incorrect and what their values should be. This patch makes the sdhci
driver use those properties to correct the caps during
__sdhci_read_caps.

During __sdhci_read_caps
Use the sdhci-caps-mask property to turn off the incorrect bits of the
sdhci registers after reading them.
Use the sdhci-caps to turn on bits after using sdhci-caps-mask to turn
off the incorrect ones.

Signed-off-by: Zach Brown 
---
 drivers/mmc/host/sdhci.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 1e25b01..d5feae4 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -2991,6 +2992,8 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
 void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 
*caps1)
 {
u16 v;
+   u64 dt_caps_mask = 0;
+   u64 dt_caps = 0;
 
if (host->read_caps)
return;
@@ -3005,18 +3008,35 @@ void __sdhci_read_caps(struct sdhci_host *host, u16 
*ver, u32 *caps, u32 *caps1)
 
sdhci_do_reset(host, SDHCI_RESET_ALL);
 
+   of_property_read_u64(mmc_dev(host->mmc)->of_node,
+"sdhci-caps-mask", _caps_mask);
+   of_property_read_u64(mmc_dev(host->mmc)->of_node,
+"sdhci-caps", _caps);
+
v = ver ? *ver : sdhci_readw(host, SDHCI_HOST_VERSION);
host->version = (v & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT;
 
if (host->quirks & SDHCI_QUIRK_MISSING_CAPS)
return;
 
-   host->caps = caps ? *caps : sdhci_readl(host, SDHCI_CAPABILITIES);
+   if (caps)
+   host->caps = *caps;
+   else {
+   host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+   host->caps &= ~lower_32_bits(dt_caps_mask);
+   host->caps |= lower_32_bits(dt_caps);
+   }
 
if (host->version < SDHCI_SPEC_300)
return;
 
-   host->caps1 = caps1 ? *caps1 : sdhci_readl(host, SDHCI_CAPABILITIES_1);
+   if (caps1)
+   host->caps1 = *caps1;
+   else {
+   host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
+   host->caps1 &= ~upper_32_bits(dt_caps_mask);
+   host->caps1 |= upper_32_bits(dt_caps);
+   }
 }
 EXPORT_SYMBOL_GPL(__sdhci_read_caps);
 
-- 
2.7.4



[RFC 0/2] mmc: sdhci: Fix sdhci caps register bits with corrections provided by dt

2016-10-25 Thread Zach Brown
For various reasons the sdhci caps register can be incorrect. This patch set
introduces a general way to correct the bits when they are read to accurately
reflect the capabilties of the controller/board combo.

The first patch creates sdhci-caps and sdhci-caps-mask dt properties that
combined represent the correction to the sdhci caps register.

The second patch uses the new dt properties to correct the caps from the
register as they read during __sdhci_read_caps.

Zach Brown (2):
  mmc: sdhci: dt: Add device tree properties sdhci-caps and sdhci-caps-mask
  mmc: sdhci: Use sdhci-caps-mask and sdhci-caps to change the caps read
during __sdhci_read_caps

 Documentation/devicetree/bindings/mmc/mmc.txt |  7 +++
 drivers/mmc/host/sdhci.c  | 24 ++--
 2 files changed, 29 insertions(+), 2 deletions(-)

--
2.7.4



[RFC 1/2] mmc: sdhci: dt: Add device tree properties sdhci-caps and sdhci-caps-mask

2016-10-25 Thread Zach Brown
On some systems the sdhci capabilty registers are incorrect for one
reason or another.

The sdhci-caps-mask property specifies which bits in the registers
are incorrect and should be turned off before using sdhci-caps to turn
on bits.

The sdhci-caps property specifies which bits should be turned on.

Signed-off-by: Zach Brown 
---
 Documentation/devicetree/bindings/mmc/mmc.txt | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt 
b/Documentation/devicetree/bindings/mmc/mmc.txt
index 8a37782..1415aa0 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -52,6 +52,13 @@ Optional properties:
 - no-sdio: controller is limited to send sdio cmd during initialization
 - no-sd: controller is limited to send sd cmd during initialization
 - no-mmc: controller is limited to send mmc cmd during initialization
+- sdhci-caps-mask: The sdhci capabilities registers are incorrect. This 64bit
+  property corresponds to the bits in the sdhci capabilty registers. If the bit
+  is on in the mask then the bit is incorrect in the registers and should be
+  turned off.
+- sdhci-caps: The sdhci capabilities registers are incorrect. This 64bit
+  property corresponds to the bits in the sdhci capability registers. If the
+  bit is on in the property then the bit should be on in the reigsters.
 
 *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers 
line
 polarity properties, we have to fix the meaning of the "normal" and "inverted"
-- 
2.7.4



Re: [PATCH] virtio-net: Update the mtu code to match virtio spec

2016-10-25 Thread Aaron Conole
> From: Aaron Conole 
>
> The virtio committee recently ratified a change, VIRTIO-152, which
> defines the mtu field to be 'max' MTU, not simply desired MTU.
>
> This commit brings the virtio-net device in compliance with VIRTIO-152.
>
> Additionally, drop the max_mtu branch - it cannot be taken since the u16
> returned by virtio_cread16 will never exceed the initial value of
> max_mtu.
>
> Cc: "Michael S. Tsirkin" 
> Cc: Jarod Wilson 
> Signed-off-by: Aaron Conole 
> ---

Sorry about the subject line, David.  This is targetted at net-next, and
it appears my from was mangled.  Would you like me to resubmit with
these details corrected?

-Aaron


[PATCH v2 1/1] remoteproc: Add support for xo clock

2016-10-25 Thread Sarangdhar Joshi
Add xo clock support required to boot up Qualcomm ADSP processor.
The ADSP remoteproc driver keeps xo clock enabled until the
driver receives "handover" irq, in order to allow ADSP processor
to vote for xo clock with rpm.

Signed-off-by: Sarangdhar Joshi 
---
 drivers/remoteproc/qcom_adsp_pil.c | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/qcom_adsp_pil.c 
b/drivers/remoteproc/qcom_adsp_pil.c
index 9141633..5bb25d1 100644
--- a/drivers/remoteproc/qcom_adsp_pil.c
+++ b/drivers/remoteproc/qcom_adsp_pil.c
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -48,6 +49,8 @@ struct qcom_adsp {
struct qcom_smem_state *state;
unsigned stop_bit;
 
+   struct clk *xo;
+
struct regulator *cx_supply;
 
struct completion start_done;
@@ -102,10 +105,14 @@ static int adsp_start(struct rproc *rproc)
struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
int ret;
 
-   ret = regulator_enable(adsp->cx_supply);
+   ret = clk_prepare_enable(adsp->xo);
if (ret)
return ret;
 
+   ret = regulator_enable(adsp->cx_supply);
+   if (ret)
+   goto disable_clocks;
+
ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID);
if (ret) {
dev_err(adsp->dev,
@@ -126,6 +133,8 @@ static int adsp_start(struct rproc *rproc)
 
 disable_regulators:
regulator_disable(adsp->cx_supply);
+disable_clocks:
+   clk_disable_unprepare(adsp->xo);
 
return ret;
 }
@@ -223,6 +232,21 @@ static irqreturn_t adsp_stop_ack_interrupt(int irq, void 
*dev)
return IRQ_HANDLED;
 }
 
+static int adsp_init_clock(struct qcom_adsp *adsp)
+{
+   int ret;
+
+   adsp->xo = devm_clk_get(adsp->dev, "xo");
+   if (IS_ERR(adsp->xo)) {
+   ret = PTR_ERR(adsp->xo);
+   if (ret != -EPROBE_DEFER)
+   dev_err(adsp->dev, "failed to get xo clock");
+   return ret;
+   }
+
+   return 0;
+}
+
 static int adsp_init_regulator(struct qcom_adsp *adsp)
 {
adsp->cx_supply = devm_regulator_get(adsp->dev, "cx");
@@ -320,6 +344,10 @@ static int adsp_probe(struct platform_device *pdev)
if (ret)
goto free_rproc;
 
+   ret = adsp_init_clock(adsp);
+   if (ret)
+   goto free_rproc;
+
ret = adsp_init_regulator(adsp);
if (ret)
goto free_rproc;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[v4.9 PATCH] spi: fsl-espi: avoid processing uninitalized data on error

2016-10-25 Thread Arnd Bergmann
When we get a spurious interrupt in fsl_espi_irq, we end up
processing four uninitalized bytes of data, as shown in this
warning message:

   drivers/spi/spi-fsl-espi.c: In function 'fsl_espi_irq':
   drivers/spi/spi-fsl-espi.c:462:4: warning: 'rx_data' may be used 
uninitialized in this function [-Wmaybe-uninitialized]

This adds another check so we skip the data in this case.

Fixes: 6319a68011b8 ("spi/fsl-espi: avoid infinite loops on fsl_espi_cpu_irq()")
Cc: sta...@vger.kernel.org
Signed-off-by: Arnd Bergmann 
---
 drivers/spi/spi-fsl-espi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

This is a bugfix that we should get into v4.9. It conflicts with
a rework of that function that is currently scheduled in spi-next
for v4.10, but is also required there in some form.

I suppose we also want this backported to -stable, as we also get
the warning in older kernels, and the patch that introduced
the condition apparently address to fix the hardware problem
that would now lead to incorrect data instead of an infinite loop.

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 7451585..2c175b9 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -458,7 +458,7 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 
events)
 
mspi->len -= rx_nr_bytes;
 
-   if (mspi->rx)
+   if (rx_nr_bytes && mspi->rx)
mspi->get_rx(rx_data, mspi);
}
 
-- 
2.9.0



Re: [PATCH 17/28] spi: fsl-espi: avoid processing uninitalized data on error

2016-10-25 Thread Arnd Bergmann
On Tuesday, October 25, 2016 8:13:09 PM CEST Mark Brown wrote:
> 
> Not enough information to check signature validity.   Show Details
> On Mon, Oct 24, 2016 at 10:37:53PM +0200, Arnd Bergmann wrote:
> 
> > I think my patch (the version I sent) should ideally make it into
> > v4.9 as a bugfix. This was the powerpc warning I saw from Olof's
> > autobuilder with the -Wmaybe-uninitialized warning added back, and
> > it's one of the actual bugs I found (though rather unlikely
> > to hit in practice).
> 
> > Merging with Heiner's patches should be trivial, and I'm pretty
> > sure we want the patch either way. Not sure if we need a backport,
> > it was introduced earlier this year in commit 6319a68011b8
> > ("spi/fsl-espi: avoid infinite loops on fsl_espi_cpu_irq()") as
> > I now found.
> 
> Sorry but I've lost track of which patches are being talked about here.
> If there's stuff for v4.9 can you send me a version that applies on
> Linus' tree and I'll merge that up into what's applied for -next?
> 

Done.

Arnd



Re: [PATCH V2 0/8] PM / OPP: Multiple regulator support

2016-10-25 Thread Dave Gerlach

Hi,
On 10/23/2016 11:26 PM, Viresh Kumar wrote:

On 23-10-16, 20:08, Dave Gerlach wrote:

Overall this series looks good to me apart from a few small things. Most
importantly I was able to get a working implementation using two regulators
on ti dra7xx platform with proper sequencing built on top of this series. We
have cpu regulator and Adaptive body bias (abb) regulator that must be
scaled in a certain order before or after clock scaling and I was able to
implement a rough custom set_rate to perform this and ran some dvfs stress
tests that all worked fine.


Thanks for testing it buddy.


First comment, I think the platform specific set_rate is a good place to
hook in for adaptive voltage scaling as well. I was able to implement TI
Class0 AVS in the same code by using the requested transition voltage as a
reference and programming AVS voltage using that, along with scaling the
additional regulators in sequence (the original multi regulator
functionality).


Hmm, interesting..


I would think some people would want to use this even with
single regulator platforms, no?


Maybe, but I would like to see such user code first. It may be possible to
handle much of AVS stuff in core so that everyone isn't required to do it.


Ok, I think it would be a logical next step to look at once this series 
gets accepted. For now, the particular implementation I did just looks 
up an optimized value for the requested voltage from a register and 
programs the optimal value instead of the requested voltage.





This raises some concerns about dependencies/probe sequencing. Right now we
just need to make sure the cpufreq-dt driver probes after we have called
_set_regulators, but if our platform code fails cpufreq-dt currently will
treat this as no regulator needed for the platform and operate without one,
which will likely hang the system. Is there a good way to to guarantee this
doesn't happen? My main concern is that if we plan to provide a platform
specific set-rate function, we should have a way to indicate this and
prevent things from progressing if it isn't yet ready.

Again, overall I think it solves the multi regulator problem, and it works
well for AVS as well. For the series:

Tested-by: Dave Gerlach 


Thanks.

For the concern you shared about, does the below patch fix it ? I will include
that in V3 then.


I think what you have shared below is a good safety check but if I 
rename the regulator properties in the DT for the cpu (to vdd and vbb, 
meaning cpufreq detects no regulator) and do *not* call 
dev_pm_opp_set_regulators before cpufreq-dt probes we fail before we 
even get to that point:


[16.946] cpu cpu0: opp_parse_supplies: Invalid number of elements in 
opp-microvolt property (6) with supplies (1)

[16.967] cpu cpu0: _of_add_opp_table_v2: Failed to add OPP, -22
[16.982] cpu cpu0: dev_pm_opp_get_opp_count: OPP table not found (-19)
[16.982] cpu cpu0: OPP table is not ready, deferring probe

This failure is because opp_parse_supplies assumes a count of 1 
regulator if no regulators at all are present and then hard fails if too 
many voltages have been passed for each OPP. It seems we need a check 
much earlier similar to what you suggested below to allow us to defer if 
an OPP has supplied voltages but no regulator has been registered with 
the system. I think this is reasonable even for the 1 regulator case, 
no? If we have passed voltages then we presumably are hoping to use them 
with a regulator, and if no regulators are present, OPP framework should 
defer.


cpufreq-dt won't handle this properly as is, but now that the opp core 
is evolving perhaps it makes sense to modify the resources_available 
check slightly to rely on the OPP core rather than just a dummy 
regulator_get_optional to see if the regulator is ready.


Regards,
Dave



-8<-

From: Viresh Kumar 
Date: Mon, 24 Oct 2016 09:45:30 +0530
Subject: [PATCH] PM / OPP: Don't assume platform doesn't have regulators

If the regulators aren't set explicitly by the platform, the OPP core
assumes that the platform doesn't have any regulator and uses the
clk-only callback.

If the platform failed to register a regulator with the core, then this
can turn out to be a dangerous assumption as the OPP core will try to
change clk without changing regulators.

Handle that properly by making sure that the DT didn't had any entries
for supply voltages as well.

Signed-off-by: Viresh Kumar 
---
 drivers/base/power/opp/core.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index b69908b74ed6..fb4250532180 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -737,7 +737,17 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long 
target_freq)

/* Only frequency scaling */
if (!regulators) {
-  

[net-next PATCH 13/27] arch/microblaze: Add option to skip DMA sync as a part of map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: Michal Simek 
Signed-off-by: Alexander Duyck 
---
 arch/microblaze/kernel/dma.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
index ec04dc1..818daf2 100644
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/microblaze/kernel/dma.c
@@ -61,6 +61,10 @@ static int dma_direct_map_sg(struct device *dev, struct 
scatterlist *sgl,
/* FIXME this part of code is untested */
for_each_sg(sgl, sg, nents, i) {
sg->dma_address = sg_phys(sg);
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
__dma_sync(page_to_phys(sg_page(sg)) + sg->offset,
sg->length, direction);
}
@@ -80,7 +84,8 @@ static inline dma_addr_t dma_direct_map_page(struct device 
*dev,
 enum dma_data_direction direction,
 unsigned long attrs)
 {
-   __dma_sync(page_to_phys(page) + offset, size, direction);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   __dma_sync(page_to_phys(page) + offset, size, direction);
return page_to_phys(page) + offset;
 }
 
@@ -95,7 +100,8 @@ static inline void dma_direct_unmap_page(struct device *dev,
  * phys_to_virt is here because in __dma_sync_page is __virt_to_phys and
  * dma_address is physical address
  */
-   __dma_sync(dma_address, size, direction);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   __dma_sync(dma_address, size, direction);
 }
 
 static inline void



[net-next PATCH 19/27] arch/sh: Add option to skip DMA sync as a part of mapping

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: linux...@vger.kernel.org
Signed-off-by: Alexander Duyck 
---
 arch/sh/kernel/dma-nommu.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/sh/kernel/dma-nommu.c b/arch/sh/kernel/dma-nommu.c
index eadb669..47fee3b 100644
--- a/arch/sh/kernel/dma-nommu.c
+++ b/arch/sh/kernel/dma-nommu.c
@@ -18,7 +18,9 @@ static dma_addr_t nommu_map_page(struct device *dev, struct 
page *page,
dma_addr_t addr = page_to_phys(page) + offset;
 
WARN_ON(size == 0);
-   dma_cache_sync(dev, page_address(page) + offset, size, dir);
+
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   dma_cache_sync(dev, page_address(page) + offset, size, dir);
 
return addr;
 }
@@ -35,7 +37,8 @@ static int nommu_map_sg(struct device *dev, struct 
scatterlist *sg,
for_each_sg(sg, s, nents, i) {
BUG_ON(!sg_page(s));
 
-   dma_cache_sync(dev, sg_virt(s), s->length, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   dma_cache_sync(dev, sg_virt(s), s->length, dir);
 
s->dma_address = sg_phys(s);
s->dma_length = s->length;



[net-next PATCH 23/27] dma: Add calls for dma_map_page_attrs and dma_unmap_page_attrs

2016-10-25 Thread Alexander Duyck
Add support for mapping and unmapping a page with attributes.  The primary
use for this is currently to allow for us to pass the
DMA_ATTR_SKIP_CPU_SYNC attribute when mapping and unmapping a page.  On
some architectures such as ARM the synchronization has significant overhead
and if we are already taking care of the sync_for_cpu and sync_for_device
from the driver there isn't much need to handle this in the map/unmap calls
as well.

Signed-off-by: Alexander Duyck 
---
 include/linux/dma-mapping.h |   20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 08528af..10c5a17 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -243,29 +243,33 @@ static inline void dma_unmap_sg_attrs(struct device *dev, 
struct scatterlist *sg
ops->unmap_sg(dev, sg, nents, dir, attrs);
 }
 
-static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
- size_t offset, size_t size,
- enum dma_data_direction dir)
+static inline dma_addr_t dma_map_page_attrs(struct device *dev,
+   struct page *page,
+   size_t offset, size_t size,
+   enum dma_data_direction dir,
+   unsigned long attrs)
 {
struct dma_map_ops *ops = get_dma_ops(dev);
dma_addr_t addr;
 
kmemcheck_mark_initialized(page_address(page) + offset, size);
BUG_ON(!valid_dma_direction(dir));
-   addr = ops->map_page(dev, page, offset, size, dir, 0);
+   addr = ops->map_page(dev, page, offset, size, dir, attrs);
debug_dma_map_page(dev, page, offset, size, dir, addr, false);
 
return addr;
 }
 
-static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
- size_t size, enum dma_data_direction dir)
+static inline void dma_unmap_page_attrs(struct device *dev,
+   dma_addr_t addr, size_t size,
+   enum dma_data_direction dir,
+   unsigned long attrs)
 {
struct dma_map_ops *ops = get_dma_ops(dev);
 
BUG_ON(!valid_dma_direction(dir));
if (ops->unmap_page)
-   ops->unmap_page(dev, addr, size, dir, 0);
+   ops->unmap_page(dev, addr, size, dir, attrs);
debug_dma_unmap_page(dev, addr, size, dir, false);
 }
 
@@ -385,6 +389,8 @@ static inline void dma_sync_single_range_for_device(struct 
device *dev,
 #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
 #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, 0)
 #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, 0)
+#define dma_map_page(d, p, o, s, r) dma_map_page_attrs(d, p, o, s, r, 0)
+#define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, 0)
 
 extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
   void *cpu_addr, dma_addr_t dma_addr, size_t size);



[net-next PATCH 20/27] arch/sparc: Add option to skip DMA sync as a part of map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: "David S. Miller" 
Cc: sparcli...@vger.kernel.org
Signed-off-by: Alexander Duyck 
---
 arch/sparc/kernel/iommu.c  |4 ++--
 arch/sparc/kernel/ioport.c |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 5c615ab..8fda4e4 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -415,7 +415,7 @@ static void dma_4u_unmap_page(struct device *dev, 
dma_addr_t bus_addr,
ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL;
 
/* Step 1: Kick data out of streaming buffers if necessary. */
-   if (strbuf->strbuf_enabled)
+   if (strbuf->strbuf_enabled && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
strbuf_flush(strbuf, iommu, bus_addr, ctx,
 npages, direction);
 
@@ -640,7 +640,7 @@ static void dma_4u_unmap_sg(struct device *dev, struct 
scatterlist *sglist,
base = iommu->page_table + entry;
 
dma_handle &= IO_PAGE_MASK;
-   if (strbuf->strbuf_enabled)
+   if (strbuf->strbuf_enabled && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
strbuf_flush(strbuf, iommu, dma_handle, ctx,
 npages, direction);
 
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 2344103..6ffaec4 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -527,7 +527,7 @@ static dma_addr_t pci32_map_page(struct device *dev, struct 
page *page,
 static void pci32_unmap_page(struct device *dev, dma_addr_t ba, size_t size,
 enum dma_data_direction dir, unsigned long attrs)
 {
-   if (dir != PCI_DMA_TODEVICE)
+   if (dir != PCI_DMA_TODEVICE && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
dma_make_coherent(ba, PAGE_ALIGN(size));
 }
 
@@ -572,7 +572,7 @@ static void pci32_unmap_sg(struct device *dev, struct 
scatterlist *sgl,
struct scatterlist *sg;
int n;
 
-   if (dir != PCI_DMA_TODEVICE) {
+   if (dir != PCI_DMA_TODEVICE && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
for_each_sg(sgl, sg, nents, n) {
dma_make_coherent(sg_phys(sg), PAGE_ALIGN(sg->length));
}



[net-next PATCH 21/27] arch/tile: Add option to skip DMA sync as a part of map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: Chris Metcalf 
Signed-off-by: Alexander Duyck 
---
 arch/tile/kernel/pci-dma.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/tile/kernel/pci-dma.c b/arch/tile/kernel/pci-dma.c
index 09bb774..24e0f8c 100644
--- a/arch/tile/kernel/pci-dma.c
+++ b/arch/tile/kernel/pci-dma.c
@@ -213,10 +213,12 @@ static int tile_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
 
for_each_sg(sglist, sg, nents, i) {
sg->dma_address = sg_phys(sg);
-   __dma_prep_pa_range(sg->dma_address, sg->length, direction);
 #ifdef CONFIG_NEED_SG_DMA_LENGTH
sg->dma_length = sg->length;
 #endif
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+   __dma_prep_pa_range(sg->dma_address, sg->length, direction);
}
 
return nents;
@@ -232,6 +234,8 @@ static void tile_dma_unmap_sg(struct device *dev, struct 
scatterlist *sglist,
BUG_ON(!valid_dma_direction(direction));
for_each_sg(sglist, sg, nents, i) {
sg->dma_address = sg_phys(sg);
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
__dma_complete_pa_range(sg->dma_address, sg->length,
direction);
}
@@ -245,7 +249,8 @@ static dma_addr_t tile_dma_map_page(struct device *dev, 
struct page *page,
BUG_ON(!valid_dma_direction(direction));
 
BUG_ON(offset + size > PAGE_SIZE);
-   __dma_prep_page(page, offset, size, direction);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   __dma_prep_page(page, offset, size, direction);
 
return page_to_pa(page) + offset;
 }
@@ -256,6 +261,9 @@ static void tile_dma_unmap_page(struct device *dev, 
dma_addr_t dma_address,
 {
BUG_ON(!valid_dma_direction(direction));
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return;
+
__dma_complete_page(pfn_to_page(PFN_DOWN(dma_address)),
dma_address & (PAGE_SIZE - 1), size, direction);
 }



[net-next PATCH 27/27] igb: Revert "igb: Revert support for build_skb in igb"

2016-10-25 Thread Alexander Duyck
This reverts commit f9d40f6a9921 ("igb: Revert support for build_skb in
igb") and adds a few changes to update it to work with the latest version
of igb. We are now able to revert the removal of this due to the fact
that with the recent changes to the page count and the use of
DMA_ATTR_SKIP_CPU_SYNC we can make the pages writable so we should not be
invalidating the additional data added when we call build_skb.

The biggest risk with this change is that we are now not able to support
full jumbo frames when using build_skb.  Instead we can only support up to
2K minus the skb overhead and padding offset.

Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/intel/igb/igb.h  |   29 ++
 drivers/net/ethernet/intel/igb/igb_main.c |  130 ++---
 2 files changed, 142 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb.h 
b/drivers/net/ethernet/intel/igb/igb.h
index acbc3ab..c3420f3 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -145,6 +145,10 @@ struct vf_data_storage {
 #define IGB_RX_HDR_LEN IGB_RXBUFFER_256
 #define IGB_RX_BUFSZ   IGB_RXBUFFER_2048
 
+#define IGB_SKB_PAD(NET_SKB_PAD + NET_IP_ALIGN)
+#define IGB_MAX_BUILD_SKB_SIZE \
+   (SKB_WITH_OVERHEAD(IGB_RX_BUFSZ) - (IGB_SKB_PAD + IGB_TS_HDR_LEN))
+
 /* How many Rx Buffers do we bundle into one write to the hardware ? */
 #define IGB_RX_BUFFER_WRITE16 /* Must be power of 2 */
 
@@ -301,12 +305,29 @@ struct igb_q_vector {
 };
 
 enum e1000_ring_flags_t {
-   IGB_RING_FLAG_RX_SCTP_CSUM,
-   IGB_RING_FLAG_RX_LB_VLAN_BSWAP,
-   IGB_RING_FLAG_TX_CTX_IDX,
-   IGB_RING_FLAG_TX_DETECT_HANG
+   IGB_RING_FLAG_RX_SCTP_CSUM = 0,
+#if (NET_IP_ALIGN != 0)
+   IGB_RING_FLAG_RX_BUILD_SKB_ENABLED = 1,
+#endif
+   IGB_RING_FLAG_RX_LB_VLAN_BSWAP = 2,
+   IGB_RING_FLAG_TX_CTX_IDX = 3,
+   IGB_RING_FLAG_TX_DETECT_HANG = 4,
+#if (NET_IP_ALIGN == 0)
+#if (L1_CACHE_SHIFT < 5)
+   IGB_RING_FLAG_RX_BUILD_SKB_ENABLED = 5,
+#else
+   IGB_RING_FLAG_RX_BUILD_SKB_ENABLED = L1_CACHE_SHIFT,
+#endif
+#endif
 };
 
+#define ring_uses_build_skb(ring) \
+   test_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
+#define set_ring_build_skb_enabled(ring) \
+   set_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
+#define clear_ring_build_skb_enabled(ring) \
+   clear_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags)
+
 #define IGB_TXD_DCMD (E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_RS)
 
 #define IGB_RX_DESC(R, i)  \
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 5e66cde..e55407a 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3761,6 +3761,16 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
wr32(E1000_RXDCTL(reg_idx), rxdctl);
 }
 
+static void igb_set_rx_buffer_len(struct igb_adapter *adapter,
+ struct igb_ring *rx_ring)
+{
+   /* set build_skb flag */
+   if (adapter->max_frame_size <= IGB_MAX_BUILD_SKB_SIZE)
+   set_ring_build_skb_enabled(rx_ring);
+   else
+   clear_ring_build_skb_enabled(rx_ring);
+}
+
 /**
  *  igb_configure_rx - Configure receive Unit after Reset
  *  @adapter: board private structure
@@ -3778,8 +3788,12 @@ static void igb_configure_rx(struct igb_adapter *adapter)
/* Setup the HW Rx Head and Tail Descriptor Pointers and
 * the Base and Length of the Rx Descriptor Ring
 */
-   for (i = 0; i < adapter->num_rx_queues; i++)
-   igb_configure_rx_ring(adapter, adapter->rx_ring[i]);
+   for (i = 0; i < adapter->num_rx_queues; i++) {
+   struct igb_ring *rx_ring = adapter->rx_ring[i];
+
+   igb_set_rx_buffer_len(adapter, rx_ring);
+   igb_configure_rx_ring(adapter, rx_ring);
+   }
 }
 
 /**
@@ -4238,7 +4252,7 @@ static void igb_set_rx_mode(struct net_device *netdev)
struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = >hw;
unsigned int vfn = adapter->vfs_allocated_count;
-   u32 rctl = 0, vmolr = 0;
+   u32 rctl = 0, vmolr = 0, rlpml = MAX_JUMBO_FRAME_SIZE;
int count;
 
/* Check for Promiscuous and All Multicast modes */
@@ -4310,12 +4324,18 @@ static void igb_set_rx_mode(struct net_device *netdev)
vmolr |= rd32(E1000_VMOLR(vfn)) &
 ~(E1000_VMOLR_ROPE | E1000_VMOLR_MPME | E1000_VMOLR_ROMPE);
 
-   /* enable Rx jumbo frames, no need for restriction */
+   /* enable Rx jumbo frames, restrict as needed to support build_skb */
vmolr &= ~E1000_VMOLR_RLPML_MASK;
-   vmolr |= MAX_JUMBO_FRAME_SIZE | E1000_VMOLR_LPE;
+   vmolr |= E1000_VMOLR_LPE;
+   vmolr |= (adapter->max_frame_size <= IGB_MAX_BUILD_SKB_SIZE) ?
+

[net-next PATCH 18/27] arch/powerpc: Add option to skip DMA sync as a part of mapping

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: linuxppc-...@lists.ozlabs.org
Signed-off-by: Alexander Duyck 
---
 arch/powerpc/kernel/dma.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index e64a601..6877e3f 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -203,6 +203,10 @@ static int dma_direct_map_sg(struct device *dev, struct 
scatterlist *sgl,
for_each_sg(sgl, sg, nents, i) {
sg->dma_address = sg_phys(sg) + get_dma_offset(dev);
sg->dma_length = sg->length;
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
}
 
@@ -235,7 +239,10 @@ static inline dma_addr_t dma_direct_map_page(struct device 
*dev,
 unsigned long attrs)
 {
BUG_ON(dir == DMA_NONE);
-   __dma_sync_page(page, offset, size, dir);
+
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   __dma_sync_page(page, offset, size, dir);
+
return page_to_phys(page) + offset + get_dma_offset(dev);
 }
 



[net-next PATCH 25/27] igb: Update driver to make use of DMA_ATTR_SKIP_CPU_SYNC

2016-10-25 Thread Alexander Duyck
The ARM architecture provides a mechanism for deferring cache line
invalidation in the case of map/unmap.  This patch makes use of this
mechanism to avoid unnecessary synchronization.

A secondary effect of this change is that the portion of the page that has
been synchronized for use by the CPU should be writable and could be passed
up the stack (at least on ARM).

The last bit that occurred to me is that on architectures where the
sync_for_cpu call invalidates cache lines we were prefetching and then
invalidating the first 128 bytes of the packet.  To avoid that I have moved
the sync up to before we perform the prefetch and allocate the skbuff so
that we can actually make use of it.

Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/intel/igb/igb_main.c |   53 ++---
 1 file changed, 33 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 4feca69..c8c458c 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3947,10 +3947,21 @@ static void igb_clean_rx_ring(struct igb_ring *rx_ring)
if (!buffer_info->page)
continue;
 
-   dma_unmap_page(rx_ring->dev,
-  buffer_info->dma,
-  PAGE_SIZE,
-  DMA_FROM_DEVICE);
+   /* Invalidate cache lines that may have been written to by
+* device so that we avoid corrupting memory.
+*/
+   dma_sync_single_range_for_cpu(rx_ring->dev,
+ buffer_info->dma,
+ buffer_info->page_offset,
+ IGB_RX_BUFSZ,
+ DMA_FROM_DEVICE);
+
+   /* free resources associated with mapping */
+   dma_unmap_page_attrs(rx_ring->dev,
+buffer_info->dma,
+PAGE_SIZE,
+DMA_FROM_DEVICE,
+DMA_ATTR_SKIP_CPU_SYNC);
__free_page(buffer_info->page);
 
buffer_info->page = NULL;
@@ -6808,12 +6819,6 @@ static void igb_reuse_rx_page(struct igb_ring *rx_ring,
 
/* transfer page from old buffer to new buffer */
*new_buff = *old_buff;
-
-   /* sync the buffer for use by the device */
-   dma_sync_single_range_for_device(rx_ring->dev, old_buff->dma,
-old_buff->page_offset,
-IGB_RX_BUFSZ,
-DMA_FROM_DEVICE);
 }
 
 static inline bool igb_page_is_reserved(struct page *page)
@@ -6934,6 +6939,13 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
igb_ring *rx_ring,
page = rx_buffer->page;
prefetchw(page);
 
+   /* we are reusing so sync this buffer for CPU use */
+   dma_sync_single_range_for_cpu(rx_ring->dev,
+ rx_buffer->dma,
+ rx_buffer->page_offset,
+ size,
+ DMA_FROM_DEVICE);
+
if (likely(!skb)) {
void *page_addr = page_address(page) +
  rx_buffer->page_offset;
@@ -6958,21 +6970,15 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
igb_ring *rx_ring,
prefetchw(skb->data);
}
 
-   /* we are reusing so sync this buffer for CPU use */
-   dma_sync_single_range_for_cpu(rx_ring->dev,
- rx_buffer->dma,
- rx_buffer->page_offset,
- size,
- DMA_FROM_DEVICE);
-
/* pull page into skb */
if (igb_add_rx_frag(rx_ring, rx_buffer, size, rx_desc, skb)) {
/* hand second half of page back to the ring */
igb_reuse_rx_page(rx_ring, rx_buffer);
} else {
/* we are not reusing the buffer so unmap it */
-   dma_unmap_page(rx_ring->dev, rx_buffer->dma,
-  PAGE_SIZE, DMA_FROM_DEVICE);
+   dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma,
+PAGE_SIZE, DMA_FROM_DEVICE,
+DMA_ATTR_SKIP_CPU_SYNC);
}
 
/* clear contents of rx_buffer */
@@ -7230,7 +7236,8 @@ static bool igb_alloc_mapped_page(struct igb_ring 
*rx_ring,
}
 
/* map page for use */
-   dma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);
+   dma = dma_map_page_attrs(rx_ring->dev, page, 0, PAGE_SIZE,
+DMA_FROM_DEVICE, 

[net-next PATCH 26/27] igb: Update code to better handle incrementing page count

2016-10-25 Thread Alexander Duyck
This patch updates the driver code so that we do bulk updates of the page
reference count instead of just incrementing it by one reference at a time.
The advantage to doing this is that we cut down on atomic operations and
this in turn should give us a slight improvement in cycles per packet.  In
addition if we eventually move this over to using build_skb the gains will
be more noticeable.

Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/intel/igb/igb.h  |7 ++-
 drivers/net/ethernet/intel/igb/igb_main.c |   24 +---
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb.h 
b/drivers/net/ethernet/intel/igb/igb.h
index d11093d..acbc3ab 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -210,7 +210,12 @@ struct igb_tx_buffer {
 struct igb_rx_buffer {
dma_addr_t dma;
struct page *page;
-   unsigned int page_offset;
+#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
+   __u32 page_offset;
+#else
+   __u16 page_offset;
+#endif
+   __u16 pagecnt_bias;
 };
 
 struct igb_tx_queue_stats {
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index c8c458c..5e66cde 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3962,7 +3962,8 @@ static void igb_clean_rx_ring(struct igb_ring *rx_ring)
 PAGE_SIZE,
 DMA_FROM_DEVICE,
 DMA_ATTR_SKIP_CPU_SYNC);
-   __free_page(buffer_info->page);
+   __page_frag_drain(buffer_info->page, 0,
+ buffer_info->pagecnt_bias);
 
buffer_info->page = NULL;
}
@@ -6830,13 +6831,15 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer 
*rx_buffer,
  struct page *page,
  unsigned int truesize)
 {
+   unsigned int pagecnt_bias = rx_buffer->pagecnt_bias--;
+
/* avoid re-using remote pages */
if (unlikely(igb_page_is_reserved(page)))
return false;
 
 #if (PAGE_SIZE < 8192)
/* if we are only owner of page we can reuse it */
-   if (unlikely(page_count(page) != 1))
+   if (unlikely(page_ref_count(page) != pagecnt_bias))
return false;
 
/* flip page offset to other buffer */
@@ -6849,10 +6852,14 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer 
*rx_buffer,
return false;
 #endif
 
-   /* Even if we own the page, we are not allowed to use atomic_set()
-* This would break get_page_unless_zero() users.
+   /* If we have drained the page fragment pool we need to update
+* the pagecnt_bias and page count so that we fully restock the
+* number of references the driver holds.
 */
-   page_ref_inc(page);
+   if (unlikely(pagecnt_bias == 1)) {
+   page_ref_add(page, USHRT_MAX);
+   rx_buffer->pagecnt_bias = USHRT_MAX;
+   }
 
return true;
 }
@@ -6904,7 +6911,6 @@ static bool igb_add_rx_frag(struct igb_ring *rx_ring,
return true;
 
/* this page cannot be reused so discard it */
-   __free_page(page);
return false;
}
 
@@ -6975,10 +6981,13 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
igb_ring *rx_ring,
/* hand second half of page back to the ring */
igb_reuse_rx_page(rx_ring, rx_buffer);
} else {
-   /* we are not reusing the buffer so unmap it */
+   /* We are not reusing the buffer so unmap it and free
+* any references we are holding to it
+*/
dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma,
 PAGE_SIZE, DMA_FROM_DEVICE,
 DMA_ATTR_SKIP_CPU_SYNC);
+   __page_frag_drain(page, 0, rx_buffer->pagecnt_bias);
}
 
/* clear contents of rx_buffer */
@@ -7252,6 +7261,7 @@ static bool igb_alloc_mapped_page(struct igb_ring 
*rx_ring,
bi->dma = dma;
bi->page = page;
bi->page_offset = 0;
+   bi->pagecnt_bias = 1;
 
return true;
 }



[net-next PATCH 24/27] mm: Add support for releasing multiple instances of a page

2016-10-25 Thread Alexander Duyck
This patch adds a function that allows us to batch free a page that has
multiple references outstanding.  Specifically this function can be used to
drop a page being used in the page frag alloc cache.  With this drivers can
make use of functionality similar to the page frag alloc cache without
having to do any workarounds for the fact that there is no function that
frees multiple references.

Cc: linux...@kvack.org
Signed-off-by: Alexander Duyck 
---
 include/linux/gfp.h |2 ++
 mm/page_alloc.c |   14 ++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index f8041f9de..4175dca 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -506,6 +506,8 @@ extern struct page *alloc_pages_vma(gfp_t gfp_mask, int 
order,
 extern void free_hot_cold_page_list(struct list_head *list, bool cold);
 
 struct page_frag_cache;
+extern void __page_frag_drain(struct page *page, unsigned int order,
+ unsigned int count);
 extern void *__alloc_page_frag(struct page_frag_cache *nc,
   unsigned int fragsz, gfp_t gfp_mask);
 extern void __free_page_frag(void *addr);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ca423cc..253046a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3883,6 +3883,20 @@ static struct page *__page_frag_refill(struct 
page_frag_cache *nc,
return page;
 }
 
+void __page_frag_drain(struct page *page, unsigned int order,
+  unsigned int count)
+{
+   VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
+
+   if (page_ref_sub_and_test(page, count)) {
+   if (order == 0)
+   free_hot_cold_page(page, false);
+   else
+   __free_pages_ok(page, order);
+   }
+}
+EXPORT_SYMBOL(__page_frag_drain);
+
 void *__alloc_page_frag(struct page_frag_cache *nc,
unsigned int fragsz, gfp_t gfp_mask)
 {



[net-next PATCH 14/27] arch/mips: Add option to skip DMA sync as a part of map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: Ralf Baechle 
Cc: Keguang Zhang 
Cc: linux-m...@linux-mips.org
Signed-off-by: Alexander Duyck 
---
 arch/mips/loongson64/common/dma-swiotlb.c |2 +-
 arch/mips/mm/dma-default.c|8 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/mips/loongson64/common/dma-swiotlb.c 
b/arch/mips/loongson64/common/dma-swiotlb.c
index 1a80b6f..aab4fd6 100644
--- a/arch/mips/loongson64/common/dma-swiotlb.c
+++ b/arch/mips/loongson64/common/dma-swiotlb.c
@@ -61,7 +61,7 @@ static int loongson_dma_map_sg(struct device *dev, struct 
scatterlist *sg,
int nents, enum dma_data_direction dir,
unsigned long attrs)
 {
-   int r = swiotlb_map_sg_attrs(dev, sg, nents, dir, 0);
+   int r = swiotlb_map_sg_attrs(dev, sg, nents, dir, attrs);
mb();
 
return r;
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index b2eadd6..dd998d7 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -293,7 +293,7 @@ static inline void __dma_sync(struct page *page,
 static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
size_t size, enum dma_data_direction direction, unsigned long attrs)
 {
-   if (cpu_needs_post_dma_flush(dev))
+   if (cpu_needs_post_dma_flush(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
__dma_sync(dma_addr_to_page(dev, dma_addr),
   dma_addr & ~PAGE_MASK, size, direction);
plat_post_dma_flush(dev);
@@ -307,7 +307,8 @@ static int mips_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
struct scatterlist *sg;
 
for_each_sg(sglist, sg, nents, i) {
-   if (!plat_device_is_coherent(dev))
+   if (!plat_device_is_coherent(dev) &&
+   !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
__dma_sync(sg_page(sg), sg->offset, sg->length,
   direction);
 #ifdef CONFIG_NEED_SG_DMA_LENGTH
@@ -324,7 +325,7 @@ static dma_addr_t mips_dma_map_page(struct device *dev, 
struct page *page,
unsigned long offset, size_t size, enum dma_data_direction direction,
unsigned long attrs)
 {
-   if (!plat_device_is_coherent(dev))
+   if (!plat_device_is_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
__dma_sync(page, offset, size, direction);
 
return plat_map_dma_mem_page(dev, page) + offset;
@@ -339,6 +340,7 @@ static void mips_dma_unmap_sg(struct device *dev, struct 
scatterlist *sglist,
 
for_each_sg(sglist, sg, nhwentries, i) {
if (!plat_device_is_coherent(dev) &&
+   !(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
direction != DMA_TO_DEVICE)
__dma_sync(sg_page(sg), sg->offset, sg->length,
   direction);



[PATCH v3 1/1] ahci: imx: Add imx53 SATA temperature sensor support

2016-10-25 Thread Fabien Lahoudere
From: Csaba Kertesz 

Add a hwmon entry to get the temperature from the die of imx53
SATA.

The original patch was made by Richard Zhu for kernel 2.6.x:
ENGR00134041-MX53-Add-the-SATA-AHCI-temperature-monitor.patch

Signed-off-by: Fabien Lahoudere 
---
 drivers/ata/ahci_imx.c | 195 +
 1 file changed, 195 insertions(+)

diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
index 3f3a7db..420f065 100644
--- a/drivers/ata/ahci_imx.c
+++ b/drivers/ata/ahci_imx.c
@@ -26,6 +26,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include "ahci.h"
 
 #define DRV_NAME "ahci-imx"
@@ -214,6 +217,180 @@ static int imx_sata_phy_reset(struct ahci_host_priv 
*hpriv)
return timeout ? 0 : -ETIMEDOUT;
 }
 
+enum {
+   /* SATA PHY Register */
+   SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT = 0x0001,
+   SATA_PHY_CR_CLOCK_DAC_CTL = 0x0008,
+   SATA_PHY_CR_CLOCK_RTUNE_CTL = 0x0009,
+   SATA_PHY_CR_CLOCK_ADC_OUT = 0x000A,
+   SATA_PHY_CR_CLOCK_MPLL_TST = 0x0017,
+};
+
+static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio)
+{
+   u16 adc_out_reg, read_sum;
+   u32 index, read_attempt;
+   const u32 attempt_limit = 100;
+
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio);
+   imx_phy_reg_write(rtune_ctl_reg, mmio);
+
+   /* two dummy read */
+   index = 0;
+   read_attempt = 0;
+   adc_out_reg = 0;
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_ADC_OUT, mmio);
+   while (index < 2) {
+   imx_phy_reg_read(_out_reg, mmio);
+   /* check if valid */
+   if (adc_out_reg & 0x400)
+   index++;
+
+   read_attempt++;
+   if (read_attempt > attempt_limit) {
+   dev_err(dev, "Read REG more than %d times!\n",
+   attempt_limit);
+   break;
+   }
+   }
+
+   index = 0;
+   read_attempt = 0;
+   read_sum = 0;
+   while (index < 80) {
+   imx_phy_reg_read(_out_reg, mmio);
+   if (adc_out_reg & 0x400) {
+   read_sum = read_sum + (adc_out_reg & 0x3FF);
+   index++;
+   }
+   read_attempt++;
+   if (read_attempt > attempt_limit) {
+   dev_err(dev, "Read REG more than %d times!\n",
+   attempt_limit);
+   break;
+   }
+   }
+
+   /* Use the U32 to make 1000 precision */
+   return (read_sum * 1000) / 80;
+}
+
+/* SATA AHCI temperature monitor */
+static int sata_ahci_read_temperature(void *dev, int *temp)
+{
+   u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;
+   u32 str1, str2, str3, str4;
+   int m1, m2, a;
+   struct ahci_host_priv *hpriv = dev_get_drvdata(dev);
+   void __iomem *mmio = hpriv->mmio;
+
+   /* check rd-wr to reg */
+   read_sum = 0;
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_CRCMP_LT_LIMIT, mmio);
+   imx_phy_reg_write(read_sum, mmio);
+   imx_phy_reg_read(_sum, mmio);
+   if ((read_sum & 0x) != 0)
+   dev_err(dev, "Read/Write REG error, 0x%x!\n", read_sum);
+
+   imx_phy_reg_write(0x5A5A, mmio);
+   imx_phy_reg_read(_sum, mmio);
+   if ((read_sum & 0x) != 0x5A5A)
+   dev_err(dev, "Read/Write REG error, 0x%x!\n", read_sum);
+
+   imx_phy_reg_write(0x1234, mmio);
+   imx_phy_reg_read(_sum, mmio);
+   if ((read_sum & 0x) != 0x1234)
+   dev_err(dev, "Read/Write REG error, 0x%x!\n", read_sum);
+
+   /* start temperature test */
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_MPLL_TST, mmio);
+   imx_phy_reg_read(_test_reg, mmio);
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio);
+   imx_phy_reg_read(_ctl_reg, mmio);
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_DAC_CTL, mmio);
+   imx_phy_reg_read(_ctl_reg, mmio);
+
+   /* mpll_tst.meas_iv   ([12:2]) */
+   str1 = (mpll_test_reg >> 2) & 0x7FF;
+   /* rtune_ctl.mode ([1:0]) */
+   str2 = (rtune_ctl_reg) & 0x3;
+   /* dac_ctl.dac_mode   ([14:12]) */
+   str3 = (dac_ctl_reg >> 12)  & 0x7;
+   /* rtune_ctl.sel_atbp ([4]) */
+   str4 = (rtune_ctl_reg >> 4);
+
+   /* Calculate the m1 */
+   /* mpll_tst.meas_iv */
+   mpll_test_reg = (mpll_test_reg & 0xE03) | (512) << 2;
+   /* rtune_ctl.mode */
+   rtune_ctl_reg = (rtune_ctl_reg & 0xFFC) | (1);
+   /* dac_ctl.dac_mode */
+   dac_ctl_reg = (dac_ctl_reg & 0x8FF) | (4) << 12;
+   /* rtune_ctl.sel_atbp */
+   rtune_ctl_reg = (rtune_ctl_reg & 0xFEF) | (0) << 4;
+   imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_MPLL_TST, mmio);
+   imx_phy_reg_write(mpll_test_reg, mmio);
+   

Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion

2016-10-25 Thread Arnd Bergmann
On Tuesday, October 25, 2016 9:48:22 AM CEST Jason Gunthorpe wrote:
> 
> Using a completion to model exclusive ownership seems convoluted to
> me - is that a thing now? What about an atomic?

I also totally missed how this is used. I initially mentioned to Binoy
that almost all semaphores can either be converted to a mutex or a
completion unless they rely on the counting behavior of the semaphore.

This driver clearly falls into another category and none of the above
apply here.

> open:
> 
> while (true) {
>wait_event_interruptible(priv->queue,test_bit(CLAIMED_BIT, >flags));
>if (!test_and_set_bit(CLAIMED_BIT, >flags))
> break;
> }

I'd fold the test_and_set_bit() into the wait_event() and get rid of the
loop here, otherwise this looks nice.

I'm generally a bit suspicious of open() functions that try to
protect you from having multiple file descriptors open, as dup()
or fork() will also result in extra file descriptors, but this
use here seems harmless, as the device itself only supports
open() and close() and the only thing it does is to keep track
of whether it is open or not.

It's also interesting that the ib_modify_port() function also
keeps track of the a flag that is set in open() and cleared
in close(), so in principle we should be able to unify this
with the semaphore, but the wait_event() approach is certainly
much simpler.

Arnd


Re: [PATCH V2 4/8] PM / OPP: Pass struct dev_pm_opp_supply to _set_opp_voltage()

2016-10-25 Thread Stephen Boyd
On 10/25, Viresh Kumar wrote:
> On 24-10-16, 16:14, Stephen Boyd wrote:
> > On 10/20, Viresh Kumar wrote:
> > > Pass the entire supply structure instead of all of its fields.
> > > 
> > > Signed-off-by: Viresh Kumar 
> > > ---
> > 
> > This patch should be combined with the previous one.
> 
> I think it is a fair to do this separately as this is a completely different
> logical change.

Let's agree to disagree.

> 
> > I'm still
> > not sure if it even makes sense to do this though.
> 
> :)
> 
> > Do we really
> > have to make duplicate "OPP snapshot" structures just because of
> > how OPPs use RCU?
> 
> I agree. With RCU, yes this change is probably required. But I am not sure if
> RCU fits that well to OPP core anymore. A rw-lock may be much easier to help.
> 

For things like AVS we'll probably want to do that, although it's
sort of funny because replacing RCU with rw-locks is the opposite
direction most people go. With AVS we would be updating the
voltage(s) in use for the current OPP, and we would want that
update to block any OPP transition until the voltage is adjusted.
I don't know how we would do that with RCU very well. Plus, RCU
is for reader heavy things, but we mostly have one or two
readers.

I guess it's ok for now to do all this copying, but it feels like
we'll need to undo a large portion of it later with things like
AVS. Or at least we'll be doing copies for almost no reason
because we'll want to hold the read lock across the whole OPP
transition. I was going to suggest we pass around information
about what we want to grab from the RCU protected data
structures, think index of regulator, etc. and then have small
RCU read-side critical sections to grab that info during the OPP
transition but I'm not sure that's any better. It might be worse
because the OPP could change during the OPP transition and we
could be using half of the old and half of the new data.

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


[PATCH v2] Input: synaptics-rmi4 - stop scanning PDT after two empty pages

2016-10-25 Thread Nick Dyer
We have encountered some RMI4 firmwares where there are blank pages in
between PDT pages which contain functions. This change makes them
correctly enumerate all functions on the device.

Tested on S7817 (has empty page 2).

Signed-off-by: Nick Dyer 
---
 drivers/input/rmi4/rmi_driver.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 4a88312..425bd19 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -422,6 +422,7 @@ static void rmi_driver_copy_pdt_to_fd(const struct 
pdt_entry *pdt,
 
 static int rmi_scan_pdt_page(struct rmi_device *rmi_dev,
 int page,
+int *empty_pages,
 void *ctx,
 int (*callback)(struct rmi_device *rmi_dev,
 void *ctx,
@@ -449,7 +450,16 @@ static int rmi_scan_pdt_page(struct rmi_device *rmi_dev,
return retval;
}
 
-   return (data->f01_bootloader_mode || addr == pdt_start) ?
+   /*
+* Count number of empty PDT pages. If a gap of two pages
+* or more is found, stop scanning.
+*/
+   if (addr == pdt_start)
+   ++*empty_pages;
+   else
+   *empty_pages = 0;
+
+   return (data->f01_bootloader_mode || *empty_pages >= 2) ?
RMI_SCAN_DONE : RMI_SCAN_CONTINUE;
 }
 
@@ -459,10 +469,12 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev, void 
*ctx,
const struct pdt_entry *entry))
 {
int page;
+   int empty_pages = 0;
int retval = RMI_SCAN_DONE;
 
for (page = 0; page <= RMI4_MAX_PAGE; page++) {
-   retval = rmi_scan_pdt_page(rmi_dev, page, ctx, callback);
+   retval = rmi_scan_pdt_page(rmi_dev, page, _pages,
+  ctx, callback);
if (retval != RMI_SCAN_CONTINUE)
break;
}
-- 
2.7.4



[RFC PATCH 02/13] of: Remove excessive printks to reduce clutter

2016-10-25 Thread frowand . list
From: Frank Rowand 

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 28 
 1 file changed, 28 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 4ff0220d7aa2..93a7ca0bf98c 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -116,8 +116,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
 
propval = kmalloc(rprop->length, GFP_KERNEL);
if (!propval) {
-   pr_err("%s: Could not copy value of '%s'\n",
-   __func__, rprop->name);
return -ENOMEM;
}
memcpy(propval, rprop->value, rprop->length);
@@ -129,8 +127,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
nodestr = propcur;
s = strchr(propcur, ':');
if (!s) {
-   pr_err("%s: Illegal symbol entry '%s' (1)\n",
-   __func__, propcur);
err = -EINVAL;
goto err_fail;
}
@@ -139,8 +135,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
propstr = s;
s = strchr(s, ':');
if (!s) {
-   pr_err("%s: Illegal symbol entry '%s' (2)\n",
-   __func__, (char *)rprop->value);
err = -EINVAL;
goto err_fail;
}
@@ -148,15 +142,11 @@ static int __of_adjust_phandle_ref(struct device_node 
*node,
*s++ = '\0';
err = kstrtoint(s, 10, );
if (err != 0) {
-   pr_err("%s: Could get offset '%s'\n",
-   __func__, (char *)rprop->value);
goto err_fail;
}
 
refnode = __of_find_node_by_full_name(node, nodestr);
if (!refnode) {
-   pr_warn("%s: Could not find refnode '%s'\n",
-   __func__, (char *)rprop->value);
continue;
}
 
@@ -167,8 +157,6 @@ static int __of_adjust_phandle_ref(struct device_node *node,
of_node_put(refnode);
 
if (!sprop) {
-   pr_err("%s: Could not find property '%s'\n",
-   __func__, (char *)rprop->value);
err = -ENOENT;
goto err_fail;
}
@@ -220,8 +208,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
continue;
 
if ((rprop->length % 4) != 0 || rprop->length == 0) {
-   pr_err("%s: Illegal property (size) '%s' @%s\n",
-   __func__, rprop->name, node->full_name);
return -EINVAL;
}
count = rprop->length / sizeof(__be32);
@@ -232,8 +218,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
}
 
if (sprop == NULL) {
-   pr_err("%s: Could not find target property '%s' @%s\n",
-   __func__, rprop->name, node->full_name);
return -EINVAL;
}
 
@@ -241,9 +225,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
off = be32_to_cpu(((__be32 *)rprop->value)[i]);
if (off >= sprop->length ||
(off + 4) > sprop->length) {
-   pr_err("%s: Illegal property '%s' @%s\n",
-   __func__, rprop->name,
-   node->full_name);
return -EINVAL;
}
 
@@ -262,8 +243,6 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
break;
 
if (!childtarget) {
-   pr_err("%s: Could not find target child '%s' @%s\n",
-   __func__, child->name, node->full_name);
return -EINVAL;
}
 
@@ -364,15 +343,11 @@ int of_resolve_phandles(struct device_node *resolve)
err = of_property_read_string(root_sym,
rprop->name, );
if (err != 0) {
-   pr_err("%s: Could not find symbol '%s'\n",
-   __func__, rprop->name);
goto out;
}
 
refnode = of_find_node_by_path(refpath);
if (!refnode) {
-   pr_err("%s: Could not find node by path '%s'\n",
-   __func__, refpath);
   

[PATCH 2/5] pinctrl: core: Add generic pinctrl functions for managing groups

2016-10-25 Thread Tony Lindgren
We can add generic helpers for pin group handling for cases where the pin
controller driver does not need to use static arrays.

Signed-off-by: Tony Lindgren 
---
 drivers/pinctrl/Kconfig |   3 +
 drivers/pinctrl/core.c  | 178 
 drivers/pinctrl/core.h  |  47 +
 3 files changed, 228 insertions(+)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -8,6 +8,9 @@ config PINCTRL
 menu "Pin controllers"
depends on PINCTRL
 
+config GENERIC_PINCTRL
+   bool
+
 config PINMUX
bool "Support pin multiplexing controllers" if COMPILE_TEST
 
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -540,6 +540,182 @@ void pinctrl_remove_gpio_range(struct pinctrl_dev 
*pctldev,
 }
 EXPORT_SYMBOL_GPL(pinctrl_remove_gpio_range);
 
+#ifdef CONFIG_GENERIC_PINCTRL
+
+/**
+ * pinctrl_generic_get_group_count() - returns the number of pin groups
+ * @pctldev: pin controller device
+ */
+int pinctrl_generic_get_group_count(struct pinctrl_dev *pctldev)
+{
+   return pctldev->num_groups;
+}
+EXPORT_SYMBOL_GPL(pinctrl_generic_get_group_count);
+
+/**
+ * pinctrl_generic_get_group_name() - returns the name of a pin group
+ * @pctldev: pin controller device
+ * @selector: group number
+ */
+const char *pinctrl_generic_get_group_name(struct pinctrl_dev *pctldev,
+  unsigned int selector)
+{
+   struct group_desc *group;
+
+   group = radix_tree_lookup(>pin_group_tree,
+ selector);
+   if (!group)
+   return NULL;
+
+   return group->name;
+}
+EXPORT_SYMBOL_GPL(pinctrl_generic_get_group_name);
+
+/**
+ * pinctrl_generic_get_group_pins() - gets the pin group pins
+ * @pctldev: pin controller device
+ * @selector: group number
+ * @pins: pins in the group
+ * @num_pins: number of pins in the group
+ */
+int pinctrl_generic_get_group_pins(struct pinctrl_dev *pctldev,
+  unsigned int selector,
+  const unsigned int **pins,
+  unsigned int *num_pins)
+{
+   struct group_desc *group;
+
+   group = radix_tree_lookup(>pin_group_tree,
+ selector);
+   if (!group) {
+   dev_err(pctldev->dev, "%s could not find pingroup%i\n",
+   __func__, selector);
+   return -EINVAL;
+   }
+
+   *pins = group->pins;
+   *num_pins = group->num_pins;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(pinctrl_generic_get_group_pins);
+
+/**
+ * pinctrl_generic_get_group() - returns a pin group based on the number
+ * @pctldev: pin controller device
+ * @gselector: group number
+ */
+struct group_desc *pinctrl_generic_get_group(struct pinctrl_dev *pctldev,
+unsigned int selector)
+{
+   struct group_desc *group;
+
+   group = radix_tree_lookup(>pin_group_tree,
+ selector);
+   if (!group)
+   return NULL;
+
+   return group;
+}
+EXPORT_SYMBOL_GPL(pinctrl_generic_get_group);
+
+/**
+ * pinctrl_generic_add_group() - adds a new pin group
+ * @pctldev: pin controller device
+ * @name: name of the pin group
+ * @pins: pins in the pin group
+ * @num_pins: number of pins in the pin group
+ * @data: pin controller driver specific data
+ *
+ * Note that the caller must take care of locking.
+ */
+int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
+ int *pins, int num_pins, void *data)
+{
+   struct group_desc *group;
+
+   group = devm_kzalloc(pctldev->dev, sizeof(*group), GFP_KERNEL);
+   if (!group)
+   return -ENOMEM;
+
+   group->name = name;
+   group->pins = pins;
+   group->num_pins = num_pins;
+   group->data = data;
+
+   radix_tree_insert(>pin_group_tree, pctldev->num_groups,
+ group);
+
+   pctldev->num_groups++;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(pinctrl_generic_add_group);
+
+/**
+ * pinctrl_generic_remove_group() - removes a numbered pin group
+ * @pctldev: pin controller device
+ * @selector: group number
+ *
+ * Note that the caller must take care of locking.
+ */
+int pinctrl_generic_remove_group(struct pinctrl_dev *pctldev,
+unsigned int selector)
+{
+   struct group_desc *group;
+
+   group = radix_tree_lookup(>pin_group_tree,
+ selector);
+   if (!group)
+   return -ENOENT;
+
+   radix_tree_delete(>pin_group_tree, selector);
+   devm_kfree(pctldev->dev, group);
+
+   pctldev->num_groups--;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(pinctrl_generic_remove_group);
+
+/**
+ * pinctrl_generic_free_groups() - 

[RFC PATCH 03/13] of: Remove braces around single line blocks.

2016-10-25 Thread frowand . list
From: Frank Rowand 

The single line blocks were created by previous patches in the series.

Signed-off-by: Frank Rowand 
---
 drivers/of/resolver.c | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 93a7ca0bf98c..c61ba99a1792 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -115,9 +115,8 @@ static int __of_adjust_phandle_ref(struct device_node *node,
int err = 0;
 
propval = kmalloc(rprop->length, GFP_KERNEL);
-   if (!propval) {
+   if (!propval)
return -ENOMEM;
-   }
memcpy(propval, rprop->value, rprop->length);
 
propend = propval + rprop->length;
@@ -141,14 +140,12 @@ static int __of_adjust_phandle_ref(struct device_node 
*node,
 
*s++ = '\0';
err = kstrtoint(s, 10, );
-   if (err != 0) {
+   if (err != 0)
goto err_fail;
-   }
 
refnode = __of_find_node_by_full_name(node, nodestr);
-   if (!refnode) {
+   if (!refnode)
continue;
-   }
 
for_each_property_of_node(refnode, sprop) {
if (of_prop_cmp(sprop->name, propstr) == 0)
@@ -207,9 +204,8 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
of_prop_cmp(rprop->name, "linux,phandle") == 0)
continue;
 
-   if ((rprop->length % 4) != 0 || rprop->length == 0) {
+   if ((rprop->length % 4) != 0 || rprop->length == 0)
return -EINVAL;
-   }
count = rprop->length / sizeof(__be32);
 
for_each_property_of_node(target, sprop) {
@@ -217,16 +213,13 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
break;
}
 
-   if (sprop == NULL) {
+   if (sprop == NULL)
return -EINVAL;
-   }
 
for (i = 0; i < count; i++) {
off = be32_to_cpu(((__be32 *)rprop->value)[i]);
-   if (off >= sprop->length ||
-   (off + 4) > sprop->length) {
+   if (off >= sprop->length || (off + 4) > sprop->length)
return -EINVAL;
-   }
 
if (phandle_delta) {
phandle = be32_to_cpu(*(__be32 *)(sprop->value 
+ off));
@@ -242,9 +235,8 @@ static int __of_adjust_tree_phandle_references(struct 
device_node *node,
if (__of_node_name_cmp(child, childtarget) == 0)
break;
 
-   if (!childtarget) {
+   if (!childtarget)
return -EINVAL;
-   }
 
err = __of_adjust_tree_phandle_references(child, childtarget,
phandle_delta);
@@ -342,9 +334,8 @@ int of_resolve_phandles(struct device_node *resolve)
 
err = of_property_read_string(root_sym,
rprop->name, );
-   if (err != 0) {
+   if (err != 0)
goto out;
-   }
 
refnode = of_find_node_by_path(refpath);
if (!refnode) {
-- 
1.9.1



Re: [RFC PATCH 00/13] of: Make drivers/of/resolver.c more readable

2016-10-25 Thread Frank Rowand
On 10/25/16 13:58, frowand.l...@gmail.com wrote:
> From: Frank Rowand 
> 
> drivers/of/resolve.c is a bit difficult to read.  Clean it up so
> that review of future overlay related patches will be easier.

< snip >

Hi Pantelis,

Can you test this patch series on some real hardware?

Thanks,

Frank


[PATCH 1/5] pinctrl: core: Use delayed work for hogs

2016-10-25 Thread Tony Lindgren
Having the pin control framework call pin controller functions
before it's probe has finished is not nice as the pin controller
device driver does not yet have struct pinctrl_dev handle.

Let's fix this issue by adding deferred work for hogs. This is
needed to be able to add pinctrl generic helper functions.

Note that the pinctrl functions already take care of the necessary
locking.

Signed-off-by: Tony Lindgren 
---
 drivers/pinctrl/core.c | 53 +++---
 drivers/pinctrl/core.h |  2 ++
 2 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1738,6 +1738,35 @@ static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
 }
 
 /**
+ * pinctrl_hog_work() - delayed work to set pincontroller self-claimed pins
+ * @work: work struct
+ */
+static void pinctrl_hog_work(struct work_struct *work)
+{
+   struct pinctrl_dev *pctldev;
+
+   pctldev = container_of(work, struct pinctrl_dev, hog_work.work);
+
+   pctldev->p = pinctrl_get(pctldev->dev);
+   if (IS_ERR(pctldev->p))
+   return;
+
+   pctldev->hog_default =
+   pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(pctldev->hog_default)) {
+   dev_dbg(pctldev->dev, "failed to lookup the default state\n");
+   } else {
+   if (pinctrl_select_state(pctldev->p, pctldev->hog_default))
+   dev_err(pctldev->dev, "failed to select default 
state\n");
+   }
+
+   pctldev->hog_sleep = pinctrl_lookup_state(pctldev->p,
+ PINCTRL_STATE_SLEEP);
+   if (IS_ERR(pctldev->hog_sleep))
+   dev_dbg(pctldev->dev, "failed to lookup the sleep state\n");
+}
+
+/**
  * pinctrl_register() - register a pin controller device
  * @pctldesc: descriptor for this pin controller
  * @dev: parent device for this pin controller
@@ -1766,6 +1795,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc 
*pctldesc,
pctldev->driver_data = driver_data;
INIT_RADIX_TREE(>pin_desc_tree, GFP_KERNEL);
INIT_LIST_HEAD(>gpio_ranges);
+   INIT_DELAYED_WORK(>hog_work, pinctrl_hog_work);
pctldev->dev = dev;
mutex_init(>mutex);
 
@@ -1804,26 +1834,8 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc 
*pctldesc,
list_add_tail(>node, _list);
mutex_unlock(_list_mutex);
 
-   pctldev->p = pinctrl_get(pctldev->dev);
-
-   if (!IS_ERR(pctldev->p)) {
-   pctldev->hog_default =
-   pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
-   if (IS_ERR(pctldev->hog_default)) {
-   dev_dbg(dev, "failed to lookup the default state\n");
-   } else {
-   if (pinctrl_select_state(pctldev->p,
-   pctldev->hog_default))
-   dev_err(dev,
-   "failed to select default state\n");
-   }
-
-   pctldev->hog_sleep =
-   pinctrl_lookup_state(pctldev->p,
-   PINCTRL_STATE_SLEEP);
-   if (IS_ERR(pctldev->hog_sleep))
-   dev_dbg(dev, "failed to lookup the sleep state\n");
-   }
+   schedule_delayed_work(>hog_work,
+ msecs_to_jiffies(100));
 
pinctrl_init_device_debugfs(pctldev);
 
@@ -1848,6 +1860,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
if (pctldev == NULL)
return;
 
+   cancel_delayed_work_sync(>hog_work);
mutex_lock(>mutex);
pinctrl_remove_device_debugfs(pctldev);
mutex_unlock(>mutex);
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -33,6 +33,7 @@ struct pinctrl_gpio_range;
  * @p: result of pinctrl_get() for this device
  * @hog_default: default state for pins hogged by this device
  * @hog_sleep: sleep state for pins hogged by this device
+ * @hog_work: delayed work for pin controller device claimed hog pins
  * @mutex: mutex taken on each pin controller specific action
  * @device_root: debugfs root for this device
  */
@@ -47,6 +48,7 @@ struct pinctrl_dev {
struct pinctrl *p;
struct pinctrl_state *hog_default;
struct pinctrl_state *hog_sleep;
+   struct delayed_work hog_work;
struct mutex mutex;
 #ifdef CONFIG_DEBUG_FS
struct dentry *device_root;
-- 
2.9.3


Re: UBIFS LEB properties tree with odd addresses

2016-10-25 Thread Richard Weinberger
Naga Sureshkumar Relli,

On 25.10.2016 08:05, Naga Sureshkumar Relli wrote:
> Hi,
> 
> We are testing UBIFS (NOR) on Zynq Ultrascale+ MPSoC GQSPI controller driver.
> Apart from my previous mail thread about UBIFS, i.e along with dma issue I am 
> facing one more
> Problem related to offsets.
> 
> Info about GQSPI Controller:
> This controller can access the flash device in the following modes.
> 1. Single flash mode
> 2. Two spi flash memories with separate buses (dual parallel)
> 
> Single flash mode: it is normal configuration, one controller and one flash 
> memory
> 
> In dual parallel mode following are the functionalities:
> 1) Supporting two SPI flash memories operating in parallel. 8 I/O lines.
> 2) Chip selects and clock are shared to both the flash devices
> 3) This mode is targeted for faster read/write speed and also doubles the size
> 4) Commands/data can be transmitted/received from both the devices(mirror), 
> or only upper or only lower flash memory devices.
> 5) Data arrangement:
> With stripe (controller configuration) enabled,
> Even bytes i.e. 0, 2, 4,... are transmitted on Lower Data Bus
> Odd bytes i.e. 1, 3, 5,.. are transmitted on Upper Data Bus.

But these details are hidden from UBI?

> Kernel version : 4.4.0
> Controller limitation: ZynqMP gqspi controller supports only even addresses 
> when two flash devices are connected (dual parallel mode).
> 
> Issue I am facing:
> -> Since our controller supports even addresses in dual parallel mode
> We are seeing issues with ubifs in dual parallel mode and jffs2 is working 
> fine and we observed the following:
> 
> IN dual parallel mode, the Erase block size was 128KiB whereas single flash 
> mode the Erase block size was 64KiB.
> In single flash mode, we are getting pnode_sz value as 16 and for dual 
> parallel mode we are getting an odd value 17
> And ltab_sz value in single mode as 12 and in dual parallel mode as 11.
> Because of these odd values, check_lpt_type  offset argument is odd address 
> and hence lpt_type error.
> 
> When I ran the mnt command, I am getting the following error
> "UBIFS error (ubi0:0 pid 1882): check_lpt_type: invalid type (4) in LPT node 
> type 2"
> Ran the below commands:
> a)ubiformat /dev/mtd0 -e 0 -y
> b)ubiattach -p /dev/mtd0
> c)ubimkvol -N data -m /dev/ubi0
> d)mount -t ubifs ubi0:data /mnt
> 
> So for temporary hack we did the following change
> In fs/ubifs/lpt.c
> In do_calc_lpt_geom(), added the following
> +   if (c->pnode_sz % 2)
> +   c->pnode_sz += 1; 
> +   if (c->ltab_sz % 2)
> +   c->ltab_sz += 1;
> 
> Please kindly suggest, I need your inputs, changing the pnode_sz and ltab_sz 
> to even in lpt.c, will it impact on any others?

Hmm, the calculations in lpt.c use basic properties of the MTD (number of 
blocks, etc...).
Can you please double check which property causes the failure and also verify 
whether the MTD driver
provides correct properties. i.e. page sizes, block size, number of blocks, ...

Thanks,
//richard


[PATCH v2 2/2] staging: lustre: restore initialization of return code

2016-10-25 Thread Arnd Bergmann
A recent rework removed the initialization of the successful return
code from lov_getstripe:

drivers/staging/lustre/lustre/lov/lov_pack.c: In function 'lov_getstripe':
drivers/staging/lustre/lustre/lov/lov_pack.c:426:9: error: 'rc' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
drivers/staging/lustre/lustre/lov/lov_pack.c:313:6: note: 'rc' was declared here

This adds it back.

Fixes: e10a431b3fd0 ("staging: lustre: lov: move LSM to LOV layer")
Signed-off-by: Arnd Bergmann 
---
 drivers/staging/lustre/lustre/lov/lov_pack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c 
b/drivers/staging/lustre/lustre/lov/lov_pack.c
index 17bceadd66f8..ccc1fae35791 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pack.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pack.c
@@ -418,6 +418,8 @@ int lov_getstripe(struct lov_object *obj, struct 
lov_stripe_md *lsm,
((struct lov_user_md *)lmmk)->lmm_stripe_count = lum.lmm_stripe_count;
if (copy_to_user(lump, lmmk, lmm_size))
rc = -EFAULT;
+   else
+   rc = 0;
 
 out_free:
kvfree(lmmk);
-- 
2.9.0



Re: [RFC/PATCH 2/2] perf sched: Make common options cascading

2016-10-25 Thread Namhyung Kim
On Tue, Oct 25, 2016 at 02:21:32PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 24, 2016 at 07:03:32PM +0200, Jiri Olsa escreveu:
> > On Mon, Oct 24, 2016 at 12:00:03PM +0900, Namhyung Kim wrote:
> > > The -i and -v options can be used in subcommands so enable cascading the
> > > sched_options.  This fixes the following inconvenience in 'perf sched':
> > > 
> > >   $ perf sched -i perf.data.sched  map
> > >   ... (it works well) ...
> > > 
> > >   $ perf sched map  -i perf.data.sched
> > > Error: unknown switch `i'
> > > 
> > >Usage: perf sched map []
> > > 
> > >   --color-cpus 
> > > highlight given CPUs in map
> > >   --color-pids 
> > > highlight given pids in map
> > >   --compact map output in compact mode
> > >   --cpus  display given CPUs in map
> > > 
> > > With this patch, the second command line works with the perf.data.sched
> > > data file.
> > > 
> > > Cc: Josh Poimboeuf 
> > > Signed-off-by: Namhyung Kim 
> > 
> > good idea, I'll use it in c2c ;-)
> > 
> > for both:
> > 
> > Acked-by: Jiri Olsa 
> 
> Applied, I guess 'perf kvm' would be another user, to make it sane wrt
> file_name, -i and -o being available for 'perf kvm record', etc.

Yep, I think we have few more.  I'll send the patch when I can find a
time (FYI I'm travelling now).

Thanks,
Namhyung


[net-next PATCH 02/27] swiotlb-xen: Enforce return of DMA_ERROR_CODE in mapping function

2016-10-25 Thread Alexander Duyck
The mapping function should always return DMA_ERROR_CODE when a mapping has
failed as this is what the DMA API expects when a DMA error has occurred.
The current function for mapping a page in Xen was returning either
DMA_ERROR_CODE or 0 depending on where it failed.

On x86 DMA_ERROR_CODE is 0, but on other architectures such as ARM it is
~0. We need to make sure we return the same error value if either the
mapping failed or the device is not capable of accessing the mapping.

If we are returning DMA_ERROR_CODE as our error value we can drop the
function for checking the error code as the default is to compare the
return value against DMA_ERROR_CODE if no function is defined.

Cc: Konrad Rzeszutek Wilk 
Signed-off-by: Alexander Duyck 
---
 arch/arm/xen/mm.c  |1 -
 arch/x86/xen/pci-swiotlb-xen.c |1 -
 drivers/xen/swiotlb-xen.c  |   18 ++
 include/xen/swiotlb-xen.h  |3 ---
 4 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index d062f08..bd62d94 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -186,7 +186,6 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, 
unsigned int order)
 EXPORT_SYMBOL(xen_dma_ops);
 
 static struct dma_map_ops xen_swiotlb_dma_ops = {
-   .mapping_error = xen_swiotlb_dma_mapping_error,
.alloc = xen_swiotlb_alloc_coherent,
.free = xen_swiotlb_free_coherent,
.sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu,
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index 0e98e5d..a9fafb5 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -19,7 +19,6 @@
 int xen_swiotlb __read_mostly;
 
 static struct dma_map_ops xen_swiotlb_dma_ops = {
-   .mapping_error = xen_swiotlb_dma_mapping_error,
.alloc = xen_swiotlb_alloc_coherent,
.free = xen_swiotlb_free_coherent,
.sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu,
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 87e6035..b8014bf 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -416,11 +416,12 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, 
struct page *page,
/*
 * Ensure that the address returned is DMA'ble
 */
-   if (!dma_capable(dev, dev_addr, size)) {
-   swiotlb_tbl_unmap_single(dev, map, size, dir);
-   dev_addr = 0;
-   }
-   return dev_addr;
+   if (dma_capable(dev, dev_addr, size))
+   return dev_addr;
+
+   swiotlb_tbl_unmap_single(dev, map, size, dir);
+
+   return DMA_ERROR_CODE;
 }
 EXPORT_SYMBOL_GPL(xen_swiotlb_map_page);
 
@@ -648,13 +649,6 @@ void xen_swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
 }
 EXPORT_SYMBOL_GPL(xen_swiotlb_sync_sg_for_device);
 
-int
-xen_swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
-{
-   return !dma_addr;
-}
-EXPORT_SYMBOL_GPL(xen_swiotlb_dma_mapping_error);
-
 /*
  * Return whether the given device DMA address mask can be supported
  * properly.  For example, if your device can only drive the low 24-bits
diff --git a/include/xen/swiotlb-xen.h b/include/xen/swiotlb-xen.h
index 7c35e27..a0083be 100644
--- a/include/xen/swiotlb-xen.h
+++ b/include/xen/swiotlb-xen.h
@@ -51,9 +51,6 @@ extern void xen_swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
   int nelems, enum dma_data_direction dir);
 
 extern int
-xen_swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
-
-extern int
 xen_swiotlb_dma_supported(struct device *hwdev, u64 mask);
 
 extern int



[net-next PATCH 00/27] Add support for DMA writable pages being writable by the network stack

2016-10-25 Thread Alexander Duyck
The first 22 patches in the set add support for the DMA attribute
DMA_ATTR_SKIP_CPU_SYNC on multiple platforms/architectures.  This is needed
so that we can flag the calls to dma_map/unmap_page so that we do not
invalidate cache lines that do not currently belong to the device.  Instead
we have to take care of this in the driver via a call to
sync_single_range_for_cpu prior to freeing the Rx page.

Patch 23 adds support for dma_map_page_attrs and dma_unmap_page_attrs so
that we can unmap and map a page using the DMA_ATTR_SKIP_CPU_SYNC
attribute.

Patch 24 adds support for freeing a page that has multiple references being
held by a single caller.  This way we can free page fragments that were
allocated by a given driver.

The last 3 patches use these updates in the igb driver to allow for us to
reimpelement the use of build_skb.

My hope is to get the series accepted into the net-next tree as I have a
number of other Intel drivers I could then begin updating once these
patches are accepted.

v1: Split out changes DMA_ERROR_CODE fix for swiotlb-xen
Minor fixes based on issues found by kernel build bot
Few minor changes for issues found on code review
Added Acked-by for patches that were acked and not changed

---

Alexander Duyck (27):
  swiotlb: Drop unused function swiotlb_map_sg
  swiotlb-xen: Enforce return of DMA_ERROR_CODE in mapping function
  swiotlb: Add support for DMA_ATTR_SKIP_CPU_SYNC
  arch/arc: Add option to skip sync on DMA mapping
  arch/arm: Add option to skip sync on DMA map and unmap
  arch/avr32: Add option to skip sync on DMA map
  arch/blackfin: Add option to skip sync on DMA map
  arch/c6x: Add option to skip sync on DMA map and unmap
  arch/frv: Add option to skip sync on DMA map
  arch/hexagon: Add option to skip DMA sync as a part of mapping
  arch/m68k: Add option to skip DMA sync as a part of mapping
  arch/metag: Add option to skip DMA sync as a part of map and unmap
  arch/microblaze: Add option to skip DMA sync as a part of map and unmap
  arch/mips: Add option to skip DMA sync as a part of map and unmap
  arch/nios2: Add option to skip DMA sync as a part of map and unmap
  arch/openrisc: Add option to skip DMA sync as a part of mapping
  arch/parisc: Add option to skip DMA sync as a part of map and unmap
  arch/powerpc: Add option to skip DMA sync as a part of mapping
  arch/sh: Add option to skip DMA sync as a part of mapping
  arch/sparc: Add option to skip DMA sync as a part of map and unmap
  arch/tile: Add option to skip DMA sync as a part of map and unmap
  arch/xtensa: Add option to skip DMA sync as a part of mapping
  dma: Add calls for dma_map_page_attrs and dma_unmap_page_attrs
  mm: Add support for releasing multiple instances of a page
  igb: Update driver to make use of DMA_ATTR_SKIP_CPU_SYNC
  igb: Update code to better handle incrementing page count
  igb: Revert "igb: Revert support for build_skb in igb"


 arch/arc/mm/dma.c |5 +
 arch/arm/common/dmabounce.c   |   16 +-
 arch/arm/xen/mm.c |1 
 arch/avr32/mm/dma-coherent.c  |7 +
 arch/blackfin/kernel/dma-mapping.c|8 +
 arch/c6x/kernel/dma.c |   14 +-
 arch/frv/mb93090-mb00/pci-dma-nommu.c |   14 +-
 arch/frv/mb93090-mb00/pci-dma.c   |9 +
 arch/hexagon/kernel/dma.c |6 +
 arch/m68k/kernel/dma.c|8 +
 arch/metag/kernel/dma.c   |   16 ++
 arch/microblaze/kernel/dma.c  |   10 +
 arch/mips/loongson64/common/dma-swiotlb.c |2 
 arch/mips/mm/dma-default.c|8 +
 arch/nios2/mm/dma-mapping.c   |   26 +++-
 arch/openrisc/kernel/dma.c|3 
 arch/parisc/kernel/pci-dma.c  |   20 ++-
 arch/powerpc/kernel/dma.c |9 +
 arch/sh/kernel/dma-nommu.c|7 +
 arch/sparc/kernel/iommu.c |4 -
 arch/sparc/kernel/ioport.c|4 -
 arch/tile/kernel/pci-dma.c|   12 +-
 arch/x86/xen/pci-swiotlb-xen.c|1 
 arch/xtensa/kernel/pci-dma.c  |7 +
 drivers/net/ethernet/intel/igb/igb.h  |   36 -
 drivers/net/ethernet/intel/igb/igb_main.c |  207 +++--
 drivers/xen/swiotlb-xen.c |   27 ++--
 include/linux/dma-mapping.h   |   20 ++-
 include/linux/gfp.h   |2 
 include/linux/swiotlb.h   |   10 +
 include/xen/swiotlb-xen.h |3 
 lib/swiotlb.c |   56 
 mm/page_alloc.c   |   14 ++
 33 files changed, 433 insertions(+), 159 deletions(-)

--
Signature


[net-next PATCH 09/27] arch/frv: Add option to skip sync on DMA map

2016-10-25 Thread Alexander Duyck
The use of DMA_ATTR_SKIP_CPU_SYNC was not consistent across all of the DMA
APIs in the arch/arm folder.  This change is meant to correct that so that
we get consistent behavior.

Signed-off-by: Alexander Duyck 
---
 arch/frv/mb93090-mb00/pci-dma-nommu.c |   14 ++
 arch/frv/mb93090-mb00/pci-dma.c   |9 +++--
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/arch/frv/mb93090-mb00/pci-dma-nommu.c 
b/arch/frv/mb93090-mb00/pci-dma-nommu.c
index 90f2e4c..1876881 100644
--- a/arch/frv/mb93090-mb00/pci-dma-nommu.c
+++ b/arch/frv/mb93090-mb00/pci-dma-nommu.c
@@ -109,16 +109,19 @@ static int frv_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
int nents, enum dma_data_direction direction,
unsigned long attrs)
 {
-   int i;
struct scatterlist *sg;
+   int i;
+
+   BUG_ON(direction == DMA_NONE);
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return nents;
 
for_each_sg(sglist, sg, nents, i) {
frv_cache_wback_inv(sg_dma_address(sg),
sg_dma_address(sg) + sg_dma_len(sg));
}
 
-   BUG_ON(direction == DMA_NONE);
-
return nents;
 }
 
@@ -127,7 +130,10 @@ static dma_addr_t frv_dma_map_page(struct device *dev, 
struct page *page,
enum dma_data_direction direction, unsigned long attrs)
 {
BUG_ON(direction == DMA_NONE);
-   flush_dcache_page(page);
+
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   flush_dcache_page(page);
+
return (dma_addr_t) page_to_phys(page) + offset;
 }
 
diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
index f585745..dba7df9 100644
--- a/arch/frv/mb93090-mb00/pci-dma.c
+++ b/arch/frv/mb93090-mb00/pci-dma.c
@@ -40,13 +40,16 @@ static int frv_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
int nents, enum dma_data_direction direction,
unsigned long attrs)
 {
+   struct scatterlist *sg;
unsigned long dampr2;
void *vaddr;
int i;
-   struct scatterlist *sg;
 
BUG_ON(direction == DMA_NONE);
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return nents;
+
dampr2 = __get_DAMPR(2);
 
for_each_sg(sglist, sg, nents, i) {
@@ -70,7 +73,9 @@ static dma_addr_t frv_dma_map_page(struct device *dev, struct 
page *page,
unsigned long offset, size_t size,
enum dma_data_direction direction, unsigned long attrs)
 {
-   flush_dcache_page(page);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   flush_dcache_page(page);
+
return (dma_addr_t) page_to_phys(page) + offset;
 }
 



[net-next PATCH 06/27] arch/avr32: Add option to skip sync on DMA map

2016-10-25 Thread Alexander Duyck
The use of DMA_ATTR_SKIP_CPU_SYNC was not consistent across all of the DMA
APIs in the arch/arm folder.  This change is meant to correct that so that
we get consistent behavior.

Acked-by: Hans-Christian Noren Egtvedt 
Signed-off-by: Alexander Duyck 
---
 arch/avr32/mm/dma-coherent.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/avr32/mm/dma-coherent.c b/arch/avr32/mm/dma-coherent.c
index 58610d0..54534e5 100644
--- a/arch/avr32/mm/dma-coherent.c
+++ b/arch/avr32/mm/dma-coherent.c
@@ -146,7 +146,8 @@ static dma_addr_t avr32_dma_map_page(struct device *dev, 
struct page *page,
 {
void *cpu_addr = page_address(page) + offset;
 
-   dma_cache_sync(dev, cpu_addr, size, direction);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   dma_cache_sync(dev, cpu_addr, size, direction);
return virt_to_bus(cpu_addr);
 }
 
@@ -162,6 +163,10 @@ static int avr32_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
 
sg->dma_address = page_to_bus(sg_page(sg)) + sg->offset;
virt = sg_virt(sg);
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
dma_cache_sync(dev, virt, sg->length, direction);
}
 



[net-next PATCH 08/27] arch/c6x: Add option to skip sync on DMA map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
later via a sync_for_cpu or sync_for_device call.

Cc: Mark Salter 
Cc: Aurelien Jacquiot 
Signed-off-by: Alexander Duyck 
---
 arch/c6x/kernel/dma.c |   14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/c6x/kernel/dma.c b/arch/c6x/kernel/dma.c
index db4a6a3..6752df3 100644
--- a/arch/c6x/kernel/dma.c
+++ b/arch/c6x/kernel/dma.c
@@ -42,14 +42,17 @@ static dma_addr_t c6x_dma_map_page(struct device *dev, 
struct page *page,
 {
dma_addr_t handle = virt_to_phys(page_address(page) + offset);
 
-   c6x_dma_sync(handle, size, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   c6x_dma_sync(handle, size, dir);
+
return handle;
 }
 
 static void c6x_dma_unmap_page(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
-   c6x_dma_sync(handle, size, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   c6x_dma_sync(handle, size, dir);
 }
 
 static int c6x_dma_map_sg(struct device *dev, struct scatterlist *sglist,
@@ -60,7 +63,8 @@ static int c6x_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
 
for_each_sg(sglist, sg, nents, i) {
sg->dma_address = sg_phys(sg);
-   c6x_dma_sync(sg->dma_address, sg->length, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   c6x_dma_sync(sg->dma_address, sg->length, dir);
}
 
return nents;
@@ -72,9 +76,11 @@ static void c6x_dma_unmap_sg(struct device *dev, struct 
scatterlist *sglist,
struct scatterlist *sg;
int i;
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return;
+
for_each_sg(sglist, sg, nents, i)
c6x_dma_sync(sg_dma_address(sg), sg->length, dir);
-
 }
 
 static void c6x_dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,



[net-next PATCH 15/27] arch/nios2: Add option to skip DMA sync as a part of map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: Ley Foon Tan 
Signed-off-by: Alexander Duyck 
---
 arch/nios2/mm/dma-mapping.c |   26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c
index d800fad..f6a5dcf 100644
--- a/arch/nios2/mm/dma-mapping.c
+++ b/arch/nios2/mm/dma-mapping.c
@@ -98,13 +98,17 @@ static int nios2_dma_map_sg(struct device *dev, struct 
scatterlist *sg,
int i;
 
for_each_sg(sg, sg, nents, i) {
-   void *addr;
+   void *addr = sg_virt(sg);
 
-   addr = sg_virt(sg);
-   if (addr) {
-   __dma_sync_for_device(addr, sg->length, direction);
-   sg->dma_address = sg_phys(sg);
-   }
+   if (!addr)
+   continue;
+
+   sg->dma_address = sg_phys(sg);
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
+   __dma_sync_for_device(addr, sg->length, direction);
}
 
return nents;
@@ -117,7 +121,9 @@ static dma_addr_t nios2_dma_map_page(struct device *dev, 
struct page *page,
 {
void *addr = page_address(page) + offset;
 
-   __dma_sync_for_device(addr, size, direction);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   __dma_sync_for_device(addr, size, direction);
+
return page_to_phys(page) + offset;
 }
 
@@ -125,7 +131,8 @@ static void nios2_dma_unmap_page(struct device *dev, 
dma_addr_t dma_address,
size_t size, enum dma_data_direction direction,
unsigned long attrs)
 {
-   __dma_sync_for_cpu(phys_to_virt(dma_address), size, direction);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   __dma_sync_for_cpu(phys_to_virt(dma_address), size, direction);
 }
 
 static void nios2_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
@@ -138,6 +145,9 @@ static void nios2_dma_unmap_sg(struct device *dev, struct 
scatterlist *sg,
if (direction == DMA_TO_DEVICE)
return;
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return;
+
for_each_sg(sg, sg, nhwentries, i) {
addr = sg_virt(sg);
if (addr)



[net-next PATCH 03/27] swiotlb: Add support for DMA_ATTR_SKIP_CPU_SYNC

2016-10-25 Thread Alexander Duyck
As a first step to making DMA_ATTR_SKIP_CPU_SYNC apply to architectures
beyond just ARM I need to make it so that the swiotlb will respect the
flag.  In order to do that I also need to update the swiotlb-xen since it
heavily makes use of the functionality.

Cc: Konrad Rzeszutek Wilk 
Signed-off-by: Alexander Duyck 
---
 drivers/xen/swiotlb-xen.c |   11 +++---
 include/linux/swiotlb.h   |6 --
 lib/swiotlb.c |   48 +++--
 3 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index b8014bf..3d048af 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -405,7 +405,8 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct 
page *page,
 */
trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
 
-   map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir);
+   map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir,
+attrs);
if (map == SWIOTLB_MAP_ERROR)
return DMA_ERROR_CODE;
 
@@ -419,7 +420,8 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct 
page *page,
if (dma_capable(dev, dev_addr, size))
return dev_addr;
 
-   swiotlb_tbl_unmap_single(dev, map, size, dir);
+   swiotlb_tbl_unmap_single(dev, map, size, dir,
+attrs | DMA_ATTR_SKIP_CPU_SYNC);
 
return DMA_ERROR_CODE;
 }
@@ -445,7 +447,7 @@ static void xen_unmap_single(struct device *hwdev, 
dma_addr_t dev_addr,
 
/* NOTE: We use dev_addr here, not paddr! */
if (is_xen_swiotlb_buffer(dev_addr)) {
-   swiotlb_tbl_unmap_single(hwdev, paddr, size, dir);
+   swiotlb_tbl_unmap_single(hwdev, paddr, size, dir, attrs);
return;
}
 
@@ -558,11 +560,12 @@ void xen_swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
 start_dma_addr,
 sg_phys(sg),
 sg->length,
-dir);
+dir, attrs);
if (map == SWIOTLB_MAP_ERROR) {
dev_warn(hwdev, "swiotlb buffer is full\n");
/* Don't panic here, we expect map_sg users
   to do proper error handling. */
+   attrs |= DMA_ATTR_SKIP_CPU_SYNC;
xen_swiotlb_unmap_sg_attrs(hwdev, sgl, i, dir,
   attrs);
sg_dma_len(sgl) = 0;
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index e237b6f..4517be9 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -44,11 +44,13 @@ enum dma_sync_target {
 extern phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
  dma_addr_t tbl_dma_addr,
  phys_addr_t phys, size_t size,
- enum dma_data_direction dir);
+ enum dma_data_direction dir,
+ unsigned long attrs);
 
 extern void swiotlb_tbl_unmap_single(struct device *hwdev,
 phys_addr_t tlb_addr,
-size_t size, enum dma_data_direction dir);
+size_t size, enum dma_data_direction dir,
+unsigned long attrs);
 
 extern void swiotlb_tbl_sync_single(struct device *hwdev,
phys_addr_t tlb_addr,
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 47aad37..b538d39 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -425,7 +425,8 @@ static void swiotlb_bounce(phys_addr_t orig_addr, 
phys_addr_t tlb_addr,
 phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
   dma_addr_t tbl_dma_addr,
   phys_addr_t orig_addr, size_t size,
-  enum dma_data_direction dir)
+  enum dma_data_direction dir,
+  unsigned long attrs)
 {
unsigned long flags;
phys_addr_t tlb_addr;
@@ -526,7 +527,8 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
 */
for (i = 0; i < nslots; i++)
io_tlb_orig_addr[index+i] = orig_addr + (i << IO_TLB_SHIFT);
-   if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&

[net-next PATCH 17/27] arch/parisc: Add option to skip DMA sync as a part of map and unmap

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
via a sync_for_cpu or sync_for_device call.

Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: linux-par...@vger.kernel.org
Signed-off-by: Alexander Duyck 
---
 arch/parisc/kernel/pci-dma.c |   20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 02d9ed0..be55ede 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -459,7 +459,9 @@ static dma_addr_t pa11_dma_map_page(struct device *dev, 
struct page *page,
void *addr = page_address(page) + offset;
BUG_ON(direction == DMA_NONE);
 
-   flush_kernel_dcache_range((unsigned long) addr, size);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   flush_kernel_dcache_range((unsigned long) addr, size);
+
return virt_to_phys(addr);
 }
 
@@ -469,8 +471,11 @@ static void pa11_dma_unmap_page(struct device *dev, 
dma_addr_t dma_handle,
 {
BUG_ON(direction == DMA_NONE);
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return;
+
if (direction == DMA_TO_DEVICE)
-   return;
+   return;
 
/*
 * For PCI_DMA_FROMDEVICE this flush is not necessary for the
@@ -479,7 +484,6 @@ static void pa11_dma_unmap_page(struct device *dev, 
dma_addr_t dma_handle,
 */
 
flush_kernel_dcache_range((unsigned long) phys_to_virt(dma_handle), 
size);
-   return;
 }
 
 static int pa11_dma_map_sg(struct device *dev, struct scatterlist *sglist,
@@ -496,6 +500,10 @@ static int pa11_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
 
sg_dma_address(sg) = (dma_addr_t) virt_to_phys(vaddr);
sg_dma_len(sg) = sg->length;
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
flush_kernel_dcache_range(vaddr, sg->length);
}
return nents;
@@ -510,14 +518,16 @@ static void pa11_dma_unmap_sg(struct device *dev, struct 
scatterlist *sglist,
 
BUG_ON(direction == DMA_NONE);
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   return;
+
if (direction == DMA_TO_DEVICE)
-   return;
+   return;
 
/* once we do combining we'll need to use 
phys_to_virt(sg_dma_address(sglist)) */
 
for_each_sg(sglist, sg, nents, i)
flush_kernel_vmap_range(sg_virt(sg), sg->length);
-   return;
 }
 
 static void pa11_dma_sync_single_for_cpu(struct device *dev,



[net-next PATCH 01/27] swiotlb: Drop unused function swiotlb_map_sg

2016-10-25 Thread Alexander Duyck
There are no users for swiotlb_map_sg so we might as well just drop it.

Acked-by: Konrad Rzeszutek Wilk 
Signed-off-by: Alexander Duyck 
---
 include/linux/swiotlb.h |4 
 lib/swiotlb.c   |8 
 2 files changed, 12 deletions(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 5f81f8a..e237b6f 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -72,10 +72,6 @@ extern void swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
   size_t size, enum dma_data_direction dir,
   unsigned long attrs);
 
-extern int
-swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
-  enum dma_data_direction dir);
-
 extern void
 swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
 enum dma_data_direction dir);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 22e13a0..47aad37 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -910,14 +910,6 @@ void swiotlb_unmap_page(struct device *hwdev, dma_addr_t 
dev_addr,
 }
 EXPORT_SYMBOL(swiotlb_map_sg_attrs);
 
-int
-swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
-  enum dma_data_direction dir)
-{
-   return swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, 0);
-}
-EXPORT_SYMBOL(swiotlb_map_sg);
-
 /*
  * Unmap a set of streaming mode DMA translations.  Again, cpu read rules
  * concerning calls here are the same as for swiotlb_unmap_page() above.



[net-next PATCH 04/27] arch/arc: Add option to skip sync on DMA mapping

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
later via a sync_for_cpu or sync_for_device call.

Cc: Vineet Gupta 
Cc: linux-snps-...@lists.infradead.org
Signed-off-by: Alexander Duyck 
---
 arch/arc/mm/dma.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index 20afc65..6303c34 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -133,7 +133,10 @@ static dma_addr_t arc_dma_map_page(struct device *dev, 
struct page *page,
unsigned long attrs)
 {
phys_addr_t paddr = page_to_phys(page) + offset;
-   _dma_cache_sync(paddr, size, dir);
+
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   _dma_cache_sync(paddr, size, dir);
+
return plat_phys_to_dma(dev, paddr);
 }
 



[net-next PATCH 07/27] arch/blackfin: Add option to skip sync on DMA map

2016-10-25 Thread Alexander Duyck
The use of DMA_ATTR_SKIP_CPU_SYNC was not consistent across all of the DMA
APIs in the arch/arm folder.  This change is meant to correct that so that
we get consistent behavior.

Cc: Steven Miao 
Signed-off-by: Alexander Duyck 
---
 arch/blackfin/kernel/dma-mapping.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/blackfin/kernel/dma-mapping.c 
b/arch/blackfin/kernel/dma-mapping.c
index 53fbbb6..a27a74a 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -118,6 +118,10 @@ static int bfin_dma_map_sg(struct device *dev, struct 
scatterlist *sg_list,
 
for_each_sg(sg_list, sg, nents, i) {
sg->dma_address = (dma_addr_t) sg_virt(sg);
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
__dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
}
 
@@ -143,7 +147,9 @@ static dma_addr_t bfin_dma_map_page(struct device *dev, 
struct page *page,
 {
dma_addr_t handle = (dma_addr_t)(page_address(page) + offset);
 
-   _dma_sync(handle, size, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   _dma_sync(handle, size, dir);
+
return handle;
 }
 



Re: Hexagon-setup: Combine four seq_printf() calls into one call in show_cpuinfo()

2016-10-25 Thread Richard Kuo
I wrote it the original way precisely for readability; it's easier, at least
to me, to read and modify the old way.

However, in my development version I happen to be printing a lot more
stuff.

To test, I collapsed 18 of my seq_printf's into one call.  That reduced the
function size by a couple hundred bytes.  (Didn't do anything for the final
kernel size though.)

If it makes things better, even if only slightly, doesn't introduce bugs, 
and doesn't otherwise violate any other rules (correct me if I'm wrong), I
would personally accept the minor readability tradeoff in this case.


Acked-by: Richard Kuo 



On Fri, Oct 21, 2016 at 08:50:11PM +0200, SF Markus Elfring wrote:
> > When the author of the semantic patch language is telling you to stand down,
> 
> The collaboration evolved between Julia and me during the years somehow.
> Different software development opinions occur then as usual.
> Further opinions from contributors like you can eventually show variations
> between disagreement and acceptance.
> 
> 
> > and you still want to try to argue for blind application of patches,
> 
> I guess that we have got different views about "blind" tries.
> 
> 
> > we have a really big problem.
> 
> I hope that potential communication difficulties can still be resolved.
> 
> 
> > Especially when some of your patches have actually introduced bugs.
> 
> I assume that these incidents could be clarified further, couldn't they?
> 
> Regards,
> Markus
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 05/27] arch/arm: Add option to skip sync on DMA map and unmap

2016-10-25 Thread Alexander Duyck
The use of DMA_ATTR_SKIP_CPU_SYNC was not consistent across all of the DMA
APIs in the arch/arm folder.  This change is meant to correct that so that
we get consistent behavior.

Cc: Russell King 
Signed-off-by: Alexander Duyck 
---
 arch/arm/common/dmabounce.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 3012816..75055df 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -243,7 +243,8 @@ static int needs_bounce(struct device *dev, dma_addr_t 
dma_addr, size_t size)
 }
 
 static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
-   enum dma_data_direction dir)
+   enum dma_data_direction dir,
+   unsigned long attrs)
 {
struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
struct safe_buffer *buf;
@@ -262,7 +263,8 @@ static inline dma_addr_t map_single(struct device *dev, 
void *ptr, size_t size,
__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
buf->safe, buf->safe_dma_addr);
 
-   if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) {
+   if ((dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) &&
+   !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
dev_dbg(dev, "%s: copy unsafe %p to safe %p, size %d\n",
__func__, ptr, buf->safe, size);
memcpy(buf->safe, ptr, size);
@@ -272,7 +274,8 @@ static inline dma_addr_t map_single(struct device *dev, 
void *ptr, size_t size,
 }
 
 static inline void unmap_single(struct device *dev, struct safe_buffer *buf,
-   size_t size, enum dma_data_direction dir)
+   size_t size, enum dma_data_direction dir,
+   unsigned long attrs)
 {
BUG_ON(buf->size != size);
BUG_ON(buf->direction != dir);
@@ -283,7 +286,8 @@ static inline void unmap_single(struct device *dev, struct 
safe_buffer *buf,
 
DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
-   if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) {
+   if ((dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) &&
+   !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
void *ptr = buf->ptr;
 
dev_dbg(dev, "%s: copy back safe %p to unsafe %p size %d\n",
@@ -334,7 +338,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, 
struct page *page,
return DMA_ERROR_CODE;
}
 
-   return map_single(dev, page_address(page) + offset, size, dir);
+   return map_single(dev, page_address(page) + offset, size, dir, attrs);
 }
 
 /*
@@ -357,7 +361,7 @@ static void dmabounce_unmap_page(struct device *dev, 
dma_addr_t dma_addr, size_t
return;
}
 
-   unmap_single(dev, buf, size, dir);
+   unmap_single(dev, buf, size, dir, attrs);
 }
 
 static int __dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,



Re: [RFC][PATCH] usb: dwc2: Make sure we disconnect the gadget state on reset

2016-10-25 Thread John Stultz
On Tue, Oct 25, 2016 at 2:29 PM, John Youn  wrote:
> On 10/19/2016 11:00 PM, John Stultz wrote:
>> I had seen some odd behavior with HiKey's usb-gadget interface
>> that I finally seemed to have chased down. Basically every other
>> time I pluged in the OTG port, the gadget interface would
>> properly initialize. The other times, I'd get a big WARN_ON
>> in dwc2_hsotg_init_fifo() about the fifo_map not being clear.
>>
>> Ends up If we don't disconnect the gadget state on reset, the
>> fifo-map doesn't get cleared properly, which causes WARN_ON
>> messages and also results in the device not properly being
>> setup as a gadget every other time the OTG port is connected.
>>
>> So this patch adds a call to dwc2_hsotg_disconnect() in the
>> reset path so the state is properly cleared.
>>
>> With it, the gadget interface initializes properly on every
>> plug in.
>>
>> I don't know if this is actually the right fix, but it seems
>> to work well. Feedback would be greatly appreciated!
>>
>> Cc: Wei Xu 
>> Cc: Guodong Xu 
>> Cc: Chen Yu 
>> Cc: Amit Pundir 
>> Cc: Rob Herring 
>> Cc: Mark Rutland 
>> Cc: John Youn 
>> Cc: Douglas Anderson 
>> Cc: Greg Kroah-Hartman 
>> Cc: linux-...@vger.kernel.org
>> Signed-off-by: John Stultz 
>> ---
>>  drivers/usb/dwc2/gadget.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>> index 24fbebc..5505001 100644
>> --- a/drivers/usb/dwc2/gadget.c
>> +++ b/drivers/usb/dwc2/gadget.c
>> @@ -2519,6 +2519,8 @@ void dwc2_hsotg_core_init_disconnected(struct 
>> dwc2_hsotg *hsotg,
>>
>>   /* Kill any ep0 requests as controller will be reinitialized */
>>   kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
>> + /* Make sure everything is disconnected */
>> + dwc2_hsotg_disconnect(hsotg);
>>
>>   if (!is_usb_reset)
>>   if (dwc2_core_reset(hsotg))
>>
>
> Seems fine with our testing.
>
> Acked-by: John Youn 

Awesome! Thanks so much for the review and testing!

I'm curious, did you happen to have any thoughts or objections on the
"dwc2: Force port resume on switching to device mode" patch
(https://patchwork.kernel.org/patch/9375965/ ) as well?

thanks
-john


[PATCH] thinkpad_acpi: Add support for X1 Yoga (2016) Tablet Mode

2016-10-25 Thread Lyude
For whatever reason, the X1 Yoga doesn't support the normal method of
querying for tablet mode. Instead of providing the MHKG method under the
hotkey handle, we're instead given the CMMD method under the EC handle.
Values on this handle are either 0x1, laptop mode, or 0x6, tablet mode.

Signed-off-by: Lyude 
---
So HOPEFULLY I actually did this right. There was some discussion here
previously about supporting this, and it was previously mentioned that the IOST
method was responsible for holding the current tablet status. However, it
really doesn't seem like this is the case:

Method (_Q2E, 0, NotSerialized)  // _Qxx: EC Query
{
Local0 = \_SB.PCI0.LPC.EC.CMMD
If ((Local0 != 0x00) && (Local0 <= 0x06))
{
If (Local0 != \PMMD)
{
\PMMD = Local0
\_SB.PCI0.LPC.EC.HKEY.MHKQ (0x60C0)
}
}

If ((Local0 == 0x00) || (Local0 >= 0x07))
{
Local1 = 0x01
}
ElseIf ((Local0 == 0x02) || (Local0 == 0x03))
{
Local1 = 0x02
}
Else
{
Local1 = 0x03
}

If (Local1 != \LVMD)
{
\LVMD = Local1
Sleep (0x0A)
\_SB.PCI0.LPC.EC.HKEY.MHKQ (0x60F0)
}
}

IOST seems to be present in the decompiled DSDT from my Yoga, however it's
quite far from the spot that actually sends the 0x60C0 hotkey event. Let me
know if you guys want to verify this against the full decompiled DSDT for this
machine.

 drivers/platform/x86/thinkpad_acpi.c | 36 +---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index b65ce75..8082dc9 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -190,6 +190,9 @@ enum tpacpi_hkey_event_t {
TP_HKEY_EV_LID_OPEN = 0x5002, /* laptop lid opened */
TP_HKEY_EV_TABLET_TABLET= 0x5009, /* tablet swivel up */
TP_HKEY_EV_TABLET_NOTEBOOK  = 0x500a, /* tablet swivel down */
+   TP_HKEY_EV_TABLET_CHANGED   = 0x60c0, /* X1 Yoga (2016):
+  * enter/leave tablet mode
+  */
TP_HKEY_EV_PEN_INSERTED = 0x500b, /* tablet pen inserted */
TP_HKEY_EV_PEN_REMOVED  = 0x500c, /* tablet pen removed */
TP_HKEY_EV_BRGHT_CHANGED= 0x5010, /* backlight control event */
@@ -303,6 +306,7 @@ static struct {
u32 hotkey_mask:1;
u32 hotkey_wlsw:1;
u32 hotkey_tablet:1;
+   u32 hotkey_tablet_cmmd:1;
u32 kbdlight:1;
u32 light:1;
u32 light_status:1;
@@ -2059,6 +2063,8 @@ static void hotkey_poll_setup(const bool may_warn);
 
 /* HKEY.MHKG() return bits */
 #define TP_HOTKEY_TABLET_MASK (1 << 3)
+/* ThinkPad X1 Yoga (2016) */
+#define TP_EC_CMMD_TABLET_MODE 0x6
 
 static int hotkey_get_wlsw(void)
 {
@@ -2083,10 +2089,18 @@ static int hotkey_get_tablet_mode(int *status)
 {
int s;
 
-   if (!acpi_evalf(hkey_handle, , "MHKG", "d"))
-   return -EIO;
+   if (tp_features.hotkey_tablet_cmmd) {
+   if (!acpi_evalf(ec_handle, , "CMMD", "d"))
+   return -EIO;
+
+   *status = (s == TP_EC_CMMD_TABLET_MODE);
+   } else {
+   if (!acpi_evalf(hkey_handle, , "MHKG", "d"))
+   return -EIO;
+
+   *status = ((s & TP_HOTKEY_TABLET_MASK) != 0);
+   }
 
-   *status = ((s & TP_HOTKEY_TABLET_MASK) != 0);
return 0;
 }
 
@@ -3475,6 +3489,18 @@ static int __init hotkey_init(struct ibm_init_struct 
*iibm)
_attr_hotkey_tablet_mode.attr);
}
 
+   /* For X1 Yoga (2016) */
+   if (!res && acpi_evalf(ec_handle, , "CMMD", "qd")) {
+   tp_features.hotkey_tablet = 1;
+   tp_features.hotkey_tablet_cmmd = 1;
+   tabletsw_state = (status == TP_EC_CMMD_TABLET_MODE);
+
+   pr_info("Possible tablet mode switch found; ThinkPad in %s 
mode\n",
+   (tabletsw_state) ? "tablet" : "laptop");
+   res = add_to_attr_set(hotkey_dev_attributes,
+ _attr_hotkey_tablet_mode.attr);
+   }
+
if (!res)
res = register_attr_set_with_sysfs(
hotkey_dev_attributes,
@@ -3899,6 +3925,10 @@ static bool hotkey_notify_6xxx(const u32 hkey,
*ignore_acpi_ev = true;
return true;
 
+   case TP_HKEY_EV_TABLET_CHANGED:
+   tpacpi_input_send_tabletsw();
+   break;
+
default:
pr_warn("unknown possible thermal alarm or keyboard event 
received\n");
known = false;
-- 
2.7.4



[PATCH 0/7] powerpc/mm: refactor vDSO mapping code

2016-10-25 Thread Dmitry Safonov
Cleanup patches for vDSO on powerpc.
Originally, I wanted to add vDSO remapping on arm/aarch64 and
I decided to cleanup that part on powerpc.
I've add a hook for vm_ops for vDSO just like I did for x86.
Other changes - reduce exhaustive code duplication.
No visible to userspace changes expected.

Tested on qemu with buildroot rootfs.

Dmitry Safonov (7):
  powerpc/vdso: unify return paths in setup_additional_pages
  powerpc/vdso: remove unused params in vdso_do_func_patch{32,64}
  powerpc/vdso: separate common code in vdso_common
  powerpc/vdso: introduce init_vdso{32,64}_pagelist
  powerpc/vdso: split map_vdso from arch_setup_additional_pages
  powerpc/vdso: switch from legacy_special_mapping_vmops
  mm: kill arch_mremap

 arch/alpha/include/asm/Kbuild|   1 -
 arch/arc/include/asm/Kbuild  |   1 -
 arch/arm/include/asm/Kbuild  |   1 -
 arch/arm64/include/asm/Kbuild|   1 -
 arch/avr32/include/asm/Kbuild|   1 -
 arch/blackfin/include/asm/Kbuild |   1 -
 arch/c6x/include/asm/Kbuild  |   1 -
 arch/cris/include/asm/Kbuild |   1 -
 arch/frv/include/asm/Kbuild  |   1 -
 arch/h8300/include/asm/Kbuild|   1 -
 arch/hexagon/include/asm/Kbuild  |   1 -
 arch/ia64/include/asm/Kbuild |   1 -
 arch/m32r/include/asm/Kbuild |   1 -
 arch/m68k/include/asm/Kbuild |   1 -
 arch/metag/include/asm/Kbuild|   1 -
 arch/microblaze/include/asm/Kbuild   |   1 -
 arch/mips/include/asm/Kbuild |   1 -
 arch/mn10300/include/asm/Kbuild  |   1 -
 arch/nios2/include/asm/Kbuild|   1 -
 arch/openrisc/include/asm/Kbuild |   1 -
 arch/parisc/include/asm/Kbuild   |   1 -
 arch/powerpc/include/asm/mm-arch-hooks.h |  28 --
 arch/powerpc/kernel/vdso.c   | 492 +--
 arch/powerpc/kernel/vdso_common.c| 248 
 arch/s390/include/asm/Kbuild |   1 -
 arch/score/include/asm/Kbuild|   1 -
 arch/sh/include/asm/Kbuild   |   1 -
 arch/sparc/include/asm/Kbuild|   1 -
 arch/tile/include/asm/Kbuild |   1 -
 arch/um/include/asm/Kbuild   |   1 -
 arch/unicore32/include/asm/Kbuild|   1 -
 arch/x86/include/asm/Kbuild  |   1 -
 arch/xtensa/include/asm/Kbuild   |   1 -
 include/asm-generic/mm-arch-hooks.h  |  16 -
 include/linux/mm-arch-hooks.h|  25 --
 mm/mremap.c  |   4 -
 36 files changed, 323 insertions(+), 520 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/mm-arch-hooks.h
 create mode 100644 arch/powerpc/kernel/vdso_common.c
 delete mode 100644 include/asm-generic/mm-arch-hooks.h
 delete mode 100644 include/linux/mm-arch-hooks.h

-- 
2.10.0



Re: [PATCH] iio: maxim_thermocouple: return -EINVAL on invalid read size

2016-10-25 Thread Colin Ian King
On 25/10/16 20:11, Lars-Peter Clausen wrote:
> On 10/25/2016 09:04 PM, Colin King wrote:
>> From: Colin Ian King 
>>
>> In the case that the read size is not 2 or 4 bytes
>> then maxim_thermocouple_read is not initializing ret and
>> hence may return early with a bogus error return or
>> just through to return with a bogos unread value in *val.
>> Fix this by setting ret to -EINVAL for invalid (unhandled)
>> read sizes.
>>
>> Signed-off-by: Colin Ian King 
> 
> Again, Arnd already took the prize, https://lkml.org/lkml/2016/10/25/518
> 
Not my day :-)

Colin


Re: [PATCH] tpm: sanitize constant expressions

2016-10-25 Thread Jarkko Sakkinen
On Sat, Oct 22, 2016 at 12:39:27AM +0300, Jarkko Sakkinen wrote:
> Use cpu_to_b32 at the time it is needed in enum tpm_capabilities and
> enum tpm_sub_capabilities in order to be consistent with the other
> enums in drivats/char/tpm/tpm.h.
> 
> Signed-off-by: Jarkko Sakkinen 

I'll apply this to my master branch as it is very trivial patch. Report
if you have any problems.

/Jarkko

> ---
> v2: parameter type of subcap_id to u32
>  drivers/char/tpm/tpm-interface.c | 15 +--
>  drivers/char/tpm/tpm-sysfs.c |  4 ++--
>  drivers/char/tpm/tpm.h   | 25 -
>  3 files changed, 23 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c 
> b/drivers/char/tpm/tpm-interface.c
> index acf89e8..fa97520 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -442,26 +442,29 @@ static const struct tpm_input_header tpm_getcap_header 
> = {
>   .ordinal = TPM_ORD_GET_CAP
>  };
>  
> -ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
> +ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
>  const char *desc)
>  {
>   struct tpm_cmd_t tpm_cmd;
>   int rc;
>  
>   tpm_cmd.header.in = tpm_getcap_header;
> - if (subcap_id == CAP_VERSION_1_1 || subcap_id == CAP_VERSION_1_2) {
> - tpm_cmd.params.getcap_in.cap = subcap_id;
> + if (subcap_id == TPM_CAP_VERSION_1_1 ||
> + subcap_id == TPM_CAP_VERSION_1_2) {
> + tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
>   /*subcap field not necessary */
>   tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
>   tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
>   } else {
>   if (subcap_id == TPM_CAP_FLAG_PERM ||
>   subcap_id == TPM_CAP_FLAG_VOL)
> - tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
> + tpm_cmd.params.getcap_in.cap =
> + cpu_to_be32(TPM_CAP_FLAG);
>   else
> - tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
> + tpm_cmd.params.getcap_in.cap =
> + cpu_to_be32(TPM_CAP_PROP);
>   tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
> - tpm_cmd.params.getcap_in.subcap = subcap_id;
> + tpm_cmd.params.getcap_in.subcap = cpu_to_be32(subcap_id);
>   }
>   rc = tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, 0,
> desc);
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
> index a76ab4a..59a1ead 100644
> --- a/drivers/char/tpm/tpm-sysfs.c
> +++ b/drivers/char/tpm/tpm-sysfs.c
> @@ -193,7 +193,7 @@ static ssize_t caps_show(struct device *dev, struct 
> device_attribute *attr,
>  be32_to_cpu(cap.manufacturer_id));
>  
>   /* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */
> - rc = tpm_getcap(chip, CAP_VERSION_1_2, ,
> + rc = tpm_getcap(chip, TPM_CAP_VERSION_1_2, ,
>   "attempting to determine the 1.2 version");
>   if (!rc) {
>   str += sprintf(str,
> @@ -204,7 +204,7 @@ static ssize_t caps_show(struct device *dev, struct 
> device_attribute *attr,
>  cap.tpm_version_1_2.revMinor);
>   } else {
>   /* Otherwise just use TPM_STRUCT_VER */
> - rc = tpm_getcap(chip, CAP_VERSION_1_1, ,
> + rc = tpm_getcap(chip, TPM_CAP_VERSION_1_1, ,
>   "attempting to determine the 1.1 version");
>   if (rc)
>   return 0;
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 4d183c9..1864932 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -282,21 +282,20 @@ typedef union {
>  } cap_t;
>  
>  enum tpm_capabilities {
> - TPM_CAP_FLAG = cpu_to_be32(4),
> - TPM_CAP_PROP = cpu_to_be32(5),
> - CAP_VERSION_1_1 = cpu_to_be32(0x06),
> - CAP_VERSION_1_2 = cpu_to_be32(0x1A)
> + TPM_CAP_FLAG = 4,
> + TPM_CAP_PROP = 5,
> + TPM_CAP_VERSION_1_1 = 0x06,
> + TPM_CAP_VERSION_1_2 = 0x1A,
>  };
>  
>  enum tpm_sub_capabilities {
> - TPM_CAP_PROP_PCR = cpu_to_be32(0x101),
> - TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103),
> - TPM_CAP_FLAG_PERM = cpu_to_be32(0x108),
> - TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
> - TPM_CAP_PROP_OWNER = cpu_to_be32(0x111),
> - TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115),
> - TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120),
> -
> + TPM_CAP_PROP_PCR = 0x101,
> + TPM_CAP_PROP_MANUFACTURER = 0x103,
> + TPM_CAP_FLAG_PERM = 0x108,
> + TPM_CAP_FLAG_VOL = 0x109,
> + TPM_CAP_PROP_OWNER = 0x111,
> + TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
> + TPM_CAP_PROP_TIS_DURATION = 0x120,
>  };
>  
>  struct   

Re: [tpmdd-devel] [PATCH] tpm, tpm_crb: remove redundant CRB_FL_CRB_START flag

2016-10-25 Thread Jarkko Sakkinen
On Fri, Oct 21, 2016 at 06:11:41PM +0300, Jarkko Sakkinen wrote:
> On Thu, Oct 20, 2016 at 02:24:21PM -0600, Jason Gunthorpe wrote:
> > On Thu, Oct 20, 2016 at 05:00:11PM +0300, Jarkko Sakkinen wrote:
> > 
> > > > > I have a 4th Gen Core NUC where I experienced this issue. It reported
> > > > > requiring only ACPI start but actually required ACPI + CRB start. The
> > > > > comment could have been better.
> > 
> > Shouldn't bios work arounds be keyed on something? What happens if a
> > system rolls around that cannot do ACPI + CRB start? How does this
> > system work in windows?
> 
> I didn't find anything better to key it on at the time and it has been
> working for two years now without any problems.

I've though about this and came to conclusion that maybe I won't apply
this patch because it is good to keep this robustness in for now. I
think your point is valid.

/Jarkko


Re: [PATCH 2/3] usb: dwc3: host: Do not use dma_set_coherent_mask

2016-10-25 Thread Arnd Bergmann
On Tuesday, October 25, 2016 4:26:27 PM CEST Sriram Dash wrote:
> Do not require dma_set_coherent_mask for hcd
> 
> Signed-off-by: Arnd Bergmann 

Aside from the comments I had for patch 3, you are doing two
different things here:

> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index 89a2f71..4d7439c 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -218,7 +218,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
>   if (IS_ERR(regmap))
>   return PTR_ERR(regmap);
>  
> - dma_set_coherent_mask(dev, dev->coherent_dma_mask);
>   dwc3_data->dev = dev;
>   dwc3_data->regmap = regmap;
>  

This one was setting the mask for the device itself (incorrectly),
so it can be removed along with the dma_coerce_mask_and_coherent()
call in dwc3_exynos_probe, or as a separate patch. It is an
independent cleanup.

> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -833,9 +833,6 @@ struct platform_device *ci_hdrc_add_device(struct device 
> *dev,
>
> - dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
>  
>   ret = platform_device_add_resources(pdev, res, nres);
>   if (ret)

> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1059,12 +1059,6 @@ static int dwc3_probe(struct platform_device *pdev)
>  
>   spin_lock_init(>lock);
>  
> - dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);

> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -72,11 +72,7 @@ int dwc3_host_init(struct dwc3 *dwc)
>   return -ENOMEM;
>   }
>  
> - dma_set_coherent_mask(>dev, dwc->dev->coherent_dma_mask);
> -

These three all set the mask for the *child* devices, as
that is no longer needed after the change in patch 1/3.
I'd suggest leaving those changes together with the rest of
that patch.

However, it's probably better to split up that patch along the
boundaries of the drivers, starting with the USB core:

1/4 usb: separate out sysdev pointer from usb_bus
2/4 usb: chipidea: use bus->sysdev for DMA configuration
3/4 usb: xhci: use bus->sysdev for DMA configuration
4/4 usb: dwc3: use bus->sysdev for DMA configuration

Arnd


Re: [PATCH] phy: Add reset callback for not generic phy

2016-10-25 Thread John Youn
On 10/25/2016 7:15 AM, Randy Li wrote:
> I forget to add a dummy function in case the CONFIG_GENERIC_PHY
> is disabled.
> 
> Signed-off-by: Randy Li 

Fixes: cac18ecb6f44 ("phy: Add reset callback")
Tested-by: John Youn 

Hi Kishon,

Can you take this for 4.9-rc?

Thanks,
John



> ---
>  include/linux/phy/phy.h | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index ee1bed7..78bb0d7 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -253,6 +253,13 @@ static inline int phy_set_mode(struct phy *phy, enum 
> phy_mode mode)
>   return -ENOSYS;
>  }
>  
> +static inline int phy_reset(struct phy *phy)
> +{
> + if (!phy)
> + return 0;
> + return -ENOSYS;
> +}
> +
>  static inline int phy_get_bus_width(struct phy *phy)
>  {
>   return -ENOSYS;
> 
>





Re: [PATCH 0/3] iopmem : A block device for PCIe memory

2016-10-25 Thread Dave Chinner
On Tue, Oct 25, 2016 at 05:50:43AM -0600, Stephen Bates wrote:
> Hi Dave and Christoph
> 
> On Fri, Oct 21, 2016 at 10:12:53PM +1100, Dave Chinner wrote:
> > On Fri, Oct 21, 2016 at 02:57:14AM -0700, Christoph Hellwig wrote:
> > > On Fri, Oct 21, 2016 at 10:22:39AM +1100, Dave Chinner wrote:
> > > > You do realise that local filesystems can silently change the
> > > > location of file data at any point in time, so there is no such
> > > > thing as a "stable mapping" of file data to block device addresses
> > > > in userspace?
> > > >
> > > > If you want remote access to the blocks owned and controlled by a
> > > > filesystem, then you need to use a filesystem with a remote locking
> > > > mechanism to allow co-ordinated, coherent access to the data in
> > > > those blocks. Anything else is just asking for ongoing, unfixable
> > > > filesystem corruption or data leakage problems (i.e.  security
> > > > issues).
> > >
> 
> Dave are you saying that even for local mappings of files on a DAX
> capable system it is possible for the mappings to move on you unless
> the FS supports locking?

Yes.

> Does that not mean DAX on such FS is
> inherently broken?

No. DAX is accessed through a virtual mapping layer that abstracts
the physical location from userspace applications.

Example: think copy-on-write overwrites. It occurs atomically from
the perspective of userspace and starts by invalidating any current
mappings userspace has of that physical location. The location is
changes, the data copied in, and then when the locks are released
userspace can fault in a new page table mapping on the next
access

> > > And at least for XFS we have such a mechanism :)  E.g. I have a
> > > prototype of a pNFS layout that uses XFS+DAX to allow clients to do
> > > RDMA directly to XFS files, with the same locking mechanism we use
> > > for the current block and scsi layout in xfs_pnfs.c.
> 
> Thanks for fixing this issue on XFS Christoph! I assume this problem
> continues to exist on the other DAX capable FS?

Yes, but it they implement the exportfs API that supplies this
capability, they'll be able to use pNFS, too.

> One more reason to consider a move to /dev/dax I guess ;-)...

That doesn't get rid of the need for sane access control arbitration
across all machines that are directly accessing the storage. That's
the problem pNFS solves, regardless of whether your direct access
target is a filesystem, a block device or object storage...

Cheers,

Dave.
-- 
Dave Chinner
da...@fromorbit.com


[PATCHv2 7/7] mm: kill arch_mremap

2016-10-25 Thread Dmitry Safonov
This reverts commit 4abad2ca4a4d ("mm: new arch_remap() hook") and
commit 2ae416b142b6 ("mm: new mm hook framework").
It also keeps the same functionality of mremapping vDSO blob with
introducing vm_special_mapping mremap op for powerpc.

Cc: Laurent Dufour 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: "Kirill A. Shutemov" 
Cc: Andy Lutomirski 
Cc: Oleg Nesterov 
Cc: Andrew Morton 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux...@kvack.org 
Signed-off-by: Dmitry Safonov 
---
v2: use vdso64_pages only under CONFIG_PPC64

 arch/alpha/include/asm/Kbuild|  1 -
 arch/arc/include/asm/Kbuild  |  1 -
 arch/arm/include/asm/Kbuild  |  1 -
 arch/arm64/include/asm/Kbuild|  1 -
 arch/avr32/include/asm/Kbuild|  1 -
 arch/blackfin/include/asm/Kbuild |  1 -
 arch/c6x/include/asm/Kbuild  |  1 -
 arch/cris/include/asm/Kbuild |  1 -
 arch/frv/include/asm/Kbuild  |  1 -
 arch/h8300/include/asm/Kbuild|  1 -
 arch/hexagon/include/asm/Kbuild  |  1 -
 arch/ia64/include/asm/Kbuild |  1 -
 arch/m32r/include/asm/Kbuild |  1 -
 arch/m68k/include/asm/Kbuild |  1 -
 arch/metag/include/asm/Kbuild|  1 -
 arch/microblaze/include/asm/Kbuild   |  1 -
 arch/mips/include/asm/Kbuild |  1 -
 arch/mn10300/include/asm/Kbuild  |  1 -
 arch/nios2/include/asm/Kbuild|  1 -
 arch/openrisc/include/asm/Kbuild |  1 -
 arch/parisc/include/asm/Kbuild   |  1 -
 arch/powerpc/include/asm/mm-arch-hooks.h | 28 
 arch/powerpc/kernel/vdso.c   | 25 +
 arch/powerpc/kernel/vdso_common.c|  1 +
 arch/s390/include/asm/Kbuild |  1 -
 arch/score/include/asm/Kbuild|  1 -
 arch/sh/include/asm/Kbuild   |  1 -
 arch/sparc/include/asm/Kbuild|  1 -
 arch/tile/include/asm/Kbuild |  1 -
 arch/um/include/asm/Kbuild   |  1 -
 arch/unicore32/include/asm/Kbuild|  1 -
 arch/x86/include/asm/Kbuild  |  1 -
 arch/xtensa/include/asm/Kbuild   |  1 -
 include/asm-generic/mm-arch-hooks.h  | 16 
 include/linux/mm-arch-hooks.h| 25 -
 mm/mremap.c  |  4 
 36 files changed, 26 insertions(+), 103 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/mm-arch-hooks.h
 delete mode 100644 include/asm-generic/mm-arch-hooks.h
 delete mode 100644 include/linux/mm-arch-hooks.h

diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index bf8475ce85ee..0a5e0ec2842b 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -6,7 +6,6 @@ generic-y += exec.h
 generic-y += export.h
 generic-y += irq_work.h
 generic-y += mcs_spinlock.h
-generic-y += mm-arch-hooks.h
 generic-y += preempt.h
 generic-y += sections.h
 generic-y += trace_clock.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index c332604606dd..e6059a808463 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -22,7 +22,6 @@ generic-y += kvm_para.h
 generic-y += local.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
-generic-y += mm-arch-hooks.h
 generic-y += mman.h
 generic-y += msgbuf.h
 generic-y += msi.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 0745538b26d3..44b717cb4a55 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -15,7 +15,6 @@ generic-y += irq_regs.h
 generic-y += kdebug.h
 generic-y += local.h
 generic-y += local64.h
-generic-y += mm-arch-hooks.h
 generic-y += msgbuf.h
 generic-y += msi.h
 generic-y += param.h
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 44e1d7f10add..a42a1367aea4 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -20,7 +20,6 @@ generic-y += kvm_para.h
 generic-y += local.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
-generic-y += mm-arch-hooks.h
 generic-y += mman.h
 generic-y += msgbuf.h
 generic-y += msi.h
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild
index 241b9b9729d8..519810d0d5e1 100644
--- a/arch/avr32/include/asm/Kbuild
+++ b/arch/avr32/include/asm/Kbuild
@@ -12,7 +12,6 @@ generic-y += irq_work.h
 generic-y += local.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
-generic-y += mm-arch-hooks.h
 generic-y += param.h
 generic-y += percpu.h
 generic-y += preempt.h
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild
index 91d49c0a3118..c80181e4454f 100644
--- a/arch/blackfin/include/asm/Kbuild
+++ 

Re: [PATCH v2 0/9] mtd: spi-nor: parse SFDP tables to setup (Q)SPI memories

2016-10-25 Thread Jagan Teki
Hi Cyrille,

On Tue, Oct 25, 2016 at 2:38 PM, Jagan Teki  wrote:
> On Mon, Oct 24, 2016 at 7:37 PM, Cyrille Pitchen
>  wrote:
>> Le 24/10/2016 à 14:09, Cyrille Pitchen a écrit :
>>> Hi Jagan,
>>>
>>> Le 24/10/2016 à 09:41, Jagan Teki a écrit :
 On Sun, Oct 23, 2016 at 2:03 AM, Marek Vasut  wrote:
> On 10/22/2016 01:00 PM, Jagan Teki wrote:
>> On Wed, Oct 5, 2016 at 5:30 PM, Cyrille Pitchen
>>  wrote:
>>> Hi all,
>>>
>>> This series extends support of SPI protocols to new protocols such as
>>> SPI x-2-2 and SPI x-4-4. Also spi_nor_scan() tries now to select the 
>>> right
>>> op codes, timing parameters (number of mode and dummy cycles) and erase
>>> sector size by parsing the Serial Flash Discoverable Parameter (SFDP)
>>> tables, when available, as defined in the JEDEC JESD216 specifications.
>>>
>>> When SFDP tables are not available, legacy settings are still used for
>>> backward compatibility (SPI and earlier QSPI memories).
>>>
>>> Support of SPI memories >128Mbits is also improved by using the 4byte
>>> address instruction set, when available. Using those dedicated op codes
>>> is stateless as opposed to enter the 4byte address mode, hence a better
>>> compatibility with some boot loaders which expect to use 3byte address
>>> op codes.
>>
>> The memories which are > 128Mbits should have 4-bytes addressing
>> support based on my experience, do you think BAR is also required
>> atleast from spi-nor side?
>
> Yes, I believe BAR is still required for broken/dumb flash chips.
> Not all chips > 16 MiB support dedicated 4-byte addressing opcodes :-(

 Do you have list for those broken chips? because I never find any
 chips which has > 16 MiB with not support of 4-byte address opcodes
 and I've seen the controller has dependable with BAR though it can
 access > 16MiB ex: zynq qspi/

 thanks!

>>>
>>> Let's take the case of Micron n25q256* memories. Depending of the part 
>>> number,
>>> the 12h op code is associated with either 4-byte address Page Program 1-1-1
>>> or 3-byte address Page Program 1-4-4.
>>> Then considering parts where the 12h op code is used for 3-byte address Page
>>> Program 1-4-4, there is no op code for a 4-byte address Page Program 1-1-1.
>>>
>>> Note 15, extracted from the Micron n25q_256mb_3v_65nm.pdf datasheet, about
>>> the 3-byte address Page Program 1-4-4 (Extended Quad Input Fast Program):
>>> The code 38h is valid only for part numbers N25Q256A83ESF40x, 
>>> N25Q256A83E1240x
>>> and N25Q256A83ESFA0F; the code 12h is valid for the other part numbers.

I am trying to understand the conflict more clearly with an example of
Micron, so on Table 18 from Micron n25q_256mb_3v_65nm.pdf datasheet,
Page program 3-byte has 02h and Quad page program 3-byte has 32h but
for 4-byte addressing only quad page program (no support of page
program) can be either 02h/32h/12h and indeed these can change based
on the n25q256* parts so why can't we rely on Quad page program for
4-byte addressing? and so there is no necessity for BAR here.

And also other than the un-supported-controller can't we rely directly
on supported page program opcodes for 4-byte addressing? say if it is
supporting QPP on 4-byte then use it as it is and no need to take care
of PP here.

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.


Re: [PATCH] virtio-net: Update the mtu code to match virtio spec

2016-10-25 Thread Aaron Conole
Aaron Conole  writes:

>> From: Aaron Conole 
>>
>> The virtio committee recently ratified a change, VIRTIO-152, which
>> defines the mtu field to be 'max' MTU, not simply desired MTU.
>>
>> This commit brings the virtio-net device in compliance with VIRTIO-152.
>>
>> Additionally, drop the max_mtu branch - it cannot be taken since the u16
>> returned by virtio_cread16 will never exceed the initial value of
>> max_mtu.
>>
>> Cc: "Michael S. Tsirkin" 
>> Cc: Jarod Wilson 
>> Signed-off-by: Aaron Conole 
>> ---
>
> Sorry about the subject line, David.  This is targetted at net-next, and
> it appears my from was mangled.  Would you like me to resubmit with
> these details corrected?

I answered my own question.  Sorry for the noise.


Re: [PATCH 1/3] drivers: iommu: arm-smmu: constify iommu_gather_ops structures

2016-10-25 Thread Julia Lawall


On Tue, 25 Oct 2016, Bhumika Goyal wrote:

> Check for iommu_gather_ops structures that are only stored in the tlb
> field of an io_pgtable_cfg structure. The tlb field is of type
> const struct iommu_gather_ops *, so iommu_gather_ops structures
> having this property can be declared as const.
>
> Signed-off-by: Bhumika Goyal 

Acked-by: Julia Lawall 

> ---
>  drivers/iommu/arm-smmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index c841eb7..a5bc8fb 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -640,7 +640,7 @@ static void arm_smmu_tlb_inv_range_nosync(unsigned long 
> iova, size_t size,
>   }
>  }
>
> -static struct iommu_gather_ops arm_smmu_gather_ops = {
> +static const struct iommu_gather_ops arm_smmu_gather_ops = {
>   .tlb_flush_all  = arm_smmu_tlb_inv_context,
>   .tlb_add_flush  = arm_smmu_tlb_inv_range_nosync,
>   .tlb_sync   = arm_smmu_tlb_sync,
> --
> 1.9.1
>
>


Re: [PATCH 2/3] drivers: iommu: arm-smmu-v3: constify iommu_gather_ops structures

2016-10-25 Thread Julia Lawall


On Tue, 25 Oct 2016, Bhumika Goyal wrote:

> Check for iommu_gather_ops structures that are only stored in the tlb
> field of an io_pgtable_cfg structure. The tlb field is of type
> const struct iommu_gather_ops *, so iommu_gather_ops structures
> having this property can be declared as const.
>
> Signed-off-by: Bhumika Goyal 

Acked-by: Julia Lawall 

> ---
>  drivers/iommu/arm-smmu-v3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> index 15c01c3..51d8be4 100644
> --- a/drivers/iommu/arm-smmu-v3.c
> +++ b/drivers/iommu/arm-smmu-v3.c
> @@ -1358,7 +1358,7 @@ static void arm_smmu_tlb_inv_range_nosync(unsigned long 
> iova, size_t size,
>   } while (size -= granule);
>  }
>
> -static struct iommu_gather_ops arm_smmu_gather_ops = {
> +static const struct iommu_gather_ops arm_smmu_gather_ops = {
>   .tlb_flush_all  = arm_smmu_tlb_inv_context,
>   .tlb_add_flush  = arm_smmu_tlb_inv_range_nosync,
>   .tlb_sync   = arm_smmu_tlb_sync,
> --
> 1.9.1
>
>


[PATCH v2] cw1200: fix bogus maybe-uninitialized warning

2016-10-25 Thread Arnd Bergmann
On x86, the cw1200 driver produces a rather silly warning about the
possible use of the 'ret' variable without an initialization
presumably after being confused by the architecture specific definition
of WARN_ON:

drivers/net/wireless/st/cw1200/wsm.c: In function ‘wsm_handle_rx’:
drivers/net/wireless/st/cw1200/wsm.c:1457:9: error: ‘ret’ may be used 
uninitialized in this function [-Werror=maybe-uninitialized]

We have already checked that 'count' is larger than 0 here, so
we know that 'ret' is initialized. Changing the 'for' loop
into do/while also makes this clear to the compiler.

Suggested-by: David Laight 
Signed-off-by: Arnd Bergmann 
---
 drivers/net/wireless/st/cw1200/wsm.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

v2: rewrite based on David Laight's suggestion, the first version
was completely wrong.

diff --git a/drivers/net/wireless/st/cw1200/wsm.c 
b/drivers/net/wireless/st/cw1200/wsm.c
index 680d60eabc75..ed93bf3474ec 100644
--- a/drivers/net/wireless/st/cw1200/wsm.c
+++ b/drivers/net/wireless/st/cw1200/wsm.c
@@ -379,7 +379,6 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv,
 {
int ret;
int count;
-   int i;
 
count = WSM_GET32(buf);
if (WARN_ON(count <= 0))
@@ -395,11 +394,10 @@ static int wsm_multi_tx_confirm(struct cw1200_common 
*priv,
}
 
cw1200_debug_txed_multi(priv, count);
-   for (i = 0; i < count; ++i) {
+   do {
ret = wsm_tx_confirm(priv, buf, link_id);
-   if (ret)
-   return ret;
-   }
+   } while (!ret && --count);
+
return ret;
 
 underflow:
-- 
2.9.0



[net-next PATCH 11/27] arch/m68k: Add option to skip DMA sync as a part of mapping

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
later via a sync_for_cpu or sync_for_device call.

Cc: Geert Uytterhoeven 
Cc: linux-m...@lists.linux-m68k.org
Signed-off-by: Alexander Duyck 
---
 arch/m68k/kernel/dma.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index 8cf97cb..0707006 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -134,7 +134,9 @@ static dma_addr_t m68k_dma_map_page(struct device *dev, 
struct page *page,
 {
dma_addr_t handle = page_to_phys(page) + offset;
 
-   dma_sync_single_for_device(dev, handle, size, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   dma_sync_single_for_device(dev, handle, size, dir);
+
return handle;
 }
 
@@ -146,6 +148,10 @@ static int m68k_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
 
for_each_sg(sglist, sg, nents, i) {
sg->dma_address = sg_phys(sg);
+
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
dma_sync_single_for_device(dev, sg->dma_address, sg->length,
   dir);
}



[net-next PATCH 10/27] arch/hexagon: Add option to skip DMA sync as a part of mapping

2016-10-25 Thread Alexander Duyck
This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
avoid invoking cache line invalidation if the driver will just handle it
later via a sync_for_cpu or sync_for_device call.

Cc: Richard Kuo 
Cc: linux-hexa...@vger.kernel.org
Signed-off-by: Alexander Duyck 
---
 arch/hexagon/kernel/dma.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c
index b901778..dbc4f10 100644
--- a/arch/hexagon/kernel/dma.c
+++ b/arch/hexagon/kernel/dma.c
@@ -119,6 +119,9 @@ static int hexagon_map_sg(struct device *hwdev, struct 
scatterlist *sg,
 
s->dma_length = s->length;
 
+   if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+   continue;
+
flush_dcache_range(dma_addr_to_virt(s->dma_address),
   dma_addr_to_virt(s->dma_address + 
s->length));
}
@@ -180,7 +183,8 @@ static dma_addr_t hexagon_map_page(struct device *dev, 
struct page *page,
if (!check_addr("map_single", dev, bus, size))
return bad_dma_address;
 
-   dma_sync(dma_addr_to_virt(bus), size, dir);
+   if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+   dma_sync(dma_addr_to_virt(bus), size, dir);
 
return bus;
 }



Re: [RFC PATCH 0/6] UART slave devices using serio

2016-10-25 Thread Sebastian Reichel
Hi,

On Wed, Aug 24, 2016 at 06:24:30PM -0500, Rob Herring wrote:
> This is a new approach to supporting UART slave devices using the
> existing serio bus. After Arnd's proding, I took another look at serio
> and decided extending it does make sense. Using serio primarily requires
> adding DT based device matching and supporting buffer based write and
> receive.
> 
> Currently, I'm using the existing serio serport ldisc for testing. This
> requires using inputattach to open the tty and set the ldisc which in
> turn registers a serio port with the serio core:
> 
> inputattach -bare /dev/ttyAMA1
> 
> Once a tty_port based serio port driver is in place, this step will not
> be needed. Supporting cases like a USB UART will also work if the USB
> UART is described in DT. If not described in DT, I'm not sure if the
> existing serio manual binding is sufficient (Need to figure out how that
> works). Slave drivers also need other ways to specify additional data
> using module params perhaps. Getting DT overlays to work for
> non-discoverable devices behind discoverable buses (i.e. detached from
> a base DT) is another option, but that's not yet supported in general.
> 
> I've done all the serio changes in place, but ultimately I think at
> least the core of serio should be moved out of drivers/input/. I don't
> think it belongs under drivers/tty/ or drivers/tty/serial/, so
> drivers/serio/?
> 
> BT is working under QEMU to the point a slave driver can bind to a
> serio port device via DT, register as a BT device, start sending out
> initial packets and receive data (typed at a terminal). Now I need to
> find a real device.

I had a more detailed look at the series during the last two weeks.
For me the approach looks ok and it should work for the nokia bluetooth
use case. Actually my work on that driver is more or less stalled until
this is solved, so it would be nice to get this forward. Whose feedback
is this waiting from? I guess

 * Alan & Greg for the serial parts
 * Marcel for the bluetooth parts
 * Dmitry for the serio parts

Maybe you can try to find some minutes at the Kernel Summit to talk
about this?

Anyways, for the series:

Tested-By: Sebastian Reichel 

-- Sebastian


signature.asc
Description: PGP signature


  1   2   3   4   5   6   7   8   9   10   >