init.c (ad4a7b5065c1b4f5176e7d031c3cc2b36f776884) | init.c (4222a9074339fccc59526cbf30d8d2ec41468574) |
---|---|
1/* 2 * Intel I/OAT DMA Linux driver 3 * Copyright(c) 2004 - 2015 Intel Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * --- 13 unchanged lines hidden (view full) --- 22#include <linux/pci.h> 23#include <linux/interrupt.h> 24#include <linux/dmaengine.h> 25#include <linux/delay.h> 26#include <linux/dma-mapping.h> 27#include <linux/workqueue.h> 28#include <linux/prefetch.h> 29#include <linux/dca.h> | 1/* 2 * Intel I/OAT DMA Linux driver 3 * Copyright(c) 2004 - 2015 Intel Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * --- 13 unchanged lines hidden (view full) --- 22#include <linux/pci.h> 23#include <linux/interrupt.h> 24#include <linux/dmaengine.h> 25#include <linux/delay.h> 26#include <linux/dma-mapping.h> 27#include <linux/workqueue.h> 28#include <linux/prefetch.h> 29#include <linux/dca.h> |
30#include <linux/aer.h> |
|
30#include "dma.h" 31#include "registers.h" 32#include "hw.h" 33 34#include "../dmaengine.h" 35 36MODULE_VERSION(IOAT_DMA_VERSION); 37MODULE_LICENSE("Dual BSD/GPL"); --- 1168 unchanged lines hidden (view full) --- 1206 spin_unlock_bh(&ioat_chan->prep_lock); 1207 /* this should quiesce then reset */ 1208 ioat_reset_hw(ioat_chan); 1209 } 1210 1211 ioat_disable_interrupts(ioat_dma); 1212} 1213 | 31#include "dma.h" 32#include "registers.h" 33#include "hw.h" 34 35#include "../dmaengine.h" 36 37MODULE_VERSION(IOAT_DMA_VERSION); 38MODULE_LICENSE("Dual BSD/GPL"); --- 1168 unchanged lines hidden (view full) --- 1207 spin_unlock_bh(&ioat_chan->prep_lock); 1208 /* this should quiesce then reset */ 1209 ioat_reset_hw(ioat_chan); 1210 } 1211 1212 ioat_disable_interrupts(ioat_dma); 1213} 1214 |
1215void ioat_resume(struct ioatdma_device *ioat_dma) 1216{ 1217 struct ioatdma_chan *ioat_chan; 1218 u32 chanerr; 1219 int i; 1220 1221 for (i = 0; i < IOAT_MAX_CHANS; i++) { 1222 ioat_chan = ioat_dma->idx[i]; 1223 if (!ioat_chan) 1224 continue; 1225 1226 spin_lock_bh(&ioat_chan->prep_lock); 1227 clear_bit(IOAT_CHAN_DOWN, &ioat_chan->state); 1228 spin_unlock_bh(&ioat_chan->prep_lock); 1229 1230 chanerr = readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET); 1231 writel(chanerr, ioat_chan->reg_base + IOAT_CHANERR_OFFSET); 1232 1233 /* no need to reset as shutdown already did that */ 1234 } 1235} 1236 |
|
1214#define DRV_NAME "ioatdma" 1215 | 1237#define DRV_NAME "ioatdma" 1238 |
1239static pci_ers_result_t ioat_pcie_error_detected(struct pci_dev *pdev, 1240 enum pci_channel_state error) 1241{ 1242 dev_dbg(&pdev->dev, "%s: PCIe AER error %d\n", DRV_NAME, error); 1243 1244 /* quiesce and block I/O */ 1245 ioat_shutdown(pdev); 1246 1247 return PCI_ERS_RESULT_NEED_RESET; 1248} 1249 1250static pci_ers_result_t ioat_pcie_error_slot_reset(struct pci_dev *pdev) 1251{ 1252 pci_ers_result_t result = PCI_ERS_RESULT_RECOVERED; 1253 int err; 1254 1255 dev_dbg(&pdev->dev, "%s post reset handling\n", DRV_NAME); 1256 1257 if (pci_enable_device_mem(pdev) < 0) { 1258 dev_err(&pdev->dev, 1259 "Failed to enable PCIe device after reset.\n"); 1260 result = PCI_ERS_RESULT_DISCONNECT; 1261 } else { 1262 pci_set_master(pdev); 1263 pci_restore_state(pdev); 1264 pci_save_state(pdev); 1265 pci_wake_from_d3(pdev, false); 1266 } 1267 1268 err = pci_cleanup_aer_uncorrect_error_status(pdev); 1269 if (err) { 1270 dev_err(&pdev->dev, 1271 "AER uncorrect error status clear failed: %#x\n", err); 1272 } 1273 1274 return result; 1275} 1276 1277static void ioat_pcie_error_resume(struct pci_dev *pdev) 1278{ 1279 struct ioatdma_device *ioat_dma = pci_get_drvdata(pdev); 1280 1281 dev_dbg(&pdev->dev, "%s: AER handling resuming\n", DRV_NAME); 1282 1283 /* initialize and bring everything back */ 1284 ioat_resume(ioat_dma); 1285} 1286 1287static const struct pci_error_handlers ioat_err_handler = { 1288 .error_detected = ioat_pcie_error_detected, 1289 .slot_reset = ioat_pcie_error_slot_reset, 1290 .resume = ioat_pcie_error_resume, 1291}; 1292 |
|
1216static struct pci_driver ioat_pci_driver = { 1217 .name = DRV_NAME, 1218 .id_table = ioat_pci_tbl, 1219 .probe = ioat_pci_probe, 1220 .remove = ioat_remove, 1221 .shutdown = ioat_shutdown, | 1293static struct pci_driver ioat_pci_driver = { 1294 .name = DRV_NAME, 1295 .id_table = ioat_pci_tbl, 1296 .probe = ioat_pci_probe, 1297 .remove = ioat_remove, 1298 .shutdown = ioat_shutdown, |
1299 .err_handler = &ioat_err_handler, |
|
1222}; 1223 1224static struct ioatdma_device * 1225alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase) 1226{ 1227 struct device *dev = &pdev->dev; 1228 struct ioatdma_device *d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL); 1229 --- 36 unchanged lines hidden (view full) --- 1266 1267 device = alloc_ioatdma(pdev, iomap[IOAT_MMIO_BAR]); 1268 if (!device) 1269 return -ENOMEM; 1270 pci_set_master(pdev); 1271 pci_set_drvdata(pdev, device); 1272 1273 device->version = readb(device->reg_base + IOAT_VER_OFFSET); | 1300}; 1301 1302static struct ioatdma_device * 1303alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase) 1304{ 1305 struct device *dev = &pdev->dev; 1306 struct ioatdma_device *d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL); 1307 --- 36 unchanged lines hidden (view full) --- 1344 1345 device = alloc_ioatdma(pdev, iomap[IOAT_MMIO_BAR]); 1346 if (!device) 1347 return -ENOMEM; 1348 pci_set_master(pdev); 1349 pci_set_drvdata(pdev, device); 1350 1351 device->version = readb(device->reg_base + IOAT_VER_OFFSET); |
1274 if (device->version >= IOAT_VER_3_0) | 1352 if (device->version >= IOAT_VER_3_0) { |
1275 err = ioat3_dma_probe(device, ioat_dca_enabled); | 1353 err = ioat3_dma_probe(device, ioat_dca_enabled); |
1276 else | 1354 1355 if (device->version >= IOAT_VER_3_3) 1356 pci_enable_pcie_error_reporting(pdev); 1357 } else |
1277 return -ENODEV; 1278 1279 if (err) { 1280 dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n"); | 1358 return -ENODEV; 1359 1360 if (err) { 1361 dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n"); |
1362 pci_disable_pcie_error_reporting(pdev); |
|
1281 return -ENODEV; 1282 } 1283 1284 return 0; 1285} 1286 1287static void ioat_remove(struct pci_dev *pdev) 1288{ 1289 struct ioatdma_device *device = pci_get_drvdata(pdev); 1290 1291 if (!device) 1292 return; 1293 1294 dev_err(&pdev->dev, "Removing dma and dca services\n"); 1295 if (device->dca) { 1296 unregister_dca_provider(device->dca, &pdev->dev); 1297 free_dca_provider(device->dca); 1298 device->dca = NULL; 1299 } | 1363 return -ENODEV; 1364 } 1365 1366 return 0; 1367} 1368 1369static void ioat_remove(struct pci_dev *pdev) 1370{ 1371 struct ioatdma_device *device = pci_get_drvdata(pdev); 1372 1373 if (!device) 1374 return; 1375 1376 dev_err(&pdev->dev, "Removing dma and dca services\n"); 1377 if (device->dca) { 1378 unregister_dca_provider(device->dca, &pdev->dev); 1379 free_dca_provider(device->dca); 1380 device->dca = NULL; 1381 } |
1382 1383 pci_disable_pcie_error_reporting(pdev); |
|
1300 ioat_dma_remove(device); 1301} 1302 1303static int __init ioat_init_module(void) 1304{ 1305 int err = -ENOMEM; 1306 1307 pr_info("%s: Intel(R) QuickData Technology Driver %s\n", --- 33 unchanged lines hidden --- | 1384 ioat_dma_remove(device); 1385} 1386 1387static int __init ioat_init_module(void) 1388{ 1389 int err = -ENOMEM; 1390 1391 pr_info("%s: Intel(R) QuickData Technology Driver %s\n", --- 33 unchanged lines hidden --- |