Re: [PATCH v2 0/2] Improve drm_of_component_probe() and move rockchip to use it

2015-12-23 Thread Jean-Francois Moine
On Tue, 22 Dec 2015 17:38:00 +
Liviu Dudau  wrote:

> On Fri, Nov 20, 2015 at 02:22:03PM +, Liviu Dudau wrote:
> > Hello,
> > 
> > This is v2 of the patchset trying to make drm_of_component_probe() cope 
> > with finding
> > both local crtc ports and remote encoder ones. Heiko Stübner was nice 
> > enough to test
> > an earlier version that was patched following Russell's suggestions on 
> > rk3288, but
> > I haven't seen any reports from iMX or Armada users.
> > 
> > Changelog:
> >  v2: Updated the drm_of_component_probe() comment to explain why the 
> > reference count
> >  is not dropped. Fixed the compare_port() function for rockchip as 
> > described by
> >  Russell.
> >  v1: Original submission. 
> > http://lists.freedesktop.org/archives/dri-devel/2015-November/094546.html
> 
> Gentle ping, this has now been tested by Rockchip people and fixes the 
> earlier version
> that had to be reverted in mainline. Can it be included in the -next 
> somewhere?

Hi Liviu,

Sorry for being a bit late.

I wanted to use drm_of_component_probe() for a new DRM driver, but I
could not find any way to do it: you add the "ports" nodes as
components while, usually, the components are the device nodes
themselves.

With this simple patch:

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 493c05c..dbd2921 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -101,7 +101,7 @@ int drm_of_component_probe(struct device *dev,
continue;
}
 
-   component_match_add(dev, , compare_of, port);
+   component_match_add(dev, , compare_of, port->parent);
of_node_put(port);
}
 
everything is easy, my DT being like:

de_controller {
...
ports = <_p>;
};

lcd_controller {
...
lcd0_p: port {
lcd0_ep: endpoint {
remote-endpoint = <_ep>;
};
};
};

What was the reason to keep the "ports" node instead of the device?

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] [PATCH] staging: lustre: Remove unused memhog functionality

2015-12-23 Thread Dighe, Niranjan (N.)
From: Niranjan Dighe 

Remove IOC_LIBCFS_MEMHOG ioctl functionality as it is no longer needed thereby
making functions like - kportal_memhog_alloc(), kportal_memhog_free() and type -
struct libcfs_device_userstate unused.

Signed-off-by: Niranjan Dighe 
---
 .../lustre/include/linux/libcfs/libcfs_private.h   |5 -
 .../lustre/lustre/libcfs/linux/linux-module.c  |   14 +-
 drivers/staging/lustre/lustre/libcfs/module.c  |  139 
 3 files changed, 2 insertions(+), 156 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index d6273e1..e044d6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -391,11 +391,6 @@ int cfs_percpt_atomic_summary(atomic_t **refs);
  * Support for temporary event tracing with minimal Heisenberg effect.
  *  */
 
-struct libcfs_device_userstate {
-   intldu_memhog_pages;
-   struct page   *ldu_memhog_root_page;
-};
-
 #define MKSTR(ptr) ((ptr)) ? (ptr) : ""
 
 static inline int cfs_size_round4(int val)
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c 
b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
index 70a99cf0..eccfe8bd 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
@@ -98,14 +98,12 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size)
 static int
 libcfs_psdev_open(struct inode *inode, struct file *file)
 {
-   struct libcfs_device_userstate **pdu = NULL;
intrc = 0;
 
if (!inode)
return -EINVAL;
-   pdu = (struct libcfs_device_userstate **)>private_data;
if (libcfs_psdev_ops.p_open != NULL)
-   rc = libcfs_psdev_ops.p_open(0, (void *)pdu);
+   rc = libcfs_psdev_ops.p_open(0, NULL);
else
return -EPERM;
return rc;
@@ -115,14 +113,12 @@ libcfs_psdev_open(struct inode *inode, struct file *file)
 static int
 libcfs_psdev_release(struct inode *inode, struct file *file)
 {
-   struct libcfs_device_userstate *pdu;
intrc = 0;
 
if (!inode)
return -EINVAL;
-   pdu = file->private_data;
if (libcfs_psdev_ops.p_close != NULL)
-   rc = libcfs_psdev_ops.p_close(0, (void *)pdu);
+   rc = libcfs_psdev_ops.p_close(0, NULL);
else
rc = -EPERM;
return rc;
@@ -152,14 +148,8 @@ static long libcfs_ioctl(struct file *file,
return -EPERM;
panic("debugctl-invoked panic");
return 0;
-   case IOC_LIBCFS_MEMHOG:
-   if (!capable(CFS_CAP_SYS_ADMIN))
-   return -EPERM;
-   /* go thought */
}
 
-   pfile.off = 0;
-   pfile.private_data = file->private_data;
if (libcfs_psdev_ops.p_ioctl != NULL)
rc = libcfs_psdev_ops.p_ioctl(, cmd, (void *)arg);
else
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c 
b/drivers/staging/lustre/lustre/libcfs/module.c
index 329d78c..0067e53 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -68,142 +68,16 @@ MODULE_LICENSE("GPL");
 
 static struct dentry *lnet_debugfs_root;
 
-static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
-{
-   struct page **level0p = >ldu_memhog_root_page;
-   struct page **level1p;
-   struct page **level2p;
-   intcount1;
-   intcount2;
-
-   if (*level0p != NULL) {
-
-   level1p = (struct page **)page_address(*level0p);
-   count1 = 0;
-
-   while (count1 < PAGE_CACHE_SIZE/sizeof(struct page *) &&
-  *level1p != NULL) {
-
-   level2p = (struct page **)page_address(*level1p);
-   count2 = 0;
-
-   while (count2 < PAGE_CACHE_SIZE/sizeof(struct page *) &&
-  *level2p != NULL) {
-
-   __free_page(*level2p);
-   ldu->ldu_memhog_pages--;
-   level2p++;
-   count2++;
-   }
-
-   __free_page(*level1p);
-   ldu->ldu_memhog_pages--;
-   level1p++;
-   count1++;
-   }
-
-   __free_page(*level0p);
-   ldu->ldu_memhog_pages--;
-
-   *level0p = NULL;
-   }
-
-   LASSERT(ldu->ldu_memhog_pages == 0);
-}
-
-static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int 
npages,
-gfp_t 

Re: [PATCH V2 22/23] pci, acpi: Match PCI config space accessors against platfrom specific quirks.

2015-12-23 Thread Hanjun Guo

On 12/22/2015 10:48 PM, Gabriele Paoloni wrote:

Hi Tomasz


-Original Message-
From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
ow...@vger.kernel.org] On Behalf Of Tomasz Nowicki
Sent: 22 December 2015 10:20
To: Gabriele Paoloni; bhelg...@google.com; a...@arndb.de;
will.dea...@arm.com; catalin.mari...@arm.com; r...@rjwysocki.net;
hanjun@linaro.org; lorenzo.pieral...@arm.com; ok...@codeaurora.org;
jiang@linux.intel.com; stefano.stabell...@eu.citrix.com
Cc: robert.rich...@caviumnetworks.com; m...@semihalf.com;
liviu.du...@arm.com; dda...@caviumnetworks.com; t...@linutronix.de;
Wangyijing; suravee.suthikulpa...@amd.com; msal...@redhat.com; linux-
p...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-
a...@vger.kernel.org; linux-kernel@vger.kernel.org; linaro-
a...@lists.linaro.org; jchan...@broadcom.com; j...@redhat.com
Subject: Re: [PATCH V2 22/23] pci, acpi: Match PCI config space
accessors against platfrom specific quirks.

On 21.12.2015 12:47, Gabriele Paoloni wrote:

2) In the quirk mechanism you proposed, I see that the callback

function

 allows to do some preparation work for the host bridge. For

example in

 Hisilicon hip05 case we would need to read some values from the

ACPI

 table (see acpi_pci_root_hisi_add() function in
 https://lkml.org/lkml/2015/12/3/426).
 I am quite new to ACPI and I wonder if it is OK to add such

"Packages"

 to the  PCI host bridge ACPI device...or maybe we need to declare

a new

 one...?


I may miss sth so please correct me in that case.

https://lkml.org/lkml/2015/12/3/426 shows that you need special
handling for root->secondary.start bus number only, right? So how about
creating special MCFG region  only for
.
Like that:

[0008]   Base Address : 
[0002]   Segment Group Number : 
[0001]   Start Bus Number : secondary.start>
[0001] End Bus Number : secondary.start>
[0004]   Reserved : 


static const struct dmi_system_id hisi_quirk[] = {
{
.ident = "HiSi...",
.matches = {
DMI_MATCH(),
},
},
{ }
};

static struct pci_ops hisi_ecam_pci_ops = {
.map_bus = pci_mcfg_dev_base,
.read = hisi_pcie_cfg_read,
.write = hisi_pcie_cfg_write,
};

DECLARE_ACPI_MCFG_FIXUP(hisi_quirk, _ecam_pci_ops,
, );

With above code you can use your custom PCI config accessor only for
that region.

Let me know if that is not enough for you.


In principle I think it can work...

Liudongdong, Guo Hanjun what is your opinion about?


Let me and Dongdong prepare a patch for Hip05 and then will
back to this discussion to see if we met some problems.

Thanks
Hanjun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection

2015-12-23 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 22 Dec 2015 22:32:07 +0100

This issue was detected by using the Coccinelle software.

Let us return directly if a memory allocation failed.

Signed-off-by: Markus Elfring 
---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index e507cfb..a50385c 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -433,7 +433,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions 
*state,
tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
if (!tb[1]) {
ldm_crit("Out of memory.");
-   goto err;
+   return false;
}
tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
-- 
2.6.3

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


RE: [PATCH 3/6] ASoC: da7219: Update REFERENCES reg default, in-line with HW

2015-12-23 Thread Opensource [Adam Thomson]
On December 23, 2015 00:10, Mark Brown wrote:

> On Tue, Dec 22, 2015 at 06:27:53PM +, Adam Thomson wrote:
> > In current AB silicon, BIAS_EN field is enabled by default in the
> > REFERENCES register, so the regmap default value should reflect
> > this.
> 
> This is the sort of thing where a register patch would normally be used
> - if you put in a register patch for the older silicon then the driver
> can correct for the register default automatically.

Thanks. Yes, am aware of that. Were the older silicon still in use then I'd have
taken that route, but didn't seem necessary in this instance.


RE: [f2fs-dev] [PATCH 4/4] f2fs: call f2fs_balance_fs only when node was changed

2015-12-23 Thread Chao Yu
Hi Jaegeuk,

> -Original Message-
> From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> Sent: Wednesday, December 23, 2015 9:00 AM
> To: linux-kernel@vger.kernel.org; linux-fsde...@vger.kernel.org;
> linux-f2fs-de...@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 4/4] f2fs: call f2fs_balance_fs only when node was 
> changed
> 
> If user tries to update or read data, we don't need to call f2fs_balance_fs
> which triggers f2fs_gc, which increases unnecessary long latency.

One missing case is get_data_block_dio, how about also covering it based on
following patch?


>From 7175efac7473e7a04285055c69edfb7432f8ca4e Mon Sep 17 00:00:00 2001
From: Chao Yu 
Date: Wed, 23 Dec 2015 17:11:43 +0800
Subject: [PATCH] f2fs: reduce covered region of sbi->cp_rwsem in
 f2fs_map_blocks

Only cover sbi->cp_rwsem on one dnode page's allocation and modification
instead of multiple's in f2fs_map_blocks, it can reduce the covered region
of cp_rwsem, then we can avoid potential long time delay for concurrent
checkpointer.

Signed-off-by: Chao Yu 
---
 fs/f2fs/data.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8f8f8b0..3c83b16 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -594,7 +594,7 @@ int f2fs_map_blocks(struct inode *inode, struct 
f2fs_map_blocks *map,
}
 
if (create)
-   f2fs_lock_op(F2FS_I_SB(inode));
+   f2fs_lock_op(sbi);
 
/* When reading holes, we need its node page */
set_new_dnode(, inode, NULL, NULL, 0);
@@ -651,6 +651,11 @@ get_next:
allocated = false;
f2fs_put_dnode();
 
+   if (create) {
+   f2fs_unlock_op(sbi);
+   f2fs_lock_op(sbi);
+   }
+
set_new_dnode(, inode, NULL, NULL, 0);
err = get_dnode_of_data(, pgofs, mode);
if (err) {
@@ -706,7 +711,7 @@ put_out:
f2fs_put_dnode();
 unlock_out:
if (create)
-   f2fs_unlock_op(F2FS_I_SB(inode));
+   f2fs_unlock_op(sbi);
 out:
trace_f2fs_map_blocks(inode, map, err);
return err;
-- 
2.6.3


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


[PATCH 1/2] f2fs: report error of do_checkpoint

2015-12-23 Thread Chao Yu
do_checkpoint and write_checkpoint can fail due to reasons like triggering
in a readonly fs or encountering IO error of storage device.

So it's better to report such error info to user, let user be aware of
failure of doing checkpoint.

Signed-off-by: Chao Yu 
---
 fs/f2fs/checkpoint.c | 29 +++--
 fs/f2fs/f2fs.h   |  2 +-
 fs/f2fs/file.c   |  5 +++--
 fs/f2fs/recovery.c   |  2 +-
 fs/f2fs/segment.c|  5 +++--
 fs/f2fs/super.c  |  5 +++--
 6 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index fdd43f7..9cdb161 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -910,7 +910,7 @@ static void wait_on_all_pages_writeback(struct f2fs_sb_info 
*sbi)
finish_wait(>cp_wait, );
 }
 
-static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
@@ -936,7 +936,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
while (get_pages(sbi, F2FS_DIRTY_META)) {
sync_meta_pages(sbi, META, LONG_MAX);
if (unlikely(f2fs_cp_error(sbi)))
-   return;
+   return -EIO;
}
 
next_free_nid(sbi, _nid);
@@ -1021,7 +1021,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
/* need to wait for end_io results */
wait_on_all_pages_writeback(sbi);
if (unlikely(f2fs_cp_error(sbi)))
-   return;
+   return -EIO;
 
/* write out checkpoint buffer at block 0 */
update_meta_page(sbi, ckpt, start_blk++);
@@ -1049,7 +1049,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
wait_on_all_pages_writeback(sbi);
 
if (unlikely(f2fs_cp_error(sbi)))
-   return;
+   return -EIO;
 
filemap_fdatawait_range(NODE_MAPPING(sbi), 0, LONG_MAX);
filemap_fdatawait_range(META_MAPPING(sbi), 0, LONG_MAX);
@@ -1075,19 +1075,22 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
release_ino_entry(sbi);
 
if (unlikely(f2fs_cp_error(sbi)))
-   return;
+   return -EIO;
 
clear_prefree_segments(sbi, cpc);
clear_sbi_flag(sbi, SBI_IS_DIRTY);
+
+   return 0;
 }
 
 /*
  * We guarantee that this checkpoint procedure will not fail.
  */
-void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
unsigned long long ckpt_ver;
+   int err = 0;
 
mutex_lock(>cp_mutex);
 
@@ -1095,14 +1098,19 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
(cpc->reason == CP_FASTBOOT || cpc->reason == CP_SYNC ||
(cpc->reason == CP_DISCARD && !sbi->discard_blks)))
goto out;
-   if (unlikely(f2fs_cp_error(sbi)))
+   if (unlikely(f2fs_cp_error(sbi))) {
+   err = -EIO;
goto out;
-   if (f2fs_readonly(sbi->sb))
+   }
+   if (f2fs_readonly(sbi->sb)) {
+   err = -EROFS;
goto out;
+   }
 
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops");
 
-   if (block_operations(sbi))
+   err = block_operations(sbi);
+   if (err)
goto out;
 
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops");
@@ -1124,7 +1132,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
flush_sit_entries(sbi, cpc);
 
/* unlock all the fs_lock[] in do_checkpoint() */
-   do_checkpoint(sbi, cpc);
+   err = do_checkpoint(sbi, cpc);
 
unblock_operations(sbi);
stat_inc_cp_count(sbi->stat_info);
@@ -1138,6 +1146,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint");
 out:
mutex_unlock(>cp_mutex);
+   return err;
 }
 
 void init_ino_entry_info(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 0f4d329..0d23962 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1838,7 +1838,7 @@ void update_dirty_page(struct inode *, struct page *);
 void add_dirty_dir_inode(struct inode *);
 void remove_dirty_inode(struct inode *);
 void sync_dirty_inodes(struct f2fs_sb_info *, enum inode_type);
-void write_checkpoint(struct f2fs_sb_info *, struct cp_control *);
+int write_checkpoint(struct f2fs_sb_info *, struct cp_control *);
 void init_ino_entry_info(struct f2fs_sb_info *);
 int __init create_checkpoint_caches(void);
 void 

RE: [f2fs-dev] [PATCH 2/2] f2fs: speed up shrinking extent tree entries

2015-12-23 Thread Chao Yu
> -Original Message-
> From: He YunLei [mailto:heyun...@huawei.com]
> Sent: Tuesday, December 22, 2015 8:35 PM
> To: Chao Yu
> Cc: 'Jaegeuk Kim'; linux-fsde...@vger.kernel.org; 
> linux-kernel@vger.kernel.org;
> linux-f2fs-de...@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: speed up shrinking extent tree 
> entries
> 
> On 2015/12/22 13:20, Chao Yu wrote:
> > Hi Jaegeuk,
> >
> > We should update _zombie_tree whenever removing unreferenced
> > extent tree during shrinking:
> > - f2fs_shrink_extent_tree
> > if (!atomic_read(>refcount)) {
> > ...
> > atomic_dec(>total_ext_tree);
> > atomic_dec(>total_zombie_tree);
> > ...
> > }
> >
> > Other parts look good to me. :)
> >
> > Reviewed-by: Chao Yu 
> >
> > Thanks,
> >
> >> -Original Message-
> >> From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> >> Sent: Tuesday, December 22, 2015 11:39 AM
> >> To: linux-kernel@vger.kernel.org; linux-fsde...@vger.kernel.org;
> >> linux-f2fs-de...@lists.sourceforge.net
> >> Cc: Jaegeuk Kim
> >> Subject: [f2fs-dev] [PATCH 2/2] f2fs: speed up shrinking extent tree 
> >> entries
> >>
> >> If there is no candidates for shrinking slab entries, we don't need to 
> >> traverse
> >> any trees at all.
> >>
> >> Signed-off-by: Jaegeuk Kim 
> >> ---
> >>   fs/f2fs/extent_cache.c | 12 
> >>   fs/f2fs/f2fs.h |  1 +
> >>   fs/f2fs/shrinker.c |  2 +-
> >>   3 files changed, 14 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
> >> index 0e97d6af..32693af 100644
> >> --- a/fs/f2fs/extent_cache.c
> >> +++ b/fs/f2fs/extent_cache.c
> >> @@ -71,6 +71,8 @@ static struct extent_tree *__grab_extent_tree(struct 
> >> inode *inode)
> >>atomic_set(>refcount, 0);
> >>et->count = 0;
> >>atomic_inc(>total_ext_tree);
> >> +  } else {
> >> +  atomic_dec(>total_zombie_tree);
> >>}
> >>atomic_inc(>refcount);
> >>up_write(>extent_tree_lock);
> >> @@ -547,10 +549,14 @@ unsigned int f2fs_shrink_extent_tree(struct 
> >> f2fs_sb_info *sbi, int
> >> nr_shrink)
> >>unsigned int found;
> >>unsigned int node_cnt = 0, tree_cnt = 0;
> >>int remained;
> >> +  bool do_free = false;
> >>
> >>if (!test_opt(sbi, EXTENT_CACHE))
> >>return 0;
> >>
> >> +  if (!atomic_read(>total_zombie_tree))
> >> +  goto free_node;
> >> +
> >>if (!down_write_trylock(>extent_tree_lock))
> >>goto out;
> >>
> >> @@ -580,6 +586,7 @@ unsigned int f2fs_shrink_extent_tree(struct 
> >> f2fs_sb_info *sbi, int
> >> nr_shrink)
> >>}
> >>up_write(>extent_tree_lock);
> >>
> >> +free_node:
> >>/* 2. remove LRU extent entries */
> >>if (!down_write_trylock(>extent_tree_lock))
> >>goto out;
> >> @@ -591,9 +598,13 @@ unsigned int f2fs_shrink_extent_tree(struct 
> >> f2fs_sb_info *sbi, int
> >> nr_shrink)
> >>if (!remained--)
> >>break;
> >>list_del_init(>list);
> >> +  do_free = true;
> >>}
> >>spin_unlock(>extent_lock);
> >>
> >> +  if (do_free == false)
> >> +  goto unlock_out;
> >> +
> >>/*
> >> * reset ino for searching victims from beginning of global extent tree.
> >> */
> >> @@ -651,6 +662,7 @@ void f2fs_destroy_extent_tree(struct inode *inode)
> >>
> >>if (inode->i_nlink && !is_bad_inode(inode) && et->count) {
> >>atomic_dec(>refcount);
> >> +  atomic_dec(>total_zombie_tree);
> >>return;
> >>}
> Hi,all
>   here, sbi->total_ext_tree-- also should change to
>   atomic_dec(>total_ext_tree);

Yunlei,

Seems not right.

Thanks,

> Thanks,
> 
> >>
> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> >> index a7f6191..90fb970 100644
> >> --- a/fs/f2fs/f2fs.h
> >> +++ b/fs/f2fs/f2fs.h
> >> @@ -763,6 +763,7 @@ struct f2fs_sb_info {
> >>struct list_head extent_list;   /* lru list for shrinker */
> >>spinlock_t extent_lock; /* locking extent lru list */
> >>atomic_t total_ext_tree;/* extent tree count */
> >> +  atomic_t total_zombie_tree; /* extent zombie tree count */
> >>atomic_t total_ext_node;/* extent info count */
> >>
> >>/* basic filesystem units */
> >> diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
> >> index a11e099..93606f2 100644
> >> --- a/fs/f2fs/shrinker.c
> >> +++ b/fs/f2fs/shrinker.c
> >> @@ -32,7 +32,7 @@ static unsigned long __count_free_nids(struct 
> >> f2fs_sb_info *sbi)
> >>
> >>   static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)
> >>   {
> >> -  return atomic_read(>total_ext_tree) +
> >> +  return atomic_read(>total_zombie_tree) +
> >>atomic_read(>total_ext_node);
> >>   }
> >>
> >> --
> >> 2.5.4 (Apple Git-61)
> >>
> >>
> >> --
> >> 

[PATCH 2/2] f2fs: don't convert inline inode when inline_data option is disable

2015-12-23 Thread Chao Yu
If inline_data option is disable, when truncating an inline inode with
size which is not exceed maxinum inline size, we should not convert
inline inode to regular one to avoid the overhead of synchronizing
conversion.

Signed-off-by: Chao Yu 
---
 fs/f2fs/inline.c | 3 ---
 fs/f2fs/namei.c  | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index c24e5d9..5ffbd16 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -16,9 +16,6 @@
 
 bool f2fs_may_inline_data(struct inode *inode)
 {
-   if (!test_opt(F2FS_I_SB(inode), INLINE_DATA))
-   return false;
-
if (f2fs_is_atomic_file(inode))
return false;
 
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 8d2616f..8655dc8 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -60,7 +60,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, 
umode_t mode)
if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode))
f2fs_set_encrypted_inode(inode);
 
-   if (f2fs_may_inline_data(inode))
+   if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode))
set_inode_flag(F2FS_I(inode), FI_INLINE_DATA);
if (f2fs_may_inline_dentry(inode))
set_inode_flag(F2FS_I(inode), FI_INLINE_DENTRY);
-- 
2.6.3


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


[PATCH] staging: lustre: Remove unused memhog functionality

2015-12-23 Thread Dighe, Niranjan (N.)
From: Niranjan Dighe 

Remove IOC_LIBCFS_MEMHOG ioctl functionality as it is no longer needed thereby
making functions like - kportal_memhog_alloc(), kportal_memhog_free() and type -
struct libcfs_device_userstate unused.

Signed-off-by: Niranjan Dighe 
---
 .../lustre/include/linux/libcfs/libcfs_private.h   |5 -
 .../lustre/lustre/libcfs/linux/linux-module.c  |   14 +-
 drivers/staging/lustre/lustre/libcfs/module.c  |  139 
 3 files changed, 2 insertions(+), 156 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index d6273e1..e044d6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -391,11 +391,6 @@ int cfs_percpt_atomic_summary(atomic_t **refs);
  * Support for temporary event tracing with minimal Heisenberg effect.
  *  */
 
