From owner-freebsd-scsi  Thu Sep 30 10:43:47 1999
Delivered-To: freebsd-scsi@freebsd.org
Received: from panzer.kdm.org (panzer.kdm.org [216.160.178.169])
	by hub.freebsd.org (Postfix) with ESMTP
	id C4DBC14F1B; Thu, 30 Sep 1999 10:43:41 -0700 (PDT)
	(envelope-from ken@panzer.kdm.org)
Received: (from ken@localhost)
	by panzer.kdm.org (8.9.3/8.9.1) id LAA32290;
	Thu, 30 Sep 1999 11:40:57 -0600 (MDT)
	(envelope-from ken)
Message-Id: <199909301740.LAA32290@panzer.kdm.org>
Subject: Re: check for unaligned buffers in CAM [was Re: Cdrecord problems...]
In-Reply-To: <19990930115210.A325@frolic.no-support.loc> from Bjoern Fischer at "Sep 30, 1999 11:52:10 am"
To: bfischer@Techfak.Uni-Bielefeld.DE (Bjoern Fischer)
Date: Thu, 30 Sep 1999 11:40:57 -0600 (MDT)
Cc: mmuir@es.co.nz (Mike Muir),
	elie@uncle.cult.cu (Eliezer Rodriguez Gonzalez),
	freebsd-stable@FreeBSD.ORG, freebsd-scsi@FreeBSD.ORG
From: "Kenneth D. Merry" <ken@kdm.org>
X-Mailer: ELM [version 2.4ME+ PL54 (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Sender: owner-freebsd-scsi@FreeBSD.ORG
Precedence: bulk
X-Loop: FreeBSD.org

Bjoern Fischer wrote...
> On Thu, Sep 30, 1999 at 10:34:15AM +1200, Mike Muir wrote:
> > Eliezer Rodriguez Gonzalez wrote:
> > > 
> > > Hello everybody:
> > > 
> > > Finally I was able to burn my own copy of 3.3-RELEASE, downloaded via ftp
> > > from a mirror site.
> > > I found out, by research and because Mr Fischer told me so, that while
> > > using version 1.6.1 of cdrecord there was a problem using the internal
> > > buffer, so I disabled that feature via the command option fs=0 and then
> > > everything worked fine and I was able to burn my CD-ROM with the older
> > > cdrecord version.
> > 
> > This also happens when using 1.8a28 under -current.. not quite sure why,
> > but i'm
> > guessing for the same reasons outlined in an earlier posting in this
> > thread.
> > (I'm going to try a29 next).
> 
> You could check for unaligned buffers in
> sys/cam/cam_periph.c:cam_periph_mapmem() (around line 530 in -stable).
> 
> One (Kenneth? me?) could also make this debugging hook permanent in
> conjunction with one or more sysctl knobs which switch on the check
> or/and -- even better -- send a signal (SIGBUS?) to the process on
> unaligned buffers. That would make it very easy to debug not only
> cdrecord but *any* userland process that uses cam transport.
> 
> Any opinions?

I think it would be better for userland code authors to use the tools
available for debugging.  It's pretty easy to do something like

assert((ccb->csio.data_ptr & PAGE_MASK) == 0);

Sending non-page-aligned buffers to the passthrough driver is not
forbidden outright.  The problem is sending buffers that are close (within
a page) to the maximum size (64K) that are not page aligned.

Joerg had a problem at one point in cdrecord with non page-aligned buffers,
and he fixed it.  My guess is that he has introduced a new problem.  If you
tell him about it, I'm sure he'll fix it.  (I think he may be out of town
at the moment, so it may be a little while before he responds.)

In the mean time, you can get around the problem by changing the CAM
version of scsi_maxdma() in libscg/scsi-bsd.c to return DFLTPHYS -
PAGE_SIZE instead of DFLTPHYS.  That will prevent the problem from
occuring.

Ken
-- 
Kenneth Merry
ken@kdm.org


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