Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support

2016-08-07 Thread Keerthy



On Monday 08 August 2016 11:56 AM, kbuild test robot wrote:

Hi Keerthy,

[auto build test ERROR on gpio/for-next]
[also build test ERROR on v4.8-rc1 next-20160805]
[cannot apply to ljones-mfd/for-mfd-next]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Keerthy/mfd-lp873x-Add-lp873x-PMIC-support/20160808-135204
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
 # save the attached .config to linux build tree
 make ARCH=i386

All errors (new ones prefixed by >>):


drivers/mfd/lp873x.c:83:2: error: unknown field 'probe_new' specified in 
initializer

  .probe_new  = lp873x_probe,
  ^

drivers/mfd/lp873x.c:83:16: error: initialization from incompatible pointer 
type [-Werror=incompatible-pointer-types]

  .probe_new  = lp873x_probe,
^~~~
drivers/mfd/lp873x.c:83:16: note: (near initialization for 
'lp873x_driver.id_table')
cc1: some warnings being treated as errors

vim +/probe_new +83 drivers/mfd/lp873x.c

 77 
 78 static struct i2c_driver lp873x_driver = {
 79 .driver = {
 80 .name   = "lp873x",
 81 .of_match_table = of_lp873x_match_table,
 82 },
   > 83  .probe_new  = lp873x_probe,


Depends on: Rebased on top of 
http://www.gossamer-threads.com/lists/linux/kernel/2457552


As mentioned clearly.


 84 };
 85 module_i2c_driver(lp873x_driver);
 86 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation



Re: [PATCH 09/11] powerpc/mpic: use of_property_read_bool

2016-08-07 Thread Michael Ellerman
Julia Lawall  writes:

> Use of_property_read_bool to check for the existence of a property.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // 
> @@
> expression e1,e2;
> statement S2,S1;
> @@
> -   if (of_get_property(e1,e2,NULL))
> +   if (of_property_read_bool(e1,e2))
> S1 else S2
> // 
>
> Signed-off-by: Julia Lawall 
>
> ---
>  arch/powerpc/sysdev/mpic.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Michael Ellerman 

cheers


[PATCH v3 kernel 4/7] virtio-balloon: speed up inflate/deflate process

2016-08-07 Thread Liang Li
The implementation of the current virtio-balloon is not very
efficient, the time spends on different stages of inflating
the balloon to 7GB of a 8GB idle guest:

a. allocating pages (6.5%)
b. sending PFNs to host (68.3%)
c. address translation (6.1%)
d. madvise (19%)

It takes about 4126ms for the inflating process to complete.
Debugging shows that the bottle neck are the stage b and stage d.

If using a bitmap to send the page info instead of the PFNs, we
can reduce the overhead in stage b quite a lot. Furthermore, we
can do the address translation and call madvise() with a bulk of
RAM pages, instead of the current page per page way, the overhead
of stage c and stage d can also be reduced a lot.

This patch is the kernel side implementation which is intended to
speed up the inflating & deflating process by adding a new feature
to the virtio-balloon device. With this new feature, inflating the
balloon to 7GB of a 8GB idle guest only takes 590ms, the
performance improvement is about 85%.

TODO: optimize stage a by allocating/freeing a chunk of pages
instead of a single page at a time.

Signed-off-by: Liang Li 
Suggested-by: Michael S. Tsirkin 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 drivers/virtio/virtio_balloon.c | 233 +++-
 1 file changed, 209 insertions(+), 24 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 59ffe5a..c31839c 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -42,6 +42,10 @@
 #define OOM_VBALLOON_DEFAULT_PAGES 256
 #define VIRTBALLOON_OOM_NOTIFY_PRIORITY 80
 
+#define BALLOON_BMAP_SIZE  (8 * PAGE_SIZE)
+#define PFNS_PER_BMAP  (BALLOON_BMAP_SIZE * BITS_PER_BYTE)
+#define BALLOON_BMAP_COUNT 32
+
 static int oom_pages = OOM_VBALLOON_DEFAULT_PAGES;
 module_param(oom_pages, int, S_IRUSR | S_IWUSR);
 MODULE_PARM_DESC(oom_pages, "pages to free on OOM");
@@ -67,6 +71,13 @@ struct virtio_balloon {
 
/* Number of balloon pages we've told the Host we're not using. */
unsigned int num_pages;
+   /* Pointer of the bitmap header. */
+   void *bmap_hdr;
+   /* Bitmap and bitmap count used to tell the host the pages */
+   unsigned long *page_bitmap[BALLOON_BMAP_COUNT];
+   unsigned int nr_page_bmap;
+   /* Used to record the processed pfn range */
+   unsigned long min_pfn, max_pfn, start_pfn, end_pfn;
/*
 * The pages we've told the Host we're not using are enqueued
 * at vb_dev_info->pages list.
@@ -110,16 +121,66 @@ static void balloon_ack(struct virtqueue *vq)
wake_up(&vb->acked);
 }
 
+static inline void init_pfn_range(struct virtio_balloon *vb)
+{
+   vb->min_pfn = ULONG_MAX;
+   vb->max_pfn = 0;
+}
+
+static inline void update_pfn_range(struct virtio_balloon *vb,
+struct page *page)
+{
+   unsigned long balloon_pfn = page_to_balloon_pfn(page);
+
+   if (balloon_pfn < vb->min_pfn)
+   vb->min_pfn = balloon_pfn;
+   if (balloon_pfn > vb->max_pfn)
+   vb->max_pfn = balloon_pfn;
+}
+
 static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
 {
-   struct scatterlist sg;
-   unsigned int len;
+   struct scatterlist sg, sg2[BALLOON_BMAP_COUNT + 1];
+   unsigned int len, i;
+
+   if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_PAGE_BITMAP)) {
+   struct balloon_bmap_hdr *hdr = vb->bmap_hdr;
+   unsigned long bmap_len;
+   int nr_pfn, nr_used_bmap, nr_buf;
+
+   nr_pfn = vb->end_pfn - vb->start_pfn + 1;
+   nr_pfn = roundup(nr_pfn, BITS_PER_LONG);
+   nr_used_bmap = nr_pfn / PFNS_PER_BMAP;
+   bmap_len = nr_pfn / BITS_PER_BYTE;
+   nr_buf = nr_used_bmap + 1;
+
+   /* cmd, reserved and req_id are init to 0, unused here */
+   hdr->page_shift = cpu_to_virtio16(vb->vdev, PAGE_SHIFT);
+   hdr->start_pfn = cpu_to_virtio64(vb->vdev, vb->start_pfn);
+   hdr->bmap_len = cpu_to_virtio64(vb->vdev, bmap_len);
+   sg_init_table(sg2, nr_buf);
+   sg_set_buf(&sg2[0], hdr, sizeof(struct balloon_bmap_hdr));
+   for (i = 0; i < nr_used_bmap; i++) {
+   unsigned int  buf_len = BALLOON_BMAP_SIZE;
+
+   if (i + 1 == nr_used_bmap)
+   buf_len = bmap_len - BALLOON_BMAP_SIZE * i;
+   sg_set_buf(&sg2[i + 1], vb->page_bitmap[i], buf_len);
+   }
 
-   sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
+   while (vq->num_free < nr_buf)
+   msleep(2);
+   if (virtqueue_add_outbuf(vq, sg2, nr_buf, vb, GFP_KERNEL) == 0)
+   virtqueue_kick(vq);
 
-   /* We should always be able to add one buffer to an

[PATCH v3 kernel 6/7] virtio-balloon: define feature bit and head for misc virt queue

2016-08-07 Thread Liang Li
Define a new feature bit which supports a new virtual queue. This
new virtual qeuque is for information exchange between hypervisor
and guest. The VMM hypervisor can make use of this virtual queue
to request the guest do some operations, e.g. drop page cache,
synchronize file system, etc. And the VMM hypervisor can get some
of guest's runtime information through this virtual queue, e.g. the
guest's unused page information, which can be used for live migration
optimization.

Signed-off-by: Liang Li 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 include/uapi/linux/virtio_balloon.h | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/include/uapi/linux/virtio_balloon.h 
b/include/uapi/linux/virtio_balloon.h
index d3b182a..3a9d633 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -35,6 +35,7 @@
 #define VIRTIO_BALLOON_F_STATS_VQ  1 /* Memory Stats virtqueue */
 #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM2 /* Deflate balloon on OOM */
 #define VIRTIO_BALLOON_F_PAGE_BITMAP   3 /* Send page info with bitmap */
+#define VIRTIO_BALLOON_F_MISC_VQ   4 /* Misc info virtqueue */
 
 /* Size of a PFN in the balloon interface. */
 #define VIRTIO_BALLOON_PFN_SHIFT 12
@@ -101,4 +102,25 @@ struct balloon_bmap_hdr {
__virtio64 bmap_len;
 };
 
+enum balloon_req_id {
+   /* Get unused pages information */
+   BALLOON_GET_UNUSED_PAGES,
+};
+
+enum balloon_flag {
+   /* Have more data for a request */
+   BALLOON_FLAG_CONT,
+   /* No more data for a request */
+   BALLOON_FLAG_DONE,
+};
+
+struct balloon_req_hdr {
+   /* Used to distinguish different request */
+   __virtio16 cmd;
+   /* Reserved */
+   __virtio16 reserved[3];
+   /* Request parameter */
+   __virtio64 param;
+};
+
 #endif /* _LINUX_VIRTIO_BALLOON_H */
-- 
1.8.3.1



[PATCH v3 kernel 5/7] mm: add the related functions to get unused page

2016-08-07 Thread Liang Li
Save the unused page info into page bitmap. The virtio balloon
driver call this new API to get the unused page bitmap and send
the bitmap to hypervisor(QEMU) for speeding up live migration.
During sending the bitmap, some the pages may be modified and are
no free anymore, this inaccuracy can be corrected by the dirty
page logging mechanism.

Signed-off-by: Liang Li 
Cc: Andrew Morton 
Cc: Mel Gorman 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 include/linux/mm.h |  2 ++
 mm/page_alloc.c| 84 ++
 2 files changed, 86 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5873057..d181864 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1789,6 +1789,8 @@ extern void free_area_init_node(int nid, unsigned long * 
zones_size,
unsigned long zone_start_pfn, unsigned long *zholes_size);
 extern void free_initmem(void);
 extern unsigned long get_max_pfn(void);
+extern int get_unused_pages(unsigned long start_pfn, unsigned long end_pfn,
+   unsigned long *bitmap[], unsigned long len, unsigned int nr_bmap);
 
 /*
  * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3373704..1b5419d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4401,6 +4401,90 @@ unsigned long get_max_pfn(void)
 }
 EXPORT_SYMBOL(get_max_pfn);
 
+static void mark_unused_pages_bitmap(struct zone *zone,
+   unsigned long start_pfn, unsigned long end_pfn,
+   unsigned long *bitmap[], unsigned long bits,
+   unsigned int nr_bmap)
+{
+   unsigned long pfn, flags, nr_pg, pos, *bmap;
+   unsigned int order, i, t, bmap_idx;
+   struct list_head *curr;
+
+   if (zone_is_empty(zone))
+   return;
+
+   end_pfn = min(start_pfn + nr_bmap * bits, end_pfn);
+   spin_lock_irqsave(&zone->lock, flags);
+
+   for_each_migratetype_order(order, t) {
+   list_for_each(curr, &zone->free_area[order].free_list[t]) {
+   pfn = page_to_pfn(list_entry(curr, struct page, lru));
+   if (pfn < start_pfn || pfn >= end_pfn)
+   continue;
+   nr_pg = 1UL << order;
+   if (pfn + nr_pg > end_pfn)
+   nr_pg = end_pfn - pfn;
+   bmap_idx = (pfn - start_pfn) / bits;
+   if (bmap_idx == (pfn + nr_pg - start_pfn) / bits) {
+   bmap = bitmap[bmap_idx];
+   pos = (pfn - start_pfn) % bits;
+   bitmap_set(bmap, pos, nr_pg);
+   } else
+   for (i = 0; i < nr_pg; i++) {
+   bmap_idx = pos / bits;
+   bmap = bitmap[bmap_idx];
+   pos = pos % bits;
+   bitmap_set(bmap, pos, 1);
+   }
+   }
+   }
+
+   spin_unlock_irqrestore(&zone->lock, flags);
+}
+
+/*
+ * During live migration, page is always discardable unless it's
+ * content is needed by the system.
+ * get_unused_pages provides an API to get the unused pages, these
+ * unused pages can be discarded if there is no modification since
+ * the request. Some other mechanism, like the dirty page logging
+ * can be used to track the modification.
+ *
+ * This function scans the free page list to get the unused pages
+ * whose pfn are range from start_pfn to end_pfn, and set the
+ * corresponding bit in the bitmap if an unused page is found.
+ *
+ * Allocating a large bitmap may fail because of fragmentation,
+ * instead of using a single bitmap, we use a scatter/gather bitmap.
+ * The 'bitmap' is the start address of an array which contains
+ * 'nr_bmap' separate small bitmaps, each bitmap contains 'bits' bits.
+ *
+ * return -1 if parameters are invalid
+ * return 0 when end_pfn >= max_pfn
+ * return 1 when end_pfn < max_pfn
+ */
+int get_unused_pages(unsigned long start_pfn, unsigned long end_pfn,
+   unsigned long *bitmap[], unsigned long bits, unsigned int nr_bmap)
+{
+   struct zone *zone;
+   int ret = 0;
+
+   if (bitmap == NULL || *bitmap == NULL || nr_bmap == 0 ||
+bits == 0 || start_pfn > end_pfn)
+   return -1;
+   if (end_pfn < max_pfn)
+   ret = 1;
+   if (end_pfn >= max_pfn)
+   ret = 0;
+
+   for_each_populated_zone(zone)
+   mark_unused_pages_bitmap(zone, start_pfn, end_pfn, bitmap,
+bits, nr_bmap);
+
+   return ret;
+}
+EXPORT_SYMBOL(get_unused_pages);
+
 static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref)
 {
zoneref->zone = zone;
-- 
1.8.3.1



[PATCH v3 kernel 7/7] virtio-balloon: tell host vm's unused page info

2016-08-07 Thread Liang Li
Support the request for vm's unused page information, response with
a page bitmap. QEMU can make use of this bitmap and the dirty page
logging mechanism to skip the transportation of these unused pages,
this is very helpful to speed up the live migration process.

Signed-off-by: Liang Li 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 drivers/virtio/virtio_balloon.c | 143 +---
 1 file changed, 134 insertions(+), 9 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index c31839c..f10bb8b 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -56,7 +56,7 @@ static struct vfsmount *balloon_mnt;
 
 struct virtio_balloon {
struct virtio_device *vdev;
-   struct virtqueue *inflate_vq, *deflate_vq, *stats_vq;
+   struct virtqueue *inflate_vq, *deflate_vq, *stats_vq, *misc_vq;
 
/* The balloon servicing is delegated to a freezable workqueue. */
struct work_struct update_balloon_stats_work;
@@ -78,6 +78,8 @@ struct virtio_balloon {
unsigned int nr_page_bmap;
/* Used to record the processed pfn range */
unsigned long min_pfn, max_pfn, start_pfn, end_pfn;
+   /* Request header */
+   struct balloon_req_hdr req_hdr;
/*
 * The pages we've told the Host we're not using are enqueued
 * at vb_dev_info->pages list.
@@ -423,6 +425,78 @@ static void update_balloon_stats(struct virtio_balloon *vb)
pages_to_bytes(available));
 }
 
+static void send_unused_pages_info(struct virtio_balloon *vb,
+   unsigned long req_id)
+{
+   struct scatterlist sg_in, sg_out[BALLOON_BMAP_COUNT + 1];
+   unsigned long pfn = 0, bmap_len, pfn_limit, last_pfn, nr_pfn;
+   struct virtqueue *vq = vb->misc_vq;
+   struct balloon_bmap_hdr *hdr = vb->bmap_hdr;
+   int ret = 1, nr_buf, used_nr_bmap = 0, i;
+
+   if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_PAGE_BITMAP) &&
+   vb->nr_page_bmap == 1)
+   extend_page_bitmap(vb);
+
+   pfn_limit = PFNS_PER_BMAP * vb->nr_page_bmap;
+   mutex_lock(&vb->balloon_lock);
+   last_pfn = get_max_pfn();
+
+   while (ret) {
+   clear_page_bitmap(vb);
+   ret = get_unused_pages(pfn, pfn + pfn_limit, vb->page_bitmap,
+PFNS_PER_BMAP, vb->nr_page_bmap);
+   if (ret < 0)
+   break;
+   hdr->cmd = cpu_to_virtio16(vb->vdev, BALLOON_GET_UNUSED_PAGES);
+   hdr->page_shift = cpu_to_virtio16(vb->vdev, PAGE_SHIFT);
+   hdr->req_id = cpu_to_virtio64(vb->vdev, req_id);
+   hdr->start_pfn = cpu_to_virtio64(vb->vdev, pfn);
+   bmap_len = BALLOON_BMAP_SIZE * vb->nr_page_bmap;
+
+   if (!ret) {
+   hdr->flag = cpu_to_virtio16(vb->vdev,
+BALLOON_FLAG_DONE);
+   nr_pfn = last_pfn - pfn;
+   used_nr_bmap = nr_pfn / PFNS_PER_BMAP;
+   if (nr_pfn % PFNS_PER_BMAP)
+   used_nr_bmap++;
+   bmap_len = nr_pfn / BITS_PER_BYTE;
+   } else {
+   hdr->flag = cpu_to_virtio16(vb->vdev,
+   BALLOON_FLAG_CONT);
+   used_nr_bmap = vb->nr_page_bmap;
+   }
+   hdr->bmap_len = cpu_to_virtio64(vb->vdev, bmap_len);
+   nr_buf = used_nr_bmap + 1;
+   sg_init_table(sg_out, nr_buf);
+   sg_set_buf(&sg_out[0], hdr, sizeof(struct balloon_bmap_hdr));
+   for (i = 0; i < used_nr_bmap; i++) {
+   unsigned int buf_len = BALLOON_BMAP_SIZE;
+
+   if (i + 1 == used_nr_bmap)
+   buf_len = bmap_len - BALLOON_BMAP_SIZE * i;
+   sg_set_buf(&sg_out[i + 1], vb->page_bitmap[i], buf_len);
+   }
+
+   while (vq->num_free < nr_buf)
+   msleep(2);
+   if (virtqueue_add_outbuf(vq, sg_out, nr_buf, vb,
+GFP_KERNEL) == 0) {
+   virtqueue_kick(vq);
+   while (!virtqueue_get_buf(vq, &i)
+   && !virtqueue_is_broken(vq))
+   cpu_relax();
+   }
+   pfn += pfn_limit;
+   }
+
+   mutex_unlock(&vb->balloon_lock);
+   sg_init_one(&sg_in, &vb->req_hdr, sizeof(vb->req_hdr));
+   virtqueue_add_inbuf(vq, &sg_in, 1, &vb->req_hdr, GFP_KERNEL);
+   virtqueue_kick(vq);
+}
+
 /*
  * While most virtqueues communicate guest-initiated requests to the 
hypervisor,
  * the stats queue operates in reverse.  The driver initializes the 

[PATCH v3 kernel 3/7] mm: add a function to get the max pfn

2016-08-07 Thread Liang Li
Expose the function to get the max pfn, so it can be used in the
virtio-balloon device driver. Simply include the 'linux/bootmem.h'
is not enough, if the device driver is built to a module, directly
refer the max_pfn lead to build failed.

Signed-off-by: Liang Li 
Cc: Andrew Morton 
Cc: Mel Gorman 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 include/linux/mm.h |  1 +
 mm/page_alloc.c| 10 ++
 2 files changed, 11 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 08ed53e..5873057 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1788,6 +1788,7 @@ extern void free_area_init(unsigned long * zones_size);
 extern void free_area_init_node(int nid, unsigned long * zones_size,
unsigned long zone_start_pfn, unsigned long *zholes_size);
 extern void free_initmem(void);
+extern unsigned long get_max_pfn(void);
 
 /*
  * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fb975ce..3373704 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4391,6 +4391,16 @@ void show_free_areas(unsigned int filter)
show_swap_cache_info();
 }
 
+/*
+ * The max_pfn can change because of memory hot plug, so it's only good
+ * as a hint. e.g. for sizing data structures.
+ */
+unsigned long get_max_pfn(void)
+{
+   return max_pfn;
+}
+EXPORT_SYMBOL(get_max_pfn);
+
 static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref)
 {
zoneref->zone = zone;
-- 
1.8.3.1



[PATCH v3 kernel 2/7] virtio-balloon: define new feature bit and page bitmap head

2016-08-07 Thread Liang Li
Add a new feature which supports sending the page information with
a bitmap. The current implementation uses PFNs array, which is not
very efficient. Using bitmap can improve the performance of
inflating/deflating significantly

The page bitmap header will used to tell the host some information
about the page bitmap. e.g. the page size, page bitmap length and
start pfn.

Signed-off-by: Liang Li 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 include/uapi/linux/virtio_balloon.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/include/uapi/linux/virtio_balloon.h 
b/include/uapi/linux/virtio_balloon.h
index 343d7dd..d3b182a 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -34,6 +34,7 @@
 #define VIRTIO_BALLOON_F_MUST_TELL_HOST0 /* Tell before reclaiming 
pages */
 #define VIRTIO_BALLOON_F_STATS_VQ  1 /* Memory Stats virtqueue */
 #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM2 /* Deflate balloon on OOM */
+#define VIRTIO_BALLOON_F_PAGE_BITMAP   3 /* Send page info with bitmap */
 
 /* Size of a PFN in the balloon interface. */
 #define VIRTIO_BALLOON_PFN_SHIFT 12
@@ -82,4 +83,22 @@ struct virtio_balloon_stat {
__virtio64 val;
 } __attribute__((packed));
 
+/* Page bitmap header structure */
+struct balloon_bmap_hdr {
+   /* Used to distinguish different request */
+   __virtio16 cmd;
+   /* Shift width of page in the bitmap */
+   __virtio16 page_shift;
+   /* flag used to identify different status */
+   __virtio16 flag;
+   /* Reserved */
+   __virtio16 reserved;
+   /* ID of the request */
+   __virtio64 req_id;
+   /* The pfn of 0 bit in the bitmap */
+   __virtio64 start_pfn;
+   /* The length of the bitmap, in bytes */
+   __virtio64 bmap_len;
+};
+
 #endif /* _LINUX_VIRTIO_BALLOON_H */
-- 
1.8.3.1



[PATCH v3 kernel 0/7] Extend virtio-balloon for fast (de)inflating & fast live migration

2016-08-07 Thread Liang Li
This patch set contains two parts of changes to the virtio-balloon. 

One is the change for speeding up the inflating & deflating process,
the main idea of this optimization is to use bitmap to send the page
information to host instead of the PFNs, to reduce the overhead of
virtio data transmission, address translation and madvise(). This can
help to improve the performance by about 85%.

Another change is for speeding up live migration. By skipping process
guest's free pages in the first round of data copy, to reduce needless
data processing, this can help to save quite a lot of CPU cycles and
network bandwidth. We put guest's free page information in bitmap and
send it to host with the virt queue of virtio-balloon. For an idle 8GB
guest, this can help to shorten the total live migration time from 2Sec
to about 500ms in the 10Gbps network environment.  

Dave Hansen suggested a new scheme to encode the data structure,
because of additional complexity, it's not implemented in v3.

Changes from v2 to v3:
* Change the name of 'free page' to 'unused page'.
* Use the scatter & gather bitmap instead of a 1MB page bitmap. 
* Fix overwriting the page bitmap after kicking. 
* Some of MST's comments for v2. 

Changes from v1 to v2:
* Abandon the patch for dropping page cache.
* Put some structures to uapi head file.
* Use a new way to determine the page bitmap size.
* Use a unified way to send the free page information with the bitmap 
* Address the issues referred in MST's comments


Liang Li (7):
  virtio-balloon: rework deflate to add page to a list
  virtio-balloon: define new feature bit and page bitmap head
  mm: add a function to get the max pfn
  virtio-balloon: speed up inflate/deflate process
  mm: add the related functions to get unused page
  virtio-balloon: define feature bit and head for misc virt queue
  virtio-balloon: tell host vm's unused page info

 drivers/virtio/virtio_balloon.c | 390 
 include/linux/mm.h  |   3 +
 include/uapi/linux/virtio_balloon.h |  41 
 mm/page_alloc.c |  94 +
 4 files changed, 485 insertions(+), 43 deletions(-)

-- 
1.8.3.1



[PATCH v3 kernel 1/7] virtio-balloon: rework deflate to add page to a list

2016-08-07 Thread Liang Li
Will allow faster notifications using a bitmap down the road.
balloon_pfn_to_page() can be removed because it's useless.

Signed-off-by: Liang Li 
Signed-off-by: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 drivers/virtio/virtio_balloon.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 4e7003d..59ffe5a 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -103,12 +103,6 @@ static u32 page_to_balloon_pfn(struct page *page)
return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE;
 }
 
-static struct page *balloon_pfn_to_page(u32 pfn)
-{
-   BUG_ON(pfn % VIRTIO_BALLOON_PAGES_PER_PAGE);
-   return pfn_to_page(pfn / VIRTIO_BALLOON_PAGES_PER_PAGE);
-}
-
 static void balloon_ack(struct virtqueue *vq)
 {
struct virtio_balloon *vb = vq->vdev->priv;
@@ -181,18 +175,16 @@ static unsigned fill_balloon(struct virtio_balloon *vb, 
size_t num)
return num_allocated_pages;
 }
 
-static void release_pages_balloon(struct virtio_balloon *vb)
+static void release_pages_balloon(struct virtio_balloon *vb,
+struct list_head *pages)
 {
-   unsigned int i;
-   struct page *page;
+   struct page *page, *next;
 
-   /* Find pfns pointing at start of each page, get pages and free them. */
-   for (i = 0; i < vb->num_pfns; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
-   page = balloon_pfn_to_page(virtio32_to_cpu(vb->vdev,
-  vb->pfns[i]));
+   list_for_each_entry_safe(page, next, pages, lru) {
if (!virtio_has_feature(vb->vdev,
VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
adjust_managed_page_count(page, 1);
+   list_del(&page->lru);
put_page(page); /* balloon reference */
}
 }
@@ -202,6 +194,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
size_t num)
unsigned num_freed_pages;
struct page *page;
struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
+   LIST_HEAD(pages);
 
/* We can only do one array worth at a time. */
num = min(num, ARRAY_SIZE(vb->pfns));
@@ -215,6 +208,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
size_t num)
if (!page)
break;
set_page_pfns(vb, vb->pfns + vb->num_pfns, page);
+   list_add(&page->lru, &pages);
vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
}
 
@@ -226,7 +220,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
size_t num)
 */
if (vb->num_pfns != 0)
tell_host(vb, vb->deflate_vq);
-   release_pages_balloon(vb);
+   release_pages_balloon(vb, &pages);
mutex_unlock(&vb->balloon_lock);
return num_freed_pages;
 }
-- 
1.8.3.1



Re: [PATCH] clk: Hi6220: enable stub clock driver for ARCH_HISI

2016-08-07 Thread Leo Yan
Hi Amit,

On Mon, Aug 08, 2016 at 11:23:31AM +0530, Amit Kucheria wrote:
> On Mon, Aug 8, 2016 at 9:07 AM, Leo Yan  wrote:
> > In current kernel config 'CONFIG_STUB_CLK_HI6220' is disabled by
> > default, as result stub clock driver has not been registered and
> > CPUFreq driver cannot work.
> 
> I have a related patch that has been pending for a while:
> https://lkml.org/lkml/2016/6/20/375 but it was tied only to the
> thermal driver.

I also have concern this patch may duplicate with yours.

> Is the stub mandatory for the architecture? Will other SoCs in the
> family will use the same stub?

I don't think stub driver is mandartory for archtitecture and it's
only used by Hi6220 on Hikey. AFAIK, currently stub driver is only used
by CPU frequency change.

The logic is:
  Thermal cooling device driver
  `-> CPUFreq DT driver
  `-> Stub clock driver

ARM is working on Hikey for EAS profiling, so usually the use case is
to enable CPUFreq driver and stub clock driver. Sometimes it only
need enable this driver without thermal driver; so this is why we
cannot rely on thermal driver to enable stub clock driver.

I'm open-minded if you have better idea to enable it.

> > This patch is to enable stub clock driver in config for ARCH_HISI.
> >
> > Reported-by: Dietmar Eggemann 
> > Signed-off-by: Leo Yan 
> > ---
> >  drivers/clk/hisilicon/Kconfig | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
> > index 3f537a0..9e0a95e 100644
> > --- a/drivers/clk/hisilicon/Kconfig
> > +++ b/drivers/clk/hisilicon/Kconfig
> > @@ -23,5 +23,6 @@ config RESET_HISI
> >  config STUB_CLK_HI6220
> > bool "Hi6220 Stub Clock Driver"
> > depends on COMMON_CLK_HI6220 && MAILBOX
> > +   default ARCH_HISI
> > help
> >   Build the Hisilicon Hi6220 stub clock driver.
> > --
> > 1.9.1
> >


RE: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro

2016-08-07 Thread Ni, BaoleX
Dear Darren, 

Thank you very much! I'll be glad to take your advice.

Baole

-Original Message-
From: Darren Hart [mailto:dvh...@infradead.org] 
Sent: Saturday, August 06, 2016 6:57 AM
To: Henrique de Moraes Holschuh
Cc: Ni, BaoleX; ibm-acpi-de...@lists.sourceforge.net; 
platform-driver-...@vger.kernel.org; linux-kernel@vger.kernel.org; Liu, 
Chuansheng
Subject: Re: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro

On Tue, Aug 02, 2016 at 02:34:07PM -0300, Henrique de Moraes Holschuh wrote:
> (cc list trimmed)
> 
> On Tue, 02 Aug 2016, Baole Ni wrote:
> > I find that the developers often just specified the numeric value 
> > when calling a macro which is defined with a parameter for access 
> > permission.
> > As we know, these numeric value for access permission have had the 
> > corresponding macro, and that using macro can improve the robustness 
> > and readability of the code, thus, I suggest replacing the numeric 
> > parameter with the macro.
> > 
> > Signed-off-by: Chuansheng Liu 
> > Signed-off-by: Baole Ni 
> 
> NACK.
> 
> IMO, the proposed change reduces readiability for no good reason.  
> Most people touching kernel code have 0444, 0644, 0755, etc. already 
> hardwired into their pattern recognition neural network, while the 
> POSIX
> S_* crap is actually bug food.

While I'm generally in favor of using macros where they exist, I do agree with 
Henrique that this is actually less legible.

> 
> PS: no more ill-managed ultra-large patch bombs, *please*.

Indeed. 1285 patches with the same subject line is "not ideal". Prefixing with 
the subsystem at the very least would have been an improvement. An RFC on the 
concept, cc'ing the subsystem maintainers to get consensus and direction on how 
to manage the large change would have been advisable.

I'm dropping these for pdx86 unless a compelling argument arises for including 
them (like - the only subsystem not taking these is pdx86...)

--
Darren Hart
Intel Open Source Technology Center


Re: [PATCH v2] RANDOM: ATH9K RNG delivers zero bits of entropy

2016-08-07 Thread Stephan Mueller
Am Montag, 8. August 2016, 02:03:36 CEST schrieb Pan, Miaoqing:

Hi Miaoqing,

> The entropy was evaluated by crypto expert,  the analysis report show the
> ADC with at least 10bits and up to 22 bits of min-entropy for a 32 bits
> value, we conservatively assume the min-entropy is 10 bits out of 32 bits,
> so that's why set entropy quality  to  320/1024 = 10/32.  Also we have
> explained in the commit message why can't use the HW RNG framework.

Where is the description of the RNG, where is the test implementation? 
> 
> Otherwise, your patch will cause high CPU load,  as continuously read ADC
> data if entropy bits under write_wakeup_threshold.

The issue is that although you may have analyzed it, others are unable to 
measure the quality of the RNG and assess the design as well as the 
implementation of the RNG. This RNG is the only implementation of a hardware 
RNG that per default and without being able to change it at runtime injects 
data into the input_pool where the noise source cannot be audited. Note, even 
other respected RNG noise sources like the Intel RDRAND will not feed into /
dev/random per default in a way that dominates all other noise sources.

I would like to be able to deactivate that noise source to the extent that it 
does not cause /dev/random to unblock. The reason is that your noise source 
starts to dominate all other noise sources.

If you think that this patch is a challenge because your driver starts to 
spin, please help and offer another solution.
> 
> --
> Miaoqing
> 
> -Original Message-
> From: Stephan Mueller [mailto:smuel...@chronox.de]
> Sent: Sunday, August 07, 2016 5:36 PM
> To: Ted Tso 
> Cc: herb...@gondor.apana.org.au; linux-kernel@vger.kernel.org;
> linux-cry...@vger.kernel.org; ath9k-devel ;
> linux-wirel...@vger.kernel.org; ath9k-de...@lists.ath9k.org; Kalle Valo
> ; Jason Cooper  Subject: [PATCH
> v2] RANDOM: ATH9K RNG delivers zero bits of entropy
> 
> The ATH9K driver implements an RNG which is completely bypassing the
> standard Linux HW generator logic.
> 
> The RNG may or may not deliver entropy. Considering the conservative
> approach in treating entropy with respect to non-auditable sources, this
> patch changes the delivered entropy value to zero. The RNG still feeds data
> into the input_pool but it is assumed to have no entropy.
> 
> When the ATH9K RNG changes to use the HW RNG framework, it may re-enable 
the
> entropy estimation considering that a user can change that value at boot
> and runtime.
> 
> Reviewed-by: Jason Cooper 
> Signed-off-by: Stephan Mueller 
> ---
>  drivers/net/wireless/ath/ath9k/rng.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/rng.c
> b/drivers/net/wireless/ath/ath9k/rng.c index d38e50f..1ed8338 100644
> --- a/drivers/net/wireless/ath/ath9k/rng.c
> +++ b/drivers/net/wireless/ath/ath9k/rng.c
> @@ -22,7 +22,6 @@
>  #include "ar9003_phy.h"
> 
>  #define ATH9K_RNG_BUF_SIZE   320
> -#define ATH9K_RNG_ENTROPY(x) (((x) * 8 * 320) >> 10) /* quality: 320/1024
> */
> 
>  static int ath9k_rng_data_read(struct ath_softc *sc, u32 *buf, u32
> buf_size)  { @@ -92,8 +91,7 @@ static int ath9k_rng_kthread(void *data)
> fail_stats = 0;
> 
>   /* sleep until entropy bits under write_wakeup_threshold */
> - add_hwgenerator_randomness((void *)rng_buf, bytes_read,
> -ATH9K_RNG_ENTROPY(bytes_read));
> + add_hwgenerator_randomness((void *)rng_buf, bytes_read, 0);
>   }
> 
>   kfree(rng_buf);
> --
> 2.7.4



Ciao
Stephan


Partnership Cooperation

2016-08-07 Thread Sheikh Maktoum Hasher Al Maktoum
Dear Friend,

Your contact details came to me by recommendation, I am interested in investing 
in your country and I believe you have the capabilities of providing the needed 
assistance, solutions and advise in actualizing this, Let me know if you are 
willing to understake this task for me so we can discuss more. I hope to hear 
from you soon.

Regards,
Sheikh Maktoum Hasher Al Maktoum
Chairman/Chief Executive Officer
Dubai International Holding Company.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



Re: 4.7.0-rc7 ext4 error in dx_probe

2016-08-07 Thread Darrick J. Wong
On Sun, Aug 07, 2016 at 11:56:34PM -0400, Theodore Ts'o wrote:
> On Fri, Aug 05, 2016 at 12:15:48PM -0700, Darrick J. Wong wrote:
> > > > [1] 
> > > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/ext4/inode.c?id=b47820edd1634dc1208f9212b7ecfb4230610a23
> > > 
> > > I added the patch, rebuilt and rebooted.  It will take some time
> > > before I'll report back since the issue is so hard to reproduce.
> > 
> > FWIW I could trigger it reliably by running a bunch of directory traversal
> > programs simultaneously on the same directory.  I have a script that fires
> > up multiple mutts pointing to the Maildirs for the high traffic Linux lists.
> 
> Hmm, I wonder if we should request that this patch be backported to
> -stable.  Darrick, what do you think?

Seems like an excellent idea.

I have one lingering concern -- is it a bug that two processes could be
computing the checksum of a buffer simultaneously?  I would have thought ext4
would serialize that kind of buffer_head access...

--D
> 
>   - Ted


Re: [PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support

2016-08-07 Thread kbuild test robot
Hi Keerthy,

[auto build test ERROR on gpio/for-next]
[also build test ERROR on v4.8-rc1 next-20160805]
[cannot apply to ljones-mfd/for-mfd-next]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Keerthy/mfd-lp873x-Add-lp873x-PMIC-support/20160808-135204
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/mfd/lp873x.c:83:2: error: unknown field 'probe_new' specified in 
>> initializer
 .probe_new  = lp873x_probe,
 ^
>> drivers/mfd/lp873x.c:83:16: error: initialization from incompatible pointer 
>> type [-Werror=incompatible-pointer-types]
 .probe_new  = lp873x_probe,
   ^~~~
   drivers/mfd/lp873x.c:83:16: note: (near initialization for 
'lp873x_driver.id_table')
   cc1: some warnings being treated as errors

vim +/probe_new +83 drivers/mfd/lp873x.c

77  
78  static struct i2c_driver lp873x_driver = {
79  .driver = {
80  .name   = "lp873x",
81  .of_match_table = of_lp873x_match_table,
82  },
  > 83  .probe_new  = lp873x_probe,
84  };
85  module_i2c_driver(lp873x_driver);
86  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH v4 7/7] doc: bindings: act8945a-charger: Update properties

2016-08-07 Thread Wenyou Yang
Due the driver improvements, update the properties,
 - Remove "active-semi,check-battery-temperature" property.
 - Add the properties, "active-semi,irq_gpio"
   and "active-semi,lbo-gpios".

Signed-off-by: Wenyou Yang 
---

Changes in v4:
 - Update the doc/binding for using "interrupts" property.

Changes in v3: None
Changes in v2: None

 .../devicetree/bindings/power/act8945a-charger.txt   | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/act8945a-charger.txt 
b/Documentation/devicetree/bindings/power/act8945a-charger.txt
index bea254c..f9866c4 100644
--- a/Documentation/devicetree/bindings/power/act8945a-charger.txt
+++ b/Documentation/devicetree/bindings/power/act8945a-charger.txt
@@ -4,10 +4,15 @@ Required properties:
  - compatible: "active-semi,act8945a", please refer to ../mfd/act8945a.txt.
  - active-semi,chglev-gpios: charge current level phandle with args
as described in ../gpio/gpio.txt.
+ - active-semi,lbo-gpios: specify the low battery voltage detect phandle
+   with args as as described in ../gpio/gpio.txt.
+ - interrupts:  where a is the interrupt number and b is a
+   field that represents an encoding of the sense and level
+   information for the interrupt.
+ - interrupt-parent: the phandle for the interrupt controller that
+   services interrupts for this device.
 
 Optional properties:
- - active-semi,check-battery-temperature: boolean to check the battery
-   temperature or not.
  - active-semi,input-voltage-threshold-microvolt: unit: mV;
Specifies the charger's input over-voltage threshold value;
The value can be: 6600, 7000, 7500, 8000; default: 6600
@@ -27,9 +32,14 @@ Example:
status = "okay";
 
pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_charger_chglev>;
+   pinctrl-0 = <&pinctrl_charger_chglev &pinctrl_charger_lbo 
&pinctrl_charger_irq>;
+
active-semi,chglev-gpios = <&pioA 12 GPIO_ACTIVE_HIGH>;
+   active-semi,lbo-gpios = <&pioA 72 GPIO_ACTIVE_LOW>;
active-semi,input-voltage-threshold-microvolt = <6600>;
active-semi,precondition-timeout = <40>;
active-semi,total-timeout = <3>;
+   interrupt-parent = <&pioA>;
+   interrupts = <45 GPIO_ACTIVE_LOW>;
+
};
-- 
2.7.4



[PATCH v4 6/7] power: act8945a_charger: Add max current property

2016-08-07 Thread Wenyou Yang
Add the power supply's current max property,
POWER_SUPPLY_PROP_CURRENT_MAX.

Signed-off-by: Wenyou Yang 
---

Changes in v4:
 - Fix wrong gpio assignment for chglev_pin.

Changes in v3: None
Changes in v2: None

 drivers/power/act8945a_charger.c | 79 +++-
 1 file changed, 77 insertions(+), 2 deletions(-)

diff --git a/drivers/power/act8945a_charger.c b/drivers/power/act8945a_charger.c
index 2321796..9bfbc87 100644
--- a/drivers/power/act8945a_charger.c
+++ b/drivers/power/act8945a_charger.c
@@ -84,6 +84,7 @@ struct act8945a_charger {
 
bool init_done;
int lbo_pin;
+   int chgin_level;
 };
 
 static int act8945a_get_charger_state(struct regmap *regmap, int *val)
@@ -267,12 +268,79 @@ static int act8945a_get_capacity_level(struct 
act8945a_charger *charger,
return 0;
 }
 
+#define MAX_CURRENT_USB_HIGH   45
+#define MAX_CURRENT_USB_LOW9
+#define MAX_CURRENT_USB_PRE45000
+/*
+ * Riset(K) = 2336 * (1V/Ichg(mA)) - 0.205
+ * Riset = 2.43K
+ */
+#define MAX_CURRENT_AC_HIGH886527
+#define MAX_CURRENT_AC_LOW 117305
+#define MAX_CURRENT_AC_HIGH_PRE88653
+#define MAX_CURRENT_AC_LOW_PRE 11731
+
+static int act8945a_get_current_max(struct act8945a_charger *charger,
+   struct regmap *regmap, int *val)
+{
+   int ret;
+   unsigned int status, state;
+   unsigned int acin_state;
+
+   ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status);
+   if (ret < 0)
+   return ret;
+
+   ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state);
+   if (ret < 0)
+   return ret;
+
+   acin_state = (state & APCH_STATE_ACINSTAT) >> 1;
+
+   state &= APCH_STATE_CSTATE;
+   state >>= APCH_STATE_CSTATE_SHIFT;
+
+   switch (state) {
+   case APCH_STATE_CSTATE_PRE:
+   if (acin_state) {
+   if (charger->chgin_level)
+   *val = MAX_CURRENT_AC_HIGH_PRE;
+   else
+   *val = MAX_CURRENT_AC_LOW_PRE;
+   } else {
+   *val = MAX_CURRENT_USB_PRE;
+   }
+   break;
+   case APCH_STATE_CSTATE_FAST:
+   if (acin_state) {
+   if (charger->chgin_level)
+   *val = MAX_CURRENT_AC_HIGH;
+   else
+   *val = MAX_CURRENT_AC_LOW;
+   } else {
+   if (charger->chgin_level)
+   *val = MAX_CURRENT_USB_HIGH;
+   else
+   *val = MAX_CURRENT_USB_LOW;
+   }
+   break;
+   case APCH_STATE_CSTATE_EOC:
+   case APCH_STATE_CSTATE_DISABLED:
+   default:
+   *val = 0;
+   break;
+   }
+
+   return 0;
+}
+
 static enum power_supply_property act8945a_charger_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
+   POWER_SUPPLY_PROP_CURRENT_MAX,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER
 };
@@ -302,6 +370,10 @@ static int act8945a_charger_get_property(struct 
power_supply *psy,
ret = act8945a_get_capacity_level(charger,
  regmap, &val->intval);
break;
+   case POWER_SUPPLY_PROP_CURRENT_MAX:
+   ret = act8945a_get_current_max(charger,
+  regmap, &val->intval);
+   break;
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = act8945a_charger_model;
break;
@@ -434,8 +506,11 @@ static int act8945a_charger_config(struct device *dev,
"active-semi,chglev-gpios", 0, &flags);
 
if (gpio_is_valid(chglev_pin)) {
-   gpio_set_value(chglev_pin,
-  ((flags == OF_GPIO_ACTIVE_LOW) ? 0 : 1));
+   if (!devm_gpio_request(dev, chglev_pin, "chglev-pin")) {
+   charger->chgin_level =
+   (flags == OF_GPIO_ACTIVE_LOW) ? 0 : 1;
+   gpio_set_value(chglev_pin, charger->chgin_level);
+   }
}
 
if (of_property_read_u32(np,
-- 
2.7.4



[PATCH v4 5/7] power: act8945a_charger: Add capacity level property

2016-08-07 Thread Wenyou Yang
Add the power supply capacity level property, it corresponds to
POWER_SUPPLY_CAPACITY_LEVEL_*.

It also utilizes the precision voltage detector function module
to catch the low battery voltage.

Signed-off-by: Wenyou Yang 
---

Changes in v4:
 - Change devname of devm_request_irq() from "lbo-detect" to
   "act8945a, lbo-detect".

Changes in v3: None
Changes in v2: None

 drivers/power/act8945a_charger.c | 78 
 1 file changed, 78 insertions(+)

diff --git a/drivers/power/act8945a_charger.c b/drivers/power/act8945a_charger.c
index a3d89be..2321796 100644
--- a/drivers/power/act8945a_charger.c
+++ b/drivers/power/act8945a_charger.c
@@ -83,6 +83,7 @@ struct act8945a_charger {
struct work_struct work;
 
bool init_done;
+   int lbo_pin;
 };
 
 static int act8945a_get_charger_state(struct regmap *regmap, int *val)
@@ -208,11 +209,70 @@ static int act8945a_get_battery_health(struct regmap 
*regmap, int *val)
return 0;
 }
 
+static int act8945a_get_capacity_level(struct act8945a_charger *charger,
+  struct regmap *regmap, int *val)
+{
+   int ret;
+   unsigned int status, state, config;
+   int lbo_level = 1;
+
+   if (gpio_is_valid(charger->lbo_pin))
+   lbo_level = gpio_get_value(charger->lbo_pin);
+
+   ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status);
+   if (ret < 0)
+   return ret;
+
+   ret = regmap_read(regmap, ACT8945A_APCH_CFG, &config);
+   if (ret < 0)
+   return ret;
+
+   ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state);
+   if (ret < 0)
+   return ret;
+
+   state &= APCH_STATE_CSTATE;
+   state >>= APCH_STATE_CSTATE_SHIFT;
+
+   switch (state) {
+   case APCH_STATE_CSTATE_PRE:
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
+   break;
+   case APCH_STATE_CSTATE_FAST:
+   if (lbo_level)
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_HIGH;
+   else
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
+   break;
+   case APCH_STATE_CSTATE_EOC:
+   if (status & APCH_STATUS_CHGDAT)
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
+   else
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
+   break;
+   case APCH_STATE_CSTATE_DISABLED:
+   default:
+   if (config & APCH_CFG_SUSCHG) {
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
+   } else {
+   *val = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
+   if (!(status & APCH_STATUS_INDAT)) {
+   if (!lbo_level)
+   *val = 
POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
+   }
+   }
+   break;
+   }
+
+   return 0;
+}
+
 static enum power_supply_property act8945a_charger_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_HEALTH,
+   POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER
 };