-struct libcfs_device_userstate {
-   intldu_memhog_pages;
-   struct page   *ldu_memhog_root_page;
-};
-
 #define MKSTR(ptr) ((ptr)) ? (ptr) : ""
 
 static inline int cfs_size_round4(int val)
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c 
b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
index 70a99cf0..eccfe8bd 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
@@ -98,14 +98,12 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size)
 static int
 libcfs_psdev_open(struct inode *inode, struct file *file)
 {
-   struct libcfs_device_userstate **pdu = NULL;
intrc = 0;
 
if (!inode)
return -EINVAL;
-   pdu = (struct libcfs_device_userstate **)>private_data;
if (libcfs_psdev_ops.p_open != NULL)
-   rc = libcfs_psdev_ops.p_open(0, (void *)pdu);
+   rc = libcfs_psdev_ops.p_open(0, NULL);
else
return -EPERM;
return rc;
@@ -115,14 +113,12 @@ libcfs_psdev_open(struct inode *inode, struct file *file)
 static int
 libcfs_psdev_release(struct inode *inode, struct file *file)
 {
-   struct libcfs_device_userstate *pdu;
intrc = 0;
 
if (!inode)
return -EINVAL;
-   pdu = file->private_data;
if (libcfs_psdev_ops.p_close != NULL)
-   rc = libcfs_psdev_ops.p_close(0, (void *)pdu);
+   rc = libcfs_psdev_ops.p_close(0, NULL);
else
rc = -EPERM;
return rc;
@@ -152,14 +148,8 @@ static long libcfs_ioctl(struct file *file,
return -EPERM;
panic("debugctl-invoked panic");
return 0;
-   case IOC_LIBCFS_MEMHOG:
-   if (!capable(CFS_CAP_SYS_ADMIN))
-   return -EPERM;
-   /* go thought */
}
 
-   pfile.off = 0;
-   pfile.private_data = file->private_data;
if (libcfs_psdev_ops.p_ioctl != NULL)
rc = libcfs_psdev_ops.p_ioctl(, cmd, (void *)arg);
else
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c 
b/drivers/staging/lustre/lustre/libcfs/module.c
index 329d78c..0067e53 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -68,142 +68,16 @@ MODULE_LICENSE("GPL");
 
 static struct dentry *lnet_debugfs_root;
 
-static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
-{
-   struct page **level0p = >ldu_memhog_root_page;
-   struct page **level1p;
-   struct page **level2p;
-   intcount1;
-   intcount2;
-
-   if (*level0p != NULL) {
-
-   level1p = (struct page **)page_address(*level0p);
-   count1 = 0;
-
-   while (count1 < PAGE_CACHE_SIZE/sizeof(struct page *) &&
-  *level1p != NULL) {
-
-   level2p = (struct page **)page_address(*level1p);
-   count2 = 0;
-
-   while (count2 < PAGE_CACHE_SIZE/sizeof(struct page *) &&
-  *level2p != NULL) {
-
-   __free_page(*level2p);
-   ldu->ldu_memhog_pages--;
-   level2p++;
-   count2++;
-   }
-
-   __free_page(*level1p);
-   ldu->ldu_memhog_pages--;
-   level1p++;
-   count1++;
-   }
-
-   __free_page(*level0p);
-   ldu->ldu_memhog_pages--;
-
-   *level0p = NULL;
-   }
-
-   LASSERT(ldu->ldu_memhog_pages == 0);
-}
-
-static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int 
npages,
-gfp_t 

[PATCH 2/2] ixgbe: Use core to device locality interface

2015-12-23 Thread Daniel J Blueman
Rather than assuming cores starting from 0 are local to the ethernet
device, use the introduced interface to find near cores.

Not only does this improve performance due to spreading interrupts via near
NUMA nodes, it prevents assigning cores on distant NUMA nodes, which aren't
reachable by device interrupts due to the 8-bit APIC ID limitation.

With Numascale NumaConnect2 systems with Intel ixgbe cards on
non-primary PCI domains, all ixgbe NICs would previously revector
interrupts to cores 0 to 63 (cores 0 to 47 would be considered
near the primary PCI domain). Now, cores 48 to 95 are used, increasing
performance and addressing interrupt delivery issues:

do_IRQ: 79.180 No irq handler for vector (irq -1)
do_IRQ: 78.42 No irq handler for vector (irq -1)
do_IRQ: 71.172 No irq handler for vector (irq -1)
do_IRQ: 70.236 No irq handler for vector (irq -1)
do_IRQ: 69.109 No irq handler for vector (irq -1)
do_IRQ: 68.189 No irq handler for vector (irq -1)
do_IRQ: 72.92 No irq handler for vector (irq -1)
do_IRQ: 73.235 No irq handler for vector (irq -1)
do_IRQ: 66.185 No irq handler for vector (irq -1)
do_IRQ: 67.62 No irq handler for vector (irq -1)
do_IRQ: 197 callbacks suppressed

Signed-off-by: Daniel J Blueman 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
index f3168bc..12c4ce1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
@@ -817,10 +817,8 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter 
*adapter,
if ((tcs <= 1) && !(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) {
u16 rss_i = adapter->ring_feature[RING_F_RSS].indices;
if (rss_i > 1 && adapter->atr_sample_rate) {
-   if (cpu_online(v_idx)) {
-   cpu = v_idx;
-   node = cpu_to_node(cpu);
-   }
+   cpu = cpu_near_dev(adapter->pdev, v_idx);
+   node = cpu_to_node(cpu);
}
}

--
2.5.0

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


Re: [PATCH v7 2/4] drm: Add support for ARM's HDLCD controller.

2015-12-23 Thread Daniel Stone
Hi,

On 22 December 2015 at 17:41, Liviu Dudau  wrote:
> The HDLCD controller is a display controller that supports resolutions
> up to 4096x4096 pixels. It is present on various development boards
> produced by ARM Ltd and emulated by the latest Fast Models from the
> company.

I didn't get to take as close a look as last time, but I only had
fairly minor quibbles then, and nothing jumped out at me this time
either.

Reviewed-by: Daniel Stone 

Cheers,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/2] Improve drm_of_component_probe() and move rockchip to use it

2015-12-23 Thread Liviu Dudau
On Wed, Dec 23, 2015 at 10:39:06AM +0100, Jean-Francois Moine wrote:
> On Tue, 22 Dec 2015 17:38:00 +
> Liviu Dudau  wrote:
> 
> > On Fri, Nov 20, 2015 at 02:22:03PM +, Liviu Dudau wrote:
> > > Hello,
> > > 
> > > This is v2 of the patchset trying to make drm_of_component_probe() cope 
> > > with finding
> > > both local crtc ports and remote encoder ones. Heiko Stübner was nice 
> > > enough to test
> > > an earlier version that was patched following Russell's suggestions on 
> > > rk3288, but
> > > I haven't seen any reports from iMX or Armada users.
> > > 
> > > Changelog:
> > >  v2: Updated the drm_of_component_probe() comment to explain why the 
> > > reference count
> > >  is not dropped. Fixed the compare_port() function for rockchip as 
> > > described by
> > >  Russell.
> > >  v1: Original submission. 
> > > http://lists.freedesktop.org/archives/dri-devel/2015-November/094546.html
> > 
> > Gentle ping, this has now been tested by Rockchip people and fixes the 
> > earlier version
> > that had to be reverted in mainline. Can it be included in the -next 
> > somewhere?
> 
> Hi Liviu,
> 
> Sorry for being a bit late.
> 
> I wanted to use drm_of_component_probe() for a new DRM driver, but I
> could not find any way to do it: you add the "ports" nodes as
> components while, usually, the components are the device nodes
> themselves.
> 
> With this simple patch:
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index 493c05c..dbd2921 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -101,7 +101,7 @@ int drm_of_component_probe(struct device *dev,
>   continue;
>   }
>  
> - component_match_add(dev, , compare_of, port);
> + component_match_add(dev, , compare_of, port->parent);
>   of_node_put(port);
>   }
>  
> everything is easy, my DT being like:
> 
>   de_controller {
>   ...
>   ports = <_p>;
>   };
> 
>   lcd_controller {
>   ...
>   lcd0_p: port {
>   lcd0_ep: endpoint {
>   remote-endpoint = <_ep>;
>   };
>   };
>   };
> 
> What was the reason to keep the "ports" node instead of the device?

The function is an extract of common code sprinkled through a few DRM drivers,
they all used port rather than port->parent.

Have a look at my v2 where I've introduced two compare functions and also
modified the Rockchip compare_port() to use port->parent in the comparison. I
guess that should solve your problem.

Best regards,
Liviu

> 
> -- 
> Ken ar c'hentañ   | ** Breizh ha Linux atav! **
> Jef   |   http://moinejf.free.fr/
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86/ucode: replace redundant string literals

2015-12-23 Thread Jan Beulich
>>> Borislav Petkov  12/22/15 7:14 PM >>>
>On Tue, Dec 22, 2015 at 10:20:36AM -0700, Jan Beulich wrote:
>> As said - 4.3.4 (I only now realize that this could also have been a
>> kernel version).
>
>Just fetched stable from
>git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable
>
>$ git tag --list | grep v4.3
>v4.3
>v4.3-rc1
>v4.3-rc2
>v4.3-rc3
>v4.3-rc4
>v4.3-rc5
>v4.3-rc6
>v4.3-rc7
>v4.3.1
>v4.3.2
>v4.3.3
>
>I don't see a v4.3.4 tag yet...

Sigh - this was in reply to your gcc version question. Right after having sent
the most recent reply I realized that there's no Linux 4.3.4 yet, so there 
really
was no ambiguity from the beginning. Therefore I have a hard time
understanding what you're asking for.

Jan

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


Re: [PATCH v7 2/4] drm: Add support for ARM's HDLCD controller.

2015-12-23 Thread Liviu Dudau
On Wed, Dec 23, 2015 at 10:03:00AM +, Daniel Stone wrote:
> Hi,
> 
> On 22 December 2015 at 17:41, Liviu Dudau  wrote:
> > The HDLCD controller is a display controller that supports resolutions
> > up to 4096x4096 pixels. It is present on various development boards
> > produced by ARM Ltd and emulated by the latest Fast Models from the
> > company.
> 
> I didn't get to take as close a look as last time, but I only had
> fairly minor quibbles then, and nothing jumped out at me this time
> either.
> 
> Reviewed-by: Daniel Stone 

Cheers and Merry Holidays!
Liviu

> 
> Cheers,
> Daniel
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86/ucode: replace redundant string literals

2015-12-23 Thread Borislav Petkov
On Wed, Dec 23, 2015 at 03:06:08AM -0700, Jan Beulich wrote:
> Sigh - this was in reply to your gcc version question. Right after having sent
> the most recent reply I realized that there's no Linux 4.3.4 yet, so there 
> really
> was no ambiguity from the beginning. Therefore I have a hard time
> understanding what you're asking for.

I'm asking how exactly you're triggering this so that I can reproduce it too
here.

-- 
Regards/Gruss,
Boris.

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


Re: [PATCH] x86/ucode: replace redundant string literals

2015-12-23 Thread Jan Beulich
>>> Borislav Petkov  12/23/15 11:10 AM >>>
>On Wed, Dec 23, 2015 at 03:06:08AM -0700, Jan Beulich wrote:
>> Sigh - this was in reply to your gcc version question. Right after having 
>> sent
>> the most recent reply I realized that there's no Linux 4.3.4 yet, so there 
>> really
>> was no ambiguity from the beginning. Therefore I have a hard time
>> understanding what you're asking for.
>
>I'm asking how exactly you're triggering this so that I can reproduce it too
>here.

Simple 32-bit build on SLE11 SP4.

Jan

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


[PATCH] regulator: mt6397: convert to arch_initcall

2015-12-23 Thread Henry Chen
Due to some device may need reulator operation in earlier boot time like gpu 
module which
power domain need regulator power on first. Move regulator of mt6397
initialization earlier in boot so that real devices can use regulator
without probe deferring.

Signed-off-by: Henry Chen 
---
 drivers/regulator/mt6397-regulator.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/mt6397-regulator.c 
b/drivers/regulator/mt6397-regulator.c
index a5b2f47..9b89023 100644
--- a/drivers/regulator/mt6397-regulator.c
+++ b/drivers/regulator/mt6397-regulator.c
@@ -324,7 +324,11 @@ static struct platform_driver mt6397_regulator_driver = {
.probe = mt6397_regulator_probe,
 };
 
-module_platform_driver(mt6397_regulator_driver);
+static int __init mt6397_regulator_init(void)
+{
+   return platform_driver_register(_regulator_driver);
+}
+arch_initcall(mt6397_regulator_init);
 
 MODULE_AUTHOR("Flora Fu ");
 MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6397 PMIC");
-- 
1.9.1

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


[PATCH 1/2] PCI: Add mechanism to find topologically near cores

2015-12-23 Thread Daniel J Blueman
Some devices (eg ixgbe) make assumptions about device to core locality when
specifying interrupts locality hints and allocate starting from core 0.
Moreover, interrupts may not be routable to distant NUMA nodes due to the
8-bit APIC ID space limitations.

Provide a mechanism drivers can use to find cores with reasonable locality
to a device; use the existing precendent of RECLAIM_DISTANCE (30), wrapping
the offset.

Signed-off-by: Daniel J Blueman 
---
 drivers/pci/pci.c   | 15 +++
 include/linux/pci.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 314db8c..d5535d1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4833,6 +4833,22 @@ void __weak pci_fixup_cardbus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL(pci_fixup_cardbus);

+int cpu_near_dev(const struct pci_dev *pdev, unsigned offset)
+{
+   /* Start search from node device is on for optimal locality */
+   int localnode = pcibus_to_node(pdev->bus);
+   int cpu = cpumask_first(cpumask_of_node(localnode));
+
+   while (offset--) {
+   do {
+   cpu = (cpu + 1) % nr_cpu_ids;
+   } while (!cpu_online(cpu) || node_distance(cpu_to_node(cpu),
+   localnode) > RECLAIM_DISTANCE);
+   }
+
+   return cpu;
+}
+
 static int __init pci_setup(char *str)
 {
while (str) {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6ae25aa..f7491bd 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -842,6 +842,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
 void pci_remove_root_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 void pci_sort_breadthfirst(void);
+int cpu_near_dev(const struct pci_dev *pdev, unsigned offset);
 #define dev_is_pci(d) ((d)->bus == _bus_type)
 #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
 #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
--
2.5.0

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


Re: [PATCH 00/24] crypto: atmel-aes: global rework of the driver

2015-12-23 Thread Herbert Xu
On Thu, Dec 17, 2015 at 05:48:31PM +0100, Cyrille Pitchen wrote:
> Hi all,
> 
> this series of patches is a global rework of the Atmel driver. Some
> patches improve the performances whereas others fix some bugs like
> the counter overflow in CTR mode.
> 
> It also updates some part of the code to make them more generic. For
> instance the crypto request queue management supports both async block
> cipher and AEAD requests, which allows us to add support the the GCM
> mode. The support of the GCM mode is only available on sama5d4 and later.
> 
> This series is based on linux-next and was tested on sama5d2, sama5d3 and
> sama5d4 boards. The driver implementation was validated using the tcrypt
> module running modes:
> - 10: ecb(aes), cbc(aes), ctr(aes), rfc3686(ctr(aes))
> - 35: gcm(aes)
> 
> tcrypt speed test was run with modes:
> - 211: rfc4106(gcm(aes)), gcm(aes)
> - 500: ecb(aes), cbc(aes), ctr(aes), cfb(aes), ofc(aes), rfc3686(ctr(aes))
> 
> Finally iperf was run for at least 5 mins over an IPSEC/L2TP tunnel using
> the rfc4106(gcm(aes)) cipher suite.

All applied.  Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] crypto: 842 - remove WARN inside printk

2015-12-23 Thread Herbert Xu
On Mon, Dec 21, 2015 at 12:52:10PM -0500, Dan Streetman wrote:
> Remove the WARN() from the beN_to_cpu macro, which is used as a param to a
> pr_debug() call.  With a certain kernel config, this printk-in-printk
> results in the no_printk() macro trying to recursively call the
> no_printk() macro, and since macros can't recursively call themselves
> a build error results.
> 
> Reported-by: Randy Dunlap 
> Signed-off-by: Dan Streetman 

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] iio:adc:at91_adc8xx: introduce new atmel adc driver

2015-12-23 Thread Alexandre Belloni
On 21/12/2015 at 10:24:08 +0100, Ludovic Desroches wrote :
> +++ b/Documentation/devicetree/bindings/iio/adc/at91_adc8xx.txt
> @@ -0,0 +1,27 @@
> +* AT91 SAMA5D2 Analog to Digital Converter (ADC)
> +
> +Required properties:
> +  - compatible: Should be "atmel,sama5d2-adc".
> +  - reg: Should contain ADC registers location and length.
> +  - interrupts: Should contain the IRQ line for the ADC.
> +  - clocks: phandles to clocks.
> +  - clock-names: tuple listing clock names.
> +  Required elements: "adc_clk", "adc_op_clk". "adc_clk" is the peripheral
> +  clock, "adc_clk" is the sampling clock.

I think we should not have adc_op_clk but rather have a property like
vf610 has fsl,adck-max-frequency.
Even better, would be the ability to change it with
/sys/bus/iio/devices/iio:deviceX/sampling_frequency


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/5] iio:adc:at91_adc8xx: introduce new atmel adc driver

2015-12-23 Thread Ludovic Desroches
On Tue, Dec 22, 2015 at 06:34:00PM +, Jonathan Cameron wrote:
> On 21/12/15 09:24, Ludovic Desroches wrote:
> > This driver supports the new version of the Atmel ADC device introduced
> > with the SAMA5D2 SoC family.
> > 
> > Signed-off-by: Ludovic Desroches 
> A few more bits and bobs from me. Mostly looking good.
> 
> Jonathan
> > ---
> >  .../devicetree/bindings/iio/adc/at91_adc8xx.txt|  27 ++
> >  drivers/iio/adc/Kconfig|  11 +
> >  drivers/iio/adc/Makefile   |   1 +
> >  drivers/iio/adc/at91_adc8xx.c  | 417 
> > +
> >  4 files changed, 456 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/iio/adc/at91_adc8xx.txt
> >  create mode 100644 drivers/iio/adc/at91_adc8xx.c
> > 
> > diff --git a/Documentation/devicetree/bindings/iio/adc/at91_adc8xx.txt 
> > b/Documentation/devicetree/bindings/iio/adc/at91_adc8xx.txt
> > new file mode 100644
> > index 000..64ad6a5
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/adc/at91_adc8xx.txt
> > @@ -0,0 +1,27 @@
> > +* AT91 SAMA5D2 Analog to Digital Converter (ADC)
> > +
> > +Required properties:
> > +  - compatible: Should be "atmel,sama5d2-adc".
> > +  - reg: Should contain ADC registers location and length.
> > +  - interrupts: Should contain the IRQ line for the ADC.
> > +  - clocks: phandles to clocks.
> > +  - clock-names: tuple listing clock names.
> > +  Required elements: "adc_clk", "adc_op_clk". "adc_clk" is the 
> > peripheral
> > +  clock, "adc_clk" is the sampling clock.
> > +  - vref-supply: Supply used as reference for conversions.
> > +
> > +Optional properties:
> > +  - vddana-supply: Supply for the adc device.
> > +
> > +
> > +Example:
> > +
> > +adc: adc@fc03 {
> > +   compatible = "atmel,sama5d2-adc";
> > +   reg = <0xfc03 0x100>;
> > +   interrupts = <40 IRQ_TYPE_LEVEL_HIGH 7>;
> > +   clocks = <_clk>, <_op_clk>;
> > +   clock-names = "adc_clk", "adc_op_clk";
> > +   vddana-supply = <_3v3_lp_reg>;
> > +   vref-supply = <_3v3_lp_reg>;
> > +}
> > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> > index 9162dfe..5819e41 100644
> > --- a/drivers/iio/adc/Kconfig
> > +++ b/drivers/iio/adc/Kconfig
> > @@ -131,6 +131,17 @@ config AT91_ADC
> >   To compile this driver as a module, choose M here: the module will be
> >   called at91_adc.
> >  
> > +config AT91_ADC8xx
> > +   tristate "Atmel AT91 ADC 8xx"
> > +   depends on ARCH_AT91
> > +   depends on INPUT
> > +   help
> > + Say yes here to build support for Atmel ADC 8xx which is available
> > + from SAMA5D2 SoC family.
> > +
> > + To compile this driver as a module, choose M here: the module will be
> > + called at91_adc8xx.
> > +
> >  config AXP288_ADC
> > tristate "X-Powers AXP288 ADC driver"
> > depends on MFD_AXP20X
> > diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> > index 91a65bf..d684a52 100644
> > --- a/drivers/iio/adc/Makefile
> > +++ b/drivers/iio/adc/Makefile
> > @@ -14,6 +14,7 @@ obj-$(CONFIG_AD7793) += ad7793.o
> >  obj-$(CONFIG_AD7887) += ad7887.o
> >  obj-$(CONFIG_AD799X) += ad799x.o
> >  obj-$(CONFIG_AT91_ADC) += at91_adc.o
> > +obj-$(CONFIG_AT91_ADC8xx) += at91_adc8xx.o
> >  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
> >  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
> >  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
> > diff --git a/drivers/iio/adc/at91_adc8xx.c b/drivers/iio/adc/at91_adc8xx.c
> > new file mode 100644
> > index 000..8b4a6e7
> > --- /dev/null
> > +++ b/drivers/iio/adc/at91_adc8xx.c
> > @@ -0,0 +1,417 @@
> > +/*
> > + * Atmel ADC driver for SAMA5D2 devices and later.
> > + *
> > + * Copyright (C) 2015 Atmel,
> > + *   2015 Ludovic Desroches 
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define ADC_CR 0x00/* Control Register */
> > +#defineADC_CR_SWRSTBIT(0)  /* Software 
> > Reset */
> > +#defineADC_CR_STARTBIT(1)  /* Start 
> > Conversion */
> > +#defineADC_CR_TSCALIB  BIT(2)  /* Touchscreen 
> > Calibration */
> > +#defineADC_CR_CMPRST   BIT(4)  /* Comparison 
> > Restart */
> > +#define ADC_MR  

Re: [PATCH 13/19] ARM: dts: tegra: replace legacy *,wakeup property with wakeup-source

2015-12-23 Thread Sudeep Holla
On Wed, Oct 21, 2015 at 11:10 AM, Sudeep Holla  wrote:
> Though the keyboard and other driver will continue to support the legacy
> "gpio-key,wakeup", "nvidia,wakeup-source" boolean property to enable the
> wakeup source, "wakeup-source" is the new standard binding.
>
> This patch replaces all the legacy wakeup properties with the unified
> "wakeup-source" property in order to avoid any futher copy-paste
> duplication.
>
> Cc: Stephen Warren 
> Cc: Thierry Reding 
> Cc: Alexandre Courbot 

Ping, do you prefer taking via your tree or should I send to armsoc
directly ?

--
Regards,
Sudeep
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC] spi: dw: support setting tmode dynamically

2015-12-23 Thread Jisheng Zhang
Hi all,

Currently the spi-dw tmode is fixed to SPI_TMOD_TR if cs_control is NULL, but we
need to set it as SPI_TMOD_EPROMREAD to read nor flash, my solution is to add 
and
export one functions to set the tmode, then the nor flash driver call it
before reading and set back to SPI_TMOD_TR after done.

Is there any elegant solution from SPI framework? Any suggestions are 
appreciated!

Thanks,
Jisheng
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] clockevents/exynos_mct: Implement ->set_state_oneshot_stopped()

2015-12-23 Thread Viresh Kumar
set_state_oneshot_stopped() is called by the clkevt core, when the next
event is required at an expiry time of 'KTIME_MAX'. This normally
happens with NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.

This patch makes the clockevent device to stop on such an event, to
avoid spurious interrupts, as explained by: commit 8fff52fd5093
("clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state").

Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/exynos_mct.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index ff44082a0827..be09bc0b5e26 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -313,6 +313,7 @@ static struct clock_event_device mct_comp_device = {
.set_state_periodic = mct_set_state_periodic,
.set_state_shutdown = mct_set_state_shutdown,
.set_state_oneshot  = mct_set_state_shutdown,
+   .set_state_oneshot_stopped = mct_set_state_shutdown,
.tick_resume= mct_set_state_shutdown,
 };
 
@@ -452,6 +453,7 @@ static int exynos4_local_timer_setup(struct 
mct_clock_event_device *mevt)
evt->set_state_periodic = set_state_periodic;
evt->set_state_shutdown = set_state_shutdown;
evt->set_state_oneshot = set_state_shutdown;
+   evt->set_state_oneshot_stopped = set_state_shutdown;
evt->tick_resume = set_state_shutdown;
evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
evt->rating = 450;
-- 
2.7.0.rc1.186.g94414c4

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


[PATCH 2/3] clockevents/arm_global_timer: Implement ->set_state_oneshot_stopped()

2015-12-23 Thread Viresh Kumar
set_state_oneshot_stopped() is called by the clkevt core, when the next
event is required at an expiry time of 'KTIME_MAX'. This normally
happens with NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.

This patch makes the clockevent device to stop on such an event, to
avoid spurious interrupts, as explained by: commit 8fff52fd5093
("clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state").

Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/arm_global_timer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/arm_global_timer.c 
b/drivers/clocksource/arm_global_timer.c
index a2cb6fae9295..801cfe5833c1 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -174,6 +174,7 @@ static int gt_clockevents_init(struct clock_event_device 
*clk)
clk->set_state_shutdown = gt_clockevent_shutdown;
clk->set_state_periodic = gt_clockevent_set_periodic;
clk->set_state_oneshot = gt_clockevent_shutdown;
+   clk->set_state_oneshot_stopped = gt_clockevent_shutdown;
clk->set_next_event = gt_clockevent_set_next_event;
clk->cpumask = cpumask_of(cpu);
clk->rating = 300;
-- 
2.7.0.rc1.186.g94414c4

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


[PATCH 1/3] clockevents/arm_arch_timer: Implement ->set_state_oneshot_stopped()

2015-12-23 Thread Viresh Kumar
set_state_oneshot_stopped() is called by the clkevt core, when the next
event is required at an expiry time of 'KTIME_MAX'. This normally
happens with NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.

