From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33437C433F5 for ; Sat, 9 Oct 2021 09:50:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CCB060F70 for ; Sat, 9 Oct 2021 09:50:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232359AbhJIJww (ORCPT ); Sat, 9 Oct 2021 05:52:52 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:23360 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhJIJwu (ORCPT ); Sat, 9 Oct 2021 05:52:50 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HRKvQ4vd9zbcx4; Sat, 9 Oct 2021 17:46:26 +0800 (CST) Received: from dggpeml500017.china.huawei.com (7.185.36.243) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Sat, 9 Oct 2021 17:50:51 +0800 Received: from [10.40.238.78] (10.40.238.78) by dggpeml500017.china.huawei.com (7.185.36.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Sat, 9 Oct 2021 17:50:50 +0800 Subject: Re: [PATCH] RDMA/hns: Use dma_alloc_coherent() instead of kmalloc/dma_map_single() To: Jason Gunthorpe , Cai Huoqing References: <20210926061116.282-1-caihuoqing@baidu.com> <20210927115913.GA3544071@ziepe.ca> <20211004195224.GA2576309@nvidia.com> CC: Lijun Ou , Weihang Li , "Doug Ledford" , , From: Wenpeng Liang Message-ID: <07922740-2d3d-50dc-7239-421e39c42142@huawei.com> Date: Sat, 9 Oct 2021 17:50:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20211004195224.GA2576309@nvidia.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.238.78] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500017.china.huawei.com (7.185.36.243) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/10/5 3:52, Jason Gunthorpe wrote: > On Mon, Sep 27, 2021 at 08:59:13AM -0300, Jason Gunthorpe wrote: >> On Sun, Sep 26, 2021 at 02:11:15PM +0800, Cai Huoqing wrote: >>> Replacing kmalloc/kfree/dma_map_single/dma_unmap_single() >>> with dma_alloc_coherent/dma_free_coherent() helps to reduce >>> code size, and simplify the code, and coherent DMA will not >>> clear the cache every time. >>> >>> Signed-off-by: Cai Huoqing >>> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 20 +++++--------------- >>> 1 file changed, 5 insertions(+), 15 deletions(-) >> >> Given I don't see any dma_sync_single calls for this mapping, isn't >> this a correctness fix too? > > HNS folks? > > Jason > . > Our SoC can keep cache coherent, so there is no exception even if dma_sync_single* is not called, but the driver should not make assumptions about SoC. So using dma_alloc_coherent() instead of kmalloc/dma_map_single() can simplify the code and achieve the same purpose. Wenpeng Liang