From owner-freebsd-stable@FreeBSD.ORG Tue Sep 26 03:13:23 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CDC3716A40F for ; Tue, 26 Sep 2006 03:13:23 +0000 (UTC) (envelope-from janm@transactionware.com) Received: from mail.transactionware.com (mail.transactionware.com [203.14.245.7]) by mx1.FreeBSD.org (Postfix) with SMTP id AA24343D46 for ; Tue, 26 Sep 2006 03:13:22 +0000 (GMT) (envelope-from janm@transactionware.com) Received: (qmail 7242 invoked from network); 26 Sep 2006 03:13:42 -0000 Received: from new.transactionware.com (192.168.1.55) by dm.transactionware.com with SMTP; 26 Sep 2006 03:13:42 -0000 Received: (qmail 79405 invoked by uid 1026); 26 Sep 2006 03:13:42 -0000 Received: from 127.0.0.1 by new.transactionware.com (envelope-from , uid 1003) with qmail-scanner-1.25 (spamassassin: 3.0.2. Clear:RC:1(127.0.0.1):. Processed in 3.289937 secs); 26 Sep 2006 03:13:42 -0000 Received: from unknown (HELO JMLAPTOP) (unknown) by unknown with SMTP; 26 Sep 2006 03:13:38 -0000 From: "Jan Mikkelsen" To: Date: Tue, 26 Sep 2006 13:13:19 +1000 Organization: Transactionware Message-ID: <003001c6e119$b7d59e20$c801a8c0@transactionware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0031_01C6E16D.8981AE20" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Importance: Normal In-Reply-To: <001701c6df61$48504640$0202a8c0@transactzbkv04> Cc: 'Stefan Esser' Subject: RE: Patch: sym(4) "VTOBUS FAILED" panics on amd64, amd64/89550 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Sep 2006 03:13:24 -0000 This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C6E16D.8981AE20 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Attached is a simpler patch, after some feedback from Stefan over general niceness. It removes the amd64 special case by splitting the target member (an array of struct sym_tcb) of sym_hcb out into a separately allocated structure. This way there is never a need to allocate anything bigger than a page and the whole problem goes away with minimal change, less wasted memory and fewer outright hacks. I did spend some time looking at ripping out the custom allocator entirely, and got as far as it building and one of the cache tests failing. I don't think I'm going to spend the time to track down why; if anyone wants to pick it up then let me know. Regards, Jan Mikkelsen ------=_NextPart_000_0031_01C6E16D.8981AE20 Content-Type: application/octet-stream; name="sym_hipd.c-smaller-hcb.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sym_hipd.c-smaller-hcb.diff" --- = /home/janm/p4/image-freebsd-std-main/FreeBSD/src/sys/dev/sym/sym_hipd.c = Sun Sep 24 08:06:41 2006=0A= +++ sym_hipd.c Mon Sep 25 17:25:02 2006=0A= @@ -421,11 +421,7 @@=0A= */=0A= =0A= #define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */=0A= -#ifndef __amd64__=0A= #define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */=0A= -#else=0A= -#define MEMO_PAGE_ORDER 1 /* 2 PAGEs maximum on amd64 */=0A= -#endif=0A= #if 0=0A= #define MEMO_FREE_UNUSED /* Free unused pages immediately */=0A= #endif=0A= @@ -434,14 +430,8 @@=0A= #define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT)=0A= #define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)=0A= =0A= -#ifndef __amd64__=0A= #define get_pages() malloc(MEMO_CLUSTER_SIZE, M_DEVBUF, M_NOWAIT)=0A= #define free_pages(p) free((p), M_DEVBUF)=0A= -#else=0A= -#define get_pages() contigmalloc(MEMO_CLUSTER_SIZE, M_DEVBUF, \=0A= - 0, 0, 1LL << 32, PAGE_SIZE, 1LL << 32)=0A= -#define free_pages(p) contigfree((p), MEMO_CLUSTER_SIZE, M_DEVBUF)=0A= -#endif=0A= =0A= typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */=0A= =0A= @@ -675,7 +665,7 @@=0A= BUS_DMA_NOWAIT, &vbp->dmamap))=0A= goto out_err;=0A= bus_dmamap_load(mp->dmat, vbp->dmamap, vaddr,=0A= - MEMO_CLUSTER_SIZE, getbaddrcb, &baddr, 0);=0A= + MEMO_CLUSTER_SIZE, getbaddrcb, &baddr, BUS_DMA_NOWAIT);=0A= if (baddr) {=0A= int hc =3D VTOB_HASH_CODE(vaddr);=0A= vbp->vaddr =3D (m_addr_t) vaddr;=0A= @@ -735,7 +725,7 @@=0A= mp->dev_dmat =3D dev_dmat;=0A= if (!bus_dma_tag_create(dev_dmat, 1, MEMO_CLUSTER_SIZE,=0A= BUS_SPACE_MAXADDR_32BIT,=0A= - BUS_SPACE_MAXADDR_32BIT,=0A= + BUS_SPACE_MAXADDR,=0A= NULL, NULL, MEMO_CLUSTER_SIZE, 1,=0A= MEMO_CLUSTER_SIZE, 0,=0A= busdma_lock_mutex, &Giant, &mp->dmat)) {=0A= @@ -1592,7 +1582,7 @@=0A= /*=0A= * Target data.=0A= */=0A= - struct sym_tcb target[SYM_CONF_MAX_TARGET];=0A= + struct sym_tcb *target;=0A= =0A= /*=0A= * Target control block bus address array used by the SCRIPT =0A= @@ -8698,6 +8688,11 @@=0A= np->fw_patch =3D fw->patch;=0A= np->fw_name =3D fw->name;=0A= =0A= + np->target =3D sym_calloc_dma(SYM_CONF_MAX_TARGET * = sizeof(*(np->target)),=0A= + "TARGET");=0A= + if (!np->target)=0A= + goto attach_failed;=0A= +=0A= /*=0A= * Edit its name.=0A= */=0A= @@ -9096,6 +9091,9 @@=0A= "LUNMP");=0A= #endif =0A= }=0A= + if (np->target)=0A= + sym_mfree_dma(np->target,=0A= + SYM_CONF_MAX_TARGET * sizeof(*(np->target)), "TARGET");=0A= if (np->targtbl)=0A= sym_mfree_dma(np->targtbl, 256, "TARGTBL");=0A= if (np->data_dmat)=0A= ------=_NextPart_000_0031_01C6E16D.8981AE20--