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

dmaengine: idxd: fix mapping of portal size

Portal size is 4k. Current code is mapping all 4 portals in a single chunk.
Restrict the mapped portal size to a single portal to ensure that submission
only goes to the intended portal address.

Fixes: c52ca478233c ("dmaengine: idxd: add configuration component of driver")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/160513342642.510187.16450549281618747065.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dave Jiang and committed by
Vinod Koul
8326be9f 29a25b92

+3 -3
+1 -1
drivers/dma/idxd/device.c
··· 271 271 resource_size_t start; 272 272 273 273 start = pci_resource_start(pdev, IDXD_WQ_BAR); 274 - start = start + wq->id * IDXD_PORTAL_SIZE; 274 + start += idxd_get_wq_portal_full_offset(wq->id, IDXD_PORTAL_LIMITED); 275 275 276 276 wq->dportal = devm_ioremap(dev, start, IDXD_PORTAL_SIZE); 277 277 if (!wq->dportal)
+1 -1
drivers/dma/idxd/registers.h
··· 8 8 9 9 #define IDXD_MMIO_BAR 0 10 10 #define IDXD_WQ_BAR 2 11 - #define IDXD_PORTAL_SIZE 0x4000 11 + #define IDXD_PORTAL_SIZE PAGE_SIZE 12 12 13 13 /* MMIO Device BAR0 Registers */ 14 14 #define IDXD_VER_OFFSET 0x00
+1 -1
drivers/dma/idxd/submit.c
··· 74 74 if (idxd->state != IDXD_DEV_ENABLED) 75 75 return -EIO; 76 76 77 - portal = wq->dportal + idxd_get_wq_portal_offset(IDXD_PORTAL_UNLIMITED); 77 + portal = wq->dportal; 78 78 /* 79 79 * The wmb() flushes writes to coherent DMA data before possibly 80 80 * triggering a DMA read. The wmb() is necessary even on UP because