This patch makes the clockevent device to stop on such an event, to
avoid spurious interrupts, as explained by: commit 8fff52fd5093
("clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state").

Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/arm_arch_timer.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/clocksource/arm_arch_timer.c 
b/drivers/clocksource/arm_arch_timer.c
index c64d543d64bf..c816823888c0 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -266,10 +266,12 @@ static void __arch_timer_setup(unsigned type,
if (arch_timer_use_virtual) {
clk->irq = arch_timer_ppi[VIRT_PPI];
clk->set_state_shutdown = arch_timer_shutdown_virt;
+   clk->set_state_oneshot_stopped = 
arch_timer_shutdown_virt;
clk->set_next_event = arch_timer_set_next_event_virt;
} else {
clk->irq = arch_timer_ppi[PHYS_SECURE_PPI];
clk->set_state_shutdown = arch_timer_shutdown_phys;
+   clk->set_state_oneshot_stopped = 
arch_timer_shutdown_phys;
clk->set_next_event = arch_timer_set_next_event_phys;
}
} else {
@@ -279,10 +281,12 @@ static void __arch_timer_setup(unsigned type,
clk->cpumask = cpu_all_mask;
if (arch_timer_mem_use_virtual) {
clk->set_state_shutdown = arch_timer_shutdown_virt_mem;
+   clk->set_state_oneshot_stopped = 
arch_timer_shutdown_virt_mem;
clk->set_next_event =
arch_timer_set_next_event_virt_mem;
} else {
clk->set_state_shutdown = arch_timer_shutdown_phys_mem;
+   clk->set_state_oneshot_stopped = 
arch_timer_shutdown_phys_mem;
clk->set_next_event =
arch_timer_set_next_event_phys_mem;
}
-- 
2.7.0.rc1.186.g94414c4

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


[PATCH 0/3] clockevents/arm: Implement ->set_state_oneshot_stopped()

2015-12-23 Thread Viresh Kumar
Hi Daniel/Thomas,

ONESHOT-STOPPED state was merged into mainline sometime back and doesn't
have any users until now.

This series implements the set_state_oneshot_stopped() callback for few
ARM clkevt drivers.

Which other clkevt drivers will you advice to update, if any?

Tested on ARM Exynos 5250 dual A15 board (1/3 and 3/3, 2/3 is compile
tested only but is changed as many ARM SoCs use it).
Rebased on v4.4-rc6.

Viresh Kumar (3):
  clockevents/arm_arch_timer: Implement ->set_state_oneshot_stopped()
  clockevents/arm_global_timer: Implement ->set_state_oneshot_stopped()
  clockevents/exynos_mct: Implement ->set_state_oneshot_stopped()

 drivers/clocksource/arm_arch_timer.c   | 4 
 drivers/clocksource/arm_global_timer.c | 1 +
 drivers/clocksource/exynos_mct.c   | 2 ++
 3 files changed, 7 insertions(+)

-- 
2.7.0.rc1.186.g94414c4

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


[PATCH v2 00/11] KVM: x86: track guest page access

2015-12-23 Thread Xiao Guangrong
Changelog in v2:
- fix a issue that the track memory of memslot is freed if we only move
  the memslot or change the flags of memslot
- do not track the gfn which is not mapped in memslots
- introduce the nolock APIs at the begin of the patchset
- use 'unsigned short' as the track counter to reduce the memory and which
  should be enough for shadow page table and KVMGT

This patchset introduces the feature which allows us to track page
access in guest. Currently, only write access tracking is implemented
in this version.

Four APIs are introduces:
- kvm_page_track_add_page(kvm, gfn, mode), single guest page @gfn is
  added into the track pool of the guest instance represented by @kvm,
  @mode specifies which kind of access on the @gfn is tracked
  
- kvm_page_track_remove_page(kvm, gfn, mode), is the opposed operation
  of kvm_page_track_add_page() which removes @gfn from the tracking pool.
  gfn is no tracked after its last user is gone

- kvm_page_track_register_notifier(kvm, n), register a notifier so that
  the event triggered by page tracking will be received, at that time,
  the callback of n->track_write() will be called

- kvm_page_track_unregister_notifier(kvm, n), does the opposed operation
  of kvm_page_track_register_notifier(), which unlinks the notifier and
  stops receiving the tracked event

The first user of page track is non-leaf shadow page tables as they are
always write protected. It also gains performance improvement because
page track speeds up page fault handler for the tracked pages. The
performance result of kernel building is as followings:

   before   after
real 461.63   real 455.48
user 4529.55  user 4557.88
sys 1995.39   sys 1922.57

Furthermore, it is the infrastructure of other kind of shadow page table,
such as GPU shadow page table introduced in KVMGT (1) and native nested
IOMMU.

This patch can be divided into two parts:
- patch 1 ~ patch 7, implement page tracking
- others patches apply page tracking to non-leaf shadow page table

(1): http://lkml.iu.edu/hypermail/linux/kernel/1510.3/01562.html

Xiao Guangrong (11):
  KVM: MMU: rename has_wrprotected_page to mmu_gfn_lpage_is_disallowed
  KVM: MMU: introduce kvm_mmu_gfn_{allow,disallow}_lpage
  KVM: MMU: introduce kvm_mmu_slot_gfn_write_protect
  KVM: page track: add the framework of guest page tracking
  KVM: page track: introduce kvm_page_track_{add,remove}_page
  KVM: MMU: let page fault handler be aware tracked page
  KVM: page track: add notifier support
  KVM: MMU: use page track for non-leaf shadow pages
  KVM: MMU: simplify mmu_need_write_protect
  KVM: MMU: clear write-flooding on the fast path of tracked page
  KVM: MMU: apply page track notifier

 Documentation/virtual/kvm/mmu.txt |   6 +-
 arch/x86/include/asm/kvm_host.h   |  12 +-
 arch/x86/include/asm/kvm_page_track.h |  67 +
 arch/x86/kvm/Makefile |   3 +-
 arch/x86/kvm/mmu.c| 199 ++
 arch/x86/kvm/mmu.h|   5 +
 arch/x86/kvm/page_track.c | 257 ++
 arch/x86/kvm/paging_tmpl.h|   5 +
 arch/x86/kvm/x86.c|  27 ++--
 9 files changed, 509 insertions(+), 72 deletions(-)
 create mode 100644 arch/x86/include/asm/kvm_page_track.h
 create mode 100644 arch/x86/kvm/page_track.c

-- 
1.8.3.1

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


Re: [PATCH] drivers/char/mem.c: Add /dev/ioports, supporting 16-bit and 32-bit ports

2015-12-23 Thread Santosh Shukla
On 23 December 2015 at 03:26, Arnd Bergmann  wrote:
> On Tuesday 22 December 2015, Santosh Shukla wrote:
>> }
>>
>> So I care for /dev/ioport types interface who could do more than byte
>> data copy to/from user-space. I tested this patch with little
>> modification and could able to run pmd driver for arm/arm64 case.
>>
>> Like to know how to address pci_io region mapping problem for
>> arm/arm64, in-case /dev/ioports approach is not acceptable or else I
>> can spent time on restructuring the patch?
>>
>
> For the use case you describe, can't you use the vfio framework to
> access the PCI BARs?
>

I looked at file: drivers/vfio/pci/vfio_pci.c, func vfio_pci_map() and
it look to me that it only maps ioresource_mem pci region, pasting
code snap:

if (!(pci_resource_flags(pdev, index) & IORESOURCE_MEM))
return -EINVAL;


and I want to map ioresource_io pci region for arm platform in my
use-case. Not sure vfio maps pci_iobar region?

> After all, you are talking about regular PCI devices, not access to
> random unknown I/O port numbers.
>
Yes, pci_iobar region.

> Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 06/11] KVM: MMU: let page fault handler be aware tracked page

2015-12-23 Thread Xiao Guangrong
The page fault caused by write access on the write tracked page can not
be fixed, it always need to be emulated. page_fault_handle_page_track()
is the fast path we introduce here to skip holding mmu-lock and shadow
page table walking

However, if the page table is not present, it is worth making the page
table entry present and readonly to make the read access happy

mmu_need_write_protect() need to be cooked to avoid page becoming writable
when making page table present or sync/prefetch shadow page table entries

Signed-off-by: Xiao Guangrong 
---
 arch/x86/include/asm/kvm_page_track.h |  2 ++
 arch/x86/kvm/mmu.c| 44 +--
 arch/x86/kvm/page_track.c | 14 +++
 arch/x86/kvm/paging_tmpl.h|  3 +++
 4 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/kvm_page_track.h 
b/arch/x86/include/asm/kvm_page_track.h
index c010124..97ac9c3 100644
--- a/arch/x86/include/asm/kvm_page_track.h
+++ b/arch/x86/include/asm/kvm_page_track.h
@@ -23,4 +23,6 @@ void kvm_slot_page_track_remove_page_nolock(struct kvm *kvm,
enum kvm_page_track_mode mode);
 void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
enum kvm_page_track_mode mode);
+bool kvm_page_track_check_mode(struct kvm_vcpu *vcpu, gfn_t gfn,
+  enum kvm_page_track_mode mode);
 #endif
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 39809b8..b23f9fc 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * When setting this variable to true it enables Two-Dimensional-Paging
@@ -2456,25 +2457,29 @@ static void kvm_unsync_pages(struct kvm_vcpu *vcpu,  
gfn_t gfn)
}
 }
 
-static int mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,
- bool can_unsync)
+static bool mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,
+  bool can_unsync)
 {
struct kvm_mmu_page *s;
bool need_unsync = false;
 
+   if (kvm_page_track_check_mode(vcpu, gfn, KVM_PAGE_TRACK_WRITE))
+   return true;
+
for_each_gfn_indirect_valid_sp(vcpu->kvm, s, gfn) {
if (!can_unsync)
-   return 1;
+   return true;
 
if (s->role.level != PT_PAGE_TABLE_LEVEL)
-   return 1;
+   return true;
 
if (!s->unsync)
need_unsync = true;
}
if (need_unsync)
kvm_unsync_pages(vcpu, gfn);
-   return 0;
+
+   return false;
 }
 
 static bool kvm_is_mmio_pfn(pfn_t pfn)
@@ -3388,10 +3393,30 @@ int handle_mmio_page_fault(struct kvm_vcpu *vcpu, u64 
addr, bool direct)
 }
 EXPORT_SYMBOL_GPL(handle_mmio_page_fault);
 
+static bool page_fault_handle_page_track(struct kvm_vcpu *vcpu,
+u32 error_code, gfn_t gfn)
+{
+   if (unlikely(error_code & PFERR_RSVD_MASK))
+   return false;
+
+   if (!(error_code & PFERR_PRESENT_MASK) ||
+ !(error_code & PFERR_WRITE_MASK))
+   return false;
+
+   /*
+* guest is writing the page which is write tracked which can
+* not be fixed by page fault handler.
+*/
+   if (kvm_page_track_check_mode(vcpu, gfn, KVM_PAGE_TRACK_WRITE))
+   return true;
+
+   return false;
+}
+
 static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
u32 error_code, bool prefault)
 {
-   gfn_t gfn;
+   gfn_t gfn = gva >> PAGE_SHIFT;
int r;
 
pgprintk("%s: gva %lx error %x\n", __func__, gva, error_code);
@@ -3403,13 +3428,15 @@ static int nonpaging_page_fault(struct kvm_vcpu *vcpu, 
gva_t gva,
return r;
}
 
+   if (page_fault_handle_page_track(vcpu, error_code, gfn))
+   return 1;
+
r = mmu_topup_memory_caches(vcpu);
if (r)
return r;
 
MMU_WARN_ON(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
 
-   gfn = gva >> PAGE_SHIFT;
 
return nonpaging_map(vcpu, gva & PAGE_MASK,
 error_code, gfn, prefault);
@@ -3493,6 +3520,9 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t 
gpa, u32 error_code,
return r;
}
 
+   if (page_fault_handle_page_track(vcpu, error_code, gfn))
+   return 1;
+
r = mmu_topup_memory_caches(vcpu);
if (r)
return r;
diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
index e17efe9..de9b32f 100644
--- a/arch/x86/kvm/page_track.c
+++ b/arch/x86/kvm/page_track.c
@@ -174,3 +174,17 @@ void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,

[PATCH v2 07/11] KVM: page track: add notifier support

2015-12-23 Thread Xiao Guangrong
Notifier list is introduced so that any node wants to receive the track
event can register to the list

Two APIs are introduced here:
- kvm_page_track_register_notifier(): register the notifier to receive
  track event

- kvm_page_track_unregister_notifier(): stop receiving track event by
  unregister the notifier

The callback, node->track_write() is called when a write access on the
write tracked page happens

Signed-off-by: Xiao Guangrong 
---
 arch/x86/include/asm/kvm_host.h   |  1 +
 arch/x86/include/asm/kvm_page_track.h | 39 
 arch/x86/kvm/page_track.c | 67 +++
 arch/x86/kvm/x86.c|  4 +++
 4 files changed, 111 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 085fde7..50ad7e8 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -671,6 +671,7 @@ struct kvm_arch {
 */
struct list_head active_mmu_pages;
struct list_head zapped_obsolete_pages;
+   struct kvm_page_track_notifier_head track_notifier_head;
 
struct list_head assigned_dev_head;
struct iommu_domain *iommu_domain;
diff --git a/arch/x86/include/asm/kvm_page_track.h 
b/arch/x86/include/asm/kvm_page_track.h
index 97ac9c3..1aae4ef 100644
--- a/arch/x86/include/asm/kvm_page_track.h
+++ b/arch/x86/include/asm/kvm_page_track.h
@@ -6,6 +6,36 @@ enum kvm_page_track_mode {
KVM_PAGE_TRACK_MAX,
 };
 
+/*
+ * The notifier represented by @kvm_page_track_notifier_node is linked into
+ * the head which will be notified when guest is triggering the track event.
+ *
+ * Write access on the head is protected by kvm->mmu_lock, read access
+ * is protected by track_srcu.
+ */
+struct kvm_page_track_notifier_head {
+   struct srcu_struct track_srcu;
+   struct hlist_head track_notifier_list;
+};
+
+struct kvm_page_track_notifier_node {
+   struct hlist_node node;
+
+   /*
+* It is called when guest is writing the write-tracked page
+* and write emulation is finished at that time.
+*
+* @vcpu: the vcpu where the write access happened.
+* @gpa: the physical address written by guest.
+* @new: the data was written to the address.
+* @bytes: the written length.
+*/
+   void (*track_write)(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
+   int bytes);
+};
+
+void kvm_page_track_init(struct kvm *kvm);
+
 void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
 struct kvm_memory_slot *dont);
 int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
@@ -25,4 +55,13 @@ void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
enum kvm_page_track_mode mode);
 bool kvm_page_track_check_mode(struct kvm_vcpu *vcpu, gfn_t gfn,
   enum kvm_page_track_mode mode);
+
+void
+kvm_page_track_register_notifier(struct kvm *kvm,
+struct kvm_page_track_notifier_node *n);
+void
+kvm_page_track_unregister_notifier(struct kvm *kvm,
+  struct kvm_page_track_notifier_node *n);
+void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
+ int bytes);
 #endif
diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
index de9b32f..0692cc6 100644
--- a/arch/x86/kvm/page_track.c
+++ b/arch/x86/kvm/page_track.c
@@ -188,3 +188,70 @@ bool kvm_page_track_check_mode(struct kvm_vcpu *vcpu, 
gfn_t gfn,
 
return !!ACCESS_ONCE(slot->arch.gfn_track[mode][index]);
 }
+
+void kvm_page_track_init(struct kvm *kvm)
+{
+   struct kvm_page_track_notifier_head *head;
+
+   head = >arch.track_notifier_head;
+   init_srcu_struct(>track_srcu);
+   INIT_HLIST_HEAD(>track_notifier_list);
+}
+
+/*
+ * register the notifier so that event interception for the tracked guest
+ * pages can be received.
+ */
+void
+kvm_page_track_register_notifier(struct kvm *kvm,
+struct kvm_page_track_notifier_node *n)
+{
+   struct kvm_page_track_notifier_head *head;
+
+   head = >arch.track_notifier_head;
+
+   spin_lock(>mmu_lock);
+   hlist_add_head_rcu(>node, >track_notifier_list);
+   spin_unlock(>mmu_lock);
+}
+
+/*
+ * stop receiving the event interception. It is the opposed operation of
+ * kvm_page_track_register_notifier().
+ */
+void
+kvm_page_track_unregister_notifier(struct kvm *kvm,
+  struct kvm_page_track_notifier_node *n)
+{
+   struct kvm_page_track_notifier_head *head;
+
+   head = >arch.track_notifier_head;
+
+   spin_lock(>mmu_lock);
+   hlist_del_rcu(>node);
+   spin_unlock(>mmu_lock);
+   synchronize_srcu(>track_srcu);
+}
+
+/*
+ * Notify the node that write access is intercepted and write emulation is
+ * finished 

[PATCH v2 10/11] KVM: MMU: clear write-flooding on the fast path of tracked page

2015-12-23 Thread Xiao Guangrong
If the page fault is caused by write access on write tracked page, the
real shadow page walking is skipped, we lost the chance to clear write
flooding for the page structure current vcpu is using

Fix it by locklessly waking shadow page table to clear write flooding
on the shadow page structure out of mmu-lock. So that we change the
count to atomic_t

Signed-off-by: Xiao Guangrong 
---
 arch/x86/include/asm/kvm_host.h |  2 +-
 arch/x86/kvm/mmu.c  | 25 +
 arch/x86/kvm/paging_tmpl.h  |  4 +++-
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 50ad7e8..1d2968e 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -252,7 +252,7 @@ struct kvm_mmu_page {
 #endif
 
/* Number of writes since the last time traversal visited this page.  */
-   int write_flooding_count;
+   atomic_t write_flooding_count;
 };
 
 struct kvm_pio_request {
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index f89e77f..9f6a4ef 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2081,7 +2081,7 @@ static void init_shadow_page_table(struct kvm_mmu_page 
*sp)
 
 static void __clear_sp_write_flooding_count(struct kvm_mmu_page *sp)
 {
-   sp->write_flooding_count = 0;
+   atomic_set(>write_flooding_count,  0);
 }
 
 static void clear_sp_write_flooding_count(u64 *spte)
@@ -2461,8 +2461,7 @@ static void __kvm_unsync_page(struct kvm_vcpu *vcpu, 
struct kvm_mmu_page *sp)
kvm_mmu_mark_parents_unsync(sp);
 }
 
-static bool kvm_unsync_pages(struct kvm_vcpu *vcpu, gfn_t gfn,
-bool can_unsync)
+static bool kvm_unsync_pages(struct kvm_vcpu *vcpu,  gfn_t gfn, bool 
can_unsync)
 {
struct kvm_mmu_page *s;
 
@@ -3419,6 +3418,23 @@ static bool page_fault_handle_page_track(struct kvm_vcpu 
*vcpu,
return false;
 }
 
+static void shadow_page_table_clear_flood(struct kvm_vcpu *vcpu, gva_t addr)
+{
+   struct kvm_shadow_walk_iterator iterator;
+   u64 spte;
+
+   if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
+   return;
+
+   walk_shadow_page_lockless_begin(vcpu);
+   for_each_shadow_entry_lockless(vcpu, addr, iterator, spte) {
+   clear_sp_write_flooding_count(iterator.sptep);
+   if (!is_shadow_present_pte(spte))
+   break;
+   }
+   walk_shadow_page_lockless_end(vcpu);
+}
+
 static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
u32 error_code, bool prefault)
 {
@@ -4246,7 +4262,8 @@ static bool detect_write_flooding(struct kvm_mmu_page *sp)
if (sp->role.level == PT_PAGE_TABLE_LEVEL)
return false;
 
-   return ++sp->write_flooding_count >= 3;
+   atomic_inc(>write_flooding_count);
+   return atomic_read(>write_flooding_count) >= 3;
 }
 
 /*
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index ac85682..97fe5ac 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -735,8 +735,10 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t 
addr, u32 error_code,
return 0;
}
 
-   if (page_fault_handle_page_track(vcpu, error_code, walker.gfn))
+   if (page_fault_handle_page_track(vcpu, error_code, walker.gfn)) {
+   shadow_page_table_clear_flood(vcpu, addr);
return 1;
+   }
 
vcpu->arch.write_fault_to_shadow_pgtable = false;
 
-- 
1.8.3.1

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


[PATCH v2 04/11] KVM: page track: add the framework of guest page tracking

2015-12-23 Thread Xiao Guangrong
The array, gfn_track[mode][gfn], is introduced in memory slot for every
guest page, this is the tracking count for the gust page on different
modes. If the page is tracked then the count is increased, the page is
not tracked after the count reaches zero

We use 'unsigned short' as the tracking count which should be enough as
shadow page table only can use 2^14 (2^3 for level, 2^1 for cr4_pae, 2^2
for quadrant, 2^3 for access, 2^1 for nxe, 2^1 for cr0_wp, 2^1 for
smep_andnot_wp, 2^1 for smap_andnot_wp, and 2^1 for smm) at most, there
is enough room for other trackers

Two callbacks, kvm_page_track_create_memslot() and
kvm_page_track_free_memslot() are implemented in this patch, they are
internally used to initialize and reclaim the memory of the array

Currently, only write track mode is supported

Signed-off-by: Xiao Guangrong 
---
 arch/x86/include/asm/kvm_host.h   |  2 ++
 arch/x86/include/asm/kvm_page_track.h | 13 +
 arch/x86/kvm/Makefile |  3 +-
 arch/x86/kvm/page_track.c | 52 +++
 arch/x86/kvm/x86.c|  5 
 5 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/include/asm/kvm_page_track.h
 create mode 100644 arch/x86/kvm/page_track.c

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 1d37c1b..085fde7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define KVM_MAX_VCPUS 255
 #define KVM_SOFT_MAX_VCPUS 160
@@ -625,6 +626,7 @@ struct kvm_lpage_info {
 struct kvm_arch_memory_slot {
struct kvm_rmap_head *rmap[KVM_NR_PAGE_SIZES];
struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1];
+   unsigned short *gfn_track[KVM_PAGE_TRACK_MAX];
 };
 
 /*
diff --git a/arch/x86/include/asm/kvm_page_track.h 
b/arch/x86/include/asm/kvm_page_track.h
new file mode 100644
index 000..55200406
--- /dev/null
+++ b/arch/x86/include/asm/kvm_page_track.h
@@ -0,0 +1,13 @@
+#ifndef _ASM_X86_KVM_PAGE_TRACK_H
+#define _ASM_X86_KVM_PAGE_TRACK_H
+
+enum kvm_page_track_mode {
+   KVM_PAGE_TRACK_WRITE,
+   KVM_PAGE_TRACK_MAX,
+};
+
+void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
+struct kvm_memory_slot *dont);
+int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
+ unsigned long npages);
+#endif
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index a1ff508..464fa47 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -13,9 +13,10 @@ kvm-$(CONFIG_KVM_ASYNC_PF)   += $(KVM)/async_pf.o
 
 kvm-y  += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \
   i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o \
-  hyperv.o
+  hyperv.o page_track.o
 
 kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= assigned-dev.o iommu.o
+
 kvm-intel-y+= vmx.o pmu_intel.o
 kvm-amd-y  += svm.o pmu_amd.o
 
diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
new file mode 100644
index 000..8c396d0
--- /dev/null
+++ b/arch/x86/kvm/page_track.c
@@ -0,0 +1,52 @@
+/*
+ * Support KVM gust page tracking
+ *
+ * This feature allows us to track page access in guest. Currently, only
+ * write access is tracked.
+ *
+ * Copyright(C) 2015 Intel Corporation.
+ *
+ * Author:
+ *   Xiao Guangrong 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include 
+#include 
+#include 
+
+#include "mmu.h"
+
+void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
+struct kvm_memory_slot *dont)
+{
+   int i;
+
+   for (i = 0; i < KVM_PAGE_TRACK_MAX; i++)
+   if (!dont || free->arch.gfn_track[i] !=
+ dont->arch.gfn_track[i]) {
+   kvfree(free->arch.gfn_track[i]);
+   free->arch.gfn_track[i] = NULL;
+   }
+}
+
+int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
+ unsigned long npages)
+{
+   int  i;
+
+   for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) {
+   slot->arch.gfn_track[i] = kvm_kvzalloc(npages *
+   sizeof(*slot->arch.gfn_track[i]));
+   if (!slot->arch.gfn_track[i])
+   goto track_free;
+   }
+
+   return 0;
+
+track_free:
+   kvm_page_track_free_memslot(slot, NULL);
+   return -ENOMEM;
+}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a8c88a8..8ab1ad9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7844,6 +7844,8 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct 
kvm_memory_slot *free,

[PATCH v2 08/11] KVM: MMU: use page track for non-leaf shadow pages

2015-12-23 Thread Xiao Guangrong
non-leaf shadow pages are always write protected, it can be the user
of page track

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/mmu.c | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index b23f9fc..5a2ca73 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -806,11 +806,17 @@ static void account_shadowed(struct kvm *kvm, struct 
kvm_mmu_page *sp)
struct kvm_memory_slot *slot;
gfn_t gfn;
 
+   kvm->arch.indirect_shadow_pages++;
gfn = sp->gfn;
slots = kvm_memslots_for_spte_role(kvm, sp->role);
slot = __gfn_to_memslot(slots, gfn);
+
+   /* the non-leaf shadow pages are keeping readonly. */
+   if (sp->role.level > PT_PAGE_TABLE_LEVEL)
+   return kvm_slot_page_track_add_page_nolock(kvm, slot, gfn,
+   KVM_PAGE_TRACK_WRITE);
+
kvm_mmu_gfn_disallow_lpage(slot, gfn);
-   kvm->arch.indirect_shadow_pages++;
 }
 
 static void unaccount_shadowed(struct kvm *kvm, struct kvm_mmu_page *sp)
@@ -819,11 +825,15 @@ static void unaccount_shadowed(struct kvm *kvm, struct 
kvm_mmu_page *sp)
struct kvm_memory_slot *slot;
gfn_t gfn;
 
+   kvm->arch.indirect_shadow_pages--;
gfn = sp->gfn;
slots = kvm_memslots_for_spte_role(kvm, sp->role);
slot = __gfn_to_memslot(slots, gfn);
+   if (sp->role.level > PT_PAGE_TABLE_LEVEL)
+   return kvm_slot_page_track_remove_page_nolock(kvm, slot, gfn,
+   KVM_PAGE_TRACK_WRITE);
+
kvm_mmu_gfn_allow_lpage(slot, gfn);
-   kvm->arch.indirect_shadow_pages--;
 }
 
 static bool __mmu_gfn_lpage_is_disallowed(gfn_t gfn, int level,
@@ -2140,12 +2150,18 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct 
kvm_vcpu *vcpu,
hlist_add_head(>hash_link,
>kvm->arch.mmu_page_hash[kvm_page_table_hashfn(gfn)]);
if (!direct) {
-   if (rmap_write_protect(vcpu, gfn))
+   /*
+* we should do write protection before syncing pages
+* otherwise the content of the synced shadow page may
+* be inconsistent with guest page table.
+*/
+   account_shadowed(vcpu->kvm, sp);
+
+   if (level == PT_PAGE_TABLE_LEVEL &&
+ rmap_write_protect(vcpu, gfn))
kvm_flush_remote_tlbs(vcpu->kvm);
if (level > PT_PAGE_TABLE_LEVEL && need_sync)
kvm_sync_pages(vcpu, gfn);
-
-   account_shadowed(vcpu->kvm, sp);
}
sp->mmu_valid_gen = vcpu->kvm->arch.mmu_valid_gen;
init_shadow_page_table(sp);
-- 
1.8.3.1

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


[PATCH v2 11/11] KVM: MMU: apply page track notifier

2015-12-23 Thread Xiao Guangrong
Register the notifier to receive write track event so that we can update
our shadow page table

It makes kvm_mmu_pte_write() be the callback of the notifier, no function
is changed

Signed-off-by: Xiao Guangrong 
---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/mmu.c  | 19 +--
 arch/x86/kvm/x86.c  |  4 ++--
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 1d2968e..28f5c7d 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -671,6 +671,7 @@ struct kvm_arch {
 */
struct list_head active_mmu_pages;
struct list_head zapped_obsolete_pages;
+   struct kvm_page_track_notifier_node mmu_sp_tracker;
struct kvm_page_track_notifier_head track_notifier_head;
 
struct list_head assigned_dev_head;
@@ -966,6 +967,8 @@ void kvm_mmu_module_exit(void);
 void kvm_mmu_destroy(struct kvm_vcpu *vcpu);
 int kvm_mmu_create(struct kvm_vcpu *vcpu);
 void kvm_mmu_setup(struct kvm_vcpu *vcpu);
+void kvm_mmu_init_vm(struct kvm *kvm);
+void kvm_mmu_uninit_vm(struct kvm *kvm);
 void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask,
u64 dirty_mask, u64 nx_mask, u64 x_mask);
 
@@ -1105,8 +1108,6 @@ void kvm_pic_clear_all(struct kvm_pic *pic, int 
irq_source_id);
 
 void kvm_inject_nmi(struct kvm_vcpu *vcpu);
 
-void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
-  const u8 *new, int bytes);
 int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn);
 int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
 void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 9f6a4ef..a420c43 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4325,8 +4325,8 @@ static u64 *get_written_sptes(struct kvm_mmu_page *sp, 
gpa_t gpa, int *nspte)
return spte;
 }
 
-void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
-  const u8 *new, int bytes)
+static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
+ const u8 *new, int bytes)
 {
gfn_t gfn = gpa >> PAGE_SHIFT;
struct kvm_mmu_page *sp;
@@ -4540,6 +4540,21 @@ void kvm_mmu_setup(struct kvm_vcpu *vcpu)
init_kvm_mmu(vcpu);
 }
 
