diff mbox

dmaengine: mv_xor: Add support for IO (PCIe) src/dst areas

Message ID 20160817095318.28034-1-sr@denx.de (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Roese Aug. 17, 2016, 9:53 a.m. UTC
To enable the access to a specific area, the MVEBU XOR controllers needs
to have this area enabled / mapped via an address window. Right now,
only the DRAM memory area is enabled via such memory windows. So
using this driver to DMA to / from a e.g. PCIe memory region is
currently not supported.

This patch now adds support for such PCIe / IO regions by checking
if the src / dst address is located in an IO memory area in contrast
to being located in DRAM. This is done by using the newly introduced
MBus function mvebu_mbus_get_io_win_info(). If the src / dst address
is located in such an IO area, a new address window is created in
the XOR DMA controller. Enabling the controller to access this area.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Marcin Wojtas <mw@semihalf.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vinod Koul <vinod.koul@intel.com>
---
RFC -> v1:
- Use a cache for the already mapped areas for performance reasons, as
  the MMIO registers don't need to get queried any more if the area is
  already mapped now

 drivers/dma/mv_xor.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 drivers/dma/mv_xor.h |  7 ++++
 2 files changed, 97 insertions(+), 1 deletion(-)

Comments

kernel test robot Aug. 24, 2016, 4:16 a.m. UTC | #1
Hi Stefan,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc3 next-20160823]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Stefan-Roese/dmaengine-mv_xor-Add-support-for-IO-PCIe-src-dst-areas/20160817-175632
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `set_param_ifnum':
>> ipmi_poweroff.c:(.text+0x10157c): undefined reference to `mvebu_mbus_get_io_win_info'
   drivers/built-in.o: In function `mv_xor_add_io_win':
   mv_xor.c:(.text+0x11039e): undefined reference to `mvebu_mbus_get_io_win_info'
   drivers/built-in.o: In function `mc13xxx_led_probe':
   leds-mc13783.c:(.init.text+0x39a9c): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15588)
   leds-mc13783.c:(.init.text+0x39b0c): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x155a8)
   leds-mc13783.c:(.init.text+0x39b28): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x155ac)
   leds-mc13783.c:(.init.text+0x39b46): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x155b0)
   leds-mc13783.c:(.init.text+0x39b5c): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x155b4)
   leds-mc13783.c:(.init.text+0x39b95): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x155b8)
   leds-mc13783.c:(.init.text+0x39b13): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x155fc)
   leds-mc13783.c:(.init.text+0x39b2f): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15600)
   leds-mc13783.c:(.init.text+0x39b87): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15604)
   leds-mc13783.c:(.init.text+0x39b9e): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15608)
   leds-mc13783.c:(.init.text+0x39be0): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1560c)
   drivers/built-in.o: In function `max77693_led_driver_init':
   leds-max77693.c:(.init.text+0x39bfb): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15610)
   leds-max77693.c:(.init.text+0x39c02): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15614)
   drivers/built-in.o: In function `max8997_led_driver_init':
   leds-max8997.c:(.init.text+0x39c0f): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15618)
   leds-max8997.c:(.init.text+0x39c16): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1561c)
   drivers/built-in.o: In function `lm355x_i2c_driver_init':
   leds-lm355x.c:(.init.text+0x39c23): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15620)
   leds-lm355x.c:(.init.text+0x39c2a): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15624)
   drivers/built-in.o: In function `blinkm_driver_init':
   leds-blinkm.c:(.init.text+0x39c37): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15628)
   leds-blinkm.c:(.init.text+0x39c3e): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1562c)
   drivers/built-in.o: In function `syscon_led_driver_init':
   leds-syscon.c:(.init.text+0x39c4b): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15630)
   leds-syscon.c:(.init.text+0x39c52): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15634)
   drivers/built-in.o: In function `menf21bmc_led_init':
   leds-menf21bmc.c:(.init.text+0x39c5f): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15638)
   leds-menf21bmc.c:(.init.text+0x39c66): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1563c)
   drivers/built-in.o: In function `ktd2692_driver_init':
   leds-ktd2692.c:(.init.text+0x39c73): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15640)
   leds-ktd2692.c:(.init.text+0x39c7a): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15644)
   drivers/built-in.o: In function `is31fl32xx_driver_init':
   leds-is31fl32xx.c:(.init.text+0x39c87): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15648)
   leds-is31fl32xx.c:(.init.text+0x39c8e): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1564c)
   drivers/built-in.o: In function `dac124s085_driver_init':
   leds-dac124s085.c:(.init.text+0x39c9b): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15650)
   leds-dac124s085.c:(.init.text+0x39ca2): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15654)
   drivers/built-in.o: In function `timer_trig_init':
   ledtrig-timer.c:(.init.text+0x39caf): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15658)
   ledtrig-timer.c:(.init.text+0x39cb4): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1565c)
   drivers/built-in.o: In function `oneshot_trig_init':
   ledtrig-oneshot.c:(.init.text+0x39cc3): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15660)
   ledtrig-oneshot.c:(.init.text+0x39cc8): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15664)
   drivers/built-in.o: In function `ledtrig_disk_init':
   ledtrig-disk.c:(.init.text+0x39cd7): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15668)
   ledtrig-disk.c:(.init.text+0x39cda): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1566c)
   ledtrig-disk.c:(.init.text+0x39ce5): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15670)
   ledtrig-disk.c:(.init.text+0x39ce8): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15674)
   ledtrig-disk.c:(.init.text+0x39cdf): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15678)
   ledtrig-disk.c:(.init.text+0x39cee): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1567c)
   drivers/built-in.o: In function `ledtrig_mtd_init':
   ledtrig-mtd.c:(.init.text+0x39cfb): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15680)
   ledtrig-mtd.c:(.init.text+0x39cfe): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15684)
   ledtrig-mtd.c:(.init.text+0x39d09): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15688)
   ledtrig-mtd.c:(.init.text+0x39d0c): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1568c)
   ledtrig-mtd.c:(.init.text+0x39d03): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15690)
   ledtrig-mtd.c:(.init.text+0x39d12): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15694)
   drivers/built-in.o: In function `heartbeat_trig_init':
   ledtrig-heartbeat.c:(.init.text+0x39d1f): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15698)
   ledtrig-heartbeat.c:(.init.text+0x39d30): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1569c)
   ledtrig-heartbeat.c:(.init.text+0x39d33): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156a0)
   ledtrig-heartbeat.c:(.init.text+0x39d3c): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156a4)
   ledtrig-heartbeat.c:(.init.text+0x39d24): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156a8)
   ledtrig-heartbeat.c:(.init.text+0x39d36): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156ac)
   ledtrig-heartbeat.c:(.init.text+0x39d3f): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156b0)
   drivers/built-in.o: In function `bl_trig_init':
   ledtrig-backlight.c:(.init.text+0x39d4b): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156b4)
   ledtrig-backlight.c:(.init.text+0x39d50): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156b8)
   drivers/built-in.o: In function `gpio_trig_init':
   ledtrig-gpio.c:(.init.text+0x39d5f): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156bc)
   ledtrig-gpio.c:(.init.text+0x39d64): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156c0)
   drivers/built-in.o: In function `ledtrig_cpu_init':
   ledtrig-cpu.c:(.init.text+0x39d73): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156c4)
   ledtrig-cpu.c:(.init.text+0x39d76): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156c8)
   ledtrig-cpu.c:(.init.text+0x39d89): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156cc)
   ledtrig-cpu.c:(.init.text+0x39d94): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156d0)
   ledtrig-cpu.c:(.init.text+0x39d9d): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156d4)
   ledtrig-cpu.c:(.init.text+0x39da0): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156d8)
   ledtrig-cpu.c:(.init.text+0x39da3): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156dc)
   ledtrig-cpu.c:(.init.text+0x39db8): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156e0)
   ledtrig-cpu.c:(.init.text+0x39dc1): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156e4)
   ledtrig-cpu.c:(.init.text+0x39d83): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156e8)
   ledtrig-cpu.c:(.init.text+0x39d8e): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156ec)
   ledtrig-cpu.c:(.init.text+0x39d97): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156f0)
   ledtrig-cpu.c:(.init.text+0x39dac): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156f4)
   ledtrig-cpu.c:(.init.text+0x39dbb): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156f8)
   ledtrig-cpu.c:(.init.text+0x39dc6): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x156fc)
   drivers/built-in.o: In function `defon_trig_init':
   ledtrig-default-on.c:(.init.text+0x39dd3): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15700)
   ledtrig-default-on.c:(.init.text+0x39dd8): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15704)
   drivers/built-in.o: In function `transient_trig_init':
   ledtrig-transient.c:(.init.text+0x39de7): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15708)
   ledtrig-transient.c:(.init.text+0x39dec): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x1570c)
   drivers/built-in.o: In function `ledtrig_camera_init':
   ledtrig-camera.c:(.init.text+0x39dfb): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15710)
   ledtrig-camera.c:(.init.text+0x39dfe): dangerous relocation: l32r: literal target out of range (try using text-section-literals): (.init.literal+0x15714)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Stefan Roese Aug. 24, 2016, 8:23 a.m. UTC | #2
On 24.08.2016 06:16, kbuild test robot wrote:
> Hi Stefan,
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.8-rc3 next-20160823]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> [Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
> [Check https://git-scm.com/docs/git-format-patch for more information]
> 
> url:    https://github.com/0day-ci/linux/commits/Stefan-Roese/dmaengine-mv_xor-Add-support-for-IO-PCIe-src-dst-areas/20160817-175632
> config: xtensa-allyesconfig (attached as .config)
> compiler: xtensa-linux-gcc (GCC) 4.9.0
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=xtensa 
> 
> All errors (new ones prefixed by >>):
> 
>    drivers/built-in.o: In function `set_param_ifnum':
>>> ipmi_poweroff.c:(.text+0x10157c): undefined reference to `mvebu_mbus_get_io_win_info'
>    drivers/built-in.o: In function `mv_xor_add_io_win':
>    mv_xor.c:(.text+0x11039e): undefined reference to `mvebu_mbus_get_io_win_info'

Does it really make sense to compile this driver for all archs?
Or should I send a v2 of this patch that removes COMPILE_TEST for
this driver from Kconfig so that its only compiled for the
target platforms?

Thanks,
Stefan
Thomas Petazzoni Aug. 24, 2016, 12:43 p.m. UTC | #3
Hello,

On Wed, 24 Aug 2016 10:23:02 +0200, Stefan Roese wrote:

> > All errors (new ones prefixed by >>):
> > 
> >    drivers/built-in.o: In function `set_param_ifnum':  
> >>> ipmi_poweroff.c:(.text+0x10157c): undefined reference to `mvebu_mbus_get_io_win_info'  
> >    drivers/built-in.o: In function `mv_xor_add_io_win':
> >    mv_xor.c:(.text+0x11039e): undefined reference to `mvebu_mbus_get_io_win_info'  
> 
> Does it really make sense to compile this driver for all archs?
> Or should I send a v2 of this patch that removes COMPILE_TEST for
> this driver from Kconfig so that its only compiled for the
> target platforms?

I'm not sure what's the exact policy, but I believe kernel maintainers
like when the compilation coverage is as wide as possible. The MBus
driver could provide some stub functions when not enabled? I don't know
if it's worth it, since indeed mv_xor is only ever going to be used on
ARM.

Thomas
Vinod Koul Aug. 30, 2016, 4:02 p.m. UTC | #4
On Wed, Aug 24, 2016 at 10:23:02AM +0200, Stefan Roese wrote:
> On 24.08.2016 06:16, kbuild test robot wrote:
> > Hi Stefan,
> > 
> > [auto build test ERROR on linus/master]
> > [also build test ERROR on v4.8-rc3 next-20160823]
> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> > [Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
> > [Check https://git-scm.com/docs/git-format-patch for more information]
> > 
> > url:    https://github.com/0day-ci/linux/commits/Stefan-Roese/dmaengine-mv_xor-Add-support-for-IO-PCIe-src-dst-areas/20160817-175632
> > config: xtensa-allyesconfig (attached as .config)
> > compiler: xtensa-linux-gcc (GCC) 4.9.0
> > reproduce:
> >         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # save the attached .config to linux build tree
> >         make.cross ARCH=xtensa 
> > 
> > All errors (new ones prefixed by >>):
> > 
> >    drivers/built-in.o: In function `set_param_ifnum':
> >>> ipmi_poweroff.c:(.text+0x10157c): undefined reference to `mvebu_mbus_get_io_win_info'
> >    drivers/built-in.o: In function `mv_xor_add_io_win':
> >    mv_xor.c:(.text+0x11039e): undefined reference to `mvebu_mbus_get_io_win_info'
> 
> Does it really make sense to compile this driver for all archs?
> Or should I send a v2 of this patch that removes COMPILE_TEST for
> this driver from Kconfig so that its only compiled for the
> target platforms?

Compile test is helpful :) 

If it is reasonable possible, that I would urge you to keep it.
diff mbox

Patch

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index f4c9f98..0162750 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -470,12 +470,86 @@  static int mv_xor_alloc_chan_resources(struct dma_chan *chan)
 	return mv_chan->slots_allocated ? : -ENOMEM;
 }
 
+/*
+ * Check if source or destination is an PCIe/IO address (non-SDRAM) and add
+ * a new MBus window if necessary. Use a cache for these check so that
+ * the MMIO mapped registers don't have to be accessed for this check
+ * to speed up this process.
+ */
+static int mv_xor_add_io_win(struct mv_xor_chan *mv_chan, u32 addr)
+{
+	struct mv_xor_device *xordev = mv_chan->xordev;
+	void __iomem *base = mv_chan->mmr_high_base;
+	u32 win_enable;
+	u32 size;
+	u8 target, attr;
+	int ret;
+	int i;
+
+	/*
+	 * Loop over the cached windows to check, if the requested area
+	 * is already mapped. If this the case, nothing needs to be done
+	 * and we can return.
+	 */
+	for (i = 0; i < WINDOW_COUNT; i++) {
+		if (addr >= xordev->win_start[i] &&
+		    addr <= xordev->win_end[i]) {
+			/* Window is already mapped */
+			return 0;
+		}
+	}
+
+	/*
+	 * The window is not mapped, so we need to create the new mapping
+	 */
+
+	/* If no IO window is found that addr has to be located in SDRAM */
+	ret = mvebu_mbus_get_io_win_info(addr, &size, &target, &attr);
+	if (ret < 0)
+		return 0;
+
+	/*
+	 * Mask the base addr 'addr' according to 'size' read back from the
+	 * MBus window. Otherwise we might end up with an address located
+	 * somewhere in the middle of this area here.
+	 */
+	size -= 1;
+	addr &= ~size;
+
+	/*
+	 * Reading one of both enabled register is enough, as they are always
+	 * programmed to the identical values
+	 */
+	win_enable = readl(base + WINDOW_BAR_ENABLE(0));
+
+	/* Set 'i' to the first free window to write the new values to */
+	i = ffs(~win_enable) - 1;
+	if (i >= WINDOW_COUNT)
+		return -ENOMEM;
+
+	writel((addr & 0xffff0000) | (attr << 8) | target,
+	       base + WINDOW_BASE(i));
+	writel(size & 0xffff0000, base + WINDOW_SIZE(i));
+
+	/* Fill the caching variables for later use */
+	xordev->win_start[i] = addr;
+	xordev->win_end[i] = addr + size;
+
+	win_enable |= (1 << i);
+	win_enable |= 3 << (16 + (2 * i));
+	writel(win_enable, base + WINDOW_BAR_ENABLE(0));
+	writel(win_enable, base + WINDOW_BAR_ENABLE(1));
+
+	return 0;
+}
+
 static struct dma_async_tx_descriptor *
 mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
 		    unsigned int src_cnt, size_t len, unsigned long flags)
 {
 	struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan);
 	struct mv_xor_desc_slot *sw_desc;
+	int ret;
 
 	if (unlikely(len < MV_XOR_MIN_BYTE_COUNT))
 		return NULL;
@@ -486,6 +560,11 @@  mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
 		"%s src_cnt: %d len: %zu dest %pad flags: %ld\n",
 		__func__, src_cnt, len, &dest, flags);
 
+	/* Check if a new window needs to get added for 'dest' */
+	ret = mv_xor_add_io_win(mv_chan, dest);
+	if (ret)
+		return NULL;
+
 	sw_desc = mv_chan_alloc_slot(mv_chan);
 	if (sw_desc) {
 		sw_desc->type = DMA_XOR;
@@ -493,8 +572,13 @@  mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
 		mv_desc_init(sw_desc, dest, len, flags);
 		if (mv_chan->op_in_desc == XOR_MODE_IN_DESC)
 			mv_desc_set_mode(sw_desc);
-		while (src_cnt--)
+		while (src_cnt--) {
+			/* Check if a new window needs to get added for 'src' */
+			ret = mv_xor_add_io_win(mv_chan, src[src_cnt]);
+			if (ret)
+				return NULL;
 			mv_desc_set_src_addr(sw_desc, src_cnt, src[src_cnt]);
+		}
 	}
 
 	dev_dbg(mv_chan_to_devp(mv_chan),
@@ -959,6 +1043,7 @@  mv_xor_channel_add(struct mv_xor_device *xordev,
 		mv_chan->op_in_desc = XOR_MODE_IN_DESC;
 
 	dma_dev = &mv_chan->dmadev;
+	mv_chan->xordev = xordev;
 
 	/*
 	 * These source and destination dummy buffers are used to implement
@@ -1086,6 +1171,10 @@  mv_xor_conf_mbus_windows(struct mv_xor_device *xordev,
 		       dram->mbus_dram_target_id, base + WINDOW_BASE(i));
 		writel((cs->size - 1) & 0xffff0000, base + WINDOW_SIZE(i));
 
+		/* Fill the caching variables for later use */
+		xordev->win_start[i] = cs->base;
+		xordev->win_end[i] = cs->base + cs->size - 1;
+
 		win_enable |= (1 << i);
 		win_enable |= 3 << (16 + (2 * i));
 	}
diff --git a/drivers/dma/mv_xor.h b/drivers/dma/mv_xor.h
index bf56e08..88eeab2 100644
--- a/drivers/dma/mv_xor.h
+++ b/drivers/dma/mv_xor.h
@@ -80,12 +80,17 @@ 
 #define WINDOW_BAR_ENABLE(chan)	(0x40 + ((chan) << 2))
 #define WINDOW_OVERRIDE_CTRL(chan)	(0xA0 + ((chan) << 2))
 
+#define WINDOW_COUNT		8
+
 struct mv_xor_device {
 	void __iomem	     *xor_base;
 	void __iomem	     *xor_high_base;
 	struct clk	     *clk;
 	struct mv_xor_chan   *channels[MV_XOR_MAX_CHANNELS];
 	int		     xor_type;
+
+	u32                  win_start[WINDOW_COUNT];
+	u32                  win_end[WINDOW_COUNT];
 };
 
 /**
@@ -127,6 +132,8 @@  struct mv_xor_chan {
 	char			dummy_dst[MV_XOR_MIN_BYTE_COUNT];
 	dma_addr_t		dummy_src_addr, dummy_dst_addr;
 	u32                     saved_config_reg, saved_int_mask_reg;
+
+	struct mv_xor_device	*xordev;
 };
 
 /**