From owner-svn-src-head@freebsd.org Fri Feb 16 15:41:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84ABFF1EA9C; Fri, 16 Feb 2018 15:41:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 35C87806C9; Fri, 16 Feb 2018 15:41:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30B337963; Fri, 16 Feb 2018 15:41:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1GFfGVe061553; Fri, 16 Feb 2018 15:41:16 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1GFfG0j061551; Fri, 16 Feb 2018 15:41:16 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201802161541.w1GFfG0j061551@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 16 Feb 2018 15:41:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329376 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 329376 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Feb 2018 15:41:17 -0000 Author: hselasky Date: Fri Feb 16 15:41:16 2018 New Revision: 329376 URL: https://svnweb.freebsd.org/changeset/base/329376 Log: Implement tasklet_enable() and tasklet_disable() in the LinuxKPI. MFC after: 1 week Requested by: Johannes Lundberg Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/interrupt.h head/sys/compat/linuxkpi/common/src/linux_tasklet.c Modified: head/sys/compat/linuxkpi/common/include/linux/interrupt.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/interrupt.h Fri Feb 16 15:41:03 2018 (r329375) +++ head/sys/compat/linuxkpi/common/include/linux/interrupt.h Fri Feb 16 15:41:16 2018 (r329376) @@ -200,5 +200,7 @@ extern void tasklet_schedule(struct tasklet_struct *); extern void tasklet_kill(struct tasklet_struct *); extern void tasklet_init(struct tasklet_struct *, tasklet_func_t *, unsigned long data); +extern void tasklet_enable(struct tasklet_struct *); +extern void tasklet_disable(struct tasklet_struct *); #endif /* _LINUX_INTERRUPT_H_ */ Modified: head/sys/compat/linuxkpi/common/src/linux_tasklet.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_tasklet.c Fri Feb 16 15:41:03 2018 (r329375) +++ head/sys/compat/linuxkpi/common/src/linux_tasklet.c Fri Feb 16 15:41:16 2018 (r329376) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #define TASKLET_ST_BUSY 1 #define TASKLET_ST_EXEC 2 #define TASKLET_ST_LOOP 3 +#define TASKLET_ST_PAUSED 4 #define TASKLET_ST_CMPSET(ts, old, new) \ atomic_cmpset_ptr((volatile uintptr_t *)&(ts)->entry.tqe_prev, old, new) @@ -195,4 +196,22 @@ tasklet_kill(struct tasklet_struct *ts) /* wait until tasklet is no longer busy */ while (TASKLET_ST_GET(ts) != TASKLET_ST_IDLE) pause("W", 1); +} + +void +tasklet_enable(struct tasklet_struct *ts) +{ + (void) TASKLET_ST_CMPSET(ts, TASKLET_ST_PAUSED, TASKLET_ST_IDLE); +} + +void +tasklet_disable(struct tasklet_struct *ts) +{ + while (1) { + if (TASKLET_ST_GET(ts) == TASKLET_ST_PAUSED) + break; + if (TASKLET_ST_CMPSET(ts, TASKLET_ST_IDLE, TASKLET_ST_PAUSED)) + break; + pause("W", 1); + } }