diff options
author | se <se@FreeBSD.org> | 2007-07-20 23:02:01 +0000 |
---|---|---|
committer | se <se@FreeBSD.org> | 2007-07-20 23:02:01 +0000 |
commit | 192b9573601035404375d85939b0e5cfd098f7a8 (patch) | |
tree | b88238747f4a5ae20bf46f5ed3386da50807f750 /sys/dev/sym | |
parent | 8fdd1a79d0f77863b38e6de503ef08f19bef2e89 (diff) | |
download | FreeBSD-src-192b9573601035404375d85939b0e5cfd098f7a8.zip FreeBSD-src-192b9573601035404375d85939b0e5cfd098f7a8.tar.gz |
Fix Symbios driver on amd64: Since amd64 has 64 bit pointers but the same
4KB pages as i386, data structures that just fit in one page on i386 (and
on 64 bit architectures with 8KB pages) can be distributed over two pages
on amd64. This is a porblem in the case of the Symbios driver, since the
SCRIPTS engine in the SCSI chip operates on physical addresses and needs
physically contiguous memory. Earlier patches used contigmalloc on amd64,
but this version replaces part of a structure by a pointer to that data.
In order to not introduce an extra indirection for other architectures,
the change has been made conditional on __amd64__.
Earlier attempts to repair this problem are removed (i.e. the macros that
made amd64 use contigmalloc). The fix was submitted by Jan Mikkelsen and
modified by me to only affect amd64.
PR: 89550
Submitted by: janm at transactionware dot com (Jan Mikkelsen)
Approved by: re (Hiroki Sato)
MFC after: 2 weeks
Diffstat (limited to 'sys/dev/sym')
-rw-r--r-- | sys/dev/sym/sym_hipd.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index f3bdc92..547db54 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -373,11 +373,7 @@ static void MDELAY(int ms) { while (ms--) UDELAY(1000); } */ #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 @@ -386,14 +382,8 @@ static void MDELAY(int ms) { while (ms--) UDELAY(1000); } #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 */ @@ -627,7 +617,7 @@ static m_addr_t ___dma_getp(m_pool_s *mp) 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; @@ -687,7 +677,7 @@ static m_pool_s *___cre_dma_pool(bus_dma_tag_t dev_dmat) 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)) { @@ -1536,7 +1526,11 @@ struct sym_hcb { /* * Target data. */ +#ifdef __amd64__ + struct sym_tcb *target; +#else struct sym_tcb target[SYM_CONF_MAX_TARGET]; +#endif /* * Target control block bus address array used by the SCRIPT @@ -8532,6 +8526,12 @@ sym_pci_attach(device_t dev) np->fw_patch = fw->patch; np->fw_name = fw->name; +#ifdef __amd64__ + np->target = sym_calloc_dma(SYM_CONF_MAX_TARGET * sizeof(*(np->target)), + "TARGET"); + if (!np->target) + goto attach_failed; +#endif /* * Edit its name. */ @@ -8930,6 +8930,11 @@ static void sym_pci_free(hcb_p np) "LUNMP"); #endif } +#ifdef __amd64__ + if (np->target) + sym_mfree_dma(np->target, + SYM_CONF_MAX_TARGET * sizeof(*(np->target)), "TARGET"); +#endif if (np->targtbl) sym_mfree_dma(np->targtbl, 256, "TARGTBL"); if (np->data_dmat) |