diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-07-28 17:42:38 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-09-08 20:29:54 -0400 |
commit | f2427e276ffec5ce599c6bc116e0927269a360ef (patch) | |
tree | d23b47ad7a00daeba720c25bb900fd96bf226f54 /drivers/dma/ioat/pci.c | |
parent | b31b78f1ab7806759622b703357e39a21f757281 (diff) |
ioat: split ioat_dma_probe into core/version-specific routines
Towards the removal of ioatdma_device.version split the initialization
path into distinct versions. This conversion:
1/ moves version specific probe code to version specific routines
2/ removes the need for ioat_device
3/ turns off the ioat1 msi quirk if the device is reinitialized for intx
Signed-off-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/ioat/pci.c')
-rw-r--r-- | drivers/dma/ioat/pci.c | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/drivers/dma/ioat/pci.c b/drivers/dma/ioat/pci.c index 982e38fd177c..55414d88ac1b 100644 --- a/drivers/dma/ioat/pci.c +++ b/drivers/dma/ioat/pci.c | |||
@@ -60,14 +60,8 @@ static struct pci_device_id ioat_pci_tbl[] = { | |||
60 | { 0, } | 60 | { 0, } |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct ioat_device { | 63 | static int __devinit ioat_pci_probe(struct pci_dev *pdev, |
64 | struct pci_dev *pdev; | 64 | const struct pci_device_id *id); |
65 | struct ioatdma_device *dma; | ||
66 | struct dca_provider *dca; | ||
67 | }; | ||
68 | |||
69 | static int __devinit ioat_probe(struct pci_dev *pdev, | ||
70 | const struct pci_device_id *id); | ||
71 | static void __devexit ioat_remove(struct pci_dev *pdev); | 65 | static void __devexit ioat_remove(struct pci_dev *pdev); |
72 | 66 | ||
73 | static int ioat_dca_enabled = 1; | 67 | static int ioat_dca_enabled = 1; |
@@ -79,17 +73,28 @@ MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)" | |||
79 | static struct pci_driver ioat_pci_driver = { | 73 | static struct pci_driver ioat_pci_driver = { |
80 | .name = DRV_NAME, | 74 | .name = DRV_NAME, |
81 | .id_table = ioat_pci_tbl, | 75 | .id_table = ioat_pci_tbl, |
82 | .probe = ioat_probe, | 76 | .probe = ioat_pci_probe, |
83 | .remove = __devexit_p(ioat_remove), | 77 | .remove = __devexit_p(ioat_remove), |
84 | }; | 78 | }; |
85 | 79 | ||
86 | static int __devinit ioat_probe(struct pci_dev *pdev, | 80 | static struct ioatdma_device * |
87 | const struct pci_device_id *id) | 81 | alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase) |
82 | { | ||
83 | struct device *dev = &pdev->dev; | ||
84 | struct ioatdma_device *d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL); | ||
85 | |||
86 | if (!d) | ||
87 | return NULL; | ||
88 | d->pdev = pdev; | ||
89 | d->reg_base = iobase; | ||
90 | return d; | ||
91 | } | ||
92 | |||
93 | static int __devinit ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | ||
88 | { | 94 | { |
89 | void __iomem * const *iomap; | 95 | void __iomem * const *iomap; |
90 | void __iomem *iobase; | ||
91 | struct device *dev = &pdev->dev; | 96 | struct device *dev = &pdev->dev; |
92 | struct ioat_device *device; | 97 | struct ioatdma_device *device; |
93 | int err; | 98 | int err; |
94 | 99 | ||
95 | err = pcim_enable_device(pdev); | 100 | err = pcim_enable_device(pdev); |
@@ -119,33 +124,24 @@ static int __devinit ioat_probe(struct pci_dev *pdev, | |||
119 | if (!device) | 124 | if (!device) |
120 | return -ENOMEM; | 125 | return -ENOMEM; |
121 | 126 | ||
122 | device->pdev = pdev; | ||
123 | pci_set_drvdata(pdev, device); | ||
124 | iobase = iomap[IOAT_MMIO_BAR]; | ||
125 | |||
126 | pci_set_master(pdev); | 127 | pci_set_master(pdev); |
127 | 128 | ||
128 | switch (readb(iobase + IOAT_VER_OFFSET)) { | 129 | device = alloc_ioatdma(pdev, iomap[IOAT_MMIO_BAR]); |
129 | case IOAT_VER_1_2: | 130 | if (!device) |
130 | device->dma = ioat_dma_probe(pdev, iobase); | 131 | return -ENOMEM; |
131 | if (device->dma && ioat_dca_enabled) | 132 | pci_set_drvdata(pdev, device); |
132 | device->dca = ioat_dca_init(pdev, iobase); | 133 | |
133 | break; | 134 | device->version = readb(device->reg_base + IOAT_VER_OFFSET); |
134 | case IOAT_VER_2_0: | 135 | if (device->version == IOAT_VER_1_2) |
135 | device->dma = ioat_dma_probe(pdev, iobase); | 136 | err = ioat1_dma_probe(device, ioat_dca_enabled); |
136 | if (device->dma && ioat_dca_enabled) | 137 | else if (device->version == IOAT_VER_2_0) |
137 | device->dca = ioat2_dca_init(pdev, iobase); | 138 | err = ioat2_dma_probe(device, ioat_dca_enabled); |
138 | break; | 139 | else if (device->version >= IOAT_VER_3_0) |
139 | case IOAT_VER_3_0: | 140 | err = ioat3_dma_probe(device, ioat_dca_enabled); |
140 | device->dma = ioat_dma_probe(pdev, iobase); | 141 | else |
141 | if (device->dma && ioat_dca_enabled) | ||
142 | device->dca = ioat3_dca_init(pdev, iobase); | ||
143 | break; | ||
144 | default: | ||
145 | return -ENODEV; | 142 | return -ENODEV; |
146 | } | ||
147 | 143 | ||
148 | if (!device->dma) { | 144 | if (err) { |
149 | dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n"); | 145 | dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n"); |
150 | return -ENODEV; | 146 | return -ENODEV; |
151 | } | 147 | } |
@@ -155,7 +151,10 @@ static int __devinit ioat_probe(struct pci_dev *pdev, | |||
155 | 151 | ||
156 | static void __devexit ioat_remove(struct pci_dev *pdev) | 152 | static void __devexit ioat_remove(struct pci_dev *pdev) |
157 | { | 153 | { |
158 | struct ioat_device *device = pci_get_drvdata(pdev); | 154 | struct ioatdma_device *device = pci_get_drvdata(pdev); |
155 | |||
156 | if (!device) | ||
157 | return; | ||
159 | 158 | ||
160 | dev_err(&pdev->dev, "Removing dma and dca services\n"); | 159 | dev_err(&pdev->dev, "Removing dma and dca services\n"); |
161 | if (device->dca) { | 160 | if (device->dca) { |
@@ -163,11 +162,7 @@ static void __devexit ioat_remove(struct pci_dev *pdev) | |||
163 | free_dca_provider(device->dca); | 162 | free_dca_provider(device->dca); |
164 | device->dca = NULL; | 163 | device->dca = NULL; |
165 | } | 164 | } |
166 | 165 | ioat_dma_remove(device); | |
167 | if (device->dma) { | ||
168 | ioat_dma_remove(device->dma); | ||
169 | device->dma = NULL; | ||
170 | } | ||
171 | } | 166 | } |
172 | 167 | ||
173 | static int __init ioat_init_module(void) | 168 | static int __init ioat_init_module(void) |