Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3931809imm; Mon, 8 Oct 2018 11:54:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV61rN0L7BRmRnUUclVBPpPuwFr8Kwm4Pg6hc4lI4tnSoPPpc/JEnI1DnsN1Kt/NZLW9TSEoi X-Received: by 2002:a63:700e:: with SMTP id l14-v6mr21728797pgc.359.1539024849641; Mon, 08 Oct 2018 11:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024849; cv=none; d=google.com; s=arc-20160816; b=s5Thu1T5Xfh53CGOGgZdbmt7SFDq4SwyScrSeQ6/NjeRPAmmDJKnGY6sbz3DTe8Lv1 n0yEJWBanAE6qMLBGI1VELYeIW8R+XWg+/YbU600/JGSegBRrbWd8B0eAZncvzpCQUJV WlDuu+vD2K5+FWtGntTFz4grT0wJOhJGUzDigocGA/BRky4Szuh81CO5V1Gn+AHFDJVu 5lPOM4+z8ZA0/oSqa4gEkd/aFblpHYKwro2pL9LhxPxU0hNp31/QbY/uiy8SYt47yx3K ocz11ZpsoL7ADySsT2RV/A4IlgfatCZm5kvgBOJguHB95EMm7QUthFHRcH0y4INM01vM OiAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/KCGF8WKla+7RJ6ebE//Gr/+2SJ671b6WBE0QufS4yI=; b=FU6jcqB9wd6EBpxgxl8dByFpLRQQIKnTayksd5vQ8EW4m7JCq02XDUVbmqpCpBLjLZ gPHa6oQVf+MR+4gnsDrjVLLJPzzPg7U3l+7tJs74jB9JoABYP+Hysw8imi6NvXXl/a1H dTm/81BZS+vxV5dHr1r9tX/DxuivgmGbFSejwk3AdSKjPwySIzZW5IftmxaWlzgwFoa/ L+HbNXlusRMkanUzdCbomdb4Gvtzt7YBhg6MA6U57rPLGRE+R1AvLxGrAHOv+7DGi42v n8ReZl4JPsXH4E/qxU14b8Mm9ybr9qlM5DtuPJKqmp9oXTHsTqbnOlwVQygp0as75w16 D3rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RlsKClDn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6-v6si17159364pgw.391.2018.10.08.11.53.54; Mon, 08 Oct 2018 11:54:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=RlsKClDn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732565AbeJICFn (ORCPT + 99 others); Mon, 8 Oct 2018 22:05:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:55848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727260AbeJICFm (ORCPT ); Mon, 8 Oct 2018 22:05:42 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E17C204FD; Mon, 8 Oct 2018 18:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024754; bh=vxNPkCRK8MeGgrxt2S03qUK3ZKZRm/Lbq2Tn2KW5dvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlsKClDnAokQoWrqo+SC/ZkGjVqZjvsjLCvIgd5VUfVL+zi6ahpZfQL1rZgTNcOy+ YUveEoW8R4KlypZ1PQtXf3mJvTkidx/wJmJqrKz7LBDo6rImWYqyyG24u+hLAN37vB GvhO+AOASpq+4gWpOUjgXvv22Wp0EtgnDIXDkWhw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Netanel Belgazal , "David S. Miller" , Sasha Levin Subject: [PATCH 4.18 119/168] net: ena: fix driver when PAGE_SIZE == 64kB Date: Mon, 8 Oct 2018 20:31:39 +0200 Message-Id: <20181008175624.571749146@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Netanel Belgazal [ Upstream commit ef5b0771d247379c90c8bf1332ff32f7f74bff7f ] The buffer length field in the ena rx descriptor is 16 bit, and the current driver passes a full page in each ena rx descriptor. When PAGE_SIZE equals 64kB or more, the buffer length field becomes zero. To solve this issue, limit the ena Rx descriptor to use 16kB even when allocating 64kB kernel pages. This change would not impact ena device functionality, as 16kB is still larger than maximum MTU. Signed-off-by: Netanel Belgazal Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 10 +++++----- drivers/net/ethernet/amazon/ena/ena_netdev.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -461,7 +461,7 @@ static inline int ena_alloc_rx_page(stru return -ENOMEM; } - dma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE, + dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(rx_ring->dev, dma))) { u64_stats_update_begin(&rx_ring->syncp); @@ -478,7 +478,7 @@ static inline int ena_alloc_rx_page(stru rx_info->page_offset = 0; ena_buf = &rx_info->ena_buf; ena_buf->paddr = dma; - ena_buf->len = PAGE_SIZE; + ena_buf->len = ENA_PAGE_SIZE; return 0; } @@ -495,7 +495,7 @@ static void ena_free_rx_page(struct ena_ return; } - dma_unmap_page(rx_ring->dev, ena_buf->paddr, PAGE_SIZE, + dma_unmap_page(rx_ring->dev, ena_buf->paddr, ENA_PAGE_SIZE, DMA_FROM_DEVICE); __free_page(page); @@ -916,10 +916,10 @@ static struct sk_buff *ena_rx_skb(struct do { dma_unmap_page(rx_ring->dev, dma_unmap_addr(&rx_info->ena_buf, paddr), - PAGE_SIZE, DMA_FROM_DEVICE); + ENA_PAGE_SIZE, DMA_FROM_DEVICE); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page, - rx_info->page_offset, len, PAGE_SIZE); + rx_info->page_offset, len, ENA_PAGE_SIZE); netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, "rx skb updated. len %d. data_len %d\n", --- a/drivers/net/ethernet/amazon/ena/ena_netdev.h +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h @@ -355,4 +355,15 @@ void ena_dump_stats_to_buf(struct ena_ad int ena_get_sset_count(struct net_device *netdev, int sset); +/* The ENA buffer length fields is 16 bit long. So when PAGE_SIZE == 64kB the + * driver passas 0. + * Since the max packet size the ENA handles is ~9kB limit the buffer length to + * 16kB. + */ +#if PAGE_SIZE > SZ_16K +#define ENA_PAGE_SIZE SZ_16K +#else +#define ENA_PAGE_SIZE PAGE_SIZE +#endif + #endif /* !(ENA_H) */