From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 9 18:25:48 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3FCEBACE for ; Tue, 9 Oct 2012 18:25:48 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 1210F8FC1D for ; Tue, 9 Oct 2012 18:25:48 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 6333FB91E; Tue, 9 Oct 2012 14:25:47 -0400 (EDT) From: John Baldwin To: Warner Losh Subject: Re: No bus_space_read_8 on x86 ? Date: Tue, 9 Oct 2012 11:54:15 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p20; KDE/4.5.5; amd64; ; ) References: <506DC574.9010300@intel.com> <201210051208.45550.jhb@freebsd.org> <8BC4C95F-2D10-46A5-89C8-74801BB4E23A@bsdimp.com> In-Reply-To: <8BC4C95F-2D10-46A5-89C8-74801BB4E23A@bsdimp.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201210091154.15873.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 09 Oct 2012 14:25:47 -0400 (EDT) Cc: freebsd-hackers@freebsd.org, Carl Delsey X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Oct 2012 18:25:48 -0000 On Monday, October 08, 2012 4:59:24 pm Warner Losh wrote: > > On Oct 5, 2012, at 10:08 AM, John Baldwin wrote: > > > On Thursday, October 04, 2012 1:20:52 pm Carl Delsey wrote: > >> I noticed that the bus_space_*_8 functions are unimplemented for x86. > >> Looking at the code, it seems this is intentional. > >> > >> Is this done because on 32-bit systems we don't know, in the general > >> case, whether to read the upper or lower 32-bits first? > >> > >> If that's the reason, I was thinking we could provide two > >> implementations for i386: bus_space_read_8_upper_first and > >> bus_space_read_8_lower_first. For amd64 we would just have bus_space_read_8 > >> > >> Anybody who wants to use bus_space_read_8 in their file would do > >> something like: > >> #define BUS_SPACE_8_BYTES LOWER_FIRST > >> or > >> #define BUS_SPACE_8_BYTES UPPER_FIRST > >> whichever is appropriate for their hardware. > >> > >> This would go in their source file before including bus.h and we would > >> take care of mapping to the correct implementation. > >> > >> With the prevalence of 64-bit registers these days, if we don't provide > >> an implementation, I expect many drivers will end up rolling their own. > >> > >> If this seems like a good idea, I'll happily whip up a patch and submit it. > > > > I think cxgb* already have an implementation. For amd64 we should certainly > > have bus_space_*_8(), at least for SYS_RES_MEMORY. I think they should fail > > for SYS_RES_IOPORT. I don't think we can force a compile-time error though, > > would just have to return -1 on reads or some such? > > I believe it was because bus reads weren't guaranteed to be atomic on i386. > don't know if that's still the case or a concern, but it was an intentional omission. True. If you are on a 32-bit system you can read the two 4 byte values and then build a 64-bit value. For 64-bit platforms we should offer bus_read_8() however. -- John Baldwin