From owner-freebsd-drivers@freebsd.org Wed Oct 7 18:15:14 2015 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 DC3859D07B3 for ; Wed, 7 Oct 2015 18:15:14 +0000 (UTC) (envelope-from leonardofogel@yahoo.com.br) Received: from nm8-vm0.bullet.mail.ne1.yahoo.com (nm8-vm0.bullet.mail.ne1.yahoo.com [98.138.91.23]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B2326CB for ; Wed, 7 Oct 2015 18:15:13 +0000 (UTC) (envelope-from leonardofogel@yahoo.com.br) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.br; s=s2048; t=1444241537; bh=udbbcbIFbktHCfk7iuINGnL8PW/v80nV26uVzVZ2d1E=; h=Date:From:Subject:To:From:Subject; b=c+dyaFHgOh48wKpzFb+sma1kJx+AcJvzO9uWYeD/iFdT7KP4QDKI5CaXYU+XDmhJWSxH+iE8u4Kn8xm/X49D5xOBOcJOs1QirkrX9vGDhpmBH5OTzxAGp2qVCIvBwIzMPNT6Y4jrve39sYVUpf4Q5bm5RaOPsiI3qa8mg4JcpErLFuJdYNeQ8g5boT6hLgwoH7T+hBH6BdRt/uXD589484ZTOm2KYmq7PAiFmh5UBsd++WcdTeMLcWk3s7Yw3+1t4ffnHbz1QujFq+1RQnAlnVlMux3EuO9B6/MAF6Y69BTpW6z++RpvrH8r2a8xr/142X1bD4TpOBBCUoC4CNZ94w== Received: from [98.138.100.103] by nm8.bullet.mail.ne1.yahoo.com with NNFMP; 07 Oct 2015 18:12:17 -0000 Received: from [98.138.226.169] by tm102.bullet.mail.ne1.yahoo.com with NNFMP; 07 Oct 2015 18:12:17 -0000 Received: from [127.0.0.1] by omp1070.mail.ne1.yahoo.com with NNFMP; 07 Oct 2015 18:12:17 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 322875.2051.bm@omp1070.mail.ne1.yahoo.com Received: (qmail 27666 invoked by uid 60001); 7 Oct 2015 18:12:17 -0000 X-YMail-OSG: pvVED7YVM1m0yhWXoiKmKAJCKUgN1vznqv7hyD1THpoHreS LhzINAYCrhd9A4Xj6_c5kC3WoDCaocQMkUlO8MZ4Jw7_qHOAzfkmT3Zh81U6 6lvIvHolhMrAbP.UQPnlavAlIj6EAwOqEP63d5h.3Ej7aykw4OXy37CwgNpz e66QkprtY0hDCBFQ7iAoX4wfIVJYeytF4CWLDkK4GtBueerW21IunjrDI_SW 338O2HOUlWCiEpVFblM3DuBGRh9qfaABqmHJkqvgUREAB4zVipKlPvqw79dR mvCWHaTreLtkJ7bY74XALLpQgtGsQKfZ7khnrqLdX8jOx3FZ1ez8JbLFk.og NLHYFJKhKjrzwPP2SGpL.0yfMjMcecFxDxH0EbXpHE9X4ZgE_IuQrAFIpBvJ 6cCvq2r.QMWdWqtVSXVR_Mudtf_U7Fsee7GGwDbWm9x_zwZSJmSM_yR_p.5w YCj.9JZ_.qiX8zw8gd4EbrHPKwO7ArQXk0n9KR06KGvO9iVwjT2GX4YMVRGU XmuJoJn.1aD1V3eFXcT199sIWnnK0GjlbyBrkoxn_C4ByFmEuFldzNa4l263 YTL198R4Hs1RGK9767g-- Received: from [186.228.53.250] by web120802.mail.ne1.yahoo.com via HTTP; Wed, 07 Oct 2015 11:12:17 PDT X-Rocket-MIMEInfo: 002.001, SGVsbG8uDQpQbGVhc2UsIGNvdWxkIHNvbWVvbmUga2luZGx5IHBvaW50IG1lIHRvIGRvY3VtZW50YXRpb24gb24gaG93IHRvIHdyaXRlIGEgdmlkZW8gZHJpdmVyIGFuZCBpbnRlZ3JhdGUgaXQgdG8gdnQoNCk_IEkndmUgd3JpdHRlbiBhIGRyaXZlciB0byBjaGFyIGRpc3BsYXlzIGJhc2VkIG9uIHRoZSBIRDQ0NzgwLCBidXQgdGhlIHVzZXIgaW5wdXQvaW50ZXJmYWNlIGlzIGEgY2hhciBkZXZpY2UgZmlsZSAoZS5nLiBlY2hvIEhlbGxvID4gL2Rldi9maWxlKS4gSSB3b3VsZCBsaWtlIHRvIGludGVncmF0ZSABMAEBAQE- X-Mailer: YahooMailBasic/764 YahooMailWebService/0.8.203.817 Message-ID: <1444241537.96292.YahooMailBasic@web120802.mail.ne1.yahoo.com> Date: Wed, 7 Oct 2015 11:12:17 -0700 From: Leonardo Fogel Subject: How to write video drivers? To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2015 18:15:15 -0000 Hello. Please, could someone kindly point me to documentation on how to write a vi= deo driver and integrate it to vt(4)? I've written a driver to char display= s based on the HD44780, but the user input/interface is a char device file = (e.g. echo Hello > /dev/file). I would like to integrate it to vt(4). Thank you for your attention. Leonardo From owner-freebsd-drivers@freebsd.org Thu Oct 8 22:39:37 2015 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 DCA339D2CE1 for ; Thu, 8 Oct 2015 22:39:37 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "gold.funkthat.com", Issuer "gold.funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id A3D618A2 for ; Thu, 8 Oct 2015 22:39:37 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.14.5/8.14.5) with ESMTP id t98MdaA0092043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Oct 2015 15:39:36 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.14.5/8.14.5/Submit) id t98Mda0l092042; Thu, 8 Oct 2015 15:39:36 -0700 (PDT) (envelope-from jmg) Date: Thu, 8 Oct 2015 15:39:35 -0700 From: John-Mark Gurney To: Leonardo Fogel Cc: freebsd-drivers@freebsd.org Subject: Re: Memory barrier Message-ID: <20151008223935.GH67524@funkthat.com> References: <2149458.2Hg3JbBXY3@ralph.baldwin.cx> <1441547636.78646.YahooMailBasic@web120801.mail.ne1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441547636.78646.YahooMailBasic@web120801.mail.ne1.yahoo.com> X-Operating-System: FreeBSD 9.1-PRERELEASE amd64 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (gold.funkthat.com [127.0.0.1]); Thu, 08 Oct 2015 15:39:36 -0700 (PDT) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2015 22:39:38 -0000 Leonardo Fogel wrote this message on Sun, Sep 06, 2015 at 06:53 -0700: > Please, what are the correct barriers for the following cases? > > Case 1: > bus_write_1(region_0, ...); > /* barrier here */ > DELAY(some_time); > > Case 2: > bus_write_1(region_0, ...); > /* barrier here */ > bus_write_1(region_2, ...); > > In the first one, I want the write to reach the device before the thread busy-waits. As I understand it, bus_space_barrier(9) is not adequate, because it does not prevent the processor from executing instructions (or load/store to RAM) before the write completes. > > In the second one, I want the write to a device (e.g. power management) to complete before the write to another starts/completes. Again, bus_space_barrier() seems not to be adequate because it can not cover two regions. > > Thank you for your time. If this is a PCI device, you need to do a read from the device before it is guaranteed that all the bridges have flushed the writes to the device... A barrier only guarantees from the processor's perspective that the write "has completed", but not that it will reach the device.. If this is a different bus, then the rules are probably different... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@freebsd.org Fri Oct 9 12:18:01 2015 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 11A569D1D00 for ; Fri, 9 Oct 2015 12:18:01 +0000 (UTC) (envelope-from leonardofogel@yahoo.com.br) Received: from nm11.bullet.mail.ne1.yahoo.com (nm11.bullet.mail.ne1.yahoo.com [98.138.90.74]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C847CDB6 for ; Fri, 9 Oct 2015 12:18:00 +0000 (UTC) (envelope-from leonardofogel@yahoo.com.br) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.br; s=s2048; t=1444392942; bh=VDgCOx9Y+wEpbmS8nmso4sJNOVRTfybs/WJRYzikb4c=; h=Date:From:Subject:To:Cc:In-Reply-To:From:Subject; b=FQQ/WLeVIiBfRky3RpR14XV1Jfkfx5439BQzdzIFPNjoLU4IEw8ilVUe1UhjyT07MIxmzBJRwnxRW2r6NQHgLj5XN09Ii5opj4OAcKaXoCTJuBj2jaq3CbwB5v/KsOq8SgAHhim5/n0eVbN6I/Ue9scble7fGHtYs/s8QgBzBGwTxgVuOMPtkmMS39C7wAzFeZ16bp1h8OZ/AX0t2DlL3je84+Zk+hocMgFODucuAEfIiklqooc8G79hhTl1cHCrjOefHXKIKlZR0xTSSrdy6LzXlDBamZYWAra3Gv5JOpYvfu3idHt6UacVAsI2bkemUQxHZEdgA7GgBSflgk1uQQ== Received: from [98.138.100.115] by nm11.bullet.mail.ne1.yahoo.com with NNFMP; 09 Oct 2015 12:15:42 -0000 Received: from [98.138.87.9] by tm106.bullet.mail.ne1.yahoo.com with NNFMP; 09 Oct 2015 12:15:42 -0000 Received: from [127.0.0.1] by omp1009.mail.ne1.yahoo.com with NNFMP; 09 Oct 2015 12:15:42 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 683586.65642.bm@omp1009.mail.ne1.yahoo.com Received: (qmail 5736 invoked by uid 60001); 9 Oct 2015 12:15:42 -0000 X-YMail-OSG: GmYfYLEVM1kRTOB.hu23FNP2964JKFt_g9iVAkfqIAnX2vg dIUtv7tOhYxe5BcEWwmtSJU35hQztBxSLJJoekPtlGTEFx1miDrDGOpmHufv DvaQ2Jg9ztKcgnlmcxSfFVKijQqSblioqJuc3.x7eZBdHWTnLcM.jJdeazrX WiabOvYVgVMWIX3mVX1V.QJjt8vYAne1AUJPeTs8MYBq2cBvTIYeUfNC3jPU OrcGdjjOQK2ZBb0_WZGhxoo9.CHShWvW6GdOnnHKGDgHL2UhrF2b.8N19rqG ZUmYzcgVoW03jwBpdjYtmZT0TrA7IeXOByHaJ.FoavCvFoXn.K3npueUp7c0 dY6O6ljBtCmSE_Lkz.Nb4Fa_GsXLTil0zBQGxnxpVyjl58BFrJG1FQJG6AGb dk2E7GhHVogf7Emzk47RkOXSGfRFHgrOJG_jiZEt6oBHyeujB5pQNOjuWhuh PAgpUniousbCithmzdadJ4BQKKg67fSlDC5yNu9ySr2.u321l_Np9UJxILIA .QEWKY.RUIVbvM3ZY4iF6FcElGZ9D1wyyvzrlsoIlnbtMtVn_M8J9YsucIPA 4EPSWDMhinFnZoUW7dA-- Received: from [186.228.53.250] by web120801.mail.ne1.yahoo.com via HTTP; Fri, 09 Oct 2015 05:15:42 PDT X-Rocket-MIMEInfo: 002.001, T24gVGh1LCAxMC84LzE1LCBKb2huLU1hcmsgR3VybmV5IHdyb3RlOg0KDQo.IElmIHRoaXMgaXMgYSBQQ0kgZGV2aWNlLCB5b3UgbmVlZCB0byBkbyBhIHJlYWQgZnJvbSB0aGUgZGV2aWNlIGJlZm9yZQ0KPiBpdCBpcyBndWFyYW50ZWVkIHRoYXQgYWxsIHRoZSBicmlkZ2VzIGhhdmUgZmx1c2hlZCB0aGUgd3JpdGVzIHRvIHRoZQ0KPiBkZXZpY2UuLi4gIEEgYmFycmllciBvbmx5IGd1YXJhbnRlZXMgZnJvbSB0aGUgcHJvY2Vzc29yJ3MgcGVyc3BlY3RpdmUNCj4gdGhhdCB0aGUgd3JpdGUgImhhcyBjb21wbGUBMAEBAQE- X-Mailer: YahooMailBasic/779 YahooMailWebService/0.8.203.817 Message-ID: <1444392942.1258.YahooMailBasic@web120801.mail.ne1.yahoo.com> Date: Fri, 9 Oct 2015 05:15:42 -0700 From: Leonardo Fogel Subject: Re: Memory barrier To: John-Mark Gurney Cc: freebsd-drivers@freebsd.org In-Reply-To: <20151008223935.GH67524@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Oct 2015 12:18:01 -0000 On Thu, 10/8/15, John-Mark Gurney wrote: > If this is a PCI device, you need to do a read from the device before > it is guaranteed that all the bridges have flushed the writes to the > device... A barrier only guarantees from the processor's perspective > that the write "has completed", but not that it will reach the device.. >=20 > If this is a different bus, then the rules are probably different... Good points. I've ignored them. It is a System-on-Chip based on ARM, which has different buses and bridges.= Device registers are memory-mapped (MMIO). The formal definition of memory barriers is quite obscure; in simple terms:= memory accesses before the barrier are "observed" before memory accesses a= fter the barrier. However, the definition of an "observer" is not provided.= Since the device registers are memory-mapped, I've assumed that a write be= fore the barrier would reach the device before a write after the barrier. B= ut, on a second thought, the buses and bridges might reorder them. I really= don't know, but, to be on the safe side, I'll include the read. Thanks for your attention. Leonardo. From owner-freebsd-drivers@freebsd.org Fri Oct 9 15:38:55 2015 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 81E879D23F8 for ; Fri, 9 Oct 2015 15:38:55 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk0-f174.google.com (mail-qk0-f174.google.com [209.85.220.174]) (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 43B447A7 for ; Fri, 9 Oct 2015 15:38:54 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by qkap81 with SMTP id p81so34186570qka.2 for ; Fri, 09 Oct 2015 08:38:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=B879xi6dGWi8UxzfQ5TgaJNriVa6dhcieVrUi6jkej4=; b=HYZawQrUWnJoO6KZUvgKxagQ8KmiZL5YFofrYV2jyfQvQ85h7x+DwQvT6I+qT9+6WI 85tduO0B9tT4GzhjzXDoE7K2EPA8eihDR1OfVJ8zxxxFkK33sCwh3FzdnGKNA5P+jCM8 W/Op2E8hjVSoB2pEaH6wk4wohQInfxZdqZnZmO0wsaeup49kvAxSCcpgcbZbEtdmvyQJ acYzAmolPh/u3aakvWF2yOgRS8XU2wk1Gg1eu1YD4CPyFR2jxYaR7v4ZCCRGTni7CPTz KWCi+OfUBqzz8ssRYwSeTja66OdSDIvyeZp5zxK8+Cuk7jW7VxY8kRmLT7AiaEycJ1+y lLKw== X-Gm-Message-State: ALoCoQkJDwRb07B/fKPRTaO7KXZJfxS/sBjwC5TVgB4R3jdMf3an50Rmg+0LQxZhybqeD9mnRCzW MIME-Version: 1.0 X-Received: by 10.55.24.6 with SMTP id j6mr15851251qkh.93.1444405127842; Fri, 09 Oct 2015 08:38:47 -0700 (PDT) Sender: wlosh@bsdimp.com Received: by 10.140.80.167 with HTTP; Fri, 9 Oct 2015 08:38:47 -0700 (PDT) X-Originating-IP: [50.253.99.174] In-Reply-To: <1444392942.1258.YahooMailBasic@web120801.mail.ne1.yahoo.com> References: <20151008223935.GH67524@funkthat.com> <1444392942.1258.YahooMailBasic@web120801.mail.ne1.yahoo.com> Date: Fri, 9 Oct 2015 09:38:47 -0600 X-Google-Sender-Auth: WPa_jV2GJ0R3ejCyTmkNJujcKLg Message-ID: Subject: Re: Memory barrier From: Warner Losh To: Leonardo Fogel Cc: John-Mark Gurney , "freebsd-drivers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Oct 2015 15:38:55 -0000 On Fri, Oct 9, 2015 at 6:15 AM, Leonardo Fogel wrote: > On Thu, 10/8/15, John-Mark Gurney wrote: > > > If this is a PCI device, you need to do a read from the device before > > it is guaranteed that all the bridges have flushed the writes to the > > device... A barrier only guarantees from the processor's perspective > > that the write "has completed", but not that it will reach the device.. > > > > If this is a different bus, then the rules are probably different... > > Good points. I've ignored them. > It is a System-on-Chip based on ARM, which has different buses and > bridges. Device registers are memory-mapped (MMIO). > The formal definition of memory barriers is quite obscure; in simple > terms: memory accesses before the barrier are "observed" before memory > accesses after the barrier. However, the definition of an "observer" is not > provided. Since the device registers are memory-mapped, I've assumed that a > write before the barrier would reach the device before a write after the > barrier. But, on a second thought, the buses and bridges might reorder > them. I really don't know, but, to be on the safe side, I'll include the > read. > Thanks for your attention. > Yes, memory barriers are CPU artifacts. They tell you nothing about what any bridges or other bus technology has done before it reaches the actual device. If you need write ordering in the actual device, you almost certainly need to do a read to act as a write barrier. Warner