Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp680326ybl; Fri, 24 Jan 2020 07:37:50 -0800 (PST) X-Google-Smtp-Source: APXvYqx2mSqy3gCn2RJ3e8jF/O0MTmyuOWvcR9ko7bpiJ9Xjo5dQwNjUPLCliBwafokTVA5SNdhh X-Received: by 2002:a05:6830:139a:: with SMTP id d26mr3239352otq.75.1579880270061; Fri, 24 Jan 2020 07:37:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579880270; cv=none; d=google.com; s=arc-20160816; b=KsSQ11UDCZQbvSl7+L+gNmATML7aOX7vLjStdbEUpR5mYtoQ7iitOKQveGVMAyvpm2 ztimQ6IHYMxyl0bkePYo2QqABEdAzKcGsKhdMFPg/2QgPeZVqkTsviuxyNA00KNSGFqp fVk4U1MWEdx3hiKP7gviZ02hejFXP9sjgCB7j79kMLzbWn4Cbji5HLMNKTxlv54qGh9h 6bUfzeyzUQStWe1SjluxlQTdhvOl6uDDM2XJfT5O2DXIGjeoHgyEqYfpcX8xJ2KPTGy7 jAe+pJbOamIgJaPA4M3MBl9qFoNeWCzKa+AcyRPlvLWaSnB9u2vsaBmPo7mEEV3wEW8+ Q4sg== 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=IZ3LPadTOlAnBApp0OPShWRHcKeD2YAs1ko8NWW9Nnw=; b=EAtBA127AgkplNPQzRuuoxWiAPFCDQ6Wq04JSFTB6lxn2JZw2YDnUe4qG7i2WUpwoq CuHwj2fadX83XS5oq/MG6JXm3jrLneuUulCqEnYPO/Op2tDNz+mJ3XCA5nM9xyp4+uDw 9WKssxDynQY5LyucoBnB0lA5YR5SwUq6agdri08pytNkBI9JJZDUWDpRn8nBbbyh8vZO w6gSr2hxn+stOqPGsFNa623GbL6c+UPQntQF1biUFo5DeQATK6vbtfMt8K03EN4hAz9/ m6DrWdTN9/IEBBLfWr2tBtbJMuLBDSOxxJOdzwe/2nxF07bAvpULtzvaCigZCDEJjKqS ufoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y2Oz4FOp; 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 a13si800521otq.201.2020.01.24.07.37.37; Fri, 24 Jan 2020 07:37:50 -0800 (PST) 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=Y2Oz4FOp; 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 S2389137AbgAXKEf (ORCPT + 99 others); Fri, 24 Jan 2020 05:04:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:40914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730743AbgAXKEf (ORCPT ); Fri, 24 Jan 2020 05:04:35 -0500 Received: from localhost (unknown [145.15.244.15]) (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 6C0F2208C4; Fri, 24 Jan 2020 10:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579860274; bh=X0BzG4EHO5sSzLhs68OT+ifvsw+VUl8p4SXf7M975Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2Oz4FOpUXNNEqF/mmjWgdntKDgC/kHY/iR8nQPcppNys2HtoDls0bwoMAHYleLHw ZypEHwkAkrA/QsqGC5WHlw2+VG789t+rYJ3hEq5uOsx6w+oxb+ePXyzBQOlOtkTcPY 9F/Y+QmAPmNRkwm50CKHQlEBInrAbWP1Feb1KIxs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Firo Yang , Alexander Duyck , Andrew Bowers , Jeff Kirsher , Sasha Levin Subject: [PATCH 4.14 300/343] ixgbe: sync the first fragment unconditionally Date: Fri, 24 Jan 2020 10:31:58 +0100 Message-Id: <20200124092959.373694763@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124092919.490687572@linuxfoundation.org> References: <20200124092919.490687572@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Firo Yang [ Upstream commit e7ba676c6188d394a0133fc4b9bcd7ee50d54b7f ] In Xen environment, if Xen-swiotlb is enabled, ixgbe driver could possibly allocate a page, DMA memory buffer, for the first fragment which is not suitable for Xen-swiotlb to do DMA operations. Xen-swiotlb have to internally allocate another page for doing DMA operations. This mechanism requires syncing the data from the internal page to the page which ixgbe sends to upper network stack. However, since commit f3213d932173 ("ixgbe: Update driver to make use of DMA attributes in Rx path"), the unmap operation is performed with DMA_ATTR_SKIP_CPU_SYNC. As a result, the sync is not performed. Since the sync isn't performed, the upper network stack could receive a incomplete network packet. By incomplete, it means the linear data on the first fragment(between skb->head and skb->end) is invalid. So we have to copy the data from the internal xen-swiotlb page to the page which ixgbe sends to upper network stack through the sync operation. More details from Alexander Duyck: Specifically since we are mapping the frame with DMA_ATTR_SKIP_CPU_SYNC we have to unmap with that as well. As a result a sync is not performed on an unmap and must be done manually as we skipped it for the first frag. As such we need to always sync before possibly performing a page unmap operation. Fixes: f3213d932173 ("ixgbe: Update driver to make use of DMA attributes in Rx path") Signed-off-by: Firo Yang Reviewed-by: Alexander Duyck Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 0edfd199937d5..e4c1e6345edd0 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1871,13 +1871,7 @@ static void ixgbe_pull_tail(struct ixgbe_ring *rx_ring, static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring, struct sk_buff *skb) { - /* if the page was released unmap it, else just sync our portion */ - if (unlikely(IXGBE_CB(skb)->page_released)) { - dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma, - ixgbe_rx_pg_size(rx_ring), - DMA_FROM_DEVICE, - IXGBE_RX_DMA_ATTR); - } else if (ring_uses_build_skb(rx_ring)) { + if (ring_uses_build_skb(rx_ring)) { unsigned long offset = (unsigned long)(skb->data) & ~PAGE_MASK; dma_sync_single_range_for_cpu(rx_ring->dev, @@ -1894,6 +1888,14 @@ static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring, skb_frag_size(frag), DMA_FROM_DEVICE); } + + /* If the page was released, just unmap it. */ + if (unlikely(IXGBE_CB(skb)->page_released)) { + dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma, + ixgbe_rx_pg_size(rx_ring), + DMA_FROM_DEVICE, + IXGBE_RX_DMA_ATTR); + } } /** -- 2.20.1