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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CFCCC433FF for ; Tue, 30 Jul 2019 15:48:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3178D208E3 for ; Tue, 30 Jul 2019 15:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564501698; bh=u8G3uu/YLVUjZICLkZ9ngEhNPuxZKK87scZFtu1ZmgY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=R9LAI3IiNvciDHwyRSK2AtxEuS3Ax8VB5Gmc7Q028q21IUgX2Xe+lyyr+IAumaxw6 fJVthHWUO6s2P/9q5iWrizIjd6vkHsEx3vJVpHBxVWBrNUu/XP077WaPwcNJKFL0fh I8hNgazqF3xb1NLXKxeKO/ACnz/Tzo7n3Ux10TuY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730501AbfG3PsR (ORCPT ); Tue, 30 Jul 2019 11:48:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:35266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbfG3PsR (ORCPT ); Tue, 30 Jul 2019 11:48:17 -0400 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3900F208E3; Tue, 30 Jul 2019 15:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564501696; bh=u8G3uu/YLVUjZICLkZ9ngEhNPuxZKK87scZFtu1ZmgY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=i1Lsevi8fySkHyU5LXwS5gZUwf3cfIKuX2KQHwjdzh8snOZu8xwAQ1Wk+8+fvpbdC jBuXYUTXy+spMjRuWnCiD5B1+46Kha3w/JXnCYstU7g9vMl1ZrLWov5rLxjmUn8USg 3Ar6lwmN8o1Fe4irwWkiObgVm27qZRJGEXDTv/Yk= Received: by mail-wm1-f46.google.com with SMTP id s3so57627350wms.2; Tue, 30 Jul 2019 08:48:16 -0700 (PDT) X-Gm-Message-State: APjAAAUOUyXnBSVUBofNXekrQp5yclIW1m9drkl6066UfqqIf+Z6xhqy MC/zy1pzeJ0AGdEmaOVQuyqBzdBy2krf3/r4JBY= X-Google-Smtp-Source: APXvYqzy094AIRwYpa7T0yizmHQReD9dLlNYBxyC0FmWxogigflCzHYWW1iUGyikNSAoRQRF4+oKPDeKtgn4z6mdlL4= X-Received: by 2002:a05:600c:20c3:: with SMTP id y3mr108901006wmm.3.1564501694671; Tue, 30 Jul 2019 08:48:14 -0700 (PDT) MIME-Version: 1.0 References: <1564488945-20149-1-git-send-email-guoren@kernel.org> <1564488945-20149-4-git-send-email-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Tue, 30 Jul 2019 23:48:03 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/4] csky: Add dma_inv_range for DMA_FROM_DEVICE To: Arnd Bergmann Cc: Linux Kernel Mailing List , linux-arch , linux-csky@vger.kernel.org, feng_shizhu@dahuatech.com, zhang_jian5@dahuatech.com, zheng_xingjian@dahuatech.com, zhu_peng@dahuatech.com, Guo Ren Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thx Arnd, On Tue, Jul 30, 2019 at 11:22 PM Arnd Bergmann wrote: > > On Tue, Jul 30, 2019 at 5:11 PM Guo Ren wrote: > > > > diff --git a/arch/csky/mm/dma-mapping.c b/arch/csky/mm/dma-mapping.c > > > > cache_op(paddr, size, dma_wb_range); > > > > break; > > > > case DMA_FROM_DEVICE: > > > > + cache_op(paddr, size, dma_inv_range); > > > > + break; > > > > case DMA_BIDIRECTIONAL: > > > > cache_op(paddr, size, dma_wbinv_range); > > > > break; > > > > > > When syncing 'for_cpu', you should not need to write back, because > > > there won't be any dirty cache lines. > > > > I just follow the dma_data_direction param, seems dir param and > > function are a little bit duplicated. And our cpu won't clear clean > > cache line into memory, so dma_wb_page won't cause problem. > > Seems arch_sync_dma_for_cpu with dir=DMA_TO_DEVICE is > > self-contradictory. > > Right, you generally don't need to do cache management for that > combination. > > There might be other things to do here though, e.g. with a strict > iommu implementation one could tear down the i/o page table > entry to prevent the device from accessing a buffer while that is > owned by the cpu. Tear down i/o page table shouldn't be put here and it's for map/unmap(). And I think arch_sync_dma_for_cpu/device should only do cache issues. -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/