Date: Tue, 26 Sep 2006 13:13:19 +1000 From: "Jan Mikkelsen" <janm@transactionware.com> To: <freebsd-stable@freebsd.org> Cc: 'Stefan Esser' <se@FreeBSD.org> Subject: RE: Patch: sym(4) "VTOBUS FAILED" panics on amd64, amd64/89550 Message-ID: <003001c6e119$b7d59e20$c801a8c0@transactionware.com> In-Reply-To: <001701c6df61$48504640$0202a8c0@transactzbkv04>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003001c6e119$b7d59e20$c801a8c0>