From owner-svn-src-all@freebsd.org Tue May 24 07:46:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C2E0B480B2; Tue, 24 May 2016 07:46:22 +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 mx1.freebsd.org (Postfix) with ESMTPS id F319F10EC; Tue, 24 May 2016 07:46:21 +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 u4O7kLG0085995; Tue, 24 May 2016 07:46:21 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4O7kLLi085991; Tue, 24 May 2016 07:46:21 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201605240746.u4O7kLLi085991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 24 May 2016 07:46:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300590 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 07:46:22 -0000 Author: hselasky Date: Tue May 24 07:46:20 2016 New Revision: 300590 URL: https://svnweb.freebsd.org/changeset/base/300590 Log: Set "current" for all PCI enumeration callbacks. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/compat.h head/sys/compat/linuxkpi/common/src/linux_compat.c head/sys/compat/linuxkpi/common/src/linux_pci.c Modified: head/sys/compat/linuxkpi/common/include/linux/compat.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/compat.h Tue May 24 07:21:23 2016 (r300589) +++ head/sys/compat/linuxkpi/common/include/linux/compat.h Tue May 24 07:46:20 2016 (r300590) @@ -31,4 +31,10 @@ #ifndef _LINUX_COMPAT_H_ #define _LINUX_COMPAT_H_ +struct thread; +struct task_struct; + +void linux_set_current(struct thread *td, struct task_struct *t); +void linux_clear_current(struct thread *td); + #endif /* _LINUX_COMPAT_H_ */ Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Tue May 24 07:21:23 2016 (r300589) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Tue May 24 07:46:20 2016 (r300590) @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -380,7 +381,7 @@ kobject_init_and_add(struct kobject *kob return kobject_add_complete(kobj, parent); } -static void +void linux_set_current(struct thread *td, struct task_struct *t) { memset(t, 0, sizeof(*t)); @@ -388,7 +389,7 @@ linux_set_current(struct thread *td, str task_struct_set(td, t); } -static void +void linux_clear_current(struct thread *td) { task_struct_set(td, NULL); Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_pci.c Tue May 24 07:21:23 2016 (r300589) +++ head/sys/compat/linuxkpi/common/src/linux_pci.c Tue May 24 07:46:20 2016 (r300590) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include static device_probe_t linux_pci_probe; static device_attach_t linux_pci_attach; @@ -120,8 +121,12 @@ linux_pci_attach(device_t dev) struct pci_dev *pdev; struct pci_driver *pdrv; const struct pci_device_id *id; + struct task_struct t; + struct thread *td; int error; + td = curthread; + linux_set_current(td, &t); pdrv = linux_pci_find(dev, &id); pdev = device_get_softc(dev); pdev->dev.parent = &linux_root_device; @@ -152,16 +157,21 @@ linux_pci_attach(device_t dev) list_del(&pdev->links); spin_unlock(&pci_lock); put_device(&pdev->dev); - return (-error); + error = -error; } - return (0); + linux_clear_current(td); + return (error); } static int linux_pci_detach(device_t dev) { struct pci_dev *pdev; + struct task_struct t; + struct thread *td; + td = curthread; + linux_set_current(td, &t); pdev = device_get_softc(dev); mtx_unlock(&Giant); pdev->pdrv->remove(pdev); @@ -170,6 +180,7 @@ linux_pci_detach(device_t dev) list_del(&pdev->links); spin_unlock(&pci_lock); put_device(&pdev->dev); + linux_clear_current(td); return (0); } @@ -179,13 +190,18 @@ linux_pci_suspend(device_t dev) { struct pm_message pm = { }; struct pci_dev *pdev; + struct task_struct t; + struct thread *td; int err; + td = curthread; + linux_set_current(td, &t); pdev = device_get_softc(dev); if (pdev->pdrv->suspend != NULL) err = -pdev->pdrv->suspend(pdev, pm); else err = 0; + linux_clear_current(td); return (err); } @@ -193,13 +209,18 @@ static int linux_pci_resume(device_t dev) { struct pci_dev *pdev; + struct task_struct t; + struct thread *td; int err; + td = curthread; + linux_set_current(td, &t); pdev = device_get_softc(dev); if (pdev->pdrv->resume != NULL) err = -pdev->pdrv->resume(pdev); else err = 0; + linux_clear_current(td); return (err); } @@ -207,13 +228,18 @@ static int linux_pci_shutdown(device_t dev) { struct pci_dev *pdev; + struct task_struct t; + struct thread *td; + td = curthread; + linux_set_current(td, &t); pdev = device_get_softc(dev); if (pdev->pdrv->shutdown != NULL) { DROP_GIANT(); pdev->pdrv->shutdown(pdev); PICKUP_GIANT(); } + linux_clear_current(td); return (0); }