Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Nov 1998 11:34:27 +0000 (GMT)
From:      Doug Rabson <dfr@nlsystems.com>
To:        Mike Smith <mike@smith.net.au>
Cc:        shimon@simon-shapiro.org, freebsd-alpha@FreeBSD.ORG
Subject:   Re: UnAligned Access, but why? 
Message-ID:  <Pine.BSF.4.01.9811241131400.21711-100000@herring.nlsystems.com>
In-Reply-To: <199811240553.VAA02779@dingo.cdrom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 23 Nov 1998, Mike Smith wrote:

> > > > 
> > > > The bus_space_read_[14] are causing unaligned access panics.  These
> > > > panics
> > > > can be eliminated by casting explicitly:
> > >  
> > >  Don't do this.  Align the objects you're trying to transfer instead.
> > 
> > Thanx, but how?  I took the CAM driver as is and just triesd to actually
> > align the data.  It makes no difference at all.  I am still getting the
> > panics.  If you look again at my example (the one following the casts), you
> > will see that it does not help.
> 
> I saw no evidence that you were performing aligned transfers; your
> example was, if I remember correctly, casting some arbitrary pointer to 
> a pointer to a 32-bit object.  This will fail if the arbitrary 
> pointer's value is not 32-bit aligned.
> 
> > Also (forgive my ignorance here), different PCI busss appear to have
> > different sizes for the same thing.  Or, at least this is how all this
> > bus_rea/write stuff tries to imply.
> 
> No.  Different PCI bus implementations used different host methods to
> achieve identical PCI bus transactions.
> 
> > The end result is a mass confusion on my part.  i am trying to fit the
> > driver into the existing framework, not change the framework (unless
> > obviously broken).  I do not have enough information to suggest anything is
> > broken, except the panics.
> 
> The problem is most likely that you are attempting to access a local 
> memory data structure member of a given size that is not aligned to 
> that size, or you are attempting to access a data structure inside a 
> PCI device where the region in question is memory-mapped and the data 
> structure is not aligned in the mapping according to its size.
> 
> > I may need some detailed help here....
> 
> You may need to provide a more detailed example.  To begin with, it'd
> help if you can clarify whether you're sure you understand what
> constitutes an "unaligned access", as that's pretty key to working out 
> where you're falling over here.

You must not pass unaligned offsets to in[wl], out[wl], read[wl] and
write[wl].  For 'w' sized accesses, the offset must be even aligned, for
'l' sized accesses, the offset must be a multiple of 4.  I think NetBSD
has code to panic if an illegal offset is used to access device memory.  I
may do the same (probably for kernels compiled with DIAGNOSTIC defined).

--
Doug Rabson				Mail:  dfr@nlsystems.com
Nonlinear Systems Ltd.			Phone: +44 181 951 1891
					Fax:   +44 181 381 1039


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.01.9811241131400.21711-100000>