@@ -534,18 +534,6 @@ static int ioat_probe(struct ioatdma_device *ioat_dma)
534534 return err ;
535535}
536536
537- static int ioat_register (struct ioatdma_device * ioat_dma )
538- {
539- int err = dma_async_device_register (& ioat_dma -> dma_dev );
540-
541- if (err ) {
542- ioat_disable_interrupts (ioat_dma );
543- dma_pool_destroy (ioat_dma -> completion_pool );
544- }
545-
546- return err ;
547- }
548-
549537static void ioat_dma_remove (struct ioatdma_device * ioat_dma )
550538{
551539 struct dma_device * dma = & ioat_dma -> dma_dev ;
@@ -1181,9 +1169,9 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca)
11811169 ioat_chan -> reg_base + IOAT_DCACTRL_OFFSET );
11821170 }
11831171
1184- err = ioat_register ( ioat_dma );
1172+ err = dma_async_device_register ( & ioat_dma -> dma_dev );
11851173 if (err )
1186- return err ;
1174+ goto err_disable_interrupts ;
11871175
11881176 ioat_kobject_add (ioat_dma , & ioat_ktype );
11891177
@@ -1192,20 +1180,29 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca)
11921180
11931181 /* disable relaxed ordering */
11941182 err = pcie_capability_read_word (pdev , PCI_EXP_DEVCTL , & val16 );
1195- if (err )
1196- return pcibios_err_to_errno (err );
1183+ if (err ) {
1184+ err = pcibios_err_to_errno (err );
1185+ goto err_disable_interrupts ;
1186+ }
11971187
11981188 /* clear relaxed ordering enable */
11991189 val16 &= ~PCI_EXP_DEVCTL_RELAX_EN ;
12001190 err = pcie_capability_write_word (pdev , PCI_EXP_DEVCTL , val16 );
1201- if (err )
1202- return pcibios_err_to_errno (err );
1191+ if (err ) {
1192+ err = pcibios_err_to_errno (err );
1193+ goto err_disable_interrupts ;
1194+ }
12031195
12041196 if (ioat_dma -> cap & IOAT_CAP_DPS )
12051197 writeb (ioat_pending_level + 1 ,
12061198 ioat_dma -> reg_base + IOAT_PREFETCH_LIMIT_OFFSET );
12071199
12081200 return 0 ;
1201+
1202+ err_disable_interrupts :
1203+ ioat_disable_interrupts (ioat_dma );
1204+ dma_pool_destroy (ioat_dma -> completion_pool );
1205+ return err ;
12091206}
12101207
12111208static void ioat_shutdown (struct pci_dev * pdev )
@@ -1350,6 +1347,8 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13501347 void __iomem * const * iomap ;
13511348 struct device * dev = & pdev -> dev ;
13521349 struct ioatdma_device * device ;
1350+ unsigned int i ;
1351+ u8 version ;
13531352 int err ;
13541353
13551354 err = pcim_enable_device (pdev );
@@ -1363,6 +1362,10 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13631362 if (!iomap )
13641363 return - ENOMEM ;
13651364
1365+ version = readb (iomap [IOAT_MMIO_BAR ] + IOAT_VER_OFFSET );
1366+ if (version < IOAT_VER_3_0 )
1367+ return - ENODEV ;
1368+
13661369 err = dma_set_mask_and_coherent (& pdev -> dev , DMA_BIT_MASK (64 ));
13671370 if (err )
13681371 return err ;
@@ -1373,17 +1376,18 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13731376 pci_set_master (pdev );
13741377 pci_set_drvdata (pdev , device );
13751378
1376- device -> version = readb ( device -> reg_base + IOAT_VER_OFFSET ) ;
1379+ device -> version = version ;
13771380 if (device -> version >= IOAT_VER_3_4 )
13781381 ioat_dca_enabled = 0 ;
1379- if (device -> version >= IOAT_VER_3_0 ) {
1380- if (is_skx_ioat (pdev ))
1381- device -> version = IOAT_VER_3_2 ;
1382- err = ioat3_dma_probe (device , ioat_dca_enabled );
1383- } else
1384- return - ENODEV ;
13851382
1383+ if (is_skx_ioat (pdev ))
1384+ device -> version = IOAT_VER_3_2 ;
1385+
1386+ err = ioat3_dma_probe (device , ioat_dca_enabled );
13861387 if (err ) {
1388+ for (i = 0 ; i < IOAT_MAX_CHANS ; i ++ )
1389+ kfree (device -> idx [i ]);
1390+ kfree (device );
13871391 dev_err (dev , "Intel(R) I/OAT DMA Engine init failed\n" );
13881392 return - ENODEV ;
13891393 }
@@ -1445,6 +1449,7 @@ module_init(ioat_init_module);
14451449static void __exit ioat_exit_module (void )
14461450{
14471451 pci_unregister_driver (& ioat_pci_driver );
1452+ kmem_cache_destroy (ioat_sed_cache );
14481453 kmem_cache_destroy (ioat_cache );
14491454}
14501455module_exit (ioat_exit_module );
0 commit comments