From patchwork Wed Apr 29 23:58:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 466331 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 43842140308 for ; Thu, 30 Apr 2015 09:58:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbbD2X61 (ORCPT ); Wed, 29 Apr 2015 19:58:27 -0400 Received: from mx0a-000f0801.pphosted.com ([67.231.144.122]:25975 "EHLO mx0a-000f0801.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751477AbbD2X6Q (ORCPT ); Wed, 29 Apr 2015 19:58:16 -0400 Received: from pps.filterd (m0048193.ppops.net [127.0.0.1]) by mx0a-000f0801.pphosted.com (8.14.7/8.14.7) with SMTP id t3TMxeEX019133; Wed, 29 Apr 2015 16:58:12 -0700 Received: from hq1wp-exchub02.corp.brocade.com ([144.49.131.13]) by mx0a-000f0801.pphosted.com with ESMTP id 1u38fp82n2-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 29 Apr 2015 16:58:11 -0700 Received: from HQ1WP-EXMB12.corp.brocade.com (10.70.20.186) by hq1wp-exchub02.corp.brocade.com (10.70.38.99) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 29 Apr 2015 16:58:11 -0700 Received: from urahara (10.72.48.124) by HQ1WP-EXMB12.corp.brocade.com (10.70.20.186) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Wed, 29 Apr 2015 16:58:10 -0700 Date: Wed, 29 Apr 2015 16:58:13 -0700 From: Stephen Hemminger To: Francois Romieu , Eric Dumazet CC: Subject: [RFC] r8169 DMA failure with iommu=off Message-ID: <20150429165813.5d64daf0@urahara> Organization: Brocade MIME-Version: 1.0 X-Originating-IP: [10.72.48.124] X-ClientProxiedBy: hq1wp-excas12.corp.brocade.com (10.70.38.22) To HQ1WP-EXMB12.corp.brocade.com (10.70.20.186) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2015-04-29_07:2015-04-29, 2015-04-29, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=8 spamscore=8 suspectscore=1 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1504290282 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This only fixes the Rx side, what about Tx? I think maybe just removing the whole use_dac flag completely? Subject: r8169: allocate rx memory in correct region This fixes failure when using r8169 with IOMMU defined but not enabled. Reproduced on a 16G machine with LOM r8169 and kernel set to 'iommu=off'. This driver has two dma modes. By default use_dac module parameter is zero and therefore the driver uses only has a 32 bit DMA mask. But since it calls kmalloc_node() without setting DMA32 flag the receive buffer maybe above 4G and the dma_map_single will fail. In either case since this is a receive DMA buffer, it should set the appropriate GFP_DMA since that may matter on some platforms. This an old bug was introduced by: commit 6f0333b8fde44b8c04a53b2461504f0e8f1cebe6 Author: Eric Dumazet Date: Mon Oct 11 11:17:47 2010 +0000 r8169: use 50% less ram for RX ring Using standard skb allocations in r8169 leads to order-3 allocations (if PAGE_SIZE=4096), because NIC needs 16383 bytes, and skb overhead makes this bigger than 16384 -> 32768 bytes per "skb" Using kmalloc() permits to reduce memory requirements of one r8169 nic by 4Mbytes. (256 frames * 16Kbytes). This is fine since a hardware bug requires us to copy incoming frames, so we build real skb when doing this copy. Signed-off-by: Stephen Hemminger --- 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 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5721,14 +5721,16 @@ static struct sk_buff *rtl8169_alloc_rx_ struct device *d = &tp->pci_dev->dev; struct net_device *dev = tp->dev; int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; + gfp_t flags = GFP_KERNEL; - data = kmalloc_node(rx_buf_sz, GFP_KERNEL, node); + flags |= (dev->features & NETIF_F_HIGHDMA) ? GFP_DMA : GFP_DMA32; + data = kmalloc_node(rx_buf_sz, flags, node); if (!data) return NULL; if (rtl8169_align(data) != data) { kfree(data); - data = kmalloc_node(rx_buf_sz + 15, GFP_KERNEL, node); + data = kmalloc_node(rx_buf_sz + 15, flags, node); if (!data) return NULL; }