aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-05-14 16:40:15 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-17 14:31:09 -0400
commit27896c83fe94e2190f121a2fdbffffbf1d83d573 (patch)
tree41c57b6171dd4d4a863078a65b31f1a6933a58d4
parent81003bc924bac0a99bfdc2869f5dff5a87aa4a3d (diff)
r8169: default to 64-bit DMA on recent PCIe chips
The current logic around the 'use_dac' module parameter prevents the r81969 driver from being loadable on 64-bit systems without any RAM below 4 GB when the parameter is left at its default value. So introduce a new default value -1 which indicates that 64-bit DMA should be enabled on sufficiently recent PCIe chips, i.e., versions RTL_GIGA_MAC_VER_18 or later. Explicit param values of 0 or 1 retain the existing behavior of unconditionally enabling/disabling 64-bit DMA on 64-bit architectures (i.e., regardless of the type and version of the chip) Since PCIe chips do not need to CPlusCmd Dual Address Cycle to be set, make that conditional on the device type as well. Cc: Realtek linux nic maintainers <nic_swsd@realtek.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/realtek/r8169.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 94f08f1e841c..0e62d74b09b3 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -345,7 +345,7 @@ static const struct pci_device_id rtl8169_pci_tbl[] = {
345MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); 345MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
346 346
347static int rx_buf_sz = 16383; 347static int rx_buf_sz = 16383;
348static int use_dac; 348static int use_dac = -1;
349static struct { 349static struct {
350 u32 msg_enable; 350 u32 msg_enable;
351} debug = { -1 }; 351} debug = { -1 };
@@ -8224,20 +8224,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8224 goto err_out_mwi_2; 8224 goto err_out_mwi_2;
8225 } 8225 }
8226 8226
8227 tp->cp_cmd = 0;
8228
8229 if ((sizeof(dma_addr_t) > 4) &&
8230 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) {
8231 tp->cp_cmd |= PCIDAC;
8232 dev->features |= NETIF_F_HIGHDMA;
8233 } else {
8234 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
8235 if (rc < 0) {
8236 netif_err(tp, probe, dev, "DMA configuration failed\n");
8237 goto err_out_free_res_3;
8238 }
8239 }
8240
8241 /* ioremap MMIO region */ 8227 /* ioremap MMIO region */
8242 ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); 8228 ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE);
8243 if (!ioaddr) { 8229 if (!ioaddr) {
@@ -8253,6 +8239,25 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8253 /* Identify chip attached to board */ 8239 /* Identify chip attached to board */
8254 rtl8169_get_mac_version(tp, dev, cfg->default_ver); 8240 rtl8169_get_mac_version(tp, dev, cfg->default_ver);
8255 8241
8242 tp->cp_cmd = 0;
8243
8244 if ((sizeof(dma_addr_t) > 4) &&
8245 (use_dac == 1 || (use_dac == -1 && pci_is_pcie(pdev) &&
8246 tp->mac_version >= RTL_GIGA_MAC_VER_18)) &&
8247 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
8248
8249 /* CPlusCmd Dual Access Cycle is only needed for non-PCIe */
8250 if (!pci_is_pcie(pdev))
8251 tp->cp_cmd |= PCIDAC;
8252 dev->features |= NETIF_F_HIGHDMA;
8253 } else {
8254 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
8255 if (rc < 0) {
8256 netif_err(tp, probe, dev, "DMA configuration failed\n");
8257 goto err_out_unmap_4;
8258 }
8259 }
8260
8256 rtl_init_rxcfg(tp); 8261 rtl_init_rxcfg(tp);
8257 8262
8258 rtl_irq_disable(tp); 8263 rtl_irq_disable(tp);
@@ -8412,12 +8417,12 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8412 &tp->counters_phys_addr, GFP_KERNEL); 8417 &tp->counters_phys_addr, GFP_KERNEL);
8413 if (!tp->counters) { 8418 if (!tp->counters) {
8414 rc = -ENOMEM; 8419 rc = -ENOMEM;
8415 goto err_out_msi_4; 8420 goto err_out_msi_5;
8416 } 8421 }
8417 8422
8418 rc = register_netdev(dev); 8423 rc = register_netdev(dev);
8419 if (rc < 0) 8424 if (rc < 0)
8420 goto err_out_cnt_5; 8425 goto err_out_cnt_6;
8421 8426
8422 pci_set_drvdata(pdev, dev); 8427 pci_set_drvdata(pdev, dev);
8423 8428
@@ -8451,12 +8456,13 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8451out: 8456out:
8452 return rc; 8457 return rc;
8453 8458
8454err_out_cnt_5: 8459err_out_cnt_6:
8455 dma_free_coherent(&pdev->dev, sizeof(*tp->counters), tp->counters, 8460 dma_free_coherent(&pdev->dev, sizeof(*tp->counters), tp->counters,
8456 tp->counters_phys_addr); 8461 tp->counters_phys_addr);
8457err_out_msi_4: 8462err_out_msi_5:
8458 netif_napi_del(&tp->napi); 8463 netif_napi_del(&tp->napi);
8459 rtl_disable_msi(pdev, tp); 8464 rtl_disable_msi(pdev, tp);
8465err_out_unmap_4:
8460 iounmap(ioaddr); 8466 iounmap(ioaddr);
8461err_out_free_res_3: 8467err_out_free_res_3:
8462 pci_release_regions(pdev); 8468 pci_release_regions(pdev);