From owner-freebsd-arm@FreeBSD.ORG Fri Jan 16 23:34:55 2015 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 739CD1CB; Fri, 16 Jan 2015 23:34:55 +0000 (UTC) Received: from mail-wg0-x232.google.com (mail-wg0-x232.google.com [IPv6:2a00:1450:400c:c00::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1E5B7F97; Fri, 16 Jan 2015 23:34:55 +0000 (UTC) Received: by mail-wg0-f50.google.com with SMTP id n12so1161042wgh.9; Fri, 16 Jan 2015 15:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=umxtFma3dLSgFYqzY9iBAbLM3n6xnYfxSDAE9aDvgyE=; b=HWO+Ud4YQ2Fh8pbJC1cwz9IoV4+vWFh5aO4vZilXg2APz2rkwB4rK63jAYoXOVOAVy 9eUkTMAaHFRwIXj/PQ3v2qG3fHs3ag+1iQThWXPIkET2pyN9D3Dt8lJCLmzdZFNrNFka a548z/EjEB/P4lCt7CnONsEmbDyZjvkYI9MxqP0ERF/PTVWWAv32FVUDHrtBo0+RtUgu 8aBK4QTl454Cas7IJcN8hAzxs8TT8Gb2OfGMz3zDFmWPRe0U3ed0td1FUgSrHlErOXEh 4u26YNZjs4tZ6Q9quDDzcl3ZnYj1MeOI0WQlbqAtpkT2UpZHef7B2ghUjNrFgm/l4BhQ 8Glw== MIME-Version: 1.0 X-Received: by 10.180.74.15 with SMTP id p15mr10960929wiv.29.1421451293583; Fri, 16 Jan 2015 15:34:53 -0800 (PST) Sender: johny.mattsson@gmail.com Received: by 10.27.82.83 with HTTP; Fri, 16 Jan 2015 15:34:53 -0800 (PST) In-Reply-To: <1421432019.14601.302.camel@freebsd.org> References: <54B945FB.10609@freenet.de> <1421432019.14601.302.camel@freebsd.org> Date: Sat, 17 Jan 2015 10:34:53 +1100 X-Google-Sender-Auth: mgspsCOTto0VGuYdCOn3cMxNYV0 Message-ID: Subject: Re: mmap-issue From: Johny Mattsson To: Ian Lepore Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-arm@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jan 2015 23:34:55 -0000 On 17 January 2015 at 05:13, Ian Lepore wrote: > My gut-level reply is "Don't try to access hardware registers like that, > you're only going to run into problems" (as you already have). But I've > just been informed that linux allows such things. Indeed it does, and what a life^Wproject-saver it can be! Only last year I had to deal with an existing large-scale deployment (100,000s of devices) where a peripheral on the SPI bus had a hardware bug where it could intermittently "lose" a clock pulse and get itself completely out of sync on the bus. Being able to quietly pull the SPI control from the driver and do a little dance on the clock and data lines in GPIO mode before returning control to the driver saved the day on that one. A few years before that, we had some extremely performance sensitive network I/O to deal with, where we effectively had a driver stub which allocated the resources and then allowed them to be mmap()ed into userspace for direct hardware control. Given the complexity of the system, it wasn't considered viable to have this processing done in the kernel. Another case is the Linux Raspberry Pi userpace library libbcm2835 which provides gpio control (among other things), similar to what you'd get normally through /sys/class/gpio but with two major distinctions: (a) it provides access to pull-up/downs, which is not normally available in Linux, and (b) it provides a whole different level of performance compared to going through the kernel. > It seems crazy to me > to allow userland access to the same hardware that freebsd drivers are > trying to work with. > Absolutely, and you can't complain if things break when you do. But having the ability to pull stunts like this is gold. Cheers, /Johny