Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp143794imm; Thu, 27 Sep 2018 17:52:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV63dNaE6tOP6mAEne+L8X5mhajDsdcfBYmfXAKuE88xPIqq5jnbTTyzhDx+yiBXBYAOk5lSg X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr13489305pli.315.1538095974322; Thu, 27 Sep 2018 17:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538095974; cv=none; d=google.com; s=arc-20160816; b=MY/jSp8axKHGlQdOov8hYJszXiydlrl5crTBpd0c4Y1pKdMPrcrB8OzRtgbZw1EUFR 3Yl8Mn/sR4KztJJ1tGAuR++2A1pg7DBYMmrVjMFvFhCei2wGAyN3XxyDiIHzRTeZvUdD zfQlu0dOHBdkDImkjZ0Jtibni0w0rtmdCpKN+zNcpLQ3xrS6JLzamCTxPtQpqhEkNXmp qfs4HhDizeCQ6X4wf20yrF0PxzAqqsKWhHh8bFFXfK4o6HdOjUNDDF+INYQIkB4bLHYG iE3BYMjmpqWX9Z2ZkhtSa8FPosz6oH+9BS5hSjtBuL9t7/bU+LEHAx5j+XxRuYJjc0Zo Aa8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=6GmcM6MPc4sZWGPhjLEKoMBUNJHYhYn6XCWjAe2zGYY=; b=FK8CSTIx943JJA4I/4RuHegAqU7ixoG4HkDC6SjCaaIJbTL6g16aJsldTrBDiBuDps Zpdj/W3aKhF0+r7YWzmW2q6xwoMSMjJ88HGK3KeivXwYBTi1cswO81ebKvy/+4WO4+lX XO9GdozlEU8r/iMsTLixhQnq6BVdY2sHPK7GhjbKCQBZVeCxQxXKxZMkbdVsMc4HOWdt uW4fR1wR8ecm2qNjciPB4oS58Fs1YWkYjBLikgEsKjp9SRlCCHh8JdCWJYde+NuHPRBh v9hSM6P2W3c0LmeeBHoiwSS+U2tjGg3ibiqJ4DtkN3VnHChuXPNDUHdMKVstdQB1Bf1G gnoQ== ARC-Authentication-Results: i=1; mx.google.com; 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 u10-v6si3359399pls.89.2018.09.27.17.52.38; Thu, 27 Sep 2018 17:52:54 -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; 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 S1728161AbeI1HN0 (ORCPT + 99 others); Fri, 28 Sep 2018 03:13:26 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:52931 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbeI1HN0 (ORCPT ); Fri, 28 Sep 2018 03:13:26 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08872253|-1;CH=blue;FP=7344213741358826467|1|1|12|0|-1|-1|-1;HT=e02c03307;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=18;RT=18;SR=0;TI=SMTPD_---.CwkaOHk_1538095931; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:SMTPD_---.CwkaOHk_1538095931) by smtp.aliyun-inc.com(10.147.41.137); Fri, 28 Sep 2018 08:52:11 +0800 From: Guo Ren To: akpm@linux-foundation.org, arnd@arndb.de, daniel.lezcano@linaro.org, davem@davemloft.net, gregkh@linuxfoundation.org, jason@lakedaemon.net, marc.zyngier@arm.com, mark.rutland@arm.com, mchehab+samsung@kernel.org, peterz@infradead.org, robh@kernel.org, robh+dt@kernel.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, devicetree@vger.kernel.org, green.hu@gmail.com, Guo Ren Subject: [PATCH V6 20/33] csky/dma: fix up dma_mapping error Date: Fri, 28 Sep 2018 08:51:17 +0800 Message-Id: <378d4064bf29863785f4cc637999e07507e2e926.1538058840.git.ren_guo@c-sky.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <62098e7d0a7fbdd09f44d7e23333dad258a01bd2.1538058840.git.ren_guo@c-sky.com> References: <62098e7d0a7fbdd09f44d7e23333dad258a01bd2.1538058840.git.ren_guo@c-sky.com> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The arch_sync_dma_for_cpu()/arch_sync_dma_for_device() implementation is broken for some combinations that end up in a BUG() instead of performing the necessary flushes. The implementation of arch should follow the following rules: map for_cpu for_device unmap TO_DEV writeback none writeback none TO_CPU invalidate invalidate* invalidate invalidate* BIDIR writeback invalidate writeback invalidate Link: https://lore.kernel.org/lkml/20180518215548.GH17671@n2100.armlinux.org.uk/ Signed-off-by: Guo Ren --- arch/csky/mm/dma-mapping.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/csky/mm/dma-mapping.c b/arch/csky/mm/dma-mapping.c index 16c2087..30a2041 100644 --- a/arch/csky/mm/dma-mapping.c +++ b/arch/csky/mm/dma-mapping.c @@ -217,7 +217,8 @@ void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr, break; case DMA_FROM_DEVICE: case DMA_BIDIRECTIONAL: - BUG(); + dma_wbinv_range(vaddr + offset, vaddr + offset + size); + break; default: BUG(); } @@ -240,7 +241,7 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, switch (dir) { case DMA_TO_DEVICE: - BUG(); + break; case DMA_FROM_DEVICE: case DMA_BIDIRECTIONAL: dma_wbinv_range(vaddr + offset, vaddr + offset + size); -- 2.7.4