Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3702434pxb; Mon, 24 Jan 2022 15:48:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3IoHGgBdwtjJkSRKHpH8C00a4VSvaBb1VeePrzwC+vkkOGrqgppFkxVgA0+uluccC6DIZ X-Received: by 2002:a62:8fd0:0:b0:4c6:e1d9:7822 with SMTP id n199-20020a628fd0000000b004c6e1d97822mr16087966pfd.38.1643068113641; Mon, 24 Jan 2022 15:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068113; cv=none; d=google.com; s=arc-20160816; b=TB/3XTFZQavlGlTTCG5q+cRr8xqlW8gi5DHNTE6rFYj5YYRgmhppKYVqo1cKFkzSEn 46d1Q0zZVTl23anbUXMEpOZXPolI1dyeasT6V1aHAAmkZUY0hNescTmJOMkN3knT3LHv VHLAjDgWcUZCFrb6y01z7M0q/P+33o/VzDPqP1JPN7Rie6jRtUHkKJXQZDVJ8GEJcr4W qasCzMy9FQoeoOR+DOZuEg6A1jSG6yA/UtfuoRgQXIdpuZ3zAVeTifP/I+yezbO1fFDf XxCavjcO0ZQa0dmFdDEDAA7LRL/PAVsTw/mjDIu47nqXVAgSn+qVXaK6DgTRYZAXmPzt FRAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g+uAXbktAP2o/gWOWQ4ILO1hnETyP/KS6oSAdi8uaqs=; b=cAkUKKUjowVPLVPahlzN8KYajhJAstVSKkf9MKkkdgdKZEPn+rupGUWi41FaH/kOaH mOcnN21m9hBZIemFHFKK5yWig5VWX71j/IQ76Nkpq6UAysBxe5k1y3xFXPwNrgBfKh7+ Y78VrS3pAAdDRYSTjDMpqSD+LMGyIIBJ2x28XdgETod1ghMd1W8JSBFKMTSDEEObxrH7 eff7zaW05chTIZG6zv1GoAmDkryscCn7+ODTje5cHy6aybUZ7Aw0qCbCaXYeRomyD69o vUwgtNXzYfq+JSjShN5QqKZ2IjfeONkhACfO/EEsknX3X/GTrn1pvWS8t24OUpdGe/kL ZIiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oforqcSW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si13125894pls.47.2022.01.24.15.48.22; Mon, 24 Jan 2022 15:48:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oforqcSW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2362019AbiAXXlY (ORCPT + 99 others); Mon, 24 Jan 2022 18:41:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1841813AbiAXXAE (ORCPT ); Mon, 24 Jan 2022 18:00:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DABC1C09D322; Mon, 24 Jan 2022 13:13:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A24A4B81142; Mon, 24 Jan 2022 21:13:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1DE8C340E5; Mon, 24 Jan 2022 21:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058819; bh=h2FlKSl0WAXSPEKWoJS3EvlZl717LALX1016o4oT2YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oforqcSWeXmpFqKTu9RYhUw+hxfZCa8uGzvp0Xb29SYRPBm5NNYPfqalyQS1ea5wI qjk3IkENINEUDxcghzUgzVZfr+Sk1hkgzI5kfGcxPhHHoQmrNKPU3i/p4IRisCB/o4 9IXTA0IYw3tDLN5/BQLbz/YyRXbhKbupljXd2mVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aya Levin , Gal Pressman , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.16 0405/1039] net/mlx5e: Fix page DMA map/unmap attributes Date: Mon, 24 Jan 2022 19:36:34 +0100 Message-Id: <20220124184138.928021863@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aya Levin [ Upstream commit 0b7cfa4082fbf550595bc0e40f05614bd83bf0cd ] Driver initiates DMA sync, hence it may skip CPU sync. Add DMA_ATTR_SKIP_CPU_SYNC as input attribute both to dma_map_page and dma_unmap_page to avoid redundant sync with the CPU. When forcing the device to work with SWIOTLB, the extra sync might cause data corruption. The driver unmaps the whole page while the hardware used just a part of the bounce buffer. So syncing overrides the entire page with bounce buffer that only partially contains real data. Fixes: bc77b240b3c5 ("net/mlx5e: Add fragmented memory support for RX multi packet WQE") Fixes: db05815b36cb ("net/mlx5e: Add XSK zero-copy support") Signed-off-by: Aya Levin Reviewed-by: Gal Pressman Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c index 7b562d2c8a196..279cd8f4e79f7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c @@ -11,13 +11,13 @@ static int mlx5e_xsk_map_pool(struct mlx5e_priv *priv, { struct device *dev = mlx5_core_dma_dev(priv->mdev); - return xsk_pool_dma_map(pool, dev, 0); + return xsk_pool_dma_map(pool, dev, DMA_ATTR_SKIP_CPU_SYNC); } static void mlx5e_xsk_unmap_pool(struct mlx5e_priv *priv, struct xsk_buff_pool *pool) { - return xsk_pool_dma_unmap(pool, 0); + return xsk_pool_dma_unmap(pool, DMA_ATTR_SKIP_CPU_SYNC); } static int mlx5e_xsk_get_pools(struct mlx5e_xsk *xsk) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 793511d5ee4cd..dfc6604b9538b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -278,8 +278,8 @@ static inline int mlx5e_page_alloc_pool(struct mlx5e_rq *rq, if (unlikely(!dma_info->page)) return -ENOMEM; - dma_info->addr = dma_map_page(rq->pdev, dma_info->page, 0, - PAGE_SIZE, rq->buff.map_dir); + dma_info->addr = dma_map_page_attrs(rq->pdev, dma_info->page, 0, PAGE_SIZE, + rq->buff.map_dir, DMA_ATTR_SKIP_CPU_SYNC); if (unlikely(dma_mapping_error(rq->pdev, dma_info->addr))) { page_pool_recycle_direct(rq->page_pool, dma_info->page); dma_info->page = NULL; @@ -300,7 +300,8 @@ static inline int mlx5e_page_alloc(struct mlx5e_rq *rq, void mlx5e_page_dma_unmap(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info) { - dma_unmap_page(rq->pdev, dma_info->addr, PAGE_SIZE, rq->buff.map_dir); + dma_unmap_page_attrs(rq->pdev, dma_info->addr, PAGE_SIZE, rq->buff.map_dir, + DMA_ATTR_SKIP_CPU_SYNC); } void mlx5e_page_release_dynamic(struct mlx5e_rq *rq, -- 2.34.1