Lines Matching refs:plxdev

129 static struct plx_dma_desc *plx_dma_get_desc(struct plx_dma_dev *plxdev, int i)  in plx_dma_get_desc()  argument
131 return plxdev->desc_ring[i & (PLX_DMA_RING_COUNT - 1)]; in plx_dma_get_desc()
134 static void plx_dma_process_desc(struct plx_dma_dev *plxdev) in plx_dma_process_desc() argument
140 spin_lock(&plxdev->ring_lock); in plx_dma_process_desc()
142 while (plxdev->tail != plxdev->head) { in plx_dma_process_desc()
143 desc = plx_dma_get_desc(plxdev, plxdev->tail); in plx_dma_process_desc()
165 plxdev->tail++; in plx_dma_process_desc()
168 spin_unlock(&plxdev->ring_lock); in plx_dma_process_desc()
171 static void plx_dma_abort_desc(struct plx_dma_dev *plxdev) in plx_dma_abort_desc() argument
176 plx_dma_process_desc(plxdev); in plx_dma_abort_desc()
178 spin_lock_bh(&plxdev->ring_lock); in plx_dma_abort_desc()
180 while (plxdev->tail != plxdev->head) { in plx_dma_abort_desc()
181 desc = plx_dma_get_desc(plxdev, plxdev->tail); in plx_dma_abort_desc()
192 plxdev->tail++; in plx_dma_abort_desc()
195 spin_unlock_bh(&plxdev->ring_lock); in plx_dma_abort_desc()
198 static void __plx_dma_stop(struct plx_dma_dev *plxdev) in __plx_dma_stop() argument
203 val = readl(plxdev->bar + PLX_REG_CTRL); in __plx_dma_stop()
208 plxdev->bar + PLX_REG_CTRL); in __plx_dma_stop()
211 val = readl(plxdev->bar + PLX_REG_CTRL); in __plx_dma_stop()
219 dev_err(plxdev->dma_dev.dev, in __plx_dma_stop()
223 plxdev->bar + PLX_REG_CTRL); in __plx_dma_stop()
225 writel(0, plxdev->bar + PLX_REG_DESC_RING_COUNT); in __plx_dma_stop()
226 writel(0, plxdev->bar + PLX_REG_DESC_RING_ADDR); in __plx_dma_stop()
227 writel(0, plxdev->bar + PLX_REG_DESC_RING_ADDR_HI); in __plx_dma_stop()
228 writel(0, plxdev->bar + PLX_REG_DESC_RING_NEXT_ADDR); in __plx_dma_stop()
231 static void plx_dma_stop(struct plx_dma_dev *plxdev) in plx_dma_stop() argument
234 if (!rcu_dereference(plxdev->pdev)) { in plx_dma_stop()
239 __plx_dma_stop(plxdev); in plx_dma_stop()
246 struct plx_dma_dev *plxdev = from_tasklet(plxdev, t, desc_task); in plx_dma_desc_task() local
248 plx_dma_process_desc(plxdev); in plx_dma_desc_task()
254 __acquires(plxdev->ring_lock) in plx_dma_prep_memcpy()
256 struct plx_dma_dev *plxdev = chan_to_plx_dma_dev(c); in plx_dma_prep_memcpy() local
259 spin_lock_bh(&plxdev->ring_lock); in plx_dma_prep_memcpy()
260 if (!plxdev->ring_active) in plx_dma_prep_memcpy()
263 if (!CIRC_SPACE(plxdev->head, plxdev->tail, PLX_DMA_RING_COUNT)) in plx_dma_prep_memcpy()
269 plxdesc = plx_dma_get_desc(plxdev, plxdev->head); in plx_dma_prep_memcpy()
270 plxdev->head++; in plx_dma_prep_memcpy()
294 __acquire(plxdev->ring_lock); in plx_dma_prep_memcpy()
296 spin_unlock_bh(&plxdev->ring_lock); in plx_dma_prep_memcpy()
301 __releases(plxdev->ring_lock) in plx_dma_tx_submit()
303 struct plx_dma_dev *plxdev = chan_to_plx_dma_dev(desc->chan); in plx_dma_tx_submit() local
317 spin_unlock_bh(&plxdev->ring_lock); in plx_dma_tx_submit()
325 struct plx_dma_dev *plxdev = chan_to_plx_dma_dev(chan); in plx_dma_tx_status() local
332 plx_dma_process_desc(plxdev); in plx_dma_tx_status()
339 struct plx_dma_dev *plxdev = chan_to_plx_dma_dev(chan); in plx_dma_issue_pending() local
342 if (!rcu_dereference(plxdev->pdev)) { in plx_dma_issue_pending()
353 writew(PLX_REG_CTRL_START_VAL, plxdev->bar + PLX_REG_CTRL); in plx_dma_issue_pending()
360 struct plx_dma_dev *plxdev = devid; in plx_dma_isr() local
363 status = readw(plxdev->bar + PLX_REG_INTR_STATUS); in plx_dma_isr()
368 if (status & PLX_REG_INTR_STATUS_DESC_DONE && plxdev->ring_active) in plx_dma_isr()
369 tasklet_schedule(&plxdev->desc_task); in plx_dma_isr()
371 writew(status, plxdev->bar + PLX_REG_INTR_STATUS); in plx_dma_isr()
376 static int plx_dma_alloc_desc(struct plx_dma_dev *plxdev) in plx_dma_alloc_desc() argument
381 plxdev->desc_ring = kzalloc_objs(*plxdev->desc_ring, PLX_DMA_RING_COUNT); in plx_dma_alloc_desc()
382 if (!plxdev->desc_ring) in plx_dma_alloc_desc()
390 dma_async_tx_descriptor_init(&desc->txd, &plxdev->dma_chan); in plx_dma_alloc_desc()
392 desc->hw = &plxdev->hw_ring[i]; in plx_dma_alloc_desc()
394 plxdev->desc_ring[i] = desc; in plx_dma_alloc_desc()
401 kfree(plxdev->desc_ring[i]); in plx_dma_alloc_desc()
402 kfree(plxdev->desc_ring); in plx_dma_alloc_desc()
408 struct plx_dma_dev *plxdev = chan_to_plx_dma_dev(chan); in plx_dma_alloc_chan_resources() local
409 size_t ring_sz = PLX_DMA_RING_COUNT * sizeof(*plxdev->hw_ring); in plx_dma_alloc_chan_resources()
412 plxdev->head = plxdev->tail = 0; in plx_dma_alloc_chan_resources()
413 plxdev->hw_ring = dma_alloc_coherent(plxdev->dma_dev.dev, ring_sz, in plx_dma_alloc_chan_resources()
414 &plxdev->hw_ring_dma, GFP_KERNEL); in plx_dma_alloc_chan_resources()
415 if (!plxdev->hw_ring) in plx_dma_alloc_chan_resources()
418 rc = plx_dma_alloc_desc(plxdev); in plx_dma_alloc_chan_resources()
423 if (!rcu_dereference(plxdev->pdev)) { in plx_dma_alloc_chan_resources()
429 writel(PLX_REG_CTRL_RESET_VAL, plxdev->bar + PLX_REG_CTRL); in plx_dma_alloc_chan_resources()
430 writel(lower_32_bits(plxdev->hw_ring_dma), in plx_dma_alloc_chan_resources()
431 plxdev->bar + PLX_REG_DESC_RING_ADDR); in plx_dma_alloc_chan_resources()
432 writel(upper_32_bits(plxdev->hw_ring_dma), in plx_dma_alloc_chan_resources()
433 plxdev->bar + PLX_REG_DESC_RING_ADDR_HI); in plx_dma_alloc_chan_resources()
434 writel(lower_32_bits(plxdev->hw_ring_dma), in plx_dma_alloc_chan_resources()
435 plxdev->bar + PLX_REG_DESC_RING_NEXT_ADDR); in plx_dma_alloc_chan_resources()
436 writel(PLX_DMA_RING_COUNT, plxdev->bar + PLX_REG_DESC_RING_COUNT); in plx_dma_alloc_chan_resources()
437 writel(PLX_REG_PREF_LIMIT_PREF_FOUR, plxdev->bar + PLX_REG_PREF_LIMIT); in plx_dma_alloc_chan_resources()
439 plxdev->ring_active = true; in plx_dma_alloc_chan_resources()
446 dma_free_coherent(plxdev->dma_dev.dev, ring_sz, plxdev->hw_ring, in plx_dma_alloc_chan_resources()
447 plxdev->hw_ring_dma); in plx_dma_alloc_chan_resources()
453 struct plx_dma_dev *plxdev = chan_to_plx_dma_dev(chan); in plx_dma_free_chan_resources() local
454 size_t ring_sz = PLX_DMA_RING_COUNT * sizeof(*plxdev->hw_ring); in plx_dma_free_chan_resources()
459 spin_lock_bh(&plxdev->ring_lock); in plx_dma_free_chan_resources()
460 plxdev->ring_active = false; in plx_dma_free_chan_resources()
461 spin_unlock_bh(&plxdev->ring_lock); in plx_dma_free_chan_resources()
463 plx_dma_stop(plxdev); in plx_dma_free_chan_resources()
466 pdev = rcu_dereference(plxdev->pdev); in plx_dma_free_chan_resources()
474 tasklet_kill(&plxdev->desc_task); in plx_dma_free_chan_resources()
476 plx_dma_abort_desc(plxdev); in plx_dma_free_chan_resources()
479 kfree(plxdev->desc_ring[i]); in plx_dma_free_chan_resources()
481 kfree(plxdev->desc_ring); in plx_dma_free_chan_resources()
482 dma_free_coherent(plxdev->dma_dev.dev, ring_sz, plxdev->hw_ring, in plx_dma_free_chan_resources()
483 plxdev->hw_ring_dma); in plx_dma_free_chan_resources()
489 struct plx_dma_dev *plxdev = in plx_dma_release() local
493 kfree(plxdev); in plx_dma_release()
498 struct plx_dma_dev *plxdev; in plx_dma_create() local
503 plxdev = kzalloc_obj(*plxdev); in plx_dma_create()
504 if (!plxdev) in plx_dma_create()
508 KBUILD_MODNAME, plxdev); in plx_dma_create()
512 spin_lock_init(&plxdev->ring_lock); in plx_dma_create()
513 tasklet_setup(&plxdev->desc_task, plx_dma_desc_task); in plx_dma_create()
515 RCU_INIT_POINTER(plxdev->pdev, pdev); in plx_dma_create()
516 plxdev->bar = pcim_iomap_table(pdev)[0]; in plx_dma_create()
518 dma = &plxdev->dma_dev; in plx_dma_create()
531 chan = &plxdev->dma_chan; in plx_dma_create()
542 pci_set_drvdata(pdev, plxdev); in plx_dma_create()
548 free_irq(pci_irq_vector(pdev, 0), plxdev); in plx_dma_create()
550 kfree(plxdev); in plx_dma_create()
595 struct plx_dma_dev *plxdev = pci_get_drvdata(pdev); in plx_dma_remove() local
597 free_irq(pci_irq_vector(pdev, 0), plxdev); in plx_dma_remove()
599 rcu_assign_pointer(plxdev->pdev, NULL); in plx_dma_remove()
602 spin_lock_bh(&plxdev->ring_lock); in plx_dma_remove()
603 plxdev->ring_active = false; in plx_dma_remove()
604 spin_unlock_bh(&plxdev->ring_lock); in plx_dma_remove()
606 __plx_dma_stop(plxdev); in plx_dma_remove()
607 plx_dma_abort_desc(plxdev); in plx_dma_remove()
609 plxdev->bar = NULL; in plx_dma_remove()
610 dma_async_device_unregister(&plxdev->dma_dev); in plx_dma_remove()