[PATCH] staging: fbtft: Fix module autoload

2016-10-17 Thread Javier Martinez Canillas
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/staging/fbtft/flexfb.ko | grep alias
$

After this patch:

$ modinfo drivers/staging/fbtft/flexfb.ko | grep alias
alias:  platform:flexpfb

Signed-off-by: Javier Martinez Canillas 
---

 drivers/staging/fbtft/flexfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index 2dc5f9b6b47e..ded10718712b 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -830,6 +830,7 @@ static const struct platform_device_id 
flexfb_platform_ids[] = {
{ "flexpfb", 0 },
{ },
 };
+MODULE_DEVICE_TABLE(platform, flexfb_platform_ids);
 
 static struct platform_driver flexfb_platform_driver = {
.driver = {
-- 
2.7.4



[PATCH] of: Add missing space at end of pr_fmt().

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

Make pr_fmt() in fdt.c consistent with all other files in drivers/of/

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

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index c89d5d231a0e..9f98e437e1f1 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -9,7 +9,7 @@
  * version 2 as published by the Free Software Foundation.
  */
 
-#define pr_fmt(fmt)"OF: fdt:" fmt
+#define pr_fmt(fmt)"OF: fdt: " fmt
 
 #include 
 #include 
-- 
1.9.1



Re: [PATCH] DAX: enable iostat for read/write

2016-10-17 Thread Kani, Toshimitsu
On Mon, 2016-10-17 at 11:55 -0700, Dan Williams wrote:
> On Mon, Oct 17, 2016 at 10:40 AM, Kani, Toshimitsu  m> wrote:
> > 
> > On Sat, 2016-10-15 at 18:54 +1100, Dave Chinner wrote:
> > > 
> > > On Fri, Oct 14, 2016 at 11:25:13AM -0600, Toshi Kani wrote:
> >  :
> > > 
> > > > 
> > > > +static void dax_iostat_start(struct gendisk *disk, struct
> > > > iov_iter
> > > > *iter,
> > > > + unsigned long *start)
> > > > +{
> > > > +int rw = iov_iter_rw(iter);
> > > > +int sec = iov_iter_count(iter) >> 9;
> > > > +int cpu = part_stat_lock();
> > > > +
> > > > +*start = jiffies;
> > > > +part_round_stats(cpu, &disk->part0);
> > > > +part_stat_inc(cpu, &disk->part0, ios[rw]);
> > > > +part_stat_add(cpu, &disk->part0, sectors[rw], sec);
> > > > +part_inc_in_flight(&disk->part0, rw);
> > > > +part_stat_unlock();
> > > > +}
> > > 
> > > Why reimplement generic_start_io_acct() and
> > > generic_end_io_acct()?
> > 
> > It was modeled after __nd_iostat_start() / nd_iostart_end().  I
> > agree that we can use generic_start_io_acct() and
> > generic_end_io_acct() here.
> > 
> > Should we also change the nd interface to use the generic version
> > as well?
> 
> Yes, sounds good to me.

Will do. Thanks!
-Toshi

Re: Oops on Power8 (was Re: [PATCH v2 1/7] workqueue: make workqueue available early during boot)

2016-10-17 Thread Tejun Heo
Hello, Michael.

Other NUMA archs are lazy-initializing cpu to node mapping too, so we
need to fix it from workqueue side.  This also means that we've been
getting NUMA node wrong for percpu pools on those archs.

Can you please try the following patch and if it resolves the issue,
report the workqueue part (it's at the end) of sysrq-t dump?

Thanks.

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 984f6ff..276557b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4411,14 +4411,14 @@ void show_workqueue_state(void)
break;
}
}
-   if (idle)
-   continue;
+   //if (idle)
+   //  continue;
 
pr_info("workqueue %s: flags=0x%x\n", wq->name, wq->flags);
 
for_each_pwq(pwq, wq) {
spin_lock_irqsave(&pwq->pool->lock, flags);
-   if (pwq->nr_active || !list_empty(&pwq->delayed_works))
+   //if (pwq->nr_active || 
!list_empty(&pwq->delayed_works))
show_pwq(pwq);
spin_unlock_irqrestore(&pwq->pool->lock, flags);
}
@@ -4429,8 +4429,8 @@ void show_workqueue_state(void)
bool first = true;
 
spin_lock_irqsave(&pool->lock, flags);
-   if (pool->nr_workers == pool->nr_idle)
-   goto next_pool;
+   //if (pool->nr_workers == pool->nr_idle)
+   //  goto next_pool;
 
pr_info("pool %d:", pool->id);
pr_cont_pool_info(pool);
@@ -4649,10 +4649,12 @@ int workqueue_online_cpu(unsigned int cpu)
for_each_pool(pool, pi) {
mutex_lock(&pool->attach_mutex);
 
-   if (pool->cpu == cpu)
+   if (pool->cpu == cpu) {
+   pool->node = cpu_to_node(cpu);
rebind_workers(pool);
-   else if (pool->cpu < 0)
+   } else if (pool->cpu < 0) {
restore_unbound_workers_cpumask(pool, cpu);
+   }
 
mutex_unlock(&pool->attach_mutex);
}
@@ -5495,8 +5497,6 @@ int __init workqueue_init_early(void)
 
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
 
