[PATCH 5/9] rfkill: Factor rfkill_global_states[].cur assignments

2016-02-08 Thread João Paulo Rechi Vita
Factor all assignments to rfkill_global_states[].cur into a single
function rfkill_update_global_state().

Signed-off-by: João Paulo Rechi Vita 
---
 net/rfkill/core.c | 38 +-
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 56d79cb..8b96869 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -302,6 +302,19 @@ static void rfkill_set_block(struct rfkill *rfkill, bool 
blocked)
rfkill_event(rfkill);
 }
 
+static void rfkill_update_global_state(enum rfkill_type type, bool blocked)
+{
+   int i;
+
+   if (type != RFKILL_TYPE_ALL) {
+   rfkill_global_states[type].cur = blocked;
+   return;
+   }
+
+   for (i = 0; i < NUM_RFKILL_TYPES; i++)
+   rfkill_global_states[i].cur = blocked;
+}
+
 #ifdef CONFIG_RFKILL_INPUT
 static atomic_t rfkill_input_disabled = ATOMIC_INIT(0);
 
@@ -319,15 +332,7 @@ static void __rfkill_switch_all(const enum rfkill_type 
type, bool blocked)
 {
struct rfkill *rfkill;
 
-   if (type == RFKILL_TYPE_ALL) {
-   int i;
-
-   for (i = 0; i < NUM_RFKILL_TYPES; i++)
-   rfkill_global_states[i].cur = blocked;
-   } else {
-   rfkill_global_states[type].cur = blocked;
-   }
-
+   rfkill_update_global_state(type, blocked);
list_for_each_entry(rfkill, _list, node) {
if (rfkill->type != type && type != RFKILL_TYPE_ALL)
continue;
@@ -1164,15 +1169,8 @@ static ssize_t rfkill_fop_write(struct file *file, const 
char __user *buf,
 
mutex_lock(_global_mutex);
 
-   if (ev.op == RFKILL_OP_CHANGE_ALL) {
-   if (ev.type == RFKILL_TYPE_ALL) {
-   enum rfkill_type i;
-   for (i = 0; i < NUM_RFKILL_TYPES; i++)
-   rfkill_global_states[i].cur = ev.soft;
-   } else {
-   rfkill_global_states[ev.type].cur = ev.soft;
-   }
-   }
+   if (ev.op == RFKILL_OP_CHANGE_ALL)
+   rfkill_update_global_state(ev.type, ev.soft);
 
list_for_each_entry(rfkill, _list, node) {
if (rfkill->idx != ev.idx && ev.op != RFKILL_OP_CHANGE_ALL)
@@ -1261,10 +1259,8 @@ static struct miscdevice rfkill_miscdev = {
 static int __init rfkill_init(void)
 {
int error;
-   int i;
 
-   for (i = 0; i < NUM_RFKILL_TYPES; i++)
-   rfkill_global_states[i].cur = !rfkill_default_state;
+   rfkill_update_global_state(RFKILL_TYPE_ALL, !rfkill_default_state);
 
error = class_register(_class);
if (error)
-- 
2.5.0

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


[PATCH 3/9] rfkill: Point to the correct deprecated doc location

2016-02-08 Thread João Paulo Rechi Vita
The "claim" sysfs interface has been removed, so its documentation now
lives in the "removed" folder.

Signed-off-by: João Paulo Rechi Vita 
---
 Documentation/ABI/stable/sysfs-class-rfkill | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/stable/sysfs-class-rfkill 
b/Documentation/ABI/stable/sysfs-class-rfkill
index 097f522..e51571e 100644
--- a/Documentation/ABI/stable/sysfs-class-rfkill
+++ b/Documentation/ABI/stable/sysfs-class-rfkill
@@ -2,8 +2,10 @@ rfkill - radio frequency (RF) connector kill switch support
 
 For details to this subsystem look at Documentation/rfkill.txt.
 
-For the deprecated /sys/class/rfkill/*/state and
-/sys/class/rfkill/*/claim knobs of this interface look in
+For the deprecated /sys/class/rfkill/*/claim knobs of this interface look in
+Documentation/ABI/removed/sysfs-class-rfkill.
+
+For the deprecated /sys/class/rfkill/*/state knobs of this interface look in
 Documentation/ABI/obsolete/sysfs-class-rfkill.
 
 What:  /sys/class/rfkill
-- 
2.5.0

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


[PATCH 8/9] rfkill: Userspace control for airplane mode

2016-02-08 Thread João Paulo Rechi Vita
Provide an interface for the airplane-mode indicator be controlled from
userspace. User has to first acquire the control through
RFKILL_OP_AIRPLANE_MODE_ACQUIRE and keep the fd open for the whole time
it wants to be in control of the indicator. Closing the fd or using
RFKILL_OP_AIRPLANE_MODE_RELEASE restores the default policy.

To change state of the indicator, the RFKILL_OP_AIRPLANE_MODE_CHANGE
operation is used, passing the value on "struct rfkill_event.soft". If
the caller has not acquired the airplane-mode control beforehand, the
operation fails.

Signed-off-by: João Paulo Rechi Vita 
---
 Documentation/rfkill.txt| 10 ++
 include/uapi/linux/rfkill.h |  3 +++
 net/rfkill/core.c   | 47 ++---
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index b13025a..aa6e014 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -87,6 +87,7 @@ RFKill provides per-switch LED triggers, which can be used to 
drive LEDs
 according to the switch state (LED_FULL when blocked, LED_OFF otherwise).
 An airplane-mode indicator LED trigger is also available, which triggers
 LED_FULL when all radios known by RFKill are blocked, and LED_OFF otherwise.
+The airplane-mode indicator LED trigger policy can be overridden by userspace.
 
 
 5. Userspace support
@@ -123,5 +124,14 @@ RFKILL_TYPE
 The contents of these variables corresponds to the "name", "state" and
 "type" sysfs files explained above.
 
+Userspace can also override the default airplane-mode indicator policy through
+/dev/rfkill. Control of the airplane mode indicator has to be acquired first,
+using RFKILL_OP_AIRPLANE_MODE_ACQUIRE, and is only available for one userspace
+application at a time. Closing the fd or using RFKILL_OP_AIRPLANE_MODE_RELEASE
+reverts the airplane-mode indicator back to the default kernel policy and makes
+it available for other applications to take control. Changes to the
+airplane-mode indicator state can be made using RFKILL_OP_AIRPLANE_MODE_CHANGE,
+passing the new value in the 'soft' field of 'struct rfkill_event'.
+
 
 For further details consult Documentation/ABI/stable/sysfs-class-rfkill.
diff --git a/include/uapi/linux/rfkill.h b/include/uapi/linux/rfkill.h
index 2e00dce..9cb999b 100644
--- a/include/uapi/linux/rfkill.h
+++ b/include/uapi/linux/rfkill.h
@@ -67,6 +67,9 @@ enum rfkill_operation {
RFKILL_OP_DEL,
RFKILL_OP_CHANGE,
RFKILL_OP_CHANGE_ALL,
+   RFKILL_OP_AIRPLANE_MODE_ACQUIRE,
+   RFKILL_OP_AIRPLANE_MODE_RELEASE,
+   RFKILL_OP_AIRPLANE_MODE_CHANGE,
 };
 
 /**
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index fb11547..8067701 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -89,6 +89,7 @@ struct rfkill_data {
struct mutexmtx;
wait_queue_head_t   read_wait;
boolinput_handler;
+   boolis_apm_owner;
 };
 
 
@@ -123,7 +124,7 @@ static struct {
 } rfkill_global_states[NUM_RFKILL_TYPES];
 
 static bool rfkill_epo_lock_active;
-
+static bool rfkill_apm_owned;
 
 #ifdef CONFIG_RFKILL_LEDS
 static struct led_trigger rfkill_apm_led_trigger;
@@ -350,7 +351,8 @@ static void rfkill_update_global_state(enum rfkill_type 
type, bool blocked)
 
for (i = 0; i < NUM_RFKILL_TYPES; i++)
rfkill_global_states[i].cur = blocked;
-   rfkill_apm_led_trigger_event(blocked);
+   if (!rfkill_apm_owned)
+   rfkill_apm_led_trigger_event(blocked);
 }
 
 #ifdef CONFIG_RFKILL_INPUT
@@ -1183,6 +1185,7 @@ static ssize_t rfkill_fop_read(struct file *file, char 
__user *buf,
 static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
 {
+   struct rfkill_data *data = file->private_data;
struct rfkill *rfkill;
struct rfkill_event ev;
 
@@ -1199,7 +1202,7 @@ static ssize_t rfkill_fop_write(struct file *file, const 
char __user *buf,
if (copy_from_user(, buf, count))
return -EFAULT;
 
-   if (ev.op != RFKILL_OP_CHANGE && ev.op != RFKILL_OP_CHANGE_ALL)
+   if (ev.op < RFKILL_OP_CHANGE)
return -EINVAL;
 
if (ev.type >= NUM_RFKILL_TYPES)
@@ -1207,6 +1210,34 @@ static ssize_t rfkill_fop_write(struct file *file, const 
char __user *buf,
 
mutex_lock(_global_mutex);
 
+   if (ev.op == RFKILL_OP_AIRPLANE_MODE_ACQUIRE) {
+   if (rfkill_apm_owned && !data->is_apm_owner) {
+   count = -EACCES;
+   } else {
+   rfkill_apm_owned = true;
+   data->is_apm_owner = true;
+   }
+   }
+
+   if (ev.op == RFKILL_OP_AIRPLANE_MODE_RELEASE) {
+   if (rfkill_apm_owned && !data->is_apm_owner) {
+   count = -EACCES;
+   } else {
+ 

[PATCH 2/9] rfkill: Remove extra blank line

2016-02-08 Thread João Paulo Rechi Vita
Signed-off-by: João Paulo Rechi Vita 
---
 net/rfkill/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index ffbc375..56d79cb 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -455,7 +455,6 @@ bool rfkill_get_global_sw_state(const enum rfkill_type type)
 }
 #endif
 
-
 bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
 {
unsigned long flags;
-- 
2.5.0

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


Re: [PATCHv9 1/4] EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support

2016-02-08 Thread Thor Thayer

Hi Boris.

On 02/08/2016 05:39 AM, Borislav Petkov wrote:

On Wed, Jan 27, 2016 at 10:13:20AM -0600, ttha...@opensource.altera.com wrote:

From: Thor Thayer 

Adding L2 Cache and On-Chip RAM EDAC support for the
Altera SoCs using the EDAC device  model. The SDRAM
controller is using the Memory Controller model.

Each type of ECC is individually configurable.

Signed-off-by: Thor Thayer 
---
v9: Improve device tree node release. Free managed resources
 on error path. Fix ocram memory leak.
v8: Remove MASK from single bit mask names.
 s/altr,edac/altr,socfpga-ecc-manager
 Use debugfs instead of sysfs.
 Add chip family name to match string.
 Fix header year.
 Fix build dependencies & change commit accordingly.
 s/CONFIG_EDAC_ALTERA_MC/CONFIG_EDAC_ALTERA
v7: s/of_get_named_gen_pool/of_gen_pool_get
 Remove #ifdef for EDAC_DEBUG
 Use -ENODEV instead of EPROBE_DEFER
v6: Convert to nested EDAC in device tree. Force L2 cache
 on for L2Cache ECC & remove L2 cache syscon for checking
 enable bit. Update year in header.
v5: No change.
v4: Change mask defines to use BIT().
 Fix comment style to agree with kernel coding style.
 Better printk description for read != write in trigger.
 Remove SysFS debugging message.
 Better dci->mod_name
 Move gen_pool pointer assignment to end of function.
 Invert logic to reduce indent in ocram depenency check.
 Change from dev_err() to edac_printk()
 Replace magic numbers with defines & comments.
 Improve error injection test.
 Change Makefile intermediary name to altr (from alt)
v3: Move OCRAM and L2 cache EDAC functions into altera_edac.c
 instead of separate files.
v2: Fix L2 dependency comments.
---
  drivers/edac/Kconfig   |   26 ++-
  drivers/edac/Makefile  |2 +-
  drivers/edac/altera_edac.c |  487 +++-
  3 files changed, 507 insertions(+), 8 deletions(-)


I'm still waiting for the people on CC to confirm the DT changes. A
couple of comments on the EDAC bits below.




Understood. I did get a conditional ACK from Rob Herring on the DT 
portion of the patch from the last revision (as long as I made the 
changes he suggested which I did in this patch). There may be other 
comments though.







+static irqreturn_t altr_edac_device_handler(int irq, void *dev_id)
+{
+   struct edac_device_ctl_info *dci = dev_id;
+   struct altr_edac_device_dev *drvdata = dci->pvt_info;
+   const struct edac_device_prv_data *priv = drvdata->data;
+
+   if (irq == drvdata->sb_irq) {
+   if (priv->ce_clear_mask)
+   writel(priv->ce_clear_mask, drvdata->base);
+   edac_device_handle_ce(dci, 0, 0, drvdata->edac_dev_name);
+   }
+   if (irq == drvdata->db_irq) {
+   if (priv->ue_clear_mask)
+   writel(priv->ue_clear_mask, drvdata->base);
+   edac_device_handle_ue(dci, 0, 0, drvdata->edac_dev_name);
+   panic("\nEDAC:ECC_DEVICE[Uncorrectable errors]\n");
+   }


And irq is guaranteed to always be ->sb_irq or ->db_irq?

Otherwise, you can do

else
WARN_ON(1);

just in case.


Those are the only cases of irq but it would be good to be alerted if 
that is not the case. I will add. Thanks!





+
+   return IRQ_HANDLED;
+}


...


+/*
+ * altr_edac_device_probe()
+ * This is a generic EDAC device driver that will support
+ * various Altera memory devices such as the L2 cache ECC and
+ * OCRAM ECC as well as the memories for other peripherals.
+ * Module specific initialization is done by passing the
+ * function index in the device tree.
+ */
+static int altr_edac_device_probe(struct platform_device *pdev)
+{





+
+   dci->mod_name = "Altera ECC Manager";
+   dci->dev_name = drvdata->edac_dev_name;
+
+   debugfs = edac_debugfs_create_dir(ecc_name);
+   if (debugfs)
+   altr_create_edacdev_dbgfs(dci, drvdata->data, debugfs);
+
+   if (edac_device_add_device(dci))


<--- if you end up here and debugfs nodes have been created, you need to
destroy them here. You probably could change edac_debugfs_exit() to call
debugfs_remove_recursive() and make sure your driver calls it.

Right now we're calling edac_debugfs_exit() in edac_exit() and I *think*
that is ok for a platform device driver as this one but I haven't
actually *verified* that.


Yes, thanks. I was using the xgene code as an example but I missed the 
unregister (although it looks like the xgene's unregister affects sysfs 
instead of debugfs). I'm also moving the debugfs creation to the end of 
the probe since it is not critical and avoids an error path if creation 
fails.


I'll make the debugfs_remove_recursive() change as a separate patch in 
my next version.





+   goto fail1;
+
+   devres_close_group(>dev, NULL);





+
+  

Re: [PATCH 8/9] rfkill: Userspace control for airplane mode

2016-02-08 Thread Marcel Holtmann
Hi Joa Paulo,

> Provide an interface for the airplane-mode indicator be controlled from
> userspace. User has to first acquire the control through
> RFKILL_OP_AIRPLANE_MODE_ACQUIRE and keep the fd open for the whole time
> it wants to be in control of the indicator. Closing the fd or using
> RFKILL_OP_AIRPLANE_MODE_RELEASE restores the default policy.
> 
> To change state of the indicator, the RFKILL_OP_AIRPLANE_MODE_CHANGE
> operation is used, passing the value on "struct rfkill_event.soft". If
> the caller has not acquired the airplane-mode control beforehand, the
> operation fails.

as explained in an earlier response, the concept Airplane Mode seems to be 
imposing policy into the kernel. Do we really want have this as a kernel 
exposed API.

Regards

Marcel

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


Re: [PATCH 8/9] rfkill: Userspace control for airplane mode

2016-02-08 Thread Dan Williams
On Mon, 2016-02-08 at 10:41 -0500, João Paulo Rechi Vita wrote:
> Provide an interface for the airplane-mode indicator be controlled
> from
> userspace. User has to first acquire the control through
> RFKILL_OP_AIRPLANE_MODE_ACQUIRE and keep the fd open for the whole
> time
> it wants to be in control of the indicator. Closing the fd or using
> RFKILL_OP_AIRPLANE_MODE_RELEASE restores the default policy.
> 
> To change state of the indicator, the RFKILL_OP_AIRPLANE_MODE_CHANGE
> operation is used, passing the value on "struct rfkill_event.soft".
> If
> the caller has not acquired the airplane-mode control beforehand, the
> operation fails.

I'd like to clarify a bit, so tell me if I'm correct or not.  Using
RFKILL_OP_AIRPLANE_MODE_CHANGE does not actually change any device
state. It's just an indicator with no relationship to any of the
registered rfkill switches, right?

I wonder if setting RFKILL_OP_AIRPLANE_MODE_CHANGE(true) shouldn't also
softblock all switches, otherwise you can set airplane mode all day
long with RFKILL_OP_AIRPLANE_MODE_CHANGE and it doesn't actually enable
airplane mode at all?

Dan

> Signed-off-by: João Paulo Rechi Vita 
> ---
>  Documentation/rfkill.txt| 10 ++
>  include/uapi/linux/rfkill.h |  3 +++
>  net/rfkill/core.c   | 47
> ++---
>  3 files changed, 57 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
> index b13025a..aa6e014 100644
> --- a/Documentation/rfkill.txt
> +++ b/Documentation/rfkill.txt
> @@ -87,6 +87,7 @@ RFKill provides per-switch LED triggers, which can
> be used to drive LEDs
>  according to the switch state (LED_FULL when blocked, LED_OFF
> otherwise).
>  An airplane-mode indicator LED trigger is also available, which
> triggers
>  LED_FULL when all radios known by RFKill are blocked, and LED_OFF
> otherwise.
> +The airplane-mode indicator LED trigger policy can be overridden by
> userspace.
>  
>  
>  5. Userspace support
> @@ -123,5 +124,14 @@ RFKILL_TYPE
>  The contents of these variables corresponds to the "name", "state"
> and
>  "type" sysfs files explained above.
>  
> +Userspace can also override the default airplane-mode indicator
> policy through
> +/dev/rfkill. Control of the airplane mode indicator has to be
> acquired first,
> +using RFKILL_OP_AIRPLANE_MODE_ACQUIRE, and is only available for one
> userspace
> +application at a time. Closing the fd or using
> RFKILL_OP_AIRPLANE_MODE_RELEASE
> +reverts the airplane-mode indicator back to the default kernel
> policy and makes
> +it available for other applications to take control. Changes to the
> +airplane-mode indicator state can be made using
> RFKILL_OP_AIRPLANE_MODE_CHANGE,
> +passing the new value in the 'soft' field of 'struct rfkill_event'.
> +
>  
>  For further details consult Documentation/ABI/stable/sysfs-class
> -rfkill.
> diff --git a/include/uapi/linux/rfkill.h
> b/include/uapi/linux/rfkill.h
> index 2e00dce..9cb999b 100644
> --- a/include/uapi/linux/rfkill.h
> +++ b/include/uapi/linux/rfkill.h
> @@ -67,6 +67,9 @@ enum rfkill_operation {
>   RFKILL_OP_DEL,
>   RFKILL_OP_CHANGE,
>   RFKILL_OP_CHANGE_ALL,
> + RFKILL_OP_AIRPLANE_MODE_ACQUIRE,
> + RFKILL_OP_AIRPLANE_MODE_RELEASE,
> + RFKILL_OP_AIRPLANE_MODE_CHANGE,
>  };
>  
>  /**
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index fb11547..8067701 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -89,6 +89,7 @@ struct rfkill_data {
>   struct mutexmtx;
>   wait_queue_head_t   read_wait;
>   boolinput_handler;
> + boolis_apm_owner;
>  };
>  
>  
> @@ -123,7 +124,7 @@ static struct {
>  } rfkill_global_states[NUM_RFKILL_TYPES];
>  
>  static bool rfkill_epo_lock_active;
> -
> +static bool rfkill_apm_owned;
>  
>  #ifdef CONFIG_RFKILL_LEDS
>  static struct led_trigger rfkill_apm_led_trigger;
> @@ -350,7 +351,8 @@ static void rfkill_update_global_state(enum
> rfkill_type type, bool blocked)
>  
>   for (i = 0; i < NUM_RFKILL_TYPES; i++)
>   rfkill_global_states[i].cur = blocked;
> - rfkill_apm_led_trigger_event(blocked);
> + if (!rfkill_apm_owned)
> + rfkill_apm_led_trigger_event(blocked);
>  }
>  
>  #ifdef CONFIG_RFKILL_INPUT
> @@ -1183,6 +1185,7 @@ static ssize_t rfkill_fop_read(struct file
> *file, char __user *buf,
>  static ssize_t rfkill_fop_write(struct file *file, const char __user
> *buf,
>   size_t count, loff_t *pos)
>  {
> + struct rfkill_data *data = file->private_data;
>   struct rfkill *rfkill;
>   struct rfkill_event ev;
>  
> @@ -1199,7 +1202,7 @@ static ssize_t rfkill_fop_write(struct file
> *file, const char __user *buf,
>   if (copy_from_user(, buf, count))
>   return -EFAULT;
>  
> - if (ev.op != RFKILL_OP_CHANGE && ev.op !=
> RFKILL_OP_CHANGE_ALL)
> + if (ev.op < 

Re: [PATCH v4 01/11] drm/hisilicon: Add device tree binding for hi6220 display subsystem

2016-02-08 Thread Archit Taneja

Hi,

On 02/06/2016 08:54 AM, Xinliang Liu wrote:

Add ADE display controller binding doc.
Add DesignWare DSI Host Controller v1.20a binding doc.

v4:
- Describe more specific of clocks and ports.
- Fix indentation.
v3:
- Make ade as the drm master node.
- Use assigned-clocks to set clock rate.
- Use ports to connect display relavant nodes.
v2:
- Move dt binding docs to bindings/display/hisilicon directory.

Signed-off-by: Xinwei Kong 
Signed-off-by: Xinliang Liu 
---
  .../bindings/display/hisilicon/dw-dsi.txt  | 77 ++
  .../bindings/display/hisilicon/hisi-ade.txt| 69 +++
  2 files changed, 146 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/display/hisilicon/dw-dsi.txt
  create mode 100644 
Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt

diff --git a/Documentation/devicetree/bindings/display/hisilicon/dw-dsi.txt 
b/Documentation/devicetree/bindings/display/hisilicon/dw-dsi.txt
new file mode 100644
index ..af6d702f3282
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/hisilicon/dw-dsi.txt
@@ -0,0 +1,77 @@
+Device-Tree bindings for DesignWare DSI Host Controller v1.20a driver
+
+A DSI Host Controller resides in the middle of display controller and external
+HDMI converter.
+
+Required properties:
+- compatible: value should be "hisilicon,hi6220-dsi".
+- reg: physical base address and length of dsi controller's registers.
+- clocks: the clocks needed.
+- clock-names: the name of the clocks.
+- ports: contains DSI controller input and output sub port.
+  The input port connects to ADE output port with the reg value "0".
+  The output port with the reg value "1", it could connect to panel or
+  any other bridge endpoints. And the reg value for bridge endpoint is "0",
+  other values for panel endpoint.
+  See Documentation/devicetree/bindings/graph.txt for more device graph info.
+
+A example of HiKey board hi6220 SoC and board specific DT entry:
+Example:
+
+SoC specific:
+   dsi: dsi@f4107800 {
+   compatible = "hisilicon,hi6220-dsi";
+   reg = <0x0 0xf4107800 0x0 0x100>;
+   clocks = <_ctrl  HI6220_DSI_PCLK>;
+   clock-names = "pclk_dsi";
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   /* 0 for input port */
+   port@0 {
+   reg = <0>;
+   dsi_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+   };
+
+
+Board specific:
+{
+   status = "ok";
+
+   ports {
+   /* 1 for output port */
+   port@1 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <1>;
+
+   /* 0 for bridge, other value for panel */
+   dsi_out0: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+   };
+
+{
+   ...
+
+   adv7533: adv7533@39 {
+   ...
+
+   port {
+   adv7533_in: endpoint {
+   remote-endpoint = <_out0>;
+   };
+   };
+   };
+   };
+
diff --git a/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt 
b/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt
new file mode 100644
index ..1eff5a41b98d
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/hisilicon/hisi-ade.txt
@@ -0,0 +1,69 @@
+Device-Tree bindings for hisilicon ADE display controller driver
+
+ADE (Advanced Display Engine) is the display controller which grab image
+data from memory, do composition, do post image processing, generate RGB
+timing stream and transfer to DSI.
+
+Required properties:
+- compatible: value should be "hisilicon,hi6220-ade".
+- reg: physical base address and length of the controller's registers.
+  Three reg ranges are used in ADE driver:
+  ADE reg range, value should be "<0x0 0xf410 0x0 0x7800>";
+  media subsystem reg range, value should be "<0x0 0xf441 0x0 0x1000>";
+  media subsystem NOC QoS reg range, value should be "<0x0 0xf452 0x0
+  0x1000>".
+- reg-names: name of physical base.Valuse should be "ade_base",  
"media_base"
+  and "media_noc_base".


The "media_base" and "media_noc_base" don't really look like a part of 
the ADE subsytem's MMIO region. If we need 

RE: [PATCH V2 3/6] stm class: provision for statically assigned masterIDs

2016-02-08 Thread Alexander Shishkin
Mike Leach  writes:

> Hi,
>
> I think a quick clarification of the ARM hardware STM architecture may be of 
> value here.
>
> The ARM hardware STM, when implemented as recommend in a hardware design, the 
> master IDs are not under driver control, but have a hardwire association with 
> source devices in the system. The master IDs are hardwired to individual 
> cores and core security states, and there could be other IDs associated with 
> hardware trace sources requiring output via the hardware STM. (an example of 
> this is the ARM Juno development board).
>
> Therefore in multi-core systems many masters may be associated with a single 
> software STM stream. A user-space application running on Core 1, may have a 
> master ID of 0x11 in the STPv2 trace stream, but if this application is 
> context switched and later continues running on Core 2, then master ID could 
> change to 0x21.  Masters identify a hardware source in this scheme, the 
> precise values used will be implementation dependent.
>
> So the number of masters "available to the software" depends on your 
> interpretation of the phrase.
> If you mean "master IDs on which software trace will appear" then that will 
> be many - it depends on which core is running the application. However as 
> described above, this is not predictable by any decoder, and the master set 
> used may not be contiguous.
> If you mean "master IDs selectable/allocated by the driver" then that will be 
> 0 - the driver has no control, and possibly no knowledge of which master is 
> associated with the current execution context. (this is of course system 
> dependent - it may well be possible to have some configuration database 
> associating cores with hardware IDs, but this will be implementation and 
> board support dependant).
>
> Therefore, there is a requirement to tell both the user-space STM client and 
> decoder that not only is master ID management not needed - it is in fact not 
> possible and the key to identify the software source for a given STM packet 
> is the channel alone. In addition we have a nominal single Master ID 
> "available to the software", to satisfy the requirements of the generic ST 
> module API.
>
> So on Juno for example, while we do have 128 masters, each with 65536 
> channels, the master allocation is not visible to system software - each core 
> sees a single master with 65536 channels. Therefore differentiation between 
> software sources in the STM trace is by channel number allocations only.

Ok, thanks a lot for the detailed explanation. I was confused by the
"static" bit in the patch description. It looks like something along the
lines of this patch might indeed be in order.

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


Re: [PATCH v4 03/11] drm/hisilicon: Add crtc driver for ADE

2016-02-08 Thread Archit Taneja



On 02/06/2016 08:54 AM, Xinliang Liu wrote:

Add crtc funcs and helper funcs for ADE.

v4: None.
v3:
- Make ade as the master driver.
- Use port to connect with encoder.
- A few cleanup.
v2:
- Remove abtraction layer.

Signed-off-by: Xinliang Liu 
---
  drivers/gpu/drm/hisilicon/kirin/Makefile|   3 +-
  drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h | 280 +++
  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 458 
  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  15 +
  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |   8 +
  5 files changed, 763 insertions(+), 1 deletion(-)
  create mode 100644 drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h
  create mode 100644 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c

diff --git a/drivers/gpu/drm/hisilicon/kirin/Makefile 
b/drivers/gpu/drm/hisilicon/kirin/Makefile
index cb346de47d48..2a61ab006ddb 100644
--- a/drivers/gpu/drm/hisilicon/kirin/Makefile
+++ b/drivers/gpu/drm/hisilicon/kirin/Makefile
@@ -1,3 +1,4 @@
-kirin-drm-y := kirin_drm_drv.o
+kirin-drm-y := kirin_drm_drv.o \
+  kirin_drm_ade.o

  obj-$(CONFIG_DRM_HISI_KIRIN) += kirin-drm.o
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h 
b/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h
new file mode 100644
index ..78020747abfe
--- /dev/null
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2016 Linaro Limited.
+ * Copyright (c) 2014-2016 Hisilicon Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __KIRIN_ADE_REG_H__
+#define __KIRIN_ADE_REG_H__
+
+/*
+ * ADE Registers
+ */
+#define MASK(x)(BIT(x) - 1)
+
+#define ADE_CTRL   0x0004
+#define FRM_END_START_OFST 0
+#define FRM_END_START_MASK MASK(2)
+#define ADE_CTRL1  0x008C
+#define AUTO_CLK_GATE_EN_OFST  0
+#define AUTO_CLK_GATE_EN   BIT(0)
+#define ADE_ROT_SRC_CFG0x0010
+#define ADE_DISP_SRC_CFG   0x0018
+#define ADE_WDMA2_SRC_CFG  0x001C
+#define ADE_SEC_OVLY_SRC_CFG   0x0020
+#define ADE_WDMA3_SRC_CFG  0x0024
+#define ADE_OVLY1_TRANS_CFG0x002C
+#define ADE_EN 0x0100
+#define ADE_DISABLE0
+#define ADE_ENABLE 1
+#define INTR_MASK_CPU(x)   (0x0C10 + (x) * 0x4)
+#define ADE_FRM_DISGARD_CTRL   0x00A4
+/* reset and reload regs */
+#define ADE_SOFT_RST_SEL(x)(0x0078 + (x) * 0x4)
+#define ADE_RELOAD_DIS(x)  (0x00AC + (x) * 0x4)
+#define RDMA_OFST  0
+#define CLIP_OFST  15
+#define SCL_OFST   21
+#define CTRAN_OFST 24
+#define OVLY_OFST  37 /* 32+5 */
+/* channel regs */
+#define RD_CH_PE(x)(0x1000 + (x) * 0x80)
+#define RD_CH_CTRL(x)  (0x1004 + (x) * 0x80)
+#define RD_CH_ADDR(x)  (0x1008 + (x) * 0x80)
+#define RD_CH_SIZE(x)  (0x100C + (x) * 0x80)
+#define RD_CH_STRIDE(x)(0x1010 + (x) * 0x80)
+#define RD_CH_SPACE(x) (0x1014 + (x) * 0x80)
+#define RD_CH_PARTIAL_SIZE(x)  (0x1018 + (x) * 0x80)
+#define RD_CH_PARTIAL_SPACE(x) (0x101C + (x) * 0x80)
+#define RD_CH_EN(x)(0x1020 + (x) * 0x80)
+#define RD_CH_STATUS(x)(0x1024 + (x) * 0x80)
+#define RD_CH_DISP_CTRL0x1404
+#define RD_CH_DISP_ADDR0x1408
+#define RD_CH_DISP_SIZE0x140C
+#define RD_CH_DISP_STRIDE  0x1410
+#define RD_CH_DISP_SPACE   0x1414
+#define RD_CH_DISP_EN  0x142C
+/* clip regs */
+#define ADE_CLIP_DISABLE(x)(0x6800 + (x) * 0x100)
+#define ADE_CLIP_SIZE0(x)  (0x6804 + (x) * 0x100)
+#define ADE_CLIP_SIZE1(x)  (0x6808 + (x) * 0x100)
+#define ADE_CLIP_SIZE2(x)  (0x680C + (x) * 0x100)
+#define ADE_CLIP_CFG_OK(x) (0x6810 + (x) * 0x100)
+/* scale regs */
+#define ADE_SCL1_MUX_CFG   0x000C
+#define ADE_SCL2_SRC_CFG   0x0014
+#define ADE_SCL3_MUX_CFG   0x0008
+#define ADE_SCL_CTRL(x)(0x3000 + (x) * 0x800)
+#define ADE_SCL_HSP(x) (0x3004 + (x) * 0x800)
+#define ADE_SCL_UV_HSP(x)  (0x3008 + (x) * 0x800)
+#define ADE_SCL_VSP(x) (0x300C + (x) * 0x800)
+#define ADE_SCL_UV_VSP(x)  (0x3010 + (x) * 0x800)
+#define ADE_SCL_ORES(x)(0x3014 + (x) * 0x800)
+#define ADE_SCL_IRES(x)(0x3018 + (x) * 0x800)
+#define 

[PATCH] Doc: DocBook: Fix a typo in device-drivers.tmpl

2016-02-08 Thread Masanari Iida
This patch fix a spelling typo in device-drivers.tmpl.

Signed-off-by: Masanari Iida 
---
 Documentation/DocBook/device-drivers.tmpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/DocBook/device-drivers.tmpl 
b/Documentation/DocBook/device-drivers.tmpl
index cc303a2..184f3c7 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -369,7 +369,7 @@ X!Ilib/fonts/fonts.c
 !Iinclude/linux/input-polldev.h
 !Edrivers/input/input-polldev.c
  
- Matrix keyboars/keypads
+ Matrix keyboards/keypads
 !Iinclude/linux/input/matrix_keypad.h
  
  Sparse keymap support
-- 
2.7.1.250.gff4ea60

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


Re: [PATCH] tty: serial: meson: Implement earlycon support

2016-02-08 Thread Andreas Färber
Hi Peter,

Am 08.02.2016 um 05:22 schrieb Peter Hurley:
> On 02/07/2016 12:57 PM, Andreas Färber wrote:
>> Reuse the existing console write implementation for implementing
>> DT-based and command-line-based earlycon support.
>>
>> Signed-off-by: Andreas Färber 
>> ---
>>  Documentation/kernel-parameters.txt |  6 ++
>>  drivers/tty/serial/meson_uart.c | 13 +
>>  2 files changed, 19 insertions(+)
>>
>> diff --git a/Documentation/kernel-parameters.txt 
>> b/Documentation/kernel-parameters.txt
>> index 602065c..90801ac 100644
>> --- a/Documentation/kernel-parameters.txt
>> +++ b/Documentation/kernel-parameters.txt
>> @@ -1030,6 +1030,12 @@ Such letter suffixes can also be entirely omitted.
>>  the driver will use only 32-bit accessors to read/write
>>  the device registers.
>>  
>> +meson_serial,
>> +Start an early, polled-mode console on a meson serial
>> +port at the specified address. The serial port must
>> +already be setup and configured. Options are not yet
>> +supported.
>> +
>>  msm_serial,
>>  Start an early, polled-mode console on an msm serial
>>  port at the specified address. The serial port
>> diff --git a/drivers/tty/serial/meson_uart.c 
>> b/drivers/tty/serial/meson_uart.c
>> index b12a37b..6f89567 100644
>> --- a/drivers/tty/serial/meson_uart.c
>> +++ b/drivers/tty/serial/meson_uart.c
>> @@ -548,6 +548,19 @@ static int __init meson_serial_console_init(void)
>>  }
>>  console_initcall(meson_serial_console_init);
>>  
>> +static int __init
>> +meson_serial_early_console_setup(struct earlycon_device *device, const char 
>> *opt)
>> +{
>> +if (!device->port.membase)
>> +return -ENODEV;
>> +
>> +device->con->write = meson_serial_console_write;
> 
> meson_serial_console_write() is not appropriate for earlycon; it assumes the
> earlycon port is the same as the driver port (it isn't).

Thanks for spotting that.

I forgot to mention that I tested this on arm64, where there is no
earlyprintk any more, seemingly successfully getting a bootconsole
uart0. Using co->data instead of co->index I now get meson_serial0
instead, doh.

This probably slipped though because another patch is necessary for
fixing the baudrate calculation on my device.

>> +return 0;
>> +}
>> +EARLYCON_DECLARE(meson_serial, meson_serial_early_console_setup);
>> +OF_EARLYCON_DECLARE(meson_serial, "amlogic,meson-uart",
>> +meson_serial_early_console_setup);
> 
> With today's linux-next (or Greg's tty-next tree), it is no longer necessary 
> to
> declare separate earlycon's when you want both; OF_EARLYCON_DECLARE() declares
> both a devicetree-enabled earlycon and automatically provides for a command 
> line
> earlycon of the same name.

Thanks for the hint, it was based on linux-next from a couple days ago.

Is there any guidance wrt naming? I noticed that msm uses -uart in the
compatible string and _serial for earlycon, so I copied that; should it
rather be meson_uart or just meson?

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv9 1/4] EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support

2016-02-08 Thread Borislav Petkov
On Wed, Jan 27, 2016 at 10:13:20AM -0600, ttha...@opensource.altera.com wrote:
> From: Thor Thayer 
> 
> Adding L2 Cache and On-Chip RAM EDAC support for the
> Altera SoCs using the EDAC device  model. The SDRAM
> controller is using the Memory Controller model.
> 
> Each type of ECC is individually configurable.
> 
> Signed-off-by: Thor Thayer 
> ---
> v9: Improve device tree node release. Free managed resources
> on error path. Fix ocram memory leak.
> v8: Remove MASK from single bit mask names.
> s/altr,edac/altr,socfpga-ecc-manager
> Use debugfs instead of sysfs.
> Add chip family name to match string.
> Fix header year.
> Fix build dependencies & change commit accordingly.
> s/CONFIG_EDAC_ALTERA_MC/CONFIG_EDAC_ALTERA
> v7: s/of_get_named_gen_pool/of_gen_pool_get
> Remove #ifdef for EDAC_DEBUG
> Use -ENODEV instead of EPROBE_DEFER
> v6: Convert to nested EDAC in device tree. Force L2 cache
> on for L2Cache ECC & remove L2 cache syscon for checking
> enable bit. Update year in header.
> v5: No change.
> v4: Change mask defines to use BIT().
> Fix comment style to agree with kernel coding style.
> Better printk description for read != write in trigger.
> Remove SysFS debugging message.
> Better dci->mod_name
> Move gen_pool pointer assignment to end of function.
> Invert logic to reduce indent in ocram depenency check.
> Change from dev_err() to edac_printk()
> Replace magic numbers with defines & comments.
> Improve error injection test.
> Change Makefile intermediary name to altr (from alt)
> v3: Move OCRAM and L2 cache EDAC functions into altera_edac.c
> instead of separate files.
> v2: Fix L2 dependency comments.
> ---
>  drivers/edac/Kconfig   |   26 ++-
>  drivers/edac/Makefile  |2 +-
>  drivers/edac/altera_edac.c |  487 
> +++-
>  3 files changed, 507 insertions(+), 8 deletions(-)

I'm still waiting for the people on CC to confirm the DT changes. A
couple of comments on the EDAC bits below.





> +static irqreturn_t altr_edac_device_handler(int irq, void *dev_id)
> +{
> + struct edac_device_ctl_info *dci = dev_id;
> + struct altr_edac_device_dev *drvdata = dci->pvt_info;
> + const struct edac_device_prv_data *priv = drvdata->data;
> +
> + if (irq == drvdata->sb_irq) {
> + if (priv->ce_clear_mask)
> + writel(priv->ce_clear_mask, drvdata->base);
> + edac_device_handle_ce(dci, 0, 0, drvdata->edac_dev_name);
> + }
> + if (irq == drvdata->db_irq) {
> + if (priv->ue_clear_mask)
> + writel(priv->ue_clear_mask, drvdata->base);
> + edac_device_handle_ue(dci, 0, 0, drvdata->edac_dev_name);
> + panic("\nEDAC:ECC_DEVICE[Uncorrectable errors]\n");
> + }

And irq is guaranteed to always be ->sb_irq or ->db_irq?

Otherwise, you can do

else
WARN_ON(1);

just in case.

> +
> + return IRQ_HANDLED;
> +}

...

> +/*
> + * altr_edac_device_probe()
> + *   This is a generic EDAC device driver that will support
> + *   various Altera memory devices such as the L2 cache ECC and
> + *   OCRAM ECC as well as the memories for other peripherals.
> + *   Module specific initialization is done by passing the
> + *   function index in the device tree.
> + */
> +static int altr_edac_device_probe(struct platform_device *pdev)
> +{
> + struct edac_device_ctl_info *dci;
> + struct altr_edac_device_dev *drvdata;
> + struct resource *r;
> + int res = 0;
> + struct device_node *np = pdev->dev.of_node;
> + char *ecc_name = (char *)np->name;
> + static int dev_instance;
> + struct dentry *debugfs;
> +
> + if (!devres_open_group(>dev, NULL, GFP_KERNEL)) {
> + edac_printk(KERN_ERR, EDAC_DEVICE,
> + "Unable to open devm\n");
> + return -ENOMEM;
> + }
> +
> + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!r) {
> + edac_printk(KERN_ERR, EDAC_DEVICE,
> + "Unable to get mem resource\n");
> + res = -ENODEV;
> + goto fail;
> + }
> +
> + if (!devm_request_mem_region(>dev, r->start, resource_size(r),
> +  dev_name(>dev))) {
> + edac_printk(KERN_ERR, EDAC_DEVICE,
> + "%s:Error requesting mem region\n", ecc_name);
> + res = -EBUSY;
> + goto fail;
> + }
> +
> + dci = edac_device_alloc_ctl_info(sizeof(*drvdata), ecc_name,
> +  1, ecc_name, 1, 0, NULL, 0,
> +  dev_instance++);
> +
> + if (!dci) {
> + edac_printk(KERN_ERR, EDAC_DEVICE,
> + "%s: Unable to allocate EDAC device\n", ecc_name);
> + res = 

Re: [PATCH 3/3] Documentation for the GCC plugin infrastructure

2016-02-08 Thread Kees Cook
On Sun, Feb 7, 2016 at 1:32 PM, Emese Revfy  wrote:
> This is the GCC infrastructure documentation about its operation, how to add
> and use a new plugin with an example.
>
> ---
>  Documentation/example_gcc_plugin.c | 103 
> +

Perhaps this example should live in samples/gcc_plugin/ ?

>  Documentation/gcc-plugins.txt  |  76 +++
>  2 files changed, 179 insertions(+)
>  create mode 100644 Documentation/example_gcc_plugin.c
>  create mode 100644 Documentation/gcc-plugins.txt
>
> diff --git a/Documentation/example_gcc_plugin.c 
> b/Documentation/example_gcc_plugin.c
> new file mode 100644
> index 000..950ff78
> --- /dev/null
> +++ b/Documentation/example_gcc_plugin.c
> @@ -0,0 +1,103 @@
> +/*
> + * Copyright 2011-2016 by Emese Revfy 
> + * Licensed under the GPL v2, or (at your option) v3
> + */
> +
> +#include "gcc-common.h"
> +
> +int plugin_is_GPL_compatible;
> +
> +static struct plugin_info example_plugin_info = {
> +   .version= "0",
> +   .help   = "example plugin\n",
> +};
> +
> +static unsigned int handle_function(void)
> +{
> +   gimple_stmt_iterator gsi;
> +   basic_block bb;
> +
> +   FOR_ALL_BB_FN(bb, cfun) {
> +   for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next())
> +   debug_gimple_stmt(gsi_stmt(gsi));
> +   }
> +   return 0;
> +}
> +
> +#if BUILDING_GCC_VERSION >= 4009
> +namespace {
> +static const struct pass_data example_plugin_pass_data = {
> +#else
> +static struct gimple_opt_pass example_plugin_pass = {
> +   .pass = {
> +#endif
> +   .type   = GIMPLE_PASS,
> +   .name   = "example_plugin",
> +#if BUILDING_GCC_VERSION >= 4008
> +   .optinfo_flags  = OPTGROUP_NONE,
> +#endif
> +#if BUILDING_GCC_VERSION >= 5000
> +#elif BUILDING_GCC_VERSION >= 4009
> +   .has_gate   = false,
> +   .has_execute= true,
> +#else
> +   .gate   = NULL,
> +   .execute= handle_function,
> +   .sub= NULL,
> +   .next   = NULL,
> +   .static_pass_number = 0,
> +#endif
> +   .tv_id  = TV_NONE,
> +   .properties_required= 0,
> +   .properties_provided= 0,
> +   .properties_destroyed   = 0,
> +   .todo_flags_start   = 0,
> +   .todo_flags_finish  = TODO_dump_func
> +#if BUILDING_GCC_VERSION < 4009
> +   }
> +#endif
> +};
> +
> +#if BUILDING_GCC_VERSION >= 4009
> +class example_plugin_pass : public gimple_opt_pass {
> +public:
> +   example_plugin_pass() : gimple_opt_pass(example_plugin_pass_data, g) 
> {}
> +#if BUILDING_GCC_VERSION >= 5000
> +   virtual unsigned int execute(function *) { return handle_function(); }
> +#else
> +   unsigned int execute() { return handle_function(); }
> +#endif
> +};
> +}
> +
> +static opt_pass *make_example_plugin_pass(void)
> +{
> +   return new example_plugin_pass();
> +}
> +#else
> +static struct opt_pass *make_example_plugin_pass(void)
> +{
> +   return _plugin_pass.pass;
> +}
> +#endif
> +
> +int plugin_init(struct plugin_name_args *plugin_info, struct 
> plugin_gcc_version *version)
> +{
> +   const char * const plugin_name = plugin_info->base_name;
> +   struct register_pass_info example_plugin_pass_info;
> +
> +   example_plugin_pass_info.pass   = 
> make_example_plugin_pass();
> +   example_plugin_pass_info.reference_pass_name= "ssa";
> +   example_plugin_pass_info.ref_pass_instance_number   = 1;
> +   example_plugin_pass_info.pos_op = 
> PASS_POS_INSERT_AFTER;
> +
> +   if (!plugin_default_version_check(version, _version)) {
> +   error(G_("incompatible gcc/plugin versions"));
> +   return 1;
> +   }
> +
> +   register_callback(plugin_name, PLUGIN_INFO, NULL, 
> _plugin_info);
> +   register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, 
> _plugin_pass_info);
> +
> +   return 0;
> +}

For an example, I'd expect verbose comments. :) Imagine someone
reading it who knows very little about plugins or compiler internals.

> diff --git a/Documentation/gcc-plugins.txt b/Documentation/gcc-plugins.txt
> new file mode 100644
> index 000..e669d83
> --- /dev/null
> +++ b/Documentation/gcc-plugins.txt
> @@ -0,0 +1,76 @@
> +GCC plugin infrastructure
> +=
> +
> +
> +1. Introduction
> +===
> +
> +GCC plugins are loadable modules that provide extra features to the
> +compiler [1]. They are useful for runtime instrumentation and static 
> analysis.
> +We can analyse, change and add further code during compilation via
> +callbacks [2], GIMPLE [3], 

[PATCH 9/9] rfkill: Notify userspace of airplane-mode state changes

2016-02-08 Thread João Paulo Rechi Vita
Signed-off-by: João Paulo Rechi Vita 
---
 Documentation/rfkill.txt |  3 +++
 net/rfkill/core.c| 13 +
 2 files changed, 16 insertions(+)

diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index aa6e014..5248812 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -133,5 +133,8 @@ it available for other applications to take control. 
Changes to the
 airplane-mode indicator state can be made using RFKILL_OP_AIRPLANE_MODE_CHANGE,
 passing the new value in the 'soft' field of 'struct rfkill_event'.
 
+This same API is also used to provide userspace with notifications of changes
+to airplane-mode indicator state.
+
 
 For further details consult Documentation/ABI/stable/sysfs-class-rfkill.
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 8067701..abbb8f7 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -131,7 +131,20 @@ static struct led_trigger rfkill_apm_led_trigger;
 
 static void rfkill_apm_led_trigger_event(bool state)
 {
+   struct rfkill_data *data;
+   struct rfkill_int_event *ev;
+
led_trigger_event(_apm_led_trigger, state ? LED_FULL : LED_OFF);
+
+   list_for_each_entry(data, _fds, list) {
+   ev = kzalloc(sizeof(*ev), GFP_KERNEL);
+   if (!ev)
+   continue;
+   ev->ev.op = RFKILL_OP_AIRPLANE_MODE_CHANGE;
+   ev->ev.soft = state;
+   list_add_tail(>list, >events);
+   wake_up_interruptible(>read_wait);
+   }
 }
 
 static void rfkill_apm_led_trigger_activate(struct led_classdev *led)
-- 
2.5.0

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


Re: [RFC PATCH v4 0/6] (mostly) Arch-independent livepatch

2016-02-08 Thread Miroslav Benes
On Wed, 3 Feb 2016, Jessica Yu wrote:

> Jessica Yu (6):
>   Elf: add livepatch-specific Elf constants
>   module: preserve Elf information for livepatch modules
>   module: s390: keep mod_arch_specific for livepatch modules
>   livepatch: reuse module loader code to write relocations
>   samples: livepatch: mark as livepatch module
>   Documentation: livepatch: outline Elf format and requirements for
> patch modules

Hi,

I walked through the code and it looks good except for several minor 
things in the fourth patch (livepatch: reuse module loader code to write 
relocations). I'd propose to send the next version as a regular PATCH set 
and not RFC. We can start collecting Reviews and Acks. Hopefully it won't 
take more than one or two iterations. Would that be ok with everyone?

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


Re: [PATCH 8/9] rfkill: Userspace control for airplane mode

2016-02-08 Thread João Paulo Rechi Vita
Hello Marcel,

On 8 February 2016 at 11:20, Marcel Holtmann  wrote:
> Hi Joa Paulo,
>
>> Provide an interface for the airplane-mode indicator be controlled from
>> userspace. User has to first acquire the control through
>> RFKILL_OP_AIRPLANE_MODE_ACQUIRE and keep the fd open for the whole time
>> it wants to be in control of the indicator. Closing the fd or using
>> RFKILL_OP_AIRPLANE_MODE_RELEASE restores the default policy.
>>
>> To change state of the indicator, the RFKILL_OP_AIRPLANE_MODE_CHANGE
>> operation is used, passing the value on "struct rfkill_event.soft". If
>> the caller has not acquired the airplane-mode control beforehand, the
>> operation fails.
>
> as explained in an earlier response, the concept Airplane Mode seems to be 
> imposing policy into the kernel. Do we really want have this as a kernel 
> exposed API.
>

On that very same thread we decided to keep using the "airplane mode"
name both for when having the default policy of "set it when all
radios are off" or when allowing userspace to override the default.
Please see the following message from Johannes
http://www.spinics.net/lists/linux-wireless/msg146069.html and let me
know if that covers your concern.

Thanks!

--
João Paulo Rechi Vita
http://about.me/jprvita
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 8/9] rfkill: Userspace control for airplane mode

2016-02-08 Thread Johannes Berg

On 2016-02-08 17:20, Marcel Holtmann wrote:


as explained in an earlier response, the concept Airplane Mode seems
to be imposing policy into the kernel. Do we really want have this as
a kernel exposed API.


This patch is the one that *solves* that problem ... please read it more 
carefully?


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


Re: [PATCHv9 3/4] ARM: socfpga: enable L2 cache ECC on startup

2016-02-08 Thread Dinh Nguyen


On 01/27/2016 10:13 AM, ttha...@opensource.altera.com wrote:
> From: Thor Thayer 
> 
> This patch enables the ECC for L2 cache on machine startup. The ECC has to
> be enabled before data is stored in memory otherwise the ECC will fail on
> reads.
> 
> Signed-off-by: Thor Thayer 
> ---
> v9: Improve node put handling.
> v8: Address community suggestions for strings. Fix string based on
> maintainer feedback. Update year in header.
> v7: unmap locally scoped mapped_l2_edac_addr and add of_node_put(np)
> v6: Remove pr_debug() & update year in header.
> ---
>  arch/arm/mach-socfpga/Makefile   |1 +
>  arch/arm/mach-socfpga/core.h |1 +
>  arch/arm/mach-socfpga/l2_cache.c |   41 
> ++
>  arch/arm/mach-socfpga/socfpga.c  |2 ++
>  4 files changed, 45 insertions(+)
>  create mode 100644 arch/arm/mach-socfpga/l2_cache.c
> 

Acked-by: Dinh Nguyen 


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


Re: [RFC PATCH v4 2/6] module: preserve Elf information for livepatch modules

2016-02-08 Thread Josh Poimboeuf
On Wed, Feb 03, 2016 at 08:11:07PM -0500, Jessica Yu wrote:
> For livepatch modules, copy Elf section, symbol, and string information
> from the load_info struct in the module loader. Persist copies of the
> original symbol table and string table.
> 
> Livepatch manages its own relocation sections in order to reuse module
> loader code to write relocations. Livepatch modules must preserve Elf
> information such as section indices in order to apply livepatch relocation
> sections using the module loader's apply_relocate_add() function.
> 
> In order to apply livepatch relocation sections, livepatch modules must
> keep a complete copy of their original symbol table in memory. Normally, a
> stripped down copy of a module's symbol table (containing only "core"
> symbols) is made available through module->core_symtab. But for livepatch
> modules, the symbol table copied into memory on module load must be exactly
> the same as the symbol table produced when the patch module was compiled.
> This is because the relocations in each livepatch relocation section refer
> to their respective symbols with their symbol indices, and the original
> symbol indices (and thus the symtab ordering) must be preserved in order
> for apply_relocate_add() to find the right symbol.

This patch didn't apply clean to linux-next/master.  I didn't
investigate why, but maybe it depends on the other patch set which
removes the notifiers?  (If so, that should be mentioned in the cover
letter.)

A couple of minor comments below...

> Signed-off-by: Jessica Yu 
> ---
>  include/linux/module.h |  25 ++
>  kernel/module.c| 133 
> ++---
>  2 files changed, 151 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 4560d8f..58e6200 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -324,6 +324,15 @@ struct module_layout {
>  #define __module_layout_align
>  #endif
>  
> +#ifdef CONFIG_LIVEPATCH
> +struct klp_modinfo {
> + Elf_Ehdr hdr;
> + Elf_Shdr *sechdrs;
> + char *secstrings;
> + unsigned int symndx;
> +};
> +#endif
> +
>  struct module {
>   enum module_state state;
>  
> @@ -455,7 +464,11 @@ struct module {
>  #endif
>  
>  #ifdef CONFIG_LIVEPATCH
> + bool klp; /* Is this a livepatch module? */
>   bool klp_alive;
> +
> + /* Elf information */
> + struct klp_modinfo *klp_info;
>  #endif
>  
>  #ifdef CONFIG_MODULE_UNLOAD
> @@ -629,6 +642,18 @@ static inline bool module_requested_async_probing(struct 
> module *module)
>   return module && module->async_probe_requested;
>  }
>  
> +#ifdef CONFIG_LIVEPATCH
> +static inline bool is_livepatch_module(struct module *mod)
> +{
> + return mod->klp;
> +}
> +#else /* !CONFIG_LIVEPATCH */
> +static inline bool is_livepatch_module(struct module *mod)
> +{
> + return false;
> +}
> +#endif /* CONFIG_LIVEPATCH */
> +
>  #else /* !CONFIG_MODULES... */
>  
>  /* Given an address, look for it in the exception tables. */
> diff --git a/kernel/module.c b/kernel/module.c
> index 71c77ed..9c16eb2 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -1970,6 +1970,82 @@ static void module_enable_nx(const struct module *mod) 
> { }
>  static void module_disable_nx(const struct module *mod) { }
>  #endif
>  
> +#ifdef CONFIG_LIVEPATCH
> +/*
> + * Persist Elf information about a module. Copy the Elf header,
> + * section header table, section string table, and symtab section
> + * index from info to mod->klp_info.
> + */
> +static int copy_module_elf(struct module *mod, struct load_info *info)
> +{
> + unsigned int size, symndx;
> + int ret = 0;
> +
> + size = sizeof(*mod->klp_info);
> + mod->klp_info = kmalloc(size, GFP_KERNEL);
> + if (mod->klp_info == NULL)
> + return -ENOMEM;
> +
> + /* Elf header */
> + size = sizeof(Elf_Ehdr);
> + memcpy(>klp_info->hdr, info->hdr, size);
> +
> + /* Elf section header table */
> + size = sizeof(Elf_Shdr) * info->hdr->e_shnum;
> + mod->klp_info->sechdrs = kmalloc(size, GFP_KERNEL);
> + if (mod->klp_info->sechdrs == NULL) {
> + ret = -ENOMEM;
> + goto free_info;
> + }
> + memcpy(mod->klp_info->sechdrs, info->sechdrs, size);
> +
> + /* Elf section name string table */
> + size = info->sechdrs[info->hdr->e_shstrndx].sh_size;
> + mod->klp_info->secstrings = kmalloc(size, GFP_KERNEL);
> + if (mod->klp_info->secstrings == NULL) {
> + ret = -ENOMEM;
> + goto free_sechdrs;
> + }
> + memcpy(mod->klp_info->secstrings, info->secstrings, size);
> +
> + /* Elf symbol section index */
> + symndx = info->index.sym;
> + mod->klp_info->symndx = symndx;
> +
> + /*
> +  * For livepatch modules, core_symtab is a complete copy
> +  * of the original symbol table. Adjust sh_addr to point
> +  * to core_symtab since the copy of the 

Re: [PATCHv9 4/4] ARM: socfpga: Enable OCRAM ECC on startup

2016-02-08 Thread Dinh Nguyen


On 01/27/2016 10:13 AM, ttha...@opensource.altera.com wrote:
> From: Thor Thayer 
> 
> This patch enables the ECC for On-Chip RAM on machine startup. The ECC
> has to be enabled before data is stored in memory otherwise the ECC will
> fail on reads.
> 
> Signed-off-by: Thor Thayer 
> ---
> v9: Improve node release handling.
> v8: Address community comments on strings. Fix match strings based
> on maintainer feedback. Update year in header.
> v7: enable OCRAM ECC during platform init
> v6: Implement OCRAM discovery changes from community. Add
> of_node_put(). Remove be32_to_cpup(). Use __init() which
> allows removal of .init_machine(). Update year in header.
> ---
>  arch/arm/mach-socfpga/Makefile  |1 +
>  arch/arm/mach-socfpga/core.h|1 +
>  arch/arm/mach-socfpga/ocram.c   |   49 
> +++
>  arch/arm/mach-socfpga/socfpga.c |3 +++
>  4 files changed, 54 insertions(+)
>  create mode 100644 arch/arm/mach-socfpga/ocram.c
> 

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


Re: [PATCH 5/9] rfkill: Factor rfkill_global_states[].cur assignments

2016-02-08 Thread Julian Calaby
Hi João,

On Tue, Feb 9, 2016 at 2:41 AM, João Paulo Rechi Vita  wrote:
> Factor all assignments to rfkill_global_states[].cur into a single
> function rfkill_update_global_state().
>
> Signed-off-by: João Paulo Rechi Vita 

Looks sane to me.

Reviewed-by: Julian Calaby 

> ---
>  net/rfkill/core.c | 38 +-
>  1 file changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index 56d79cb..8b96869 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -302,6 +302,19 @@ static void rfkill_set_block(struct rfkill *rfkill, bool 
> blocked)
> rfkill_event(rfkill);
>  }
>
> +static void rfkill_update_global_state(enum rfkill_type type, bool blocked)
> +{
> +   int i;
> +
> +   if (type != RFKILL_TYPE_ALL) {
> +   rfkill_global_states[type].cur = blocked;
> +   return;
> +   }
> +
> +   for (i = 0; i < NUM_RFKILL_TYPES; i++)
> +   rfkill_global_states[i].cur = blocked;
> +}
> +
>  #ifdef CONFIG_RFKILL_INPUT
>  static atomic_t rfkill_input_disabled = ATOMIC_INIT(0);
>
> @@ -319,15 +332,7 @@ static void __rfkill_switch_all(const enum rfkill_type 
> type, bool blocked)
>  {
> struct rfkill *rfkill;
>
> -   if (type == RFKILL_TYPE_ALL) {
> -   int i;
> -
> -   for (i = 0; i < NUM_RFKILL_TYPES; i++)
> -   rfkill_global_states[i].cur = blocked;
> -   } else {
> -   rfkill_global_states[type].cur = blocked;
> -   }
> -
> +   rfkill_update_global_state(type, blocked);
> list_for_each_entry(rfkill, _list, node) {
> if (rfkill->type != type && type != RFKILL_TYPE_ALL)
> continue;
> @@ -1164,15 +1169,8 @@ static ssize_t rfkill_fop_write(struct file *file, 
> const char __user *buf,
>
> mutex_lock(_global_mutex);
>
> -   if (ev.op == RFKILL_OP_CHANGE_ALL) {
> -   if (ev.type == RFKILL_TYPE_ALL) {
> -   enum rfkill_type i;
> -   for (i = 0; i < NUM_RFKILL_TYPES; i++)
> -   rfkill_global_states[i].cur = ev.soft;
> -   } else {
> -   rfkill_global_states[ev.type].cur = ev.soft;
> -   }
> -   }
> +   if (ev.op == RFKILL_OP_CHANGE_ALL)
> +   rfkill_update_global_state(ev.type, ev.soft);
>
> list_for_each_entry(rfkill, _list, node) {
> if (rfkill->idx != ev.idx && ev.op != RFKILL_OP_CHANGE_ALL)
> @@ -1261,10 +1259,8 @@ static struct miscdevice rfkill_miscdev = {
>  static int __init rfkill_init(void)
>  {
> int error;
> -   int i;
>
> -   for (i = 0; i < NUM_RFKILL_TYPES; i++)
> -   rfkill_global_states[i].cur = !rfkill_default_state;
> +   rfkill_update_global_state(RFKILL_TYPE_ALL, !rfkill_default_state);
>
> error = class_register(_class);
> if (error)
> --
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 8/9] rfkill: Userspace control for airplane mode

2016-02-08 Thread Julian Calaby
Hi João,

On Tue, Feb 9, 2016 at 2:41 AM, João Paulo Rechi Vita  wrote:
> Provide an interface for the airplane-mode indicator be controlled from
> userspace. User has to first acquire the control through
> RFKILL_OP_AIRPLANE_MODE_ACQUIRE and keep the fd open for the whole time
> it wants to be in control of the indicator. Closing the fd or using
> RFKILL_OP_AIRPLANE_MODE_RELEASE restores the default policy.
>
> To change state of the indicator, the RFKILL_OP_AIRPLANE_MODE_CHANGE
> operation is used, passing the value on "struct rfkill_event.soft". If
> the caller has not acquired the airplane-mode control beforehand, the
> operation fails.
>
> Signed-off-by: João Paulo Rechi Vita 
> ---
>  Documentation/rfkill.txt| 10 ++
>  include/uapi/linux/rfkill.h |  3 +++
>  net/rfkill/core.c   | 47 
> ++---
>  3 files changed, 57 insertions(+), 3 deletions(-)
>
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index fb11547..8067701 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -1207,6 +1210,34 @@ static ssize_t rfkill_fop_write(struct file *file, 
> const char __user *buf,
>
> mutex_lock(_global_mutex);
>
> +   if (ev.op == RFKILL_OP_AIRPLANE_MODE_ACQUIRE) {
> +   if (rfkill_apm_owned && !data->is_apm_owner) {
> +   count = -EACCES;
> +   } else {
> +   rfkill_apm_owned = true;
> +   data->is_apm_owner = true;
> +   }
> +   }
> +
> +   if (ev.op == RFKILL_OP_AIRPLANE_MODE_RELEASE) {
> +   if (rfkill_apm_owned && !data->is_apm_owner) {

Are you sure this is correct?

In the case that airplane mode isn't owned, the
rfkill_apm_led_trigger_event() call will be a noop, so we should
arguably not be calling it.

Also, should we just fail silently if we're not the owner? I.e. what
does userspace learn from this op failing and is that useful?

> +   count = -EACCES;
> +   } else {
> +   bool state = 
> rfkill_global_states[RFKILL_TYPE_ALL].cur;
> +
> +   rfkill_apm_owned = false;
> +   data->is_apm_owner = false;
> +   rfkill_apm_led_trigger_event(state);
> +   }
> +   }
> +
> +   if (ev.op == RFKILL_OP_AIRPLANE_MODE_CHANGE) {
> +   if (rfkill_apm_owned && data->is_apm_owner)
> +   rfkill_apm_led_trigger_event(ev.soft);
> +   else
> +   count = -EACCES;
> +   }
> +
> if (ev.op == RFKILL_OP_CHANGE_ALL)
> rfkill_update_global_state(ev.type, ev.soft);
>
> @@ -1230,7 +1261,17 @@ static int rfkill_fop_release(struct inode *inode, 
> struct file *file)
> struct rfkill_int_event *ev, *tmp;
>
> mutex_lock(_global_mutex);
> +
> +   if (data->is_apm_owner) {
> +   bool state = rfkill_global_states[RFKILL_TYPE_ALL].cur;
> +
> +   rfkill_apm_owned = false;
> +   data->is_apm_owner = false;
> +   rfkill_apm_led_trigger_event(state);

Also, this code is duplicated from the _RELEASE op above. Would it
make sense to factor it out into a separate function?

> +   }
> +
> list_del(>list);
> +

(extra line)

> mutex_unlock(_global_mutex);
>
> mutex_destroy(>mtx);

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html