From owner-freebsd-hackers@FreeBSD.ORG Fri May 27 09:14:40 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 614D916A41C for ; Fri, 27 May 2005 09:14:40 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id C248943D1F for ; Fri, 27 May 2005 09:14:39 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id 6951B7CF41 for ; Fri, 27 May 2005 11:14:37 +0200 (CEST) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09516-06 for ; Fri, 27 May 2005 11:14:32 +0200 (CEST) Received: from firewall.demig (p5092941B.dip0.t-ipconnect.de [80.146.148.27]) by server.absolute-media.de (Postfix) with ESMTP id 737767C68D for ; Fri, 27 May 2005 11:14:32 +0200 (CEST) Received: from ws-ew-3 (ws-ew-3.w2kdemig [192.168.1.72]) by firewall.demig (8.13.4/8.13.1) with SMTP id j4R9BUaL075972 for ; Fri, 27 May 2005 11:11:30 +0200 (CEST) (envelope-from NKoch@demig.de) From: "Norbert Koch" To: Date: Fri, 27 May 2005 11:11:29 +0200 Message-ID: <000401c5629c$117c34a0$4801a8c0@ws-ew-3.W2KDEMIG> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0 X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Subject: panic in device driver strategy function: bp->b_dev==NULL X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2005 09:14:40 -0000 Hello, I have written a small device driver for a static ram based disk. The code is - more or less - derived from Poul Henning Kamp's md device. It is written for FreeBSD 4.X. This device is kld-loaded and runs without any problems with my 'standard' kernel configuration. As soon as I boot a kernel with some debug settings the driver crashes due to a failed assertion in my strategy routine. ******** Here are the diffs between my standard(-) and debug(+) kernel configuration: +options DDB +options DEBUG_LOCKS +options KBDIO_DEBUG +options SC_DEBUG_LEVEL=5 -options PANIC_REBOOT_WAIT_TIME=5 +options PANIC_REBOOT_WAIT_TIME=60 -options SC_DISABLE_DDBKEY +options SC_HISTORY_SIZE=1000 -device sio0 at isa? port IO_COM1 flags 0x10 irq 4 +device sio0 at isa? port IO_COM1 flags 0x90 irq 4 Some of the common options are HZ=400, DEVICE_POLLING, KTRACE, NO_SWAPPING, SOFTUPDATES, UFS_DIRHASH ******** Here is my debugging output: (kgdb) bt #1 0xc0153318 in panic (fmt=0xc0cabc80 "\"sram.c\", 362: sram_strategy: bp->b_dev==NULL") at ../../kern/kern_shutdown.c:593 #2 0xc0cab2e8 in sram_strategy (bp=0xc349bdc0) at sram.c:362 #3 0xc015ccad in diskstrategy (bp=0xc349bdc0) at ../../kern/subr_disk.c:251 #4 0xc0224952 in dsinit (dev=0xc0ca3e80, lp=0xc0c240d0, sspp=0xc0c240cc) at ../../kern/subr_diskmbr.c:191 #5 0xc015dbfa in dsopen (dev=0xc0ca3e80, mode=8192, flags=0, sspp=0xc0c240cc, lp=0xc0c240d0) at ../../kern/subr_diskslice.c:696 #6 0xc015cb36 in diskopen (dev=0xc0ca3e80, oflags=1, devtype=8192, p=0xc7bb5260) at ../../kern/subr_disk.c:196 #7 0xc018d72d in spec_open (ap=0xc8908dfc) at ../../miscfs/specfs/spec_vnops.c:193 #8 0xc018d62d in spec_vnoperate (ap=0xc8908dfc) at ../../miscfs/specfs/spec_vnops.c:119 #9 0xc01ccfb5 in ufs_vnoperatespec (ap=0xc8908dfc) at ../../ufs/ufs/ufs_vnops.c:2394 #10 0xc0189641 in vn_open (ndp=0xc8908ec8, fmode=1, cmode=385) at vnode_if.h:189 #11 0xc01854ec in open (p=0xc7bb5260, uap=0xc8908f80) at ../../kern/vfs_syscalls.c:1035 #12 0xc02193f9 in syscall2 (frame={tf_fs = 47, tf_es = 47, tf_ds = 47, tf_edi = 134543916, tf_esi = -1077936648, tf_ebp = -1077936736, tf_isp = -930050092, tf_ebx = 0, tf_edx = 134543904, tf_ecx = -13, tf_eax = 5, tf_trapno = 0, tf_err = 2, tf_eip = 671988064, tf_cs = 31, tf_eflags = 582, tf_esp = -1077937068, tf_ss = 47}) at ../../i386/i386/trap.c:1255 #13 0xc020c685 in Xint0x80_syscall () (kgdb) frame 2 (kgdb) p *bp $2 = {b_hash = {le_next = 0xc3504000, le_prev = 0xc0286c0c}, b_vnbufs = {tqe_next = 0x0, tqe_prev = 0x0}, b_freelist = {tqe_next = 0xc349bf18, tqe_prev = 0xc026e9e8}, b_act = {tqe_next = 0x0, tqe_prev = 0x0}, b_flags = 1122304, b_qindex = 0, b_xflags = 0 '\000', b_lock = {lk_interlock = {lock_data = 0}, lk_flags = 1024, lk_sharecount = 0, lk_waitcount = 0, lk_exclusivecount = 1, lk_prio = 20, lk_wmesg = 0xc0239afc "bufwait", lk_timo = 0, lk_lockholder = 134}, b_error = -1071408864, b_bufsize = -1071408848, b_runningbufspace = 286, b_bcount = 0, b_resid = 512, b_dev = 0x0, b_data = 0x200
, b_kvabase = 0x0, b_kvasize = -1060487424, b_lblkno = -1060470784, b_blkno = -1014542336, b_offset = 16384, b_iodone = 0, b_iodone_chain = 0xffffffff, b_vp = 0xffffffff, b_dirtyoff = 0, b_dirtyend = 0, b_rcred = 0x0, b_wcred = 0x0, b_pblkno = 0, b_saveaddr = 0x0, b_driver1 = 0x0, b_driver2 = 0x0, b_caller1 = 0x0, b_caller2 = 0x0, b_pager = { pg_spc = 0x0, pg_reqpage = 0}, b_cluster = {cluster_head = {tqh_first = 0x0, tqh_last = 0x0}, cluster_entry = {tqe_next = 0x0, tqe_prev = 0x0}}, b_pages = {0x0 }, b_npages = 0, b_dep = {lh_first = 0x0}, b_chain = {parent = 0x0, count = 0}} ******** And here is the source of the beginning of my strategy routine: static void sram_strategy (struct buf * bp) { intrmask_t s; struct sram_softc * sc; ASSERT (bp != NULL, "sram_strategy: bp==NULL");/* #1 */ ASSERT (bp->b_dev != NULL, "sram_strategy: bp->b_dev==NULL");/* #2 */ sc = bp->b_dev->si_drv1; ASSERT (sc != NULL, "sram_strategy: bp->b_dev->si_drv1==NULL");/* #3 */ DPRINTF (9, "sram_strategy: (%p) %s %lx, %d, %ld, %p)\n", bp, devtoname (bp->b_dev), bp->b_flags, bp->b_blkno, bp->b_bcount / DEV_BSIZE, bp->b_data); s = splbio (); ... ASSERT #2 fails. Any idea? Thank you for any help, Norbert Koch