init.c (50501936288d6a29d7ef78f25d00e33240fad45f) init.c (f4f84fb632b30580f11133fb81372338da2229f5)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Intel I/OAT DMA Linux driver
4 * Copyright(c) 2004 - 2015 Intel Corporation.
5 */
6
7#include <linux/init.h>
8#include <linux/module.h>

--- 406 unchanged lines hidden (view full) ---

415 goto msi;
416 if (!strcmp(ioat_interrupt_style, "intx"))
417 goto intx;
418 dev_err(dev, "invalid ioat_interrupt_style %s\n", ioat_interrupt_style);
419 goto err_no_irq;
420
421msix:
422 /* The number of MSI-X vectors should equal the number of channels */
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Intel I/OAT DMA Linux driver
4 * Copyright(c) 2004 - 2015 Intel Corporation.
5 */
6
7#include <linux/init.h>
8#include <linux/module.h>

--- 406 unchanged lines hidden (view full) ---

415 goto msi;
416 if (!strcmp(ioat_interrupt_style, "intx"))
417 goto intx;
418 dev_err(dev, "invalid ioat_interrupt_style %s\n", ioat_interrupt_style);
419 goto err_no_irq;
420
421msix:
422 /* The number of MSI-X vectors should equal the number of channels */
423 msixcnt = ioat_dma->dma_dev.chancnt;
423 msixcnt = ioat_dma->chancnt;
424 for (i = 0; i < msixcnt; i++)
425 ioat_dma->msix_entries[i].entry = i;
426
427 err = pci_enable_msix_exact(pdev, ioat_dma->msix_entries, msixcnt);
428 if (err)
429 goto msi;
430
431 for (i = 0; i < msixcnt; i++) {

--- 74 unchanged lines hidden (view full) ---

506 goto err_out;
507 }
508
509 ioat_enumerate_channels(ioat_dma);
510
511 dma_cap_set(DMA_MEMCPY, dma->cap_mask);
512 dma->dev = &pdev->dev;
513
424 for (i = 0; i < msixcnt; i++)
425 ioat_dma->msix_entries[i].entry = i;
426
427 err = pci_enable_msix_exact(pdev, ioat_dma->msix_entries, msixcnt);
428 if (err)
429 goto msi;
430
431 for (i = 0; i < msixcnt; i++) {

--- 74 unchanged lines hidden (view full) ---

506 goto err_out;
507 }
508
509 ioat_enumerate_channels(ioat_dma);
510
511 dma_cap_set(DMA_MEMCPY, dma->cap_mask);
512 dma->dev = &pdev->dev;
513
514 if (!dma->chancnt) {
514 if (!ioat_dma->chancnt) {
515 dev_err(dev, "channel enumeration error\n");
516 goto err_setup_interrupts;
517 }
518
519 err = ioat_dma_setup_interrupts(ioat_dma);
520 if (err)
521 goto err_setup_interrupts;
522

--- 39 unchanged lines hidden (view full) ---

562 * @ioat_dma: the ioat dma device to be enumerated
563 */
564static void ioat_enumerate_channels(struct ioatdma_device *ioat_dma)
565{
566 struct ioatdma_chan *ioat_chan;
567 struct device *dev = &ioat_dma->pdev->dev;
568 struct dma_device *dma = &ioat_dma->dma_dev;
569 u8 xfercap_log;
515 dev_err(dev, "channel enumeration error\n");
516 goto err_setup_interrupts;
517 }
518
519 err = ioat_dma_setup_interrupts(ioat_dma);
520 if (err)
521 goto err_setup_interrupts;
522

--- 39 unchanged lines hidden (view full) ---

562 * @ioat_dma: the ioat dma device to be enumerated
563 */
564static void ioat_enumerate_channels(struct ioatdma_device *ioat_dma)
565{
566 struct ioatdma_chan *ioat_chan;
567 struct device *dev = &ioat_dma->pdev->dev;
568 struct dma_device *dma = &ioat_dma->dma_dev;
569 u8 xfercap_log;
570 int chancnt;
570 int i;
571
572 INIT_LIST_HEAD(&dma->channels);
571 int i;
572
573 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)) {
576 dev_warn(dev, "(%d) exceeds max supported channels (%zu)\n",
577 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);
579 }
580 xfercap_log = readb(ioat_dma->reg_base + IOAT_XFERCAP_OFFSET);
581 xfercap_log &= 0x1f; /* bits [4:0] valid */
582 if (xfercap_log == 0)
583 return;
584 dev_dbg(dev, "%s: xfercap = %d\n", __func__, 1 << xfercap_log);
585
580 }
581 xfercap_log = readb(ioat_dma->reg_base + IOAT_XFERCAP_OFFSET);
582 xfercap_log &= 0x1f; /* bits [4:0] valid */
583 if (xfercap_log == 0)
584 return;
585 dev_dbg(dev, "%s: xfercap = %d\n", __func__, 1 << xfercap_log);
586
586 for (i = 0; i < dma->chancnt; i++) {
587 for (i = 0; i < chancnt; i++) {
587 ioat_chan = kzalloc(sizeof(*ioat_chan), GFP_KERNEL);
588 if (!ioat_chan)
589 break;
590
591 ioat_init_channel(ioat_dma, ioat_chan, i);
592 ioat_chan->xfercap_log = xfercap_log;
593 spin_lock_init(&ioat_chan->prep_lock);
594 if (ioat_reset_hw(ioat_chan)) {
595 i = 0;
596 break;
597 }
598 }
588 ioat_chan = kzalloc(sizeof(*ioat_chan), GFP_KERNEL);
589 if (!ioat_chan)
590 break;
591
592 ioat_init_channel(ioat_dma, ioat_chan, i);
593 ioat_chan->xfercap_log = xfercap_log;
594 spin_lock_init(&ioat_chan->prep_lock);
595 if (ioat_reset_hw(ioat_chan)) {
596 i = 0;
597 break;
598 }
599 }
599 dma->chancnt = i;
600 ioat_dma->chancnt = i;
600}
601
602/**
603 * ioat_free_chan_resources - release all the descriptors
604 * @c: the channel to be cleaned
605 */
606static void ioat_free_chan_resources(struct dma_chan *c)
607{

--- 842 unchanged lines hidden ---
601}
602
603/**
604 * ioat_free_chan_resources - release all the descriptors
605 * @c: the channel to be cleaned
606 */
607static void ioat_free_chan_resources(struct dma_chan *c)
608{

--- 842 unchanged lines hidden ---