-   wq_numa_init();
-
/* initialize CPU pools */
for_each_possible_cpu(cpu) {
struct worker_pool *pool;
@@ -5571,6 +5571,9 @@ int __init workqueue_init(void)
struct worker_pool *pool;
int cpu, bkt;
 
+   wq_numa_init();
+   wq_update_unbound_numa(wq, smp_processor_id(), true);
+
/* create the initial workers */
for_each_online_cpu(cpu) {
for_each_cpu_worker_pool(pool, cpu) {


[PATCH v2 3/3] doc: add documentation for uio-hv-generic

2016-10-17 Thread Stephen Hemminger
From: Stephen Hemminger 

Update UIO documentation to include basic information about
uio_hv_generic.

Signed-off-by: Stephen Hemminger 
---
 Documentation/DocBook/uio-howto.tmpl | 62 
 1 file changed, 62 insertions(+)

diff --git a/Documentation/DocBook/uio-howto.tmpl 
b/Documentation/DocBook/uio-howto.tmpl
index cd0e452..5210f8a 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -46,6 +46,13 @@ GPL version 2.
 
 

+   0.10
+   2016-10-17
+   sch
+   Added generic hyperv driver
+   
+   
+   
0.9
2009-07-16
mst
@@ -1033,6 +1040,61 @@ int main()
 
 
 
+
+
+Generic Hyper-V UIO driver
+   
+   The generic driver is a kernel module named uio_hv_generic.
+   It supports devices on the Hyper-V VMBus similar to uio_pci_generic
+   on PCI bus.
+   
+
+
+Making the driver recognize the device
+   
+Since the driver does not declare any device GUID's, it will not get loaded
+automatically and will not automatically bind to any devices, you must load it
+and allocate id to the driver yourself. For example, to use the network device
+GUID:
+   
+ modprobe uio_hv_generic
+ echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" > 
/sys/bus/vmbus/drivers/uio_hv_generic/new_id
+   
+   
+   
+If there already is a hardware specific kernel driver for the device, the
+generic driver still won't bind to it, in this case if you want to use the
+generic driver (why would you?) you'll have to manually unbind the hardware
+specific driver and bind the generic driver, like this:
+   
+ echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 > 
/sys/bus/vmbus/drivers/hv_netvsc/unbind
+ echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 > 
/sys/bus/vmbus/drivers/uio_hv_generic/bind
+   
+   
+   
+You can verify that the device has been bound to the driver
+by looking for it in sysfs, for example like the following:
+   
+ls -l 
/sys/bus/vmbus/devices/vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
+   
+Which if successful should print
+   
+  .../vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -> 
../../../bus/vmbus/drivers/uio_hv_generic
+   
+   
+
+
+
+Things to know about uio_hv_generic
+   
+On each interrupt, uio_hv_generic sets the Interrupt Disable bit.
+This prevents the device from generating further interrupts
+until the bit is cleared. The userspace driver should clear this
+bit before blocking and waiting for more interrupts.
+   
+
+
+
 
 Further information
 
-- 
2.9.3




[PATCH v2 1/3] vmbus: add support for dynamic device id's

2016-10-17 Thread Stephen Hemminger
From: Stephen Hemminger 

This patch adds sysfs interface to dynamically bind new UUID values
to existing VMBus device. This is useful for generic UIO driver to
act similar to uio_pci_generic.

Signed-off-by: Stephen Hemminger 
---
v2 - allow device driver to have empty id table, and fix bugs

 drivers/hv/vmbus_drv.c | 174 ++---
 include/linux/hyperv.h |   6 ++
 2 files changed, 172 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index a259e18..d8d34bf 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -45,6 +45,11 @@
 #include 
 #include "hyperv_vmbus.h"
 
+struct vmbus_dynid {
+   struct list_head node;
+   struct hv_vmbus_device_id id;
+};
+
 static struct acpi_device  *hv_acpi_dev;
 
 static struct completion probe_event;
@@ -500,7 +505,7 @@ static ssize_t device_show(struct device *dev,
 static DEVICE_ATTR_RO(device);
 
 /* Set up per device attributes in /sys/bus/vmbus/devices/ */
-static struct attribute *vmbus_attrs[] = {
+static struct attribute *vmbus_dev_attrs[] = {
&dev_attr_id.attr,
&dev_attr_state.attr,
&dev_attr_monitor_id.attr,
@@ -528,7 +533,7 @@ static struct attribute *vmbus_attrs[] = {
&dev_attr_device.attr,
NULL,
 };
-ATTRIBUTE_GROUPS(vmbus);
+ATTRIBUTE_GROUPS(vmbus_dev);
 
 /*
  * vmbus_uevent - add uevent for our device
@@ -565,10 +570,29 @@ static inline bool is_null_guid(const uuid_le *guid)
  * Return a matching hv_vmbus_device_id pointer.
  * If there is no match, return NULL.
  */
-static const struct hv_vmbus_device_id *hv_vmbus_get_id(
-   const struct hv_vmbus_device_id *id,
+static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
const uuid_le *guid)
 {
+   const struct hv_vmbus_device_id *id = NULL;
+   struct vmbus_dynid *dynid;
+
+   /* Look at the dynamic ids first, before the static ones */
+   spin_lock(&drv->dynids.lock);
+   list_for_each_entry(dynid, &drv->dynids.list, node) {
+   if (!uuid_le_cmp(dynid->id.guid, *guid)) {
+   id = &dynid->id;
+   break;
+   }
+   }
+   spin_unlock(&drv->dynids.lock);
+
+   if (id)
+   return id;
+
+   id = drv->id_table;
+   if (id == NULL)
+   return NULL; /* empty device table */
+
for (; !is_null_guid(&id->guid); id++)
if (!uuid_le_cmp(id->guid, *guid))
return id;
@@ -576,6 +600,134 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(
return NULL;
 }
 
+/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */
+static int vmbus_add_dynid(struct hv_driver *drv, uuid_le *guid)
+{
+   struct vmbus_dynid *dynid;
+
+   dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
+   if (!dynid)
+   return -ENOMEM;
+
+   dynid->id.guid = *guid;
+
+   spin_lock(&drv->dynids.lock);
+   list_add_tail(&dynid->node, &drv->dynids.list);
+   spin_unlock(&drv->dynids.lock);
+
+   return driver_attach(&drv->driver);
+}
+
+static void vmbus_free_dynids(struct hv_driver *drv)
+{
+   struct vmbus_dynid *dynid, *n;
+
+   spin_lock(&drv->dynids.lock);
+   list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
+   list_del(&dynid->node);
+   kfree(dynid);
+   }
+   spin_unlock(&drv->dynids.lock);
+}
+
+/* Parse string of form: 1b4e28ba-2fa1-11d2-883f-b9a761bde3f */
+static int get_uuid_le(const char *str, uuid_le *uu)
+{
+   unsigned int b[16];
+   int i;
+
+   if (strlen(str) < 37)
+   return -1;
+
+   for (i = 0; i < 36; i++) {
+   switch (i) {
+   case 8: case 13: case 18: case 23:
+   if (str[i] != '-')
+   return -1;
+   break;
+   default:
+   if (!isxdigit(str[i]))
+   return -1;
+   }
+   }
+
+   /* unparse little endian output byte order */
+   if (sscanf(str,
+  "%2x%2x%2x%2x-%2x%2x-%2x%2x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+  &b[3], &b[2], &b[1], &b[0],
+  &b[5], &b[4], &b[7], &b[6], &b[8], &b[9],
+  &b[10], &b[11], &b[12], &b[13], &b[14], &b[15]) != 16)
+   return -1;
+
+   for (i = 0; i < 16; i++)
+   uu->b[i] = b[i];
+   return 0;
+}
+
+/*
+ * store_new_id - sysfs frontend to vmbus_add_dynid()
+ *
+ * Allow GUIDs to be added to an existing driver via sysfs.
+ */
+static ssize_t store_new_id(struct device_driver *driver, const char *buf,
+   size_t count)
+{
+   struct hv_driver *drv = drv_to_hv_drv(driver);
+   uuid_le guid = NULL_UUID_LE;
+   ssize_t retval;
+
+   if (get_uu

[git pull] FireWire (IEEE 1394) fixlet

2016-10-17 Thread Stefan Richter
Linus,

please pull from the tag "firewire-update" at

git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git 
firewire-update

to receive the following IEEE 1394 subsystem patch:
  - catch an initialization error in the packet sniffer nosy

Alexey Khoroshilov (1):
  firewire: nosy: do not ignore errors in ioremap_nocache()

 drivers/firewire/nosy.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Thanks.
-- 
Stefan Richter
-==- =-=- =---=
http://arcgraph.de/sr/


[PATCH v2 2/3] uio-hv-generic: new userspace i/o driver for VMBus

2016-10-17 Thread Stephen Hemminger
From: Stephen Hemminger 

This is a new driver to enable userspace networking on VMBus.
It is based largely on the similar driver that already exists
for PCI, and earlier work done by Brocade to support DPDK.

Signed-off-by: Stephen Hemminger 
---
v2 - put in UIO not staging
 rename to uio-hv-generic (since it is like uio-pci-generic)
 add example to comment

 drivers/hv/connection.c  |   1 +
 drivers/uio/Kconfig  |   9 ++
 drivers/uio/Makefile |   1 +
 drivers/uio/uio_hv_generic.c | 216 +++
 4 files changed, 227 insertions(+)
 create mode 100644 drivers/uio/uio_hv_generic.c

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 78e6368..6ce8b87 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -39,6 +39,7 @@ struct vmbus_connection vmbus_connection = {
.conn_state = DISCONNECTED,
.next_gpadl_handle  = ATOMIC_INIT(0xE1E10),
 };
+EXPORT_SYMBOL_GPL(vmbus_connection);
 
 /*
  * Negotiated protocol version with the host.
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 52c98ce..7e8dc78 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -155,4 +155,13 @@ config UIO_MF624
 
  If you compile this as a module, it will be called uio_mf624.
 
+config UIO_HV_GENERIC
+   tristate "Generic driver for Hyper-V VMBus"
+   depends on HYPERV
+   help
+ Generic driver that you can bind, dynamically, to any
+ Hyper-V VMBus device. It is useful to provide direct access
+ to network and storage devices from userspace.
+
+ If you compile this as a module, it will be called uio_hv_generic.
 endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 8560dad..e9663bb 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_UIO_NETX)  += uio_netx.o
 obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o
 obj-$(CONFIG_UIO_MF624) += uio_mf624.o
 obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o
+obj-$(CONFIG_UIO_HV_GENERIC)   += uio_hv_generic.o
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
new file mode 100644
index 000..66ea574
--- /dev/null
+++ b/drivers/uio/uio_hv_generic.c
@@ -0,0 +1,216 @@
+/*
+ * uio_hv_generic - generic UIO driver for VMBus
+ *
+ * Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+ * Copyright (c) 2016, Microsoft Corporation.
+ *
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ *
+ * Since the driver does not declare any device ids, you must allocate
+ * id and bind the device to the driver yourself.  For example:
+ *
+ * # echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" \
+ *> /sys/bus/vmbus/drivers/uio_hv_generic
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *> /sys/bus/vmbus/drivers/hv_netvsc/unbind
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *> /sys/bus/vmbus/drivers/uio_hv_generic/bind
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../hv/hyperv_vmbus.h"
+
+#define DRIVER_VERSION "0.02.0"
+#define DRIVER_AUTHOR  "Stephen Hemminger "
+#define DRIVER_DESC"Generic UIO driver for VMBus devices"
+
+/*
+ * List of resources to be mapped to user space
+ * can be extended up to MAX_UIO_MAPS(5) items
+ */
+enum hv_uio_map {
+   TXRX_RING_MAP = 0,
+   INT_PAGE_MAP,
+   MON_PAGE_MAP,
+};
+
+#define HV_RING_SIZE   512
+
+struct hv_uio_private_data {
+   struct uio_info info;
+   struct hv_device *device;
+};
+
+static int
+hv_uio_mmap(struct uio_info *info, struct vm_area_struct *vma)
+{
+   int mi;
+
+   if (vma->vm_pgoff >= MAX_UIO_MAPS)
+   return -EINVAL;
+
+   if (info->mem[vma->vm_pgoff].size == 0)
+   return -EINVAL;
+
+   mi = (int)vma->vm_pgoff;
+
+   return remap_pfn_range(vma, vma->vm_start,
+  virt_to_phys((void *)info->mem[mi].addr) >> 
PAGE_SHIFT,
+  vma->vm_end - vma->vm_start, vma->vm_page_prot);
+}
+
+/*
+ * This is the irqcontrol callback to be registered to uio_info.
+ * It can be used to disable/enable interrupt from user space processes.
+ *
+ * @param info
+ *  pointer to uio_info.
+ * @param irq_state
+ *  state value. 1 to enable interrupt, 0 to disable interrupt.
+ */
+static int
+hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
+{
+   struct hv_uio_private_data *pdata = info->priv;
+   struct hv_device *dev = pdata->device;
+
+   dev->channel->inbound.ring_buffer->interrupt_mask = !irq_state;
+   virt_mb();
+
+   return 0;
+}
+
+/*
+ * Callback from vmbus_event when something is in inbound ring.
+ */
+static void hv_uio_channel_cb(void *context)
+{
+   struct hv_uio_private_data *pdata = context;
+   struct hv_device *dev = pdata->device;
+
+

Re: [PATCH v4 11/18] x86/intel_rdt: Add basic resctrl filesystem support

2016-10-17 Thread Thomas Gleixner
On Fri, 14 Oct 2016, Fenghua Yu wrote:
> +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
> + *
> + * More information about RDT be found in the Intel (R) x86 Architecture
> + * Software Developer Manual.

Yes, that's how it should look like.

> +static void l3_qos_cfg_update(void *arg)
> +{
> + struct rdt_resource *r = arg;
> +
> + wrmsrl(IA32_L3_QOS_CFG, r->cdp_enabled);
> +}
> +
> +static void set_l3_qos_cfg(struct rdt_resource *r)
> +{
> + struct list_head *l;
> + struct rdt_domain *d;
> + struct cpumask cpu_mask;

You cannot have cpumasks on stack.

cpumask_var_t mask;

if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
return -ENOMEM;


> + int cpu;
> +
> + cpumask_clear(&cpu_mask);

That can go away then

> + list_for_each(l, &r->domains) {

list_for_each_entry() again

> + d = list_entry(l, struct rdt_domain, list);
> + cpumask_set_cpu(cpumask_any(&d->cpu_mask), &cpu_mask);

A comment to explain what this does would be helpful.

> + }
> + cpu = get_cpu();
> + /* Update QOS_CFG MSR on this cpu if it's in cpu_mask. */
> + if (cpumask_test_cpu(cpu, &cpu_mask))
> + l3_qos_cfg_update(r);
> + /* Update QOS_CFG MSR on all other cpus in cpu_mask. */
> + smp_call_function_many(&cpu_mask, l3_qos_cfg_update, r, 1);
> + put_cpu();
> +}
> +
> +static int parse_rdtgroupfs_options(char *data)
> +{
> + char *token, *o = data;
> + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3];
> +
> + r->cdp_enabled = false;
> + while ((token = strsep(&o, ",")) != NULL) {
> + if (!*token)
> + return -EINVAL;
> +
> + if (!strcmp(token, "cdp"))
> + if (r->enabled && r->cdp_capable)
> + r->cdp_enabled = true;
> + }
> +
> + return 0;
> +}
> +
> +static struct dentry *rdt_mount(struct file_system_type *fs_type,
> + int flags, const char *unused_dev_name,
> + void *data)
> +{
> + struct dentry *dentry;
> + int ret;
> + bool new_sb;
> +
> + mutex_lock(&rdtgroup_mutex);
> + /*
> +  * resctrl file system can only be mounted once.
> +  */
> + if (static_branch_unlikely(&rdt_enable_key)) {
> + dentry = ERR_PTR(-EBUSY);
> + goto out;
> + }
> +
> + ret = parse_rdtgroupfs_options(data);
> + if (ret) {
> + dentry = ERR_PTR(ret);
> + goto out;
> + }
> +
> + dentry = kernfs_mount(fs_type, flags, rdt_root,
> +   RDTGROUP_SUPER_MAGIC, &new_sb);

&new_sb is pointless here. It just tells the caller that a new superblock
has been created, So in case of a valid dentry new_sb will always be true,
and if anything failed in kernfs_mount() including the allocation of a new
superblock then new_sb is completely irrelevant as IS_ERR(dentry) will be
true. So you can just hand in NULL because you do not allow multiple
mounts.

> + if (IS_ERR(dentry))
> + goto out;
> + if (!new_sb) {
> + dentry = ERR_PTR(-EINVAL);
> + goto out;
> + }
> + if (rdt_resources_all[RDT_RESOURCE_L3].cdp_capable)
> + set_l3_qos_cfg(&rdt_resources_all[RDT_RESOURCE_L3]);
> + static_branch_enable(&rdt_enable_key);
> +
> +out:
> + mutex_unlock(&rdtgroup_mutex);
> +
> + return dentry;
> +}
> +
> +static void reset_all_cbms(struct rdt_resource *r)
> +{
> + struct list_head *l;
> + struct rdt_domain *d;
> + struct msr_param msr_param;
> + struct cpumask cpu_mask;
> + int i, cpu;
> +
> + cpumask_clear(&cpu_mask);
> + msr_param.res = r;
> + msr_param.low = 0;
> + msr_param.high = r->max_closid;
> +
> + list_for_each(l, &r->domains) {
> + d = list_entry(l, struct rdt_domain, list);

list_for_each_entry()

> + cpumask_set_cpu(cpumask_any(&d->cpu_mask), &cpu_mask);
> +
> + for (i = 0; i < r->max_closid; i++)
> + d->cbm[i] = r->max_cbm;
> + }
> + cpu = get_cpu();
> + /* Update CBM on this cpu if it's in cpu_mask. */
> + if (cpumask_test_cpu(cpu, &cpu_mask))
> + rdt_cbm_update(&msr_param);
> + /* Updte CBM on all other cpus in cpu_mask. */

Update

> + smp_call_function_many(&cpu_mask, rdt_cbm_update, &msr_param, 1);
> + put_cpu();
> +}
> +

Thanks,

tglx


[PATCH] hwrng: meson: Fix module autoload for OF registration

2016-10-17 Thread Javier Martinez Canillas
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/char/hw_random/meson-rng.ko | grep alias
alias:  platform:meson-rng

After this patch:

$ modinfo drivers/char/hw_random/meson-rng.ko | grep alias
alias:  platform:meson-rng
alias:  of:N*T*Camlogic,meson-rngC*
alias:  of:N*T*Camlogic,meson-rng

Signed-off-by: Javier Martinez Canillas 
---

 drivers/char/hw_random/meson-rng.c | 1 +
 drivers/char/tpm/Kconfig   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/meson-rng.c 
b/drivers/char/hw_random/meson-rng.c
index 58bef39f7286..51864a509be7 100644
--- a/drivers/char/hw_random/meson-rng.c
+++ b/drivers/char/hw_random/meson-rng.c
@@ -110,6 +110,7 @@ static const struct of_device_id meson_rng_of_match[] = {
{ .compatible = "amlogic,meson-rng", },
{},
 };
+MODULE_DEVICE_TABLE(of, meson_rng_of_match);
 
 static struct platform_driver meson_rng_driver = {
.probe  = meson_rng_probe,
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index 9faa0b1e7766..982ed2fe927c 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -32,7 +32,7 @@ config TCG_TIS_CORE
 
 config TCG_TIS
tristate "TPM Interface Specification 1.2 Interface / TPM 2.0 FIFO 
Interface"
-   depends on X86
+   depends on X86 || COMPILE_TEST
select TCG_TIS_CORE
---help---
  If you have a TPM security chip that is compliant with the
-- 
2.7.4



Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

2016-10-17 Thread Jeff Moyer
Christoph Hellwig  writes:

> On Mon, Oct 17, 2016 at 02:19:47PM -0400, Jeff Moyer wrote:
>> This ends up being a call to __sb_end_write:
>> 
>> void __sb_end_write(struct super_block *sb, int level)
>> {
>> percpu_up_read(sb->s_writers.rw_sem + level-1);
>> }
>> 
>> Nothing guarantees that submission and completion happen on the same
>> CPU.  Is this safe?
>
> Good point.  From my reading of the percpu_rwsem implementation it
> is not safe to release it from a different CPU.  Which makes me
> wonder how we can protect aio writes properly here..

Could we just change percpu_rw_semaphore->read_count to be a signed
integer?  The down_write path sums up the counters from all cpus...

-Jeff


Re: [PATCH v8 1/2] ARM: dts: Add TOPEET itop core board SCP package version

2016-10-17 Thread Krzysztof Kozlowski
On Tue, Oct 18, 2016 at 01:57:47AM +0800, ayaka wrote:
> 
> 
> On 10/18/2016 12:27 AM, Krzysztof Kozlowski wrote:
> >On Mon, Sep 19, 2016 at 11:48:22PM +0800, Randy Li wrote:
> >>The TOPEET itop is a samsung exnynos 4412 core board, which have
> >>two package versions. This patch add the support for SCP version.
> >>
> >>Currently supported are USB3503A HSIC, USB OTG, eMMC, rtc and
> >>PMIC. The future features are in the based board. Also MFC and
> >>watchdog have been enabled.
> >>
> >>Signed-off-by: Randy Li 
> >>---
> >>  arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi | 501 
> >> 
> >>  1 file changed, 501 insertions(+)
> >>  create mode 100644 arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi
> >I wanted to apply it... but then I saw a bunch of checkpatch trivial issues.
> >Really, after v8? The code must compile (v6 did not compile...), there
> >should be no warnings from smatch, sparse and checkpatch (only the last
> >one is applicable for DTS). Unless of course checkpatch would be
> >wrong... but in this case it is correct. You did not follow coding
> >style:
> >
> >WARNING: please, no spaces at the start of a line
> >#134: FILE: arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi:109:
> >+devfreq = <&bus_leftbus>;$
> >
> >ERROR: code indent should use tabs where possible
> >#135: FILE: arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi:110:
> >+status = "okay";$
> Oh, it is a copy mistake, the copy operation makes the original tab becomes
> spaces.
> Should I send a new version to correct them?

Yes, please send new version. The DTS (code) itself looked fine, so only
the checkpatch issues are remaining.

BTW, why are you copying the files? Even if you have multiple trees
(like product/vendor kernel and mainline) then you can easily move
patches with cherry-pick, apply or am commands. Then finally just 'git
format-patch -2 -v9' and 'git send-email'.

Best regards,
Krzysztof


[PATCH 0/5] staging/vchi: Start on 64-bit cleanup, TODO file.

2016-10-17 Thread Eric Anholt
Here's a little cleanup of VCHI this morning, working toward building
on aarch64 (not there yet) and adding some notes on what I think we
need to do with the driver.

Eric Anholt (5):
  staging/vchi: Fix build error in debugfs ops on aarch64.
  staging/vchi: Fix build warnings when formatting pointers on aarch64.
  staging/vchi: Fix some pointer math for 64-bit.
  staging/vchi: Add a TODO file of things I know we need to deal with.
  MAINTAINERS: Add the staging vchiq driver as a bcm2835 responsibility.

 MAINTAINERS|   1 +
 drivers/staging/vc04_services/interface/vchi/TODO  |  50 ++
 .../interface/vchiq_arm/vchiq_2835_arm.c   |  15 +-
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |  32 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_core.c | 183 +++--
 .../interface/vchiq_arm/vchiq_debugfs.c|   4 +-
 6 files changed, 168 insertions(+), 117 deletions(-)
 create mode 100644 drivers/staging/vc04_services/interface/vchi/TODO

-- 
2.9.3



Re: Build failure with v4.9-rc1 and GCC trunk -- compiler weirdness

2016-10-17 Thread Ard Biesheuvel
On 17 October 2016 at 19:38, Will Deacon  wrote:
> Hi all,
>
> I'm seeing an arm64 build failure with -rc1 and GCC trunk, although I
> believe that the new compiler behaviour at the heart of the problem
> has the potential to affect other architectures and other pieces of
> kernel code relying on dead-code elimination to remove deliberately
> undefined functions.
>
> The failure looks like:
>
>   | drivers/built-in.o: In function `armada_3700_add_composite_clk':
>   |
>   | linux/drivers/clk/mvebu/armada-37xx-periph.c:351:
>   | undefined reference to `ilog2_NaN'
>   |
>   | linux/drivers/clk/mvebu/armada-37xx-periph.c:351:(.text+0xc72e0):
>   | relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol
>   | `ilog2_NaN'
>   |
>   | make: *** [vmlinux] Error 1
>
> and if we look at the source for armada_3700_add_composite_clk, we see
> that this is caused by:
>
>   int table_size = 0;
>
>   rate->reg = reg + (u64)rate->reg;
>   for (clkt = rate->table; clkt->div; clkt++)
>  table_size++;
>   rate->width = order_base_2(table_size);
>
> order_base_2 calls ilog2, which has the ilog2_NaN call:
>
> #define ilog2(n)\
> (   \
> __builtin_constant_p(n) ? ( \
> (n) < 1 ? ilog2_NaN() : \
>
> This is because we're in a curious case where GCC has emitted a
> special-cased version of armada_3700_add_composite_clk, with table_size
> effectively constant-folded as 0. Whilst we shouldn't see this in a
> non-buggy kernel (hence the deliberate call to the undefined function
> ilog2_NaN), it means that the final link fails because we have a
> ilog2_NaN in the code, with a runtime check on table_size.
>

This is indeed an unintended side effect, but I would not call it
weird behaviour at all. The code in its current form does not handle
the case where it could end up passing 0 into order_base_2(), and we
simply need to handle that case. If order_base_2() is not defined for
input 0, it should BUG() in that case, and the associated
__builtin_unreachable() should prevent the special version from being
emitted. If order_base_2() is defined for input 0, it should not
invoke ilog2() with that argument, and the problem should go away as
well.

-- 
Ard.


> In other words, __builtin_constant_p appears to be weaker than we've
> been assuming. Talking to the compiler guys here, this is due to the
> "jump-threading" optimisation pass, so the patch below disables that.
>
> A simpler example is:
>
> int foo();
> int bar();
>
> int count(int *argc)
> {
> int table_size = 0;
>
> for (; *argc; argc++)
> table_size++;
>
> if (__builtin_constant_p(table_size))
> return table_size == 0 ? foo() : bar();
>
> return bar();
> }
>
> which compiles to:
>
> count:
> ldr w0, [x0]
> cbz w0, .L4
> b   bar
> .p2align 3
> .L4:
> b   foo
>
> and, with the "optimisation" disabled:
>
> count:
> b   bar
>
> Thoughts? It feels awfully fragile disabling passes like this, but with
> GCC transforming the code like this, I can't immediately think of a way
> to preserve the intended behaviour of the code.
>
> Will
>
> --->8
>
> diff --git a/Makefile b/Makefile
> index 512e47a53e9a..750873d6d11e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -641,6 +641,11 @@ endif
>  # Tell gcc to never replace conditional load with a non-conditional one
>  KBUILD_CFLAGS  += $(call cc-option,--param=allow-store-data-races=0)
>
> +# Stop gcc from converting switches into a form that defeats dead code
> +# elimination and can subsequently lead to calls to intentionally
> +# undefined functions appearing in the final link.
> +KBUILD_CFLAGS  += $(call cc-option,--param=max-fsm-thread-path-insns=1)
> +
>  include scripts/Makefile.gcc-plugins
>
>  ifdef CONFIG_READABLE_ASM


[PATCH 1/5] staging/vchi: Fix build error in debugfs ops on aarch64.

2016-10-17 Thread Eric Anholt
file_operations.write returns a ssize_t, which worked out fine on 32
bit but errors out on 64 bit.

Signed-off-by: Eric Anholt 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 7e032130d967..f07cd4448ddf 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -120,7 +120,7 @@ static int debugfs_log_open(struct inode *inode, struct 
file *file)
return single_open(file, debugfs_log_show, inode->i_private);
 }
 
-static int debugfs_log_write(struct file *file,
+static ssize_t debugfs_log_write(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
 {
@@ -229,7 +229,7 @@ static int debugfs_trace_open(struct inode *inode, struct 
file *file)
return single_open(file, debugfs_trace_show, inode->i_private);
 }
 
-static int debugfs_trace_write(struct file *file,
+static ssize_t debugfs_trace_write(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
 {
-- 
2.9.3



Re: [PATCH] hwrng: meson: Fix module autoload for OF registration

2016-10-17 Thread Javier Martinez Canillas
Hello Jason,

On 10/17/2016 04:45 PM, Jason Gunthorpe wrote:
> On Mon, Oct 17, 2016 at 04:40:14PM -0300, Javier Martinez Canillas wrote:
> 
>> Signed-off-by: Javier Martinez Canillas 
>>
>>  drivers/char/hw_random/meson-rng.c | 1 +
>>  drivers/char/tpm/Kconfig   | 2 +-
> 
> Looks like this patch should not have tpm in it.
>

Argh, yes. I had some unrelated changes in my staging area and did a
commit by mistake. Thanks a lot for pointing out and sorry for that.

I'll post a v2 without this.

> Jason
> 

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America


exynos-drm: display manager fails to start without IOMMU problem

2016-10-17 Thread Shuah Khan
Restarting the thread with a different subject line:

I haven't given up on this yet. I am still seeing the following failure:

Additional debug messages I added:
[   15.287403] exynos_drm_gem_create_ioctl() 1
[   15.287419] exynos_drm_gem_create() flags 1

[   15.311511] [drm:exynos_drm_framebuffer_init] *ERROR* Non-contiguous GEM 
memory is not supported.

Additional debug message I added:
[   15.318981] [drm:exynos_user_fb_create] *ERROR* failed to initialize 
framebuffer

This is what happens:

1. exynos_drm_gem_create_ioctl() gets called with EXYNOS_BO_NONCONTIG request
2. exynos_drm_gem_create(0 goes ahead and creates the GEM buffers
3. exynos_user_fb_create() tries to associate GEM to fb and fails during
   check_fb_gem_memory_type()

At this point, there is no recovery and lightdm fails

xf86-video-armsoc/src/drmmode_exynos/drmmode_exynos.c assumes contiguous
allocations are not supported in some exynos drm versions: The following
commit introduced this change:

https://git.linaro.org/arm/xorg/driver/xf86-video-armsoc.git/commitdiff/3be1f6273441fe95dd442f44064387322e16b7e9

excerpts from the diff:-   if (create_gem->buf_type == ARMSOC_BO_SCANOUT)
-   create_exynos.flags = EXYNOS_BO_CONTIG;
-   else
-   create_exynos.flags = EXYNOS_BO_NONCONTIG;
+
+   /* Contiguous allocations are not supported in some exynos drm versions.
+* When they are supported all allocations are effectively contiguous
+* anyway, so for simplicity we always request non contiguous buffers.
+*/
+   create_exynos.flags = EXYNOS_BO_NONCONTIG;

There might have been logic on exynos_drm that forced Contig when it coudn't
support NONCONTIG. At least, that is what this comment suggests. This assumption
doesn't appear to be a good one and not sure if this change was made to fix a 
bug.

After the IOMMU support, this assumption is no longer true. Hence, with IOMMU
support, latest kernels have a mismatch with the installed xf86-video-armsoc

This is what I am running into. This leads to the following question:

1. How do we ensure exynos_drm kernel changes don't break user-space
   specifically xf86-video-armsoc
2. This seems to have gone undetected for a while. I see a change in
   exynos_drm_gem_dumb_create() that is probably addressing this type
   of breakage. Commit 122beea84bb90236b1ae545f08267af58591c21b adds
   handling for IOMMU NONCONTIG case.

Anyway, I am interested in getting the exynos_drm kernel side code
and xf86-video-armsoc in sync to resolve the issue.

Could you recommend a going forward plan?

I can submit a patch to xf86-video-armsoc. I am also looking ahead to
see if we can avoid such breaks in the future by keeping kernel and
xf86-video-armsoc in sync.

thanks,
-- Shuah



[PATCH v3 2/4] net: smc91x: isolate u16 writes alignment workaround

2016-10-17 Thread Robert Jarzmik
Writes to u16 has a special handling on 3 PXA platforms, where the
hardware wiring forces these writes to be u32 aligned.

This patch isolates this handling for PXA platforms as before, but
enables this "workaround" to be set up dynamically, which will be the
case in device-tree build types.

This patch was tested on 2 PXA platforms : mainstone, which relies on
the workaround, and lubbock, which doesn't.

Signed-off-by: Robert Jarzmik 
--
Since v2: fixed arch/mn10300 case
  removed machine_is_*() calls
---
 arch/mn10300/unit-asb2303/include/unit/smc9.h |  2 +-
 drivers/net/ethernet/smsc/smc91x.c|  3 +-
 drivers/net/ethernet/smsc/smc91x.h| 82 ---
 3 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/arch/mn10300/unit-asb2303/include/unit/smc9.h 
b/arch/mn10300/unit-asb2303/include/unit/smc9.h
index dd456e9c513f..dd4e2946438e 100644
--- a/arch/mn10300/unit-asb2303/include/unit/smc9.h
+++ b/arch/mn10300/unit-asb2303/include/unit/smc9.h
@@ -30,7 +30,7 @@
 
 #if SMC_CAN_USE_16BIT
 #define SMC_inw(a, r)  inw((unsigned long) ((a) + (r)))
-#define SMC_outw(v, a, r)  outw(v, (unsigned long) ((a) + (r)))
+#define SMC_outw(lp, v, a, r)  outw(v, (unsigned long) ((a) + (r)))
 #define SMC_insw(a, r, p, l)   insw((unsigned long) ((a) + (r)), (p), (l))
 #define SMC_outsw(a, r, p, l)  outsw((unsigned long) ((a) + (r)), (p), (l))
 #endif
diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 9b4780f87863..705d99b2d947 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -602,7 +602,8 @@ static void smc_hardware_send_pkt(unsigned long data)
SMC_PUSH_DATA(lp, buf, len & ~1);
 
/* Send final ctl word with the last byte if there is one */
-   SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG(lp));
+   SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len - 1]) : 0), ioaddr,
+DATA_REG(lp));
 
/*
 * If THROTTLE_TX_PKTS is set, we stop the queue here. This will
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index ea8465467469..45e6b81a6a92 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -63,8 +63,6 @@
 
 #if defined(CONFIG_ARM)
 
-#include 
-
 /* Now the bus width is specified in the platform data
  * pretend here to support all I/O access types
  */
@@ -86,11 +84,11 @@
 
 #define SMC_inl(a, r)  readl((a) + (r))
 #define SMC_outb(v, a, r)  writeb(v, (a) + (r))
-#define SMC_outw(v, a, r)  \
+#define SMC_outw(lp, v, a, r)  \
do {\
unsigned int __v = v, __smc_r = r;  \
if (SMC_16BIT(lp))  \
-   __SMC_outw(__v, a, __smc_r);\
+   __SMC_outw(lp, __v, a, __smc_r);\
else if (SMC_8BIT(lp))  \
SMC_outw_b(__v, a, __smc_r);\
else\
@@ -107,10 +105,10 @@
 #define SMC_IRQ_FLAGS  (-1)/* from resource */
 
 /* We actually can't write halfwords properly if not word aligned */
-static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg)
+static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
+   bool use_align4_workaround)
 {
-   if ((machine_is_mainstone() || machine_is_stargate2() ||
-machine_is_pxa_idp()) && reg & 2) {
+   if (use_align4_workaround) {
unsigned int v = val << 16;
v |= readl(ioaddr + (reg & ~2)) & 0x;
writel(v, ioaddr + (reg & ~2));
@@ -119,6 +117,12 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
}
 }
 
+#define __SMC_outw(lp, v, a, r)
\
+   _SMC_outw_align4((v), (a), (r), \
+IS_BUILTIN(CONFIG_ARCH_PXA) && ((r) & 2) &&\
+(lp)->cfg.pxa_u16_align4)
+
+
 #elif  defined(CONFIG_SH_SH4202_MICRODEV)
 
 #define SMC_CAN_USE_8BIT   0
@@ -129,7 +133,7 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
 #define SMC_inw(a, r)  inw((a) + (r) - 0xa000)
 #define SMC_inl(a, r)  inl((a) + (r) - 0xa000)
 #define SMC_outb(v, a, r)  outb(v, (a) + (r) - 0xa000)
-#define SMC_outw(v, a, r)  outw(v, (a) + (r) - 0xa000)
+#define SMC_outw(lp, v, a, r)  outw(v, (a) + (r) - 0xa000)
 #define SMC_outl(v, a, r)  outl(v, (a) + (r) - 0xa000)
 #define SMC_insl(a, r, p, l)   insl

Re: [PATCH v4 12/18] x86/intel_rdt: Add "info" files to resctrl file system

2016-10-17 Thread Thomas Gleixner
On Fri, 14 Oct 2016, Fenghua Yu wrote:
>  static int __init rdtgroup_setup_root(void)
>  {
> + int ret;
> +
>   rdt_root = kernfs_create_root(&rdtgroup_kf_syscall_ops,
> KERNFS_ROOT_CREATE_DEACTIVATED,
> &rdtgroup_default);
> @@ -193,7 +364,9 @@ static int __init rdtgroup_setup_root(void)
>   list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups);
>  
>   rdtgroup_default.kn = rdt_root->kn;
> - kernfs_activate(rdtgroup_default.kn);
> + ret = rdtgroup_create_info_dir(rdtgroup_default.kn);
> + if (!ret)
> + kernfs_activate(rdtgroup_default.kn);
>  
>   mutex_unlock(&rdtgroup_mutex);

So this is followed by:

return 0;

which means that an error in rdtgroup_create_info_dir() is ignored. As a
consequence the mount point is created and the file system is registered
w/o the info directory

Thanks,

tglx


[PATCH v2] hwrng: meson: Fix module autoload for OF registration

2016-10-17 Thread Javier Martinez Canillas
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/char/hw_random/meson-rng.ko | grep alias
alias:  platform:meson-rng

After this patch:

$ modinfo drivers/char/hw_random/meson-rng.ko | grep alias
alias:  platform:meson-rng
alias:  of:N*T*Camlogic,meson-rngC*
alias:  of:N*T*Camlogic,meson-rng

Signed-off-by: Javier Martinez Canillas 

---

Changes in v2:
- Remove unrelated changes added by mistake. Suggested by Jason Gunthorpe.

 drivers/char/hw_random/meson-rng.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/hw_random/meson-rng.c 
b/drivers/char/hw_random/meson-rng.c
index 58bef39f7286..51864a509be7 100644
--- a/drivers/char/hw_random/meson-rng.c
+++ b/drivers/char/hw_random/meson-rng.c
@@ -110,6 +110,7 @@ static const struct of_device_id meson_rng_of_match[] = {
{ .compatible = "amlogic,meson-rng", },
{},
 };
+MODULE_DEVICE_TABLE(of, meson_rng_of_match);
 
 static struct platform_driver meson_rng_driver = {
.probe  = meson_rng_probe,
-- 
2.7.4



Re: [PATCH] hwrng: meson: Fix module autoload for OF registration

2016-10-17 Thread Jason Gunthorpe
On Mon, Oct 17, 2016 at 04:40:14PM -0300, Javier Martinez Canillas wrote:

> Signed-off-by: Javier Martinez Canillas 
> 
>  drivers/char/hw_random/meson-rng.c | 1 +
>  drivers/char/tpm/Kconfig   | 2 +-

Looks like this patch should not have tpm in it.

Jason


[PATCH 3/5] staging/vchi: Fix some pointer math for 64-bit.

2016-10-17 Thread Eric Anholt
These were throwing warnings on aarch64, and all are trivially
converted to longs.

Signed-off-by: Eric Anholt 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 6 +++---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index c5255bc6c589..3c7165b34dab 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -121,7 +121,7 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
return -ENOMEM;
}
 
-   WARN_ON(((int)slot_mem & (PAGE_SIZE - 1)) != 0);
+   WARN_ON(((unsigned long)slot_mem & (PAGE_SIZE - 1)) != 0);
 
vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size);
if (!vchiq_slot_zero)
@@ -222,7 +222,7 @@ remote_event_signal(REMOTE_EVENT_T *event)
 int
 vchiq_copy_from_user(void *dst, const void *src, int size)
 {
-   if ((uint32_t)src < TASK_SIZE) {
+   if ((unsigned long)src < TASK_SIZE) {
return copy_from_user(dst, src, size);
} else {
memcpy(dst, src, size);
@@ -375,7 +375,7 @@ create_pagelist(char __user *buf, size_t count, unsigned 
short type,
int run, addridx, actual_pages;
 unsigned long *need_release;
 
-   offset = (unsigned int)buf & (PAGE_SIZE - 1);
+   offset = (unsigned long)buf & (PAGE_SIZE - 1);
num_pages = (count + offset + PAGE_SIZE - 1) / PAGE_SIZE;
 
*ppagelist = NULL;
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 93a6ac75791f..6862cbc0d7a9 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1723,7 +1723,7 @@ parse_rx_slots(VCHIQ_STATE_T *state)
min(64, size));
}
 
-   if (((unsigned int)header & VCHIQ_SLOT_MASK) + calc_stride(size)
+   if (((unsigned long)header & VCHIQ_SLOT_MASK) + 
calc_stride(size)
> VCHIQ_SLOT_SIZE) {
vchiq_log_error(vchiq_core_log_level,
"header %p (msgid %x) - size %x too big for "
@@ -2268,7 +2268,8 @@ get_conn_state_name(VCHIQ_CONNSTATE_T conn_state)
 VCHIQ_SLOT_ZERO_T *
 vchiq_init_slots(void *mem_base, int mem_size)
 {
-   int mem_align = (VCHIQ_SLOT_SIZE - (int)mem_base) & VCHIQ_SLOT_MASK;
+   int mem_align = (VCHIQ_SLOT_SIZE -
+(unsigned long)mem_base) & VCHIQ_SLOT_MASK;
VCHIQ_SLOT_ZERO_T *slot_zero =
(VCHIQ_SLOT_ZERO_T *)((char *)mem_base + mem_align);
int num_slots = (mem_size - mem_align)/VCHIQ_SLOT_SIZE;
-- 
2.9.3



[PATCH v3 0/4] support smc91x on mainstone and devicetree

2016-10-17 Thread Robert Jarzmik
This serie aims at bringing support to mainstone board on a device-tree based
build, as what is already in place for legacy mainstone.

The bulk of the mainstone "specific" behavior is that a u16 write doesn't work
on a address of the form 4*n + 2, while it works on 4*n.

The legacy workaround was in SMC_outw(), with calls to
machine_is_mainstone(). These calls don't work with a pxa27x-dt machine type,
which is used when a generic device-tree pxa27x machine is used to boot the
mainstone board.

Therefore, this serie enables the smc91c111 adapter of the mainstone board to
work on a device-tree build, exaclty as it's been working for years with the
legacy arch/arm/mach-pxa/mainstone.c definition.

As a sum up, this extends an existing mechanism to device-tree based pxa 
platforms.

Cheers.

--
Robert

Robert Jarzmik (4):
  ARM: pxa: enhance smc91x platform data
  net: smc91x: isolate u16 writes alignment workaround
  net: smc91x: take into account half-word workaround
  net: smsc91x: add u16 workaround for pxa platforms

 .../devicetree/bindings/net/smsc-lan91c111.txt |  2 +
 arch/arm/mach-pxa/idp.c|  1 +
 arch/arm/mach-pxa/mainstone.c  |  1 +
 arch/arm/mach-pxa/stargate2.c  |  1 +
 arch/mn10300/unit-asb2303/include/unit/smc9.h  |  2 +-
 drivers/net/ethernet/smsc/smc91x.c |  5 +-
 drivers/net/ethernet/smsc/smc91x.h | 82 --
 include/linux/smc91x.h |  1 +
 8 files changed, 55 insertions(+), 40 deletions(-)

-- 
2.1.4



[PATCH 2/5] staging/vchi: Fix build warnings when formatting pointers on aarch64.

2016-10-17 Thread Eric Anholt
The code was generally using "%x" to print and "(unsigned int)" to
cast the pointers, but we have %p for printing pointers in the same
format without any broken casts.

Signed-off-by: Eric Anholt 
---
 .../interface/vchiq_arm/vchiq_2835_arm.c   |   9 +-
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |  32 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_core.c | 178 ++---
 3 files changed, 109 insertions(+), 110 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 4cb5bff23728..c5255bc6c589 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -174,8 +174,8 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
}
 
vchiq_log_info(vchiq_arm_log_level,
-   "vchiq_init - done (slots %x, phys %pad)",
-   (unsigned int)vchiq_slot_zero, &slot_phys);
+   "vchiq_init - done (slots %p, phys %pad)",
+   vchiq_slot_zero, &slot_phys);
 
vchiq_call_connected_callbacks();
 
@@ -389,8 +389,7 @@ create_pagelist(char __user *buf, size_t count, unsigned 
short type,
(num_pages * sizeof(pages[0])),
GFP_KERNEL);
 
-   vchiq_log_trace(vchiq_arm_log_level,
-   "create_pagelist - %x", (unsigned int)pagelist);
+   vchiq_log_trace(vchiq_arm_log_level, "create_pagelist - %p", pagelist);
if (!pagelist)
return -ENOMEM;
 
@@ -515,7 +514,7 @@ free_pagelist(PAGELIST_T *pagelist, int actual)
unsigned int num_pages, i;
 
vchiq_log_trace(vchiq_arm_log_level,
-   "free_pagelist - %x, %d", (unsigned int)pagelist, actual);
+   "free_pagelist - %p, %d", pagelist, actual);
 
num_pages =
(pagelist->length + pagelist->offset + PAGE_SIZE - 1) /
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 47df1af2219d..68ee5216f5bc 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -418,8 +418,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
DEBUG_INITIALISE(g_state.local)
 
vchiq_log_trace(vchiq_arm_log_level,
-"vchiq_ioctl - instance %x, cmd %s, arg %lx",
-   (unsigned int)instance,
+"vchiq_ioctl - instance %p, cmd %s, arg %lx",
+   instance,
((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&
(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
ioctl_names[_IOC_NR(cmd)] : "", arg);
@@ -713,8 +713,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
break;
}
vchiq_log_info(vchiq_arm_log_level,
-   "found bulk_waiter %x for pid %d",
-   (unsigned int)waiter, current->pid);
+   "found bulk_waiter %p for pid %d",
+   waiter, current->pid);
args.userdata = &waiter->bulk_waiter;
}
status = vchiq_bulk_transfer
@@ -743,8 +743,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
list_add(&waiter->list, &instance->bulk_waiter_list);
mutex_unlock(&instance->bulk_waiter_list_mutex);
vchiq_log_info(vchiq_arm_log_level,
-   "saved bulk_waiter %x for pid %d",
-   (unsigned int)waiter, current->pid);
+   "saved bulk_waiter %p for pid %d",
+   waiter, current->pid);
 
if (copy_to_user((void __user *)
&(((VCHIQ_QUEUE_BULK_TRANSFER_T __user *)
@@ -826,9 +826,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
if (args.msgbufsize < msglen) {
vchiq_log_error(
vchiq_arm_log_level,
-   "header %x: msgbufsize"
+   "header %p: msgbufsize"
" %x < msglen %x",
-   (unsigned int)header,
+   header,
args.msgbufsize,
msglen);
 

[PATCH v3 1/4] ARM: pxa: enhance smc91x platform data

2016-10-17 Thread Robert Jarzmik
Instead of having the smc91x driver relying on machine_is_*() calls,
provide this data through platform data, ie. idp, mainstone and
stargate.

This way, the driver doesn't need anymore machine_is_*() calls, which
wouldn't work anymore with a device-tree build.

Signed-off-by: Robert Jarzmik 
---
 arch/arm/mach-pxa/idp.c   | 1 +
 arch/arm/mach-pxa/mainstone.c | 1 +
 arch/arm/mach-pxa/stargate2.c | 1 +
 include/linux/smc91x.h| 1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index 66070acaa888..d1db32b1a2c6 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -85,6 +85,7 @@ static struct resource smc91x_resources[] = {
 static struct smc91x_platdata smc91x_platdata = {
.flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
 SMC91X_USE_DMA | SMC91X_NOWAIT,
+   .pxa_u16_align4 = true,
 };
 
 static struct platform_device smc91x_device = {
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 40964069a17c..a2d851a3a546 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -140,6 +140,7 @@ static struct resource smc91x_resources[] = {
 static struct smc91x_platdata mainstone_smc91x_info = {
.flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
  SMC91X_NOWAIT | SMC91X_USE_DMA,
+   .pxa_u16_align4 = true,
 };
 
 static struct platform_device smc91x_device = {
diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 702f4f14b708..7b6610e9dae4 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -673,6 +673,7 @@ static struct resource smc91x_resources[] = {
 static struct smc91x_platdata stargate2_smc91x_info = {
.flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
| SMC91X_NOWAIT | SMC91X_USE_DMA,
+   .pxa_u16_align4 = true,
 };
 
 static struct platform_device smc91x_device = {
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h
index e302c447e057..129bc674dcf5 100644
--- a/include/linux/smc91x.h
+++ b/include/linux/smc91x.h
@@ -39,6 +39,7 @@ struct smc91x_platdata {
unsigned long flags;
unsigned char leda;
unsigned char ledb;
+   bool pxa_u16_align4;/* PXA buggy u16 writes on 4*n+2 addresses */
 };
 
 #endif /* __SMC91X_H__ */
-- 
2.1.4



[PATCH 4/5] staging/vchi: Add a TODO file of things I know we need to deal with.

2016-10-17 Thread Eric Anholt
I've left out the downstream HDMI audio driver from the "to be
imported" section, as we'll want to handle it natively in vc4.  The
downstream kernel will likely continue to use that driver for a while
due to using the interim "vc4 firmware KMS" mode while vc4 gets its
featureset (such as HDMI audio!) completed.

I've also left out VC-CMA, which appears to be about having Linux
manage a CMA area that the firmware gets to make allocations out of.
I'm not clear on if this is useful (the firmware's need for memory
drops massively with vc4 present, and may drop even more depending on
how we resolve dmabuf handling for camera and video decode)

Signed-off-by: Eric Anholt 
---
 drivers/staging/vc04_services/interface/vchi/TODO | 50 +++
 1 file changed, 50 insertions(+)
 create mode 100644 drivers/staging/vc04_services/interface/vchi/TODO

diff --git a/drivers/staging/vc04_services/interface/vchi/TODO 
b/drivers/staging/vc04_services/interface/vchi/TODO
new file mode 100644
index ..03aa65183b25
--- /dev/null
+++ b/drivers/staging/vc04_services/interface/vchi/TODO
@@ -0,0 +1,50 @@
+1) Port to aarch64
+
+This driver won't be very useful unless we also have it working on
+Raspberry Pi 3.  This requires, at least:
+
+  - Figure out an alternative to the dmac_map_area() hack.
+
+  - Decide what to use instead of dsb().
+
+  - Do something about (int) cast of bulk->data in
+vchiq_bulk_transfer().
+
+bulk->data is a bus address going across to the firmware.  We know
+our bus addresses are <32bit.
+
+2) Write a DT binding doc and get the corresponding DT node merged to
+   bcm2835.
+
+This will let the driver probe when enabled.
+
+3) Import drivers using VCHI.
+
+VCHI is just a tool to let drivers talk to the firmware.  Here are
+some of the ones we want:
+
+  - vc_mem 
(https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/char/broadcom/vc_mem.c)
+
+  This driver is what the vcdbg userspace program uses to set up its
+  requests to the firmware, which are transmitted across VCHIQ.  vcdbg
+  is really useful for debugging firmware interactions.
+
+  - bcm2835-camera 
(https://github.com/raspberrypi/linux/tree/rpi-4.4.y/drivers/media/platform/bcm2835)
+
+  This driver will let us get images from the camera using the MMAL
+  protocol over VCHI.
+
+  - VCSM 
(https://github.com/raspberrypi/linux/tree/rpi-4.4.y/drivers/char/broadcom/vc_sm)
+
+  This driver is used for talking about regions of VC memory across
+  firmware protocols including VCHI.  We'll want to extend this driver
+  to manage these buffers as dmabufs so that we can zero-copy import
+  camera images into vc4 for rendering/display.
+
+4) Garbage-collect unused code
+
+One of the reasons this driver wasn't upstreamed previously was that
+there's a lot code that got built that's probably unnecessary these
+days.  Once we have the set of VCHI-using drivers we want in tree, we
+should be able to do a sweep of the code to see what's left that's
+unused.
-- 
2.9.3



[PATCH 5/5] MAINTAINERS: Add the staging vchiq driver as a bcm2835 responsibility.

2016-10-17 Thread Eric Anholt
It's being merged to support firmware communication on the Raspberry
Pi, so we should probably send its patches to linux-rpi-kernel.

Signed-off-by: Eric Anholt 
---

Greg, I'd be pulling this one through broadcom trees.

 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1cd38a7e0064..8ed85a51d9c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2586,6 +2586,7 @@ L:linux-arm-ker...@lists.infradead.org (moderated 
for non-subscribers)
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/rpi/linux-rpi.git
 S: Maintained
 N: bcm2835
+F: drivers/staging/vc04_services
 
 BROADCOM BCM47XX MIPS ARCHITECTURE
 M: Hauke Mehrtens 
-- 
2.9.3



Re: [PATCH] hwrng: meson: Fix module autoload for OF registration

2016-10-17 Thread Fabio Estevam
On Mon, Oct 17, 2016 at 5:40 PM, Javier Martinez Canillas
 wrote:

> --- a/drivers/char/tpm/Kconfig
> +++ b/drivers/char/tpm/Kconfig
> @@ -32,7 +32,7 @@ config TCG_TIS_CORE
>
>  config TCG_TIS
> tristate "TPM Interface Specification 1.2 Interface / TPM 2.0 FIFO 
> Interface"
> -   depends on X86
> +   depends on X86 || COMPILE_TEST

This is a separate change.


[PATCH v3 3/4] net: smc91x: take into account half-word workaround

2016-10-17 Thread Robert Jarzmik
For device-tree builds, platforms such as mainstone, idp and stargate2
must have their u16 writes all aligned on 32 bit boundaries. This is
already enabled in platform data builds, and this patch adds it to
device-tree builds.

Signed-off-by: Robert Jarzmik 
---
Since v1: rename dt property to pxa-u16-align4
---
 drivers/net/ethernet/smsc/smc91x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 705d99b2d947..65077c77082a 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2326,6 +2326,8 @@ static int smc_drv_probe(struct platform_device *pdev)
if (!device_property_read_u32(&pdev->dev, "reg-shift",
  &val))
lp->io_shift = val;
+   lp->cfg.pxa_u16_align4 =
+   device_property_read_bool(&pdev->dev, "pxa-u16-align4");
}
 #endif
 
-- 
2.1.4



[PATCH net-next 08/15] ethernet/sun: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
cassini: min_mtu 60, max_mtu 9000

niu: min_mtu 68, max_mtu 9216

sungem: min_mtu 68, max_mtu 1500 (comments say jumbo mode is broken)

sunvnet: min_mtu 68, max_mtu 65535
- removed sunvnet_change_mut_common as it does nothing now

CC: net...@vger.kernel.org
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/sun/cassini.c|  7 ---
 drivers/net/ethernet/sun/ldmvsw.c |  5 -
 drivers/net/ethernet/sun/niu.c|  7 ---
 drivers/net/ethernet/sun/sungem.c | 11 ++-
 drivers/net/ethernet/sun/sunvnet.c|  5 -
 drivers/net/ethernet/sun/sunvnet_common.c | 10 --
 drivers/net/ethernet/sun/sunvnet_common.h |  3 ++-
 7 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c 
b/drivers/net/ethernet/sun/cassini.c
index 062bce9..e9e5ef2 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -3863,9 +3863,6 @@ static int cas_change_mtu(struct net_device *dev, int 
new_mtu)
 {
struct cas *cp = netdev_priv(dev);
 
-   if (new_mtu < CAS_MIN_MTU || new_mtu > CAS_MAX_MTU)
-   return -EINVAL;
-
dev->mtu = new_mtu;
if (!netif_running(dev) || !netif_device_present(dev))
return 0;
@@ -5115,6 +5112,10 @@ static int cas_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (pci_using_dac)
dev->features |= NETIF_F_HIGHDMA;
 
+   /* MTU range: 60 - varies or 9000 */
+   dev->min_mtu = CAS_MIN_MTU;
+   dev->max_mtu = CAS_MAX_MTU;
+
if (register_netdev(dev)) {
dev_err(&pdev->dev, "Cannot register net device, aborting\n");
goto err_out_free_consistent;
diff --git a/drivers/net/ethernet/sun/ldmvsw.c 
b/drivers/net/ethernet/sun/ldmvsw.c
index 0ac449a..335b876 100644
--- a/drivers/net/ethernet/sun/ldmvsw.c
+++ b/drivers/net/ethernet/sun/ldmvsw.c
@@ -139,7 +139,6 @@ static const struct net_device_ops vsw_ops = {
.ndo_set_mac_address= sunvnet_set_mac_addr_common,
.ndo_validate_addr  = eth_validate_addr,
.ndo_tx_timeout = sunvnet_tx_timeout_common,
-   .ndo_change_mtu = sunvnet_change_mtu_common,
.ndo_start_xmit = vsw_start_xmit,
.ndo_select_queue   = vsw_select_queue,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -239,6 +238,10 @@ static struct net_device *vsw_alloc_netdev(u8 hwaddr[],
   NETIF_F_HW_CSUM | NETIF_F_SG;
dev->features = dev->hw_features;
 
+   /* MTU range: 68 - 65535 */
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = VNET_MAX_MTU;
+
SET_NETDEV_DEV(dev, &vdev->dev);
 
return dev;
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index a2371aa..f90d1af 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -6754,9 +6754,6 @@ static int niu_change_mtu(struct net_device *dev, int 
new_mtu)
struct niu *np = netdev_priv(dev);
int err, orig_jumbo, new_jumbo;
 
-   if (new_mtu < 68 || new_mtu > NIU_MAX_MTU)
-   return -EINVAL;
-
orig_jumbo = (dev->mtu > ETH_DATA_LEN);
new_jumbo = (new_mtu > ETH_DATA_LEN);
 
@@ -9823,6 +9820,10 @@ static int niu_pci_init_one(struct pci_dev *pdev,
 
dev->irq = pdev->irq;
 
+   /* MTU range: 68 - 9216 */
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = NIU_MAX_MTU;
+
niu_assign_netdev_ops(dev);
 
err = niu_get_invariants(np);
diff --git a/drivers/net/ethernet/sun/sungem.c 
b/drivers/net/ethernet/sun/sungem.c
index d6ad0fb..66ecf0f 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -2476,9 +2476,9 @@ static void gem_set_multicast(struct net_device *dev)
 }
 
 /* Jumbo-grams don't seem to work :-( */
-#define GEM_MIN_MTU68
+#define GEM_MIN_MTUETH_MIN_MTU
 #if 1
-#define GEM_MAX_MTU1500
+#define GEM_MAX_MTUETH_DATA_LEN
 #else
 #define GEM_MAX_MTU9000
 #endif
@@ -2487,9 +2487,6 @@ static int gem_change_mtu(struct net_device *dev, int 
new_mtu)
 {
struct gem *gp = netdev_priv(dev);
 
-   if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU)
-   return -EINVAL;
-
dev->mtu = new_mtu;
 
/* We'll just catch it later when the device is up'd or resumed */
@@ -2977,6 +2974,10 @@ static int gem_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (pci_using_dac)
dev->features |= NETIF_F_HIGHDMA;
 
+   /* MTU range: 68 - 1500 (Jumbo mode is broken) */
+   dev->min_mtu = GEM_MIN_MTU;
+   dev->max_mtu = GEM_MAX_MTU;
+
/* Register with kernel */
if (register_netdev(dev)) {
pr_err("Cannot register net device, aborting\n");
diff --git a/drivers/net/ethernet/sun/sunvnet.c 
b/drivers/net/ethernet/sun/sunvnet.c
index a2f9b47..5356a70 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/dr

[PATCH net-next 12/15] ethernet/ibm: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
ehea: min_mtu 68, max_mtu 9022
- remove ehea_change_mtu, it's now redundant

emac: min_mtu 46, max_mtu 1500 or whatever gets read from OF

CC: net...@vger.kernel.org
CC: Douglas Miller 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/ibm/ehea/ehea_main.c | 13 -
 drivers/net/ethernet/ibm/emac/core.c  |  9 +
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c 
b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index 54efa9a..e9719ba 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -1981,14 +1981,6 @@ static void ehea_set_multicast_list(struct net_device 
*dev)
ehea_update_bcmc_registrations();
 }
 
-static int ehea_change_mtu(struct net_device *dev, int new_mtu)
-{
-   if ((new_mtu < 68) || (new_mtu > EHEA_MAX_PACKET_SIZE))
-   return -EINVAL;
-   dev->mtu = new_mtu;
-   return 0;
-}
-
 static void xmit_common(struct sk_buff *skb, struct ehea_swqe *swqe)
 {
swqe->tx_control |= EHEA_SWQE_IMM_DATA_PRESENT | EHEA_SWQE_CRC;
@@ -2968,7 +2960,6 @@ static const struct net_device_ops ehea_netdev_ops = {
.ndo_set_mac_address= ehea_set_mac_addr,
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_rx_mode= ehea_set_multicast_list,
-   .ndo_change_mtu = ehea_change_mtu,
.ndo_vlan_rx_add_vid= ehea_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid   = ehea_vlan_rx_kill_vid,
.ndo_tx_timeout = ehea_tx_watchdog,
@@ -3041,6 +3032,10 @@ static struct ehea_port *ehea_setup_single_port(struct 
ehea_adapter *adapter,
NETIF_F_IP_CSUM;
dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT;
 
+   /* MTU range: 68 - 9022 */
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = EHEA_MAX_PACKET_SIZE;
+
INIT_WORK(&port->reset_task, ehea_reset_port);
INIT_DELAYED_WORK(&port->stats_work, ehea_update_stats);
 
diff --git a/drivers/net/ethernet/ibm/emac/core.c 
b/drivers/net/ethernet/ibm/emac/core.c
index 5d804a5..52a69c9 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -1099,9 +1099,6 @@ static int emac_change_mtu(struct net_device *ndev, int 
new_mtu)
struct emac_instance *dev = netdev_priv(ndev);
int ret = 0;
 
-   if (new_mtu < EMAC_MIN_MTU || new_mtu > dev->max_mtu)
-   return -EINVAL;
-
DBG(dev, "change_mtu(%d)" NL, new_mtu);
 
if (netif_running(ndev)) {
@@ -2564,7 +2561,7 @@ static int emac_init_config(struct emac_instance *dev)
if (emac_read_uint_prop(np, "cell-index", &dev->cell_index, 1))
return -ENXIO;
if (emac_read_uint_prop(np, "max-frame-size", &dev->max_mtu, 0))
-   dev->max_mtu = 1500;
+   dev->max_mtu = ETH_DATA_LEN;
if (emac_read_uint_prop(np, "rx-fifo-size", &dev->rx_fifo_size, 0))
dev->rx_fifo_size = 2048;
if (emac_read_uint_prop(np, "tx-fifo-size", &dev->tx_fifo_size, 0))
@@ -2890,6 +2887,10 @@ static int emac_probe(struct platform_device *ofdev)
ndev->netdev_ops = &emac_netdev_ops;
ndev->ethtool_ops = &emac_ethtool_ops;
 
+   /* MTU range: 46 - 1500 or whatever is in OF */
+   ndev->min_mtu = EMAC_MIN_MTU;
+   ndev->max_mtu = dev->max_mtu;
+
netif_carrier_off(ndev);
 
err = register_netdev(ndev);
-- 
2.10.0



[PATCH net-next 13/15] ethernet/tile: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
tilegx: min_mtu 68, max_mtu 1500 or 9000, depending on modparam
- remove tile_net_change_mtu now that it is fully redundant

tilepro: min_mtu 68, max_mtu 1500
- hardware supports jumbo packets up to 10226, but it's not implemented or
  tested yet, according to code comments

CC: net...@vger.kernel.org
CC: Chris Metcalf 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/tile/tilegx.c  | 21 -
 drivers/net/ethernet/tile/tilepro.c | 27 +--
 2 files changed, 13 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/tile/tilegx.c 
b/drivers/net/ethernet/tile/tilegx.c
index 11213a3..0aaf975 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -59,6 +59,9 @@
 /* Maximum number of packets to handle per "poll". */
 #define TILE_NET_WEIGHT 64
 
+/* Maximum Jumbo Packet MTU */
+#define TILE_JUMBO_MAX_MTU 9000
+
 /* Number of entries in each iqueue. */
 #define IQUEUE_ENTRIES 512
 
@@ -2101,17 +2104,6 @@ static int tile_net_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
return -EOPNOTSUPP;
 }
 
-/* Change the MTU. */
-static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
-{
-   if (new_mtu < 68)
-   return -EINVAL;
-   if (new_mtu > ((jumbo_num != 0) ? 9000 : 1500))
-   return -EINVAL;
-   dev->mtu = new_mtu;
-   return 0;
-}
-
 /* Change the Ethernet address of the NIC.
  *
  * The hypervisor driver does not support changing MAC address.  However,
@@ -2154,7 +2146,6 @@ static const struct net_device_ops tile_net_ops = {
.ndo_start_xmit = tile_net_tx,
.ndo_select_queue = tile_net_select_queue,
.ndo_do_ioctl = tile_net_ioctl,
-   .ndo_change_mtu = tile_net_change_mtu,
.ndo_tx_timeout = tile_net_tx_timeout,
.ndo_set_mac_address = tile_net_set_mac_address,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2174,7 +2165,11 @@ static void tile_net_setup(struct net_device *dev)
ether_setup(dev);
dev->netdev_ops = &tile_net_ops;
dev->watchdog_timeo = TILE_NET_TIMEOUT;
-   dev->mtu = 1500;
+
+   /* MTU range: 68 - 1500 or 9000 */
+   dev->mtu = ETH_DATA_LEN;
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = jumbo_num ? TILE_JUMBO_MAX_MTU : ETH_DATA_LEN;
 
features |= NETIF_F_HW_CSUM;
features |= NETIF_F_SG;
diff --git a/drivers/net/ethernet/tile/tilepro.c 
b/drivers/net/ethernet/tile/tilepro.c
index 4ef605a..0a3b7da 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -87,7 +87,7 @@
 /* This should be 1500 if "jumbo" is not set in LIPP. */
 /* This should be at most 10226 (10240 - 14) if "jumbo" is set in LIPP. */
 /* ISSUE: This has not been thoroughly tested (except at 1500). */
-#define TILE_NET_MTU 1500
+#define TILE_NET_MTU ETH_DATA_LEN
 
 /* HACK: Define this to verify incoming packets. */
 /* #define TILE_NET_VERIFY_INGRESS */
@@ -2095,26 +2095,6 @@ static struct rtnl_link_stats64 
*tile_net_get_stats64(struct net_device *dev,
 }
 
 
-/*
- * Change the "mtu".
- *
- * The "change_mtu" method is usually not needed.
- * If you need it, it must be like this.
- */
-static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
-{
-   PDEBUG("tile_net_change_mtu()\n");
-
-   /* Check ranges. */
-   if ((new_mtu < 68) || (new_mtu > 1500))
-   return -EINVAL;
-
-   /* Accept the value. */
-   dev->mtu = new_mtu;
-
-   return 0;
-}
-
 
 /*
  * Change the Ethernet Address of the NIC.
@@ -2229,7 +2209,6 @@ static const struct net_device_ops tile_net_ops = {
.ndo_start_xmit = tile_net_tx,
.ndo_do_ioctl = tile_net_ioctl,
.ndo_get_stats64 = tile_net_get_stats64,
-   .ndo_change_mtu = tile_net_change_mtu,
.ndo_tx_timeout = tile_net_tx_timeout,
.ndo_set_mac_address = tile_net_set_mac_address,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2252,7 +2231,11 @@ static void tile_net_setup(struct net_device *dev)
dev->netdev_ops = &tile_net_ops;
dev->watchdog_timeo = TILE_NET_TIMEOUT;
dev->tx_queue_len = TILE_NET_TX_QUEUE_LEN;
+
+   /* MTU range: 68 - 1500 */
dev->mtu = TILE_NET_MTU;
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = TILE_NET_MTU;
 
features |= NETIF_F_HW_CSUM;
features |= NETIF_F_SG;
-- 
2.10.0



[PATCH net-next 10/15] ethernet/neterion: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
s2io: min_mtu 46, max_mtu 9600

vxge: min_mtu 68, max_mtu 9600

CC: net...@vger.kernel.org
CC: Jon Mason 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/neterion/s2io.c | 9 -
 drivers/net/ethernet/neterion/vxge/vxge-config.h | 2 +-
 drivers/net/ethernet/neterion/vxge/vxge-main.c   | 9 -
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/neterion/s2io.c 
b/drivers/net/ethernet/neterion/s2io.c
index eaa37c0..564f682 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -6678,11 +6678,6 @@ static int s2io_change_mtu(struct net_device *dev, int 
new_mtu)
struct s2io_nic *sp = netdev_priv(dev);
int ret = 0;
 
-   if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) {
-   DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n", dev->name);
-   return -EPERM;
-   }
-
dev->mtu = new_mtu;
if (netif_running(dev)) {
s2io_stop_all_tx_queue(sp);
@@ -8019,6 +8014,10 @@ s2io_init_nic(struct pci_dev *pdev, const struct 
pci_device_id *pre)
config->mc_start_offset = S2IO_HERC_MC_ADDR_START_OFFSET;
}
 
+   /* MTU range: 46 - 9600 */
+   dev->min_mtu = MIN_MTU;
+   dev->max_mtu = S2IO_JUMBO_SIZE;
+
/* store mac addresses from CAM to s2io_nic structure */
do_s2io_store_unicast_mc(sp);
 
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.h 
b/drivers/net/ethernet/neterion/vxge/vxge-config.h
index 6ce4412..cfa9704 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-config.h
+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.h
@@ -27,7 +27,7 @@
(((size) - (((u64)adrs) & ((size)-1))) & ((size)-1))
 #endif
 
-#define VXGE_HW_MIN_MTU68
+#define VXGE_HW_MIN_MTUETH_MIN_MTU
 #define VXGE_HW_MAX_MTU9600
 #define VXGE_HW_DEFAULT_MTU1500
 
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c 
b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index e0993eb..e07b936 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -3074,11 +3074,6 @@ static int vxge_change_mtu(struct net_device *dev, int 
new_mtu)
 
vxge_debug_entryexit(vdev->level_trace,
"%s:%d", __func__, __LINE__);
-   if ((new_mtu < VXGE_HW_MIN_MTU) || (new_mtu > VXGE_HW_MAX_MTU)) {
-   vxge_debug_init(vdev->level_err,
-   "%s: mtu size is invalid", dev->name);
-   return -EPERM;
-   }
 
/* check if device is down already */
if (unlikely(!is_vxge_card_up(vdev))) {
@@ -3462,6 +3457,10 @@ static int vxge_device_register(struct __vxge_hw_device 
*hldev,
"%s : using High DMA", __func__);
}
 
+   /* MTU range: 68 - 9600 */
+   ndev->min_mtu = VXGE_HW_MIN_MTU;
+   ndev->max_mtu = VXGE_HW_MAX_MTU;
+
ret = register_netdev(ndev);
if (ret) {
vxge_debug_init(vxge_hw_device_trace_level_get(hldev),
-- 
2.10.0



[PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
dl2k: min_mtu 68, max_mtu 1536 or 8000, depending on hardware
- Removed change_mtu, does nothing productive anymore

sundance: min_mtu 68, max_mtu 8191

CC: net...@vger.kernel.org
CC: Denis Kirjanov 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/dlink/dl2k.c | 22 --
 drivers/net/ethernet/dlink/sundance.c |  6 --
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/dlink/dl2k.c 
b/drivers/net/ethernet/dlink/dl2k.c
index 78f1446..8c95a8a 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -76,7 +76,6 @@ static void rio_free_tx (struct net_device *dev, int irq);
 static void tx_error (struct net_device *dev, int tx_status);
 static int receive_packet (struct net_device *dev);
 static void rio_error (struct net_device *dev, int int_status);
-static int change_mtu (struct net_device *dev, int new_mtu);
 static void set_multicast (struct net_device *dev);
 static struct net_device_stats *get_stats (struct net_device *dev);
 static int clear_stats (struct net_device *dev);
@@ -106,7 +105,6 @@ static const struct net_device_ops netdev_ops = {
.ndo_set_rx_mode= set_multicast,
.ndo_do_ioctl   = rio_ioctl,
.ndo_tx_timeout = rio_tx_timeout,
-   .ndo_change_mtu = change_mtu,
 };
 
 static int
@@ -230,6 +228,10 @@ rio_probe1 (struct pci_dev *pdev, const struct 
pci_device_id *ent)
 #if 0
dev->features = NETIF_F_IP_CSUM;
 #endif
+   /* MTU range: 68 - 1536 or 8000 */
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = np->jumbo ? MAX_JUMBO : PACKET_SIZE;
+
pci_set_drvdata (pdev, dev);
 
ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
@@ -1198,22 +1200,6 @@ clear_stats (struct net_device *dev)
return 0;
 }
 
-
-static int
-change_mtu (struct net_device *dev, int new_mtu)
-{
-   struct netdev_private *np = netdev_priv(dev);
-   int max = (np->jumbo) ? MAX_JUMBO : 1536;
-
-   if ((new_mtu < 68) || (new_mtu > max)) {
-   return -EINVAL;
-   }
-
-   dev->mtu = new_mtu;
-
-   return 0;
-}
-
 static void
 set_multicast (struct net_device *dev)
 {
diff --git a/drivers/net/ethernet/dlink/sundance.c 
b/drivers/net/ethernet/dlink/sundance.c
index 79d8009..eab36ac 100644
--- a/drivers/net/ethernet/dlink/sundance.c
+++ b/drivers/net/ethernet/dlink/sundance.c
@@ -580,6 +580,10 @@ static int sundance_probe1(struct pci_dev *pdev,
dev->ethtool_ops = ðtool_ops;
dev->watchdog_timeo = TX_TIMEOUT;
 
+   /* MTU range: 68 - 8191 */
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = 8191;
+
pci_set_drvdata(pdev, dev);
 
i = register_netdev(dev);
@@ -713,8 +717,6 @@ static int sundance_probe1(struct pci_dev *pdev,
 
 static int change_mtu(struct net_device *dev, int new_mtu)
 {
-   if ((new_mtu < 68) || (new_mtu > 8191)) /* Set by RxDMAFrameLen */
-   return -EINVAL;
if (netif_running(dev))
return -EBUSY;
dev->mtu = new_mtu;
-- 
2.10.0



[PATCH net-next 11/15] ethernet/cavium: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
liquidio: min_mtu 68, max_mtu 16000

thunder: min_mtu 64, max_mtu 9200

CC: net...@vger.kernel.org
CC: Sunil Goutham 
CC: Robert Richter 
CC: Derek Chickles 
CC: Satanand Burla 
CC: Felix Manlunas 
CC: Raghu Vatsavayi 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c   | 15 ---
 drivers/net/ethernet/cavium/liquidio/octeon_network.h |  2 +-
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c  | 13 +++--
 drivers/net/ethernet/cavium/thunder/nicvf_main.c  | 10 --
 4 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index afc6f9dc..71d01a7 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -2868,17 +2868,6 @@ static int liquidio_change_mtu(struct net_device 
*netdev, int new_mtu)
struct octnic_ctrl_pkt nctrl;
int ret = 0;
 
-   /* Limit the MTU to make sure the ethernet packets are between 68 bytes
-* and 16000 bytes
-*/
-   if ((new_mtu < LIO_MIN_MTU_SIZE) ||
-   (new_mtu > LIO_MAX_MTU_SIZE)) {
-   dev_err(&oct->pci_dev->dev, "Invalid MTU: %d\n", new_mtu);
-   dev_err(&oct->pci_dev->dev, "Valid range %d and %d\n",
-   LIO_MIN_MTU_SIZE, LIO_MAX_MTU_SIZE);
-   return -EINVAL;
-   }
-
memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
 
nctrl.ncmd.u64 = 0;
@@ -3891,6 +3880,10 @@ static int setup_nic_devices(struct octeon_device 
*octeon_dev)
netdev->hw_features = netdev->hw_features &
~NETIF_F_HW_VLAN_CTAG_RX;
 
+   /* MTU range: 68 - 16000 */
+   netdev->min_mtu = LIO_MIN_MTU_SIZE;
+   netdev->max_mtu = LIO_MAX_MTU_SIZE;
+
/* Point to the  properties for octeon device to which this
 * interface belongs.
 */
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index e5d1deb..54b9665 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -29,7 +29,7 @@
 #include 
 
 #define LIO_MAX_MTU_SIZE (OCTNET_MAX_FRM_SIZE - OCTNET_FRM_HEADER_SIZE)
-#define LIO_MIN_MTU_SIZE 68
+#define LIO_MIN_MTU_SIZE ETH_MIN_MTU
 
 struct oct_nic_stats_resp {
u64 rh;
diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c 
b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index 4ab404f..16e12c4 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -645,16 +645,6 @@ static int octeon_mgmt_change_mtu(struct net_device 
*netdev, int new_mtu)
struct octeon_mgmt *p = netdev_priv(netdev);
int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
 
-   /* Limit the MTU to make sure the ethernet packets are between
-* 64 bytes and 16383 bytes.
-*/
-   if (size_without_fcs < 64 || size_without_fcs > 16383) {
-   dev_warn(p->dev, "MTU must be between %d and %d.\n",
-64 - OCTEON_MGMT_RX_HEADROOM,
-16383 - OCTEON_MGMT_RX_HEADROOM);
-   return -EINVAL;
-   }
-
netdev->mtu = new_mtu;
 
cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
@@ -1491,6 +1481,9 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
netdev->netdev_ops = &octeon_mgmt_ops;
netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
 
+   netdev->min_mtu = 64 - OCTEON_MGMT_RX_HEADROOM;
+   netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM;
+
mac = of_get_mac_address(pdev->dev.of_node);
 
if (mac)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c 
b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 45a13f7..b192712 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1312,12 +1312,6 @@ static int nicvf_change_mtu(struct net_device *netdev, 
int new_mtu)
 {
struct nicvf *nic = netdev_priv(netdev);
 
-   if (new_mtu > NIC_HW_MAX_FRS)
-   return -EINVAL;
-
-   if (new_mtu < NIC_HW_MIN_FRS)
-   return -EINVAL;
-
if (nicvf_update_hw_max_frs(nic, new_mtu))
return -EINVAL;
netdev->mtu = new_mtu;
@@ -1630,6 +1624,10 @@ static int nicvf_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
netdev->netdev_ops = &nicvf_netdev_ops;
netdev->watchdog_timeo = NICVF_TX_TIMEOUT;
 
+   /* MTU range: 64 - 9200 */
+   netdev->min_mtu = NIC_HW_MIN_FRS;
+   netdev->max_mtu = NIC_HW_MAX_FRS;
+
INIT_WORK(&nic->reset_task, nicvf_reset_task);
 
err = register_netdev(netdev);
-- 
2.10.0



[PATCH net-next 15/15] ethernet: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
et131x: min_mtu 64, max_mtu 9216

altera_tse: min_mtu 64, max_mtu 1500

amd8111e: min_mtu 60, max_mtu 9000

bnad: min_mtu 46, max_mtu 9000

macb: min_mtu 68, max_mtu 1500 or 10240 depending on hardware capability

xgmac: min_mtu 46, max_mtu 9000

cxgb2: min_mtu 68, max_mtu 9582 (pm3393) or 9600 (vsc7326)

enic: min_mtu 68, max_mtu 9000

gianfar: min_mtu 50, max_mu 9586

hns_enet: min_mtu 68, max_mtu 9578 (v1) or 9706 (v2)

ksz884x: min_mtu 60, max_mtu 1894

myri10ge: min_mtu 68, max_mtu 9000

natsemi: min_mtu 64, max_mtu 2024

nfp: min_mtu 68, max_mtu hardware-specific

forcedeth: min_mtu 64, max_mtu 1500 or 9100, depending on hardware

pch_gbe: min_mtu 46, max_mtu 10300

pasemi_mac: min_mtu 64, max_mtu 9000

qcaspi: min_mtu 46, max_mtu 1500
- remove qcaspi_netdev_change_mtu as it is now redundant

rocker: min_mtu 68, max_mtu 9000

sxgbe: min_mtu 68, max_mtu 9000

stmmac: min_mtu 46, max_mtu depends on hardware

tehuti: min_mtu 60, max_mtu 16384
- driver had no max mtu checking, but product docs say 16k jumbo packets
  are supported by the hardware

netcp: min_mtu 68, max_mtu 9486
- remove netcp_ndo_change_mtu as it is now redundant

via-velocity: min_mtu 64, max_mtu 9000

octeon: min_mtu 46, max_mtu 65370

CC: net...@vger.kernel.org
CC: Mark Einon 
CC: Vince Bridgers 
CC: Rasesh Mody 
CC: Nicolas Ferre 
CC: Santosh Raspatur 
CC: Hariprasad S 
CC:  Christian Benvenuti 
CC: Sujith Sankar 
CC: Govindarajulu Varadarajan <_gov...@gmx.com>
CC: Neel Patel 
CC: Claudiu Manoil 
CC: Yisen Zhuang 
CC: Salil Mehta 
CC: Hyong-Youb Kim 
CC: Jakub Kicinski 
CC: Olof Johansson 
CC: Jiri Pirko 
CC: Byungho An 
CC: Girish K S 
CC: Vipul Pandya 
CC: Giuseppe Cavallaro 
CC: Alexandre Torgue 
CC: Andy Gospodarek 
CC: Wingman Kwok 
CC: Murali Karicheri 
CC: Francois Romieu 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/agere/et131x.c|  7 +++--
 drivers/net/ethernet/altera/altera_tse.h   |  1 -
 drivers/net/ethernet/altera/altera_tse_main.c  | 14 ++---
 drivers/net/ethernet/amd/amd8111e.c|  5 ++--
 drivers/net/ethernet/brocade/bna/bnad.c|  7 +++--
 drivers/net/ethernet/cadence/macb.c| 19 ++---
 drivers/net/ethernet/calxeda/xgmac.c   | 20 -
 drivers/net/ethernet/chelsio/cxgb/common.h |  5 
 drivers/net/ethernet/chelsio/cxgb/cxgb2.c  | 18 ++--
 drivers/net/ethernet/chelsio/cxgb/pm3393.c |  8 +-
 drivers/net/ethernet/chelsio/cxgb/vsc7326.c|  5 
 drivers/net/ethernet/cisco/enic/enic_main.c|  7 +++--
 drivers/net/ethernet/cisco/enic/enic_res.h |  2 +-
 drivers/net/ethernet/freescale/gianfar.c   |  9 ++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  |  3 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 11 +---
 drivers/net/ethernet/micrel/ksz884x.c  | 33 +++---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   | 20 +++--
 drivers/net/ethernet/natsemi/natsemi.c |  7 +++--
 .../net/ethernet/netronome/nfp/nfp_net_common.c| 10 +++
 drivers/net/ethernet/nvidia/forcedeth.c|  9 +++---
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 13 -
 drivers/net/ethernet/pasemi/pasemi_mac.c   | 12 
 drivers/net/ethernet/qualcomm/qca_framing.h|  6 ++--
 drivers/net/ethernet/qualcomm/qca_spi.c| 16 +++
 drivers/net/ethernet/rocker/rocker_main.c  | 12 
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c| 17 +++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 25 ++--
 drivers/net/ethernet/tehuti/tehuti.c   | 14 +++--
 drivers/net/ethernet/tehuti/tehuti.h   |  3 ++
 drivers/net/ethernet/ti/netcp_core.c   | 20 +++--
 drivers/net/ethernet/via/via-velocity.c| 11 +++-
 drivers/staging/octeon/ethernet.c  | 22 +++
 33 files changed, 169 insertions(+), 222 deletions(-)

diff --git a/drivers/net/ethernet/agere/et131x.c 
b/drivers/net/ethernet/agere/et131x.c
index 9066838..831bab3 100644
--- a/drivers/net/ethernet/agere/et131x.c
+++ b/drivers/net/ethernet/agere/et131x.c
@@ -176,6 +176,8 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for 
the ET1310 by Agere S
 #define NUM_FBRS   2
 
 #define MAX_PACKETS_HANDLED256
+#define ET131X_MIN_MTU 64
+#define ET131X_MAX_MTU 9216
 
 #define ALCATEL_MULTICAST_PKT  0x0100
 #define ALCATEL_BROADCAST_PKT  0x0200
@@ -3869,9 +3871,6 @@ static int et131x_change_mtu(struct net_device *netdev, 
int new_mtu)
int result = 0;
struct et131x_adapter *adapter = netdev_priv(netdev);
 
-   if (new_mtu < 64 || new_mtu > 9216)
-   return -EINVAL;
-
et131x_disable_txrx(netdev);
 
netdev->mtu = new_mtu;
@@ -3958,6 +3957,8 @@ static int et131x_pci_setup(struct pci_dev *pdev,
 

Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

2016-10-17 Thread Peter Zijlstra
On Mon, Oct 17, 2016 at 03:40:24PM -0400, Jeff Moyer wrote:
> Christoph Hellwig  writes:
> 
> > On Mon, Oct 17, 2016 at 02:19:47PM -0400, Jeff Moyer wrote:
> >> This ends up being a call to __sb_end_write:
> >> 
> >> void __sb_end_write(struct super_block *sb, int level)
> >> {
> >> percpu_up_read(sb->s_writers.rw_sem + level-1);
> >> }
> >> 
> >> Nothing guarantees that submission and completion happen on the same
> >> CPU.  Is this safe?
> >
> > Good point.  From my reading of the percpu_rwsem implementation it
> > is not safe to release it from a different CPU.  Which makes me
> > wonder how we can protect aio writes properly here..
> 
> Could we just change percpu_rw_semaphore->read_count to be a signed
> integer?  The down_write path sums up the counters from all cpus...

To what point?


Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

2016-10-17 Thread Peter Zijlstra
On Mon, Oct 17, 2016 at 08:55:52PM +0200, Christoph Hellwig wrote:
> On Mon, Oct 17, 2016 at 02:19:47PM -0400, Jeff Moyer wrote:
> > This ends up being a call to __sb_end_write:
> > 
> > void __sb_end_write(struct super_block *sb, int level)
> > {
> > percpu_up_read(sb->s_writers.rw_sem + level-1);
> > }
> > 
> > Nothing guarantees that submission and completion happen on the same
> > CPU.  Is this safe?
> 
> Good point.  From my reading of the percpu_rwsem implementation it
> is not safe to release it from a different CPU.  Which makes me
> wonder how we can protect aio writes properly here..

percpu-rwsem has the same semantics as regular rwsems, so preemptible
and 'owner' stuff.

Therefore we must support doing up from a different cpu than we did down
on; the owner could've been migrated while we held it.

And while there's a metric ton of tricky in the implementation, this
part is actually fairly straight forward. We only care about the direct
sum of the per-cpu counter, see readers_active_check() -> per_cpu_sum().

So one cpu doing an inc and another doing a dec summed is still 0.


[PATCH net-next 14/15] ethernet/toshiba: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
gelic_net: min_mtu 64, max_mtu 1518
- remove gelic_net_change_mtu now that it is redundant

spidernet: min_Mtu 64, max_mtu 2294
- remove spiter_net_change_mtu now that it is redundant

CC: net...@vger.kernel.org
CC: Geoff Levand 
CC: Ishizaki Kou 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c  | 23 --
 drivers/net/ethernet/toshiba/ps3_gelic_net.h  |  1 -
 drivers/net/ethernet/toshiba/ps3_gelic_wireless.c |  1 -
 drivers/net/ethernet/toshiba/spider_net.c | 24 ---
 4 files changed, 8 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 272f2b1..345316c 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -1114,24 +1114,6 @@ static int gelic_net_poll(struct napi_struct *napi, int 
budget)
}
return packets_done;
 }
-/**
- * gelic_net_change_mtu - changes the MTU of an interface
- * @netdev: interface device structure
- * @new_mtu: new MTU value
- *
- * returns 0 on success, <0 on failure
- */
-int gelic_net_change_mtu(struct net_device *netdev, int new_mtu)
-{
-   /* no need to re-alloc skbs or so -- the max mtu is about 2.3k
-* and mtu is outbound only anyway */
-   if ((new_mtu < GELIC_NET_MIN_MTU) ||
-   (new_mtu > GELIC_NET_MAX_MTU)) {
-   return -EINVAL;
-   }
-   netdev->mtu = new_mtu;
-   return 0;
-}
 
 /**
  * gelic_card_interrupt - event handler for gelic_net
@@ -1446,7 +1428,6 @@ static const struct net_device_ops gelic_netdevice_ops = {
.ndo_stop = gelic_net_stop,
.ndo_start_xmit = gelic_net_xmit,
.ndo_set_rx_mode = gelic_net_set_multi,
-   .ndo_change_mtu = gelic_net_change_mtu,
.ndo_tx_timeout = gelic_net_tx_timeout,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
@@ -1513,6 +1494,10 @@ int gelic_net_setup_netdev(struct net_device *netdev, 
struct gelic_card *card)
netdev->features |= NETIF_F_VLAN_CHALLENGED;
}
 
+   /* MTU range: 64 - 1518 */
+   netdev->min_mtu = GELIC_NET_MIN_MTU;
+   netdev->max_mtu = GELIC_NET_MAX_MTU;
+
status = register_netdev(netdev);
if (status) {
dev_err(ctodev(card), "%s:Couldn't register %s %d\n",
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.h 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.h
index 8505196..003d045 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.h
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.h
@@ -373,7 +373,6 @@ int gelic_net_stop(struct net_device *netdev);
 int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
 void gelic_net_set_multi(struct net_device *netdev);
 void gelic_net_tx_timeout(struct net_device *netdev);
-int gelic_net_change_mtu(struct net_device *netdev, int new_mtu);
 int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card);
 
 /* shared ethtool ops */
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
index 446ea58..b3abd02 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
@@ -2558,7 +2558,6 @@ static const struct net_device_ops gelic_wl_netdevice_ops 
= {
.ndo_stop = gelic_wl_stop,
.ndo_start_xmit = gelic_net_xmit,
.ndo_set_rx_mode = gelic_net_set_multi,
-   .ndo_change_mtu = gelic_net_change_mtu,
.ndo_tx_timeout = gelic_net_tx_timeout,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/ethernet/toshiba/spider_net.c 
b/drivers/net/ethernet/toshiba/spider_net.c
index 36a6e8b..cb341df 100644
--- a/drivers/net/ethernet/toshiba/spider_net.c
+++ b/drivers/net/ethernet/toshiba/spider_net.c
@@ -1279,25 +1279,6 @@ static int spider_net_poll(struct napi_struct *napi, int 
budget)
 }
 
 /**
- * spider_net_change_mtu - changes the MTU of an interface
- * @netdev: interface device structure
- * @new_mtu: new MTU value
- *
- * returns 0 on success, <0 on failure
- */
-static int
-spider_net_change_mtu(struct net_device *netdev, int new_mtu)
-{
-   /* no need to re-alloc skbs or so -- the max mtu is about 2.3k
-* and mtu is outbound only anyway */
-   if ( (new_mtu < SPIDER_NET_MIN_MTU ) ||
-   (new_mtu > SPIDER_NET_MAX_MTU) )
-   return -EINVAL;
-   netdev->mtu = new_mtu;
-   return 0;
-}
-
-/**
  * spider_net_set_mac - sets the MAC of an interface
  * @netdev: interface device structure
  * @ptr: pointer to new MAC address
@@ -2229,7 +2210,6 @@ static const struct net_device_ops spider_net_ops = {
.ndo_start_xmit = spider_net_xmit,
.ndo_set_rx_mode= spider_net_set_multi,
.ndo_set_mac_address= spider_net_set_mac,
-   

[PATCH v3 4/4] net: smsc91x: add u16 workaround for pxa platforms

2016-10-17 Thread Robert Jarzmik
Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
which must be aligned on 32 bits addresses.

Signed-off-by: Robert Jarzmik 
Cc: Jeremy Linton 
---
Since v1: rename dt property to pxa-u16-align4
  change the binding documentation file
---
 Documentation/devicetree/bindings/net/smsc-lan91c111.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt 
b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index e77e167593db..309e37eb7c7c 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -13,3 +13,5 @@ Optional properties:
   16-bit access only.
 - power-gpios: GPIO to control the PWRDWN pin
 - reset-gpios: GPIO to control the RESET pin
+- pxa-u16-align4 : Boolean, put in place the workaround the force all
+  u16 writes to be 32 bits aligned
-- 
2.1.4



Re: [PATCH] hwrng: meson: Fix module autoload for OF registration

2016-10-17 Thread Javier Martinez Canillas
Hello Fabio,

On 10/17/2016 04:45 PM, Fabio Estevam wrote:
> On Mon, Oct 17, 2016 at 5:40 PM, Javier Martinez Canillas
>  wrote:
> 
>> --- a/drivers/char/tpm/Kconfig
>> +++ b/drivers/char/tpm/Kconfig
>> @@ -32,7 +32,7 @@ config TCG_TIS_CORE
>>
>>  config TCG_TIS
>> tristate "TPM Interface Specification 1.2 Interface / TPM 2.0 FIFO 
>> Interface"
>> -   depends on X86
>> +   depends on X86 || COMPILE_TEST
> 
> This is a separate change.
> 

Yes, I did a commit by mistake. Sorry about that.

Jason already pointed out and I posted a v2.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America


[PATCH net-next 02/15] ethernet/broadcom: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
tg3: min_mtu 60, max_mtu 9000/1500

bnxt: min_mtu 60, max_mtu 9000

bnx2x: min_mtu 46, max_mtu 9600
- Fix up ETH_OVREHEAD -> ETH_OVERHEAD while we're in here, remove
  duplicated defines from bnx2x_link.c.

bnx2: min_mtu 46, max_mtu 9000
- Use more standard ETH_* defines while we're at it.

bcm63xx_enet: min_mtu 46, max_mtu 2028
- compute_hw_mtu was made largely pointless, and thus merged back into
  bcm_enet_change_mtu.

b44: min_mtu 60, max_mtu 1500

CC: net...@vger.kernel.org
CC: Michael Chan 
CC: Sony Chacko 
CC: Ariel Elior 
CC: dept-hsglinuxnic...@qlogic.com
CC: Siva Reddy Kallam 
CC: Prashant Sreedharan 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/broadcom/b44.c  |  9 +++---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 35 
 drivers/net/ethernet/broadcom/bnx2.c | 16 +--
 drivers/net/ethernet/broadcom/bnx2.h |  6 ++--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h  |  6 ++--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c  |  8 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 22 ++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  7 +++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.c|  7 +++--
 drivers/net/ethernet/broadcom/tg3.c  |  9 +++---
 10 files changed, 51 insertions(+), 74 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/b44.c 
b/drivers/net/ethernet/broadcom/b44.c
index 17aa33c..1df3048 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -59,8 +59,8 @@
 #define B44_TX_TIMEOUT (5 * HZ)
 
 /* hardware minimum and maximum for a single frame's data payload */
-#define B44_MIN_MTU60
-#define B44_MAX_MTU1500
+#define B44_MIN_MTUETH_ZLEN
+#define B44_MAX_MTUETH_DATA_LEN
 
 #define B44_RX_RING_SIZE   512
 #define B44_DEF_RX_RING_PENDING200
@@ -1064,9 +1064,6 @@ static int b44_change_mtu(struct net_device *dev, int 
new_mtu)
 {
struct b44 *bp = netdev_priv(dev);
 
-   if (new_mtu < B44_MIN_MTU || new_mtu > B44_MAX_MTU)
-   return -EINVAL;
-
if (!netif_running(dev)) {
/* We'll just catch it later when the
 * device is up'd.
@@ -2377,6 +2374,8 @@ static int b44_init_one(struct ssb_device *sdev,
dev->netdev_ops = &b44_netdev_ops;
netif_napi_add(dev, &bp->napi, b44_poll, 64);
dev->watchdog_timeo = B44_TX_TIMEOUT;
+   dev->min_mtu = B44_MIN_MTU;
+   dev->max_mtu = B44_MAX_MTU;
dev->irq = sdev->irq;
dev->ethtool_ops = &b44_ethtool_ops;
 
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c 
b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index ae364c7..7e513ca 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1622,20 +1622,19 @@ static int bcm_enet_ioctl(struct net_device *dev, 
struct ifreq *rq, int cmd)
 }
 
 /*
- * calculate actual hardware mtu
+ * adjust mtu, can't be called while device is running
  */
-static int compute_hw_mtu(struct bcm_enet_priv *priv, int mtu)
+static int bcm_enet_change_mtu(struct net_device *dev, int new_mtu)
 {
-   int actual_mtu;
+   struct bcm_enet_priv *priv = netdev_priv(dev);
+   int actual_mtu = new_mtu;
 
-   actual_mtu = mtu;
+   if (netif_running(dev))
+   return -EBUSY;
 
/* add ethernet header + vlan tag size */
actual_mtu += VLAN_ETH_HLEN;
 
-   if (actual_mtu < 64 || actual_mtu > BCMENET_MAX_MTU)
-   return -EINVAL;
-
/*
 * setup maximum size before we get overflow mark in
 * descriptor, note that this will not prevent reception of
@@ -1650,22 +1649,7 @@ static int compute_hw_mtu(struct bcm_enet_priv *priv, 
int mtu)
 */
priv->rx_skb_size = ALIGN(actual_mtu + ETH_FCS_LEN,
  priv->dma_maxburst * 4);
-   return 0;
-}
 
-/*
- * adjust mtu, can't be called while device is running
- */
-static int bcm_enet_change_mtu(struct net_device *dev, int new_mtu)
-{
-   int ret;
-
-   if (netif_running(dev))
-   return -EBUSY;
-
-   ret = compute_hw_mtu(netdev_priv(dev), new_mtu);
-   if (ret)
-   return ret;
dev->mtu = new_mtu;
return 0;
 }
@@ -1755,7 +1739,7 @@ static int bcm_enet_probe(struct platform_device *pdev)
priv->enet_is_sw = false;
priv->dma_maxburst = BCMENET_DMA_MAXBURST;
 
-   ret = compute_hw_mtu(priv, dev->mtu);
+   ret = bcm_enet_change_mtu(dev, dev->mtu);
if (ret)
goto out;
 
@@ -1888,6 +1872,9 @@ static int bcm_enet_probe(struct platform_device *pdev)
netif_napi_add(dev, &priv->napi, bcm_enet_poll, 16);
 
dev->ethtool_ops = &bcm_enet_ethtool_ops;
+   /* MTU range: 46 - 2028 */
+   dev->min_mtu = ETH_ZLEN - ETH_HLEN;
+   

[PATCH net-next 03/15] ethernet/intel: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
e100: min_mtu 68, max_mtu 1500
- remove e100_change_mtu entirely, is identical to old eth_change_mtu,
  and no longer serves a purpose. No need to set min_mtu or max_mtu
  explicitly, as ether_setup() will already set them to 68 and 1500.

e1000: min_mtu 46, max_mtu 16110

e1000e: min_mtu 68, max_mtu varies based on adapter

fm10k: min_mtu 68, max_mtu 15342
- remove fm10k_change_mtu entirely, does nothing now

i40e: min_mtu 68, max_mtu 9706

i40evf: min_mtu 68, max_mtu 9706

igb: min_mtu 68, max_mtu 9216
- There are two different "max" frame sizes claimed and both checked in
  the driver, the larger value wasn't relevant though, so I've set max_mtu
  to the smaller of the two values here to retain identical behavior.

igbvf: min_mtu 68, max_mtu 9216
- Same issue as igb duplicated

ixgb: min_mtu 68, max_mtu 16114
- Also remove pointless old == new check, as that's done in dev_set_mtu

ixgbe: min_mtu 68, max_mtu 9710

ixgbevf: min_mtu 68, max_mtu dependent on hardware/firmware
- Some hw can only handle up to max_mtu 1504 on a vf, others 9710

CC: net...@vger.kernel.org
CC: intel-wired-...@lists.osuosl.org
CC: Jeff Kirsher 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/intel/e100.c |  9 ---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 12 -
 drivers/net/ethernet/intel/e1000e/netdev.c| 14 +-
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c   | 15 +++
 drivers/net/ethernet/intel/i40e/i40e_main.c   | 10 +++
 drivers/net/ethernet/intel/i40evf/i40evf_main.c   |  8 +++---
 drivers/net/ethernet/intel/igb/e1000_defines.h|  3 ++-
 drivers/net/ethernet/intel/igb/igb_main.c | 15 +++
 drivers/net/ethernet/intel/igbvf/defines.h|  3 ++-
 drivers/net/ethernet/intel/igbvf/netdev.c | 14 +++---
 drivers/net/ethernet/intel/ixgb/ixgb_main.c   | 16 +++
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 11 
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 33 ---
 13 files changed, 62 insertions(+), 101 deletions(-)

diff --git a/drivers/net/ethernet/intel/e100.c 
b/drivers/net/ethernet/intel/e100.c
index 068789e..25c6dfd 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -2286,14 +2286,6 @@ static int e100_set_mac_address(struct net_device 
*netdev, void *p)
return 0;
 }
 
-static int e100_change_mtu(struct net_device *netdev, int new_mtu)
-{
-   if (new_mtu < ETH_ZLEN || new_mtu > ETH_DATA_LEN)
-   return -EINVAL;
-   netdev->mtu = new_mtu;
-   return 0;
-}
-
 static int e100_asf(struct nic *nic)
 {
/* ASF can be enabled from eeprom */
@@ -2834,7 +2826,6 @@ static const struct net_device_ops e100_netdev_ops = {
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_rx_mode= e100_set_multicast_list,
.ndo_set_mac_address= e100_set_mac_address,
-   .ndo_change_mtu = e100_change_mtu,
.ndo_do_ioctl   = e100_do_ioctl,
.ndo_tx_timeout = e100_tx_timeout,
 #ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
index f42129d..33076fa 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1085,6 +1085,10 @@ static int e1000_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
hw->subsystem_vendor_id != PCI_VENDOR_ID_VMWARE)
netdev->priv_flags |= IFF_UNICAST_FLT;
 
+   /* MTU range: 46 - 16110 */
+   netdev->min_mtu = ETH_ZLEN - ETH_HLEN;
+   netdev->max_mtu = MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN);
+
adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
 
/* initialize eeprom parameters */
@@ -3549,13 +3553,7 @@ static int e1000_change_mtu(struct net_device *netdev, 
int new_mtu)
 {
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
-   int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
-
-   if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
-   (max_frame > MAX_JUMBO_FRAME_SIZE)) {
-   e_err(probe, "Invalid MTU setting\n");
-   return -EINVAL;
-   }
+   int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
 
/* Adapter-specific max frame size limits. */
switch (hw->mac_type) {
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/netdev.c
index 7017281..8759d92 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -5974,19 +5974,12 @@ static int e1000_change_mtu(struct net_device *netdev, 
int new_mtu)
int max_frame = new_mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
 
/* Jumbo frame support */
-   if ((max_frame > (VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)) &&
+   if ((new_mtu > ETH_DATA_L

[PATCH net-next 07/15] ethernet/realtek: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
8139cp: min_mtu 60, max_mtu 4096

8139too: min_mtu 68, max_mtu 1770

r8169: min_mtu 60, max_mtu depends on chipset, 1500 to 9k-ish

CC: net...@vger.kernel.org
CC: Realtek linux nic maintainers 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/realtek/8139cp.c  |  8 
 drivers/net/ethernet/realtek/8139too.c | 13 -
 drivers/net/ethernet/realtek/r8169.c   |  8 
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/realtek/8139cp.c 
b/drivers/net/ethernet/realtek/8139cp.c
index 5297bf7..b7c89eb 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -1277,10 +1277,6 @@ static int cp_change_mtu(struct net_device *dev, int 
new_mtu)
 {
struct cp_private *cp = netdev_priv(dev);
 
-   /* check for invalid MTU, according to hardware limits */
-   if (new_mtu < CP_MIN_MTU || new_mtu > CP_MAX_MTU)
-   return -EINVAL;
-
/* if network interface not up, no need for complexity */
if (!netif_running(dev)) {
dev->mtu = new_mtu;
@@ -2010,6 +2006,10 @@ static int cp_init_one (struct pci_dev *pdev, const 
struct pci_device_id *ent)
dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
NETIF_F_HIGHDMA;
 
+   /* MTU range: 60 - 4096 */
+   dev->min_mtu = CP_MIN_MTU;
+   dev->max_mtu = CP_MAX_MTU;
+
rc = register_netdev(dev);
if (rc)
goto err_out_iomap;
diff --git a/drivers/net/ethernet/realtek/8139too.c 
b/drivers/net/ethernet/realtek/8139too.c
index da4c2d8..9bc047a 100644
--- a/drivers/net/ethernet/realtek/8139too.c
+++ b/drivers/net/ethernet/realtek/8139too.c
@@ -924,19 +924,10 @@ static int rtl8139_set_features(struct net_device *dev, 
netdev_features_t featur
return 0;
 }
 
-static int rtl8139_change_mtu(struct net_device *dev, int new_mtu)
-{
-   if (new_mtu < 68 || new_mtu > MAX_ETH_DATA_SIZE)
-   return -EINVAL;
-   dev->mtu = new_mtu;
-   return 0;
-}
-
 static const struct net_device_ops rtl8139_netdev_ops = {
.ndo_open   = rtl8139_open,
.ndo_stop   = rtl8139_close,
.ndo_get_stats64= rtl8139_get_stats64,
-   .ndo_change_mtu = rtl8139_change_mtu,
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_mac_address= rtl8139_set_mac_address,
.ndo_start_xmit = rtl8139_start_xmit,
@@ -1022,6 +1013,10 @@ static int rtl8139_init_one(struct pci_dev *pdev,
dev->hw_features |= NETIF_F_RXALL;
dev->hw_features |= NETIF_F_RXFCS;
 
+   /* MTU range: 68 - 1770 */
+   dev->min_mtu = ETH_MIN_MTU;
+   dev->max_mtu = MAX_ETH_DATA_SIZE;
+
/* tp zeroed and aligned in alloc_etherdev */
tp = netdev_priv(dev);
 
diff --git a/drivers/net/ethernet/realtek/r8169.c 
b/drivers/net/ethernet/realtek/r8169.c
index e55638c..b698ea5 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -6673,10 +6673,6 @@ static int rtl8169_change_mtu(struct net_device *dev, 
int new_mtu)
 {
struct rtl8169_private *tp = netdev_priv(dev);
 
-   if (new_mtu < ETH_ZLEN ||
-   new_mtu > rtl_chip_infos[tp->mac_version].jumbo_max)
-   return -EINVAL;
-
if (new_mtu > ETH_DATA_LEN)
rtl_hw_jumbo_enable(tp);
else
@@ -8430,6 +8426,10 @@ static int rtl_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
dev->hw_features |= NETIF_F_RXALL;
dev->hw_features |= NETIF_F_RXFCS;
 
+   /* MTU range: 60 - hw-specific max */
+   dev->min_mtu = ETH_ZLEN;
+   dev->max_mtu = rtl_chip_infos[chipset].jumbo_max;
+
tp->hw_start = cfg->hw_start;
tp->event_slow = cfg->event_slow;
 
-- 
2.10.0



[PATCH net-next 05/15] ethernet/mellanox: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
mlx4: min_mtu 46, max_mtu depends on hardware

mlx5: min_mtu 68, max_mtu depends on hardware

CC: net...@vger.kernel.org
CC: Tariq Toukan 
CC: Saeed Mahameed 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c|  8 
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 24 ++-
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 7e703be..bf35ac4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2205,10 +2205,6 @@ static int mlx4_en_change_mtu(struct net_device *dev, 
int new_mtu)
en_dbg(DRV, priv, "Change MTU called - current:%d new:%d\n",
 dev->mtu, new_mtu);
 
-   if ((new_mtu < MLX4_EN_MIN_MTU) || (new_mtu > priv->max_mtu)) {
-   en_err(priv, "Bad MTU size:%d.\n", new_mtu);
-   return -EPERM;
-   }
if (priv->xdp_ring_num && MLX4_EN_EFF_MTU(new_mtu) > FRAG_SZ0) {
en_err(priv, "MTU size:%d requires frags but XDP running\n",
   new_mtu);
@@ -3288,6 +3284,10 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
port,
dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM;
}
 
+   /* MTU range: 46 - hw-specific max */
+   dev->min_mtu = MLX4_EN_MIN_MTU;
+   dev->max_mtu = priv->max_mtu;
+
mdev->pndev[port] = dev;
mdev->upper[port] = NULL;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7eaf380..03183eb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2851,31 +2851,13 @@ static int mlx5e_set_features(struct net_device *netdev,
return err ? -EINVAL : 0;
 }
 
-#define MXL5_HW_MIN_MTU 64
-#define MXL5E_MIN_MTU (MXL5_HW_MIN_MTU + ETH_FCS_LEN)
-
 static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
 {
struct mlx5e_priv *priv = netdev_priv(netdev);
-   struct mlx5_core_dev *mdev = priv->mdev;
bool was_opened;
-   u16 max_mtu;
-   u16 min_mtu;
int err = 0;
bool reset;
 
-   mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
-
-   max_mtu = MLX5E_HW2SW_MTU(max_mtu);
-   min_mtu = MLX5E_HW2SW_MTU(MXL5E_MIN_MTU);
-
-   if (new_mtu > max_mtu || new_mtu < min_mtu) {
-   netdev_err(netdev,
-  "%s: Bad MTU (%d), valid range is: [%d..%d]\n",
-  __func__, new_mtu, min_mtu, max_mtu);
-   return -EINVAL;
-   }
-
mutex_lock(&priv->state_lock);
 
reset = !priv->params.lro_en &&
@@ -3835,6 +3817,7 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, 
struct net_device *netdev)
 {
const struct mlx5e_profile *profile;
struct mlx5e_priv *priv;
+   u16 max_mtu;
int err;
 
priv = netdev_priv(netdev);
@@ -3865,6 +3848,11 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, 
struct net_device *netdev)
 
mlx5e_init_l2_addr(priv);
 
+   /* MTU range: 68 - hw-specific max */
+   netdev->min_mtu = ETH_MIN_MTU;
+   mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
+   netdev->max_mtu = MLX5E_HW2SW_MTU(max_mtu);
+
mlx5e_set_dev_port_mtu(netdev);
 
if (profile->enable)
-- 
2.10.0



[PATCH net-next 01/15] ethernet/atheros: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
atl2: min_mtu 40, max_mtu 1504

- Remove a few redundant defines that already have equivalents in
  if_ether.h.

atl1: min_mtu 42, max_mtu 10218

atl1e: min_mtu 42, max_mtu 8170

atl1c: min_mtu 42, max_mtu 6122/1500

- GbE hardware gets a max_mtu of 6122, slower hardware gets 1500.

alx: min_mtu 34, max_mtu 9256

- Not so sure that minimum MTU number is really what was intended, but
  that's what the math actually makes it out to be, due to max_frame
  manipulations and comparison in alx_change_mtu, rather than just
  comparing new_mtu. (I think 68 was the intended min_mtu value).

CC: net...@vger.kernel.org
CC: Jay Cliburn 
CC: Chris Snook 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/atheros/alx/hw.h   |  1 -
 drivers/net/ethernet/atheros/alx/main.c | 10 ++
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 41 -
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 12 +++-
 drivers/net/ethernet/atheros/atlx/atl1.c| 15 -
 drivers/net/ethernet/atheros/atlx/atl2.c| 16 +-
 drivers/net/ethernet/atheros/atlx/atl2.h|  3 --
 7 files changed, 47 insertions(+), 51 deletions(-)

diff --git a/drivers/net/ethernet/atheros/alx/hw.h 
b/drivers/net/ethernet/atheros/alx/hw.h
index 0191477..e42d7e0 100644
--- a/drivers/net/ethernet/atheros/alx/hw.h
+++ b/drivers/net/ethernet/atheros/alx/hw.h
@@ -351,7 +351,6 @@ struct alx_rrd {
 #define ALX_MAX_JUMBO_PKT_SIZE (9*1024)
 #define ALX_MAX_TSO_PKT_SIZE   (7*1024)
 #define ALX_MAX_FRAME_SIZE ALX_MAX_JUMBO_PKT_SIZE
-#define ALX_MIN_FRAME_SIZE (ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN)
 
 #define ALX_MAX_RX_QUEUES  8
 #define ALX_MAX_TX_QUEUES  4
diff --git a/drivers/net/ethernet/atheros/alx/main.c 
b/drivers/net/ethernet/atheros/alx/main.c
index c0f84b7..eccbacd 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -892,6 +892,9 @@ static int alx_init_sw(struct alx_priv *alx)
hw->smb_timer = 400;
hw->mtu = alx->dev->mtu;
alx->rxbuf_size = ALX_MAX_FRAME_LEN(hw->mtu);
+   /* MTU range: 34 - 9256 */
+   alx->dev->min_mtu = 34;
+   alx->dev->max_mtu = ALX_MAX_FRAME_LEN(ALX_MAX_FRAME_SIZE);
alx->tx_ringsz = 256;
alx->rx_ringsz = 512;
hw->imt = 200;
@@ -994,13 +997,6 @@ static int alx_change_mtu(struct net_device *netdev, int 
mtu)
struct alx_priv *alx = netdev_priv(netdev);
int max_frame = ALX_MAX_FRAME_LEN(mtu);
 
-   if ((max_frame < ALX_MIN_FRAME_SIZE) ||
-   (max_frame > ALX_MAX_FRAME_SIZE))
-   return -EINVAL;
-
-   if (netdev->mtu == mtu)
-   return 0;
-
netdev->mtu = mtu;
alx->hw.mtu = mtu;
alx->rxbuf_size = max(max_frame, ALX_DEF_RXBUF_SIZE);
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c 
b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index a3200ea..773d3b7 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -519,6 +519,26 @@ static int atl1c_set_features(struct net_device *netdev,
return 0;
 }
 
+static void atl1c_set_max_mtu(struct net_device *netdev)
+{
+   struct atl1c_adapter *adapter = netdev_priv(netdev);
+   struct atl1c_hw *hw = &adapter->hw;
+
+   switch (hw->nic_type) {
+   /* These (GbE) devices support jumbo packets, max_mtu 6122 */
+   case athr_l1c:
+   case athr_l1d:
+   case athr_l1d_2:
+   netdev->max_mtu = MAX_JUMBO_FRAME_SIZE -
+ (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
+   break;
+   /* The 10/100 devices don't support jumbo packets, max_mtu 1500 */
+   default:
+   netdev->max_mtu = ETH_DATA_LEN;
+   break;
+   }
+}
+
 /**
  * atl1c_change_mtu - Change the Maximum Transfer Unit
  * @netdev: network interface device structure
@@ -529,22 +549,9 @@ static int atl1c_set_features(struct net_device *netdev,
 static int atl1c_change_mtu(struct net_device *netdev, int new_mtu)
 {
struct atl1c_adapter *adapter = netdev_priv(netdev);
-   struct atl1c_hw *hw = &adapter->hw;
-   int old_mtu   = netdev->mtu;
-   int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
-
-   /* Fast Ethernet controller doesn't support jumbo packet */
-   if (((hw->nic_type == athr_l2c ||
- hw->nic_type == athr_l2c_b ||
- hw->nic_type == athr_l2c_b2) && new_mtu > ETH_DATA_LEN) ||
- max_frame < ETH_ZLEN + ETH_FCS_LEN ||
- max_frame > MAX_JUMBO_FRAME_SIZE) {
-   if (netif_msg_link(adapter))
-   dev_warn(&adapter->pdev->dev, "invalid MTU setting\n");
-   return -EINVAL;
-   }
+
/* set MTU */
-   if (old_mtu != new_mtu && netif_running(netdev)) {
+   if (netif_running(netdev)) {
while (test_and_set_bit(__AT_RESETTING, &adapter->flags))
   

[PATCH net-next 04/15] ethernet/marvell: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
mvneta: min_mtu 68, max_mtu 9676
- mtu validation routine mostly did range check, merge back into
  mvneta_change_mtu for simplicity

mvpp2: min_mtu 68, max_mtu 9676
- mtu validation routine mostly did range check, merge back into
  mvpp2_change_mtu for simplicity

pxa168_eth: min_mtu 68, max_mtu 9500

skge: min_mtu 60, max_mtu 9000

sky2: min_mtu 68, max_mtu 1500 or 9000, depending on hw

CC: net...@vger.kernel.org
CC: Mirko Lindner 
CC: Stephen Hemminger 
CC: Thomas Petazzoni 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/marvell/mvneta.c | 36 +--
 drivers/net/ethernet/marvell/mvpp2.c  | 36 ---
 drivers/net/ethernet/marvell/pxa168_eth.c |  7 +++---
 drivers/net/ethernet/marvell/skge.c   |  7 +++---
 drivers/net/ethernet/marvell/sky2.c   | 18 +++-
 5 files changed, 35 insertions(+), 69 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index 5cb07c2..b85819e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3024,29 +3024,6 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
mvneta_rx_reset(pp);
 }
 
-/* Return positive if MTU is valid */
-static int mvneta_check_mtu_valid(struct net_device *dev, int mtu)
-{
-   if (mtu < 68) {
-   netdev_err(dev, "cannot change mtu to less than 68\n");
-   return -EINVAL;
-   }
-
-   /* 9676 == 9700 - 20 and rounding to 8 */
-   if (mtu > 9676) {
-   netdev_info(dev, "Illegal MTU value %d, round to 9676\n", mtu);
-   mtu = 9676;
-   }
-
-   if (!IS_ALIGNED(MVNETA_RX_PKT_SIZE(mtu), 8)) {
-   netdev_info(dev, "Illegal MTU value %d, rounding to %d\n",
-   mtu, ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8));
-   mtu = ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8);
-   }
-
-   return mtu;
-}
-
 static void mvneta_percpu_enable(void *arg)
 {
struct mvneta_port *pp = arg;
@@ -3067,9 +3044,11 @@ static int mvneta_change_mtu(struct net_device *dev, int 
mtu)
struct mvneta_port *pp = netdev_priv(dev);
int ret;
 
-   mtu = mvneta_check_mtu_valid(dev, mtu);
-   if (mtu < 0)
-   return -EINVAL;
+   if (!IS_ALIGNED(MVNETA_RX_PKT_SIZE(mtu), 8)) {
+   netdev_info(dev, "Illegal MTU value %d, rounding to %d\n",
+   mtu, ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8));
+   mtu = ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8);
+   }
 
dev->mtu = mtu;
 
@@ -4154,6 +4133,11 @@ static int mvneta_probe(struct platform_device *pdev)
dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE;
dev->gso_max_segs = MVNETA_MAX_TSO_SEGS;
 
+   /* MTU range: 68 - 9676 */
+   dev->min_mtu = ETH_MIN_MTU;
+   /* 9676 == 9700 - 20 and rounding to 8 */
+   dev->max_mtu = 9676;
+
err = register_netdev(dev);
if (err < 0) {
dev_err(&pdev->dev, "failed to register\n");
diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 60227a3..c8bf155 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5453,29 +5453,6 @@ static void mvpp2_stop_dev(struct mvpp2_port *port)
phy_stop(ndev->phydev);
 }
 
-/* Return positive if MTU is valid */
-static inline int mvpp2_check_mtu_valid(struct net_device *dev, int mtu)
-{
-   if (mtu < 68) {
-   netdev_err(dev, "cannot change mtu to less than 68\n");
-   return -EINVAL;
-   }
-
-   /* 9676 == 9700 - 20 and rounding to 8 */
-   if (mtu > 9676) {
-   netdev_info(dev, "illegal MTU value %d, round to 9676\n", mtu);
-   mtu = 9676;
-   }
-
-   if (!IS_ALIGNED(MVPP2_RX_PKT_SIZE(mtu), 8)) {
-   netdev_info(dev, "illegal MTU value %d, round to %d\n", mtu,
-   ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8));
-   mtu = ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8);
-   }
-
-   return mtu;
-}
-
 static int mvpp2_check_ringparam_valid(struct net_device *dev,
   struct ethtool_ringparam *ring)
 {
@@ -5717,10 +5694,10 @@ static int mvpp2_change_mtu(struct net_device *dev, int 
mtu)
struct mvpp2_port *port = netdev_priv(dev);
int err;
 
-   mtu = mvpp2_check_mtu_valid(dev, mtu);
-   if (mtu < 0) {
-   err = mtu;
-   goto error;
+   if (!IS_ALIGNED(MVPP2_RX_PKT_SIZE(mtu), 8)) {
+   netdev_info(dev, "illegal MTU value %d, round to %d\n", mtu,
+   ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8));
+   mtu = ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8);
}
 
if (!netif_running(dev)) {
@@ -6212,6 +6189,11 @@ static int mvpp2_port_probe(struct platform_device *pdev,
dev->hw_features |= features | NETIF_F_RXCSUM | NETIF_F_GRO;
dev-

[PATCH net-next 06/15] ethernet/qlogic: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
qede: min_mtu 46, max_mtu 9600
- Put define for max in qede.h

qlcnic: min_mtu 68, max_mtu 9600

CC: net...@vger.kernel.org
CC dept-gelinuxnic...@qlogic.com
CC: Yuval Mintz 
CC: Ariel Elior 
Signed-off-by: Jarod Wilson 
---
 drivers/net/ethernet/qlogic/qede/qede.h  | 5 +++--
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c  | 8 
 drivers/net/ethernet/qlogic/qede/qede_main.c | 4 
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c   | 6 --
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 4 
 5 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index f50e527..9135b9d 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -362,8 +362,9 @@ void qede_recycle_rx_bd_ring(struct qede_rx_queue *rxq, 
struct qede_dev *edev,
 #define NUM_TX_BDS_MIN 128
 #define NUM_TX_BDS_DEF NUM_TX_BDS_MAX
 
-#define QEDE_MIN_PKT_LEN   64
-#define QEDE_RX_HDR_SIZE   256
+#define QEDE_MIN_PKT_LEN   64
+#define QEDE_RX_HDR_SIZE   256
+#define QEDE_MAX_JUMBO_PACKET_SIZE 9600
 #definefor_each_queue(i) for (i = 0; i < edev->num_queues; i++)
 
 #endif /* _QEDE_H_ */
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index 25a9b29..b7dbb44 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -723,19 +723,11 @@ static void qede_update_mtu(struct qede_dev *edev, union 
qede_reload_args *args)
 }
 
 /* Netdevice NDOs */
-#define ETH_MAX_JUMBO_PACKET_SIZE  9600
-#define ETH_MIN_PACKET_SIZE60
 int qede_change_mtu(struct net_device *ndev, int new_mtu)
 {
struct qede_dev *edev = netdev_priv(ndev);
union qede_reload_args args;
 
-   if ((new_mtu > ETH_MAX_JUMBO_PACKET_SIZE) ||
-   ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) {
-   DP_ERR(edev, "Can't support requested MTU size\n");
-   return -EINVAL;
-   }
-
DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
   "Configuring MTU size of %d\n", new_mtu);
 
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c 
b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 0e483af..4f29865 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -2391,6 +2391,10 @@ static void qede_init_ndev(struct qede_dev *edev)
 
ndev->hw_features = hw_features;
 
+   /* MTU range: 46 - 9600 */
+   ndev->min_mtu = ETH_ZLEN - ETH_HLEN;
+   ndev->max_mtu = QEDE_MAX_JUMBO_PACKET_SIZE;
+
/* Set network device HW mac */
ether_addr_copy(edev->ndev->dev_addr, edev->dev_info.common.hw_mac);
 }
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
index 509b596..838cc0c 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
@@ -1024,12 +1024,6 @@ int qlcnic_change_mtu(struct net_device *netdev, int mtu)
struct qlcnic_adapter *adapter = netdev_priv(netdev);
int rc = 0;
 
-   if (mtu < P3P_MIN_MTU || mtu > P3P_MAX_MTU) {
-   dev_err(&adapter->netdev->dev, "%d bytes < mtu < %d bytes"
-   " not supported\n", P3P_MAX_MTU, P3P_MIN_MTU);
-   return -EINVAL;
-   }
-
rc = qlcnic_fw_cmd_set_mtu(adapter, mtu);
 
if (!rc)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 3ae3968..4c0cce96 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -2342,6 +2342,10 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, 
struct net_device *netdev,
netdev->priv_flags |= IFF_UNICAST_FLT;
netdev->irq = adapter->msix_entries[0].vector;
 
+   /* MTU range: 68 - 9600 */
+   netdev->min_mtu = P3P_MIN_MTU;
+   netdev->max_mtu = P3P_MAX_MTU;
+
err = qlcnic_set_real_num_queues(adapter, adapter->drv_tx_rings,
 adapter->drv_sds_rings);
if (err)
-- 
2.10.0



[PATCH net-next 00/15] ethernet: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
Now that the network stack core min/max MTU checking infrastructure is in
place, time to start making drivers use it. We'll start with the easiest
ones, the ethernet drivers, split roughly by vendor, with a catch-all
patch at the end.

For the most part, every patch does the same essential thing: removes the
MTU range checking from the drivers' ndo_change_mtu function, puts those
ranges into the core net_device min_mtu and max_mtu fields, and where
possible, removes ndo_change_mtu functions entirely.

These patches have all been built through the 0-day build infrastructure
provided by Intel, on top of net-next as of October 17.

Rebasing git tree with these patches can be found here:

  https://github.com/jarodwilson/linux-muck

Jarod Wilson (15):
  ethernet/atheros: use core min/max MTU checking
  ethernet/broadcom: use core min/max MTU checking
  ethernet/intel: use core min/max MTU checking
  ethernet/marvell: use core min/max MTU checking
  ethernet/mellanox: use core min/max MTU checking
  ethernet/qlogic: use core min/max MTU checking
  ethernet/realtek: use core min/max MTU checking
  ethernet/sun: use core min/max MTU checking
  ethernet/dlink: use core min/max MTU checking
  ethernet/neterion: use core min/max MTU checking
  ethernet/cavium: use core min/max MTU checking
  ethernet/ibm: use core min/max MTU checking
  ethernet/tile: use core min/max MTU checking
  ethernet/toshiba: use core min/max MTU checking
  ethernet: use core min/max MTU checking

CC: net...@vger.kernel.org

 drivers/net/ethernet/agere/et131x.c|  7 ++--
 drivers/net/ethernet/altera/altera_tse.h   |  1 -
 drivers/net/ethernet/altera/altera_tse_main.c  | 14 ++--
 drivers/net/ethernet/amd/amd8111e.c|  5 ++-
 drivers/net/ethernet/atheros/alx/hw.h  |  1 -
 drivers/net/ethernet/atheros/alx/main.c| 10 ++
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c| 41 ++
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c| 12 +++
 drivers/net/ethernet/atheros/atlx/atl1.c   | 15 
 drivers/net/ethernet/atheros/atlx/atl2.c   | 16 -
 drivers/net/ethernet/atheros/atlx/atl2.h   |  3 --
 drivers/net/ethernet/broadcom/b44.c|  9 +++--
 drivers/net/ethernet/broadcom/bcm63xx_enet.c   | 35 ++
 drivers/net/ethernet/broadcom/bnx2.c   | 16 -
 drivers/net/ethernet/broadcom/bnx2.h   |  6 ++--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|  6 ++--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c|  8 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c   | 22 +---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  7 ++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.c  |  7 ++--
 drivers/net/ethernet/broadcom/tg3.c|  9 ++---
 drivers/net/ethernet/brocade/bna/bnad.c|  7 ++--
 drivers/net/ethernet/cadence/macb.c| 19 +-
 drivers/net/ethernet/calxeda/xgmac.c   | 20 +++
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 15 +++-
 .../net/ethernet/cavium/liquidio/octeon_network.h  |  2 +-
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c   | 13 ++-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   | 10 +++---
 drivers/net/ethernet/chelsio/cxgb/common.h |  5 +++
 drivers/net/ethernet/chelsio/cxgb/cxgb2.c  | 18 --
 drivers/net/ethernet/chelsio/cxgb/pm3393.c |  8 +
 drivers/net/ethernet/chelsio/cxgb/vsc7326.c|  5 ---
 drivers/net/ethernet/cisco/enic/enic_main.c|  7 ++--
 drivers/net/ethernet/cisco/enic/enic_res.h |  2 +-
 drivers/net/ethernet/dlink/dl2k.c  | 22 +++-
 drivers/net/ethernet/dlink/sundance.c  |  6 ++--
 drivers/net/ethernet/freescale/gianfar.c   |  9 ++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  |  3 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 11 +++---
 drivers/net/ethernet/ibm/ehea/ehea_main.c  | 13 +++
 drivers/net/ethernet/ibm/emac/core.c   |  9 ++---
 drivers/net/ethernet/intel/e100.c  |  9 -
 drivers/net/ethernet/intel/e1000/e1000_main.c  | 12 +++
 drivers/net/ethernet/intel/e1000e/netdev.c | 14 
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c| 15 +++-
 drivers/net/ethernet/intel/i40e/i40e_main.c| 10 +++---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c|  8 ++---
 drivers/net/ethernet/intel/igb/e1000_defines.h |  3 +-
 drivers/net/ethernet/intel/igb/igb_main.c  | 15 +++-
 drivers/net/ethernet/intel/igbvf/defines.h |  3 +-
 drivers/net/ethernet/intel/igbvf/netdev.c  | 14 +++-
 drivers/net/ethernet/intel/ixgb/ixgb_main.c| 16 +++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 11 +++---
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c  | 33 -
 dri

Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

2016-10-17 Thread Jeff Moyer
Peter Zijlstra  writes:

> On Mon, Oct 17, 2016 at 03:40:24PM -0400, Jeff Moyer wrote:
>> Christoph Hellwig  writes:
>> 
>> > On Mon, Oct 17, 2016 at 02:19:47PM -0400, Jeff Moyer wrote:
>> >> This ends up being a call to __sb_end_write:
>> >> 
>> >> void __sb_end_write(struct super_block *sb, int level)
>> >> {
>> >> percpu_up_read(sb->s_writers.rw_sem + level-1);
>> >> }
>> >> 
>> >> Nothing guarantees that submission and completion happen on the same
>> >> CPU.  Is this safe?
>> >
>> > Good point.  From my reading of the percpu_rwsem implementation it
>> > is not safe to release it from a different CPU.  Which makes me
>> > wonder how we can protect aio writes properly here..
>> 
>> Could we just change percpu_rw_semaphore->read_count to be a signed
>> integer?  The down_write path sums up the counters from all cpus...
>
> To what point?

Duh, nevermind.  You're right, it should work as-is.

-Jeff


Re: [PATCH net-next 00/15] ethernet: use core min/max MTU checking

2016-10-17 Thread David Miller
From: Jarod Wilson 
Date: Mon, 17 Oct 2016 15:54:02 -0400

> For the most part, every patch does the same essential thing: removes the
> MTU range checking from the drivers' ndo_change_mtu function, puts those
> ranges into the core net_device min_mtu and max_mtu fields, and where
> possible, removes ndo_change_mtu functions entirely.

Jarod, please read my other posting.

You've positively broken the maximum MTU for all of these drivers.

That's not cool.

And this series fixing things doesn't make things better, because now
we've significanyly broken bisection for anyone running into this
regression.

You should have arranged this in such a way that the drivers needing
> 1500 byte MTU were not impacted at all by your changes, but that
isn't what happened.


Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

2016-10-17 Thread Jeff Moyer
Christoph Hellwig  writes:

> From: Jan Kara 
>
> Currently we dropped freeze protection of aio writes just after IO was
> submitted. Thus aio write could be in flight while the filesystem was
> frozen and that could result in unexpected situation like aio completion
> wanting to convert extent type on frozen filesystem. Testcase from
> Dmitry triggering this is like:
>
> for ((i=0;i<60;i++));do fsfreeze -f /mnt ;sleep 1;fsfreeze -u /mnt;done &
> fio --bs=4k --ioengine=libaio --iodepth=128 --size=1g --direct=1 \
> --runtime=60 --filename=/mnt/file --name=rand-write --rw=randwrite
>
> Fix the problem by dropping freeze protection only once IO is completed
> in aio_complete().
>
> [hch: The above was the changelog of the original patch from Jan.
>  It turns out that it fixes something even more important - a use
>  after free of the file structucture given that the direct I/O
>  code calls fput and potentially drops the last reference to it in
>  aio_complete.  Together with two racing threads and a zero sized
>  I/O this seems easily exploitable]
>
> Reported-by: Dmitry Monakhov 
> Signed-off-by: Jan Kara 
> [hch: switch to use __sb_writers_acquired and file_inode(file),
>   updated changelog]
> Signed-off-by: Christoph Hellwig 

Reviewed-by: Jeff Moyer 


Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

2016-10-17 Thread Christoph Hellwig
On Mon, Oct 17, 2016 at 04:04:00PM -0400, Jeff Moyer wrote:
> >> Could we just change percpu_rw_semaphore->read_count to be a signed
> >> integer?  The down_write path sums up the counters from all cpus...
> >
> > To what point?
> 
> Duh, nevermind.  You're right, it should work as-is.

Ok, thanks.  That also explains why I didn't see any splat in
xfstests..


Re: [PATCH v3 net-next 2/2] net: deprecate eth_change_mtu, remove usage

2016-10-17 Thread Jarod Wilson
On Mon, Oct 17, 2016 at 01:25:53PM -0400, David Miller wrote:
> From: Jakub Kicinski 
> Date: Mon, 17 Oct 2016 18:20:49 +0100
> 
> > Hm.  I must be missing something really obvious.  I just booted
> > net-next an hour ago and couldn't set MTU to anything larger than 1500
> > on either nfp or igb.  As far as I can read the code it will set the
> > max_mtu to 1500 in setup_ether() but none of the jumbo-capable drivers
> > had been touched by Jarod so far...
> 
> Indeed.
> 
> Jarod, this doesn't work.
> 
> I guess the idea was that if the driver overrides ndo_change_mtu and
> enforeced it's limits there, the driver would still work after your
> changes.
> 
> But that isn't what is happening, look at the IGB example.
> 
> It uses ether_setup(), which sets those new defaults, but now when
> the MTU is changed you enforce those default min/max before the
> driver's ->ndo_change_mtu() has a change to step in front and make
> the decision on it's own.
> 
> This means your changes pretty much did indeed break a lot of
> drivers's ability to set larger than a 1500 byte MTU.

Argh. Yeah, I see it now. I was primarily operating with the follow-on
patches also in play, which do touch all the ethernet drivers and set
max_mtu to match current behavior, didn't consider the max_mtu case where
only the initial patches were applied and the follow-on ones weren't. I've
sent that set, which should theoretically make this problem go away, but I
can also try to rework things if need be to restore intermediate jumbo
frames functionality. (And there are actually non-ethernet devices that
also call ether_setup and may or may not have larger than 1500 mtu that
aren't yet addressed by that follow-on set).

-- 
Jarod Wilson
ja...@redhat.com



Re: [PATCH 0/8] infiniband: Remove semaphores

2016-10-17 Thread Arnd Bergmann
On Monday, October 17, 2016 9:57:34 AM CEST Bart Van Assche wrote:
> On 10/17/2016 09:30 AM, Binoy Jayan wrote:
> > These are a set of patches which removes semaphores from infiniband.
> > These are part of a bigger effort to eliminate all semaphores from the
> > linux kernel.
> 
> Hello Binoy,
> 
> Why do you think it would be a good idea to eliminate all semaphores 
> from the Linux kernel? I don't know anyone who doesn't consider 
> semaphores a useful abstraction.

There are a several reasons why the semaphores as defined in the
kernel are bad and we should get rid of them:

- semaphores cannot be analysed using lockdep, since they don't
  always fit in the simpler 'mutex' semantics

- those that are basically mutexes should be converted to mutexes
  for efficiency and consistency anyway

- the semaphores that are not just used as mutexes are typically
  used as completions and should just be converted to completions
  for simplicity

- when running a preempt-rt kernel, semaphores suffer from priority
  inversion problems, while mutexes use use priority inheritance
  as a countermeasure

There are very few remaining semaphores in the kernel and generally
speaking we'd be better off removing them all so no new users
show up in the future. Most of them are trivial to replace with
mutexes or completions. For the ones that are not trivially replaced,
we have to look at each one and decide what to do about them,
there usually is some solution that actually improves the code.

Using an open-coded semaphore as a replacement is probably just
the last resort that we can consider once we are down to the
last handful of users. I haven't looked at drivers/infiniband/
yet for this, but I believe that drivers/acpi/ is a case for
which I see no better alternative (the AML bytecode requires
counting semaphore semantics).

Arnd


[PATCH RFC 1/3] fpu/x86: add make_fpregs_active(_newstate) helper functions

2016-10-17 Thread riel
From: Rik van Riel 

Add helper functions that ensure a task's floating point registers are
set up the way they need to be - either with the task's floating point
state loaded in, or ready to accept a task's new floating point state.

These helpers can be called from code that accesses the floating point
state from a preemptible state, in preparation for the lazier floating
point loading code, using loops like this:

do {
make_fpregs_active();
...
} while (unlikely(!fpregs_active()));

This way a task can safely do things like saving the floating point
state of a task to user space memory (the signal handling code does
this), without requiring that the floating point state is restored
at every context switch.

If the floating point registers are still active when leaving the
loop, the floating point state has ended up in its destination
(registers or memory) in one piece, and will be saved at the next
context switch.

When the floating point state is already present, these functions
do nothing.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 53 +
 1 file changed, 48 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 621ba3bfa2a7..d40deb337807 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -473,6 +473,14 @@ static inline void copy_kernel_to_fpregs(union 
fpregs_state *fpstate)
 extern int copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int 
size);
 
 /*
+ * Is this thread using floating point state.
+ */
+static inline int fpstate_active(void)
+{
+   return current->thread.fpu.fpstate_active;
+}
+
+/*
  * FPU context switch related helper methods:
  */
 
@@ -548,6 +556,44 @@ static inline int fpregs_active(void)
 }
 
 /*
+ * Ensure the floating point registers are ready for this task, and
+ * contain the task's floating point state.
+ *
+ * The loadnew variant can be used when loading new floating point
+ * state, and the old floating point register state does not matter.
+ */
+static inline void __make_fpregs_active(struct fpu *fpu, int cpu)
+{
+   if (!fpregs_state_valid(fpu, cpu))
+   copy_kernel_to_fpregs(&fpu->state);
+   fpregs_activate(fpu);
+}
+
+static inline void make_fpregs_active(void)
+{
+   struct fpu *fpu = ¤t->thread.fpu;
+
+   if (fpregs_active())
+   return;
+
+   preempt_disable();
+   __make_fpregs_active(fpu, raw_smp_processor_id());
+   preempt_enable();
+}
+
+static inline void make_fpregs_active_loadnew(void)
+{
+   struct fpu *fpu = ¤t->thread.fpu;
+
+   if (fpregs_active())
+   return;
+
+   preempt_disable();
+   fpregs_activate(fpu);
+   preempt_enable();
+}
+
+/*
  * FPU state switching for scheduling.
  *
  * This is a two-stage process:
@@ -587,11 +633,8 @@ static inline void switch_fpu_finish(struct fpu *new_fpu, 
int cpu)
bool preload = static_cpu_has(X86_FEATURE_FPU) &&
   new_fpu->fpstate_active;
 
-   if (preload) {
-   if (!fpregs_state_valid(new_fpu, cpu))
-   copy_kernel_to_fpregs(&new_fpu->state);
-   fpregs_activate(new_fpu);
-   }
+   if (preload)
+   __make_fpregs_active(new_fpu, cpu);
 }
 
 /*
-- 
2.7.4



[PATCH RFC 0/3] x86/fpu: defer FPU state loading until return to userspace

2016-10-17 Thread riel
These patches defer FPU state loading until return to userspace.

This has the advantage of not clobbering the FPU state of one task
with that of another, when that other task only stays in kernel mode.

It also allows us to skip the FPU restore in kernel_fpu_end(), which
will help tasks that do multiple invokations of kernel_fpu_begin/end
without returning to userspace, for example KVM VCPU tasks.

We could also skip the restore of the KVM VCPU guest FPU state at
guest entry time, if it is still valid, but I have not implemented
that yet.

The code that loads FPU context directly into registers from user
space memory, or saves directly to user space memory, is wrapped
in a retry loop, that ensures the FPU state is correctly set up
at the start, and verifies that it is still valid at the end.

I have stress tested these patches with various FPU test programs,
and things seem to survive.

However, I have not found any good test suites that mix FPU
use and signal handlers. Close scrutiny of these patches would
be appreciated.



[PATCH RFC 2/3] x86/fpu: prepare misc FPU state handling code for lazy FPU loading

2016-10-17 Thread riel
From: Rik van Riel 

The patch that defers loading of FPU state until return to userspace
can result in tasks with an FPU state not having that FPU state loaded
in certain paths in the kernel, which want to access it.

Wrap those code paths in a loop that ensures the FPU state is valid before
any operations begin, and still valid afterwards.

Right now this code does nothing, since the FPU state of a task is loaded
at context switch time and will always be valid.

After the patch that defers loading of FPU state, the condition at the end
of the loop will ensure that the operation is restarted if the task was
context switched away during the operation.

Some of these loops involve code that involve copying FPU state from
or to user space memory. The potential for page faults mean this code
cannot be made non-preemptible, making a retry loop the easiest option.

Sufficiently fast operations to or from kernel memory can simply be run
with preempt disabled.

Signed-off-by: Rik van Riel 
---
 arch/x86/kernel/fpu/core.c   |  2 ++
 arch/x86/kernel/fpu/signal.c | 28 +---
 arch/x86/kernel/fpu/xstate.c |  5 +
 arch/x86/mm/pkeys.c  | 11 +++
 4 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 30f11ab6c07e..34ba9d47c20f 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -490,11 +490,13 @@ void fpu__clear(struct fpu *fpu)
/* FPU state will be reallocated lazily at the first use. */
fpu__drop(fpu);
} else {
+   preempt_disable();
if (!fpu->fpstate_active) {
fpu__activate_curr(fpu);
user_fpu_begin();
}
copy_init_fpstate_to_fpregs();
+   preempt_enable();
}
 }
 
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 83c23c230b4c..15128532aa81 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -121,12 +121,16 @@ static inline int copy_fpregs_to_sigframe(struct 
xregs_state __user *buf)
 {
int err;
 
-   if (use_xsave())
-   err = copy_xregs_to_user(buf);
-   else if (use_fxsr())
-   err = copy_fxregs_to_user((struct fxregs_state __user *) buf);
-   else
-   err = copy_fregs_to_user((struct fregs_state __user *) buf);
+   do {
+   make_fpregs_active();
+
+   if (use_xsave())
+   err = copy_xregs_to_user(buf);
+   else if (use_fxsr())
+   err = copy_fxregs_to_user((struct fxregs_state __user 
*) buf);
+   else
+   err = copy_fregs_to_user((struct fregs_state __user *) 
buf);
+   } while (unlikely(!fpregs_active()));
 
if (unlikely(err) && __clear_user(buf, fpu_user_xstate_size))
err = -EFAULT;
@@ -350,11 +354,13 @@ static int __fpu__restore_sig(void __user *buf, void 
__user *buf_fx, int size)
 * For 64-bit frames and 32-bit fsave frames, restore the user
 * state to the registers directly (with exceptions handled).
 */
-   user_fpu_begin();
-   if (copy_user_to_fpregs_zeroing(buf_fx, xfeatures, fx_only)) {
-   fpu__clear(fpu);
-   return -1;
-   }
+   do {
+   user_fpu_begin();
+   if (copy_user_to_fpregs_zeroing(buf_fx, xfeatures, 
fx_only)) {
+   fpu__clear(fpu);
+   return -1;
+   }
+   } while (unlikely(!fpregs_active()));
}
 
return 0;
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 76bc2a1a3a79..798cfb242b18 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -896,6 +896,9 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int 
pkey,
/* Shift the bits in to the correct place in PKRU for pkey: */
new_pkru_bits <<= pkey_shift;
 
+   preempt_disable();
+   make_fpregs_active();
+
/* Get old PKRU and mask off any old bits in place: */
old_pkru = read_pkru();
old_pkru &= ~((PKRU_AD_BIT|PKRU_WD_BIT) << pkey_shift);
@@ -903,6 +906,8 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int 
pkey,
/* Write old part along with new part: */
write_pkru(old_pkru | new_pkru_bits);
 
+   preempt_enable();
+
return 0;
 }
 
diff --git a/arch/x86/mm/pkeys.c b/arch/x86/mm/pkeys.c
index e8c474451928..9eba07353404 100644
--- a/arch/x86/mm/pkeys.c
+++ b/arch/x86/mm/pkeys.c
@@ -32,10 +32,13 @@ int __execute_only_pkey(struct mm_struct *mm)
 * can make fpregs inactive.
 */
preempt_disable();
-   if (fpregs_active() &&
-   !__pkru_allows_r

[PATCH RFC 3/3] x86/fpu: defer FPU state load until return to userspace

2016-10-17 Thread riel
From: Rik van Riel 

Defer loading of FPU state until return to userspace. This gives
the kernel the potential to skip loading FPU state for tasks that
stay in kernel mode, or for tasks that end up with repeated
invocations of kernel_fpu_begin.

It also increases the chances that a task's FPU state will remain
valid in the FPU registers until it is scheduled back in, allowing
us to skip restoring that task's FPU state altogether.

This also prepares the ground work for not having to restore
qemu userspace FPU state in KVM VCPU threads, when merely returning
to the host kernel because the guest went idle, or is running a
kernel thread. That functionality will come in a later patch.

Signed-off-by: Rik van Riel 
---
 arch/x86/entry/common.c |  9 +
 arch/x86/include/asm/fpu/api.h  |  5 +
 arch/x86/include/asm/fpu/internal.h | 13 +
 arch/x86/include/asm/thread_info.h  |  4 +++-
 arch/x86/kernel/fpu/core.c  | 28 
 arch/x86/kernel/process_32.c|  5 ++---
 arch/x86/kernel/process_64.c|  5 ++---
 7 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index bdd9cc59d20f..0c11ee22f90b 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include 
@@ -189,6 +190,14 @@ __visible inline void prepare_exit_to_usermode(struct 
pt_regs *regs)
if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
exit_to_usermode_loop(regs, cached_flags);
 
+   /* Reload ti->flags; we may have rescheduled above. */
+   cached_flags = READ_ONCE(ti->flags);
+
+   if (unlikely(cached_flags & _TIF_LOAD_FPU)) {
+   clear_thread_flag(TIF_LOAD_FPU);
+   switch_fpu_return();
+   }
+
 #ifdef CONFIG_COMPAT
/*
 * Compat syscalls set TS_COMPAT.  Make sure we clear it before
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 1429a7c736db..d7ef49a03b51 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -37,6 +37,11 @@ extern int  irq_ts_save(void);
 extern void irq_ts_restore(int TS_state);
 
 /*
+ * Load the task FPU state before returning to userspace.
+ */
+extern void switch_fpu_return(void);
+
+/*
  * Query the presence of one or more xfeatures. Works on any legacy CPU as 
well.
  *
  * If 'feature_name' is set then put a human-readable description of
diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index d40deb337807..0c059b41 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -601,8 +601,8 @@ static inline void make_fpregs_active_loadnew(void)
  *  - switch_fpu_prepare() saves the old state.
  *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state as
- *necessary.
+ *  - switch_fpu_finish() sets TIF_LOAD_FPU; the floating point state
+ *will get loaded on return to userspace, or when the kernel needs it.
  */
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)
@@ -628,13 +628,10 @@ switch_fpu_prepare(struct fpu *old_fpu, int cpu)
  * Set up the userspace FPU context for the new task, if the task
  * has used the FPU.
  */
-static inline void switch_fpu_finish(struct fpu *new_fpu, int cpu)
+static inline void switch_fpu_finish(void)
 {
-   bool preload = static_cpu_has(X86_FEATURE_FPU) &&
-  new_fpu->fpstate_active;
-
-   if (preload)
-   __make_fpregs_active(new_fpu, cpu);
+   if (static_cpu_has(X86_FEATURE_FPU))
+   set_thread_flag(TIF_LOAD_FPU);
 }
 
 /*
diff --git a/arch/x86/include/asm/thread_info.h 
b/arch/x86/include/asm/thread_info.h
index 2aaca53c0974..9941d118f2cc 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -90,6 +90,7 @@ struct task_struct;
 #define TIF_SYSCALL_TRACEPOINT 28  /* syscall tracepoint instrumentation */
 #define TIF_ADDR32 29  /* 32-bit address space on 64 bits */
 #define TIF_X3230  /* 32-bit native x86-64 binary 
*/
+#define TIF_LOAD_FPU   31  /* load FPU on return to userspace */
 
 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
@@ -112,6 +113,7 @@ struct task_struct;
 #define _TIF_SYSCALL_TRACEPOINT(1 << TIF_SYSCALL_TRACEPOINT)
 #define _TIF_ADDR32(1 << TIF_ADDR32)
 #define _TIF_X32   (1 << TIF_X32)
+#define _TIF_LOAD_FPU  (1 << TIF_LOAD_FPU)
 
 /*
  * work to do in syscall_trace_enter().  Also includes TIF_NOHZ for
@@ -125,7 +127,7 @@ struct task_struct;
 /* work to do on any return to user space */
 #define _TIF_ALLWORK_MASK  \
((0xFF

Re: [linux-sunxi] [PATCH 2/5] pwm: sun4i: Add support for PWM controller on sun6i SoCs

2016-10-17 Thread Maxime Ripard
Hi Icenowy,

On Sun, Oct 16, 2016 at 10:29:17PM +0800, Icenowy Zheng wrote:
> Hi,
> 
> 14.10.2016, 20:58, "Maxime Ripard" :
> > Hi,
> >
> > On Wed, Oct 12, 2016 at 04:10:03PM +0800, Icenowy Zheng wrote:
> >>  > On Wed, Oct 12, 2016 at 12:20 PM, Icenowy Zheng  
> >> wrote:
> >>  > > The PWM controller in A31 is different with other Allwinner SoCs, with
> >>  > > a control register per channel (in other SoCs the control register is
> >>  > > shared), and each channel are allocated 16 bytes of address (but only 
> >> 8
> >>  > > bytes are used.). The register map in one channel is just like a
> >>  > > single-channel A10 PWM controller, however, A31 have a different
> >>  > > prescaler table than other SoCs.
> >>  > >
> >>  > > In order to use the driver for all 4 channels, device nodes should be
> >>  > > created per channel.
> >>  >
> >>  > I think Maxime wants you to support the different register offsets
> >>  > in this driver, and have all 4 channels in the same device (node).
> >>
> >>  I think that will make the code much more complex... And in
> >>  hardware there may also be 4 controllers... as the register is
> >>  aligned at 0x10.
> >
> > You also have to think about it the other way around. This is exposed
> > everywhere as a single device. There may be some undocumented
> > registers hidden somewhere in the memory space of that device. How
> > would you deal with that without touching the device tree?
> 
> Is the reason only they're listed in the one chapter of user manual?

Well, yes, because it is one single device.

> >
> > Exposing this as a single device is the best solution both from the
> > philosophical point of view, but also from a maintainance aspect.
> 
> If we really do so, I will go back to the original patch (pwm-sun6i)
> and merge 4 channels.
> 
> No other PWM block of Allwinner devices uses 4 control registers, and it's
> a significant difference to make it a dedicated driver.
> 
> However, I still think we should have 4 nodes, since the 4 channels can work
> very dedicatedly, with different control register... This can be a reason to 
> see
> them as 4 dedicated controllers.
> 
> (And as PWM uses only oscXX, we cannot judge it according to the clock tree,
> and Occam's Razor will apply to think it's 4 A10-like PWM controller...)
> 
> If we just think it's because it's a whole part, why don't we combine ehci 
> and ohci
> to one driver? Just because we can reuse {e,o}hci-platform...
> 
> It's the same reason to see it as 4 controllers.

Duplicating code is usually not a good idea. In this case, this will
be easier for you to deal with the A31 PWM, but all the rest of the
code (how to enable, disable it, setup the rates, when to enable the
clocks, when to disable them) will be duplicated, even though part of
them are really non-trivial.

Have you looked at reg_field? It really allows you to deal quite
cleanly with those kinds of quirks.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


[RESEND PATCH v4] clk: x86: Add Atom PMC platform clocks

2016-10-17 Thread Irina Tirdea
The BayTrail and CherryTrail platforms provide platform clocks
through their Power Management Controller (PMC).

The SoC supports up to 6 clocks (PMC_PLT_CLK[5:0]) with a
frequency of either 19.2 MHz (PLL) or 25 MHz (XTAL) for BayTrail
an a frequency of 19.2 MHz (XTAL) for CherryTrail. These clocks
are available for general system use, where appropriate, and each
have Control & Frequency register fields associated with them.

For example, the usage for platform clocks suggested in the datasheet
is the following:
  PLT_CLK[2:0] - Camera
  PLT_CLK[3] - Audio Codec
  PLT_CLK[4] -
  PLT_CLK[5] - COMMs

Signed-off-by: Irina Tirdea 
Signed-off-by: Pierre-Louis Bossart 
---
Hi,

This patch specifically enables the audio MCLK required by Baytrail CR
devices (support already merged in Mark's tree).

The patch has already been reviewed by Stephen Boyd [1].
The only remaining question is the one pointed out by Stephen:
"Will there be problems if this merges through clk tree? If so we
could take the clk driver part and the platform data include part
could be duplicated into both trees. Or clk tree could be pulled
into x86?" [1]

Ingo, can you help answer this question (or point me to the right person)?
I am not sure what the process should be in this case.

Thank you,
Irina

[1] http://www.spinics.net/lists/alsa-devel/msg54832.html

Changes from v3:
 - replace devm_kzalloc with devm_kcalloc
 - add x86 architecture maintainers

Changes from v2:
 - move clk platform data structures to a separate include file
 - store clk_hw pointer for the fixed rate clocks

Changes from v1:
 - register the clk device as child of pmc device
 - pass iomem pointer from pmc driver to clk driver to avoid using
pmc_atom_read()/write() and use readl/writel API instead
 - use devm_clk_hw_register/clkdev_hw_create instead of
clk_register/clkdev_create

 arch/x86/Kconfig  |   1 +
 arch/x86/include/asm/pmc_atom.h   |   3 +
 arch/x86/platform/atom/pmc_atom.c |  78 +-
 drivers/clk/x86/Makefile  |   1 +
 drivers/clk/x86/clk-byt-plt.c | 380 ++
 include/linux/platform_data/clk-byt-plt.h |  31 +++
 6 files changed, 491 insertions(+), 3 deletions(-)
 create mode 100644 drivers/clk/x86/clk-byt-plt.c
 create mode 100644 include/linux/platform_data/clk-byt-plt.h

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index bada636..233898e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2756,6 +2756,7 @@ config X86_DMA_REMAP
 config PMC_ATOM
def_bool y
 depends on PCI
+   select COMMON_CLK
 
 source "net/Kconfig"
 
diff --git a/arch/x86/include/asm/pmc_atom.h b/arch/x86/include/asm/pmc_atom.h
index aa8744c..2d310cf 100644
--- a/arch/x86/include/asm/pmc_atom.h
+++ b/arch/x86/include/asm/pmc_atom.h
@@ -50,6 +50,9 @@
BIT_ORED_DEDICATED_IRQ_GPSC | \
BIT_SHARED_IRQ_GPSS)
 
+/* Platform clock control registers */
+#define PMC_CLK_CTL_0  0x60
+
 /* The timers acumulate time spent in sleep state */
 #definePMC_S0IR_TMR0x80
 #definePMC_S0I1_TMR0x84
diff --git a/arch/x86/platform/atom/pmc_atom.c 
b/arch/x86/platform/atom/pmc_atom.c
index 964ff4f..b353893 100644
--- a/arch/x86/platform/atom/pmc_atom.c
+++ b/arch/x86/platform/atom/pmc_atom.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -37,6 +39,11 @@ struct pmc_reg_map {
const struct pmc_bit_map *pss;
 };
 
+struct pmc_data {
+   const struct pmc_reg_map *map;
+   const struct pmc_clk *clks;
+};
+
 struct pmc_dev {
u32 base_addr;
void __iomem *regmap;
@@ -50,6 +57,29 @@ struct pmc_dev {
 static struct pmc_dev pmc_device;
 static u32 acpi_base_addr;
 
+static const struct pmc_clk byt_clks[] = {
+   {
+   .name = "xtal",
+   .freq = 2500,
+   .parent_name = NULL,
+   },
+   {
+   .name = "pll",
+   .freq = 1920,
+   .parent_name = "xtal",
+   },
+   {},
+};
+
+static const struct pmc_clk cht_clks[] = {
+   {
+   .name = "xtal",
+   .freq = 1920,
+   .parent_name = NULL,
+   },
+   {},
+};
+
 static const struct pmc_bit_map d3_sts_0_map[] = {
{"LPSS1_F0_DMA",BIT_LPSS1_F0_DMA},
{"LPSS1_F1_PWM1",   BIT_LPSS1_F1_PWM1},
@@ -169,6 +199,16 @@ struct pmc_dev {
.pss= cht_pss_map,
 };
 
+static const struct pmc_data byt_data = {
+   .map = &byt_reg_map,
+   .clks = byt_clks,
+};
+
+static const struct pmc_data cht_data = {
+   .map = &cht_reg_map,
+   .clks = cht_clks,
+};
+
 static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset)
 {
return readl(pmc->regmap + reg_offset);
@@ -382,10 +422,36 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc)
 }
 #endif /* CONFIG_DEBUG_FS */
 
+static int

Re: [PATCH v3 net-next 2/2] net: deprecate eth_change_mtu, remove usage

2016-10-17 Thread Jarod Wilson
On Mon, Oct 17, 2016 at 04:07:12PM -0400, Jarod Wilson wrote:
> On Mon, Oct 17, 2016 at 01:25:53PM -0400, David Miller wrote:
> > From: Jakub Kicinski 
> > Date: Mon, 17 Oct 2016 18:20:49 +0100
> > 
> > > Hm.  I must be missing something really obvious.  I just booted
> > > net-next an hour ago and couldn't set MTU to anything larger than 1500
> > > on either nfp or igb.  As far as I can read the code it will set the
> > > max_mtu to 1500 in setup_ether() but none of the jumbo-capable drivers
> > > had been touched by Jarod so far...
> > 
> > Indeed.
> > 
> > Jarod, this doesn't work.
> > 
> > I guess the idea was that if the driver overrides ndo_change_mtu and
> > enforeced it's limits there, the driver would still work after your
> > changes.
> > 
> > But that isn't what is happening, look at the IGB example.
> > 
> > It uses ether_setup(), which sets those new defaults, but now when
> > the MTU is changed you enforce those default min/max before the
> > driver's ->ndo_change_mtu() has a change to step in front and make
> > the decision on it's own.
> > 
> > This means your changes pretty much did indeed break a lot of
> > drivers's ability to set larger than a 1500 byte MTU.
> 
> Argh. Yeah, I see it now. I was primarily operating with the follow-on
> patches also in play, which do touch all the ethernet drivers and set
> max_mtu to match current behavior, didn't consider the max_mtu case where
> only the initial patches were applied and the follow-on ones weren't. I've
> sent that set, which should theoretically make this problem go away, but I
> can also try to rework things if need be to restore intermediate jumbo
> frames functionality. (And there are actually non-ethernet devices that
> also call ether_setup and may or may not have larger than 1500 mtu that
> aren't yet addressed by that follow-on set).

Looks like the simplest thing to do is going to be to revert a52ad514, and
only make that change after all callers of ether_setup() are setting
min/max_mtu themselves as needed, then it can be reintroduced.

-- 
Jarod Wilson
ja...@redhat.com



Re: [PATCH] mtd: nand: omap2: Fix module autoload

2016-10-17 Thread Boris Brezillon
On Mon, 17 Oct 2016 13:19:37 -0300
Javier Martinez Canillas  wrote:

> If the driver is built as a module, autoload won't work because the module
> alias information is not filled. So user-space can't match the registered
> device with the corresponding module.
> 
> Export the module alias information using the MODULE_DEVICE_TABLE() macro.
> 
> Before this patch:
> 
> $ modinfo drivers/mtd/nand/omap2_nand.ko | grep alias
> alias:  platform:omap2-nand
> 
> After this patch:
> 
> $ modinfo drivers/mtd/nand/omap2_nand.ko | grep alias
> alias:  platform:omap2-nand
> alias:  of:N*T*Cti,omap2-nandC*
> alias:  of:N*T*Cti,omap2-nand
> 
> Signed-off-by: Javier Martinez Canillas 

Applied.

Thanks,

Boris

> 
> ---
> 
>  drivers/mtd/nand/omap2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index 5513bfd9cdc9..0934c3b3f70e 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -2197,6 +2197,7 @@ static const struct of_device_id omap_nand_ids[] = {
>   { .compatible = "ti,omap2-nand", },
>   {},
>  };
> +MODULE_DEVICE_TABLE(of, omap_nand_ids);
>  
>  static struct platform_driver omap_nand_driver = {
>   .probe  = omap_nand_probe,



Re: [PATCH net-next 03/15] ethernet/intel: use core min/max MTU checking

2016-10-17 Thread Jakub Kicinski
Looks better, unfortunately, I can't test since net-next also seem to
make nfs implode on my setup.

On Mon, 17 Oct 2016 15:54:05 -0400, Jarod Wilson wrote:
> @@ -7187,6 +7180,11 @@ static int e1000_probe(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>   netdev->vlan_features |= NETIF_F_HIGHDMA;
>   }
>  
> + /* MTU range: 68 - max_hw_frame_size */
> + netdev->min_mtu = ETH_MIN_MTU;

Nitpick: we probably don't have to reinit min_mtu if it's 68.


Re: [PATCH v4 08/18] x86/intel_rdt: Pick up L3/L2 RDT parameters from CPUID

2016-10-17 Thread Luck, Tony
On Mon, Oct 17, 2016 at 09:43:41AM -0700, Yu, Fenghua wrote:
> > > > I wonder whether this is the proper abstraction level. We might as
> > > > well do the following:
> > > >
> > > > rdtresources[] = {
> > > >  {
> > > > .name   = "L3",
> > > >  },
> > > >  {
> > > > .name   = "L3Data",
> > > >  },
> > > >  {
> > > > .name   = "L3Code",
> > > >  },
> > > >
> > > > and enable either L3 or L3Data+L3Code. Not sure if that makes things
> > > > simpler, but it's definitely worth a thought or two.
> > >
> > > This way will be better than having cdp_enabled/capable for L3 and not
> > > for L2.  And this doesn't change current userinterface design either,
> > > I think.
> > 
> > User interface would change if you did this. The schemata file would look 
> > like
> > this with CDP enabled:
> > 
> > # cat schemata
> > L3Data:0=f;1=f;2=f;3=f
> > L3Code:0=f;1=f;2=f;3=f
> > 
> > but that is easier to read than the current:
> > 
> > # cat schemata
> > L3:0=f,f;1=f,f;2=f,f;3=f,f
> > 
> > which gives you no clue on which mask is code and which is data.
> 
> Right.
> 
> Also changing to uniform format :=cbm1;=cbm2;...
> is lot easier to parse schemata line in CDP mode.
> 
> So I'll change the code and doc to have two new resources: L3Data and L3Code 
> for CDP mode.

Doc change (fold into part 05):
diff --git a/Documentation/x86/intel_rdt_ui.txt 
b/Documentation/x86/intel_rdt_ui.txt
index e56781952f42..b9f634c9a058 100644
--- a/Documentation/x86/intel_rdt_ui.txt
+++ b/Documentation/x86/intel_rdt_ui.txt
@@ -97,13 +97,18 @@ With CDP disabled the L3 schemata format is:
 
 L3 details (CDP enabled via mount option to resctrl)
 
-When CDP is enabled, you need to specify separate cache bit masks for
-code and data access. The generic format is:
+When CDP is enabled L3 control is split into two separate resources
+so you can specify independent masks for code and data like this:
 
-   L3:=,;=,;...
+   L3data:=;=;...
+   L3code:=;=;...
 
-where the d_cbm masks are for data access, and the i_cbm masks for code.
+L2 details
+--
+L2 cache does not support code and data prioritization, so the
+schemata format is always:
 
+   L2:=;=;...
 
 Example 1
 -


[PATCH] tags: honor COMPILED_SOURCE with apart output directory

2016-10-17 Thread Robert Jarzmik
When the kernel is compiled with an "O=" argument, the object files are
not necessarily in the source tree, and more probably in another tree.

In this situation, the current used check doesn't work, and
COMPILED_SOURCE tags is broken with O= builds.

This patch fixes it by looking for object files both in source tree and
potential destination tree.

Signed-off-by: Robert Jarzmik 
---
 scripts/tags.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index b3775a9604ea..c0220fa05617 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -106,7 +106,9 @@ all_compiled_sources()
case "$i" in
*.[cS])
j=${i/\.[cS]/\.o}
-   if [ -e $j ]; then
+   k=${i/"$tree"/"$O"\/}
+   k=${k/\.[cS]/\.o}
+   if [ -e $j -o -e "$k" ]; then
echo $i
fi
;;
-- 
2.1.4



Re: [PATCH 0/8] infiniband: Remove semaphores

2016-10-17 Thread Bart Van Assche

On 10/17/2016 01:06 PM, Arnd Bergmann wrote:

Using an open-coded semaphore as a replacement is probably just
the last resort that we can consider once we are down to the
last handful of users. I haven't looked at drivers/infiniband/
yet for this, but I believe that drivers/acpi/ is a case for
which I see no better alternative (the AML bytecode requires
counting semaphore semantics).


Hello Arnd,

Thanks for the detailed reply. However, I doubt that removing and 
open-coding counting semaphores is the best alternative. Counting 
semaphores are a useful abstraction. I think open-coding counting 
semaphores everywhere counting semaphores are used would be a step back 
instead of a step forward.


Bart.



Re: [PATCH 2/5] staging/vchi: Fix build warnings when formatting pointers on aarch64.

2016-10-17 Thread Greg Kroah-Hartman
On Mon, Oct 17, 2016 at 12:44:03PM -0700, Eric Anholt wrote:
> The code was generally using "%x" to print and "(unsigned int)" to
> cast the pointers, but we have %p for printing pointers in the same
> format without any broken casts.

I already did this work, it's all checked into my tree, and is in
linux-next now.  You were cc:ed on the patches as well.

Also, please use "%pK" for kernel pointers, you never want to print an
address to userspace unless debugging is enabled, as it is a security
leak.

thanks,

greg k-h


Re: [PATCH 1/5] staging/vchi: Fix build error in debugfs ops on aarch64.

2016-10-17 Thread Greg Kroah-Hartman
On Mon, Oct 17, 2016 at 12:44:02PM -0700, Eric Anholt wrote:
> file_operations.write returns a ssize_t, which worked out fine on 32
> bit but errors out on 64 bit.
> 
> Signed-off-by: Eric Anholt 
> ---
>  drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

I also have already fixed this one :)


Re: [PATCH net-next 00/15] ethernet: use core min/max MTU checking

2016-10-17 Thread Jarod Wilson
On Mon, Oct 17, 2016 at 04:03:41PM -0400, David Miller wrote:
> From: Jarod Wilson 
> Date: Mon, 17 Oct 2016 15:54:02 -0400
> 
> > For the most part, every patch does the same essential thing: removes the
> > MTU range checking from the drivers' ndo_change_mtu function, puts those
> > ranges into the core net_device min_mtu and max_mtu fields, and where
> > possible, removes ndo_change_mtu functions entirely.
> 
> Jarod, please read my other posting.

Done, didn't see it until just after I'd hit send, have replied there as
well.

> You've positively broken the maximum MTU for all of these drivers.
> 
> That's not cool.
>
> And this series fixing things doesn't make things better, because now
> we've significanyly broken bisection for anyone running into this
> regression.

Agreed, and my suggestion right now is to revert the 2nd patch from the
prior series. I believe it can be resubmitted after all other callers of
ether_setup() have been converted to have their own min/max_mtu.

> You should have arranged this in such a way that the drivers needing
> > 1500 byte MTU were not impacted at all by your changes, but that
> isn't what happened.

Yeah, I must admit to not looking closely enough at the state the first
two patches left things in. It was absolutely my intention to not alter
behaviour in any way, but I neglected to test sufficiently without this
additional set applied.

-- 
Jarod Wilson
ja...@redhat.com



Re: [PATCH 6/8] IB/hns: Replace counting semaphore event_sem with wait condition

2016-10-17 Thread Arnd Bergmann
On Monday, October 17, 2016 10:01:00 PM CEST Binoy Jayan wrote:
> --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
> @@ -248,10 +248,14 @@ static int hns_roce_cmd_mbox_wait(struct hns_roce_dev 
> *hr_dev, u64 in_param,
>  {
> int ret = 0;
>  
> -   down(&hr_dev->cmd.event_sem);
> +   wait_event(hr_dev->cmd.event_sem.wq,
> +  atomic_add_unless(&hr_dev->cmd.event_sem.count, -1, 0));
> +
> ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
>in_modifier, op_modifier, op, timeout);
> -   up(&hr_dev->cmd.event_sem);
> +
> +   if (atomic_inc_return(&hr_dev->cmd.event_sem.count) == 1)
> +   wake_up(&hr_dev->cmd.event_sem.wq);
>  
> return ret;
>  }

This is the only interesting use of the event_sem that cares about
the counting and it protects the __hns_roce_cmd_mbox_wait() from being
entered too often. The count here is the number of size of the
hr_dev->cmd.context[] array.

However, that function already use a spinlock to protect that array
and pick the correct context. I think changing the inner function
to handle the case of 'no context available' by using a waitqueue
without counting anything would be a reasonable transformation
away from the semaphore.

Arnd


[PATCH V2] usb: xhci: add support for performing fake doorbell

2016-10-17 Thread Rafał Miłecki
From: Rafał Miłecki 

Broadcom's Northstar XHCI controllers seem to need a special start
procedure to work correctly. There isn't any official documentation of
this, the problem is that controller doesn't detect any connected
devices with default setup. Moreover connecting USB device to controller
that doesn't run properly can cause SoC's watchdog issues.

A workaround that was successfully tested on multiple devices is to
perform a fake doorbell. This patch adds code for doing this and enables
it on BCM4708 family.

Signed-off-by: Rafał Miłecki 
---
V2: Enable quirk for brcm,bcm4708 machines instead of adding separated binding
for it. Thanks Rob for your comment on this.
---
 drivers/usb/host/xhci-plat.c |  6 +
 drivers/usb/host/xhci.c  | 63 +---
 drivers/usb/host/xhci.h  |  1 +
 3 files changed, 67 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..b01a3be 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -56,12 +56,18 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+   struct platform_device  *pdev = to_platform_device(dev);
+   struct device_node  *node = pdev->dev.of_node;
+
/*
 * As of now platform drivers don't provide MSI support so we ensure
 * here that the generic code does not try to make a pci_dev from our
 * dev struct in order to setup MSI
 */
xhci->quirks |= XHCI_PLAT;
+
+   if (node && of_machine_is_compatible("brcm,bcm4708"))
+   xhci->quirks |= XHCI_FAKE_DOORBELL;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1a4ca02..c77035e9b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -153,6 +153,49 @@ static int xhci_start(struct xhci_hcd *xhci)
return ret;
 }
 
+/**
+ * xhci_fake_doorbell - Perform a fake doorbell on a specified slot
+ *
+ * Some controllers require a fake doorbell to start correctly. Without that
+ * they simply don't detect any devices.
+ */
+static int xhci_fake_doorbell(struct xhci_hcd *xhci, int slot_id)
+{
+   u32 temp;
+
+   /* Alloc a virt device for that slot */
+   if (!xhci_alloc_virt_device(xhci, slot_id, NULL, GFP_NOIO)) {
+   xhci_warn(xhci, "Could not allocate xHCI USB device data 
structures\n");
+   return -ENOMEM;
+   }
+
+   /* Ring fake doorbell for slot_id ep 0 */
+   xhci_ring_ep_doorbell(xhci, slot_id, 0, 0);
+   usleep_range(1000, 1500);
+
+   /* Read the status to check if HSE is set or not */
+   temp = readl(&xhci->op_regs->status);
+
+   /* Clear HSE if set */
+   if (temp & STS_FATAL) {
+   xhci_dbg(xhci, "HSE problem detected, status: 0x%08x\n", temp);
+   temp &= ~0x1fff;
+   temp |= STS_FATAL;
+   writel(temp, &xhci->op_regs->status);
+   usleep_range(1000, 1500);
+   readl(&xhci->op_regs->status);
+   }
+
+   /* Free virt device */
+   xhci_free_virt_device(xhci, slot_id);
+
+   /* We're done if controller is already running */
+   if (readl(&xhci->op_regs->command) & CMD_RUN)
+   return 0;
+
+   return xhci_start(xhci);
+}
+
 /*
  * Reset a halted HC.
  *
@@ -565,10 +608,20 @@ int xhci_init(struct usb_hcd *hcd)
 
 static int xhci_run_finished(struct xhci_hcd *xhci)
 {
-   if (xhci_start(xhci)) {
-   xhci_halt(xhci);
-   return -ENODEV;
+   int err;
+
+   err = xhci_start(xhci);
+   if (err) {
+   err = -ENODEV;
+   goto err_halt;
+   }
+
+   if (xhci->quirks & XHCI_FAKE_DOORBELL) {
+   err = xhci_fake_doorbell(xhci, 1);
+   if (err)
+   goto err_halt;
}
+
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
 
@@ -578,6 +631,10 @@ static int xhci_run_finished(struct xhci_hcd *xhci)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB3 roothub");
return 0;
+
+err_halt:
+   xhci_halt(xhci);
+   return err;
 }
 
 /*
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index b2c1dc5..52d7498 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1653,6 +1653,7 @@ struct xhci_hcd {
 #define XHCI_MTK_HOST  (1 << 21)
 #define XHCI_SSIC_PORT_UNUSED  (1 << 22)
 #define XHCI_NO_64BIT_SUPPORT  (1 << 23)
+#define XHCI_FAKE_DOORBELL (1 << 24)
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
/* There are two roothubs to keep track of bus suspend info for */
-- 
2.9.3



Re: [PATCH 7/8] IB/mthca: Replace counting semaphore event_sem with wait condition

2016-10-17 Thread Arnd Bergmann
On Monday, October 17, 2016 9:39:54 AM CEST Christoph Hellwig wrote:
> Same NAK as for the last patch.

Right, whatever we decide to do for patch 6 is what should be
done here too, as the hns code was clearly copied unchanged.

Arnd


Re: [PATCH v5 1/3] z3fold: make counters atomic

2016-10-17 Thread Dan Streetman
On Sat, Oct 15, 2016 at 7:58 AM, Vitaly Wool  wrote:
> This patch converts pages_nr per-pool counter to atomic64_t.
> It also introduces a new counter, unbuddied_nr, which is also
> atomic64_t, to track the number of unbuddied (shrinkable) pages,
> as a step to prepare for z3fold shrinker implementation.
>
> Signed-off-by: Vitaly Wool 
> ---
>  mm/z3fold.c | 33 +
>  1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 8f9e89c..5197d7b 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -69,6 +69,7 @@ struct z3fold_ops {
>   * @lru:   list tracking the z3fold pages in LRU order by most recently
>   * added buddy.
>   * @pages_nr:  number of z3fold pages in the pool.
> + * @unbuddied_nr:  number of unbuddied z3fold pages in the pool.
>   * @ops:   pointer to a structure of user defined operations specified at
>   * pool creation time.
>   *
> @@ -80,7 +81,8 @@ struct z3fold_pool {
> struct list_head unbuddied[NCHUNKS];
> struct list_head buddied;
> struct list_head lru;
> -   u64 pages_nr;
> +   atomic64_t pages_nr;
> +   atomic64_t unbuddied_nr;
> const struct z3fold_ops *ops;
> struct zpool *zpool;
> const struct zpool_ops *zpool_ops;
> @@ -234,7 +236,8 @@ static struct z3fold_pool *z3fold_create_pool(gfp_t gfp,
> INIT_LIST_HEAD(&pool->unbuddied[i]);
> INIT_LIST_HEAD(&pool->buddied);
> INIT_LIST_HEAD(&pool->lru);
> -   pool->pages_nr = 0;
> +   atomic64_set(&pool->pages_nr, 0);
> +   atomic64_set(&pool->unbuddied_nr, 0);
> pool->ops = ops;
> return pool;
>  }
> @@ -334,6 +337,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t 
> size, gfp_t gfp,
> continue;
> }
> list_del(&zhdr->buddy);
> +   atomic64_dec(&pool->unbuddied_nr);
> goto found;
> }
> }
> @@ -346,7 +350,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t 
> size, gfp_t gfp,
> if (!page)
> return -ENOMEM;
> spin_lock(&pool->lock);
> -   pool->pages_nr++;
> +   atomic64_inc(&pool->pages_nr);
> zhdr = init_z3fold_page(page);
>
> if (bud == HEADLESS) {
> @@ -369,6 +373,7 @@ found:
> /* Add to unbuddied list */
> freechunks = num_free_chunks(zhdr);
> list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
> +   atomic64_inc(&pool->unbuddied_nr);
> } else {
> /* Add to buddied list */
> list_add(&zhdr->buddy, &pool->buddied);
> @@ -412,6 +417,11 @@ static void z3fold_free(struct z3fold_pool *pool, 
> unsigned long handle)
> /* HEADLESS page stored */
> bud = HEADLESS;
> } else {
> +   if (zhdr->first_chunks == 0 ||
> +   zhdr->middle_chunks == 0 ||
> +   zhdr->last_chunks == 0)
> +   atomic64_dec(&pool->unbuddied_nr);
> +
> bud = handle_to_buddy(handle);
>
> switch (bud) {
> @@ -429,6 +439,7 @@ static void z3fold_free(struct z3fold_pool *pool, 
> unsigned long handle)
> pr_err("%s: unknown bud %d\n", __func__, bud);
> WARN_ON(1);
> spin_unlock(&pool->lock);
> +   atomic64_inc(&pool->unbuddied_nr);

this is wrong if the page was fully buddied; instead it may be better
to set a flag above, e.g. is_unbuddied, and later at the list_del call
do the dec if is_unbuddied.  That avoids needing to do this inc.

otherwise,

Acked-by: Dan Streetman 

> return;
> }
> }
> @@ -451,12 +462,13 @@ static void z3fold_free(struct z3fold_pool *pool, 
> unsigned long handle)
> list_del(&page->lru);
> clear_bit(PAGE_HEADLESS, &page->private);
> free_z3fold_page(zhdr);
> -   pool->pages_nr--;
> +   atomic64_dec(&pool->pages_nr);
> } else {
> z3fold_compact_page(zhdr);
> /* Add to the unbuddied list */
> freechunks = num_free_chunks(zhdr);
> list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
> +   atomic64_inc(&pool->unbuddied_nr);
> }
>
> spin_unlock(&pool->lock);
> @@ -520,6 +532,11 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, 
> unsigned int retries)
> zhdr = page_address(page);
> if (!test_bit(PAGE_HEADLESS, &page->private)) {
> list_del(&zhdr->buddy);
> +   if (zhdr->first_chunks == 0 ||
> +   zhdr->middle_chunks

Re: [PATCH v20 06/10] fpga: add fpga bridge framework

2016-10-17 Thread atull
On Mon, 17 Oct 2016, Alan Tull wrote:

> +/**
> + * of_fpga_bridge_get - get an exclusive reference to a fpga bridge
> + *
> + * @np: node pointer of a FPGA bridge
> + * @info: fpga image specific information
> + *
> + * Return fpga_bridge struct if successful.
> + * Return -EBUSY if someone already has a reference to the bridge.
> + * Return -ENODEV if @np is not a FPGA Bridge.
> + */
> +struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
> +struct fpga_image_info *info)
> +
> +{
> + struct device *dev;
> + struct fpga_bridge *bridge;
> + int ret = -ENODEV;
> +
> + of_node_get(np);

I thought I had fixed this.  This of_node_get is unmatched,
never called in fpga_bridge_put.  And it's not necessary
since class_find_device will do kobject_get on the child
device anyway.  So I should remove this of_node_get
and the of_node_put below.

> +
> + dev = class_find_device(fpga_bridge_class, NULL, np,
> + fpga_bridge_of_node_match);
> + if (!dev)
> + goto err_dev;
> +
> + bridge = to_fpga_bridge(dev);
> + if (!bridge)
> + goto err_dev;
> +
> + bridge->info = info;
> +
> + if (!mutex_trylock(&bridge->mutex)) {
> + ret = -EBUSY;
> + goto err_dev;
> + }
> +
> + if (!try_module_get(dev->parent->driver->owner))
> + goto err_ll_mod;
> +
> + dev_dbg(&bridge->dev, "get\n");
> +
> + return bridge;
> +
> +err_ll_mod:
> + mutex_unlock(&bridge->mutex);
> +err_dev:
> + put_device(dev);
> + of_node_put(np);

Remove of_node_put.

> + return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL_GPL(of_fpga_bridge_get);
> +
> +/**
> + * fpga_bridge_put - release a reference to a bridge
> + *
> + * @bridge: FPGA bridge
> + */
> +void fpga_bridge_put(struct fpga_bridge *bridge)
> +{
> + dev_dbg(&bridge->dev, "put\n");
> +
> + bridge->info = NULL;
> + module_put(bridge->dev.parent->driver->owner);
> + mutex_unlock(&bridge->mutex);
> + put_device(&bridge->dev);
> +}
> +EXPORT_SYMBOL_GPL(fpga_bridge_put);


[PATCH] tpm, tpm_crb: remove redundant CRB_FL_CRB_START flag

2016-10-17 Thread Jarkko Sakkinen
Because all the existing hardware have HID MSFT0101 we end up always
setting CRB_FL_CRB_START flag as a workaround for 4th Gen Core CPUs.
Even if ACPI start is used, the driver will always issue also CRB start.

This commit makes the invocation of CRB start unconditional.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm_crb.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index 65040d7..5928ec8 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -72,7 +72,6 @@ enum crb_status {
 
 enum crb_flags {
CRB_FL_ACPI_START   = BIT(0),
-   CRB_FL_CRB_START= BIT(1),
 };
 
 struct crb_priv {
@@ -226,8 +225,11 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t 
len)
/* Make sure that cmd is populated before issuing start. */
wmb();
 
-   if (priv->flags & CRB_FL_CRB_START)
-   iowrite32(CRB_START_INVOKE, &priv->cca->start);
+
+   /* At least some of the 4th Gen Core CPUs that report only needing ACPI
+* start require also CRB start so we always set it just in case.
+*/
+   iowrite32(CRB_START_INVOKE, &priv->cca->start);
 
if (priv->flags & CRB_FL_ACPI_START)
rc = crb_do_acpi_start(chip);
@@ -407,14 +409,6 @@ static int crb_acpi_add(struct acpi_device *device)
if (!priv)
return -ENOMEM;
 
-   /* The reason for the extra quirk is that the PTT in 4th Gen Core CPUs
-* report only ACPI start but in practice seems to require both
-* ACPI start and CRB start.
-*/
-   if (sm == ACPI_TPM2_COMMAND_BUFFER || sm == ACPI_TPM2_MEMORY_MAPPED ||
-   !strcmp(acpi_device_hid(device), "MSFT0101"))
-   priv->flags |= CRB_FL_CRB_START;
-
if (sm == ACPI_TPM2_START_METHOD ||
sm == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD)
priv->flags |= CRB_FL_ACPI_START;
-- 
2.9.3



Re: please, where has xconfig KConf option documentation gone with linux 4.8's Qt5 / Qt4 xconfig ?

2016-10-17 Thread Boris Barbulovski
can you try this patch?



On Mon, Oct 17, 2016 at 7:28 PM, Randy Dunlap  wrote:
> Boris or Thiago,
>
> Any comments, suggestions, or patches about this?
>
> thanks.
>
> On 10/15/16 04:09, Jason Vas Dias wrote:
>>  Aha, thanks! I never would have known this without being told -
>>  there is no visible indication that the symbol info pane exists
>>  at all until one tries to drag the lower right corner of the window
>>  notth-eastwards - is this meant to be somehow an intuitive thing to
>>  do these days to view more info ?
>>
>>  I did manage to view the option documentation with nconfig  /
>>  using emacs to view the KConf files (preferable).
>>
>>  Really, it would be nice if xconfig had some 'View' Menu & one could select
>>  View -> Option Documentation  or press  over an option to view the
>>  documentation for it , and if the geometry of the different panes was
>> correct at
>>  startup .- the whole Option value pane initially appears on the far right 
>> hand
>>  side, about 10 pixels wide , until resized ; and there really is no sign of 
>> the
>>  documentation pane at all until lower right-hand corner dragged.
>>
>>  Also, in the Help -> Introduction panel, it says :
>>"Toggling Show Debug Info under the Options menu will show the
>> dependencies..."
>>  but there is no "Show Debug Info" option on the Options menu - sounds like
>>  it might be a useful feature - should I be seeing a "Show Debug Info" 
>> option ?
>>  why don't I see one ?  Maybe the Options menu might be a good place to put
>>  an "Expand Option Documentation Pane" option ?
>>
>> Thanks anyway for the info.
>>
>> Regards,
>> Jason
>>
>>
>>
>>
>> On 11/10/2016, Randy Dunlap  wrote:
>>> [changed linux-config to linux-kbuild list]
>>>
>>> On 10/09/16 13:46, Jason Vas Dias wrote:
 Hi -
 I've been doing 'make xconfig'  to configure the kernel for many years
 now, and
 always there used to be some option documentation pane populated with
 summary documentation for the specific option selected .
 But now,  when built for Qt 5.7.0, (also tried Qt 4.8 and GTK) there
 is no option
 documentation pane - this is a real pain !  The option documentation also
 is not displayed with any other gui, eg.  'make menuconfig' / 'make
 gtkconfig' -
 I'm sure it used to be . This is a regression IMHO .
 How can I restore display of documentation for each selected option ?
 Will older xconfig work for Linux 4.8 ? it appears not ...
 Thanks in advance for any replies,
 Jason
>>>
>>> That's odd. I see the help info in all of xconfig, gconfig, menuconfig, &
>>> nconfig.
>>>
>>> In xconfig, if the right hand side of the config window only lists some
>>> kernel config
>>> options and no symbol help/info, the symbol info portion may be hidden. Try
>>> pointing
>>> to the bottom of the right side of the window and hold down the left mouse
>>> button
>>> and then drag the mouse pointer upward to open the symbol info pane.
>>> At least that is what works for me.
>>>
>>> --
>>> ~Randy
>
>
> --
> ~Randy



-- 
Boris Barbulovski
http://mkfusion.bokicsoft.com/
From 75350fa3ec1dd925a30b2511892128a07cbe10de Mon Sep 17 00:00:00 2001
From: Boris Barbulovski 
Date: Mon, 17 Oct 2016 22:23:14 +0200
Subject: [PATCH] qconfig initial slider sizes fix.

On first `make xconfig`, suboption and help panels were hidden.
Now we properly detect the first run, and show those panels.

Signed-off-by: Boris Barbulovski 
---
 scripts/kconfig/qconf.cc | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index fc9..e99c04f 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -65,11 +65,19 @@ ConfigSettings::ConfigSettings()
 QList ConfigSettings::readSizes(const QString& key, bool *ok)
 {
 	QList result;
-	QStringList entryList = value(key).toStringList();
-	QStringList::Iterator it;
 
-	for (it = entryList.begin(); it != entryList.end(); ++it)
-		result.push_back((*it).toInt());
+	if (contains(key))
+	{
+		QStringList entryList = value(key).toStringList();
+		QStringList::Iterator it;
+
+		for (it = entryList.begin(); it != entryList.end(); ++it)
+			result.push_back((*it).toInt());
+
+		*ok = true;
+	}
+	else
+		*ok = false;
 
 	return result;
 }
-- 
2.7.4



Re: [PATCH 0/8] infiniband: Remove semaphores

2016-10-17 Thread Arnd Bergmann
On Monday, October 17, 2016 1:28:01 PM CEST Bart Van Assche wrote:
> On 10/17/2016 01:06 PM, Arnd Bergmann wrote:
> > Using an open-coded semaphore as a replacement is probably just
> > the last resort that we can consider once we are down to the
> > last handful of users. I haven't looked at drivers/infiniband/
> > yet for this, but I believe that drivers/acpi/ is a case for
> > which I see no better alternative (the AML bytecode requires
> > counting semaphore semantics).
> 
> Hello Arnd,
> 
> Thanks for the detailed reply. However, I doubt that removing and 
> open-coding counting semaphores is the best alternative. Counting 
> semaphores are a useful abstraction. I think open-coding counting 
> semaphores everywhere counting semaphores are used would be a step back 
> instead of a step forward.

Absolutely agreed, that's why I said 'last resort' above. I don't
think that we need to go there for infiniband. See my reply
for patch 6 for one idea on how to handle hns and mthca. There
might be better ways.

These fall into the general category of using the counting semaphore
to count something that we already know in the code that uses
the semaphore, so we can remove the count and just need some other
waiting primitive.

Arnd



Re: [PATCH v2 2/2] arm64: dts: Updated NAND DT properties for NS2 SVK

2016-10-17 Thread Ray Jui

Hi Florian,

Would you be able to help to queue the following patch for v4.10? Sorry 
I did not include you in the "To" field of the original email.


Thanks,

Ray

On 7/20/2016 2:53 PM, Ray Jui wrote:

This patch adds NAND DT properties for NS2 SVK to configure the bus
width width and OOB sector size

Signed-off-by: Prafulla Kota 
Signed-off-by: Ray Jui 
---
 arch/arm64/boot/dts/broadcom/ns2-svk.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts 
b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
index 54ca40c..5ef0407 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
@@ -128,6 +128,8 @@
nand-ecc-mode = "hw";
nand-ecc-strength = <8>;
nand-ecc-step-size = <512>;
+   nand-bus-width = <16>;
+   brcm,nand-oob-sector-size = <16>;
#address-cells = <1>;
#size-cells = <1>;
};



Re: [PATCH v5 2/3] z3fold: remove redundant locking

2016-10-17 Thread Dan Streetman
On Sat, Oct 15, 2016 at 7:59 AM, Vitaly Wool  wrote:
> The per-pool z3fold spinlock should generally be taken only when
> a non-atomic pool variable is modified. There's no need to take it
> to map/unmap an object.

no.  it absolutely needs to be taken, because z3fold_compact_page
could move the middle bud's contents to the first bud, and if the
middle bud gets mapped while it's being moved really bad things will
happen.

you can change that to a per-page lock in the z3fold_header, but some
locking needs to happen between mapping and middle bud moving (and
handle encoding/decoding and first_num access).


>
> Signed-off-by: Vitaly Wool 
> ---
>  mm/z3fold.c | 17 +
>  1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 5197d7b..10513b5 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -580,6 +580,7 @@ next:
> if ((test_bit(PAGE_HEADLESS, &page->private) && ret == 0) ||
> (zhdr->first_chunks == 0 && zhdr->last_chunks == 0 &&
>  zhdr->middle_chunks == 0)) {
> +   spin_unlock(&pool->lock);
> /*
>  * All buddies are now free, free the z3fold page and
>  * return success.
> @@ -587,7 +588,6 @@ next:
> clear_bit(PAGE_HEADLESS, &page->private);
> free_z3fold_page(zhdr);
> atomic64_dec(&pool->pages_nr);
> -   spin_unlock(&pool->lock);
> return 0;
> }  else if (!test_bit(PAGE_HEADLESS, &page->private)) {
> if (zhdr->first_chunks != 0 &&
> @@ -629,7 +629,6 @@ static void *z3fold_map(struct z3fold_pool *pool, 
> unsigned long handle)
> void *addr;
> enum buddy buddy;
>
> -   spin_lock(&pool->lock);
> zhdr = handle_to_z3fold_header(handle);
> addr = zhdr;
> page = virt_to_page(zhdr);
> @@ -656,7 +655,6 @@ static void *z3fold_map(struct z3fold_pool *pool, 
> unsigned long handle)
> break;
> }
>  out:
> -   spin_unlock(&pool->lock);
> return addr;
>  }
>
> @@ -671,19 +669,14 @@ static void z3fold_unmap(struct z3fold_pool *pool, 
> unsigned long handle)
> struct page *page;
> enum buddy buddy;
>
> -   spin_lock(&pool->lock);
> zhdr = handle_to_z3fold_header(handle);
> page = virt_to_page(zhdr);
>
> -   if (test_bit(PAGE_HEADLESS, &page->private)) {
> -   spin_unlock(&pool->lock);
> -   return;
> +   if (!test_bit(PAGE_HEADLESS, &page->private)) {
> +   buddy = handle_to_buddy(handle);
> +   if (buddy == MIDDLE)
> +   clear_bit(MIDDLE_CHUNK_MAPPED, &page->private);
> }
> -
> -   buddy = handle_to_buddy(handle);
> -   if (buddy == MIDDLE)
> -   clear_bit(MIDDLE_CHUNK_MAPPED, &page->private);
> -   spin_unlock(&pool->lock);
>  }
>
>  /**
> --
> 2.4.2


Re: please, where has xconfig KConf option documentation gone with linux 4.8's Qt5 / Qt4 xconfig ?

2016-10-17 Thread Boris Barbulovski
And make sure to delete ~/.config/kernel.org/qconf.conf file before
testing because it might have some illegal settings that might trigger
the same issue again.


On Mon, Oct 17, 2016 at 10:43 PM, Boris Barbulovski
 wrote:
> can you try this patch?
>
>
>
> On Mon, Oct 17, 2016 at 7:28 PM, Randy Dunlap  wrote:
>> Boris or Thiago,
>>
>> Any comments, suggestions, or patches about this?
>>
>> thanks.
>>
>> On 10/15/16 04:09, Jason Vas Dias wrote:
>>>  Aha, thanks! I never would have known this without being told -
>>>  there is no visible indication that the symbol info pane exists
>>>  at all until one tries to drag the lower right corner of the window
>>>  notth-eastwards - is this meant to be somehow an intuitive thing to
>>>  do these days to view more info ?
>>>
>>>  I did manage to view the option documentation with nconfig  /
>>>  using emacs to view the KConf files (preferable).
>>>
>>>  Really, it would be nice if xconfig had some 'View' Menu & one could select
>>>  View -> Option Documentation  or press  over an option to view the
>>>  documentation for it , and if the geometry of the different panes was
>>> correct at
>>>  startup .- the whole Option value pane initially appears on the far right 
>>> hand
>>>  side, about 10 pixels wide , until resized ; and there really is no sign 
>>> of the
>>>  documentation pane at all until lower right-hand corner dragged.
>>>
>>>  Also, in the Help -> Introduction panel, it says :
>>>"Toggling Show Debug Info under the Options menu will show the
>>> dependencies..."
>>>  but there is no "Show Debug Info" option on the Options menu - sounds like
>>>  it might be a useful feature - should I be seeing a "Show Debug Info" 
>>> option ?
>>>  why don't I see one ?  Maybe the Options menu might be a good place to put
>>>  an "Expand Option Documentation Pane" option ?
>>>
>>> Thanks anyway for the info.
>>>
>>> Regards,
>>> Jason
>>>
>>>
>>>
>>>
>>> On 11/10/2016, Randy Dunlap  wrote:
 [changed linux-config to linux-kbuild list]

 On 10/09/16 13:46, Jason Vas Dias wrote:
> Hi -
> I've been doing 'make xconfig'  to configure the kernel for many years
> now, and
> always there used to be some option documentation pane populated with
> summary documentation for the specific option selected .
> But now,  when built for Qt 5.7.0, (also tried Qt 4.8 and GTK) there
> is no option
> documentation pane - this is a real pain !  The option documentation also
> is not displayed with any other gui, eg.  'make menuconfig' / 'make
> gtkconfig' -
> I'm sure it used to be . This is a regression IMHO .
> How can I restore display of documentation for each selected option ?
> Will older xconfig work for Linux 4.8 ? it appears not ...
> Thanks in advance for any replies,
> Jason

 That's odd. I see the help info in all of xconfig, gconfig, menuconfig, &
 nconfig.

 In xconfig, if the right hand side of the config window only lists some
 kernel config
 options and no symbol help/info, the symbol info portion may be hidden. Try
 pointing
 to the bottom of the right side of the window and hold down the left mouse
 button
 and then drag the mouse pointer upward to open the symbol info pane.
 At least that is what works for me.

 --
 ~Randy
>>
>>
>> --
>> ~Randy
>
>
>
> --
> Boris Barbulovski
> http://mkfusion.bokicsoft.com/



-- 
Boris Barbulovski
http://mkfusion.bokicsoft.com/


Re: [PATCH v2] Coccinelle: Add misc/boolconv.cocci

2016-10-17 Thread Julia Lawall
On Mon, 17 Oct 2016, Andrew F. Davis wrote:

> Add a script to check for unneeded conversions to bool.

What changed since the previous version?

julia


>
> Signed-off-by: Andrew F. Davis 
> Acked-by: Julia Lawall 
> ---
>  scripts/coccinelle/misc/boolconv.cocci | 90 
> ++
>  1 file changed, 90 insertions(+)
>  create mode 100644 scripts/coccinelle/misc/boolconv.cocci
>
> diff --git a/scripts/coccinelle/misc/boolconv.cocci 
> b/scripts/coccinelle/misc/boolconv.cocci
> new file mode 100644
> index 000..33c464d
> --- /dev/null
> +++ b/scripts/coccinelle/misc/boolconv.cocci
> @@ -0,0 +1,90 @@
> +/// Remove unneeded conversion to bool
> +///
> +//# Relational and logical operators evaluate to bool,
> +//# explicit conversion is overly verbose and unneeded.
> +//
> +// Copyright: (C) 2016 Andrew F. Davis  GPLv2.
> +
> +virtual patch
> +virtual context
> +virtual org
> +virtual report
> +
> +//--
> +//  For patch mode
> +//--
> +
> +@depends on patch@
> +expression A, B;
> +symbol true, false;
> +@@
> +
> +(
> +  A == B
> +|
> +  A != B
> +|
> +  A > B
> +|
> +  A < B
> +|
> +  A >= B
> +|
> +  A <= B
> +|
> +  A && B
> +|
> +  A || B
> +)
> +- ? true : false
> +
> +//--
> +//  For context mode
> +//--
> +
> +@r depends on !patch@
> +expression A, B;
> +symbol true, false;
> +position p;
> +@@
> +
> +(
> +  A == B
> +|
> +  A != B
> +|
> +  A > B
> +|
> +  A < B
> +|
> +  A >= B
> +|
> +  A <= B
> +|
> +  A && B
> +|
> +  A || B
> +)
> +* ? true : false@p
> +
> +//--
> +//  For org mode
> +//--
> +
> +@script:python depends on r&&org@
> +p << r.p;
> +@@
> +
> +msg = "WARNING: conversion to bool not needed here"
> +coccilib.org.print_todo(p[0], msg)
> +
> +//--
> +//  For report mode
> +//--
> +
> +@script:python depends on r&&report@
> +p << r.p;
> +@@
> +
> +msg = "WARNING: conversion to bool not needed here"
> +coccilib.report.print_report(p[0], msg)
> --
> 2.10.1
>
>


[PATCH] x86, pkeys: remove cruft from never-merged syscalls

2016-10-17 Thread Dave Hansen

From: Dave Hansen 

pkey_set() and pkey_get() were syscalls present in older versions
of the protection keys patches.  The syscall number definitions
were inadvertently left in place.  This patch removes them.

I did a git grep and verified that these are the last places in
the tree that these appear, save for the protection_keys.c tests
and Documentation.  Those spots talk about functions called
pkey_get/set() which are wrappers for the direct PKRU
instructions, not the syscalls.

Signed-off-by: Dave Hansen 
Cc: Thomas Gleixner 
Cc: linux-a...@vger.kernel.org
Cc: mgor...@techsingularity.net
Cc: a...@arndb.de
Cc: linux-...@vger.kernel.org
Cc: linux...@kvack.org
Cc: l...@kernel.org
Cc: a...@linux-foundation.org
Cc: torva...@linux-foundation.org
Fixes: f9afc6197e9bb ("x86: Wire up protection keys system calls")
---

 b/arch/x86/entry/syscalls/syscall_32.tbl |2 --
 b/arch/x86/entry/syscalls/syscall_64.tbl |2 --
 2 files changed, 4 deletions(-)

diff -puN arch/x86/entry/syscalls/syscall_32.tbl~kill-x86-pkey-syscall-nr-cruft 
arch/x86/entry/syscalls/syscall_32.tbl
--- a/arch/x86/entry/syscalls/syscall_32.tbl~kill-x86-pkey-syscall-nr-cruft 
2016-10-17 13:00:11.607811388 -0700
+++ b/arch/x86/entry/syscalls/syscall_32.tbl2016-10-17 13:00:14.216930557 
-0700
@@ -389,5 +389,3 @@
 380i386pkey_mprotect   sys_pkey_mprotect
 381i386pkey_alloc  sys_pkey_alloc
 382i386pkey_free   sys_pkey_free
-#383   i386pkey_getsys_pkey_get
-#384   i386pkey_setsys_pkey_set
diff -puN arch/x86/entry/syscalls/syscall_64.tbl~kill-x86-pkey-syscall-nr-cruft 
arch/x86/entry/syscalls/syscall_64.tbl
--- a/arch/x86/entry/syscalls/syscall_64.tbl~kill-x86-pkey-syscall-nr-cruft 
2016-10-17 13:00:11.609811480 -0700
+++ b/arch/x86/entry/syscalls/syscall_64.tbl2016-10-17 13:00:21.896281301 
-0700
@@ -338,8 +338,6 @@
 329common  pkey_mprotect   sys_pkey_mprotect
 330common  pkey_alloc  sys_pkey_alloc
 331common  pkey_free   sys_pkey_free
-#332   common  pkey_getsys_pkey_get
-#333   common  pkey_setsys_pkey_set
 
 #
 # x32-specific system call numbers start at 512 to avoid cache impact
_


[PATCH 0/2] sparc/net: Fix compiler warnings

2016-10-17 Thread Tushar Dave
Recently, ATU (iommu) changes are submitted to sparclinux that
enables 64bit DMA on SPARC. However, this change also makes
'incompatible pointer type' compiler warnings inevitable on sunqe
and sunbmac driver.

The two patches in series fix compiler warnings.

Tushar Dave (2):
  sunqe: Fix compiler warnings
  sunbmac: Fix compiler warning

 drivers/net/ethernet/sun/sunbmac.c |  5 +++--
 drivers/net/ethernet/sun/sunbmac.h |  2 +-
 drivers/net/ethernet/sun/sunqe.c   | 11 ++-
 drivers/net/ethernet/sun/sunqe.h   |  4 ++--
 4 files changed, 12 insertions(+), 10 deletions(-)

-- 
1.9.1



[PATCH 2/2] sunbmac: Fix compiler warning

2016-10-17 Thread Tushar Dave
sunbmac uses '__u32' for dma handle while invoking kernel DMA APIs,
instead of using dma_addr_t. This hasn't caused any 'incompatible
pointer type' warning on SPARC because until now dma_addr_t is of
type u32. However, recent changes in SPARC ATU (iommu) enables 64bit
DMA and therefore dma_addr_t becomes of type u64. This makes
'incompatible pointer type' warnings inevitable.

e.g.
drivers/net/ethernet/sun/sunbmac.c: In function ‘bigmac_ether_init’:
drivers/net/ethernet/sun/sunbmac.c:1166: warning: passing argument 3 of 
‘dma_alloc_coherent’ from incompatible pointer type
./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but argument 
is of type ‘__u32 *’

This patch resolves above compiler warning.

Signed-off-by: Tushar Dave 
Reviewed-by: chris hyser 
---
 drivers/net/ethernet/sun/sunbmac.c | 5 +++--
 drivers/net/ethernet/sun/sunbmac.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunbmac.c 
b/drivers/net/ethernet/sun/sunbmac.c
index aa4f9d2..02f4527 100644
--- a/drivers/net/ethernet/sun/sunbmac.c
+++ b/drivers/net/ethernet/sun/sunbmac.c
@@ -623,6 +623,7 @@ static int bigmac_init_hw(struct bigmac *bp, int from_irq)
void __iomem *gregs= bp->gregs;
void __iomem *cregs= bp->creg;
void __iomem *bregs= bp->bregs;
+   __u32 bblk_dvma = (__u32)bp->bblock_dvma;
unsigned char *e = &bp->dev->dev_addr[0];
 
/* Latch current counters into statistics. */
@@ -671,9 +672,9 @@ static int bigmac_init_hw(struct bigmac *bp, int from_irq)
bregs + BMAC_XIFCFG);
 
/* Tell the QEC where the ring descriptors are. */
-   sbus_writel(bp->bblock_dvma + bib_offset(be_rxd, 0),
+   sbus_writel(bblk_dvma + bib_offset(be_rxd, 0),
cregs + CREG_RXDS);
-   sbus_writel(bp->bblock_dvma + bib_offset(be_txd, 0),
+   sbus_writel(bblk_dvma + bib_offset(be_txd, 0),
cregs + CREG_TXDS);
 
/* Setup the FIFO pointers into QEC local memory. */
diff --git a/drivers/net/ethernet/sun/sunbmac.h 
b/drivers/net/ethernet/sun/sunbmac.h
index 06dd217..532fc56 100644
--- a/drivers/net/ethernet/sun/sunbmac.h
+++ b/drivers/net/ethernet/sun/sunbmac.h
@@ -291,7 +291,7 @@ struct bigmac {
void __iomem*bregs; /* BigMAC Registers   */
void __iomem*tregs; /* BigMAC Transceiver */
struct bmac_init_block  *bmac_block;/* RX and TX descriptors */
-   __u32bblock_dvma;   /* RX and TX descriptors */
+   dma_addr_t  bblock_dvma;/* RX and TX descriptors */
 
spinlock_t  lock;
 
-- 
1.9.1



[PATCH 1/2] sunqe: Fix compiler warnings

2016-10-17 Thread Tushar Dave
sunqe uses '__u32' for dma handle while invoking kernel DMA APIs,
instead of using dma_addr_t. This hasn't caused any 'incompatible
pointer type' warning on SPARC because until now dma_addr_t is of
type u32. However, recent changes in SPARC ATU (iommu) enables 64bit
DMA and therefore dma_addr_t becomes of type u64. This makes
'incompatible pointer type' warnings inevitable.

e.g.
drivers/net/ethernet/sun/sunqe.c: In function ‘qec_ether_init’:
drivers/net/ethernet/sun/sunqe.c:883: warning: passing argument 3 of 
‘dma_alloc_coherent’ from incompatible pointer type
./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but argument 
is of type ‘__u32 *’
drivers/net/ethernet/sun/sunqe.c:885: warning: passing argument 3 of 
‘dma_alloc_coherent’ from incompatible pointer type
./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but argument 
is of type ‘__u32 *’

This patch resolves above compiler warnings.

Signed-off-by: Tushar Dave 
Reviewed-by: chris hyser 
---
 drivers/net/ethernet/sun/sunqe.c | 11 ++-
 drivers/net/ethernet/sun/sunqe.h |  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunqe.c b/drivers/net/ethernet/sun/sunqe.c
index 9b825780..9582948 100644
--- a/drivers/net/ethernet/sun/sunqe.c
+++ b/drivers/net/ethernet/sun/sunqe.c
@@ -124,7 +124,7 @@ static void qe_init_rings(struct sunqe *qep)
 {
struct qe_init_block *qb = qep->qe_block;
struct sunqe_buffers *qbufs = qep->buffers;
-   __u32 qbufs_dvma = qep->buffers_dvma;
+   __u32 qbufs_dvma = (__u32)qep->buffers_dvma;
int i;
 
qep->rx_new = qep->rx_old = qep->tx_new = qep->tx_old = 0;
@@ -144,6 +144,7 @@ static int qe_init(struct sunqe *qep, int from_irq)
void __iomem *mregs = qep->mregs;
void __iomem *gregs = qecp->gregs;
unsigned char *e = &qep->dev->dev_addr[0];
+   __u32 qblk_dvma = (__u32)qep->qblock_dvma;
u32 tmp;
int i;
 
@@ -152,8 +153,8 @@ static int qe_init(struct sunqe *qep, int from_irq)
return -EAGAIN;
 
/* Setup initial rx/tx init block pointers. */
-   sbus_writel(qep->qblock_dvma + qib_offset(qe_rxd, 0), cregs + 
CREG_RXDS);
-   sbus_writel(qep->qblock_dvma + qib_offset(qe_txd, 0), cregs + 
CREG_TXDS);
+   sbus_writel(qblk_dvma + qib_offset(qe_rxd, 0), cregs + CREG_RXDS);
+   sbus_writel(qblk_dvma + qib_offset(qe_txd, 0), cregs + CREG_TXDS);
 
/* Enable/mask the various irq's. */
sbus_writel(0, cregs + CREG_RIMASK);
@@ -413,7 +414,7 @@ static void qe_rx(struct sunqe *qep)
struct net_device *dev = qep->dev;
struct qe_rxd *this;
struct sunqe_buffers *qbufs = qep->buffers;
-   __u32 qbufs_dvma = qep->buffers_dvma;
+   __u32 qbufs_dvma = (__u32)qep->buffers_dvma;
int elem = qep->rx_new;
u32 flags;
 
@@ -572,7 +573,7 @@ static int qe_start_xmit(struct sk_buff *skb, struct 
net_device *dev)
 {
struct sunqe *qep = netdev_priv(dev);
struct sunqe_buffers *qbufs = qep->buffers;
-   __u32 txbuf_dvma, qbufs_dvma = qep->buffers_dvma;
+   __u32 txbuf_dvma, qbufs_dvma = (__u32)qep->buffers_dvma;
unsigned char *txbuf;
int len, entry;
 
diff --git a/drivers/net/ethernet/sun/sunqe.h b/drivers/net/ethernet/sun/sunqe.h
index 581781b..ae190b7 100644
--- a/drivers/net/ethernet/sun/sunqe.h
+++ b/drivers/net/ethernet/sun/sunqe.h
@@ -334,12 +334,12 @@ struct sunqe {
void __iomem*qcregs;/* QEC 
per-channel Registers   */
void __iomem*mregs; /* Per-channel MACE 
Registers  */
struct qe_init_block*qe_block;  /* RX and TX 
descriptors   */
-   __u32   qblock_dvma;/* RX and TX 
descriptors   */
+   dma_addr_t  qblock_dvma;/* RX and TX 
descriptors   */
spinlock_t  lock;   /* Protects txfull 
state   */
int rx_new, rx_old; /* RX ring extents  
   */
int tx_new, tx_old; /* TX ring extents  
   */
struct sunqe_buffers*buffers;   /* CPU visible address. 
   */
-   __u32   buffers_dvma;   /* DVMA visible 
address.   */
+   dma_addr_t  buffers_dvma;   /* DVMA visible 
address.   */
struct sunqec   *parent;
u8  mconfig;/* Base MACE mconfig 
value */
struct platform_device  *op;/* QE's OF device 
struct   */
-- 
1.9.1



Re: [PATCH RFC 1/3] fpu/x86: add make_fpregs_active(_newstate) helper functions

2016-10-17 Thread Andy Lutomirski
On Mon, Oct 17, 2016 at 1:09 PM,   wrote:
> From: Rik van Riel 
>
> Add helper functions that ensure a task's floating point registers are
> set up the way they need to be - either with the task's floating point
> state loaded in, or ready to accept a task's new floating point state.
>
> These helpers can be called from code that accesses the floating point
> state from a preemptible state, in preparation for the lazier floating
> point loading code, using loops like this:
>
> do {
> make_fpregs_active();
> ...
> } while (unlikely(!fpregs_active()));
>
> This way a task can safely do things like saving the floating point
> state of a task to user space memory (the signal handling code does
> this), without requiring that the floating point state is restored
> at every context switch.

Sadly, I think this model is problematic.  An attacker can set up some
memory that causes writes to block in a controlled manner (using
userfaultfd, FUSE, madvise() hammering, etc).  The attacker can
arrange for the uaccess write in the "..." to block and then for some
privileged target task to be scheduled.  The attacker then gets their
task to be scheduled next and the privileged xstate gets written to
the attacker's memory.  Then the attacker either reads it back from a
different thread or arranges for the next iteration of the loop to
fail outright.  Now the attacker has read another task's xstate.

Dave and/or Yu-cheng: didn't one of you have some code to allow a user
xstate buffer to be filled from the copy in kernel memory?  If we did
that, we could avoid this mess entirely.

Alternatively, there could be flag that causes FPU loads to be
temporarily eager.  Maybe the sequence would look like:

pin_fpregs_active();
...
unpin_fpregs_active();

or maybe get_fpregs() / put_fpregs().

--Andy


Re: [PATCH RFC 3/3] x86/fpu: defer FPU state load until return to userspace

2016-10-17 Thread Andy Lutomirski
On Mon, Oct 17, 2016 at 1:09 PM,   wrote:
> From: Rik van Riel 
>
> Defer loading of FPU state until return to userspace. This gives
> the kernel the potential to skip loading FPU state for tasks that
> stay in kernel mode, or for tasks that end up with repeated
> invocations of kernel_fpu_begin.
>
> It also increases the chances that a task's FPU state will remain
> valid in the FPU registers until it is scheduled back in, allowing
> us to skip restoring that task's FPU state altogether.
>
> This also prepares the ground work for not having to restore
> qemu userspace FPU state in KVM VCPU threads, when merely returning
> to the host kernel because the guest went idle, or is running a
> kernel thread. That functionality will come in a later patch.
>
> Signed-off-by: Rik van Riel 
> ---
>  arch/x86/entry/common.c |  9 +
>  arch/x86/include/asm/fpu/api.h  |  5 +
>  arch/x86/include/asm/fpu/internal.h | 13 +
>  arch/x86/include/asm/thread_info.h  |  4 +++-
>  arch/x86/kernel/fpu/core.c  | 28 
>  arch/x86/kernel/process_32.c|  5 ++---
>  arch/x86/kernel/process_64.c|  5 ++---
>  7 files changed, 50 insertions(+), 19 deletions(-)
>
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index bdd9cc59d20f..0c11ee22f90b 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define CREATE_TRACE_POINTS
>  #include 
> @@ -189,6 +190,14 @@ __visible inline void prepare_exit_to_usermode(struct 
> pt_regs *regs)
> if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> exit_to_usermode_loop(regs, cached_flags);
>
> +   /* Reload ti->flags; we may have rescheduled above. */
> +   cached_flags = READ_ONCE(ti->flags);

Stick this bit in the "if" above, please.

> +
> +   if (unlikely(cached_flags & _TIF_LOAD_FPU)) {
> +   clear_thread_flag(TIF_LOAD_FPU);
> +   switch_fpu_return();
> +   }
> +

But I still don't see how this can work correctly with PKRU.

--Andy


Re: [PATCH v20 02/10] doc: fpga-mgr: add fpga image info to api

2016-10-17 Thread Moritz Fischer
Hi Alan,

couple of nits inline and some comments on ordering the patches ;-)

On Mon, Oct 17, 2016 at 6:09 PM, Alan Tull  wrote:
> This patch adds a minor change in the FPGA Mangager API

s/Mangager/Manager/

> to hold information that is specific to an FPGA image
> file.  This change is expected to bring little, if any,
> pain.
>
> An FPGA image file will have particulars that affect how the
> image is programmed to the FPGA.  One example is that
> current 'flags' currently has one bit which shows whether the
> FPGA image was built for full reconfiguration or partial
> reconfiguration.  Another example is timeout values for
> enabling or disabling the bridges in the FPGA.  As the
> complexity of the FPGA design increases, the bridges in the
> FPGA may take longer times to enable or disable.

According for the current ordering bridges are not yet defined if we
merge patches in this order?
Not terrible imho, but I thought I'd point it out. Would swapping the
order make sense?

I also think [5/10] should be squashed together with this commit to
make it an atomic change.

Apart from my comments above feel free to add my Acked-by

Thanks for keeping this going,

Moritz


Remove binary files from documentation

2016-10-17 Thread Laura Abbott

Hi,

Some of the files in documentation are binary (pdfs/jpg/png etc.)
and do not play nicely with patches

$ curl -s https://cdn.kernel.org/pub/linux/kernel/v4.x/testing/patch-4.9-rc1.xz | xzcat | 
grep "Binary files"
Binary files a/Documentation/media/media_api_files/typical_media_device.pdf and 
b/Documentation/media/media_api_files/typical_media_device.pdf differ
Binary files a/Documentation/media/uapi/v4l/dev-raw-vbi_files/vbi_525.pdf and 
b/Documentation/media/uapi/v4l/dev-raw-vbi_files/vbi_525.pdf differ
Binary files a/Documentation/media/uapi/v4l/dev-raw-vbi_files/vbi_625.pdf and 
b/Documentation/media/uapi/v4l/dev-raw-vbi_files/vbi_625.pdf differ
Binary files a/Documentation/media/uapi/v4l/pixfmt-nv12mt_files/nv12mt.gif and 
/dev/null differ
Binary files /dev/null and 
b/Documentation/media/uapi/v4l/pixfmt-nv12mt_files/nv12mt.png differ
Binary files 
a/Documentation/media/uapi/v4l/pixfmt-nv12mt_files/nv12mt_example.gif and 
/dev/null differ
Binary files /dev/null and 
b/Documentation/media/uapi/v4l/pixfmt-nv12mt_files/nv12mt_example.png differ

The patch files generated can't be applied with either git or
patch when there are changes to these files. Can future
documentation exclude checking in binary files or at least
come up with a way that patches on kernel.org can still be
applied?

Thanks,
Laura


Re: Build regressions/improvements in v4.9-rc1

2016-10-17 Thread Arnd Bergmann
On Monday, October 17, 2016 9:59:24 AM CEST Vineet Gupta wrote:
> +CC Arnd, Michal
> 
> Hi Geert, Arnd
> 
> Need some guidance here.
> 
> On 10/17/2016 12:34 AM, Geert Uytterhoeven wrote:
> >> 48 error regressions:
> >> >   + /home/kisskb/slave/src/arch/arc/include/asm/atomic.h: Error: bad 
> >> > instruction `llockd r2,[r0]':  => 476
> >> >   + /home/kisskb/slave/src/arch/arc/include/asm/atomic.h: Error: bad 
> >> > instruction `llockd r2,[r13]':  => 475
> 
> [snip...]
> 
> >> >   + /home/kisskb/slave/src/arch/arc/include/asm/atomic.h: Error: bad 
> >> > instruction `scondd r4,[r8]':  => 516
> >> >   + /home/kisskb/slave/src/arch/arc/include/asm/atomic.h: Error: bad 
> >> > instruction `scondd r6,[r3]':  => 478
> > arcv2/axs103_smp_defconfig
> 
> 
> I'm thinking how to address this correctly.
> 
> This is due to the older version of compiler.  The fix itself is trivial - 
> add an
> "call as-instr" construct in Makefile to get -DARC_TOOLS_SUPPORT_LLOCKD
> 
> However the atomic64 API variant (CONFIG_GENERIC_ATOMIC64 or arch native) 
> which
> gets included in build comes from Kconfig (ISA supports them or not). How do 
> we
> tie the Makefile info into the Kconfig.
> 
> We could trigger a build failure for invalid combinations of GENERIC_ATOMIC64 
> and
> ARC_TOOLS_SUPPORT_LLOCKD but that would be less than ideal out of box 
> experience.
> 
> Or the simpler solution is that kisskb upgrades the ARC GNU compiler 

Some ideas, none of which are perfect:

- add an #ifndef ARC_TOOLS_SUPPORT_LLOCKD clause in asm/atomic.h that uses
  .long with hardcoded opcodes in place of the mnemonics.

- instead of setting CONFIG_GENERIC_ATOMIC64 from Kconfig, add a file
  in arch/arc/kernel/ that includes lib/atomic64.c if ARC_TOOLS_SUPPORT_LLOCKD
  is not set.

- add "-DCONFIG_GENERIC_ATOMIC64" to cflags-y from arch/arc/Makefile if
  old binutils are found.

I think someone was suggesting in the past that Kconfig could be extended
to make decisions based on the gcc version, and the same thing could
be done for binutils. Don't remember who that was though. I think a number
of awkward hacks in the kernel could be simplified if we had this.

And


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

2016-10-17 Thread Agustin Vega-Frias
This allows irqchip drivers to associate an ACPI DSDT device to
an IRQ domain and provides support for using the ResourceSource
in Extended IRQ Resources to find the domain and map the IRQs
specified on that domain.

Signed-off-by: Agustin Vega-Frias 
---
 drivers/acpi/Makefile |   1 +
 drivers/acpi/irqdomain.c  | 135 ++
 drivers/acpi/resource.c   |  21 +++---
 include/asm-generic/vmlinux.lds.h |   1 +
 include/linux/acpi.h  |  50 ++
 include/linux/irqchip.h   |  17 -
 6 files changed, 213 insertions(+), 12 deletions(-)
 create mode 100644 drivers/acpi/irqdomain.c

diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 9ed0878..81bdc95 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -57,6 +57,7 @@ acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
 acpi-y += acpi_lpat.o
 acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o
 acpi-$(CONFIG_ACPI_WATCHDOG)   += acpi_watchdog.o
+acpi-y += irqdomain.o
 
 # These are (potentially) separate modules
 
diff --git a/drivers/acpi/irqdomain.c b/drivers/acpi/irqdomain.c
new file mode 100644
index 000..0429607
--- /dev/null
+++ b/drivers/acpi/irqdomain.c
@@ -0,0 +1,135 @@
+/*
+ * ACPI ResourceSource/IRQ domain mapping support
+ *
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+
+/**
+ * acpi_irq_domain_ensure_probed() - Check if the device has registered
+ *   an IRQ domain and probe as necessary
+ *
+ * @device: Device to check and probe
+ *
+ * Returns: 0 on success, -ENODEV otherwise
+ */
+static int acpi_irq_domain_ensure_probed(struct acpi_device *device)
+{
+   struct acpi_dsdt_probe_entry *entry;
+
+   if (irq_find_matching_fwnode(&device->fwnode, DOMAIN_BUS_ANY) != 0)
+   return 0;
+
+   for (entry = &__dsdt_acpi_probe_table;
+entry < &__dsdt_acpi_probe_table_end; e++)
+   if (strcmp(e->_hid, acpi_device_hid(device)) == 0)
+   return e->probe(device);
+
+   return -ENODEV;
+}
+
+/**
+ * acpi_irq_domain_register_irq() - Register the mapping for an IRQ produced
+ *  by the given acpi_resource_source to a
+ *  Linux IRQ number
+ * @source: IRQ source
+ * @hwirq: Hardware IRQ number
+ * @trigger: trigger type of the IRQ number to be mapped
+ * @polarity: polarity of the IRQ to be mapped
+ *
+ * Returns: a valid linux IRQ number on success
+ *  -ENODEV if the given acpi_resource_source cannot be found
+ *  -EPROBE_DEFER if the IRQ domain has not been registered
+ *  -EINVAL for all other errors
+ */
+int acpi_irq_domain_register_irq(struct acpi_resource_source *source, u32 
hwirq,
+int trigger, int polarity)
+{
+   struct irq_fwspec fwspec;
+   struct acpi_device *device;
+   acpi_handle handle;
+   acpi_status status;
+   int ret;
+
+   if (source->string_length == 0)
+   return acpi_register_gsi(NULL, hwirq, trigger, polarity);
+
+   status = acpi_get_handle(NULL, source->string_ptr, &handle);
+   if (ACPI_FAILURE(status))
+   return -ENODEV;
+
+   device = acpi_bus_get_acpi_device(handle);
+   if (!device)
+   return -ENODEV;
+
+   if (acpi_irq_domain_ensure_probed(device))
+   return -ENODEV;
+
+   fwspec.fwnode = &device->fwnode;
+   fwspec.param[0] = hwirq;
+   fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity);
+   fwspec.param_count = 2;
+
+   ret = irq_create_fwspec_mapping(&fwspec);
+   acpi_bus_put_acpi_device(device);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(acpi_irq_domain_register_irq);
+
+/**
+ * acpi_irq_domain_unregister_irq() - Delete the mapping for an IRQ produced
+ *by the given acpi_resource_source to a
+ *Linux IRQ number
+ * @source: IRQ source
+ * @hwirq: Hardware IRQ number
+ *
+ * Returns: 0 on success
+ *  -ENODEV if the given acpi_resource_source cannot be found
+ *  -EINVAL for all other errors
+ */
+int acpi_irq_domain_unregister_irq(struct acpi_resource_source *source,
+  u32 hwirq)
+{
+   struct irq_domain *domain;
+   struct acpi_device *device;
+   acpi_handle handle;
+   acpi_status 

[PATCH V4 0/2] irqchip: qcom: Add IRQ combiner driver

2016-10-17 Thread Agustin Vega-Frias
Add support for IRQ combiners in the Top-level Control and Status
Registers (TCSR) hardware block in Qualcomm Technologies chips.

The first patch adds support for ResourceSource/IRQ domain mapping
when using Extended IRQ Resources with a specific ResourceSource.
The core ACPI resource management code has been changed to lookup
the IRQ domain when an IRQ resource indicates a ResourceSource,
and register the IRQ on that domain, instead of a GSI.

The second patch takes advantage of the new capabilities to implement
the driver for the IRQ combiners.

Changes V1 -> V2:
* Remove use of GPIO library for the combiner
* Refactor to use fwnode/ResourceSource to IRQ domain mapping
  introduced in ACPI core

Changes V2 -> V3:
* Removed parsing of _PRS to find IRQs
* Removed acpi_irq_domain_create and acpi_irq_domain_remove

Changes V3 -> V3:
* Add a DSDT device probe table that is used to probe DSDT IRQ chips
  as necessary when converting HW IRQs to Linux IRQs
* Describe IRQ combiner registers as ACPI Register resources

Agustin Vega-Frias (2):
  ACPI: Add support for ResourceSource/IRQ domain mapping
  irqchip: qcom: Add IRQ combiner driver

 drivers/acpi/Makefile   |   1 +
 drivers/acpi/irqdomain.c| 135 +++
 drivers/acpi/resource.c |  21 ++-
 drivers/irqchip/Kconfig |   8 +
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/qcom-irq-combiner.c | 332 
 include/asm-generic/vmlinux.lds.h   |   1 +
 include/linux/acpi.h|  50 ++
 include/linux/irqchip.h |  17 +-
 9 files changed, 554 insertions(+), 12 deletions(-)
 create mode 100644 drivers/acpi/irqdomain.c
 create mode 100644 drivers/irqchip/qcom-irq-combiner.c

-- 
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, 
Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.



[PATCH V4 2/2] irqchip: qcom: Add IRQ combiner driver

2016-10-17 Thread Agustin Vega-Frias
Driver for interrupt combiners in the Top-level Control and Status
Registers (TCSR) hardware block in Qualcomm Technologies chips.

An interrupt combiner in this block combines a set of interrupts by
OR'ing the individual interrupt signals into a summary interrupt
signal routed to a parent interrupt controller, and provides read-
only, 32-bit registers to query the status of individual interrupts.
The status bit for IRQ n is bit (n % 32) within register (n / 32)
of the given combiner. Thus, each combiner can be described as a set
of register offsets and the number of IRQs managed.

Signed-off-by: Agustin Vega-Frias 
---
 drivers/irqchip/Kconfig |   8 +
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/qcom-irq-combiner.c | 332 
 3 files changed, 341 insertions(+)
 create mode 100644 drivers/irqchip/qcom-irq-combiner.c

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 82b0b5d..05ecd91 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -279,3 +279,11 @@ config EZNPS_GIC
 config STM32_EXTI
bool
select IRQ_DOMAIN
+
+config QCOM_IRQ_COMBINER
+   bool "QCOM IRQ combiner support"
+   depends on ARCH_QCOM
+   select IRQ_DOMAIN
+   help
+ Say yes here to add support for the IRQ combiner devices embedded
+ in Qualcomm Technologies chips.
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index e4dbfc8..1818a0b 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o
 obj-$(CONFIG_EZNPS_GIC)+= irq-eznps.o
 obj-$(CONFIG_ARCH_ASPEED)  += irq-aspeed-vic.o
 obj-$(CONFIG_STM32_EXTI)   += irq-stm32-exti.o
+obj-$(CONFIG_QCOM_IRQ_COMBINER)+= qcom-irq-combiner.o
diff --git a/drivers/irqchip/qcom-irq-combiner.c 
b/drivers/irqchip/qcom-irq-combiner.c
new file mode 100644
index 000..b117cd7
--- /dev/null
+++ b/drivers/irqchip/qcom-irq-combiner.c
@@ -0,0 +1,332 @@
+/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/*
+ * Driver for interrupt combiners in the Top-level Control and Status
+ * Registers (TCSR) hardware block in Qualcomm Technologies chips.
+ * An interrupt combiner in this block combines a set of interrupts by
+ * OR'ing the individual interrupt signals into a summary interrupt
+ * signal routed to a parent interrupt controller, and provides read-
+ * only, 32-bit registers to query the status of individual interrupts.
+ * The status bit for IRQ n is bit (n % 32) within register (n / 32)
+ * of the given combiner. Thus, each combiner can be described as a set
+ * of register offsets and the number of IRQs managed.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define REG_SIZE 32
+
+struct combiner_reg {
+   void __iomem *addr;
+   unsigned long mask;
+};
+
+struct combiner {
+   struct irq_chip irq_chip;
+   struct irq_domain   *domain;
+   int parent_irq;
+   u32 nirqs;
+   u32 nregs;
+   struct combiner_reg regs[0];
+};
+
+static inline u32 irq_register(int irq)
+{
+   return irq / REG_SIZE;
+}
+
+static inline u32 irq_bit(int irq)
+{
+   return irq % REG_SIZE;
+
+}
+
+static inline int irq_nr(u32 reg, u32 bit)
+{
+   return reg * REG_SIZE + bit;
+}
+
+/*
+ * Handler for the cascaded IRQ.
+ */
+static void combiner_handle_irq(struct irq_desc *desc)
+{
+   struct combiner *combiner = irq_desc_get_handler_data(desc);
+   struct irq_chip *chip = irq_desc_get_chip(desc);
+   u32 reg;
+
+   chained_irq_enter(chip, desc);
+
+   for (reg = 0; reg < combiner->nregs; reg++) {
+   int virq;
+   int hwirq;
+   u32 bit;
+   u32 status;
+
+   if (combiner->regs[reg].mask == 0)
+   continue;
+
+   status = readl_relaxed(combiner->regs[reg].addr);
+   status &= combiner->regs[reg].mask;
+
+   while (status) {
+   bit = __ffs(status);
+   status &= ~(1 << bit);
+   hwirq = irq_nr(reg, bit);
+   virq = irq_find_mapping(combiner->domain, hwirq);
+   if (virq >= 0)
+   generic_handle_irq(virq);
+
+   }
+   }
+
+   chained_irq_exit(chip, desc);

Re: [PATCH resend 4.9] hw_random: Don't use a stack buffer in add_early_randomness()

2016-10-17 Thread Andy Lutomirski
On Mon, Oct 17, 2016 at 11:36 AM, Stephan Mueller  wrote:
> Am Montag, 17. Oktober 2016, 10:30:13 CEST schrieb Andy Lutomirski:
>
> Hi Andy,
>>
>> Sure, but shouldn't that be a separate patch covering the whole hw_crypto
>> core?
>
> I think that you are right -- there are many more cases where a memset(0) is
> warranted.
>
> Do you want to make this change or should I send a patch?

Can you do it?  I have my work cut out for me making sure that all the
known regressions get stomped quickly...


Re: [PATCH] spi: mark device nodes only in case of successful instantiation

2016-10-17 Thread Wolfram Sang
On Mon, Oct 17, 2016 at 10:20:47PM +0300, Pantelis Antoniou wrote:
> Hi Ralf,
> 
> > On Oct 16, 2016, at 12:55 , Ralf Ramsauer  
> > wrote:
> > 
> > Hi Geert,
> > 
> > On 10/16/2016 10:49 AM, Geert Uytterhoeven wrote:
> >> Hi Ralf,
> >> 
> >> (Cc i2c)
> >> 
> >> On Fri, Oct 14, 2016 at 9:31 PM, Ralf Ramsauer
> >>  wrote:
> >>> Instantiated SPI device nodes are marked with OF_POPULATE. This was
> >>> introduced in bd6c164. On unloading, loaded device nodes will of course
> >>> be unmarked. The problem are nodes the fail during initialisation: If a
> >>> node failed during registration, it won't be unloaded and hence never be
> >>> unmarked again.
> >>> 
> >>> So if a SPI driver module is unloaded and reloaded, it will skip nodes
> >>> that failed before.
> >>> 
> >>> Skip device nodes that are already populated and mark them only in case
> >>> of success.
> >>> 
> >>> Fixes: bd6c164 ("spi: Mark instantiated device nodes with OF_POPULATE")
> >>> Signed-off-by: Ralf Ramsauer 
> >>> Cc: Geert Uytterhoeven 
> >>> ---
> >>> Hi,
> >>> 
> >>> imagine the following situation: you loaded a spi driver as module, but
> >>> it fails to instantiate, because of some reasons (e.g. some resources,
> >>> like gpios, might be in use in userspace).
> >>> 
> >>> When reloading the driver, _all_ nodes, including previously failed
> >>> ones, should be probed again. This is not the case at the moment.
> >>> Current behaviour only re-registers nodes that were previously
> >>> successfully loaded.
> >>> 
> >>> This small patches fixes this behaviour. I stumbled over this while
> >>> working on a spi driver.
> >> 
> >> Thanks for your patch!
> >> 
> >>> drivers/spi/spi.c | 7 +--
> >>> 1 file changed, 5 insertions(+), 2 deletions(-)
> >>> 
> >>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> >>> index 200ca22..f96a04e 100644
> >>> --- a/drivers/spi/spi.c
> >>> +++ b/drivers/spi/spi.c
> >>> @@ -1604,12 +1604,15 @@ static void of_register_spi_devices(struct 
> >>> spi_master *master)
> >>>return;
> >>> 
> >>>for_each_available_child_of_node(master->dev.of_node, nc) {
> >>> -   if (of_node_test_and_set_flag(nc, OF_POPULATED))
> >>> +   if (of_node_check_flag(nc, OF_POPULATED))
> >>>continue;
> >>>spi = of_register_spi_device(master, nc);
> >>> -   if (IS_ERR(spi))
> >>> +   if (IS_ERR(spi)) {
> >>>dev_warn(&master->dev, "Failed to create SPI 
> >>> device for %s\n",
> >>>nc->full_name);
> >>> +   continue;
> >>> +   }
> >>> +   of_node_set_flag(nc, OF_POPULATED);
> >> 
> >> I think it's safer to keep the atomic test-and-set, but clear the flag on
> >> failure, cfr. of_platform_device_create_pdata() and 
> >> of_amba_device_create().
> > Ack, no prob. Let me change this in the next version.
> >> 

> Thanks for this. This is a very rare case that’s easy to slip through.
> It is good to be consistent :)

I read this as acked-by for the series?



signature.asc
Description: PGP signature


Re: [PATCH v2] Coccinelle: Add misc/boolconv.cocci

2016-10-17 Thread Andrew F. Davis
On 10/17/2016 03:54 PM, Julia Lawall wrote:
> On Mon, 17 Oct 2016, Andrew F. Davis wrote:
> 
>> Add a script to check for unneeded conversions to bool.
> 
> What changed since the previous version?
> 

Nothing, just a resend, forgot to label it as such.

Andrew

> julia
> 
> 
>>
>> Signed-off-by: Andrew F. Davis 
>> Acked-by: Julia Lawall 
>> ---
>>  scripts/coccinelle/misc/boolconv.cocci | 90 
>> ++
>>  1 file changed, 90 insertions(+)
>>  create mode 100644 scripts/coccinelle/misc/boolconv.cocci
>>
>> diff --git a/scripts/coccinelle/misc/boolconv.cocci 
>> b/scripts/coccinelle/misc/boolconv.cocci
>> new file mode 100644
>> index 000..33c464d
>> --- /dev/null
>> +++ b/scripts/coccinelle/misc/boolconv.cocci
>> @@ -0,0 +1,90 @@
>> +/// Remove unneeded conversion to bool
>> +///
>> +//# Relational and logical operators evaluate to bool,
>> +//# explicit conversion is overly verbose and unneeded.
>> +//
>> +// Copyright: (C) 2016 Andrew F. Davis  GPLv2.
>> +
>> +virtual patch
>> +virtual context
>> +virtual org
>> +virtual report
>> +
>> +//--
>> +//  For patch mode
>> +//--
>> +
>> +@depends on patch@
>> +expression A, B;
>> +symbol true, false;
>> +@@
>> +
>> +(
>> +  A == B
>> +|
>> +  A != B
>> +|
>> +  A > B
>> +|
>> +  A < B
>> +|
>> +  A >= B
>> +|
>> +  A <= B
>> +|
>> +  A && B
>> +|
>> +  A || B
>> +)
>> +- ? true : false
>> +
>> +//--
>> +//  For context mode
>> +//--
>> +
>> +@r depends on !patch@
>> +expression A, B;
>> +symbol true, false;
>> +position p;
>> +@@
>> +
>> +(
>> +  A == B
>> +|
>> +  A != B
>> +|
>> +  A > B
>> +|
>> +  A < B
>> +|
>> +  A >= B
>> +|
>> +  A <= B
>> +|
>> +  A && B
>> +|
>> +  A || B
>> +)
>> +* ? true : false@p
>> +
>> +//--
>> +//  For org mode
>> +//--
>> +
>> +@script:python depends on r&&org@
>> +p << r.p;
>> +@@
>> +
>> +msg = "WARNING: conversion to bool not needed here"
>> +coccilib.org.print_todo(p[0], msg)
>> +
>> +//--
>> +//  For report mode
>> +//--
>> +
>> +@script:python depends on r&&report@
>> +p << r.p;
>> +@@
>> +
>> +msg = "WARNING: conversion to bool not needed here"
>> +coccilib.report.print_report(p[0], msg)
>> --
>> 2.10.1
>>
>>


Re: [PATCH] spi: mark device nodes only in case of successful instantiation

2016-10-17 Thread Wolfram Sang
> > Thanks for this. This is a very rare case that’s easy to slip through.
> > It is good to be consistent :)
> 
> I read this as acked-by for the series?

Ah, I mixed up. You acked V2 :)



signature.asc
Description: PGP signature


Re: [PATCH v2] iio: light: ltr501: claim direct mode during raw writes

2016-10-17 Thread Peter Meerwald-Stadler
On Sun, 16 Oct 2016, Jonathan Cameron wrote:

> On 16/10/16 06:02, Alison Schofield wrote:
> > Driver was checking for direct mode but not locking it.  Use
> > claim/release helper functions to guarantee the device stays
> > in direct mode during all raw write operations.
> > 
> > Signed-off-by: Alison Schofield 
> > ---
> > Changes in v2:
> >   Replaced 'goto release' statements with breaks.
> >   The release helper function remains in the same place as in version
> >   one of patch, but now break statements control the flow rather than
> >   jumping out with goto's.
> >   
> >   I may have 'break'd more than needed at tail end of nested switch.
> >   Tried to follow official c language definition.  
> > 
> I'd have done it exactly the same
> 
> Applied to the togreg branch of iio.git.  Again, Peter, if you have
> a chance to look at this that would be great.  If not then not to worry!

Acked-by: Peter Meerwald-Stadler 
 
> Jonathan
> > 
> >  drivers/iio/light/ltr501.c | 81 
> > +-
> >  1 file changed, 51 insertions(+), 30 deletions(-)
> > 
> > diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> > index 3afc53a..8f9d5cf 100644
> > --- a/drivers/iio/light/ltr501.c
> > +++ b/drivers/iio/light/ltr501.c
> > @@ -729,8 +729,9 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
> > int i, ret, freq_val, freq_val2;
> > struct ltr501_chip_info *info = data->chip_info;
> >  
> > -   if (iio_buffer_enabled(indio_dev))
> > -   return -EBUSY;
> > +   ret = iio_device_claim_direct_mode(indio_dev);
> > +   if (ret)
> > +   return ret;
> >  
> > switch (mask) {
> > case IIO_CHAN_INFO_SCALE:
> > @@ -739,85 +740,105 @@ static int ltr501_write_raw(struct iio_dev 
> > *indio_dev,
> > i = ltr501_get_gain_index(info->als_gain,
> >   info->als_gain_tbl_size,
> >   val, val2);
> > -   if (i < 0)
> > -   return -EINVAL;
> > +   if (i < 0) {
> > +   ret = -EINVAL;
> > +   break;
> > +   }
> >  
> > data->als_contr &= ~info->als_gain_mask;
> > data->als_contr |= i << info->als_gain_shift;
> >  
> > -   return regmap_write(data->regmap, LTR501_ALS_CONTR,
> > -   data->als_contr);
> > +   ret = regmap_write(data->regmap, LTR501_ALS_CONTR,
> > +  data->als_contr);
> > +   break;
> > case IIO_PROXIMITY:
> > i = ltr501_get_gain_index(info->ps_gain,
> >   info->ps_gain_tbl_size,
> >   val, val2);
> > -   if (i < 0)
> > -   return -EINVAL;
> > +   if (i < 0) {
> > +   ret = -EINVAL;
> > +   break;
> > +   }
> > data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK;
> > data->ps_contr |= i << LTR501_CONTR_PS_GAIN_SHIFT;
> >  
> > -   return regmap_write(data->regmap, LTR501_PS_CONTR,
> > -   data->ps_contr);
> > +   ret = regmap_write(data->regmap, LTR501_PS_CONTR,
> > +  data->ps_contr);
> > +   break;
> > default:
> > -   return -EINVAL;
> > +   ret = -EINVAL;
> > +   break;
> > }
> > +   break;
> > +
> > case IIO_CHAN_INFO_INT_TIME:
> > switch (chan->type) {
> > case IIO_INTENSITY:
> > -   if (val != 0)
> > -   return -EINVAL;
> > +   if (val != 0) {
> > +   ret = -EINVAL;
> > +   break;
> > +   }
> > mutex_lock(&data->lock_als);
> > -   i = ltr501_set_it_time(data, val2);
> > +   ret = ltr501_set_it_time(data, val2);
> > mutex_unlock(&data->lock_als);
> > -   return i;
> > +   break;
> > default:
> > -   return -EINVAL;
> > +   ret = -EINVAL;
> > +   break;
> > }
> > +   break;
> > +
> > case IIO_CHAN_INFO_SAMP_FREQ:
> > switch (chan->type) {
> > case IIO_INTENSITY:
> > ret = ltr501_als_read_samp_freq(data, &freq_val,
> > &freq_val2);
> > if (ret < 0)
> > -   return ret;
> > +   break;
> >  
> > 

Re: [PATCH V2] usb: xhci: add support for performing fake doorbell

2016-10-17 Thread Hauke Mehrtens
On 10/17/2016 10:30 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki 
> 
> Broadcom's Northstar XHCI controllers seem to need a special start
> procedure to work correctly. There isn't any official documentation of
> this, the problem is that controller doesn't detect any connected
> devices with default setup. Moreover connecting USB device to controller
> that doesn't run properly can cause SoC's watchdog issues.
> 
> A workaround that was successfully tested on multiple devices is to
> perform a fake doorbell. This patch adds code for doing this and enables
> it on BCM4708 family.
> 
> Signed-off-by: Rafał Miłecki 
> ---
> V2: Enable quirk for brcm,bcm4708 machines instead of adding separated binding
> for it. Thanks Rob for your comment on this.
> ---
>  drivers/usb/host/xhci-plat.c |  6 +
>  drivers/usb/host/xhci.c  | 63 
> +---
>  drivers/usb/host/xhci.h  |  1 +
>  3 files changed, 67 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index ed56bf9..b01a3be 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -56,12 +56,18 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd)
>  
>  static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
>  {
> + struct platform_device  *pdev = to_platform_device(dev);
> + struct device_node  *node = pdev->dev.of_node;
> +
>   /*
>* As of now platform drivers don't provide MSI support so we ensure
>* here that the generic code does not try to make a pci_dev from our
>* dev struct in order to setup MSI
>*/
>   xhci->quirks |= XHCI_PLAT;
> +
> + if (node && of_machine_is_compatible("brcm,bcm4708"))
> + xhci->quirks |= XHCI_FAKE_DOORBELL;

Are you sure only the bcm4708 and similar SoCs are affected? Having here
a list with 3 or more checks would looks strange. I prefer your first patch.

@Florian do you know if other Broadcom SoC are affected by this problem
or are only Northstar SoCs affected?

Hauke


<    4   5   6   7   8   9   10   11   12   >