RE: [PATCH][v3] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided

2016-02-21 Thread Zheng, Lv
Hi, Yu

> From: linux-acpi-ow...@vger.kernel.org [mailto:linux-acpi-
> ow...@vger.kernel.org] On Behalf Of Chen Yu
> Subject: [PATCH][v3] ACPI: Do not report _OSI("Darwin") when
> acpi_osi=!Darwin provided
> 
> Commit 7bc5a2bad0b8 ("ACPI: Support _OSI("Darwin") correctly") always
> reports positive value when Apple hardware queries _OSI("Darwin").
> But sometimes the users might want to tell the hardware they don't
> need the Darwin feature, for example, users may leverage the hardware
> to power off the Thunderbolt, by appending acpi_osi=!Darwin in command
> line, thus Apple hardware regards it as an incompatible OS X system,
> hence turns off the Thunderbolt.
[Lv Zheng] 
Both this patch and the original commit that is from Matthew look wrong to me.
IMO, the feature should be done with an entirely different approach.
Without test, I'm not sure if my comment is helpful for you.
So could you let me take over to fix this issue?

Thanks and best regards
-Lv

> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111
> Signed-off-by: Chen Yu 
> ---
> v3:
>  - Simplify acpi_osi_setup_disabled suggested by Andy Shevchenko.
> v2:
>  - Convert osi_setup_entries to non-initdata variable, to
>eliminate the warning from 0-DAY test infrastructure.
> ---
>  drivers/acpi/osl.c | 26 +++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
> index 67da6fb..8bb3a93 100644
> --- a/drivers/acpi/osl.c
> +++ b/drivers/acpi/osl.c
> @@ -97,6 +97,7 @@ static LIST_HEAD(acpi_ioremaps);
>  static DEFINE_MUTEX(acpi_ioremap_lock);
> 
>  static void __init acpi_osi_setup_late(void);
> +static bool acpi_osi_setup_disabled(char *str);
> 
>  /*
>   * The story of _OSI(Linux)
> @@ -149,11 +150,13 @@ static u32 acpi_osi_handler(acpi_string interface,
> u32 supported)
>   osi_linux.dmi ? " via DMI" : "");
>   }
> 
> - if (!strcmp("Darwin", interface)) {
> + if (!strcmp("Darwin", interface) &&
> + !acpi_osi_setup_disabled(interface)) {
>   /*
>* Apple firmware will behave poorly if it receives positive
>* answers to "Darwin" and any other OS. Respond positively
> -  * to Darwin and then disable all other vendor strings.
> +  * to Darwin and then disable all other vendor strings if
> +  * acpi_osi="!Darwin" is not appended in cmdline.
>*/
> 
>   acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
>   supported = ACPI_UINT32_MAX;
> @@ -1688,13 +1691,30 @@ struct osi_setup_entry {
>  };
> 
>  static struct osi_setup_entry
> - osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
> + osi_setup_entries[OSI_STRING_ENTRIES_MAX] = {
>   {"Module Device", true},
>   {"Processor Device", true},
>   {"3.0 _SCP Extensions", true},
>   {"Processor Aggregator Device", true},
>  };
> 
> +static bool acpi_osi_setup_disabled(char *str)
> +{
> + int i;
> + struct osi_setup_entry *osi;
> +
> + if (str == NULL || *str == '\0')
> + return false;
> +
> + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
> + osi = _setup_entries[i];
> + if (!strcmp(osi->string, str))
> + return !osi->enable;
> + }
> +
> + return false;
> +}
> +
>  void __init acpi_osi_setup(char *str)
>  {
>   struct osi_setup_entry *osi;
> --
> 1.8.4.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/8] EC-based USB Power Delivery support for Chrome machines

2016-02-21 Thread Tomeu Vizoso
On 20 February 2016 at 17:22, Pavel Machek  wrote:
> Hi!
>
>> this series contains a driver that exposes a power_supply to userspace
>> representing a port that support USB PD charging.
>
> Well, if this is meant for userspace, should it add some
> documentation, too?

Hi Pavel, in v3 I have dropped any new sysfs attributes, so everything
exposed to userspace is already documented.

Thanks,

Tomeu

> Thanks,
> Pavel
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Re: [PATCH v2 0/8] EC-based USB Power Delivery support for Chrome machines

2016-02-21 Thread Tomeu Vizoso
On 20 February 2016 at 17:22, Pavel Machek  wrote:
> Hi!
>
>> this series contains a driver that exposes a power_supply to userspace
>> representing a port that support USB PD charging.
>
> Well, if this is meant for userspace, should it add some
> documentation, too?

Hi Pavel, in v3 I have dropped any new sysfs attributes, so everything
exposed to userspace is already documented.

Thanks,

Tomeu

> Thanks,
> Pavel
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


RE: [PATCH][v3] ACPI: Do not report _OSI("Darwin") when acpi_osi=!Darwin provided

2016-02-21 Thread Zheng, Lv
Hi, Yu

> From: linux-acpi-ow...@vger.kernel.org [mailto:linux-acpi-
> ow...@vger.kernel.org] On Behalf Of Chen Yu
> Subject: [PATCH][v3] ACPI: Do not report _OSI("Darwin") when
> acpi_osi=!Darwin provided
> 
> Commit 7bc5a2bad0b8 ("ACPI: Support _OSI("Darwin") correctly") always
> reports positive value when Apple hardware queries _OSI("Darwin").
> But sometimes the users might want to tell the hardware they don't
> need the Darwin feature, for example, users may leverage the hardware
> to power off the Thunderbolt, by appending acpi_osi=!Darwin in command
> line, thus Apple hardware regards it as an incompatible OS X system,
> hence turns off the Thunderbolt.
[Lv Zheng] 
Both this patch and the original commit that is from Matthew look wrong to me.
IMO, the feature should be done with an entirely different approach.
Without test, I'm not sure if my comment is helpful for you.
So could you let me take over to fix this issue?

Thanks and best regards
-Lv

> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=92111
> Signed-off-by: Chen Yu 
> ---
> v3:
>  - Simplify acpi_osi_setup_disabled suggested by Andy Shevchenko.
> v2:
>  - Convert osi_setup_entries to non-initdata variable, to
>eliminate the warning from 0-DAY test infrastructure.
> ---
>  drivers/acpi/osl.c | 26 +++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
> index 67da6fb..8bb3a93 100644
> --- a/drivers/acpi/osl.c
> +++ b/drivers/acpi/osl.c
> @@ -97,6 +97,7 @@ static LIST_HEAD(acpi_ioremaps);
>  static DEFINE_MUTEX(acpi_ioremap_lock);
> 
>  static void __init acpi_osi_setup_late(void);
> +static bool acpi_osi_setup_disabled(char *str);
> 
>  /*
>   * The story of _OSI(Linux)
> @@ -149,11 +150,13 @@ static u32 acpi_osi_handler(acpi_string interface,
> u32 supported)
>   osi_linux.dmi ? " via DMI" : "");
>   }
> 
> - if (!strcmp("Darwin", interface)) {
> + if (!strcmp("Darwin", interface) &&
> + !acpi_osi_setup_disabled(interface)) {
>   /*
>* Apple firmware will behave poorly if it receives positive
>* answers to "Darwin" and any other OS. Respond positively
> -  * to Darwin and then disable all other vendor strings.
> +  * to Darwin and then disable all other vendor strings if
> +  * acpi_osi="!Darwin" is not appended in cmdline.
>*/
> 
>   acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
>   supported = ACPI_UINT32_MAX;
> @@ -1688,13 +1691,30 @@ struct osi_setup_entry {
>  };
> 
>  static struct osi_setup_entry
> - osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
> + osi_setup_entries[OSI_STRING_ENTRIES_MAX] = {
>   {"Module Device", true},
>   {"Processor Device", true},
>   {"3.0 _SCP Extensions", true},
>   {"Processor Aggregator Device", true},
>  };
> 
> +static bool acpi_osi_setup_disabled(char *str)
> +{
> + int i;
> + struct osi_setup_entry *osi;
> +
> + if (str == NULL || *str == '\0')
> + return false;
> +
> + for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
> + osi = _setup_entries[i];
> + if (!strcmp(osi->string, str))
> + return !osi->enable;
> + }
> +
> + return false;
> +}
> +
>  void __init acpi_osi_setup(char *str)
>  {
>   struct osi_setup_entry *osi;
> --
> 1.8.4.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] ARM: dts: use syscon in cygnus touchscreen dt node

2016-02-21 Thread Raveendra Padasalagi
In Cygnus SOC touch screen controller registers are shared
with ADC and flex timer. Using readl/writel could lead to
race condition. So in such case register access is handled
through syscon framework API's in the touch screen driver.
This feature is enabled if "brcm,iproc-touchscreen-syscon"
compatible string is selected in touchscreen dt node.

