diff options
author | Amit Kumar Salecha <amit.salecha@qlogic.com> | 2010-05-14 03:07:46 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-14 03:07:46 -0700 |
commit | 1bb09fb9c9333c97dc58524b05d4ee35b02b4216 (patch) | |
tree | 2c0daaa5a98508b127960a863c27df011090b253 /drivers/net/qlcnic | |
parent | 6edae7a4848ae5b363dcc7d8ee4f3f7a34e31e36 (diff) | |
download | kernel_samsung_crespo-1bb09fb9c9333c97dc58524b05d4ee35b02b4216.zip kernel_samsung_crespo-1bb09fb9c9333c97dc58524b05d4ee35b02b4216.tar.gz kernel_samsung_crespo-1bb09fb9c9333c97dc58524b05d4ee35b02b4216.tar.bz2 |
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 cfedcbd..189453f 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h @@ -924,7 +924,6 @@ struct qlcnic_adapter { u8 driver_mismatch; u8 msix_supported; u8 rx_csum; - u8 pci_using_dac; u8 portnum; u8 physical_port; diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index bd6730e..a3d010a 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) memset(&adapter->stats, 0, sizeof(adapter->stats)); } -static int qlcnic_set_dma_mask(struct qlcnic_adapter *adapter) -{ - struct pci_dev *pdev = adapter->pdev; - u64 mask, cmask; - - adapter->pci_using_dac = 0; - - mask = DMA_BIT_MASK(39); - cmask = mask; - - if (pci_set_dma_mask(pdev, mask) == 0 && - pci_set_consistent_dma_mask(pdev, cmask) == 0) { - adapter->pci_using_dac = 1; - return 0; - } - - return -EIO; -} - -/* Update addressable range if firmware supports it */ -static int -qlcnic_update_dma_mask(struct qlcnic_adapter *adapter) -{ - int change, shift, err; - u64 mask, old_mask, old_cmask; - struct pci_dev *pdev = adapter->pdev; - - change = 0; - - shift = QLCRD32(adapter, CRB_DMA_SHIFT); - if (shift > 32) - return 0; - - if (shift > 9) - change = 1; - - if (change) { - old_mask = pdev->dma_mask; - old_cmask = pdev->dev.coherent_dma_mask; - - mask = DMA_BIT_MASK(32+shift); - - err = pci_set_dma_mask(pdev, mask); - if (err) - goto err_out; - - err = pci_set_consistent_dma_mask(pdev, mask); - if (err) - goto err_out; - dev_info(&pdev->dev, "using %d-bit dma mask\n", 32+shift); - } - - return 0; - -err_out: - pci_set_dma_mask(pdev, old_mask); - pci_set_consistent_dma_mask(pdev, old_cmask); - return err; -} - static void qlcnic_set_port_mode(struct qlcnic_adapter *adapter) { u32 val, data; @@ -644,10 +584,6 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter) { int val, err, first_boot; - err = qlcnic_set_dma_mask(adapter); - if (err) - return err; - err = qlcnic_can_start_firmware(adapter); if (err < 0) return err; @@ -698,8 +634,6 @@ wait_init: QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); - qlcnic_update_dma_mask(adapter); - qlcnic_check_options(adapter); adapter->need_fw_reset = 0; @@ -1025,7 +959,7 @@ qlcnic_reset_context(struct qlcnic_adapter *adapter) static int qlcnic_setup_netdev(struct qlcnic_adapter *adapter, - struct net_device *netdev) + struct net_device *netdev, u8 pci_using_dac) { int err; struct pci_dev *pdev = adapter->pdev; @@ -1048,7 +982,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); - if (adapter->pci_using_dac) { + if (pci_using_dac) { netdev->features |= NETIF_F_HIGHDMA; netdev->vlan_features |= NETIF_F_HIGHDMA; } @@ -1078,6 +1012,22 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, return 0; } +static int qlcnic_set_dma_mask(struct pci_dev *pdev, u8 *pci_using_dac) +{ + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && + !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) + *pci_using_dac = 1; + else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) && + !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) + *pci_using_dac = 0; + else { + dev_err(&pdev->dev, "Unable to set DMA mask, aborting\n"); + return -EIO; + } + + return 0; +} + static int __devinit qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1086,6 +1036,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) int err; int pci_func_id = PCI_FUNC(pdev->devfn); uint8_t revision_id; + uint8_t pci_using_dac; err = pci_enable_device(pdev); if (err) @@ -1096,6 +1047,10 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_disable_pdev; } + err = qlcnic_set_dma_mask(pdev, &pci_using_dac); + if (err) + goto err_out_disable_pdev; + err = pci_request_regions(pdev, qlcnic_driver_name); if (err) goto err_out_disable_pdev; @@ -1153,7 +1108,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) qlcnic_setup_intr(adapter); - err = qlcnic_setup_netdev(adapter, netdev); + err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac); if (err) goto err_out_disable_msi; |