@@ -238,6 +298,10 @@ static int act8945a_charger_get_property(struct 
power_supply *psy,
case POWER_SUPPLY_PROP_HEALTH:
ret = act8945a_get_battery_health(regmap, &val->intval);
break;
+   case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
+   ret = act8945a_get_capacity_level(charger,
+ regmap, &val->intval);
+   break;
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = act8945a_charger_model;
break;
@@ -352,6 +416,20 @@ static int act8945a_charger_config(struct device *dev,
if (tmp & APCH_CFG_SUSCHG)
value |= APCH_CFG_SUSCHG;
 
+   charger->lbo_pin = of_get_named_gpio(np, "active-semi,lbo-gpios", 0);
+   if (gpio_is_valid(charger->lbo_pin)) {
+   if (!devm_gpio_request(dev, charger->lbo_pin, "lbo-detect")) {
+   ret = devm_request_irq(dev,
+  gpio_to_irq(charger->lbo_pin),
+  act8945a_status_changed,
+  IRQF_TRIGGER_FALLING |
+  IRQF_TRIGGER_RISING,
+  "act8945a, lbo-detect", charger);
+   if (ret)
+   dev_dbg(dev, "failed to request LBO pin IRQ\n");
+   }
+   }
+
chglev_pin = of_get_named_gpio_flags(np,
"active-semi,chglev-gpios", 0, &flags);
 
-- 
2.7.4



[PATCH v4 4/7] power: act8945a_charger: Fix the power supply type

2016-08-07 Thread Wenyou Yang
The power supply type property is varying as the external power
supply changes. It is not a constant.

Signed-off-by: Wenyou Yang 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/power/act8945a_charger.c | 48 
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/power/act8945a_charger.c b/drivers/power/act8945a_charger.c
index 74778f7..a3d89be 100644
--- a/drivers/power/act8945a_charger.c
+++ b/drivers/power/act8945a_charger.c
@@ -78,6 +78,7 @@ static const char *act8945a_charger_manufacturer = 
"Active-semi";
 
 struct act8945a_charger {
struct power_supply *psy;
+   struct power_supply_desc desc;
struct regmap *regmap;
struct work_struct work;
 
@@ -250,14 +251,6 @@ static int act8945a_charger_get_property(struct 
power_supply *psy,
return ret;
 }
 
-static const struct power_supply_desc act8945a_charger_desc = {
-   .name   = "act8945a-charger",
-   .type   = POWER_SUPPLY_TYPE_BATTERY,
-   .get_property   = act8945a_charger_get_property,
-   .properties = act8945a_charger_props,
-   .num_properties = ARRAY_SIZE(act8945a_charger_props),
-};
-
 static int act8945a_enable_interrupt(struct act8945a_charger *charger)
 {
struct regmap *regmap = charger->regmap;
@@ -281,11 +274,39 @@ static int act8945a_enable_interrupt(struct 
act8945a_charger *charger)
return 0;
 }
 
+static unsigned int act8945a_set_supply_type(struct act8945a_charger *charger,
+unsigned int *type)
+{
+   unsigned int status, state;
+   int ret;
+
+   ret = regmap_read(charger->regmap, ACT8945A_APCH_STATUS, &status);
+   if (ret < 0)
+   return ret;
+
+   ret = regmap_read(charger->regmap, ACT8945A_APCH_STATE, &state);
+   if (ret < 0)
+   return ret;
+
+   if (status & APCH_STATUS_INDAT) {
+   if (state & APCH_STATE_ACINSTAT)
+   *type = POWER_SUPPLY_TYPE_MAINS;
+   else
+   *type = POWER_SUPPLY_TYPE_USB;
+   } else {
+   *type = POWER_SUPPLY_TYPE_BATTERY;
+   }
+
+   return 0;
+}
+
 static void act8945a_work(struct work_struct *work)
 {
struct act8945a_charger *charger =
container_of(work, struct act8945a_charger, work);
 
+   act8945a_set_supply_type(charger, &charger->desc.type);
+
power_supply_changed(charger->psy);
 }
 
@@ -438,11 +459,20 @@ static int act8945a_charger_probe(struct platform_device 
*pdev)
return ret;
}
 
+   charger->desc.name = "act8945a-charger";
+   charger->desc.get_property = act8945a_charger_get_property;
+   charger->desc.properties = act8945a_charger_props;
+   charger->desc.num_properties = ARRAY_SIZE(act8945a_charger_props);
+
+   ret = act8945a_set_supply_type(charger, &charger->desc.type);
+   if (ret)
+   return -EINVAL;
+
psy_cfg.of_node = pdev->dev.parent->of_node;
psy_cfg.drv_data = charger;
 
charger->psy = devm_power_supply_register(&pdev->dev,
- &act8945a_charger_desc,
+ &charger->desc,
  &psy_cfg);
if (IS_ERR(charger->psy)) {
dev_err(&pdev->dev, "failed to register power supply\n");
-- 
2.7.4



[PATCH v4 3/7] power: act8945a_charger: Add status change update support

2016-08-07 Thread Wenyou Yang
Add the charger status change interrupt support, it will report
the power supply changed event.

This interrupt is generated by one of the conditions as below:
 - the state machine jumps out of or into the EOC state
 - the CHGIN input voltage goes out of or into the valid range.
 - the battery temperature goes out of or into the valid range.
 - the PRECHARGE time-out occurs.
 - the total charge time-out occurs.

Signed-off-by: Wenyou Yang 
---

Changes in v4:
 - Use "interrupts" property, instead of "active-semi,lbo-gpios"
   for irq.

Changes in v3: None
Changes in v2: None

 drivers/power/act8945a_charger.c | 82 
 1 file changed, 75 insertions(+), 7 deletions(-)

diff --git a/drivers/power/act8945a_charger.c b/drivers/power/act8945a_charger.c
index 6ddfc1d..74778f7 100644
--- a/drivers/power/act8945a_charger.c
+++ b/drivers/power/act8945a_charger.c
@@ -10,9 +10,11 @@
  * published by the Free Software Foundation.
  *
  */
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,7 +77,11 @@ static const char *act8945a_charger_manufacturer = 
"Active-semi";
 #define APCH_STATE_CSTATE_PRE  0x03
 
 struct act8945a_charger {
+   struct power_supply *psy;
struct regmap *regmap;
+   struct work_struct work;
+
+   bool init_done;
 };
 
 static int act8945a_get_charger_state(struct regmap *regmap, int *val)
@@ -252,6 +258,47 @@ static const struct power_supply_desc 
act8945a_charger_desc = {
.num_properties = ARRAY_SIZE(act8945a_charger_props),
 };
 
+static int act8945a_enable_interrupt(struct act8945a_charger *charger)
+{
+   struct regmap *regmap = charger->regmap;
+   unsigned char ctrl;
+   int ret;
+
+   ctrl = APCH_CTRL_CHGEOCOUT | APCH_CTRL_CHGEOCIN |
+  APCH_CTRL_INDIS | APCH_CTRL_INCON |
+  APCH_CTRL_TEMPOUT | APCH_CTRL_TEMPIN |
+  APCH_CTRL_TIMRPRE | APCH_CTRL_TIMRTOT;
+   ret = regmap_write(regmap, ACT8945A_APCH_CTRL, ctrl);
+   if (ret)
+   return ret;
+
+   ctrl = APCH_STATUS_CHGSTAT | APCH_STATUS_INSTAT |
+  APCH_STATUS_TEMPSTAT | APCH_STATUS_TIMRSTAT;
+   ret = regmap_write(regmap, ACT8945A_APCH_STATUS, ctrl);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void act8945a_work(struct work_struct *work)
+{
+   struct act8945a_charger *charger =
+   container_of(work, struct act8945a_charger, work);
+
+   power_supply_changed(charger->psy);
+}
+
+static irqreturn_t act8945a_status_changed(int irq, void *dev_id)
+{
+   struct act8945a_charger *charger = dev_id;
+
+   if (charger->init_done)
+   schedule_work(&charger->work);
+
+   return IRQ_HANDLED;
+}
+
 #define DEFAULT_TOTAL_TIME_OUT 3
 #define DEFAULT_PRE_TIME_OUT   40
 #define DEFAULT_INPUT_OVP_THRESHOLD6600
@@ -360,9 +407,8 @@ static int act8945a_charger_config(struct device *dev,
 static int act8945a_charger_probe(struct platform_device *pdev)
 {
struct act8945a_charger *charger;
-   struct power_supply *psy;
struct power_supply_config psy_cfg = {};
-   int ret;
+   int irq, ret;
 
charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
if (!charger)
@@ -378,17 +424,39 @@ static int act8945a_charger_probe(struct platform_device 
*pdev)
if (ret)
return ret;
 
+   irq = of_irq_get(pdev->dev.parent->of_node, 0);
+   if (irq == -EPROBE_DEFER) {
+   dev_err(&pdev->dev, "failed to find IRQ number\n");
+   return -EPROBE_DEFER;
+   }
+
+   ret = devm_request_irq(&pdev->dev, irq, act8945a_status_changed,
+  IRQF_TRIGGER_FALLING, "act8945a_interrupt",
+  charger);
+   if (ret) {
+   dev_err(&pdev->dev, "failed to request nIRQ pin IRQ\n");
+   return ret;
+   }
+
psy_cfg.of_node = pdev->dev.parent->of_node;
psy_cfg.drv_data = charger;
 
-   psy = devm_power_supply_register(&pdev->dev,
-&act8945a_charger_desc,
-&psy_cfg);
-   if (IS_ERR(psy)) {
+   charger->psy = devm_power_supply_register(&pdev->dev,
+ &act8945a_charger_desc,
+ &psy_cfg);
+   if (IS_ERR(charger->psy)) {
dev_err(&pdev->dev, "failed to register power supply\n");
-   return PTR_ERR(psy);
+   return PTR_ERR(charger->psy);
}
 
+   INIT_WORK(&charger->work, act8945a_work);
+
+   ret = act8945a_enable_interrupt(charger);
+   if (ret)
+   return -EIO;
+
+   charger->init_done = true;
+
return 0;
 }
 
-- 
2.7.4



[PATCH v4 2/7] power: act8945a_charger: Improve

2016-08-07 Thread Wenyou Yang
When get the property, first check the charger state machine,
then check the status bit to decide what value is assigned to
the corresponding property.

Retain the SUSCHG bit of REG 0x71 when configure the timers to
avoid losting the charger suspending info after boot.

Signed-off-by: Wenyou Yang 
Signed-off-by: Fengguang Wu 
---

Changes in v4: None
Changes in v3:
 - Remove unneeded semicolon to fix semicolon.cocci warning.

Changes in v2:
 - Add missing ret declaration.

 drivers/power/act8945a_charger.c | 84 
 1 file changed, 68 insertions(+), 16 deletions(-)

diff --git a/drivers/power/act8945a_charger.c b/drivers/power/act8945a_charger.c
index 72d39ba..6ddfc1d 100644
--- a/drivers/power/act8945a_charger.c
+++ b/drivers/power/act8945a_charger.c
@@ -94,16 +94,24 @@ static int act8945a_get_charger_state(struct regmap 
*regmap, int *val)
state &= APCH_STATE_CSTATE;
state >>= APCH_STATE_CSTATE_SHIFT;
 
-   if (state == APCH_STATE_CSTATE_EOC) {
+   switch (state) {
+   case APCH_STATE_CSTATE_PRE:
+   case APCH_STATE_CSTATE_FAST:
+   *val = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case APCH_STATE_CSTATE_EOC:
if (status & APCH_STATUS_CHGDAT)
*val = POWER_SUPPLY_STATUS_FULL;
else
+   *val = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case APCH_STATE_CSTATE_DISABLED:
+   default:
+   if (!(status & APCH_STATUS_INDAT))
+   *val = POWER_SUPPLY_STATUS_DISCHARGING;
+   else
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
-   } else if ((state == APCH_STATE_CSTATE_FAST) ||
-  (state == APCH_STATE_CSTATE_PRE)) {
-   *val = POWER_SUPPLY_STATUS_CHARGING;
-   } else {
-   *val = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
}
 
return 0;
@@ -112,7 +120,11 @@ static int act8945a_get_charger_state(struct regmap 
*regmap, int *val)
 static int act8945a_get_charge_type(struct regmap *regmap, int *val)
 {
int ret;
-   unsigned int state;
+   unsigned int status, state;
+
+   ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status);
+   if (ret < 0)
+   return ret;
 
ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state);
if (ret < 0)
@@ -129,9 +141,15 @@ static int act8945a_get_charge_type(struct regmap *regmap, 
int *val)
*val = POWER_SUPPLY_CHARGE_TYPE_FAST;
break;
case APCH_STATE_CSTATE_EOC:
+   *val = POWER_SUPPLY_CHARGE_TYPE_NONE;
+   break;
case APCH_STATE_CSTATE_DISABLED:
default:
-   *val = POWER_SUPPLY_CHARGE_TYPE_NONE;
+   if (!(status & APCH_STATUS_INDAT))
+   *val = POWER_SUPPLY_CHARGE_TYPE_NONE;
+   else
+   *val = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   break;
}
 
return 0;
@@ -140,20 +158,45 @@ static int act8945a_get_charge_type(struct regmap 
*regmap, int *val)
 static int act8945a_get_battery_health(struct regmap *regmap, int *val)
 {
int ret;
-   unsigned int status;
+   unsigned int status, state, config;
 
ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status);
if (ret < 0)
return ret;
 
-   if (status & APCH_STATUS_TEMPDAT)
-   *val = POWER_SUPPLY_HEALTH_OVERHEAT;
-   else if (!(status & APCH_STATUS_INDAT))
-   *val = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
-   else if (status & APCH_STATUS_TIMRDAT)
-   *val = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE;
-   else
+   ret = regmap_read(regmap, ACT8945A_APCH_CFG, &config);
+   if (ret < 0)
+   return ret;
+
+   ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state);
+   if (ret < 0)
+   return ret;
+
+   state &= APCH_STATE_CSTATE;
+   state >>= APCH_STATE_CSTATE_SHIFT;
+
+   switch (state) {
+   case APCH_STATE_CSTATE_DISABLED:
+   if (config & APCH_CFG_SUSCHG) {
+   *val = POWER_SUPPLY_HEALTH_UNKNOWN;
+   } else if (status & APCH_STATUS_INDAT) {
+   if (!(status & APCH_STATUS_TEMPDAT))
+   *val = POWER_SUPPLY_HEALTH_OVERHEAT;
+   else if (status & APCH_STATUS_TIMRDAT)
+   *val = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE;
+   else
+   *val = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
+   } else {
+   *val = POWER_SUPPLY_HEALTH_GOOD;
+   }
+   break;
+   case APCH_STATE_CSTATE_PRE:
+   case APCH_STATE_CSTATE_FAST:
+   case APCH_STATE_CSTATE_EOC:
+   default:
*val = POWER_SUPPLY_HEALTH_GOOD;
+

[PATCH v4 1/7] power: act8945a_charger: Remove "battery_temperature"

2016-08-07 Thread Wenyou Yang
Remove "battery_temperature" member, it is redundant, it is the
hardware's responsibility to handle TH pin properly.
It is unnecessary to use the dt property to check if there is
a battery temperature monitor or not.

Signed-off-by: Wenyou Yang 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/power/act8945a_charger.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/power/act8945a_charger.c b/drivers/power/act8945a_charger.c
index b5c00e4..72d39ba 100644
--- a/drivers/power/act8945a_charger.c
+++ b/drivers/power/act8945a_charger.c
@@ -76,7 +76,6 @@ static const char *act8945a_charger_manufacturer = 
"Active-semi";
 
 struct act8945a_charger {
struct regmap *regmap;
-   bool battery_temperature;
 };
 
 static int act8945a_get_charger_state(struct regmap *regmap, int *val)
@@ -138,8 +137,7 @@ static int act8945a_get_charge_type(struct regmap *regmap, 
int *val)
return 0;
 }
 
-static int act8945a_get_battery_health(struct act8945a_charger *charger,
-  struct regmap *regmap, int *val)
+static int act8945a_get_battery_health(struct regmap *regmap, int *val)
 {
int ret;
unsigned int status;
@@ -148,7 +146,7 @@ static int act8945a_get_battery_health(struct 
act8945a_charger *charger,
if (ret < 0)
return ret;
 
-   if (charger->battery_temperature && !(status & APCH_STATUS_TEMPDAT))
+   if (status & APCH_STATUS_TEMPDAT)
*val = POWER_SUPPLY_HEALTH_OVERHEAT;
else if (!(status & APCH_STATUS_INDAT))
*val = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
@@ -188,8 +186,7 @@ static int act8945a_charger_get_property(struct 
power_supply *psy,
val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
break;
case POWER_SUPPLY_PROP_HEALTH:
-   ret = act8945a_get_battery_health(charger,
- regmap, &val->intval);
+   ret = act8945a_get_battery_health(regmap, &val->intval);
break;
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = act8945a_charger_model;
@@ -235,9 +232,6 @@ static int act8945a_charger_config(struct device *dev,
return -EINVAL;
}
 
-   charger->battery_temperature = of_property_read_bool(np,
-   "active-semi,check-battery-temperature");
-
chglev_pin = of_get_named_gpio_flags(np,
"active-semi,chglev-gpios", 0, &flags);
 
-- 
2.7.4



[PATCH v4 0/7] power: act8945a_charger: Improvements

2016-08-07 Thread Wenyou Yang
This patch series is to improve the implementation of act8945a-charger
driver, such as improve the way to check the status, fix the power
supply type property, add the status change update, and add more
properties: capacity level property and max current property.

Changes in v4:
 - Use "interrupts" property, instead of "active-semi,lbo-gpios"
   for irq.
 - Change devname of devm_request_irq() from "lbo-detect" to
   "act8945a, lbo-detect".
 - Fix wrong gpio assignment for chglev_pin.
 - Update the doc/binding for using "interrupts" property.

Changes in v3:
 - Remove unneeded semicolon to fix semicolon.cocci warning.

Changes in v2:
 - Add missing ret declaration.

Wenyou Yang (7):
  power: act8945a_charger: Remove "battery_temperature"
  power: act8945a_charger: Improve
  power: act8945a_charger: Add status change update support
  power: act8945a_charger: Fix the power supply type
  power: act8945a_charger: Add capacity level property
  power: act8945a_charger: Add max current property
  doc: bindings: act8945a-charger: Update properties

 .../devicetree/bindings/power/act8945a-charger.txt |  16 +-
 drivers/power/act8945a_charger.c   | 373 ++---
 2 files changed, 348 insertions(+), 41 deletions(-)

-- 
2.7.4



Re: [PATCH v3 3/3] serial: 8250_dw: add ACPI support for uart on Hisilicon Hip05 soc

2016-08-07 Thread Kefeng Wang
+ kernel malilist

Hi Andriy and all, any comments, thanks.

On 2016/7/15 19:01, Kefeng Wang wrote:
> Use built-in device properties to set device parameters for the
> existing device probed by acpi.
> 
> Add ACPI identifier for UART on Hisilicon Hip05 soc, be careful
> that it is not 16550 compatibal, so we need set "reg-io-width"
> and "reg-shift" by _DSD method in DSDT.
> 
> Signed-off-by: Kefeng Wang 
> ---
>  drivers/tty/serial/8250/8250_dw.c | 23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c 
> b/drivers/tty/serial/8250/8250_dw.c
> index d6934310..5ab9cfe 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -297,12 +297,6 @@ static void dw8250_quirks(struct uart_port *p, struct 
> dw8250_data *data)
>   p->serial_in = dw8250_serial_in32be;
>   p->serial_out = dw8250_serial_out32be;
>   }
> - } else if (has_acpi_companion(p->dev)) {
> - p->iotype = UPIO_MEM32;
> - p->regshift = 2;
> - p->serial_in = dw8250_serial_in32;
> - /* So far none of there implement the Busy Functionality */
> - data->uart_16550_compatible = true;
>   }
>  
>   /* Platforms with iDMA */
> @@ -352,6 +346,19 @@ static void dw8250_setup_port(struct uart_port *p)
>   up->capabilities |= UART_CAP_AFE;
>  }
>  
> +static struct property_entry dw8250_properties[] = {
> + PROPERTY_ENTRY_U32("reg-io-width", 4),
> + PROPERTY_ENTRY_U32("reg-shift", 2),
> + PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
> + { },
> +};
> +
> +/* non 16550 compatible id list*/
> +static const struct acpi_device_id non_16550_ids[] = {
> + { "HISI0031", 0 },
> + { },
> +};
> +
>  static int dw8250_probe(struct platform_device *pdev)
>  {
>   struct uart_8250_port uart = {};
> @@ -395,6 +402,9 @@ static int dw8250_probe(struct platform_device *pdev)
>   if (!data)
>   return -ENOMEM;
>  
> + if (has_acpi_companion(dev) && !acpi_match_device(non_16550_ids, dev))
> + platform_device_add_properties(pdev, dw8250_properties);
> +
>   data->dma.fn = dw8250_fallback_dma_filter;
>   data->usr_reg = DW_UART_USR;
>   p->private_data = data;
> @@ -619,6 +629,7 @@ static const struct acpi_device_id dw8250_acpi_match[] = {
>   { "APMC0D08", 0},
>   { "AMD0020", 0 },
>   { "AMDI0020", 0 },
> + { "HISI0031", 0 },
>   { },
>  };
>  MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
> 



Re: [PATCH 1/2] mac80211/wlcore: Add ieee80211_hw variable to get_expected_throughput

2016-08-07 Thread Johannes Berg
On Sun, 2016-08-07 at 13:42 +, Altshul, Maxim wrote:
> Hi Johaness,
> I have prepared a patch for the issue and it is waiting for me to
> send it, but I feel that maybe I have not explained the previous
> issue well enough or I did not understand your request fully.
> I would like to clarify about the previous patch (the one that you
> applied) again:
> 
> a. The bug occurred because I have added a member called wl to the
> structure wl_sta, but it turned to be NULL when the function
> drv_get_expected_throughput was called.

Right.

> b. This member was NULL because it was initialized in the wrong place
> (sta_add instead of update_sta_state), and thus the regression has
> failed. 

Ah. So you *do* in fact implement the sta_state op (op_sta_state)
instead of the sta_add op, which I thought you were using and which was
causing the error. Perhaps sta_add came from being originally called
through mac80211's sta_add op.

So in essence, in this particular case it ended up being just a driver
bug because it was initializing the pointer in the wrong place, and I
agree that the fix in mac80211 to pass the hw pointer like everywhere
else makes perfect sense.

> c. Even so, wl_sta itself was not NULL at any point.

Right.

> d. This is why I have created two patches:
> First patch (the one that you have applied) made it easy for the
> driver to access hw->priv (the problematic access to hw->priv was the
> reason I added wl to wl_sta in the first place, which was a mistake).
> Second patch reverted the addition of wl member to wl_sta.

Right.
 
> 2. From what I have seen, other ops that take ieee80211_sta as a
> parameter do not check for sta->uploaded, which is why it feels a
> little odd to do it in drv_get_expected_throughput and nowhere else.

I think most of them have a different protection; perhaps some are
lacking it?

 * set_tim: can only be called when the station is associated
 * set_key: likewise, iirc, though perhaps userspace can mess up?
 * update_tkip_key: must have a key and traffic
 * sta_notify: powersave - must be associated
 * sta_pre_rcu_remove: only pre removal etc.
 * sta_rc_update: looks partially problematic through RX action frame, 
                  if a peer messes up and sends one ... oops
 * TDLS ones look fine, I think

So I *think* that most are OK - RC update might be an issue.

get_expected_throughput is unique in that it can be called from
userspace at any time after the station is added, and that happened in
the case that John had (called immediately after ADD_STA notification,
afaict)

johannes


RE: [PATCH v3 7/7] doc: bindings: act8945a-charger: Update properties

2016-08-07 Thread Wenyou.Yang
Hi Rob,

> -Original Message-
> From: Rob Herring [mailto:r...@kernel.org]
> Sent: 2016年7月30日 5:40
> To: Wenyou Yang 
> Cc: Sebastian Reichel ; Dmitry Eremin-Solenikov
> ; David Woodhouse ; Pawel
> Moll ; Mark Brown ; Ian Campbell
> ; Kumar Gala ; linux-
> ker...@vger.kernel.org; devicet...@vger.kernel.org; linux-arm-
> ker...@lists.infradead.org; Nicolas Ferre ; linux-
> p...@vger.kernel.org
> Subject: Re: [PATCH v3 7/7] doc: bindings: act8945a-charger: Update properties
> 
> On Fri, Jul 29, 2016 at 09:25:28AM +0800, Wenyou Yang wrote:
> > Due the driver improvements, update the properties,
> >  - Remove "active-semi,check-battery-temperature" property.
> >  - Add the properties, "active-semi,irq_gpio"
> >and "active-semi,lbo-gpios".
> >
> > Signed-off-by: Wenyou Yang 
> > ---
> >
> > Changes in v3: None
> > Changes in v2: None
> >
> >  Documentation/devicetree/bindings/power/act8945a-charger.txt | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/power/act8945a-charger.txt
> b/Documentation/devicetree/bindings/power/act8945a-charger.txt
> > index bea254c..d7cf05b 100644
> > --- a/Documentation/devicetree/bindings/power/act8945a-charger.txt
> > +++ b/Documentation/devicetree/bindings/power/act8945a-charger.txt
> > @@ -4,10 +4,12 @@ Required properties:
> >   - compatible: "active-semi,act8945a", please refer to ../mfd/act8945a.txt.
> >   - active-semi,chglev-gpios: charge current level phandle with args
> > as described in ../gpio/gpio.txt.
> > + - active-semi,irq_gpios: specify the charger interrupt input phanle
> > +   with args as as described in ../gpio/gpio.txt.
> 
> As I said in v2, this should be an interrupt property instead.

Sorry for forgetting to change.

Accepted, will be in next version. Thanks.

> 
> > + - active-semi,lbo-gpios: specify the low battery voltage detect phandle
> > +   with args as as described in ../gpio/gpio.txt.
> 
> Maybe this one too.

The capacity level function need to read this pin level, so this one should not
use "interrupts" property.

> 
> >
> >  Optional properties:
> > - - active-semi,check-battery-temperature: boolean to check the battery
> > -   temperature or not.
> >   - active-semi,input-voltage-threshold-microvolt: unit: mV;
> > Specifies the charger's input over-voltage threshold value;
> > The value can be: 6600, 7000, 7500, 8000; default: 6600
> > --
> > 2.7.4
> >

Best Regards,
Wenyou Yang


[PATCH RESEND v2 4/8] uio: Add new UIO_MEM_DEVICE type for mem regions

2016-08-07 Thread Anup Patel
On ARM64, the MMU supports special memory attributes for device
memory/registers. Due to this we have pgprot_device() provided
by asm/pgtable.h of arch/arm64.

On architectures that do not have special MMU attribute for device
memory/registers, the asm-generic/pgtable.h maps pgprot_device()
to pgprot_noncached().

This patch introduces a new UIO mem region type UIO_MEM_DEVICE to
represent device registers/memory. The UIO device drivers should
prefer this new UIO mem region type for memory mapped device registers.

Signed-off-by: Anup Patel 
---
 drivers/uio/uio.c  | 4 
 include/linux/uio_driver.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 0e53076..a00990c 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -663,6 +663,9 @@ static int uio_mmap_physical(struct vm_area_struct *vma, 
int memtype)
case UIO_MEM_PHYS_CACHE:
/* Do nothing. */
break;
+   case UIO_MEM_DEVICE:
+   vma->vm_page_prot = pgprot_device(vma->vm_page_prot);
+   break;
default:
return -EINVAL;
}
@@ -714,6 +717,7 @@ static int uio_mmap(struct file *filep, struct 
vm_area_struct *vma)
switch (idev->info->mem[mi].memtype) {
case UIO_MEM_PHYS:
case UIO_MEM_PHYS_CACHE:
+   case UIO_MEM_DEVICE:
return uio_mmap_physical(vma, idev->info->mem[mi].memtype);
case UIO_MEM_LOGICAL:
case UIO_MEM_VIRTUAL:
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 31359aee..7349f95 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -129,6 +129,7 @@ extern void uio_event_notify(struct uio_info *info);
 #define UIO_MEM_LOGICAL2
 #define UIO_MEM_VIRTUAL3
 #define UIO_MEM_PHYS_CACHE 4
+#define UIO_MEM_DEVICE 5
 
 /* defines for uio_port->porttype */
 #define UIO_PORT_NONE  0
-- 
1.9.1



[PATCH RESEND v2 3/8] uio: Add new UIO_MEM_PHYS_CACHE type for mem regions

2016-08-07 Thread Anup Patel
From: Ankit Jindal 

Currently, three types of mem regions are supported: UIO_MEM_PHYS,
UIO_MEM_LOGICAL and UIO_MEM_VIRTUAL. Among these UIO_MEM_PHYS helps
UIO driver export physcial memory to user space as non-cacheable
user memory. Typcially memory-mapped registers of a device are exported
to user space as UIO_MEM_PHYS type mem region. The UIO_MEM_PHYS type
is not efficient if dma-capable devices are capable of maintaining
coherency with CPU caches.

This patch adds new type UIO_MEM_PHYS_CACHE for mem regions to enable
cacheable access to physical memory from user space.

Signed-off-by: Ankit Jindal 
Signed-off-by: Anup Patel 
---
 drivers/uio/uio.c  | 16 +---
 include/linux/uio_driver.h |  9 +
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index f2729b7..0e53076 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -641,7 +641,7 @@ static const struct vm_operations_struct 
uio_physical_vm_ops = {
 #endif
 };
 
-static int uio_mmap_physical(struct vm_area_struct *vma)
+static int uio_mmap_physical(struct vm_area_struct *vma, int memtype)
 {
struct uio_device *idev = vma->vm_private_data;
int mi = uio_find_mem_index(vma);
@@ -656,7 +656,16 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
return -EINVAL;
 
vma->vm_ops = &uio_physical_vm_ops;
-   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+   switch (memtype) {
+   case UIO_MEM_PHYS:
+   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+   break;
+   case UIO_MEM_PHYS_CACHE:
+   /* Do nothing. */
+   break;
+   default:
+   return -EINVAL;
+   }
 
/*
 * We cannot use the vm_iomap_memory() helper here,
@@ -704,7 +713,8 @@ static int uio_mmap(struct file *filep, struct 
vm_area_struct *vma)
 
switch (idev->info->mem[mi].memtype) {
case UIO_MEM_PHYS:
-   return uio_mmap_physical(vma);
+   case UIO_MEM_PHYS_CACHE:
+   return uio_mmap_physical(vma, idev->info->mem[mi].memtype);
case UIO_MEM_LOGICAL:
case UIO_MEM_VIRTUAL:
return uio_mmap_logical(vma);
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 32c0e83..31359aee 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -124,10 +124,11 @@ extern void uio_event_notify(struct uio_info *info);
 #define UIO_IRQ_NONE   0
 
 /* defines for uio_mem->memtype */
-#define UIO_MEM_NONE   0
-#define UIO_MEM_PHYS   1
-#define UIO_MEM_LOGICAL2
-#define UIO_MEM_VIRTUAL 3
+#define UIO_MEM_NONE   0
+#define UIO_MEM_PHYS   1
+#define UIO_MEM_LOGICAL2
+#define UIO_MEM_VIRTUAL3
+#define UIO_MEM_PHYS_CACHE 4
 
 /* defines for uio_port->porttype */
 #define UIO_PORT_NONE  0
-- 
1.9.1



[PATCH RESEND v2 6/8] uio: UIO_IRQ_NONE is a valid option for uioinfo->irq

2016-08-07 Thread Anup Patel
From: Jan Viktorin 

We can simplify handling of platform_get_irq into one place as it is
acceptable to see UIO_IRQ_NONE instead of a valid IRQ number. Some
devices don't have or don't need any interrupt to be handled. The
same change has been already done for uio_pdrv_genirq.

Signed-off-by: Jan Viktorin 
---
 drivers/uio/uio_dmem_genirq.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index e1134a4..a4d6d81 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -154,8 +154,6 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
int i;
 
if (pdev->dev.of_node) {
-   int irq;
-
/* alloc uioinfo for one device */
uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL);
if (!uioinfo) {
@@ -165,13 +163,6 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
}
uioinfo->name = pdev->dev.of_node->name;
uioinfo->version = "devicetree";
-
-   /* Multiple IRQs are not supported */
-   irq = platform_get_irq(pdev, 0);
-   if (irq == -ENXIO)
-   uioinfo->irq = UIO_IRQ_NONE;
-   else
-   uioinfo->irq = irq;
}
 
if (!uioinfo || !uioinfo->name || !uioinfo->version) {
@@ -200,14 +191,18 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
priv->pdev = pdev;
mutex_init(&priv->alloc_lock);
 
+   /* Multiple IRQs are not supported */
if (!uioinfo->irq) {
ret = platform_get_irq(pdev, 0);
-   if (ret < 0) {
+   uioinfo->irq = ret;
+   if (ret == -ENXIO && pdev->dev.of_node)
+   uioinfo->irq = UIO_IRQ_NONE;
+   else if (ret < 0) {
dev_err(&pdev->dev, "failed to get IRQ\n");
goto bad1;
}
-   uioinfo->irq = ret;
}
+
uiomem = &uioinfo->mem[0];
 
for (i = 0; i < pdev->num_resources; ++i) {
-- 
1.9.1



[PATCH RESEND v2 8/8] uio: Use new memtypes in uio_dmem_genirq

2016-08-07 Thread Anup Patel
This patch extends uio_dmem_genirq driver to use recently
added memtypes as follows:
1. Use UIO_MEM_DEVICE memtype for MEM resources
2. Use UIO_MEM_PHYS_CACHE memtype for dynamic regions
when UIO DT node is marked as DMA coherent.

Signed-off-by: Anup Patel 
---
 drivers/uio/uio_dmem_genirq.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index 1db2559..ce36afd 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -327,7 +327,7 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
break;
}
 
-   uiomem->memtype = UIO_MEM_PHYS;
+   uiomem->memtype = UIO_MEM_DEVICE;
uiomem->addr = r->start;
uiomem->size = resource_size(r);
++uiomem;
@@ -343,7 +343,12 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
" dynamic and fixed memory regions.\n");
break;
}
-   uiomem->memtype = UIO_MEM_PHYS;
+
+   if (pdev->dev.of_node &&
+   of_dma_is_coherent(pdev->dev.of_node))
+   uiomem->memtype = UIO_MEM_PHYS_CACHE;
+   else
+   uiomem->memtype = UIO_MEM_PHYS;
uiomem->addr = DMEM_MAP_ERROR;
uiomem->size = pdata->dynamic_region_sizes[i];
++uiomem;
-- 
1.9.1



[PATCH RESEND v2 7/8] uio: bind uio_dmem_genirq via OF

2016-08-07 Thread Anup Patel
From: Jan Viktorin 

The uio_dmem_genirq works in a similar ways as uio_pdrv_genirq now.

It accepts the of_id module parameter to specify UIO compatible
string as module parameter. There are few other module parameters
to specify number bits in DMA mask and sizes dynamic regions.

Following are the newly added module parameters:
1) of_id: The UIO compatible string to be used for DT probing
2) dmem_dma_bits: This is the number of DMA mask bits for UIO device.
3) dmem_sizes: This is a formatted string specifying sizes of dynamic
required by some of the UIO devices.

Below are few examples of formatted string for dmem_sizes:
a) UIO dmem device with 3 dynamic regions:
uio_dmem_genirq.dmem_sizes=abc:4K,16K,4M
b) Two UIO dmem devices with different number of dynamic regions:
uio_dmem_genirq.dmem_sizes=abc:4K,16K,4M;xyz:8K

Signed-off-by: Jan Viktorin 
Signed-off-by: Anup Patel 
---
 drivers/uio/uio_dmem_genirq.c | 162 +++---
 1 file changed, 135 insertions(+), 27 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index a4d6d81..1db2559 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -12,6 +12,27 @@
  * the Free Software Foundation.
  */
 
+/*
+ * For DeviceTree based platform devices, the compatible string, the DMA mask
+ * bits and sizes of dynamic regions are derived from kernel command-line.
+ *
+ * The format for specifying dynamic region sizes in kernel command line
+ * is as follows:
+ *
+ * uio_dmem_genirq.dmem_sizes := [;]
+ *:= :[,]
+ *  := name as shown in /sys/class/uio/uioX/name
+ *  := standard linux memsize
+ *
+ * Examples:
+ *
+ * 1) UIO dmem device with 3 dynamic regions:
+ * uio_dmem_genirq.dmem_sizes=abc:4K,16K,4M
+ *
+ * 2) Two UIO dmem devices with different number of dynamic regions:
+ * uio_dmem_genirq.dmem_sizes=abc:4K,16K,4M;xyz:8K
+ */
+
 #include 
 #include 
 #include 