So this patch enables syscon support in touchscreen driver
by adding necessary properties in touchscreen dt node.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 3878793..1704dc0 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -351,9 +351,16 @@
< 142 10 1>;
};
 
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
touchscreen: tsc@180a6000 {
-   compatible = "brcm,iproc-touchscreen";
-   reg = <0x180a6000 0x40>;
+   compatible = "brcm,iproc-touchscreen-syscon";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ts_syscon = <_adc_syscon>;
clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
clock-names = "tsc_clk";
interrupts = ;
-- 
1.9.1



[PATCH v3 3/3] ARM: dts: use syscon in cygnus touchscreen dt node

2016-02-21 Thread Raveendra Padasalagi
In Cygnus SOC touch screen controller registers are shared
with ADC and flex timer. Using readl/writel could lead to
race condition. So in such case register access is handled
through syscon framework API's in the touch screen driver.
This feature is enabled if "brcm,iproc-touchscreen-syscon"
compatible string is selected in touchscreen dt node.

So this patch enables syscon support in touchscreen driver
by adding necessary properties in touchscreen dt node.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 3878793..1704dc0 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -351,9 +351,16 @@
< 142 10 1>;
};
 
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
touchscreen: tsc@180a6000 {
-   compatible = "brcm,iproc-touchscreen";
-   reg = <0x180a6000 0x40>;
+   compatible = "brcm,iproc-touchscreen-syscon";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ts_syscon = <_adc_syscon>;
clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
clock-names = "tsc_clk";
interrupts = ;
-- 
1.9.1



[PATCH v3 2/3] input: syscon support in bcm_iproc_tsc driver

2016-02-21 Thread Raveendra Padasalagi
In Cygnus SOC touch screen controller registers are shared
with ADC and flex timer. Using readl/writel could lead to
race condition. So touch screen driver is enhanced to support

1. If touchscreen register's are not shared. Register access
is handled through readl/writel if "brcm,iproc-touchscreen"
compatible is provided in touchscreen dt node. This will help
for future SOC's if comes with dedicated touchscreen IP register's.

2. If touchscreen register's are shared with other IP's, register
access is handled through syscon framework API's to take care of
mutually exclusive access. This feature can be enabled by selecting
"brcm,iproc-touchscreen-syscon" compatible string in the touchscreen
dt node.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 drivers/input/touchscreen/bcm_iproc_tsc.c | 152 ++
 1 file changed, 112 insertions(+), 40 deletions(-)

diff --git a/drivers/input/touchscreen/bcm_iproc_tsc.c 
b/drivers/input/touchscreen/bcm_iproc_tsc.c
index ae460a5c..3ef80c6 100644
--- a/drivers/input/touchscreen/bcm_iproc_tsc.c
+++ b/drivers/input/touchscreen/bcm_iproc_tsc.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define IPROC_TS_NAME "iproc-ts"
 
@@ -88,7 +90,7 @@
 #define TS_WIRE_MODE_BITBIT(1)
 
 #define dbg_reg(dev, priv, reg) \
-   dev_dbg(dev, "%20s= 0x%08x\n", #reg, readl((priv)->regs + reg))
+   dev_dbg(dev, "%20s= 0x%08x\n", #reg, iproc_reg_read(priv, reg))
 
 struct tsc_param {
/* Each step is 1024 us.  Valid 1-256 */
@@ -142,12 +144,18 @@ struct iproc_ts_priv {
struct input_dev *idev;
 
void __iomem *regs;
+   struct regmap *regmap;
struct clk *tsc_clk;
 
int  pen_status;
struct tsc_param cfg_params;
 };
 
+enum iproc_ts_reg_type {
+   IPROC_TS_REG,
+   IPROC_TS_SYSCON,
+};
+
 /*
  * Set default values the same as hardware reset values
  * except for fifo_threshold with is set to 1.
@@ -163,6 +171,41 @@ static const struct tsc_param iproc_default_config = {
.max_y= Y_MAX,
 };
 
+static int iproc_reg_update_bits(struct iproc_ts_priv *priv, u32 reg,
+  u32 mask, u32 val)
+{
+   int ret = 0;
+   u32 tmp, orig;
+
+   if (priv->regs) {
+   orig = readl(priv->regs);
+   tmp = orig & ~mask;
+   tmp |= val & mask;
+   writel(tmp, priv->regs + reg);
+   } else
+   ret = regmap_update_bits(priv->regmap, reg, mask, val);
+   return ret;
+}
+
+static void iproc_reg_write(struct iproc_ts_priv *priv, u32 reg, u32 val)
+{
+   if (priv->regs)
+   writel(val, priv->regs + reg);
+   else
+   regmap_write(priv->regmap, reg, val);
+}
+
+static u32 iproc_reg_read(struct iproc_ts_priv *priv, u32 reg)
+{
+   u32 val;
+
+   if (priv->regs)
+   val = readl(priv->regs + reg);
+   else
+   regmap_read(priv->regmap, reg, );
+   return val;
+}
+
 static void ts_reg_dump(struct iproc_ts_priv *priv)
 {
struct device *dev = >pdev->dev;
@@ -196,22 +239,22 @@ static irqreturn_t iproc_touchscreen_interrupt(int irq, 
void *data)
int i;
bool needs_sync = false;
 
-   intr_status = readl(priv->regs + INTERRUPT_STATUS);
-   intr_status &= TS_PEN_INTR_MASK | TS_FIFO_INTR_MASK;
+   intr_status = iproc_reg_read(priv, INTERRUPT_STATUS);
+   intr_status &= (TS_PEN_INTR_MASK | TS_FIFO_INTR_MASK);
if (intr_status == 0)
return IRQ_NONE;
 
/* Clear all interrupt status bits, write-1-clear */
-   writel(intr_status, priv->regs + INTERRUPT_STATUS);
-
+   iproc_reg_write(priv, INTERRUPT_STATUS, intr_status);
/* Pen up/down */
if (intr_status & TS_PEN_INTR_MASK) {
-   if (readl(priv->regs + CONTROLLER_STATUS) & TS_PEN_DOWN)
+   priv->pen_status = iproc_reg_read(priv, CONTROLLER_STATUS);
+   if (priv->pen_status & TS_PEN_DOWN)
priv->pen_status = PEN_DOWN_STATUS;
else
priv->pen_status = PEN_UP_STATUS;
 
-   input_report_key(priv->idev, BTN_TOUCH, priv->pen_status);
+   input_report_key(priv->idev, BTN_TOUCH, priv->pen_status);
needs_sync = true;
 
dev_dbg(>pdev->dev,
@@ -221,7 +264,7 @@ static irqreturn_t iproc_touchscreen_interrupt(int irq, 
void *data)
/* coordinates in FIFO exceed the theshold */
if (intr_status & TS_FIFO_INTR_MASK) {
for (i = 0; i < priv->cfg_params.fifo_threshold; i++) {
-   raw_coordinate = readl(priv->regs + FIFO_DATA);
+   raw_coordinate = iproc_reg_read(priv, FIFO_DATA);
if (raw_coordinate == INVALID_COORD)

[PATCH v3 2/3] input: syscon support in bcm_iproc_tsc driver

2016-02-21 Thread Raveendra Padasalagi
In Cygnus SOC touch screen controller registers are shared
with ADC and flex timer. Using readl/writel could lead to
race condition. So touch screen driver is enhanced to support

1. If touchscreen register's are not shared. Register access
is handled through readl/writel if "brcm,iproc-touchscreen"
compatible is provided in touchscreen dt node. This will help
for future SOC's if comes with dedicated touchscreen IP register's.

2. If touchscreen register's are shared with other IP's, register
access is handled through syscon framework API's to take care of
mutually exclusive access. This feature can be enabled by selecting
"brcm,iproc-touchscreen-syscon" compatible string in the touchscreen
dt node.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 drivers/input/touchscreen/bcm_iproc_tsc.c | 152 ++
 1 file changed, 112 insertions(+), 40 deletions(-)

diff --git a/drivers/input/touchscreen/bcm_iproc_tsc.c 
b/drivers/input/touchscreen/bcm_iproc_tsc.c
index ae460a5c..3ef80c6 100644
--- a/drivers/input/touchscreen/bcm_iproc_tsc.c
+++ b/drivers/input/touchscreen/bcm_iproc_tsc.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define IPROC_TS_NAME "iproc-ts"
 
@@ -88,7 +90,7 @@
 #define TS_WIRE_MODE_BITBIT(1)
 
 #define dbg_reg(dev, priv, reg) \
-   dev_dbg(dev, "%20s= 0x%08x\n", #reg, readl((priv)->regs + reg))
+   dev_dbg(dev, "%20s= 0x%08x\n", #reg, iproc_reg_read(priv, reg))
 
 struct tsc_param {
/* Each step is 1024 us.  Valid 1-256 */
@@ -142,12 +144,18 @@ struct iproc_ts_priv {
struct input_dev *idev;
 
void __iomem *regs;
+   struct regmap *regmap;
struct clk *tsc_clk;
 
int  pen_status;
struct tsc_param cfg_params;
 };
 
+enum iproc_ts_reg_type {
+   IPROC_TS_REG,
+   IPROC_TS_SYSCON,
+};
+
 /*
  * Set default values the same as hardware reset values
  * except for fifo_threshold with is set to 1.
@@ -163,6 +171,41 @@ static const struct tsc_param iproc_default_config = {
.max_y= Y_MAX,
 };
 
+static int iproc_reg_update_bits(struct iproc_ts_priv *priv, u32 reg,
+  u32 mask, u32 val)
+{
+   int ret = 0;
+   u32 tmp, orig;
+
+   if (priv->regs) {
+   orig = readl(priv->regs);
+   tmp = orig & ~mask;
+   tmp |= val & mask;
+   writel(tmp, priv->regs + reg);
+   } else
+   ret = regmap_update_bits(priv->regmap, reg, mask, val);
+   return ret;
+}
+
+static void iproc_reg_write(struct iproc_ts_priv *priv, u32 reg, u32 val)
+{
+   if (priv->regs)
+   writel(val, priv->regs + reg);
+   else
+   regmap_write(priv->regmap, reg, val);
+}
+
+static u32 iproc_reg_read(struct iproc_ts_priv *priv, u32 reg)
+{
+   u32 val;
+
+   if (priv->regs)
+   val = readl(priv->regs + reg);
+   else
+   regmap_read(priv->regmap, reg, );
+   return val;
+}
+
 static void ts_reg_dump(struct iproc_ts_priv *priv)
 {
struct device *dev = >pdev->dev;
@@ -196,22 +239,22 @@ static irqreturn_t iproc_touchscreen_interrupt(int irq, 
void *data)
int i;
bool needs_sync = false;
 
-   intr_status = readl(priv->regs + INTERRUPT_STATUS);
-   intr_status &= TS_PEN_INTR_MASK | TS_FIFO_INTR_MASK;
+   intr_status = iproc_reg_read(priv, INTERRUPT_STATUS);
+   intr_status &= (TS_PEN_INTR_MASK | TS_FIFO_INTR_MASK);
if (intr_status == 0)
return IRQ_NONE;
 
/* Clear all interrupt status bits, write-1-clear */
-   writel(intr_status, priv->regs + INTERRUPT_STATUS);
-
+   iproc_reg_write(priv, INTERRUPT_STATUS, intr_status);
/* Pen up/down */
if (intr_status & TS_PEN_INTR_MASK) {
-   if (readl(priv->regs + CONTROLLER_STATUS) & TS_PEN_DOWN)
+   priv->pen_status = iproc_reg_read(priv, CONTROLLER_STATUS);
+   if (priv->pen_status & TS_PEN_DOWN)
priv->pen_status = PEN_DOWN_STATUS;
else
priv->pen_status = PEN_UP_STATUS;
 
-   input_report_key(priv->idev, BTN_TOUCH, priv->pen_status);
+   input_report_key(priv->idev, BTN_TOUCH, priv->pen_status);
needs_sync = true;
 
dev_dbg(>pdev->dev,
@@ -221,7 +264,7 @@ static irqreturn_t iproc_touchscreen_interrupt(int irq, 
void *data)
/* coordinates in FIFO exceed the theshold */
if (intr_status & TS_FIFO_INTR_MASK) {
for (i = 0; i < priv->cfg_params.fifo_threshold; i++) {
-   raw_coordinate = readl(priv->regs + FIFO_DATA);
+   raw_coordinate = iproc_reg_read(priv, FIFO_DATA);
if (raw_coordinate == INVALID_COORD)
continue;
 
@@ -239,7 +282,7 @@ static irqreturn_t 

[PATCH v3 0/3] Syscon support for iProc touchscreen driver

2016-02-21 Thread Raveendra Padasalagi
This patchset is based on v4.5-rc3 tag and its tested on
Broadcom Cygnus SoC.

The patches can be fetched from iproc-tsc-v3 branch of
https://github.com/Broadcom/arm64-linux.git

Changes since v2:
 - Omitted '0x' in "tsc node" definition in dt documentation file
 - Omitted '0x' in "ts_adc_syscon" definition in dt documentation file
 - Added "brcm,iproc-ts-adc-syscon" compatible string in "ts_adc_syscon"
   node. Updated dt documentation file to reflect this change.

Raveendra Padasalagi (3):
  input: cygnus-update touchscreen dt node document
  input: syscon support in bcm_iproc_tsc driver
  ARM: dts: use syscon in cygnus touchscreen dt node

 .../input/touchscreen/brcm,iproc-touchscreen.txt   |  59 +++-
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  11 +-
 drivers/input/touchscreen/bcm_iproc_tsc.c  | 152 +++--
 3 files changed, 173 insertions(+), 49 deletions(-)

-- 
1.9.1



[PATCH v3 0/3] Syscon support for iProc touchscreen driver

2016-02-21 Thread Raveendra Padasalagi
This patchset is based on v4.5-rc3 tag and its tested on
Broadcom Cygnus SoC.

The patches can be fetched from iproc-tsc-v3 branch of
https://github.com/Broadcom/arm64-linux.git

Changes since v2:
 - Omitted '0x' in "tsc node" definition in dt documentation file
 - Omitted '0x' in "ts_adc_syscon" definition in dt documentation file
 - Added "brcm,iproc-ts-adc-syscon" compatible string in "ts_adc_syscon"
   node. Updated dt documentation file to reflect this change.

Raveendra Padasalagi (3):
  input: cygnus-update touchscreen dt node document
  input: syscon support in bcm_iproc_tsc driver
  ARM: dts: use syscon in cygnus touchscreen dt node

 .../input/touchscreen/brcm,iproc-touchscreen.txt   |  59 +++-
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  11 +-
 drivers/input/touchscreen/bcm_iproc_tsc.c  | 152 +++--
 3 files changed, 173 insertions(+), 49 deletions(-)

-- 
1.9.1



[PATCH v3 1/3] input: cygnus-update touchscreen dt node document

2016-02-21 Thread Raveendra Padasalagi
In Cygnus SOC touch screen controller registers are shared
with ADC and flex timer. Using readl/writel could lead to
race condition. So touch screen driver is enhanced to support

1. If touchscreen register's are not shared. Register access
is handled through readl/writel if "brcm,iproc-touchscreen"
compatible is provided in touchscreen dt node. This will help
for future SOC's if comes with dedicated touchscreen IP register's.

2. If touchscreen register's are shared with other IP's, register
access is handled through syscon framework API's to take care of
mutually exclusive access. This feature can be enabled by selecting
"brcm,iproc-touchscreen-syscon" compatible string in the touchscreen
dt node.

Hence touchscreen dt node bindings document is updated to take care
of above changes in the touchscreen driver.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 .../input/touchscreen/brcm,iproc-touchscreen.txt   | 59 +++---
 1 file changed, 52 insertions(+), 7 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
 
b/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
index 34e3382..c186162 100644
--- 
a/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
+++ 
b/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
@@ -1,12 +1,30 @@
 * Broadcom's IPROC Touchscreen Controller
 
 Required properties:
-- compatible: must be "brcm,iproc-touchscreen"
-- reg: physical base address of the controller and length of memory mapped
-  region.
+- compatible: should be one of
+"brcm,iproc-touchscreen"
+"brcm,iproc-touchscreen-syscon"
+- ts_syscon: if "brcm,iproc-touchscreen-syscon" compatible string
+  is selected then "ts_syscon" is mandatory or else not required.
+  The "ts_syscon" is handler of syscon node defining physical base
+  address of the controller and length of memory mapped region.
+  If this property is selected please make sure MFD_SYSCON config
+  is enabled in the defconfig file.
+- reg: if "brcm,iproc-touchscreen" compatible string is selected
+  then "reg" property is mandatory or else not required.
+  The "reg" should be physical base address of the controller and
+  length of memory mapped region.
 - clocks:  The clock provided by the SOC to driver the tsc
 - clock-name:  name for the clock
 - interrupts: The touchscreen controller's interrupt
+- address-cells: Specify the number of u32 entries needed in child nodes.
+ Should set to 1. This property is mandatory when
+ "brcm,iproc-touchscreen-syscon" compatible string is selected
+ or else not required.
+- size-cells: Specify number of u32 entries needed to specify child nodes size
+  in reg property. Should set to 1.This property is mandatory when
+  "brcm,iproc-touchscreen-syscon" compatible string is selected or
+  else not required.
 
 Optional properties:
 - scanning_period: Time between scans. Each step is 1024 us.  Valid 1-256.
@@ -53,13 +71,40 @@ Optional properties:
 - touchscreen-inverted-x: X axis is inverted (boolean)
 - touchscreen-inverted-y: Y axis is inverted (boolean)
 
-Example:
+Example 1: An example of touchscreen node with "brcm,iproc-touchscreen-syscon"
+   compatible string.
 
-   touchscreen: tsc@0x180A6000 {
-   compatible = "brcm,iproc-touchscreen";
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
+   touchscreen: tsc@180A6000 {
+   compatible = "brcm,iproc-touchscreen-syscon";
#address-cells = <1>;
#size-cells = <1>;
-   reg = <0x180A6000 0x40>;
+   ts_syscon = <_adc_syscon>;
+   clocks = <_clk>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+
+   scanning_period = <5>;
+   debounce_timeout = <40>;
+   settling_timeout = <7>;
+   touch_timeout = <10>;
+   average_data = <5>;
+   fifo_threshold = <1>;
+   /* Touchscreen is rotated 180 degrees. */
+   touchscreen-inverted-x;
+   touchscreen-inverted-y;
+   };
+
+Example 2: An example of touchscreen node with "brcm,iproc-touchscreen"
+  compatible string.
+
+   touchscreen: tsc@180A6000 {
+   compatible = "brcm,iproc-touchscreen";
+   reg = <0x180a6000 0x40>;
clocks = <_clk>;
clock-names = "tsc_clk";
interrupts = ;
-- 
1.9.1



[PATCH v3 1/3] input: cygnus-update touchscreen dt node document

2016-02-21 Thread Raveendra Padasalagi
In Cygnus SOC touch screen controller registers are shared
with ADC and flex timer. Using readl/writel could lead to
race condition. So touch screen driver is enhanced to support

1. If touchscreen register's are not shared. Register access
is handled through readl/writel if "brcm,iproc-touchscreen"
compatible is provided in touchscreen dt node. This will help
for future SOC's if comes with dedicated touchscreen IP register's.

2. If touchscreen register's are shared with other IP's, register
access is handled through syscon framework API's to take care of
mutually exclusive access. This feature can be enabled by selecting
"brcm,iproc-touchscreen-syscon" compatible string in the touchscreen
dt node.

Hence touchscreen dt node bindings document is updated to take care
of above changes in the touchscreen driver.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 .../input/touchscreen/brcm,iproc-touchscreen.txt   | 59 +++---
 1 file changed, 52 insertions(+), 7 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
 
b/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
index 34e3382..c186162 100644
--- 
a/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
+++ 
b/Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt
@@ -1,12 +1,30 @@
 * Broadcom's IPROC Touchscreen Controller
 
 Required properties:
-- compatible: must be "brcm,iproc-touchscreen"
-- reg: physical base address of the controller and length of memory mapped
-  region.
+- compatible: should be one of
+"brcm,iproc-touchscreen"
+"brcm,iproc-touchscreen-syscon"
+- ts_syscon: if "brcm,iproc-touchscreen-syscon" compatible string
+  is selected then "ts_syscon" is mandatory or else not required.
+  The "ts_syscon" is handler of syscon node defining physical base
+  address of the controller and length of memory mapped region.
+  If this property is selected please make sure MFD_SYSCON config
+  is enabled in the defconfig file.
+- reg: if "brcm,iproc-touchscreen" compatible string is selected
+  then "reg" property is mandatory or else not required.
+  The "reg" should be physical base address of the controller and
+  length of memory mapped region.
 - clocks:  The clock provided by the SOC to driver the tsc
 - clock-name:  name for the clock
 - interrupts: The touchscreen controller's interrupt
+- address-cells: Specify the number of u32 entries needed in child nodes.
+ Should set to 1. This property is mandatory when
+ "brcm,iproc-touchscreen-syscon" compatible string is selected
+ or else not required.
+- size-cells: Specify number of u32 entries needed to specify child nodes size
+  in reg property. Should set to 1.This property is mandatory when
+  "brcm,iproc-touchscreen-syscon" compatible string is selected or
+  else not required.
 
 Optional properties:
 - scanning_period: Time between scans. Each step is 1024 us.  Valid 1-256.
@@ -53,13 +71,40 @@ Optional properties:
 - touchscreen-inverted-x: X axis is inverted (boolean)
 - touchscreen-inverted-y: Y axis is inverted (boolean)
 
-Example:
+Example 1: An example of touchscreen node with "brcm,iproc-touchscreen-syscon"
+   compatible string.
 
-   touchscreen: tsc@0x180A6000 {
-   compatible = "brcm,iproc-touchscreen";
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
+   touchscreen: tsc@180A6000 {
+   compatible = "brcm,iproc-touchscreen-syscon";
#address-cells = <1>;
#size-cells = <1>;
-   reg = <0x180A6000 0x40>;
+   ts_syscon = <_adc_syscon>;
+   clocks = <_clk>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+
+   scanning_period = <5>;
+   debounce_timeout = <40>;
+   settling_timeout = <7>;
+   touch_timeout = <10>;
+   average_data = <5>;
+   fifo_threshold = <1>;
+   /* Touchscreen is rotated 180 degrees. */
+   touchscreen-inverted-x;
+   touchscreen-inverted-y;
+   };
+
+Example 2: An example of touchscreen node with "brcm,iproc-touchscreen"
+  compatible string.
+
+   touchscreen: tsc@180A6000 {
+   compatible = "brcm,iproc-touchscreen";
+   reg = <0x180a6000 0x40>;
clocks = <_clk>;
clock-names = "tsc_clk";
interrupts = ;
-- 
1.9.1



[PATCH v16 2/8] perf config: Add 'list-all' option to perf-config

2016-02-21 Thread Taeung Song
'list-all' option is to display both current config variables
and all possible config variables with default values.
The syntax examples are like below

perf config [] [options]

display all perf config with default values.
# perf config -a | --list-all

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |   6 +
 tools/perf/builtin-config.c  | 231 ++-
 2 files changed, 235 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 15949e2..d9fb8c3 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -9,6 +9,8 @@ SYNOPSIS
 
 [verse]
 'perf config' [] -l | --list
+or
+'perf config' [] -a | --list-all
 
 DESCRIPTION
 ---
@@ -29,6 +31,10 @@ OPTIONS
For writing and reading options: write to system-wide
'$(sysconfdir)/perfconfig' or read it.
 
+-a::
+--list-all::
+   Show current and all possible config variables with default values.
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index c43234e..8a63119 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -21,17 +21,160 @@ static const char * const config_usage[] = {
 };
 
 enum actions {
-   ACTION_LIST = 1
+   ACTION_LIST = 1,
+   ACTION_LIST_ALL
 } actions;
 
 static struct option config_options[] = {
OPT_SET_UINT('l', "list", ,
 "show current config variables", ACTION_LIST),
+   OPT_SET_UINT('a', "list-all", ,
+"show current and all possible config"
+" variables with default values", ACTION_LIST_ALL),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
OPT_BOOLEAN(0, "user", _user_config, "use user config file"),
OPT_END()
 };
 
+enum config_idx {
+   CONFIG_COLORS_TOP,
+   CONFIG_COLORS_MEDIUM,
+   CONFIG_COLORS_NORMAL,
+   CONFIG_COLORS_SELECTED,
+   CONFIG_COLORS_JUMP_ARROWS,
+   CONFIG_COLORS_ADDR,
+   CONFIG_COLORS_ROOT,
+   CONFIG_TUI_REPORT,
+   CONFIG_TUI_ANNOTATE,
+   CONFIG_TUI_TOP,
+   CONFIG_BUILDID_DIR,
+   CONFIG_ANNOTATE_HIDE_SRC_CODE,
+   CONFIG_ANNOTATE_USE_OFFSET,
+   CONFIG_ANNOTATE_JUMP_ARROWS,
+   CONFIG_ANNOTATE_SHOW_NR_JUMPS,
+   CONFIG_ANNOTATE_SHOW_LINENR,
+   CONFIG_ANNOTATE_SHOW_TOTAL_PERIOD,
+   CONFIG_GTK_ANNOTATE,
+   CONFIG_GTK_REPORT,
+   CONFIG_GTK_TOP,
+   CONFIG_PAGER_CMD,
+   CONFIG_PAGER_REPORT,
+   CONFIG_PAGER_ANNOTATE,
+   CONFIG_PAGER_TOP,
+   CONFIG_PAGER_DIFF,
+   CONFIG_HELP_FORMAT,
+   CONFIG_HELP_AUTOCORRECT,
+   CONFIG_HIST_PERCENTAGE,
+   CONFIG_UI_SHOW_HEADERS,
+   CONFIG_CALL_GRAPH_RECORD_MODE,
+   CONFIG_CALL_GRAPH_DUMP_SIZE,
+   CONFIG_CALL_GRAPH_PRINT_TYPE,
+   CONFIG_CALL_GRAPH_ORDER,
+   CONFIG_CALL_GRAPH_SORT_KEY,
+   CONFIG_CALL_GRAPH_THRESHOLD,
+   CONFIG_CALL_GRAPH_PRINT_LIMIT,
+   CONFIG_REPORT_GROUP,
+   CONFIG_REPORT_CHILDREN,
+   CONFIG_REPORT_PERCENT_LIMIT,
+   CONFIG_REPORT_QUEUE_SIZE,
+   CONFIG_TOP_CHILDREN,
+   CONFIG_MAN_VIEWER,
+   CONFIG_KMEM_DEFAULT,
+};
+
+enum config_type {
+   CONFIG_TYPE_BOOL,
+   CONFIG_TYPE_INT,
+   CONFIG_TYPE_LONG,
+   CONFIG_TYPE_U64,
+   CONFIG_TYPE_FLOAT,
+   CONFIG_TYPE_DOUBLE,
+   CONFIG_TYPE_STRING,
+   /* special type */
+   CONFIG_END
+};
+
+struct config_item {
+   const char *section;
+   const char *name;
+   union {
+   bool b;
+   int i;
+   u32 l;
+   u64 ll;
+   float f;
+   double d;
+   const char *s;
+   } value;
+   enum config_type type;
+};
+
+#define CONF_VAR(_sec, _name, _field, _val, _type) \
+   { .section = _sec, .name = _name, .value._field = _val, .type = _type }
+
+#define CONF_BOOL_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL)
+#define CONF_INT_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT)
+#define CONF_LONG_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG)
+#define CONF_U64_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64)
+#define CONF_FLOAT_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT)
+#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE)
+#define CONF_STR_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = 

[PATCH v16 4/8] perf config: Add --verbose option for showing config description

2016-02-21 Thread Taeung Song
To explain what each of variable options configures,
this option can be used with 'skel', 'list' and
'list-all' options, i.e.

print the possible config variables with comments over each of them.
# perf config -vk | --verbose --skel
or
print all or current config variables with descriptions
# perf config -vl | --verbose --list
# perf config -va | --verbose --list-all

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |   4 +
 tools/perf/builtin-config.c  | 186 +--
 2 files changed, 130 insertions(+), 60 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 964879a..1da577f 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -41,6 +41,10 @@ OPTIONS
 --skel::
Produce an skeleton with the possible config variables.
 
+-v::
+--verbose::
+   Be more verbose. (show config description)
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 6ab53b2..ad82074 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -35,6 +35,8 @@ static struct option config_options[] = {
OPT_SET_UINT('k', "skel", ,
 "produce an skeleton with the possible"
 " config variables", ACTION_SKEL),
+   OPT_INCR('v', "verbose", , "Be more verbose"
+" (show config description)"),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
OPT_BOOLEAN(0, "user", _user_config, "use user config file"),
OPT_END()
@@ -111,71 +113,117 @@ struct config_item {
const char *s;
} value;
enum config_type type;
+   const char *desc;
 };
 
-#define CONF_VAR(_sec, _name, _field, _val, _type) \
-   { .section = _sec, .name = _name, .value._field = _val, .type = _type }
-
-#define CONF_BOOL_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL)
-#define CONF_INT_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT)
-#define CONF_LONG_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG)
-#define CONF_U64_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64)
-#define CONF_FLOAT_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT)
-#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE)
-#define CONF_STR_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING)
+#define CONF_VAR(_sec, _name, _field, _val, _type, _desc) \
+   { .section = _sec, .name = _name, .value._field = _val, .type = _type, 
.desc = _desc}
+
+#define CONF_BOOL_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL, 
_desc)
+#define CONF_INT_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT, _desc)
+#define CONF_LONG_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG, 
_desc)
+#define CONF_U64_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64, 
_desc)
+#define CONF_FLOAT_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT, 
_desc)
+#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE, 
_desc)
+#define CONF_STR_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING, 
_desc)
 #define CONF_END() { .type = CONFIG_END }
 
 struct config_item default_configs[] = {
-   CONF_STR_VAR(COLORS_TOP, "colors", "top", "red, default"),
-   CONF_STR_VAR(COLORS_MEDIUM, "colors", "medium", "green, default"),
-   CONF_STR_VAR(COLORS_NORMAL, "colors", "normal", "lightgray, default"),
-   CONF_STR_VAR(COLORS_SELECTED, "colors", "selected", "white, lightgray"),
-   CONF_STR_VAR(COLORS_JUMP_ARROWS, "colors", "jump_arrows", "blue, 
default"),
-   CONF_STR_VAR(COLORS_ADDR, "colors", "addr", "magenta, default"),
-   CONF_STR_VAR(COLORS_ROOT, "colors", "root", "white, blue"),
-   CONF_BOOL_VAR(TUI_REPORT, "tui", "report", true),
-   CONF_BOOL_VAR(TUI_ANNOTATE, "tui", "annotate", true),
-   CONF_BOOL_VAR(TUI_TOP, "tui", "top", true),
-   CONF_STR_VAR(BUILDID_DIR, "buildid", "dir", "~/.debug"),
-   

[PATCH v16 2/8] perf config: Add 'list-all' option to perf-config

2016-02-21 Thread Taeung Song
'list-all' option is to display both current config variables
and all possible config variables with default values.
The syntax examples are like below

perf config [] [options]

display all perf config with default values.
# perf config -a | --list-all

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |   6 +
 tools/perf/builtin-config.c  | 231 ++-
 2 files changed, 235 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 15949e2..d9fb8c3 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -9,6 +9,8 @@ SYNOPSIS
 
 [verse]
 'perf config' [] -l | --list
+or
+'perf config' [] -a | --list-all
 
 DESCRIPTION
 ---
@@ -29,6 +31,10 @@ OPTIONS
For writing and reading options: write to system-wide
'$(sysconfdir)/perfconfig' or read it.
 
+-a::
+--list-all::
+   Show current and all possible config variables with default values.
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index c43234e..8a63119 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -21,17 +21,160 @@ static const char * const config_usage[] = {
 };
 
 enum actions {
-   ACTION_LIST = 1
+   ACTION_LIST = 1,
+   ACTION_LIST_ALL
 } actions;
 
 static struct option config_options[] = {
OPT_SET_UINT('l', "list", ,
 "show current config variables", ACTION_LIST),
+   OPT_SET_UINT('a', "list-all", ,
+"show current and all possible config"
+" variables with default values", ACTION_LIST_ALL),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
OPT_BOOLEAN(0, "user", _user_config, "use user config file"),
OPT_END()
 };
 
+enum config_idx {
+   CONFIG_COLORS_TOP,
+   CONFIG_COLORS_MEDIUM,
+   CONFIG_COLORS_NORMAL,
+   CONFIG_COLORS_SELECTED,
+   CONFIG_COLORS_JUMP_ARROWS,
+   CONFIG_COLORS_ADDR,
+   CONFIG_COLORS_ROOT,
+   CONFIG_TUI_REPORT,
+   CONFIG_TUI_ANNOTATE,
+   CONFIG_TUI_TOP,
+   CONFIG_BUILDID_DIR,
+   CONFIG_ANNOTATE_HIDE_SRC_CODE,
+   CONFIG_ANNOTATE_USE_OFFSET,
+   CONFIG_ANNOTATE_JUMP_ARROWS,
+   CONFIG_ANNOTATE_SHOW_NR_JUMPS,
+   CONFIG_ANNOTATE_SHOW_LINENR,
+   CONFIG_ANNOTATE_SHOW_TOTAL_PERIOD,
+   CONFIG_GTK_ANNOTATE,
+   CONFIG_GTK_REPORT,
+   CONFIG_GTK_TOP,
+   CONFIG_PAGER_CMD,
+   CONFIG_PAGER_REPORT,
+   CONFIG_PAGER_ANNOTATE,
+   CONFIG_PAGER_TOP,
+   CONFIG_PAGER_DIFF,
+   CONFIG_HELP_FORMAT,
+   CONFIG_HELP_AUTOCORRECT,
+   CONFIG_HIST_PERCENTAGE,
+   CONFIG_UI_SHOW_HEADERS,
+   CONFIG_CALL_GRAPH_RECORD_MODE,
+   CONFIG_CALL_GRAPH_DUMP_SIZE,
+   CONFIG_CALL_GRAPH_PRINT_TYPE,
+   CONFIG_CALL_GRAPH_ORDER,
+   CONFIG_CALL_GRAPH_SORT_KEY,
+   CONFIG_CALL_GRAPH_THRESHOLD,
+   CONFIG_CALL_GRAPH_PRINT_LIMIT,
+   CONFIG_REPORT_GROUP,
+   CONFIG_REPORT_CHILDREN,
+   CONFIG_REPORT_PERCENT_LIMIT,
+   CONFIG_REPORT_QUEUE_SIZE,
+   CONFIG_TOP_CHILDREN,
+   CONFIG_MAN_VIEWER,
+   CONFIG_KMEM_DEFAULT,
+};
+
+enum config_type {
+   CONFIG_TYPE_BOOL,
+   CONFIG_TYPE_INT,
+   CONFIG_TYPE_LONG,
+   CONFIG_TYPE_U64,
+   CONFIG_TYPE_FLOAT,
+   CONFIG_TYPE_DOUBLE,
+   CONFIG_TYPE_STRING,
+   /* special type */
+   CONFIG_END
+};
+
+struct config_item {
+   const char *section;
+   const char *name;
+   union {
+   bool b;
+   int i;
+   u32 l;
+   u64 ll;
+   float f;
+   double d;
+   const char *s;
+   } value;
+   enum config_type type;
+};
+
+#define CONF_VAR(_sec, _name, _field, _val, _type) \
+   { .section = _sec, .name = _name, .value._field = _val, .type = _type }
+
+#define CONF_BOOL_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL)
+#define CONF_INT_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT)
+#define CONF_LONG_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG)
+#define CONF_U64_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64)
+#define CONF_FLOAT_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT)
+#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE)
+#define CONF_STR_VAR(_idx, _sec, _name, _val) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING)
+#define CONF_END() 

[PATCH v16 4/8] perf config: Add --verbose option for showing config description

2016-02-21 Thread Taeung Song
To explain what each of variable options configures,
this option can be used with 'skel', 'list' and
'list-all' options, i.e.

print the possible config variables with comments over each of them.
# perf config -vk | --verbose --skel
or
print all or current config variables with descriptions
# perf config -vl | --verbose --list
# perf config -va | --verbose --list-all

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |   4 +
 tools/perf/builtin-config.c  | 186 +--
 2 files changed, 130 insertions(+), 60 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 964879a..1da577f 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -41,6 +41,10 @@ OPTIONS
 --skel::
Produce an skeleton with the possible config variables.
 
+-v::
+--verbose::
+   Be more verbose. (show config description)
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 6ab53b2..ad82074 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -35,6 +35,8 @@ static struct option config_options[] = {
OPT_SET_UINT('k', "skel", ,
 "produce an skeleton with the possible"
 " config variables", ACTION_SKEL),
+   OPT_INCR('v', "verbose", , "Be more verbose"
+" (show config description)"),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
OPT_BOOLEAN(0, "user", _user_config, "use user config file"),
OPT_END()
@@ -111,71 +113,117 @@ struct config_item {
const char *s;
} value;
enum config_type type;
+   const char *desc;
 };
 
-#define CONF_VAR(_sec, _name, _field, _val, _type) \
-   { .section = _sec, .name = _name, .value._field = _val, .type = _type }
-
-#define CONF_BOOL_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL)
-#define CONF_INT_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT)
-#define CONF_LONG_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG)
-#define CONF_U64_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64)
-#define CONF_FLOAT_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT)
-#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE)
-#define CONF_STR_VAR(_idx, _sec, _name, _val) \
-   [CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING)
+#define CONF_VAR(_sec, _name, _field, _val, _type, _desc) \
+   { .section = _sec, .name = _name, .value._field = _val, .type = _type, 
.desc = _desc}
+
+#define CONF_BOOL_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL, 
_desc)
+#define CONF_INT_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT, _desc)
+#define CONF_LONG_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG, 
_desc)
+#define CONF_U64_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64, 
_desc)
+#define CONF_FLOAT_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT, 
_desc)
+#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE, 
_desc)
+#define CONF_STR_VAR(_idx, _sec, _name, _val, _desc) \
+   [CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING, 
_desc)
 #define CONF_END() { .type = CONFIG_END }
 
 struct config_item default_configs[] = {
-   CONF_STR_VAR(COLORS_TOP, "colors", "top", "red, default"),
-   CONF_STR_VAR(COLORS_MEDIUM, "colors", "medium", "green, default"),
-   CONF_STR_VAR(COLORS_NORMAL, "colors", "normal", "lightgray, default"),
-   CONF_STR_VAR(COLORS_SELECTED, "colors", "selected", "white, lightgray"),
-   CONF_STR_VAR(COLORS_JUMP_ARROWS, "colors", "jump_arrows", "blue, 
default"),
-   CONF_STR_VAR(COLORS_ADDR, "colors", "addr", "magenta, default"),
-   CONF_STR_VAR(COLORS_ROOT, "colors", "root", "white, blue"),
-   CONF_BOOL_VAR(TUI_REPORT, "tui", "report", true),
-   CONF_BOOL_VAR(TUI_ANNOTATE, "tui", "annotate", true),
-   CONF_BOOL_VAR(TUI_TOP, "tui", "top", true),
-   CONF_STR_VAR(BUILDID_DIR, "buildid", "dir", "~/.debug"),
-   CONF_BOOL_VAR(ANNOTATE_HIDE_SRC_CODE, "annotate", "hide_src_code", 
false),
-   

[PATCH v16 5/8] perf config: Add 'get' functionality

2016-02-21 Thread Taeung Song
This patch consists of functions
which can get specific config variables.
For the syntax examples,

perf config [] [section.name ...]

display key-value pairs of specific config variables
# perf config report.queue-size report.children

In addition, the functionality can work with --verbose option
to show the config description, i.e.

# perf config -v report.queue-size

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |  2 +
 tools/perf/builtin-config.c  | 87 ++--
 tools/perf/util/cache.h  |  1 +
 3 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 1da577f..f83e9de 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -8,6 +8,8 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 
 [verse]
+'perf config' [] [section.name ...]
+or
 'perf config' [] -l | --list
 or
 'perf config' [] -a | --list-all
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index ad82074..b7162ab 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -16,7 +16,7 @@
 static bool use_system_config, use_user_config;
 
 static const char * const config_usage[] = {
-   "perf config [] [options]",
+   "perf config [] [options] [section.name ...]",
NULL
 };
 
@@ -404,6 +404,44 @@ static int show_all_config(struct list_head *sections)
return 0;
 }
 
+static int show_spec_config(struct list_head *sections,
+   const char *section_name, const char *name)
+{
+   int i;
+   struct config_section *section = NULL;
+   struct config_element *element = NULL;
+
+   find_config(sections, , , section_name, name);
+
+   for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+   struct config_item *config = _configs[i];
+
+   if (!strcmp(config->section, section_name) &&
+   !strcmp(config->name, name)) {
+   char *value = get_value(config);
+
+   if (verbose)
+   printf("# %s\n", config->desc);
+   printf("%s.%s", config->section, config->name);
+   if (!section && !element)
+   printf("=%s (default)", value);
+   else
+   printf("=%s", element->value);
+   printf("\n");
+   free(value);
+   return 0;
+   }
+   }
+
+   if (section && element) {
+   printf("%s.%s=%s\n", section->name,
+  element->name, element->value);
+   return 0;
+   }
+
+   return -1;
+}
+
 static int collect_current_config(const char *var, const char *value,
  void *spec_sections)
 {
@@ -453,6 +491,43 @@ out_err:
return ret;
 }
 
+static int perf_configset_with_option(configset_fn_t fn, struct list_head 
*sections,
+ const char *var)
+{
+   int ret = -1;
+   char *ptr, *key;
+   const char *last_dot;
+   char *section_name, *name;
+
+   key = ptr = strdup(var);
+   if (!key) {
+   pr_err("%s: strdup failed\n", __func__);
+   return -1;
+   }
+   last_dot = strchr(key, '.');
+   /*
+* Since "key" actually contains the section name and the real
+* key name separated by a dot, we have to know where the dot is.
+*/
+   if (last_dot == NULL || last_dot == key) {
+   pr_err("The config variable does not contain a section: %s\n", 
key);
+   goto out_err;
+   }
+   if (!last_dot[1]) {
+   pr_err("The config varible does not contain variable name: 
%s\n", key);
+   goto out_err;
+   }
+
+   section_name = strsep(, ".");
+   name = ptr;
+   fn(sections, section_name, name);
+   ret = 0;
+
+out_err:
+   free(key);
+   return ret;
+}
+
 static int show_config(struct list_head *sections)
 {
int i;
@@ -485,7 +560,7 @@ static int show_config(struct list_head *sections)
 
 int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 {
-   int ret = 0;
+   int i, ret = 0;
struct list_head sections;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
 
@@ -523,7 +598,6 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
ret = show_all_config();
break;
}
-   /* fall through */
case ACTION_LIST:
if (argc) {

[PATCH v16 5/8] perf config: Add 'get' functionality

2016-02-21 Thread Taeung Song
This patch consists of functions
which can get specific config variables.
For the syntax examples,

perf config [] [section.name ...]

display key-value pairs of specific config variables
# perf config report.queue-size report.children

In addition, the functionality can work with --verbose option
to show the config description, i.e.

# perf config -v report.queue-size

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |  2 +
 tools/perf/builtin-config.c  | 87 ++--
 tools/perf/util/cache.h  |  1 +
 3 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 1da577f..f83e9de 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -8,6 +8,8 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 
 [verse]
+'perf config' [] [section.name ...]
+or
 'perf config' [] -l | --list
 or
 'perf config' [] -a | --list-all
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index ad82074..b7162ab 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -16,7 +16,7 @@
 static bool use_system_config, use_user_config;
 
 static const char * const config_usage[] = {
-   "perf config [] [options]",
+   "perf config [] [options] [section.name ...]",
NULL
 };
 
@@ -404,6 +404,44 @@ static int show_all_config(struct list_head *sections)
return 0;
 }
 
+static int show_spec_config(struct list_head *sections,
+   const char *section_name, const char *name)
+{
+   int i;
+   struct config_section *section = NULL;
+   struct config_element *element = NULL;
+
+   find_config(sections, , , section_name, name);
+
+   for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+   struct config_item *config = _configs[i];
+
+   if (!strcmp(config->section, section_name) &&
+   !strcmp(config->name, name)) {
+   char *value = get_value(config);
+
+   if (verbose)
+   printf("# %s\n", config->desc);
+   printf("%s.%s", config->section, config->name);
+   if (!section && !element)
+   printf("=%s (default)", value);
+   else
+   printf("=%s", element->value);
+   printf("\n");
+   free(value);
+   return 0;
+   }
+   }
+
+   if (section && element) {
+   printf("%s.%s=%s\n", section->name,
+  element->name, element->value);
+   return 0;
+   }
+
+   return -1;
+}
+
 static int collect_current_config(const char *var, const char *value,
  void *spec_sections)
 {
@@ -453,6 +491,43 @@ out_err:
return ret;
 }
 
+static int perf_configset_with_option(configset_fn_t fn, struct list_head 
*sections,
+ const char *var)
+{
+   int ret = -1;
+   char *ptr, *key;
+   const char *last_dot;
+   char *section_name, *name;
+
+   key = ptr = strdup(var);
+   if (!key) {
+   pr_err("%s: strdup failed\n", __func__);
+   return -1;
+   }
+   last_dot = strchr(key, '.');
+   /*
+* Since "key" actually contains the section name and the real
+* key name separated by a dot, we have to know where the dot is.
+*/
+   if (last_dot == NULL || last_dot == key) {
+   pr_err("The config variable does not contain a section: %s\n", 
key);
+   goto out_err;
+   }
+   if (!last_dot[1]) {
+   pr_err("The config varible does not contain variable name: 
%s\n", key);
+   goto out_err;
+   }
+
+   section_name = strsep(, ".");
+   name = ptr;
+   fn(sections, section_name, name);
+   ret = 0;
+
+out_err:
+   free(key);
+   return ret;
+}
+
 static int show_config(struct list_head *sections)
 {
int i;
@@ -485,7 +560,7 @@ static int show_config(struct list_head *sections)
 
 int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
 {
-   int ret = 0;
+   int i, ret = 0;
struct list_head sections;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
 
@@ -523,7 +598,6 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
ret = show_all_config();
break;
}
-   /* fall through */
case ACTION_LIST:
if (argc) {
pr_err("Error: takes no arguments\n");
@@ -543,7 +617,12 @@ int 

[PATCH v16 6/8] perf config: Add 'set' functionality

2016-02-21 Thread Taeung Song
This patch consists of functions
which can set specific config variables.
For the syntax examples,

perf config [] [options] [section.name[=value] ...]

set specific config variables
# perf config report.queue-size=100M report.children=true

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |   2 +-
 tools/perf/builtin-config.c  | 122 +--
 tools/perf/util/cache.h  |   5 +-
 tools/perf/util/config.c |  27 ++-
 4 files changed, 131 insertions(+), 25 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index f83e9de..52fdb4b 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -8,7 +8,7 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 
 [verse]
-'perf config' [] [section.name ...]
+'perf config' [] [section.name[=value] ...]
 or
 'perf config' [] -l | --list
 or
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index b7162ab..d2587c5 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -16,7 +16,7 @@
 static bool use_system_config, use_user_config;
 
 static const char * const config_usage[] = {
-   "perf config [] [options] [section.name ...]",
+   "perf config [] [options] [section.name[=value] ...]",
NULL
 };
 
@@ -405,7 +405,9 @@ static int show_all_config(struct list_head *sections)
 }
 
 static int show_spec_config(struct list_head *sections,
-   const char *section_name, const char *name)
+   const char *config_file_name __maybe_unused,
+   const char *section_name, const char *name,
+   char *value)
 {
int i;
struct config_section *section = NULL;
@@ -418,7 +420,7 @@ static int show_spec_config(struct list_head *sections,
 
if (!strcmp(config->section, section_name) &&
!strcmp(config->name, name)) {
-   char *value = get_value(config);
+   value = get_value(config);
 
if (verbose)
printf("# %s\n", config->desc);
@@ -442,6 +444,39 @@ static int show_spec_config(struct list_head *sections,
return -1;
 }
 
+static int set_config(struct list_head *sections, const char *config_file_name,
+ const char *section_name, const char *name, char *value)
+{
+   struct config_section *section = NULL;
+   struct config_element *element = NULL;
+
+   find_config(sections, , , section_name, name);
+   if (value != NULL) {
+   value = strdup(value);
+   if (!value) {
+   pr_err("%s: strdup failed\n", __func__);
+   return -1;
+   }
+
+   /* if there isn't existent section, add a new section */
+   if (!section) {
+   section = init_section(section_name);
+   if (!section)
+   return -1;
+   list_add_tail(>list, sections);
+   }
+   /* if nothing to replace, add a new element which contains 
key-value pair. */
+   if (!element) {
+   add_element(>element_head, name, value);
+   } else {
+   free(element->value);
+   element->value = value;
+   }
+   }
+
+   return perf_configset_write_in_full(sections, config_file_name);
+}
+
 static int collect_current_config(const char *var, const char *value,
  void *spec_sections)
 {
@@ -491,8 +526,10 @@ out_err:
return ret;
 }
 
-static int perf_configset_with_option(configset_fn_t fn, struct list_head 
*sections,
- const char *var)
+static int perf_configset_with_option(configset_fn_t fn,
+ struct list_head *sections,
+ const char *config_file_name,
+ const char *var, char *value)
 {
int ret = -1;
char *ptr, *key;
@@ -519,10 +556,24 @@ static int perf_configset_with_option(configset_fn_t fn, 
struct list_head *secti
}
 
section_name = strsep(, ".");
-   name = ptr;
-   fn(sections, section_name, name);
-   ret = 0;
+   name = strsep(, "=");
+   if (!value) {
+   /* do nothing */
+   } else if (!strcmp(value, "=")) {
+   pr_err("The config variable does not contain a value: %s.%s\n",
+  section_name, name);
+   goto out_err;
+   } else {
+   value++;
+   name = 

[PATCH v16 8/8] perf config: Add a option 'remove' to perf-config

2016-02-21 Thread Taeung Song
A option 'remove' is to remove specific config variables.
For the syntax examples,

# perf config [] -r | --remove [section.name ...]

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |  6 ++
 tools/perf/builtin-config.c  | 37 ++--
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 52fdb4b..89c1ceb 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -15,6 +15,8 @@ or
 'perf config' [] -a | --list-all
 or
 'perf config' [] -k | --skel
+or
+'perf config' [] -r | --remove [section.name ...]
 
 DESCRIPTION
 ---
@@ -47,6 +49,10 @@ OPTIONS
 --verbose::
Be more verbose. (show config description)
 
+-r::
+--remove::
+   Remove specific config variables.
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index bad8182..7ba842c 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -23,7 +23,8 @@ static const char * const config_usage[] = {
 enum actions {
ACTION_LIST = 1,
ACTION_LIST_ALL,
-   ACTION_SKEL
+   ACTION_SKEL,
+   ACTION_REMOVE
 } actions;
 
 static struct option config_options[] = {
@@ -35,6 +36,8 @@ static struct option config_options[] = {
OPT_SET_UINT('k', "skel", ,
 "produce an skeleton with the possible"
 " config variables", ACTION_SKEL),
+   OPT_SET_UINT('r', "remove", ,
+"remove specific variables: [section.name ...]", 
ACTION_REMOVE),
OPT_INCR('v', "verbose", , "Be more verbose"
 " (show config description)"),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
@@ -499,7 +502,13 @@ static int set_config(struct list_head *sections, const 
char *config_file_name,
struct config_element *element = NULL;
 
find_config(sections, , , section_name, name);
-   if (value != NULL) {
+   if (!value) {
+   /* value == NULL means remove the variable */
+   if (section && element) {
+   free(element->value);
+   element->value = NULL;
+   }
+   } else {
value = normalize_value(section_name, name, value);
 
/* if there isn't existent section, add a new section */
@@ -663,6 +672,7 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
set_option_flag(config_options, 'l', "list", PARSE_OPT_EXCLUSIVE);
set_option_flag(config_options, 'a', "list-all", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(config_options, 'r', "remove", PARSE_OPT_EXCLUSIVE);
 
argc = parse_options(argc, argv, config_options, config_usage,
 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -692,6 +702,29 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
}
 
switch (actions) {
+   case ACTION_REMOVE:
+   if (argc) {
+   for (i = 0; argv[i]; i++) {
+   if (!use_system_config && !use_user_config) {
+   ret = 
perf_configset_with_option(set_config,
+
_sections,
+
system_config,
+
argv[i], NULL);
+   ret = 
perf_configset_with_option(set_config,
+
_sections,
+
user_config,
+
argv[i], NULL);
+   } else
+   ret = 
perf_configset_with_option(set_config, sections,
+
config_exclusive_filename,
+
argv[i], NULL);
+   }
+   } else {
+   pr_err("Error: Missing arguments\n");
+   parse_options_usage(config_usage, config_options, "r", 
1);
+   return -1;
+   }
+   break;
case ACTION_SKEL:
if (argc)
parse_options_usage(config_usage, config_options, "k", 
1);
-- 
2.5.0



[PATCH v16 6/8] perf config: Add 'set' functionality

2016-02-21 Thread Taeung Song
This patch consists of functions
which can set specific config variables.
For the syntax examples,

perf config [] [options] [section.name[=value] ...]

set specific config variables
# perf config report.queue-size=100M report.children=true

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |   2 +-
 tools/perf/builtin-config.c  | 122 +--
 tools/perf/util/cache.h  |   5 +-
 tools/perf/util/config.c |  27 ++-
 4 files changed, 131 insertions(+), 25 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index f83e9de..52fdb4b 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -8,7 +8,7 @@ perf-config - Get and set variables in a configuration file.
 SYNOPSIS
 
 [verse]
-'perf config' [] [section.name ...]
+'perf config' [] [section.name[=value] ...]
 or
 'perf config' [] -l | --list
 or
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index b7162ab..d2587c5 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -16,7 +16,7 @@
 static bool use_system_config, use_user_config;
 
 static const char * const config_usage[] = {
-   "perf config [] [options] [section.name ...]",
+   "perf config [] [options] [section.name[=value] ...]",
NULL
 };
 
@@ -405,7 +405,9 @@ static int show_all_config(struct list_head *sections)
 }
 
 static int show_spec_config(struct list_head *sections,
-   const char *section_name, const char *name)
+   const char *config_file_name __maybe_unused,
+   const char *section_name, const char *name,
+   char *value)
 {
int i;
struct config_section *section = NULL;
@@ -418,7 +420,7 @@ static int show_spec_config(struct list_head *sections,
 
if (!strcmp(config->section, section_name) &&
!strcmp(config->name, name)) {
-   char *value = get_value(config);
+   value = get_value(config);
 
if (verbose)
printf("# %s\n", config->desc);
@@ -442,6 +444,39 @@ static int show_spec_config(struct list_head *sections,
return -1;
 }
 
+static int set_config(struct list_head *sections, const char *config_file_name,
+ const char *section_name, const char *name, char *value)
+{
+   struct config_section *section = NULL;
+   struct config_element *element = NULL;
+
+   find_config(sections, , , section_name, name);
+   if (value != NULL) {
+   value = strdup(value);
+   if (!value) {
+   pr_err("%s: strdup failed\n", __func__);
+   return -1;
+   }
+
+   /* if there isn't existent section, add a new section */
+   if (!section) {
+   section = init_section(section_name);
+   if (!section)
+   return -1;
+   list_add_tail(>list, sections);
+   }
+   /* if nothing to replace, add a new element which contains 
key-value pair. */
+   if (!element) {
+   add_element(>element_head, name, value);
+   } else {
+   free(element->value);
+   element->value = value;
+   }
+   }
+
+   return perf_configset_write_in_full(sections, config_file_name);
+}
+
 static int collect_current_config(const char *var, const char *value,
  void *spec_sections)
 {
@@ -491,8 +526,10 @@ out_err:
return ret;
 }
 
-static int perf_configset_with_option(configset_fn_t fn, struct list_head 
*sections,
- const char *var)
+static int perf_configset_with_option(configset_fn_t fn,
+ struct list_head *sections,
+ const char *config_file_name,
+ const char *var, char *value)
 {
int ret = -1;
char *ptr, *key;
@@ -519,10 +556,24 @@ static int perf_configset_with_option(configset_fn_t fn, 
struct list_head *secti
}
 
section_name = strsep(, ".");
-   name = ptr;
-   fn(sections, section_name, name);
-   ret = 0;
+   name = strsep(, "=");
+   if (!value) {
+   /* do nothing */
+   } else if (!strcmp(value, "=")) {
+   pr_err("The config variable does not contain a value: %s.%s\n",
+  section_name, name);
+   goto out_err;
+   } else {
+   value++;
+   name = strsep(, "=");
+   if (name[0] == '\0') {
+ 

[PATCH v16 8/8] perf config: Add a option 'remove' to perf-config

2016-02-21 Thread Taeung Song
A option 'remove' is to remove specific config variables.
For the syntax examples,

# perf config [] -r | --remove [section.name ...]

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |  6 ++
 tools/perf/builtin-config.c  | 37 ++--
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index 52fdb4b..89c1ceb 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -15,6 +15,8 @@ or
 'perf config' [] -a | --list-all
 or
 'perf config' [] -k | --skel
+or
+'perf config' [] -r | --remove [section.name ...]
 
 DESCRIPTION
 ---
@@ -47,6 +49,10 @@ OPTIONS
 --verbose::
Be more verbose. (show config description)
 
+-r::
+--remove::
+   Remove specific config variables.
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index bad8182..7ba842c 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -23,7 +23,8 @@ static const char * const config_usage[] = {
 enum actions {
ACTION_LIST = 1,
ACTION_LIST_ALL,
-   ACTION_SKEL
+   ACTION_SKEL,
+   ACTION_REMOVE
 } actions;
 
 static struct option config_options[] = {
@@ -35,6 +36,8 @@ static struct option config_options[] = {
OPT_SET_UINT('k', "skel", ,
 "produce an skeleton with the possible"
 " config variables", ACTION_SKEL),
+   OPT_SET_UINT('r', "remove", ,
+"remove specific variables: [section.name ...]", 
ACTION_REMOVE),
OPT_INCR('v', "verbose", , "Be more verbose"
 " (show config description)"),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
@@ -499,7 +502,13 @@ static int set_config(struct list_head *sections, const 
char *config_file_name,
struct config_element *element = NULL;
 
find_config(sections, , , section_name, name);
-   if (value != NULL) {
+   if (!value) {
+   /* value == NULL means remove the variable */
+   if (section && element) {
+   free(element->value);
+   element->value = NULL;
+   }
+   } else {
value = normalize_value(section_name, name, value);
 
/* if there isn't existent section, add a new section */
@@ -663,6 +672,7 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
set_option_flag(config_options, 'l', "list", PARSE_OPT_EXCLUSIVE);
set_option_flag(config_options, 'a', "list-all", PARSE_OPT_EXCLUSIVE);
+   set_option_flag(config_options, 'r', "remove", PARSE_OPT_EXCLUSIVE);
 
argc = parse_options(argc, argv, config_options, config_usage,
 PARSE_OPT_STOP_AT_NON_OPTION);
@@ -692,6 +702,29 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
}
 
switch (actions) {
+   case ACTION_REMOVE:
+   if (argc) {
+   for (i = 0; argv[i]; i++) {
+   if (!use_system_config && !use_user_config) {
+   ret = 
perf_configset_with_option(set_config,
+
_sections,
+
system_config,
+
argv[i], NULL);
+   ret = 
perf_configset_with_option(set_config,
+
_sections,
+
user_config,
+
argv[i], NULL);
+   } else
+   ret = 
perf_configset_with_option(set_config, sections,
+
config_exclusive_filename,
+
argv[i], NULL);
+   }
+   } else {
+   pr_err("Error: Missing arguments\n");
+   parse_options_usage(config_usage, config_options, "r", 
1);
+   return -1;
+   }
+   break;
case ACTION_SKEL:
if (argc)
parse_options_usage(config_usage, config_options, "k", 
1);
-- 
2.5.0



[PATCH v16 7/8] perf config: normalize a value depending on default type of it

2016-02-21 Thread Taeung Song
Whether or not user mis-type wrong data type to set config,
normalize the value. If a config user enter isn't contained
in default configs, just pass as it is.
For the examples,

   # perf config report.queue-size=1M
   # perf config report.queue-size
   report.queue-size=1048576

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-config.c | 54 -
 1 file changed, 49 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index d2587c5..bad8182 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -444,6 +444,54 @@ static int show_spec_config(struct list_head *sections,
return -1;
 }
 
+static char *normalize_value(const char *section_name, const char *name, const 
char *value)
+{
+   int i, ret = 0;
+   char *endptr;
+   char key[BUFSIZ];
+   char *normalized;
+
+   scnprintf(key, sizeof(key), "%s.%s", section_name, name);
+   for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+   struct config_item *config = _configs[i];
+
+   if (!strcmp(config->section, section_name) &&
+   !strcmp(config->name, name)) {
+   if (config->type == CONFIG_TYPE_BOOL)
+   ret = asprintf(, "%s",
+  perf_config_bool(key, value) ? 
"true" : "false");
+   else if (config->type == CONFIG_TYPE_INT ||
+config->type == CONFIG_TYPE_LONG)
+   ret = asprintf(, "%d",
+  perf_config_int(key, value));
+   else if (config->type == CONFIG_TYPE_U64)
+   ret = asprintf(, "%"PRId64,
+  perf_config_u64(key, value));
+   else if (config->type == CONFIG_TYPE_FLOAT)
+   ret = asprintf(, "%f",
+  strtof(value, ));
+   else if (config->type == CONFIG_TYPE_DOUBLE)
+   ret = asprintf(, "%f",
+  strtod(value, ));
+   else
+   ret = asprintf(, "%s", value);
+
+   if (ret < 0)
+   return NULL;
+
+   return normalized;
+   }
+   }
+
+   normalized = strdup(value);
+   if (!normalized) {
+   pr_err("%s: strdup failed\n", __func__);
+   return NULL;
+   }
+
+   return normalized;
+}
+
 static int set_config(struct list_head *sections, const char *config_file_name,
  const char *section_name, const char *name, char *value)
 {
@@ -452,11 +500,7 @@ static int set_config(struct list_head *sections, const 
char *config_file_name,
 
find_config(sections, , , section_name, name);
if (value != NULL) {
-   value = strdup(value);
-   if (!value) {
-   pr_err("%s: strdup failed\n", __func__);
-   return -1;
-   }
+   value = normalize_value(section_name, name, value);
 
/* if there isn't existent section, add a new section */
if (!section) {
-- 
2.5.0



[PATCH v16 1/8] perf config: Collect configs to handle config variables

2016-02-21 Thread Taeung Song
Collecting configs into list because of two reason.

First of all, if there are same variables both user
and system config file, they all will be printed
when 'list' command work. But if config variables are
duplicated, user config variables should only be printed
because it has priority.

Lastly, list into which configs is collected
will be required to keep and handle config variables
and values in the near furture. For example,
getting or setting functionality.

And change show_config() function.
Old show_config() worked depending on perf_config().
New show_config() work using collected configs list.

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-config.c | 150 ++--
 tools/perf/util/cache.h |  13 
 2 files changed, 158 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index c42448e..c43234e 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -32,13 +32,148 @@ static struct option config_options[] = {
OPT_END()
 };
 
-static int show_config(const char *key, const char *value,
-  void *cb __maybe_unused)
+static struct config_section *find_section(struct list_head *sections,
+  const char *section_name)
 {
+   struct config_section *section;
+
+   list_for_each_entry(section, sections, list)
+   if (!strcmp(section->name, section_name))
+   return section;
+
+   return NULL;
+}
+
+static struct config_element *find_element(const char *name,
+  struct config_section *section)
+{
+   struct config_element *element;
+
+   list_for_each_entry(element, >element_head, list)
+   if (!strcmp(element->name, name))
+   return element;
+
+   return NULL;
+}
+
+static void find_config(struct list_head *sections,
+   struct config_section **section,
+   struct config_element **element,
+   const char *section_name, const char *name)
+{
+   *section = find_section(sections, section_name);
+
+   if (*section != NULL)
+   *element = find_element(name, *section);
+   else
+   *element = NULL;
+}
+
+static struct config_section *init_section(const char *section_name)
+{
+   struct config_section *section;
+
+   section = zalloc(sizeof(*section));
+   if (!section)
+   return NULL;
+
+   INIT_LIST_HEAD(>element_head);
+   section->name = strdup(section_name);
+   if (!section->name) {
+   pr_err("%s: strdup failed\n", __func__);
+   free(section);
+   return NULL;
+   }
+
+   return section;
+}
+
+static int add_element(struct list_head *head,
+ const char *name, const char *value)
+{
+   struct config_element *element;
+
+   element = zalloc(sizeof(*element));
+   if (!element)
+   return -1;
+
+   element->name = strdup(name);
+   if (!element->name) {
+   pr_err("%s: strdup failed\n", __func__);
+   free(element);
+   return -1;
+   }
if (value)
-   printf("%s=%s\n", key, value);
+   element->value = (char *)value;
else
-   printf("%s\n", key);
+   element->value = NULL;
+
+   list_add_tail(>list, head);
+   return 0;
+}
+
+static int collect_current_config(const char *var, const char *value,
+ void *spec_sections)
+{
+   int ret = -1;
+   char *ptr, *key;
+   char *section_name, *name;
+   struct config_section *section = NULL;
+   struct config_element *element = NULL;
+   struct list_head *sections = (struct list_head *)spec_sections;
+
+   key = ptr = strdup(var);
+   if (!key) {
+   pr_err("%s: strdup failed\n", __func__);
+   return -1;
+   }
+
+   section_name = strsep(, ".");
+   name = ptr;
+   if (name == NULL || value == NULL)
+   goto out_err;
+
+   find_config(sections, , , section_name, name);
+
+   if (!section) {
+   section = init_section(section_name);
+   if (!section)
+   goto out_err;
+   list_add_tail(>list, sections);
+   }
+
+   value = strdup(value);
+   if (!value) {
+   pr_err("%s: strdup failed\n", __func__);
+   goto out_err;
+   }
+
+   if (!element)
+   add_element(>element_head, name, value);
+   else {
+   free(element->value);
+   element->value = (char *)value;
+   }
+
+   ret = 0;
+out_err:
+   free(key);
+   return ret;
+}
+
+static int 

[PATCH v16 3/8] perf config: Add a option 'skel' to perf-config

2016-02-21 Thread Taeung Song
Produce an skeleton with the possible config variables so
that one could then use $EDITOR ~/.perfconfig or
$(sysconfdir)/perfconfigand go on setting the knobs.

For the syntax examples,

# perf config -k | --skel
Initialize the possible config variables on config file.
# perf config --skel > ~/.perfconfig

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |  6 ++
 tools/perf/builtin-config.c  | 32 +++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index d9fb8c3..964879a 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -11,6 +11,8 @@ SYNOPSIS
 'perf config' [] -l | --list
 or
 'perf config' [] -a | --list-all
+or
+'perf config' [] -k | --skel
 
 DESCRIPTION
 ---
@@ -35,6 +37,10 @@ OPTIONS
 --list-all::
Show current and all possible config variables with default values.
 
+-k::
+--skel::
+   Produce an skeleton with the possible config variables.
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 8a63119..6ab53b2 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -22,7 +22,8 @@ static const char * const config_usage[] = {
 
 enum actions {
ACTION_LIST = 1,
-   ACTION_LIST_ALL
+   ACTION_LIST_ALL,
+   ACTION_SKEL
 } actions;
 
 static struct option config_options[] = {
@@ -31,6 +32,9 @@ static struct option config_options[] = {
OPT_SET_UINT('a', "list-all", ,
 "show current and all possible config"
 " variables with default values", ACTION_LIST_ALL),
+   OPT_SET_UINT('k', "skel", ,
+"produce an skeleton with the possible"
+" config variables", ACTION_SKEL),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
OPT_BOOLEAN(0, "user", _user_config, "use user config file"),
OPT_END()
@@ -282,6 +286,26 @@ static char *get_value(struct config_item *config)
return value;
 }
 
+static int show_skel_config(void)
+{
+   int i;
+   const char *section = "";
+
+   for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+   struct config_item *config = _configs[i];
+   char *value = get_value(config);
+
+   if (strcmp(section, config->section) != 0) {
+   section = config->section;
+   printf("\n[%s]\n", config->section);
+   }
+   printf("\t%s = %s\n", config->name, value);
+   free(value);
+   }
+
+   return 0;
+}
+
 static int show_all_config(struct list_head *sections)
 {
int i;
@@ -422,6 +446,12 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
perf_config(collect_current_config, );
 
switch (actions) {
+   case ACTION_SKEL:
+   if (argc)
+   parse_options_usage(config_usage, config_options, "k", 
1);
+   else
+   ret = show_skel_config();
+   break;
case ACTION_LIST_ALL:
if (argc == 0) {
ret = show_all_config();
-- 
2.5.0



[PATCH v16 7/8] perf config: normalize a value depending on default type of it

2016-02-21 Thread Taeung Song
Whether or not user mis-type wrong data type to set config,
normalize the value. If a config user enter isn't contained
in default configs, just pass as it is.
For the examples,

   # perf config report.queue-size=1M
   # perf config report.queue-size
   report.queue-size=1048576

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-config.c | 54 -
 1 file changed, 49 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index d2587c5..bad8182 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -444,6 +444,54 @@ static int show_spec_config(struct list_head *sections,
return -1;
 }
 
+static char *normalize_value(const char *section_name, const char *name, const 
char *value)
+{
+   int i, ret = 0;
+   char *endptr;
+   char key[BUFSIZ];
+   char *normalized;
+
+   scnprintf(key, sizeof(key), "%s.%s", section_name, name);
+   for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+   struct config_item *config = _configs[i];
+
+   if (!strcmp(config->section, section_name) &&
+   !strcmp(config->name, name)) {
+   if (config->type == CONFIG_TYPE_BOOL)
+   ret = asprintf(, "%s",
+  perf_config_bool(key, value) ? 
"true" : "false");
+   else if (config->type == CONFIG_TYPE_INT ||
+config->type == CONFIG_TYPE_LONG)
+   ret = asprintf(, "%d",
+  perf_config_int(key, value));
+   else if (config->type == CONFIG_TYPE_U64)
+   ret = asprintf(, "%"PRId64,
+  perf_config_u64(key, value));
+   else if (config->type == CONFIG_TYPE_FLOAT)
+   ret = asprintf(, "%f",
+  strtof(value, ));
+   else if (config->type == CONFIG_TYPE_DOUBLE)
+   ret = asprintf(, "%f",
+  strtod(value, ));
+   else
+   ret = asprintf(, "%s", value);
+
+   if (ret < 0)
+   return NULL;
+
+   return normalized;
+   }
+   }
+
+   normalized = strdup(value);
+   if (!normalized) {
+   pr_err("%s: strdup failed\n", __func__);
+   return NULL;
+   }
+
+   return normalized;
+}
+
 static int set_config(struct list_head *sections, const char *config_file_name,
  const char *section_name, const char *name, char *value)
 {
@@ -452,11 +500,7 @@ static int set_config(struct list_head *sections, const 
char *config_file_name,
 
find_config(sections, , , section_name, name);
if (value != NULL) {
-   value = strdup(value);
-   if (!value) {
-   pr_err("%s: strdup failed\n", __func__);
-   return -1;
-   }
+   value = normalize_value(section_name, name, value);
 
/* if there isn't existent section, add a new section */
if (!section) {
-- 
2.5.0



[PATCH v16 1/8] perf config: Collect configs to handle config variables

2016-02-21 Thread Taeung Song
Collecting configs into list because of two reason.

First of all, if there are same variables both user
and system config file, they all will be printed
when 'list' command work. But if config variables are
duplicated, user config variables should only be printed
because it has priority.

Lastly, list into which configs is collected
will be required to keep and handle config variables
and values in the near furture. For example,
getting or setting functionality.

And change show_config() function.
Old show_config() worked depending on perf_config().
New show_config() work using collected configs list.

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/builtin-config.c | 150 ++--
 tools/perf/util/cache.h |  13 
 2 files changed, 158 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index c42448e..c43234e 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -32,13 +32,148 @@ static struct option config_options[] = {
OPT_END()
 };
 
-static int show_config(const char *key, const char *value,
-  void *cb __maybe_unused)
+static struct config_section *find_section(struct list_head *sections,
+  const char *section_name)
 {
+   struct config_section *section;
+
+   list_for_each_entry(section, sections, list)
+   if (!strcmp(section->name, section_name))
+   return section;
+
+   return NULL;
+}
+
+static struct config_element *find_element(const char *name,
+  struct config_section *section)
+{
+   struct config_element *element;
+
+   list_for_each_entry(element, >element_head, list)
+   if (!strcmp(element->name, name))
+   return element;
+
+   return NULL;
+}
+
+static void find_config(struct list_head *sections,
+   struct config_section **section,
+   struct config_element **element,
+   const char *section_name, const char *name)
+{
+   *section = find_section(sections, section_name);
+
+   if (*section != NULL)
+   *element = find_element(name, *section);
+   else
+   *element = NULL;
+}
+
+static struct config_section *init_section(const char *section_name)
+{
+   struct config_section *section;
+
+   section = zalloc(sizeof(*section));
+   if (!section)
+   return NULL;
+
+   INIT_LIST_HEAD(>element_head);
+   section->name = strdup(section_name);
+   if (!section->name) {
+   pr_err("%s: strdup failed\n", __func__);
+   free(section);
+   return NULL;
+   }
+
+   return section;
+}
+
+static int add_element(struct list_head *head,
+ const char *name, const char *value)
+{
+   struct config_element *element;
+
+   element = zalloc(sizeof(*element));
+   if (!element)
+   return -1;
+
+   element->name = strdup(name);
+   if (!element->name) {
+   pr_err("%s: strdup failed\n", __func__);
+   free(element);
+   return -1;
+   }
if (value)
-   printf("%s=%s\n", key, value);
+   element->value = (char *)value;
else
-   printf("%s\n", key);
+   element->value = NULL;
+
+   list_add_tail(>list, head);
+   return 0;
+}
+
+static int collect_current_config(const char *var, const char *value,
+ void *spec_sections)
+{
+   int ret = -1;
+   char *ptr, *key;
+   char *section_name, *name;
+   struct config_section *section = NULL;
+   struct config_element *element = NULL;
+   struct list_head *sections = (struct list_head *)spec_sections;
+
+   key = ptr = strdup(var);
+   if (!key) {
+   pr_err("%s: strdup failed\n", __func__);
+   return -1;
+   }
+
+   section_name = strsep(, ".");
+   name = ptr;
+   if (name == NULL || value == NULL)
+   goto out_err;
+
+   find_config(sections, , , section_name, name);
+
+   if (!section) {
+   section = init_section(section_name);
+   if (!section)
+   goto out_err;
+   list_add_tail(>list, sections);
+   }
+
+   value = strdup(value);
+   if (!value) {
+   pr_err("%s: strdup failed\n", __func__);
+   goto out_err;
+   }
+
+   if (!element)
+   add_element(>element_head, name, value);
+   else {
+   free(element->value);
+   element->value = (char *)value;
+   }
+
+   ret = 0;
+out_err:
+   free(key);
+   return ret;
+}
+
+static int show_config(struct list_head *sections)
+{
+   struct config_section 

[PATCH v16 3/8] perf config: Add a option 'skel' to perf-config

2016-02-21 Thread Taeung Song
Produce an skeleton with the possible config variables so
that one could then use $EDITOR ~/.perfconfig or
$(sysconfdir)/perfconfigand go on setting the knobs.

For the syntax examples,

# perf config -k | --skel
Initialize the possible config variables on config file.
# perf config --skel > ~/.perfconfig

Cc: Namhyung Kim 
Cc: Jiri Olsa 
Signed-off-by: Taeung Song 
---
 tools/perf/Documentation/perf-config.txt |  6 ++
 tools/perf/builtin-config.c  | 32 +++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index d9fb8c3..964879a 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -11,6 +11,8 @@ SYNOPSIS
 'perf config' [] -l | --list
 or
 'perf config' [] -a | --list-all
+or
+'perf config' [] -k | --skel
 
 DESCRIPTION
 ---
@@ -35,6 +37,10 @@ OPTIONS
 --list-all::
Show current and all possible config variables with default values.
 
+-k::
+--skel::
+   Produce an skeleton with the possible config variables.
+
 CONFIGURATION FILE
 --
 
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 8a63119..6ab53b2 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -22,7 +22,8 @@ static const char * const config_usage[] = {
 
 enum actions {
ACTION_LIST = 1,
-   ACTION_LIST_ALL
+   ACTION_LIST_ALL,
+   ACTION_SKEL
 } actions;
 
 static struct option config_options[] = {
@@ -31,6 +32,9 @@ static struct option config_options[] = {
OPT_SET_UINT('a', "list-all", ,
 "show current and all possible config"
 " variables with default values", ACTION_LIST_ALL),
+   OPT_SET_UINT('k', "skel", ,
+"produce an skeleton with the possible"
+" config variables", ACTION_SKEL),
OPT_BOOLEAN(0, "system", _system_config, "use system config file"),
OPT_BOOLEAN(0, "user", _user_config, "use user config file"),
OPT_END()
@@ -282,6 +286,26 @@ static char *get_value(struct config_item *config)
return value;
 }
 
+static int show_skel_config(void)
+{
+   int i;
+   const char *section = "";
+
+   for (i = 0; default_configs[i].type != CONFIG_END; i++) {
+   struct config_item *config = _configs[i];
+   char *value = get_value(config);
+
+   if (strcmp(section, config->section) != 0) {
+   section = config->section;
+   printf("\n[%s]\n", config->section);
+   }
+   printf("\t%s = %s\n", config->name, value);
+   free(value);
+   }
+
+   return 0;
+}
+
 static int show_all_config(struct list_head *sections)
 {
int i;
@@ -422,6 +446,12 @@ int cmd_config(int argc, const char **argv, const char 
*prefix __maybe_unused)
perf_config(collect_current_config, );
 
switch (actions) {
+   case ACTION_SKEL:
+   if (argc)
+   parse_options_usage(config_usage, config_options, "k", 
1);
+   else
+   ret = show_skel_config();
+   break;
case ACTION_LIST_ALL:
if (argc == 0) {
ret = show_all_config();
-- 
2.5.0



[PATCHSET v16 0/8] perf config: Add several functionalities into perf-config

2016-02-21 Thread Taeung Song
Hello,

This patchset implements new functionalities for perf-config subcommand.
Add options (list-all, skel, verbose, remove) and
getting and setting functionalities into perf-config subcommand to more useful.

Changes in v16:
- rebased onto the current tip/perf/core

Changes in v15:
- separate out perf-config documention from this patchset
- 'list' and 'list-all' options can also work with --verbose
- 'get' functionality can also work with --verbose

Changes in v14:
- change default value for report.group config [Namhyung]
- make a distinction between user and system config file name
  in error message when nothing configured
- bug fix, segmentation fault of '--skel' option
  of which reason is that a variable wasn't initialized
- rename colors.code to colors.jump_arrows among config variables

Changes in v13:
- add record.build-id config info to perf-config doc [Namhyung]
- fill missing options info ('verbose', 'skel') on perf-config doc

Changes in v12:
- modify perf-config documentation for each section to be more proper
  and correct small typing errors [Namhyung]
- add missing config variables that are group, show_linenr and
  show_total_period [Namhyung]

Changes in v11:
- add --skel option to produce an skeleton with the possible config
  variables [Arnaldo]
- add exception handling to --list option when nothing configured 
[Arnaldo]
- default action without option is to show an usage message [Arnaldo]

Changes in v10:
- split perf-config.txt into several patches for each section and 
replace some
  paragraphes with better proper things [Arnaldo, Namhyung]
- correct wrong default values for each variable [Namhyung]
- remove the compare name function

Changes in v9:
- add the compare name functionality treating '-' and '-' as being
  the same thing for usability

Changes in v8:
- correct small typing errors in a perf-config documention
- split the collecting configs part into a separate patch
- use new enum and struct for default configs instead of
  hard-coded value [Namhyung]

Changes in v7:
- modify explanations of syntax and options(color, gtk, tui, buildid, 
annotate)
  to be better proper descriptions [Arnaldo]

Changes in v6:
- split a 'set' feature patch into two patch to separate 
normalize_value() from it
- bug fix : 'remove' and 'set' malfunctions when without a specific 
file-option
  (If file-option isn't used, 'remove' feature had to use both user and 
system
  config file and 'set' feature had to only handle user config file.)

Changes in v5:
- simplify the switch statement in cmd_config()
- set a config file path with '--system' or '--user'
  instead of '--global' or '--system' [Namhyung]
- the patch about 'get' and 'set 'split into two patchs [Namhyung]

Changes in v4:
- if some config value is default value, notice it is '(default)' 
[Jirka]
- if there wasn't any perfconfig file, perf-config malfunctioned
  so add exception routine with '--global' and '--system'
  option which can select perf config file path [Jirka]

Changes in v3:
- add a config variable 'kmem.default' with a default value [Namhyung]

Changes in v2:
- change option name of listing all configs as '--list-all'
  instead of '--all' [Namhyung]
- correct small infelicities or typing errors in a perf-config 
documention [Arnaldo]
- declaration a global variable 'static struct default_configsets' has 
config
  variables with default values instead of using a 
'util/PERFCONFIG-DEFAULT' file.
- add a function to normalize a value and check data type of it.
- simplify parsing arguments as arguments is just divided by '=' and 
then
  in front of '.' is a section, between '.' and '=' is a name,
  and behind '=' is a value.
- if run perf-config command without any option, perf-config work as 
'--list'.

Taeung Song (8):
  perf config: Collect configs to handle config variables
  perf config: Add 'list-all' option to perf-config
  perf config: Add a option 'skel' to perf-config
  perf config: Add --verbose option for showing config description
  perf config: Add 'get' functionality
  perf config: Add 'set' feature
  perf config: normalize a value depending on default type of it
  perf config: Add a option 'remove' to perf-config

 tools/perf/Documentation/perf-config.txt |  24 +
 tools/perf/builtin-config.c  | 723 ++-
 tools/perf/util/cache.h  |  17 +
 tools/perf/util/config.c |  27 +-
 4 files changed, 777 insertions(+), 14 deletions(-)

-- 
2.5.0



[PATCHSET v16 0/8] perf config: Add several functionalities into perf-config

2016-02-21 Thread Taeung Song
Hello,

This patchset implements new functionalities for perf-config subcommand.
Add options (list-all, skel, verbose, remove) and
getting and setting functionalities into perf-config subcommand to more useful.

Changes in v16:
- rebased onto the current tip/perf/core

Changes in v15:
- separate out perf-config documention from this patchset
- 'list' and 'list-all' options can also work with --verbose
- 'get' functionality can also work with --verbose

Changes in v14:
- change default value for report.group config [Namhyung]
- make a distinction between user and system config file name
  in error message when nothing configured
- bug fix, segmentation fault of '--skel' option
  of which reason is that a variable wasn't initialized
- rename colors.code to colors.jump_arrows among config variables

Changes in v13:
- add record.build-id config info to perf-config doc [Namhyung]
- fill missing options info ('verbose', 'skel') on perf-config doc

Changes in v12:
- modify perf-config documentation for each section to be more proper
  and correct small typing errors [Namhyung]
- add missing config variables that are group, show_linenr and
  show_total_period [Namhyung]

Changes in v11:
- add --skel option to produce an skeleton with the possible config
  variables [Arnaldo]
- add exception handling to --list option when nothing configured 
[Arnaldo]
- default action without option is to show an usage message [Arnaldo]

Changes in v10:
- split perf-config.txt into several patches for each section and 
replace some
  paragraphes with better proper things [Arnaldo, Namhyung]
- correct wrong default values for each variable [Namhyung]
- remove the compare name function

Changes in v9:
- add the compare name functionality treating '-' and '-' as being
  the same thing for usability

Changes in v8:
- correct small typing errors in a perf-config documention
- split the collecting configs part into a separate patch
- use new enum and struct for default configs instead of
  hard-coded value [Namhyung]

Changes in v7:
- modify explanations of syntax and options(color, gtk, tui, buildid, 
annotate)
  to be better proper descriptions [Arnaldo]

Changes in v6:
- split a 'set' feature patch into two patch to separate 
normalize_value() from it
- bug fix : 'remove' and 'set' malfunctions when without a specific 
file-option
  (If file-option isn't used, 'remove' feature had to use both user and 
system
  config file and 'set' feature had to only handle user config file.)

Changes in v5:
- simplify the switch statement in cmd_config()
- set a config file path with '--system' or '--user'
  instead of '--global' or '--system' [Namhyung]
- the patch about 'get' and 'set 'split into two patchs [Namhyung]

Changes in v4:
- if some config value is default value, notice it is '(default)' 
[Jirka]
- if there wasn't any perfconfig file, perf-config malfunctioned
  so add exception routine with '--global' and '--system'
  option which can select perf config file path [Jirka]

Changes in v3:
- add a config variable 'kmem.default' with a default value [Namhyung]

Changes in v2:
- change option name of listing all configs as '--list-all'
  instead of '--all' [Namhyung]
- correct small infelicities or typing errors in a perf-config 
documention [Arnaldo]
- declaration a global variable 'static struct default_configsets' has 
config
  variables with default values instead of using a 
'util/PERFCONFIG-DEFAULT' file.
- add a function to normalize a value and check data type of it.
- simplify parsing arguments as arguments is just divided by '=' and 
then
  in front of '.' is a section, between '.' and '=' is a name,
  and behind '=' is a value.
- if run perf-config command without any option, perf-config work as 
'--list'.

Taeung Song (8):
  perf config: Collect configs to handle config variables
  perf config: Add 'list-all' option to perf-config
  perf config: Add a option 'skel' to perf-config
  perf config: Add --verbose option for showing config description
  perf config: Add 'get' functionality
  perf config: Add 'set' feature
  perf config: normalize a value depending on default type of it
  perf config: Add a option 'remove' to perf-config

 tools/perf/Documentation/perf-config.txt |  24 +
 tools/perf/builtin-config.c  | 723 ++-
 tools/perf/util/cache.h  |  17 +
 tools/perf/util/config.c |  27 +-
 4 files changed, 777 insertions(+), 14 deletions(-)

-- 
2.5.0



[PATCH 1/6] ARM: decompressor: drop unneeded assignments to "targets"

2016-02-21 Thread Masahiro Yamada
The "targets" exists to specify which files need the corresponding
".*_cmd" files to be included during the build.  In other words, it
is used for files that need to detect the change of the command line
by if_changed, if_changed_dep, and if_changed_rule.  While, these
files are just copied by "$(call cmd,shipped)".  Adding them to the
"targets" is meaningless because $(call cmd,...) never creates
".*_cmd" files.  Such files as ".lib1funcs.S.cmd", ".ashldi3.S.cmd"
do not exist in the first place.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 7a6a58e..7090ad3 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -91,8 +91,8 @@ endif
 
 targets   := vmlinux vmlinux.lds \
 piggy.$(suffix_y) piggy.$(suffix_y).o \
-lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S bswapsdi2.o \
-bswapsdi2.S font.o font.c head.o misc.o $(OBJS)
+lib1funcs.o ashldi3.o bswapsdi2.o \
+font.o head.o misc.o $(OBJS)
 
 # Make sure files are removed during clean
 extra-y   += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-- 
1.9.1



[PATCH 2/6] ARM: decompressor: drop more unneeded assignments to "targets"

2016-02-21 Thread Masahiro Yamada
The objects "font.o" and "misc.o" are contained in $(OBJS), and it
is already added to the "targets".

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 7090ad3..476ef00 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -92,7 +92,7 @@ endif
 targets   := vmlinux vmlinux.lds \
 piggy.$(suffix_y) piggy.$(suffix_y).o \
 lib1funcs.o ashldi3.o bswapsdi2.o \
-font.o head.o misc.o $(OBJS)
+head.o $(OBJS)
 
 # Make sure files are removed during clean
 extra-y   += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-- 
1.9.1



[PATCH 5/6] ARM: decompressor: merge piggy.*.S and simplify Makefile

2016-02-21 Thread Masahiro Yamada
The files piggy.$(suffix).S are similar enough to be merged into a
single file.  This also allows clean up of the Makefile.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/.gitignore|  6 +-
 arch/arm/boot/compressed/Makefile  | 14 ++
 arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} |  2 +-
 arch/arm/boot/compressed/piggy.lz4.S   |  6 --
 arch/arm/boot/compressed/piggy.lzma.S  |  6 --
 arch/arm/boot/compressed/piggy.lzo.S   |  6 --
 arch/arm/boot/compressed/piggy.xzkern.S|  6 --
 7 files changed, 8 insertions(+), 38 deletions(-)
 rename arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} (67%)
 delete mode 100644 arch/arm/boot/compressed/piggy.lz4.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzma.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzo.S
 delete mode 100644 arch/arm/boot/compressed/piggy.xzkern.S

diff --git a/arch/arm/boot/compressed/.gitignore 
b/arch/arm/boot/compressed/.gitignore
index 0714e03..86b2f5d 100644
--- a/arch/arm/boot/compressed/.gitignore
+++ b/arch/arm/boot/compressed/.gitignore
@@ -3,11 +3,7 @@ bswapsdi2.S
 font.c
 lib1funcs.S
 hyp-stub.S
-piggy.gzip
-piggy.lzo
-piggy.lzma
-piggy.xzkern
-piggy.lz4
+piggy_data
 vmlinux
 vmlinux.lds
 
diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 903b953..3243f09 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -89,14 +89,12 @@ ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
 OBJS   += $(libfdt_objs) atags_to_fdt.o
 endif
 
-targets   := vmlinux vmlinux.lds \
-piggy.$(suffix_y) piggy.$(suffix_y).o \
+targets   := vmlinux vmlinux.lds piggy_data piggy.o \
 lib1funcs.o ashldi3.o bswapsdi2.o \
 head.o $(OBJS)
 
-clean-files += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \
-hyp-stub.S
+clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S \
+   $(libfdt) $(libfdt_hdrs) hyp-stub.S
 
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 
@@ -177,17 +175,17 @@ fi
 
 efi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
 
-$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
+$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
$(bswapsdi2) $(efi-obj-y) FORCE
@$(check_for_multiple_zreladdr)
$(call if_changed,ld)
@$(check_for_bad_syms)
 
-$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
+$(obj)/piggy_data: $(obj)/../Image FORCE
$(call if_changed,$(suffix_y))
 
-$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y)
+$(obj)/piggy.o: $(obj)/piggy_data
 
 CFLAGS_font.o := -Dstatic=
 
diff --git a/arch/arm/boot/compressed/piggy.gzip.S 
b/arch/arm/boot/compressed/piggy.S
similarity index 67%
rename from arch/arm/boot/compressed/piggy.gzip.S
rename to arch/arm/boot/compressed/piggy.S
index a68adf9..f720884 100644
--- a/arch/arm/boot/compressed/piggy.gzip.S
+++ b/arch/arm/boot/compressed/piggy.S
@@ -1,6 +1,6 @@
.section .piggydata,#alloc
.globl  input_data
 input_data:
-   .incbin "arch/arm/boot/compressed/piggy.gzip"
+   .incbin "arch/arm/boot/compressed/piggy_data"
.globl  input_data_end
 input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.lz4.S 
b/arch/arm/boot/compressed/piggy.lz4.S
deleted file mode 100644
index 3d9a575..000
--- a/arch/arm/boot/compressed/piggy.lz4.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin "arch/arm/boot/compressed/piggy.lz4"
-   .globl  input_data_end
-input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.lzma.S 
b/arch/arm/boot/compressed/piggy.lzma.S
deleted file mode 100644
index d7e69cf..000
--- a/arch/arm/boot/compressed/piggy.lzma.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin "arch/arm/boot/compressed/piggy.lzma"
-   .globl  input_data_end
-input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.lzo.S 
b/arch/arm/boot/compressed/piggy.lzo.S
deleted file mode 100644
index a425ad9..000
--- a/arch/arm/boot/compressed/piggy.lzo.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin "arch/arm/boot/compressed/piggy.lzo"
-   .globl  input_data_end
-input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.xzkern.S 
b/arch/arm/boot/compressed/piggy.xzkern.S
deleted file mode 100644
index 5703f30..000
--- a/arch/arm/boot/compressed/piggy.xzkern.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   

Re: Nokia N900: musb is in wrong state after boot

2016-02-21 Thread Felipe Balbi
Pali Rohár  writes:

> On Tuesday 26 January 2016 18:26:32 Tony Lindgren wrote:
>> * Pali Rohár  [160126 06:35]:
>> > On Thursday 21 January 2016 12:30:13 Tony Lindgren wrote:
>> > > * joerg Reisenweber  [160121 11:35]:
>> > > > On Thu 21 January 2016 11:21:13 Tony Lindgren wrote:
>> > > > > Do you have some pointer
>> > > > > to the "certain resistor value on ID to GND" spec? Is it
>> > > > > maybe part of the carkit related parts of the USB spec?
>> > > > 
>> > > > ""Three additional ID pin states are defined[4] at the nominal
>> > > > resistance values of 124 kΩ, 68 kΩ, and 36.5 kΩ, with respect
>> > > > to the ground pin. These permit the device to work with USB
>> > > > Accessory Charger Adapters that allows the OTG device to be
>> > > > attached to both a charger and another device simultaneously.
>> > > > [6]""
>> > > > https://en.wikipedia.org/wiki/USB_On-The-Go#OTG_micro_plugs
>> > > 
>> > > OK thanks. So it's the "accessory charger" part of the
>> > > battery charging specification 1.1.
>> > 
>> > So, Tony, do you have some idea what needs to be changed and how to
>> > fix peripheral mode after boot on Nokia N900?
>> 
>> No, I'm waiting to hear an educated guess from Felipe on this one.

about why peripheral mode doesn't work on n900 ? No idea. that's always
the default role of MUSB and last I checked, before stopping working on
this, BBB was working just fine.

N900 is odd in that it has two PHYs (1701 handles data lines while
twl4030 handles power lines, IIRC), but peripheral should be working.

The only reason for MUSB to not start would be that it's not detecting
VBUS being above session valid threshold, however twl4030 should have an
IRQ for that.

What happens when cable is attached ? Any IRQs anywhere firing ?

-- 
balbi


signature.asc
Description: PGP signature


[PATCH 2/6] ARM: decompressor: drop more unneeded assignments to "targets"

2016-02-21 Thread Masahiro Yamada
The objects "font.o" and "misc.o" are contained in $(OBJS), and it
is already added to the "targets".

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 7090ad3..476ef00 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -92,7 +92,7 @@ endif
 targets   := vmlinux vmlinux.lds \
 piggy.$(suffix_y) piggy.$(suffix_y).o \
 lib1funcs.o ashldi3.o bswapsdi2.o \
-font.o head.o misc.o $(OBJS)
+head.o $(OBJS)
 
 # Make sure files are removed during clean
 extra-y   += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-- 
1.9.1



[PATCH 5/6] ARM: decompressor: merge piggy.*.S and simplify Makefile

2016-02-21 Thread Masahiro Yamada
The files piggy.$(suffix).S are similar enough to be merged into a
single file.  This also allows clean up of the Makefile.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/.gitignore|  6 +-
 arch/arm/boot/compressed/Makefile  | 14 ++
 arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} |  2 +-
 arch/arm/boot/compressed/piggy.lz4.S   |  6 --
 arch/arm/boot/compressed/piggy.lzma.S  |  6 --
 arch/arm/boot/compressed/piggy.lzo.S   |  6 --
 arch/arm/boot/compressed/piggy.xzkern.S|  6 --
 7 files changed, 8 insertions(+), 38 deletions(-)
 rename arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} (67%)
 delete mode 100644 arch/arm/boot/compressed/piggy.lz4.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzma.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzo.S
 delete mode 100644 arch/arm/boot/compressed/piggy.xzkern.S

diff --git a/arch/arm/boot/compressed/.gitignore 
b/arch/arm/boot/compressed/.gitignore
index 0714e03..86b2f5d 100644
--- a/arch/arm/boot/compressed/.gitignore
+++ b/arch/arm/boot/compressed/.gitignore
@@ -3,11 +3,7 @@ bswapsdi2.S
 font.c
 lib1funcs.S
 hyp-stub.S
-piggy.gzip
-piggy.lzo
-piggy.lzma
-piggy.xzkern
-piggy.lz4
+piggy_data
 vmlinux
 vmlinux.lds
 
diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 903b953..3243f09 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -89,14 +89,12 @@ ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
 OBJS   += $(libfdt_objs) atags_to_fdt.o
 endif
 
-targets   := vmlinux vmlinux.lds \
-piggy.$(suffix_y) piggy.$(suffix_y).o \
+targets   := vmlinux vmlinux.lds piggy_data piggy.o \
 lib1funcs.o ashldi3.o bswapsdi2.o \
 head.o $(OBJS)
 
-clean-files += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \
-hyp-stub.S
+clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S \
+   $(libfdt) $(libfdt_hdrs) hyp-stub.S
 
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 
@@ -177,17 +175,17 @@ fi
 
 efi-obj-$(CONFIG_EFI_STUB) := $(objtree)/drivers/firmware/efi/libstub/lib.a
 
-$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
+$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
$(bswapsdi2) $(efi-obj-y) FORCE
@$(check_for_multiple_zreladdr)
$(call if_changed,ld)
@$(check_for_bad_syms)
 
-$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
+$(obj)/piggy_data: $(obj)/../Image FORCE
$(call if_changed,$(suffix_y))
 
-$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y)
+$(obj)/piggy.o: $(obj)/piggy_data
 
 CFLAGS_font.o := -Dstatic=
 
diff --git a/arch/arm/boot/compressed/piggy.gzip.S 
b/arch/arm/boot/compressed/piggy.S
similarity index 67%
rename from arch/arm/boot/compressed/piggy.gzip.S
rename to arch/arm/boot/compressed/piggy.S
index a68adf9..f720884 100644
--- a/arch/arm/boot/compressed/piggy.gzip.S
+++ b/arch/arm/boot/compressed/piggy.S
@@ -1,6 +1,6 @@
.section .piggydata,#alloc
.globl  input_data
 input_data:
-   .incbin "arch/arm/boot/compressed/piggy.gzip"
+   .incbin "arch/arm/boot/compressed/piggy_data"
.globl  input_data_end
 input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.lz4.S 
b/arch/arm/boot/compressed/piggy.lz4.S
deleted file mode 100644
index 3d9a575..000
--- a/arch/arm/boot/compressed/piggy.lz4.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin "arch/arm/boot/compressed/piggy.lz4"
-   .globl  input_data_end
-input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.lzma.S 
b/arch/arm/boot/compressed/piggy.lzma.S
deleted file mode 100644
index d7e69cf..000
--- a/arch/arm/boot/compressed/piggy.lzma.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin "arch/arm/boot/compressed/piggy.lzma"
-   .globl  input_data_end
-input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.lzo.S 
b/arch/arm/boot/compressed/piggy.lzo.S
deleted file mode 100644
index a425ad9..000
--- a/arch/arm/boot/compressed/piggy.lzo.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin "arch/arm/boot/compressed/piggy.lzo"
-   .globl  input_data_end
-input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.xzkern.S 
b/arch/arm/boot/compressed/piggy.xzkern.S
deleted file mode 100644
index 5703f30..000
--- a/arch/arm/boot/compressed/piggy.xzkern.S
+++ /dev/null
@@ -1,6 +0,0 @@
-   .section .piggydata,#alloc
-   .globl  input_data
-input_data:
-   .incbin 

Re: Nokia N900: musb is in wrong state after boot

2016-02-21 Thread Felipe Balbi
Pali Rohár  writes:

> On Tuesday 26 January 2016 18:26:32 Tony Lindgren wrote:
>> * Pali Rohár  [160126 06:35]:
>> > On Thursday 21 January 2016 12:30:13 Tony Lindgren wrote:
>> > > * joerg Reisenweber  [160121 11:35]:
>> > > > On Thu 21 January 2016 11:21:13 Tony Lindgren wrote:
>> > > > > Do you have some pointer
>> > > > > to the "certain resistor value on ID to GND" spec? Is it
>> > > > > maybe part of the carkit related parts of the USB spec?
>> > > > 
>> > > > ""Three additional ID pin states are defined[4] at the nominal
>> > > > resistance values of 124 kΩ, 68 kΩ, and 36.5 kΩ, with respect
>> > > > to the ground pin. These permit the device to work with USB
>> > > > Accessory Charger Adapters that allows the OTG device to be
>> > > > attached to both a charger and another device simultaneously.
>> > > > [6]""
>> > > > https://en.wikipedia.org/wiki/USB_On-The-Go#OTG_micro_plugs
>> > > 
>> > > OK thanks. So it's the "accessory charger" part of the
>> > > battery charging specification 1.1.
>> > 
>> > So, Tony, do you have some idea what needs to be changed and how to
>> > fix peripheral mode after boot on Nokia N900?
>> 
>> No, I'm waiting to hear an educated guess from Felipe on this one.

about why peripheral mode doesn't work on n900 ? No idea. that's always
the default role of MUSB and last I checked, before stopping working on
this, BBB was working just fine.

N900 is odd in that it has two PHYs (1701 handles data lines while
twl4030 handles power lines, IIRC), but peripheral should be working.

The only reason for MUSB to not start would be that it's not detecting
VBUS being above session valid threshold, however twl4030 should have an
IRQ for that.

What happens when cable is attached ? Any IRQs anywhere firing ?

-- 
balbi


signature.asc
Description: PGP signature


[PATCH 1/6] ARM: decompressor: drop unneeded assignments to "targets"

2016-02-21 Thread Masahiro Yamada
The "targets" exists to specify which files need the corresponding
".*_cmd" files to be included during the build.  In other words, it
is used for files that need to detect the change of the command line
by if_changed, if_changed_dep, and if_changed_rule.  While, these
files are just copied by "$(call cmd,shipped)".  Adding them to the
"targets" is meaningless because $(call cmd,...) never creates
".*_cmd" files.  Such files as ".lib1funcs.S.cmd", ".ashldi3.S.cmd"
do not exist in the first place.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 7a6a58e..7090ad3 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -91,8 +91,8 @@ endif
 
 targets   := vmlinux vmlinux.lds \
 piggy.$(suffix_y) piggy.$(suffix_y).o \
-lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S bswapsdi2.o \
-bswapsdi2.S font.o font.c head.o misc.o $(OBJS)
+lib1funcs.o ashldi3.o bswapsdi2.o \
+font.o head.o misc.o $(OBJS)
 
 # Make sure files are removed during clean
 extra-y   += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-- 
1.9.1



[PATCH 0/6] ARM: decompressor: several cleanups

2016-02-21 Thread Masahiro Yamada



Masahiro Yamada (6):
  ARM: decompressor: drop unneeded assignments to "targets"
  ARM: decompressor: drop more unneeded assignments to "targets"
  ARM: decompressor: use clean-files instead of extra-y to clean files
  ARM: decompressor: drop redundant FORCE in Makefile
  ARM: decompressor: merge piggy.*.S and simplify Makefile
  ARM: decompressor: rename suffix_y to compress-y

 arch/arm/boot/compressed/.gitignore|  6 +
 arch/arm/boot/compressed/Makefile  | 31 ++
 arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} |  2 +-
 arch/arm/boot/compressed/piggy.lz4.S   |  6 -
 arch/arm/boot/compressed/piggy.lzma.S  |  6 -
 arch/arm/boot/compressed/piggy.lzo.S   |  6 -
 arch/arm/boot/compressed/piggy.xzkern.S|  6 -
 7 files changed, 16 insertions(+), 47 deletions(-)
 rename arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} (67%)
 delete mode 100644 arch/arm/boot/compressed/piggy.lz4.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzma.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzo.S
 delete mode 100644 arch/arm/boot/compressed/piggy.xzkern.S

-- 
1.9.1



[PATCH 0/6] ARM: decompressor: several cleanups

2016-02-21 Thread Masahiro Yamada



Masahiro Yamada (6):
  ARM: decompressor: drop unneeded assignments to "targets"
  ARM: decompressor: drop more unneeded assignments to "targets"
  ARM: decompressor: use clean-files instead of extra-y to clean files
  ARM: decompressor: drop redundant FORCE in Makefile
  ARM: decompressor: merge piggy.*.S and simplify Makefile
  ARM: decompressor: rename suffix_y to compress-y

 arch/arm/boot/compressed/.gitignore|  6 +
 arch/arm/boot/compressed/Makefile  | 31 ++
 arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} |  2 +-
 arch/arm/boot/compressed/piggy.lz4.S   |  6 -
 arch/arm/boot/compressed/piggy.lzma.S  |  6 -
 arch/arm/boot/compressed/piggy.lzo.S   |  6 -
 arch/arm/boot/compressed/piggy.xzkern.S|  6 -
 7 files changed, 16 insertions(+), 47 deletions(-)
 rename arch/arm/boot/compressed/{piggy.gzip.S => piggy.S} (67%)
 delete mode 100644 arch/arm/boot/compressed/piggy.lz4.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzma.S
 delete mode 100644 arch/arm/boot/compressed/piggy.lzo.S
 delete mode 100644 arch/arm/boot/compressed/piggy.xzkern.S

-- 
1.9.1



[PATCH 3/6] ARM: decompressor: use clean-files instead of extra-y to clean files

2016-02-21 Thread Masahiro Yamada
This code works fine here, but it is tricky to use "extra-y" for
specifying files to be removed during "make clean".  Kbuild provides
"clean-files" for this purpose.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 476ef00..f9e8e68 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -94,8 +94,7 @@ targets   := vmlinux vmlinux.lds \
 lib1funcs.o ashldi3.o bswapsdi2.o \
 head.o $(OBJS)
 
-# Make sure files are removed during clean
-extra-y   += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
+clean-files += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
 lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \
 hyp-stub.S
 
-- 
1.9.1



[PATCH 3/6] ARM: decompressor: use clean-files instead of extra-y to clean files

2016-02-21 Thread Masahiro Yamada
This code works fine here, but it is tricky to use "extra-y" for
specifying files to be removed during "make clean".  Kbuild provides
"clean-files" for this purpose.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 476ef00..f9e8e68 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -94,8 +94,7 @@ targets   := vmlinux vmlinux.lds \
 lib1funcs.o ashldi3.o bswapsdi2.o \
 head.o $(OBJS)
 
-# Make sure files are removed during clean
-extra-y   += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
+clean-files += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
 lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \
 hyp-stub.S
 
-- 
1.9.1



[PATCH 6/6] ARM: decompressor: rename suffix_y to compress-y

2016-02-21 Thread Masahiro Yamada
The "$(suffix_y)" no longer appears in the file names, but it just
specifies the method of the file compression.  The "compress-y" sounds
more suitable.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 3243f09..5018bfa 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -66,11 +66,11 @@ endif
 
 CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
 
-suffix_$(CONFIG_KERNEL_GZIP) = gzip
-suffix_$(CONFIG_KERNEL_LZO)  = lzo
-suffix_$(CONFIG_KERNEL_LZMA) = lzma
-suffix_$(CONFIG_KERNEL_XZ)   = xzkern
-suffix_$(CONFIG_KERNEL_LZ4)  = lz4
+compress-$(CONFIG_KERNEL_GZIP) = gzip
+compress-$(CONFIG_KERNEL_LZO)  = lzo
+compress-$(CONFIG_KERNEL_LZMA) = lzma
+compress-$(CONFIG_KERNEL_XZ)   = xzkern
+compress-$(CONFIG_KERNEL_LZ4)  = lz4
 
 # Borrowed libfdt files for the ATAG compatibility mode
 
@@ -183,7 +183,7 @@ $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) 
$(obj)/piggy.o \
@$(check_for_bad_syms)
 
 $(obj)/piggy_data: $(obj)/../Image FORCE
-   $(call if_changed,$(suffix_y))
+   $(call if_changed,$(compress-y))
 
 $(obj)/piggy.o: $(obj)/piggy_data
 
-- 
1.9.1



[PATCH 6/6] ARM: decompressor: rename suffix_y to compress-y

2016-02-21 Thread Masahiro Yamada
The "$(suffix_y)" no longer appears in the file names, but it just
specifies the method of the file compression.  The "compress-y" sounds
more suitable.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index 3243f09..5018bfa 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -66,11 +66,11 @@ endif
 
 CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
 
-suffix_$(CONFIG_KERNEL_GZIP) = gzip
-suffix_$(CONFIG_KERNEL_LZO)  = lzo
-suffix_$(CONFIG_KERNEL_LZMA) = lzma
-suffix_$(CONFIG_KERNEL_XZ)   = xzkern
-suffix_$(CONFIG_KERNEL_LZ4)  = lz4
+compress-$(CONFIG_KERNEL_GZIP) = gzip
+compress-$(CONFIG_KERNEL_LZO)  = lzo
+compress-$(CONFIG_KERNEL_LZMA) = lzma
+compress-$(CONFIG_KERNEL_XZ)   = xzkern
+compress-$(CONFIG_KERNEL_LZ4)  = lz4
 
 # Borrowed libfdt files for the ATAG compatibility mode
 
@@ -183,7 +183,7 @@ $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) 
$(obj)/piggy.o \
@$(check_for_bad_syms)
 
 $(obj)/piggy_data: $(obj)/../Image FORCE
-   $(call if_changed,$(suffix_y))
+   $(call if_changed,$(compress-y))
 
 $(obj)/piggy.o: $(obj)/piggy_data
 
-- 
1.9.1



[PATCH 4/6] ARM: decompressor: drop redundant FORCE in Makefile

2016-02-21 Thread Masahiro Yamada
The object "piggy.$(suffix_y).o" is created from "piggy.$(suffix).S"
by the following pattern rule defined in scripts/Makefile.build:

  $(obj)/%.o: $(src)/%.S FORCE
  $(call if_changed_dep,as_o_S)

FORCE is already added to the prerequisite of the object there.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index f9e8e68..903b953 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -187,7 +187,7 @@ $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) 
$(obj)/piggy.$(suffix_y).o \
 $(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
$(call if_changed,$(suffix_y))
 
-$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y) FORCE
+$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y)
 
 CFLAGS_font.o := -Dstatic=
 
-- 
1.9.1



[PATCH 4/6] ARM: decompressor: drop redundant FORCE in Makefile

2016-02-21 Thread Masahiro Yamada
The object "piggy.$(suffix_y).o" is created from "piggy.$(suffix).S"
by the following pattern rule defined in scripts/Makefile.build:

  $(obj)/%.o: $(src)/%.S FORCE
  $(call if_changed_dep,as_o_S)

FORCE is already added to the prerequisite of the object there.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/Makefile 
b/arch/arm/boot/compressed/Makefile
index f9e8e68..903b953 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -187,7 +187,7 @@ $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) 
$(obj)/piggy.$(suffix_y).o \
 $(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
$(call if_changed,$(suffix_y))
 
-$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y) FORCE
+$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y)
 
 CFLAGS_font.o := -Dstatic=
 
-- 
1.9.1



RE: [PATCH] ACPI / button: Avoid using broken _LID on Surface tablet

2016-02-21 Thread Zheng, Lv
Hi, Yu

> From: Chen, Yu C
> Subject: RE: [PATCH] ACPI / button: Avoid using broken _LID on Surface tablet
> 
> Hi Lv,
> 
> > From: Zheng, Lv
> > Subject: RE: [PATCH] ACPI / button: Avoid using broken _LID on Surface
> > tablet
> >
> > Hi, Yu
> >
> > > From: linux-acpi-ow...@vger.kernel.org
> > > [mailto:linux-acpi-ow...@vger.kernel.org] On Behalf Of Chen Yu
> > > Subject: [PATCH] ACPI / button: Avoid using broken _LID on Surface
> > > tablet
> > >
> > [Lv Zheng]
> > The word 'broken' is not proper.
> > This just seems like an indication of a Linux gap.
> > Possibly just:
> > 1. losses of GPEs;
> > 2. lacking in the correct init value of lid driver state; and 3. lacking in 
> > the
> sense
> > of lid capability
> [Yu] I agree, but the major problem here is that, there is no SCI triggered 
> when
> opening the LID,
> and since this problem exist on Windows too(can not wake system up by open
> lid),
> it looks like either a BIOS problem(does not get the right lid status
> by EC eccess) or a hardware issue, I'm not sure if Linux is aware of the open
> event from lid.
> And even if Linux does not send the lid status after resume(althought wrong
> status: close) to input layer/netlink,
> the daemon systemd would also suspend   the system after 20 seconds(and
> there is no SCI during 20s), so
> it seems systemd(or other) daemon is using a timeout framework, so the
> quickest way to fix this problem
> is to send the 'correct' lid status to daemon after resume, I know this is 
> ugly..
> >
> > > Some platforms such as Surface 3, Surface Pro 1 have broken _LID
> > [Lv Zheng]
> > Ditto, 'broken' is not correct.
> >
> > > that, either _LID returns 'closed' during bootup, or _LID fails to
> > > return the up-to-date lid state to OSPM. This is because that, on
> > > these platforms _LID is implemented by returning a local variable,
> > > which can only be updated by lid events:
> > >
> > > Device (LID)
> > > {
> > >   Name (LIDB, Zero)
> > >   Method (_LID, 0, NotSerialized)
> > >   {
> > >   Return (LIDB)
> > >   }
> > > }
> > >
> > > Method (_E4C, 0, Serialized)
> > > {
> > >   If ((HELD == One))
> > >   {
> > >   ^^LID.LIDB = One
> > >   }
> > >   Else
> > >   {
> > >   ^^LID.LIDB = Zero
> > >   Notify (LID, 0x80)
> > >   }
> > > }
> > >
> > > After the lid is closed, _E4C updates the LIDB to zero, then system
> > > falls asleep, however when lid is opened, there would be no interrupt
> > > triggered due to hardware design, we have to wake the system up by
> > > pressing power button, as a result, LIDB remains zero after resumed,
> > > thus _LID returns 'close' to systemd daemon(or does not return any
> > > value to systemd), as a result the system suspends again even though
> > > we do nothing.
> > >
> > > This patch is to provide a possible workaround for these broken
> > > platforms, by introducing a 'cached' lid state, which is not based on
> > > evaluating _LID, but based on maintaining the lid state in a
> > > event-driven manner:
> > >
> > > 1. lid cache state is assigned to 'open' explicitly during boot up.
> > > 2. lid cache state can only be changed during suspend/resume, or someone
> > >notifies the lid device.
> > > 3. always return lid cache state instead of _LID to sysfs.
> > [Lv Zheng]
> > According to my understanding, returning _LID isn't wrong.
> >
> > In fact, some platforms rely on this behavior.
> > I know for sure there is a platform:
> > 1. Only generates LID open notification, and doesn't generate LID close
> > notification; and 2. _LID return correct state as it includes several EC 
> > accesses
> > to obtain correct hardware status.
> > Changing this behavior could break such platform while it is apparently
> > working by returning _LID from sysfs.
> >
> > OTOH, if BIOS lid state has been correctly updated according to the
> > notification, _LID is ensured to be correct by BIOS.
> >
> > So could you stop changing this behavior?
> > I can sense regressions around this change.
> >
> > >
> > > Linked: https://bugzilla.kernel.org/show_bug.cgi?id=89211
> > > Reported-and-tested-by: GiH 
> > > Reported-by: David J. Goehrig 
> > > Reported-by: Stephen Just 
> > > Signed-off-by: Chen Yu 
> > > ---
> > >  drivers/acpi/button.c | 61
> > > ++-
> > >  1 file changed, 60 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index
> > > 5c3b091..ec2a027 100644
> > > --- a/drivers/acpi/button.c
> > > +++ b/drivers/acpi/button.c
> > > @@ -28,6 +28,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >
> > >  #define PREFIX "ACPI: "
> > > @@ -53,6 +54,9 @@
> > >  #define ACPI_BUTTON_DEVICE_NAME_LID  "Lid Switch"
> > >  #define ACPI_BUTTON_TYPE_LID 0x05
> > >
> > > +#define ACPI_LID_CACHE_OPEN  1
> > > +#define 

RE: [PATCH] ACPI / button: Avoid using broken _LID on Surface tablet

2016-02-21 Thread Zheng, Lv
Hi, Yu

> From: Chen, Yu C
> Subject: RE: [PATCH] ACPI / button: Avoid using broken _LID on Surface tablet
> 
> Hi Lv,
> 
> > From: Zheng, Lv
> > Subject: RE: [PATCH] ACPI / button: Avoid using broken _LID on Surface
> > tablet
> >
> > Hi, Yu
> >
> > > From: linux-acpi-ow...@vger.kernel.org
> > > [mailto:linux-acpi-ow...@vger.kernel.org] On Behalf Of Chen Yu
> > > Subject: [PATCH] ACPI / button: Avoid using broken _LID on Surface
> > > tablet
> > >
> > [Lv Zheng]
> > The word 'broken' is not proper.
> > This just seems like an indication of a Linux gap.
> > Possibly just:
> > 1. losses of GPEs;
> > 2. lacking in the correct init value of lid driver state; and 3. lacking in 
> > the
> sense
> > of lid capability
> [Yu] I agree, but the major problem here is that, there is no SCI triggered 
> when
> opening the LID,
> and since this problem exist on Windows too(can not wake system up by open
> lid),
> it looks like either a BIOS problem(does not get the right lid status
> by EC eccess) or a hardware issue, I'm not sure if Linux is aware of the open
> event from lid.
> And even if Linux does not send the lid status after resume(althought wrong
> status: close) to input layer/netlink,
> the daemon systemd would also suspend   the system after 20 seconds(and
> there is no SCI during 20s), so
> it seems systemd(or other) daemon is using a timeout framework, so the
> quickest way to fix this problem
> is to send the 'correct' lid status to daemon after resume, I know this is 
> ugly..
> >
> > > Some platforms such as Surface 3, Surface Pro 1 have broken _LID
> > [Lv Zheng]
> > Ditto, 'broken' is not correct.
> >
> > > that, either _LID returns 'closed' during bootup, or _LID fails to
> > > return the up-to-date lid state to OSPM. This is because that, on
> > > these platforms _LID is implemented by returning a local variable,
> > > which can only be updated by lid events:
> > >
> > > Device (LID)
> > > {
> > >   Name (LIDB, Zero)
> > >   Method (_LID, 0, NotSerialized)
> > >   {
> > >   Return (LIDB)
> > >   }
> > > }
> > >
> > > Method (_E4C, 0, Serialized)
> > > {
> > >   If ((HELD == One))
> > >   {
> > >   ^^LID.LIDB = One
> > >   }
> > >   Else
> > >   {
> > >   ^^LID.LIDB = Zero
> > >   Notify (LID, 0x80)
> > >   }
> > > }
> > >
> > > After the lid is closed, _E4C updates the LIDB to zero, then system
> > > falls asleep, however when lid is opened, there would be no interrupt
> > > triggered due to hardware design, we have to wake the system up by
> > > pressing power button, as a result, LIDB remains zero after resumed,
> > > thus _LID returns 'close' to systemd daemon(or does not return any
> > > value to systemd), as a result the system suspends again even though
> > > we do nothing.
> > >
> > > This patch is to provide a possible workaround for these broken
> > > platforms, by introducing a 'cached' lid state, which is not based on
> > > evaluating _LID, but based on maintaining the lid state in a
> > > event-driven manner:
> > >
> > > 1. lid cache state is assigned to 'open' explicitly during boot up.
> > > 2. lid cache state can only be changed during suspend/resume, or someone
> > >notifies the lid device.
> > > 3. always return lid cache state instead of _LID to sysfs.
> > [Lv Zheng]
> > According to my understanding, returning _LID isn't wrong.
> >
> > In fact, some platforms rely on this behavior.
> > I know for sure there is a platform:
> > 1. Only generates LID open notification, and doesn't generate LID close
> > notification; and 2. _LID return correct state as it includes several EC 
> > accesses
> > to obtain correct hardware status.
> > Changing this behavior could break such platform while it is apparently
> > working by returning _LID from sysfs.
> >
> > OTOH, if BIOS lid state has been correctly updated according to the
> > notification, _LID is ensured to be correct by BIOS.
> >
> > So could you stop changing this behavior?
> > I can sense regressions around this change.
> >
> > >
> > > Linked: https://bugzilla.kernel.org/show_bug.cgi?id=89211
> > > Reported-and-tested-by: GiH 
> > > Reported-by: David J. Goehrig 
> > > Reported-by: Stephen Just 
> > > Signed-off-by: Chen Yu 
> > > ---
> > >  drivers/acpi/button.c | 61
> > > ++-
> > >  1 file changed, 60 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index
> > > 5c3b091..ec2a027 100644
> > > --- a/drivers/acpi/button.c
> > > +++ b/drivers/acpi/button.c
> > > @@ -28,6 +28,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >
> > >  #define PREFIX "ACPI: "
> > > @@ -53,6 +54,9 @@
> > >  #define ACPI_BUTTON_DEVICE_NAME_LID  "Lid Switch"
> > >  #define ACPI_BUTTON_TYPE_LID 0x05
> > >
> > > +#define ACPI_LID_CACHE_OPEN  1
> > > +#define ACPI_LID_CACHE_CLOSE 0
> > > +
> > >  #define _COMPONENT   

Re: [PATCH 1/2] ARM: OMAP1: DMA: Provide dma_slave_map to omap-dma

2016-02-21 Thread Peter Ujfalusi
On 2016-02-19 23:44, Aaro Koskinen wrote:
> On Tue, Feb 02, 2016 at 04:27:06PM +0200, Peter Ujfalusi wrote:
>> OMAP1 can not boot in DT mode and to be able to clean up the driver
>> regarding to the dmaengine API use (switching to the new API) the
>> device/slave -> filter mapping needs to be provided to the omap-dma driver.
>>
>> Signed-off-by: Peter Ujfalusi 
> 
> Acked-by: Aaro Koskinen 

Thanks Aaro,

I believe the map covers all drivers using DMA, but in case I missed any we -
you ;) will notice it as they will fail to get the DMA channels. This only
going to be visible after I send the driver changes for 4.7. In such a case we
will need to add the given device to the list.

-- 
Péter

> 
> A.
> 
>> ---
>>  arch/arm/mach-omap1/dma.c | 45 +
>>  1 file changed, 45 insertions(+)
>>
>> diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c
>> index 7b02ed218a42..f6ba589cd312 100644
>> --- a/arch/arm/mach-omap1/dma.c
>> +++ b/arch/arm/mach-omap1/dma.c
>> @@ -25,6 +25,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  
>> @@ -265,6 +266,42 @@ static const struct platform_device_info 
>> omap_dma_dev_info = {
>>  .num_res = 1,
>>  };
>>  
>> +/* OMAP730, OMAP850 */
>> +static const struct dma_slave_map omap7xx_sdma_map[] = {
>> +{ "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(8) },
>> +{ "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(9) },
>> +{ "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(10) },
>> +{ "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(11) },
>> +{ "mmci-omap.0", "tx", SDMA_FILTER_PARAM(21) },
>> +{ "mmci-omap.0", "rx", SDMA_FILTER_PARAM(22) },
>> +{ "omap_udc", "rx0", SDMA_FILTER_PARAM(26) },
>> +{ "omap_udc", "rx1", SDMA_FILTER_PARAM(27) },
>> +{ "omap_udc", "rx2", SDMA_FILTER_PARAM(28) },
>> +{ "omap_udc", "tx0", SDMA_FILTER_PARAM(29) },
>> +{ "omap_udc", "tx1", SDMA_FILTER_PARAM(30) },
>> +{ "omap_udc", "tx2", SDMA_FILTER_PARAM(31) },
>> +};
>> +
>> +/* OMAP1510, OMAP1610*/
>> +static const struct dma_slave_map omap1xxx_sdma_map[] = {
>> +{ "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(8) },
>> +{ "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(9) },
>> +{ "omap-mcbsp.3", "tx", SDMA_FILTER_PARAM(10) },
>> +{ "omap-mcbsp.3", "rx", SDMA_FILTER_PARAM(11) },
>> +{ "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(16) },
>> +{ "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(17) },
>> +{ "mmci-omap.0", "tx", SDMA_FILTER_PARAM(21) },
>> +{ "mmci-omap.0", "rx", SDMA_FILTER_PARAM(22) },
>> +{ "omap_udc", "rx0", SDMA_FILTER_PARAM(26) },
>> +{ "omap_udc", "rx1", SDMA_FILTER_PARAM(27) },
>> +{ "omap_udc", "rx2", SDMA_FILTER_PARAM(28) },
>> +{ "omap_udc", "tx0", SDMA_FILTER_PARAM(29) },
>> +{ "omap_udc", "tx1", SDMA_FILTER_PARAM(30) },
>> +{ "omap_udc", "tx2", SDMA_FILTER_PARAM(31) },
>> +{ "mmci-omap.1", "tx", SDMA_FILTER_PARAM(54) },
>> +{ "mmci-omap.1", "rx", SDMA_FILTER_PARAM(55) },
>> +};
>> +
>>  static struct omap_system_dma_plat_info dma_plat_info __initdata = {
>>  .reg_map= reg_map,
>>  .channel_stride = 0x40,
>> @@ -342,6 +379,14 @@ static int __init omap1_system_dma_init(void)
>>  p.dma_attr = d;
>>  p.errata = configure_dma_errata();
>>  
>> +if (cpu_is_omap7xx()) {
>> +p.slave_map = omap7xx_sdma_map;
>> +p.slavecnt = ARRAY_SIZE(omap7xx_sdma_map);
>> +} else {
>> +p.slave_map = omap1xxx_sdma_map;
>> +p.slavecnt = ARRAY_SIZE(omap1xxx_sdma_map);
>> +}
>> +
>>  ret = platform_device_add_data(pdev, , sizeof(p));
>>  if (ret) {
>>  dev_err(>dev, "%s: Unable to add resources for %s%d\n",
>> -- 
>> 2.7.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [PATCH 1/2] ARM: OMAP1: DMA: Provide dma_slave_map to omap-dma

2016-02-21 Thread Peter Ujfalusi
On 2016-02-19 23:44, Aaro Koskinen wrote:
> On Tue, Feb 02, 2016 at 04:27:06PM +0200, Peter Ujfalusi wrote:
>> OMAP1 can not boot in DT mode and to be able to clean up the driver
>> regarding to the dmaengine API use (switching to the new API) the
>> device/slave -> filter mapping needs to be provided to the omap-dma driver.
>>
>> Signed-off-by: Peter Ujfalusi 
> 
> Acked-by: Aaro Koskinen 

Thanks Aaro,

I believe the map covers all drivers using DMA, but in case I missed any we -
you ;) will notice it as they will fail to get the DMA channels. This only
going to be visible after I send the driver changes for 4.7. In such a case we
will need to add the given device to the list.

-- 
Péter

> 
> A.
> 
>> ---
>>  arch/arm/mach-omap1/dma.c | 45 +
>>  1 file changed, 45 insertions(+)
>>
>> diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c
>> index 7b02ed218a42..f6ba589cd312 100644
>> --- a/arch/arm/mach-omap1/dma.c
>> +++ b/arch/arm/mach-omap1/dma.c
>> @@ -25,6 +25,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  
>> @@ -265,6 +266,42 @@ static const struct platform_device_info 
>> omap_dma_dev_info = {
>>  .num_res = 1,
>>  };
>>  
>> +/* OMAP730, OMAP850 */
>> +static const struct dma_slave_map omap7xx_sdma_map[] = {
>> +{ "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(8) },
>> +{ "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(9) },
>> +{ "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(10) },
>> +{ "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(11) },
>> +{ "mmci-omap.0", "tx", SDMA_FILTER_PARAM(21) },
>> +{ "mmci-omap.0", "rx", SDMA_FILTER_PARAM(22) },
>> +{ "omap_udc", "rx0", SDMA_FILTER_PARAM(26) },
>> +{ "omap_udc", "rx1", SDMA_FILTER_PARAM(27) },
>> +{ "omap_udc", "rx2", SDMA_FILTER_PARAM(28) },
>> +{ "omap_udc", "tx0", SDMA_FILTER_PARAM(29) },
>> +{ "omap_udc", "tx1", SDMA_FILTER_PARAM(30) },
>> +{ "omap_udc", "tx2", SDMA_FILTER_PARAM(31) },
>> +};
>> +
>> +/* OMAP1510, OMAP1610*/
>> +static const struct dma_slave_map omap1xxx_sdma_map[] = {
>> +{ "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(8) },
>> +{ "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(9) },
>> +{ "omap-mcbsp.3", "tx", SDMA_FILTER_PARAM(10) },
>> +{ "omap-mcbsp.3", "rx", SDMA_FILTER_PARAM(11) },
>> +{ "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(16) },
>> +{ "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(17) },
>> +{ "mmci-omap.0", "tx", SDMA_FILTER_PARAM(21) },
>> +{ "mmci-omap.0", "rx", SDMA_FILTER_PARAM(22) },
>> +{ "omap_udc", "rx0", SDMA_FILTER_PARAM(26) },
>> +{ "omap_udc", "rx1", SDMA_FILTER_PARAM(27) },
>> +{ "omap_udc", "rx2", SDMA_FILTER_PARAM(28) },
>> +{ "omap_udc", "tx0", SDMA_FILTER_PARAM(29) },
>> +{ "omap_udc", "tx1", SDMA_FILTER_PARAM(30) },
>> +{ "omap_udc", "tx2", SDMA_FILTER_PARAM(31) },
>> +{ "mmci-omap.1", "tx", SDMA_FILTER_PARAM(54) },
>> +{ "mmci-omap.1", "rx", SDMA_FILTER_PARAM(55) },
>> +};
>> +
>>  static struct omap_system_dma_plat_info dma_plat_info __initdata = {
>>  .reg_map= reg_map,
>>  .channel_stride = 0x40,
>> @@ -342,6 +379,14 @@ static int __init omap1_system_dma_init(void)
>>  p.dma_attr = d;
>>  p.errata = configure_dma_errata();
>>  
>> +if (cpu_is_omap7xx()) {
>> +p.slave_map = omap7xx_sdma_map;
>> +p.slavecnt = ARRAY_SIZE(omap7xx_sdma_map);
>> +} else {
>> +p.slave_map = omap1xxx_sdma_map;
>> +p.slavecnt = ARRAY_SIZE(omap1xxx_sdma_map);
>> +}
>> +
>>  ret = platform_device_add_data(pdev, , sizeof(p));
>>  if (ret) {
>>  dev_err(>dev, "%s: Unable to add resources for %s%d\n",
>> -- 
>> 2.7.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [PATCH v6] serial: rewrite pxa2xx-uart to use 8250_core

2016-02-21 Thread Robert Jarzmik
Sergei Ianovich  writes:

> On Sat, 2016-02-06 at 22:22 -0800, Greg Kroah-Hartman wrote:
>> On Thu, Dec 24, 2015 at 06:15:14PM +0300, Sergei Ianovich wrote:
>> > pxa2xx-uart was a separate uart platform driver. It was declaring
>> > the same device names and numbers as 8250 driver. As a result,
>> > it was impossible to use 8250 driver on PXA SoCs.
>> > 
>> > Upon closer examination pxa2xx-uart turned out to be a clone of
>> > 8250_core driver.
>> > 
>> > Workaround for Erratum #19 according to Marvel(R) PXA270M Processor
>> > Specification Update (April 19, 2010) is dropped. 8250_core reads
>> > from FIFO immediately after checking DR bit in LSR.
>> > 
>> > The patch leaves the original SERIAL_PXA driver around. The
>> > original
>> > driver is just marked DEPRECATED in Kconfig and C source. When
>> > the original driver is considered safe to remove, no changes
>> > to SERIAL_8250 will be necessary.
>> 
>> But, you just broke existing configurations, right?  The serial port is
>> a different name now, are you willing to handle the angry users?
>
> No, the port name remains /dev/ttyS0. In fact, this conflict (both
> drivers use the same name and char major) is the reason for the patch.
> Noone should notice the change at runtime. There will be a warning at
> compile time which should make the transition to the new driver faster.
>
>> If so, great, get the platform maintainer to sign off on this please and
>> then resend it.

If you're talking about the PXA maintainer, then :
Acked-by: Robert Jarzmik 

I'm happy with the patch, all pxa board maintainers have been warned, and there
exists a fallback solution.

So let's go forward, and if people complain, let them complain and forward them
to me.

Cheers.

-- 
Robert


Re: [PATCH v6] serial: rewrite pxa2xx-uart to use 8250_core

2016-02-21 Thread Robert Jarzmik
Sergei Ianovich  writes:

> On Sat, 2016-02-06 at 22:22 -0800, Greg Kroah-Hartman wrote:
>> On Thu, Dec 24, 2015 at 06:15:14PM +0300, Sergei Ianovich wrote:
>> > pxa2xx-uart was a separate uart platform driver. It was declaring
>> > the same device names and numbers as 8250 driver. As a result,
>> > it was impossible to use 8250 driver on PXA SoCs.
>> > 
>> > Upon closer examination pxa2xx-uart turned out to be a clone of
>> > 8250_core driver.
>> > 
>> > Workaround for Erratum #19 according to Marvel(R) PXA270M Processor
>> > Specification Update (April 19, 2010) is dropped. 8250_core reads
>> > from FIFO immediately after checking DR bit in LSR.
>> > 
>> > The patch leaves the original SERIAL_PXA driver around. The
>> > original
>> > driver is just marked DEPRECATED in Kconfig and C source. When
>> > the original driver is considered safe to remove, no changes
>> > to SERIAL_8250 will be necessary.
>> 
>> But, you just broke existing configurations, right?  The serial port is
>> a different name now, are you willing to handle the angry users?
>
> No, the port name remains /dev/ttyS0. In fact, this conflict (both
> drivers use the same name and char major) is the reason for the patch.
> Noone should notice the change at runtime. There will be a warning at
> compile time which should make the transition to the new driver faster.
>
>> If so, great, get the platform maintainer to sign off on this please and
>> then resend it.

If you're talking about the PXA maintainer, then :
Acked-by: Robert Jarzmik 

I'm happy with the patch, all pxa board maintainers have been warned, and there
exists a fallback solution.

So let's go forward, and if people complain, let them complain and forward them
to me.

Cheers.

-- 
Robert


linux-next: Tree for Feb 22

2016-02-21 Thread Stephen Rothwell
Hi all,

Changes since 20160219:

The net-next tree lost its build failure.

The wireless-drivers-next tree lost its build failure.

The crypto tree gained conflicts against Linus' tree.

The drm tree gained conflicts against Linus' tree and a build failure
for which I applied a merge fix patch.

The kvm-arm tree gained conflicts against the arm64 tree.

The staging tree gained a conflict against the crypto tree.

The aio tree still had a build failure so I used the version from
next-20160111.

Non-merge commits (relative to Linus' tree): 6333
 5198 files changed, 236520 insertions(+), 117618 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(this fails its final link) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 239 trees (counting Linus' and 36 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (81f70ba233d5 Linux 4.5-rc5)
Merging fixes/master (36f90b0a2ddd Linux 4.5-rc2)
Merging kbuild-current/rc-fixes (3d1450d54a4f Makefile: Force gzip and xz on 
module install)
Merging arc-current/for-curr (74bf8efb5fa6 Linux 4.4-rc7)
Merging arm-current/fixes (e972c37459c8 ARM: 8519/1: ICST: try other dividends 
than 1)
Merging m68k-current/for-linus (daf670bc9d36 m68k/defconfig: Update defconfigs 
for v4.5-rc1)
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-fixes/fixes (6ecad912a007 powerpc/ioda: Set "read" permission 
when "write" is set)
Merging powerpc-merge-mpe/fixes (bc0195aad0da Linux 4.2-rc2)
Merging sparc/master (ca0bb0798022 Add sun4v_wdt watchdog driver)
Merging net/master (d07c0278da1f net: bcmgenet: Fix internal PHY link state)
Merging ipsec/master (325b71fe0f57 vti: Add pmtu handling to vti_xmit.)
Merging ipvs/master (5acaf89f88b9 netfilter: ipvs: handle 
ip_vs_fill_iph_skb_off failure)
Merging wireless-drivers/master (c699404db182 Merge tag 
'iwlwifi-for-kalle-2016-02-15' of 
https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging mac80211/master (212c5a5e6ba6 mac80211: minstrel: Change expected 
throughput unit back to Kbps)
Merging sound-current/for-linus (67ec1072b053 ALSA: pcm: Fix rwsem deadlock for 
non-atomic PCM stream)
Merging pci-current/for-linus (7d99d59d4c6b Revert "PCI, x86: Implement 
pcibios_alloc_irq() and pcibios_free_irq()")
Merging driver-core.current/driver-core-linus (18558cae0272 Linux 4.5-rc4)
Merging tty.current/tty-linus (18558cae0272 Linux 4.5-rc4)
Merging usb.current/usb-linus (e5bdfd50d6f7 Revert "usb: hub: do not clear BOS 
field during reset device")
Merging usb-gadget-fixes/fixes (ca06c4e3a00c usb: musb: fix DMA for host mode)
Merging usb-serial-fixes/usb-linus (d061c1caa31d USB: option: add "4G LTE 
usb-modem U901")
Merging usb-chipidea-fixes/ci-for-usb-stable (8c0614ca312c usb: chipidea: fix 
return value check in ci_hdrc_pci_probe())
Merging staging.current/staging-linus (7a64cd887fdb drivers: android: correct 
the size of struct binder_uintptr_t for BC_DEAD_BINDER_DONE)
Merging char-misc.current/char-misc-linus (18558cae0272 Linux 4.5-rc4)
Merging input-current/for-linus (ff84dabe3c6e Input: colibri-vf50-ts - add 
missing #include )
Merging crypto-current/master (8a3978ad55fb crypto: marvell/cesa - fix test in 
mv_cesa_dev_dma_init())
Merging ide/master (e04a2bd6d8c9 drivers/ide: make ide-scan-pci.c driver 
explicitly non-modular)
Merging devicetree-current/devicetree/merge 

linux-next: Tree for Feb 22

2016-02-21 Thread Stephen Rothwell
Hi all,

Changes since 20160219:

The net-next tree lost its build failure.

The wireless-drivers-next tree lost its build failure.

The crypto tree gained conflicts against Linus' tree.

The drm tree gained conflicts against Linus' tree and a build failure
for which I applied a merge fix patch.

The kvm-arm tree gained conflicts against the arm64 tree.

The staging tree gained a conflict against the crypto tree.

The aio tree still had a build failure so I used the version from
next-20160111.

Non-merge commits (relative to Linus' tree): 6333
 5198 files changed, 236520 insertions(+), 117618 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(this fails its final link) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 239 trees (counting Linus' and 36 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (81f70ba233d5 Linux 4.5-rc5)
Merging fixes/master (36f90b0a2ddd Linux 4.5-rc2)
Merging kbuild-current/rc-fixes (3d1450d54a4f Makefile: Force gzip and xz on 
module install)
Merging arc-current/for-curr (74bf8efb5fa6 Linux 4.4-rc7)
Merging arm-current/fixes (e972c37459c8 ARM: 8519/1: ICST: try other dividends 
than 1)
Merging m68k-current/for-linus (daf670bc9d36 m68k/defconfig: Update defconfigs 
for v4.5-rc1)
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-fixes/fixes (6ecad912a007 powerpc/ioda: Set "read" permission 
when "write" is set)
Merging powerpc-merge-mpe/fixes (bc0195aad0da Linux 4.2-rc2)
Merging sparc/master (ca0bb0798022 Add sun4v_wdt watchdog driver)
Merging net/master (d07c0278da1f net: bcmgenet: Fix internal PHY link state)
Merging ipsec/master (325b71fe0f57 vti: Add pmtu handling to vti_xmit.)
Merging ipvs/master (5acaf89f88b9 netfilter: ipvs: handle 
ip_vs_fill_iph_skb_off failure)
Merging wireless-drivers/master (c699404db182 Merge tag 
'iwlwifi-for-kalle-2016-02-15' of 
https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging mac80211/master (212c5a5e6ba6 mac80211: minstrel: Change expected 
throughput unit back to Kbps)
Merging sound-current/for-linus (67ec1072b053 ALSA: pcm: Fix rwsem deadlock for 
non-atomic PCM stream)
Merging pci-current/for-linus (7d99d59d4c6b Revert "PCI, x86: Implement 
pcibios_alloc_irq() and pcibios_free_irq()")
Merging driver-core.current/driver-core-linus (18558cae0272 Linux 4.5-rc4)
Merging tty.current/tty-linus (18558cae0272 Linux 4.5-rc4)
Merging usb.current/usb-linus (e5bdfd50d6f7 Revert "usb: hub: do not clear BOS 
field during reset device")
Merging usb-gadget-fixes/fixes (ca06c4e3a00c usb: musb: fix DMA for host mode)
Merging usb-serial-fixes/usb-linus (d061c1caa31d USB: option: add "4G LTE 
usb-modem U901")
Merging usb-chipidea-fixes/ci-for-usb-stable (8c0614ca312c usb: chipidea: fix 
return value check in ci_hdrc_pci_probe())
Merging staging.current/staging-linus (7a64cd887fdb drivers: android: correct 
the size of struct binder_uintptr_t for BC_DEAD_BINDER_DONE)
Merging char-misc.current/char-misc-linus (18558cae0272 Linux 4.5-rc4)
Merging input-current/for-linus (ff84dabe3c6e Input: colibri-vf50-ts - add 
missing #include )
Merging crypto-current/master (8a3978ad55fb crypto: marvell/cesa - fix test in 
mv_cesa_dev_dma_init())
Merging ide/master (e04a2bd6d8c9 drivers/ide: make ide-scan-pci.c driver 
explicitly non-modular)
Merging devicetree-current/devicetree/merge 

Re: [PATCH] rtlwifi: pass struct rtl_stats by reference as it is more efficient

2016-02-21 Thread Alexander Stein
On Saturday 20 February 2016 22:10:27, Colin King wrote:
> From: Colin Ian King 
> 
> passing rtl_stats by value is inefficient; the structure is over 300
> bytes in size and generally just one field (packet_report_type)
> is being accessed, so the pass by value is a relatively large overhead.
> This change just affects just the rx_command_packet calls.

Why not using a const pointer?

Best regards,
Alexander



Re: [PATCH] rtlwifi: pass struct rtl_stats by reference as it is more efficient

2016-02-21 Thread Alexander Stein
On Saturday 20 February 2016 22:10:27, Colin King wrote:
> From: Colin Ian King 
> 
> passing rtl_stats by value is inefficient; the structure is over 300
> bytes in size and generally just one field (packet_report_type)
> is being accessed, so the pass by value is a relatively large overhead.
> This change just affects just the rx_command_packet calls.

Why not using a const pointer?

Best regards,
Alexander



Re: [PATCH v2 3/5] perf tools: Update srcline/file if needed

2016-02-21 Thread Jiri Olsa
On Mon, Feb 22, 2016 at 09:31:51AM +0900, Namhyung Kim wrote:
> Normally the hist entry's srcline and/or srcfile is set during sorting.
> However sometime it's possible to a hist entry's srcline is not set yet
> after the sorting.  This is because the entry is so unique and other
> sort keys already make it distinct.  Then the srcline/file sort didn't
> have a chance to be called during the sorting.  In that case it has NULL
> srcline/srcfile field and shows nothing.
> 
> Before:
> 
>   $ perf report -s comm,sym,srcline
>   ...
>   Overhead  Command   Symbol
>   -
> 34.42%  swapper   [k] intel_idle  intel_idle.c:0
>  2.44%  perf  [.] __poll_nocancel (null)
>  1.70%  gnome-shell   [k] fw_domains_get  (null)
>  1.04%  Xorg  [k] sock_poll   (null)
> 
> After:
> 
> 34.42%  swapper   [k] intel_idle  intel_idle.c:0
>  2.44%  perf  [.] __poll_nocancel .:0
>  1.70%  gnome-shell   [k] fw_domains_get  fw_domains_get+42
>  1.04%  Xorg  [k] sock_poll   socket.c:0
> 
> Signed-off-by: Namhyung Kim 

Acked-by: Jiri Olsa 

thanks,
jirka


Re: [PATCH v2 3/5] perf tools: Update srcline/file if needed

2016-02-21 Thread Jiri Olsa
On Mon, Feb 22, 2016 at 09:31:51AM +0900, Namhyung Kim wrote:
> Normally the hist entry's srcline and/or srcfile is set during sorting.
> However sometime it's possible to a hist entry's srcline is not set yet
> after the sorting.  This is because the entry is so unique and other
> sort keys already make it distinct.  Then the srcline/file sort didn't
> have a chance to be called during the sorting.  In that case it has NULL
> srcline/srcfile field and shows nothing.
> 
> Before:
> 
>   $ perf report -s comm,sym,srcline
>   ...
>   Overhead  Command   Symbol
>   -
> 34.42%  swapper   [k] intel_idle  intel_idle.c:0
>  2.44%  perf  [.] __poll_nocancel (null)
>  1.70%  gnome-shell   [k] fw_domains_get  (null)
>  1.04%  Xorg  [k] sock_poll   (null)
> 
> After:
> 
> 34.42%  swapper   [k] intel_idle  intel_idle.c:0
>  2.44%  perf  [.] __poll_nocancel .:0
>  1.70%  gnome-shell   [k] fw_domains_get  fw_domains_get+42
>  1.04%  Xorg  [k] sock_poll   socket.c:0
> 
> Signed-off-by: Namhyung Kim 

Acked-by: Jiri Olsa 

thanks,
jirka


Re: mmc: Add CONFIG_MMC_BLOCK_MAX_SPEED

2016-02-21 Thread Pavel Machek
Hi!

On Thu 2016-02-04 12:29:07, Mark Salyzyn wrote:
> When CONFIG_MMC_BLOCK_MAX_SPEED is enabled, Expose max_read_speed,
> max_write_speed and cache_size controls to simulate a slow eMMC device.
> The boot default values for each respectively are
> CONFIG_MMC_BLOCK_MAX_READ_SPEED, CONFIG_MMC_BLOCK_MAX_WRITE_SPEED and
> CONFIG_MMC_BLOCK_CACHE_SIZE respectively; and if not defined are
> 0 (off), 0, (off) and 4 MB also respectively.

Extra , after 0.

Dunno. At minimum, I'd call the option something like
"MMC_DEBUG_MAX_SPEED" and the speeds should be really controlled via
/sys or something...

...and ... is there reason to limit it to mmc devices? Making
harddrive slow would make it useful for testing, too...

...and you have the /sys interface. Drop the config options?

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Re: mmc: Add CONFIG_MMC_BLOCK_MAX_SPEED

2016-02-21 Thread Pavel Machek
Hi!

On Thu 2016-02-04 12:29:07, Mark Salyzyn wrote:
> When CONFIG_MMC_BLOCK_MAX_SPEED is enabled, Expose max_read_speed,
> max_write_speed and cache_size controls to simulate a slow eMMC device.
> The boot default values for each respectively are
> CONFIG_MMC_BLOCK_MAX_READ_SPEED, CONFIG_MMC_BLOCK_MAX_WRITE_SPEED and
> CONFIG_MMC_BLOCK_CACHE_SIZE respectively; and if not defined are
> 0 (off), 0, (off) and 4 MB also respectively.

Extra , after 0.

Dunno. At minimum, I'd call the option something like
"MMC_DEBUG_MAX_SPEED" and the speeds should be really controlled via
/sys or something...

...and ... is there reason to limit it to mmc devices? Making
harddrive slow would make it useful for testing, too...

...and you have the /sys interface. Drop the config options?

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Re: [PATCH v3 3/3] pci: dra7xx: use pdata callbacks to perform reset

2016-02-21 Thread Paul Walmsley
Kishon,

On Mon, 22 Feb 2016, Kishon Vijay Abraham I wrote:

> Sekhar,
> 
> On Thursday 18 February 2016 07:51 PM, Sekhar Nori wrote:
> > On Friday 12 February 2016 10:50 PM, Suman Anna wrote:
> >> Sekhar,
> >> Will you be following up with above suggestion since Kishon is gonna be 
> >> out?
> > 
> > Alright, noticed this action for me :) Went through the thread, and 
> > looks like this is what we want to see?
> > 
> > Thanks,
> > Sekhar
> > 
> > ---8<---
> > From e3ba368f2235e1bf38a22ba8ea4e5c12aaafda19 Mon Sep 17 00:00:00 2001
> > Message-Id: 
> > 
> > From: Sekhar Nori 
> > Date: Thu, 18 Feb 2016 16:49:56 +0530
> > Subject: [PATCH 1/1] ARM: DRA7: hwmod: Add custom reset handler for PCIeSS
> > 
> > Add a custom reset handler for DRA7x PCIeSS. This
> > handler is required to deassert PCIe hardreset lines
> > after they have been asserted.
> > 
> > This enables the PCIe driver to access registers after
> > PCIeSS has been runtime enabled without having to
> > deassert hardreset lines itself.
> > 
> > With this patch applied, used lspci to make sure
> > connected PCIe device enumerates on DRA74x and DRA72x
> > EVMs.
> > 
> > Signed-off-by: Sekhar Nori 
> > ---
> > Applies to tag for-v4.6/omap-hwmod-a of Paul W's tree.
> > 
> >  arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 23 +++
> >  1 file changed, 23 insertions(+)
> > 
> > diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
> > b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> > index b61355e2a771..252b74633e31 100644
> > --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> > +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> > @@ -1526,8 +1526,31 @@ static struct omap_hwmod dra7xx_ocp2scp3_hwmod = {
> >   *
> >   */
> >  
> > +/*
> > + * As noted in documentation for _reset() in omap_hwmod.c, the stock reset
> > + * functionality of OMAP HWMOD layer does not deassert the hardreset lines
> > + * associated with an IP automatically leaving the driver to handle that
> > + * by itself. This does not work for PCIeSS which needs the reset lines
> > + * deasserted for the driver to start accessing registers.
> > + *
> > + * We use a PCIeSS HWMOD class specific reset handler to deassert the 
> > hardreset
> > + * lines after asserting them.
> > + */
> > +static int dra7xx_pciess_reset(struct omap_hwmod *oh)
> > +{
> > +   int i;
> > +
> > +   for (i = 0; i < oh->rst_lines_cnt; i++) {
> > +   omap_hwmod_assert_hardreset(oh, oh->rst_lines[i].name);
> > +   omap_hwmod_deassert_hardreset(oh, oh->rst_lines[i].name);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  static struct omap_hwmod_class dra7xx_pciess_hwmod_class = {
> > .name   = "pcie",
> > +   .reset  = dra7xx_pciess_reset,
> >  };
> 
> Thanks for the patch.

Could you please test the bind/unbind functionality just to make sure it 
works?

thanks

- Paul


Re: [PATCH v3 3/3] pci: dra7xx: use pdata callbacks to perform reset

2016-02-21 Thread Paul Walmsley
Kishon,

On Mon, 22 Feb 2016, Kishon Vijay Abraham I wrote:

> Sekhar,
> 
> On Thursday 18 February 2016 07:51 PM, Sekhar Nori wrote:
> > On Friday 12 February 2016 10:50 PM, Suman Anna wrote:
> >> Sekhar,
> >> Will you be following up with above suggestion since Kishon is gonna be 
> >> out?
> > 
> > Alright, noticed this action for me :) Went through the thread, and 
> > looks like this is what we want to see?
> > 
> > Thanks,
> > Sekhar
> > 
> > ---8<---
> > From e3ba368f2235e1bf38a22ba8ea4e5c12aaafda19 Mon Sep 17 00:00:00 2001
> > Message-Id: 
> > 
> > From: Sekhar Nori 
> > Date: Thu, 18 Feb 2016 16:49:56 +0530
> > Subject: [PATCH 1/1] ARM: DRA7: hwmod: Add custom reset handler for PCIeSS
> > 
> > Add a custom reset handler for DRA7x PCIeSS. This
> > handler is required to deassert PCIe hardreset lines
> > after they have been asserted.
> > 
> > This enables the PCIe driver to access registers after
> > PCIeSS has been runtime enabled without having to
> > deassert hardreset lines itself.
> > 
> > With this patch applied, used lspci to make sure
> > connected PCIe device enumerates on DRA74x and DRA72x
> > EVMs.
> > 
> > Signed-off-by: Sekhar Nori 
> > ---
> > Applies to tag for-v4.6/omap-hwmod-a of Paul W's tree.
> > 
> >  arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 23 +++
> >  1 file changed, 23 insertions(+)
> > 
> > diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
> > b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> > index b61355e2a771..252b74633e31 100644
> > --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> > +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> > @@ -1526,8 +1526,31 @@ static struct omap_hwmod dra7xx_ocp2scp3_hwmod = {
> >   *
> >   */
> >  
> > +/*
> > + * As noted in documentation for _reset() in omap_hwmod.c, the stock reset
> > + * functionality of OMAP HWMOD layer does not deassert the hardreset lines
> > + * associated with an IP automatically leaving the driver to handle that
> > + * by itself. This does not work for PCIeSS which needs the reset lines
> > + * deasserted for the driver to start accessing registers.
> > + *
> > + * We use a PCIeSS HWMOD class specific reset handler to deassert the 
> > hardreset
> > + * lines after asserting them.
> > + */
> > +static int dra7xx_pciess_reset(struct omap_hwmod *oh)
> > +{
> > +   int i;
> > +
> > +   for (i = 0; i < oh->rst_lines_cnt; i++) {
> > +   omap_hwmod_assert_hardreset(oh, oh->rst_lines[i].name);
> > +   omap_hwmod_deassert_hardreset(oh, oh->rst_lines[i].name);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  static struct omap_hwmod_class dra7xx_pciess_hwmod_class = {
> > .name   = "pcie",
> > +   .reset  = dra7xx_pciess_reset,
> >  };
> 
> Thanks for the patch.

Could you please test the bind/unbind functionality just to make sure it 
works?

thanks

- Paul


Re: [PATCH v3 3/3] pci: dra7xx: use pdata callbacks to perform reset

2016-02-21 Thread Kishon Vijay Abraham I
Sekhar,

On Thursday 18 February 2016 07:51 PM, Sekhar Nori wrote:
> On Friday 12 February 2016 10:50 PM, Suman Anna wrote:
>> Sekhar,
>> Will you be following up with above suggestion since Kishon is gonna be out?
> 
> Alright, noticed this action for me :) Went through the thread, and 
> looks like this is what we want to see?
> 
> Thanks,
> Sekhar
> 
> ---8<---
> From e3ba368f2235e1bf38a22ba8ea4e5c12aaafda19 Mon Sep 17 00:00:00 2001
> Message-Id: 
> 
> From: Sekhar Nori 
> Date: Thu, 18 Feb 2016 16:49:56 +0530
> Subject: [PATCH 1/1] ARM: DRA7: hwmod: Add custom reset handler for PCIeSS
> 
> Add a custom reset handler for DRA7x PCIeSS. This
> handler is required to deassert PCIe hardreset lines
> after they have been asserted.
> 
> This enables the PCIe driver to access registers after
> PCIeSS has been runtime enabled without having to
> deassert hardreset lines itself.
> 
> With this patch applied, used lspci to make sure
> connected PCIe device enumerates on DRA74x and DRA72x
> EVMs.
> 
> Signed-off-by: Sekhar Nori 
> ---
> Applies to tag for-v4.6/omap-hwmod-a of Paul W's tree.
> 
>  arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 23 +++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
> b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> index b61355e2a771..252b74633e31 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> @@ -1526,8 +1526,31 @@ static struct omap_hwmod dra7xx_ocp2scp3_hwmod = {
>   *
>   */
>  
> +/*
> + * As noted in documentation for _reset() in omap_hwmod.c, the stock reset
> + * functionality of OMAP HWMOD layer does not deassert the hardreset lines
> + * associated with an IP automatically leaving the driver to handle that
> + * by itself. This does not work for PCIeSS which needs the reset lines
> + * deasserted for the driver to start accessing registers.
> + *
> + * We use a PCIeSS HWMOD class specific reset handler to deassert the 
> hardreset
> + * lines after asserting them.
> + */
> +static int dra7xx_pciess_reset(struct omap_hwmod *oh)
> +{
> + int i;
> +
> + for (i = 0; i < oh->rst_lines_cnt; i++) {
> + omap_hwmod_assert_hardreset(oh, oh->rst_lines[i].name);
> + omap_hwmod_deassert_hardreset(oh, oh->rst_lines[i].name);
> + }
> +
> + return 0;
> +}
> +
>  static struct omap_hwmod_class dra7xx_pciess_hwmod_class = {
>   .name   = "pcie",
> + .reset  = dra7xx_pciess_reset,
>  };

Thanks for the patch.

-Kishon


Re: [PATCH v3 3/3] pci: dra7xx: use pdata callbacks to perform reset

2016-02-21 Thread Kishon Vijay Abraham I
Sekhar,

On Thursday 18 February 2016 07:51 PM, Sekhar Nori wrote:
> On Friday 12 February 2016 10:50 PM, Suman Anna wrote:
>> Sekhar,
>> Will you be following up with above suggestion since Kishon is gonna be out?
> 
> Alright, noticed this action for me :) Went through the thread, and 
> looks like this is what we want to see?
> 
> Thanks,
> Sekhar
> 
> ---8<---
> From e3ba368f2235e1bf38a22ba8ea4e5c12aaafda19 Mon Sep 17 00:00:00 2001
> Message-Id: 
> 
> From: Sekhar Nori 
> Date: Thu, 18 Feb 2016 16:49:56 +0530
> Subject: [PATCH 1/1] ARM: DRA7: hwmod: Add custom reset handler for PCIeSS
> 
> Add a custom reset handler for DRA7x PCIeSS. This
> handler is required to deassert PCIe hardreset lines
> after they have been asserted.
> 
> This enables the PCIe driver to access registers after
> PCIeSS has been runtime enabled without having to
> deassert hardreset lines itself.
> 
> With this patch applied, used lspci to make sure
> connected PCIe device enumerates on DRA74x and DRA72x
> EVMs.
> 
> Signed-off-by: Sekhar Nori 
> ---
> Applies to tag for-v4.6/omap-hwmod-a of Paul W's tree.
> 
>  arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 23 +++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
> b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> index b61355e2a771..252b74633e31 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
> @@ -1526,8 +1526,31 @@ static struct omap_hwmod dra7xx_ocp2scp3_hwmod = {
>   *
>   */
>  
> +/*
> + * As noted in documentation for _reset() in omap_hwmod.c, the stock reset
> + * functionality of OMAP HWMOD layer does not deassert the hardreset lines
> + * associated with an IP automatically leaving the driver to handle that
> + * by itself. This does not work for PCIeSS which needs the reset lines
> + * deasserted for the driver to start accessing registers.
> + *
> + * We use a PCIeSS HWMOD class specific reset handler to deassert the 
> hardreset
> + * lines after asserting them.
> + */
> +static int dra7xx_pciess_reset(struct omap_hwmod *oh)
> +{
> + int i;
> +
> + for (i = 0; i < oh->rst_lines_cnt; i++) {
> + omap_hwmod_assert_hardreset(oh, oh->rst_lines[i].name);
> + omap_hwmod_deassert_hardreset(oh, oh->rst_lines[i].name);
> + }
> +
> + return 0;
> +}
> +
>  static struct omap_hwmod_class dra7xx_pciess_hwmod_class = {
>   .name   = "pcie",
> + .reset  = dra7xx_pciess_reset,
>  };

Thanks for the patch.

-Kishon


Re: [PATCH] usb: chipidea: Configure DMA properties and ops from DT

2016-02-21 Thread Bjorn Andersson
On Sun 21 Feb 22:02 PST 2016, Peter Chen wrote:

> On Sun, Feb 21, 2016 at 09:32:13PM -0800, Bjorn Andersson wrote:
> > On certain platforms (e.g. ARM64) the dma_ops needs to be explicitly set
> > to be able to do DMA allocations, so use the of_dma_configure() helper
> > to populate the dma properties and assign an appropriate dma_ops.
> > 
> > Signed-off-by: Bjorn Andersson 
> > ---
> >  drivers/usb/chipidea/core.c | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 7404064b9bbc..047b9d4e67aa 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -62,6 +62,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -834,6 +835,9 @@ struct platform_device *ci_hdrc_add_device(struct 
> > device *dev,
> > pdev->dev.dma_parms = dev->dma_parms;
> > dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
> >  
> > +   if (IS_ENABLED(CONFIG_OF) && dev->of_node)
> > +   of_dma_configure(>dev, dev->of_node);
> > +
> > ret = platform_device_add_resources(pdev, res, nres);
> > if (ret)
> > goto err;
> 
> Just would like to confirm, it will not affect the default behavior
> which the "dma-ranges" is not set at those platforms?
> 

If I read the code correctly, the only difference if you don't specify 
dma-ranges, dma-coherent or specify an iommu is that the dma_ops gets
assigned.

Regards,
Bjorn


Re: [PATCH] usb: chipidea: Configure DMA properties and ops from DT

2016-02-21 Thread Bjorn Andersson
On Sun 21 Feb 22:02 PST 2016, Peter Chen wrote:

> On Sun, Feb 21, 2016 at 09:32:13PM -0800, Bjorn Andersson wrote:
> > On certain platforms (e.g. ARM64) the dma_ops needs to be explicitly set
> > to be able to do DMA allocations, so use the of_dma_configure() helper
> > to populate the dma properties and assign an appropriate dma_ops.
> > 
> > Signed-off-by: Bjorn Andersson 
> > ---
> >  drivers/usb/chipidea/core.c | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 7404064b9bbc..047b9d4e67aa 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -62,6 +62,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -834,6 +835,9 @@ struct platform_device *ci_hdrc_add_device(struct 
> > device *dev,
> > pdev->dev.dma_parms = dev->dma_parms;
> > dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
> >  
> > +   if (IS_ENABLED(CONFIG_OF) && dev->of_node)
> > +   of_dma_configure(>dev, dev->of_node);
> > +
> > ret = platform_device_add_resources(pdev, res, nres);
> > if (ret)
> > goto err;
> 
> Just would like to confirm, it will not affect the default behavior
> which the "dma-ranges" is not set at those platforms?
> 

If I read the code correctly, the only difference if you don't specify 
dma-ranges, dma-coherent or specify an iommu is that the dma_ops gets
assigned.

Regards,
Bjorn


Re: [linux-sunxi] Re: [PATCH v7 0/2] ASoC: Add SPDIF support for Allwinner SoCs

2016-02-21 Thread Code Kipper
On 22 February 2016 at 04:12, Mark Brown  wrote:
> On Sun, Feb 21, 2016 at 12:13:36PM +0100, codekip...@gmail.com wrote:
>> From: Marcus Cooper 
>>
>> For now just the SPDIF transmitter has been tested on a Mele A2000(A10)
>> and a Itead Ibox(A20).
>
> This was already applied.  If any updates are required or you are
> submitting further changes they should be sent as incremental updates
> against current git, existing patches will not be replaced.

No worries...I saw the ACK from Maxime and then your comment so I
thought I needed to do another revision. I can push an incremental
update later,
thanks,
CK
>
> --
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v7 0/2] ASoC: Add SPDIF support for Allwinner SoCs

2016-02-21 Thread Code Kipper
On 22 February 2016 at 04:12, Mark Brown  wrote:
> On Sun, Feb 21, 2016 at 12:13:36PM +0100, codekip...@gmail.com wrote:
>> From: Marcus Cooper 
>>
>> For now just the SPDIF transmitter has been tested on a Mele A2000(A10)
>> and a Itead Ibox(A20).
>
> This was already applied.  If any updates are required or you are
> submitting further changes they should be sent as incremental updates
> against current git, existing patches will not be replaced.

No worries...I saw the ACK from Maxime and then your comment so I
thought I needed to do another revision. I can push an incremental
update later,
thanks,
CK
>
> --
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Re: [Xen-devel] [PATCH 8/9] x86/rtc: replace paravirt_enabled() check with subarch check

2016-02-21 Thread Luis R. Rodriguez
On Fri, Feb 19, 2016 at 03:48:41PM +0100, Luis R. Rodriguez wrote:
> On Fri, Feb 19, 2016 at 02:22:12PM +0100, Juergen Gross wrote:
> > On 19/02/16 14:08, Luis R. Rodriguez wrote:
> > > The current check is a super long winded way of asking if this
> > > is on lguest. The flags is used for legacy features, this is
> > 
> > What about Xen pv-domU? I wouldn't expect those to have PV_SUPPORTED_RTC
> > set.
> 
> Hrm, I see -- how do we check for that in a standard more clean way?

OK we have 4 types of x86 platforms that disable RTC:

  * Intel MID
  * Lguest
  * Xen dom-U
  * x86 on legacy systems annotated with an ACPI legacy flag

So it would seem its best to just generalize the disabling of
the RTC for any x86 platform, we could also fold the ACPI check
into the FADT parse table routine, which is called during
setup_arch().

So how about this:

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index f6192502149e..c261402340e3 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -19,12 +19,6 @@ static inline int paravirt_enabled(void)
return pv_info.paravirt_enabled;
 }
 
-static inline int paravirt_has_feature(unsigned int feature)
-{
-   WARN_ON_ONCE(!pv_info.paravirt_enabled);
-   return (pv_info.features & feature);
-}
-
 static inline void load_sp0(struct tss_struct *tss,
 struct thread_struct *thread)
 {
diff --git a/arch/x86/include/asm/paravirt_types.h 
b/arch/x86/include/asm/paravirt_types.h
index 77db5616a473..2489d6a08e89 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -70,14 +70,9 @@ struct pv_info {
 #endif
 
int paravirt_enabled;
-   unsigned int features;/* valid only if paravirt_enabled is set */
const char *name;
 };
 
-#define paravirt_has(x) paravirt_has_feature(PV_SUPPORTED_##x)
-/* Supported features */
-#define PV_SUPPORTED_RTC(1<<0)
-
 struct pv_init_ops {
/*
 * Patch may replace one of the defined code sequences with
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 20c11d1aa4cc..10f3614265c1 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -472,7 +472,6 @@ static inline unsigned long current_top_of_stack(void)
 #else
 #define __cpuidnative_cpuid
 #define paravirt_enabled() 0
-#define paravirt_has(x)0
 
 static inline void load_sp0(struct tss_struct *tss,
struct thread_struct *thread)
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 1ae89a2721d6..fe0d579b63e3 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -84,11 +84,14 @@ struct x86_init_paging {
  * boot cpu
  * @timer_init:initialize the platform timer (default 
PIT/HPET)
  * @wallclock_init:init the wallclock device
+ * @no_cmos_rtc:   set when platform has no CMOS real-time clock
+ * present
  */
 struct x86_init_timers {
void (*setup_percpu_clockev)(void);
void (*timer_init)(void);
void (*wallclock_init)(void);
+   bool no_cmos_rtc;
 };
 
 /**
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e75907601a41..6b2cac0f276b 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -913,6 +913,10 @@ late_initcall(hpet_insert_resource);
 
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
+   if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
+   pr_debug("ACPI: not registering RTC platform device\n");
+   x86_init.timers.no_cmos_rtc = true;
+   }
 
 #ifdef CONFIG_X86_PM_TIMER
/* detect the location of the ACPI PM Timer */
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 4af8d063fb36..ef92aa84c2e3 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_X86_32
 /*
@@ -188,19 +189,7 @@ static __init int add_rtc_cmos(void)
if (of_have_populated_dt())
return 0;
 
-   /* Intel MID platforms don't have ioport rtc */
-   if (intel_mid_identify_cpu())
-   return -ENODEV;
-
-#ifdef CONFIG_ACPI
-   if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
-   /* This warning can likely go away again in a year or two. */
-   pr_info("ACPI: not registering RTC platform device\n");
-   return -ENODEV;
-   }
-#endif
-
-   if (paravirt_enabled() && !paravirt_has(RTC))
+   if (x86_init.timers.no_cmos_rtc)
return -ENODEV;
 
platform_device_register(_device);
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 4ba229ac3f4f..62535a869e06 100644
--- a/arch/x86/lguest/boot.c

Re: [Xen-devel] [PATCH 8/9] x86/rtc: replace paravirt_enabled() check with subarch check

2016-02-21 Thread Luis R. Rodriguez
On Fri, Feb 19, 2016 at 03:48:41PM +0100, Luis R. Rodriguez wrote:
> On Fri, Feb 19, 2016 at 02:22:12PM +0100, Juergen Gross wrote:
> > On 19/02/16 14:08, Luis R. Rodriguez wrote:
> > > The current check is a super long winded way of asking if this
> > > is on lguest. The flags is used for legacy features, this is
> > 
> > What about Xen pv-domU? I wouldn't expect those to have PV_SUPPORTED_RTC
> > set.
> 
> Hrm, I see -- how do we check for that in a standard more clean way?

OK we have 4 types of x86 platforms that disable RTC:

  * Intel MID
  * Lguest
  * Xen dom-U
  * x86 on legacy systems annotated with an ACPI legacy flag

So it would seem its best to just generalize the disabling of
the RTC for any x86 platform, we could also fold the ACPI check
into the FADT parse table routine, which is called during
setup_arch().

So how about this:

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index f6192502149e..c261402340e3 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -19,12 +19,6 @@ static inline int paravirt_enabled(void)
return pv_info.paravirt_enabled;
 }
 
-static inline int paravirt_has_feature(unsigned int feature)
-{
-   WARN_ON_ONCE(!pv_info.paravirt_enabled);
-   return (pv_info.features & feature);
-}
-
 static inline void load_sp0(struct tss_struct *tss,
 struct thread_struct *thread)
 {
diff --git a/arch/x86/include/asm/paravirt_types.h 
b/arch/x86/include/asm/paravirt_types.h
index 77db5616a473..2489d6a08e89 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -70,14 +70,9 @@ struct pv_info {
 #endif
 
int paravirt_enabled;
-   unsigned int features;/* valid only if paravirt_enabled is set */
const char *name;
 };
 
-#define paravirt_has(x) paravirt_has_feature(PV_SUPPORTED_##x)
-/* Supported features */
-#define PV_SUPPORTED_RTC(1<<0)
-
 struct pv_init_ops {
/*
 * Patch may replace one of the defined code sequences with
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 20c11d1aa4cc..10f3614265c1 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -472,7 +472,6 @@ static inline unsigned long current_top_of_stack(void)
 #else
 #define __cpuidnative_cpuid
 #define paravirt_enabled() 0
-#define paravirt_has(x)0
 
 static inline void load_sp0(struct tss_struct *tss,
struct thread_struct *thread)
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 1ae89a2721d6..fe0d579b63e3 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -84,11 +84,14 @@ struct x86_init_paging {
  * boot cpu
  * @timer_init:initialize the platform timer (default 
PIT/HPET)
  * @wallclock_init:init the wallclock device
+ * @no_cmos_rtc:   set when platform has no CMOS real-time clock
+ * present
  */
 struct x86_init_timers {
void (*setup_percpu_clockev)(void);
void (*timer_init)(void);
void (*wallclock_init)(void);
+   bool no_cmos_rtc;
 };
 
 /**
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e75907601a41..6b2cac0f276b 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -913,6 +913,10 @@ late_initcall(hpet_insert_resource);
 
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
+   if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
+   pr_debug("ACPI: not registering RTC platform device\n");
+   x86_init.timers.no_cmos_rtc = true;
+   }
 
 #ifdef CONFIG_X86_PM_TIMER
/* detect the location of the ACPI PM Timer */
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 4af8d063fb36..ef92aa84c2e3 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_X86_32
 /*
@@ -188,19 +189,7 @@ static __init int add_rtc_cmos(void)
if (of_have_populated_dt())
return 0;
 
-   /* Intel MID platforms don't have ioport rtc */
-   if (intel_mid_identify_cpu())
-   return -ENODEV;
-
-#ifdef CONFIG_ACPI
-   if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
-   /* This warning can likely go away again in a year or two. */
-   pr_info("ACPI: not registering RTC platform device\n");
-   return -ENODEV;
-   }
-#endif
-
-   if (paravirt_enabled() && !paravirt_has(RTC))
+   if (x86_init.timers.no_cmos_rtc)
return -ENODEV;
 
platform_device_register(_device);
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 4ba229ac3f4f..62535a869e06 100644
--- a/arch/x86/lguest/boot.c

Re: [PATCH] usb: chipidea: Configure DMA properties and ops from DT

2016-02-21 Thread Peter Chen
On Sun, Feb 21, 2016 at 09:32:13PM -0800, Bjorn Andersson wrote:
> On certain platforms (e.g. ARM64) the dma_ops needs to be explicitly set
> to be able to do DMA allocations, so use the of_dma_configure() helper
> to populate the dma properties and assign an appropriate dma_ops.
> 
> Signed-off-by: Bjorn Andersson 
> ---
>  drivers/usb/chipidea/core.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 7404064b9bbc..047b9d4e67aa 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -62,6 +62,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -834,6 +835,9 @@ struct platform_device *ci_hdrc_add_device(struct device 
> *dev,
>   pdev->dev.dma_parms = dev->dma_parms;
>   dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
>  
> + if (IS_ENABLED(CONFIG_OF) && dev->of_node)
> + of_dma_configure(>dev, dev->of_node);
> +
>   ret = platform_device_add_resources(pdev, res, nres);
>   if (ret)
>   goto err;

Just would like to confirm, it will not affect the default behavior
which the "dma-ranges" is not set at those platforms?

-- 

Best Regards,
Peter Chen


Re: [PATCH] usb: chipidea: Configure DMA properties and ops from DT

2016-02-21 Thread Peter Chen
On Sun, Feb 21, 2016 at 09:32:13PM -0800, Bjorn Andersson wrote:
> On certain platforms (e.g. ARM64) the dma_ops needs to be explicitly set
> to be able to do DMA allocations, so use the of_dma_configure() helper
> to populate the dma properties and assign an appropriate dma_ops.
> 
> Signed-off-by: Bjorn Andersson 
> ---
>  drivers/usb/chipidea/core.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 7404064b9bbc..047b9d4e67aa 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -62,6 +62,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -834,6 +835,9 @@ struct platform_device *ci_hdrc_add_device(struct device 
> *dev,
>   pdev->dev.dma_parms = dev->dma_parms;
>   dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
>  
> + if (IS_ENABLED(CONFIG_OF) && dev->of_node)
> + of_dma_configure(>dev, dev->of_node);
> +
>   ret = platform_device_add_resources(pdev, res, nres);
>   if (ret)
>   goto err;

Just would like to confirm, it will not affect the default behavior
which the "dma-ranges" is not set at those platforms?

-- 

Best Regards,
Peter Chen


[PATCH v2 2/4] dmaengine: xilinx_vdma: Simplify spin lock handling

2016-02-21 Thread Kedareswara rao Appana
This patch simplifies the spin lock handling in the driver.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 27 ++-
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 06bffec..d646218 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -605,17 +605,14 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_config *config = >config;
struct xilinx_vdma_tx_descriptor *desc, *tail_desc;
-   unsigned long flags;
u32 reg;
struct xilinx_vdma_tx_segment *tail_segment;
 
if (chan->err)
return;
 
-   spin_lock_irqsave(>lock, flags);
-
if (list_empty(>pending_list))
-   goto out_unlock;
+   return;
 
desc = list_first_entry(>pending_list,
struct xilinx_vdma_tx_descriptor, node);
@@ -629,7 +626,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
if (chan->has_sg && xilinx_vdma_is_running(chan) &&
!xilinx_vdma_is_idle(chan)) {
dev_dbg(chan->dev, "DMA controller still busy\n");
-   goto out_unlock;
+   return;
}
 
/*
@@ -676,7 +673,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
xilinx_vdma_start(chan);
 
if (chan->err)
-   goto out_unlock;
+   return;
 
/* Start the transfer */
if (chan->has_sg) {
@@ -696,7 +693,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
}
 
if (!last)
-   goto out_unlock;
+   return;
 
/* HW expects these parameters to be same for one transaction */
vdma_desc_write(chan, XILINX_VDMA_REG_HSIZE, last->hw.hsize);
@@ -707,9 +704,6 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 
list_splice_tail_init(>pending_list, >active_list);
chan->desc_pendingcount = 0;
-
-out_unlock:
-   spin_unlock_irqrestore(>lock, flags);
 }
 
 /**
@@ -719,8 +713,11 @@ out_unlock:
 static void xilinx_vdma_issue_pending(struct dma_chan *dchan)
 {
struct xilinx_vdma_chan *chan = to_xilinx_chan(dchan);
+   unsigned long flags;
 
+   spin_lock_irqsave(>lock, flags);
xilinx_vdma_start_transfer(chan);
+   spin_unlock_irqrestore(>lock, flags);
 }
 
 /**
@@ -732,21 +729,15 @@ static void xilinx_vdma_issue_pending(struct dma_chan 
*dchan)
 static void xilinx_vdma_complete_descriptor(struct xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_tx_descriptor *desc, *next;
-   unsigned long flags;
-
-   spin_lock_irqsave(>lock, flags);
 
if (list_empty(>active_list))
-   goto out_unlock;
+   return;
 
list_for_each_entry_safe(desc, next, >active_list, node) {
list_del(>node);
dma_cookie_complete(>async_tx);
list_add_tail(>node, >done_list);
}
-
-out_unlock:
-   spin_unlock_irqrestore(>lock, flags);
 }
 
 /**
@@ -857,8 +848,10 @@ static irqreturn_t xilinx_vdma_irq_handler(int irq, void 
*data)
}
 
if (status & XILINX_VDMA_DMASR_FRM_CNT_IRQ) {
+   spin_lock(>lock);
xilinx_vdma_complete_descriptor(chan);
xilinx_vdma_start_transfer(chan);
+   spin_unlock(>lock);
}
 
tasklet_schedule(>tasklet);
-- 
2.1.2



[PATCH v2 2/4] dmaengine: xilinx_vdma: Simplify spin lock handling

2016-02-21 Thread Kedareswara rao Appana
This patch simplifies the spin lock handling in the driver.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 27 ++-
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 06bffec..d646218 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -605,17 +605,14 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_config *config = >config;
struct xilinx_vdma_tx_descriptor *desc, *tail_desc;
-   unsigned long flags;
u32 reg;
struct xilinx_vdma_tx_segment *tail_segment;
 
if (chan->err)
return;
 
-   spin_lock_irqsave(>lock, flags);
-
if (list_empty(>pending_list))
-   goto out_unlock;
+   return;
 
desc = list_first_entry(>pending_list,
struct xilinx_vdma_tx_descriptor, node);
@@ -629,7 +626,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
if (chan->has_sg && xilinx_vdma_is_running(chan) &&
!xilinx_vdma_is_idle(chan)) {
dev_dbg(chan->dev, "DMA controller still busy\n");
-   goto out_unlock;
+   return;
}
 
/*
@@ -676,7 +673,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
xilinx_vdma_start(chan);
 
if (chan->err)
-   goto out_unlock;
+   return;
 
/* Start the transfer */
if (chan->has_sg) {
@@ -696,7 +693,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
}
 
if (!last)
-   goto out_unlock;
+   return;
 
/* HW expects these parameters to be same for one transaction */
vdma_desc_write(chan, XILINX_VDMA_REG_HSIZE, last->hw.hsize);
@@ -707,9 +704,6 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 
list_splice_tail_init(>pending_list, >active_list);
chan->desc_pendingcount = 0;
-
-out_unlock:
-   spin_unlock_irqrestore(>lock, flags);
 }
 
 /**
@@ -719,8 +713,11 @@ out_unlock:
 static void xilinx_vdma_issue_pending(struct dma_chan *dchan)
 {
struct xilinx_vdma_chan *chan = to_xilinx_chan(dchan);
+   unsigned long flags;
 
+   spin_lock_irqsave(>lock, flags);
xilinx_vdma_start_transfer(chan);
+   spin_unlock_irqrestore(>lock, flags);
 }
 
 /**
@@ -732,21 +729,15 @@ static void xilinx_vdma_issue_pending(struct dma_chan 
*dchan)
 static void xilinx_vdma_complete_descriptor(struct xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_tx_descriptor *desc, *next;
-   unsigned long flags;
-
-   spin_lock_irqsave(>lock, flags);
 
if (list_empty(>active_list))
-   goto out_unlock;
+   return;
 
list_for_each_entry_safe(desc, next, >active_list, node) {
list_del(>node);
dma_cookie_complete(>async_tx);
list_add_tail(>node, >done_list);
}
-
-out_unlock:
-   spin_unlock_irqrestore(>lock, flags);
 }
 
 /**
@@ -857,8 +848,10 @@ static irqreturn_t xilinx_vdma_irq_handler(int irq, void 
*data)
}
 
if (status & XILINX_VDMA_DMASR_FRM_CNT_IRQ) {
+   spin_lock(>lock);
xilinx_vdma_complete_descriptor(chan);
xilinx_vdma_start_transfer(chan);
+   spin_unlock(>lock);
}
 
tasklet_schedule(>tasklet);
-- 
2.1.2



[PATCH v2 4/4] dmaengine: xilinx_vdma: Improve channel idle checking

2016-02-21 Thread Kedareswara rao Appana
This patch improves the channel idle cheking by introduing
a new varibale in chan private structure.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 41 
 1 file changed, 8 insertions(+), 33 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 8db07f7..51686d1 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -202,6 +202,7 @@ struct xilinx_vdma_tx_descriptor {
  * @has_sg: Support scatter transfers
  * @genlock: Support genlock mode
  * @err: Channel has errors
+ * @idle: Check for channel idle
  * @tasklet: Cleanup work after irq
  * @config: Device configuration info
  * @flush_on_fsync: Flush on Frame sync
@@ -225,6 +226,7 @@ struct xilinx_vdma_chan {
bool has_sg;
bool genlock;
bool err;
+   bool idle;
struct tasklet_struct tasklet;
struct xilinx_vdma_config config;
bool flush_on_fsync;
@@ -519,32 +521,6 @@ static enum dma_status xilinx_vdma_tx_status(struct 
dma_chan *dchan,
 }
 
 /**
- * xilinx_vdma_is_running - Check if VDMA channel is running
- * @chan: Driver specific VDMA channel
- *
- * Return: '1' if running, '0' if not.
- */
-static bool xilinx_vdma_is_running(struct xilinx_vdma_chan *chan)
-{
-   return !(vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
-XILINX_VDMA_DMASR_HALTED) &&
-   (vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) &
-XILINX_VDMA_DMACR_RUNSTOP);
-}
-
-/**
- * xilinx_vdma_is_idle - Check if VDMA channel is idle
- * @chan: Driver specific VDMA channel
- *
- * Return: '1' if idle, '0' if not.
- */
-static bool xilinx_vdma_is_idle(struct xilinx_vdma_chan *chan)
-{
-   return vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
-   XILINX_VDMA_DMASR_IDLE;
-}
-
-/**
  * xilinx_vdma_halt - Halt VDMA channel
  * @chan: Driver specific VDMA channel
  */
@@ -614,6 +590,9 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
if (list_empty(>pending_list))
return;
 
+   if (!chan->idle)
+   return;
+
desc = list_first_entry(>pending_list,
struct xilinx_vdma_tx_descriptor, node);
tail_desc = list_last_entry(>pending_list,
@@ -622,13 +601,6 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
tail_segment = list_last_entry(_desc->segments,
   struct xilinx_vdma_tx_segment, node);
 
-   /* If it is SG mode and hardware is busy, cannot submit */
-   if (chan->has_sg && xilinx_vdma_is_running(chan) &&
-   !xilinx_vdma_is_idle(chan)) {
-   dev_dbg(chan->dev, "DMA controller still busy\n");
-   return;
-   }
-
/*
 * If hardware is idle, then all descriptors on the running lists are
 * done, start new transfers
@@ -708,6 +680,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 
list_splice_tail_init(>pending_list, >active_list);
chan->desc_pendingcount = 0;
+   chan->idle = false;
 }
 
 /**
@@ -854,6 +827,7 @@ static irqreturn_t xilinx_vdma_irq_handler(int irq, void 
*data)
if (status & XILINX_VDMA_DMASR_FRM_CNT_IRQ) {
spin_lock(>lock);
xilinx_vdma_complete_descriptor(chan);
+   chan->idle = true;
xilinx_vdma_start_transfer(chan);
spin_unlock(>lock);
}
@@ -1212,6 +1186,7 @@ static int xilinx_vdma_chan_probe(struct 
xilinx_vdma_device *xdev,
 
list_add_tail(>common.device_node, >common.channels);
xdev->chan[chan->id] = chan;
+   chan->idle = true;
 
/* Reset the channel */
err = xilinx_vdma_chan_reset(chan);
-- 
2.1.2



[PATCH v2 4/4] dmaengine: xilinx_vdma: Improve channel idle checking

2016-02-21 Thread Kedareswara rao Appana
This patch improves the channel idle cheking by introduing
a new varibale in chan private structure.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 41 
 1 file changed, 8 insertions(+), 33 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 8db07f7..51686d1 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -202,6 +202,7 @@ struct xilinx_vdma_tx_descriptor {
  * @has_sg: Support scatter transfers
  * @genlock: Support genlock mode
  * @err: Channel has errors
+ * @idle: Check for channel idle
  * @tasklet: Cleanup work after irq
  * @config: Device configuration info
  * @flush_on_fsync: Flush on Frame sync
@@ -225,6 +226,7 @@ struct xilinx_vdma_chan {
bool has_sg;
bool genlock;
bool err;
+   bool idle;
struct tasklet_struct tasklet;
struct xilinx_vdma_config config;
bool flush_on_fsync;
@@ -519,32 +521,6 @@ static enum dma_status xilinx_vdma_tx_status(struct 
dma_chan *dchan,
 }
 
 /**
- * xilinx_vdma_is_running - Check if VDMA channel is running
- * @chan: Driver specific VDMA channel
- *
- * Return: '1' if running, '0' if not.
- */
-static bool xilinx_vdma_is_running(struct xilinx_vdma_chan *chan)
-{
-   return !(vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
-XILINX_VDMA_DMASR_HALTED) &&
-   (vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) &
-XILINX_VDMA_DMACR_RUNSTOP);
-}
-
-/**
- * xilinx_vdma_is_idle - Check if VDMA channel is idle
- * @chan: Driver specific VDMA channel
- *
- * Return: '1' if idle, '0' if not.
- */
-static bool xilinx_vdma_is_idle(struct xilinx_vdma_chan *chan)
-{
-   return vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) &
-   XILINX_VDMA_DMASR_IDLE;
-}
-
-/**
  * xilinx_vdma_halt - Halt VDMA channel
  * @chan: Driver specific VDMA channel
  */
@@ -614,6 +590,9 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
if (list_empty(>pending_list))
return;
 
+   if (!chan->idle)
+   return;
+
desc = list_first_entry(>pending_list,
struct xilinx_vdma_tx_descriptor, node);
tail_desc = list_last_entry(>pending_list,
@@ -622,13 +601,6 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
tail_segment = list_last_entry(_desc->segments,
   struct xilinx_vdma_tx_segment, node);
 
-   /* If it is SG mode and hardware is busy, cannot submit */
-   if (chan->has_sg && xilinx_vdma_is_running(chan) &&
-   !xilinx_vdma_is_idle(chan)) {
-   dev_dbg(chan->dev, "DMA controller still busy\n");
-   return;
-   }
-
/*
 * If hardware is idle, then all descriptors on the running lists are
 * done, start new transfers
@@ -708,6 +680,7 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 
list_splice_tail_init(>pending_list, >active_list);
chan->desc_pendingcount = 0;
+   chan->idle = false;
 }
 
 /**
@@ -854,6 +827,7 @@ static irqreturn_t xilinx_vdma_irq_handler(int irq, void 
*data)
if (status & XILINX_VDMA_DMASR_FRM_CNT_IRQ) {
spin_lock(>lock);
xilinx_vdma_complete_descriptor(chan);
+   chan->idle = true;
xilinx_vdma_start_transfer(chan);
spin_unlock(>lock);
}
@@ -1212,6 +1186,7 @@ static int xilinx_vdma_chan_probe(struct 
xilinx_vdma_device *xdev,
 
list_add_tail(>common.device_node, >common.channels);
xdev->chan[chan->id] = chan;
+   chan->idle = true;
 
/* Reset the channel */
err = xilinx_vdma_chan_reset(chan);
-- 
2.1.2



[PATCH v2 1/4] dmaengine: xilinx_vdma: Improve SG engine handling

2016-02-21 Thread Kedareswara rao Appana
The current driver allows user to queue up multiple segments
on to a single transaction descriptor. User will submit this single desc
and in the issue_pending() we decode multiple segments and submit to SG HW 
engine.
We free up the allocated_desc when it is submitted to the HW.

Existing code prevents the user to prepare multiple trasactions at same time as
we are overwrite with the allocated_desc.

The best utilization of HW SG engine would happen if we collate the pending
list when we start dma this patch updates the same.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 127 ++-
 1 file changed, 72 insertions(+), 55 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 6f4b501..06bffec 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -190,8 +190,7 @@ struct xilinx_vdma_tx_descriptor {
  * @desc_offset: TX descriptor registers offset
  * @lock: Descriptor operation lock
  * @pending_list: Descriptors waiting
- * @active_desc: Active descriptor
- * @allocated_desc: Allocated descriptor
+ * @active_list: Descriptors ready to submit
  * @done_list: Complete descriptors
  * @common: DMA common channel
  * @desc_pool: Descriptors pool
@@ -206,6 +205,7 @@ struct xilinx_vdma_tx_descriptor {
  * @tasklet: Cleanup work after irq
  * @config: Device configuration info
  * @flush_on_fsync: Flush on Frame sync
+ * @desc_pendingcount: Descriptor pending count
  */
 struct xilinx_vdma_chan {
struct xilinx_vdma_device *xdev;
@@ -213,8 +213,7 @@ struct xilinx_vdma_chan {
u32 desc_offset;
spinlock_t lock;
struct list_head pending_list;
-   struct xilinx_vdma_tx_descriptor *active_desc;
-   struct xilinx_vdma_tx_descriptor *allocated_desc;
+   struct list_head active_list;
struct list_head done_list;
struct dma_chan common;
struct dma_pool *desc_pool;
@@ -229,6 +228,7 @@ struct xilinx_vdma_chan {
struct tasklet_struct tasklet;
struct xilinx_vdma_config config;
bool flush_on_fsync;
+   u32 desc_pendingcount;
 };
 
 /**
@@ -342,19 +342,11 @@ static struct xilinx_vdma_tx_descriptor *
 xilinx_vdma_alloc_tx_descriptor(struct xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_tx_descriptor *desc;
-   unsigned long flags;
-
-   if (chan->allocated_desc)
-   return chan->allocated_desc;
 
desc = kzalloc(sizeof(*desc), GFP_KERNEL);
if (!desc)
return NULL;
 
-   spin_lock_irqsave(>lock, flags);
-   chan->allocated_desc = desc;
-   spin_unlock_irqrestore(>lock, flags);
-
INIT_LIST_HEAD(>segments);
 
return desc;
@@ -412,9 +404,7 @@ static void xilinx_vdma_free_descriptors(struct 
xilinx_vdma_chan *chan)
 
xilinx_vdma_free_desc_list(chan, >pending_list);
xilinx_vdma_free_desc_list(chan, >done_list);
-
-   xilinx_vdma_free_tx_descriptor(chan, chan->active_desc);
-   chan->active_desc = NULL;
+   xilinx_vdma_free_desc_list(chan, >active_list);
 
spin_unlock_irqrestore(>lock, flags);
 }
@@ -614,25 +604,26 @@ static void xilinx_vdma_start(struct xilinx_vdma_chan 
*chan)
 static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_config *config = >config;
-   struct xilinx_vdma_tx_descriptor *desc;
+   struct xilinx_vdma_tx_descriptor *desc, *tail_desc;
unsigned long flags;
u32 reg;
-   struct xilinx_vdma_tx_segment *head, *tail = NULL;
+   struct xilinx_vdma_tx_segment *tail_segment;
 
if (chan->err)
return;
 
spin_lock_irqsave(>lock, flags);
 
-   /* There's already an active descriptor, bail out. */
-   if (chan->active_desc)
-   goto out_unlock;
-
if (list_empty(>pending_list))
goto out_unlock;
 
desc = list_first_entry(>pending_list,
struct xilinx_vdma_tx_descriptor, node);
+   tail_desc = list_last_entry(>pending_list,
+   struct xilinx_vdma_tx_descriptor, node);
+
+   tail_segment = list_last_entry(_desc->segments,
+  struct xilinx_vdma_tx_segment, node);
 
/* If it is SG mode and hardware is busy, cannot submit */
if (chan->has_sg && xilinx_vdma_is_running(chan) &&
@@ -645,14 +636,9 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 * If hardware is idle, then all descriptors on the running lists are
 * done, start new transfers
 */
-   if (chan->has_sg) {
-   head = list_first_entry(>segments,
-   struct xilinx_vdma_tx_segment, node);
-   tail = list_entry(desc->segments.prev,
- 

[PATCH v2 1/4] dmaengine: xilinx_vdma: Improve SG engine handling

2016-02-21 Thread Kedareswara rao Appana
The current driver allows user to queue up multiple segments
on to a single transaction descriptor. User will submit this single desc
and in the issue_pending() we decode multiple segments and submit to SG HW 
engine.
We free up the allocated_desc when it is submitted to the HW.

Existing code prevents the user to prepare multiple trasactions at same time as
we are overwrite with the allocated_desc.

The best utilization of HW SG engine would happen if we collate the pending
list when we start dma this patch updates the same.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 127 ++-
 1 file changed, 72 insertions(+), 55 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 6f4b501..06bffec 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -190,8 +190,7 @@ struct xilinx_vdma_tx_descriptor {
  * @desc_offset: TX descriptor registers offset
  * @lock: Descriptor operation lock
  * @pending_list: Descriptors waiting
- * @active_desc: Active descriptor
- * @allocated_desc: Allocated descriptor
+ * @active_list: Descriptors ready to submit
  * @done_list: Complete descriptors
  * @common: DMA common channel
  * @desc_pool: Descriptors pool
@@ -206,6 +205,7 @@ struct xilinx_vdma_tx_descriptor {
  * @tasklet: Cleanup work after irq
  * @config: Device configuration info
  * @flush_on_fsync: Flush on Frame sync
+ * @desc_pendingcount: Descriptor pending count
  */
 struct xilinx_vdma_chan {
struct xilinx_vdma_device *xdev;
@@ -213,8 +213,7 @@ struct xilinx_vdma_chan {
u32 desc_offset;
spinlock_t lock;
struct list_head pending_list;
-   struct xilinx_vdma_tx_descriptor *active_desc;
-   struct xilinx_vdma_tx_descriptor *allocated_desc;
+   struct list_head active_list;
struct list_head done_list;
struct dma_chan common;
struct dma_pool *desc_pool;
@@ -229,6 +228,7 @@ struct xilinx_vdma_chan {
struct tasklet_struct tasklet;
struct xilinx_vdma_config config;
bool flush_on_fsync;
+   u32 desc_pendingcount;
 };
 
 /**
@@ -342,19 +342,11 @@ static struct xilinx_vdma_tx_descriptor *
 xilinx_vdma_alloc_tx_descriptor(struct xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_tx_descriptor *desc;
-   unsigned long flags;
-
-   if (chan->allocated_desc)
-   return chan->allocated_desc;
 
desc = kzalloc(sizeof(*desc), GFP_KERNEL);
if (!desc)
return NULL;
 
-   spin_lock_irqsave(>lock, flags);
-   chan->allocated_desc = desc;
-   spin_unlock_irqrestore(>lock, flags);
-
INIT_LIST_HEAD(>segments);
 
return desc;
@@ -412,9 +404,7 @@ static void xilinx_vdma_free_descriptors(struct 
xilinx_vdma_chan *chan)
 
xilinx_vdma_free_desc_list(chan, >pending_list);
xilinx_vdma_free_desc_list(chan, >done_list);
-
-   xilinx_vdma_free_tx_descriptor(chan, chan->active_desc);
-   chan->active_desc = NULL;
+   xilinx_vdma_free_desc_list(chan, >active_list);
 
spin_unlock_irqrestore(>lock, flags);
 }
@@ -614,25 +604,26 @@ static void xilinx_vdma_start(struct xilinx_vdma_chan 
*chan)
 static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan)
 {
struct xilinx_vdma_config *config = >config;
-   struct xilinx_vdma_tx_descriptor *desc;
+   struct xilinx_vdma_tx_descriptor *desc, *tail_desc;
unsigned long flags;
u32 reg;
-   struct xilinx_vdma_tx_segment *head, *tail = NULL;
+   struct xilinx_vdma_tx_segment *tail_segment;
 
if (chan->err)
return;
 
spin_lock_irqsave(>lock, flags);
 
-   /* There's already an active descriptor, bail out. */
-   if (chan->active_desc)
-   goto out_unlock;
-
if (list_empty(>pending_list))
goto out_unlock;
 
desc = list_first_entry(>pending_list,
struct xilinx_vdma_tx_descriptor, node);
+   tail_desc = list_last_entry(>pending_list,
+   struct xilinx_vdma_tx_descriptor, node);
+
+   tail_segment = list_last_entry(_desc->segments,
+  struct xilinx_vdma_tx_segment, node);
 
/* If it is SG mode and hardware is busy, cannot submit */
if (chan->has_sg && xilinx_vdma_is_running(chan) &&
@@ -645,14 +636,9 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
 * If hardware is idle, then all descriptors on the running lists are
 * done, start new transfers
 */
-   if (chan->has_sg) {
-   head = list_first_entry(>segments,
-   struct xilinx_vdma_tx_segment, node);
-   tail = list_entry(desc->segments.prev,
- struct 

[PATCH v2 3/4] dmaengine: xilinx_vdma: Fix issues with non-parking mode

2016-02-21 Thread Kedareswara rao Appana
This patch fixes issues with the Non-parking mode(Cirular mode).
With the  existing driver in cirular mode if we submit frames less than h/w
configured we simply end-up having misconfigured vdma h/w.
This patch fixes this issue by configuring the frame count register.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index d646218..8db07f7 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -645,6 +645,10 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
else
reg &= ~XILINX_VDMA_DMACR_FRAMECNT_EN;
 
+   /* Configure channel to allow number frame buffers */
+   vdma_ctrl_write(chan, XILINX_VDMA_REG_FRMSTORE,
+   chan->desc_pendingcount);
+
/*
 * With SG, start with circular mode, so that BDs can be fetched.
 * In direct register mode, if not parking, enable circular mode
-- 
2.1.2



[PATCH v2 3/4] dmaengine: xilinx_vdma: Fix issues with non-parking mode

2016-02-21 Thread Kedareswara rao Appana
This patch fixes issues with the Non-parking mode(Cirular mode).
With the  existing driver in cirular mode if we submit frames less than h/w
configured we simply end-up having misconfigured vdma h/w.
This patch fixes this issue by configuring the frame count register.

Signed-off-by: Kedareswara rao Appana 
---
Changes for v2:
---> splitted the changes into multiple patches.

 drivers/dma/xilinx/xilinx_vdma.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index d646218..8db07f7 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -645,6 +645,10 @@ static void xilinx_vdma_start_transfer(struct 
xilinx_vdma_chan *chan)
else
reg &= ~XILINX_VDMA_DMACR_FRAMECNT_EN;
 
+   /* Configure channel to allow number frame buffers */
+   vdma_ctrl_write(chan, XILINX_VDMA_REG_FRMSTORE,
+   chan->desc_pendingcount);
+
/*
 * With SG, start with circular mode, so that BDs can be fetched.
 * In direct register mode, if not parking, enable circular mode
-- 
2.1.2



Re: [PATCH v2 2/8] arm64: dts: qcom: apq8016-sbc: add usb support

2016-02-21 Thread Bjorn Andersson
On Wed 10 Feb 03:36 PST 2016, Srinivas Kandagatla wrote:

> Signed-off-by: Srinivas Kandagatla 
> ---
>  arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi | 15 ++
>  arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi  | 35 
> ++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi 
> b/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi
> index cbeee0b..4a79dd9 100644
> --- a/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi
> +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi
> @@ -10,4 +10,19 @@
>   output-low;
>   };
>   };
> +
> + usb_id_default: usb_id_default {

Labels are built with _, node names with -.

> + pinmux {
> + function = "gpio";
> + pins = "gpio121";
> + };

You don't need a separate node to specify function...

> +
> + pinconf {
> + pins = "gpio121";
> + function = "gpio";

...but if you really want it, then you shouldn't specify the function
here.

> + drive-strength = <8>;
> + input-enable;
> + bias-pull-up;
> + };
> + };
>  };
> diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi 
> b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
[..]
> +
> + usb_id: usb-id {
> + interrupt-parent = <>;

interrupt-parent is part of specifying an interrupt. You're not doing
that here, so no need to specify a parent.

> + compatible = "linux,extcon-usb-gpio";
> + id-gpio = < 121 GPIO_ACTIVE_HIGH>;
> + pinctrl-names = "default";
> + pinctrl-0 = <_id_default>;
>   };
>  };

Apart from these two nits

Acked-by: Bjorn Andersson 

Regards,
Bjorn


Re: [PATCH v2 2/8] arm64: dts: qcom: apq8016-sbc: add usb support

2016-02-21 Thread Bjorn Andersson
On Wed 10 Feb 03:36 PST 2016, Srinivas Kandagatla wrote:

> Signed-off-by: Srinivas Kandagatla 
> ---
>  arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi | 15 ++
>  arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi  | 35 
> ++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi 
> b/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi
> index cbeee0b..4a79dd9 100644
> --- a/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi
> +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc-soc-pins.dtsi
> @@ -10,4 +10,19 @@
>   output-low;
>   };
>   };
> +
> + usb_id_default: usb_id_default {

Labels are built with _, node names with -.

> + pinmux {
> + function = "gpio";
> + pins = "gpio121";
> + };

You don't need a separate node to specify function...

> +
> + pinconf {
> + pins = "gpio121";
> + function = "gpio";

...but if you really want it, then you shouldn't specify the function
here.

> + drive-strength = <8>;
> + input-enable;
> + bias-pull-up;
> + };
> + };
>  };
> diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi 
> b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
[..]
> +
> + usb_id: usb-id {
> + interrupt-parent = <>;

interrupt-parent is part of specifying an interrupt. You're not doing
that here, so no need to specify a parent.

> + compatible = "linux,extcon-usb-gpio";
> + id-gpio = < 121 GPIO_ACTIVE_HIGH>;
> + pinctrl-names = "default";
> + pinctrl-0 = <_id_default>;
>   };
>  };

Apart from these two nits

Acked-by: Bjorn Andersson 

Regards,
Bjorn


Processes attached to shared memory

2016-02-21 Thread W. Michael Petullo
Given a struct shmid_kernel, is it possible to find each
process/task_struct which is attached to the shared memory?

I have been trying to use find_get_pages(shmid->shm_file->f_mapping, ...)
along with rmap_walk(...). But what I have come up with seems a little
convoluted and also triggers "BUG: scheduling while atomic" errors.

-- 
Mike

:wq


Processes attached to shared memory

2016-02-21 Thread W. Michael Petullo
Given a struct shmid_kernel, is it possible to find each
process/task_struct which is attached to the shared memory?

I have been trying to use find_get_pages(shmid->shm_file->f_mapping, ...)
along with rmap_walk(...). But what I have come up with seems a little
convoluted and also triggers "BUG: scheduling while atomic" errors.

-- 
Mike

:wq


Re: [PATCH v3 1/5] ACPI: change __init to __ref for early_acpi_os_unmap_memory()

2016-02-21 Thread Peter Hurley
On 02/19/2016 09:20 AM, Christopher Covington wrote:
> 
> 
> On February 19, 2016 10:25:50 AM EST, Peter Hurley  
> wrote:
>> On 02/19/2016 02:42 AM, Aleksey Makarov wrote:
>>> Hi Peter,
>>>
>>> Thank you for review.
>>>
>>> On 02/19/2016 01:03 AM, Peter Hurley wrote:
 On 02/17/2016 07:36 PM, Zheng, Lv wrote:
> Hi,
>
>> From: Aleksey Makarov [mailto:aleksey.maka...@linaro.org]
>> Subject: Re: [PATCH v3 1/5] ACPI: change __init to __ref for
>> early_acpi_os_unmap_memory()
>>
>> Hi Lv,
>>
>> Thank you for review.
>>
>> On 02/17/2016 05:51 AM, Zheng, Lv wrote:
>>
>> [..]
>>
> early_acpi_os_unmap_memory() is marked as __init because it
>> calls
> __acpi_unmap_table(), but only when acpi_gbl_permanent_mmap is
>> not
>> set.
>
> acpi_gbl_permanent_mmap is set in __init acpi_early_init()
> so it is safe to call early_acpi_os_unmap_memory() from
>> anywhere
>
> We need this function to be non-__init because we need access
>> to
> some tables at unpredictable time--it may be before or after
> acpi_gbl_permanent_mmap is set.  For example, SPCR (Serial Port
>> Console
> Redirection) table is needed each time a new console is
>> registered.
> It can be quite early (console_initcall) or when a module is
>> inserted.
> When this table accessed before acpi_gbl_permanent_mmap is set,
> the pointer should be unmapped.  This is exactly what this
>> function
> does.
 [Lv Zheng]
 Why don't you use another API instead of
>> early_acpi_os_unmap_memory()
>> in
 case you want to unmap things in any cases.
 acpi_os_unmap_memory() should be the one to match this purpose.
 It checks acpi_gbl_ppermanent_mmap in acpi_os_unmap_iomem().
>>
>> As far as I understand, there exist two steps in ACPI
>> initialization:
>>
>> 1. Before acpi_gbl_permanent_mmap is set, tables received with
>> acpi_get_table_with_size()
>>are mapped by early_memremap().  If a subsystem gets such a
>> pointer it
>> should be unmapped.
>>
>> 2  After acpi_gbl_permanent_mmap is set this pointer should not be
>> unmapped
>> at all.
>>
> [Lv Zheng] 
> This statement is wrong, this should be:
> As long as there is a __reference__ to the mapped table, the
>> pointer should not be unmapped.
> In fact, we have a series to introduce acpi_put_table() to achieve
>> this.
> So your argument is wrong from very first point.
>
>> That exactly what early_acpi_os_unmap_memory() does--it checks
>> acpi_gbl_permanent_mmap.
>> If I had used acpi_os_unmap_memory() after acpi_gbl_permanent_mmap
>> had
>> been set,
>> it would have tried to free that pointer with an oops (actually, I
>> checked that
>> and got that oops).
>>
>> So using acpi_os_unmap_memory() is not an option here, but
>> early_acpi_os_unmap_memory()
>> match perfectly.
> [Lv Zheng] 
> I don't think so.
> For definition block tables, we know for sure there will always be
>> references, until "Unload" opcode is invoked by the AML interpreter.
> But for the data tables, OSPMs should use them in this way:
> 1. map the table
> 2. parse the table and convert it to OS specific structures
> 3. unmap the table
> This helps to shrink virtual memory address space usages.
>
> So from this point of view, all data tables should be unmapped
>> right after being parsed.
> Why do you need the map to be persistent in the kernel address
>> space?
> You can always map a small table, but what if the table size is
>> very big?
>
>>
 And in fact early_acpi_os_unmap_memory() should be removed.
>>
>> I don't think so -- I have explained why.  It does different
>> thing.
>> Probably it (and/or other functions in that api) should be
>> renamed.
>>
> [Lv Zheng] 
> Just let me ask one more question.
> eary_acpi_os_unmap_memory() is not used inside of ACPICA.
> How ACPICA can work with just acpi_os_unmap_memory()?
> You can check drivers/acpi/tbxxx.c.
> Especially: acpi_tb_release_temp_table() and the code invoking it.
>
>>> [Lv Zheng]
>>> One more thing is:
>>> If you can't switch your driver to use acpi_os_unmap_memory()
>> instead of
>> early_acpi_os_unmap_memory(),
>>> then it implies that your driver does have a defect.
>>
>> I still don't understand what defect, sorry.
> [Lv Zheng] 
> If you can't ensure this sequence for using the data tables:
> 1. map the table
> 2. parse the table and convert it to OS specific structure
> 3. unmap the table
> It implies there is a bug in the driver or a bug in the ACPI
>> subsystem core.

 Exactly.

 The central problem here is the way Aleksey is trying to hookup a
>> console.

Re: [PATCH v3 1/5] ACPI: change __init to __ref for early_acpi_os_unmap_memory()

2016-02-21 Thread Peter Hurley
On 02/19/2016 09:20 AM, Christopher Covington wrote:
> 
> 
> On February 19, 2016 10:25:50 AM EST, Peter Hurley  
> wrote:
>> On 02/19/2016 02:42 AM, Aleksey Makarov wrote:
>>> Hi Peter,
>>>
>>> Thank you for review.
>>>
>>> On 02/19/2016 01:03 AM, Peter Hurley wrote:
 On 02/17/2016 07:36 PM, Zheng, Lv wrote:
> Hi,
>
>> From: Aleksey Makarov [mailto:aleksey.maka...@linaro.org]
>> Subject: Re: [PATCH v3 1/5] ACPI: change __init to __ref for
>> early_acpi_os_unmap_memory()
>>
>> Hi Lv,
>>
>> Thank you for review.
>>
>> On 02/17/2016 05:51 AM, Zheng, Lv wrote:
>>
>> [..]
>>
> early_acpi_os_unmap_memory() is marked as __init because it
>> calls
> __acpi_unmap_table(), but only when acpi_gbl_permanent_mmap is
>> not
>> set.
>
> acpi_gbl_permanent_mmap is set in __init acpi_early_init()
> so it is safe to call early_acpi_os_unmap_memory() from
>> anywhere
>
> We need this function to be non-__init because we need access
>> to
> some tables at unpredictable time--it may be before or after
> acpi_gbl_permanent_mmap is set.  For example, SPCR (Serial Port
>> Console
> Redirection) table is needed each time a new console is
>> registered.
> It can be quite early (console_initcall) or when a module is
>> inserted.
> When this table accessed before acpi_gbl_permanent_mmap is set,
> the pointer should be unmapped.  This is exactly what this
>> function
> does.
 [Lv Zheng]
 Why don't you use another API instead of
>> early_acpi_os_unmap_memory()
>> in
 case you want to unmap things in any cases.
 acpi_os_unmap_memory() should be the one to match this purpose.
 It checks acpi_gbl_ppermanent_mmap in acpi_os_unmap_iomem().
>>
>> As far as I understand, there exist two steps in ACPI
>> initialization:
>>
>> 1. Before acpi_gbl_permanent_mmap is set, tables received with
>> acpi_get_table_with_size()
>>are mapped by early_memremap().  If a subsystem gets such a
>> pointer it
>> should be unmapped.
>>
>> 2  After acpi_gbl_permanent_mmap is set this pointer should not be
>> unmapped
>> at all.
>>
> [Lv Zheng] 
> This statement is wrong, this should be:
> As long as there is a __reference__ to the mapped table, the
>> pointer should not be unmapped.
> In fact, we have a series to introduce acpi_put_table() to achieve
>> this.
> So your argument is wrong from very first point.
>
>> That exactly what early_acpi_os_unmap_memory() does--it checks
>> acpi_gbl_permanent_mmap.
>> If I had used acpi_os_unmap_memory() after acpi_gbl_permanent_mmap
>> had
>> been set,
>> it would have tried to free that pointer with an oops (actually, I
>> checked that
>> and got that oops).
>>
>> So using acpi_os_unmap_memory() is not an option here, but
>> early_acpi_os_unmap_memory()
>> match perfectly.
> [Lv Zheng] 
> I don't think so.
> For definition block tables, we know for sure there will always be
>> references, until "Unload" opcode is invoked by the AML interpreter.
> But for the data tables, OSPMs should use them in this way:
> 1. map the table
> 2. parse the table and convert it to OS specific structures
> 3. unmap the table
> This helps to shrink virtual memory address space usages.
>
> So from this point of view, all data tables should be unmapped
>> right after being parsed.
> Why do you need the map to be persistent in the kernel address
>> space?
> You can always map a small table, but what if the table size is
>> very big?
>
>>
 And in fact early_acpi_os_unmap_memory() should be removed.
>>
>> I don't think so -- I have explained why.  It does different
>> thing.
>> Probably it (and/or other functions in that api) should be
>> renamed.
>>
> [Lv Zheng] 
> Just let me ask one more question.
> eary_acpi_os_unmap_memory() is not used inside of ACPICA.
> How ACPICA can work with just acpi_os_unmap_memory()?
> You can check drivers/acpi/tbxxx.c.
> Especially: acpi_tb_release_temp_table() and the code invoking it.
>
>>> [Lv Zheng]
>>> One more thing is:
>>> If you can't switch your driver to use acpi_os_unmap_memory()
>> instead of
>> early_acpi_os_unmap_memory(),
>>> then it implies that your driver does have a defect.
>>
>> I still don't understand what defect, sorry.
> [Lv Zheng] 
> If you can't ensure this sequence for using the data tables:
> 1. map the table
> 2. parse the table and convert it to OS specific structure
> 3. unmap the table
> It implies there is a bug in the driver or a bug in the ACPI
>> subsystem core.

 Exactly.

 The central problem here is the way Aleksey is trying to hookup a
>> console.

 What should be 

Re: [patch] sched,rt: __always_inline preemptible_lazy()

2016-02-21 Thread Hillf Danton
> 
> sched,rt: __always_inline preemptible_lazy()
> 
> Functions called within a notrace function must either also be
> notrace or be inlined, lest recursion blow the stack.
> 
> homer: # nm kernel/sched/core.o|grep preemptible_lazy
> 00b5 t preemptible_lazy
> 
> echo wakeup_rt > current_tracer ==> Welcome to infinity.
> 
> Signed-off-by: Mike Galbraith 
> ---

Thank you, Mike.

Acked-by: Hillf Danton 

>  kernel/sched/core.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3469,7 +3469,7 @@ static void __sched notrace preempt_sche
>   * set by a RT task. Oterwise we try to avoid beeing scheduled out as long as
>   * preempt_lazy_count counter >0.
>   */
> -static int preemptible_lazy(void)
> +static __always_inline int preemptible_lazy(void)
>  {
>   if (test_thread_flag(TIF_NEED_RESCHED))
>   return 1;



Re: [patch] sched,rt: __always_inline preemptible_lazy()

2016-02-21 Thread Hillf Danton
> 
> sched,rt: __always_inline preemptible_lazy()
> 
> Functions called within a notrace function must either also be
> notrace or be inlined, lest recursion blow the stack.
> 
> homer: # nm kernel/sched/core.o|grep preemptible_lazy
> 00b5 t preemptible_lazy
> 
> echo wakeup_rt > current_tracer ==> Welcome to infinity.
> 
> Signed-off-by: Mike Galbraith 
> ---

Thank you, Mike.

Acked-by: Hillf Danton 

>  kernel/sched/core.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3469,7 +3469,7 @@ static void __sched notrace preempt_sche
>   * set by a RT task. Oterwise we try to avoid beeing scheduled out as long as
>   * preempt_lazy_count counter >0.
>   */
> -static int preemptible_lazy(void)
> +static __always_inline int preemptible_lazy(void)
>  {
>   if (test_thread_flag(TIF_NEED_RESCHED))
>   return 1;



Re: [PATCH] cpufreq: simplify for_each_suitable_policy() macro

2016-02-21 Thread Viresh Kumar
On 21-02-16, 12:53, Eric Biggers wrote:
> Signed-off-by: Eric Biggers 
> ---
>  drivers/cpufreq/cpufreq.c | 44 +++-
>  1 file changed, 3 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e979ec7..3aa7b2b 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -38,48 +38,10 @@ static inline bool policy_is_inactive(struct 
> cpufreq_policy *policy)
>   return cpumask_empty(policy->cpus);
>  }
>  
> -static bool suitable_policy(struct cpufreq_policy *policy, bool active)
> -{
> - return active == !policy_is_inactive(policy);
> -}
> -
> -/* Finds Next Acive/Inactive policy */
> -static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> -   bool active)
> -{
> - do {
> - /* No more policies in the list */
> - if (list_is_last(>policy_list, _policy_list))
> - return NULL;
> -
> - policy = list_next_entry(policy, policy_list);
> - } while (!suitable_policy(policy, active));
> -
> - return policy;
> -}
> -
> -static struct cpufreq_policy *first_policy(bool active)
> -{
> - struct cpufreq_policy *policy;
> -
> - /* No policies in the list */
> - if (list_empty(_policy_list))
> - return NULL;
> -
> - policy = list_first_entry(_policy_list, typeof(*policy),
> -   policy_list);
> -
> - if (!suitable_policy(policy, active))
> - policy = next_policy(policy, active);
> -
> - return policy;
> -}
> -
>  /* Macros to iterate over CPU policies */
> -#define for_each_suitable_policy(__policy, __active) \
> - for (__policy = first_policy(__active); \
> -  __policy;  \
> -  __policy = next_policy(__policy, __active))
> +#define for_each_suitable_policy(__policy, __active)  \
> + list_for_each_entry(__policy, _policy_list, policy_list) \
> + if ((__active) == !policy_is_inactive(__policy))
>  
>  #define for_each_active_policy(__policy) \
>   for_each_suitable_policy(__policy, true)

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH] cpufreq: simplify for_each_suitable_policy() macro

2016-02-21 Thread Viresh Kumar
On 21-02-16, 12:53, Eric Biggers wrote:
> Signed-off-by: Eric Biggers 
> ---
>  drivers/cpufreq/cpufreq.c | 44 +++-
>  1 file changed, 3 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e979ec7..3aa7b2b 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -38,48 +38,10 @@ static inline bool policy_is_inactive(struct 
> cpufreq_policy *policy)
>   return cpumask_empty(policy->cpus);
>  }
>  
> -static bool suitable_policy(struct cpufreq_policy *policy, bool active)
> -{
> - return active == !policy_is_inactive(policy);
> -}
> -
> -/* Finds Next Acive/Inactive policy */
> -static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> -   bool active)
> -{
> - do {
> - /* No more policies in the list */
> - if (list_is_last(>policy_list, _policy_list))
> - return NULL;
> -
> - policy = list_next_entry(policy, policy_list);
> - } while (!suitable_policy(policy, active));
> -
> - return policy;
> -}
> -
> -static struct cpufreq_policy *first_policy(bool active)
> -{
> - struct cpufreq_policy *policy;
> -
> - /* No policies in the list */
> - if (list_empty(_policy_list))
> - return NULL;
> -
> - policy = list_first_entry(_policy_list, typeof(*policy),
> -   policy_list);
> -
> - if (!suitable_policy(policy, active))
> - policy = next_policy(policy, active);
> -
> - return policy;
> -}
> -
>  /* Macros to iterate over CPU policies */
> -#define for_each_suitable_policy(__policy, __active) \
> - for (__policy = first_policy(__active); \
> -  __policy;  \
> -  __policy = next_policy(__policy, __active))
> +#define for_each_suitable_policy(__policy, __active)  \
> + list_for_each_entry(__policy, _policy_list, policy_list) \
> + if ((__active) == !policy_is_inactive(__policy))
>  
>  #define for_each_active_policy(__policy) \
>   for_each_suitable_policy(__policy, true)

Acked-by: Viresh Kumar 

-- 
viresh


[PATCH] usb: chipidea: Configure DMA properties and ops from DT

2016-02-21 Thread Bjorn Andersson
On certain platforms (e.g. ARM64) the dma_ops needs to be explicitly set
to be able to do DMA allocations, so use the of_dma_configure() helper
to populate the dma properties and assign an appropriate dma_ops.

Signed-off-by: Bjorn Andersson 
---
 drivers/usb/chipidea/core.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 7404064b9bbc..047b9d4e67aa 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -834,6 +835,9 @@ struct platform_device *ci_hdrc_add_device(struct device 
*dev,
pdev->dev.dma_parms = dev->dma_parms;
dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
 
+   if (IS_ENABLED(CONFIG_OF) && dev->of_node)
+   of_dma_configure(>dev, dev->of_node);
+
ret = platform_device_add_resources(pdev, res, nres);
if (ret)
goto err;
-- 
2.5.0



[PATCH] usb: chipidea: Configure DMA properties and ops from DT

2016-02-21 Thread Bjorn Andersson
On certain platforms (e.g. ARM64) the dma_ops needs to be explicitly set
to be able to do DMA allocations, so use the of_dma_configure() helper
to populate the dma properties and assign an appropriate dma_ops.

Signed-off-by: Bjorn Andersson 
---
 drivers/usb/chipidea/core.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 7404064b9bbc..047b9d4e67aa 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -834,6 +835,9 @@ struct platform_device *ci_hdrc_add_device(struct device 
*dev,
pdev->dev.dma_parms = dev->dma_parms;
dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
 
+   if (IS_ENABLED(CONFIG_OF) && dev->of_node)
+   of_dma_configure(>dev, dev->of_node);
+
ret = platform_device_add_resources(pdev, res, nres);
if (ret)
goto err;
-- 
2.5.0



RE: [PATCH] nati_x86_64_defconfig: Enable some net QoS modules

2016-02-21 Thread Sheng Wang
This is an internal patch, it's just destined for internal folks, please ignore 
it if you have no interest in it. Sorry for the spam.

Best Regards!
Sheng Wang
NI Shanghai, Bld43
sheng.w...@ni.com


-Original Message-
From: Gangfeng Huang [mailto:gangfeng.hu...@ni.com] 
Sent: Monday, February 22, 2016 10:14 AM
To: Josh Cartwright ; Brad Mouring 
; Rishika Gupta ; Gratian Crisan 
; Xander Huff ; James Minor 
; Joshua Hernstrom ; Adrian Ratiu 

Cc: t...@linutronix.de; mi...@redhat.com; h...@zytor.com; 
linux-kernel@vger.kernel.org; Sheng Wang 
Subject: [PATCH] nati_x86_64_defconfig: Enable some net QoS modules

From: Sheng Wang 

NI-TSN needs to send packets in a dedicated NIC queue which is different with 
Best Effort, it depends on these QoS related modules support.

Signed-off-by: Sheng Wang 

Natinst-CAR-ID: 537122
Natinst-ReviewBoard-ID: 127478
---
 arch/x86/configs/nati_x86_64_defconfig |5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/configs/nati_x86_64_defconfig 
b/arch/x86/configs/nati_x86_64_defconfig
index d849e6b..4100aaa 100644
--- a/arch/x86/configs/nati_x86_64_defconfig
+++ b/arch/x86/configs/nati_x86_64_defconfig
@@ -210,8 +210,13 @@ CONFIG_L2TP_ETH=m
 CONFIG_BRIDGE=m
 CONFIG_VLAN_8021Q=m
 CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_MULTIQ=m
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_U32=m
 CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_CMP=m
 CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_SKBEDIT=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BPF_JIT=y
 CONFIG_BT=m
--
1.7.9.5



RE: [PATCH] nati_x86_64_defconfig: Enable some net QoS modules

2016-02-21 Thread Sheng Wang
This is an internal patch, it's just destined for internal folks, please ignore 
it if you have no interest in it. Sorry for the spam.

Best Regards!
Sheng Wang
NI Shanghai, Bld43
sheng.w...@ni.com


-Original Message-
From: Gangfeng Huang [mailto:gangfeng.hu...@ni.com] 
Sent: Monday, February 22, 2016 10:14 AM
To: Josh Cartwright ; Brad Mouring 
; Rishika Gupta ; Gratian Crisan 
; Xander Huff ; James Minor 
; Joshua Hernstrom ; Adrian Ratiu 

Cc: t...@linutronix.de; mi...@redhat.com; h...@zytor.com; 
linux-kernel@vger.kernel.org; Sheng Wang 
Subject: [PATCH] nati_x86_64_defconfig: Enable some net QoS modules

From: Sheng Wang 

NI-TSN needs to send packets in a dedicated NIC queue which is different with 
Best Effort, it depends on these QoS related modules support.

Signed-off-by: Sheng Wang 

Natinst-CAR-ID: 537122
Natinst-ReviewBoard-ID: 127478
---
 arch/x86/configs/nati_x86_64_defconfig |5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/configs/nati_x86_64_defconfig 
b/arch/x86/configs/nati_x86_64_defconfig
index d849e6b..4100aaa 100644
--- a/arch/x86/configs/nati_x86_64_defconfig
+++ b/arch/x86/configs/nati_x86_64_defconfig
@@ -210,8 +210,13 @@ CONFIG_L2TP_ETH=m
 CONFIG_BRIDGE=m
 CONFIG_VLAN_8021Q=m
 CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_MULTIQ=m
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_U32=m
 CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_CMP=m
 CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_SKBEDIT=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BPF_JIT=y
 CONFIG_BT=m
--
1.7.9.5



Re: [PATCH] cpufreq: fix comment about return value of cpufreq_register_driver()

2016-02-21 Thread Viresh Kumar
On 20-02-16, 21:50, Eric Biggers wrote:
> The comment has been incorrect since commit 4dea5806d332
> ("cpufreq: return EEXIST instead of EBUSY for second registering").
> 
> Signed-off-by: Eric Biggers 
> ---
>  drivers/cpufreq/cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e979ec7..bfefc91 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2384,7 +2384,7 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
>   * submitted by the CPU Frequency driver.
>   *
>   * Registers a CPU Frequency driver to this core code. This code
> - * returns zero on success, -EBUSY when another driver got here first
> + * returns zero on success, -EEXIST when another driver got here first
>   * (and isn't unregistered in the meantime).
>   *
>   */

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH] cpufreq: fix comment about return value of cpufreq_register_driver()

2016-02-21 Thread Viresh Kumar
On 20-02-16, 21:50, Eric Biggers wrote:
> The comment has been incorrect since commit 4dea5806d332
> ("cpufreq: return EEXIST instead of EBUSY for second registering").
> 
> Signed-off-by: Eric Biggers 
> ---
>  drivers/cpufreq/cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e979ec7..bfefc91 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2384,7 +2384,7 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
>   * submitted by the CPU Frequency driver.
>   *
>   * Registers a CPU Frequency driver to this core code. This code
> - * returns zero on success, -EBUSY when another driver got here first
> + * returns zero on success, -EEXIST when another driver got here first
>   * (and isn't unregistered in the meantime).
>   *
>   */

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH 2/2] cpufreq: governor: Make gov_set_update_util() static

2016-02-21 Thread Viresh Kumar
On 21-02-16, 03:15, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> The gov_set_update_util() routine is only used internally by the
> common governor code and it doesn't need to be exported, so make
> it static.
> 
> No functional changes.
> 
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/cpufreq/cpufreq_governor.c |5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
> ===
> --- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
> +++ linux-pm/drivers/cpufreq/cpufreq_governor.c
> @@ -261,8 +261,8 @@ unsigned int dbs_update(struct cpufreq_p
>  }
>  EXPORT_SYMBOL_GPL(dbs_update);
>  
> -void gov_set_update_util(struct policy_dbs_info *policy_dbs,
> -  unsigned int delay_us)
> +static void gov_set_update_util(struct policy_dbs_info *policy_dbs,
> + unsigned int delay_us)
>  {
>   struct cpufreq_policy *policy = policy_dbs->policy;
>   int cpu;
> @@ -276,7 +276,6 @@ void gov_set_update_util(struct policy_d
>   cpufreq_set_update_util_data(cpu, >update_util);
>   }
>  }
> -EXPORT_SYMBOL_GPL(gov_set_update_util);
>  
>  static inline void gov_clear_update_util(struct cpufreq_policy *policy)
>  {

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH 2/2] cpufreq: governor: Make gov_set_update_util() static

2016-02-21 Thread Viresh Kumar
On 21-02-16, 03:15, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> The gov_set_update_util() routine is only used internally by the
> common governor code and it doesn't need to be exported, so make
> it static.
> 
> No functional changes.
> 
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/cpufreq/cpufreq_governor.c |5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
> ===
> --- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
> +++ linux-pm/drivers/cpufreq/cpufreq_governor.c
> @@ -261,8 +261,8 @@ unsigned int dbs_update(struct cpufreq_p
>  }
>  EXPORT_SYMBOL_GPL(dbs_update);
>  
> -void gov_set_update_util(struct policy_dbs_info *policy_dbs,
> -  unsigned int delay_us)
> +static void gov_set_update_util(struct policy_dbs_info *policy_dbs,
> + unsigned int delay_us)
>  {
>   struct cpufreq_policy *policy = policy_dbs->policy;
>   int cpu;
> @@ -276,7 +276,6 @@ void gov_set_update_util(struct policy_d
>   cpufreq_set_update_util_data(cpu, >update_util);
>   }
>  }
> -EXPORT_SYMBOL_GPL(gov_set_update_util);
>  
>  static inline void gov_clear_update_util(struct cpufreq_policy *policy)
>  {

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH 1/2] cpufreq: governor: Fix race in dbs_update_util_handler()

2016-02-21 Thread Viresh Kumar
On 21-02-16, 03:14, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> There is a scenarion that may lead to undesired results in

 scenario

> dbs_update_util_handler().  Namely, if two CPUs sharing a policy
> enter the funtion at the same time, pass the sample delay check
> and then one of them is stalled until dbs_work_handler() (queued
> up by the other CPU) clears the work counter, it may update the
> work counter and queue up another work item prematurely.
> 
> To prevent that from happening, use the observation that the CPU
> queuing up a work item in dbs_update_util_handler() updates the
> last sample time.  This means that if another CPU was stalling after
> passing the sample delay check and now successfully updated the work
> counter as a result of the race described above, it will see the new
> value of the last sample time which is different from what it used in
> the sample delay check before.  If that happens, the sample delay
> check passed previously is not valid any more, so the CPU should not
> continue, but leaving the funtion at that point might miss an
> opportunity to take the next sample, so simply clear the work
> counter and jump to the beginning of the function in that case.
> 
> Fixes: f17cbb53783c (cpufreq: governor: Avoid atomic operations in hot paths)
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/cpufreq/cpufreq_governor.c |   22 +-
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
> ===
> --- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
> +++ linux-pm/drivers/cpufreq/cpufreq_governor.c
> @@ -341,8 +341,9 @@ static void dbs_update_util_handler(stru
>  {
>   struct cpu_dbs_info *cdbs = container_of(data, struct cpu_dbs_info, 
> update_util);
>   struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
> - u64 delta_ns;
> + u64 delta_ns, lst;
>  
> + start:
>   /*
>* The work may not be allowed to be queued up right now.
>* Possible reasons:
> @@ -357,7 +358,8 @@ static void dbs_update_util_handler(stru
>* of sample_delay_ns used in the computation may be stale.
>*/
>   smp_rmb();
> - delta_ns = time - policy_dbs->last_sample_time;
> + lst = ACCESS_ONCE(policy_dbs->last_sample_time);

The comment on the top of ACCESS_ONCE() asks us to use READ_ONCE() if possible.

> + delta_ns = time - lst;
>   if ((s64)delta_ns < policy_dbs->sample_delay_ns)
>   return;
>  
> @@ -366,9 +368,19 @@ static void dbs_update_util_handler(stru
>* at this point.  Otherwise, we need to ensure that only one of the
>* CPUs sharing the policy will do that.
>*/
> - if (policy_dbs->is_shared &&
> - !atomic_add_unless(_dbs->work_count, 1, 1))
> - return;
> + if (policy_dbs->is_shared) {
> + if (!atomic_add_unless(_dbs->work_count, 1, 1))
> + return;
> +
> + /*
> +  * If another CPU updated last_sample_time in the meantime, we
> +  * shouldn't be here, so clear the work counter and try again.
> +  */
> + if (unlikely(lst != ACCESS_ONCE(policy_dbs->last_sample_time))) 
> {
> + atomic_set(_dbs->work_count, 0);
> + goto start;
> + }

I think we should be doing this here:

delta_ns = time - ACCESS_ONCE(policy_dbs->last_sample_time);
if ((s64)delta_ns < policy_dbs->sample_delay_ns) {
atomic_set(_dbs->work_count, 0);
return;
}

There is no point running the routine again, we already have ->work_count
incremented for us, lets do the check right now.

Over that, in theory, with your code, it is possible that one of the CPU can get
stuck in the goto->start loop indefinitely :)

> + }
>  
>   policy_dbs->last_sample_time = time;
>   policy_dbs->work_in_progress = true;

-- 
viresh


Re: [PATCH 1/2] cpufreq: governor: Fix race in dbs_update_util_handler()

2016-02-21 Thread Viresh Kumar
On 21-02-16, 03:14, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> There is a scenarion that may lead to undesired results in

 scenario

> dbs_update_util_handler().  Namely, if two CPUs sharing a policy
> enter the funtion at the same time, pass the sample delay check
> and then one of them is stalled until dbs_work_handler() (queued
> up by the other CPU) clears the work counter, it may update the
> work counter and queue up another work item prematurely.
> 
> To prevent that from happening, use the observation that the CPU
> queuing up a work item in dbs_update_util_handler() updates the
> last sample time.  This means that if another CPU was stalling after
> passing the sample delay check and now successfully updated the work
> counter as a result of the race described above, it will see the new
> value of the last sample time which is different from what it used in
> the sample delay check before.  If that happens, the sample delay
> check passed previously is not valid any more, so the CPU should not
> continue, but leaving the funtion at that point might miss an
> opportunity to take the next sample, so simply clear the work
> counter and jump to the beginning of the function in that case.
> 
> Fixes: f17cbb53783c (cpufreq: governor: Avoid atomic operations in hot paths)
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/cpufreq/cpufreq_governor.c |   22 +-
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
> ===
> --- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
> +++ linux-pm/drivers/cpufreq/cpufreq_governor.c
> @@ -341,8 +341,9 @@ static void dbs_update_util_handler(stru
>  {
>   struct cpu_dbs_info *cdbs = container_of(data, struct cpu_dbs_info, 
> update_util);
>   struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
> - u64 delta_ns;
> + u64 delta_ns, lst;
>  
> + start:
>   /*
>* The work may not be allowed to be queued up right now.
>* Possible reasons:
> @@ -357,7 +358,8 @@ static void dbs_update_util_handler(stru
>* of sample_delay_ns used in the computation may be stale.
>*/
>   smp_rmb();
> - delta_ns = time - policy_dbs->last_sample_time;
> + lst = ACCESS_ONCE(policy_dbs->last_sample_time);

The comment on the top of ACCESS_ONCE() asks us to use READ_ONCE() if possible.

> + delta_ns = time - lst;
>   if ((s64)delta_ns < policy_dbs->sample_delay_ns)
>   return;
>  
> @@ -366,9 +368,19 @@ static void dbs_update_util_handler(stru
>* at this point.  Otherwise, we need to ensure that only one of the
>* CPUs sharing the policy will do that.
>*/
> - if (policy_dbs->is_shared &&
> - !atomic_add_unless(_dbs->work_count, 1, 1))
> - return;
> + if (policy_dbs->is_shared) {
> + if (!atomic_add_unless(_dbs->work_count, 1, 1))
> + return;
> +
> + /*
> +  * If another CPU updated last_sample_time in the meantime, we
> +  * shouldn't be here, so clear the work counter and try again.
> +  */
> + if (unlikely(lst != ACCESS_ONCE(policy_dbs->last_sample_time))) 
> {
> + atomic_set(_dbs->work_count, 0);
> + goto start;
> + }

I think we should be doing this here:

delta_ns = time - ACCESS_ONCE(policy_dbs->last_sample_time);
if ((s64)delta_ns < policy_dbs->sample_delay_ns) {
atomic_set(_dbs->work_count, 0);
return;
}

There is no point running the routine again, we already have ->work_count
incremented for us, lets do the check right now.

Over that, in theory, with your code, it is possible that one of the CPU can get
stuck in the goto->start loop indefinitely :)

> + }
>  
>   policy_dbs->last_sample_time = time;
>   policy_dbs->work_in_progress = true;

-- 
viresh


  1   2   3   4   5   6   7   >