diff options
author | Amit Kumar Salecha <amit.salecha@qlogic.com> | 2010-05-14 06:07:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-14 06:07:46 -0400 |
commit | 1bb09fb9c9333c97dc58524b05d4ee35b02b4216 (patch) | |
tree | 2c0daaa5a98508b127960a863c27df011090b253 /drivers/net/qlcnic | |
parent | 6edae7a4848ae5b363dcc7d8ee4f3f7a34e31e36 (diff) |
qlcnic: cleanup dma mask setting
Device support 64 bit dma mask.
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/qlcnic')
-rw-r--r-- | drivers/net/qlcnic/qlcnic.h | 1 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_main.c | 93 |
2 files changed, 24 insertions, 70 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index cfedcbdd8c75..189453fc5047 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h | |||
@@ -924,7 +924,6 @@ struct qlcnic_adapter { | |||
924 | u8 driver_mismatch; | 924 | u8 driver_mismatch; |
925 | u8 msix_supported; | 925 | u8 msix_supported; |
926 | u8 rx_csum; | 926 | u8 rx_csum; |
927 | u8 pci_using_dac; | ||
928 | u8 portnum; | 927 | u8 portnum; |
929 | u8 physical_port; | 928 | u8 physical_port; |
930 | 929 | ||
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index bd6730e53fd0..a3d010a24747 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
@@ -241,66 +241,6 @@ static void qlcnic_clear_stats(struct qlcnic_adapter *adapter) | |||
241 | memset(&adapter->stats, 0, sizeof(adapter->stats)); | 241 | memset(&adapter->stats, 0, sizeof(adapter->stats)); |
242 | } | 242 | } |
243 | 243 | ||
244 | static int qlcnic_set_dma_mask(struct qlcnic_adapter *adapter) | ||
245 | { | ||
246 | struct pci_dev *pdev = adapter->pdev; | ||
247 | u64 mask, cmask; | ||
248 | |||
249 | adapter->pci_using_dac = 0; | ||
250 | |||
251 | mask = DMA_BIT_MASK(39); | ||
252 | cmask = mask; | ||
253 | |||
254 | if (pci_set_dma_mask(pdev, mask) == 0 && | ||
255 | pci_set_consistent_dma_mask(pdev, cmask) == 0) { | ||
256 | adapter->pci_using_dac = 1; | ||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | return -EIO; | ||
261 | } | ||
262 | |||
263 | /* Update addressable range if firmware supports it */ | ||
264 | static int | ||
265 | qlcnic_update_dma_mask(struct qlcnic_adapter *adapter) | ||
266 | { | ||
267 | int change, shift, err; | ||
268 | u64 mask, old_mask, old_cmask; | ||
269 | struct pci_dev *pdev = adapter->pdev; | ||
270 | |||
271 | change = 0; | ||
272 | |||
273 | shift = QLCRD32(adapter, CRB_DMA_SHIFT); | ||
274 | if (shift > 32) | ||
275 | return 0; | ||
276 | |||
277 | if (shift > 9) | ||
278 | change = 1; | ||
279 | |||
280 | if (change) { | ||
281 | old_mask = pdev->dma_mask; | ||
282 | old_cmask = pdev->dev.coherent_dma_mask; | ||
283 | |||
284 | mask = DMA_BIT_MASK(32+shift); | ||
285 | |||
286 | err = pci_set_dma_mask(pdev, mask); | ||
287 | if (err) | ||
288 | goto err_out; | ||
289 | |||
290 | err = pci_set_consistent_dma_mask(pdev, mask); | ||
291 | if (err) | ||
292 | goto err_out; | ||
293 | dev_info(&pdev->dev, "using %d-bit dma mask\n", 32+shift); | ||
294 | } | ||
295 | |||
296 | return 0; | ||
297 | |||
298 | err_out: | ||
299 | pci_set_dma_mask(pdev, old_mask); | ||
300 | pci_set_consistent_dma_mask(pdev, old_cmask); | ||
301 | return err; | ||
302 | } | ||
303 | |||
304 | static void qlcnic_set_port_mode(struct qlcnic_adapter *adapter) | 244 | static void qlcnic_set_port_mode(struct qlcnic_adapter *adapter) |
305 | { | 245 | { |
306 | u32 val, data; | 246 | u32 val, data; |
@@ -644,10 +584,6 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter) | |||
644 | { | 584 | { |
645 | int val, err, first_boot; | 585 | int val, err, first_boot; |
646 | 586 | ||
647 | err = qlcnic_set_dma_mask(adapter); | ||
648 | if (err) | ||
649 | return err; | ||
650 | |||
651 | err = qlcnic_can_start_firmware(adapter); | 587 | err = qlcnic_can_start_firmware(adapter); |
652 | if (err < 0) | 588 | if (err < 0) |
653 | return err; | 589 | return err; |
@@ -698,8 +634,6 @@ wait_init: | |||
698 | 634 | ||
699 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); | 635 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); |
700 | 636 | ||
701 | qlcnic_update_dma_mask(adapter); | ||
702 | |||
703 | qlcnic_check_options(adapter); | 637 | qlcnic_check_options(adapter); |
704 | 638 | ||
705 | adapter->need_fw_reset = 0; | 639 | adapter->need_fw_reset = 0; |
@@ -1025,7 +959,7 @@ qlcnic_reset_context(struct qlcnic_adapter *adapter) | |||
1025 | 959 | ||
1026 | static int | 960 | static int |
1027 | qlcnic_setup_netdev(struct qlcnic_adapter *adapter, | 961 | qlcnic_setup_netdev(struct qlcnic_adapter *adapter, |
1028 | struct net_device *netdev) | 962 | struct net_device *netdev, u8 pci_using_dac) |
1029 | { | 963 | { |
1030 | int err; | 964 | int err; |
1031 | struct pci_dev *pdev = adapter->pdev; | 965 | struct pci_dev *pdev = adapter->pdev; |
@@ -1048,7 +982,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, | |||
1048 | netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); | 982 | netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); |
1049 | netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); | 983 | netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); |
1050 | 984 | ||
1051 | if (adapter->pci_using_dac) { | 985 | if (pci_using_dac) { |
1052 | netdev->features |= NETIF_F_HIGHDMA; | 986 | netdev->features |= NETIF_F_HIGHDMA; |
1053 | netdev->vlan_features |= NETIF_F_HIGHDMA; | 987 | netdev->vlan_features |= NETIF_F_HIGHDMA; |
1054 | } | 988 | } |
@@ -1078,6 +1012,22 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, | |||
1078 | return 0; | 1012 | return 0; |
1079 | } | 1013 | } |
1080 | 1014 | ||
1015 | static int qlcnic_set_dma_mask(struct pci_dev *pdev, u8 *pci_using_dac) | ||
1016 | { | ||
1017 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && | ||
1018 | !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) | ||
1019 | *pci_using_dac = 1; | ||
1020 | else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) && | ||
1021 | !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) | ||
1022 | *pci_using_dac = 0; | ||
1023 | else { | ||
1024 | dev_err(&pdev->dev, "Unable to set DMA mask, aborting\n"); | ||
1025 | return -EIO; | ||
1026 | } | ||
1027 | |||
1028 | return 0; | ||
1029 | } | ||
1030 | |||
1081 | static int __devinit | 1031 | static int __devinit |
1082 | qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 1032 | qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
1083 | { | 1033 | { |
@@ -1086,6 +1036,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1086 | int err; | 1036 | int err; |
1087 | int pci_func_id = PCI_FUNC(pdev->devfn); | 1037 | int pci_func_id = PCI_FUNC(pdev->devfn); |
1088 | uint8_t revision_id; | 1038 | uint8_t revision_id; |
1039 | uint8_t pci_using_dac; | ||
1089 | 1040 | ||
1090 | err = pci_enable_device(pdev); | 1041 | err = pci_enable_device(pdev); |
1091 | if (err) | 1042 | if (err) |
@@ -1096,6 +1047,10 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1096 | goto err_out_disable_pdev; | 1047 | goto err_out_disable_pdev; |
1097 | } | 1048 | } |
1098 | 1049 | ||
1050 | err = qlcnic_set_dma_mask(pdev, &pci_using_dac); | ||
1051 | if (err) | ||
1052 | goto err_out_disable_pdev; | ||
1053 | |||
1099 | err = pci_request_regions(pdev, qlcnic_driver_name); | 1054 | err = pci_request_regions(pdev, qlcnic_driver_name); |
1100 | if (err) | 1055 | if (err) |
1101 | goto err_out_disable_pdev; | 1056 | goto err_out_disable_pdev; |
@@ -1153,7 +1108,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1153 | 1108 | ||
1154 | qlcnic_setup_intr(adapter); | 1109 | qlcnic_setup_intr(adapter); |
1155 | 1110 | ||
1156 | err = qlcnic_setup_netdev(adapter, netdev); | 1111 | err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac); |
1157 | if (err) | 1112 | if (err) |
1158 | goto err_out_disable_msi; | 1113 | goto err_out_disable_msi; |
1159 | 1114 | ||