Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: pxa_dma: add support for legacy transition

In order to achieve smooth transition of pxa drivers from old legacy dma
handling to new dmaengine, introduce a function to "hide" dma physical
channels from dmaengine.

This is temporary situation where pxa dma will be handled in 2 places :
- arch/arm/plat-pxa/dma.c
- drivers/dma/pxa_dma.c

The resources, ie. dma channels, will be controlled by pxa_dma. The
legacy code will request or release a channel with
pxad_toggle_reserved_channel().

This is not very pretty, but it ensures both legacy and dmaengine
consumers can live in the same kernel until the conversion is done.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Robert Jarzmik and committed by
Vinod Koul
c91134d9 c01d1b51

+28
+28
drivers/dma/pxa_dma.c
··· 410 410 static inline void pxad_cleanup_debugfs(struct pxad_device *pdev) {} 411 411 #endif 412 412 413 + /* 414 + * In the transition phase where legacy pxa handling is done at the same time as 415 + * mmp_dma, the DMA physical channel split between the 2 DMA providers is done 416 + * through legacy_reserved. Legacy code reserves DMA channels by settings 417 + * corresponding bits in legacy_reserved. 418 + */ 419 + static u32 legacy_reserved; 420 + static u32 legacy_unavailable; 421 + 413 422 static struct pxad_phy *lookup_phy(struct pxad_chan *pchan) 414 423 { 415 424 int prio, i; ··· 439 430 for (i = 0; i < pdev->nr_chans; i++) { 440 431 if (prio != (i & 0xf) >> 2) 441 432 continue; 433 + if ((i < 32) && (legacy_reserved & BIT(i))) 434 + continue; 442 435 phy = &pdev->phys[i]; 443 436 if (!phy->vchan) { 444 437 phy->vchan = pchan; 445 438 found = phy; 439 + if (i < 32) 440 + legacy_unavailable |= BIT(i); 446 441 goto out_unlock; 447 442 } 448 443 } ··· 466 453 struct pxad_device *pdev = to_pxad_dev(chan->vc.chan.device); 467 454 unsigned long flags; 468 455 u32 reg; 456 + int i; 469 457 470 458 dev_dbg(&chan->vc.chan.dev->device, 471 459 "%s(): freeing\n", __func__); ··· 478 464 writel_relaxed(0, chan->phy->base + reg); 479 465 480 466 spin_lock_irqsave(&pdev->phy_lock, flags); 467 + for (i = 0; i < 32; i++) 468 + if (chan->phy == &pdev->phys[i]) 469 + legacy_unavailable &= ~BIT(i); 481 470 chan->phy->vchan = NULL; 482 471 chan->phy = NULL; 483 472 spin_unlock_irqrestore(&pdev->phy_lock, flags); ··· 711 694 i = __ffs(dint); 712 695 dint &= (dint - 1); 713 696 phy = &pdev->phys[i]; 697 + if ((i < 32) && (legacy_reserved & BIT(i))) 698 + continue; 714 699 if (pxad_chan_handler(irq, phy) == IRQ_HANDLED) 715 700 ret = IRQ_HANDLED; 716 701 } ··· 1450 1431 return true; 1451 1432 } 1452 1433 EXPORT_SYMBOL_GPL(pxad_filter_fn); 1434 + 1435 + int pxad_toggle_reserved_channel(int legacy_channel) 1436 + { 1437 + if (legacy_unavailable & (BIT(legacy_channel))) 1438 + return -EBUSY; 1439 + legacy_reserved ^= BIT(legacy_channel); 1440 + return 0; 1441 + } 1442 + EXPORT_SYMBOL_GPL(pxad_toggle_reserved_channel); 1453 1443 1454 1444 module_platform_driver(pxad_driver); 1455 1445