+void kvm_mmu_init_vm(struct kvm *kvm)
+{
+   struct kvm_page_track_notifier_node *node = >arch.mmu_sp_tracker;
+
+   node->track_write = kvm_mmu_pte_write;
+   kvm_page_track_register_notifier(kvm, node);
+}
+
+void kvm_mmu_uninit_vm(struct kvm *kvm)
+{
+   struct kvm_page_track_notifier_node *node = >arch.mmu_sp_tracker;
+
+   kvm_page_track_unregister_notifier(kvm, node);
+}
+
 /* The return value indicates if tlb flush on all vcpus is needed. */
 typedef bool (*slot_level_handler) (struct kvm *kvm, struct kvm_rmap_head 
*rmap_head);
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dc43d99..f06a4fc 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4330,7 +4330,6 @@ int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
ret = kvm_vcpu_write_guest(vcpu, gpa, val, bytes);
if (ret < 0)
return 0;
-   kvm_mmu_pte_write(vcpu, gpa, val, bytes);
kvm_page_track_write(vcpu, gpa, val, bytes);
return 1;
 }
@@ -4589,7 +4588,6 @@ static int emulator_cmpxchg_emulated(struct 
x86_emulate_ctxt *ctxt,
return X86EMUL_CMPXCHG_FAILED;
 
kvm_vcpu_mark_page_dirty(vcpu, gpa >> PAGE_SHIFT);
-   kvm_mmu_pte_write(vcpu, gpa, new, bytes);
kvm_page_track_write(vcpu, gpa, new, bytes);
 
return X86EMUL_CONTINUE;
@@ -7700,6 +7698,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
INIT_DELAYED_WORK(>arch.kvmclock_sync_work, kvmclock_sync_fn);
 
kvm_page_track_init(kvm);
+   kvm_mmu_init_vm(kvm);
 
return 0;
 }
@@ -7827,6 +7826,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
kfree(kvm->arch.vioapic);
kvm_free_vcpus(kvm);
kfree(rcu_dereference_check(kvm->arch.apic_map, 1));
+   kvm_mmu_uninit_vm(kvm);
 }
 
 void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
-- 
1.8.3.1

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


[PATCH v2 05/11] KVM: page track: introduce kvm_page_track_{add,remove}_page

2015-12-23 Thread Xiao Guangrong
These two functions are the user APIs:
- kvm_page_track_add_page(): add the page to the tracking pool after
  that later specified access on that page will be tracked

- kvm_page_track_remove_page(): remove the page from the tracking pool,
  the specified access on the page is not tracked after the last user is
  gone

Both of these are called under the protection of kvm->srcu or
kvm->slots_lock

Signed-off-by: Xiao Guangrong 
---
 arch/x86/include/asm/kvm_page_track.h |  13 
 arch/x86/kvm/page_track.c | 124 ++
 2 files changed, 137 insertions(+)

diff --git a/arch/x86/include/asm/kvm_page_track.h 
b/arch/x86/include/asm/kvm_page_track.h
index 55200406..c010124 100644
--- a/arch/x86/include/asm/kvm_page_track.h
+++ b/arch/x86/include/asm/kvm_page_track.h
@@ -10,4 +10,17 @@ void kvm_page_track_free_memslot(struct kvm_memory_slot 
*free,
 struct kvm_memory_slot *dont);
 int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
  unsigned long npages);
+
+void
+kvm_slot_page_track_add_page_nolock(struct kvm *kvm,
+   struct kvm_memory_slot *slot, gfn_t gfn,
+   enum kvm_page_track_mode mode);
+void kvm_page_track_add_page(struct kvm *kvm, gfn_t gfn,
+enum kvm_page_track_mode mode);
+void kvm_slot_page_track_remove_page_nolock(struct kvm *kvm,
+   struct kvm_memory_slot *slot,
+   gfn_t gfn,
+   enum kvm_page_track_mode mode);
+void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
+   enum kvm_page_track_mode mode);
 #endif
diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
index 8c396d0..e17efe9 100644
--- a/arch/x86/kvm/page_track.c
+++ b/arch/x86/kvm/page_track.c
@@ -50,3 +50,127 @@ track_free:
kvm_page_track_free_memslot(slot, NULL);
return -ENOMEM;
 }
+
+static bool check_mode(enum kvm_page_track_mode mode)
+{
+   if (mode < 0 || mode >= KVM_PAGE_TRACK_MAX)
+   return false;
+
+   return true;
+}
+
+static void update_gfn_track(struct kvm_memory_slot *slot, gfn_t gfn,
+enum kvm_page_track_mode mode, short count)
+{
+   int index;
+   unsigned short val;
+
+   index = gfn_to_index(gfn, slot->base_gfn, PT_PAGE_TABLE_LEVEL);
+
+   val = slot->arch.gfn_track[mode][index];
+
+   /* does tracking count wrap? */
+   WARN_ON((count > 0) && (val + count < val));
+   /* the last tracker has already gone? */
+   WARN_ON((count < 0) && (val < !count));
+
+   slot->arch.gfn_track[mode][index] += count;
+}
+
+void
+kvm_slot_page_track_add_page_nolock(struct kvm *kvm,
+   struct kvm_memory_slot *slot, gfn_t gfn,
+   enum kvm_page_track_mode mode)
+{
+
+   WARN_ON(!check_mode(mode));
+
+   update_gfn_track(slot, gfn, mode, 1);
+
+   /*
+* new track stops large page mapping for the
+* tracked page.
+*/
+   kvm_mmu_gfn_disallow_lpage(slot, gfn);
+
+   if (mode == KVM_PAGE_TRACK_WRITE)
+   if (kvm_mmu_slot_gfn_write_protect(kvm, slot, gfn))
+   kvm_flush_remote_tlbs(kvm);
+}
+
+/*
+ * add guest page to the tracking pool so that corresponding access on that
+ * page will be intercepted.
+ *
+ * It should be called under the protection of kvm->srcu or kvm->slots_lock
+ *
+ * @kvm: the guest instance we are interested in.
+ * @gfn: the guest page.
+ * @mode: tracking mode, currently only write track is supported.
+ */
+void kvm_page_track_add_page(struct kvm *kvm, gfn_t gfn,
+enum kvm_page_track_mode mode)
+{
+   struct kvm_memslots *slots;
+   struct kvm_memory_slot *slot;
+   int i;
+
+   for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
+   slots = __kvm_memslots(kvm, i);
+
+   slot = __gfn_to_memslot(slots, gfn);
+   if (!slot)
+   continue;
+
+   spin_lock(>mmu_lock);
+   kvm_slot_page_track_add_page_nolock(kvm, slot, gfn, mode);
+   spin_unlock(>mmu_lock);
+   }
+}
+
+void kvm_slot_page_track_remove_page_nolock(struct kvm *kvm,
+   struct kvm_memory_slot *slot,
+   gfn_t gfn,
+   enum kvm_page_track_mode mode)
+{
+   WARN_ON(!check_mode(mode));
+
+   update_gfn_track(slot, gfn, mode, -1);
+
+   /*
+* allow large page mapping for the tracked page
+* after the tracker is gone.
+*/
+   kvm_mmu_gfn_allow_lpage(slot, gfn);
+}
+
+/*
+ * remove the guest page from the tracking pool which stops the 

[PATCH v2 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-23 Thread Xiao Guangrong
Now, all non-leaf shadow page are page tracked, if gfn is not tracked
there is no non-leaf shadow page of gfn is existed, we can directly
make the shadow page of gfn to unsync

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/mmu.c | 26 --
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 5a2ca73..f89e77f 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2461,41 +2461,31 @@ static void __kvm_unsync_page(struct kvm_vcpu *vcpu, 
struct kvm_mmu_page *sp)
kvm_mmu_mark_parents_unsync(sp);
 }
 
-static void kvm_unsync_pages(struct kvm_vcpu *vcpu,  gfn_t gfn)
+static bool kvm_unsync_pages(struct kvm_vcpu *vcpu, gfn_t gfn,
+bool can_unsync)
 {
struct kvm_mmu_page *s;
 
for_each_gfn_indirect_valid_sp(vcpu->kvm, s, gfn) {
+   if (!can_unsync)
+   return true;
+
if (s->unsync)
continue;
WARN_ON(s->role.level != PT_PAGE_TABLE_LEVEL);
__kvm_unsync_page(vcpu, s);
}
+
+   return false;
 }
 
 static bool mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,
   bool can_unsync)
 {
-   struct kvm_mmu_page *s;
-   bool need_unsync = false;
-
if (kvm_page_track_check_mode(vcpu, gfn, KVM_PAGE_TRACK_WRITE))
return true;
 
-   for_each_gfn_indirect_valid_sp(vcpu->kvm, s, gfn) {
-   if (!can_unsync)
-   return true;
-
-   if (s->role.level != PT_PAGE_TABLE_LEVEL)
-   return true;
-
-   if (!s->unsync)
-   need_unsync = true;
-   }
-   if (need_unsync)
-   kvm_unsync_pages(vcpu, gfn);
-
-   return false;
+   return kvm_unsync_pages(vcpu, gfn, can_unsync);
 }
 
 static bool kvm_is_mmio_pfn(pfn_t pfn)
-- 
1.8.3.1

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


[PATCH v2 02/11] KVM: MMU: introduce kvm_mmu_gfn_{allow,disallow}_lpage

2015-12-23 Thread Xiao Guangrong
Abstract the common operations from account_shadowed() and
unaccount_shadowed(), then introduce kvm_mmu_gfn_disallow_lpage()
and kvm_mmu_gfn_allow_lpage()

These two functions will be used by page tracking in the later patch

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/mmu.c | 38 +-
 arch/x86/kvm/mmu.h |  3 +++
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 61259ff..4b04d13 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -776,21 +776,39 @@ static struct kvm_lpage_info *lpage_info_slot(gfn_t gfn,
return >arch.lpage_info[level - 2][idx];
 }
 
+static void update_gfn_disallow_lpage_count(struct kvm_memory_slot *slot,
+   gfn_t gfn, int count)
+{
+   struct kvm_lpage_info *linfo;
+   int i;
+
+   for (i = PT_DIRECTORY_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) {
+   linfo = lpage_info_slot(gfn, slot, i);
+   linfo->disallow_lpage += count;
+   WARN_ON(linfo->disallow_lpage < 0);
+   }
+}
+
+void kvm_mmu_gfn_disallow_lpage(struct kvm_memory_slot *slot, gfn_t gfn)
+{
+   update_gfn_disallow_lpage_count(slot, gfn, 1);
+}
+
+void kvm_mmu_gfn_allow_lpage(struct kvm_memory_slot *slot, gfn_t gfn)
+{
+   update_gfn_disallow_lpage_count(slot, gfn, -1);
+}
+
 static void account_shadowed(struct kvm *kvm, struct kvm_mmu_page *sp)
 {
struct kvm_memslots *slots;
struct kvm_memory_slot *slot;
-   struct kvm_lpage_info *linfo;
gfn_t gfn;
-   int i;
 
gfn = sp->gfn;
slots = kvm_memslots_for_spte_role(kvm, sp->role);
slot = __gfn_to_memslot(slots, gfn);
-   for (i = PT_DIRECTORY_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) {
-   linfo = lpage_info_slot(gfn, slot, i);
-   linfo->disallow_lpage += 1;
-   }
+   kvm_mmu_gfn_disallow_lpage(slot, gfn);
kvm->arch.indirect_shadow_pages++;
 }
 
@@ -798,18 +816,12 @@ static void unaccount_shadowed(struct kvm *kvm, struct 
kvm_mmu_page *sp)
 {
struct kvm_memslots *slots;
struct kvm_memory_slot *slot;
-   struct kvm_lpage_info *linfo;
gfn_t gfn;
-   int i;
 
gfn = sp->gfn;
slots = kvm_memslots_for_spte_role(kvm, sp->role);
slot = __gfn_to_memslot(slots, gfn);
-   for (i = PT_DIRECTORY_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) {
-   linfo = lpage_info_slot(gfn, slot, i);
-   linfo->disallow_lpage -= 1;
-   WARN_ON(linfo->disallow_lpage < 0);
-   }
+   kvm_mmu_gfn_allow_lpage(slot, gfn);
kvm->arch.indirect_shadow_pages--;
 }
 
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index 55ffb7b..de92bed 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -174,4 +174,7 @@ static inline bool permission_fault(struct kvm_vcpu *vcpu, 
struct kvm_mmu *mmu,
 
 void kvm_mmu_invalidate_zap_all_pages(struct kvm *kvm);
 void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end);
+
+void kvm_mmu_gfn_disallow_lpage(struct kvm_memory_slot *slot, gfn_t gfn);
+void kvm_mmu_gfn_allow_lpage(struct kvm_memory_slot *slot, gfn_t gfn);
 #endif
-- 
1.8.3.1

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


Re: [PATCH] regulator: s2m,s5m: constify regulator_ops structures

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 08:20:43AM +0100, Julia Lawall wrote:
> On Wed, 23 Dec 2015, Mark Brown wrote:

> > On Sat, Dec 19, 2015 at 03:58:00PM +0100, Julia Lawall wrote:
> > > The regulator_ops structures are never modified, so declare them as const.

> > > Done with the help of Coccinelle.

> > This doesn't apply against current code, please check and resend.

> It works fine for me on today's linux-next (80c75a0f1d).  What goes wrong?

It just doesn't apply against my tree.  Presumably there's a change
somewhere else in -next (probably the MFD tree).


signature.asc
Description: PGP signature


[PATCH v2 01/11] KVM: MMU: rename has_wrprotected_page to mmu_gfn_lpage_is_disallowed

2015-12-23 Thread Xiao Guangrong
kvm_lpage_info->write_count is used to detect if the large page mapping
for the gfn on the specified level is allowed, rename it to disallow_lpage
to reflect its purpose, also we rename has_wrprotected_page() to
mmu_gfn_lpage_is_disallowed() to make the code more clearer

Later we will extend this mechanism for page tracking: if the gfn is
tracked then large mapping for that gfn on any level is not allowed.
The new name is more straightforward

Signed-off-by: Xiao Guangrong 
---
 Documentation/virtual/kvm/mmu.txt |  6 +++---
 arch/x86/include/asm/kvm_host.h   |  2 +-
 arch/x86/kvm/mmu.c| 25 +
 arch/x86/kvm/x86.c| 14 --
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/Documentation/virtual/kvm/mmu.txt 
b/Documentation/virtual/kvm/mmu.txt
index daf9c0f..dda2e93 100644
--- a/Documentation/virtual/kvm/mmu.txt
+++ b/Documentation/virtual/kvm/mmu.txt
@@ -391,11 +391,11 @@ To instantiate a large spte, four constraints must be 
satisfied:
   write-protected pages
 - the guest page must be wholly contained by a single memory slot
 
-To check the last two conditions, the mmu maintains a ->write_count set of
+To check the last two conditions, the mmu maintains a ->disallow_lpage set of
 arrays for each memory slot and large page size.  Every write protected page
-causes its write_count to be incremented, thus preventing instantiation of
+causes its disallow_lpage to be incremented, thus preventing instantiation of
 a large spte.  The frames at the end of an unaligned memory slot have
-artificially inflated ->write_counts so they can never be instantiated.
+artificially inflated ->disallow_lpages so they can never be instantiated.
 
 Zapping all pages (page generation count)
 =
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index a7c8987..1d37c1b 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -619,7 +619,7 @@ struct kvm_vcpu_arch {
 };
 
 struct kvm_lpage_info {
-   int write_count;
+   int disallow_lpage;
 };
 
 struct kvm_arch_memory_slot {
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a1a3d19..61259ff 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -789,7 +789,7 @@ static void account_shadowed(struct kvm *kvm, struct 
kvm_mmu_page *sp)
slot = __gfn_to_memslot(slots, gfn);
for (i = PT_DIRECTORY_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) {
linfo = lpage_info_slot(gfn, slot, i);
-   linfo->write_count += 1;
+   linfo->disallow_lpage += 1;
}
kvm->arch.indirect_shadow_pages++;
 }
@@ -807,31 +807,32 @@ static void unaccount_shadowed(struct kvm *kvm, struct 
kvm_mmu_page *sp)
slot = __gfn_to_memslot(slots, gfn);
for (i = PT_DIRECTORY_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) {
linfo = lpage_info_slot(gfn, slot, i);
-   linfo->write_count -= 1;
-   WARN_ON(linfo->write_count < 0);
+   linfo->disallow_lpage -= 1;
+   WARN_ON(linfo->disallow_lpage < 0);
}
kvm->arch.indirect_shadow_pages--;
 }
 
-static int __has_wrprotected_page(gfn_t gfn, int level,
- struct kvm_memory_slot *slot)
+static bool __mmu_gfn_lpage_is_disallowed(gfn_t gfn, int level,
+ struct kvm_memory_slot *slot)
 {
struct kvm_lpage_info *linfo;
 
if (slot) {
linfo = lpage_info_slot(gfn, slot, level);
-   return linfo->write_count;
+   return !!linfo->disallow_lpage;
}
 
-   return 1;
+   return true;
 }
 
-static int has_wrprotected_page(struct kvm_vcpu *vcpu, gfn_t gfn, int level)
+static bool mmu_gfn_lpage_is_disallowed(struct kvm_vcpu *vcpu, gfn_t gfn,
+   int level)
 {
struct kvm_memory_slot *slot;
 
slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
-   return __has_wrprotected_page(gfn, level, slot);
+   return __mmu_gfn_lpage_is_disallowed(gfn, level, slot);
 }
 
 static int host_mapping_level(struct kvm *kvm, gfn_t gfn)
@@ -897,7 +898,7 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t 
large_gfn,
max_level = min(kvm_x86_ops->get_lpage_level(), host_level);
 
for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level)
-   if (__has_wrprotected_page(large_gfn, level, slot))
+   if (__mmu_gfn_lpage_is_disallowed(large_gfn, level, slot))
break;
 
return level - 1;
@@ -2511,7 +2512,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
 * be fixed if guest refault.
 */
if (level > PT_PAGE_TABLE_LEVEL &&
-   has_wrprotected_page(vcpu, gfn, level))
+   mmu_gfn_lpage_is_disallowed(vcpu, 

[PATCH v2 03/11] KVM: MMU: introduce kvm_mmu_slot_gfn_write_protect

2015-12-23 Thread Xiao Guangrong
Split rmap_write_protect() and introduce the function to abstract the write
protection based on the slot

This function will be used in the later patch

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/mmu.c | 16 +++-
 arch/x86/kvm/mmu.h |  2 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 4b04d13..39809b8 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1336,23 +1336,29 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm 
*kvm,
kvm_mmu_write_protect_pt_masked(kvm, slot, gfn_offset, mask);
 }
 
-static bool rmap_write_protect(struct kvm_vcpu *vcpu, u64 gfn)
+bool kvm_mmu_slot_gfn_write_protect(struct kvm *kvm,
+   struct kvm_memory_slot *slot, u64 gfn)
 {
-   struct kvm_memory_slot *slot;
struct kvm_rmap_head *rmap_head;
int i;
bool write_protected = false;
 
-   slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
-
for (i = PT_PAGE_TABLE_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) {
rmap_head = __gfn_to_rmap(gfn, i, slot);
-   write_protected |= __rmap_write_protect(vcpu->kvm, rmap_head, 
true);
+   write_protected |= __rmap_write_protect(kvm, rmap_head, true);
}
 
return write_protected;
 }
 
+static bool rmap_write_protect(struct kvm_vcpu *vcpu, u64 gfn)
+{
+   struct kvm_memory_slot *slot;
+
+   slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
+   return kvm_mmu_slot_gfn_write_protect(vcpu->kvm, slot, gfn);
+}
+
 static bool kvm_zap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
 {
u64 *sptep;
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index de92bed..58fe98a 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -177,4 +177,6 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, 
gfn_t gfn_end);
 
 void kvm_mmu_gfn_disallow_lpage(struct kvm_memory_slot *slot, gfn_t gfn);
 void kvm_mmu_gfn_allow_lpage(struct kvm_memory_slot *slot, gfn_t gfn);
+bool kvm_mmu_slot_gfn_write_protect(struct kvm *kvm,
+   struct kvm_memory_slot *slot, u64 gfn);
 #endif
-- 
1.8.3.1

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


Re: [PATCH 3/6] ASoC: da7219: Update REFERENCES reg default, in-line with HW

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 09:47:23AM +, Opensource [Adam Thomson] wrote:
> On December 23, 2015 00:10, Mark Brown wrote:

> > This is the sort of thing where a register patch would normally be used
> > - if you put in a register patch for the older silicon then the driver
> > can correct for the register default automatically.

> Thanks. Yes, am aware of that. Were the older silicon still in use then I'd 
> have
> taken that route, but didn't seem necessary in this instance.

It costs you nothing to do it properly and you might be surprised how
often older silicon turns up somewhere.


signature.asc
Description: PGP signature


Re: [PATCH 3/6] regulator: lp872x: Remove warning about invalid DVS GPIO

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 11:58:36AM +0100, Paul Kocialkowski wrote:
> Some devices don't hook the DVS pin to a GPIO but to ground or VCC.
> In those cases, it is not a problem to have no DVS GPIO.

I would expect the driver at least needs to know how the pins or
strapped, or otherwise have configuration for ignoring the input on the
pins.  This just deletes the warnings, it doesn't have any handling for
this case that I can see.


signature.asc
Description: PGP signature


Re: [RFC LINUX PATCH] dt: xilinx: xadc: provision to control clock frequency

2015-12-23 Thread Sören Brinkmann
On Wed, 2015-12-23 at 03:58PM +0530, Ranjit Waghmode wrote:
> This patch adds parameter to the xilinx-xadc node for controlling
> clock frequency.
> 
> Following are the possible options for user to control the frequency:
>   * 00 : 1/2 of clock frequency
>   * 01 : 1/4 of clock frequency
>   * 10 : 1/8 of clock frequency
>   * 11 : 1/16 of clock frequency

How is this chosen? Are these just arbitrary values that you need for
some use-case? Or are these the options HW allows?

> 
> So this patch adds parameter tck-rate to set user defined values from
> above pool to control the clock frequency.

This is no longer describing HW, but configuring driver/HW. Why does
this have to be in DT? Why can't the driver request/set the frequency as
operation requires it?

Thanks,
Sören
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] IMA: policy can be updated zero times

2015-12-23 Thread Petko Manolov
On 15-12-22 16:50:01, Sasha Levin wrote:
> On 12/22/2015 04:40 PM, Petko Manolov wrote:
> >> Thanks, Sasha.  By the time ima_update_policy() is called
> >> >ima_release_policy() has already output the policy update status
> >> >message.  I guess an empty policy could be considered a valid policy.
> >> >Could you add a msg indicating that the new policy was empty?
> > 
> > As far as I can say we can't get to ima_update_policy() with empty 
> > ima_temp_rules because ima_write_policy() will set valid_policy to 0 in 
> > case 
> > of an empty rule.  I'll double check it tomorrow, but please you do that 
> > too.
> 
> This is based on an actual crash rather than code analysis.

I was able to reproduce the crash with: echo "" > 
/sys/kernel/security/ima/policy

It turns out ima_parse_add_rule() returns 1, even though the string is empty 
This logic may be part of "empty policy is a valid policy" or something else.  
As it is more dangerous to change the behavior at this point i assume your 
patch 
is the right solution for the problem.

Acked-by: Petko Manolov 

Mimi, shall we change ima_parse_add_rule's behavior in the future or it's too 
much work?


cheers,
Petko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] PM / Domains: Release mutex when powering on master domain

