Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5144658ybh; Wed, 7 Aug 2019 01:18:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS12vb9W88RK5g9Cn9kJKbzKqblboiTz38B1/3sj9RbAOdiHzkT+NwywUTboOGRbYrwrsZ X-Received: by 2002:a62:750c:: with SMTP id q12mr8337777pfc.59.1565165909295; Wed, 07 Aug 2019 01:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565165909; cv=none; d=google.com; s=arc-20160816; b=IbVQDzWLXUAyRNj77GvprfpvjVYEXTFRTMP8hkvJ3aZ4hGzdr2XOsVh6DFsFuMYoQu JerZ/z4QGGHw0VA3725H1TePiVdJaZRhujxl3lC6n3nVBWGsGIiOuS5k67NF/R7zGsPD UYo4LPayiiaPPDE4F3128nNstxhdxJaA5mlPbcGmr0f4p6GHqPTP84Qzgou/2duI4na4 EqrTNI1/+EI0Hy71izSCjpq9UgotRtb50jSRf2HPEz7wVFh/SShrkOsHAmI2MCATfdE/ IW6wZpEJP4cS8QlAuUpcHgflUMsZ6M6466bq/3AfBcugJRp24pWcy8/XMxWYFW4mUSWP abaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=vb94Xu/WRdFxAZR3eQGfCToyPrjki8zHPtft8A3HtDI=; b=rHl6MpzcFwHKaunWFtU/bPkWqD6IZ44QZGdoBsvCk4uWkCzZwdJFbkX+BZ1m/rcyS/ H9wKXye0b4G8RnXW6BaivEeXoKCOoiGEeUhzJemVnUKXuKTuG53cTsSi3w03zNMoMByD tueIe8PMZlNynxITRMiyM+qYFuX8q3B3oTOuLKBE6nie3xhvr8y8IQ9Rffnl8SuGX2vr y0GRSCP1CaeFMwQnclDAShxa+Sk7TMmvVHGU8f1Dr3nK95DvahFsDq6SWlfVO+L2BvEs dPKtR2Om4uAgyTM9C1EOyBx5Ce2y9Lce61yQfTmzKHQPcCUBDzo5YoUoAqSA0qOzwbMb avVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Wh70IRXx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si27231750pgp.22.2019.08.07.01.18.14; Wed, 07 Aug 2019 01:18:29 -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=@oracle.com header.s=corp-2018-07-02 header.b=Wh70IRXx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387526AbfHGH4Z (ORCPT + 99 others); Wed, 7 Aug 2019 03:56:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58286 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727413AbfHGH4Z (ORCPT ); Wed, 7 Aug 2019 03:56:25 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x777sVrp042116; Wed, 7 Aug 2019 07:56:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=vb94Xu/WRdFxAZR3eQGfCToyPrjki8zHPtft8A3HtDI=; b=Wh70IRXxx4ZxP4r2wEFpWJx5eB0HIE3YqCkGEcmEBs1hMlRjDxwAyc0ViDxpxJaddqkQ iicMxYAuK1i+FUlrVeBdydzSZMbB7ABmO0VXqkuqRMqvGTYe6xIgyA+kSA83/LTbRiwE 8c4Sh0FkT2zRg0Jzd4iO3wASvjO2UfbjER4q4tUCXOw8Y4f65V9Jae3B1xqRtSre6asb tqHQRDrIgJnwtVo9hrTpQruobh52IwCG3LHLZrvQ8i+3IjIQyXoBCwMs2ci9S+ZEhFrK efAHUYIwWdZ9VGrDMHVstAr8Y5z+3AFKoEvPQbuGUSZ8V9lnBaxprl4+e+8ivOcM4Rst sA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2u527ptk8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Aug 2019 07:56:12 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x777qf6X126164; Wed, 7 Aug 2019 07:56:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2u75bw6j0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Aug 2019 07:56:11 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x777uApC001488; Wed, 7 Aug 2019 07:56:11 GMT Received: from [10.191.27.28] (/10.191.27.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 Aug 2019 00:56:10 -0700 Subject: Re: [PATCH v2 1/1] ixgbe: sync the first fragment unconditionally To: Firo Yang , "davem@davemloft.net" Cc: "alexander.h.duyck@linux.intel.com" , "jeffrey.t.kirsher@intel.com" , "netdev@vger.kernel.org" , "intel-wired-lan@lists.osuosl.org" , "linux-kernel@vger.kernel.org" References: <20190807024917.27682-1-firo.yang@suse.com> From: Jacob Wen Message-ID: <85aaefdf-d454-1823-5840-d9e2f71ffb19@oracle.com> Date: Wed, 7 Aug 2019 15:56:07 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190807024917.27682-1-firo.yang@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9341 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908070085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9341 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908070085 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I think the description is not correct. Consider using something like below. In Xen environment, due to memory fragmentation ixgbe may allocate a 'DMA' buffer with pages that are not physically contiguous. A NIC doesn't support directly write such buffer. So xen-swiotlb would use the pages, which are physically contiguous, from the swiotlb buffer for the NIC. The unmap operation is used to copy the swiotlb buffer to the pages that are allocated by ixgbe. On 8/7/19 10:49 AM, Firo Yang wrote: > 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. It requires syncing between those two pages. 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. > > To fix this problem, always sync before possibly performing a page > unmap operation. > > Fixes: f3213d932173 ("ixgbe: Update driver to make use of DMA > attributes in Rx path") > Reviewed-by: Alexander Duyck > Signed-off-by: Firo Yang > --- > > Changes from v1: > * Imporved the patch description. > * Added Reviewed-by: and Fixes: as suggested by Alexander Duyck > > 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 cbaf712d6529..200de9838096 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > @@ -1825,13 +1825,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, > @@ -1848,6 +1842,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); > + } > } > > /**