Skip site navigation (1)Skip section navigation (2)
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

[-- Attachment #1 --]

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

[-- Attachment #2 --]
--- /home/janm/p4/image-freebsd-std-main/FreeBSD/src/sys/dev/sym/sym_hipd.c	Sun Sep 24 08:06:41 2006
+++ sym_hipd.c	Mon Sep 25 17:25:02 2006
@@ -421,11 +421,7 @@
  */
 
 #define MEMO_SHIFT	4	/* 16 bytes minimum memory chunk */
-#ifndef __amd64__
 #define MEMO_PAGE_ORDER	0	/* 1 PAGE  maximum */
-#else
-#define MEMO_PAGE_ORDER	1	/* 2 PAGEs maximum on amd64 */
-#endif
 #if 0
 #define MEMO_FREE_UNUSED	/* Free unused pages immediately */
 #endif
@@ -434,14 +430,8 @@
 #define MEMO_CLUSTER_SIZE	(1UL << MEMO_CLUSTER_SHIFT)
 #define MEMO_CLUSTER_MASK	(MEMO_CLUSTER_SIZE-1)
 
-#ifndef __amd64__
 #define get_pages()		malloc(MEMO_CLUSTER_SIZE, M_DEVBUF, M_NOWAIT)
 #define free_pages(p)		free((p), M_DEVBUF)
-#else
-#define get_pages()		contigmalloc(MEMO_CLUSTER_SIZE, M_DEVBUF, \
-				    0, 0, 1LL << 32, PAGE_SIZE, 1LL << 32)
-#define free_pages(p)		contigfree((p), MEMO_CLUSTER_SIZE, M_DEVBUF)
-#endif
 
 typedef u_long m_addr_t;	/* Enough bits to bit-hack addresses */
 
@@ -675,7 +665,7 @@
 			      BUS_DMA_NOWAIT, &vbp->dmamap))
 		goto out_err;
 	bus_dmamap_load(mp->dmat, vbp->dmamap, vaddr,
-			MEMO_CLUSTER_SIZE, getbaddrcb, &baddr, 0);
+			MEMO_CLUSTER_SIZE, getbaddrcb, &baddr, BUS_DMA_NOWAIT);
 	if (baddr) {
 		int hc = VTOB_HASH_CODE(vaddr);
 		vbp->vaddr = (m_addr_t) vaddr;
@@ -735,7 +725,7 @@
 		mp->dev_dmat = dev_dmat;
 		if (!bus_dma_tag_create(dev_dmat, 1, MEMO_CLUSTER_SIZE,
 			       BUS_SPACE_MAXADDR_32BIT,
-			       BUS_SPACE_MAXADDR_32BIT,
+			       BUS_SPACE_MAXADDR,
 			       NULL, NULL, MEMO_CLUSTER_SIZE, 1,
 			       MEMO_CLUSTER_SIZE, 0,
 			       busdma_lock_mutex, &Giant, &mp->dmat)) {
@@ -1592,7 +1582,7 @@
 	/*
 	 *  Target data.
 	 */
-	struct sym_tcb	target[SYM_CONF_MAX_TARGET];
+	struct sym_tcb	*target;
 
 	/*
 	 *  Target control block bus address array used by the SCRIPT 
@@ -8698,6 +8688,11 @@
 	np->fw_patch	 = fw->patch;
 	np->fw_name	 = fw->name;
 
+	np->target = sym_calloc_dma(SYM_CONF_MAX_TARGET * sizeof(*(np->target)),
+			"TARGET");
+	if (!np->target)
+		goto attach_failed;
+
 	/*
 	 * Edit its name.
 	 */
@@ -9096,6 +9091,9 @@
 			       "LUNMP");
 #endif 
 	}
+	if (np->target)
+		sym_mfree_dma(np->target,
+			SYM_CONF_MAX_TARGET * sizeof(*(np->target)), "TARGET");
 	if (np->targtbl)
 		sym_mfree_dma(np->targtbl, 256, "TARGTBL");
 	if (np->data_dmat)

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003001c6e119$b7d59e20$c801a8c0>