2015-12-23 Thread Ulf Hansson
On 22 December 2015 at 14:13, Daniel Kurtz  wrote:
> Commit ba2bbfbf6307 (PM / Domains: Remove intermediate states from the
> power off sequence) removed the mutex_unlock()/_lock() around powering on
> a genpd's master domain in __genpd_poweron().
>
> Since all genpd's share a mutex lockdep class, this causes a "possible
> recursive locking detected" lockdep warning on boot when trying to power
> on a genpd slave domain:
>
> [1.893137] =
> [1.893139] [ INFO: possible recursive locking detected ]
> [1.893143] 3.18.0 #531 Not tainted
> [1.893145] -
> [1.893148] kworker/u8:4/113 is trying to acquire lock:
> [1.893167]  (>lock){+.+...}, at: [] 
> genpd_poweron+0x30/0x70
> [1.893169]
> [1.893169] but task is already holding lock:
> [1.893179]  (>lock){+.+...}, at: [] 
> genpd_poweron+0x30/0x70
> [1.893182]
> [1.893182] other info that might help us debug this:
> [1.893184]  Possible unsafe locking scenario:
> [1.893184]
> [1.893185]CPU0
> [1.893187]
> [1.893191]   lock(>lock);
> [1.893195]   lock(>lock);
> [1.893196]
> [1.893196]  *** DEADLOCK ***
> [1.893196]
> [1.893198]  May be due to missing lock nesting notation
> [1.893198]
> [1.893201] 4 locks held by kworker/u8:4/113:
> [1.893217]  #0:  ("%s""deferwq"){.+}, at: [] 
> process_one_work+0x1f8/0x50c
> [1.893229]  #1:  (deferred_probe_work){+.+.+.}, at: [] 
> process_one_work+0x1f8/0x50c
> [1.893241]  #2:  (>mutex){..}, at: [] 
> __device_attach+0x40/0x12c
> [1.893251]  #3:  (>lock){+.+...}, at: [] 
> genpd_poweron+0x30/0x70
> [1.893253]
> [1.893253] stack backtrace:
> [1.893259] CPU: 2 PID: 113 Comm: kworker/u8:4 Not tainted 3.18.0 #531
> [1.893269] Workqueue: deferwq deferred_probe_work_func
> [1.893271] Call trace:
> [1.893295] [] __lock_acquire+0x68c/0x19a8
> [1.893299] [] lock_acquire+0x128/0x164
> [1.893304] [] mutex_lock_nested+0x90/0x3b4
> [1.893308] [] genpd_poweron+0x2c/0x70
> [1.893312] [] __genpd_poweron.part.14+0x54/0xcc
> [1.893316] [] genpd_poweron+0x4c/0x70
> [1.893321] [] genpd_dev_pm_attach+0x160/0x19c
> [1.893326] [] dev_pm_domain_attach+0x1c/0x2c
> ...
>
> Fix this by releasing the slaves mutex before acquiring the master's,
> which restores the old behavior.
>
> Cc: sta...@vger.kernel.org
> Fixes: 5d837eef7b99 ("PM / Domains: Remove intermediate states from the power 
> off sequence")
> Signed-off-by: Daniel Kurtz 
> ---
>  drivers/base/power/domain.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 65f50ec..56fa335 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -196,7 +196,12 @@ static int __genpd_poweron(struct generic_pm_domain 
> *genpd)
> list_for_each_entry(link, >slave_links, slave_node) {
> genpd_sd_counter_inc(link->master);
>
> +   mutex_unlock(>lock);
> +
> ret = genpd_poweron(link->master);
> +
> +   mutex_lock(>lock);
> +
> if (ret) {
> genpd_sd_counter_dec(link->master);
> goto err;
> --
> 2.6.0.rc2.230.g3dd15c0
>

As we no longer have protection to deal with intermediate power
states, releasing the lock would mean that __genpd_poweron() can be
called for the same genpd as we just were operating on.

Since the genpd->status hasn't become GPD_STATE_ACTIVE yet, that means
a new power up cycle may start. For example causing the atomic
subdomain count to increase once more. Not good. :-)

So, this approach doesn't work.

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] usb: gadget: f_midi: refactor state machine

2015-12-23 Thread Felipe Ferreri Tonello
Hi Clemens,

On 22/12/15 17:10, Clemens Ladisch wrote:
> Felipe F. Tonello wrote:
>> This refactor includes the following:
>>  * Cleaner state machine code;
> 
> It does not correctly handle system real time messages inserted between
> the status and data bytes of other messages.

True, thanks for pointing that out. I fixed that on next revision of
this patch.

> 
>>  * Reset state if MIDI message parsed is non-conformant;
> 
> Why?  In a byte stream like "C1 C3 44", where the data byte of the first
> message was lost, the reset would also drop the second message.

True. That was fixed as well.

> 
>>  * Fixed bug when a conformant MIDI message was followed by a non-conformant
>>causing the MIDI-USB message to use old temporary data (port->data[0..1]),
>>thus packing a wrong MIDI-USB request.
> 
> Running status is feature.

What do you mean by that? I don't qualify writing a *wrong* MIDI-USB
packet because of a previous MIDI message as a feature.

For instance, try this MIDI message:
"8A 54 24 00 40"

It will be converted to MIDI-USB as "08 8A 54 24 08 8A 00 40" which is
wrong. It should only be "08 8A 54 24" and ignore the "00 40" MIDI bytes.

On every state byte the message should basically reset data[0..1] to
zero overwriting previous data. This should also be true when a MIDI-USB
packet is complete.

Felipe


0x92698E6A.asc
Description: application/pgp-keys


Suspend To RAM failure in >= 4.1 - bissected to "drm/i915: Track GEN6 page table usage"

2015-12-23 Thread Sylvain Munaut
Hi,


When trying to upgrade my kernel yesterday to the latest 4.3.3 I
noticed that the suspend to ram was not working. Basically it goes to
sleep but never wakes up. It seems to power up but no screen, not
available through ssh either and afaict nothing runs afterwards.

I first tried a couple official release to see where it broke and I
found that 4.0.9 was working fine, but 4.1.15 was not.

I then ran a git bissect between v4.0 and v4.1 from Linus's tree and
found the "guilty" commit was

commit 317b4e903636305cfe702ab3e5b3d68547a69e72
Author: Ben Widawsky 
Date:   Mon Mar 16 16:00:55 2015 +

drm/i915: Extract context switch skip and add pd load logic


Here's the full log :

git bisect start
# bad: [b953c0d234bc72e8489d3bf51a276c5c4ec85345] Linux 4.1
git bisect bad b953c0d234bc72e8489d3bf51a276c5c4ec85345
# good: [39a8804455fb23f09157341d3ba7db6d7ae6ee76] Linux 4.0
git bisect good 39a8804455fb23f09157341d3ba7db6d7ae6ee76
# good: [d0a3997c0c3f9351e24029349dee65dd1d9e8d84] Merge tag
'sound-4.1-rc1' of
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
git bisect good d0a3997c0c3f9351e24029349dee65dd1d9e8d84
# bad: [cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58] watchdog:
stmp3xxx_rtc_wdt: fix broken email address
git bisect bad cf82f52d3619d2e15c83ec9a03c6ce8cdf6c6b58
# good: [79319a052cb0ae862954fe9f6e606417f1698ddb] Merge tag
'iommu-updates-v4.1' of
git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
git bisect good 79319a052cb0ae862954fe9f6e606417f1698ddb
# bad: [8f443e2372ba23d51ee365974f54507acd6f69d1] Revert "ocfs2:
incorrect check for debugfs returns"
git bisect bad 8f443e2372ba23d51ee365974f54507acd6f69d1
# bad: [3165c074175cddab1dcfd553042ea4f363bc76e7] drm/i915: Use atomic
state in intel_ddi_crtc_get_new_encoder()
git bisect bad 3165c074175cddab1dcfd553042ea4f363bc76e7
# good: [8dd0eb3566711d81bfbe2b4421b33f0dd723cec4] Merge tag
'drm-intel-next-2015-02-27' of git://anongit.freedesktop.org/drm-intel
into drm-next
git bisect good 8dd0eb3566711d81bfbe2b4421b33f0dd723cec4
# good: [5704195c3f3c04a00c16334a033b180f16db1f94] drm/i915/skl:
Updated the gen6_set_rps function
git bisect good 5704195c3f3c04a00c16334a033b180f16db1f94
# good: [07749ef32c4fd60334c2451739460dd1cf600281] drm/i915: page
table generalizations
git bisect good 07749ef32c4fd60334c2451739460dd1cf600281
# bad: [58072ccbb81c6f2d67c5b4cc7597707c4fb86a5e] drm/i915: fix race
when clearing RPS IIR bits
git bisect bad 58072ccbb81c6f2d67c5b4cc7597707c4fb86a5e
# bad: [48fe4691ae639e60fda37faf06dccdff60245149] drm/i915: Eliminate
plane control register RMW from sprite code
git bisect bad 48fe4691ae639e60fda37faf06dccdff60245149
# bad: [bdd7554d568fa165b0e86fc32b1cde3c895ff774] drm/i915: Kill
intel_plane->obj
git bisect bad bdd7554d568fa165b0e86fc32b1cde3c895ff774
# bad: [678d96fbb3b5995a2fdff2bca5e1ab4a40b7e968] drm/i915: Track GEN6
page table usage
git bisect bad 678d96fbb3b5995a2fdff2bca5e1ab4a40b7e968
# good: [317b4e903636305cfe702ab3e5b3d68547a69e72] drm/i915: Extract
context switch skip and add pd load logic
git bisect good 317b4e903636305cfe702ab3e5b3d68547a69e72
# first bad commit: [678d96fbb3b5995a2fdff2bca5e1ab4a40b7e968]
drm/i915: Track GEN6 page table usage


The machine is a Lenovo T440s laptop :


00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT
Integrated Graphics Controller (rev 0b)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04)
00:16.0 Communication controller: Intel Corporation 8 Series HECI #0 (rev 04)
00:16.3 Serial controller: Intel Corporation 8 Series HECI KT (rev 04)
00:19.0 Ethernet controller: Intel Corporation Ethernet Connection
I218-LM (rev 04)
00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 6 (rev e4)
00:1c.1 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 3 (rev e4)
00:1c.4 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 5 (rev e4)
00:1d.0 USB controller: Intel Corporation 8 Series USB EHCI #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation 8 Series LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 8 Series SATA Controller 1
[AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 8 Series SMBus Controller (rev 04)
02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd.
RTS5227 PCI Express Card Reader (rev 01)
03:00.0 Network controller: Intel Corporation Wireless 7260 (rev 83)
04:00.0 VGA compatible controller: NVIDIA Corporation GK208M [GeForce
GT 730M] (rev a1)


Cheers,

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

Re: [PATCH 3/6] regulator: lp872x: Remove warning about invalid DVS GPIO

2015-12-23 Thread Paul Kocialkowski
Le mercredi 23 décembre 2015 à 11:41 +, Mark Brown a écrit :
> On Wed, Dec 23, 2015 at 11:58:36AM +0100, Paul Kocialkowski wrote:
> > Some devices don't hook the DVS pin to a GPIO but to ground or VCC.
> > In those cases, it is not a problem to have no DVS GPIO.
> 
> I would expect the driver at least needs to know how the pins or
> strapped, or otherwise have configuration for ignoring the input on the
> pins.  This just deletes the warnings, it doesn't have any handling for
> this case that I can see.

When the DVS GPIO is invalid, lp872x_init_dvs jumps to the
set_default_dvs_mode label, which instructs the chip not to use the DVS
pin at all and do it all in software instead (by clearing the
LP8720_EXT_DVS_M bit in the LP872X_GENERAL_CFG register).

That is reflected later in the code, when setting the bucks (the DVS pin
only applies to the bucks) by checking for the LP8720_EXT_DVS_M bit on
the LP872X_GENERAL_CFG register (in lp872x_select_buck_vout_addr) to
decide whether to use software or hardware DVS selection.

As far as I understood, everything goes well when the GPIO is invalid.

-- 
Paul Kocialkowski, Replicant developer

Replicant is a fully free Android distribution running on several
devices, a free software mobile operating system putting the emphasis on
freedom and privacy/security.

Website: https://www.replicant.us/
Blog: https://blog.replicant.us/
Wiki/tracker/forums: https://redmine.replicant.us/



signature.asc
Description: This is a digitally signed message part


Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote:

> + gpio = lp->pdata->enable_gpio;
> + if (!gpio_is_valid(gpio))
> + return 0;
> +
> + /* Always set enable GPIO high. */
> + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X 
> EN");
> + if (ret) {
> + dev_err(lp->dev, "gpio request err: %d\n", ret);
> + return ret;
> + }

This isn't really adding support for the enable GPIO as the changelog
suggests, it's requesting but not managing the GPIO.  Since there is
core support for manging enable GPIOs this seems especially silly,
please tell the core about the GPIO and then it will work at runtime
too.


signature.asc
Description: PGP signature


[PATCH] BugFix in XHCI controller driver for scatter gather DMA

2015-12-23 Thread Vikas Bansal
From: Sumit Batra  

Pre-Condition 
URB with Scatter Gather list is queued to bulk OUT endpoint.
Every buffer in scatter gather list is not a multiple of maximum packet 
size for that endpoint(short packet).
CHAIN bit is set for all TRBs in a TD so that the DMA happens to all of 
them at once. 

Issue
DMA operation copies all the CHAINED TRBs at contiguous device memory.
But since the original packet was a short packet, so the actual data is 
re-aligned after this DMA operation.
At device end this re-aligned data causes data integrity issue with 
applications like ICMP ping.

Solution
Don't set the CHAINED bit for these TRBs, if their buffers are not a 
multiple of maximum packet size.
This will reduce the benefit in throughput as required from a scatter 
gather implementation, but this reduces the CPU utilization.
And solves the data integrity issue on Device End


Signed-off-by: Sumit Batra 
Signed-off-by: Vikas Bansal 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7d34cbf..7363dee 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3110,7 +3110,9 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t 
mem_flags,
 * TRB to indicate it's the last TRB in the chain.
 */
if (num_trbs > 1) {
-   field |= TRB_CHAIN;
+   if (this_sg_len %
+   usb_endpoint_maxp(>ep->desc) == 0)
+   field |= TRB_CHAIN;
} else {
/* FIXME - add check for ZERO_PACKET flag before this */
td->last_trb = ep_ring->enqueue;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/6] regulator: lp872x: Remove warning about invalid DVS GPIO

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 12:50:20PM +0100, Paul Kocialkowski wrote:
> Le mercredi 23 décembre 2015 à 11:41 +, Mark Brown a écrit :

> > I would expect the driver at least needs to know how the pins or
> > strapped, or otherwise have configuration for ignoring the input on the
> > pins.  This just deletes the warnings, it doesn't have any handling for
> > this case that I can see.

> When the DVS GPIO is invalid, lp872x_init_dvs jumps to the
> set_default_dvs_mode label, which instructs the chip not to use the DVS
> pin at all and do it all in software instead (by clearing the
> LP8720_EXT_DVS_M bit in the LP872X_GENERAL_CFG register).

> That is reflected later in the code, when setting the bucks (the DVS pin
> only applies to the bucks) by checking for the LP8720_EXT_DVS_M bit on
> the LP872X_GENERAL_CFG register (in lp872x_select_buck_vout_addr) to
> decide whether to use software or hardware DVS selection.

> As far as I understood, everything goes well when the GPIO is invalid.

So please put this analysis in the changelog so that the changelog
accurately reflects what the change is doing.


signature.asc
Description: PGP signature


Re: [PATCH] regulator: mt6397: convert to arch_initcall

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 06:16:08PM +0800, Henry Chen wrote:

Please fix your mail client to word wrap within paragraphs at something
substantially less than 80 columns.  Doing this makes your messages much
easier to read and reply to.

> Due to some device may need reulator operation in earlier boot time like gpu 
> module which
> power domain need regulator power on first. Move regulator of mt6397
> initialization earlier in boot so that real devices can use regulator
> without probe deferring.

Several problems here.  One is that we usually use subsys_initcall() for
working around the known broken subsystems here, why have you decided to
go for arch_initcall() instead.  Another is that you're saying this is
for GPUs but I'm not aware of any reason why GPUs are broken and we
should not be introducing new problems here - what's going on?


signature.asc
Description: PGP signature


[PATCH] vfio/iommu_type1: make use of info.flags

2015-12-23 Thread Pierre Morel
The flags entry is there to tell the user that some
optional information is available.

Since we report the iova_pgsizes signal it to the user
by setting the flags to VFIO_IOMMU_INFO_PGSIZES.

Signed-off-by: Pierre Morel 
---
 drivers/vfio/vfio_iommu_type1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 59d47cb..6f1ea3d 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -995,7 +995,7 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
if (info.argsz < minsz)
return -EINVAL;
 
-   info.flags = 0;
+   info.flags = VFIO_IOMMU_INFO_PGSIZES;
 
info.iova_pgsizes = vfio_pgsize_bitmap(iommu);
 
-- 
2.3.0

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


Applied "regulator: lp872x: Get rid of duplicate reference to DVS GPIO" to the regulator tree

2015-12-23 Thread Mark Brown
The patch

   regulator: lp872x: Get rid of duplicate reference to DVS GPIO

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 8a99cc6ff5710780e3d9bfc41027c142725089e5 Mon Sep 17 00:00:00 2001
From: Paul Kocialkowski 
Date: Wed, 23 Dec 2015 11:58:35 +0100
Subject: [PATCH] regulator: lp872x: Get rid of duplicate reference to DVS GPIO

The lp872x structure holds a reference to the DVS GPIO, but it is never actually
used anywhere, since a first reference exists from the lp872x_dvs structure.

Signed-off-by: Paul Kocialkowski 
Signed-off-by: Mark Brown 
---
 drivers/regulator/lp872x.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 9412353da622..19d758486553 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -108,7 +108,6 @@ struct lp872x {
struct lp872x_platform_data *pdata;
int num_regulators;
enum lp872x_dvs_state dvs_pin;
-   int dvs_gpio;
 };
 
 /* LP8720/LP8725 shared voltage table for LDOs */
@@ -752,7 +751,6 @@ static int lp872x_init_dvs(struct lp872x *lp)
}
 
lp->dvs_pin = pinstate;
-   lp->dvs_gpio = gpio;
 
return 0;
 
-- 
2.6.2

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


Applied "regulator: lp872x: Add missing of_match in regulators descriptions" to the regulator tree

2015-12-23 Thread Mark Brown
The patch

   regulator: lp872x: Add missing of_match in regulators descriptions

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 1f97fe4777217123428e3212a95a67c0de7a0132 Mon Sep 17 00:00:00 2001
From: Paul Kocialkowski 
Date: Wed, 23 Dec 2015 11:58:34 +0100
Subject: [PATCH] regulator: lp872x: Add missing of_match in regulators
 descriptions

In order to select the regulators via of_find_regulator_by_node (and thus use
them in devicetree), defining of_match for each regulator is required.