@@ -144,46 +165,134 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info 
*dev_info, s32 irq_on)
return 0;
 }
 
+static unsigned int uio_dmem_dma_bits = 32;
+static char uio_dmem_sizes[256];
+
+static int uio_dmem_genirq_alloc_platdata(struct platform_device *pdev)
+{
+   int ret, name_len;
+   u32 regions = 0;
+   char *s, *name, *sz;
+   char *sizes_str = NULL, *sizes_endstr = NULL;
+   struct uio_dmem_genirq_pdata pdata;
+   unsigned long long sizes[MAX_UIO_MAPS];
+
+   memset(&pdata, 0, sizeof(pdata));
+
+   /* Set DMA coherent mask */
+   if (uio_dmem_dma_bits > 64)
+   uio_dmem_dma_bits = 64;
+   ret = dma_set_coherent_mask(&pdev->dev,
+   DMA_BIT_MASK(uio_dmem_dma_bits));
+   if (ret) {
+   dev_err(&pdev->dev, "Unable to dma_set_coherent_mask\n");
+   return ret;
+   }
+
+   /* Find-out start and end of sizes list */
+   s = uio_dmem_sizes;
+   while (*s != '\0') {
+   name = s;
+   s = strchr(s, ':');
+   if (!s)
+   break;
+   name_len = s - name;
+   s++;
+   if (*s == '\0')
+   break;
+   sz = s;
+   s = strchr(s, ';');
+   if (!s)
+   s = &uio_dmem_sizes[strlen(uio_dmem_sizes)];
+   if (strncmp(name, pdev->dev.of_node->name, name_len) == 0) {
+   sizes_str = sz;
+   sizes_endstr = s;
+   break;
+   }
+   s++;
+   }
+
+   /* Parse dynamic regions from sizes list */
+   regions = 0;
+   sizes[0] = 0;
+   while (sizes_str && sizes_endstr &&
+  (sizes_str < sizes_endstr) &&
+  (*sizes_str != '\0') &&
+  (*sizes_str != ';') &&
+  (regions < MAX_UIO_MAPS)) {
+   if (*sizes_str == ',') {
+   sizes_str++;
+   continue;
+   }
+   sizes[regions] = memparse(sizes_str, &sizes_str);
+   if (sizes[regions])
+   regions++;
+   }
+
+   /* Populate platform data */
+   pdata.num_dynamic_regions = regions;
+   pdata.dynamic_region_sizes = devm_kzalloc(&pdev->dev,
+   sizeof(*pdata.dynamic_region_sizes) *
+   pdata.num_dynamic_regions, GFP_KERNEL);
+   if (!pdata.dynamic_region_sizes) {
+   dev_err(&pdev->dev, "Unable to alloc dynamic_region_sizes\n");
+   ret = -ENOMEM;
+   return ret;
+   }
+
+   while (regions--)
+   pdata.dynamic_region_sizes[regions] = sizes[regions];
+
+   pdata.uioinfo.name = pdev->dev.of_node->name;
+   pdata.uioinfo.version = "devicetree";
+
+   return platform_device_add_data(pdev, &pdata, sizeof(pdata));
+}
+
 static int uio_dmem_genirq_probe(struct platfo

[PATCH RESEND v2 2/8] uio: code style cleanup

2016-08-07 Thread Anup Patel
From: Ankit Jindal 

This patch fixes the indentation of switch-case block in uio driver.

Signed-off-by: Ankit Jindal 
Signed-off-by: Anup Patel 
---
 drivers/uio/uio.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index fba021f..f2729b7 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -703,13 +703,13 @@ static int uio_mmap(struct file *filep, struct 
vm_area_struct *vma)
}
 
switch (idev->info->mem[mi].memtype) {
-   case UIO_MEM_PHYS:
-   return uio_mmap_physical(vma);
-   case UIO_MEM_LOGICAL:
-   case UIO_MEM_VIRTUAL:
-   return uio_mmap_logical(vma);
-   default:
-   return -EINVAL;
+   case UIO_MEM_PHYS:
+   return uio_mmap_physical(vma);
+   case UIO_MEM_LOGICAL:
+   case UIO_MEM_VIRTUAL:
+   return uio_mmap_logical(vma);
+   default:
+   return -EINVAL;
}
 }
 
-- 
1.9.1



[PATCH RESEND v2 5/8] Documentation: Update documentation for UIO_MEM_PHYS_CACHE and UIO_MEM_DEVICE

2016-08-07 Thread Anup Patel
From: Ankit Jindal 

This patch updates UIO documentation for new mem region
types UIO_MEM_PHYS_CACHE and UIO_MEM_DEVICE.

Signed-off-by: Ankit Jindal 
Signed-off-by: Anup Patel 
---
 Documentation/DocBook/uio-howto.tmpl | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/uio-howto.tmpl 
b/Documentation/DocBook/uio-howto.tmpl
index cd0e452..de9dafe 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -529,8 +529,10 @@ the memory region, it will show up in the corresponding 
sysfs node.
 int memtype: Required if the mapping is used. Set this to
 UIO_MEM_PHYS if you you have physical memory on your
 card to be mapped. Use UIO_MEM_LOGICAL for logical
-memory (e.g. allocated with kmalloc()). There's also
-UIO_MEM_VIRTUAL for virtual memory.
+memory (e.g. allocated with kmalloc()). There are also
+UIO_MEM_VIRTUAL for virtual memory,
+UIO_MEM_PHYS_CACHE for cacheable physical memory and,
+UIO_MEM_DEVICE for memory mapped device registers.
 
 
 
-- 
1.9.1



Re: [PATCH] clk: Hi6220: enable stub clock driver for ARCH_HISI

2016-08-07 Thread Amit Kucheria
On Mon, Aug 8, 2016 at 9:07 AM, Leo Yan  wrote:
> In current kernel config 'CONFIG_STUB_CLK_HI6220' is disabled by
> default, as result stub clock driver has not been registered and
> CPUFreq driver cannot work.

I have a related patch that has been pending for a while:
https://lkml.org/lkml/2016/6/20/375 but it was tied only to the
thermal driver.

Is the stub mandatory for the architecture? Will other SoCs in the
family will use the same stub?


> This patch is to enable stub clock driver in config for ARCH_HISI.
>
> Reported-by: Dietmar Eggemann 
> Signed-off-by: Leo Yan 
> ---
>  drivers/clk/hisilicon/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
> index 3f537a0..9e0a95e 100644
> --- a/drivers/clk/hisilicon/Kconfig
> +++ b/drivers/clk/hisilicon/Kconfig
> @@ -23,5 +23,6 @@ config RESET_HISI
>  config STUB_CLK_HI6220
> bool "Hi6220 Stub Clock Driver"
> depends on COMMON_CLK_HI6220 && MAILBOX
> +   default ARCH_HISI
> help
>   Build the Hisilicon Hi6220 stub clock driver.
> --
> 1.9.1
>


[PATCH RESEND v2 1/8] uio: fix dmem_region_start computation

2016-08-07 Thread Anup Patel
From: Jan Viktorin 

The variable i contains a total number of resources (including
IORESOURCE_IRQ). However, we want the dmem_region_start to point
after the last resource of type IORESOURCE_MEM. The original behaviour
leads (very likely) to skipping several UIO mapping regions and makes
them useless. Fix this by computing dmem_region_start from the uiomem
which points to the last used UIO mapping.

Fixes: 0a0c3b5a24bd ("Add new uio device for dynamic memory allocation")

Signed-off-by: Jan Viktorin 
Signed-off-by: Anup Patel 
Cc: linux-stable 
---
 drivers/uio/uio_dmem_genirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index 915facb..e1134a4 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -229,7 +229,7 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
++uiomem;
}
 
-   priv->dmem_region_start = i;
+   priv->dmem_region_start = uiomem - &uioinfo->mem[0];
priv->num_dmem_regions = pdata->num_dynamic_regions;
 
for (i = 0; i < pdata->num_dynamic_regions; ++i) {
-- 
1.9.1



[PATCH RESEND v2 0/8] Cache-coherent DMA access using UIO

2016-08-07 Thread Anup Patel
The goal of this patchset is to improve UIO framework and UIO dmem
driver to allow cache-coherent DMA accesses from user-space.

This patchset is based on two previous patchsets:
1) [PATCH v5 0/6] UIO driver for APM X-Gene QMTM
(Refer, http://www.spinics.net/lists/devicetree/msg58244.html)
2) [PATCH 0/4] Fix and extend uio_dmem_genirq
(Refer, https://lkml.org/lkml/2016/5/17/141)

We have adopted only patch0-3 of patchset1 which was abandoned
long time back. We have taken care of last few unaddressed comments
on these patches.

The patchset2 is quite recent has been adopted entirely. We have
taken care review comments on these patches too.

This patchset is based on v4.7-rc7 tag and it is available in uio-v2
branch of https://github.com/Broadcom/arm64-linux.git

Changes since v1:
 - Make patch5 as first patch1 and mark it for linux-stable
 - Check return value of dma_set_coherent_mask()
 - Get UIO dmem dynamic region details as module parameter instead
   of getting it from DT node

Ankit Jindal (3):
  uio: code style cleanup
  uio: Add new UIO_MEM_PHYS_CACHE type for mem regions
  Documentation: Update documentation for UIO_MEM_PHYS_CACHE and
UIO_MEM_DEVICE

Anup Patel (2):
  uio: Add new UIO_MEM_DEVICE type for mem regions
  uio: Use new memtypes in uio_dmem_genirq

Jan Viktorin (3):
  uio: fix dmem_region_start computation
  uio: UIO_IRQ_NONE is a valid option for uioinfo->irq
  uio: bind uio_dmem_genirq via OF

 Documentation/DocBook/uio-howto.tmpl |   6 +-
 drivers/uio/uio.c|  32 --
 drivers/uio/uio_dmem_genirq.c| 190 +++
 include/linux/uio_driver.h   |  10 +-
 4 files changed, 182 insertions(+), 56 deletions(-)

-- 
1.9.1



[PATCH v6 3/4] gpio: lp873x: Add support for General Purpose Outputs

2016-08-07 Thread Keerthy
Add driver for lp873x PMIC family GPOs. Two GPOs are supported
and can be configured in Open-drain output or Push-pull output.

Acked-by: Linus Walleij 
Signed-off-by: Keerthy 
---
 drivers/gpio/Kconfig   |  10 +++
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-lp873x.c | 185 +
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/gpio/gpio-lp873x.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 6de9062..ff68a80 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -853,6 +853,16 @@ config GPIO_LP3943
  LP3943 can be used as a GPIO expander which provides up to 16 GPIOs.
  Open drain outputs are required for this usage.
 
+config GPIO_LP873X
+   tristate "TI LP873X GPO"
+   depends on MFD_TI_LP873X
+   help
+ This driver supports the GPO on TI Lp873x PMICs. 2 GPOs are present
+ on LP873X PMICs.
+
+ This driver can also be built as a module. If so, the module will be
+  called gpio-lp873x.
+
 config GPIO_MAX77620
tristate "GPIO support for PMIC MAX77620 and MAX20024"
depends on MFD_MAX77620
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 2a035ed..d60432f 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_GPIO_LOONGSON)   += gpio-loongson.o
 obj-$(CONFIG_GPIO_LP3943)  += gpio-lp3943.o
 obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o
 obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o
+obj-$(CONFIG_GPIO_LP873X)  += gpio-lp873x.o
 obj-$(CONFIG_GPIO_LYNXPOINT)   += gpio-lynxpoint.o
 obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o
 obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o
diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
new file mode 100644
index 000..77deaa4
--- /dev/null
+++ b/drivers/gpio/gpio-lp873x.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ * Keerthy 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether expressed or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License version 2 for more details.
+ *
+ * Based on the TPS65218 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct lp873x_gpio {
+   struct gpio_chip chip;
+   struct lp873x *lp873;
+};
+
+static int lp873x_gpio_get_direction(struct gpio_chip *chip,
+unsigned int offset)
+{
+   /* This device is output only */
+   return 0;
+}
+
+static int lp873x_gpio_direction_input(struct gpio_chip *chip,
+  unsigned int offset)
+{
+   /* This device is output only */
+   return -EINVAL;
+}
+
+static int lp873x_gpio_direction_output(struct gpio_chip *chip,
+   unsigned int offset, int value)
+{
+   struct lp873x_gpio *gpio = gpiochip_get_data(chip);
+
+   /* Set the initial value */
+   return regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
+ BIT(offset * 4), value ? BIT(offset * 4) : 0);
+}
+
+static int lp873x_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+   struct lp873x_gpio *gpio = gpiochip_get_data(chip);
+   int ret, val;
+
+   ret = regmap_read(gpio->lp873->regmap, LP873X_REG_GPO_CTRL, &val);
+   if (ret < 0)
+   return ret;
+
+   return val & BIT(offset * 4);
+}
+
+static void lp873x_gpio_set(struct gpio_chip *chip, unsigned int offset,
+   int value)
+{
+   struct lp873x_gpio *gpio = gpiochip_get_data(chip);
+
+   regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
+  BIT(offset * 4), value ? BIT(offset * 4) : 0);
+}
+
+static int lp873x_gpio_request(struct gpio_chip *gc, unsigned int offset)
+{
+   struct lp873x_gpio *gpio = gpiochip_get_data(gc);
+   int ret;
+
+   switch (offset) {
+   case 0:
+   /* No MUX Set up Needed for GPO */
+   break;
+   case 1:
+   /* Setup the CLKIN_PIN_SEL MUX to GPO2 */
+   ret = regmap_update_bits(gpio->lp873->regmap, LP873X_REG_CONFIG,
+LP873X_CONFIG_CLKIN_PIN_SEL, 0);
+   if (ret)
+   return ret;
+
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int lp873x_gpio_set_single_ended(struct gpio_chip *gc,
+   unsigned int offset,
+   enum single_ended_mode mode)
+{
+   struct lp873x_gp

[PATCH v6 0/4] mfd: lp873x: Add lp873x PMIC support

2016-08-07 Thread Keerthy
The LP873X chip is a power management IC for Portable Navigation Systems
and Tablet Computing devices. It contains the following components:

 - Regulators.
 - Configurable General Purpose Output Signals(GPO).

PMIC interacts with the main processor through i2c. PMIC has
couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
Converter Cores) and GPOs(General Purpose Output Signals).

The regulator patch is already queued:
http://marc.info/?l=linux-kernel&m=146298767110771&w=2

Hence posting the remaining patches of the series with
the comments fixed on mfd driver.

Changes in v6:

Series depends on: http://www.gossamer-threads.com/lists/linux/kernel/2457552
probe_new used.

Chnages in v4:

Added GPO driver support.

Keerthy (4):
  Documentation: mfd: LP873X: Add information for the mfd driver
  mfd: lp873x: Add lp873x PMIC support
  gpio: lp873x: Add support for General Purpose Outputs
  regulator: lp873x: Change the MFD config option as per latest naming

 Documentation/devicetree/bindings/mfd/lp873x.txt |  59 +
 drivers/gpio/Kconfig |  10 +
 drivers/gpio/Makefile|   1 +
 drivers/gpio/gpio-lp873x.c   | 185 
 drivers/mfd/Kconfig  |  14 ++
 drivers/mfd/Makefile |   2 +
 drivers/mfd/lp873x.c |  89 
 drivers/regulator/Kconfig|   2 +-
 include/linux/mfd/lp873x.h   | 264 +++
 9 files changed, 625 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt
 create mode 100644 drivers/gpio/gpio-lp873x.c
 create mode 100644 drivers/mfd/lp873x.c
 create mode 100644 include/linux/mfd/lp873x.h

-- 
1.9.1



[PATCH v6 1/4] Documentation: mfd: LP873X: Add information for the mfd driver

2016-08-07 Thread Keerthy
The lp873x series of PMICs have a bunch of regulators and a couple
of GPO(General Purpose Outputs).
Add information for the MFD and regulator drivers.

Acked-by: Rob Herring 
Signed-off-by: Keerthy 
---
Changes in v6:

  * Added more formating for properties.

Changes in v4:

  * Added the GPIO properties.

Changes in v3:

  * Changed the example node lable to pmic from lp8733.

 Documentation/devicetree/bindings/mfd/lp873x.txt | 59 
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt

diff --git a/Documentation/devicetree/bindings/mfd/lp873x.txt 
b/Documentation/devicetree/bindings/mfd/lp873x.txt
new file mode 100644
index 000..1377c25
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/lp873x.txt
@@ -0,0 +1,59 @@
+TI LP873X PMIC MFD driver
+
+Required properties:
+  - compatible:"ti,lp8732", "ti,lp8733"
+  - reg:   I2C slave address.
+  - gpio-controller:   Marks the device node as a GPIO Controller.
+  - #gpio-cells:   Should be two.  The first cell is the pin number and
+   the second cell is used to specify flags.
+   See ../gpio/gpio.txt for more information.
+  - regulators:List of child nodes that specify the regulator
+   initialization data.
+Example:
+
+pmic: lp8733@60 {
+   compatible = "ti,lp8733";
+   reg = <0x60>;
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   regulators {
+   lp8733_buck0: buck0 {
+   regulator-name = "lp8733-buck0";
+   regulator-min-microvolt = <80>;
+   regulator-max-microvolt = <140>;
+   regulator-min-microamp = <150>;
+   regulator-max-microamp = <400>;
+   regulator-ramp-delay = <1>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   lp8733_buck1: buck1 {
+   regulator-name = "lp8733-buck1";
+   regulator-min-microvolt = <80>;
+   regulator-max-microvolt = <140>;
+   regulator-min-microamp = <150>;
+   regulator-max-microamp = <400>;
+   regulator-ramp-delay = <1>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   lp8733_ldo0: ldo0 {
+   regulator-name = "lp8733-ldo0";
+   regulator-min-microvolt = <80>;
+   regulator-max-microvolt = <300>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   lp8733_ldo1: ldo1 {
+   regulator-name = "lp8733-ldo1";
+   regulator-min-microvolt = <80>;
+   regulator-max-microvolt = <300>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+   };
+};
-- 
1.9.1



[PATCH v6 4/4] regulator: lp873x: Change the MFD config option as per latest naming

2016-08-07 Thread Keerthy
Change the MFD config option as per latest naming

Signed-off-by: Keerthy 
---
 drivers/regulator/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 6c88e31..97dc4cc 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -323,7 +323,7 @@ config REGULATOR_LP872X
 
 config REGULATOR_LP873X
tristate "TI LP873X Power regulators"
-   depends on MFD_LP873X && OF
+   depends on MFD_TI_LP873X && OF
help
  This driver supports LP873X voltage regulator chips. LP873X
  provides two step-down converters and two general-purpose LDO
-- 
1.9.1



[PATCH v6 2/4] mfd: lp873x: Add lp873x PMIC support

2016-08-07 Thread Keerthy
The LP873X chip is a power management IC for Portable Navigation Systems
and Tablet Computing devices. It contains the following components:

 - Regulators.
 - Configurable General Purpose Output Signals(GPO).

PMIC interacts with the main processor through i2c. PMIC has
couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
Converter Cores) and GPOs(General Purpose Output Signals).

Signed-off-by: Keerthy 
---
Changes in v6:

  * Rebased on top of 
http://www.gossamer-threads.com/lists/linux/kernel/2457552.
  * Hence added probe_new instead of probe and removed unused i2c_device_id.

Changes in v4:

  * Added Author.
  * Added the mfd_cell for gpio.

Changes in v3:

  * Reordered the probe code.
  * Fixed Typo in Kconfig description.
  * Removed unused member from struct lp873x.

 drivers/mfd/Kconfig|  14 +++
 drivers/mfd/Makefile   |   2 +
 drivers/mfd/lp873x.c   |  89 +++
 include/linux/mfd/lp873x.h | 264 +
 4 files changed, 369 insertions(+)
 create mode 100644 drivers/mfd/lp873x.c
 create mode 100644 include/linux/mfd/lp873x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2d1fb64..45fe00a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1224,6 +1224,20 @@ config MFD_TPS65217
  This driver can also be built as a module.  If so, the module
  will be called tps65217.
 
+config MFD_TI_LP873X
+   tristate "TI LP873X Power Management IC"
+   depends on I2C
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ If you say yes here then you get support for the LP873X series of
+ Power Management Integrated Circuits(PMIC).
+ These include voltage regulators, Thermal protection, Configurable
+ General Purpose Outputs(GPO) that are used in portable devices.
+
+ This driver can also be built as a module. If so, the module
+ will be called lp873x.
+
 config MFD_TPS65218
tristate "TI TPS65218 Power Management chips"
depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 2ba3ba3..42acbcd 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO)   += htc-egpio.o
 obj-$(CONFIG_HTC_PASIC3)   += htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)   += htc-i2cpld.o
 
+obj-$(CONFIG_MFD_TI_LP873X)+= lp873x.o
+
 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)   += davinci_voicecodec.o
 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_AM335X_TSCADC) += ti_am335x_tscadc.o
diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
new file mode 100644
index 000..3c8e8d0
--- /dev/null
+++ b/drivers/mfd/lp873x.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author: Keerthy 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config lp873x_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = LP873X_REG_MAX,
+};
+
+static const struct mfd_cell lp873x_cells[] = {
+   { .name = "lp873x-regulator", },
+   { .name = "lp873x-gpio", },
+};
+
+static int lp873x_probe(struct i2c_client *client)
+{
+   struct lp873x *lp873;
+   int ret;
+   unsigned int otpid;
+
+   lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
+   if (!lp873)
+   return -ENOMEM;
+
+   lp873->dev = &client->dev;
+
+   lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
+   if (IS_ERR(lp873->regmap)) {
+   ret = PTR_ERR(lp873->regmap);
+   dev_err(lp873->dev,
+   "Failed to initialize register map: %d\n", ret);
+   return ret;
+   }
+
+   mutex_init(&lp873->lock);
+
+   ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
+   if (ret) {
+   dev_err(lp873->dev, "Failed to read OTP ID\n");
+   return ret;
+   }
+
+   lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
+   i2c_set_clientdata(client, lp873);
+   ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
+ ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
+
+   return ret;
+}
+
+static const struct of_device_id of_lp873x_match_table[] = {
+   { .compatible = "ti,lp8733", },
+   { .compatible = "ti,lp8732", },
+   {}
+};
+MODULE_DEVICE_TABLE(of, of_lp873x_match_table)

Re: [PATCH v5 5/6] dmaengine: pl330: Make sure microcode is privileged

2016-08-07 Thread Vinod Koul
On Wed, Jul 27, 2016 at 04:42:07PM -0700, Mitchel Humpherys wrote:
> The PL330 performs privileged instruction fetches.  This can result in
> SMMU permission faults on SMMUs that implement the ARMv8 VMSA, which

Lot of acronyms with no explanation whatsoever

> specifies that mappings that are writeable at one execution level shall
> not be executable at any higher-privileged level.  Fix this by using the
> DMA_ATTR_PRIVILEGED attribute, which will ensure that the microcode
> IOMMU mapping is only accessible to the privileged level.

And I get satndalone patch with no context for the series!

> 
> Cc: Dan Williams 
> Cc: Vinod Koul 
> Reviewed-by: Robin Murphy 
> Tested-by: Robin Murphy 
> Signed-off-by: Mitchel Humpherys 
> ---
> 
> Notes:
> v3..v4
> 
>   - Reworked against the new dma attrs format.
> 
>  drivers/dma/pl330.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index 4fc3ffbd5ca0..8cd624fc3760 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -1854,14 +1854,16 @@ static int dmac_alloc_resources(struct pl330_dmac 
> *pl330)
>  {
>   int chans = pl330->pcfg.num_chan;
>   int ret;
> + unsigned long dma_attrs = DMA_ATTR_PRIVILEGED;
>  
>   /*
>* Alloc MicroCode buffer for 'chans' Channel threads.
>* A channel's buffer offset is (Channel_Id * MCODE_BUFF_PERCHAN)
>*/
> - pl330->mcode_cpu = dma_alloc_coherent(pl330->ddma.dev,
> + pl330->mcode_cpu = dma_alloc_attrs(pl330->ddma.dev,
>   chans * pl330->mcbufsz,
> - &pl330->mcode_bus, GFP_KERNEL);
> + &pl330->mcode_bus, GFP_KERNEL,
> + dma_attrs);
>   if (!pl330->mcode_cpu) {
>   dev_err(pl330->ddma.dev, "%s:%d Can't allocate memory!\n",
>   __func__, __LINE__);
> -- 
> Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

-- 
~Vinod


Re: [PATCH] fix platform_no_drv_owner.cocci warnings

2016-08-07 Thread Vinod Koul
On Wed, Jul 27, 2016 at 04:41:16PM +0200, Julia Lawall wrote:
> No need to set .owner here. The core will do it.

And which tree was this generated against :-)

Upstream doesn't have  _dpdma.c

> 
> Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
> 
> Signed-off-by: Julia Lawall 
> Signed-off-by: Fengguang Wu 
> ---
> 
>  xilinx_dpdma.c |1 -
>  1 file changed, 1 deletion(-)
> 
> --- a/drivers/dma/xilinx/xilinx_dpdma.c
> +++ b/drivers/dma/xilinx/xilinx_dpdma.c
> @@ -1944,7 +1944,6 @@ static struct platform_driver xilinx_dpd
>   .remove = xilinx_dpdma_remove,
>   .driver = {
>   .name   = "xilinx-dpdma",
> - .owner  = THIS_MODULE,
>   .of_match_table = xilinx_dpdma_of_match,
>   },
>  };

-- 
~Vinod


Re: [PATCH v2 6/6] dmaengine: omap-dma: Support for LinkedList transfer of slave_sg

2016-08-07 Thread Vinod Koul
On Wed, Jul 20, 2016 at 11:50:32AM +0300, Peter Ujfalusi wrote:
> sDMA in OMAP3630 or newer SoC have support for LinkedList transfer. When
> LinkedList or Descriptor load feature is present we can create the
> descriptors for each and program sDMA to walk through the list of
> descriptors instead of the current way of sDMA stop, sDMA reconfiguration
> and sDMA start after each SG transfer.
> By using LinkedList transfer in sDMA the number of DMA interrupts will
> decrease dramatically.
> Booting up the board with filesystem on SD card for example:
> W/o LinkedList support:
>  27:   4436  0 WUGEN  13 Level omap-dma-engine
> 
> Same board/filesystem with this patch:
>  27:   1027  0 WUGEN  13 Level omap-dma-engine
> 
> Or copying files from SD card to eMCC:
> 2.1G/usr/
> 232001
> 
> W/o LinkedList we see ~761069 DMA interrupts.
> With LinkedList support it is down to ~269314 DMA interrupts.
> 
> With the decreased DMA interrupt number the CPU load is dropping
> significantly as well.

Interesting, I would have counted the throughput of DMA by using time for
transfer and not really interrupts and CPU load. With LL mode, you get a
big performance boost due to starting next transaction by hardware without
waiting for CPU intervention and yes side effect is lesser interrupts and
load :)

