Commit 5149fd01 authored by Shannon Nelson's avatar Shannon Nelson Committed by Linus Torvalds

I/OAT: clean up error handling and some print messages

Make better use of dev_err(), and catch an error where the transaction
creation might fail.
Signed-off-by: default avatarShannon Nelson <shannon.nelson@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dfe2299e
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "ioatdma_registers.h" #include "ioatdma_registers.h"
#include "ioatdma_hw.h" #include "ioatdma_hw.h"
MODULE_VERSION("1.24"); MODULE_VERSION(IOAT_DMA_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Intel Corporation"); MODULE_AUTHOR("Intel Corporation");
...@@ -85,6 +85,7 @@ static void ioat_shutdown_functionality(struct pci_dev *pdev) ...@@ -85,6 +85,7 @@ static void ioat_shutdown_functionality(struct pci_dev *pdev)
{ {
struct ioat_device *device = pci_get_drvdata(pdev); struct ioat_device *device = pci_get_drvdata(pdev);
dev_err(&pdev->dev, "Removing dma and dca services\n");
if (device->dca) { if (device->dca) {
unregister_dca_provider(device->dca); unregister_dca_provider(device->dca);
free_dca_provider(device->dca); free_dca_provider(device->dca);
......
...@@ -65,7 +65,7 @@ static inline u16 dcaid_from_pcidev(struct pci_dev *pci) ...@@ -65,7 +65,7 @@ static inline u16 dcaid_from_pcidev(struct pci_dev *pci)
return (pci->bus->number << 8) | pci->devfn; return (pci->bus->number << 8) | pci->devfn;
} }
static int dca_enabled_in_bios(void) static int dca_enabled_in_bios(struct pci_dev *pdev)
{ {
/* CPUID level 9 returns DCA configuration */ /* CPUID level 9 returns DCA configuration */
/* Bit 0 indicates DCA enabled by the BIOS */ /* Bit 0 indicates DCA enabled by the BIOS */
...@@ -75,17 +75,17 @@ static int dca_enabled_in_bios(void) ...@@ -75,17 +75,17 @@ static int dca_enabled_in_bios(void)
cpuid_level_9 = cpuid_eax(9); cpuid_level_9 = cpuid_eax(9);
res = test_bit(0, &cpuid_level_9); res = test_bit(0, &cpuid_level_9);
if (!res) if (!res)
printk(KERN_ERR "ioat dma: DCA is disabled in BIOS\n"); dev_err(&pdev->dev, "DCA is disabled in BIOS\n");
return res; return res;
} }
static int system_has_dca_enabled(void) static int system_has_dca_enabled(struct pci_dev *pdev)
{ {
if (boot_cpu_has(X86_FEATURE_DCA)) if (boot_cpu_has(X86_FEATURE_DCA))
return dca_enabled_in_bios(); return dca_enabled_in_bios(pdev);
printk(KERN_ERR "ioat dma: boot cpu doesn't have X86_FEATURE_DCA\n"); dev_err(&pdev->dev, "boot cpu doesn't have X86_FEATURE_DCA\n");
return 0; return 0;
} }
...@@ -208,7 +208,7 @@ struct dca_provider *ioat_dca_init(struct pci_dev *pdev, void __iomem *iobase) ...@@ -208,7 +208,7 @@ struct dca_provider *ioat_dca_init(struct pci_dev *pdev, void __iomem *iobase)
int i; int i;
int err; int err;
if (!system_has_dca_enabled()) if (!system_has_dca_enabled(pdev))
return NULL; return NULL;
/* I/OAT v1 systems must have a known tag_map to support DCA */ /* I/OAT v1 systems must have a known tag_map to support DCA */
......
...@@ -267,7 +267,7 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan) ...@@ -267,7 +267,7 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
chanerr = readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET); chanerr = readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET);
if (chanerr) { if (chanerr) {
dev_err(&ioat_chan->device->pdev->dev, dev_err(&ioat_chan->device->pdev->dev,
"ioatdma: CHANERR = %x, clearing\n", chanerr); "CHANERR = %x, clearing\n", chanerr);
writel(chanerr, ioat_chan->reg_base + IOAT_CHANERR_OFFSET); writel(chanerr, ioat_chan->reg_base + IOAT_CHANERR_OFFSET);
} }
...@@ -276,7 +276,7 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan) ...@@ -276,7 +276,7 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_KERNEL); desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_KERNEL);
if (!desc) { if (!desc) {
dev_err(&ioat_chan->device->pdev->dev, dev_err(&ioat_chan->device->pdev->dev,
"ioatdma: Only %d initial descriptors\n", i); "Only %d initial descriptors\n", i);
break; break;
} }
list_add_tail(&desc->node, &tmp_list); list_add_tail(&desc->node, &tmp_list);
...@@ -342,7 +342,7 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan) ...@@ -342,7 +342,7 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan)
/* one is ok since we left it on there on purpose */ /* one is ok since we left it on there on purpose */
if (in_use_descs > 1) if (in_use_descs > 1)
dev_err(&ioat_chan->device->pdev->dev, dev_err(&ioat_chan->device->pdev->dev,
"ioatdma: Freeing %d in use descriptors!\n", "Freeing %d in use descriptors!\n",
in_use_descs - 1); in_use_descs - 1);
ioat_chan->last_completion = ioat_chan->completion_addr = 0; ioat_chan->last_completion = ioat_chan->completion_addr = 0;
...@@ -482,7 +482,7 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan) ...@@ -482,7 +482,7 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
if ((ioat_chan->completion_virt->full & IOAT_CHANSTS_DMA_TRANSFER_STATUS) == if ((ioat_chan->completion_virt->full & IOAT_CHANSTS_DMA_TRANSFER_STATUS) ==
IOAT_CHANSTS_DMA_TRANSFER_STATUS_HALTED) { IOAT_CHANSTS_DMA_TRANSFER_STATUS_HALTED) {
dev_err(&ioat_chan->device->pdev->dev, dev_err(&ioat_chan->device->pdev->dev,
"ioatdma: Channel halted, chanerr = %x\n", "Channel halted, chanerr = %x\n",
readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET)); readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET));
/* TODO do something to salvage the situation */ /* TODO do something to salvage the situation */
...@@ -643,7 +643,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device) ...@@ -643,7 +643,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
u8 *src; u8 *src;
u8 *dest; u8 *dest;
struct dma_chan *dma_chan; struct dma_chan *dma_chan;
struct dma_async_tx_descriptor *tx; struct dma_async_tx_descriptor *tx = NULL;
dma_addr_t addr; dma_addr_t addr;
dma_cookie_t cookie; dma_cookie_t cookie;
int err = 0; int err = 0;
...@@ -673,6 +673,13 @@ static int ioat_dma_self_test(struct ioatdma_device *device) ...@@ -673,6 +673,13 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
} }
tx = ioat_dma_prep_memcpy(dma_chan, IOAT_TEST_SIZE, 0); tx = ioat_dma_prep_memcpy(dma_chan, IOAT_TEST_SIZE, 0);
if (!tx) {
dev_err(&device->pdev->dev,
"Self-test prep failed, disabling\n");
err = -ENODEV;
goto free_resources;
}
async_tx_ack(tx); async_tx_ack(tx);
addr = dma_map_single(dma_chan->device->dev, src, IOAT_TEST_SIZE, addr = dma_map_single(dma_chan->device->dev, src, IOAT_TEST_SIZE,
DMA_TO_DEVICE); DMA_TO_DEVICE);
...@@ -686,13 +693,13 @@ static int ioat_dma_self_test(struct ioatdma_device *device) ...@@ -686,13 +693,13 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
if (ioat_dma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) { if (ioat_dma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) {
dev_err(&device->pdev->dev, dev_err(&device->pdev->dev,
"ioatdma: Self-test copy timed out, disabling\n"); "Self-test copy timed out, disabling\n");
err = -ENODEV; err = -ENODEV;
goto free_resources; goto free_resources;
} }
if (memcmp(src, dest, IOAT_TEST_SIZE)) { if (memcmp(src, dest, IOAT_TEST_SIZE)) {
dev_err(&device->pdev->dev, dev_err(&device->pdev->dev,
"ioatdma: Self-test copy failed compare, disabling\n"); "Self-test copy failed compare, disabling\n");
err = -ENODEV; err = -ENODEV;
goto free_resources; goto free_resources;
} }
...@@ -730,6 +737,9 @@ static int ioat_dma_setup_interrupts(struct ioatdma_device *device) ...@@ -730,6 +737,9 @@ static int ioat_dma_setup_interrupts(struct ioatdma_device *device)
goto msi; goto msi;
if (!strcmp(ioat_interrupt_style, "intx")) if (!strcmp(ioat_interrupt_style, "intx"))
goto intx; goto intx;
dev_err(&device->pdev->dev, "invalid ioat_interrupt_style %s\n",
ioat_interrupt_style);
goto err_no_irq;
msix: msix:
/* The number of MSI-X vectors should equal the number of channels */ /* The number of MSI-X vectors should equal the number of channels */
...@@ -906,9 +916,9 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev, ...@@ -906,9 +916,9 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev,
device->common.device_dependency_added = ioat_dma_dependency_added; device->common.device_dependency_added = ioat_dma_dependency_added;
device->common.dev = &pdev->dev; device->common.dev = &pdev->dev;
dev_err(&device->pdev->dev, dev_err(&device->pdev->dev,
"ioatdma: Intel(R) I/OAT DMA Engine found," "Intel(R) I/OAT DMA Engine found,"
" %d channels, device version 0x%02x\n", " %d channels, device version 0x%02x, driver version %s\n",
device->common.chancnt, device->version); device->common.chancnt, device->version, IOAT_DMA_VERSION);
err = ioat_dma_setup_interrupts(device); err = ioat_dma_setup_interrupts(device);
if (err) if (err)
...@@ -932,7 +942,7 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev, ...@@ -932,7 +942,7 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev,
kfree(device); kfree(device);
err_kzalloc: err_kzalloc:
dev_err(&device->pdev->dev, dev_err(&device->pdev->dev,
"ioatdma: Intel(R) I/OAT DMA Engine initialization failed\n"); "Intel(R) I/OAT DMA Engine initialization failed\n");
return NULL; return NULL;
} }
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/pci_ids.h> #include <linux/pci_ids.h>
#define IOAT_DMA_VERSION "1.26"
enum ioat_interrupt { enum ioat_interrupt {
none = 0, none = 0,
msix_multi_vector = 1, msix_multi_vector = 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment