diff options
| -rw-r--r-- | drivers/atm/fore200e.c | 128 | ||||
| -rw-r--r-- | drivers/atm/fore200e.h | 2 |
2 files changed, 45 insertions, 85 deletions
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index beeb71088560..86be269500a9 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
| @@ -209,6 +209,34 @@ fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk) | |||
| 209 | kfree(chunk->alloc_addr); | 209 | kfree(chunk->alloc_addr); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | /* | ||
| 213 | * Allocate a DMA consistent chunk of memory intended to act as a communication | ||
| 214 | * mechanism (to hold descriptors, status, queues, etc.) shared by the driver | ||
| 215 | * and the adapter. | ||
| 216 | */ | ||
| 217 | static int | ||
| 218 | fore200e_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk, | ||
| 219 | int size, int nbr, int alignment) | ||
| 220 | { | ||
| 221 | /* returned chunks are page-aligned */ | ||
| 222 | chunk->alloc_size = size * nbr; | ||
| 223 | chunk->alloc_addr = dma_alloc_coherent(fore200e->dev, chunk->alloc_size, | ||
| 224 | &chunk->dma_addr, GFP_KERNEL); | ||
| 225 | if (!chunk->alloc_addr) | ||
| 226 | return -ENOMEM; | ||
| 227 | chunk->align_addr = chunk->alloc_addr; | ||
| 228 | return 0; | ||
| 229 | } | ||
| 230 | |||
| 231 | /* | ||
| 232 | * Free a DMA consistent chunk of memory. | ||
| 233 | */ | ||
| 234 | static void | ||
| 235 | fore200e_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk) | ||
| 236 | { | ||
| 237 | dma_free_coherent(fore200e->dev, chunk->alloc_size, chunk->alloc_addr, | ||
| 238 | chunk->dma_addr); | ||
| 239 | } | ||
| 212 | 240 | ||
| 213 | static void | 241 | static void |
| 214 | fore200e_spin(int msecs) | 242 | fore200e_spin(int msecs) |
| @@ -301,10 +329,10 @@ fore200e_uninit_bs_queue(struct fore200e* fore200e) | |||
| 301 | struct chunk* rbd_block = &fore200e->host_bsq[ scheme ][ magn ].rbd_block; | 329 | struct chunk* rbd_block = &fore200e->host_bsq[ scheme ][ magn ].rbd_block; |
| 302 | 330 | ||
| 303 | if (status->alloc_addr) | 331 | if (status->alloc_addr) |
| 304 | fore200e->bus->dma_chunk_free(fore200e, status); | 332 | fore200e_dma_chunk_free(fore200e, status); |
| 305 | 333 | ||
| 306 | if (rbd_block->alloc_addr) | 334 | if (rbd_block->alloc_addr) |
| 307 | fore200e->bus->dma_chunk_free(fore200e, rbd_block); | 335 | fore200e_dma_chunk_free(fore200e, rbd_block); |
| 308 | } | 336 | } |
| 309 | } | 337 | } |
| 310 | } | 338 | } |
| @@ -370,17 +398,17 @@ fore200e_shutdown(struct fore200e* fore200e) | |||
| 370 | 398 | ||
| 371 | /* fall through */ | 399 | /* fall through */ |
| 372 | case FORE200E_STATE_INIT_RXQ: | 400 | case FORE200E_STATE_INIT_RXQ: |
| 373 | fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.status); | 401 | fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.status); |
| 374 | fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.rpd); | 402 | fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.rpd); |
| 375 | 403 | ||
| 376 | /* fall through */ | 404 | /* fall through */ |
| 377 | case FORE200E_STATE_INIT_TXQ: | 405 | case FORE200E_STATE_INIT_TXQ: |
| 378 | fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.status); | 406 | fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.status); |
| 379 | fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.tpd); | 407 | fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.tpd); |
| 380 | 408 | ||
| 381 | /* fall through */ | 409 | /* fall through */ |
| 382 | case FORE200E_STATE_INIT_CMDQ: | 410 | case FORE200E_STATE_INIT_CMDQ: |
| 383 | fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_cmdq.status); | 411 | fore200e_dma_chunk_free(fore200e, &fore200e->host_cmdq.status); |
| 384 | 412 | ||
| 385 | /* fall through */ | 413 | /* fall through */ |
| 386 | case FORE200E_STATE_INITIALIZE: | 414 | case FORE200E_STATE_INITIALIZE: |
| @@ -427,41 +455,6 @@ static void fore200e_pca_write(u32 val, volatile u32 __iomem *addr) | |||
| 427 | writel(cpu_to_le32(val), addr); | 455 | writel(cpu_to_le32(val), addr); |
| 428 | } | 456 | } |
| 429 | 457 | ||
| 430 | /* allocate a DMA consistent chunk of memory intended to act as a communication mechanism | ||
| 431 | (to hold descriptors, status, queues, etc.) shared by the driver and the adapter */ | ||
| 432 | |||
| 433 | static int | ||
| 434 | fore200e_pca_dma_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, | ||
| 435 | int size, int nbr, int alignment) | ||
| 436 | { | ||
| 437 | /* returned chunks are page-aligned */ | ||
| 438 | chunk->alloc_size = size * nbr; | ||
| 439 | chunk->alloc_addr = dma_alloc_coherent(fore200e->dev, | ||
| 440 | chunk->alloc_size, | ||
| 441 | &chunk->dma_addr, | ||
| 442 | GFP_KERNEL); | ||
| 443 | |||
| 444 | if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0)) | ||
| 445 | return -ENOMEM; | ||
| 446 | |||
| 447 | chunk->align_addr = chunk->alloc_addr; | ||
| 448 | |||
| 449 | return 0; | ||
| 450 | } | ||
| 451 | |||
| 452 | |||
| 453 | /* free a DMA consistent chunk of memory */ | ||
| 454 | |||
| 455 | static void | ||
| 456 | fore200e_pca_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk) | ||
| 457 | { | ||
| 458 | dma_free_coherent(fore200e->dev, | ||
| 459 | chunk->alloc_size, | ||
| 460 | chunk->alloc_addr, | ||
| 461 | chunk->dma_addr); | ||
| 462 | } | ||
| 463 | |||
| 464 | |||
| 465 | static int | 458 | static int |
| 466 | fore200e_pca_irq_check(struct fore200e* fore200e) | 459 | fore200e_pca_irq_check(struct fore200e* fore200e) |
| 467 | { | 460 | { |
| @@ -631,8 +624,6 @@ static const struct fore200e_bus fore200e_pci_ops = { | |||
| 631 | .status_alignment = 32, | 624 | .status_alignment = 32, |
| 632 | .read = fore200e_pca_read, | 625 | .read = fore200e_pca_read, |
| 633 | .write = fore200e_pca_write, | 626 | .write = fore200e_pca_write, |
| 634 | .dma_chunk_alloc = fore200e_pca_dma_chunk_alloc, | ||
| 635 | .dma_chunk_free = fore200e_pca_dma_chunk_free, | ||
| 636 | .configure = fore200e_pca_configure, | 627 | .configure = fore200e_pca_configure, |
| 637 | .map = fore200e_pca_map, | 628 | .map = fore200e_pca_map, |
| 638 | .reset = fore200e_pca_reset, | 629 | .reset = fore200e_pca_reset, |
| @@ -656,33 +647,6 @@ static void fore200e_sba_write(u32 val, volatile u32 __iomem *addr) | |||
| 656 | sbus_writel(val, addr); | 647 | sbus_writel(val, addr); |
| 657 | } | 648 | } |
| 658 | 649 | ||
| 659 | /* Allocate a DVMA consistent chunk of memory intended to act as a communication mechanism | ||
| 660 | * (to hold descriptors, status, queues, etc.) shared by the driver and the adapter. | ||
| 661 | */ | ||
| 662 | static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk, | ||
| 663 | int size, int nbr, int alignment) | ||
| 664 | { | ||
| 665 | chunk->alloc_size = size * nbr; | ||
| 666 | |||
| 667 | /* returned chunks are page-aligned */ | ||
| 668 | chunk->alloc_addr = dma_alloc_coherent(fore200e->dev, chunk->alloc_size, | ||
| 669 | &chunk->dma_addr, GFP_ATOMIC); | ||
| 670 | |||
| 671 | if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0)) | ||
| 672 | return -ENOMEM; | ||
| 673 | |||
| 674 | chunk->align_addr = chunk->alloc_addr; | ||
| 675 | |||
| 676 | return 0; | ||
| 677 | } | ||
| 678 | |||
| 679 | /* free a DVMA consistent chunk of memory */ | ||
| 680 | static void fore200e_sba_dma_chunk_free(struct fore200e *fore200e, struct chunk *chunk) | ||
| 681 | { | ||
| 682 | dma_free_coherent(fore200e->dev, chunk->alloc_size, | ||
| 683 | chunk->alloc_addr, chunk->dma_addr); | ||
| 684 | } | ||
| 685 | |||
| 686 | static void fore200e_sba_irq_enable(struct fore200e *fore200e) | 650 | static void fore200e_sba_irq_enable(struct fore200e *fore200e) |
| 687 | { | 651 | { |
| 688 | u32 hcr = fore200e->bus->read(fore200e->regs.sba.hcr) & SBA200E_HCR_STICKY; | 652 | u32 hcr = fore200e->bus->read(fore200e->regs.sba.hcr) & SBA200E_HCR_STICKY; |
| @@ -796,8 +760,6 @@ static const struct fore200e_bus fore200e_sbus_ops = { | |||
| 796 | .status_alignment = 32, | 760 | .status_alignment = 32, |
| 797 | .read = fore200e_sba_read, | 761 | .read = fore200e_sba_read, |
| 798 | .write = fore200e_sba_write, | 762 | .write = fore200e_sba_write, |
| 799 | .dma_chunk_alloc = fore200e_sba_dma_chunk_alloc, | ||
| 800 | .dma_chunk_free = fore200e_sba_dma_chunk_free, | ||
| 801 | .configure = fore200e_sba_configure, | 763 | .configure = fore200e_sba_configure, |
| 802 | .map = fore200e_sba_map, | 764 | .map = fore200e_sba_map, |
| 803 | .reset = fore200e_sba_reset, | 765 | .reset = fore200e_sba_reset, |
| @@ -2111,7 +2073,7 @@ static int fore200e_init_bs_queue(struct fore200e *fore200e) | |||
| 2111 | bsq = &fore200e->host_bsq[ scheme ][ magn ]; | 2073 | bsq = &fore200e->host_bsq[ scheme ][ magn ]; |
| 2112 | 2074 | ||
| 2113 | /* allocate and align the array of status words */ | 2075 | /* allocate and align the array of status words */ |
| 2114 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2076 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2115 | &bsq->status, | 2077 | &bsq->status, |
| 2116 | sizeof(enum status), | 2078 | sizeof(enum status), |
| 2117 | QUEUE_SIZE_BS, | 2079 | QUEUE_SIZE_BS, |
| @@ -2120,13 +2082,13 @@ static int fore200e_init_bs_queue(struct fore200e *fore200e) | |||
| 2120 | } | 2082 | } |
| 2121 | 2083 | ||
| 2122 | /* allocate and align the array of receive buffer descriptors */ | 2084 | /* allocate and align the array of receive buffer descriptors */ |
| 2123 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2085 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2124 | &bsq->rbd_block, | 2086 | &bsq->rbd_block, |
| 2125 | sizeof(struct rbd_block), | 2087 | sizeof(struct rbd_block), |
| 2126 | QUEUE_SIZE_BS, | 2088 | QUEUE_SIZE_BS, |
| 2127 | fore200e->bus->descr_alignment) < 0) { | 2089 | fore200e->bus->descr_alignment) < 0) { |
| 2128 | 2090 | ||
| 2129 | fore200e->bus->dma_chunk_free(fore200e, &bsq->status); | 2091 | fore200e_dma_chunk_free(fore200e, &bsq->status); |
| 2130 | return -ENOMEM; | 2092 | return -ENOMEM; |
| 2131 | } | 2093 | } |
| 2132 | 2094 | ||
| @@ -2167,7 +2129,7 @@ static int fore200e_init_rx_queue(struct fore200e *fore200e) | |||
| 2167 | DPRINTK(2, "receive queue is being initialized\n"); | 2129 | DPRINTK(2, "receive queue is being initialized\n"); |
| 2168 | 2130 | ||
| 2169 | /* allocate and align the array of status words */ | 2131 | /* allocate and align the array of status words */ |
| 2170 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2132 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2171 | &rxq->status, | 2133 | &rxq->status, |
| 2172 | sizeof(enum status), | 2134 | sizeof(enum status), |
| 2173 | QUEUE_SIZE_RX, | 2135 | QUEUE_SIZE_RX, |
| @@ -2176,13 +2138,13 @@ static int fore200e_init_rx_queue(struct fore200e *fore200e) | |||
| 2176 | } | 2138 | } |
| 2177 | 2139 | ||
| 2178 | /* allocate and align the array of receive PDU descriptors */ | 2140 | /* allocate and align the array of receive PDU descriptors */ |
| 2179 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2141 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2180 | &rxq->rpd, | 2142 | &rxq->rpd, |
| 2181 | sizeof(struct rpd), | 2143 | sizeof(struct rpd), |
| 2182 | QUEUE_SIZE_RX, | 2144 | QUEUE_SIZE_RX, |
| 2183 | fore200e->bus->descr_alignment) < 0) { | 2145 | fore200e->bus->descr_alignment) < 0) { |
| 2184 | 2146 | ||
| 2185 | fore200e->bus->dma_chunk_free(fore200e, &rxq->status); | 2147 | fore200e_dma_chunk_free(fore200e, &rxq->status); |
| 2186 | return -ENOMEM; | 2148 | return -ENOMEM; |
| 2187 | } | 2149 | } |
| 2188 | 2150 | ||
| @@ -2226,7 +2188,7 @@ static int fore200e_init_tx_queue(struct fore200e *fore200e) | |||
| 2226 | DPRINTK(2, "transmit queue is being initialized\n"); | 2188 | DPRINTK(2, "transmit queue is being initialized\n"); |
| 2227 | 2189 | ||
| 2228 | /* allocate and align the array of status words */ | 2190 | /* allocate and align the array of status words */ |
| 2229 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2191 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2230 | &txq->status, | 2192 | &txq->status, |
| 2231 | sizeof(enum status), | 2193 | sizeof(enum status), |
| 2232 | QUEUE_SIZE_TX, | 2194 | QUEUE_SIZE_TX, |
| @@ -2235,13 +2197,13 @@ static int fore200e_init_tx_queue(struct fore200e *fore200e) | |||
| 2235 | } | 2197 | } |
| 2236 | 2198 | ||
| 2237 | /* allocate and align the array of transmit PDU descriptors */ | 2199 | /* allocate and align the array of transmit PDU descriptors */ |
| 2238 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2200 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2239 | &txq->tpd, | 2201 | &txq->tpd, |
| 2240 | sizeof(struct tpd), | 2202 | sizeof(struct tpd), |
| 2241 | QUEUE_SIZE_TX, | 2203 | QUEUE_SIZE_TX, |
| 2242 | fore200e->bus->descr_alignment) < 0) { | 2204 | fore200e->bus->descr_alignment) < 0) { |
| 2243 | 2205 | ||
| 2244 | fore200e->bus->dma_chunk_free(fore200e, &txq->status); | 2206 | fore200e_dma_chunk_free(fore200e, &txq->status); |
| 2245 | return -ENOMEM; | 2207 | return -ENOMEM; |
| 2246 | } | 2208 | } |
| 2247 | 2209 | ||
| @@ -2288,7 +2250,7 @@ static int fore200e_init_cmd_queue(struct fore200e *fore200e) | |||
| 2288 | DPRINTK(2, "command queue is being initialized\n"); | 2250 | DPRINTK(2, "command queue is being initialized\n"); |
| 2289 | 2251 | ||
| 2290 | /* allocate and align the array of status words */ | 2252 | /* allocate and align the array of status words */ |
| 2291 | if (fore200e->bus->dma_chunk_alloc(fore200e, | 2253 | if (fore200e_dma_chunk_alloc(fore200e, |
| 2292 | &cmdq->status, | 2254 | &cmdq->status, |
| 2293 | sizeof(enum status), | 2255 | sizeof(enum status), |
| 2294 | QUEUE_SIZE_CMD, | 2256 | QUEUE_SIZE_CMD, |
diff --git a/drivers/atm/fore200e.h b/drivers/atm/fore200e.h index f62fc9b85db0..caf0ea6a328a 100644 --- a/drivers/atm/fore200e.h +++ b/drivers/atm/fore200e.h | |||
| @@ -805,8 +805,6 @@ typedef struct fore200e_bus { | |||
| 805 | int status_alignment; /* status words DMA alignment requirement */ | 805 | int status_alignment; /* status words DMA alignment requirement */ |
| 806 | u32 (*read)(volatile u32 __iomem *); | 806 | u32 (*read)(volatile u32 __iomem *); |
| 807 | void (*write)(u32, volatile u32 __iomem *); | 807 | void (*write)(u32, volatile u32 __iomem *); |
| 808 | int (*dma_chunk_alloc)(struct fore200e*, struct chunk*, int, int, int); | ||
| 809 | void (*dma_chunk_free)(struct fore200e*, struct chunk*); | ||
| 810 | int (*configure)(struct fore200e*); | 808 | int (*configure)(struct fore200e*); |
| 811 | int (*map)(struct fore200e*); | 809 | int (*map)(struct fore200e*); |
| 812 | void (*reset)(struct fore200e*); | 810 | void (*reset)(struct fore200e*); |