Signed-off-by: Paul Kocialkowski 
Signed-off-by: Mark Brown 
---
 drivers/regulator/lp872x.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index e5af07208f9d..9412353da622 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -520,6 +520,7 @@ static struct regulator_ops lp8725_buck_ops = {
 static struct regulator_desc lp8720_regulator_desc[] = {
{
.name = "ldo1",
+   .of_match = of_match_ptr("ldo1"),
.id = LP8720_ID_LDO1,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -533,6 +534,7 @@ static struct regulator_desc lp8720_regulator_desc[] = {
},
{
.name = "ldo2",
+   .of_match = of_match_ptr("ldo2"),
.id = LP8720_ID_LDO2,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -546,6 +548,7 @@ static struct regulator_desc lp8720_regulator_desc[] = {
},
{
.name = "ldo3",
+   .of_match = of_match_ptr("ldo3"),
.id = LP8720_ID_LDO3,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -559,6 +562,7 @@ static struct regulator_desc lp8720_regulator_desc[] = {
},
{
.name = "ldo4",
+   .of_match = of_match_ptr("ldo4"),
.id = LP8720_ID_LDO4,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp8720_ldo4_vtbl),
@@ -572,6 +576,7 @@ static struct regulator_desc lp8720_regulator_desc[] = {
},
{
.name = "ldo5",
+   .of_match = of_match_ptr("ldo5"),
.id = LP8720_ID_LDO5,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -585,6 +590,7 @@ static struct regulator_desc lp8720_regulator_desc[] = {
},
{
.name = "buck",
+   .of_match = of_match_ptr("buck"),
.id = LP8720_ID_BUCK,
.ops = _buck_ops,
.n_voltages = ARRAY_SIZE(lp8720_buck_vtbl),
@@ -599,6 +605,7 @@ static struct regulator_desc lp8720_regulator_desc[] = {
 static struct regulator_desc lp8725_regulator_desc[] = {
{
.name = "ldo1",
+   .of_match = of_match_ptr("ldo1"),
.id = LP8725_ID_LDO1,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -612,6 +619,7 @@ static struct regulator_desc lp8725_regulator_desc[] = {
},
{
.name = "ldo2",
+   .of_match = of_match_ptr("ldo2"),
.id = LP8725_ID_LDO2,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -625,6 +633,7 @@ static struct regulator_desc lp8725_regulator_desc[] = {
},
{
.name = "ldo3",
+   .of_match = of_match_ptr("ldo3"),
.id = LP8725_ID_LDO3,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -638,6 +647,7 @@ static struct regulator_desc lp8725_regulator_desc[] = {
},
{
.name = "ldo4",
+   .of_match = of_match_ptr("ldo4"),
.id = LP8725_ID_LDO4,
.ops = _ldo_ops,
.n_voltages = ARRAY_SIZE(lp872x_ldo_vtbl),
@@ -651,6 +661,7 @@ static struct regulator_desc lp8725_regulator_desc[] = {
},

Re: [RFC] spi: dw: support setting tmode dynamically

2015-12-23 Thread Mark Brown
On Wed, Dec 23, 2015 at 07:23:38PM +0800, Jisheng Zhang wrote:

> Currently the spi-dw tmode is fixed to SPI_TMOD_TR if cs_control is NULL, but 
> we
> need to set it as SPI_TMOD_EPROMREAD to read nor flash, my solution is to add 
> and
> export one functions to set the tmode, then the nor flash driver call it
> before reading and set back to SPI_TMOD_TR after done.

What does this mean - what is TMOD and why do we need to set it to read
NOR flash?  I've no information on this controller...


signature.asc
Description: PGP signature


Re: [PATCH v9 0/4] Exynos SROMc configuration and Ethernet support for SMDK5410

2015-12-23 Thread Krzysztof Kozlowski
W dniu 18.12.2015 o 18:16, Pavel Fedin pisze:
>  Hello!
> 
>> 4. This branch is not pushed to linux-next. I will sort it out if my
>> previous pull requests get in. I will be out of office for Christmas so
>> depending on the timing of {arm-soc,Christmas,Kukjin} this may or may
>> not go into v4.5 (yay...).
>>
>> 5. If it does not get into v4.5, I will rebase it and proceed further
>> for v4.6.
>>
>> If you have any questions, please let me know.
> 
>  Thank you very much. No, i don't have any questions, i'm glad that my work 
> is picked up and not lost, i'm just keeping an eye on it
> until it goes to stable.
> 
>  P.S. Not related to these sets directly, just to note... When i was writing 
> the doc for SROMc bindings, i noticed that we have two
> directories for Exynos in Documentation/devicetree/bindings/arm:
> 1. Documentation/devicetree/bindings/arm/exynos
> 2. Documentation/devicetree/bindings/arm/Samsung
> 
>  In (1) we have only a single old file, shouldn't this be cleaned up and 
> shouldn't this file be moved to (2)?

Thanks for hind but I already cleaned it up:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=068812ed108acbfe070b893faba9845fe2ea3fd9

Best regards,
Krzysztof

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


Re: [PATCH powerpc/next v6 0/4] atomics: powerpc: Implement relaxed/acquire/release variants

2015-12-23 Thread Davidlohr Bueso

On Wed, 23 Dec 2015, Boqun Feng wrote:

There is one thing we should be aware of, that is the bug:

http://lkml.kernel.org/r/5669d5f2.5050...@caviumnetworks.com

which though has been fixed by:

http://lkml.kernel.org/r/20151217160549.gh6...@twins.programming.kicks-ass.net


Right, and fwiw the testing I did included this fix.

signature.asc
Description: Digital signature


Re: [PATCH] BugFix in XHCI controller driver for scatter gather DMA

2015-12-23 Thread Mathias Nyman

On 23.12.2015 13:58, Vikas Bansal wrote:

From: Sumit Batra 

Pre-Condition
URB with Scatter Gather list is queued to bulk OUT endpoint.
Every buffer in scatter gather list is not a multiple of maximum packet
size for that endpoint(short packet).
CHAIN bit is set for all TRBs in a TD so that the DMA happens to all of
them at once.

Issue
DMA operation copies all the CHAINED TRBs at contiguous device memory.
But since the original packet was a short packet, so the actual data is
re-aligned after this DMA operation.
At device end this re-aligned data causes data integrity issue with
applications like ICMP ping.

Solution
Don't set the CHAINED bit for these TRBs, if their buffers are not a
multiple of maximum packet size.
This will reduce the benefit in throughput as required from a scatter
gather implementation, but this reduces the CPU utilization.
And solves the data integrity issue on Device End


Signed-off-by: Sumit Batra 
Signed-off-by: Vikas Bansal 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7d34cbf..7363dee 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3110,7 +3110,9 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t 
mem_flags,
 * TRB to indicate it's the last TRB in the chain.
 */
if (num_trbs > 1) {
-   field |= TRB_CHAIN;
+   if (this_sg_len %
+   usb_endpoint_maxp(>ep->desc) == 0)
+   field |= TRB_CHAIN;
} else {
/* FIXME - add check for ZERO_PACKET flag before this */


Hi

I don't fully understand the issue here yet, and I need to look into this more.
I believe removing the CHAIN bit from a TRB mid TD would make the xhc interpret
it as two separate TDs, and in this case the TD size fields of the TRBs will be 
wrong.

xhci supports Scatter/Gather transfers where the TRBs of a Multi-TRB TD have 
different
length fields. specs say "(xhc) form a concatenated data buffer from separate 
buffers
that reside in memory. If the Transfer Ring was associated with an OUT Endpoint 
then the
concatenated data buffer would be sent to the USB Device as single transfer"

"Note that no constraints are placed on the TRB Length fields in a 
Scatter/Gather list.
Classically all the buffers pointed to by a scatter gather list were required 
to be “page size”
in length except for the first and last (as illustrated by the example above).
The xHCI does not require this constraint. Any buffer pointed to by a Normal, 
Data Stage,
or Isoch TRB in a TD may be any size between 0 and 64K bytes in size."

"Note: A USB packet may be comprised of the data from many TRBs, or many USB 
packets may be
required to transfer a single TRB.
Note: No relationship is assumed between USB packet boundaries and TRB data buffer 
boundaries."

Is the case here that a TRB Length field of a Scatter/Father is less than max 
packet size,
or just not aligned with max packet size boundaries?

Is it possible this is about TD fragments? xhci has some requirements on how TDs
should be fragmented, it's possible the driver doesn't live up to all these 
requirements.

See xhci specs section 4.11.7.1, TD Fragments
  
I need to dig into this after the holidays,

I'll be back 7 January 2016.

Don't be afraid to ping me about this issue after that.

-Mathias  
--

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


Re: [PATCH v4] crypto: KEYS: convert public key and digsig asym to the akcipher api

2015-12-23 Thread Herbert Xu
On Wed, Dec 23, 2015 at 06:33:53AM -0800, Tadeusz Struk wrote:
>
> Changes in v4:
> - Flatten both patches into one to avoid bisect compilation problems.

Why is this necessary?

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4] crypto: KEYS: convert public key and digsig asym to the akcipher api

2015-12-23 Thread Tadeusz Struk
On 12/23/2015 06:51 AM, Herbert Xu wrote:
>> > Changes in v4:
>> > - Flatten both patches into one to avoid bisect compilation problems.
> Why is this necessary?

Because the first patch modifies the struct public_key and removes the MPIs 
from it,
which the code modified in the second patch still uses. If bisect only takes 
the first
then the build will fail on the security/integrity/digsig_asymmetric.c as 
reported by
kbuild test robot:

>> security/integrity/digsig_asymmetric.c:95:5: error: 'struct 
>> public_key_signature' has no member named 'nr_mpi'
 pks.nr_mpi = 1;

Thanks,
-- 
TS
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] [GIT PULL] ftrace/recordmcount: Fix hardlink issue with ccache

2015-12-23 Thread Steven Rostedt

Linus,

[ Well, as you know, my test box was not suffering from a harddrive
  failure, but a bug in the block layer. After wasting several days
  to figure that out, I got my test box up and running again, and was
  able to complete my testing. ]

Russell King was reporting lots of warnings when he compiled his kernel
with ftrace enabled. With some investigation it was discovered that it
was his compile setup. He was using ccache with hard links, which allowed
recordmcount to process the same .o twice. When this happens, recordmcount
will detect that it was already done and give a warning about it.

Russell fixed this by having recordmcount detect that the object file
has more than one hard link, and if it does, it unlinks the object file
after it maps it and processes then. This appears to fix the issue.

As you did not like the fact that recordmcount modified the file in place
and thought that it should do the modifications in memory and then write
it out to disk and move it over the old file to prevent other more subtle
issues like the one above, a second patch is added on top of Russell's to
do just that. Luckily the original code had write and lseek wrappers that
I was able to modify to not do inplace writes, but simply keep track
of the changes made in memory. When a write is made, a "update" flag is
set, and at the end of processing, if the update is set, then it writes
the file with changes out to a new file, and then renames it over the
original one.

The file descriptor is still passed to the write and lseek wrappers because
removing that would cause the change to be more intrusive. That can be
removed in a follow up cleanup patch that can wait till the next merge
window.

Please pull the latest trace-v4.4-rc4-2 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.4-rc4-2

Tag SHA1: c8eaa389dd82351cf142d7b5419964dede5e797b
Head SHA1: a50bd43935586420fb75f4558369eb08566fac5e


Russell King (1):
  scripts: recordmcount: break hardlinks

Steven Rostedt (Red Hat) (1):
  ftrace/scripts: Have recordmcount copy the object file


 scripts/recordmcount.c | 137 -
 1 file changed, 113 insertions(+), 24 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V16 00/11] x86: Intel Cache Allocation Technology Support

2015-12-23 Thread Tejun Heo
Hello, Fenghua, Ingo.

So, I'm seeing this patchset in -next and it looks like it came
through -tip.  What's going on?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/8] perf script: Add python support for stat events

2015-12-23 Thread Jiri Olsa
On Wed, Dec 23, 2015 at 10:42:47PM +0900, Namhyung Kim wrote:

SNIP

> > +static void
> > +process_stat(struct perf_evsel *counter, int cpu, int thread, u64 time,
> > +struct perf_counts_values *count)
> > +{
> > +   PyObject *handler, *t;
> > +   static char handler_name[256];
> > +   int n = 0;
> > +
> > +   t = PyTuple_New(MAX_FIELDS);
> > +   if (!t)
> > +   Py_FatalError("couldn't create Python tuple");
> > +
> > +   get_handler_name(handler_name, sizeof(handler_name),
> > +counter);
> > +
> > +   handler = get_handler(handler_name);
> > +   if (!handler) {
> > +   pr_debug("can't find python handler %s\n", handler_name);
> > +   return;
> > +   }
> > +
> > +   PyTuple_SetItem(t, n++, PyInt_FromLong(cpu));
> > +   PyTuple_SetItem(t, n++, PyInt_FromLong(thread));
> > +   PyTuple_SetItem(t, n++, PyLong_FromLong(time));
> > +   PyTuple_SetItem(t, n++, PyLong_FromLong(count->val));
> > +   PyTuple_SetItem(t, n++, PyLong_FromLong(count->ena));
> > +   PyTuple_SetItem(t, n++, PyLong_FromLong(count->run));
> 
> What about 32-bit systems?  It seems the PyLong_FromLong() takes long
> but the counts are u64.

hum, if it does I think we'll have problems in other
parts of python code.. I'll check, thanks

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8] watchdog: ts4800: add driver for TS-4800 watchdog

2015-12-23 Thread Wim Van Sebroeck
Hi Damien,

> On Tue, Dec 08, 2015 at 11:37:28AM -0500, Damien Riegel wrote:
> > This watchdog is instantiated in a FPGA that is memory mapped. It is
> > made of only one register, called the feed register. Writing to this
> > register will re-arm the watchdog for a given time (and enable it if it
> > was disable). It can be disabled by writing a special value into it.
> > 
> > It is part of a syscon block, and the watchdog register offset in this
> > block varies from board to board. This offset is passed in the syscon
> > property after the phandle to the syscon node.
> > 
> > Signed-off-by: Damien Riegel 
> > Acked-by: Rob Herring 
> > Reviewed-by: Guenter Roeck 
> 
> Hi Guenter,
> 
> 
> You have reviewed this patch but not picked it up in your tree. Shall I
> expect Wim to pick it up directly for the next merge window? The board
> would be quite useless without its watchdog driver.
> 
> 
> Thanks,
> Damien

It's on my todo list for the next merge window.

Kind regards,
Wim.

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


Re: [PATCH V7 00/24] Coresight integration with perf

2015-12-23 Thread Mathieu Poirier
On 19 December 2015 at 10:42, Rabin Vincent  wrote:
> On Fri, Dec 18, 2015 at 01:58:56PM -0700, Mathieu Poirier wrote:
>> This patchset aims to integrate configuration and control of
>> the Coresight tracers with the perf sub-system.
>>
>> The goal is to use PMUs to represent tracers and the auxiliary
>> buffer enhancement to collect processor traces.  As such a lot
>> of work is done to move the current Coresight sysFS oriented
>> configuration and control commands to perf's AUX API.
>
> These patches allow the trace to be recorded with perf, but what do you
> use to actually get something useful out of the resulting perf.data?
> AFAICS it can't be processed by perf script or the other perf tools.

You are correct.  The team is working on a trace decoder that will be
embedded in the perf tool suite.

>
> # echo 1 > /sys/bus/coresight/devices/54162000.etb/enable_sink
>
> # perf record -e cs_etm// true
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.032 MB perf.data ]
>
> # perf script
> 0x188 [0x80]: failed to process type: 70
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dmaengine: xgene-dma: Fix double IRQ issue by setting IRQ_DISABLE_UNLAZY flag

2015-12-23 Thread Rameshswar Prasad Sahu
From: Rameshwar Prasad Sahu 

For interrupt controller that doesn't support irq_disable and hardware
with level interrupt, an extra interrupt can be pending. This patch fixes
the issue by setting IRQ_DISABLE_UNLAZY flag for the interrupt line.

Reference: http://git.kernel.org/tip/e9849777d0e27cdd2902805be51da73e7c79578c

Signed-off-by: Rameshwar Prasad Sahu 
---
 drivers/dma/xgene-dma.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
index 9dfa2b0..6363e84 100644
--- a/drivers/dma/xgene-dma.c
+++ b/drivers/dma/xgene-dma.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 

@@ -1610,6 +1611,7 @@ static int xgene_dma_request_irqs(struct xgene_dma *pdma)
/* Register DMA channel rx irq */
for (i = 0; i < XGENE_DMA_MAX_CHANNEL; i++) {
chan = >chan[i];
+   irq_set_status_flags(chan->rx_irq, IRQ_DISABLE_UNLAZY);
ret = devm_request_irq(chan->dev, chan->rx_irq,
   xgene_dma_chan_ring_isr,
   0, chan->name, chan);
@@ -1620,6 +1622,7 @@ static int xgene_dma_request_irqs(struct xgene_dma *pdma)

for (j = 0; j < i; j++) {
chan = >chan[i];
+   irq_clear_status_flags(chan->rx_irq, 
IRQ_DISABLE_UNLAZY);
devm_free_irq(chan->dev, chan->rx_irq, chan);
}

@@ -1640,6 +1643,7 @@ static void xgene_dma_free_irqs(struct xgene_dma *pdma)

for (i = 0; i < XGENE_DMA_MAX_CHANNEL; i++) {
chan = >chan[i];
+   irq_clear_status_flags(chan->rx_irq, IRQ_DISABLE_UNLAZY);
devm_free_irq(chan->dev, chan->rx_irq, chan);
}
 }
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v4)

2015-12-23 Thread Namhyung Kim
Hi Jiri,

On Wed, Dec 23, 2015 at 09:46:23AM +0100, Jiri Olsa wrote:
> On Wed, Dec 23, 2015 at 02:06:57AM +0900, Namhyung Kim wrote:
> > Hello,
> > 
> > This is an attempt to improve perf to deal with tracepoint events
> > better.  The perf tools can handle tracepoint events but perf report
> > on them is less useful since they're always sampled in a fixed
> > location and not provide event specific info.  We can use perf script
> > but I always wishes there's more convenient way to see the result.
> > 
> >  * changes in v4)
> >   - support '.*' syntax for dynamic sort key
> >   - skip unrelated dynamic fields in the output
> >   - add 'trace_fields' sort key  (Jiri)
> >   - reuse get_trace_output function  (Jiri)
> 
> real beauty now ;-)
> 
> Acked-by: Jiri Olsa 

Thanks for your review and feedback!
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4] crypto: KEYS: convert public key and digsig asym to the akcipher api

2015-12-23 Thread Tadeusz Struk
This patch converts the module verification and digital signature
code to the new akcipher API.
RSA implementation has been removed from crypto/asymmetric_keys and the
new API is used for cryptographic primitives.
There is no need for MPI above the akcipher API anymore.
Modules can be verified with software as well as HW RSA implementations.

Patches generated against cryptodev-2.6

Changes in v4:
- Flatten both patches into one to avoid bisect compilation problems.

Changes in v3:
- Don't include keys/asymmetric-type.h in crypto/public_key.h

Changes in v2:
- Fix the whey public_key_signature is setup. The pointer s needs to
  point to the signature instread of the signature_v2_hdr.
- Select CRYPTO_RSA when INTEGRITY_ASYMMETRIC_KEYS is selected.

Signed-off-by: Tadeusz Struk 
---
 crypto/asymmetric_keys/Kconfig|2 
 crypto/asymmetric_keys/Makefile   |7 -
 crypto/asymmetric_keys/pkcs7_parser.c |   12 +-
 crypto/asymmetric_keys/pkcs7_trust.c  |2 
 crypto/asymmetric_keys/pkcs7_verify.c |2 
 crypto/asymmetric_keys/public_key.c   |   64 +++--
 crypto/asymmetric_keys/public_key.h   |   36 -
 crypto/asymmetric_keys/rsa.c  |  213 +++--
 crypto/asymmetric_keys/x509_cert_parser.c |   37 +
 crypto/asymmetric_keys/x509_public_key.c  |   17 +-
 crypto/asymmetric_keys/x509_rsakey.asn1   |4 -
 include/crypto/public_key.h   |   48 +--
 security/integrity/Kconfig|1 
 security/integrity/digsig_asymmetric.c|   10 -
 14 files changed, 139 insertions(+), 316 deletions(-)
 delete mode 100644 crypto/asymmetric_keys/public_key.h
 delete mode 100644 crypto/asymmetric_keys/x509_rsakey.asn1

diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig
index 4870f28..905d745 100644
--- a/crypto/asymmetric_keys/Kconfig
+++ b/crypto/asymmetric_keys/Kconfig
@@ -22,7 +22,7 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
 
 config PUBLIC_KEY_ALGO_RSA
tristate "RSA public-key algorithm"
-   select MPILIB
+   select CRYPTO_RSA
help
  This option enables support for the RSA algorithm (PKCS#1, RFC3447).
 
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index cd1406f..b78a194 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -16,21 +16,18 @@ obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
 x509_key_parser-y := \
x509-asn1.o \
x509_akid-asn1.o \
-   x509_rsakey-asn1.o \
x509_cert_parser.o \
x509_public_key.o
 
 $(obj)/x509_cert_parser.o: \
$(obj)/x509-asn1.h \
-   $(obj)/x509_akid-asn1.h \
-   $(obj)/x509_rsakey-asn1.h
+   $(obj)/x509_akid-asn1.h
+
 $(obj)/x509-asn1.o: $(obj)/x509-asn1.c $(obj)/x509-asn1.h
 $(obj)/x509_akid-asn1.o: $(obj)/x509_akid-asn1.c $(obj)/x509_akid-asn1.h
-$(obj)/x509_rsakey-asn1.o: $(obj)/x509_rsakey-asn1.c $(obj)/x509_rsakey-asn1.h
 
 clean-files+= x509-asn1.c x509-asn1.h
 clean-files+= x509_akid-asn1.c x509_akid-asn1.h
-clean-files+= x509_rsakey-asn1.c x509_rsakey-asn1.h
 
 #
 # PKCS#7 message handling
diff --git a/crypto/asymmetric_keys/pkcs7_parser.c 
b/crypto/asymmetric_keys/pkcs7_parser.c
index 758acab..12912c1 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -15,7 +15,7 @@
 #include 
 #include 
 #include 
-#include "public_key.h"
+#include 
 #include "pkcs7_parser.h"
 #include "pkcs7-asn1.h"
 
@@ -44,7 +44,7 @@ struct pkcs7_parse_context {
 static void pkcs7_free_signed_info(struct pkcs7_signed_info *sinfo)
 {
if (sinfo) {
-   mpi_free(sinfo->sig.mpi[0]);
+   kfree(sinfo->sig.s);
kfree(sinfo->sig.digest);
kfree(sinfo->signing_cert_id);
kfree(sinfo);
@@ -616,16 +616,14 @@ int pkcs7_sig_note_signature(void *context, size_t hdrlen,
 const void *value, size_t vlen)
 {
struct pkcs7_parse_context *ctx = context;
-   MPI mpi;
 
BUG_ON(ctx->sinfo->sig.pkey_algo != PKEY_ALGO_RSA);
 
-   mpi = mpi_read_raw_data(value, vlen);
-   if (!mpi)
+   ctx->sinfo->sig.s = kmemdup(value, vlen, GFP_KERNEL);
+   if (!ctx->sinfo->sig.s)
return -ENOMEM;
 
-   ctx->sinfo->sig.mpi[0] = mpi;
-   ctx->sinfo->sig.nr_mpi = 1;
+   ctx->sinfo->sig.s_size = vlen;
return 0;
 }
 
diff --git a/crypto/asymmetric_keys/pkcs7_trust.c 
b/crypto/asymmetric_keys/pkcs7_trust.c
index 90d6d47..3bbdcc7 100644
--- a/crypto/asymmetric_keys/pkcs7_trust.c
+++ b/crypto/asymmetric_keys/pkcs7_trust.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 #include 
-#include "public_key.h"
+#include 
 #include "pkcs7_parser.h"
 
 /**
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c 
b/crypto/asymmetric_keys/pkcs7_verify.c
index 325575c..f5db137 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ 

Re: [PATCH] futex: Prevent pi_state from double freeing in case of error

2015-12-23 Thread Bhuvanesh
Hi,

>  - Why was this patch created in the first place?
> 
>The changelog is completely useless. It does not tell what the
>observed issue was or whether this was merily the result of reading
>the code and assuming that this is a double free. But it was
>certainly not due to a thorough analysis of the code in question.

Apologies for not putting the backtrace earlier.

During our regression test of the kernel version 3.14, generated a 
warning in futex code and resulted in crash with the backtrace given 
below:

WARNING: CPU: 0 PID: 1468 at fs/inode.c:399 ihold+0x40/0x48()
Backtrace: 
[<80011b88>] (dump_backtrace) from [<80011d90>] (show_stack+0x18/0x1c)
[<80011d78>] (show_stack) from [<805036b8>] (dump_stack+0x74/0xc0)
[<80503644>] (dump_stack) from [<8002393c>] (warn_slowpath_common+0x70/0x94)
[<800238cc>] (warn_slowpath_common) from [<80023a04>] 
(warn_slowpath_null+0x24/0x2c)
[<800239e0>] (warn_slowpath_null) from [<80115004>] (ihold+0x40/0x48)
[<80114fc4>] (ihold) from [<8007f33c>] (get_futex_key_refs+0x58/0x64)
[<8007f2e4>] (get_futex_key_refs) from [<8007f524>] (get_futex_key+0x1dc/0x200)
[<8007f348>] (get_futex_key) from [<80080048>] (futex_wake+0x4c/0x144)
[<8007fffc>] (futex_wake) from [<800819dc>] (do_futex+0xf8/0x984)
[<800818e4>] (do_futex) from [<80082358>] (SyS_futex+0xf0/0x15c)
[<80082268>] (SyS_futex) from [<8000e060>] (ret_fast_syscall+0x0/0x50)
Kernel BUG at 80114f5c [verbose debug info unavailable]
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
CPU: 1 PID: 826 Comm: mediaengine_out Tainted: GW
3.14.51-03408-gf4477ef #1
task: a31c6d40 ti: 96ab2000 task.ti: 96ab2000
PC is at clear_inode+0x5c/0x60
LR is at preempt_count_sub+0xd8/0x104
pc : [<80114f5c>]lr : [<8050aae0>]psr: 20070113
sp : 96ab3e78  ip : 96ab3e48  fp : 96ab3e8c
r10: 7eb42200  r9 : 836b5a30  r8 : 96ab3f04
r7 : 836b5a20  r6 : 836b5a30  r5 : 836b5b14  r4 : 836b5a30
r3 : 0060  r2 : 836b5b58  r1 : 80114f30  r0 : 80508274
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 10c5387d  Table: 331dc04a  DAC: 0015
Process mediaengine_out (pid: 826, stack limit = 0x96ab2238)
Stack: (0x96ab3e78 to 0x96ab4000)
3e60:   836b5a20 836b5a20
3e80: 96ab3eb4 96ab3e90 800d5e68 80114f0c   836b5a30 836b5ad4
3ea0: 80518f30 80518f30 96ab3ed4 96ab3eb8 80115154 800d5d48  836b5a30
3ec0: 836b5a80 a27a6c00 96ab3ef4 96ab3ed8 80115bc4 801150c4  a0353aa0
3ee0:  836c7000 96ab3f94 96ab3ef8 8010bae0 80115a94 a287b310 ff9c
3f00: 836b5a30  a287b310 a0053660 faee90ab 0027 836c7019 96ab3e38
3f20:  a0007330 a20f04c0  0002 00e4  
3f40: 8000e224 8000e224 96ab2000  96ab3f6c 96ab3f60 800fff9c 800ffd6c
3f60: 96ab3f8c 96ab2000 0004 0064dc48 49fc2fb8 0023 000a 8000e224
3f80: 96ab2000  96ab3fa4 96ab3f98 8010c694 8010b9e4  96ab3fa8
3fa0: 8000e060 8010c688 0064dc48 49fc2fb8 7eb42200 0064dc6c  006e696f
3fc0: 0064dc48 49fc2fb8 0023 000a 2c90eb88 7eb42c90 7eb45334 7eb4224c
3fe0: 49fcd178 7eb421fc 49fbe248 49f0b6ec 400f0010 7eb42200  
Backtrace: 
[<80114f00>] (clear_inode) from [<800d5e68>] (shmem_evict_inode+0x12c/0x148)
[<800d5d3c>] (shmem_evict_inode) from [<80115154>] (evict+0x9c/0x160)
[<801150b8>] (evict) from [<80115bc4>] (iput+0x13c/0x144)
[<80115a88>] (iput) from [<8010bae0>] (do_unlinkat+0x108/0x1c8)
[<8010b9d8>] (do_unlinkat) from [<8010c694>] (SyS_unlink+0x18/0x1c)
[<8010c67c>] (SyS_unlink) from [<8000e060>] (ret_fast_syscall+0x0/0x50)
Code: e3130040 03a03060 0584306c 089da830 (e7f001f2) 
Kernel panic - not syncing: Fatal exception
Backtrace: 
[<80011b88>] (dump_backtrace) from [<80011d90>] (show_stack+0x18/0x1c)
[<80011d78>] (show_stack) from [<805036b8>] (dump_stack+0x74/0xc0)
[<80503644>] (dump_stack) from [<800136a0>] (handle_IPI+0xdc/0x184)
[<800135c4>] (handle_IPI) from [<8000858c>] (gic_handle_irq+0x60/0x68)
[<8000852c>] (gic_handle_irq) from [<80508a84>] (__irq_svc+0x44/0x78)
[<8000ed4c>] (arch_cpu_idle) from [<80069644>] (cpu_startup_entry+0x1c0/0x254)
[<80069484>] (cpu_startup_entry) from [<804ff4ec>] (rest_init+0x78/0x90)
[<804ff474>] (rest_init) from [<806d1b40>] (start_kernel+0x314/0x370)
[<806d182c>] (start_kernel) from [<10008074>] (0x10008074)

We observed the above issue thrice in our testing. Unfortunately we 
don't know the usecase or steps which resulted in the above behavior, 
since the testing was random. 

We did the static analysis of the futex code and didn't find anything
suspicious in usage of get_futex_key_refs and drop_futex_key_refs.
Assuming it could be due to corruption of futex_key struct we arrived
at the patch.

Sorry for overlooking the code. Thanks for the clarification.

Thank you,
Regards,
Bhuvanesh

On 12/19/2015 11:54 PM, Thomas Gleixner wrote:
> On Fri, 18 Dec 2015, Davidlohr Bueso wrote:
>> On Fri, 18 Dec 2015, bhuvanesh_surach...@mentor.com 

[PATCH] ARM: dts: uniphier: fix a typo in comment block

2015-12-23 Thread Masahiro Yamada
Signed-off-by: Masahiro Yamada 
---

 arch/arm/boot/dts/uniphier-ph1-ld6b.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/uniphier-ph1-ld6b.dtsi 
b/arch/arm/boot/dts/uniphier-ph1-ld6b.dtsi
index c6499ee..5321152 100644
--- a/arch/arm/boot/dts/uniphier-ph1-ld6b.dtsi
+++ b/arch/arm/boot/dts/uniphier-ph1-ld6b.dtsi
@@ -53,7 +53,7 @@
compatible = "socionext,ph1-ld6b";
 };
 
-/* UART3 unavilable: the pads are not wired to the package balls */
+/* UART3 unavailable: the pads are not wired to the package balls */
  {
status = "disabled";
 };
-- 
1.9.1

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


Re: [PATCH v8] watchdog: ts4800: add driver for TS-4800 watchdog

2015-12-23 Thread Damien Riegel
On Tue, Dec 08, 2015 at 11:37:28AM -0500, Damien Riegel wrote:
> This watchdog is instantiated in a FPGA that is memory mapped. It is
> made of only one register, called the feed register. Writing to this
> register will re-arm the watchdog for a given time (and enable it if it
> was disable). It can be disabled by writing a special value into it.
> 
> It is part of a syscon block, and the watchdog register offset in this
> block varies from board to board. This offset is passed in the syscon
> property after the phandle to the syscon node.
> 
> Signed-off-by: Damien Riegel 
> Acked-by: Rob Herring 
> Reviewed-by: Guenter Roeck 

Hi Guenter,


You have reviewed this patch but not picked it up in your tree. Shall I
expect Wim to pick it up directly for the next merge window? The board
would be quite useless without its watchdog driver.


Thanks,
Damien

> ---
> Changes in v8:
>  - Split the serie into two parts: watchdog and dts as there are no
>build dependencies between the two
>  - Added Reviewed-by Guenter Roeck and Acked-by by Rob Herring (for
>the dts bindings).
> 
> Changes in v7:
>  - syscon: change bus-width DT property to reg-io-width
>  - watchdog: add dependency on HAS_IOMEM (spotted by a 0-day build) 
> 
> Changes in v6:
>  - vendor prefix: reorder to sort alphabetically (wrong order since v3)
>  - split commit adding device tree into two patches: one for the doc, one for
>the bindings
> 
> Changes in v5:
>  - watchdog: changed iteration stop condition in set_timeout to be less
>error prone
> 
> Changes in v4:
>  - syscon: rewrite DT property reading to be clearer
>  - watchdog: made fixes suggested by Guenter (now uses
>watchdog_init_timeout, u32 instead of u16, fixed error checking in
>probe, cleaned set_timeout)
> 
> Changes in v3:
>  - Rebased on v4.3
>  - Changed vendor prefix from "ts" to "technologic"
>  - Added a DT option to generic syscon driver to allow regmap configuration
>  - Dropped custom mfd driver, use generic syscon driver instead.
> 
> Changes in v2:
>  - Added a mfd driver to handle syscon registers
>  - The watchdog driver now uses the regmap (created by the mfd driver)
>to access the feed register
>  - Remove watchdog's dependency on SOC_IMX51
> 
>  .../devicetree/bindings/watchdog/ts4800-wdt.txt|  25 +++
>  drivers/watchdog/Kconfig   |  10 +
>  drivers/watchdog/Makefile  |   1 +
>  drivers/watchdog/ts4800_wdt.c  | 215 
> +
>  4 files changed, 251 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
>  create mode 100644 drivers/watchdog/ts4800_wdt.c
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt 
> b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> new file mode 100644
> index 000..8f6caad
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> @@ -0,0 +1,25 @@
> +Technologic Systems Watchdog
> +
> +Required properties:
> +- compatible: must be "technologic,ts4800-wdt"
> +- syscon: phandle / integer array that points to the syscon node which
> +  describes the FPGA's syscon registers.
> +  - phandle to FPGA's syscon
> +  - offset to the watchdog register
> +
> +Optional property:
> +- timeout-sec: contains the watchdog timeout in seconds.
> +
> +Example:
> +
> +syscon: syscon@b001 {
> + compatible = "syscon", "simple-mfd";
> + reg = <0xb001 0x3d>;
> + reg-io-width = <2>;
> +
> + wdt@e {
> + compatible = "technologic,ts4800-wdt";
> + syscon = < 0xe>;
> + timeout-sec = <10>;
> + };
> +}
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 79e1aa1..bb624d2 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -426,6 +426,16 @@ config NUC900_WATCHDOG
> To compile this driver as a module, choose M here: the
> module will be called nuc900_wdt.
>  
> +config TS4800_WATCHDOG
> + tristate "TS-4800 Watchdog"
> + depends on HAS_IOMEM && OF
> + select WATCHDOG_CORE
> + select MFD_SYSCON
> + help
> +   Technologic Systems TS-4800 has watchdog timer implemented in
> +   an external FPGA. Say Y here if you want to support for the
> +   watchdog timer on TS-4800 board.
> +
>  config TS72XX_WATCHDOG
>   tristate "TS-72XX SBC Watchdog"
>   depends on MACH_TS72XX
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 0c616e3..3863ce0 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -53,6 +53,7 @@ obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o
>  obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o
>  obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o
>  obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
> +obj-$(CONFIG_TS4800_WATCHDOG) += 

Re: [PATCH 8/8] perf script: Add stat-cpi.py script

2015-12-23 Thread Jiri Olsa
On Wed, Dec 23, 2015 at 10:44:20PM +0900, Namhyung Kim wrote:

SNIP

> > $ perf stat -e cycles,instructions -a -I 1000 record sleep 3 | perf 
> > script -s ./scripts/python/stat-cpi.py
> >1.000202: cpu -1, thread -1 -> cpi 1.035091 (940778881/908885530)
> >2.000392: cpu -1, thread -1 -> cpi 1.442600 (627493992/434974455)
> >3.000545: cpu -1, thread -1 -> cpi 1.353612 (741463930/547766890)
> >3.000622: cpu -1, thread -1 -> cpi 2.642110 (784083/296764)
> > 
> > Tested-by: Kan Liang 
> > Link: http://lkml.kernel.org/n/tip-15vwwb4yea15wzz6bqbxd...@git.kernel.org
> > Signed-off-by: Jiri Olsa 
> > ---
> >  tools/perf/scripts/python/stat-cpi.py | 77 
> > +++
> >  1 file changed, 77 insertions(+)
> >  create mode 100644 tools/perf/scripts/python/stat-cpi.py
> > 
> > diff --git a/tools/perf/scripts/python/stat-cpi.py 
> > b/tools/perf/scripts/python/stat-cpi.py
> > new file mode 100644
> > index ..32689a83b6e6
> > --- /dev/null
> > +++ b/tools/perf/scripts/python/stat-cpi.py
> > @@ -0,0 +1,77 @@
> > +#!/bin/python
> 
> It an unusual place IMHO.  Wouldn't it be '#!/usr/bin/env python' ?

yep, I'll change that

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8] watchdog: ts4800: add driver for TS-4800 watchdog

2015-12-23 Thread Guenter Roeck

On 12/23/2015 07:43 AM, Damien Riegel wrote:

On Tue, Dec 08, 2015 at 11:37:28AM -0500, Damien Riegel wrote:

This watchdog is instantiated in a FPGA that is memory mapped. It is
made of only one register, called the feed register. Writing to this
register will re-arm the watchdog for a given time (and enable it if it
was disable). It can be disabled by writing a special value into it.

It is part of a syscon block, and the watchdog register offset in this
block varies from board to board. This offset is passed in the syscon
property after the phandle to the syscon node.

Signed-off-by: Damien Riegel 
Acked-by: Rob Herring 
Reviewed-by: Guenter Roeck 


Hi Guenter,


You have reviewed this patch but not picked it up in your tree. Shall I
expect Wim to pick it up directly for the next merge window? The board
would be quite useless without its watchdog driver.


My tree is in pretty bad shape right now; It includes some older patches
which have to be replaced. I'll have to rebase it against Wim's tree
and clean it up. Hope I can do that before the weekend.

But, yes, of course, Wim can pick up your patch directly.

Guenter

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


Re: [PATCH] IB/usnic: delete unneeded IS_ERR test

2015-12-23 Thread Doug Ledford
On 12/22/2015 10:29 AM, Dave Goodell wrote:
> [copying Nelson too]
> 
> On Sat, Dec 19, 2015 at 09:48:59PM +0100, Julia Lawall wrote:
>> kzalloc doesn't return ERR_PTR, so there is no need to test for it.
>>
>> The semantic match that finds this problem is as follows:
>> (http://coccinelle.lip6.fr/)
>>
>> // 
>> @@
>> expression x,e;
>> @@
>>
>> * x = kzalloc(...)
>> ... when != x = e
>> * IS_ERR_OR_NULL(x)
>> // 
>>
>> Signed-off-by: Julia Lawall 
> 
> Reviewed-by: Dave Goodell 
> 
> -Dave
> 

Thanks, applied.

-- 
Doug Ledford 
  GPG KeyID: 0E572FDD




signature.asc
Description: OpenPGP digital signature


Re: [PATCH V7 04/24] coresight: moving PM runtime operations to core framework

2015-12-23 Thread Mathieu Poirier
On 19 December 2015 at 10:13, Rabin Vincent  wrote:
> On Fri, Dec 18, 2015 at 01:59:00PM -0700, Mathieu Poirier wrote:
>> @@ -415,9 +418,13 @@ struct list_head *coresight_build_path(struct 
>> coresight_device *csdev)
>>   */
>>  void coresight_release_path(struct list_head *path)
>>  {
>> + struct coresight_device *csdev;
>>   struct coresight_node *nd, *next;
>>
>>   list_for_each_entry_safe(nd, next, path, link) {
>> + csdev = nd->csdev;
>> +
>> + pm_runtime_put_sync(csdev->dev.parent);
>>   list_del(>link);
>>   kfree(nd);
>>   }
>
> This leads to the following splat:
>
>  BUG: sleeping function called from invalid context at 
> /home/rabin/dev/linux/drivers/base/power/runtime.c:892
>  in_atomic(): 1, irqs_disabled(): 128, pid: 763, name: perf
>  2 locks held by perf/763:
>   #0:  (>mmap_sem){++}, at: [] vm_munmap+0x2c/0x50
>   #1:  (>mmap_mutex){+.+.+.}, at: [] 
> atomic_dec_and_mutex_lock+0x58/0x98
>  irq event stamp: 63152
>  hardirqs last  enabled at (63151): [] 
> _raw_spin_unlock_irqrestore+0x30/0x5c
>  hardirqs last disabled at (63152): [] __irq_svc+0x48/0x78
>  softirqs last  enabled at (61242): [] __do_softirq+0x408/0x4fc
>  softirqs last disabled at (61223): [] irq_exit+0xcc/0x130
>  CPU: 1 PID: 763 Comm: perf Not tainted 4.4.0-rc5-00224-ge461459-dirty #152
>  Hardware name: Generic OMAP4 (Flattened Device Tree)
>  [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
>  [] (show_stack) from [] (dump_stack+0x90/0xb8)
>  [] (dump_stack) from [] (__pm_runtime_idle+0xa4/0xa8)
>  [] (__pm_runtime_idle) from [] 
> (coresight_release_path+0x38/0x7c)
>  [] (coresight_release_path) from [] 
> (free_event_data+0x84/0x9c)
>  [] (free_event_data) from [] (rb_irq_work+0x4c/0xcc)
>  [] (rb_irq_work) from [] (irq_work_run_list+0x7c/0xb4)
>  [] (irq_work_run_list) from [] (irq_work_run+0x20/0x34)
>  [] (irq_work_run) from [] (handle_IPI+0x1cc/0x334)
>  [] (handle_IPI) from [] (gic_handle_irq+0x84/0x88)
>  [] (gic_handle_irq) from [] (__irq_svc+0x58/0x78)
>  Exception stack(0xed865e98 to 0xed865ee0)
>  5e80:   0001 0110
>  5ea0:  ee2f1080 2113 c0784808 edbe4e1c b6ae5000 edb882f0 ed9b1e04
>  5ec0: edb88298 c075648c 0002 ed865ee8 c008724c c04f7ee0 2113 
>  [] (__irq_svc) from [] 
> (_raw_spin_unlock_irqrestore+0x34/0x5c)
>  [] (_raw_spin_unlock_irqrestore) from [] 
> (irq_work_queue+0xac/0xb4)
>  [] (irq_work_queue) from [] (perf_mmap_close+0x370/0x3c8)
>  [] (perf_mmap_close) from [] (remove_vma+0x40/0x6c)
>  [] (remove_vma) from [] (do_munmap+0x210/0x35c)
>  [] (do_munmap) from [] (vm_munmap+0x3c/0x50)
>  [] (vm_munmap) from [] (ret_fast_syscall+0x0/0x1c)
>
> It should presumably be using pm_runtime_put() instead.

That's a first - what platform did you test on?  If I send you fixes
will you be able to help me with the verification?

Thanks,
Mathieu
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mmc: host: arasan: sdhci-of-arasan: Remove no-hispd and no-cmd23 quirks for sdhci-arasan4.9a

2015-12-23 Thread Rameshswar Prasad Sahu
From: Rameshwar Prasad Sahu 

The Arason SD host controller supports set block count command (cmd23)
and high speed mode. This patch re-enable both of these features that
was disabled. For device that doesn't support high speed, it should
configure its capability register accordingly instead disables it
explicitly.

Signed-off-by: Rameshwar Prasad Sahu 
---
 drivers/mmc/host/sdhci-of-arasan.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c 
b/drivers/mmc/host/sdhci-of-arasan.c
index 75379cb..5d9fdb3 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -172,11 +172,6 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
goto clk_disable_all;
}

-   if (of_device_is_compatible(pdev->dev.of_node, "arasan,sdhci-4.9a")) {
-   host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
-   host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
-   }
-
sdhci_get_of_property(pdev);
pltfm_host = sdhci_priv(host);
pltfm_host->priv = sdhci_arasan;
--
1.7.1

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


Re: [PATCH 5/8] perf script: Add stat default handlers

2015-12-23 Thread Namhyung Kim
On Tue, Dec 22, 2015 at 04:43:31PM +0100, Jiri Olsa wrote:
> Implement struct scripting_ops::(process_stat|process_stat_interval)
> handlers - calling scripting handlers from stat events handlers.
> 
> Tested-by: Kan Liang 
> Link: http://lkml.kernel.org/n/tip-3iu6vmvuur1bntbnh43v3...@git.kernel.org
> Signed-off-by: Jiri Olsa 
> ---
>  tools/perf/builtin-script.c | 33 +
>  1 file changed, 33 insertions(+)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index a90bc0b81e70..656541eff151 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -221,6 +221,9 @@ static int perf_evsel__check_attr(struct perf_evsel 
> *evsel,
>   struct perf_event_attr *attr = >attr;
>   bool allow_user_set;
>  
> + if (perf_header__has_feat(>header, HEADER_STAT))
> + return 0;
> +
>   allow_user_set = perf_header__has_feat(>header,
>  HEADER_AUXTRACE);
>  
> @@ -674,6 +677,18 @@ static void process_event(struct perf_script *script 
> __maybe_unused, union perf_
>  
>  static struct scripting_ops  *scripting_ops;
>  
> +static void process_stat(struct perf_evsel *counter, u64 time)
> +{
> + if (scripting_ops)
> + scripting_ops->process_stat(_config, counter, time);

Shouldn't it be

if (scripting_ops && scripting_ops->process_stat)

?  It seems you only set it for python in patch 7..


> +}
> +
> +static void process_stat_interval(u64 time)
> +{
> + if (scripting_ops)
> + scripting_ops->process_stat_interval(time);

Ditto.

Thanks,
Namhyung


> +}
> +
>  static void setup_scripting(void)
>  {
>   setup_perl_scripting();
> @@ -1690,6 +1705,22 @@ static void script__setup_sample_type(struct 
> perf_script *script)
>   }
>  }
>  
> +static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
> + union perf_event *event,
> + struct perf_session *session)
> +{
> + struct stat_round_event *round = >stat_round;
> + struct perf_evsel *counter;
> +
> + evlist__for_each(session->evlist, counter) {
> + perf_stat_process_counter(_config, counter);
> + process_stat(counter, round->time);
> + }
> +
> + process_stat_interval(round->time);
> + return 0;
> +}
> +
>  static int process_stat_config_event(struct perf_tool *tool __maybe_unused,
>union perf_event *event,
>struct perf_session *session 
> __maybe_unused)
> @@ -1783,6 +1814,8 @@ int cmd_script(int argc, const char **argv, const char 
> *prefix __maybe_unused)
>   .auxtrace_info   = perf_event__process_auxtrace_info,
>   .auxtrace= perf_event__process_auxtrace,
>   .auxtrace_error  = perf_event__process_auxtrace_error,
> + .stat= perf_event__process_stat_event,
> + .stat_round  = process_stat_round_event,
>   .stat_config = process_stat_config_event,
>   .thread_map  = process_thread_map_event,
>   .cpu_map = process_cpu_map_event,
> -- 
> 2.4.3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 7/8] perf script: Add python support for stat events

2015-12-23 Thread Namhyung Kim
On Tue, Dec 22, 2015 at 04:43:33PM +0100, Jiri Olsa wrote:
> Add support to get stat events data in perf python scripts.
> 
> The python script shall implement following
> new interface to process stat data:
> 
>   def stat___[](cpu, thread, time, val, ena, run):
> 
> - is called for every stat event for given counter,
>   if user monitors 'cycles,instructions:u" following
>   callbacks should be defined:
> 
>   def stat__cycles(cpu, thread, time, val, ena, run):
>   def stat__instructions_u(cpu, thread, time, val, ena, run):
> 
>   def stat__interval(time):
> 
> - is called for every interval with its time,
>   in non interval mode it's called after last
>   stat event with total measured time in ns
> 
> The rest of the current interface stays untouched..
> 
> Please check example CPI metrics script in following patch
> with command line examples in changelogs.
> 
> Tested-by: Kan Liang 
> Link: http://lkml.kernel.org/n/tip-jojiaelyckrw6040wqc06...@git.kernel.org
> Signed-off-by: Jiri Olsa 
> ---
>  .../util/scripting-engines/trace-event-python.c| 114 
> +++--
>  1 file changed, 108 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
> b/tools/perf/util/scripting-engines/trace-event-python.c
> index a8e825fca42a..8436eb23eb16 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -41,6 +41,9 @@
>  #include "../thread-stack.h"
>  #include "../trace-event.h"
>  #include "../machine.h"
> +#include "thread_map.h"
> +#include "cpumap.h"
> +#include "stat.h"
>  
>  PyMODINIT_FUNC initperf_trace_context(void);
>  
> @@ -859,6 +862,103 @@ static void python_process_event(union perf_event 
> *event,
>   }
>  }
>  
> +static void get_handler_name(char *str, size_t size,
> +  struct perf_evsel *evsel)
> +{
> + char *p = str;
> +
> + scnprintf(str, size, "stat__%s", perf_evsel__name(evsel));
> +
> + while ((p = strchr(p, ':'))) {
> + *p = '_';
> + p++;
> + }
> +}
> +
> +static void
> +process_stat(struct perf_evsel *counter, int cpu, int thread, u64 time,
> +  struct perf_counts_values *count)
> +{
> + PyObject *handler, *t;
> + static char handler_name[256];
> + int n = 0;
> +
> + t = PyTuple_New(MAX_FIELDS);
> + if (!t)
> + Py_FatalError("couldn't create Python tuple");
> +
> + get_handler_name(handler_name, sizeof(handler_name),
> +  counter);
> +
> + handler = get_handler(handler_name);
> + if (!handler) {
> + pr_debug("can't find python handler %s\n", handler_name);
> + return;
> + }
> +
> + PyTuple_SetItem(t, n++, PyInt_FromLong(cpu));
> + PyTuple_SetItem(t, n++, PyInt_FromLong(thread));
> + PyTuple_SetItem(t, n++, PyLong_FromLong(time));
> + PyTuple_SetItem(t, n++, PyLong_FromLong(count->val));
> + PyTuple_SetItem(t, n++, PyLong_FromLong(count->ena));
> + PyTuple_SetItem(t, n++, PyLong_FromLong(count->run));

What about 32-bit systems?  It seems the PyLong_FromLong() takes long
but the counts are u64.


> +
> + if (_PyTuple_Resize(, n) == -1)
> + Py_FatalError("error resizing Python tuple");
> +
> + call_object(handler, t, handler_name);
> +
> + Py_DECREF(t);
> +}
> +
> +static void python_process_stat(struct perf_stat_config *config,
> + struct perf_evsel *counter, u64 time)
> +{
> + struct thread_map *threads = counter->threads;
> + struct cpu_map *cpus = counter->cpus;
> + int cpu, thread;
> +
> + if (config->aggr_mode == AGGR_GLOBAL) {
> + process_stat(counter, -1, -1, time,
> +  >counts->aggr);
> + return;
> + }
> +
> + for (thread = 0; thread < threads->nr; thread++) {
> + for (cpu = 0; cpu < cpus->nr; cpu++) {
> + process_stat(counter, cpus->map[cpu],
> +  thread_map__pid(threads, thread), time,
> +  perf_counts(counter->counts, cpu, thread));
> + }
> + }
> +}
> +
> +static void python_process_stat_interval(u64 time)
> +{
> + PyObject *handler, *t;
> + static const char handler_name[] = "stat__interval";
> + int n = 0;
> +
> + t = PyTuple_New(MAX_FIELDS);
> + if (!t)
> + Py_FatalError("couldn't create Python tuple");
> +
> + handler = get_handler(handler_name);
> + if (!handler) {
> + pr_debug("can't find python handler %s\n", handler_name);
> + return;
> + }
> +
> + PyTuple_SetItem(t, n++, PyLong_FromLong(time));

Ditto.

Thanks,
Namhyung


> +
> + if (_PyTuple_Resize(, n) == -1)
> + Py_FatalError("error resizing Python tuple");
> +
> + call_object(handler, t, 

Re: [PATCH v6 04/20] arm64: change some CONFIG_COMPAT over to use CONFIG_AARCH32_EL0 instead

2015-12-23 Thread Yury Norov
On Wed, Dec 16, 2015 at 12:42:30AM +0300, Yury Norov wrote:
> --- a/arch/arm64/include/asm/unistd.h
> +++ b/arch/arm64/include/asm/unistd.h
> @@ -13,9 +13,8 @@
>   * You should have received a copy of the GNU General Public License
>   * along with this program.  If not, see .
>   */
> -#ifdef CONFIG_COMPAT
> +#ifdef CONFIG_AARCH32_EL0
>  #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
> -#define __ARCH_WANT_COMPAT_STAT64
>  #define __ARCH_WANT_SYS_GETHOSTNAME
>  #define __ARCH_WANT_SYS_PAUSE
>  #define __ARCH_WANT_SYS_GETPGRP
> @@ -26,7 +25,9 @@
>  #define __ARCH_WANT_COMPAT_SYS_SENDFILE
>  #define __ARCH_WANT_SYS_FORK
>  #define __ARCH_WANT_SYS_VFORK
> +#endif
>  
> +#ifdef CONFIG_COMPAT

It seems like __NR_compat_* and __ARM_NR_compat_*
are needed by aarch32 only. If so, it should not be
defined for ilp32. And the only common definition
here would be __ARCH_WANT_COMPAT_STAT64.

>  /*
>   * Compat syscall numbers used by the AArch64 kernel.
>   */
> @@ -44,6 +45,8 @@
>  #define __ARM_NR_compat_cacheflush   (__ARM_NR_COMPAT_BASE+2)
>  #define __ARM_NR_compat_set_tls  (__ARM_NR_COMPAT_BASE+5)
>  
> +#define __ARCH_WANT_COMPAT_STAT64
> +
>  #define __NR_compat_syscalls 390
>  #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] PCI/AER: include header file

2015-12-23 Thread Jens Axboe

On 12/23/2015 08:35 AM, Sudip Mukherjee wrote:

We are having build failure with sparc allmodconfig with the error:

drivers/nvme/host/pci.c:15:0:
include/linux/aer.h: In function 'pci_enable_pcie_error_reporting':
include/linux/aer.h:49:10: error: 'EINVAL' undeclared (first use in this 
function)

The file aer.h is using the error values but they are defined in
errno.h. Include errno.h so that we have the definitions of the error
codes.


Applied to for-4.5/nvme, thanks.

--
Jens Axboe

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


Re: [PATCH 1/8] kernfs: Add API to generate relative kernfs path

2015-12-23 Thread Tejun Heo
Hello, Serge.

On Tue, Dec 22, 2015 at 10:23:22PM -0600, serge.hal...@ubuntu.com wrote:
> @@ -164,18 +286,39 @@ void pr_cont_kernfs_name(struct kernfs_node *kn)
>  void pr_cont_kernfs_path(struct kernfs_node *kn)
>  {
>   unsigned long flags;
> - char *p;
> + char *p = NULL;
> + int sz1, sz2;
>  
>   spin_lock_irqsave(_rename_lock, flags);
>  
> - p = kernfs_path_locked(kn, kernfs_pr_cont_buf,
> -sizeof(kernfs_pr_cont_buf));
> - if (p)
> - pr_cont("%s", p);
> - else
> - pr_cont("");
> + sz1 = kernfs_path_from_node_locked(kn, NULL, kernfs_pr_cont_buf,
> +sizeof(kernfs_pr_cont_buf));
> + if (sz1 < 0) {
> + pr_cont("(error)");
> + goto out;
> + }
> +
> + if (sz1 < sizeof(kernfs_pr_cont_buf)) {
> + pr_cont("%s", kernfs_pr_cont_buf);
> + goto out;
> + }
> +
> + p = kmalloc(sz1 + 1, GFP_NOFS);

We can't do GFP_NOFS allocation while holding a spinlock and we don't
want to do atomic allocation here either.  I think it'd be best to
keep using the static buffer.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/8] cgroup: introduce cgroup namespaces

2015-12-23 Thread Tejun Heo
Hello,

On Tue, Dec 22, 2015 at 10:23:24PM -0600, serge.hal...@ubuntu.com wrote:
...
> +char *cgroup_path(struct cgroup *cgrp, char *buf, size_t buflen)
> +{
> + int ret;
> + 
> + ret = cgroup_path_ns(cgrp, buf, buflen, current->nsproxy->cgroup_ns);
> + if (ret < 0 || ret >= buflen)
> + return NULL;
> + return buf;
> +}
> +EXPORT_SYMBOL_GPL(cgroup_path);

Shouldn't this function check whether it's being called from a task
context?  e.g. it could be being called from an irq handler and may
end up scoping the path incorrectly.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/8] kernfs: define kernfs_node_dentry

2015-12-23 Thread Tejun Heo
On Tue, Dec 22, 2015 at 10:23:26PM -0600, serge.hal...@ubuntu.com wrote:
> From: Aditya Kali 
> 
> Add a new kernfs api is added to lookup the dentry for a particular
> kernfs path.
> 
> Signed-off-by: Aditya Kali 
> Signed-off-by: Serge E. Hallyn 

Greg, this is the other kernfs change in the series.  Can I route this
through the cgroup tree with other changes?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[Bugfix v2 3/5] x86/irq: Fix a race window in x86_vector_free_irqs()

2015-12-23 Thread Jiang Liu
There's a race condition between x86_vector_free_irqs()
{
free_apic_chip_data(irq_data->chip_data);
x   //irq_data->chip_data has been freed, but the pointer
//hasn't been reset yet
irq_domain_reset_irq_data(irq_data);
}
and smp_irq_move_cleanup_interrupt()
{
raw_spin_lock(_lock);
data = apic_chip_data(irq_desc_get_irq_data(desc));
access data->   // may access freed memory
raw_spin_unlock(>lock);
}
, which may cause smp_irq_move_cleanup_interrupt() accesses freed memory.
So use vector_lock to guard all memory free code in x86_vector_free_irqs().

Signed-off-by: Jiang Liu 
---
 arch/x86/kernel/apic/vector.c |   20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index b32c6ef7b4b0..f648fce39d5e 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -228,23 +228,16 @@ static int assign_irq_vector_policy(int irq, int node,
 static void clear_irq_vector(int irq, struct apic_chip_data *data)
 {
struct irq_desc *desc;
-   unsigned long flags;
-   int cpu, vector;
-
-   raw_spin_lock_irqsave(_lock, flags);
-   BUG_ON(!data->cfg.vector);
+   int cpu, vector = data->cfg.vector;
 
-   vector = data->cfg.vector;
+   BUG_ON(!vector);
for_each_cpu_and(cpu, data->domain, cpu_online_mask)
per_cpu(vector_irq, cpu)[vector] = VECTOR_UNUSED;
-
data->cfg.vector = 0;
cpumask_clear(data->domain);
 
-   if (likely(!data->move_in_progress)) {
-   raw_spin_unlock_irqrestore(_lock, flags);
+   if (likely(!data->move_in_progress))
return;
-   }
 
desc = irq_to_desc(irq);
for_each_cpu_and(cpu, data->old_domain, cpu_online_mask) {
@@ -257,7 +250,7 @@ static void clear_irq_vector(int irq, struct apic_chip_data 
*data)
}
}
data->move_in_progress = 0;
-   raw_spin_unlock_irqrestore(_lock, flags);
+   cpumask_clear(data->old_domain);
 }
 
 void init_irq_alloc_info(struct irq_alloc_info *info,
@@ -279,18 +272,21 @@ static void x86_vector_free_irqs(struct irq_domain 
*domain,
 unsigned int virq, unsigned int nr_irqs)
 {
struct irq_data *irq_data;
+   unsigned long flags;
int i;
 
for (i = 0; i < nr_irqs; i++) {
irq_data = irq_domain_get_irq_data(x86_vector_domain, virq + i);
if (irq_data && irq_data->chip_data) {
+   raw_spin_lock_irqsave(_lock, flags);
clear_irq_vector(virq + i, irq_data->chip_data);
free_apic_chip_data(irq_data->chip_data);
+   irq_domain_reset_irq_data(irq_data);
+   raw_spin_unlock_irqrestore(_lock, flags);
 #ifdef CONFIG_X86_IO_APIC
if (virq + i < nr_legacy_irqs())
legacy_irq_data[virq + i] = NULL;
 #endif
-   irq_domain_reset_irq_data(irq_data);
}
}
 }
-- 
1.7.10.4

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


[Bugfix v2 4/5] x86/irq: Fix a race condition between vector assigning and cleanup

2015-12-23 Thread Jiang Liu
Joe Lawrence  reported an use after release
issue related to x86 IRQ management code. Please refer to following
link for more information:
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1026840.html

Thomas pointed out that it's caused by a race condition between
__assign_irq_vector() and __send_cleanup_vector(). Based on Thomas'
draft patch, we solve this race condition by:
1) Use move_in_progress to signal that an IRQ cleanup IPI is needed
2) Use old_domain to save old CPU mask for IRQ cleanup
3) Use vector to protect move_in_progress and old_domain

This bugfix patch also helps to get rid of that atomic allocation in
__send_cleanup_vector().

Signed-off-by: Jiang Liu 
---
 arch/x86/kernel/apic/vector.c |   76 ++---
 1 file changed, 34 insertions(+), 42 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index f648fce39d5e..ab54b296a7d0 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -119,7 +119,7 @@ static int __assign_irq_vector(int irq, struct 
apic_chip_data *d,
int cpu, err;
unsigned int dest;
 
-   if (d->move_in_progress)
+   if (cpumask_intersects(d->old_domain, cpu_online_mask))
return -EBUSY;
 
/* Only try and allocate irqs on cpus that are present */
@@ -141,13 +141,14 @@ static int __assign_irq_vector(int irq, struct 
apic_chip_data *d,
cpumask_and(used_cpumask, d->domain, vector_cpumask);
err = apic->cpu_mask_to_apicid_and(mask, used_cpumask,
   );
-   if (err || cpumask_equal(vector_cpumask, d->domain))
+   if (err)
break;
-   cpumask_andnot(d->old_domain, d->domain,
-  vector_cpumask);
-   d->move_in_progress =
-  cpumask_intersects(d->old_domain, cpu_online_mask);
-   cpumask_copy(d->domain, used_cpumask);
+   d->cfg.dest_apicid = dest;
+   if (!cpumask_equal(vector_cpumask, d->domain)) {
+   cpumask_andnot(d->old_domain, d->domain,
+  vector_cpumask);
+   cpumask_copy(d->domain, used_cpumask);
+   }
break;
}
 
@@ -180,22 +181,20 @@ next:
/* Found one! */
current_vector = vector;
current_offset = offset;
-   if (d->cfg.vector) {
+   if (d->cfg.vector)
cpumask_copy(d->old_domain, d->domain);
-   d->move_in_progress =
-  cpumask_intersects(d->old_domain, cpu_online_mask);
-   }
+   d->cfg.vector = vector;
+   d->cfg.dest_apicid = dest;
for_each_cpu_and(new_cpu, vector_cpumask, cpu_online_mask)
per_cpu(vector_irq, new_cpu)[vector] = irq_to_desc(irq);
-   d->cfg.vector = vector;
cpumask_copy(d->domain, vector_cpumask);
err = 0;
break;
}
 
if (!err) {
-   /* cache destination APIC IDs into cfg->dest_apicid */
-   d->cfg.dest_apicid = dest;
+   cpumask_and(d->old_domain, d->old_domain, cpu_online_mask);
+   d->move_in_progress = !cpumask_empty(d->old_domain);
}
 
return err;
@@ -227,7 +226,7 @@ static int assign_irq_vector_policy(int irq, int node,
 
 static void clear_irq_vector(int irq, struct apic_chip_data *data)
 {
-   struct irq_desc *desc;
+   struct irq_desc *desc = irq_to_desc(irq);
int cpu, vector = data->cfg.vector;
 
BUG_ON(!vector);
@@ -236,10 +235,6 @@ static void clear_irq_vector(int irq, struct 
apic_chip_data *data)
data->cfg.vector = 0;
cpumask_clear(data->domain);
 
-   if (likely(!data->move_in_progress))
-   return;
-
-   desc = irq_to_desc(irq);
for_each_cpu_and(cpu, data->old_domain, cpu_online_mask) {
for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
 vector++) {
@@ -421,10 +416,13 @@ static void __setup_vector_irq(int cpu)
struct irq_data *idata = irq_desc_get_irq_data(desc);
 
data = apic_chip_data(idata);
-   if (!data || !cpumask_test_cpu(cpu, data->domain))
-   continue;
-   vector = data->cfg.vector;
-   per_cpu(vector_irq, cpu)[vector] = desc;
+   if (data) {
+   cpumask_clear_cpu(cpu, data->old_domain);
+   if (cpumask_test_cpu(cpu, data->domain)) {
+

[Bugfix v2 1/5] x86/irq: Do not reuse struct apic_chip_data.old_domain as temporary buffer

2015-12-23 Thread Jiang Liu
Function __assign_irq_vector() makes use of apic_chip_data.old_domain
as a temporary buffer, which causes trouble to rollback logic in case of
failure. So use a dedicated temporary buffer for __assign_irq_vector().

Signed-off-by: Jiang Liu 
---
 arch/x86/kernel/apic/vector.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 861bc59c8f25..d6ec36b4461e 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -30,7 +30,7 @@ struct apic_chip_data {
 
 struct irq_domain *x86_vector_domain;
 static DEFINE_RAW_SPINLOCK(vector_lock);
-static cpumask_var_t vector_cpumask;
+static cpumask_var_t vector_cpumask, used_cpumask;
 static struct irq_chip lapic_controller;
 #ifdef CONFIG_X86_IO_APIC
 static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY];
@@ -124,6 +124,7 @@ static int __assign_irq_vector(int irq, struct 
apic_chip_data *d,
/* Only try and allocate irqs on cpus that are present */
err = -ENOSPC;
cpumask_clear(d->old_domain);
+   cpumask_clear(used_cpumask);
cpu = cpumask_first_and(mask, cpu_online_mask);
while (cpu < nr_cpu_ids) {
int new_cpu, vector, offset;
@@ -157,9 +158,8 @@ next:
}
 
if (unlikely(current_vector == vector)) {
-   cpumask_or(d->old_domain, d->old_domain,
-  vector_cpumask);
-   cpumask_andnot(vector_cpumask, mask, d->old_domain);
+   cpumask_or(used_cpumask, used_cpumask, vector_cpumask);
+   cpumask_andnot(vector_cpumask, mask, used_cpumask);
cpu = cpumask_first_and(vector_cpumask,
cpu_online_mask);
continue;
@@ -404,6 +404,7 @@ int __init arch_early_irq_init(void)
arch_init_htirq_domain(x86_vector_domain);
 
BUG_ON(!alloc_cpumask_var(_cpumask, GFP_KERNEL));
+   BUG_ON(!alloc_cpumask_var(_cpumask, GFP_KERNEL));
 
return arch_early_ioapic_init();
 }
-- 
1.7.10.4

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


[Bugfix v2 2/5] x86/irq: Enhance __assign_irq_vector() to rollback in case of failure

2015-12-23 Thread Jiang Liu
Enhance __assign_irq_vector() to rollback in case of failure so the
caller doesn't need to explicitly rollback.

Signed-off-by: Jiang Liu 
---
 arch/x86/kernel/apic/vector.c |   26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index d6ec36b4461e..b32c6ef7b4b0 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -117,6 +117,7 @@ static int __assign_irq_vector(int irq, struct 
apic_chip_data *d,
static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START;
static int current_offset = VECTOR_OFFSET_START % 16;
int cpu, err;
+   unsigned int dest;
 
if (d->move_in_progress)
return -EBUSY;
@@ -132,19 +133,21 @@ static int __assign_irq_vector(int irq, struct 
apic_chip_data *d,
apic->vector_allocation_domain(cpu, vector_cpumask, mask);
 
if (cpumask_subset(vector_cpumask, d->domain)) {
-   err = 0;
-   if (cpumask_equal(vector_cpumask, d->domain))
-   break;
/*
 * New cpumask using the vector is a proper subset of
 * the current in use mask. So cleanup the vector
 * allocation for the members that are not used anymore.
 */
+   cpumask_and(used_cpumask, d->domain, vector_cpumask);
+   err = apic->cpu_mask_to_apicid_and(mask, used_cpumask,
+  );
+   if (err || cpumask_equal(vector_cpumask, d->domain))
+   break;
cpumask_andnot(d->old_domain, d->domain,
   vector_cpumask);
d->move_in_progress =
   cpumask_intersects(d->old_domain, cpu_online_mask);
-   cpumask_and(d->domain, d->domain, vector_cpumask);
+   cpumask_copy(d->domain, used_cpumask);
break;
}
 
@@ -167,11 +170,13 @@ next:
 
if (test_bit(vector, used_vectors))
goto next;
-
for_each_cpu_and(new_cpu, vector_cpumask, cpu_online_mask) {
if (!IS_ERR_OR_NULL(per_cpu(vector_irq, 
new_cpu)[vector]))
goto next;
}
+   if (apic->cpu_mask_to_apicid_and(mask, vector_cpumask, ))
+   goto next;
+
/* Found one! */
current_vector = vector;
current_offset = offset;
@@ -190,8 +195,7 @@ next:
 
if (!err) {
/* cache destination APIC IDs into cfg->dest_apicid */
-   err = apic->cpu_mask_to_apicid_and(mask, d->domain,
-  >cfg.dest_apicid);
+   d->cfg.dest_apicid = dest;
}
 
return err;
@@ -493,14 +497,8 @@ static int apic_set_affinity(struct irq_data *irq_data,
return -EINVAL;
 
err = assign_irq_vector(irq, data, dest);
-   if (err) {
-   if (assign_irq_vector(irq, data,
- irq_data_get_affinity_mask(irq_data)))
-   pr_err("Failed to recover vector for irq %d\n", irq);
-   return err;
-   }
 
-   return IRQ_SET_MASK_OK;
+   return err ? err : IRQ_SET_MASK_OK;
 }
 
 static struct irq_chip lapic_controller = {
-- 
1.7.10.4

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


Re: [PATCH v2 0/9] ARM: dts: Add compatible property to "partitions" node

2015-12-23 Thread Geert Uytterhoeven
Hi Olof, Gregory,

On Wed, Dec 23, 2015 at 12:04 PM, Gregory CLEMENT
 wrote:
>  On mar., déc. 22 2015, Olof Johansson  wrote:
>> On Mon, Dec 21, 2015 at 11:33:44AM +0100, Geert Uytterhoeven wrote:
>>> As of commit e488ca9f8d4f62c2 ("doc: dt: mtd: partitions: add compatible
>>> property to "partitions" node"), which is in v4.4-rc6, the "partitions"
>>> subnode of an SPI FLASH device node must have a compatible property. The
>>> partitions are no longer detected if it is not present.
>>>
>>> However, several DTSes in -next have already been converted to the
>>> "partitions" subnode without "compatible" property, introduced by
>>> commits 5cfdedb7b9a0fe38 ("mtd: ofpart: move ofpart partitions to a
>>> dedicated dt node") and fe2585e9c29a650a ("doc: dt: mtd: support
>>> partitions in a special 'partitions' subnode"). Hence all of these are
>>> now broken in -next, and will be broken in upstream during the merge
>>> window.
>>
>> So, if I understand this correctly, the partitions format was added for v4.4,
>> then this non-backwards compatible change was added in -rc6. But, there were
>> also DT files that had the new-for-v4.4 partitions nodes in them that then
>> stopped working in -rc6?
>
> At least for the mvebu dts, the change was added for v4.5 not
> v4.4. Currently it is only in the next branches (and also in your
> arm-soc tree in next/dt).

The same is true for the shmobile changes: they are queued up for v4.5.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/3] Add AMBA bus probing support to ACPI

2015-12-23 Thread Aleksey Makarov
As discussed when Shannon Zhao sent a patch to add platform_device support
to pl061 driver. Russel and other maintainers prefered that ACPI learned
how to create AMBA devices rather than converting/adding platform_device
support to AMBA drivers.

http://comments.gmane.org/gmane.linux.ports.arm.kernel/431364

1) Adds basic AMBA device probing support to ACPI, it uses a whitelist of
device IDs as the number of AMBA devices is limited. Currently the two ids
present are those used in QEMU for arm64.

2) Adds the plumbing into ACPI probe sequence.

3) From ACPI pl011 is only defined (SBSA document) to be in SBSA mode which has
reduced functionality. There may be a better method to do this that I have
overlooked.

v4:
- A memory leak has been fixed (Vladimir Zapolskiy)
- ACPI_COMPANION() -> has_acpi_companion() (Andy Shevchenko)
- pr_err() -> dev_err() (Andy Shevchenko)
- The call to amba_register_dummy_clk() has been moved to to acpi_amba_init()
  (Vladimir Zapolskiy)
- Return value has been fixed (Vladimir Zapolskiy)

v3:
https://lkml.kernel.org/g/1450716100-13688-1-git-send-email-aleksey.maka...@linaro.org
- Compilation without CONFIG_ARM_AMBA has been fixed

v2:
https://lkml.kernel.org/g/1450709399-7246-1-git-send-email-aleksey.maka...@linaro.org
- A new ACPI scan handler for AMBA devices has been implemented
- The order of `if` branches in amba-pl011.c has been changed
- A couple of `static`s have been added
- The compilation of the acpi_amba.c unit has made conditional
- A comment on SBSA UART has been added

v1:
https://lkml.kernel.org/g/1443609530-21524-1-git-send-email-graeme.greg...@linaro.org

Graeme Gregory (3):
  ACPI: amba bus probing support
  ACPI: scan add in amba probing
  serial: amba-pl011: add ACPI support to AMBA probe

 drivers/acpi/Makefile   |   1 +
 drivers/acpi/acpi_amba.c| 140 
 drivers/acpi/internal.h |   5 ++
 drivers/acpi/scan.c |   1 +
 drivers/tty/serial/amba-pl011.c |  37 +++
 5 files changed, 173 insertions(+), 11 deletions(-)
 create mode 100644 drivers/acpi/acpi_amba.c

-- 
2.6.4

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


Re: KVM: memory ballooning bug?

2015-12-23 Thread Rafael Aquini
On Wed, Dec 23, 2015 at 11:17:10PM +0900, Minchan Kim wrote:
> On Wed, Dec 23, 2015 at 06:14:49AM -0500, Rafael Aquini wrote:
> > On Wed, Dec 23, 2015 at 02:22:28PM +0900, Minchan Kim wrote:
> > > During my compaction-related stuff, I encountered some problems with
> > > ballooning.
> > > 
> > > Firstly, with repeated inflating and deflating cycle, guest memory(ie,
> > > cat /proc/meminfo | grep MemTotal) decreased and couldn't recover.
> > > 
> > > When I review source code, balloon_lock should cover 
> > > release_pages_balloon.
> > > Otherwise, struct virtio_balloon fields could be overwritten by race
> > > of fill_balloon(e,g, vb->*pfns could be critical).
> > > Below patch fixed the problem.
> > > 
> > > diff --git a/drivers/virtio/virtio_balloon.c 
> > > b/drivers/virtio/virtio_balloon.c
> > > index 7efc32945810..7d3e5d0e9aa4 100644
> > > --- a/drivers/virtio/virtio_balloon.c
> > > +++ b/drivers/virtio/virtio_balloon.c
> > > @@ -209,8 +209,8 @@ static unsigned leak_balloon(struct virtio_balloon 
> > > *vb, size_t num)
> > >  */
> > > if (vb->num_pfns != 0)
> > > tell_host(vb, vb->deflate_vq);
> > > -   mutex_unlock(>balloon_lock);
> > > release_pages_balloon(vb);
> > > +   mutex_unlock(>balloon_lock);
> > > return num_freed_pages;
> > >  }
> > >  
> > > Secondly, in balloon_page_dequeue, pages_lock should cover
> > > list_for_each_entry_safe loop. Otherwise, the cursor page
> > > could be isolated by compaction and then list_del by isolation
> > > could poison the page->lru so the loop could access wrong address
> > > like this.
> > > 
> > > general protection fault:  [#1] SMP 
> > > Dumping ftrace buffer:
> > >(ftrace buffer empty)
> > > Modules linked in:
> > > CPU: 2 PID: 82 Comm: vballoon Not tainted 4.4.0-rc5-mm1+ #1906
> > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 
> > > 01/01/2011
> > > task: 8800a7ff ti: 8800a7fec000 task.ti: 8800a7fec000
> > > RIP: 0010:[]  [] 
> > > balloon_page_dequeue+0x54/0x130
> > > RSP: 0018:8800a7fefdc0  EFLAGS: 00010246
> > > RAX: 88013fff9a70 RBX: ea56fe00 RCX: 2b7d
> > > RDX: 88013fff9a70 RSI: ea56fe00 RDI: 88013fff9a68
> > > RBP: 8800a7fefde8 R08: ea56fda0 R09: 
> > > R10: 8800a7fefd90 R11: 0001 R12: dead00e0
> > > R13: ea56fe20 R14: 880138809070 R15: 880138809060
> > > FS:  () GS:88013fc4() 
> > > knlGS:
> > > CS:  0010 DS:  ES:  CR0: 8005003b
> > > CR2: 7f229c10e000 CR3: b8b53000 CR4: 06a0
> > > Stack:
> > >  0100 880138809088 880138809000 880138809060
> > >  0046 8800a7fefe28 812c86d3 880138809020
> > >  880138809000 fff91900 0100 880138809060
> > > Call Trace:
> > >  [] leak_balloon+0x93/0x1a0
> > >  [] balloon+0x217/0x2a0
> > >  [] ? __schedule+0x31e/0x8b0
> > >  [] ? abort_exclusive_wait+0xb0/0xb0
> > >  [] ? update_balloon_stats+0xf0/0xf0
> > >  [] kthread+0xc9/0xe0
> > >  [] ? kthread_park+0x60/0x60
> > >  [] ret_from_fork+0x3f/0x70
> > >  [] ? kthread_park+0x60/0x60
> > > Code: 8d 60 e0 0f 84 af 00 00 00 48 8b 43 20 a8 01 75 3b 48 89 d8 f0 0f 
> > > ba 28 00 72 10 48 8b 03 f6 c4 08 75 2f 48 89 df e8 8c 83 f9 ff <49> 8b 44 
> > > 24 20 4d 8d 6c 24 20 48 83 e8 20 4d 39 f5 74 7a 4c 89 
> > > RIP  [] balloon_page_dequeue+0x54/0x130
> > >  RSP 
> > > ---[ end trace 43cf28060d708d5f ]---
> > > Kernel panic - not syncing: Fatal exception
> > > Dumping ftrace buffer:
> > >(ftrace buffer empty)
> > > Kernel Offset: disabled
> > > 
> > > We could fix it by protecting the entire loop by pages_lock but
> > > problem is irq latency during walking the list.
> > > But I doubt how often such worst scenario happens because
> > > in normal situation, the loop would exit easily via succeeding
> > > trylock_page.
> > > 
> > > Any comments?
> > 
> > Nope, I think the simplest way to address both cases you stumbled
> > across is by replacing the locking to extend those critical sections as
> > you suggested.
> 
> I couldn't understand why you said "Nope" and which lock do you mean?
> There are two locks to need to extend.
> If you are on same page with me, I suggested this.
> 
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 7efc329..7d3e5d0 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -209,8 +209,8 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
> size_t num)
>*/
>   if (vb->num_pfns != 0)
>   tell_host(vb, vb->deflate_vq);
> - mutex_unlock(>balloon_lock);
>   release_pages_balloon(vb);
> + mutex_unlock(>balloon_lock);
>   return num_freed_pages;
>  }
>  
> diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
> index d3116be..300117f 100644
> --- 

[PATCH 2/2] ftrace/scripts: Have recordmcount copy the object file

2015-12-23 Thread Steven Rostedt
From: "Steven Rostedt (Red Hat)" 

Russell King found that he had weird side effects when compiling the kernel
with hard linked ccache. The reason was that recordmcount modified the
kernel in place via mmap, and when a file gets modified twice by
recordmcount, it will complain about it. To fix this issue, Russell wrote a
patch that checked if the file was hard linked more than once and would
unlink it if it was.

Linus Torvalds was not happy with the fact that recordmcount does this in
place modification. Instead of doing the unlink only if the file has two or
more hard links, it does the unlink all the time. In otherwords, it always
does a copy if it changed something. That is, it does the write out if a
change was made.

Cc: sta...@vger.kernel.org # 2.6.37+
Signed-off-by: Steven Rostedt 
---
 scripts/recordmcount.c | 145 +
 1 file changed, 110 insertions(+), 35 deletions(-)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 91705ef30402..301d70b0174f 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -48,12 +48,17 @@
 
 static int fd_map; /* File descriptor for file being modified. */
 static int mmap_failed; /* Boolean flag. */
-static void *ehdr_curr; /* current ElfXX_Ehdr *  for resource cleanup */
 static char gpfx;  /* prefix for global symbol name (sometimes '_') */
 static struct stat sb; /* Remember .st_size, etc. */
 static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */
 static const char *altmcount;  /* alternate mcount symbol name */
 static int warn_on_notrace_sect; /* warn when section has mcount not being 
recorded */
+static void *file_map; /* pointer of the mapped file */
+static void *file_end; /* pointer to the end of the mapped file */
+static int file_updated; /* flag to state file was changed */
+static void *file_ptr; /* current file pointer location */
+static void *file_append; /* added to the end of the file */
+static size_t file_append_size; /* how much is added to end of file */
 
 /* setjmp() return values */
 enum {
@@ -67,10 +72,14 @@ static void
 cleanup(void)
 {
if (!mmap_failed)
-   munmap(ehdr_curr, sb.st_size);
+   munmap(file_map, sb.st_size);
else
-   free(ehdr_curr);
-   close(fd_map);
+   free(file_map);
+   file_map = NULL;
+   free(file_append);
+   file_append = NULL;
+   file_append_size = 0;
+   file_updated = 0;
 }
 
 static void __attribute__((noreturn))
@@ -92,12 +101,22 @@ succeed_file(void)
 static off_t
 ulseek(int const fd, off_t const offset, int const whence)
 {
-   off_t const w = lseek(fd, offset, whence);
-   if (w == (off_t)-1) {
-   perror("lseek");
+   switch (whence) {
+   case SEEK_SET:
+   file_ptr = file_map + offset;
+   break;
+   case SEEK_CUR:
+   file_ptr += offset;
+   break;
+   case SEEK_END:
+   file_ptr = file_map + (sb.st_size - offset);
+   break;
+   }
+   if (file_ptr < file_map) {
+   fprintf(stderr, "lseek: seek before file\n");
fail_file();
}
-   return w;
+   return file_ptr - file_map;
 }
 
 static size_t
@@ -114,12 +133,38 @@ uread(int const fd, void *const buf, size_t const count)
 static size_t
 uwrite(int const fd, void const *const buf, size_t const count)
 {
-   size_t const n = write(fd, buf, count);
-   if (n != count) {
-   perror("write");
-   fail_file();
+   size_t cnt = count;
+   off_t idx = 0;
+
+   file_updated = 1;
+
+   if (file_ptr + count >= file_end) {
+   off_t aoffset = (file_ptr + count) - file_end;
+
+   if (aoffset > file_append_size) {
+   file_append = realloc(file_append, aoffset);
+   file_append_size = aoffset;
+   }
+   if (!file_append) {
+   perror("write");
+   fail_file();
+   }
+   if (file_ptr < file_end) {
+   cnt = file_end - file_ptr;
+   } else {
+   cnt = 0;
+   idx = aoffset - count;
+   }
}
-   return n;
+
+   if (cnt)
+   memcpy(file_ptr, buf, cnt);
+
+   if (cnt < count)
+   memcpy(file_append + idx, buf + cnt, count - cnt);
+
+   file_ptr += count;
+   return count;
 }
 
 static void *
@@ -192,9 +237,7 @@ static int make_nop_arm64(void *map, size_t const offset)
  */
 static void *mmap_file(char const *fname)
 {
-   void *addr;
-
-   fd_map = open(fname, O_RDWR);
+   fd_map = open(fname, O_RDONLY);
if (fd_map < 0 || fstat(fd_map, ) < 0) {
perror(fname);
fail_file();
@@ -203,29 +246,58 @@ static void 

[PATCH v2] PCI/AER: include header file

2015-12-23 Thread Sudip Mukherjee
We are having build failure with sparc allmodconfig with the error:

drivers/nvme/host/pci.c:15:0:
include/linux/aer.h: In function 'pci_enable_pcie_error_reporting':
include/linux/aer.h:49:10: error: 'EINVAL' undeclared (first use in this 
function)

The file aer.h is using the error values but they are defined in
errno.h. Include errno.h so that we have the definitions of the error
codes.

Fixes: a0a3408ee614 ("NVMe: Add pci error handlers")
Cc: Keith Busch 
Signed-off-by: Sudip Mukherjee 
---

v1 and its review is at:
https://lkml.org/lkml/2015/12/23/226

sparc allmodconfig build is at:
https://travis-ci.org/sudipm-mukherjee/parport/jobs/98451364


 include/linux/aer.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/aer.h b/include/linux/aer.h
index 744b997..1640493 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -7,6 +7,7 @@
 #ifndef _AER_H_
 #define _AER_H_
 
+#include 
 #include 
 
 #define AER_NONFATAL   0
-- 
1.9.1

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


Re: [PATCH 5/8] perf script: Add stat default handlers

2015-12-23 Thread Jiri Olsa
On Wed, Dec 23, 2015 at 10:40:38PM +0900, Namhyung Kim wrote:
> On Tue, Dec 22, 2015 at 04:43:31PM +0100, Jiri Olsa wrote:
> > Implement struct scripting_ops::(process_stat|process_stat_interval)
> > handlers - calling scripting handlers from stat events handlers.
> > 
> > Tested-by: Kan Liang 
> > Link: http://lkml.kernel.org/n/tip-3iu6vmvuur1bntbnh43v3...@git.kernel.org
> > Signed-off-by: Jiri Olsa 
> > ---
> >  tools/perf/builtin-script.c | 33 +
> >  1 file changed, 33 insertions(+)
> > 
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index a90bc0b81e70..656541eff151 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -221,6 +221,9 @@ static int perf_evsel__check_attr(struct perf_evsel 
> > *evsel,
> > struct perf_event_attr *attr = >attr;
> > bool allow_user_set;
> >  
> > +   if (perf_header__has_feat(>header, HEADER_STAT))
> > +   return 0;
> > +
> > allow_user_set = perf_header__has_feat(>header,
> >HEADER_AUXTRACE);
> >  
> > @@ -674,6 +677,18 @@ static void process_event(struct perf_script *script 
> > __maybe_unused, union perf_
> >  
> >  static struct scripting_ops*scripting_ops;
> >  
> > +static void process_stat(struct perf_evsel *counter, u64 time)
> > +{
> > +   if (scripting_ops)
> > +   scripting_ops->process_stat(_config, counter, time);
> 
> Shouldn't it be
> 
>   if (scripting_ops && scripting_ops->process_stat)
> 
> ?  It seems you only set it for python in patch 7..

right.. forgot about perf completely..

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tracing: use seq_buf_used() in seq_buf_to_user() instead of len

2015-12-23 Thread Steven Rostedt
On Mon, 16 Nov 2015 12:57:28 -0700
Jerry Snitselaar  wrote:

> commit 5ac48378414d ("tracing: Use trace_seq_used() and seq_buf_used()
> instead of len") changed the tracing code to use trace_seq_used() and
> seq_buf_used() instead of using the seq_buf len directly to avoid
> overflow issues, but missed a spot in seq_buf_to_user() that makes use
> of s->len.
> 
> Cleaned up the code a bit as well per suggestion of Steve Rostedt.
> 
> Cc: "Steven Rostedt (Red Hat)" 
> Signed-off-by: Jerry Snitselaar 

I finally got around to applying this. Thanks!

-- Steve

> ---
>  lib/seq_buf.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/seq_buf.c b/lib/seq_buf.c
> index 5c94e10..cb18469 100644
> --- a/lib/seq_buf.c
> +++ b/lib/seq_buf.c
> @@ -306,10 +306,12 @@ int seq_buf_to_user(struct seq_buf *s, char __user 
> *ubuf, int cnt)
>   if (!cnt)
>   return 0;
>  
> - if (s->len <= s->readpos)
> + len = seq_buf_used(s);
> +
> + if (len <= s->readpos)
>   return -EBUSY;
>  
> - len = seq_buf_used(s) - s->readpos;
> + len -= s->readpos;
>   if (cnt > len)
>   cnt = len;
>   ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);

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


[PATCH v2] um: Fix pointer cast

2015-12-23 Thread Mickaël Salaün
Fix a pointer cast typo introduced in v4.4-rc5 especially visible for
the i386 subarchitecture where it results in a kernel crash.

Fixes: 8090bfd2bb9a ("um: Fix fpstate handling")
Signed-off-by: Mickaël Salaün 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: Linus Torvalds 
Cc: Al Viro 
---
 arch/x86/um/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index e5f854ce2d72..14fcd01ed992 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -470,7 +470,7 @@ long sys_sigreturn(void)
struct sigcontext __user *sc = >sc;
int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
 
-   if (copy_from_user([0], (void *)sc->oldmask, 
sizeof(set.sig[0])) ||
+   if (copy_from_user([0], >oldmask, sizeof(set.sig[0])) ||
copy_from_user([1], frame->extramask, sig_size))
goto segfault;
 
-- 
2.6.4

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


[PATCH 3/4] USB: host: use to_platform_device

2015-12-23 Thread Geliang Tang
Use to_platform_device() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/usb/host/ehci-platform.c | 6 ++
 drivers/usb/host/ehci-st.c   | 6 ++
 drivers/usb/host/ohci-platform.c | 6 ++
 drivers/usb/host/ohci-st.c   | 6 ++
 4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index bd7082f2..1757ebb 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -345,8 +345,7 @@ static int ehci_platform_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
bool do_wakeup = device_may_wakeup(dev);
int ret;
 
@@ -364,8 +363,7 @@ static int ehci_platform_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
 
if (pdata->power_on) {
diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index b7c5cfa..a94ed67 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -287,8 +287,7 @@ static int st_ehci_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
bool do_wakeup = device_may_wakeup(dev);
int ret;
 
@@ -308,8 +307,7 @@ static int st_ehci_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ehci_pdata *pdata = dev_get_platdata(dev);
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
int err;
 
pinctrl_pm_select_default_state(dev);
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index c2669f18..ae1c988 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -310,8 +310,7 @@ static int ohci_platform_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ohci_pdata *pdata = dev->platform_data;
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
bool do_wakeup = device_may_wakeup(dev);
int ret;
 
@@ -329,8 +328,7 @@ static int ohci_platform_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ohci_pdata *pdata = dev_get_platdata(dev);
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
 
if (pdata->power_on) {
int err = pdata->power_on(pdev);
diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
index df9028e..acf2eb2 100644
--- a/drivers/usb/host/ohci-st.c
+++ b/drivers/usb/host/ohci-st.c
@@ -270,8 +270,7 @@ static int st_ohci_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ohci_pdata *pdata = dev->platform_data;
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
bool do_wakeup = device_may_wakeup(dev);
int ret;
 
@@ -289,8 +288,7 @@ static int st_ohci_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct usb_ohci_pdata *pdata = dev_get_platdata(dev);
-   struct platform_device *pdev =
-   container_of(dev, struct platform_device, dev);
+   struct platform_device *pdev = to_platform_device(dev);
int err;
 
if (pdata->power_on) {
-- 
2.5.0


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


  1   2   3   4   5   6   7   8   9   10   >