From owner-freebsd-drivers@freebsd.org Wed May 4 02:21:57 2016 Return-Path: Delivered-To: freebsd-drivers@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 4DB48B2CA96 for ; Wed, 4 May 2016 02:21:57 +0000 (UTC) (envelope-from kumara.bsd@gmail.com) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DE57719EE for ; Wed, 4 May 2016 02:21:56 +0000 (UTC) (envelope-from kumara.bsd@gmail.com) Received: by mail-wm0-x22b.google.com with SMTP id g17so68724335wme.1 for ; Tue, 03 May 2016 19:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=oCgP8sM7KAHAmPGKx8G9MY8k/OusyCOpfyH2+3eQy1A=; b=mdUV1cfw1QgNoTAE7ClA754ZRBM0C3IwWiUEIJHaDyMrHTIR9H8EooGbc1F2NerRbo ngn64PhdnoIJdAI8hiGOOS6/hS6peeOZzdatBXv39SdzJkmyN0jSyFFmgXrrurWLif8+ UcEyaUVCm2k2xkLeWt9SUMY3rMT6EkHPkD75aCpq5WZAokXXAjysow5nBxgOTu8fA3XX m/cjpvok/k6OJNek0u25sq5b1hu8jngrmGGyfWVapD/Vj9LqBQQyq86pYSXs5i6sIxRa pMsdWNuK7jD/va4gOSSLO51BgaZxcaeImhrs4yz4l4K7DAs34jDkpEjvPC8BJJK6HlM7 FXFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=oCgP8sM7KAHAmPGKx8G9MY8k/OusyCOpfyH2+3eQy1A=; b=Ug/0pOjsUmoNn4QJ9/atP4FL/6RuSxEPYTmta/Ln+8imkSU4RcAcM0o/y5YzytVwhU 3Oz2w+kx6a02bawRGeoDNj706wUCbqYdRYJD1PZqE4lbH3extXTvAHWU2AqYvAC5UEqP rMGPe+r8w63BJZ8SqxgHbq2eYPCzzVNyZYuNZWzKut5q2FellhuGTvqhiyxaW3BZmGFD KIgiLvaZ4fYEClE/R8iREsMTgtk+MNt1U6ahWydzQZbms+insNWS1XlnqY5QL/+fxklV ZtkYXbCsA12yDP4AlPSffq3AO/vFHwjpy+xbfYHujNNP4MZnroVuT7SEQ/IzsjOPN0cx 9ZVw== X-Gm-Message-State: AOPr4FVJyp3raiNKQdRnfoVIzVEP2YitQryOm7lXlmidkR4z4JzakhNXsQ4otg8Bc53kRDp8oQguxaLA7Bzh/Q== MIME-Version: 1.0 X-Received: by 10.28.31.73 with SMTP id f70mr6746607wmf.77.1462328515187; Tue, 03 May 2016 19:21:55 -0700 (PDT) Received: by 10.194.188.6 with HTTP; Tue, 3 May 2016 19:21:55 -0700 (PDT) Date: Wed, 4 May 2016 07:51:55 +0530 Message-ID: Subject: Device Pager From: kumara rathnavel To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2016 02:21:57 -0000 Hello All, I have written a character device pager. I have associated an object with my device and I have mapped it to the kernel and I also have a virtual address for it. So whenever the address is accessed first time I get a page fault and i give the physical address to be associated in the fault routine. Now how do I again get a page fault for the same virtual address. I need to change the physical address periodically for a virtual address. Thanking You, Kumar From owner-freebsd-drivers@freebsd.org Wed May 4 11:23:01 2016 Return-Path: Delivered-To: freebsd-drivers@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 6B001B2C821 for ; Wed, 4 May 2016 11:23:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E10D911C1 for ; Wed, 4 May 2016 11:23:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u44BMtYe097050 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 4 May 2016 14:22:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u44BMtYe097050 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u44BMtAe097049; Wed, 4 May 2016 14:22:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 4 May 2016 14:22:55 +0300 From: Konstantin Belousov To: kumara rathnavel Cc: freebsd-drivers@freebsd.org Subject: Re: Device Pager Message-ID: <20160504112255.GB2422@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2016 11:23:01 -0000 On Wed, May 04, 2016 at 07:51:55AM +0530, kumara rathnavel wrote: > Hello All, > > I have written a character device pager. I have associated an object with > my device and I have mapped it to the kernel and I also have a virtual > address for it. So whenever the address is accessed first time I get a page > fault and i give the physical address to be associated in the fault > routine. Now how do I again get a page fault for the same virtual address. > I need to change the physical address periodically for a virtual address. This cannot be done with the device_pager, i.e. OBJT_DEVICE. VM system does not track mappings of the page into userspace processes, so it cannot invalidate existing mappings. What can be used for this purpose is OBJT_MGTDEVICE, which operates on managed fictitious pages. Such pages do track userspace mappings with the usual PV-lists mechanisms, so pmap_remove_all() works. This kind of pager is used by GEM and TTM. There is not much useful documentation about OBJT_MGTDEVICE, read the source to see how it is plumbed. From owner-freebsd-drivers@freebsd.org Wed May 4 13:04:40 2016 Return-Path: Delivered-To: freebsd-drivers@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 B239EB2B67C for ; Wed, 4 May 2016 13:04:40 +0000 (UTC) (envelope-from kumara.bsd@gmail.com) Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 513391439 for ; Wed, 4 May 2016 13:04:40 +0000 (UTC) (envelope-from kumara.bsd@gmail.com) Received: by mail-wm0-x244.google.com with SMTP id w143so10124190wmw.3 for ; Wed, 04 May 2016 06:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=nbv+mARbuFlt1iJ9zh7+HoWBxXkRlXV/WqQ7Nsa1PTM=; b=K2334RVAZgYkZZKfgqmkQv2OuHmaKpTl70wC1kOxEqZ7jVGSM5NjP6uaqSdwGUH7ET IW+v3NGC26Q6A1jtee3rzwiJ2tNdwjQywdkt+bQ7rn/D8EhE4W8NjP7NY8HfxE6tKPVj nYqeRIWEj+UkJX6wnLTDcGAEtx8ylNXQ5fmhzvS31urTkYLgbB7V9PnC61OLXZxcR2nW /lO0zn4dXCH4M0OnR5Fa+KFyXdS3/xUzWnLuTNq9olCmSOrtMtVNdznXIyqOt28H/Aei 4K3IEjW1zmCCwkYeoyd6EYZnuP6rFBgQay54zXjTtSVx6v/5crEMHJvjafYepK6t/HLq z/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=nbv+mARbuFlt1iJ9zh7+HoWBxXkRlXV/WqQ7Nsa1PTM=; b=ChhjsrE9mn/CwjLutWtCwkN49h3O3lyJ29qmsMTp6rYS3aZwDJlKSWbFhVM+YABYdw QscE+8y6bMRfQcBPp1LaaVWM9Xe+wlJORltwVj2RN7kXtMcspcQGDyhG+l+T1/VIExPq j9aG4og2f67lf8dkkN7GZ4Hv6DBrHK08bdWNNCkzxBt6A2605rAN5WRm8GAyqLIpFiKh vvJ4Pzjtpu78AvrFs+s8L5Gn11xA1UO/pK+F32ulCkQG48JcLNNo1noMeGkwbAMPfJ7n KjBCdV7nFwFtCdmx9A/KE1kxsN4uICm7A/dC3bgOxbPn4k8HdyY3QBKtwAQAzAK0fZn9 TjNg== X-Gm-Message-State: AOPr4FUSXZt13blrRnZJLaN3KgIpBXp6FtvmpWPkkIykFvb8bgBjqAnsGiEP7SnD8k/paWR4wPGDy5cwOiG+LA== MIME-Version: 1.0 X-Received: by 10.28.153.213 with SMTP id b204mr32090024wme.102.1462367078536; Wed, 04 May 2016 06:04:38 -0700 (PDT) Received: by 10.194.188.6 with HTTP; Wed, 4 May 2016 06:04:38 -0700 (PDT) Received: by 10.194.188.6 with HTTP; Wed, 4 May 2016 06:04:38 -0700 (PDT) In-Reply-To: <20160504112255.GB2422@kib.kiev.ua> References: <20160504112255.GB2422@kib.kiev.ua> Date: Wed, 4 May 2016 18:34:38 +0530 Message-ID: Subject: Re: Device Pager From: kumara rathnavel To: Konstantin Belousov Cc: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2016 13:04:40 -0000 Thanks for the reply. I have mapped it in kernel space. How do I invalidate the kernel vm_page. I have tried removing the vm_page_remove also. But I still am not getting it invalidated. On Wed, May 04, 2016 at 07:51:55AM +0530, kumara rathnavel wrote: > Hello All, > > I have written a character device pager. I have associated an object with > my device and I have mapped it to the kernel and I also have a virtual > address for it. So whenever the address is accessed first time I get a page > fault and i give the physical address to be associated in the fault > routine. Now how do I again get a page fault for the same virtual address. > I need to change the physical address periodically for a virtual address. This cannot be done with the device_pager, i.e. OBJT_DEVICE. VM system does not track mappings of the page into userspace processes, so it cannot invalidate existing mappings. What can be used for this purpose is OBJT_MGTDEVICE, which operates on managed fictitious pages. Such pages do track userspace mappings with the usual PV-lists mechanisms, so pmap_remove_all() works. This kind of pager is used by GEM and TTM. There is not much useful documentation about OBJT_MGTDEVICE, read the source to see how it is plumbed. From owner-freebsd-drivers@freebsd.org Wed May 4 14:19:32 2016 Return-Path: Delivered-To: freebsd-drivers@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 ECBCBB2C9CA for ; Wed, 4 May 2016 14:19:32 +0000 (UTC) (envelope-from john@baldwin.cx) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFC091B44 for ; Wed, 4 May 2016 14:19:32 +0000 (UTC) (envelope-from john@baldwin.cx) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AB67DB960; Wed, 4 May 2016 10:19:31 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Subject: Re: Porting FreeBSD driver from 8.4 to 10.3 - PCI_ENABLE_MSI definition missing Date: Wed, 04 May 2016 07:16:19 -0700 Message-ID: <8107686.DyeUg95lUZ@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 04 May 2016 10:19:31 -0400 (EDT) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2016 14:19:33 -0000 On Thursday, April 14, 2016 11:40:02 PM Reguna, Lakshmi wrote: > Hi, > > I am attempting to port a freebsd driver from 8.4 to 10.3. I ran into the following compilation error. I am not able to find any file which declares PCI_ENABLE_MSI, PCI_ENABLE_MSIX, PCI_DISABLE_MSI etc. The actual definition of PCI_ENABLE_MSI seems to point to pci_enable_msi_method in pci.c. Any thoughts on what might be missing ? > > DEVMETHOD(pci_enable_msi, pci_enable_msi_method), > > > Build Error: > > @/dev/pci/pcivar.h:459:5: error: implicit declaration of function 'PCI_ENABLE_MSI' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > PCI_ENABLE_MSI(device_get_parent(dev), dev, address, data); > > > @/dev/pci/pcivar.h:465:5: error: implicit declaration of function 'PCI_ENABLE_MSIX' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > PCI_ENABLE_MSIX(device_get_parent(dev), dev, index, address, data); > > @/dev/pci/pcivar.h:471:5: error: implicit declaration of function 'PCI_DISABLE_MSI' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > PCI_DISABLE_MSI(device_get_parent(dev), dev); > ^ > @/dev/pci/pcivar.h:501:13: error: implicit declaration of function 'PCI_MSIX_PBA_BAR' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > return (PCI_MSIX_PBA_BAR(device_get_parent(dev), dev)); > ^ > @/dev/pci/pcivar.h:507:13: error: implicit declaration of function 'PCI_MSIX_TABLE_BAR' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > return (PCI_MSIX_TABLE_BAR(device_get_parent(dev), dev)); > > @/dev/pci/pcivar.h:520:13: error: implicit declaration of function 'PCI_CHILD_ADDED' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > return (PCI_CHILD_ADDED(device_get_parent(dev), dev)); You need to add 'pci_if.h' to your SRCS line in your kernel module Makefile. -- John Baldwin From owner-freebsd-drivers@freebsd.org Wed May 4 19:11:47 2016 Return-Path: Delivered-To: freebsd-drivers@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 A4A2EB2DFC1 for ; Wed, 4 May 2016 19:11:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2519B13C3 for ; Wed, 4 May 2016 19:11:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u44JBg3Z014813 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 4 May 2016 22:11:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u44JBg3Z014813 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u44JBgih014812; Wed, 4 May 2016 22:11:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 4 May 2016 22:11:42 +0300 From: Konstantin Belousov To: kumara rathnavel Cc: freebsd-drivers@freebsd.org Subject: Re: Device Pager Message-ID: <20160504191141.GC2422@kib.kiev.ua> References: <20160504112255.GB2422@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2016 19:11:47 -0000 On Wed, May 04, 2016 at 06:34:38PM +0530, kumara rathnavel wrote: > Thanks for the reply. > > I have mapped it in kernel space. How do I invalidate the kernel vm_page. I > have tried removing the vm_page_remove also. But I still am not getting > it invalidated. I do not understand what you wrote. Specifically, why do you need the page fault handler for kernel mappings ? In fact, making that handler work, even without any additional complications like invalidations, is non-trivial. For kernel, when you already know the mappings, you do not need the pager and manageability. In fact, you do not want page faults there at all. Just use e.g. pmap_qenter() and pmap_qremove(), for a fictious page you created. > On Wed, May 04, 2016 at 07:51:55AM +0530, kumara rathnavel wrote: > > Hello All, > > > > I have written a character device pager. I have associated an object with > > my device and I have mapped it to the kernel and I also have a virtual > > address for it. So whenever the address is accessed first time I get a > page > > fault and i give the physical address to be associated in the fault > > routine. Now how do I again get a page fault for the same virtual address. > > I need to change the physical address periodically for a virtual address. > > This cannot be done with the device_pager, i.e. OBJT_DEVICE. VM system > does not track mappings of the page into userspace processes, so it > cannot invalidate existing mappings. > > What can be used for this purpose is OBJT_MGTDEVICE, which operates on > managed fictitious pages. Such pages do track userspace mappings with > the usual PV-lists mechanisms, so pmap_remove_all() works. This kind > of pager is used by GEM and TTM. > > There is not much useful documentation about OBJT_MGTDEVICE, read the source > to see how it is plumbed.