Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1674741imm; Thu, 19 Jul 2018 06:06:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfToUfldYhwwuRLqXscZd6XoMfBdgu+0fRaYzLXGPW9Cio/Hyhy0WhOIjRA0VlvJssvl+4V X-Received: by 2002:a17:902:3281:: with SMTP id z1-v6mr10233461plb.226.1532005577031; Thu, 19 Jul 2018 06:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532005577; cv=none; d=google.com; s=arc-20160816; b=J4lqyqRtz4gGGWKQ8gAcbUs9m3VT4Cl2LGji2Diu6oYH/SWWX2d4q5sbI5ioBmkQNm VbhtK7Mn3NQs/+AcD7EGeu4zyV5yGIIyUPUTROObdh96YvZZ6iL/deGopmIpGBqFQhZe sKtqgVwy3oVFJn0fpHD8KSEjqpHqVLhEARzSQclLprRXuIVuByAjBoB9l0gWAhZ9kgiH mtGxeL/nT9uH8htL9FTmx/cJY00NHkwtQ3OQpTd4bbeXUF349QX+/rzZARcVYtcfJYaq yic2QQQFjSdbSOUsHTwoOwSFAl+efV8rDwbT8G1+F2ra8ZPxZ63u94HRTArE7pwYLlpO WdPw== 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:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=fgDyiypyOdGUz51hRQvMvm3VaztqnkDgLYPlLCHln4M=; b=tUsEPIulSx53bMOvBJZfnBXzsj3l7iPmCco1jRCY9qxOtdX+u4xO0bqyZ0gfUPYB2H UKapLtja43H2XtySdaOlacawBSGyC39Ezmhewm3TVagznzgHK9Q8t5qZ3L/tL/miRmd5 4l4Bj4AV6u71l28HXaTn4XelI25PPIKNFf3V+DSEXrVViSkW67JWlALCEvBDQLFv7C3W 1Cuz+67TWR26L1iVc2jgWljsJeZLjrZ3jh7e3FQ+4zzCldMNagrqCmb9Mxxkq6ly9Y2M vbh/QDt5QxZFAoaJiGoP+X5LRaf9al7bGKzn4wf770HmE3M/SzObT/6wVx2JNdVvbc8Q lNcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PGiXwDJ9; 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 x5-v6si5912060pgx.310.2018.07.19.06.06.01; Thu, 19 Jul 2018 06:06:17 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PGiXwDJ9; 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 S1731595AbeGSNs2 (ORCPT + 99 others); Thu, 19 Jul 2018 09:48:28 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38782 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730195AbeGSNs2 (ORCPT ); Thu, 19 Jul 2018 09:48:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fgDyiypyOdGUz51hRQvMvm3VaztqnkDgLYPlLCHln4M=; b=PGiXwDJ9zVo+qGrbI8bMXIqvq S8XDcse8fvdH2Ww56MduyE11yq0PKOc61Gi+kuU8Sl+O4A6ZBwHk6XImPm29xr9DErS5nDUPD7VRu jj8OD3GMs/EQQliLN6egoexn+pI1IvADtnctEPNnmeYzc/BX0forXg7HJ9JHMfwxKXtkTA8jUVg6H qJrLAXXM1L6v5f2om2n7kGl3qzSA7vhXbaQOdLRQmRgCyTqsczOqm0b5W2uTDc2ZaLD8z0MlfV3jW ZDcNYjQbAEaHYIDMwQ7lqc8vSGQSUC8neIMO43ntU/7ZyUfpY6+gWFsZQ3IQEaZlsupFMa7m5deCl 3nkp8Z7vw==; Received: from [96.72.186.57] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fg8cP-0001gH-Uk; Thu, 19 Jul 2018 13:05:18 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker Cc: Jacopo Mondi , Thomas Petazzoni , linux-sh@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] sh: introduce a sh_cacheop_vaddr helper Date: Thu, 19 Jul 2018 06:05:13 -0700 Message-Id: <20180719130516.1989-3-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180719130516.1989-1-hch@lst.de> References: <20180719130516.1989-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And use it in the maple bus code to avoid a dma API dependency. Signed-off-by: Christoph Hellwig --- arch/sh/include/asm/cacheflush.h | 7 +++++++ arch/sh/mm/consistent.c | 6 +----- drivers/sh/maple/maple.c | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/sh/include/asm/cacheflush.h b/arch/sh/include/asm/cacheflush.h index d103ab5a4e4b..b932e42ef028 100644 --- a/arch/sh/include/asm/cacheflush.h +++ b/arch/sh/include/asm/cacheflush.h @@ -101,5 +101,12 @@ void kunmap_coherent(void *kvaddr); void cpu_cache_init(void); +static inline void *sh_cacheop_vaddr(void *vaddr) +{ + if (__in_29bit_mode()) + vaddr = (void *)CAC_ADDR((unsigned long)vaddr); + return vaddr; +} + #endif /* __KERNEL__ */ #endif /* __ASM_SH_CACHEFLUSH_H */ diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index e9d422bd42a5..1622ae6b9dbd 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c @@ -74,10 +74,7 @@ void dma_generic_free_coherent(struct device *dev, size_t size, void sh_sync_dma_for_device(void *vaddr, size_t size, enum dma_data_direction direction) { - void *addr; - - addr = __in_29bit_mode() ? - (void *)CAC_ADDR((unsigned long)vaddr) : vaddr; + void *addr = sh_cacheop_vaddr(vaddr); switch (direction) { case DMA_FROM_DEVICE: /* invalidate only */ @@ -93,7 +90,6 @@ void sh_sync_dma_for_device(void *vaddr, size_t size, BUG(); } } -EXPORT_SYMBOL(sh_sync_dma_for_device); static int __init memchunk_setup(char *str) { diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index 2e45988d1259..e5d7fb81ad66 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c @@ -300,8 +300,8 @@ static void maple_send(void) mutex_unlock(&maple_wlist_lock); if (maple_packets > 0) { for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) - sh_sync_dma_for_device(maple_sendbuf + i * PAGE_SIZE, - PAGE_SIZE, DMA_BIDIRECTIONAL); + __flush_purge_region(maple_sendbuf + i * PAGE_SIZE, + PAGE_SIZE); } finish: @@ -642,7 +642,8 @@ static void maple_dma_handler(struct work_struct *work) list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { mdev = mq->dev; recvbuf = mq->recvbuf->buf; - sh_sync_dma_for_device(recvbuf, 0x400, DMA_FROM_DEVICE); + __flush_invalidate_region(sh_cacheop_vaddr(recvbuf), + 0x400); code = recvbuf[0]; kfree(mq->sendbuf); list_del_init(&mq->list); -- 2.18.0