From owner-freebsd-scsi@FreeBSD.ORG Tue Mar 22 16:35:04 2005 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB99516A4CE for ; Tue, 22 Mar 2005 16:35:04 +0000 (GMT) Received: from mail.black-hole.com (192-34.bhi.com [216.185.192.34]) by mx1.FreeBSD.org (Postfix) with ESMTP id 71D8543D2F for ; Tue, 22 Mar 2005 16:35:04 +0000 (GMT) (envelope-from hank@blackhole.com) Received: from blackhole.com (mail.black-hole.com [127.0.0.1]) by blackhole.com for ; Tue, 22 Mar 2005 10:33:55 -0600 Message-ID: <380-220053222163355859@blackhole.com> X-Priority: 3 From: "Henry Miller" To: freebsd-scsi@freebsd.org Date: Tue, 22 Mar 2005 10:33:55 -0600 MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: scsi_ch issues X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2005 16:35:05 -0000 I posted a summery of this to -questions earlier this morning (you can read it there if you want background), I've dug into it more, and I think there is a bug in =20 cam/scsi/scsi=5Fch=2Ec function chgetelemstatus=2E The short summery is my tape changer says that PVOLTAG in pg=5Fhdr is=20 FALSE, (or zeroed latter) in the first request of=20 scsi=5Fread=5Felement=5Fstatus() (which freeBSD uses only to get the lengt= h of the data) on one of my changers, and thus chio(1) will not show the bar code label=2E pg=5Fhdr is not updated to reflect the location of result of the second call, when this flag is set=2E Worse, it looks like the results of the first call is a dead pointer by the time it checks anyway=2E Unless free/malloc work different in the kernel from userland this is a problem=2E I've sniped out a lot of extra code so you can see what I mean=2E =20 data =3D (caddr=5Ft)malloc(1024, M=5FDEVBUF, M=5FWAITOK); --- Fill data to get size pg=5Fhdr =3D \* data + some offset *\ /* * Reallocate storage for descriptors and get them from the * device=2E */ free(data, M=5FDEVBUF); data =3D (caddr=5Ft)malloc(size, M=5FDEVBUF, M=5FWAITOK); --- Fill data=20 copy=5Felement=5Fstatus(softc, pg=5Fhdr->flags, desc, ces); Note that pg=5Fhdr is not valid at this point anyway=2E This more or less happens in 4=2Ex, 5=2Ex and current if I read the code correctly=2E Can someone who knows kernel code better than I look at this=2E =20 Should I send a pr=3F Here is a patch against 4=2E9 (where I first found this problem) that might help to understand the fix=2E I think it needs to be ported to all versions=2E (and perhaps netbsd if there is where we get the code=3F) =20 *** scsi=5Fch=2Ec=2Eold Tue Mar 22 11:16:15 2005 --- scsi=5Fch=2Ec Tue Mar 22 11:09:13 2005 *************** *** 1184,1189 **** --- 1184,1192 ---- * Fill in the user status array=2E */ st=5Fhdr =3D (struct read=5Felement=5Fstatus=5Fheader *)data; + pg=5Fhdr =3D (struct read=5Felement=5Fstatus=5Fpage=5Fheader *)((uintptr=5Ft)st=5Fhdr + + sizeof(struct read=5Felement=5Fstatus=5Fheader)); + avail =3D scsi=5F2btoul(st=5Fhdr->count); if (avail !=3D cesr->cesr=5Felement=5Fcount) {