From patchwork Wed May 11 07:47:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 67486 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp88082qge; Wed, 11 May 2016 00:48:04 -0700 (PDT) X-Received: by 10.66.166.78 with SMTP id ze14mr2592982pab.149.1462952884893; Wed, 11 May 2016 00:48:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si7891805pfi.106.2016.05.11.00.48.04; Wed, 11 May 2016 00:48:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670AbcEKHsB (ORCPT + 4 others); Wed, 11 May 2016 03:48:01 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:34843 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382AbcEKHsA (ORCPT ); Wed, 11 May 2016 03:48:00 -0400 Received: by mail-wm0-f42.google.com with SMTP id e201so206928977wme.0 for ; Wed, 11 May 2016 00:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=SGjZcjT+HaayUnO3p9BiPKLosFCF99UdvZLQmfxTUnI=; b=k18RlRmCZiqxFsACn8oWA52SM+Oofd10NVysX7U4jioEnNkzFC2AtqKiJQg+KRgrBY G3BjDNkRJBzaFTV3fgXE1ef73DnIZqY5Ei+AmuZKTgpIJrchYtF/y+LSXWHnxlO+Mec1 cYcHqo/4Dmdxu8djXvYK0HlmxAJ0zqtgMxrDM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SGjZcjT+HaayUnO3p9BiPKLosFCF99UdvZLQmfxTUnI=; b=dy1jL7a5DUONNxZ2p0b0cjwmnU9lkuAt313fmC5zQX1hqcN6hQdwtOar+6SBmOQXy7 DiqfXjym6CnYEkpFICdSfAS8ADdHzYvU1vkiaVXOOcifat13AMTvJXWlN7uCsngD64+W IitzgpoMPipP29+x0j4rF2d8+ELemmu+prxmOWD41s5ntZlrNp3XXJ8gVjoPB9Y77apH TI3sWAMLs79o0aaGVO/MBmYD6eJ1CxqBCWhbpkWEZdi3pA1jJyEBMw5rSPoqHadHTVf6 yYvqDOWM2sZO/NaE+W8NnxKvgtRI1PiPORSWwUzewNZ7C35w+ctnUqlq6DpcV+jw6LfV gBtw== X-Gm-Message-State: AOPr4FXS4JPnWyQVIKR+6cdNv8JdOUMtRoQPdm3Jtp6elpebK4UcXpEE3bQbFNIi0TStmLr8 X-Received: by 10.28.47.206 with SMTP id v197mr2594939wmv.87.1462952879070; Wed, 11 May 2016 00:47:59 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id o4sm6553988wjx.45.2016.05.11.00.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 00:47:58 -0700 (PDT) From: Ard Biesheuvel To: netdev@vger.kernel.org Cc: ricardo.salveti@linaro.org, leo.duran@amd.com, graeme.gregory@linaro.org, Ard Biesheuvel , Realtek linux nic maintainers Subject: [PATCH] r8169: default to 64-bit DMA on systems without memory below 4 GB Date: Wed, 11 May 2016 09:47:49 +0200 Message-Id: <1462952869-23498-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 implicitly, but only if setting a 32-bit DMA mask has failed earlier. This should prevent any regressions like the ones caused by previous attempts to change this code. Cc: Realtek linux nic maintainers Signed-off-by: Ard Biesheuvel --- drivers/net/ethernet/realtek/r8169.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 94f08f1e841c..a49e8a58e539 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[] = { MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); static int rx_buf_sz = 16383; -static int use_dac; +static int use_dac = -1; static struct { u32 msg_enable; } debug = { -1 }; @@ -859,7 +859,8 @@ struct rtl8169_private { MODULE_AUTHOR("Realtek and the Linux r8169 crew "); MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); 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. Unsafe on 32 bit PCI slot (default -1: enable on 64-bit archs only if needed"); module_param_named(debug, debug.msg_enable, int, 0); MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); MODULE_LICENSE("GPL"); @@ -8226,12 +8227,16 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->cp_cmd = 0; + /* Tentatively set the DMA mask to 32 bits. This may fail + * on 64-bit architectures without any RAM below 4 GB. + */ + rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if ((sizeof(dma_addr_t) > 4) && - !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { + (use_dac == 1 || (use_dac == -1 && rc < 0)) && + !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { tp->cp_cmd |= PCIDAC; dev->features |= NETIF_F_HIGHDMA; } else { - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (rc < 0) { netif_err(tp, probe, dev, "DMA configuration failed\n"); goto err_out_free_res_3;