From owner-svn-src-stable-12@freebsd.org Mon Aug 24 10:46:10 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 98B6C3B9AC8; Mon, 24 Aug 2020 10:46:10 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BZph23Yhsz4Yq3; Mon, 24 Aug 2020 10:46:10 +0000 (UTC) (envelope-from manu@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 5DB1D17712; Mon, 24 Aug 2020 10:46:10 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07OAkAQh059382; Mon, 24 Aug 2020 10:46:10 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07OAk9Z4059378; Mon, 24 Aug 2020 10:46:09 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202008241046.07OAk9Z4059378@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 24 Aug 2020 10:46:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r364654 - stable/12/sys/compat/linuxkpi/common/include/linux X-SVN-Group: stable-12 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: stable/12/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 364654 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 10:46:10 -0000 Author: manu Date: Mon Aug 24 10:46:09 2020 New Revision: 364654 URL: https://svnweb.freebsd.org/changeset/base/364654 Log: MFC r361007, r361138-r361140, r361245-r361246 r361007: linuxkpi: Add EBADRQC to errno.h This is used in the amdgpu driver from Linux 5.2 Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24807 r361138: linuxkpi: Add atomic_dec_and_mutex_lock This function decrement the counter and if the result is 0 it acquires the mutex and returns 1, if not it simply returns 0. Needed by DRM from Linux v5.3 Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24847 r361139: linuxkpi: Add __mutex_init Same as mutex_init, the lock_class_key argument seems to be only used for debug in Linux, simply ignore it for now. Needed by DRM in Linux v5.3 Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24848 r361140: linuxkpi: Add offsetofend macro This calculate the offset of the end of the member in the given struct. Needed by DRM in Linux v5.3 Sponsored-by: The FreeBSD Foudation Differential Revision: https://reviews.freebsd.org/D24849 r361245: linuxkpi: Add __init_waitqueue_head The only difference with init_waitqueue_head is that the name and the lock class key are provided but we don't use those so use init_waitqueue_head directly. Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24861 r361246: linuxkpi: add pci_dev_present pci_dev_present shows if a set of pci ids are present in the system. It just wraps pci_find_device. Needed by DRMv5.2 Submitted by: Austing Shafer (ashafer@badland.io) Differential Revision: https://reviews.freebsd.org/D24796 Modified: stable/12/sys/compat/linuxkpi/common/include/linux/errno.h stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h stable/12/sys/compat/linuxkpi/common/include/linux/pci.h stable/12/sys/compat/linuxkpi/common/include/linux/wait.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linuxkpi/common/include/linux/errno.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/errno.h Mon Aug 24 10:42:04 2020 (r364653) +++ stable/12/sys/compat/linuxkpi/common/include/linux/errno.h Mon Aug 24 10:46:09 2020 (r364654) @@ -33,6 +33,8 @@ #include +#define EBADRQC 56 /* Bad request code */ + #define ECHRNG EDOM #define ETIME ETIMEDOUT #define ECOMM ESTALE Modified: stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h Mon Aug 24 10:42:04 2020 (r364653) +++ stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h Mon Aug 24 10:46:09 2020 (r364654) @@ -465,6 +465,9 @@ kstrtobool_from_user(const char __user *s, size_t coun type __max2 = (y); \ __max1 > __max2 ? __max1 : __max2; }) +#define offsetofend(t, m) \ + (offsetof(t, m) + sizeof((((t *)0)->m))) + #define clamp_t(type, _x, min, max) min_t(type, max_t(type, _x, min), max) #define clamp(x, lo, hi) min( max(x,lo), hi) #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) Modified: stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h Mon Aug 24 10:42:04 2020 (r364653) +++ stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h Mon Aug 24 10:46:09 2020 (r364654) @@ -37,6 +37,7 @@ #include #include +#include typedef struct mutex { struct sx sx; @@ -107,6 +108,9 @@ mutex_trylock_recursive(struct mutex *lock) #define mutex_init(_m) \ linux_mutex_init(_m, mutex_name(#_m), SX_NOWITNESS) +#define __mutex_init(_m, _n, _l) \ + linux_mutex_init(_m, _n, SX_NOWITNESS) + #define mutex_init_witness(_m) \ linux_mutex_init(_m, mutex_name(#_m), SX_DUPOK) @@ -123,6 +127,16 @@ static inline bool mutex_is_owned(mutex_t *m) { return (sx_xlocked(&m->sx)); +} + +static inline int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *m) +{ + if (atomic_dec_and_test(cnt)) { + mutex_lock(m); + return (1); + } + + return (0); } #ifdef WITNESS_ALL Modified: stable/12/sys/compat/linuxkpi/common/include/linux/pci.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/pci.h Mon Aug 24 10:42:04 2020 (r364653) +++ stable/12/sys/compat/linuxkpi/common/include/linux/pci.h Mon Aug 24 10:46:09 2020 (r364654) @@ -1050,4 +1050,16 @@ extern int linux_pci_attach_device(device_t, struct pc const struct pci_device_id *, struct pci_dev *); extern int linux_pci_detach_device(struct pci_dev *); +static inline int +pci_dev_present(const struct pci_device_id *cur) +{ + while (cur != NULL && (cur->vendor || cur->device)) { + if (pci_find_device(cur->vendor, cur->device) != NULL) { + return (1); + } + cur++; + } + return (0); +} + #endif /* _LINUX_PCI_H_ */ Modified: stable/12/sys/compat/linuxkpi/common/include/linux/wait.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/wait.h Mon Aug 24 10:42:04 2020 (r364653) +++ stable/12/sys/compat/linuxkpi/common/include/linux/wait.h Mon Aug 24 10:46:09 2020 (r364654) @@ -119,6 +119,8 @@ extern wait_queue_func_t default_wake_function; INIT_LIST_HEAD(&(wqh)->task_list); \ } while (0) +#define __init_waitqueue_head(wqh, name, lk) init_waitqueue_head(wqh) + void linux_init_wait_entry(wait_queue_t *, int); void linux_wake_up(wait_queue_head_t *, unsigned int, int, bool);