> @@ -743,6 +863,7 @@ static struct dma_async_tx_descriptor 
> *omap_dma_prep_slave_sg(
>   struct omap_desc *d;
>   dma_addr_t dev_addr;
>   unsigned i, es, en, frame_bytes;
> + bool ll_failed = false;
>   u32 burst;
>  
>   if (dir == DMA_DEV_TO_MEM) {
> @@ -818,16 +939,47 @@ static struct dma_async_tx_descriptor 
> *omap_dma_prep_slave_sg(
>*/
>   en = burst;
>   frame_bytes = es_bytes[es] * en;
> +
> + if (sglen >= 2)
> + d->using_ll = od->ll123_supported;

No upperbound on length? Does the hardware support any lengths?



-- 
~Vinod


Re: [PATCH v5 2/3] mfd: lp873x: Add lp873x PMIC support

2016-08-07 Thread Keerthy



On Friday 05 August 2016 02:31 PM, Lee Jones wrote:

On Fri, 05 Aug 2016, Keerthy wrote:

On Friday 05 August 2016 01:33 PM, Lee Jones wrote:

On Wed, 29 Jun 2016, Keerthy wrote:


The LP873X chip is a power management IC for Portable Navigation Systems
  and Tablet Computing devices. It contains the following components:

   - Regulators.
   - Configurable General Purpose Output Signals(GPO).

PMIC interacts with the main processor through i2c. PMIC has
couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC
Converter Cores) and GPOs(General Purpose Output Signals).

Signed-off-by: Keerthy 
---

Changes in v4:

* Added Author.
* Added the mfd_cell for gpio.

Changes in v3:

* Reordered the probe code.
* Fixed Typo in Kconfig description.
* Removed unused member from struct lp873x.

   drivers/mfd/Kconfig|  14 +++
   drivers/mfd/Makefile   |   2 +
   drivers/mfd/lp873x.c   |  99 +
   include/linux/mfd/lp873x.h | 264 
+
   4 files changed, 379 insertions(+)
   create mode 100644 drivers/mfd/lp873x.c
   create mode 100644 include/linux/mfd/lp873x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9987d86..e68ac28 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1221,6 +1221,20 @@ config MFD_TPS65217
  This driver can also be built as a module.  If so, the module
  will be called tps65217.

+config MFD_LP873X


Nicer as MFD_TI_LP873X I think.


+   tristate "TI LP873X Power Management IC"
+   depends on I2C
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ If you say yes here then you get support for the LP873X series of
+ power management integrated circuits(PMIC).


Power Management Integrated Circuits (PMIC).


Okay




+ These include voltage regulators, Thermal protection, Configurable
+ general purpose outputs(GPO) that are used in portable devices.


Some here.  Please standardise your capitalisation.


Okay




+ This driver can also be built as a module.  If so, the module
+ will be called lp873x.
+
   config MFD_TPS65218
tristate "TI TPS65218 Power Management chips"
depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 2ba3ba3..7d9b965 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO)   += htc-egpio.o
   obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o
   obj-$(CONFIG_HTC_I2CPLD) += htc-i2cpld.o

+obj-$(CONFIG_MFD_LP873X)   += lp873x.o
+
   obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o
   obj-$(CONFIG_MFD_DM355EVM_MSP)   += dm355evm_msp.o
   obj-$(CONFIG_MFD_TI_AM335X_TSCADC)   += ti_am335x_tscadc.o
diff --git a/drivers/mfd/lp873x.c b/drivers/mfd/lp873x.c
new file mode 100644
index 000..54ed0ce
--- /dev/null
+++ b/drivers/mfd/lp873x.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author: Keerthy 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const struct regmap_config lp873x_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = LP873X_REG_MAX,
+};
+
+static const struct mfd_cell lp873x_cells[] = {
+   { .name = "lp873x-regulator", },
+   { .name = "lp873x-gpio", },
+};
+
+static int lp873x_probe(struct i2c_client *client,
+   const struct i2c_device_id *ids)
+{
+   struct lp873x *lp873;
+   int ret;
+   unsigned int otpid;
+
+   lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
+   if (!lp873)
+   return -ENOMEM;
+
+   lp873->dev = &client->dev;
+
+   lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
+   if (IS_ERR(lp873->regmap)) {
+   ret = PTR_ERR(lp873->regmap);
+   dev_err(lp873->dev, "Failed to initialize register map: %d\n",
+   ret);


Nit: I'd prefer you break after "->dev,".


Okay




+   return ret;
+   }
+
+   mutex_init(&lp873->lp873_lock);


How many locks do you have in 'struct lp873x'?

I suggest that 'lock' will do fine.


Okay.




+   ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
+   if (ret) {
+   dev_err(lp873->dev, "Failed to read OTP ID\n");
+   return ret;
+   }
+
+   lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
+

Re: [PATCH] treewide: fix a bunch of typos (part 2)

2016-08-07 Thread Masahiro Yamada
Hi Randy,

Thanks for taking a close look!


2016-08-08 13:50 GMT+09:00 Randy Dunlap :

> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -630,9 +630,7 @@ void sctp_transport_reset(struct sctp_transport *t)
> t->srtt = 0;
> t->rttvar = 0;
>
> -   /* Reset these additional varibles so that we have a clean
> -* slate.
> -*/
> +   /* Reset these additional variables so that we have a clean state. */
>
> * Nothing wrong with original comment.


This hunk is doing three things:

 [1] varibles  -> variables
 [2] slate   ->  state
 [3] Make it into a single line


Do you mean they are all unneeded changes?



-- 
Best Regards
Masahiro Yamada


Re: [PATCH] drivers: base: dma-mapping: page align the size when unmap_kernel_range

2016-08-07 Thread Greg KH
On Mon, Aug 08, 2016 at 12:29:08PM +0800, Peng Fan wrote:
> Hi,
> 
> Kindly ping.. since more than two weeks from patch sent out.

It's the merge window, we can't take new patches during then.  Relax, it
will be handled when I catch up...


Re: [PATCH] treewide: fix a bunch of typos (part 2)

2016-08-07 Thread Randy Dunlap
On 08/07/16 06:56, Masahiro Yamada wrote:
> Signed-off-by: Masahiro Yamada 


ipc/: all OK
kernel/ : all OK
lib/: all OK
scripts/ : all OK
security/ : all OK
tools/  : all OK


block/ comments (otherwise all OK):

--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -468,7 +468,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk 
*disk, fmode_t mode,
if (err)
goto error;
 
-   /* default.  possible overriden later */
+   /* default.  possible overridden later */

* possibly


fs/ comments (otherwise all OK):

--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
  * There are two cases:
- *  a> the extent are splitted into two extent.
+ *  a> the extent are split into two extent.

* into two extents.


mm/ comment (otherwise all OK):

--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5790,7 +5790,7 @@ static unsigned long __paginginit 
calc_memmap_size(unsigned long spanned_pages,
 * the zone and SPARSEMEM is in use. If there are holes within the
 * zone, each populated memory region may cost us one or two extra
 * memmap pages due to alignment because memmap pages for each
-* populated regions may not naturally algined on page boundary.
+* populated regions may not naturally aligned on page boundary.

*may not be naturally aligned


net/ comment (otherwise all OK):

--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -630,9 +630,7 @@ void sctp_transport_reset(struct sctp_transport *t)
t->srtt = 0;
t->rttvar = 0;
 
-   /* Reset these additional varibles so that we have a clean
-* slate.
-*/
+   /* Reset these additional variables so that we have a clean state. */

* Nothing wrong with original comment.


sound/ comments (otherwise all OK):

--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -169,7 +169,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
  * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device
  * @codec: The CODEC for which to create the AC'97 device
  *
- * Allocated a new snd_ac97 device and intializes it, but does not yet register
+ * Allocated a new snd_ac97 device and initializes it, but does not yet 
register

* Allocates


---
That covers everything except arch/ and drivers/.

-- 
~Randy


Re: [PATCH] drivers: base: dma-mapping: page align the size when unmap_kernel_range

2016-08-07 Thread Peng Fan
Hi,

Kindly ping.. since more than two weeks from patch sent out.

Thanks,
Peng.
On Thu, Jul 21, 2016 at 04:04:21PM +0800, Peng Fan wrote:
>When dma_common_free_remap, the input parameter 'size' may not
>be page aligned. And, met kernel warning when doing iommu dma
>for usb on i.MX8 platform:
>"
>WARNING: CPU: 0 PID: 869 at mm/vmalloc.c:70 vunmap_page_range+0x1cc/0x1d0()
>Modules linked in:
>CPU: 0 PID: 869 Comm: kworker/u8:2 Not tainted 4.1.12-00444-gc5f9d1d-dirty #147
>Hardware name: Freescale i.MX8DV Sabreauto (DT)
>Workqueue: ci_otg ci_otg_work
>Call trace:
>[] dump_backtrace+0x0/0x124
>[] show_stack+0x10/0x1c
>[] dump_stack+0x84/0xc8
>[] warn_slowpath_common+0x98/0xd0
>[] warn_slowpath_null+0x14/0x20
>[] vunmap_page_range+0x1c8/0x1d0
>[] unmap_kernel_range+0x20/0x88
>[] dma_common_free_remap+0x74/0x84
>[] __iommu_free_attrs+0x9c/0x178
>[] ehci_mem_cleanup+0x140/0x194
>[] ehci_stop+0x8c/0xdc
>[] usb_remove_hcd+0xf0/0x1cc
>[] host_stop+0x1c/0x58
>[] ci_otg_work+0xdc/0x120
>[] process_one_work+0x134/0x33c
>[] worker_thread+0x13c/0x47c
>[] kthread+0xd8/0xf0
>"
>
>For dma_common_pages_remap:
>dma_common_pages_remap
>   |->get_vm_area_caller
>|->__get_vm_area_node
>|->size = PAGE_ALIGN(size);   Round up to page aligned
>
>So, in dma_common_free_remap, we also need a page aligned size,
>pass 'PAGE_ALIGN(size)' to unmap_kernel_range.
>
>Signed-off-by: Peng Fan 
>Cc: Greg Kroah-Hartman 
>Cc: 
>---
> drivers/base/dma-mapping.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>index d799662..261420d 100644
>--- a/drivers/base/dma-mapping.c
>+++ b/drivers/base/dma-mapping.c
>@@ -334,7 +334,7 @@ void dma_common_free_remap(void *cpu_addr, size_t size, 
>unsigned long vm_flags)
>   return;
>   }
> 
>-  unmap_kernel_range((unsigned long)cpu_addr, size);
>+  unmap_kernel_range((unsigned long)cpu_addr, PAGE_ALIGN(size));
>   vunmap(cpu_addr);
> }
> #endif
>-- 
>2.6.2
>


Re: linux-next: Tree for Aug 8

2016-08-07 Thread Stephen Rothwell
Hi Andrew,

On Mon, 8 Aug 2016 13:51:22 +1000 Andrew Donnellan 
 wrote:
>
> On 08/08/16 13:17, Stephen Rothwell wrote:
> > Please do not add material destined for v4.9 to your linux-next included
> > branches until after v4.8-rc1 has been released.  
> 
> Which has now happened :)

Yes, I will remove the above message tomorrow.

-- 
Cheers,
Stephen Rothwell


warning: (DRM_KMS_FB_HELPER && ..) selects FB_DEFERRED_IO which has unmet direct dependencies (HAS_IOMEM && ..)

2016-08-07 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   29b4817d4018df78086157ea3a55c1d9424a7cfc
commit: 339b19e3c4ff728a5dcdbd388a5fbe83c1aabc37 drm/ast: make fbdev support 
really optional
date:   3 weeks ago
config: x86_64-randconfig-s5-08081114 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
git checkout 339b19e3c4ff728a5dcdbd388a5fbe83c1aabc37
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

warning: (DRM_KMS_FB_HELPER && DRM_VMWGFX && HID_PICOLCD_FB && FB_TFT) selects 
FB_DEFERRED_IO which has unmet direct dependencies (HAS_IOMEM && FB)
warning: (VIDEO_FB_IVTV && VIDEO_VIVID && DRM_KMS_FB_HELPER && DRM_RADEON && 
DRM_AMDGPU && DRM_VMWGFX && FB_CLPS711X_OLD && FB_FFB && FB_TCX && FB_CG14 && 
FB_P9100 && FB_LEO && FB_SM750 && FB_XGI) selects FB_CFB_COPYAREA which has 
unmet direct dependencies (HAS_IOMEM && FB)
warning: (VIDEO_FB_IVTV && VIDEO_VIVID && DRM_KMS_FB_HELPER && DRM_RADEON && 
DRM_AMDGPU && DRM_VMWGFX && FB_CLPS711X_OLD && FB_FFB && FB_TCX && FB_CG14 && 
FB_P9100 && FB_LEO && FB_SM750 && FB_XGI) selects FB_CFB_IMAGEBLIT which has 
unmet direct dependencies (HAS_IOMEM && FB)
warning: (VIDEO_FB_IVTV && VIDEO_VIVID && DRM_KMS_FB_HELPER && DRM_RADEON && 
DRM_AMDGPU && DRM_VMWGFX && FB_CLPS711X_OLD && FB_TCX && FB_CG14 && FB_P9100 && 
FB_LEO && FB_SM750 && FB_XGI) selects FB_CFB_FILLRECT which has unmet direct 
dependencies (HAS_IOMEM && FB)
>> ERROR: "framebuffer_release" [drivers/gpu/drm/vmwgfx/vmwgfx.ko] undefined!
>> ERROR: "register_framebuffer" [drivers/gpu/drm/vmwgfx/vmwgfx.ko] undefined!
>> ERROR: "framebuffer_alloc" [drivers/gpu/drm/vmwgfx/vmwgfx.ko] undefined!
>> ERROR: "fb_deferred_io_cleanup" [drivers/gpu/drm/vmwgfx/vmwgfx.ko] undefined!
>> ERROR: "fb_deferred_io_init" [drivers/gpu/drm/vmwgfx/vmwgfx.ko] undefined!
>> ERROR: "unregister_framebuffer" [drivers/gpu/drm/vmwgfx/vmwgfx.ko] undefined!
>> ERROR: "remove_conflicting_framebuffers" 
>> [drivers/gpu/drm/virtio/virtio-gpu.ko] undefined!
>> ERROR: "remove_conflicting_framebuffers" 
>> [drivers/gpu/drm/mgag200/mgag200.ko] undefined!
>> ERROR: "remove_conflicting_framebuffers" [drivers/gpu/drm/cirrus/cirrus.ko] 
>> undefined!
>> ERROR: "remove_conflicting_framebuffers" 
>> [drivers/gpu/drm/bochs/bochs-drm.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH] treewide: fix a bunch of typos (Documentation/)

2016-08-07 Thread Randy Dunlap
On 08/07/16 06:56, Masahiro Yamada wrote:
> Signed-off-by: Masahiro Yamada 


for the Documentation/* files:

All of the changes look correct, but a couple of them could use some
more attention:


--- a/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt
@@ -45,7 +45,7 @@ Required Properties:
 Optional Properties:
 - reg-names: In addition to the required properties, the following are optional
   - "efuse-address"- Contains efuse base address used to pick up ABB info.
-  - "ldo-address"  - Contains address of ABB LDO overide register address.
+  - "ldo-address"  - Contains address of ABB LDO override register address.

Probably drop the last "address".



--- a/Documentation/xtensa/atomctl.txt
+++ b/Documentation/xtensa/atomctl.txt
@@ -19,7 +19,7 @@ doing a Cached (WB) transaction and use the Memory RCW for 
un-cached
 operations.
 
 For systems without an coherent cache controller, non-MX, we always
-use the memory controllers RCW, thought non-MX controlers likely
+use the memory controllers RCW, thought non-MX controllers likely
 support the Internal Operation.

I think s/thought/though/.


-- 
~Randy


Re: [PATCH RESEND] net: can: Introduce MEN 16Z192-00 CAN controller driver

2016-08-07 Thread Benjamin Poirier
On 2016/07/26 11:16, Andreas Werner wrote:
[...]
> +
> + /* Lock for CTL_BTR register access.
> +  * This register combines bittiming bits
> +  * and the operation mode bits.
> +  * It is also used for bit r/m/w access
> +  * to all registers.
> +  */
> + spinlock_t lock;

Why not use 80 cols for comments?

