From patchwork Sat Feb 20 01:00:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 45905 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E4B1FB7C09 for ; Sat, 20 Feb 2010 12:07:59 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752524Ab0BTBHf (ORCPT ); Fri, 19 Feb 2010 20:07:35 -0500 Received: from mail-yw0-f197.google.com ([209.85.211.197]:49246 "EHLO mail-yw0-f197.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774Ab0BTBHd (ORCPT ); Fri, 19 Feb 2010 20:07:33 -0500 Received: by ywh35 with SMTP id 35so672328ywh.4 for ; Fri, 19 Feb 2010 17:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=loteylKpAeHQ+QwHFqra3Va2RgH0A+utSuYkTapPAfw=; b=SSm1egCbYbKoOwIwaD2DSUfUAXs34/R9M5jtgy4N2FvwEGUesPSjwWLp16+T+FFTvA hT3mxR1/bXIuWo23qnxKtBjkAfk0XHz7TgMO+tdiVMn1IDRxkbs85ki2L2HGfTvxy4k6 qKhaf9jNtjFhYAVxB/oTKgGyewxqF7GtWiE0Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=gePP9v9lfdXuGtVfbOwwyQrDDoS4JaGRLtmNQ3tH0pwlIIvpZg8bp82fa8OyFvqklq +OZ/+B5tH1PmYlFFnuHRSy9zGcTcJ4hogJCcc+iNTznKJwW/QyRD84PZxQGJVEDkPbIJ uHnKJAJPVUbV/80U0MGRAte1UXxS2brnrAjR8= Received: by 10.151.93.5 with SMTP id v5mr2891423ybl.6.1266627689745; Fri, 19 Feb 2010 17:01:29 -0800 (PST) Received: from ?192.168.1.148? (S0106000c41bb86e1.ss.shawcable.net [70.76.40.110]) by mx.google.com with ESMTPS id 22sm324345yxe.21.2010.02.19.17.01.28 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Feb 2010 17:01:29 -0800 (PST) Message-ID: <4B7F343E.4040409@gmail.com> Date: Fri, 19 Feb 2010 19:00:46 -0600 From: Robert Hancock User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc12 Thunderbird/3.0.1 MIME-Version: 1.0 To: David Miller CC: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, romieu@fr.zoreil.com Subject: [PATCH 2.6.34] r8169: enable 64-bit DMA by default for PCI Express devices (v2) References: <4B7CAEC1.6090408@gmail.com> <20100219.131718.115496278.davem@davemloft.net> In-Reply-To: <20100219.131718.115496278.davem@davemloft.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently use of 64-bit DMA is disabled in r8169 unless the user passes the use_dac module option. This is reasonable for conventional PCI devices where broken chipsets may not handle dual-address-cycle transfers properly for 32-bit slots and so this may not be safe. However, PCI Express should not have this problem and not using 64-bit DMA results in DMA transfers needlessly using the IOMMU or SWIOTLB. Set the use_dac module parameter to a new default value of -1 which results in 64-bit DMA being enabled by default for PCI Express devices only. Signed-off-by: Robert Hancock --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 616ae5a..83965ee 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c @@ -187,7 +187,7 @@ static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); static int rx_copybreak = 200; -static int use_dac; +static int use_dac = -1; static struct { u32 msg_enable; } debug = { -1 }; @@ -511,7 +511,8 @@ MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); module_param(rx_copybreak, int, 0); MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); module_param(use_dac, int, 0); -MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); +MODULE_PARM_DESC(use_dac, "Enable PCI DAC. -1 defaults on for PCI Express only." +" Unsafe on 32 bit PCI slot."); module_param_named(debug, debug.msg_enable, int, 0); MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); MODULE_LICENSE("GPL"); @@ -2973,6 +2974,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) void __iomem *ioaddr; unsigned int i; int rc; + int this_use_dac = use_dac; if (netif_msg_drv(&debug)) { printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", @@ -3038,8 +3040,17 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->cp_cmd = PCIMulRW | RxChkSum; + tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); + if (!tp->pcie_cap) + netif_info(tp, probe, dev, "no PCI Express capability\n"); + + if (this_use_dac < 0) + this_use_dac = tp->pcie_cap != 0; + if ((sizeof(dma_addr_t) > 4) && - !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { + this_use_dac && + !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { + netif_info(tp, probe, dev, "using 64-bit DMA\n"); tp->cp_cmd |= PCIDAC; dev->features |= NETIF_F_HIGHDMA; } else { @@ -3058,10 +3069,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_free_res_4; } - tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); - if (!tp->pcie_cap) - netif_info(tp, probe, dev, "no PCI Express capability\n"); - RTL_W16(IntrMask, 0x0000); /* Soft reset the chip. */