Skip to content

Commit f4f84fb

Browse files
Yajun Dengvinodkoul
authored andcommitted
dmaengine: ioat: fixing the wrong dma_dev->chancnt
The chancnt would be updated in __dma_async_device_channel_register(), but it was assigned in ioat_enumerate_channels(). Therefore chancnt has the wrong value. Add chancnt member to the struct ioatdma_device, ioat_dma->chancnt is used in ioat, dma_dev->chancnt is used in dmaengine. Signed-off-by: Yajun Deng <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 81ebed8 commit f4f84fb

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

drivers/dma/ioat/dma.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct ioatdma_device {
7474
struct dca_provider *dca;
7575
enum ioat_irq_mode irq_mode;
7676
u32 cap;
77+
int chancnt;
7778

7879
/* shadow version for CB3.3 chan reset errata workaround */
7980
u64 msixtba0;

drivers/dma/ioat/init.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ int ioat_dma_setup_interrupts(struct ioatdma_device *ioat_dma)
420420

421421
msix:
422422
/* The number of MSI-X vectors should equal the number of channels */
423-
msixcnt = ioat_dma->dma_dev.chancnt;
423+
msixcnt = ioat_dma->chancnt;
424424
for (i = 0; i < msixcnt; i++)
425425
ioat_dma->msix_entries[i].entry = i;
426426

@@ -511,7 +511,7 @@ static int ioat_probe(struct ioatdma_device *ioat_dma)
511511
dma_cap_set(DMA_MEMCPY, dma->cap_mask);
512512
dma->dev = &pdev->dev;
513513

514-
if (!dma->chancnt) {
514+
if (!ioat_dma->chancnt) {
515515
dev_err(dev, "channel enumeration error\n");
516516
goto err_setup_interrupts;
517517
}
@@ -567,23 +567,24 @@ static void ioat_enumerate_channels(struct ioatdma_device *ioat_dma)
567567
struct device *dev = &ioat_dma->pdev->dev;
568568
struct dma_device *dma = &ioat_dma->dma_dev;
569569
u8 xfercap_log;
570+
int chancnt;
570571
int i;
571572

572573
INIT_LIST_HEAD(&dma->channels);
573-
dma->chancnt = readb(ioat_dma->reg_base + IOAT_CHANCNT_OFFSET);
574-
dma->chancnt &= 0x1f; /* bits [4:0] valid */
575-
if (dma->chancnt > ARRAY_SIZE(ioat_dma->idx)) {
574+
chancnt = readb(ioat_dma->reg_base + IOAT_CHANCNT_OFFSET);
575+
chancnt &= 0x1f; /* bits [4:0] valid */
576+
if (chancnt > ARRAY_SIZE(ioat_dma->idx)) {
576577
dev_warn(dev, "(%d) exceeds max supported channels (%zu)\n",
577-
dma->chancnt, ARRAY_SIZE(ioat_dma->idx));
578-
dma->chancnt = ARRAY_SIZE(ioat_dma->idx);
578+
chancnt, ARRAY_SIZE(ioat_dma->idx));
579+
chancnt = ARRAY_SIZE(ioat_dma->idx);
579580
}
580581
xfercap_log = readb(ioat_dma->reg_base + IOAT_XFERCAP_OFFSET);
581582
xfercap_log &= 0x1f; /* bits [4:0] valid */
582583
if (xfercap_log == 0)
583584
return;
584585
dev_dbg(dev, "%s: xfercap = %d\n", __func__, 1 << xfercap_log);
585586

586-
for (i = 0; i < dma->chancnt; i++) {
587+
for (i = 0; i < chancnt; i++) {
587588
ioat_chan = kzalloc(sizeof(*ioat_chan), GFP_KERNEL);
588589
if (!ioat_chan)
589590
break;
@@ -596,7 +597,7 @@ static void ioat_enumerate_channels(struct ioatdma_device *ioat_dma)
596597
break;
597598
}
598599
}
599-
dma->chancnt = i;
600+
ioat_dma->chancnt = i;
600601
}
601602

602603
/**

0 commit comments

Comments
 (0)