[...]
> +
> +static int men_z192_xmit(struct sk_buff *skb, struct net_device *ndev)
> +{
> + struct can_frame *cf = (struct can_frame *)skb->data;
> + struct men_z192 *priv = netdev_priv(ndev);
> + struct men_z192_regs __iomem *regs = priv->regs;
> + struct net_device_stats *stats = &ndev->stats;
> + struct men_z192_cf_buf __iomem *cf_buf;
> + u32 data[2] = {0, 0};
> + int status;
> + u32 id;
> +
> + if (can_dropped_invalid_skb(ndev, skb))
> + return NETDEV_TX_OK;
> +
> + status = readl(®s->rx_tx_sts);
> +
> + if (MEN_Z192_TX_BUF_CNT(status) >= 255) {
> + netif_stop_queue(ndev);
> + netdev_err(ndev, "not enough space in TX buffer\n");
> +
> + return NETDEV_TX_BUSY;
> + }
> +
> + cf_buf = priv->dev_base + MEN_Z192_TX_BUF_START;
> +
> + if (cf->can_id & CAN_EFF_FLAG) {
> + /* Extended frame */
> + id = ((cf->can_id & CAN_EFF_MASK) <<
> + MEN_Z192_CFBUF_ID2_SHIFT) & MEN_Z192_CFBUF_ID2;
> +
> + id |= (((cf->can_id & CAN_EFF_MASK) >>
> + (CAN_EFF_ID_BITS - CAN_SFF_ID_BITS)) <<
> +  MEN_Z192_CFBUF_ID1_SHIFT) & MEN_Z192_CFBUF_ID1;
> +
> + id |= MEN_Z192_CFBUF_IDE;
> + id |= MEN_Z192_CFBUF_SRR;
> +
> + if (cf->can_id & CAN_RTR_FLAG)
> + id |= MEN_Z192_CFBUF_E_RTR;
> + } else {
> + /* Standard frame */
> + id = ((cf->can_id & CAN_SFF_MASK) <<
> +MEN_Z192_CFBUF_ID1_SHIFT) & MEN_Z192_CFBUF_ID1;
> +
> + if (cf->can_id & CAN_RTR_FLAG)
> + id |= MEN_Z192_CFBUF_S_RTR;
> + }
> +
> + if (cf->can_dlc > 0)
> + data[0] = be32_to_cpup((__be32 *)(cf->data));
> + if (cf->can_dlc > 3)
> + data[1] = be32_to_cpup((__be32 *)(cf->data + 4));
> +
> + writel(id, &cf_buf->can_id);
> + writel(cf->can_dlc, &cf_buf->length);
> +
> + if (!(cf->can_id & CAN_RTR_FLAG)) {
> + writel(data[0], &cf_buf->data[0]);
> + writel(data[1], &cf_buf->data[1]);
> +
> + stats->tx_bytes += cf->can_dlc;
> + }
> +
> + /* be sure everything is written to the
> +  * device before acknowledge the data.
> +  */
> + mmiowb();
> +
> + /* trigger the transmission */
> + men_z192_ack_tx_pkg(priv, 1);
> +
> + stats->tx_packets++;
> +
> + kfree_skb(skb);

What prevents the skb data to be freed/reused before the device has
accessed it?

[...]
> +
> +static int men_z192_probe(struct mcb_device *mdev,
> +   const struct mcb_device_id *id)
> +{
> + struct device *dev = &mdev->dev;
> + struct men_z192 *priv;
> + struct net_device *ndev;
> + void __iomem *dev_base;
> + struct resource *mem;
> + u32 timebase;
> + int ret = 0;
> + int irq;
> +
> + mem = mcb_request_mem(mdev, dev_name(dev));
> + if (IS_ERR(mem)) {
> + dev_err(dev, "failed to request device memory");
> + return PTR_ERR(mem);
> + }
> +
> + dev_base = ioremap(mem->start, resource_size(mem));
> + if (!dev_base) {
> + dev_err(dev, "failed to ioremap device memory");
> + ret = -ENXIO;
> + goto out_release;
> + }
> +
> + irq = mcb_get_irq(mdev);
> + if (irq <= 0) {
> + ret = -ENODEV;
> + goto out_unmap;
> + }
> +
> + ndev = alloc_candev(sizeof(struct men_z192), 1);
> + if (!ndev) {
> + dev_err(dev, "failed to allocate the can device");
> + ret = -ENOMEM;
> + goto out_unmap;
> + }
> +
> + ndev->netdev_ops = &men_z192_netdev_ops;
> + ndev->irq = irq;
> +
> + priv = netdev_priv(ndev);
> + priv->ndev = ndev;
> + priv->dev = dev;
> +
> + priv->mem = mem;
> + priv->dev_base = dev_base;
> + priv->regs = priv->dev_base + MEN_Z192_REGS_OFFS;
> +
> + timebase = readl(&priv->regs->timebase);
> + if (!timebase) {
> + dev_err(dev, "invalid timebase configured (timebase=%d)\n",
> + timebase);
> + ret = -EINVAL;
> + goto out_unmap;

free_candev is missing in this error path

> + }
> +
> + priv->can.clock.freq = timebase;
> + priv->can.bittiming_const = &men_z192_bittiming_const;
> + priv->can.do_set_mode = men_z192_set_mode;
> + priv->can.do_get_berr_counter = men_z192_get_berr_counter;
> + priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
> +CAN_CTRLMODE_3_SAMPLES |
> +  

Re: 4.7.0-rc7 ext4 error in dx_probe

2016-08-07 Thread Theodore Ts'o
On Fri, Aug 05, 2016 at 12:15:48PM -0700, Darrick J. Wong wrote:
> > > [1] 
> > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/ext4/inode.c?id=b47820edd1634dc1208f9212b7ecfb4230610a23
> > 
> > I added the patch, rebuilt and rebooted.  It will take some time
> > before I'll report back since the issue is so hard to reproduce.
> 
> FWIW I could trigger it reliably by running a bunch of directory traversal
> programs simultaneously on the same directory.  I have a script that fires
> up multiple mutts pointing to the Maildirs for the high traffic Linux lists.

Hmm, I wonder if we should request that this patch be backported to
-stable.  Darrick, what do you think?

- Ted


Re: linux-next: Tree for Aug 8

2016-08-07 Thread Andrew Donnellan

On 08/08/16 13:17, Stephen Rothwell wrote:

Please do not add material destined for v4.9 to your linux-next included
branches until after v4.8-rc1 has been released.


Which has now happened :)

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



[PATCH] clk: Hi6220: enable stub clock driver for ARCH_HISI

2016-08-07 Thread Leo Yan
In current kernel config 'CONFIG_STUB_CLK_HI6220' is disabled by
default, as result stub clock driver has not been registered and
CPUFreq driver cannot work.

This patch is to enable stub clock driver in config for ARCH_HISI.

Reported-by: Dietmar Eggemann 
Signed-off-by: Leo Yan 
---
 drivers/clk/hisilicon/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
index 3f537a0..9e0a95e 100644
--- a/drivers/clk/hisilicon/Kconfig
+++ b/drivers/clk/hisilicon/Kconfig
@@ -23,5 +23,6 @@ config RESET_HISI
 config STUB_CLK_HI6220
bool "Hi6220 Stub Clock Driver"
depends on COMMON_CLK_HI6220 && MAILBOX
+   default ARCH_HISI
help
  Build the Hisilicon Hi6220 stub clock driver.
-- 
1.9.1



linux-next: Tree for Aug 8

2016-08-07 Thread Stephen Rothwell
Hi all,

Please do not add material destined for v4.9 to your linux-next included
branches until after v4.8-rc1 has been released.

Changes since 20160805:

Linus' tree gained a build failure for which I disabled a new driver.

The sound-asoc tree gained a build failure so I used the version from
next-20160805.

Non-merge commits (relative to Linus' tree): 585
 589 files changed, 41794 insertions(+), 3853 deletions(-)



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

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

Below is a summary of the state of the merge.

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

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

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

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

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (52ddb7e9dd73 Merge tag 'doc-4.8-fixes' of 
git://git.lwn.net/linux)
Merging fixes/master (77a87824ed67 clocksource/drivers/clps_711x: fixup for 
"ARM: clps711x:)
Merging kbuild-current/rc-fixes (b36fad65d61f kbuild: Initialize exported 
variables)
Merging arc-current/for-curr (9bd54517ee86 arc: unwind: warn only once if 
DW2_UNWIND is disabled)
Merging arm-current/fixes (f6492164ecb1 ARM: 8577/1: Fix Cortex-A15 798181 
errata initialization)
Merging m68k-current/for-linus (6bd80f372371 m68k/defconfig: Update defconfigs 
for v4.7-rc2)
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging powerpc-fixes/fixes (bad60e6f259a Merge tag 'powerpc-4.8-1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux)
Merging powerpc-merge-mpe/fixes (bc0195aad0da Linux 4.2-rc2)
Merging sparc/master (4620a06e4b3c shmem: Fix link error if huge pages support 
is disabled)
Merging net/master (c518189567ea net: macb: Correct CAPS mask)
Merging ipsec/master (6916fb3b10b3 xfrm: Ignore socket policies when rebuilding 
hash tables)
Merging netfilter/master (43dcff349f09 net: qlcnic: avoid superfluous 
assignement)
Merging ipvs/master (ea43f860d984 Merge branch 'ethoc-fixes')
Merging wireless-drivers/master (034fdd4a17ff Merge ath-current from ath.git)
Merging mac80211/master (2439ca040209 mac80211: Add ieee80211_hw pointer to 
get_expected_throughput)
Merging sound-current/for-linus (59ec4b57bcae ALSA: hda - Fix headset mic 
detection problem for two dell machines)
Merging pci-current/for-linus (ef0dab4aae14 PCI: Fix unaligned accesses in VC 
code)
Merging driver-core.current/driver-core-linus (523d939ef98f Linux 4.7)
Merging tty.current/tty-linus (0e06f5c0deee Merge branch 'akpm' (patches from 
Andrew))
Merging usb.current/usb-linus (0cbbc422d566 Merge tag 
'xfs-rmap-for-linus-4.8-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs)
Merging usb-gadget-fixes/fixes (50c763f8c1ba usb: dwc3: Set the ClearPendIN bit 
on Clear Stall EP command)
Merging usb-serial-fixes/usb-linus (4c2e07c6a29e Linux 4.7-rc5)
Merging usb-chipidea-fixes/ci-for-usb-stable (ea1d39a31d3b usb: common: 
otg-fsm: add license to usb-otg-fsm)
Merging staging.current/staging-linus (0e06f5c0deee Merge branch 'akpm' 
(patches from Andrew))
Merging char-misc.current/char-misc-linus (0e06f5c0deee Merge branch 'akpm' 
(patches from Andrew))
Merging input-current/for-linus (22fe874f3803 Input: silead - remove some dead 
code)
Merging crypto-current/master (8cf740ae85df crypto: marvell - Don't copy IV 
vectors from the _process op for ciphers)
Merging ide/master (797cee982eef Merge branch 'stable-4.8' of 
git://git.infradead.org/users/pcmoore/audit)
Merging rr-fixes/fixes (8244062ef1e5 modules: fix longstanding /proc/kallsyms 
vs module insertion race

[PATCH] mm: fix the incorrect hugepages count

2016-08-07 Thread zhongjiang
From: zhong jiang 

when memory hotplug enable, free hugepages will be freed if movable node 
offline.
therefore, /proc/sys/vm/nr_hugepages will be incorrect.

The patch fix it by reduce the max_huge_pages when the node offline.

Signed-off-by: zhong jiang 
---
 mm/hugetlb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f904246..3356e3a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1448,6 +1448,7 @@ static void dissolve_free_huge_page(struct page *page)
list_del(&page->lru);
h->free_huge_pages--;
h->free_huge_pages_node[nid]--;
+   h->max_huge_pages--;
update_and_free_page(h, page);
}
spin_unlock(&hugetlb_lock);
-- 
1.8.3.1



Re: [PATCH] ARM: dts: add rk3288-firefly-reload

2016-08-07 Thread Shawn Lin

在 2016/8/7 22:44, Heiko Stuebner 写道:

Hi Shawn,

Am Sonntag, 7. August 2016, 11:40:21 schrieb Shawn Lin:

On 2016/7/19 3:46, Heiko Stübner wrote:

Am Montag, 18. Juli 2016, 23:32:32 schrieb Randy Li:

The Firefly RK3288 Reload is a combination Firefly rk3288 core board
with the Reload baseboard. Add a dtsi for the Firefly rk3288 core
which can be included into the dts for the various baseboards
in the future and dts for Reload base board.

Currently supported are serial console, wired networking, eMMC and
SD storage, SPFIF, IR receiver, LEDs, SDIO wifi and USB. But only
the OTG could work on the host mode now, the other USB host can't
work now, additional patches are required.

Signed-off-by: Randy Li 
Acked-by: Rob Herring 


applied [0], after some minor reordering - please double check.

Also, while the branch is named 4.8 this will only go into 4.9, as the
merge- window supposedly opens on the weekend.


Sorry for the noise here:), but I find there is some mmc stuff
which confuse me. Maybe Randy could elaborate more?

Your sdmmc claims to support UHS-I mode like sd-uhs-sdr104, etc, which
will ask dw_mmc to switch vqmmc from 3V3 to 1V8 after sending CMD11.

But the vqmmc is vccio_sd which is fixed as 3V3? :)


so far we have only been able to achieve UHS speeds on devices based on the
rk808 pmic (I had sucess on veyron and popmetal). The act8846-based boards
seem to have some issue when trying to do the switch to 1.8V, resulting in
mmc errors and the mmc-core switching back to 3.3V.


Interesting I will have a look at it this weekend with Randy face 2
face



I think this might be caused by a bug in the act8846 driver or some dts
mistake. But so far nobody had the time and enthusiasm to investigate :-)


Heiko

___
Linux-rockchip mailing list
linux-rockc...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip




--
Best Regards
Shawn Lin



Re: [PATCH v3 1/2] Documentation: kdump: remind user of nr_cpus

2016-08-07 Thread Dave Young
On 08/03/16 at 08:59am, Zhou Wenjian wrote:
> v2->v3: add description of nr_cpus.
> v1->v2: change nr_cpus to maxcpus
> 
> nr_cpus can help to save memory. So we should remind user of it.
> 
> Signed-off-by: Zhou Wenjian 
> ---
>  Documentation/kdump/kdump.txt | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt
> index 88ff63d..4aa194e 100644
> --- a/Documentation/kdump/kdump.txt
> +++ b/Documentation/kdump/kdump.txt
> @@ -393,6 +393,8 @@ Notes on loading the dump-capture kernel:
>  * We generally don' have to bring up a SMP kernel just to capture the
>dump. Hence generally it is useful either to build a UP dump-capture
>kernel or specify maxcpus=1 option while loading dump-capture kernel.
> +  Note, though maxcpus always works, we should replace it by nr_cpus to
> +  save memory if supported by the current ARCH, such as x86. 

Can you replace "we" with "you" in both these patches?

Thanks
Dave


Re: [LKP] [lkp] [sctp] a6c2f79287: netperf.Throughput_Mbps -37.2% regression

2016-08-07 Thread Aaron Lu
On Fri, Aug 05, 2016 at 07:53:38PM +0800, Xin Long wrote:
> >> It doesn't make much sense to me. the codes I added cannot be
> >> triggered without enable any pr policies. and I also did the tests in
> >
> > It seems these pr policies has to be turned on by user space, i.e.
> > netperf in this case?
> >
> > I checked netperf's source code, it doesn't seem set any option
> > related to SCTP PR POLICY but I'm new to network code so I could be
> > wrong or missing something.
> >
> >> my local environment,  the result looks normal to me compare to
> >> prior version.
> >
> > Can you share your number?
> > We run netperf like this:
> > netperf -4 -t SCTP_STREAM_MANY -c -C -l 300 -- -m 10K -H 127.0.0.1
> > The full log of the run is attached for your reference.
> 
> Now I also changed to linux-net.git
> 
> commit 96b585267f552d4b6a28ea8bd75e5ed03deb6e71
> [root@hp-dl388g8-08 ~]# uname -r
> 4.7.0.new
> [root@hp-dl388g8-08 ~]# netperf -4 -t SCTP_STREAM_MANY -c -C -l 300 --
> -m 10K -H 127.0.0.1
> SCTP 1-TO-MANY STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
> 127.0.0.1 () port 0 AF_INET
> Recv   SendSend  Utilization   Service Demand
> Socket Socket  Message  Elapsed  Send Recv SendRecv
> Size   SizeSize Time Throughput  localremote   local   remote
> bytes  bytes   bytessecs.10^6bits/s  % S  % S  us/KB   us/KB
> 
> 212992 212992  10240300.00 11814.56   4.65 4.65 0.775   0.774
> 
> 
> commit f959fb442c35f4b61fea341401b8463dd0a1b959 (just before the buggie patch)

I'm testing on Linus' master, can we all use that please?

> [root@localhost ~]# netperf -4 -t SCTP_STREAM_MANY -c -C -l 300 -- -m
> 10K -H 127.0.0.1
> SCTP 1-TO-MANY STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
> 127.0.0.1 () port 0 AF_INET
> Recv   SendSend  Utilization   Service Demand
> Socket Socket  Message  Elapsed  Send Recv SendRecv
> Size   SizeSize Time Throughput  localremote   local   remote
> bytes  bytes   bytessecs.10^6bits/s  % S  % S  us/KB   us/KB
> 
> 212992 212992  10240300.00 9454.90   5.22 5.22 1.086   1.085
> 
> 
> I did tests on physical machine.
> did you do it on guest ?

The test is done on a ivy-bridge desktop with 8G memory:
# cpudesc : Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
# total memory : 8058152 kB

> 
> >
> >>
> >> Recently the sctp performance is not stable,  as during these patches,
> >> netperf cannot get the result, but return ENOTCONN. which may
> >> also affect the testing. anyway we've fixed the -ENOTCONN issue
> >> already in the latest version.
> >
> > I tested commit 96b585267f55, which is Linus' git tree HEAD on 08/03, I
> > guess the fix you mentioned should already be in there? But
> > unfortunately, the throughput of netperf is still at low number(we did
> > the test 5 times):
> > $ cat */netperf.json
> > {
> >   "netperf.Throughput_Mbps": [
> > 2470.69748
> >   ]
> > }{
> >   "netperf.Throughput_Mbps": [
> > 2486.7675
> >   ]
> > }{
> >   "netperf.Throughput_Mbps": [
> > 2478.945
> >   ]
> > }{
> >   "netperf.Throughput_Mbps": [
> > 2429.465
> >   ]
> > }{
> >   "netperf.Throughput_Mbps": [
> > 2476.91504
> >   ]
> >
> > Considering what you have said that the patch shouldn't make a
> > difference, the performance drop is really confusing. Any idea what
> > could be the cause? Thanks.
> Now I saw your tests result against the new kernel
> 
> Could you do the same test on the kernel before the problematic commit ?

Yes, the throughput of its parent commit is higer enough to trigger the
automatic bisect and then we send out the report.

Throughput of its parent commit 826d253d57b1("sctp: add SCTP_PR_ASSOC_STATUS
on sctp sockopt"):
Average:
"netperf.Throughput_Mbps": 3923.84375,

$ cat */netperf.json
{
  "netperf.Throughput_Mbps": [
3869.25375
  ]
}{
  "netperf.Throughput_Mbps": [
3952.58875
  ]
}{
  "netperf.Throughput_Mbps": [
3936.89625
  ]
}{
  "netperf.Throughput_Mbps": [
3936.63625
  ]
}

Feel free to let me know if you need any more information or you want me
to do more tests on other commits/machines, thanks.

Regards,
Aaron


Re: [PATCH v4 0/6] power: add power sequence library

2016-08-07 Thread Peter Chen
On Sat, Aug 06, 2016 at 02:00:08PM +0200, Oscar wrote:
> El 2016-08-02 05:30, Peter Chen escribió:
> >Hi all,
> >
> >This is a follow-up for my last power sequence framework patch set
> >[1].
> >According to Rob Herring and Ulf Hansson's comments[2], I use a
> >generic
> >power sequence library for parsing the power sequence elements on DT,
> >and implement generic power sequence on library. The host driver
> >can allocate power sequence instance, and calls pwrseq APIs
> >accordingly.
> >
> >In future, if there are special power sequence requirements, the
> >special
> >power sequence library can be created.
> >
> >This patch set is tested on i.mx6 sabresx evk using a dts change,
> >I use
> >two hot-plug devices to simulate this use case, the related binding
> >change is updated at patch [1/6], The udoo board changes were tested
> >using my last power sequence patch set.[3]
> >
> >Except for hard-wired MMC and USB devices, I find the USB ULPI PHY
> >also
> >need to power on itself before it can be found by ULPI bus.
> >
> >[1] http://www.spinics.net/lists/linux-usb/msg142755.html
> >[2] http://www.spinics.net/lists/linux-usb/msg143106.html
> >[3] http://www.spinics.net/lists/linux-usb/msg142815.html
> >
> >Changes for v4:
> >- Create the patch on next-20160722
> >- Fix the of_node is not NULL after chipidea driver is unbinded
> >[Patch 5/6]
> >- Using more friendly wait method for reset gpio [Patch 2/6]
> >- Support multiple input clocks [Patch 2/6]
> >- Add Rob Herring's ack for DT changes
> >- Add Joshua Clayton's Tested-by
> >
> >Changes for v3:
> >- Delete "power-sequence" property at binding-doc, and change
> >related code
> >  at both library and user code.
> >- Change binding-doc example node name with Rob's comments
> >- of_get_named_gpio_flags only gets the gpio, but without setting
> >gpio flags,
> >  add additional code request gpio with proper gpio flags
> >- Add Philipp Zabel's Ack and MAINTAINER's entry
> >
> >Changes for v2:
> >- Delete "pwrseq" prefix and clock-names for properties at dt binding
> >- Should use structure not but its pointer for kzalloc
> >- Since chipidea core has no of_node, let core's of_node equals glue
> >  layer's at core's probe
> >
> >Peter Chen (6):
> >  binding-doc: power: pwrseq-generic: add binding doc for generic
> >power
> >sequence library
> >  power: add power sequence library
> >  binding-doc: usb: usb-device: add optional properties for power
> >sequence
> >  usb: core: add power sequence handling for USB devices
> >  usb: chipidea: let chipidea core device of_node equal's glue layer
> >device of_node
> >  ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property
> >
> 
> Hi Peter,
> 
> I tried the last version on my udoo board but I got these compile
> errors:
> 
> [21330s] ERROR: "pwrseq_get" [drivers/usb/core/usbcore.ko] undefined!
> [21330s] ERROR: "pwrseq_free" [drivers/usb/core/usbcore.ko] undefined!
> [21330s] ERROR: "pwrseq_put" [drivers/usb/core/usbcore.ko] undefined!
> [21330s] ERROR: "pwrseq_off" [drivers/usb/core/usbcore.ko] undefined!
> [21330s] ERROR: "pwrseq_on" [drivers/usb/core/usbcore.ko] undefined!
> 
> Will you do another version?
> 

Thanks, I forgot to export above symbols, I will fix it at next
version. Below fix should work for you, I have tested.

diff --git a/drivers/power/pwrseq/core.c b/drivers/power/pwrseq/core.c
index 60f1e4e..6861a21 100644
--- a/drivers/power/pwrseq/core.c
+++ b/drivers/power/pwrseq/core.c
@@ -29,6 +29,7 @@ int pwrseq_get(struct device_node *np, struct pwrseq *p)
 
return -ENOTSUPP;
 }
+EXPORT_SYMBOL(pwrseq_get);
 
 int pwrseq_on(struct device_node *np, struct pwrseq *p)
 {
@@ -37,24 +38,28 @@ int pwrseq_on(struct device_node *np, struct pwrseq *p)
 
return -ENOTSUPP;
 }
+EXPORT_SYMBOL(pwrseq_on);
 
 void pwrseq_off(struct pwrseq *p)
 {
if (p && p->off)
p->off(p);
 }
+EXPORT_SYMBOL(pwrseq_off);
 
 void pwrseq_put(struct pwrseq *p)
 {
if (p && p->put)
p->put(p);
 }
+EXPORT_SYMBOL(pwrseq_put);
 
 void pwrseq_free(struct pwrseq *p)
 {
if (p && p->free)
p->free(p);
 }
+EXPORT_SYMBOL(pwrseq_free);

-- 

Best Regards,
Peter Chen


RE: [PATCH v2] RANDOM: ATH9K RNG delivers zero bits of entropy

2016-08-07 Thread Pan, Miaoqing
The entropy was evaluated by crypto expert,  the analysis report show the ADC 
with at least 10bits and up to 22 bits of min-entropy for a 32 bits value, we 
conservatively assume the min-entropy is 10 bits out of 32 bits, so that's why 
set entropy quality  to  320/1024 = 10/32.  Also we have explained in the 
commit message why can't use the HW RNG framework.

Otherwise, your patch will cause high CPU load,  as continuously read ADC data 
if entropy bits under write_wakeup_threshold.

--
Miaoqing

-Original Message-
From: Stephan Mueller [mailto:smuel...@chronox.de] 
Sent: Sunday, August 07, 2016 5:36 PM
To: Ted Tso 
Cc: herb...@gondor.apana.org.au; linux-kernel@vger.kernel.org; 
linux-cry...@vger.kernel.org; ath9k-devel ; 
linux-wirel...@vger.kernel.org; ath9k-de...@lists.ath9k.org; Kalle Valo 
; Jason Cooper 
Subject: [PATCH v2] RANDOM: ATH9K RNG delivers zero bits of entropy

The ATH9K driver implements an RNG which is completely bypassing the standard 
Linux HW generator logic.

The RNG may or may not deliver entropy. Considering the conservative approach 
in treating entropy with respect to non-auditable sources, this patch changes 
the delivered entropy value to zero. The RNG still feeds data into the 
input_pool but it is assumed to have no entropy.

When the ATH9K RNG changes to use the HW RNG framework, it may re-enable the 
entropy estimation considering that a user can change that value at boot and 
runtime.

Reviewed-by: Jason Cooper 
Signed-off-by: Stephan Mueller 
---
 drivers/net/wireless/ath/ath9k/rng.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/rng.c 
b/drivers/net/wireless/ath/ath9k/rng.c
index d38e50f..1ed8338 100644
--- a/drivers/net/wireless/ath/ath9k/rng.c
+++ b/drivers/net/wireless/ath/ath9k/rng.c
@@ -22,7 +22,6 @@
 #include "ar9003_phy.h"
 
 #define ATH9K_RNG_BUF_SIZE 320
-#define ATH9K_RNG_ENTROPY(x)   (((x) * 8 * 320) >> 10) /* quality: 320/1024 */
 
 static int ath9k_rng_data_read(struct ath_softc *sc, u32 *buf, u32 buf_size)  
{ @@ -92,8 +91,7 @@ static int ath9k_rng_kthread(void *data)
fail_stats = 0;
 
/* sleep until entropy bits under write_wakeup_threshold */
-   add_hwgenerator_randomness((void *)rng_buf, bytes_read,
-  ATH9K_RNG_ENTROPY(bytes_read));
+   add_hwgenerator_randomness((void *)rng_buf, bytes_read, 0);
}
 
kfree(rng_buf);
--
2.7.4




(.init.text+0x122): multiple definition of `plat_irq_setup'

2016-08-07 Thread kbuild test robot
Hi Rich,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   29b4817d4018df78086157ea3a55c1d9424a7cfc
commit: 7480e0aabd5f9e6c3e3b72ed206e89284e90f11f sh: add device tree support 
and generic board using device tree
date:   5 months ago
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 7480e0aabd5f9e6c3e3b72ed206e89284e90f11f
# save the attached .config to linux build tree
make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   arch/sh/boards/built-in.o: In function `plat_irq_setup':
>> (.init.text+0x122): multiple definition of `plat_irq_setup'
   arch/sh/kernel/built-in.o:(.init.text+0x944): first defined here
   arch/sh/boards/built-in.o: In function `arch_init_clk_ops':
>> (.init.text+0x118): multiple definition of `arch_init_clk_ops'
   arch/sh/kernel/built-in.o:(.init.text+0x990): first defined here

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


linux-next: build failure after merge of Linus' tree

2016-08-07 Thread Stephen Rothwell
Hi all,

With Linus' tree, today's linux-next build (powerpc allyesconfig) failed
like this:

drivers/infiniband/sw/built-in.o:(.opd+0x1698): multiple definition of 
`copy_data'
drivers/infiniband/hw/built-in.o:(.opd+0xe5f8): first defined here
drivers/infiniband/sw/built-in.o:(.opd+0x1320): multiple definition of 
`rxe_av_from_attr'
drivers/infiniband/hw/built-in.o:(.opd+0xe280): first defined here
drivers/infiniband/sw/built-in.o:(.opd+0x18d8): multiple definition of 
`rxe_do_task'
drivers/infiniband/hw/built-in.o:(.opd+0xe838): first defined here

and lots of others.

Caused by commit

  8700e3e7c485 ("Soft RoCE driver")

(which was never in linux-next :-()

I just disabled teh driver for today:

From: Stephen Rothwell 
Date: Mon, 8 Aug 2016 11:52:53 +1000
Subject: [PATCH] Disable the Soft RoCE driver

Signed-off-by: Stephen Rothwell 
---
 drivers/infiniband/Kconfig | 1 -
 drivers/infiniband/sw/Makefile | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
index 0c2e55c5354b..53ef194c5be1 100644
--- a/drivers/infiniband/Kconfig
+++ b/drivers/infiniband/Kconfig
@@ -86,7 +86,6 @@ source "drivers/infiniband/ulp/iser/Kconfig"
 source "drivers/infiniband/ulp/isert/Kconfig"
 
 source "drivers/infiniband/sw/rdmavt/Kconfig"
-source "drivers/infiniband/sw/rxe/Kconfig"
 
 source "drivers/infiniband/hw/hfi1/Kconfig"
 
diff --git a/drivers/infiniband/sw/Makefile b/drivers/infiniband/sw/Makefile
index 8b095b27db87..988b6a0101a4 100644
--- a/drivers/infiniband/sw/Makefile
+++ b/drivers/infiniband/sw/Makefile
@@ -1,2 +1 @@
 obj-$(CONFIG_INFINIBAND_RDMAVT)+= rdmavt/
-obj-$(CONFIG_RDMA_RXE) += rxe/
-- 
2.8.1

-- 
Cheers,
Stephen Rothwell


Linux 4.8-rc1

2016-08-07 Thread Linus Torvalds
It's been two weeks, and the merge window for 4.8 is thus closed.

Due to travel last week, I actually still have a few pull requests
pending in my inbox that I just wanted to take another look at before
merging, but the large bulk of the merge window material has been
merged, and I wanted to make sure there aren't any new ones coming in.

This seems to be building up to be one of the bigger releases lately,
but let's see how it all ends up. The merge window has been fairly
normal, although the patch itself looks somewhat unusual: over 20% of
the patch is documentation updates, due to conversion of the drm and
media documentation from docbook to the Sphinx doc format. There are
other doc updates, but that's the big bulk of it.

If you ignore the documentation format change, things look fairly
regular, with about 60% of the non-documentation diffs being drivers
(gpu, networking, media, sound, etc)  and about 15% being arch updates
(arm, powerpc and x86 dominate, but there's mips and s390 too).

The rest is spread out - core networking, tooling (mainly perf),
include files, core kernel, vfs and low-level filesystems (xfs stands
out). Few areas escaped:

  10787 files changed, 612208 insertions(+), 272098 deletions(-)

Go out and test. The diffs and logs are too big to post, so as usual
for rc1, I'm just appending my "merge log" for a very high-level view.

Linus

---

Al Viro (3):
vfs updates
qstr constification updates
more vfs updates

Alex Williamson (1):
VFIO updates

Alexandre Belloni (1):
RTC updates

Andrew Morton (5):
updates
more updates
yet more updates
even more updates
misc fixes

Bjorn Andersson (2):
remoteproc updates
hwspinlock updates

Bjorn Helgaas (1):
PCI updates

Bob Peterson (1):
gfs2 updates

Borislav Petkov (1):
EDAC updates

Brian Norris (1):
MTD updates

Bruce Fields (1):
nfsd updates

Catalin Marinas (1):
arm64 updates

Chris Mason (2):
btrfs updates
more btrfs updates

Chris Metcalf (1):
tile architecture updates

Christoph Hellwig (2):
configfs update
freevxfs updates

Corey Minyard (1):
IPMI updates

Dan Williams (1):
libnvdimm updates

Darren Hart (1):
x8 platform driver updates

Dave Airlie (3):
drm updates
i915 drm fixes
drm zpos property support

Dave Chinner (2):
xfs updates
more xfs updates

David Miller (4):
networking updates
sparc updates
IDE updates
networking fixes

David Teigland (1):
dlm updates

David Vrabel (1):
xen updates

Dmitry Torokhov (2):
input updates
more input updates

Doug Ledford (2):
base rdma updates
second round of rdma updates

Eric Biederman (1):
userns vfs updates

Greg KH (5):
char/misc driver updates
staging and IIO driver updates
tty/serial driver updates
USB updates
more USB updates

Greg Ungerer (1):
m68knommu updates

Guenter Roeck (2):
hwmon updates
more hwmon updates

Hans-Christian Noren Egtvedt (1):
AVR32 updates

Helge Deller (1):
parisc updates

Herbert Xu (2):
crypto updates
crypto fixes

Ilya Dryomov (1):
Ceph updates

Ingo Molnar (21):
RCU updates
EFI updates
locking updates
RAS updates
perf updates
scheduler updates
NOHZ updates
x86/apic updates
x86 mm updates
x86 boot updates
x86 build updates
x86 cleanups
x86 stackdump update
x86 fpu updates
x86 platform updates
x86 timer updates
x86 fix
perf fixes
x86 header cleanups
x86 fixes
perf updates

Jacek Anaszewski (1):
LED updates

Jaegeuk Kim (1):
f2fs updates

James Bottomley (3):
SCSI updates
SCSI fixes
binfmt_misc update

James Hogan (1):
metag architecture updates

James Morris (1):
security subsystem updates

Jan Kara (1):
quota update

Jens Axboe (4):
core block updates
block driver updates
block fixes
more block fixes

Jiri Kosina (2):
trivial tree updates
HID updates

Joerg Roedel (1):
IOMMU updates

Jon Mason (1):
NTB updates

Jonathan Corbet (2):
documentation updates
documentation fixes

Jussi Brar (1):
mailbox updates

Kees Cook (2):
pstore subsystem updates
pstore fixes

Lee Jones (2):
MFD updates
backlight updates

Linus Walleij (2):
GPIO updates
pin control updates

Mark Brown (3):
regmap updates
regulator updates
spi updates

Martin Brandenburg (1):
orangefs update

Martin Schwidefsky (2):
s390 updates
more s390 updates

Mauro Carvalho Chehab (4):
media updates
media documentation updates
media DocBook removal and some fixups
mailcap fixlets

Michael Ellerman (2):
powerpc updates
more powerpc updates

Michael Tsirkin (1):
virtio/vhost updates

Michael Turquette (1):
clk updates

Michal Marek (2):
kbuild updates
misc kbuild updates

Mike Mashall (1):
orangefs updates

Mike Snitzer (2):
d

drivers/pinctrl/intel/pinctrl-merrifield.c:518:10: error: implicit declaration of function 'readl'

2016-08-07 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   29b4817d4018df78086157ea3a55c1d9424a7cfc
commit: 4e80c8f505741cbdef3e10862ea36057e8d85e7c pinctrl: intel: Add Intel 
Merrifield pin controller support
date:   6 weeks ago
config: x86_64-randconfig-x012-201632 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
git checkout 4e80c8f505741cbdef3e10862ea36057e8d85e7c
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/pinctrl/intel/pinctrl-merrifield.c: In function 'mrfld_pin_dbg_show':
>> drivers/pinctrl/intel/pinctrl-merrifield.c:518:10: error: implicit 
>> declaration of function 'readl' [-Werror=implicit-function-declaration]
 value = readl(bufcfg);
 ^
   drivers/pinctrl/intel/pinctrl-merrifield.c: In function 
'mrfld_update_bufcfg':
>> drivers/pinctrl/intel/pinctrl-merrifield.c:575:2: error: implicit 
>> declaration of function 'writel' [-Werror=implicit-function-declaration]
 writel(value, bufcfg);
 ^~
   cc1: some warnings being treated as errors

vim +/readl +518 drivers/pinctrl/intel/pinctrl-merrifield.c

   512  if (!mrfld_buf_available(mp, pin)) {
   513  seq_puts(s, "not available");
   514  return;
   515  }
   516  
   517  bufcfg = mrfld_get_bufcfg(mp, pin);
 > 518  value = readl(bufcfg);
   519  
   520  mode = (value & BUFCFG_PINMODE_MASK) >> BUFCFG_PINMODE_SHIFT;
   521  if (!mode)
   522  seq_puts(s, "GPIO ");
   523  else
   524  seq_printf(s, "mode %d ", mode);
   525  
   526  seq_printf(s, "0x%08x", value);
   527  }
   528  
   529  static const struct pinctrl_ops mrfld_pinctrl_ops = {
   530  .get_groups_count = mrfld_get_groups_count,
   531  .get_group_name = mrfld_get_group_name,
   532  .get_group_pins = mrfld_get_group_pins,
   533  .pin_dbg_show = mrfld_pin_dbg_show,
   534  };
   535  
   536  static int mrfld_get_functions_count(struct pinctrl_dev *pctldev)
   537  {
   538  struct mrfld_pinctrl *mp = pinctrl_dev_get_drvdata(pctldev);
   539  
   540  return mp->nfunctions;
   541  }
   542  
   543  static const char *mrfld_get_function_name(struct pinctrl_dev *pctldev,
   544 unsigned int function)
   545  {
   546  struct mrfld_pinctrl *mp = pinctrl_dev_get_drvdata(pctldev);
   547  
   548  return mp->functions[function].name;
   549  }
   550  
   551  static int mrfld_get_function_groups(struct pinctrl_dev *pctldev,
   552   unsigned int function,
   553   const char * const **groups,
   554   unsigned int * const ngroups)
   555  {
   556  struct mrfld_pinctrl *mp = pinctrl_dev_get_drvdata(pctldev);
   557  
   558  *groups = mp->functions[function].groups;
   559  *ngroups = mp->functions[function].ngroups;
   560  return 0;
   561  }
   562  
   563  static void mrfld_update_bufcfg(struct mrfld_pinctrl *mp, unsigned int 
pin,
   564  u32 bits, u32 mask)
   565  {
   566  void __iomem *bufcfg;
   567  u32 value;
   568  
   569  bufcfg = mrfld_get_bufcfg(mp, pin);
   570  value = readl(bufcfg);
   571  
   572  value &= ~mask;
   573  value |= bits & mask;
   574  
 > 575  writel(value, bufcfg);
   576  }
   577  
   578  static int mrfld_pinmux_set_mux(struct pinctrl_dev *pctldev,

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH] USB: serial: fix memleak on error path in usb-serial

2016-08-07 Thread Alan Stern
On Mon, 8 Aug 2016, Alexey Klimov wrote:

> udriver struct allocated by kzalloc() will not be freed
> if usb_register() and next calls fail. This patch fixes this
> by adding one more step with kfree(udriver) in error path.
> 
> Cc: Alan Stern 
> Signed-off-by: Alexey Klimov 
> ---
>  drivers/usb/serial/usb-serial.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> index b1b9bac..d213cf4 100644
> --- a/drivers/usb/serial/usb-serial.c
> +++ b/drivers/usb/serial/usb-serial.c
> @@ -1433,7 +1433,7 @@ int usb_serial_register_drivers(struct 
> usb_serial_driver *const serial_drivers[]
>  
>   rc = usb_register(udriver);
>   if (rc)
> - return rc;
> + goto failed_usb_register;
>  
>   for (sd = serial_drivers; *sd; ++sd) {
>   (*sd)->usb_driver = udriver;
> @@ -1451,6 +1451,8 @@ int usb_serial_register_drivers(struct 
> usb_serial_driver *const serial_drivers[]
>   while (sd-- > serial_drivers)
>   usb_serial_deregister(*sd);
>   usb_deregister(udriver);
> +failed_usb_register:
> + kfree(udriver);
>   return rc;
>  }
>  EXPORT_SYMBOL_GPL(usb_serial_register_drivers);

Acked-by: Alan Stern 

Pretty careless of me...  Thanks for fixing this.

Alan Stern



[PATCH] USB: serial: fix memleak on error path in usb-serial

2016-08-07 Thread Alexey Klimov
udriver struct allocated by kzalloc() will not be freed
if usb_register() and next calls fail. This patch fixes this
by adding one more step with kfree(udriver) in error path.

Cc: Alan Stern 
Signed-off-by: Alexey Klimov 
---
 drivers/usb/serial/usb-serial.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index b1b9bac..d213cf4 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1433,7 +1433,7 @@ int usb_serial_register_drivers(struct usb_serial_driver 
*const serial_drivers[]
 
rc = usb_register(udriver);
if (rc)
-   return rc;
+   goto failed_usb_register;
 
for (sd = serial_drivers; *sd; ++sd) {
(*sd)->usb_driver = udriver;
@@ -1451,6 +1451,8 @@ int usb_serial_register_drivers(struct usb_serial_driver 
*const serial_drivers[]
while (sd-- > serial_drivers)
usb_serial_deregister(*sd);
usb_deregister(udriver);
+failed_usb_register:
+   kfree(udriver);
return rc;
 }
 EXPORT_SYMBOL_GPL(usb_serial_register_drivers);
-- 
2.5.0



Re: linux-next: build failure after merge of the sound-asoc tree

2016-08-07 Thread Kuninori Morimoto

Hi

> After merging the sound-asoc tree, today's linux-next build (arm
> multi_v7_defconfig build) failed like this:
> 
> sound/soc/generic/simple-card.c: In function 'asoc_simple_card_dai_link_of':
> sound/soc/generic/simple-card.c:350:8: error: implicit declaration of 
> function 'asoc_simple_card_parse_clk_cpu' 
> [-Werror=implicit-function-declaration]
>   ret = asoc_simple_card_parse_clk_cpu(cpu, dai_link, cpu_dai);
> ^
> sound/soc/generic/simple-card.c:354:8: error: implicit declaration of 
> function 'asoc_simple_card_parse_clk_codec' 
> [-Werror=implicit-function-declaration]
>   ret = asoc_simple_card_parse_clk_codec(codec, dai_link, codec_dai);
> ^
> sound/soc/sh/rcar/rsrc-card.c: In function 'rsrc_card_parse_links':
> sound/soc/sh/rcar/rsrc-card.c:193:9: error: implicit declaration of function 
> 'asoc_simple_card_parse_clk_cpu' [-Werror=implicit-function-declaration]
>ret = asoc_simple_card_parse_clk_cpu(np, dai_link, dai_props);
>  ^
> sound/soc/sh/rcar/rsrc-card.c:232:9: error: implicit declaration of function 
> 'asoc_simple_card_parse_clk_codec' [-Werror=implicit-function-declaration]
>ret = asoc_simple_card_parse_clk_codec(np, dai_link, dai_props);
>  ^
> 
> Caused by commits
> 
>   28abd99b6e40 ("ASoC: simple-card: use asoc_simple_card_parse_clk()")
>   c9a235da8a61 ("ASoC: rsrc-card: use asoc_simple_card_parse_clk()")
> 
> I have used the sound-asoc tree from next-20160805 for today.

It seems topic/simple branch is missing [1/7], but has [2/7], [3/7] patches.
I'm asking it to Mark now.


Charity Project !!!

2016-08-07 Thread Friedrich And Annand Mayrhofer
My wife and I have awarded you with a donation of $ 1,000,000.00 Dollars from 
part of our Jackpot Lottery of 50 Million Dollars, respond with your  
details for claims.

We await your earliest response and God Bless you.

Friedrich And Annand Mayrhofer.


RE: [PATCH] ACPICA: Remove unnecessary '\n' in the end of ACPI_INFO output

2016-08-07 Thread Zheng, Lv
> From: Alexander Kuleshov [mailto:kuleshovm...@gmail.com]
> Subject: [PATCH] ACPICA: Remove unnecessary '\n' in the end of
> ACPI_INFO output
> 
> as the ACPI_INFO already prints `\n` in the end itself.
[Lv Zheng] 
Looks good.
Acked-by: Lv Zheng 
However this patch should go through ACPICA upstream.

Thanks
-Lv

> 
> Signed-off-by: Alexander Kuleshov 
> ---
>  drivers/acpi/acpica/tbxfload.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
> index ac71abc..e7119b7 100644
> --- a/drivers/acpi/acpica/tbxfload.c
> +++ b/drivers/acpi/acpica/tbxfload.c
> @@ -240,7 +240,7 @@ acpi_status acpi_tb_load_namespace(void)
>   }
> 
>   if (!tables_failed) {
> - ACPI_INFO(("%u ACPI AML tables successfully acquired and
> loaded\n", tables_loaded));
> + ACPI_INFO(("%u ACPI AML tables successfully acquired and
> loaded", tables_loaded));
>   } else {
>   ACPI_ERROR((AE_INFO,
>   "%u table load failures, %u successful",
> --
> 2.8.0.rc3.1353.gea9bdc0



linux-next: build failure after merge of the sound-asoc tree

2016-08-07 Thread Stephen Rothwell
Hi all,

After merging the sound-asoc tree, today's linux-next build (arm
multi_v7_defconfig build) failed like this:

sound/soc/generic/simple-card.c: In function 'asoc_simple_card_dai_link_of':
sound/soc/generic/simple-card.c:350:8: error: implicit declaration of function 
'asoc_simple_card_parse_clk_cpu' [-Werror=implicit-function-declaration]
  ret = asoc_simple_card_parse_clk_cpu(cpu, dai_link, cpu_dai);
^
sound/soc/generic/simple-card.c:354:8: error: implicit declaration of function 
'asoc_simple_card_parse_clk_codec' [-Werror=implicit-function-declaration]
  ret = asoc_simple_card_parse_clk_codec(codec, dai_link, codec_dai);
^
sound/soc/sh/rcar/rsrc-card.c: In function 'rsrc_card_parse_links':
sound/soc/sh/rcar/rsrc-card.c:193:9: error: implicit declaration of function 
'asoc_simple_card_parse_clk_cpu' [-Werror=implicit-function-declaration]
   ret = asoc_simple_card_parse_clk_cpu(np, dai_link, dai_props);
 ^
sound/soc/sh/rcar/rsrc-card.c:232:9: error: implicit declaration of function 
'asoc_simple_card_parse_clk_codec' [-Werror=implicit-function-declaration]
   ret = asoc_simple_card_parse_clk_codec(np, dai_link, dai_props);
 ^

Caused by commits

  28abd99b6e40 ("ASoC: simple-card: use asoc_simple_card_parse_clk()")
  c9a235da8a61 ("ASoC: rsrc-card: use asoc_simple_card_parse_clk()")

I have used the sound-asoc tree from next-20160805 for today.

-- 
Cheers,
Stephen Rothwell


Re: [RFC PATCH v7 1/7] Restartable sequences system call

2016-08-07 Thread Boqun Feng
On Sun, Aug 07, 2016 at 03:36:24PM +, Mathieu Desnoyers wrote:
> - On Aug 3, 2016, at 11:45 AM, Boqun Feng boqun.f...@gmail.com wrote:
> 
> > On Wed, Aug 03, 2016 at 03:19:40PM +0200, Peter Zijlstra wrote:
> >> On Thu, Jul 21, 2016 at 05:14:16PM -0400, Mathieu Desnoyers wrote:
> >> > diff --git a/MAINTAINERS b/MAINTAINERS
> >> > index 1209323..daef027 100644
> >> > --- a/MAINTAINERS
> >> > +++ b/MAINTAINERS
> >> > @@ -5085,6 +5085,13 @@ M:Joe Perches 
> >> >  S:  Maintained
> >> >  F:  scripts/get_maintainer.pl
> >> >  
> >> > +RESTARTABLE SEQUENCES SUPPORT
> >> > +M:  Mathieu Desnoyers 
> >> 
> >> It would be good to have multiple people here, if we lack volunteers I'd
> >> be willing. Paul, Andrew any of you guys willing?
> >> 
> > 
> > I volunteer to review related patches, do tests/benchmarks(esp. on PPC)
> > and try to fix/improve any issue as I can.
> > 
> > Mathieu, may I join the party? ;-)
> 
> Hi!
> 
> I'm glad to see so much interest in helping me maintain rseq :)
> I'll therefore tentatively add the following lines to the maintainers
> list in my next round:
> 
> RESTARTABLE SEQUENCES SUPPORT
> M:Mathieu Desnoyers 
> M:Peter Zijlstra 
> M:"Paul E. McKenney" 
> M:Boqun Feng 
> L:linux-kernel@vger.kernel.org
> S:Supported
> F:kernel/rseq.c
> F:include/uapi/linux/rseq.h
> 

Thank you, Mathieu ;-)

Maybe we also should put the selftest directory here? Like:

F:  tools/testing/selftests/rseq

Of course, this line better be added in patch 7 rather than patch 1.

Regards,
Boqun

> Thanks!
> 
> Mathieu
> 
> > 
> > Regards,
> > Boqun
> > 
> >> > +L:  linux-kernel@vger.kernel.org
> >> > +S:  Supported
> >> > +F:  kernel/rseq.c
> >> > +F:  include/uapi/linux/rseq.h
> >> > +
> >> >  GFS2 FILE SYSTEM
> >> >  M:  Steven Whitehouse 
> >> >  M:  Bob Peterson 
> >> 
> > [...]
> 
> -- 
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com


signature.asc
Description: PGP signature


[PATCH 4/6] hwmon: (lm95241) Drop FSF address

2016-08-07 Thread Guenter Roeck
The FSF address may change, and providing it does not add any value.

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/lm95241.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index c2da2b161996..507b32b67974 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -15,10 +15,6 @@
  * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #include 
-- 
2.5.0



[PATCH 6/6] hwmon: (lm95241) Use more accurate limits

2016-08-07 Thread Guenter Roeck
The lower temperature limit is -128 degrees C. The supported upper limits
are 127.875 or 255.875 degrees C. Also, don't fail if a value outside
the supported range is provided when setting a temperature limit.
Instead, clamp the provided value to the available value range.

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/lm95241.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index df94f486b21c..3d96c3fcba9b 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -205,7 +205,7 @@ static ssize_t show_min(struct device *dev, struct 
device_attribute *attr,
 
return snprintf(buf, PAGE_SIZE - 1,
data->config & to_sensor_dev_attr(attr)->index ?
-   "-127000\n" : "0\n");
+   "-128000\n" : "0\n");
 }
 
 static ssize_t set_min(struct device *dev, struct device_attribute *attr,
@@ -216,8 +216,6 @@ static ssize_t set_min(struct device *dev, struct 
device_attribute *attr,
 
if (kstrtol(buf, 10, &val) < 0)
return -EINVAL;
-   if (val < -128000)
-   return -EINVAL;
 
mutex_lock(&data->update_lock);
 
@@ -242,7 +240,7 @@ static ssize_t show_max(struct device *dev, struct 
device_attribute *attr,
 
return snprintf(buf, PAGE_SIZE - 1,
data->config & to_sensor_dev_attr(attr)->index ?
-   "127000\n" : "255000\n");
+   "127875\n" : "255875\n");
 }
 
 static ssize_t set_max(struct device *dev, struct device_attribute *attr,
@@ -253,8 +251,6 @@ static ssize_t set_max(struct device *dev, struct 
device_attribute *attr,
 
if (kstrtol(buf, 10, &val) < 0)
return -EINVAL;
-   if (val >= 256000)
-   return -EINVAL;
 
mutex_lock(&data->update_lock);
 
-- 
2.5.0



[PATCH 3/6] hwmon: (lm95241) Order include files alphabetically

2016-08-07 Thread Guenter Roeck
Simplify detecting duplicate include files and finding the right place
for adding new ones.

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/lm95241.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index e4e7bf169b07..c2da2b161996 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -21,15 +21,15 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include 
+#include 
+#include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 #include 
+#include 
 #include 
 
 #define DEVNAME "lm95241"
-- 
2.5.0



[PATCH 2/6] hwmon: (lm95241) Add support for fault attributes

2016-08-07 Thread Guenter Roeck
The chip reports if remote diodes are present, which can be used for
the fault attrributes.

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/lm95241.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index a8cf666fe661..e4e7bf169b07 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -70,6 +70,8 @@ static const unsigned short normal_i2c[] = {
 #define R2DF_MASK (0x01 << (R2DF_SHIFT))
 #define R1FE_MASK 0x01
 #define R2FE_MASK 0x05
+#define R1DM 0x01
+#define R2DM 0x02
 #define TT1_SHIFT 0
 #define TT2_SHIFT 4
 #define TT_OFF 0
@@ -97,7 +99,7 @@ struct lm95241_data {
char valid; /* zero until following fields are valid */
/* registers values */
u8 temp[ARRAY_SIZE(lm95241_reg_address)];
-   u8 config, model, trutherm;
+   u8 status, config, model, trutherm;
 };
 
 /* Conversions */
@@ -130,6 +132,9 @@ static struct lm95241_data *lm95241_update_device(struct 
device *dev)
data->temp[i]
  = i2c_smbus_read_byte_data(client,
 lm95241_reg_address[i]);
+
+   data->status = i2c_smbus_read_byte_data(client,
+   LM95241_REG_R_STATUS);
data->last_updated = jiffies;
data->valid = 1;
}
@@ -274,6 +279,15 @@ static ssize_t set_max(struct device *dev, struct 
device_attribute *attr,
return count;
 }
 
+static ssize_t show_fault(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   struct lm95241_data *data = lm95241_update_device(dev);
+
+   return snprintf(buf, PAGE_SIZE - 1, "%d",
+   !!(data->status & to_sensor_dev_attr(attr)->index));
+}
+
 static ssize_t show_interval(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
@@ -335,6 +349,8 @@ static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, 
show_max, set_max,
  R1DF_MASK);
 static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max, set_max,
  R2DF_MASK);
+static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_fault, NULL, R1DM);
+static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_fault, NULL, R2DM);
 static DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO, show_interval,
   set_interval);
 
@@ -348,6 +364,8 @@ static struct attribute *lm95241_attrs[] = {
&sensor_dev_attr_temp3_min.dev_attr.attr,
&sensor_dev_attr_temp2_max.dev_attr.attr,
&sensor_dev_attr_temp3_max.dev_attr.attr,
+   &sensor_dev_attr_temp2_fault.dev_attr.attr,
+   &sensor_dev_attr_temp3_fault.dev_attr.attr,
&dev_attr_update_interval.attr,
NULL
 };
-- 
2.5.0



[PATCH 1/6] hwmon: (lm95241) Fix overflow problems, write conversion rate to chip

2016-08-07 Thread Guenter Roeck
Writing the update_interval attribute could result in an overflow if
a number close to the maximum unsigned long was written. At the same
time, even though the chip supports setting the conversion rate,
the selected conversion rate was not actually written to the chip.

Fix the second problem by selecting valid (supported) conversion rates,
and writing the selected conversion rate to the chip. This also fixes the
first problem, since arbitrary conversion rates are now converted to
actually supported conversion rates.

Also, set the default chip conversion rate to 1 second. Previously, the
chip was configured for continuous conversion, but readings were only
retrieved every seond, which doesn't make much sense. If we only read a
value from the chip every second, we can as well save some power and only
convert in one-second intervals.

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/lm95241.c | 40 +---
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index cdf19adaec79..a8cf666fe661 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -59,6 +59,7 @@ static const unsigned short normal_i2c[] = {
 #define CFG_CR0182 0x10
 #define CFG_CR1000 0x20
 #define CFG_CR2700 0x30
+#define CFG_CRMASK 0x30
 #define R1MS_SHIFT 0
 #define R2MS_SHIFT 2
 #define R1MS_MASK (0x01 << (R1MS_SHIFT))
@@ -91,7 +92,8 @@ static const u8 lm95241_reg_address[] = {
 struct lm95241_data {
struct i2c_client *client;
struct mutex update_lock;
-   unsigned long last_updated, interval;   /* in jiffies */
+   unsigned long last_updated; /* in jiffies */
+   unsigned long interval; /* in milli-seconds */
char valid; /* zero until following fields are valid */
/* registers values */
u8 temp[ARRAY_SIZE(lm95241_reg_address)];
@@ -118,7 +120,8 @@ static struct lm95241_data *lm95241_update_device(struct 
device *dev)
 
mutex_lock(&data->update_lock);
 
-   if (time_after(jiffies, data->last_updated + data->interval) ||
+   if (time_after(jiffies, data->last_updated
+  + msecs_to_jiffies(data->interval)) ||
!data->valid) {
int i;
 
@@ -276,8 +279,7 @@ static ssize_t show_interval(struct device *dev, struct 
device_attribute *attr,
 {
struct lm95241_data *data = lm95241_update_device(dev);
 
-   return snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->interval
-   / HZ);
+   return snprintf(buf, PAGE_SIZE - 1, "%lu\n", data->interval);
 }
 
 static ssize_t set_interval(struct device *dev, struct device_attribute *attr,
@@ -285,11 +287,35 @@ static ssize_t set_interval(struct device *dev, struct 
device_attribute *attr,
 {
struct lm95241_data *data = dev_get_drvdata(dev);
unsigned long val;
+   int convrate;
+   u8 config;
 
if (kstrtoul(buf, 10, &val) < 0)
return -EINVAL;
 
-   data->interval = val * HZ / 1000;
+   mutex_lock(&data->update_lock);
+
+   config = data->config & ~CFG_CRMASK;
+
+   if (val < 130) {
+   convrate = 76;
+   config |= CFG_CR0076;
+   } else if (val < 590) {
+   convrate = 182;
+   config |= CFG_CR0182;
+   } else if (val < 1850) {
+   convrate = 1000;
+   config |= CFG_CR1000;
+   } else {
+   convrate = 2700;
+   config |= CFG_CR2700;
+   }
+
+   data->interval = convrate;
+   data->config = config;
+   i2c_smbus_write_byte_data(data->client, LM95241_REG_RW_CONFIG,
+ config);
+   mutex_unlock(&data->update_lock);
 
return count;
 }
@@ -362,8 +388,8 @@ static int lm95241_detect(struct i2c_client *new_client,
 static void lm95241_init_client(struct i2c_client *client,
struct lm95241_data *data)
 {
-   data->interval = HZ;/* 1 sec default */
-   data->config = CFG_CR0076;
+   data->interval = 1000;
+   data->config = CFG_CR1000;
data->trutherm = (TT_OFF << TT1_SHIFT) | (TT_OFF << TT2_SHIFT);
 
i2c_smbus_write_byte_data(client, LM95241_REG_RW_CONFIG, data->config);
-- 
2.5.0



[PATCH 5/6] hwmon: (lm95241) Use BIT macro where appropriate

2016-08-07 Thread Guenter Roeck
Drop some of the SHIFT defines since shift is implied with BIT().

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/lm95241.c | 45 +
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index 507b32b67974..df94f486b21c 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -17,6 +17,7 @@
  * GNU General Public License for more details.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -50,29 +51,25 @@ static const unsigned short normal_i2c[] = {
 #define LM95241_REG_RW_REMOTE_MODEL0x30
 
 /* LM95241 specific bitfields */
-#define CFG_STOP 0x40
-#define CFG_CR0076 0x00
-#define CFG_CR0182 0x10
-#define CFG_CR1000 0x20
-#define CFG_CR2700 0x30
-#define CFG_CRMASK 0x30
-#define R1MS_SHIFT 0
-#define R2MS_SHIFT 2
-#define R1MS_MASK (0x01 << (R1MS_SHIFT))
-#define R2MS_MASK (0x01 << (R2MS_SHIFT))
-#define R1DF_SHIFT 1
-#define R2DF_SHIFT 2
-#define R1DF_MASK (0x01 << (R1DF_SHIFT))
-#define R2DF_MASK (0x01 << (R2DF_SHIFT))
-#define R1FE_MASK 0x01
-#define R2FE_MASK 0x05
-#define R1DM 0x01
-#define R2DM 0x02
-#define TT1_SHIFT 0
-#define TT2_SHIFT 4
-#define TT_OFF 0
-#define TT_ON 1
-#define TT_MASK 7
+#define CFG_STOP   BIT(6)
+#define CFG_CR0076 0x00
+#define CFG_CR0182 BIT(4)
+#define CFG_CR1000 BIT(5)
+#define CFG_CR2700 (BIT(4) | BIT(5))
+#define CFG_CRMASK (BIT(4) | BIT(5))
+#define R1MS_MASK  BIT(0)
+#define R2MS_MASK  BIT(2)
+#define R1DF_MASK  BIT(1)
+#define R2DF_MASK  BIT(2)
+#define R1FE_MASK  BIT(0)
+#define R2FE_MASK  BIT(2)
+#define R1DM   BIT(0)
+#define R2DM   BIT(1)
+#define TT1_SHIFT  0
+#define TT2_SHIFT  4
+#define TT_OFF 0
+#define TT_ON  1
+#define TT_MASK7
 #define NATSEMI_MAN_ID 0x01
 #define LM95231_CHIP_ID0xA1
 #define LM95241_CHIP_ID0xA4
@@ -148,7 +145,7 @@ static ssize_t show_input(struct device *dev, struct 
device_attribute *attr,
int index = to_sensor_dev_attr(attr)->index;
 
return snprintf(buf, PAGE_SIZE - 1, "%d\n",
-   index == 0 || (data->config & (1 << (index / 2))) ?
+   index == 0 || (data->config & BIT(index / 2)) ?
temp_from_reg_signed(data->temp[index], data->temp[index + 1]) :
temp_from_reg_unsigned(data->temp[index],
   data->temp[index + 1]));
-- 
2.5.0



Re: [PATCH v2] x86/power/64: Support unaligned addresses for temporary mapping

2016-08-07 Thread Rafael J. Wysocki
On Saturday, August 06, 2016 09:53:50 PM Yinghai Lu wrote:
> On Sat, Aug 6, 2016 at 6:03 PM, Rafael J. Wysocki  wrote:
> > On Wednesday, August 03, 2016 11:28:48 PM Rafael J. Wysocki wrote:
> >
> > On a second thought, it seems to be better to follow your suggestion to 
> > simply
> > provide a special version of kernel_ident_mapping_init() for hibernation,
> > because it is sufficiently distinct from the other users of the code in
> > ident_map.c.
> >
> > The patch below does just that (lightly tested).
> >
> >
> > ---
> > From: Rafael J. Wysocki 
> > Subject: [PATCH] x86/power/64: Always create temporary identity mapping 
> > correctly
> >
> > The low-level resume-from-hibernation code on x86-64 uses
> > kernel_ident_mapping_init() to create the temoprary identity mapping,
> > but that function assumes that the offset between kernel virtual
> > addresses and physical addresses is aligned on the PGD level.
> >
> > However, with a randomized identity mapping base, it may be aligned
> > on the PUD level and if that happens, the temporary identity mapping
> > created by set_up_temporary_mappings() will not reflect the actual
> > kernel identity mapping and the image restoration will fail as a
> > result (leading to a kernel panic most of the time).
> >
> > To fix this problem, provide simplified routines for creating the
> > temporary identity mapping during resume from hibernation on x86-64
> > that support unaligned offsets between KVA and PA up to the PMD
> > level.
> >
> > Although kernel_ident_mapping_init() might be made work in that
> > case too, using hibernation-specific code for that is way simpler.
> >
> > Reported-by: Thomas Garnier 
> > Suggested-by: Yinghai Lu 
> > Signed-off-by: Rafael J. Wysocki 
> > ---
> >  arch/x86/power/hibernate_64.c |   61 
> > --
> >  1 file changed, 53 insertions(+), 8 deletions(-)
> >
> > Index: linux-pm/arch/x86/power/hibernate_64.c
> > ===
> > --- linux-pm.orig/arch/x86/power/hibernate_64.c
> > +++ linux-pm/arch/x86/power/hibernate_64.c
> > @@ -77,18 +77,63 @@ static int set_up_temporary_text_mapping
> > return 0;
> >  }
> >
> > -static void *alloc_pgt_page(void *context)
> > +static void ident_pmd_init(pmd_t *pmd, unsigned long addr, unsigned long 
> > end)
> >  {
> > -   return (void *)get_safe_page(GFP_ATOMIC);
> > +   for (; addr < end; addr += PMD_SIZE)
> > +   set_pmd(pmd + pmd_index(addr),
> > +   __pmd((addr - __PAGE_OFFSET) | 
> > __PAGE_KERNEL_LARGE_EXEC));
> > +}
> > +
> > +static int ident_pud_init(pud_t *pud, unsigned long addr, unsigned long 
> > end)
> > +{
> > +   unsigned long next;
> > +
> > +   for (; addr < end; addr = next) {
> > +   pmd_t *pmd;
> > +
> > +   pmd = (pmd_t *)get_safe_page(GFP_ATOMIC);
> > +   if (!pmd)
> > +   return -ENOMEM;
> > +
> > +   next = (addr & PUD_MASK) + PUD_SIZE;
> > +   if (next > end)
> > +   next = end;
> > +
> > +   ident_pmd_init(pmd, addr & PMD_MASK, next);
> > +   set_pud(pud + pud_index(addr), __pud(__pa(pmd) | 
> > _KERNPG_TABLE));
> > +   }
> > +   return 0;
> > +}
> > +
> > +static int ident_mapping_init(pgd_t *pgd, unsigned long mstart, unsigned 
> > long mend)
> > +{
> > +   unsigned long addr = mstart + __PAGE_OFFSET;
> > +   unsigned long end = mend + __PAGE_OFFSET;
> > +   unsigned long next;
> > +
> > +   for (; addr < end; addr = next) {
> > +   pud_t *pud;
> > +   int result;
> > +
> > +   pud = (pud_t *)get_safe_page(GFP_ATOMIC);
> > +   if (!pud)
> > +   return -ENOMEM;
> > +
> > +   next = (addr & PGDIR_MASK) + PGDIR_SIZE;
> > +   if (next > end)
> > +   next = end;
> > +
> > +   result = ident_pud_init(pud, addr, next);
> > +   if (result)
> > +   return result;
> > +
> > +   set_pgd(pgd + pgd_index(addr), __pgd(__pa(pud) | 
> > _KERNPG_TABLE));
> > +   }
> > +   return 0;
> >  }
> >
> >  static int set_up_temporary_mappings(void)
> >  {
> > -   struct x86_mapping_info info = {
> > -   .alloc_pgt_page = alloc_pgt_page,
> > -   .pmd_flag   = __PAGE_KERNEL_LARGE_EXEC,
> > -   .kernel_mapping = true,
> > -   };
> > unsigned long mstart, mend;
> > pgd_t *pgd;
> > int result;
> > @@ -108,7 +153,7 @@ static int set_up_temporary_mappings(voi
> > mstart = pfn_mapped[i].start << PAGE_SHIFT;
> > mend   = pfn_mapped[i].end << PAGE_SHIFT;
> >
> > -   result = kernel_ident_mapping_init(&info, pgd, mstart, 
> > mend);
> > +   result = ident_mapping_init(pgd, mstart, mend);
> > if (result)
> 

[PATCH] joystick: xpad.c, new xbox controller ID (Hori Real Arcade Pro.V)

2016-08-07 Thread Philippe PITTOLI
Hello,

I added a controller ID to the xbox driver for the Real Aracade Pro V
controller from Hori.

It's my first patch, and I followed the guidances from the
kernelnewbies.org website, I hope it'll be ok.

Thanks,

---
 drivers/input/joystick/xpad.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 83af17a..ec5a670 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -190,6 +190,7 @@ static const struct xpad_device {
{ 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick", 0, XTYPE_XBOX360 },
{ 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, 
XTYPE_XBOX360 },
{ 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, 
XTYPE_XBOX360 },
+   { 0x0f0d, 0x0063, "Hori Real Arcade Pro.V", 0, XTYPE_XBOXONE },
{ 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
{ 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
{ 0x0f30, 0x, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
-- 
2.5.0


signature.asc
Description: Digital signature


Re: [PATCH 0/7] de-stage SW_SYNC validation frawework

2016-08-07 Thread Pavel Machek
On Sun 2016-07-24 15:21:11, Greg Kroah-Hartman wrote:
> On Mon, Jul 18, 2016 at 04:12:45PM -0300, Gustavo Padovan wrote:
> > Hi,
> > 
> > Do you think there is time to get this in for 4.8?
> 
> No, it was too late on my end, due to travel and vacation, sorry.  I'll
> queue it up for 4.9-rc1.

Could we get some documentation what this does? Is it visilble to
userspace?

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


Re: [RFC PATCHv2] usb: USB Type-C Connector Class

2016-08-07 Thread Pavel Machek
Hi!

> > With these boards, you will not see anything on the screen that is
> > attached to a Type-C connector until the OS has booted to the point
> > where it has negotiated the power contract and entered a mode.
> > 
> > If the system has BIOS/FW/EC capable of negotiating the power contract
> > and enter a mode, but where we still are expected to take over the
> > whole TCPM in OS, I think the connection will be reset.
> 
> Think about a DP over type C display with a USB PD power brick on a
> daisy chain.
> If the host needs more than 15W or more than 5V, a reset is suicide.
> 
> And losing earlyprintk hurts a lot.
> This means we need USB PD statically in the kernel. And a kernel
> based policy that brings up all displays.

Yes please.

Of course, even that will hurt, because I guess that means printk()
after USB, and that means late in the boot process, but better late in
kernel than in initrd.

(And yes, N900 has display pretty late in the bootprocess, and yes, it
is very annoying.)

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


Re: [PATCH v4] watchdog: ziirave_wdt: Add support to upload the firmware.

2016-08-07 Thread Guenter Roeck

On 08/01/2016 04:39 AM, Enric Balletbo i Serra wrote:

This patch adds and entry to the sysfs to start firmware upload process
on the specified device with the requested firmware.

The uploading of the firmware needs only to happen once per firmware
upgrade, as the firmware is stored in persistent storage. If the
firmware upload or the firmware verification fails then we print and
error message and exit.

Signed-off-by: Enric Balletbo i Serra 
---


[ ... ]



+static ssize_t ziirave_wdt_sysfs_store_firm(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = to_i2c_client(dev->parent);
+   struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client);
+   const struct firmware *fw;
+   int err;
+
+   err = request_ihex_firmware(&fw, ZIIRAVE_FW_NAME, dev);
+   if (err) {
+   dev_err(&client->dev, "Failed to request ihex firmware\n");
+   return err;
+   }
+
+   err = mutex_lock_interruptible(&w_priv->sysfs_mutex);
+   if (err)
+   return err;
+

This doesn't release the firmware.


+   err = ziirave_firm_upload(&w_priv->wdd, fw);
+   if (err) {
+   dev_err(&client->dev, "The firmware update failed: %d\n", err);
+   goto release_firmware;
+   }
+
+   /* Update firmware version */
+   err = ziirave_wdt_revision(client, &w_priv->firmware_rev,
+  ZIIRAVE_WDT_FIRM_VER_MAJOR);
+   if (err) {
+   dev_err(&client->dev, "Failed to read firmware version: %d\n",
+   err);
+   goto release_firmware;
+   }
+
+   dev_info(&client->dev, "Firmware updated to version 02.%02u.%02u\n",
+w_priv->firmware_rev.major, w_priv->firmware_rev.minor);
+
+   /* Restore the watchdog timeout */
+   err = ziirave_wdt_set_timeout(&w_priv->wdd, w_priv->wdd.timeout);
+   if (err)
+   dev_err(&client->dev, "Failed to set timeout: %d\n", err);
+
+release_firmware:
+   release_firmware(fw);
+   mutex_unlock(&w_priv->sysfs_mutex);


Probably best to reverse the order of calls here, and add a second label
to release the firmware without releasing the lock (for use with the above).

Guenter



Re: [PATCH] proc: faster /proc/*/status

2016-08-07 Thread Joe Perches
On Sun, 2016-08-07 at 10:44 -0700, Andi Kleen wrote:
> > > > It is so bloated that gcc needs to be asked to not screw up with stack
> > > > size.
> > > What happens when you drop all the noinlines for this? I assume
> > > this would alread make it faster. And now that we have bigger
> > > stacks we can likely tolerate it.
> > %pV recurses through these code paths.
> > I believe the maximum current recursion depth is 3.
> I assume 2 max would sufficient for all users in kernel.
> 
> And perhaps it would be better to get rid of "features" like this,
> and instead focus on more common cases.

It'd be a dubious trade-off in my opinion.

Overall code size has been reduced by hundreds of KB
by using %pV.



[GIT PULL] Final block changes for 4.8-rc1

2016-08-07 Thread Jens Axboe

Hi Linus,

As mentioned in the pull the other day, a few more fixes for this
round, all related to the bio op changes in this series. Two fixes, and
then a cleanup, renaming bio->bi_rw to bio->bi_opf. I wanted to do that
change right after or right before -rc1, so that risk of conflict was
reduced. I just rebased the series on top of current master, and no new
->bi_rw usage has snuck in.

Please pull!


  git://git.kernel.dk/linux-block.git for-linus



Jens Axboe (4):
  block/mm: make bdev_ops->rw_page() take a bool for read/write
  mm: make __swap_writepage() use bio_set_op_attrs()
  target: iblock_execute_sync_cache() should use bio_set_op_attrs()
  block: rename bio bi_rw to bi_opf

 Documentation/block/biodoc.txt|  4 ++--
 Documentation/device-mapper/dm-flakey.txt |  2 +-
 block/bio-integrity.c |  2 +-
 block/bio.c   |  6 ++---
 block/blk-core.c  | 26 +++---
 block/blk-merge.c |  8 +++
 block/blk-mq.c| 10 -
 block/blk-throttle.c  |  8 +++
 block/cfq-iosched.c   |  4 ++--
 drivers/block/brd.c   | 16 ++---
 drivers/block/drbd/drbd_main.c|  8 +++
 drivers/block/drbd/drbd_receiver.c|  2 +-
 drivers/block/drbd/drbd_req.c |  6 ++---
 drivers/block/drbd/drbd_worker.c  |  2 +-
 drivers/block/pktcdvd.c   |  2 +-
 drivers/block/umem.c  |  2 +-
 drivers/block/zram/zram_drv.c | 23 ++-
 drivers/md/bcache/request.c   | 12 +-
 drivers/md/bcache/super.c |  2 +-
 drivers/md/bcache/writeback.h |  2 +-
 drivers/md/dm-cache-target.c  |  8 +++
 drivers/md/dm-crypt.c |  4 ++--
 drivers/md/dm-era-target.c|  2 +-
 drivers/md/dm-flakey.c|  6 ++---
 drivers/md/dm-io.c|  6 ++---
 drivers/md/dm-log-writes.c|  4 ++--
 drivers/md/dm-mpath.c |  2 +-
 drivers/md/dm-raid1.c | 10 -
 drivers/md/dm-region-hash.c   |  4 ++--
 drivers/md/dm-snap.c  |  6 ++---
 drivers/md/dm-stripe.c|  4 ++--
 drivers/md/dm-thin.c  |  8 +++
 drivers/md/dm-zero.c  |  2 +-
 drivers/md/dm.c   | 10 -
 drivers/md/linear.c   |  2 +-
 drivers/md/md.c   |  4 ++--
 drivers/md/multipath.c|  8 +++
 drivers/md/raid0.c|  2 +-
 drivers/md/raid1.c|  6 ++---
 drivers/md/raid10.c   |  8 +++
 drivers/md/raid5-cache.c  |  2 +-
 drivers/md/raid5.c| 20 -
 drivers/nvdimm/btt.c  | 12 +-
 drivers/nvdimm/pmem.c | 16 ++---
 drivers/target/target_core_iblock.c   |  2 +-
 fs/block_dev.c|  6 ++---
 fs/btrfs/check-integrity.c| 10 -
 fs/btrfs/disk-io.c|  2 +-
 fs/btrfs/inode.c  |  6 ++---
 fs/btrfs/volumes.c|  6 ++---
 fs/mpage.c|  2 +-
 include/linux/bio.h   |  4 ++--
 include/linux/blk-cgroup.h|  4 ++--
 include/linux/blk_types.h | 37 
---

 include/linux/blkdev.h|  2 +-
 include/linux/fs.h|  3 +--
 include/linux/pagemap.h   |  2 +-
 include/trace/events/bcache.h |  8 +++
 include/trace/events/block.h  | 14 ++--
 kernel/trace/blktrace.c   |  6 ++---
 mm/filemap.c  |  4 ++--
 mm/page_io.c  |  5 +++--
 62 files changed, 213 insertions(+), 213 deletions(-)

--
Jens Axboe



Re: [PATCH] scripts: Translate profile2linkerlist.

2016-08-07 Thread Michal Marek
Dne 7.8.2016 v 20:33 Jorge Natz napsal(a):
> -while (<>) {
> -  my $line = $_;
> -
> -  $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
> -
> -  print "*(.text.$1)\n"
[...]
> + LINE=$( echo $LINE | sed -e s"/[0-9.][0-9.]*//" -e s"/[0-9.][0-9.]*$//" 
> | xargs)
> + case $LINE in *unknown*|*total* ) continue
> + ;;
> + esac
> + echo '*(.text.'$LINE')'
> +done

The two regular expressions are not equivalent and the shell version
does not take into account the locale-dependent decimal separator. It
also does not handle localized "total", but that's an issue of the perl
version as well. Since this script is not used during kernel build, its
dependency on perl is less of an issue and it can be left as is.

Michal


Re: [PATCH v2 3/4] perf/core: introduce PMU_EV_CAP_READ_ACTIVE_PKG

2016-08-07 Thread David Carrillo-Cisneros
Hi Nilay,

>>  static int perf_event_read(struct perf_event *event, bool group)
>>  {
>> -   int ret = 0;
>> +   int ret = 0, cpu_to_read;
>>
>> -   /*
>> -* If event is enabled and currently active on a CPU, update the
>> -* value in the event structure:
>> -*/
>> -   if (event->state == PERF_EVENT_STATE_ACTIVE) {
>> +   cpu_to_read = find_cpu_to_read(event);
>> +
>> +   if (cpu_to_read >= 0) {
>> struct perf_read_data data = {
>> .event = event,
>> .group = group,
>> .ret = 0,
>> };
>> -   ret = smp_call_function_single(event->oncpu,
>> +   ret = smp_call_function_single(cpu_to_read,
>>__perf_event_read, &data,
>> 1);
>> ret = ret ? : data.ret;
>> } else if (event->state == PERF_EVENT_STATE_INACTIVE) {
>>
>
> I would like to suggest a small change to this patch.  I think the check on
> PERF_EVENT_STATE_ACTIVE should be retained in the perf_event_read()
> function.  The new function should assume that the event is active.  I find
> this more readable since the next check in function perf_event_read() is on
> PERF_EVENT_STATE_INACTIVE.

Two oncoming flags that Intel CQM/CMT will use are meant to allow read
even if event is inactive. This makes sense in CQM/CMT because the hw
RMID is always reserved. I am ok with keeping the check for
STATE_ACTIVE until those flags are actually introduced, tough.


Re: [PATCH] mfd: syscon: Make use of of_iomap

2016-08-07 Thread Arnd Bergmann
On Sunday, August 7, 2016 10:08:19 AM CEST Andrey Smirnov wrote:
> Use of_iomap instead of explicitly calling of_address_to_resource() and
> ioremap().
> 
> Signed-off-by: Andrey Smirnov 
> 

Acked-by: Arnd Bergmann 


[PATCH v2] mtd: spi-nor: Add s25fs256s1 spi-nor flash support

2016-08-07 Thread Jagan Teki
Add Spansion s25fs256s1 spi-nor flash to the list of spi_nor_ids.

In spansion S25FS-S family the physical sectors are grouped as
normal and parameter sectors. Parameter sectors are 4kB in size
with 8 set located at the bottom or top address of a device.
Normal sectors are similar to other flash family with sizes of
64kB or 32 kB.

To erase whole flash using sector erase(D8h or DCh) won't effect
the parameter sectors, so in order to erase these we must use 4K
sector erase commands (20h or 21h) separately.

So better to erase the whole flash using 4K sector erase instead
of detecting these family parts again and do two different erase
operations.

Cc: Brian Norris 
Cc: Yunhui Cui 
Cc: Michael Trimarchi 
Signed-off-by: Jagan Teki 
---
Changes for v2:
- Fix wrong vendor name in commit message

 drivers/mtd/spi-nor/spi-nor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index d0fc165..6ad7779 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -901,6 +901,7 @@ static const struct flash_info spi_nor_ids[] = {
{ "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
{ "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+   { "s25fs256s1", INFO6(0x010219, 0x4d0181, 64 * 1024, 512, SECT_4K) },
{ "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ "s70fl01gs",  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
-- 
2.7.4



Re: [PATCH v2 3/4] perf/core: introduce PMU_EV_CAP_READ_ACTIVE_PKG

2016-08-07 Thread Nilay Vaish

On 08/06/16 22:12, David Carrillo-Cisneros wrote:

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 34049cc..77f1bd3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -,6 +,26 @@ struct perf_read_data {
int ret;
 };

+static int find_cpu_to_read(struct perf_event *event)
+{
+   bool active = event->state == PERF_EVENT_STATE_ACTIVE;
+   int event_cpu = event->oncpu, local_cpu = smp_processor_id();
+   u16 local_pkg, event_pkg;
+
+   if (!active)
+   return -1;
+
+   if (event->group_caps & PERF_EV_CAP_READ_ACTIVE_PKG) {
+   event_pkg =  topology_physical_package_id(event_cpu);
+   local_pkg =  topology_physical_package_id(local_cpu);
+
+   if (event_pkg == local_pkg)
+   return local_cpu;
+   }
+
+   return event_cpu;
+}
+
 /*
  * Cross CPU call to read the hardware event
  */
@@ -3454,19 +3474,17 @@ u64 perf_event_read_local(struct perf_event *event)

 static int perf_event_read(struct perf_event *event, bool group)
 {
-   int ret = 0;
+   int ret = 0, cpu_to_read;

-   /*
-* If event is enabled and currently active on a CPU, update the
-* value in the event structure:
-*/
-   if (event->state == PERF_EVENT_STATE_ACTIVE) {
+   cpu_to_read = find_cpu_to_read(event);
+
+   if (cpu_to_read >= 0) {
struct perf_read_data data = {
.event = event,
.group = group,
.ret = 0,
};
-   ret = smp_call_function_single(event->oncpu,
+   ret = smp_call_function_single(cpu_to_read,
   __perf_event_read, &data, 1);
ret = ret ? : data.ret;
} else if (event->state == PERF_EVENT_STATE_INACTIVE) {



I would like to suggest a small change to this patch.  I think the check 
on PERF_EVENT_STATE_ACTIVE should be retained in the perf_event_read() 
function.  The new function should assume that the event is active.  I 
find this more readable since the next check in function 
perf_event_read() is on PERF_EVENT_STATE_INACTIVE.



Diff below:

+static int find_cpu_to_read(struct perf_event *event)
+{
+int event_cpu = event->oncpu, local_cpu = smp_processor_id();
+u16 local_pkg, event_pkg;
+
+if (event->group_caps & PERF_EV_CAP_READ_ACTIVE_PKG) {
+event_pkg = topology_physical_package_id(event_cpu);
+local_pkg = topology_physical_package_id(local_cpu);
+
+if (event_pkg == local_pkg)
+return local_cpu;
+}
+
+return event_cpu;
+}
+
 /*
  * Cross CPU call to read the hardware event
  */
@@ -3477,17 +3493,15 @@ static int perf_event_read(struct perf_event 
*event, bool group)

 {
int ret = 0;

-   /*
-* If event is enabled and currently active on a CPU, update the
-* value in the event structure:
-*/
-   if (event->state == PERF_EVENT_STATE_ACTIVE) {
+   if (event->state == PERF_EVENT_STATE_ACTIVE) {
+   int cpu_to_read = find_cpu_to_read(event);
+
struct perf_read_data data = {
.event = event,
.group = group,
.ret = 0,
};
-   ret = smp_call_function_single(event->oncpu,
+   ret = smp_call_function_single(cpu_to_read,
   __perf_event_read, 
&data, 1);

ret = ret ? : data.ret;
} else if (event->state == PERF_EVENT_STATE_INACTIVE) {



[PATCH] dmaengine: pxa_dma: fix hotchain corner case

2016-08-07 Thread Robert Jarzmik
In the case where a descriptor is chained on a running channel, and as
explained in the comment in the code 10 lines above, the success of the
chaining is ensured either if :
 - the DMA is still running
 - or if the chained transfer is completed

Unfortunately the transfer completness test was done on the descriptor
to which the transfer was chained, and not the transfer being chained at
the end, ie. hot-chained.

This corner case is extremely hard to trigger, as usually the DMA chain
is still running, and the first case takes care of returning success of
the hot-chaining. It was seen by hot-chaining several "small transfers"
to a running "big transfer", not in a real-life usecase but by testing
the robustness of the driver.

Signed-off-by: Robert Jarzmik 
---
 drivers/dma/pxa_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index e756a30ccba2..64758daa9eee 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -635,7 +635,7 @@ static bool pxad_try_hotchain(struct virt_dma_chan *vc,
vd_last_issued = list_entry(vc->desc_issued.prev,
struct virt_dma_desc, node);
pxad_desc_chain(vd_last_issued, vd);
-   if (is_chan_running(chan) || is_desc_completed(vd_last_issued))
+   if (is_chan_running(chan) || is_desc_completed(vd))
return true;
}
 
-- 
2.1.4



[PATCH] dmaengine: pxa_dma: fix debug message

2016-08-07 Thread Robert Jarzmik
In a very tight timeframe, the debug message in the transfer completion
handler can be misleading, as the completion test report can change just
after the message, and the code flow cannot be deduced from the debug
message.

This is just a cleanup to make debugging easier.

Signed-off-by: Robert Jarzmik 
---
 drivers/dma/pxa_dma.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 64758daa9eee..b7414c5c9932 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -668,6 +668,7 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id)
struct virt_dma_desc *vd, *tmp;
unsigned int dcsr;
unsigned long flags;
+   bool vd_completed;
dma_cookie_t last_started = 0;
 
BUG_ON(!chan);
@@ -678,15 +679,17 @@ static irqreturn_t pxad_chan_handler(int irq, void 
*dev_id)
 
spin_lock_irqsave(&chan->vc.lock, flags);
list_for_each_entry_safe(vd, tmp, &chan->vc.desc_issued, node) {
+   vd_completed = is_desc_completed(vd);
dev_dbg(&chan->vc.chan.dev->device,
-   "%s(): checking txd %p[%x]: completed=%d\n",
-   __func__, vd, vd->tx.cookie, is_desc_completed(vd));
+   "%s(): checking txd %p[%x]: completed=%d dcsr=0x%x\n",
+   __func__, vd, vd->tx.cookie, vd_completed,
+   dcsr);
last_started = vd->tx.cookie;
if (to_pxad_sw_desc(vd)->cyclic) {
vchan_cyclic_callback(vd);
break;
}
-   if (is_desc_completed(vd)) {
+   if (vd_completed) {
list_del(&vd->node);
vchan_cookie_complete(vd);
} else {
-- 
2.1.4



[PATCH] mtd: spi-nor: Add s25fs256s1 spi-nor flash support

2016-08-07 Thread Jagan Teki
Add Atmel s25fs256s1 spi-nor flash to the list of spi_nor_ids.

In spansion S25FS-S family the physical sectors are grouped as
normal and parameter sectors. Parameter sectors are 4kB in size
with 8 set located at the bottom or top address of a device.
Normal sectors are similar to other flash family with sizes of
64kB or 32 kB.

To erase whole flash using sector erase(D8h or DCh) won't effect
the parameter sectors, so in order to erase these we must use 4K
sector erase commands (20h or 21h) separately.

So better to erase the whole flash using 4K sector erase instead
of detecting these family parts again and do two different erase
operations.

Cc: Brian Norris 
Cc: Yunhui Cui 
Cc: Michael Trimarchi 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index d0fc165..6ad7779 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -901,6 +901,7 @@ static const struct flash_info spi_nor_ids[] = {
{ "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
{ "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+   { "s25fs256s1", INFO6(0x010219, 0x4d0181, 64 * 1024, 512, SECT_4K) },
{ "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ "s70fl01gs",  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
-- 
2.7.4



[PATCH] scripts: Translate profile2linkerlist.

2016-08-07 Thread Jorge Natz

profile2linkerlist.pl is a script that takes the sorted output of the 
readprofile command and turns it into a list of C functions in a 
format for linker lists. Make the script more portable across POSIX 
systems. This script does not use any shell-specific features, only 
POSIX ones. A POSIX shell is present on all UNIX systems, while Perl 
is not as commonplace.

Signed-off-by: Jorge Natz 
---
diff -uprN a/scripts/profile2linkerlist.pl b/scripts/profile2linkerlist.pl
--- a/scripts/profile2linkerlist.pl 2016-06-10 17:27:15.17028 -0600
+++ b/scripts/profile2linkerlist.pl 1969-12-31 17:00:00.0 -0700
@@ -1,19 +0,0 @@
-#!/usr/bin/perl
-
-#
-# Takes a (sorted) output of readprofile and turns it into a list suitable for
-# linker scripts
-#
-# usage:
-#   readprofile | sort -rn | perl profile2linkerlist.pl > functionlist
-#
-use strict;
-
-while (<>) {
-  my $line = $_;
-
-  $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
-
-  print "*(.text.$1)\n"
-  unless ($line =~ /unknown/) || ($line =~ /total/);
-}
diff -uprN a/scripts/profile2linkerlist.sh b/scripts/profile2linkerlist.sh
--- a/scripts/profile2linkerlist.sh 1969-12-31 17:00:00.0 -0700
+++ b/scripts/profile2linkerlist.sh 2016-03-24 17:26:58.044958415 -0600
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Takes a (sorted) output of readprofile and turns it into a list suitable for
+# linker scripts.
+#
+# usage:
+# readprofile | sort -rn | ./profile2linkerlist.sh > functionlist
+
+# Exit on error
+set -e
+
+while read LINE; do
+   LINE=$( echo $LINE | sed -e s"/[0-9.][0-9.]*//" -e s"/[0-9.][0-9.]*$//" 
| xargs)
+   case $LINE in *unknown*|*total* ) continue
+   ;;
+   esac
+   echo '*(.text.'$LINE')'
+done



Charity Project !!!

2016-08-07 Thread Friedrich And Annand Mayrhofer
My wife and I have awarded you with a donation of $ 1,000,000.00 Dollars from 
part of our Jackpot Lottery of 50 Million Dollars, respond with your  
details for claims.

We await your earliest response and God Bless you.

Friedrich And Annand Mayrhofer.


Re: [PATCH v2 1/3] ntb: Add asynchronous devices support to NTB-bus interface

2016-08-07 Thread Serge Semin
Hello Allen.

Thanks for your careful review. Going through this mailing thread I hope we'll 
come up with solutions, which improve the driver code as well as extend the 
Linux kernel support of new devices like IDT PCIe-swtiches.

Before getting to the inline commentaries I need to give some introduction to 
the IDT NTB-related hardware so we could speak on the same language. 
Additionally I'll give a brief explanation how the setup of memory windows 
works in IDT PCIe-switches.

First of all, before getting into the IDT NTB driver development I had made a 
research of the currently developed NTB kernel API and AMD/Intel hardware 
drivers. Due to lack of the hardware manuals It might be not in deep details, 
but I understand how the AMD/Intel NTB-hardware drivers work. At least I 
understand the concept of memory windowing, which led to the current NTB bus 
kernel API.

So lets get to IDT PCIe-switches. There is a whole series of NTB-related 
switches IDT produces. All of them I split into two distinct groups:
1) Two NTB-ported switches (models 89PES8NT2, 89PES16NT2, 89PES12NT3, 
89PES124NT3),
2) Multi NTB-ported switches (models 89HPES24NT6AG2, 89HPES32NT8AG2, 
89HPES32NT8BG2, 89HPES12NT12G2, 89HPES16NT16G2, 89HPES24NT24G2, 
89HPES32NT24AG2, 89HPES32NT24BG2).
Just to note all of these switches are a part of IDT PRECISE(TM) family of PCI 
Express® switching solutions. Why do I split them up? Because of the next 
reasons:
1) Number of upstream ports, which have access to NTB functions (obviously, 
yeah? =)). So the switches of the first group can connect just two domains over 
NTB. Unlike the second group of switches, which expose a way to setup an 
interaction between several PCIe-switch ports, which have NT-function activated.
2) The groups are significantly distinct by the way of NT-functions 
configuration.

Before getting further, I should note, that the uploaded driver supports the 
second group of devices only. But still I'll give a comparative explanation, 
since the first group of switches is very similar to the AMD/Intel NTBs.

Lets dive into the configurations a bit deeper. Particularly NT-functions of 
the first group of switches can be configured the same way as AMD/Intel 
NTB-functions are. There is an PCIe end-point configuration space, which fully 
reflects the cross-coupled local and peer PCIe/NTB settings. So local Root 
complex can set any of the peer registers by direct writing to mapped memory. 
Here is the image, which perfectly explains the configuration registers mapping:
https://s8.postimg.org/3nhkzqfxx/IDT_NTB_old_configspace.png
Since the first group switches connect only two root complexes, the race 
condition of read/write operations to cross-coupled registers can be easily 
resolved just by roles distribution. So local root complex sets the translated 
base address directly to a peer configuration space registers, which correspond 
to BAR0-BAR3 locally mapped memory windows. Of course 2-4 memory windows is 
enough to connect just two domains. That's why you made the NTB bus kernel API 
the way it is.

The things get different when one wants to have an access from one domain to 
multiple coupling up to eight root complexes in the second group of switches. 
First of all the hardware doesn't support the configuration space 
cross-coupling anymore. Instead there are two Global Address Space Access 
registers provided to have an access to a peers configuration space. In fact it 
is not a big problem, since there are no much differences in accessing 
registers over a memory mapped space or a pair of fixed Address/Data registers. 
The problem arises when one wants to share a memory windows between eight 
domains. Five BARs are not enough for it even if they'd be configured to be of 
x32 address type. Instead IDT introduces Lookup table address translation. So 
BAR2/BAR4 can be configured to translate addresses using 12 or 24 entries 
lookup tables. Each entry can be initialized with translated base address of a 
peer and IDT switch port, which peer is connected to. So when local root 
complex locally maps BAR2/BAR4, one can have an access to a memory of a peer 
just by reading/writing with a shift corresponding to the lookup table entry. 
That's how more than five peers can be accessed. The root problem is the way 
the lookup table is accessed. Alas It is accessed only by a pair of "Entry 
index/Data" registers. So a root complex must write an entry index to one 
registers, then read/write data from another. As you might realise, that weak 
point leads to a race condition of multiple root complexes accessing the lookup 
table of one shared peer. Alas I could not come up with a simple and strong 
solution of the race.

That's why I've introduced the asynchronous hardware in the NTB bus kernel API. 
Since local root complex can't directly write a translated base address to a 
peer, it must wait until a peer asks him to allocate a memory and send the 
address back using some of a hardwa

Re: [PATCH] proc: faster /proc/*/status

2016-08-07 Thread Andi Kleen
> > > It is so bloated that gcc needs to be asked to not screw up with stack
> > > size.
> > What happens when you drop all the noinlines for this? I assume
> > this would alread make it faster. And now that we have bigger
> > stacks we can likely tolerate it.
> 
> %pV recurses through these code paths.
> I believe the maximum current recursion depth is 3.

I assume 2 max would sufficient for all users in kernel.

And perhaps it would be better to get rid of "features" like this,
and instead focus on more common cases.

-Andi

-- 
a...@linux.intel.com -- Speaking for myself only.


  1   2   >