Sparse improvements & regressions for Linux v5.8-rc1 -> v5.9-rc1
Hi, Here is a comparison of Sparse's unique warnings between v5.8-rc1 & v5.9-rc1 on x86-64 (defconfig + allyesconfig). Note that the differences are be caused by changes in the kernel and in Sparse. The raw logs as well as the result of the processing giving the 'unique warnings' are available at: git://github.com/lucvoo/sparse-logs.git - 19249 18621 Total + 161 191 Initializer entry defined twice +98 105 Using plain integer as NULL pointer 394 394 advancing past deep designator 4 4 arithmetics on pointers to functions -1612 bad assignment to restricted type 4 4 cast between address spaces (__percpu -> __rcu) -38 0 cast from non-scalar - 276 261 cast from restricted type + 142 473 cast removes address space '__iomem' of expression 1 1 cast removes address space '__percpu' of expression 1515 cast removes address space '__rcu' of expression +4143 cast removes address space '__user' of expression -5113 cast to non-scalar + 4512 4550 cast to restricted type 609 609 cast truncates bits from constant value - 349 332 context imbalance - different lock contexts for basic block + 453 467 context imbalance - unexpected unlock 189 189 context imbalance - wrong count at exit - 118 109 dereference of noderef expression +1316 dubious: !x & y 1 1 dubious: !x | !y 6 6 dubious: !x | y -5756 dubious: x & !y -2120 dubious: x | !y + 0 1 duplicate [noderef] 2121 function with external linkage has definition 2 2 implicit cast from nocast type - 500 490 incompatible types in comparison expression (different address spaces) 3 3 incompatible types in comparison expression (different base types) 1 1 incompatible types in comparison expression (different type sizes) + 6 7 incompatible types in conditional expression (different base types) - 1225 1087 incorrect type in argument (different address spaces) - 515 494 incorrect type in argument (different base types) - 5 0 incorrect type in argument (different modifiers) -10 0 incorrect type in argument (different type sizes) 1 1 incorrect type in argument (incompatible argument (different address spaces)) - 1 0 incorrect type in argument (incompatible argument (different base types)) - 388 382 incorrect type in assignment (different address spaces) - 4945 4762 incorrect type in assignment (different base types) 1 1 incorrect type in assignment (different modifiers) - 141 120 incorrect type in initializer (different address spaces) - 132 131 incorrect type in initializer (different base types) 7 7 incorrect type in initializer (incompatible argument (different address spaces)) -2625 incorrect type in return expression (different address spaces) +2630 incorrect type in return expression (different base types) - 451 285 invalid assignment 3737 invalid bitfield specifier for type restricted type. -13 7 invalid initializer 1 1 marked inline, but without a definition 1 1 memcpy with byte count of ... 5 5 memset with byte count of ... 7 7 mixed bitwiseness -10 8 mixing different enum types: + 1 2 multiple address spaces given + 012 multiple definitions for ... - 1 0 no newline at end of file - 1 0 non-scalar type in conditional: - 959 918 restricted type degrades to integer -43 0 return expression in void function - 3 0 shift count is (-1) - 5 0 shift too big for type 1212 static assertion failed 5 5 subtraction of different types can't work (different address spaces) -2423 subtraction of functions? Share your drugs 1 1 switch with no cases 5 5 symbol redeclared with different type (incompatible argument (different address spaces)) - 2135 1852 symbol was not declared. Should it be static? 1 1 too long token expansion 3 3 trying to concatenate long character string (8191 bytes max) -- Luc
Re: [PATCH 1/2] ceph: Use generic debugging facility
Hi Joe, I love your patch! Yet something to improve: [auto build test ERROR on ceph-client/for-linus] [also build test ERROR on v5.9-rc1 next-20200814] [cannot apply to sage-ceph/for-linus] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Joe-Perches/ceph-Neaten-debugging/20200817-060623 base: https://github.com/ceph/ceph-client.git for-linus config: arc-randconfig-r014-20200817 (attached as .config) compiler: arc-elf-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/block/rbd.c: In function 'rbd_client_create': >> drivers/block/rbd.c:761:2: error: implicit declaration of function 'dout'; >> did you mean 'dput'? [-Werror=implicit-function-declaration] 761 | dout("%s:\n", __func__); | ^~~~ | dput cc1: some warnings being treated as errors # https://github.com/0day-ci/linux/commit/ab0413062c34a692c0480a3237a04534f823e02d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Joe-Perches/ceph-Neaten-debugging/20200817-060623 git checkout ab0413062c34a692c0480a3237a04534f823e02d vim +761 drivers/block/rbd.c 602adf400201636 Yehuda Sadeh2010-08-12 751 602adf400201636 Yehuda Sadeh2010-08-12 752 /* 7262cfca430a1a0 Alex Elder 2013-05-16 753 * Initialize an rbd client instance. Success or not, this function cfbf6377b696d88 Alex Elder 2013-05-31 754 * consumes ceph_opts. Caller holds client_mutex. 602adf400201636 Yehuda Sadeh2010-08-12 755 */ f8c3892911145db Alex Elder 2012-08-10 756 static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) 602adf400201636 Yehuda Sadeh2010-08-12 757 { 602adf400201636 Yehuda Sadeh2010-08-12 758 struct rbd_client *rbdc; 602adf400201636 Yehuda Sadeh2010-08-12 759 int ret = -ENOMEM; 602adf400201636 Yehuda Sadeh2010-08-12 760 37206ee5bede14d Alex Elder 2013-02-20 @761 dout("%s:\n", __func__); 602adf400201636 Yehuda Sadeh2010-08-12 762 rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL); 602adf400201636 Yehuda Sadeh2010-08-12 763 if (!rbdc) 602adf400201636 Yehuda Sadeh2010-08-12 764 goto out_opt; 602adf400201636 Yehuda Sadeh2010-08-12 765 602adf400201636 Yehuda Sadeh2010-08-12 766 kref_init(&rbdc->kref); 602adf400201636 Yehuda Sadeh2010-08-12 767 INIT_LIST_HEAD(&rbdc->node); 602adf400201636 Yehuda Sadeh2010-08-12 768 74da4a0f574d11e Ilya Dryomov2017-03-03 769 rbdc->client = ceph_create_client(ceph_opts, rbdc); 602adf400201636 Yehuda Sadeh2010-08-12 770 if (IS_ERR(rbdc->client)) 08f75463c15e26e Alex Elder 2013-05-29 771 goto out_rbdc; 43ae47011232c1e Alex Elder 2012-07-03 772 ceph_opts = NULL; /* Now rbdc->client is responsible for ceph_opts */ 602adf400201636 Yehuda Sadeh2010-08-12 773 602adf400201636 Yehuda Sadeh2010-08-12 774 ret = ceph_open_session(rbdc->client); 602adf400201636 Yehuda Sadeh2010-08-12 775 if (ret < 0) 08f75463c15e26e Alex Elder 2013-05-29 776 goto out_client; 602adf400201636 Yehuda Sadeh2010-08-12 777 432b858749631dc Alex Elder 2012-01-29 778 spin_lock(&rbd_client_list_lock); 602adf400201636 Yehuda Sadeh2010-08-12 779 list_add_tail(&rbdc->node, &rbd_client_list); 432b858749631dc Alex Elder 2012-01-29 780 spin_unlock(&rbd_client_list_lock); 602adf400201636 Yehuda Sadeh2010-08-12 781 37206ee5bede14d Alex Elder 2013-02-20 782 dout("%s: rbdc %p\n", __func__, rbdc); bc534d86be71aaf Alex Elder 2012-01-29 783 602adf400201636 Yehuda Sadeh2010-08-12 784 return rbdc; 08f75463c15e26e Alex Elder 2013-05-29 785 out_client: 602adf400201636 Yehuda Sadeh2010-08-12 786 ceph_destroy_client(rbdc->client); 08f75463c15e26e Alex Elder 2013-05-29 787 out_rbdc: 602adf400201636 Yehuda Sadeh2010-08-12 788 kfree(rbdc); 602adf400201636 Yehuda Sadeh2010-08-12 789 out_opt: 43ae47011232c1e Alex Elder 2012-07-03 790 if (ceph_opts) 43ae47011232c1e Alex Elder 2012-07-03 791 ceph_destroy_options(ceph_opts); 37206ee5bede14d Alex Elder 2013-02-20 792 dout("%s: error %d\n", __func__, ret); 37206ee5bede14d Alex Elder
AKZEPTIEREN SIE IM GUTEN GLAUBEN
-- Hallo Mein Mann und ich haben uns freiwillig für eine Spende entschieden, daher werden wir uns mit Ihnen in Verbindung setzen. Mit dieser Spende können Sie Wohltätigkeitsprojekte in Ihrer Nähe durchführen. Wenn Sie diese Nachricht erhalten haben: "Wir würden uns über eine schnelle Antwort freuen." Danke dir. Hinweis: Ihre E-Mail-Adresse wurde aus dem internationalen Webverzeichnis unseres Landes gefunden. Gott segne dich S.Rizavas
[PATCH 1/2] kernel/sys: only take tasklist_lock for get/setpriority(PRIO_PGRP)
PRIO_PGRP needs the tasklist_lock mainly to serialize vs setpgid(2), to protect against any concurrent change_pid(PIDTYPE_PGID) that can move the task from one hlist to another while iterating. However, the remaining can only rely only on RCU: PRIO_PROCESS only does the task lookup and never iterates over tasklist and we already have an rcu-aware stable pointer. PRIO_USER is already racy vs setuid(2) so with creds being rcu protected, we can end up seeing stale data. When removing the tasklist_lock there can be a race with (i) fork but this is benign as the child's nice is inherited and the new task is not observable by the user yet either, hence the return semantics do not differ. And (ii) a race with exit, which is a small window and can cause us to miss a task which was removed from the list and it had the highest nice. Similarly change the buggy do_each_thread/while_each_thread combo in PRIO_USER for the rcu-safe for_each_process_thread flavor, which doesn't make use of next_thread/p->thread_group. Suggested-by: Oleg Nesterov Signed-off-by: Davidlohr Bueso --- kernel/sys.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index ca11af9d815d..4d4f17c01a4f 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -214,7 +214,6 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) niceval = MAX_NICE; rcu_read_lock(); - read_lock(&tasklist_lock); switch (which) { case PRIO_PROCESS: if (who) @@ -229,9 +228,11 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) pgrp = find_vpid(who); else pgrp = task_pgrp(current); + read_lock(&tasklist_lock); do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { error = set_one_prio(p, niceval, error); } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); + read_unlock(&tasklist_lock); break; case PRIO_USER: uid = make_kuid(cred->user_ns, who); @@ -243,16 +244,15 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) if (!user) goto out_unlock;/* No processes for this user */ } - do_each_thread(g, p) { + for_each_process_thread(g, p) { if (uid_eq(task_uid(p), uid) && task_pid_vnr(p)) error = set_one_prio(p, niceval, error); - } while_each_thread(g, p); + } if (!uid_eq(uid, cred->uid)) free_uid(user); /* For find_user() */ break; } out_unlock: - read_unlock(&tasklist_lock); rcu_read_unlock(); out: return error; @@ -277,7 +277,6 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) return -EINVAL; rcu_read_lock(); - read_lock(&tasklist_lock); switch (which) { case PRIO_PROCESS: if (who) @@ -295,11 +294,13 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) pgrp = find_vpid(who); else pgrp = task_pgrp(current); + read_lock(&tasklist_lock); do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { niceval = nice_to_rlimit(task_nice(p)); if (niceval > retval) retval = niceval; } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); + read_unlock(&tasklist_lock); break; case PRIO_USER: uid = make_kuid(cred->user_ns, who); @@ -311,19 +312,18 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) if (!user) goto out_unlock;/* No processes for this user */ } - do_each_thread(g, p) { + for_each_process_thread(g, p) { if (uid_eq(task_uid(p), uid) && task_pid_vnr(p)) { niceval = nice_to_rlimit(task_nice(p)); if (niceval > retval) retval = niceval; } - } while_each_thread(g, p); + } if (!uid_eq(uid, cred->uid)) free_uid(user); /* for find_user() */ break; } out_unlock: - read_unlock(&tasklist_lock); rcu_read_unlock(); return retval; -- 2.26.2
[PATCH 2/2] block: fix ioprio_get/set(IOPRIO_WHO_PGRP) vs setuid(2)
do_each_pid_thread(PIDTYPE_PGID) can race with a concurrent change_pid(PIDTYPE_PGID) that can move the task from one hlist to another while iterating. Serialize ioprio_get/set to take the tasklist_lock in this case. Fixes: d69b78ba1de (ioprio: grab rcu_read_lock in sys_ioprio_{set,get}()) Cc: Greg Thelen Signed-off-by: Davidlohr Bueso --- block/ioprio.c | 4 1 file changed, 4 insertions(+) diff --git a/block/ioprio.c b/block/ioprio.c index 77bcab11dce5..4ede2da961bb 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -119,11 +119,13 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) pgrp = task_pgrp(current); else pgrp = find_vpid(who); + read_lock(&tasklist_lock); do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { ret = set_task_ioprio(p, ioprio); if (ret) break; } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); + read_unlock(&tasklist_lock); break; case IOPRIO_WHO_USER: uid = make_kuid(current_user_ns(), who); @@ -207,6 +209,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) pgrp = task_pgrp(current); else pgrp = find_vpid(who); + read_lock(&tasklist_lock); do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { tmpio = get_task_ioprio(p); if (tmpio < 0) @@ -216,6 +219,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) else ret = ioprio_best(ret, tmpio); } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); + read_unlock(&tasklist_lock); break; case IOPRIO_WHO_USER: uid = make_kuid(current_user_ns(), who); -- 2.26.2
[PATCH -next 0/2] tasklist_lock vs get/set priority syscalls
Hi, This is a (late) update on trying to reduce some of the scope of the tasklist_lock for get/setpriority(2) as well as the block io equivalent. This version addresses Oleg's previous concerns and incorporates his feedback. Changes from v1: https://lore.kernel.org/lkml/20200512000353.23653-1-d...@stgolabs.net/ - only take the lock for PGID cases. - drop bogus PF_EXITING checks (and live with the small exit race). - add patch for IOPRIO_WHO_PGRP. Please consider for v5.10. Thanks! Davidlohr Bueso (2): kernel/sys: only take tasklist_lock for get/setpriority(PRIO_PGRP) block: fix ioprio_get/set(IOPRIO_WHO_PGRP) vs setuid(2) block/ioprio.c | 4 kernel/sys.c | 16 2 files changed, 12 insertions(+), 8 deletions(-) -- 2.26.2
drivers/message/fusion/mptbase.c:3754:9: sparse: sparse: cast removes address space '__iomem' of expression
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5 commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to define address spaces date: 8 weeks ago config: riscv-randconfig-s031-20200817 (attached as .config) compiler: riscv32-linux-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.2-180-g49f7e13a-dirty git checkout 670d0a4b10704667765f7d18f7592993d02783aa # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=riscv If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) drivers/message/fusion/mptbase.c:640:25: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3141:37: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3142:37: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3143:40: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3144:36: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3145:37: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3146:26: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3149:42: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3150:43: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3161:41: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3166:49: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3168:36: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3175:33: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3176:40: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3178:33: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3180:33: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3181:42: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3190:46: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3299:30: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3300:29: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3301:30: sparse: sparse: cast to restricted __le32 drivers/message/fusion/mptbase.c:3302:30: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3303:30: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3304:33: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3305:39: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3306:36: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3307:33: sparse: sparse: cast to restricted __le16 drivers/message/fusion/mptbase.c:3371:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] MsgVersion @@ got restricted __le16 [usertype] @@ drivers/message/fusion/mptbase.c:3371:37: sparse: expected unsigned short [addressable] [assigned] [usertype] MsgVersion drivers/message/fusion/mptbase.c:3371:37: sparse: got restricted __le16 [usertype] drivers/message/fusion/mptbase.c:3372:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] HeaderVersion @@ got restricted __le16 [usertype] @@ drivers/message/fusion/mptbase.c:3372:40: sparse: expected unsigned short [addressable] [assigned] [usertype] HeaderVersion drivers/message/fusion/mptbase.c:3372:40: sparse: got restricted __le16 [usertype] drivers/message/fusion/mptbase.c:3379:33: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] ReplyFrameSize @@ got restricted __le16 [usertype] @@ drivers/message/fusion/mptbase.c:3379:33: sparse: expected unsigned short [addressable] [assigned] [usertype] ReplyFrameSize drivers/message/fusion/mptbase.c:3379:33: sparse: got restricted __le16 [usertype] drivers/message/fusion/mptbase.c:3385:42: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [addressable] [assigned] [usertype] HostMfaHighAddr @@ got restricted __le32 [usertype] @@ drivers/message/fu
[PATCH] ata: ahci: use ata_link_info() instead of ata_link_printk()
Using ata_link_info() instead of ata_link_printk(). Signed-off-by: Xu Wang --- drivers/ata/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 0c0a736eb861..9d72d907b4ee 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -807,7 +807,7 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, (sstatus & 0xf) != 1) break; - ata_link_printk(link, KERN_INFO, "avn bounce port%d\n", + ata_link_info(link, "avn bounce port%d\n", port); pci_read_config_word(pdev, 0x92, &val); -- 2.17.1
[PATCH V2 0/6] ceph: Use more generic logging
Convert the dout macro to the normal pr_debug. Convert embedded function names in these changes to %s, __func__ Remove the dout macro definitions Joe Perches (6): ceph: Use generic debugging facility ceph: Remove embedded function names from pr_debug uses net: ceph: Use generic debugging facility net: ceph: Remove embedded function names from pr_debug uses rbd: Use generic debugging facility ceph_debug: Remove now unused dout macro definitions drivers/block/rbd.c | 231 +++--- fs/ceph/addr.c | 266 fs/ceph/cache.c | 22 +- fs/ceph/caps.c | 533 fs/ceph/debugfs.c | 4 +- fs/ceph/dir.c | 141 - fs/ceph/export.c| 36 +-- fs/ceph/file.c | 170 +- fs/ceph/inode.c | 338 ++-- fs/ceph/ioctl.c | 6 +- fs/ceph/locks.c | 42 +-- fs/ceph/mds_client.c| 374 +++--- fs/ceph/mdsmap.c| 16 +- fs/ceph/metric.c| 4 +- fs/ceph/quota.c | 4 +- fs/ceph/snap.c | 135 fs/ceph/super.c | 67 ++-- fs/ceph/xattr.c | 64 ++-- include/linux/ceph/ceph_debug.h | 30 -- include/linux/ceph/messenger.h | 2 +- net/ceph/auth.c | 21 +- net/ceph/auth_none.c| 4 +- net/ceph/auth_x.c | 85 ++--- net/ceph/buffer.c | 6 +- net/ceph/ceph_common.c | 18 +- net/ceph/cls_lock_client.c | 32 +- net/ceph/crypto.c | 8 +- net/ceph/debugfs.c | 4 +- net/ceph/messenger.c| 330 ++-- net/ceph/mon_client.c | 99 +++--- net/ceph/msgpool.c | 14 +- net/ceph/osd_client.c | 393 --- net/ceph/osdmap.c | 101 +++--- net/ceph/pagevec.c | 10 +- 34 files changed, 1835 insertions(+), 1775 deletions(-) -- 2.26.0
[PATCH V2 2/6] ceph: Remove embedded function names from pr_debug uses
Use "%s: " ..., __func__ so function renaming changes the logging too. Signed-off-by: Joe Perches --- fs/ceph/addr.c | 57 +- fs/ceph/caps.c | 92 ++ fs/ceph/debugfs.c| 2 +- fs/ceph/dir.c| 16 fs/ceph/file.c | 6 +-- fs/ceph/inode.c | 18 - fs/ceph/locks.c | 15 --- fs/ceph/mds_client.c | 95 ++-- fs/ceph/snap.c | 22 +- fs/ceph/super.c | 10 ++--- fs/ceph/xattr.c | 25 ++-- 11 files changed, 182 insertions(+), 176 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 12ae6f7874fb..4f0f177428c7 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -311,8 +311,8 @@ static void finish_read(struct ceph_osd_request *req) int num_pages; int i; - pr_debug("finish_read %p req %p rc %d bytes %d\n", -inode, req, rc, bytes); + pr_debug("%s: %p req %p rc %d bytes %d\n", +__func__, inode, req, rc, bytes); if (rc == -EBLACKLISTED) ceph_inode_to_client(inode)->blacklisted = true; @@ -333,8 +333,8 @@ static void finish_read(struct ceph_osd_request *req) int s = bytes < 0 ? 0 : bytes; zero_user_segment(page, s, PAGE_SIZE); } - pr_debug("finish_read %p uptodate %p idx %lu\n", -inode, page, page->index); + pr_debug("%s: %p uptodate %p idx %lu\n", +__func__, inode, page, page->index); flush_dcache_page(page); SetPageUptodate(page); ceph_readpage_to_fscache(inode, page); @@ -379,9 +379,10 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, ret = ceph_try_get_caps(inode, CEPH_CAP_FILE_RD, want, true, &got); if (ret < 0) { - pr_debug("start_read %p, error getting cap\n", inode); + pr_debug("%s: %p, error getting cap\n", +__func__, inode); } else if (!(got & want)) { - pr_debug("start_read %p, no cache cap\n", inode); + pr_debug("%s: %p, no cache cap\n", __func__, inode); ret = 0; } if (ret <= 0) { @@ -409,8 +410,8 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, break; } len = nr_pages << PAGE_SHIFT; - pr_debug("start_read %p nr_pages %d is %lld~%lld\n", -inode, nr_pages, off, len); + pr_debug("%s: %p nr_pages %d is %lld~%lld\n", +__func__, inode, nr_pages, off, len); vino = ceph_vino(inode); req = ceph_osdc_new_request(osdc, &ci->i_layout, vino, off, &len, 0, 1, CEPH_OSD_OP_READ, @@ -434,14 +435,14 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, BUG_ON(PageLocked(page)); list_del(&page->lru); - pr_debug("start_read %p adding %p idx %lu\n", -inode, page, page->index); + pr_debug("%s: %p adding %p idx %lu\n", +__func__, inode, page, page->index); if (add_to_page_cache_lru(page, &inode->i_data, page->index, GFP_KERNEL)) { ceph_fscache_uncache_page(inode, page); put_page(page); - pr_debug("start_read %p add_to_page_cache failed %p\n", -inode, page); + pr_debug("%s: %p add_to_page_cache failed %p\n", +__func__, inode, page); nr_pages = i; if (nr_pages > 0) { len = nr_pages << PAGE_SHIFT; @@ -456,7 +457,8 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, req->r_callback = finish_read; req->r_inode = inode; - pr_debug("start_read %p starting %p %lld~%lld\n", inode, req, off, len); + pr_debug("%s: %p starting %p %lld~%lld\n", +__func__, inode, req, off, len); ret = ceph_osdc_start_request(osdc, req, false); if (ret < 0) goto out_pages; @@ -798,7 +800,7 @@ static void writepages_finish(struct ceph_osd_request *req) struct ceph_fs_client *fsc = ceph_inode_to_client(inode); bool remove_page; - pr_debug("writepages_finish %p rc %d\n", inode, rc); + pr_debug("%s: %p rc %d\n", __func__, inode, rc); if (rc < 0) { mapping_set_error(mapping, rc); ceph_set_error_write(ci); @@ -853,8 +855,9 @@ static void writepages_fi
[PATCH V2 5/6] rbd: Use generic debugging facility
The dout macro duplicates the generic features of pr_debug with __FILE__ and __func__ output capability when using dynamic_debug. Convert dout to pr_debug and remove the "pretty" print feature of dout. Miscellanea: o Realign arguments Signed-off-by: Joe Perches --- drivers/block/rbd.c | 231 +++- 1 file changed, 120 insertions(+), 111 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index d9c0e7d154f9..19696962c4f4 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -758,7 +758,7 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) struct rbd_client *rbdc; int ret = -ENOMEM; - dout("%s:\n", __func__); + pr_debug("%s:\n", __func__); rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL); if (!rbdc) goto out_opt; @@ -779,7 +779,7 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) list_add_tail(&rbdc->node, &rbd_client_list); spin_unlock(&rbd_client_list_lock); - dout("%s: rbdc %p\n", __func__, rbdc); + pr_debug("%s: rbdc %p\n", __func__, rbdc); return rbdc; out_client: @@ -789,7 +789,7 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) out_opt: if (ceph_opts) ceph_destroy_options(ceph_opts); - dout("%s: error %d\n", __func__, ret); + pr_debug("%s: error %d\n", __func__, ret); return ERR_PTR(ret); } @@ -926,7 +926,7 @@ static void rbd_client_release(struct kref *kref) { struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref); - dout("%s: rbdc %p\n", __func__, rbdc); + pr_debug("%s: rbdc %p\n", __func__, rbdc); spin_lock(&rbd_client_list_lock); list_del(&rbdc->node); spin_unlock(&rbd_client_list_lock); @@ -1310,7 +1310,7 @@ static void zero_bvecs(struct ceph_bvec_iter *bvec_pos, u32 off, u32 bytes) static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, u32 bytes) { - dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); + pr_debug("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); switch (obj_req->img_request->data_type) { case OBJ_REQUEST_BIO: @@ -1329,8 +1329,8 @@ static void rbd_obj_request_destroy(struct kref *kref); static void rbd_obj_request_put(struct rbd_obj_request *obj_request) { rbd_assert(obj_request != NULL); - dout("%s: obj %p (was %d)\n", __func__, obj_request, - kref_read(&obj_request->kref)); + pr_debug("%s: obj %p (was %d)\n", +__func__, obj_request, kref_read(&obj_request->kref)); kref_put(&obj_request->kref, rbd_obj_request_destroy); } @@ -1341,13 +1341,13 @@ static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request, /* Image request now owns object's original reference */ obj_request->img_request = img_request; - dout("%s: img %p obj %p\n", __func__, img_request, obj_request); + pr_debug("%s: img %p obj %p\n", __func__, img_request, obj_request); } static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, struct rbd_obj_request *obj_request) { - dout("%s: img %p obj %p\n", __func__, img_request, obj_request); + pr_debug("%s: img %p obj %p\n", __func__, img_request, obj_request); list_del(&obj_request->ex.oe_item); rbd_assert(obj_request->img_request == img_request); rbd_obj_request_put(obj_request); @@ -1357,9 +1357,9 @@ static void rbd_osd_submit(struct ceph_osd_request *osd_req) { struct rbd_obj_request *obj_req = osd_req->r_priv; - dout("%s osd_req %p for obj_req %p objno %llu %llu~%llu\n", -__func__, osd_req, obj_req, obj_req->ex.oe_objno, -obj_req->ex.oe_off, obj_req->ex.oe_len); + pr_debug("%s osd_req %p for obj_req %p objno %llu %llu~%llu\n", +__func__, osd_req, obj_req, obj_req->ex.oe_objno, +obj_req->ex.oe_off, obj_req->ex.oe_len); ceph_osdc_start_request(osd_req->r_osdc, osd_req, false); } @@ -1432,8 +1432,8 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req) struct rbd_obj_request *obj_req = osd_req->r_priv; int result; - dout("%s osd_req %p result %d for obj_req %p\n", __func__, osd_req, -osd_req->r_result, obj_req); + pr_debug("%s osd_req %p result %d for obj_req %p\n", +__func__, osd_req, osd_req->r_result, obj_req); /* * Writes aren't allowed to return a data payload. In some @@ -1522,7 +1522,7 @@ static struct rbd_obj_request *rbd_obj_request_create(void) mutex_init(&obj_request->state_mutex); kref_init(&obj_request->kref); - dout("%s %p\n", __func__, obj_request); + pr_debug("%s %p\
[PATCH V2 4/6] net: ceph: Remove embedded function names from pr_debug uses
Use "%s: " ..., __func__ so function renaming changes the logging too. Signed-off-by: Joe Perches --- net/ceph/auth_none.c | 2 +- net/ceph/auth_x.c | 26 ++-- net/ceph/ceph_common.c | 4 +- net/ceph/debugfs.c | 2 +- net/ceph/messenger.c | 91 +- net/ceph/mon_client.c | 8 ++-- net/ceph/msgpool.c | 4 +- net/ceph/osd_client.c | 6 +-- net/ceph/osdmap.c | 30 +++--- 9 files changed, 87 insertions(+), 86 deletions(-) diff --git a/net/ceph/auth_none.c b/net/ceph/auth_none.c index f4be840c5961..d6e6e27e6899 100644 --- a/net/ceph/auth_none.c +++ b/net/ceph/auth_none.c @@ -130,7 +130,7 @@ int ceph_auth_none_init(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi; - pr_debug("ceph_auth_none_init %p\n", ac); + pr_debug("%s: %p\n", __func__, ac); xi = kzalloc(sizeof(*xi), GFP_NOFS); if (!xi) return -ENOMEM; diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index f83944ec10c3..312362515c28 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c @@ -25,8 +25,8 @@ static int ceph_x_is_authenticated(struct ceph_auth_client *ac) int need; ceph_x_validate_tickets(ac, &need); - pr_debug("ceph_x_is_authenticated want=%d need=%d have=%d\n", -ac->want_keys, need, xi->have_keys); + pr_debug("%s: want=%d need=%d have=%d\n", +__func__, ac->want_keys, need, xi->have_keys); return (ac->want_keys & xi->have_keys) == ac->want_keys; } @@ -36,8 +36,8 @@ static int ceph_x_should_authenticate(struct ceph_auth_client *ac) int need; ceph_x_validate_tickets(ac, &need); - pr_debug("ceph_x_should_authenticate want=%d need=%d have=%d\n", -ac->want_keys, need, xi->have_keys); + pr_debug("%s: want=%d need=%d have=%d\n", +__func__, ac->want_keys, need, xi->have_keys); return need != 0; } @@ -146,7 +146,7 @@ static void remove_ticket_handler(struct ceph_auth_client *ac, { struct ceph_x_info *xi = ac->private; - pr_debug("remove_ticket_handler %p %d\n", th, th->service); + pr_debug("%s: %p %d\n", __func__, th, th->service); rb_erase(&th->node, &xi->ticket_handlers); ceph_crypto_key_destroy(&th->session_key); if (th->ticket_blob) @@ -672,8 +672,8 @@ static int ceph_x_update_authorizer( au = (struct ceph_x_authorizer *)auth->authorizer; if (au->secret_id < th->secret_id) { - pr_debug("ceph_x_update_authorizer service %u secret %llu < %llu\n", -au->service, au->secret_id, th->secret_id); + pr_debug("%s: service %u secret %llu < %llu\n", +__func__, au->service, au->secret_id, th->secret_id); return ceph_x_build_authorizer(ac, th, au); } return 0; @@ -766,7 +766,7 @@ static void ceph_x_destroy(struct ceph_auth_client *ac) struct ceph_x_info *xi = ac->private; struct rb_node *p; - pr_debug("ceph_x_destroy %p\n", ac); + pr_debug("%s: %p\n", __func__, ac); ceph_crypto_key_destroy(&xi->secret); while ((p = rb_first(&xi->ticket_handlers)) != NULL) { @@ -903,11 +903,11 @@ static int ceph_x_check_message_signature(struct ceph_auth_handshake *auth, if (sig_check == msg->footer.sig) return 0; if (msg->footer.flags & CEPH_MSG_FOOTER_SIGNED) - pr_debug("ceph_x_check_message_signature %p has signature %llx expect %llx\n", -msg, msg->footer.sig, sig_check); + pr_debug("%s: %p has signature %llx expect %llx\n", +__func__, msg, msg->footer.sig, sig_check); else - pr_debug("ceph_x_check_message_signature %p sender did not set CEPH_MSG_FOOTER_SIGNED\n", -msg); + pr_debug("%s: %p sender did not set CEPH_MSG_FOOTER_SIGNED\n", +__func__, msg); return -EBADMSG; } @@ -934,7 +934,7 @@ int ceph_x_init(struct ceph_auth_client *ac) struct ceph_x_info *xi; int ret; - pr_debug("ceph_x_init %p\n", ac); + pr_debug("%s: %p\n", __func__, ac); ret = -ENOMEM; xi = kzalloc(sizeof(*xi), GFP_NOFS); if (!xi) diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 1750e14115e6..e8af3bf2fdb5 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -224,7 +224,7 @@ static int parse_fsid(const char *str, struct ceph_fsid *fsid) int err = -EINVAL; int d; - pr_debug("parse_fsid '%s'\n", str); + pr_debug("%s: '%s'\n", __func__, str); tmp[2] = 0; while (*str && i < 16) { if (ispunct(*str)) { @@ -244,7 +244,7 @@ static int parse_fsid(const char *str, struct ceph_fsid *fsid) if (i == 16) err = 0; - pr_debug("p
[PATCH V2 3/6] net: ceph: Use generic debugging facility
The dout macro duplicates the generic features of pr_debug with __FILE__ and __func__ output capability when using dynamic_debug. Convert dout to pr_debug and remove the "pretty" print feature of dout. Miscellanea: o Realign arguments Signed-off-by: Joe Perches --- net/ceph/auth.c| 21 +- net/ceph/auth_none.c | 4 +- net/ceph/auth_x.c | 85 net/ceph/buffer.c | 6 +- net/ceph/ceph_common.c | 18 +- net/ceph/cls_lock_client.c | 32 +-- net/ceph/crypto.c | 8 +- net/ceph/debugfs.c | 4 +- net/ceph/messenger.c | 329 +++ net/ceph/mon_client.c | 99 +- net/ceph/msgpool.c | 14 +- net/ceph/osd_client.c | 393 +++-- net/ceph/osdmap.c | 101 +- net/ceph/pagevec.c | 10 +- 14 files changed, 575 insertions(+), 549 deletions(-) diff --git a/net/ceph/auth.c b/net/ceph/auth.c index fbeee068ea14..326fc907428a 100644 --- a/net/ceph/auth.c +++ b/net/ceph/auth.c @@ -41,7 +41,7 @@ struct ceph_auth_client *ceph_auth_init(const char *name, const struct ceph_cryp struct ceph_auth_client *ac; int ret; - dout("auth_init name '%s'\n", name); + pr_debug("auth_init name '%s'\n", name); ret = -ENOMEM; ac = kzalloc(sizeof(*ac), GFP_NOFS); @@ -54,7 +54,7 @@ struct ceph_auth_client *ceph_auth_init(const char *name, const struct ceph_cryp ac->name = name; else ac->name = CEPH_AUTH_NAME_DEFAULT; - dout("auth_init name %s\n", ac->name); + pr_debug("auth_init name %s\n", ac->name); ac->key = key; return ac; @@ -64,7 +64,7 @@ struct ceph_auth_client *ceph_auth_init(const char *name, const struct ceph_cryp void ceph_auth_destroy(struct ceph_auth_client *ac) { - dout("auth_destroy %p\n", ac); + pr_debug("auth_destroy %p\n", ac); if (ac->ops) ac->ops->destroy(ac); kfree(ac); @@ -76,7 +76,7 @@ void ceph_auth_destroy(struct ceph_auth_client *ac) void ceph_auth_reset(struct ceph_auth_client *ac) { mutex_lock(&ac->mutex); - dout("auth_reset %p\n", ac); + pr_debug("auth_reset %p\n", ac); if (ac->ops && !ac->negotiating) ac->ops->reset(ac); ac->negotiating = true; @@ -110,7 +110,7 @@ int ceph_auth_build_hello(struct ceph_auth_client *ac, void *buf, size_t len) int ret; mutex_lock(&ac->mutex); - dout("auth_build_hello\n"); + pr_debug("auth_build_hello\n"); monhdr->have_version = 0; monhdr->session_mon = cpu_to_le16(-1); monhdr->session_mon_tid = 0; @@ -165,7 +165,7 @@ static int ceph_build_auth_request(struct ceph_auth_client *ac, ac->ops->name); goto out; } - dout(" built request %d bytes\n", ret); + pr_debug("built request %d bytes\n", ret); ceph_encode_32(&p, ret); ret = p + ret - msg_buf; out: @@ -191,7 +191,7 @@ int ceph_handle_auth_reply(struct ceph_auth_client *ac, int ret = -EINVAL; mutex_lock(&ac->mutex); - dout("handle_auth_reply %p %p\n", p, end); + pr_debug("handle_auth_reply %p %p\n", p, end); ceph_decode_need(&p, end, sizeof(u32) * 3 + sizeof(u64), bad); protocol = ceph_decode_32(&p); result = ceph_decode_32(&p); @@ -206,13 +206,14 @@ int ceph_handle_auth_reply(struct ceph_auth_client *ac, if (p != end) goto bad; - dout(" result %d '%.*s' gid %llu len %d\n", result, result_msg_len, -result_msg, global_id, payload_len); + pr_debug("result %d '%.*s' gid %llu len %d\n", +result, result_msg_len, result_msg, global_id, payload_len); payload_end = payload + payload_len; if (global_id && ac->global_id != global_id) { - dout(" set global_id %lld -> %lld\n", ac->global_id, global_id); + pr_debug("set global_id %lld -> %lld\n", +ac->global_id, global_id); ac->global_id = global_id; } diff --git a/net/ceph/auth_none.c b/net/ceph/auth_none.c index edb7042479ed..f4be840c5961 100644 --- a/net/ceph/auth_none.c +++ b/net/ceph/auth_none.c @@ -53,7 +53,7 @@ static int ceph_auth_none_build_authorizer(struct ceph_auth_client *ac, ceph_encode_64_safe(&p, end, ac->global_id, e_range); au->buf_len = p - (void *)au->buf; - dout("%s built authorizer len %d\n", __func__, au->buf_len); + pr_debug("%s built authorizer len %d\n", __func__, au->buf_len); return 0; e_range: @@ -130,7 +130,7 @@ int ceph_auth_none_init(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi; - dout("ceph_auth_none_init %p\n", ac); + pr_debug("ceph_auth_none_init %p\n", ac); xi = kzalloc(sizeof(*xi), GFP_NOFS); if (!xi) re
[PATCH V2 6/6] ceph_debug: Remove now unused dout macro definitions
All the uses have be converted to pr_debug, so remove these. Signed-off-by: Joe Perches --- include/linux/ceph/ceph_debug.h | 30 -- 1 file changed, 30 deletions(-) diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h index d5a5da838caf..81c0d7195f1e 100644 --- a/include/linux/ceph/ceph_debug.h +++ b/include/linux/ceph/ceph_debug.h @@ -6,34 +6,4 @@ #include -#ifdef CONFIG_CEPH_LIB_PRETTYDEBUG - -/* - * wrap pr_debug to include a filename:lineno prefix on each line. - * this incurs some overhead (kernel size and execution time) due to - * the extra function call at each call site. - */ - -# if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) -# define dout(fmt, ...) \ - pr_debug("%.*s %12.12s:%-4d : " fmt,\ -8 - (int)sizeof(KBUILD_MODNAME), "", \ -kbasename(__FILE__), __LINE__, ##__VA_ARGS__) -# else -/* faux printk call just to see any compiler warnings. */ -# define dout(fmt, ...) do {\ - if (0) \ - printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ - } while (0) -# endif - -#else - -/* - * or, just wrap pr_debug - */ -# define dout(fmt, ...)pr_debug(" " fmt, ##__VA_ARGS__) - -#endif - #endif -- 2.26.0
Re: Linux 5.9-rc1 (sparse? kernel/time/timekeeping.c)
On 8/16/20 1:50 PM, Linus Torvalds wrote: > This merge window felt a lot more normal than 5.8, and all the stats > confirm thar it seems to be the usual size. > on x86_64, allmodconfig: $ gcc --version gcc (SUSE Linux) 7.5.0 $ sparse --version 0.6.2 I seem to be having some problems with kernel/time/timekeeping.c, including a segfault. a. Is it sparse that segfaults? b. what prints this message? make[3]: *** Deleting file 'kernel/time/timekeeping.o' c. I would prefer to be able to tell the source of warning/error messages, i.e., gcc or sparse. Especially when they are intermixed. So one solution IMO would be to be able to do a full sparse check _only_, without the gcc build. That way the messages would obviously be from sparse. Another reason to do that is that I often do gcc builds and then would like to follow that up with a sparse check build, but currently that means that I have to do the full gcc + sparse build, which is really time consuming since I have a wimpy laptop. CC kernel/time/timekeeping.o CHECK ../kernel/time/timekeeping.c ../kernel/time/timekeeping.c:461:23: warning: trying to copy expression type 31 ../kernel/time/timekeeping.c:470:18: warning: trying to copy expression type 31 ../include/linux/seqlock.h:214:1: warning: unreplaced symbol 's' ../include/linux/seqlock.h:214:1: warning: unreplaced symbol 'return' ../kernel/time/timekeeping.c:461:23: warning: unreplaced symbol 's' ../kernel/time/timekeeping.c:461:23: warning: unreplaced symbol 'return' ../include/linux/seqlock.h:214:1: warning: unreplaced symbol 's' ../include/linux/seqlock.h:214:1: warning: unreplaced symbol 'return' ../kernel/time/timekeeping.c:470:18: warning: unreplaced symbol 's' ../kernel/time/timekeeping.c:470:18: warning: unreplaced symbol 'return' /bin/sh: line 1: 15126 Segmentation fault (core dumped) sparse -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise -Wno-return-void -Wno-unknown-attribute -D__x86_64__ --arch=x86_64 -mlittle-endian -m64 -Wp,-MMD,kernel/time/.timekeeping.o.d -nostdinc -isystem /usr/lib64/gcc/x86_64-suse-linux/7/include -I../arch/x86/include -I./arch/x86/include/generated -I../include -I./include -I../arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -O2 --param=allow-store-data-races=0 -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -fno-inline-functions-called-once -flive-patching=inline-clone -falign-functions=32 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fsanitize-coverage=trace-pc -I ../kernel/time -I ./kernel/time -DKBUILD_MODFILE='"kernel/time/timekeeping"' -DKBUILD_BASENAME='"timekeeping"' -DKBUILD_MODNAME='"timekeeping"' ../kernel/time/timekeeping.c make[3]: *** [../scripts/Makefile.build:283: kernel/time/timekeeping.o] Error 139 make[3]: *** Deleting file 'kernel/time/timekeeping.o' make[3]: *** Waiting for unfinished jobs thanks. -- ~Randy
[RFC v2 0/2] add bus lock VM exit support
Add the support for bus lock VM exit in KVM. It is a sub-feature of bus lock detection. Another sub-feature named bus lock debug exception is blocked due to requirement to rework the HW design: https://lore.kernel.org/lkml/87r1stmi1x@nanos.tec.linutronix.de/ In this patch series, the first patch applies Sean's refactor to vcpu_vmx.exit_reason available at https://patchwork.kernel.org/patch/11500659. It is necessary as bus lock VM exit adds a new modifier bit(bit 26) in exit_reason field in VMCS. The second patch is the enabling work for bus lock VM exit. Add the support to set the capability to enable bus lock vm exit. The current implementation just exit to user space when handling the bus lock detected in guest. The concrete throttling policy in user space still needs to be discussed. We can enforce ratelimit on bus lock in guest, just inject some sleep time, or any other ideas? Document for Bus Lock Detection is now available at the latest "Intel Architecture Instruction Set Extensions Programming Reference". Document Link: https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html v1->v2 Changelogs: - resolve Vitaly's comment to introduce the KVM_EXIT_BUS_LOCK and a capability to enable it. - add the support to exit to user space when handling bus locks. - extend the vcpu->run->flags to indicate bus lock detected for other exit reasons when exiting to user space. Chenyi Qiang (1): KVM: VMX: Enable bus lock VM exit Sean Christopherson (1): KVM: VMX: Convert vcpu_vmx.exit_reason to a union arch/x86/include/asm/kvm_host.h| 9 +++ arch/x86/include/asm/vmx.h | 1 + arch/x86/include/asm/vmxfeatures.h | 1 + arch/x86/include/uapi/asm/kvm.h| 1 + arch/x86/include/uapi/asm/vmx.h| 4 +- arch/x86/kvm/vmx/capabilities.h| 6 ++ arch/x86/kvm/vmx/nested.c | 42 - arch/x86/kvm/vmx/vmx.c | 97 -- arch/x86/kvm/vmx/vmx.h | 25 +++- arch/x86/kvm/x86.c | 36 ++- arch/x86/kvm/x86.h | 5 ++ include/uapi/linux/kvm.h | 2 + 12 files changed, 179 insertions(+), 50 deletions(-) -- 2.17.1
[RFC v2 1/2] KVM: VMX: Convert vcpu_vmx.exit_reason to a union
From: Sean Christopherson Convert vcpu_vmx.exit_reason from a u32 to a union (of size u32). The full VM_EXIT_REASON field is comprised of a 16-bit basic exit reason in bits 15:0, and single-bit modifiers in bits 31:16. Historically, KVM has only had to worry about handling the "failed VM-Entry" modifier, which could only be set in very specific flows and required dedicated handling. I.e. manually stripping the FAILED_VMENTRY bit was a somewhat viable approach. But even with only a single bit to worry about, KVM has had several bugs related to comparing a basic exit reason against the full exit reason store in vcpu_vmx. Upcoming Intel features, e.g. SGX, will add new modifier bits that can be set on more or less any VM-Exit, as opposed to the significantly more restricted FAILED_VMENTRY, i.e. correctly handling everything in one-off flows isn't scalable. Tracking exit reason in a union forces code to explicitly choose between consuming the full exit reason and the basic exit, and is a convenient way to document and access the modifiers. No functional change intended. Cc: Xiaoyao Li Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 42 - arch/x86/kvm/vmx/vmx.c| 64 --- arch/x86/kvm/vmx/vmx.h| 25 ++- 3 files changed, 84 insertions(+), 47 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 11e4df560018..ba6d5eb6a4fe 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3255,7 +3255,11 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12 = get_vmcs12(vcpu); enum vm_entry_failure_code entry_failure_code; bool evaluate_pending_interrupts; - u32 exit_reason, failed_index; + union vmx_exit_reason exit_reason = { + .basic = EXIT_REASON_INVALID_STATE, + .failed_vmentry = 1, + }; + u32 failed_index; if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu)) kvm_vcpu_flush_tlb_current(vcpu); @@ -3305,7 +3309,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, if (nested_vmx_check_guest_state(vcpu, vmcs12, &entry_failure_code)) { - exit_reason = EXIT_REASON_INVALID_STATE; + exit_reason.basic = EXIT_REASON_INVALID_STATE; vmcs12->exit_qualification = entry_failure_code; goto vmentry_fail_vmexit; } @@ -3316,7 +3320,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, vcpu->arch.tsc_offset += vmcs12->tsc_offset; if (prepare_vmcs02(vcpu, vmcs12, &entry_failure_code)) { - exit_reason = EXIT_REASON_INVALID_STATE; + exit_reason.basic = EXIT_REASON_INVALID_STATE; vmcs12->exit_qualification = entry_failure_code; goto vmentry_fail_vmexit_guest_mode; } @@ -3326,7 +3330,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); if (failed_index) { - exit_reason = EXIT_REASON_MSR_LOAD_FAIL; + exit_reason.basic = EXIT_REASON_MSR_LOAD_FAIL; vmcs12->exit_qualification = failed_index; goto vmentry_fail_vmexit_guest_mode; } @@ -3394,7 +3398,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, return NVMX_VMENTRY_VMEXIT; load_vmcs12_host_state(vcpu, vmcs12); - vmcs12->vm_exit_reason = exit_reason | VMX_EXIT_REASONS_FAILED_VMENTRY; + vmcs12->vm_exit_reason = exit_reason.full; if (enable_shadow_vmcs || vmx->nested.hv_evmcs) vmx->nested.need_vmcs12_to_shadow_sync = true; return NVMX_VMENTRY_VMEXIT; @@ -5449,7 +5453,12 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu) return kvm_skip_emulated_instruction(vcpu); fail: - nested_vmx_vmexit(vcpu, vmx->exit_reason, + /* +* This is effectively a reflected VM-Exit, as opposed to a synthesized +* nested VM-Exit. Pass the original exit reason, i.e. don't hardcode +* EXIT_REASON_VMFUNC as the exit reason. +*/ + nested_vmx_vmexit(vcpu, vmx->exit_reason.full, vmx_get_intr_info(vcpu), vmx_get_exit_qual(vcpu)); return 1; @@ -5517,7 +5526,8 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu, * MSR bitmap. This may be the case even when L0 doesn't use MSR bitmaps. */ static bool nested_vmx_exit_handled_msr(struct kvm
[RFC v2 2/2] KVM: VMX: Enable bus lock VM exit
Virtual Machine can exploit bus locks to degrade the performance of system. Bus lock can be caused by split locked access to writeback(WB) memory or by using locks on uncacheable(UC) memory. The bus lock is typically >1000 cycles slower than an atomic operation within a cache line. It also disrupts performance on other cores (which must wait for the bus lock to be released before their memory operations can complete). To address the threat, bus lock VM exit is introduced to notify the VMM when a bus lock was acquired, allowing it to enforce throttling or other policy based mitigations. A VMM can enable VM exit due to bus locks by setting a new "Bus Lock Detection" VM-execution control(bit 30 of Secondary Processor-based VM execution controls). If delivery of this VM exit was preempted by a higher priority VM exit (e.g. EPT misconfiguration, EPT violation, APIC access VM exit, APIC write VM exit, exception bitmap exiting), bit 26 of exit reason in vmcs field is set to 1. In current implementation, the KVM exposes this capability through KVM_CAP_X86_BLD. The user can set it to enable the bus lock VM exit (disabled by default). If bus locks in guest are detected by KVM, exit to user space even when current exit reason is handled by KVM internally. Set a new field KVM_RUN_BUS_LOCK in vcpu->run->flags to inform the user space that there is a bus lock in guest and it is preempted by a higher priority VM exit. Every bus lock acquired in non-root mode will be recorded in vcpu->stat.bus_locks and exposed through debugfs when the bus lock VM exit is enabled. Document for Bus Lock VM exit is now available at the latest "Intel Architecture Instruction Set Extensions Programming Reference". Document Link: https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Chenyi Qiang --- arch/x86/include/asm/kvm_host.h| 9 arch/x86/include/asm/vmx.h | 1 + arch/x86/include/asm/vmxfeatures.h | 1 + arch/x86/include/uapi/asm/kvm.h| 1 + arch/x86/include/uapi/asm/vmx.h| 4 +++- arch/x86/kvm/vmx/capabilities.h| 6 + arch/x86/kvm/vmx/vmx.c | 33 ++- arch/x86/kvm/vmx/vmx.h | 2 +- arch/x86/kvm/x86.c | 36 +- arch/x86/kvm/x86.h | 5 + include/uapi/linux/kvm.h | 2 ++ 11 files changed, 96 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index be5363b21540..bfabe2f15b30 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -829,6 +829,9 @@ struct kvm_vcpu_arch { /* AMD MSRC001_0015 Hardware Configuration */ u64 msr_hwcr; + + /* Set when bus lock VM exit is preempted by a higher priority VM exit */ + bool bus_lock_detected; }; struct kvm_lpage_info { @@ -1002,6 +1005,9 @@ struct kvm_arch { bool guest_can_read_msr_platform_info; bool exception_payload_enabled; + /* Set when bus lock vm exit is enabled by user */ + bool bus_lock_exit; + struct kvm_pmu_event_filter *pmu_event_filter; struct task_struct *nx_lpage_recovery_thread; }; @@ -1051,6 +1057,7 @@ struct kvm_vcpu_stat { u64 req_event; u64 halt_poll_success_ns; u64 halt_poll_fail_ns; + u64 bus_locks; }; struct x86_instruction_info; @@ -1388,6 +1395,8 @@ extern u8 kvm_tsc_scaling_ratio_frac_bits; extern u64 kvm_max_tsc_scaling_ratio; /* 1ull << kvm_tsc_scaling_ratio_frac_bits */ extern u64 kvm_default_tsc_scaling_ratio; +/* bus lock detection supported */ +extern bool kvm_has_bus_lock_exit; extern u64 kvm_mce_cap_supported; diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index cd7de4b401fe..93a880bc31a7 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -73,6 +73,7 @@ #define SECONDARY_EXEC_PT_USE_GPA VMCS_CONTROL_BIT(PT_USE_GPA) #define SECONDARY_EXEC_TSC_SCALING VMCS_CONTROL_BIT(TSC_SCALING) #define SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE VMCS_CONTROL_BIT(USR_WAIT_PAUSE) +#define SECONDARY_EXEC_BUS_LOCK_DETECTION VMCS_CONTROL_BIT(BUS_LOCK_DETECTION) #define PIN_BASED_EXT_INTR_MASK VMCS_CONTROL_BIT(INTR_EXITING) #define PIN_BASED_NMI_EXITING VMCS_CONTROL_BIT(NMI_EXITING) diff --git a/arch/x86/include/asm/vmxfeatures.h b/arch/x86/include/asm/vmxfeatures.h index 9915990fd8cf..e80523346274 100644 --- a/arch/x86/include/asm/vmxfeatures.h +++ b/arch/x86/include/asm/vmxfeatures.h @@ -83,5 +83,6 @@ #define VMX_FEATURE_TSC_SCALING( 2*32+ 25) /* Scale hardware TSC when read in guest */ #define VMX_FEATURE_USR_WAIT_PAUSE ( 2*32+ 26) /* Enable TPAUSE, UMONITOR, UMWAIT in guest */ #define VMX_FEATURE_ENCLV_EXITING (
Re: [PATCH v2 0/9] Audio graph card updates and usage with Tegra210 audio
Hi Sameer Cc Mark > This series proposes following enhancements to audio-graph card driver. > * Support multiple instances of a component. > * Support open platforms with empty Codec endpoint. > * Identify no-pcm DPCM DAI links which can be used in BE<->BE connections. > * Add new compatible to support DPCM based DAI chaining. > > This pushes DT support for Tegra210 based platforms which uses audio-graph > card and above enhancements. > > The series is based on following references where DPCM usgae for Tegra > Audio and simple-card driver proposal were discussed. > * https://lkml.org/lkml/2020/4/30/519 (DPCM for Tegra) > * https://lkml.org/lkml/2020/6/27/4 (simple-card driver) I will try to test this patch-set this week, and report/review it. Thank you for your help !! Best regards --- Kuninori Morimoto
Re: [RFC][PATCH 0/4] arm64:kvm: teach guest sched that VCPUs can be preempted
On (20/07/21 13:17), Sergey Senozhatsky wrote: > Hello, > > RFC > > We noticed that in a number of cases when we wake_up_process() > on arm64 guest we end up enqueuing that task on a preempted VCPU. The culprit > appears to be the fact that arm64 guests are not aware of VCPU preemption > as such, so when sched picks up an idle VCPU it always assumes that VCPU > is available: > > wake_up_process() >try_to_wake_up() > select_task_rq_fair() > available_idle_cpu() > vcpu_is_preempted()// return false; > > Which is, obviously, not the case. > > This RFC patch set adds a simple vcpu_is_preempted() implementation so > that scheduler can make better decisions when it search for the idle > (v)CPU. Hi, A gentle ping. -ss
Re: [PATCH RFC 01/12] irq_work: Add support to detect if work is pending
On Sat, Aug 15, 2020 at 10:13:30AM +0200, pet...@infradead.org wrote: > On Fri, Aug 14, 2020 at 11:18:57PM -0400, Joel Fernandes (Google) wrote: > > https://lkml.kernel.org/r/20200722153017.024407...@infradead.org Thank you, so that means I can drop this patch then. - Joel
[PATCH] otx2_common: Use devm_kcalloc() in otx2_config_npa()
A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc". Signed-off-by: Xu Wang --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c index 5975521a4c86..93c4cf7fedbf 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c @@ -1226,8 +1226,8 @@ int otx2_config_npa(struct otx2_nic *pfvf) if (!hw->pool_cnt) return -EINVAL; - qset->pool = devm_kzalloc(pfvf->dev, sizeof(struct otx2_pool) * - hw->pool_cnt, GFP_KERNEL); + qset->pool = devm_kcalloc(pfvf->dev, hw->pool_cnt, + sizeof(struct otx2_pool), GFP_KERNEL); if (!qset->pool) return -ENOMEM; -- 2.17.1
Re: [PATCH RESEND] device_cgroup: Fix RCU list debugging warning
Hi all, On Sun, 7 Jun 2020 23:17:34 -0500 "Serge E. Hallyn" wrote: > On Sun, Jun 07, 2020 at 12:08:40PM -0700, Paul E. McKenney wrote: > > On Sun, Jun 07, 2020 at 06:23:40AM +1000, Stephen Rothwell wrote: > > > > > > On Mon, 6 Apr 2020 16:29:50 +0530 Amol Grover > > > wrote: > > > > > > > > exceptions may be traversed using list_for_each_entry_rcu() > > > > outside of an RCU read side critical section BUT under the > > > > protection of decgroup_mutex. Hence add the corresponding > > > > lockdep expression to fix the following false-positive > > > > warning: > > > > > > > > [2.304417] = > > > > [2.304418] WARNING: suspicious RCU usage > > > > [2.304420] 5.5.4-stable #17 Tainted: GE > > > > [2.304422] - > > > > [2.304424] security/device_cgroup.c:355 RCU-list traversed in > > > > non-reader section!! > > > > > > > > Signed-off-by: Amol Grover > > > > --- > > > > security/device_cgroup.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/security/device_cgroup.c b/security/device_cgroup.c > > > > index 7d0f8f7431ff..b7da9e0970d9 100644 > > > > --- a/security/device_cgroup.c > > > > +++ b/security/device_cgroup.c > > > > @@ -352,7 +352,8 @@ static bool match_exception_partial(struct > > > > list_head *exceptions, short type, > > > > { > > > > struct dev_exception_item *ex; > > > > > > > > - list_for_each_entry_rcu(ex, exceptions, list) { > > > > + list_for_each_entry_rcu(ex, exceptions, list, > > > > + lockdep_is_held(&devcgroup_mutex)) { > > > > if ((type & DEVCG_DEV_BLOCK) && !(ex->type & > > > > DEVCG_DEV_BLOCK)) > > > > continue; > > > > if ((type & DEVCG_DEV_CHAR) && !(ex->type & > > > > DEVCG_DEV_CHAR)) > > > > > > I have been carrying the above patch in linux-next for some time now. > > > I have been carrying it because it fixes problems for syzbot (see the > > > third warning in > > > https://lore.kernel.org/linux-next/cact4y+ynjk+kq0pfb5fe-q1bqe2t1jq_mvkhf--z80z3wky...@mail.gmail.com/). > > > Is there some reason it has not been applied to some tree? > > > > The RCU changes on which this patch depends have long since made it to > > mainline, so it can go up any tree. I can take it if no one else will, > > but it might be better going in via the security tree. > > James, do you mind pulling it in? I am still carrying this patch. Has it been superceded, or is it still necessary? -- Cheers, Stephen Rothwell pgpH_ufMGNSCN.pgp Description: OpenPGP digital signature
RE: [PATCH RFC v2 00/18] Add VFIO mediated device support and DEV-MSI support for the idxd driver
> From: Jason Gunthorpe > Sent: Friday, August 14, 2020 9:35 PM > > On Mon, Aug 10, 2020 at 07:32:24AM +, Tian, Kevin wrote: > > > > I would prefer to see that the existing userspace interface have the > > > extra needed bits for virtualization (eg by having appropriate > > > internal kernel APIs to make this easy) and all the emulation to build > > > the synthetic PCI device be done in userspace. > > > > In the end what decides the direction is the amount of changes that > > we have to put in kernel, not whether we call it 'emulation'. > > No, this is not right. The decision should be based on what will end > up more maintable in the long run. > > Yes it would be more code to dis-aggregate some of the things > currently only bundled as uAPI inside VFIO (eg your vSVA argument > above) but once it is disaggregated the maintability of the whole > solution will be better overall, and more drivers will be able to use > this functionality. > Disaggregation is an orthogonal topic to the main divergence in this thread, which is passthrough vs. userspace DMA. I gave detail explanation about the difference between the two in last reply. the possibility of dis-aggregating something between passthrough frameworks (e.g. VFIO and vDPA) is not the reason for growing every userspace DMA framework to be a passthrough framework. Doing that is instead hurting maintainability in general... Thanks Kevin
linux-next: Tree for Aug 17
Hi all, Changes since 20200814: New tree: memblock-fixes My fixes tree contains: 73c7adb54169 ("device_cgroup: Fix RCU list debugging warning") Non-merge commits (relative to Linus' tree): 664 760 files changed, 22791 insertions(+), 6127 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig and htmldocs. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 328 trees (counting Linus' and 86 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (9123e3a74ec7 Linux 5.9-rc1) Merging fixes/master (73c7adb54169 device_cgroup: Fix RCU list debugging warning) Merging kbuild-current/fixes (06a81c1c7db9 Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux) Merging arc-current/for-curr (11ba468877bb Linux 5.8-rc5) Merging arm-current/fixes (5c6360ee4a0e ARM: 8988/1: mmu: fix crash in EFI calls due to p4d typo in create_mapping_late()) Merging arm64-fixes/for-next/fixes (6a7389f0312f MAINTAINERS: Include drivers subdirs for ARM PMU PROFILING AND DEBUGGING entry) Merging arm-soc-fixes/arm/fixes (fe1d899f4212 ARM: dts: keystone-k2g-evm: fix rgmii phy-mode for ksz9031 phy) Merging uniphier-fixes/fixes (48778464bb7d Linux 5.8-rc2) Merging drivers-memory-fixes/fixes (b3a9e3b9622a Linux 5.8-rc1) Merging m68k-current/for-linus (382f429bb559 m68k: defconfig: Update defconfigs for v5.8-rc3) Merging powerpc-fixes/fixes (6553fb799f60 powerpc/pkeys: Fix boot failures with Nemo board (A-EON AmigaOne X1000)) Merging s390-fixes/fixes (00e4db51259a Merge tag 'perf-tools-2020-08-10' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux) Merging sparc/master (0a95a6d1a4cd sparc: use for_each_child_of_node() macro) Merging fscrypt-current/for-stable (2b4eae95c736 fscrypt: don't evict dirty inodes after removing key) Merging net/master (d0f5c7076e01 ipvlan: fix device features) Merging bpf/master (4fccd2ff74fb selftests/bpf: Make test_varlen work with 32-bit user-space arch) Merging ipsec/master (61ee4137b574 ip_vti: Fix unused variable warning) Merging netfilter/master (5c04da55c754 netfilter: ebtables: reject bogus getopt len value) Merging ipvs/master (7c7ab580db49 net: Convert to use the fallthrough macro) Merging wireless-drivers/master (1cfd3426ef98 ath10k: Fix NULL pointer dereference in AHB device probe) Merging mac80211/master (9643609423c7 Revert "ipv4: tunnel: fix compilation on ARCH=um") Merging rdma-fixes/for-rc (bcf876870b95 Linux 5.8) Merging sound-current/for-linus (f5d0f820ff8a ALSA: isa: fix spelling mistakes in the comments) Merging sound-asoc-fixes/for-linus (933cc41085d5 Merge remote-tracking branch 'asoc/for-5.9' into asoc-linus) Merging regmap-fixes/for-linus (2b0f61e27f75 Merge remote-tracking branch 'regmap/for-5.8' into regmap-linus) Merging regulator-fixes/for-linus (75f4d068cb0d Merge remote-tracking branch 'regulator/for-5.9' into regulator-linus) Merging spi-fixes/for-linus (3ea884314328 Merge remote-tracking branch 'spi/for-5.9' into spi-linus) Merging pci-current/for-linus (b361663c5a40 PCI/ASPM: Disable ASPM on ASMedia ASM1083/1085 PCIe-to-PCI bridge) Merging driver-core.current/driver-core-linus (a1d21081a60d Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net) Merging tty.current/tty-linus (fc80c51fd4b2 Merge tag 'kbuild-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbu
Re: Linux 5.9-rc1 (sparse? kernel/time/timekeeping.c)
On Sun, Aug 16, 2020 at 06:35:26PM -0700, Randy Dunlap wrote: > > on x86_64, allmodconfig: > > $ gcc --version > gcc (SUSE Linux) 7.5.0 > > $ sparse --version > 0.6.2 > > > I seem to be having some problems with kernel/time/timekeeping.c, > including a segfault. > > a. Is it sparse that segfaults? It's most probably the one fixed in: eb6779f6f621 ("generic: fix missing inlining of generic expression") On the main tree there is a branch with a few fixes since the last release: git://git.kernel.org/pub/scm/devel/sparse/sparse.git maint-v0.6.2 > b. what prints this message? > make[3]: *** Deleting file 'kernel/time/timekeeping.o' It seems like a typical message from make when a command fails. > c. I would prefer to be able to tell the source of warning/error messages, > i.e., gcc or sparse. Especially when they are intermixed. You can use the option -fdiagnostic-prefix[=PREFIX] for this. It will just prefix all messages from from sparse with the given PREFIX or 'sparse: ' if none is given. You can pass this option via 'make CF=...'. It may be a good idea to directly add it to CHECKFLAGS. Best regards, -- Luc
Re: [PATCH RFC 02/12] entry/idle: Add a common function for activites during idle entry/exit
Hello Peter, On Sat, Aug 15, 2020 at 10:14:41AM +0200, pet...@infradead.org wrote: > On Fri, Aug 14, 2020 at 11:18:58PM -0400, Joel Fernandes (Google) wrote: > > Currently only RCU hooks for idle entry/exit are called. In later > > patches, kernel-entry protection functionality will be added. > > > > Signed-off-by: Joel Fernandes (Google) > > NAK, rcu_idle_enter() is broken where it is now, it needs to be pushed > in deeper: > > http://lkml.kernel.org/r/20200807193017.962482...@infradead.org Thank you for pointing it out. Not a huge problem, a couple ways I can do it: 1. Move the calls to sched_core_unsafe_{enter,exit}() deeper into the idle loop. 2. Keep the calls to sched_core_unsafe_{enter,exit}() where they are now as in this patch, but leave out the rcu_idle_{enter,exit}() calls alone so they can be moved deeper as you mentioned. #1 is not necessary for these patches to work and might be overkill. I'll go the #2 route then. Let me know any other ideas you might have. What I am trying to do here is to handle a case where task is switching to idle (say it went to sleep) and wakes up later. usermode -> syscall (kernel mode - so mark unsafe) -> idle (mark safe). idle -> syscall wakes (kernel mode - so mark unsafe) -> usermode (mark safe). Thank you, - Joel
[PATCH] bsg-lib: convert comma to semicolon
Replace a comma between expression statements by a semicolon. Signed-off-by: Xu Wang --- block/bsg-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bsg-lib.c b/block/bsg-lib.c index fb7b347f8010..d185396d88bb 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c @@ -378,7 +378,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name, bset->timeout_fn = timeout; set = &bset->tag_set; - set->ops = &bsg_mq_ops, + set->ops = &bsg_mq_ops; set->nr_hw_queues = 1; set->queue_depth = 128; set->numa_node = NUMA_NO_NODE; -- 2.17.1
Re: Linux 5.9-rc1 (sparse? kernel/time/timekeeping.c)
On 8/16/20 7:15 PM, Luc Van Oostenryck wrote: > On Sun, Aug 16, 2020 at 06:35:26PM -0700, Randy Dunlap wrote: >> >> on x86_64, allmodconfig: >> >> $ gcc --version >> gcc (SUSE Linux) 7.5.0 >> >> $ sparse --version >> 0.6.2 >> >> >> I seem to be having some problems with kernel/time/timekeeping.c, >> including a segfault. >> >> a. Is it sparse that segfaults? > > It's most probably the one fixed in: > eb6779f6f621 ("generic: fix missing inlining of generic expression") > > On the main tree there is a branch with a few fixes since the last release: > git://git.kernel.org/pub/scm/devel/sparse/sparse.git maint-v0.6.2 > >> b. what prints this message? >> make[3]: *** Deleting file 'kernel/time/timekeeping.o' > > It seems like a typical message from make when a command fails. > >> c. I would prefer to be able to tell the source of warning/error messages, >> i.e., gcc or sparse. Especially when they are intermixed. > > You can use the option -fdiagnostic-prefix[=PREFIX] for this. It will > just prefix all messages from from sparse with the given PREFIX or > 'sparse: ' if none is given. You can pass this option via 'make CF=...'. > > It may be a good idea to directly add it to CHECKFLAGS. > > Best regards, > -- Luc Thank you, Luc. I'll get the latest and also use PREFIX. -- ~Randy
include/linux/spinlock.h:393:9: sparse: sparse: context imbalance in 'ext4_trim_extent' - wrong count at exit
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5 commit: ebc00dde8a975a543f5e1a7cdac93fef89fefe58 riscv: Add jump-label implementation date: 2 weeks ago config: riscv-randconfig-s031-20200817 (attached as .config) compiler: riscv32-linux-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.2-180-g49f7e13a-dirty git checkout ebc00dde8a975a543f5e1a7cdac93fef89fefe58 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=riscv If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) fs/ext4/mballoc.c:946:9: sparse: sparse: context imbalance in 'ext4_mb_init_cache' - different lock contexts for basic block fs/ext4/mballoc.c:1860:5: sparse: sparse: context imbalance in 'ext4_mb_try_best_found' - different lock contexts for basic block fs/ext4/mballoc.c:1888:5: sparse: sparse: context imbalance in 'ext4_mb_find_by_goal' - different lock contexts for basic block fs/ext4/mballoc.c:2175:12: sparse: sparse: context imbalance in 'ext4_mb_good_group_nolock' - wrong count at exit fs/ext4/mballoc.c:2286:49: sparse: sparse: context imbalance in 'ext4_mb_regular_allocator' - different lock contexts for basic block fs/ext4/mballoc.c:2825:17: sparse: sparse: context imbalance in 'ext4_mb_release' - different lock contexts for basic block fs/ext4/mballoc.c: note: in included file (through include/linux/wait.h, include/linux/wait_bit.h, include/linux/fs.h, fs/ext4/ext4_jbd2.h): include/linux/spinlock.h:393:9: sparse: sparse: context imbalance in 'ext4_free_data_in_buddy' - wrong count at exit fs/ext4/mballoc.c:3158:15: sparse: sparse: context imbalance in 'ext4_mb_mark_diskspace_used' - different lock contexts for basic block fs/ext4/mballoc.c:3409:13: sparse: sparse: context imbalance in 'ext4_discard_allocated_blocks' - different lock contexts for basic block fs/ext4/mballoc.c:3691:13: sparse: sparse: context imbalance in 'ext4_mb_put_pa' - different lock contexts for basic block fs/ext4/mballoc.c:4027:24: sparse: sparse: context imbalance in 'ext4_mb_discard_group_preallocations' - different lock contexts for basic block fs/ext4/mballoc.c:4177:9: sparse: sparse: context imbalance in 'ext4_discard_preallocations' - different lock contexts for basic block fs/ext4/mballoc.c:4244:9: sparse: sparse: context imbalance in 'ext4_mb_show_ac' - different lock contexts for basic block fs/ext4/mballoc.c:4472:9: sparse: sparse: context imbalance in 'ext4_mb_discard_lg_preallocations' - different lock contexts for basic block fs/ext4/mballoc.c:4244:9: sparse: sparse: context imbalance in 'ext4_mb_new_blocks' - different lock contexts for basic block fs/ext4/mballoc.c:4979:9: sparse: sparse: context imbalance in 'ext4_free_blocks' - different lock contexts for basic block fs/ext4/mballoc.c:5279:15: sparse: sparse: context imbalance in 'ext4_group_add_blocks' - different lock contexts for basic block >> include/linux/spinlock.h:393:9: sparse: sparse: context imbalance in >> 'ext4_trim_extent' - wrong count at exit fs/ext4/mballoc.c:5343:1: sparse: sparse: context imbalance in 'ext4_trim_all_free' - different lock contexts for basic block fs/ext4/mballoc.c:5509:1: sparse: sparse: context imbalance in 'ext4_mballoc_query_range' - different lock contexts for basic block # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ebc00dde8a975a543f5e1a7cdac93fef89fefe58 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout ebc00dde8a975a543f5e1a7cdac93fef89fefe58 vim +/ext4_trim_extent +393 include/linux/spinlock.h c2f21ce2e31286 Thomas Gleixner 2009-12-02 390 3490565b633c70 Denys Vlasenko 2015-07-13 391 static __always_inline void spin_unlock(spinlock_t *lock) c2f21ce2e31286 Thomas Gleixner 2009-12-02 392 { c2f21ce2e31286 Thomas Gleixner 2009-12-02 @393 raw_spin_unlock(&lock->rlock); c2f21ce2e31286 Thomas Gleixner 2009-12-02 394 } c2f21ce2e31286 Thomas Gleixner 2009-12-02 395 :: The code at line 393 was first introduced by commit :: c2f21ce2e31286a0a32f8da0a7856e9ca1122ef3 locking: Implement new raw_spinlock :: TO: Thomas Gleixner :: CC: Thomas Gleixner --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
RE: [PATCH RFC v2 00/18] Add VFIO mediated device support and DEV-MSI support for the idxd driver
> From: Jason Gunthorpe > Sent: Friday, August 14, 2020 9:24 PM > > The same basic argument goes for all the points - the issue is really > the only uAPI we have for this stuff is under VFIO, and the better > solution is to disagregate that uAPI, not to try and make everything > pretend to be a VFIO device. > Nobody is proposing to make everything VFIO. there must be some criteria which can be brainstormed in LPC. But the opposite also holds - the fact that we should not make everything VFIO doesn't imply prohibition on anyone from using it. There is a clear difference between passthrough and userspace DMA requirements in idxd context, and we see good reasons to use VFIO for our passthrough requirements. Thanks Kevin
[PATCHv2] serial: 8250: change lock order in serial8250_do_startup()
We have a number of "uart.port->desc.lock vs desc.lock->uart.port" lockdep reports coming from 8250 driver; this causes a bit of trouble to people, so let's fix it. The problem is reverse lock order in two different call paths: chain #1: serial8250_do_startup() spin_lock_irqsave(&port->lock); disable_irq_nosync(port->irq); raw_spin_lock_irqsave(&desc->lock) chain #2: __report_bad_irq() raw_spin_lock_irqsave(&desc->lock) for_each_action_of_desc() printk() spin_lock_irqsave(&port->lock); Fix this by changing the order of locks in serial8250_do_startup(): do disable_irq_nosync() first, which grabs desc->lock, and grab uart->port after that, so that chain #1 and chain #2 have same lock order. Full lockdep splat: == WARNING: possible circular locking dependency detected 5.4.39 #55 Not tainted == swapper/0/0 is trying to acquire lock: ab65b6c0 (console_owner){-...}, at: console_lock_spinning_enable+0x31/0x57 but task is already holding lock: 88810a8e34c0 (&irq_desc_lock_class){-.-.}, at: __report_bad_irq+0x5b/0xba which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&irq_desc_lock_class){-.-.}: _raw_spin_lock_irqsave+0x61/0x8d __irq_get_desc_lock+0x65/0x89 __disable_irq_nosync+0x3b/0x93 serial8250_do_startup+0x451/0x75c uart_startup+0x1b4/0x2ff uart_port_activate+0x73/0xa0 tty_port_open+0xae/0x10a uart_open+0x1b/0x26 tty_open+0x24d/0x3a0 chrdev_open+0xd5/0x1cc do_dentry_open+0x299/0x3c8 path_openat+0x434/0x1100 do_filp_open+0x9b/0x10a do_sys_open+0x15f/0x3d7 kernel_init_freeable+0x157/0x1dd kernel_init+0xe/0x105 ret_from_fork+0x27/0x50 -> #1 (&port_lock_key){-.-.}: _raw_spin_lock_irqsave+0x61/0x8d serial8250_console_write+0xa7/0x2a0 console_unlock+0x3b7/0x528 vprintk_emit+0x111/0x17f printk+0x59/0x73 register_console+0x336/0x3a4 uart_add_one_port+0x51b/0x5be serial8250_register_8250_port+0x454/0x55e dw8250_probe+0x4dc/0x5b9 platform_drv_probe+0x67/0x8b really_probe+0x14a/0x422 driver_probe_device+0x66/0x130 device_driver_attach+0x42/0x5b __driver_attach+0xca/0x139 bus_for_each_dev+0x97/0xc9 bus_add_driver+0x12b/0x228 driver_register+0x64/0xed do_one_initcall+0x20c/0x4a6 do_initcall_level+0xb5/0xc5 do_basic_setup+0x4c/0x58 kernel_init_freeable+0x13f/0x1dd kernel_init+0xe/0x105 ret_from_fork+0x27/0x50 -> #0 (console_owner){-...}: __lock_acquire+0x118d/0x2714 lock_acquire+0x203/0x258 console_lock_spinning_enable+0x51/0x57 console_unlock+0x25d/0x528 vprintk_emit+0x111/0x17f printk+0x59/0x73 __report_bad_irq+0xa3/0xba note_interrupt+0x19a/0x1d6 handle_irq_event_percpu+0x57/0x79 handle_irq_event+0x36/0x55 handle_fasteoi_irq+0xc2/0x18a do_IRQ+0xb3/0x157 ret_from_intr+0x0/0x1d cpuidle_enter_state+0x12f/0x1fd cpuidle_enter+0x2e/0x3d do_idle+0x1ce/0x2ce cpu_startup_entry+0x1d/0x1f start_kernel+0x406/0x46a secondary_startup_64+0xa4/0xb0 other info that might help us debug this: Chain exists of: console_owner --> &port_lock_key --> &irq_desc_lock_class Possible unsafe locking scenario: CPU0CPU1 lock(&irq_desc_lock_class); lock(&port_lock_key); lock(&irq_desc_lock_class); lock(console_owner); *** DEADLOCK *** 2 locks held by swapper/0/0: #0: 88810a8e34c0 (&irq_desc_lock_class){-.-.}, at: __report_bad_irq+0x5b/0xba #1: ab65b5c0 (console_lock){+.+.}, at: console_trylock_spinning+0x20/0x181 stack backtrace: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.39 #55 Hardware name: XX Call Trace: dump_stack+0xbf/0x133 ? print_circular_bug+0xd6/0xe9 check_noncircular+0x1b9/0x1c3 __lock_acquire+0x118d/0x2714 lock_acquire+0x203/0x258 ? console_lock_spinning_enable+0x31/0x57 console_lock_spinning_enable+0x51/0x57 ? console_lock_spinning_enable+0x31/0x57 console_unlock+0x25d/0x528 ? console_trylock+0x18/0x4e vprintk_emit+0x111/0x17f ? lock_acquire+0x203/0x258 printk+0x59/0x73 __report_bad_irq+0xa3/0xba note_interrupt+0x19a/0x1d6 handle_irq_event_percpu+0x57/0x79 handle_irq_event+0x36/0x55 handle_fasteoi_irq+0xc2/0x18a do_IRQ+0xb3/0x157 common_interrupt+0xf/0xf Signed-off-by: Sergey Senozhatsky Fixes: 768aec0b5bcc ("serial: 8250: fix shared interrupts issues with SMP and RT kernels") Reported-by: Guenter Roeck Reported-by: Raul Ra
Re: [PATCH] net: handle the return value of pskb_carve_frag_list() correctly
David Miller wrote: >> +/* split line is in frag list */ >> +if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) { >> +/* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. >> */ >> +if (skb_has_frag_list(skb)) >> +kfree_skb_list(skb_shinfo(skb)->frag_list); >> +kfree(data); >> +return -ENOMEM; > >On error, the caller is going to kfree_skb(skb) which will take care of the >frag list. > I'am sorry for my careless. The caller will take care of the frag list and kfree(data) is enough here. Many thanks for review, will send v2 soon.
[PATCH] ARM: dts: vfxxx: Add syscon compatible with ocotp
From: Chris Healy Add syscon compatibility with Vybrid ocotp node. This is required to access the UID. Signed-off-by: Chris Healy --- arch/arm/boot/dts/vfxxx.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi index 0fe03aa0367f..2259d11af721 100644 --- a/arch/arm/boot/dts/vfxxx.dtsi +++ b/arch/arm/boot/dts/vfxxx.dtsi @@ -495,7 +495,7 @@ edma1: dma-controller@40098000 { }; ocotp: ocotp@400a5000 { - compatible = "fsl,vf610-ocotp"; + compatible = "fsl,vf610-ocotp", "syscon"; reg = <0x400a5000 0x1000>; clocks = <&clks VF610_CLK_OCOTP>; }; -- 2.26.2
Re: [PATCH v3] perf parse-events: Set exclude_guest=1 for user-space counting
Hi Arnaldo, On 8/14/2020 8:47 PM, Arnaldo Carvalho de Melo wrote: Em Fri, Aug 14, 2020 at 09:21:20AM +0800, Jin Yao escreveu: Currently if we run 'perf record -e cycles:u', exclude_guest=0. But it doesn't make sense in most cases that we request for user-space counting but we also get the guest report. Of course, we also need to consider perf kvm usage case that authorized perf users on the host may only want to count guest user space events. For example, perf kvm --guest record -e cycles:u Ok, probably this works, but what if I want to record guest user samples without using 'perf kvm'? Can we have a 'U' modifier, perhaps, for that? I.e. perf record -e cycles:uU would not set exclude_host not exclude_guest, cycles:u excludes guest user, cycles:U excludes host user, would that be possible? Anyway, I think that with what we have, your patch makes sense, having a way to, without using 'perf kvm' still be able to sample the guest can be done on top. of this. Xu, can we get your Reviewed-by if this addresses your concerns? - Arnaldo Do you suggest we will create a new modifier 'U' as a follow-up patch? cycles:u - Count host user space but it doesn't count the guest user space (exclude_host = 0, exclude_guest = 1, exclude_kernel = 1, exclude_user = 0, exclude_hv = 1) cycles:U - Count the guest user space but it doesn't count the host user space (exclude_host = 1, exclude_guest = 0, exclude_kernel = 1, exclude_user = 0, exclude_hv = 1) Is above understanding correct? Thanks Jin Yao
Re: [PATCH v2] ACPI / APEI: do memory failure on the physical address reported by ARM processor error section
@James, Could you help to check if i have fixed your review comments? thanks. On 2020/8/5 17:12, Xiaofei Tan wrote: > After the commit 8fcc4ae6faf8 ("arm64: acpi: Make apei_claim_sea() > synchronise with APEI's irq work") applied, user-mode SEA is > preferentially processed by APEI. Do memory failure to recover. > > But there are some problems: > 1) The function apei_claim_sea() has processed an CPER, does not > mean that memory failure handling has done. Because the firmware-first > RAS error is reported by both producer and consumer. Mostly SEA uses > ARM processor error section to report as a consumer. (The producer could > be DDRC and cache, and use memory error section and other error section > to report). But memory failure handling for ARM processor error section > has not been supported. This patch will add it. > > 2) Some hardware platforms can't record physical address each time. But > they could always have reported a firmware-first RAS error using ARM > processor error section. Such platform should update firmware. Don't > report the RAS error in SEA processing flow when physical address is > not recorded. > > Signed-off-by: Xiaofei Tan > --- > drivers/acpi/apei/ghes.c | 70 > > 1 file changed, 53 insertions(+), 17 deletions(-) > > diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c > index 81bf71b..aee7787 100644 > --- a/drivers/acpi/apei/ghes.c > +++ b/drivers/acpi/apei/ghes.c > @@ -429,28 +429,35 @@ static void ghes_kick_task_work(struct callback_head > *head) > gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node, node_len); > } > > -static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, > -int sev) > +static bool ghes_do_memory_failure(u64 physical_addr, int flags) > { > unsigned long pfn; > - int flags = -1; > - int sec_sev = ghes_severity(gdata->error_severity); > - struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata); > > if (!IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE)) > return false; > > - if (!(mem_err->validation_bits & CPER_MEM_VALID_PA)) > - return false; > - > - pfn = mem_err->physical_addr >> PAGE_SHIFT; > + pfn = PHYS_PFN(physical_addr); > if (!pfn_valid(pfn)) { > pr_warn_ratelimited(FW_WARN GHES_PFX > "Invalid address in generic error data: %#llx\n", > - mem_err->physical_addr); > + physical_addr); > return false; > } > > + memory_failure_queue(pfn, flags); > + return true; > +} > + > +static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, > +int sev) > +{ > + int flags = -1; > + int sec_sev = ghes_severity(gdata->error_severity); > + struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata); > + > + if (!(mem_err->validation_bits & CPER_MEM_VALID_PA)) > + return false; > + > /* iff following two events can be handled properly by now */ > if (sec_sev == GHES_SEV_CORRECTED && > (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED)) > @@ -458,14 +465,45 @@ static bool ghes_handle_memory_failure(struct > acpi_hest_generic_data *gdata, > if (sev == GHES_SEV_RECOVERABLE && sec_sev == GHES_SEV_RECOVERABLE) > flags = 0; > > - if (flags != -1) { > - memory_failure_queue(pfn, flags); > - return true; > - } > + if (flags != -1) > + return ghes_do_memory_failure(mem_err->physical_addr, flags); > > return false; > } > > +static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, > int sev) > +{ > + struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata); > + struct cper_arm_err_info *err_info; > + bool queued = false; > + int sec_sev, i; > + > + log_arm_hw_error(err); > + > + sec_sev = ghes_severity(gdata->error_severity); > + if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE) > + return false; > + > + err_info = (struct cper_arm_err_info *) (err + 1); > + for (i = 0; i < err->err_info_num; i++, err_info++) { > + if (!(err_info->validation_bits & > CPER_ARM_INFO_VALID_PHYSICAL_ADDR)) > + continue; > + > + if (err_info->type != CPER_ARM_CACHE_ERROR) { > + pr_warn_ratelimited(FW_WARN GHES_PFX > + "Physical address should be invalid for %s\n", > + err_info->type < ARRAY_SIZE(cper_proc_error_type_strs) ? > + cper_proc_error_type_strs[err_info->type] : "unknown > error type"); > + continue; > + } > + > + if (ghes_do_memory_failure(err_info->physical_fault_addr, 0)) > + queued = true; > + } > + > + return queued; > +}
[v3,1/4] dt-binding: reset-controller: ti: add reset-duration-us property
introduce 'reset' method to allow device do serialized assert and deassert operations in a single step, which needs a minimum delay to be waited between assert and deassert. Signed-off-by: Crystal Guo --- Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 5 + 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt index 86945502ccb5..ab041032339b 100644 --- a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +++ b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt @@ -59,6 +59,11 @@ Required properties: Please also refer to Documentation/devicetree/bindings/reset/reset.txt for common reset controller usage by consumers. +Optional properties: +- reset-duration-us: When do serialized assert and deassert operations, minimum delay in microseconds +is needed to be waited between an assert and a deassert to reset the device. This value can be 0, 0 means +that such a delay is not needed. + Example: The following example demonstrates a syscon node, the reset controller node -- 2.18.0
[v3,3/4] reset-controller: ti: introduce a new reset handler
Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience. Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset. Signed-off-by: Crystal Guo --- drivers/reset/reset-ti-syscon.c | 26 -- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c index a2635c21db7f..08289342f9af 100644 --- a/drivers/reset/reset-ti-syscon.c +++ b/drivers/reset/reset-ti-syscon.c @@ -15,6 +15,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -56,6 +57,7 @@ struct ti_syscon_reset_data { struct regmap *regmap; struct ti_syscon_reset_control *controls; unsigned int nr_controls; + unsigned int reset_duration_us; }; #define to_ti_syscon_reset_data(rcdev) \ @@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev, mask = BIT(control->assert_bit); value = (control->flags & ASSERT_SET) ? mask : 0x0; - return regmap_update_bits(data->regmap, control->assert_offset, mask, value); + return regmap_write_bits(data->regmap, control->assert_offset, mask, value); } /** @@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev, mask = BIT(control->deassert_bit); value = (control->flags & DEASSERT_SET) ? mask : 0x0; - return regmap_update_bits(data->regmap, control->deassert_offset, mask, value); + return regmap_write_bits(data->regmap, control->deassert_offset, mask, value); } /** @@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, !(control->flags & STATUS_SET); } +static int ti_syscon_reset(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev); + int ret; + + ret = ti_syscon_reset_assert(rcdev, id); + if (ret) + return ret; + + if (data->reset_duration_us) + usleep_range(data->reset_duration_us, data->reset_duration_us * 2); + + return ti_syscon_reset_deassert(rcdev, id); +} + static const struct reset_control_ops ti_syscon_reset_ops = { .assert = ti_syscon_reset_assert, .deassert = ti_syscon_reset_deassert, + .reset = ti_syscon_reset, .status = ti_syscon_reset_status, }; @@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev) controls[i].flags = be32_to_cpup(list++); } + of_property_read_u32(pdev->dev.of_node, "reset-duration-us", + &data->reset_duration_us); + data->rcdev.ops = &ti_syscon_reset_ops; data->rcdev.owner = THIS_MODULE; data->rcdev.of_node = np; -- 2.18.0
[v4,4/4] arm64: dts: mt8192: add infracfg_rst node
add infracfg_rst node which is for MT8192 platform Signed-off-by: Crystal Guo --- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi b/arch/arm64/boot/dts/mediatek/mt8192.dtsi index 931e1ca17220..a0cb9904706b 100644 --- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi @@ -10,6 +10,7 @@ #include #include #include +#include / { compatible = "mediatek,mt8192"; @@ -219,9 +220,17 @@ }; infracfg: infracfg@10001000 { - compatible = "mediatek,mt8192-infracfg", "syscon"; + compatible = "mediatek,mt8192-infracfg", "syscon", "simple-mfd"; reg = <0 0x10001000 0 0x1000>; #clock-cells = <1>; + + infracfg_rst: reset-controller { + compatible = "mediatek,infra-reset", "ti,syscon-reset"; + #reset-cells = <1>; + ti,reset-bits = < + 0x140 15 0x144 15 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: pcie */ + >; + }; }; pericfg: pericfg@10003000 { -- 2.18.0
[v3,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible
The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly. Signed-off-by: Crystal Guo --- Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt index ab041032339b..5a0e9365b51b 100644 --- a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +++ b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt @@ -25,6 +25,7 @@ Required properties: "ti,k2l-pscrst" "ti,k2hk-pscrst" "ti,syscon-reset" + "mediatek,infra-reset", "ti,syscon-reset" - #reset-cells: Should be 1. Please see the reset consumer node below for usage details - ti,reset-bits : Contains the reset control register information -- 2.18.0
[v3,0/6] introduce TI reset controller for MT8192 SoC
v3: 1. revert v2 changes. 2. add 'reset-duration-us' property to declare a minimum delay, which needs to be waited between assert and deassert. 3. add 'mediatek,infra-reset' to compatible. v2 changes: https://patchwork.kernel.org/patch/11697371/ 1. add 'assert-deassert-together' property to introduce a new reset handler, which allows device to do serialized assert and deassert operations in a single step by 'reset' method. 2. add 'update-force' property to introduce force-update method, which forces the write operation in case the read already happens to return the correct value. 3. add 'generic-reset' to compatible v1 changes: https://patchwork.kernel.org/patch/11690523/ https://patchwork.kernel.org/patch/11690527/ Crystal Guo (4): dt-binding: reset-controller: ti: add reset-duration-us property dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible reset-controller: ti: introduce a new reset handler arm64: dts: mt8192: add infracfg_rst node .../bindings/reset/ti-syscon-reset.txt| 6 + arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 +++- drivers/reset/reset-ti-syscon.c | 26 +-- 3 files changed, 40 insertions(+), 3 deletions(-)
[PATCHv2] selftests: rtnetlink: load fou module for kci_test_encap_fou()
The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh needs the fou module to work. Otherwise it will fail with: $ ip netns exec "$testns" ip fou add port ipproto 47 RTNETLINK answers: No such file or directory Error talking to the kernel Add the CONFIG_NET_FOU into the config file as well. Which needs at least to be set as a loadable module. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/rtnetlink.sh | 6 ++ 2 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index 3b42c06b..96d2763 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m CONFIG_NET_SCH_NETEM=y CONFIG_TEST_BLACKHOLE_DEV=m CONFIG_KALLSYMS=y +CONFIG_NET_FOU=m diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index bdbf4b3..7931b65 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -521,6 +521,11 @@ kci_test_encap_fou() return $ksft_skip fi + if ! /sbin/modprobe -q -n fou; then + echo "SKIP: module fou is not found" + return $ksft_skip + fi + /sbin/modprobe -q fou ip -netns "$testns" fou add port ipproto 47 2>/dev/null if [ $? -ne 0 ];then echo "FAIL: can't add fou port , skipping test" @@ -541,6 +546,7 @@ kci_test_encap_fou() return 1 fi + /sbin/modprobe -q -r fou echo "PASS: fou" } -- 2.7.4
Re: [PATCH] selftests: rtnetlink: load fou module for kci_test_encap_fou()
On Sat, Aug 15, 2020 at 7:43 AM David Miller wrote: > > From: Po-Hsu Lin > Date: Thu, 13 Aug 2020 12:44:22 +0800 > > > diff --git a/tools/testing/selftests/net/config > > b/tools/testing/selftests/net/config > > index 3b42c06b..96d2763 100644 > > --- a/tools/testing/selftests/net/config > > +++ b/tools/testing/selftests/net/config > > @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m > > CONFIG_NET_SCH_NETEM=y > > CONFIG_TEST_BLACKHOLE_DEV=m > > CONFIG_KALLSYMS=y > > +CONFIG_NET_FOU > > You need to assign it a value, not just add it to the file by itself. Oops! Patch re-submitted. Thanks for catching this.
[PATCH] ARM: dts: imx7d-zii-rmu2: fix rgmii phy-mode for ksz9031 phy
From: Chris Healy Since commit bcf3440c6dd7 ("net: phy: micrel: add phy-mode support for the KSZ9031 PHY") the networking is broken on the imx7d-zii-rmu2 board. Fix it by switching to phy-mode = "rgmii-id". Fixes: bcf3440c6dd7 ("net: phy: micrel: add phy-mode support for the KSZ9031 PHY") Signed-off-by: Chris Healy --- arch/arm/boot/dts/imx7d-zii-rmu2.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/imx7d-zii-rmu2.dts b/arch/arm/boot/dts/imx7d-zii-rmu2.dts index e5e20b07f184..7cb6153fc650 100644 --- a/arch/arm/boot/dts/imx7d-zii-rmu2.dts +++ b/arch/arm/boot/dts/imx7d-zii-rmu2.dts @@ -58,7 +58,7 @@ &fec1 { <&clks IMX7D_ENET1_TIME_ROOT_CLK>; assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>; assigned-clock-rates = <0>, <1>; - phy-mode = "rgmii"; + phy-mode = "rgmii-id"; phy-handle = <&fec1_phy>; status = "okay"; -- 2.26.2
Re: [PATCH 10/10] mm/hugetlb: not necessary to abuse temporary page to workaround the nasty free_huge_page
On Thu, Aug 13, 2020 at 01:46:38PM +0200, Michal Hocko wrote: >On Tue 11-08-20 14:43:28, Mike Kravetz wrote: >> On 8/10/20 11:54 PM, Michal Hocko wrote: >> > >> > I have managed to forgot all the juicy details since I have made that >> > change. All that remains is that the surplus pages accounting was quite >> > tricky and back then I didn't figure out a simpler method that would >> > achieve the consistent look at those counters. As mentioned above I >> > suspect this could lead to pre-mature allocation failures while the >> > migration is ongoing. >> >> It is likely lost in the e-mail thread, but the suggested change was to >> alloc_surplus_huge_page(). The code which allocates the migration target >> (alloc_migrate_huge_page) will not be changed. So, this should not be >> an issue. > >OK, I've missed that obviously. > >> > Sure quite unlikely to happen and the race window >> > is likely very small. Maybe this is even acceptable but I would strongly >> > recommend to have all this thinking documented in the changelog. >> >> I wrote down a description of what happens in the two different approaches >> "temporary page" vs "surplus page". It is at the very end of this e-mail. >> When looking at the details, I came up with what may be an even better >> approach. Why not just call the low level routine to free the page instead >> of going through put_page/free_huge_page? At the very least, it saves a >> lock roundtrip and there is no need to worry about the counters/accounting. >> >> Here is a patch to do that. However, we are optimizing a return path in >> a race condition that we are unlikely to ever hit. I 'tested' it by >> allocating >> an 'extra' page and freeing it via this method in alloc_surplus_huge_page. >> >> >From 864c5f8ef4900c95ca3f6f2363a85f3cb25e793e Mon Sep 17 00:00:00 2001 >> From: Mike Kravetz >> Date: Tue, 11 Aug 2020 12:45:41 -0700 >> Subject: [PATCH] hugetlb: optimize race error return in >> alloc_surplus_huge_page >> >> The routine alloc_surplus_huge_page() could race with with a pool >> size change. If this happens, the allocated page may not be needed. >> To free the page, the current code will 'Abuse temporary page to >> workaround the nasty free_huge_page codeflow'. Instead, directly >> call the low level routine that free_huge_page uses. This works >> out well because the page is new, we hold the only reference and >> already hold the hugetlb_lock. >> >> Signed-off-by: Mike Kravetz >> --- >> mm/hugetlb.c | 13 - >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index 590111ea6975..ac89b91fba86 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -1923,14 +1923,17 @@ static struct page *alloc_surplus_huge_page(struct >> hstate *h, gfp_t gfp_mask, >> /* >> * We could have raced with the pool size change. >> * Double check that and simply deallocate the new page >> - * if we would end up overcommiting the surpluses. Abuse >> - * temporary page to workaround the nasty free_huge_page >> - * codeflow >> + * if we would end up overcommiting the surpluses. >> */ >> if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { >> -SetPageHugeTemporary(page); >> +/* >> + * Since this page is new, we hold the only reference, and >> + * we already hold the hugetlb_lock call the low level free >> + * page routine. This saves at least a lock roundtrip. >> + */ >> +(void)put_page_testzero(page); /* don't call destructor */ >> +update_and_free_page(h, page); >> spin_unlock(&hugetlb_lock); >> -put_page(page); >> return NULL; >> } else { >> h->surplus_huge_pages++; > >Yes this makes sense. I would have to think about this more to be >confident and give Acked-by but this looks sensible from a quick glance. > If it is ok, I would like to send v2 without this one to give more time for a discussion? >Thanks! >-- >Michal Hocko >SUSE Labs -- Wei Yang Help you, Help me
[v4,0/4] introduce TI reset controller for MT8192 SoC
v4: fix typos on v3 commit message. v3: 1. revert v2 changes. 2. add 'reset-duration-us' property to declare a minimum delay, which needs to be waited between assert and deassert. 3. add 'mediatek,infra-reset' to compatible. v2 changes: https://patchwork.kernel.org/patch/11697371/ 1. add 'assert-deassert-together' property to introduce a new reset handler, which allows device to do serialized assert and deassert operations in a single step by 'reset' method. 2. add 'update-force' property to introduce force-update method, which forces the write operation in case the read already happens to return the correct value. 3. add 'generic-reset' to compatible v1 changes: https://patchwork.kernel.org/patch/11690523/ https://patchwork.kernel.org/patch/11690527/ Crystal Guo (4): dt-binding: reset-controller: ti: add reset-duration-us property dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible reset-controller: ti: introduce a new reset handler arm64: dts: mt8192: add infracfg_rst node .../bindings/reset/ti-syscon-reset.txt| 6 + arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 +++- drivers/reset/reset-ti-syscon.c | 26 +-- 3 files changed, 40 insertions(+), 3 deletions(-)
[v4,3/4] reset-controller: ti: introduce a new reset handler
Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience. Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset. Signed-off-by: Crystal Guo --- drivers/reset/reset-ti-syscon.c | 26 -- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c index a2635c21db7f..08289342f9af 100644 --- a/drivers/reset/reset-ti-syscon.c +++ b/drivers/reset/reset-ti-syscon.c @@ -15,6 +15,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -56,6 +57,7 @@ struct ti_syscon_reset_data { struct regmap *regmap; struct ti_syscon_reset_control *controls; unsigned int nr_controls; + unsigned int reset_duration_us; }; #define to_ti_syscon_reset_data(rcdev) \ @@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev, mask = BIT(control->assert_bit); value = (control->flags & ASSERT_SET) ? mask : 0x0; - return regmap_update_bits(data->regmap, control->assert_offset, mask, value); + return regmap_write_bits(data->regmap, control->assert_offset, mask, value); } /** @@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev, mask = BIT(control->deassert_bit); value = (control->flags & DEASSERT_SET) ? mask : 0x0; - return regmap_update_bits(data->regmap, control->deassert_offset, mask, value); + return regmap_write_bits(data->regmap, control->deassert_offset, mask, value); } /** @@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, !(control->flags & STATUS_SET); } +static int ti_syscon_reset(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev); + int ret; + + ret = ti_syscon_reset_assert(rcdev, id); + if (ret) + return ret; + + if (data->reset_duration_us) + usleep_range(data->reset_duration_us, data->reset_duration_us * 2); + + return ti_syscon_reset_deassert(rcdev, id); +} + static const struct reset_control_ops ti_syscon_reset_ops = { .assert = ti_syscon_reset_assert, .deassert = ti_syscon_reset_deassert, + .reset = ti_syscon_reset, .status = ti_syscon_reset_status, }; @@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev) controls[i].flags = be32_to_cpup(list++); } + of_property_read_u32(pdev->dev.of_node, "reset-duration-us", + &data->reset_duration_us); + data->rcdev.ops = &ti_syscon_reset_ops; data->rcdev.owner = THIS_MODULE; data->rcdev.of_node = np; -- 2.18.0
[v4,4/4] arm64: dts: mt8192: add infracfg_rst node
add infracfg_rst node which is for MT8192 platform Signed-off-by: Crystal Guo --- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi b/arch/arm64/boot/dts/mediatek/mt8192.dtsi index 931e1ca17220..a0cb9904706b 100644 --- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi @@ -10,6 +10,7 @@ #include #include #include +#include / { compatible = "mediatek,mt8192"; @@ -219,9 +220,17 @@ }; infracfg: infracfg@10001000 { - compatible = "mediatek,mt8192-infracfg", "syscon"; + compatible = "mediatek,mt8192-infracfg", "syscon", "simple-mfd"; reg = <0 0x10001000 0 0x1000>; #clock-cells = <1>; + + infracfg_rst: reset-controller { + compatible = "mediatek,infra-reset", "ti,syscon-reset"; + #reset-cells = <1>; + ti,reset-bits = < + 0x140 15 0x144 15 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: pcie */ + >; + }; }; pericfg: pericfg@10003000 { -- 2.18.0
[v4,1/4] dt-binding: reset-controller: ti: add reset-duration-us property
introduce 'reset' method to allow device do serialized assert and deassert operations in a single step, which needs a minimum delay to be waited between assert and deassert. Signed-off-by: Crystal Guo --- Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 5 + 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt index 86945502ccb5..ab041032339b 100644 --- a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +++ b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt @@ -59,6 +59,11 @@ Required properties: Please also refer to Documentation/devicetree/bindings/reset/reset.txt for common reset controller usage by consumers. +Optional properties: +- reset-duration-us: When do serialized assert and deassert operations, minimum delay in microseconds +is needed to be waited between an assert and a deassert to reset the device. This value can be 0, 0 means +that such a delay is not needed. + Example: The following example demonstrates a syscon node, the reset controller node -- 2.18.0
[v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible
The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly. Signed-off-by: Crystal Guo --- Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt index ab041032339b..5a0e9365b51b 100644 --- a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +++ b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt @@ -25,6 +25,7 @@ Required properties: "ti,k2l-pscrst" "ti,k2hk-pscrst" "ti,syscon-reset" + "mediatek,infra-reset", "ti,syscon-reset" - #reset-cells: Should be 1. Please see the reset consumer node below for usage details - ti,reset-bits : Contains the reset control register information -- 2.18.0
Re: [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence
On 8/16/20 11:22 AM, Prabhakar Mahadev Lad wrote: >> FTR, I gave it a try on the SH7751R-based I-O DATA USL-5P aka Landisk: >> SCIF is affected, and fixed by commit 3dc4db3662366306 ("serial: sh-sci: >> Make sure status register SCxSR is read in correct sequence"). >> > Thank you Geert. > > Cheers, > Prabhakar Did we ever figure out how to get linux to talk to the _first_ serial port on the qemu-system-sh4 r2d board? I'm still doing: qemu-system-sh4 -M r2d -serial null -serial mon:stdio Because I can only get a working console on the _second_ serial port. (SCI vs SCIF I think?) Rob
Re: [PATCH] bsg-lib: convert comma to semicolon
On 8/16/20 7:16 PM, Xu Wang wrote: > Replace a comma between expression statements by a semicolon. Thanks, applied. -- Jens Axboe
Re: [PATCH] ata: ahci: use ata_link_info() instead of ata_link_printk()
On 8/16/20 6:18 PM, Xu Wang wrote: > Using ata_link_info() instead of ata_link_printk(). > > Signed-off-by: Xu Wang > --- > drivers/ata/ahci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > index 0c0a736eb861..9d72d907b4ee 100644 > --- a/drivers/ata/ahci.c > +++ b/drivers/ata/ahci.c > @@ -807,7 +807,7 @@ static int ahci_avn_hardreset(struct ata_link *link, > unsigned int *class, > (sstatus & 0xf) != 1) > break; > > - ata_link_printk(link, KERN_INFO, "avn bounce port%d\n", > + ata_link_info(link, "avn bounce port%d\n", > port); Why not collapse that into one line as well when making that change, as it now fits just fine? Apart from that, looks fine to me. -- Jens Axboe
[PATCH v8 2/2] phy: Add USB3 PHY support for Intel LGM SoC
From: Ramuthevar Vadivel Murugan Add support for USB PHY on Intel LGM SoC. Signed-off-by: Ramuthevar Vadivel Murugan Reviewed-by: Philipp Zabel --- drivers/phy/Kconfig | 11 ++ drivers/phy/Makefile | 3 +- drivers/phy/phy-lgm-usb.c | 278 ++ 3 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 drivers/phy/phy-lgm-usb.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index de9362c25c07..01b53f86004c 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -49,6 +49,17 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config USB_LGM_PHY + tristate "INTEL Lightning Mountain USB PHY Driver" + depends on USB_SUPPORT + select USB_PHY + select REGULATOR + select REGULATOR_FIXED_VOLTAGE + help + Enable this to support Intel DWC3 PHY USB phy. This driver provides + interface to interact with USB GEN-II and USB 3.x PHY that is part + of the Intel network SOC. + source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index c27408e4daae..90030ff299eb 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0 +PDX-License-Identifier: GPL-2.0 # # Makefile for the phy drivers. # @@ -8,6 +8,7 @@ obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o +obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o obj-y += allwinner/ \ amlogic/ \ broadcom/\ diff --git a/drivers/phy/phy-lgm-usb.c b/drivers/phy/phy-lgm-usb.c new file mode 100644 index ..1ec9ab266e08 --- /dev/null +++ b/drivers/phy/phy-lgm-usb.c @@ -0,0 +1,278 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Intel LGM USB PHY driver + * + * Copyright (C) 2020 Intel Corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CTRL1_OFFSET 0x14 +#define SRAM_EXT_LD_DONE BIT(25) +#define SRAM_INIT_DONE BIT(26) + +#define TCPC_OFFSET0x1014 +#define TCPC_MUX_CTL GENMASK(1, 0) +#define MUX_NC 0 +#define MUX_USB1 +#define MUX_DP 2 +#define MUX_USBDP 3 +#define TCPC_FLIPPED BIT(2) +#define TCPC_LOW_POWER_EN BIT(3) +#define TCPC_VALID BIT(4) +#define TCPC_CONN \ + (TCPC_VALID | FIELD_PREP(TCPC_MUX_CTL, MUX_USB)) +#define TCPC_DISCONN \ + (TCPC_VALID | FIELD_PREP(TCPC_MUX_CTL, MUX_NC) | TCPC_LOW_POWER_EN) + +static const char *const PHY_RESETS[] = { "phy31", "phy", }; +static const char *const CTL_RESETS[] = { "apb", "ctrl", }; + +struct tca_apb { + struct reset_control *resets[ARRAY_SIZE(PHY_RESETS)]; + struct regulator *vbus; + struct work_struct wk; + struct usb_phy phy; + + bool phy_initialized; + bool connected; +}; + +static int get_flipped(struct tca_apb *ta, bool *flipped) +{ + union extcon_property_value property; + int ret; + + ret = extcon_get_property(ta->phy.edev, EXTCON_USB_HOST, + EXTCON_PROP_USB_TYPEC_POLARITY, &property); + if (ret) { + dev_err(ta->phy.dev, "no polarity property from extcon\n"); + return ret; + } + + *flipped = property.intval; + + return ret; +} + +static int phy_init(struct usb_phy *phy) +{ + struct tca_apb *ta = container_of(phy, struct tca_apb, phy); + void __iomem *ctrl1 = phy->io_priv + CTRL1_OFFSET; + int val, ret, i; + + if (ta->phy_initialized) + return 0; + + for (i = 0; i < ARRAY_SIZE(PHY_RESETS); i++) + reset_control_deassert(ta->resets[i]); + + ret = readl_poll_timeout(ctrl1, val, val & SRAM_INIT_DONE, 10, 10 * 1000); + if (ret) { + dev_err(ta->phy.dev, "SRAM init failed, 0x%x\n", val); + return ret; + } + + writel(readl(ctrl1) | SRAM_EXT_LD_DONE, ctrl1); + + ta->phy_initialized = true; + if (!ta->phy.edev) { + writel(TCPC_CONN, ta->phy.io_priv + TCPC_OFFSET); + return phy->set_vbus(phy, true); + } + + schedule_work(&ta->wk); + + return ret; +} + +static void phy_shutdown(struct usb_phy *phy) +{ + struct tca_apb *ta = container_of(phy, struct tca_apb, phy); + int i; + + if (!ta->phy_initialized) + return; + + ta->
[PATCH v8 1/2] dt-bindings: phy: Add USB PHY support for Intel LGM SoC
From: Ramuthevar Vadivel Murugan Add the dt-schema to support USB PHY on Intel LGM SoC Signed-off-by: Ramuthevar Vadivel Murugan Reviewed-by: Rob Herring --- .../devicetree/bindings/phy/intel,lgm-usb-phy.yaml | 58 ++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/intel,lgm-usb-phy.yaml diff --git a/Documentation/devicetree/bindings/phy/intel,lgm-usb-phy.yaml b/Documentation/devicetree/bindings/phy/intel,lgm-usb-phy.yaml new file mode 100644 index ..ce62c0b94daf --- /dev/null +++ b/Documentation/devicetree/bindings/phy/intel,lgm-usb-phy.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/intel,lgm-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel LGM USB PHY Device Tree Bindings + +maintainers: + - Vadivel Murugan Ramuthevar + +properties: + compatible: +const: intel,lgm-usb-phy + + reg: +maxItems: 1 + + clocks: +maxItems: 1 + + resets: +items: + - description: USB PHY and Host controller reset + - description: APB BUS reset + - description: General Hardware reset + + reset-names: +items: + - const: phy + - const: apb + - const: phy31 + + "#phy-cells": +const: 0 + +required: + - compatible + - clocks + - reg + - resets + - reset-names + - "#phy-cells" + +additionalProperties: false + +examples: + - | +usb-phy@e7e0 { +compatible = "intel,lgm-usb-phy"; +reg = <0xe7e0 0x1>; +clocks = <&cgu0 153>; +resets = <&rcu 0x70 0x24>, + <&rcu 0x70 0x26>, + <&rcu 0x70 0x28>; +reset-names = "phy", "apb", "phy31"; +#phy-cells = <0>; +}; -- 2.11.0
[PATCH v8 0/2] phy: Add USB PHY support on Intel LGM SoC
The USB PHY provides the optimized for low power dissipation while active, idle, or on standby. Requires minimal external components, a single resistor, for best operation. Supports 10/5-Gbps high-speed data transmission rates through 3-m USB 3.x cable --- v8: - Rebase to V5.9-rc1 v7: - No Change v6: - No Change v5: - As per Felipe and Greg's suggestion usb phy driver reviewed patches changed the folder from drivers/usb/phy to drivers/phy - Reviewed-By tag added in commit message v4: - Andy's review comments addressed - drop the excess error debug prints - error check optimized - merge the split line to one line v3: - Andy's review comments update - hardcode return value changed to actual return value from the callee - add error check is fixed according to the above - correct the assignment in redundant - combine the split line into one line v2: - Address Phillip's review comments - replace devm_reset_control_get() by devm_reset_control_get_exclusive() - re-design the assert and deassert fucntion calls as per review comments - address kbuild bot warnings - add the comments v1: - initial version --- dt-bindings: usb: Add USB PHY support for Intel LGM SoC v8: - No Change v7: - Fixed the bot issue: usb-phy@e7e0: '#phy-cells' is a required property v6: - Fixed the bot issue. - replace node-name by usb-phy@ in example v5: - Reviewed-By tag added v4: - No Change v3: - No Change v2: - No Change v1: - initial version Ramuthevar Vadivel Murugan (2): dt-bindings: phy: Add USB PHY support for Intel LGM SoC phy: Add USB3 PHY support for Intel LGM SoC .../devicetree/bindings/phy/intel,lgm-usb-phy.yaml | 58 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile | 3 +- drivers/phy/phy-lgm-usb.c | 278 + 4 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/intel,lgm-usb-phy.yaml create mode 100644 drivers/phy/phy-lgm-usb.c -- 2.11.0
[PATCH] upcall: Remove unneeded variable insize
Remove unneeded variable insize in venus_pioctl(). Signed-off-by: Xu Wang --- fs/coda/upcall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index eb3b1898da46..903bd7a4ee16 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c @@ -477,10 +477,9 @@ int venus_pioctl(struct super_block *sb, struct CodaFid *fid, { union inputArgs *inp; union outputArgs *outp; - int insize, outsize, error; + int outsize, error; int iocsize; - insize = VC_MAXMSGSIZE; UPARG(CODA_IOCTL); /* build packet for Venus */ -- 2.17.1
[PATCH] ata: ahci: use ata_link_info() instead of ata_link_printk()
Using ata_link_info() instead of ata_link_printk(). Signed-off-by: Xu Wang --- drivers/ata/ahci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 0c0a736eb861..fbd8eaa32d32 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -807,8 +807,7 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, (sstatus & 0xf) != 1) break; - ata_link_printk(link, KERN_INFO, "avn bounce port%d\n", - port); + ata_link_info(link, "avn bounce port%d\n", port); pci_read_config_word(pdev, 0x92, &val); val &= ~(1 << port); -- 2.17.1
[RESEND RFC v2 1/2] KVM: VMX: Convert vcpu_vmx.exit_reason to a union
From: Sean Christopherson Convert vcpu_vmx.exit_reason from a u32 to a union (of size u32). The full VM_EXIT_REASON field is comprised of a 16-bit basic exit reason in bits 15:0, and single-bit modifiers in bits 31:16. Historically, KVM has only had to worry about handling the "failed VM-Entry" modifier, which could only be set in very specific flows and required dedicated handling. I.e. manually stripping the FAILED_VMENTRY bit was a somewhat viable approach. But even with only a single bit to worry about, KVM has had several bugs related to comparing a basic exit reason against the full exit reason store in vcpu_vmx. Upcoming Intel features, e.g. SGX, will add new modifier bits that can be set on more or less any VM-Exit, as opposed to the significantly more restricted FAILED_VMENTRY, i.e. correctly handling everything in one-off flows isn't scalable. Tracking exit reason in a union forces code to explicitly choose between consuming the full exit reason and the basic exit, and is a convenient way to document and access the modifiers. No functional change intended. Cc: Xiaoyao Li Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 42 - arch/x86/kvm/vmx/vmx.c| 64 --- arch/x86/kvm/vmx/vmx.h| 25 ++- 3 files changed, 84 insertions(+), 47 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 23b58c28a1c9..0262111e5821 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3304,7 +3304,11 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12 = get_vmcs12(vcpu); enum vm_entry_failure_code entry_failure_code; bool evaluate_pending_interrupts; - u32 exit_reason, failed_index; + union vmx_exit_reason exit_reason = { + .basic = EXIT_REASON_INVALID_STATE, + .failed_vmentry = 1, + }; + u32 failed_index; if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu)) kvm_vcpu_flush_tlb_current(vcpu); @@ -3354,7 +3358,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, if (nested_vmx_check_guest_state(vcpu, vmcs12, &entry_failure_code)) { - exit_reason = EXIT_REASON_INVALID_STATE; + exit_reason.basic = EXIT_REASON_INVALID_STATE; vmcs12->exit_qualification = entry_failure_code; goto vmentry_fail_vmexit; } @@ -3365,7 +3369,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, vcpu->arch.tsc_offset += vmcs12->tsc_offset; if (prepare_vmcs02(vcpu, vmcs12, &entry_failure_code)) { - exit_reason = EXIT_REASON_INVALID_STATE; + exit_reason.basic = EXIT_REASON_INVALID_STATE; vmcs12->exit_qualification = entry_failure_code; goto vmentry_fail_vmexit_guest_mode; } @@ -3375,7 +3379,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); if (failed_index) { - exit_reason = EXIT_REASON_MSR_LOAD_FAIL; + exit_reason.basic = EXIT_REASON_MSR_LOAD_FAIL; vmcs12->exit_qualification = failed_index; goto vmentry_fail_vmexit_guest_mode; } @@ -3443,7 +3447,7 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, return NVMX_VMENTRY_VMEXIT; load_vmcs12_host_state(vcpu, vmcs12); - vmcs12->vm_exit_reason = exit_reason | VMX_EXIT_REASONS_FAILED_VMENTRY; + vmcs12->vm_exit_reason = exit_reason.full; if (enable_shadow_vmcs || vmx->nested.hv_evmcs) vmx->nested.need_vmcs12_to_shadow_sync = true; return NVMX_VMENTRY_VMEXIT; @@ -5488,7 +5492,12 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu) return kvm_skip_emulated_instruction(vcpu); fail: - nested_vmx_vmexit(vcpu, vmx->exit_reason, + /* +* This is effectively a reflected VM-Exit, as opposed to a synthesized +* nested VM-Exit. Pass the original exit reason, i.e. don't hardcode +* EXIT_REASON_VMFUNC as the exit reason. +*/ + nested_vmx_vmexit(vcpu, vmx->exit_reason.full, vmx_get_intr_info(vcpu), vmx_get_exit_qual(vcpu)); return 1; @@ -5556,7 +5565,8 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu, * MSR bitmap. This may be the case even when L0 doesn't use MSR bitmaps. */ static bool nested_vmx_exit_handled_msr(struct kvm
[RESEND RFC v2 0/2] add bus lock VM exit support
Resend to rebase on 5.9-rc1. --- Add the support for bus lock VM exit in KVM. It is a sub-feature of bus lock detection. Another sub-feature named bus lock debug exception is blocked due to requirement to rework the HW design: https://lore.kernel.org/lkml/87r1stmi1x@nanos.tec.linutronix.de/ In this patch series, the first patch applies Sean's refactor to vcpu_vmx.exit_reason available at https://patchwork.kernel.org/patch/11500659. It is necessary as bus lock VM exit adds a new modifier bit(bit 26) in exit_reason field in VMCS. The second patch is the enabling work for bus lock VM exit. Add the support to set the capability to enable bus lock vm exit. The current implementation just exit to user space when handling the bus lock detected in guest. The concrete throttling policy in user space still needs to be discussed. We can enforce ratelimit on bus lock in guest, just inject some sleep time, or any other ideas? Document for Bus Lock Detection is now available at the latest "Intel Architecture Instruction Set Extensions Programming Reference". Document Link: https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html v1->v2 Changelogs: - resolve Vitaly's comment to introduce the KVM_EXIT_BUS_LOCK and a capability to enable it. - add the support to exit to user space when handling bus locks. - extend the vcpu->run->flags to indicate bus lock detected for other exit reasons when exiting to user space. Chenyi Qiang (1): KVM: VMX: Enable bus lock VM exit Sean Christopherson (1): KVM: VMX: Convert vcpu_vmx.exit_reason to a union arch/x86/include/asm/kvm_host.h| 9 +++ arch/x86/include/asm/vmx.h | 1 + arch/x86/include/asm/vmxfeatures.h | 1 + arch/x86/include/uapi/asm/kvm.h| 1 + arch/x86/include/uapi/asm/vmx.h| 4 +- arch/x86/kvm/vmx/capabilities.h| 6 ++ arch/x86/kvm/vmx/nested.c | 42 - arch/x86/kvm/vmx/vmx.c | 97 -- arch/x86/kvm/vmx/vmx.h | 25 +++- arch/x86/kvm/x86.c | 36 ++- arch/x86/kvm/x86.h | 5 ++ include/uapi/linux/kvm.h | 2 + 12 files changed, 179 insertions(+), 50 deletions(-) -- 2.17.1
[RESEND RFC v2 2/2] KVM: VMX: Enable bus lock VM exit
Virtual Machine can exploit bus locks to degrade the performance of system. Bus lock can be caused by split locked access to writeback(WB) memory or by using locks on uncacheable(UC) memory. The bus lock is typically >1000 cycles slower than an atomic operation within a cache line. It also disrupts performance on other cores (which must wait for the bus lock to be released before their memory operations can complete). To address the threat, bus lock VM exit is introduced to notify the VMM when a bus lock was acquired, allowing it to enforce throttling or other policy based mitigations. A VMM can enable VM exit due to bus locks by setting a new "Bus Lock Detection" VM-execution control(bit 30 of Secondary Processor-based VM execution controls). If delivery of this VM exit was preempted by a higher priority VM exit (e.g. EPT misconfiguration, EPT violation, APIC access VM exit, APIC write VM exit, exception bitmap exiting), bit 26 of exit reason in vmcs field is set to 1. In current implementation, the KVM exposes this capability through KVM_CAP_X86_BLD. The user can set it to enable the bus lock VM exit (disabled by default). If bus locks in guest are detected by KVM, exit to user space even when current exit reason is handled by KVM internally. Set a new field KVM_RUN_BUS_LOCK in vcpu->run->flags to inform the user space that there is a bus lock in guest and it is preempted by a higher priority VM exit. Every bus lock acquired in non-root mode will be recorded in vcpu->stat.bus_locks and exposed through debugfs when the bus lock VM exit is enabled. Document for Bus Lock VM exit is now available at the latest "Intel Architecture Instruction Set Extensions Programming Reference". Document Link: https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Chenyi Qiang --- arch/x86/include/asm/kvm_host.h| 9 arch/x86/include/asm/vmx.h | 1 + arch/x86/include/asm/vmxfeatures.h | 1 + arch/x86/include/uapi/asm/kvm.h| 1 + arch/x86/include/uapi/asm/vmx.h| 4 +++- arch/x86/kvm/vmx/capabilities.h| 6 + arch/x86/kvm/vmx/vmx.c | 33 ++- arch/x86/kvm/vmx/vmx.h | 2 +- arch/x86/kvm/x86.c | 36 +- arch/x86/kvm/x86.h | 5 + include/uapi/linux/kvm.h | 2 ++ 11 files changed, 96 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 5ab3af7275d8..fc02fa95cb70 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -788,6 +788,9 @@ struct kvm_vcpu_arch { /* AMD MSRC001_0015 Hardware Configuration */ u64 msr_hwcr; + + /* Set when bus lock VM exit is preempted by a higher priority VM exit */ + bool bus_lock_detected; }; struct kvm_lpage_info { @@ -961,6 +964,9 @@ struct kvm_arch { bool guest_can_read_msr_platform_info; bool exception_payload_enabled; + /* Set when bus lock vm exit is enabled by user */ + bool bus_lock_exit; + struct kvm_pmu_event_filter *pmu_event_filter; struct task_struct *nx_lpage_recovery_thread; }; @@ -1010,6 +1016,7 @@ struct kvm_vcpu_stat { u64 req_event; u64 halt_poll_success_ns; u64 halt_poll_fail_ns; + u64 bus_locks; }; struct x86_instruction_info; @@ -1347,6 +1354,8 @@ extern u8 kvm_tsc_scaling_ratio_frac_bits; extern u64 kvm_max_tsc_scaling_ratio; /* 1ull << kvm_tsc_scaling_ratio_frac_bits */ extern u64 kvm_default_tsc_scaling_ratio; +/* bus lock detection supported */ +extern bool kvm_has_bus_lock_exit; extern u64 kvm_mce_cap_supported; diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index cd7de4b401fe..93a880bc31a7 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -73,6 +73,7 @@ #define SECONDARY_EXEC_PT_USE_GPA VMCS_CONTROL_BIT(PT_USE_GPA) #define SECONDARY_EXEC_TSC_SCALING VMCS_CONTROL_BIT(TSC_SCALING) #define SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE VMCS_CONTROL_BIT(USR_WAIT_PAUSE) +#define SECONDARY_EXEC_BUS_LOCK_DETECTION VMCS_CONTROL_BIT(BUS_LOCK_DETECTION) #define PIN_BASED_EXT_INTR_MASK VMCS_CONTROL_BIT(INTR_EXITING) #define PIN_BASED_NMI_EXITING VMCS_CONTROL_BIT(NMI_EXITING) diff --git a/arch/x86/include/asm/vmxfeatures.h b/arch/x86/include/asm/vmxfeatures.h index 9915990fd8cf..e80523346274 100644 --- a/arch/x86/include/asm/vmxfeatures.h +++ b/arch/x86/include/asm/vmxfeatures.h @@ -83,5 +83,6 @@ #define VMX_FEATURE_TSC_SCALING( 2*32+ 25) /* Scale hardware TSC when read in guest */ #define VMX_FEATURE_USR_WAIT_PAUSE ( 2*32+ 26) /* Enable TPAUSE, UMONITOR, UMWAIT in guest */ #define VMX_FEATURE_ENCLV_EXITING ( 2
[PATCH 0/3] KVM: arm64: Some fixes and code adjustments for pvtime ST
During picking up pvtime LPT support for arm64, I do some trivial fixes for pvtime ST. Keqian Zhu (3): KVM: arm64: Some fixes of PV-time interface document KVM: uapi: Remove KVM_DEV_TYPE_ARM_PV_TIME in kvm_device_type KVM: arm64: Use kvm_write_guest_lock when init stolen time Documentation/virt/kvm/arm/pvtime.rst | 6 +++--- arch/arm64/kvm/pvtime.c | 6 +- include/uapi/linux/kvm.h | 2 -- tools/include/uapi/linux/kvm.h| 2 -- 4 files changed, 4 insertions(+), 12 deletions(-) -- 1.8.3.1
[PATCH 3/3] KVM: arm64: Use kvm_write_guest_lock when init stolen time
There is a lock version kvm_write_guest. Use it to simplify code. Signed-off-by: Keqian Zhu --- arch/arm64/kvm/pvtime.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/arm64/kvm/pvtime.c b/arch/arm64/kvm/pvtime.c index f7b52ce..2b24e7f 100644 --- a/arch/arm64/kvm/pvtime.c +++ b/arch/arm64/kvm/pvtime.c @@ -55,7 +55,6 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu) struct pvclock_vcpu_stolen_time init_values = {}; struct kvm *kvm = vcpu->kvm; u64 base = vcpu->arch.steal.base; - int idx; if (base == GPA_INVALID) return base; @@ -66,10 +65,7 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu) */ vcpu->arch.steal.steal = 0; vcpu->arch.steal.last_steal = current->sched_info.run_delay; - - idx = srcu_read_lock(&kvm->srcu); - kvm_write_guest(kvm, base, &init_values, sizeof(init_values)); - srcu_read_unlock(&kvm->srcu, idx); + kvm_write_guest_lock(kvm, base, &init_values, sizeof(init_values)); return base; } -- 1.8.3.1
[PATCH 2/3] KVM: uapi: Remove KVM_DEV_TYPE_ARM_PV_TIME in kvm_device_type
ARM64 PV-time ST is configured by userspace through vCPU attribute, and KVM_DEV_TYPE_ARM_PV_TIME is unused. Signed-off-by: Keqian Zhu --- include/uapi/linux/kvm.h | 2 -- tools/include/uapi/linux/kvm.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 4fdf303..9a6b97e 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1258,8 +1258,6 @@ enum kvm_device_type { #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_XIVE, #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE - KVM_DEV_TYPE_ARM_PV_TIME, -#define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_MAX, }; diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index 4fdf303..9a6b97e 100644 --- a/tools/include/uapi/linux/kvm.h +++ b/tools/include/uapi/linux/kvm.h @@ -1258,8 +1258,6 @@ enum kvm_device_type { #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_XIVE, #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE - KVM_DEV_TYPE_ARM_PV_TIME, -#define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_MAX, }; -- 1.8.3.1
Re: [PATCH] Makefile: Yes. Finally remove '-Wdeclaration-after-statement'
Joe Perches (Sun, 16 Aug 2020 10:56:53 -0700): > I rather prefer block declarations instead of > sprinkling declarations around with code. Hey, we all have our guilty pleasures. Fortunately, even with this patch, you'd still be able to indulge in your preferred style, or even enforce it among contributors to the code that you maintain. However, the following statement should hold: If merged code is correct (portable, safe, etc.), then the kernel must build without any warning about that merged code. Sometimes, code is clearest (or indeed safest) when it is written with a variable definition that occurs at a point well within the body of statements. Authors need to have the option to write such code; otherwise, style ceases to be means of clarity, and instead becomes a laborious end unto itself. Matters of style should probably not be enforced by the build infrastructure; style is a matter for the maintainer to enforce: * Perhaps there could be a new build-time switch. By default, the warning can be off for a normal build; a maintainer can flip the switch to turn it on locally, and thereby check whether a patch declares variables unnecessarily hither and thither, as determined by the maintainer's taste. * Perhaps `scripts/checkpatch.pl' could be taught about this issue. Though probably easier said than done, the script could parse every modified block, and warn about declarations after statements (but maybe ignore the declarations that introduce const variables). * Perhaps there is already linting infrastructure that could be put to such use. This way, good code can compile cleanly, and style can just be an ongoing topic of discussion among contributors. Sincerely, Michael Witten
[PATCH 1/3] KVM: arm64: Some fixes of PV-time interface document
Rename PV_FEATURES tp PV_TIME_FEATURES Signed-off-by: Keqian Zhu --- Documentation/virt/kvm/arm/pvtime.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/virt/kvm/arm/pvtime.rst b/Documentation/virt/kvm/arm/pvtime.rst index 687b60d..94bffe2 100644 --- a/Documentation/virt/kvm/arm/pvtime.rst +++ b/Documentation/virt/kvm/arm/pvtime.rst @@ -3,7 +3,7 @@ Paravirtualized time support for arm64 == -Arm specification DEN0057/A defines a standard for paravirtualised time +Arm specification DEN0057/A defines a standard for paravirtualized time support for AArch64 guests: https://developer.arm.com/docs/den0057/a @@ -19,8 +19,8 @@ Two new SMCCC compatible hypercalls are defined: These are only available in the SMC64/HVC64 calling convention as paravirtualized time is not available to 32 bit Arm guests. The existence of -the PV_FEATURES hypercall should be probed using the SMCCC 1.1 ARCH_FEATURES -mechanism before calling it. +the PV_TIME_FEATURES hypercall should be probed using the SMCCC 1.1 +ARCH_FEATURES mechanism before calling it. PV_TIME_FEATURES = == -- 1.8.3.1
Re: [PATCH] ata: ahci: use ata_link_info() instead of ata_link_printk()
On 8/16/20 8:29 PM, Xu Wang wrote: > Using ata_link_info() instead of ata_link_printk(). Applied, thanks. -- Jens Axboe
[PATCH 0/7] R4000 clock enhancements for Loongson
Jiaxun Yang (7): MIPS: sync-r4k: Rework to be many cores firendly MIPS: time: Use CPUHUP to handle r4k timer MIPS: Kconfig: Always select SYNC_R4K if both SMP and r4k timer is enabled MIPS: Loongson64: Remove custom count sync procudure MIPS: cevt-r4k: Don't handle IRQ if clockevent is not enabled MIPS: cevt-r4k: Enable intimer for Loongson CPUs with extimer MIPS: KVM: Don't use htimer when INTIMER is disabled arch/mips/Kconfig| 10 +- arch/mips/include/asm/cpu-features.h | 4 + arch/mips/include/asm/cpu.h | 1 + arch/mips/include/asm/r4k-timer.h| 5 - arch/mips/include/asm/smp.h | 1 - arch/mips/include/asm/time.h | 28 +++--- arch/mips/kernel/cevt-r4k.c | 65 ++-- arch/mips/kernel/cpu-probe.c | 6 +- arch/mips/kernel/smp.c | 5 - arch/mips/kernel/sync-r4k.c | 143 --- arch/mips/kernel/time.c | 22 - arch/mips/kvm/vz.c | 6 ++ arch/mips/loongson64/smp.c | 32 +- include/linux/cpuhotplug.h | 1 + 14 files changed, 173 insertions(+), 156 deletions(-) -- 2.28.0.rc1
[PATCH 2/7] MIPS: time: Use CPUHUP to handle r4k timer
There is no need to hijack initialization procudre to take care of r4k timer we have CPUHP framework to deal with the CPU plug sequence. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/time.h | 28 +++- arch/mips/kernel/cevt-r4k.c | 30 ++ arch/mips/kernel/smp.c | 3 --- arch/mips/kernel/time.c | 22 -- include/linux/cpuhotplug.h | 1 + 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h index e855a3611d92..d00a5b05a420 100644 --- a/arch/mips/include/asm/time.h +++ b/arch/mips/include/asm/time.h @@ -39,30 +39,32 @@ extern int __weak get_c0_perfcount_int(void); * Initialize the calling CPU's compare interrupt as clockevent device */ extern unsigned int get_c0_compare_int(void); -extern int r4k_clockevent_init(void); -static inline int mips_clockevent_init(void) -{ #ifdef CONFIG_CEVT_R4K - return r4k_clockevent_init(); +extern int r4k_clockevent_init(void); +extern int r4k_clockevent_percpu_init(int cpu); #else - return -ENXIO; -#endif +static inline int r4k_clockevent_init(void) +{ + return -ENODEV; +} +static inline int r4k_clockevent_percpu_init(int cpu) +{ + return -ENODEV; } +#endif /* * Initialize the count register as a clocksource */ -extern int init_r4k_clocksource(void); - -static inline int init_mips_clocksource(void) -{ #ifdef CONFIG_CSRC_R4K - return init_r4k_clocksource(); +extern int init_r4k_clocksource(void); #else - return 0; -#endif +static inline int init_r4k_clocksource(void) +{ + return -ENODEV; } +#endif static inline void clockevent_set_clock(struct clock_event_device *cd, unsigned int clock) diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index 995ad9e69ded..f0c52d751d0a 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c @@ -294,10 +294,8 @@ core_initcall(r4k_register_cpufreq_notifier); #endif /* !CONFIG_CPU_FREQ */ -int r4k_clockevent_init(void) +int r4k_clockevent_percpu_init(int cpu) { - unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED; - unsigned int cpu = smp_processor_id(); struct clock_event_device *cd; unsigned int irq, min_delta; @@ -307,11 +305,6 @@ int r4k_clockevent_init(void) if (!c0_compare_int_usable()) return -ENXIO; - /* -* With vectored interrupts things are getting platform specific. -* get_c0_compare_int is a hook to allow a platform to return the -* interrupt number of its liking. -*/ irq = get_c0_compare_int(); cd = &per_cpu(mips_clockevent_device, cpu); @@ -331,9 +324,30 @@ int r4k_clockevent_init(void) clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fff); + return 0; +} + +int r4k_clockevent_init(void) +{ + int ret; + unsigned int irq; + unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED; + + ret = r4k_clockevent_percpu_init(0); + if (ret) + return ret; + + if (cp0_timer_irq_installed) return 0; + /* +* With vectored interrupts things are getting platform specific. +* get_c0_compare_int is a hook to allow a platform to return the +* interrupt number of its liking. +*/ + irq = get_c0_compare_int(); + cp0_timer_irq_installed = 1; if (request_irq(irq, c0_compare_interrupt, flags, "timer", diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index ead9ac883241..0ca4f7cf6402 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -337,7 +337,6 @@ asmlinkage void start_secondary(void) cpu_probe(); per_cpu_trap_init(false); - mips_clockevent_init(); mp_ops->init_secondary(); cpu_report(); maar_init(); @@ -358,8 +357,6 @@ asmlinkage void start_secondary(void) /* Notify boot CPU that we're starting & ready to sync counters */ complete(&cpu_starting); - synchronise_count_slave(cpu); - /* The CPU is running and counters synchronised, now mark it online */ set_cpu_online(cpu, true); diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c index caa01457dce6..9b16e60aaa30 100644 --- a/arch/mips/kernel/time.c +++ b/arch/mips/kernel/time.c @@ -8,6 +8,7 @@ */ #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #ifdef CONFIG_CPU_FREQ @@ -155,6 +157,16 @@ static __init int cpu_has_mfc0_count_bug(void) return 0; } +#if defined(CONFIG_CEVT_R4K) || defined(CONFIG_CSRC_R4K) +static int mips_r4k_timer_starting_cpu(unsigned int cpu) +{ + synchronise_count_slave(cpu); + r4k_clockevent_percpu_init(cpu); + + return 0; +} +#endif
[PATCH 3/7] MIPS: Kconfig: Always select SYNC_R4K if both SMP and r4k timer is enabled
Now all platforms are sharing sync-r4k procdure, there is no need to let platform to select it. Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 880680c0df31..7674f4379d39 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -234,7 +234,6 @@ config BMIPS_GENERIC select USE_OF select CEVT_R4K select CSRC_R4K - select SYNC_R4K select COMMON_CLK select BCM6345_L1_IRQ select BCM7038_L1_IRQ @@ -291,7 +290,6 @@ config BCM63XX select BOOT_RAW select CEVT_R4K select CSRC_R4K - select SYNC_R4K select DMA_NONCOHERENT select IRQ_MIPS_CPU select SYS_SUPPORTS_32BIT_KERNEL @@ -726,7 +724,6 @@ config SGI_IP30 select BOOT_ELF64 select CEVT_R4K select CSRC_R4K - select SYNC_R4K if SMP select ZONE_DMA32 select HAVE_PCI select IRQ_MIPS_CPU @@ -979,7 +976,6 @@ config NLM_XLR_BOARD select CSRC_R4K select IRQ_MIPS_CPU select ZONE_DMA32 if 64BIT - select SYNC_R4K select SYS_HAS_EARLY_PRINTK select SYS_SUPPORTS_ZBOOT select SYS_SUPPORTS_ZBOOT_UART16550 @@ -1006,7 +1002,6 @@ config NLM_XLP_BOARD select CSRC_R4K select IRQ_MIPS_CPU select ZONE_DMA32 if 64BIT - select SYNC_R4K select SYS_HAS_EARLY_PRINTK select USE_OF select SYS_SUPPORTS_ZBOOT @@ -1076,6 +1071,7 @@ config CEVT_GT641XX bool config CEVT_R4K + select SYNC_R4K if SMP bool config CEVT_SB1250 @@ -1091,6 +1087,7 @@ config CSRC_IOASIC bool config CSRC_R4K + select SYNC_R4K if SMP select CLOCKSOURCE_WATCHDOG if CPU_FREQ bool @@ -2361,7 +2358,6 @@ config MIPS_MT_SMP depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS select CPU_MIPSR2_IRQ_VI select CPU_MIPSR2_IRQ_EI - select SYNC_R4K select MIPS_MT select SMP select SMP_UP @@ -2465,7 +2461,6 @@ config MIPS_CMP bool "MIPS CMP framework support (DEPRECATED)" depends on SYS_SUPPORTS_MIPS_CMP && !CPU_MIPSR6 select SMP - select SYNC_R4K select SYS_SUPPORTS_SMP select WEAK_ORDERING default n @@ -2483,7 +2478,6 @@ config MIPS_CPS select MIPS_CM select MIPS_CPS_PM if HOTPLUG_CPU select SMP - select SYNC_R4K if (CEVT_R4K || CSRC_R4K) select SYS_SUPPORTS_HOTPLUG_CPU select SYS_SUPPORTS_SCHED_SMT if CPU_MIPSR6 select SYS_SUPPORTS_SMP -- 2.28.0.rc1
[PATCH 4/7] MIPS: Loongson64: Remove custom count sync procudure
Now we have hotplug aware reliable sync-r4k, we can simply use that instead of our IPI based implementation. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/smp.h | 1 - arch/mips/loongson64/smp.c | 32 ++-- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index 5d9ff61004ca..2300cc0bba34 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -52,7 +52,6 @@ extern int __cpu_logical_map[NR_CPUS]; #define SMP_CALL_FUNCTION 0x2 /* Octeon - Tell another core to flush its icache */ #define SMP_ICACHE_FLUSH 0x4 -#define SMP_ASK_C0COUNT0x8 /* Mask of CPUs which are currently definitely operating coherently */ extern cpumask_t cpu_coherent_mask; diff --git a/arch/mips/loongson64/smp.c b/arch/mips/loongson64/smp.c index e744e1bee49e..d6a3a7c3d1b2 100644 --- a/arch/mips/loongson64/smp.c +++ b/arch/mips/loongson64/smp.c @@ -32,7 +32,6 @@ static void *ipi_clear0_regs[16]; static void *ipi_status0_regs[16]; static void *ipi_en0_regs[16]; static void *ipi_mailbox_buf[16]; -static uint32_t core0_c0count[NR_CPUS]; /* read a 32bit value from ipi register */ #define loongson3_ipi_read32(addr) readl(addr) @@ -307,8 +306,8 @@ loongson3_send_ipi_mask(const struct cpumask *mask, unsigned int action) static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id) { - int i, cpu = smp_processor_id(); - unsigned int action, c0count; + int cpu = smp_processor_id(); + unsigned int action; action = ipi_read_clear(cpu); @@ -321,15 +320,6 @@ static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id) irq_exit(); } - if (action & SMP_ASK_C0COUNT) { - BUG_ON(cpu != 0); - c0count = read_c0_count(); - c0count = c0count ? c0count : 1; - for (i = 1; i < nr_cpu_ids; i++) - core0_c0count[i] = c0count; - __wbflush(); /* Let others see the result ASAP */ - } - return IRQ_HANDLED; } @@ -340,7 +330,6 @@ static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id) static void loongson3_init_secondary(void) { int i; - uint32_t initcount; unsigned int cpu = smp_processor_id(); unsigned int imask = STATUSF_IP7 | STATUSF_IP6 | STATUSF_IP3 | STATUSF_IP2; @@ -356,23 +345,6 @@ static void loongson3_init_secondary(void) cpu_logical_map(cpu) % loongson_sysconf.cores_per_package); cpu_data[cpu].package = cpu_logical_map(cpu) / loongson_sysconf.cores_per_package; - - i = 0; - core0_c0count[cpu] = 0; - loongson3_send_ipi_single(0, SMP_ASK_C0COUNT); - while (!core0_c0count[cpu]) { - i++; - cpu_relax(); - } - - if (i > MAX_LOOPS) - i = MAX_LOOPS; - if (cpu_data[cpu].package) - initcount = core0_c0count[cpu] + i; - else /* Local access is faster for loops */ - initcount = core0_c0count[cpu] + i/2; - - write_c0_count(initcount); } static void loongson3_smp_finish(void) -- 2.28.0.rc1
[PATCH 1/7] MIPS: sync-r4k: Rework to be many cores firendly
The original sync-r4k did a good job on reducing jitter by determine the "next time value", but it has a limitation that when we have lots of cores, the timewrap on CPU0 will become unaccpetable. That will also happen when CPU Hotplug is enabled and the counter needs to be synchronised at every plug event. Here we reworked the whole procdure. Now the synchronise event on CPU0 is triggered by smp call function, and we won't touch the count on CPU0 at all. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/r4k-timer.h | 5 -- arch/mips/kernel/smp.c| 2 - arch/mips/kernel/sync-r4k.c | 143 +- 3 files changed, 61 insertions(+), 89 deletions(-) diff --git a/arch/mips/include/asm/r4k-timer.h b/arch/mips/include/asm/r4k-timer.h index afe9e0e03fe9..2789d2fc5e23 100644 --- a/arch/mips/include/asm/r4k-timer.h +++ b/arch/mips/include/asm/r4k-timer.h @@ -12,15 +12,10 @@ #ifdef CONFIG_SYNC_R4K -extern void synchronise_count_master(int cpu); extern void synchronise_count_slave(int cpu); #else -static inline void synchronise_count_master(int cpu) -{ -} - static inline void synchronise_count_slave(int cpu) { } diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 48d84d5fcc36..ead9ac883241 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -444,8 +444,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle) return -EIO; } - synchronise_count_master(cpu); - /* Wait for CPU to finish startup & mark itself online before return */ wait_for_completion(&cpu_running); return 0; diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c index abdd7aaa3311..c3e36d6d57fa 100644 --- a/arch/mips/kernel/sync-r4k.c +++ b/arch/mips/kernel/sync-r4k.c @@ -1,122 +1,101 @@ // SPDX-License-Identifier: GPL-2.0 /* * Count register synchronisation. - * - * All CPUs will have their count registers synchronised to the CPU0 next time - * value. This can cause a small timewarp for CPU0. All other CPU's should - * not have done anything significant (but they may have had interrupts - * enabled briefly - prom_smp_finish() should not be responsible for enabling - * interrupts...) */ #include #include #include +#include +#include #include #include #include #include -static unsigned int initcount = 0; -static atomic_t count_count_start = ATOMIC_INIT(0); -static atomic_t count_count_stop = ATOMIC_INIT(0); +#define STAGE_START0 +#define STAGE_MASTER_READY 1 +#define STAGE_SLAVE_SYNCED 2 -#define COUNTON 100 -#define NR_LOOPS 3 +static unsigned int cur_count; +static unsigned int fini_count; +static atomic_t sync_stage = ATOMIC_INIT(0); +static DEFINE_RAW_SPINLOCK(sync_r4k_lock); -void synchronise_count_master(int cpu) +#define MAX_LOOPS 1000 + +void synchronise_count_master(void *unused) { - int i; unsigned long flags; + long delta; + int i; - pr_info("Synchronize counters for CPU %u: ", cpu); + if (atomic_read(&sync_stage) != STAGE_START) + BUG(); local_irq_save(flags); - /* -* We loop a few times to get a primed instruction cache, -* then the last pass is more or less synchronised and -* the master and slaves each set their cycle counters to a known -* value all at once. This reduces the chance of having random offsets -* between the processors, and guarantees that the maximum -* delay between the cycle counters is never bigger than -* the latency of information-passing (cachelines) between -* two CPUs. -*/ - - for (i = 0; i < NR_LOOPS; i++) { - /* slaves loop on '!= 2' */ - while (atomic_read(&count_count_start) != 1) - mb(); - atomic_set(&count_count_stop, 0); - smp_wmb(); + cur_count = read_c0_count(); + smp_wmb(); + atomic_inc(&sync_stage); /* inc to STAGE_MASTER_READY */ - /* Let the slave writes its count register */ - atomic_inc(&count_count_start); - - /* Count will be initialised to current timer */ - if (i == 1) - initcount = read_c0_count(); - - /* -* Everyone initialises count in the last loop: -*/ - if (i == NR_LOOPS-1) - write_c0_count(initcount); - - /* -* Wait for slave to leave the synchronization point: -*/ - while (atomic_read(&count_count_stop) != 1) - mb(); - atomic_set(&count_count_start, 0); + for (i = 0; i < MAX_LOOPS; i++) { + cur_count = read_c0_count(); smp_wmb(); - atomic_inc(&count_count_stop); + if (atomic_read(&sync_stage) == STAGE_SLAV
[PATCH 5/7] MIPS: cevt-r4k: Don't handle IRQ if clockevent is not enabled
Some platforms may have shared Cause.TI, bailing out in IRQ handler when clock event is not enabled can give another clock device a chance. Signed-off-by: Jiaxun Yang --- arch/mips/kernel/cevt-r4k.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index f0c52d751d0a..d396b1011fee 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c @@ -142,6 +142,15 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id) if (handle_perf_irq(r2)) return IRQ_HANDLED; + cd = &per_cpu(mips_clockevent_device, cpu); + /* +* If the clockevent have not enabled, then no need to check the rest. +* Some platforms may have shared Cause.TI, bailing out here can +* give another clock device a chance. +*/ + if (clockevent_state_detached(cd) || clockevent_state_shutdown(cd)) + return IRQ_NONE; + /* * The same applies to performance counter interrupts. But with the * above we now know that the reason we got here must be a timer @@ -150,7 +159,6 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id) if (!r2 || (read_c0_cause() & CAUSEF_TI)) { /* Clear Count/Compare Interrupt */ write_c0_compare(read_c0_compare()); - cd = &per_cpu(mips_clockevent_device, cpu); cd->event_handler(cd); return IRQ_HANDLED; -- 2.28.0.rc1
[PATCH 7/7] MIPS: KVM: Don't use htimer when INTIMER is disabled
When INTIMER is disabled by host, the GT compare interrupt will be ignored. Signed-off-by: Jiaxun Yang --- arch/mips/kvm/vz.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c index 9d03bd0a604a..1d2140f7461a 100644 --- a/arch/mips/kvm/vz.c +++ b/arch/mips/kvm/vz.c @@ -341,6 +341,12 @@ static bool kvm_vz_should_use_htimer(struct kvm_vcpu *vcpu) if (kvm_mips_count_disabled(vcpu)) return false; + if (cpu_has_extimer) { + /* Guest htimer compare interrupt will be ignored if INTIMER is disabled */ + if (!(read_c0_config6() & LOONGSON_CONF6_INTIMER)) + return false; + } + /* Chosen frequency must match real frequency */ if (mips_hpt_frequency != vcpu->arch.count_hz) return false; -- 2.28.0.rc1
[PATCH 6/7] MIPS: cevt-r4k: Enable intimer for Loongson CPUs with extimer
Loongson64C and Loongson64G have extimer feature, which is sharing Cause.TI with intimer (which is cevt-r4k). To ensure the cevt-r4k's usability, we need to add a callback for clock device to ensure intimer is enabled when cevt-r4k is enabled. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/cpu-features.h | 4 arch/mips/include/asm/cpu.h | 1 + arch/mips/kernel/cevt-r4k.c | 25 + arch/mips/kernel/cpu-probe.c | 6 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 78cf7e300f12..aec458eee2a5 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -576,6 +576,10 @@ # define cpu_has_gsexcex __opt(MIPS_CPU_GSEXCEX) #endif +#ifndef cpu_has_extimer +# define cpu_has_extimer __opt(MIPS_CPU_EXTIMER) +#endif + #ifdef CONFIG_SMP /* * Some systems share FTLB RAMs between threads within a core (siblings in diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h index 388a82f28a87..854e1b44254b 100644 --- a/arch/mips/include/asm/cpu.h +++ b/arch/mips/include/asm/cpu.h @@ -429,6 +429,7 @@ enum cpu_type_enum { #define MIPS_CPU_MAC_2008_ONLY BIT_ULL(60) /* CPU Only support MAC2008 Fused multiply-add instruction */ #define MIPS_CPU_FTLBPAREX BIT_ULL(61) /* CPU has FTLB parity exception */ #define MIPS_CPU_GSEXCEX BIT_ULL(62) /* CPU has GSExc exception */ +#define MIPS_CPU_EXTIMER BIT_ULL(63) /* CPU has External Timer (Loongson) */ /* * CPU ASE encodings diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index d396b1011fee..a6e56e9d4e70 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c @@ -15,6 +15,8 @@ #include #include +#include +#include static int mips_next_event(unsigned long delta, struct clock_event_device *evt) @@ -302,6 +304,24 @@ core_initcall(r4k_register_cpufreq_notifier); #endif /* !CONFIG_CPU_FREQ */ +#ifdef CONFIG_CPU_LOONGSON64 +static int c0_compare_int_enable(struct clock_event_device *cd) +{ + if (cpu_has_extimer) + set_c0_config6(LOONGSON_CONF6_INTIMER); + + return 0; +} + +static int c0_compare_int_disable(struct clock_event_device *cd) +{ + if (cpu_has_extimer) + clear_c0_config6(LOONGSON_CONF6_INTIMER); + + return 0; +} +#endif + int r4k_clockevent_percpu_init(int cpu) { struct clock_event_device *cd; @@ -330,6 +350,11 @@ int r4k_clockevent_percpu_init(int cpu) cd->set_next_event = mips_next_event; cd->event_handler = mips_event_handler; +#ifdef CONFIG_CPU_LOONGSON64 + cd->set_state_oneshot = c0_compare_int_enable; + cd->set_state_shutdown = c0_compare_int_disable; +#endif + clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fff); return 0; diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index e2955f1f6316..f41e8d4f6d84 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -2030,6 +2030,9 @@ static inline void decode_cpucfg(struct cpuinfo_mips *c) if (cfg2 & LOONGSON_CFG2_LEXT2) c->ases |= MIPS_ASE_LOONGSON_EXT2; + if (cfg2 & LOONGSON_CFG2_LLFTP) + c->options |= MIPS_CPU_EXTIMER; + if (cfg2 & LOONGSON_CFG2_LSPW) { c->options |= MIPS_CPU_LDPTE; c->guest.options |= MIPS_CPU_LDPTE; @@ -2088,7 +2091,8 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu) * Also some early Loongson-3A2000 had wrong TLB type in Config * register, we correct it here. */ - c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE; + c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE | + MIPS_CPU_EXTIMER; c->writecombine = _CACHE_UNCACHED_ACCELERATED; c->ases |= (MIPS_ASE_LOONGSON_MMI | MIPS_ASE_LOONGSON_CAM | MIPS_ASE_LOONGSON_EXT | MIPS_ASE_LOONGSON_EXT2); -- 2.28.0.rc1
Re: [PATCH] net: handle the return value of pskb_carve_frag_list() correctly
From: linmiaohe Date: Mon, 17 Aug 2020 02:27:23 + > David Miller wrote: >>> + /* split line is in frag list */ >>> + if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) { >>> + /* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. >>> */ >>> + if (skb_has_frag_list(skb)) >>> + kfree_skb_list(skb_shinfo(skb)->frag_list); >>> + kfree(data); >>> + return -ENOMEM; >> >>On error, the caller is going to kfree_skb(skb) which will take care of the >>frag list. >> > > I'am sorry for my careless. The caller will take care of the frag list and > kfree(data) is enough here. > Many thanks for review, will send v2 soon. Actually, reading this again, what about the skb_clone_fraglist() done a few lines up? Who will release that reference to the fraglist items? Maybe the kfree_skb_list() is necessary after all?
Re: [PATCH v6 2/2] soc: mediatek: add mt6779 devapc driver
Hi Chun-Kuang, On Sat, 2020-08-15 at 11:03 +0800, Chun-Kuang Hu wrote: > Hi, Neal: > > Neal Liu 於 2020年8月13日 週四 上午11:33寫道: > > > > MediaTek bus fabric provides TrustZone security support and data > > protection to prevent slaves from being accessed by unexpected > > masters. > > The security violation is logged and sent to the processor for > > further analysis or countermeasures. > > > > Any occurrence of security violation would raise an interrupt, and > > it will be handled by mtk-devapc driver. The violation > > information is printed in order to find the murderer. > > > > Signed-off-by: Neal Liu > > --- > > [snip] > > > +/* > > + * devapc_violation_irq - the devapc Interrupt Service Routine (ISR) will > > dump > > + *violation information including which master > > violates > > + *access slave. > > + */ > > +static irqreturn_t devapc_violation_irq(int irq_number, > > + struct mtk_devapc_context *ctx) > > +{ > > + /* > > +* Mask slave's irq before clearing vio status. > > +* Must do it to avoid nested interrupt and prevent > > +* unexpected behavior. > > +*/ > > + mask_module_irq(ctx, true); > > I still don't understand why nested interrupt happen. If two CPU > process different devapc interrupt at the same time, mask interrupt > could not prevent these two CPU to sync vio dbg at the same time. As I > know, in ARM CPU, only CPU0 process irq handler, and all devapc > interrupt has the same priority, so why nested interrupt happen? Could > you explain more detail about how nested interrupt happen? If there is another violation happened before previous violation is fully handled, nested interrupt would happen. Let's me take an example: vio A happen enter A ISR ... vio B happen finish A ISRenter B ISR ... finish B ISR We mask all module's irq to avoid nested interrupt. > > > + > > + while (devapc_sync_vio_dbg(ctx)) > > + devapc_extract_vio_dbg(ctx); > > + > > + /* > > +* Ensure that violation info are written > > +* before further operations > > +*/ > > + smp_mb(); > > + > > + clear_vio_status(ctx); > > + mask_module_irq(ctx, false); > > + > > + return IRQ_HANDLED; > > +} > > + > > [snip] > > > + > > +static int mtk_devapc_remove(struct platform_device *pdev) > > +{ > > + struct mtk_devapc_context *ctx = platform_get_drvdata(pdev); > > + > > + stop_devapc(ctx); > > + > > + if (ctx->infra_clk) > > This always true. Does it mean that remove function would be called only if probe function is returned successfully? Is there any chance this function would be called directly? > > Regards, > Chun-Kuang. > > > + clk_disable_unprepare(ctx->infra_clk); > > + > > + return 0; > > +} > > + > > +static struct platform_driver mtk_devapc_driver = { > > + .probe = mtk_devapc_probe, > > + .remove = mtk_devapc_remove, > > + .driver = { > > + .name = KBUILD_MODNAME, > > + .of_match_table = mtk_devapc_dt_match, > > + }, > > +}; > > + > > +module_platform_driver(mtk_devapc_driver); > > + > > +MODULE_DESCRIPTION("Mediatek Device APC Driver"); > > +MODULE_AUTHOR("Neal Liu "); > > +MODULE_LICENSE("GPL"); > > -- > > 1.7.9.5 > > ___ > > Linux-mediatek mailing list > > linux-media...@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-mediatek
[PATCH] arm64: dts: qcom: sc7180: Fix the LLCC base register size
There is only one LLCC logical bank on SC7180 SoC of size 0x5(320KB) not 2MB, so correct the size and fix copy paste mistake from SDM845 which had 4 logical banks. Fixes: 7cee5c742899 ("arm64: dts: qcom: sc7180: Fix node order") Fixes: c831fa26 ("arm64: dts: qcom: sc7180: Add Last level cache controller node") Signed-off-by: Sai Prakash Ranjan --- arch/arm64/boot/dts/qcom/sc7180.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi b/arch/arm64/boot/dts/qcom/sc7180.dtsi index d46b3833e52f..e875f6c3b663 100644 --- a/arch/arm64/boot/dts/qcom/sc7180.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi @@ -2618,7 +2618,7 @@ dc_noc: interconnect@916 { system-cache-controller@920 { compatible = "qcom,sc7180-llcc"; - reg = <0 0x0920 0 0x20>, <0 0x0960 0 0x5>; + reg = <0 0x0920 0 0x5>, <0 0x0960 0 0x5>; reg-names = "llcc_base", "llcc_broadcast_base"; interrupts = ; }; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH RESEND 0/5] Some clean-ups for bio merge
Hi, There are some duplicated code when trying to merge bio from pluged list and software queue, thus this patch set did some clean-ups when merging a bio. Any comments are welcome. Thanks. Baolin Wang (5): block: Move bio merge related functions into blk-merge.c block: Remove redundant blk_mq_sched_allow_merge() validation block: Add a new helper to attempt to merge a bio block: Remove blk_mq_attempt_merge() function block: Remove __blk_mq_sched_bio_merge() helper block/blk-core.c | 156 --- block/blk-merge.c| 168 +++ block/blk-mq-sched.c | 64 ++-- block/blk-mq-sched.h | 13 +--- block/blk.h | 9 +++ 5 files changed, 197 insertions(+), 213 deletions(-) -- 1.8.3.1
[PATCH RESEND 2/5] block: Remove redundant blk_mq_sched_allow_merge() validation
Only software queue and kyber IO scheduler will call blk_mq_bio_list_merge() to merge a bio, and kyber IO scheduler did not implement the ops->allow_merge(). Thus we can remove the redundant blk_mq_sched_allow_merge() in blk_mq_bio_list_merge() function. Signed-off-by: Baolin Wang --- block/blk-mq-sched.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index a19cdf1..bf62b34 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -403,14 +403,10 @@ bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list, switch (blk_try_merge(rq, bio)) { case ELEVATOR_BACK_MERGE: - if (blk_mq_sched_allow_merge(q, rq, bio)) - merged = bio_attempt_back_merge(rq, bio, - nr_segs); + merged = bio_attempt_back_merge(rq, bio, nr_segs); break; case ELEVATOR_FRONT_MERGE: - if (blk_mq_sched_allow_merge(q, rq, bio)) - merged = bio_attempt_front_merge(rq, bio, - nr_segs); + merged = bio_attempt_front_merge(rq, bio, nr_segs); break; case ELEVATOR_DISCARD_MERGE: merged = bio_attempt_discard_merge(q, rq, bio); -- 1.8.3.1
[PATCH RESEND 1/5] block: Move bio merge related functions into blk-merge.c
It's better to move bio merge related functions into blk-merge.c, which contains all merge related functions. Signed-off-by: Baolin Wang --- block/blk-core.c | 156 - block/blk-merge.c | 157 ++ 2 files changed, 157 insertions(+), 156 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d9d6326..ed79109 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -642,162 +642,6 @@ void blk_put_request(struct request *req) } EXPORT_SYMBOL(blk_put_request); -static void blk_account_io_merge_bio(struct request *req) -{ - if (!blk_do_io_stat(req)) - return; - - part_stat_lock(); - part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); - part_stat_unlock(); -} - -bool bio_attempt_back_merge(struct request *req, struct bio *bio, - unsigned int nr_segs) -{ - const int ff = bio->bi_opf & REQ_FAILFAST_MASK; - - if (!ll_back_merge_fn(req, bio, nr_segs)) - return false; - - trace_block_bio_backmerge(req->q, req, bio); - rq_qos_merge(req->q, req, bio); - - if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) - blk_rq_set_mixed_merge(req); - - req->biotail->bi_next = bio; - req->biotail = bio; - req->__data_len += bio->bi_iter.bi_size; - - bio_crypt_free_ctx(bio); - - blk_account_io_merge_bio(req); - return true; -} - -bool bio_attempt_front_merge(struct request *req, struct bio *bio, - unsigned int nr_segs) -{ - const int ff = bio->bi_opf & REQ_FAILFAST_MASK; - - if (!ll_front_merge_fn(req, bio, nr_segs)) - return false; - - trace_block_bio_frontmerge(req->q, req, bio); - rq_qos_merge(req->q, req, bio); - - if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) - blk_rq_set_mixed_merge(req); - - bio->bi_next = req->bio; - req->bio = bio; - - req->__sector = bio->bi_iter.bi_sector; - req->__data_len += bio->bi_iter.bi_size; - - bio_crypt_do_front_merge(req, bio); - - blk_account_io_merge_bio(req); - return true; -} - -bool bio_attempt_discard_merge(struct request_queue *q, struct request *req, - struct bio *bio) -{ - unsigned short segments = blk_rq_nr_discard_segments(req); - - if (segments >= queue_max_discard_segments(q)) - goto no_merge; - if (blk_rq_sectors(req) + bio_sectors(bio) > - blk_rq_get_max_sectors(req, blk_rq_pos(req))) - goto no_merge; - - rq_qos_merge(q, req, bio); - - req->biotail->bi_next = bio; - req->biotail = bio; - req->__data_len += bio->bi_iter.bi_size; - req->nr_phys_segments = segments + 1; - - blk_account_io_merge_bio(req); - return true; -no_merge: - req_set_nomerge(q, req); - return false; -} - -/** - * blk_attempt_plug_merge - try to merge with %current's plugged list - * @q: request_queue new bio is being queued at - * @bio: new bio being queued - * @nr_segs: number of segments in @bio - * @same_queue_rq: pointer to &struct request that gets filled in when - * another request associated with @q is found on the plug list - * (optional, may be %NULL) - * - * Determine whether @bio being queued on @q can be merged with a request - * on %current's plugged list. Returns %true if merge was successful, - * otherwise %false. - * - * Plugging coalesces IOs from the same issuer for the same purpose without - * going through @q->queue_lock. As such it's more of an issuing mechanism - * than scheduling, and the request, while may have elvpriv data, is not - * added on the elevator at this point. In addition, we don't have - * reliable access to the elevator outside queue lock. Only check basic - * merging parameters without querying the elevator. - * - * Caller must ensure !blk_queue_nomerges(q) beforehand. - */ -bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio, - unsigned int nr_segs, struct request **same_queue_rq) -{ - struct blk_plug *plug; - struct request *rq; - struct list_head *plug_list; - - plug = blk_mq_plug(q, bio); - if (!plug) - return false; - - plug_list = &plug->mq_list; - - list_for_each_entry_reverse(rq, plug_list, queuelist) { - bool merged = false; - - if (rq->q == q && same_queue_rq) { - /* -* Only blk-mq multiple hardware queues case checks the -* rq in the same queue, there should be only one such -* rq in a queue -**/ - *same_queue_rq = rq; - } - - if (rq->q != q || !blk_rq_merge_ok(rq, bio)) - continue; - - switch (blk_try_merge(rq, bio)) { - case
[PATCH RESEND 5/5] block: Remove __blk_mq_sched_bio_merge() helper
The blk_mq_sched_bio_merge() just wrap the __blk_mq_sched_bio_merge(), and no other places will use __blk_mq_sched_bio_merge(). Thus we can combine these 2 similar functions into one function. Signed-off-by: Baolin Wang --- block/blk-mq-sched.c | 5 - block/blk-mq-sched.h | 13 ++--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 1cc7919..ba34460 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -408,7 +408,7 @@ bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list, } EXPORT_SYMBOL_GPL(blk_mq_bio_list_merge); -bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, +bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, unsigned int nr_segs) { struct elevator_queue *e = q->elevator; @@ -417,6 +417,9 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, bool ret = false; enum hctx_type type; + if (blk_queue_nomerges(q) || !bio_mergeable(bio)) + return false; + if (e && e->type->ops.bio_merge) return e->type->ops.bio_merge(hctx, bio, nr_segs); diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 126021f..65151de 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -13,8 +13,6 @@ void blk_mq_sched_free_hctx_data(struct request_queue *q, void blk_mq_sched_request_inserted(struct request *rq); bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, unsigned int nr_segs, struct request **merged_request); -bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, - unsigned int nr_segs); bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq); void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx); void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx); @@ -31,15 +29,8 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx, void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e); void blk_mq_sched_free_requests(struct request_queue *q); -static inline bool -blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, - unsigned int nr_segs) -{ - if (blk_queue_nomerges(q) || !bio_mergeable(bio)) - return false; - - return __blk_mq_sched_bio_merge(q, bio, nr_segs); -} +bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, + unsigned int nr_segs); static inline bool blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq, -- 1.8.3.1
[PATCH RESEND 4/5] block: Remove blk_mq_attempt_merge() function
The small blk_mq_attempt_merge() function is only called by __blk_mq_sched_bio_merge(), just open code it. Signed-off-by: Baolin Wang --- block/blk-mq-sched.c | 33 ++--- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 8e9bafe..1cc7919 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -408,28 +408,6 @@ bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list, } EXPORT_SYMBOL_GPL(blk_mq_bio_list_merge); -/* - * Reverse check our software queue for entries that we could potentially - * merge with. Currently includes a hand-wavy stop count of 8, to not spend - * too much time checking for merges. - */ -static bool blk_mq_attempt_merge(struct request_queue *q, -struct blk_mq_hw_ctx *hctx, -struct blk_mq_ctx *ctx, struct bio *bio, -unsigned int nr_segs) -{ - enum hctx_type type = hctx->type; - - lockdep_assert_held(&ctx->lock); - - if (blk_mq_bio_list_merge(q, &ctx->rq_lists[type], bio, nr_segs)) { - ctx->rq_merged++; - return true; - } - - return false; -} - bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, unsigned int nr_segs) { @@ -447,7 +425,16 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio, !list_empty_careful(&ctx->rq_lists[type])) { /* default per sw-queue merge */ spin_lock(&ctx->lock); - ret = blk_mq_attempt_merge(q, hctx, ctx, bio, nr_segs); + /* +* Reverse check our software queue for entries that we could +* potentially merge with. Currently includes a hand-wavy stop +* count of 8, to not spend too much time checking for merges. +*/ + if (blk_mq_bio_list_merge(q, &ctx->rq_lists[type], bio, nr_segs)) { + ctx->rq_merged++; + ret = true; + } + spin_unlock(&ctx->lock); } -- 1.8.3.1
[PATCH RESEND 3/5] block: Add a new helper to attempt to merge a bio
There are lots of duplicated code when trying to merge a bio from plug list and sw queue, we can introduce a new helper to attempt to merge a bio, which can simplify the blk_mq_bio_list_merge() and blk_attempt_plug_merge(). Signed-off-by: Baolin Wang --- block/blk-merge.c| 47 +-- block/blk-mq-sched.c | 22 -- block/blk.h | 9 + 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 3619f2f..a8d1649 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -975,6 +975,33 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req, return false; } +enum bio_merge_status blk_attempt_bio_merge(struct request_queue *q, + struct request *rq, + struct bio *bio, + unsigned int nr_segs) +{ + bool merged = false; + + if (!blk_rq_merge_ok(rq, bio)) + return BIO_MERGE_NONE; + + switch (blk_try_merge(rq, bio)) { + case ELEVATOR_BACK_MERGE: + merged = bio_attempt_back_merge(rq, bio, nr_segs); + break; + case ELEVATOR_FRONT_MERGE: + merged = bio_attempt_front_merge(rq, bio, nr_segs); + break; + case ELEVATOR_DISCARD_MERGE: + merged = bio_attempt_discard_merge(q, rq, bio); + break; + default: + return BIO_MERGE_NONE; + } + + return merged ? BIO_MERGE_OK : BIO_MERGE_FAILED; +} + /** * blk_attempt_plug_merge - try to merge with %current's plugged list * @q: request_queue new bio is being queued at @@ -1011,8 +1038,6 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio, plug_list = &plug->mq_list; list_for_each_entry_reverse(rq, plug_list, queuelist) { - bool merged = false; - if (rq->q == q && same_queue_rq) { /* * Only blk-mq multiple hardware queues case checks the @@ -1022,24 +1047,10 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio, *same_queue_rq = rq; } - if (rq->q != q || !blk_rq_merge_ok(rq, bio)) + if (rq->q != q) continue; - switch (blk_try_merge(rq, bio)) { - case ELEVATOR_BACK_MERGE: - merged = bio_attempt_back_merge(rq, bio, nr_segs); - break; - case ELEVATOR_FRONT_MERGE: - merged = bio_attempt_front_merge(rq, bio, nr_segs); - break; - case ELEVATOR_DISCARD_MERGE: - merged = bio_attempt_discard_merge(q, rq, bio); - break; - default: - break; - } - - if (merged) + if (blk_attempt_bio_merge(q, rq, bio, nr_segs) == BIO_MERGE_OK) return true; } diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index bf62b34..8e9bafe 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -391,31 +391,17 @@ bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list, { struct request *rq; int checked = 8; + enum bio_merge_status merge; list_for_each_entry_reverse(rq, list, queuelist) { - bool merged = false; - if (!checked--) break; - if (!blk_rq_merge_ok(rq, bio)) + merge = blk_attempt_bio_merge(q, rq, bio, nr_segs); + if (merge == BIO_MERGE_NONE) continue; - switch (blk_try_merge(rq, bio)) { - case ELEVATOR_BACK_MERGE: - merged = bio_attempt_back_merge(rq, bio, nr_segs); - break; - case ELEVATOR_FRONT_MERGE: - merged = bio_attempt_front_merge(rq, bio, nr_segs); - break; - case ELEVATOR_DISCARD_MERGE: - merged = bio_attempt_discard_merge(q, rq, bio); - break; - default: - continue; - } - - return merged; + return merge == BIO_MERGE_OK ? true: false; } return false; diff --git a/block/blk.h b/block/blk.h index 49e2928..a6c54e1 100644 --- a/block/blk.h +++ b/block/blk.h @@ -234,6 +234,15 @@ int blk_attempt_req_merge(struct request_queue *q, struct request *rq, bool blk_rq_merge_ok(struct request *rq, struct bio *bio); enum elv_merge blk_try_merge(struct request *rq, struct bio *bio); +enum bio_merge_status { + BIO_MERGE_OK, + BIO_MERGE_NONE, + BIO_MERGE_FAILE
Re: [PATCH] phylink: : fix function prototype kernel-doc warning
From: Randy Dunlap Date: Sun, 16 Aug 2020 15:25:49 -0700 > Fix a kernel-doc warning for the pcs_config() function prototype: > > ../include/linux/phylink.h:406: warning: Excess function parameter > 'permit_pause_to_mac' description in 'pcs_config' > > Fixes: 7137e18f6f88 ("net: phylink: add struct phylink_pcs") > Signed-off-by: Randy Dunlap There's no definition of this function anywhere. Maybe just remove all of this?
Re: [PATCH] Makefile: Yes. Finally remove '-Wdeclaration-after-statement'
On Mon, 2020-08-17 at 03:37 +, Michael Witten wrote: > Matters of style should probably not be enforced by the build > infrastructure; style is a matter for the maintainer to enforce: I rather doubt style advice should be taken from someone who right justifies fixed pitch block text. cheers, Joe
[PATCH] lib: Convert test_printf.c to KUnit
Converts test lib/test_printf.c to KUnit. More information about KUnit can be found at https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html. KUnit provides a common framework for unit tests in the kernel. Signed-off-by: Arpitha Raghunandan <98.a...@gmail.com> --- lib/Kconfig.debug | 7 +- lib/Makefile | 2 +- lib/{test_printf.c => printf_kunit.c} | 498 +- 3 files changed, 246 insertions(+), 261 deletions(-) rename lib/{test_printf.c => printf_kunit.c} (45%) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index e068c3c7189a..7454258cf57a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2027,9 +2027,6 @@ config TEST_STRSCPY config TEST_KSTRTOX tristate "Test kstrto*() family of functions at runtime" -config TEST_PRINTF - tristate "Test printf() family of functions at runtime" - config TEST_BITMAP tristate "Test bitmap_*() family of functions at runtime" help @@ -2247,6 +2244,10 @@ config BITS_TEST If unsure, say N. +config PRINTF_KUNIT_TEST + tristate "KUnit tests for printf() family of functions at runtime" + depends on KUNIT + config TEST_UDELAY tristate "udelay test driver" help diff --git a/lib/Makefile b/lib/Makefile index e290fc5707ea..68e5b32a185f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -77,7 +77,6 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o -obj-$(CONFIG_TEST_PRINTF) += test_printf.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o obj-$(CONFIG_TEST_BITFIELD) += test_bitfield.o @@ -343,3 +342,4 @@ obj-$(CONFIG_PLDMFW) += pldmfw/ obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o obj-$(CONFIG_BITS_TEST) += test_bits.o +obj-$(CONFIG_PRINTF_KUNIT_TEST) += printf_kunit.o diff --git a/lib/test_printf.c b/lib/printf_kunit.c similarity index 45% rename from lib/test_printf.c rename to lib/printf_kunit.c index 7ac87f18a10f..68ac5f9b8d28 100644 --- a/lib/test_printf.c +++ b/lib/printf_kunit.c @@ -5,6 +5,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -30,79 +31,61 @@ #define PAD_SIZE 16 #define FILL_CHAR '$' -static unsigned total_tests __initdata; -static unsigned failed_tests __initdata; -static char *test_buffer __initdata; -static char *alloced_buffer __initdata; +static char *test_buffer; +static char *alloced_buffer; -static int __printf(4, 0) __init -do_test(int bufsize, const char *expect, int elen, +static void __printf(5, 0) +do_test(struct kunit *kunittest, int bufsize, const char *expect, int elen, const char *fmt, va_list ap) { va_list aq; int ret, written; - total_tests++; - memset(alloced_buffer, FILL_CHAR, BUF_SIZE + 2*PAD_SIZE); va_copy(aq, ap); ret = vsnprintf(test_buffer, bufsize, fmt, aq); va_end(aq); - if (ret != elen) { - pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d\n", + KUNIT_EXPECT_EQ_MSG(kunittest, ret, elen, + "vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d\n", bufsize, fmt, ret, elen); - return 1; - } - if (memchr_inv(alloced_buffer, FILL_CHAR, PAD_SIZE)) { - pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote before buffer\n", bufsize, fmt); - return 1; - } + KUNIT_EXPECT_EQ_MSG(kunittest, memchr_inv(alloced_buffer, FILL_CHAR, PAD_SIZE), NULL, + "vsnprintf(buf, %d, \"%s\", ...) wrote before buffer\n", + bufsize, fmt); if (!bufsize) { - if (memchr_inv(test_buffer, FILL_CHAR, BUF_SIZE + PAD_SIZE)) { - pr_warn("vsnprintf(buf, 0, \"%s\", ...) wrote to buffer\n", - fmt); - return 1; - } - return 0; + KUNIT_EXPECT_FALSE_MSG(kunittest, + memchr_inv(test_buffer, FILL_CHAR, BUF_SIZE + PAD_SIZE), + "vsnprintf(buf, 0, \"%s\", ...) wrote to buffer\n", fmt); + return; } written = min(bufsize-1, elen); - if (test_buffer[written]) { - pr_warn("vsnprintf(buf, %d, \"%s\", ...) did not nul-terminate buffer\n", + KUNIT_EXPECT_FALSE_MSG(kunittest, test_buffer[written], + "vsnprintf(buf, %d, \"%s\", ...) did not nul-terminate buffer\n", bufsize, fmt); - return 1; - } - if (memchr_inv(test_buffer + written + 1, FILL_CHAR, BUF_SIZE + PAD_SIZE - (written + 1))) { - pr_warn("vsnprintf(buf, %d, \"%s\", ...)
[PATCH] ALSA: hda/realtek: Add model alc298-samsung-headphone
The very quiet and distorted headphone output bug that afflicted my Samsung Notebook 9 is appearing in many other Samsung laptops. Expose the quirk which fixed my laptop as a model so other users can try it. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207423 Signed-off-by: Mike Pozulp --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 29f5878f0c50..722d01a06422 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -7867,6 +7867,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"}, {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"}, {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"}, + {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"}, {} }; #define ALC225_STANDARD_PINS \ -- 2.28.0
[PATCH v4] kthread: Add debugobject support
From: Qianli Zhao Add debugobject support to track the life time of kthread_work which is used to detect reinitialization/free active object problems Add kthread_init_work_onstack()/kthread_init_delayed_work_onstack() for kthread onstack support If we reinitialize a kthread_work that has been activated, this will cause delayed_work_list/work_list corruption. enable this config,there is an chance to fixup these errors or WARNING the wrong use of kthread_work [30858.395766] list_del corruption. next->prev should be ffe388ebbf88, but was ffe388ebb588 [30858.395788] WARNING: CPU: 2 PID: 387 at /home/work/data/codes/build_home/kernel/msm-4.19/lib/list_debug.c:56 __list_del_entry_valid+0xc8/0xd0 ... [30858.395906] Call trace: [30858.395909] __list_del_entry_valid+0xc8/0xd0 [30858.395912] __kthread_cancel_work_sync+0x98/0x138 [30858.395915] kthread_cancel_delayed_work_sync+0x10/0x20 [30858.395917] sde_encoder_resource_control+0xe8/0x12c0 [30858.395920] sde_encoder_prepare_for_kickoff+0x5dc/0x2008 [30858.395923] sde_crtc_commit_kickoff+0x280/0x890 [30858.395925] sde_kms_commit+0x16c/0x278 [30858.395928] complete_commit+0x3c4/0x760 [30858.395931] _msm_drm_commit_work_cb+0xec/0x1e0 [30858.395933] kthread_worker_fn+0xf8/0x190 [30858.395935] kthread+0x118/0x128 [30858.395938] ret_from_fork+0x10/0x18 crash> struct kthread_worker.delayed_work_list 0xffe3893925f0 [ffe389392620] delayed_work_list = { next = 0xffe388ebbf88, prev = 0xffe388ebb588 } crash> list 0xffe388ebbf88 ffe388ebbf88 Signed-off-by: Qianli Zhao --- V4: - Changelog update - Add comment for KWORK_ENTRY_STATIC - Code format modification - Check worker availability early in kthread_flush_work V3: - changelog update - add fixup_assert_init support - move debug_kwork_activate/debug_kwork_deactivate before list operation - name the kconfig CONFIG_DEBUG_OBJECTS_KTHREAD_WORK - use kthread_init_work_onstack/destroy_kwork_on_stack when kthread_work used on stack - __init_kwork before clear kthread_work in kthread_init_work --- include/linux/kthread.h | 30 ++- include/linux/poison.h | 4 ++ kernel/kthread.c| 135 ++-- lib/Kconfig.debug | 10 4 files changed, 173 insertions(+), 6 deletions(-) diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 65b81e0..706302b 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h @@ -108,6 +108,17 @@ struct kthread_delayed_work { struct timer_list timer; }; +#ifdef CONFIG_DEBUG_OBJECTS_KTHREAD_WORK +extern void __init_kwork(struct kthread_work *kwork, int onstack); +extern void destroy_kwork_on_stack(struct kthread_work *kwork); +extern void destroy_delayed_kwork_on_stack(struct kthread_delayed_work *kdwork); +#else +static inline void __init_kwork(struct kthread_work *kwork, int onstack) { } +static inline void destroy_kwork_on_stack(struct kthread_work *kwork) { } +static inline void destroy_delayed_kwork_on_stack(struct kthread_delayed_work *kdwork) { } +#endif + + #define KTHREAD_WORKER_INIT(worker){ \ .lock = __RAW_SPIN_LOCK_UNLOCKED((worker).lock),\ .work_list = LIST_HEAD_INIT((worker).work_list),\ @@ -115,7 +126,7 @@ struct kthread_delayed_work { } #define KTHREAD_WORK_INIT(work, fn){ \ - .node = LIST_HEAD_INIT((work).node),\ + .node = { .next = KWORK_ENTRY_STATIC }, \ .func = (fn), \ } @@ -159,6 +170,15 @@ extern void __kthread_init_worker(struct kthread_worker *worker, #define kthread_init_work(work, fn)\ do {\ + __init_kwork(work, 0); \ + memset((work), 0, sizeof(struct kthread_work)); \ + INIT_LIST_HEAD(&(work)->node); \ + (work)->func = (fn);\ + } while (0) + +#define kthread_init_work_onstack(work, fn) \ + do {\ + __init_kwork(work, 1); \ memset((work), 0, sizeof(struct kthread_work)); \ INIT_LIST_HEAD(&(work)->node); \ (work)->func = (fn);\ @@ -172,6 +192,14 @@ extern void __kthread_init_worker(struct kthread_worker *worker, TIMER_IRQSAFE);\ } while (0) +#define kthread_init_delayed_work_onstack(dwork, fn) \ + do {
Re: [PATCH] dmaengine: acpi: Put the CSRT table after using it
On 22-07-20, 17:54, Hanjun Guo wrote: > The acpi_get_table() should be coupled with acpi_put_table() if > the mapped table is not used at runtime to release the table > mapping, put the CSRT table buf after using it. Applied, thanks -- ~Vinod
Re: [PATCH v1] dmaengine: pch_dma: use generic power management
On 27-07-20, 14:19, Andy Shevchenko wrote: > On Mon, Jul 27, 2020 at 1:16 PM Vinod Koul wrote: > > On 20-07-20, 17:07, Vaibhav Gupta wrote: > > > Drivers using legacy PM have to manage PCI states and device's PM states > > > themselves. They also need to take care of configuration registers. > > > > > > With improved and powerful support of generic PM, PCI Core takes care of > > > above mentioned, device-independent, jobs. > > > > > > This driver makes use of PCI helper functions like > > > pci_save/restore_state(), pci_enable/disable_device(), > > > and pci_set_power_state() to do required operations. In generic mode, they > > > are no longer needed. > > > > > > Change function parameter in both .suspend() and .resume() to > > > "struct device*" type. Use dev_get_drvdata() to get drv data. > > > > You are doing too many things in One patch. Do consider splitting them > > up to a change per patch. for example using __maybe could be one patch, > > removing code is suspend-resume callbacks would be other one. > > Vinod, while I completely agree with you in general, in this case it > would make more unnecessary churn and will be rather unhelpful in all > ways: for the contributor to do this work, for the reader to collect > all the pieces. It also will be a bisectability issue, because the > #ifdeffery replacement (IIRC you need to move from CONFIG_PM to > CONFIG_PM_SLEEP). I really don't see any advantages of the splitting > here. > > > > Compile-tested only. > > > > I would like to see some testing before we merge this > > I have hardware to test (Intel Minnowboard v1) but have no time. And > taking into account that I did similar changes for many other drivers, > I can give my > Reviewed-by: Andy Shevchenko > and take responsibility if somebody complains in the future (I don't > believe it will be one). > > P.S. Another scenario if Vaibhav can find that board (there were > dozens of thousands at least produced and floating on the second hand > market) and test himself. It may be good since he touches the full lot > of PCH (EGT20) drivers. Applied now, thanks -- ~Vinod
Re: [PATCH] upcall: Remove unneeded variable insize
Hi Xu, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.9-rc1 next-20200814] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Xu-Wang/upcall-Remove-unneeded-variable-insize/20200817-112244 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5 config: xtensa-allyesconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): fs/coda/upcall.c: In function 'venus_setattr': fs/coda/upcall.c:115:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 115 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_close': fs/coda/upcall.c:164:20: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 164 | union outputArgs *outp; |^~~~ fs/coda/upcall.c: In function 'venus_rename': fs/coda/upcall.c:238:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 238 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_rmdir': fs/coda/upcall.c:306:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 306 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_remove': fs/coda/upcall.c:329:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 329 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_link': fs/coda/upcall.c:383:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 383 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_symlink': fs/coda/upcall.c:410:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 410 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_fsync': fs/coda/upcall.c:443:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 443 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_access': fs/coda/upcall.c:459:27: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 459 | union outputArgs *outp; | ^~~~ fs/coda/upcall.c: In function 'venus_pioctl': >> fs/coda/upcall.c:63:44: error: 'insize' undeclared (first use in this >> function); did you mean 'iocsize'? 63 | inp = (union inputArgs *)alloc_upcall(op, insize); \ |^~ fs/coda/upcall.c:483:2: note: in expansion of macro 'UPARG' 483 | UPARG(CODA_IOCTL); | ^ fs/coda/upcall.c:63:44: note: each undeclared identifier is reported only once for each function it appears in 63 | inp = (union inputArgs *)alloc_upcall(op, insize); \ |^~ fs/coda/upcall.c:483:2: note: in expansion of macro 'UPARG' 483 | UPARG(CODA_IOCTL); | ^ fs/coda/upcall.c: In function 'venus_access_intent': fs/coda/upcall.c:576:20: warning: variable 'outp' set but not used [-Wunused-but-set-variable] 576 | union outputArgs *outp; |^~~~ # https://github.com/0day-ci/linux/commit/e126bb2bc1e15e86a4267e92df88f4987d01b358 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Xu-Wang/upcall-Remove-unneeded-variable-insize/20200817-112244 git checkout e126bb2bc1e15e86a4267e92df88f4987d01b358 vim +63 fs/coda/upcall.c ^1da177e4c3f41 Linus Torvalds 2005-04-16 60 ^1da177e4c3f41 Linus Torvalds 2005-04-16 61 #define UPARG(op)\ ^1da177e4c3f41 Linus Torvalds 2005-04-16 62 do {\ ^1da177e4c3f41 Linus Torvalds 2005-04-16 @63inp = (union inputArgs *)alloc_upcall(op, insize); \ ^1da177e4c3f41 Linus Torvalds 2005-04-16 64 if (IS_ERR(inp)) { return PTR_ERR(inp); }\ ^1da177e4c3f41 Linus Torvalds 2005-04-16 65 outp = (union outputArgs *)(inp); \ ^1da177e4c3f41 Linus Torvalds 2005-04-16 66 ou
Re: [PATCH 2/4] opp: Track device's resources configuration status
On 15-08-20, 01:03, Stephen Boyd wrote: > Quoting Viresh Kumar (2020-08-12 21:28:59) > > The OPP core needs to track if the resources of devices are enabled or > > configured or not, as it disables the resources when target_freq is set > > to 0. > > > > Handle that with a separate variable to make it easy to maintain. > > > > Also note that we will unconditionally call clk_set_rate() in the case > > where the resources are getting enabled again. This shouldn't have any > > side effects anyway. > > Any reason to want to do that? To avoid more flags, code paths and simplicity of the code. And this should normally happen in a corner case as well, like calling set-rate(0) from suspend and then reinitializing things again in resume. > We'll have to grab the prepare lock in > the clk framework to figure out that there's nothing to do sometimes. If > anything, a comment may help to indicate that we call clk_set_rate() > again, but don't expect it to matter much. Ok. -- viresh
Re: [RFC 0/5] Introduce NMI aware serial drivers
On Fri, 14 Aug 2020 at 19:48, Daniel Thompson wrote: > > On Fri, Aug 14, 2020 at 05:36:36PM +0530, Sumit Garg wrote: > > On Thu, 13 Aug 2020 at 15:47, Daniel Thompson > > wrote: > > > > > > On Thu, Aug 13, 2020 at 02:55:12PM +0530, Sumit Garg wrote: > > > > On Thu, 13 Aug 2020 at 05:38, Doug Anderson > > > > wrote: > > > > > On Wed, Aug 12, 2020 at 8:27 AM Doug Anderson > > > > > wrote: > > > > > > One > > > > > > last worry is that I assume that most people testing (and even > > > > > > automated testing labs) will either always enable NMI or won't > > > > > > enable > > > > > > NMI. That means that everyone will be only testing one codepath or > > > > > > the other and (given the complexity) the non-tested codepath will > > > > > > break. > > > > > > > > > > > > > > The current patch-set only makes this NMI to work when debugger (kgdb) > > > > is enabled which I think is mostly suitable for development > > > > environments. So most people testing will involve existing IRQ mode > > > > only. > > > > > > > > However, it's very much possible to make NMI mode as default for a > > > > particular serial driver if the underlying irqchip supports it but it > > > > depends if we really see any production level usage of NMI debug > > > > feature. > > > > > > The effect of this patch is not to make kgdb work from NMI it is to make > > > (some) SysRqs work from NMI. I think that only allowing it to deploy for > > > kgdb users is a mistake. > > > > > > Having it deploy automatically for kgdb users might be OK but it seems > > > sensible to make this feature available for other users too. > > > > I think I wasn't clear enough in my prior reply. Actually I meant to > > say that this patch-set enables NMI support for a particular serial > > driver via ".poll_init()" interface and the only current user of that > > interface is kgdb. > > > > So if there are other users interested in this feature, they can use > > ".poll_init()" interface as well to enable it. > > Huh? > > We appear to speaking interchangably about users (people who sit in > front of the machine and want a stack trace) and sub-systems ;-). > > I don't think other SysRq commands have quite such a direct relationship > between the sub-system and the sysrq command. For example who are you > expecting to call .poll_init() if a user wants to use the SysRq to > provoke a stack trace? > Ah, I see. So you meant to provide a user-space interface to dynamically enable/disable NMI debug, correct? It will require IRQ <-> NMI switching at runtime which should be doable safely. -Sumit > > Daniel.
Re: [PATCH] dmaengine: ti: omap-dma: Drop of_match_ptr to fix -Wunused-const-variable
On 28-07-20, 19:09, Krzysztof Kozlowski wrote: > The of_device_id is included unconditionally by of.h header and used > in the driver as well. Remove of_match_ptr to fix W=1 compile test > warning with !CONFIG_OF: > > drivers/dma/ti/omap-dma.c:1892:34: warning: 'omap_dma_match' defined but > not used [-Wunused-const-variable=] > 1892 | static const struct of_device_id omap_dma_match[] = { Applied, thanks -- ~Vinod
Re: [PATCH] dmaengine: at_hdmac: do exception handling appropriately in at_dma_xlate()
On 29-07-20, 20:29, Yu Kuai wrote: > Do several things for exception handing: > > a. check return value of of_find_device_by_node(). > b. call put_device() if memory allocation for 'atslave' failed. > c. if dma_request_channel() failed, call put_device() and kfree(). One patch per change please -- ~Vinod
Re: [PATCH V2] dmaengine: bcm-sba-raid: add missing put_device() call in sba_probe()
On 29-07-20, 20:49, Yu Kuai wrote: > if of_find_device_by_node() succeed, sba_probe() doesn't have a > corresponding put_device(). Thus add a jump target to fix the > exception handling for this function implementation. Applied, thanks -- ~Vinod
Re: [PATCH v2 0/2] dmaengine: ti: k3-psil: Add support for j7200
On 03-08-20, 15:57, Peter Ujfalusi wrote: > Hi, > > Changes since v1: > - Drop unrelated empty line change in patch 1 (k3-psil.c) > > j7200 uses the same DMA hardware but have different set of peripherals, > needing > different PSI-L thread map compared to j721e. > > To simplify the runtime PSI-L map selection we will switch to use > soc_device_match. Applied, thanks -- ~Vinod
Re: [PATCH v4 1/2] ASoC: mediatek: mt6359: add codec driver
On Sun, Aug 16, 2020 at 1:20 AM Jiaxin Yu wrote: > > +static int mt6359_platform_driver_probe(struct platform_device *pdev) [snip] > + > + return devm_snd_soc_register_component(&pdev->dev, > + &mt6359_soc_component_driver, > + mt6359_dai_driver, > + ARRAY_SIZE(mt6359_dai_driver)); > +} > + > +static int mt6359_platform_driver_remove(struct platform_device *pdev) > +{ > + struct mt6359_priv *priv = dev_get_drvdata(&pdev->dev); > + int ret; > + > + dev_dbg(&pdev->dev, "%s(), dev name %s\n", > + __func__, dev_name(&pdev->dev)); > + > + ret = regulator_disable(priv->avdd_reg); > + if (ret) { > + dev_err(&pdev->dev, "%s(), failed to disable regulator!\n", > + __func__); > + return ret; > + } > + > + snd_soc_unregister_component(&pdev->dev); You don't need to unregister the component which is already delegated to devm.
[PATCH V3 2/3] x86/entry: directly switch to kernel stack when .Lerror_bad_iret
From: Lai Jiangshan Directly copy pt_regs to kernel stack when .Lerror_bad_iret. Directly switch to kernel stack when .Lerror_bad_iret. We can see that entry_64.S do the following things back to back when .Lerror_bad_iret: call fixup_bad_iret(), switch to sp0 stack with pt_regs copied call sync_regs(), switch to kernel stack with pt_regs copied So we can do the all things together in fixup_bad_iret(). After this patch, fixup_bad_iret() is restored to the behavior before 7f2590a110b8("x86/entry/64: Use a per-CPU trampoline stack for IDT entries") Signed-off-by: Lai Jiangshan --- arch/x86/entry/entry_64.S | 13 ++--- arch/x86/kernel/traps.c | 9 - 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 1a7715430da3..911cfa0da637 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -965,16 +965,6 @@ SYM_CODE_START_LOCAL(error_entry) ENCODE_FRAME_POINTER 8 ret -.Lerror_entry_from_usermode_after_swapgs: - /* Put us onto the real thread stack. */ - popq%r12/* save return addr in %12 */ - movq%rsp, %rdi /* arg0 = pt_regs pointer */ - callsync_regs - movq%rax, %rsp /* switch stack */ - ENCODE_FRAME_POINTER - pushq %r12 - ret - .Lerror_entry_done_lfence: FENCE_SWAPGS_KERNEL_ENTRY .Lerror_entry_done: @@ -1028,7 +1018,8 @@ SYM_CODE_START_LOCAL(error_entry) mov %rsp, %rdi callfixup_bad_iret mov %rax, %rsp - jmp .Lerror_entry_from_usermode_after_swapgs + ENCODE_FRAME_POINTER 8 + ret SYM_CODE_END(error_entry) SYM_CODE_START_LOCAL(error_return) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 1f66d2d1e998..852de6f1bf88 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -684,13 +684,12 @@ struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s) /* * This is called from entry_64.S early in handling a fault * caused by a bad iret to user mode. To handle the fault -* correctly, we want to move our stack frame to where it would -* be had we entered directly on the entry stack (rather than -* just below the IRET frame) and we want to pretend that the -* exception came from the IRET target. +* correctly, we want to move our stack frame to kernel stack +* (rather than just below the IRET frame) and we want to +* pretend that the exception came from the IRET target. */ struct bad_iret_stack tmp, *new_stack = - (struct bad_iret_stack *)__this_cpu_read(cpu_tss_rw.x86_tss.sp0) - 1; + (struct bad_iret_stack *)__this_cpu_read(cpu_current_top_of_stack) - 1; /* Copy the IRET target to the temporary storage. */ __memcpy(&tmp.regs.ip, (void *)s->regs.sp, 5*8); -- 2.19.1.6.gb485710b